fixing setting incorrect parent when grabbing entities
Showing the changes to scripts/system/controllers/controllerModules (1 of 1 file). Show all
Unified · Split
| @@ -33,6 +33,7 @@ Script.include("/~/system/libraries/cloneEntityUtils.js"); · 32 unmodified lines | |||
| 33 | this.lastUnequipCheckTime = 0; | 33 | this.lastUnequipCheckTime = 0; |
| 34 | this.autoUnequipCounter = 0; | 34 | this.autoUnequipCounter = 0; |
| 35 | this.lastUnexpectedChildrenCheckTime = 0; | 35 | this.lastUnexpectedChildrenCheckTime = 0; |
| 36 | this.robbed = false; | ||
| 36 | 37 | ||
| 37 | this.parameters = makeDispatcherModuleParameters( | 38 | this.parameters = makeDispatcherModuleParameters( |
| 38 | 500, | 39 | 500, |
| @@ -75,6 +76,14 @@ Script.include("/~/system/libraries/cloneEntityUtils.js"); · 36 unmodified lines | |||
| 75 | return false; | 76 | return false; |
| 76 | }; | 77 | }; |
| 77 | 78 | ||
| 79 | this.getOtherModule = function() { | ||
| 80 | return this.hand === RIGHT_HAND ? leftNearParentingGrabEntity : rightNearParentingGrabEntity; | ||
| 81 | }; | ||
| 82 | |||
| 83 | this.otherHandIsParent = function(props) { | ||
| 84 | return this.getOtherModule().thisHandIsParent(props); | ||
| 85 | }; | ||
| 86 | |||
| 78 | this.startNearParentingGrabEntity = function (controllerData, targetProps) { | 87 | this.startNearParentingGrabEntity = function (controllerData, targetProps) { |
| 79 | Controller.triggerHapticPulse(HAPTIC_PULSE_STRENGTH, HAPTIC_PULSE_DURATION, this.hand); | 88 | Controller.triggerHapticPulse(HAPTIC_PULSE_STRENGTH, HAPTIC_PULSE_DURATION, this.hand); |
| 80 | 89 | ||
| @@ -100,6 +109,11 @@ Script.include("/~/system/libraries/cloneEntityUtils.js"); · 19 unmodified lines | |||
| 100 | // this should never happen, but if it does, don't set previous parent to be this hand. | 109 | // this should never happen, but if it does, don't set previous parent to be this hand. |
| 101 | this.previousParentID[targetProps.id] = null; | 110 | this.previousParentID[targetProps.id] = null; |
| 102 | this.previousParentJointIndex[targetProps.id] = -1; | 111 | this.previousParentJointIndex[targetProps.id] = -1; |
| 112 | } else if (this.otherHandIsParent(targetProps)) { | ||
| 113 | var otherModule = this.getOtherModule(); | ||
| 114 | this.previousParentID[this.grabbedThingID] = otherModule.previousParentID[this.grabbedThingID]; | ||
| 115 | this.previousParentJointIndex[this.grabbedThingID] = otherModule.previousParentJointIndex[this.grabbedThingID]; | ||
| 116 | otherModule.robbed = true; | ||
| 103 | } else { | 117 | } else { |
| 104 | this.previousParentID[targetProps.id] = targetProps.parentID; | 118 | this.previousParentID[targetProps.id] = targetProps.parentID; |
| 105 | this.previousParentJointIndex[targetProps.id] = targetProps.parentJointIndex; | 119 | this.previousParentJointIndex[targetProps.id] = targetProps.parentJointIndex; |
| @@ -119,7 +133,7 @@ Script.include("/~/system/libraries/cloneEntityUtils.js"); · 13 unmodified lines | |||
| 119 | this.endNearParentingGrabEntity = function (controllerData) { | 133 | this.endNearParentingGrabEntity = function (controllerData) { |
| 120 | this.hapticTargetID = null; | 134 | this.hapticTargetID = null; |
| 121 | var props = controllerData.nearbyEntityPropertiesByID[this.targetEntityID]; | 135 | var props = controllerData.nearbyEntityPropertiesByID[this.targetEntityID]; |
| 122 | if (this.thisHandIsParent(props)) { | 136 | if (this.thisHandIsParent(props) && !this.robbed) { |
| 123 | if (this.previousParentID[this.targetEntityID] === Uuid.NULL || this.previousParentID === undefined) { | 137 | if (this.previousParentID[this.targetEntityID] === Uuid.NULL || this.previousParentID === undefined) { |
| 124 | Entities.editEntity(this.targetEntityID, { | 138 | Entities.editEntity(this.targetEntityID, { |
| 125 | parentID: this.previousParentID[this.targetEntityID], | 139 | parentID: this.previousParentID[this.targetEntityID], |
| @@ -145,6 +159,7 @@ Script.include("/~/system/libraries/cloneEntityUtils.js"); · 19 unmodified lines | |||
| 145 | })); | 159 | })); |
| 146 | this.grabbing = false; | 160 | this.grabbing = false; |
| 147 | this.targetEntityID = null; | 161 | this.targetEntityID = null; |
| 162 | this.robbed = false; | ||
| 148 | }; | 163 | }; |
| 149 | 164 | ||
| 150 | this.checkForChildTooFarAway = function (controllerData) { | 165 | this.checkForChildTooFarAway = function (controllerData) { |
| @@ -253,12 +268,14 @@ Script.include("/~/system/libraries/cloneEntityUtils.js"); · 102 unmodified lines | |||
| 253 | if (controllerData.triggerValues[this.hand] < TRIGGER_OFF_VALUE && | 268 | if (controllerData.triggerValues[this.hand] < TRIGGER_OFF_VALUE && |
| 254 | controllerData.secondaryValues[this.hand] < TRIGGER_OFF_VALUE) { | 269 | controllerData.secondaryValues[this.hand] < TRIGGER_OFF_VALUE) { |
| 255 | this.checkForUnexpectedChildren(controllerData); | 270 | this.checkForUnexpectedChildren(controllerData); |
| 271 | this.robbed = false; | ||
| 256 | return makeRunningValues(false, [], []); | 272 | return makeRunningValues(false, [], []); |
| 257 | } | 273 | } |
| 258 | 274 | ||
| 259 | if (targetProps) { | 275 | if (targetProps) { |
| 260 | if ((propsArePhysical(targetProps) || propsAreCloneDynamic(targetProps)) && | 276 | if ((propsArePhysical(targetProps) || propsAreCloneDynamic(targetProps)) && |
| 261 | targetProps.parentID === Uuid.NULL) { | 277 | targetProps.parentID === Uuid.NULL) { |
| 278 | this.robbed = false; | ||
| 262 | return makeRunningValues(false, [], []); // let nearActionGrabEntity handle it | 279 | return makeRunningValues(false, [], []); // let nearActionGrabEntity handle it |
| 263 | } else { | 280 | } else { |
| 264 | this.targetEntityID = targetProps.id; | 281 | this.targetEntityID = targetProps.id; |
| @@ -266,6 +283,7 @@ Script.include("/~/system/libraries/cloneEntityUtils.js"); · 1 unmodified line | |||
| 266 | } | 283 | } |
| 267 | } else { | 284 | } else { |
| 268 | this.hapticTargetID = null; | 285 | this.hapticTargetID = null; |
| 286 | this.robbed = false; | ||
| 269 | return makeRunningValues(false, [], []); | 287 | return makeRunningValues(false, [], []); |
| 270 | } | 288 | } |
| 271 | }; | 289 | }; |
| @@ -284,6 +302,7 @@ Script.include("/~/system/libraries/cloneEntityUtils.js"); · 12 unmodified lines | |||
| 284 | this.grabbing = false; | 302 | this.grabbing = false; |
| 285 | this.targetEntityID = null; | 303 | this.targetEntityID = null; |
| 286 | this.hapticTargetID = null; | 304 | this.hapticTargetID = null; |
| 305 | this.robbed = false; | ||
| 287 | return makeRunningValues(false, [], []); | 306 | return makeRunningValues(false, [], []); |
| 288 | } | 307 | } |
| 289 | 308 | ||
| @@ -300,6 +319,7 @@ Script.include("/~/system/libraries/cloneEntityUtils.js"); · 10 unmodified lines | |||
| 300 | // still searching / highlighting | 319 | // still searching / highlighting |
| 301 | var readiness = this.isReady(controllerData); | 320 | var readiness = this.isReady(controllerData); |
| 302 | if (!readiness.active) { | 321 | if (!readiness.active) { |
| 322 | this.robbed = false; | ||
| 303 | return readiness; | 323 | return readiness; |
| 304 | } | 324 | } |
| 305 | if (controllerData.triggerClicks[this.hand] || controllerData.secondaryValues[this.hand] > BUMPER_ON_VALUE) { | 325 | if (controllerData.triggerClicks[this.hand] || controllerData.secondaryValues[this.hand] > BUMPER_ON_VALUE) { |