mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 14:08:51 +02:00
fixed lockEndUUID offset for scripts
This commit is contained in:
parent
6173c33b51
commit
b779c33a1b
3 changed files with 31 additions and 11 deletions
|
@ -14,7 +14,7 @@
|
||||||
PICK_MAX_DISTANCE, COLORS_GRAB_SEARCHING_HALF_SQUEEZE, COLORS_GRAB_SEARCHING_FULL_SQUEEZE, COLORS_GRAB_DISTANCE_HOLD,
|
PICK_MAX_DISTANCE, COLORS_GRAB_SEARCHING_HALF_SQUEEZE, COLORS_GRAB_SEARCHING_FULL_SQUEEZE, COLORS_GRAB_DISTANCE_HOLD,
|
||||||
DEFAULT_SEARCH_SPHERE_DISTANCE, TRIGGER_OFF_VALUE, TRIGGER_ON_VALUE, ZERO_VEC, ensureDynamic,
|
DEFAULT_SEARCH_SPHERE_DISTANCE, TRIGGER_OFF_VALUE, TRIGGER_ON_VALUE, ZERO_VEC, ensureDynamic,
|
||||||
getControllerWorldLocation, projectOntoEntityXYPlane, ContextOverlay, HMD, Reticle, Overlays, isPointingAtUI
|
getControllerWorldLocation, projectOntoEntityXYPlane, ContextOverlay, HMD, Reticle, Overlays, isPointingAtUI
|
||||||
Picks, makeLaserLockInfo
|
Picks, makeLaserLockInfo Xform
|
||||||
*/
|
*/
|
||||||
|
|
||||||
Script.include("/~/system/libraries/controllerDispatcherUtils.js");
|
Script.include("/~/system/libraries/controllerDispatcherUtils.js");
|
||||||
|
@ -495,10 +495,10 @@ Script.include("/~/system/libraries/Xform.js");
|
||||||
this.distanceRotate(otherFarGrabModule);
|
this.distanceRotate(otherFarGrabModule);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return this.exitIfDisabled();
|
return this.exitIfDisabled(controllerData);
|
||||||
};
|
};
|
||||||
|
|
||||||
this.exitIfDisabled = function() {
|
this.exitIfDisabled = function(controllerData) {
|
||||||
var moduleName = this.hand === RIGHT_HAND ? "RightDisableModules" : "LeftDisableModules";
|
var moduleName = this.hand === RIGHT_HAND ? "RightDisableModules" : "LeftDisableModules";
|
||||||
var disableModule = getEnabledModuleByName(moduleName);
|
var disableModule = getEnabledModuleByName(moduleName);
|
||||||
if (disableModule) {
|
if (disableModule) {
|
||||||
|
@ -507,13 +507,28 @@ Script.include("/~/system/libraries/Xform.js");
|
||||||
return makeRunningValues(false, [], []);
|
return makeRunningValues(false, [], []);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
var grabbedThing = (this.distanceHolding || this.distanceRotating) ? this.grabbedThingID : null;
|
var grabbedThing = (this.distanceHolding || this.distanceRotating) ? this.targetObject.entityID : null;
|
||||||
var grabbedIsOverlay = (this.distanceHolding || this.distanceRotating) ? this.grabbedIsOverlay : false;
|
var offset = this.calculateOffset(controllerData);
|
||||||
var laserLockInfo = makeLaserLockInfo(grabbedThing, grabbedIsOverlay, this.hand);
|
var laserLockInfo = makeLaserLockInfo(grabbedThing, false, this.hand, offset);
|
||||||
return makeRunningValues(true, [], [], laserLockInfo);
|
return makeRunningValues(true, [], [], laserLockInfo);
|
||||||
};
|
};
|
||||||
|
|
||||||
this.cleanup = function () {
|
this.calculateOffset = function(controllerData) {
|
||||||
|
if (this.distanceHolding || this.distanceRotating) {
|
||||||
|
var targetProps = Entities.getEntityProperties(this.targetObject.entityID, [
|
||||||
|
"position",
|
||||||
|
"rotation"
|
||||||
|
]);
|
||||||
|
var zeroVector = { x: 0, y: 0, z:0, w: 0 };
|
||||||
|
var intersection = controllerData.rayPicks[this.hand].intersection;
|
||||||
|
var intersectionMat = new Xform(zeroVector, intersection);
|
||||||
|
var modelMat = new Xform(targetProps.rotation, targetProps.position);
|
||||||
|
var modelMatInv = modelMat.inv();
|
||||||
|
var xformMat = Xform.mul(modelMatInv, intersectionMat);
|
||||||
|
var offsetMat = Mat4.createFromRotAndTrans(xformMat.rot, xformMat.pos);
|
||||||
|
return offsetMat;
|
||||||
|
}
|
||||||
|
return undefined;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -125,11 +125,12 @@ makeDispatcherModuleParameters = function (priority, activitySlots, requiredData
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
makeLaserLockInfo = function(targetID, isOverlay, hand) {
|
makeLaserLockInfo = function(targetID, isOverlay, hand, offset) {
|
||||||
return {
|
return {
|
||||||
targetID: targetID,
|
targetID: targetID,
|
||||||
isOverlay: isOverlay,
|
isOverlay: isOverlay,
|
||||||
hand: hand
|
hand: hand,
|
||||||
|
offset: offset
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -130,10 +130,14 @@ Pointer = function(hudLayer, pickType, pointerData) {
|
||||||
|
|
||||||
this.lockEnd = function(lockData) {
|
this.lockEnd = function(lockData) {
|
||||||
if (lockData !== undefined) {
|
if (lockData !== undefined) {
|
||||||
if (this.visible) {
|
if (this.visible && !this.locked && lockData.targetID !== null) {
|
||||||
var targetID = lockData.targetID;
|
var targetID = lockData.targetID;
|
||||||
var targetIsOverlay = lockData.isOverlay;
|
var targetIsOverlay = lockData.isOverlay;
|
||||||
Pointers.setLockEndUUID(this.pointerID, targetID, targetIsOverlay);
|
if (lockData.offset === undefined) {
|
||||||
|
Pointers.setLockEndUUID(this.pointerID, targetID, targetIsOverlay);
|
||||||
|
} else {
|
||||||
|
Pointers.setLockEndUUID(this.pointerID, targetID, targetIsOverlay, lockData.offset);
|
||||||
|
}
|
||||||
this.locked = targetID;
|
this.locked = targetID;
|
||||||
}
|
}
|
||||||
} else if (this.locked) {
|
} else if (this.locked) {
|
||||||
|
|
Loading…
Reference in a new issue