mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-07-23 10:54:26 +02:00
Merge pull request #13887 from sethalves/fix-pick-reg-point-1
fix far-grab laser-lock on entities with non-default registration point
This commit is contained in:
commit
4ab45e70a4
5 changed files with 45 additions and 44 deletions
|
@ -105,7 +105,7 @@ PickResultPointer PathPointer::getVisualPickResult(const PickResultPointer& pick
|
||||||
glm::mat4 entityMat = createMatFromQuatAndPos(props.getRotation(), props.getPosition());
|
glm::mat4 entityMat = createMatFromQuatAndPos(props.getRotation(), props.getPosition());
|
||||||
glm::mat4 finalPosAndRotMat = entityMat * _lockEndObject.offsetMat;
|
glm::mat4 finalPosAndRotMat = entityMat * _lockEndObject.offsetMat;
|
||||||
pos = extractTranslation(finalPosAndRotMat);
|
pos = extractTranslation(finalPosAndRotMat);
|
||||||
rot = glmExtractRotation(finalPosAndRotMat);
|
rot = props.getRotation();
|
||||||
dim = props.getDimensions();
|
dim = props.getDimensions();
|
||||||
registrationPoint = props.getRegistrationPoint();
|
registrationPoint = props.getRegistrationPoint();
|
||||||
}
|
}
|
||||||
|
@ -350,4 +350,4 @@ glm::vec2 PathPointer::findPos2D(const PickedObject& pickedObject, const glm::ve
|
||||||
default:
|
default:
|
||||||
return glm::vec2(NAN);
|
return glm::vec2(NAN);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,7 +14,8 @@
|
||||||
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 Xform, makeLaserParams, AddressManager, getEntityParents, Selection, DISPATCHER_HOVERING_LIST
|
Picks, makeLaserLockInfo Xform, makeLaserParams, AddressManager, getEntityParents, Selection, DISPATCHER_HOVERING_LIST,
|
||||||
|
worldPositionToRegistrationFrameMatrix
|
||||||
*/
|
*/
|
||||||
|
|
||||||
Script.include("/~/system/libraries/controllerDispatcherUtils.js");
|
Script.include("/~/system/libraries/controllerDispatcherUtils.js");
|
||||||
|
@ -593,18 +594,9 @@ Script.include("/~/system/libraries/Xform.js");
|
||||||
|
|
||||||
this.calculateOffset = function(controllerData) {
|
this.calculateOffset = function(controllerData) {
|
||||||
if (this.distanceHolding || this.distanceRotating) {
|
if (this.distanceHolding || this.distanceRotating) {
|
||||||
var targetProps = Entities.getEntityProperties(this.targetObject.entityID, [
|
var targetProps = Entities.getEntityProperties(this.targetObject.entityID,
|
||||||
"position",
|
[ "position", "rotation", "registrationPoint", "dimensions" ]);
|
||||||
"rotation"
|
return worldPositionToRegistrationFrameMatrix(targetProps, controllerData.rayPicks[this.hand].intersection);
|
||||||
]);
|
|
||||||
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;
|
return undefined;
|
||||||
};
|
};
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
makeDispatcherModuleParameters, MSECS_PER_SEC, HAPTIC_PULSE_STRENGTH, HAPTIC_PULSE_DURATION, TRIGGER_OFF_VALUE,
|
makeDispatcherModuleParameters, MSECS_PER_SEC, HAPTIC_PULSE_STRENGTH, HAPTIC_PULSE_DURATION, TRIGGER_OFF_VALUE,
|
||||||
TRIGGER_ON_VALUE, ZERO_VEC, getControllerWorldLocation, projectOntoEntityXYPlane, ContextOverlay, HMD,
|
TRIGGER_ON_VALUE, ZERO_VEC, getControllerWorldLocation, projectOntoEntityXYPlane, ContextOverlay, HMD,
|
||||||
Picks, makeLaserLockInfo, Xform, makeLaserParams, AddressManager, getEntityParents, Selection, DISPATCHER_HOVERING_LIST,
|
Picks, makeLaserLockInfo, Xform, makeLaserParams, AddressManager, getEntityParents, Selection, DISPATCHER_HOVERING_LIST,
|
||||||
Uuid
|
Uuid, worldPositionToRegistrationFrameMatrix
|
||||||
*/
|
*/
|
||||||
|
|
||||||
Script.include("/~/system/libraries/controllerDispatcherUtils.js");
|
Script.include("/~/system/libraries/controllerDispatcherUtils.js");
|
||||||
|
@ -572,18 +572,9 @@ Script.include("/~/system/libraries/Xform.js");
|
||||||
|
|
||||||
this.calculateOffset = function(controllerData) {
|
this.calculateOffset = function(controllerData) {
|
||||||
if (this.distanceHolding || this.distanceRotating) {
|
if (this.distanceHolding || this.distanceRotating) {
|
||||||
var targetProps = Entities.getEntityProperties(this.targetObject.entityID, [
|
var targetProps = Entities.getEntityProperties(this.targetObject.entityID,
|
||||||
"position",
|
[ "position", "rotation", "registrationPoint", "dimensions" ]);
|
||||||
"rotation"
|
return worldPositionToRegistrationFrameMatrix(targetProps, controllerData.rayPicks[this.hand].intersection);
|
||||||
]);
|
|
||||||
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;
|
return undefined;
|
||||||
};
|
};
|
||||||
|
|
|
@ -11,7 +11,8 @@
|
||||||
Entities, enableDispatcherModule, disableDispatcherModule, entityIsGrabbable, makeDispatcherModuleParameters, MSECS_PER_SEC,
|
Entities, enableDispatcherModule, disableDispatcherModule, entityIsGrabbable, makeDispatcherModuleParameters, MSECS_PER_SEC,
|
||||||
HAPTIC_PULSE_STRENGTH, HAPTIC_PULSE_DURATION, TRIGGER_OFF_VALUE, TRIGGER_ON_VALUE, ZERO_VEC, getControllerWorldLocation,
|
HAPTIC_PULSE_STRENGTH, HAPTIC_PULSE_DURATION, TRIGGER_OFF_VALUE, TRIGGER_ON_VALUE, ZERO_VEC, getControllerWorldLocation,
|
||||||
projectOntoEntityXYPlane, ContextOverlay, HMD, Picks, makeLaserLockInfo, Xform, makeLaserParams, AddressManager,
|
projectOntoEntityXYPlane, ContextOverlay, HMD, Picks, makeLaserLockInfo, Xform, makeLaserParams, AddressManager,
|
||||||
getEntityParents, Selection, DISPATCHER_HOVERING_LIST, unhighlightTargetEntity, Messages, Uuid, findGroupParent
|
getEntityParents, Selection, DISPATCHER_HOVERING_LIST, unhighlightTargetEntity, Messages, Uuid, findGroupParent,
|
||||||
|
worldPositionToRegistrationFrameMatrix
|
||||||
*/
|
*/
|
||||||
|
|
||||||
Script.include("/~/system/libraries/controllerDispatcherUtils.js");
|
Script.include("/~/system/libraries/controllerDispatcherUtils.js");
|
||||||
|
@ -615,18 +616,9 @@ Script.include("/~/system/libraries/Xform.js");
|
||||||
|
|
||||||
this.calculateOffset = function(controllerData) {
|
this.calculateOffset = function(controllerData) {
|
||||||
if (this.distanceHolding || this.distanceRotating) {
|
if (this.distanceHolding || this.distanceRotating) {
|
||||||
var targetProps = Entities.getEntityProperties(this.targetObject.entityID, [
|
var targetProps = Entities.getEntityProperties(this.targetObject.entityID,
|
||||||
"position",
|
[ "position", "rotation", "registrationPoint", "dimensions" ]);
|
||||||
"rotation"
|
return worldPositionToRegistrationFrameMatrix(targetProps, controllerData.rayPicks[this.hand].intersection);
|
||||||
]);
|
|
||||||
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;
|
return undefined;
|
||||||
};
|
};
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
// Distributed under the Apache License, Version 2.0.
|
// Distributed under the Apache License, Version 2.0.
|
||||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||||
|
|
||||||
/* global module, Camera, HMD, MyAvatar, controllerDispatcherPlugins:true, Quat, Vec3, Overlays, Xform,
|
/* global module, Camera, HMD, MyAvatar, controllerDispatcherPlugins:true, Quat, Vec3, Overlays, Xform, Mat4,
|
||||||
Selection, Uuid,
|
Selection, Uuid,
|
||||||
MSECS_PER_SEC:true , LEFT_HAND:true, RIGHT_HAND:true, FORBIDDEN_GRAB_TYPES:true,
|
MSECS_PER_SEC:true , LEFT_HAND:true, RIGHT_HAND:true, FORBIDDEN_GRAB_TYPES:true,
|
||||||
HAPTIC_PULSE_STRENGTH:true, HAPTIC_PULSE_DURATION:true, ZERO_VEC:true, ONE_VEC:true,
|
HAPTIC_PULSE_STRENGTH:true, HAPTIC_PULSE_DURATION:true, ZERO_VEC:true, ONE_VEC:true,
|
||||||
|
@ -58,7 +58,8 @@
|
||||||
highlightTargetEntity:true,
|
highlightTargetEntity:true,
|
||||||
clearHighlightedEntities:true,
|
clearHighlightedEntities:true,
|
||||||
unhighlightTargetEntity:true,
|
unhighlightTargetEntity:true,
|
||||||
distanceBetweenEntityLocalPositionAndBoundingBox: true
|
distanceBetweenEntityLocalPositionAndBoundingBox: true,
|
||||||
|
worldPositionToRegistrationFrameMatrix: true
|
||||||
*/
|
*/
|
||||||
|
|
||||||
MSECS_PER_SEC = 1000.0;
|
MSECS_PER_SEC = 1000.0;
|
||||||
|
@ -487,6 +488,30 @@ entityIsFarGrabbedByOther = function(entityID) {
|
||||||
return false;
|
return false;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
worldPositionToRegistrationFrameMatrix = function(wptrProps, pos) {
|
||||||
|
// get world matrix for intersection point
|
||||||
|
var intersectionMat = new Xform({ x: 0, y: 0, z:0, w: 1 }, pos);
|
||||||
|
|
||||||
|
// calculate world matrix for registrationPoint addjusted entity
|
||||||
|
var DEFAULT_REGISTRATION_POINT = { x: 0.5, y: 0.5, z: 0.5 };
|
||||||
|
var regRatio = Vec3.subtract(DEFAULT_REGISTRATION_POINT, wptrProps.registrationPoint);
|
||||||
|
var regOffset = Vec3.multiplyVbyV(regRatio, wptrProps.dimensions);
|
||||||
|
var regOffsetRot = Vec3.multiplyQbyV(wptrProps.rotation, regOffset);
|
||||||
|
var modelMat = new Xform(wptrProps.rotation, Vec3.sum(wptrProps.position, regOffsetRot));
|
||||||
|
|
||||||
|
// get inverse of model matrix
|
||||||
|
var modelMatInv = modelMat.inv();
|
||||||
|
|
||||||
|
// transform world intersection point into object's registrationPoint frame
|
||||||
|
var xformMat = Xform.mul(modelMatInv, intersectionMat);
|
||||||
|
|
||||||
|
// convert to Mat4
|
||||||
|
var offsetMat = Mat4.createFromRotAndTrans(xformMat.rot, xformMat.pos);
|
||||||
|
return offsetMat;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
if (typeof module !== 'undefined') {
|
if (typeof module !== 'undefined') {
|
||||||
module.exports = {
|
module.exports = {
|
||||||
makeDispatcherModuleParameters: makeDispatcherModuleParameters,
|
makeDispatcherModuleParameters: makeDispatcherModuleParameters,
|
||||||
|
@ -508,6 +533,7 @@ if (typeof module !== 'undefined') {
|
||||||
projectOntoEntityXYPlane: projectOntoEntityXYPlane,
|
projectOntoEntityXYPlane: projectOntoEntityXYPlane,
|
||||||
TRIGGER_OFF_VALUE: TRIGGER_OFF_VALUE,
|
TRIGGER_OFF_VALUE: TRIGGER_OFF_VALUE,
|
||||||
TRIGGER_ON_VALUE: TRIGGER_ON_VALUE,
|
TRIGGER_ON_VALUE: TRIGGER_ON_VALUE,
|
||||||
DISPATCHER_HOVERING_LIST: DISPATCHER_HOVERING_LIST
|
DISPATCHER_HOVERING_LIST: DISPATCHER_HOVERING_LIST,
|
||||||
|
worldPositionToRegistrationFrameMatrix: worldPositionToRegistrationFrameMatrix
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue