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 | 33 | this.lastUnequipCheckTime = 0; |
| 34 | 34 | this.autoUnequipCounter = 0; |
| 35 | 35 | this.lastUnexpectedChildrenCheckTime = 0; |
| 36 | + this.robbed = false; | |
| 36 | 37 | |
| 37 | 38 | this.parameters = makeDispatcherModuleParameters( |
| 38 | 39 | 500, |
| @@ -75,6 +76,14 @@ Script.include("/~/system/libraries/cloneEntityUtils.js"); · 36 unmodified lines | ||
| 75 | 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 | 87 | this.startNearParentingGrabEntity = function (controllerData, targetProps) { |
| 79 | 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 | 109 | // this should never happen, but if it does, don't set previous parent to be this hand. |
| 101 | 110 | this.previousParentID[targetProps.id] = null; |
| 102 | 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 | 117 | } else { |
| 104 | 118 | this.previousParentID[targetProps.id] = targetProps.parentID; |
| 105 | 119 | this.previousParentJointIndex[targetProps.id] = targetProps.parentJointIndex; |
| @@ -119,7 +133,7 @@ Script.include("/~/system/libraries/cloneEntityUtils.js"); · 13 unmodified lines | ||
| 119 | 133 | this.endNearParentingGrabEntity = function (controllerData) { |
| 120 | 134 | this.hapticTargetID = null; |
| 121 | 135 | var props = controllerData.nearbyEntityPropertiesByID[this.targetEntityID]; |
| 122 | − if (this.thisHandIsParent(props)) { | |
| 136 | + if (this.thisHandIsParent(props) && !this.robbed) { | |
| 123 | 137 | if (this.previousParentID[this.targetEntityID] === Uuid.NULL || this.previousParentID === undefined) { |
| 124 | 138 | Entities.editEntity(this.targetEntityID, { |
| 125 | 139 | parentID: this.previousParentID[this.targetEntityID], |
| @@ -145,6 +159,7 @@ Script.include("/~/system/libraries/cloneEntityUtils.js"); · 19 unmodified lines | ||
| 145 | 159 | })); |
| 146 | 160 | this.grabbing = false; |
| 147 | 161 | this.targetEntityID = null; |
| 162 | + this.robbed = false; | |
| 148 | 163 | }; |
| 149 | 164 | |
| 150 | 165 | this.checkForChildTooFarAway = function (controllerData) { |
| @@ -253,12 +268,14 @@ Script.include("/~/system/libraries/cloneEntityUtils.js"); · 102 unmodified lines | ||
| 253 | 268 | if (controllerData.triggerValues[this.hand] < TRIGGER_OFF_VALUE && |
| 254 | 269 | controllerData.secondaryValues[this.hand] < TRIGGER_OFF_VALUE) { |
| 255 | 270 | this.checkForUnexpectedChildren(controllerData); |
| 271 | + this.robbed = false; | |
| 256 | 272 | return makeRunningValues(false, [], []); |
| 257 | 273 | } |
| 258 | 274 | |
| 259 | 275 | if (targetProps) { |
| 260 | 276 | if ((propsArePhysical(targetProps) || propsAreCloneDynamic(targetProps)) && |
| 261 | 277 | targetProps.parentID === Uuid.NULL) { |
| 278 | + this.robbed = false; | |
| 262 | 279 | return makeRunningValues(false, [], []); // let nearActionGrabEntity handle it |
| 263 | 280 | } else { |
| 264 | 281 | this.targetEntityID = targetProps.id; |
| @@ -266,6 +283,7 @@ Script.include("/~/system/libraries/cloneEntityUtils.js"); · 1 unmodified line | ||
| 266 | 283 | } |
| 267 | 284 | } else { |
| 268 | 285 | this.hapticTargetID = null; |
| 286 | + this.robbed = false; | |
| 269 | 287 | return makeRunningValues(false, [], []); |
| 270 | 288 | } |
| 271 | 289 | }; |
| @@ -284,6 +302,7 @@ Script.include("/~/system/libraries/cloneEntityUtils.js"); · 12 unmodified lines | ||
| 284 | 302 | this.grabbing = false; |
| 285 | 303 | this.targetEntityID = null; |
| 286 | 304 | this.hapticTargetID = null; |
| 305 | + this.robbed = false; | |
| 287 | 306 | return makeRunningValues(false, [], []); |
| 288 | 307 | } |
| 289 | 308 | |
| @@ -300,6 +319,7 @@ Script.include("/~/system/libraries/cloneEntityUtils.js"); · 10 unmodified lines | ||
| 300 | 319 | // still searching / highlighting |
| 301 | 320 | var readiness = this.isReady(controllerData); |
| 302 | 321 | if (!readiness.active) { |
| 322 | + this.robbed = false; | |
| 303 | 323 | return readiness; |
| 304 | 324 | } |
| 305 | 325 | if (controllerData.triggerClicks[this.hand] || controllerData.secondaryValues[this.hand] > BUMPER_ON_VALUE) { |