don't call release when off state is entered. don't attempt to unhook stylus as a stray child

This commit is contained in:
Seth Alves 2017-01-15 11:29:29 -08:00
parent 3b4f5e3023
commit 4a451e95dc

View file

@ -27,7 +27,7 @@ Script.include("/~/system/libraries/controllers.js");
// add lines where the hand ray picking is happening // add lines where the hand ray picking is happening
// //
var WANT_DEBUG = false; var WANT_DEBUG = false;
var WANT_DEBUG_STATE = true; var WANT_DEBUG_STATE = false;
var WANT_DEBUG_SEARCH_NAME = null; var WANT_DEBUG_SEARCH_NAME = null;
var FORCE_IGNORE_IK = false; var FORCE_IGNORE_IK = false;
@ -211,7 +211,6 @@ var CONTROLLER_STATE_MACHINE = {};
CONTROLLER_STATE_MACHINE[STATE_OFF] = { CONTROLLER_STATE_MACHINE[STATE_OFF] = {
name: "off", name: "off",
enterMethod: "offEnter",
updateMethod: "off" updateMethod: "off"
}; };
CONTROLLER_STATE_MACHINE[STATE_SEARCHING] = { CONTROLLER_STATE_MACHINE[STATE_SEARCHING] = {
@ -953,7 +952,6 @@ function MyController(hand) {
if (!MyAvatar.sessionUUID) { if (!MyAvatar.sessionUUID) {
return; return;
} }
print("SHOW");
var stylusTipProperties = { var stylusTipProperties = {
localPosition: Vec3.sum({ x: 0, y: WEB_TOUCH_DISTANCE - (WEB_TOUCH_SPHERE_RADIUS / 2.0), z: 0 }, localPosition: Vec3.sum({ x: 0, y: WEB_TOUCH_DISTANCE - (WEB_TOUCH_SPHERE_RADIUS / 2.0), z: 0 },
getGrabPointSphereOffset(this.handToController())), getGrabPointSphereOffset(this.handToController())),
@ -995,7 +993,6 @@ function MyController(hand) {
if (!this.stylus) { if (!this.stylus) {
return; return;
} }
print("HIDE");
Overlays.deleteOverlay(this.stylus); Overlays.deleteOverlay(this.stylus);
this.stylus = null; this.stylus = null;
Overlays.deleteOverlay(this.stylusTip); Overlays.deleteOverlay(this.stylusTip);
@ -2645,10 +2642,6 @@ function MyController(hand) {
this.callEntityMethodOnGrabbed("continueFarTrigger"); this.callEntityMethodOnGrabbed("continueFarTrigger");
}; };
this.offEnter = function() {
this.release();
};
this.entityTouchingEnter = function() { this.entityTouchingEnter = function() {
// test for intersection between controller laser and web entity plane. // test for intersection between controller laser and web entity plane.
var intersectInfo = handLaserIntersectEntity(this.grabbedEntity, var intersectInfo = handLaserIntersectEntity(this.grabbedEntity,
@ -2959,17 +2952,20 @@ function MyController(hand) {
"_CONTROLLER_LEFTHAND"); "_CONTROLLER_LEFTHAND");
children = children.concat(Entities.getChildrenIDsOfJoint(MyAvatar.sessionUUID, controllerJointIndex)); children = children.concat(Entities.getChildrenIDsOfJoint(MyAvatar.sessionUUID, controllerJointIndex));
children.forEach(function(childID) { children.forEach(function(childID) {
// we appear to be holding something and this script isn't in a state that would be holding something. if (childID !== _this.stylus) {
// unhook it. if we previously took note of this entity's parent, put it back where it was. This print(childID + " vs " + _this.stylus);
// works around some problems that happen when more than one hand or avatar is passing something around. // we appear to be holding something and this script isn't in a state that would be holding something.
print("disconnecting stray child of hand: (" + _this.hand + ") " + childID); // unhook it. if we previously took note of this entity's parent, put it back where it was. This
if (_this.previousParentID[childID]) { // works around some problems that happen when more than one hand or avatar is passing something around.
Entities.editEntity(childID, { print("disconnecting stray child of hand: (" + _this.hand + ") " + childID);
parentID: _this.previousParentID[childID], if (_this.previousParentID[childID]) {
parentJointIndex: _this.previousParentJointIndex[childID] Entities.editEntity(childID, {
}); parentID: _this.previousParentID[childID],
} else { parentJointIndex: _this.previousParentJointIndex[childID]
Entities.editEntity(childID, { parentID: NULL_UUID }); });
} else {
Entities.editEntity(childID, { parentID: NULL_UUID });
}
} }
}); });
}; };