mirror of
https://github.com/overte-org/overte.git
synced 2025-04-16 10:28:57 +02:00
Bug fixes for laser offset and avatar hold action
This commit is contained in:
parent
98c89cbe78
commit
a1b94fd9d2
6 changed files with 9 additions and 30 deletions
|
@ -165,7 +165,7 @@ bool AvatarActionHold::getTarget(float deltaTimeStep, glm::quat& rotation, glm::
|
|||
|
||||
Transform avatarTransform;
|
||||
avatarTransform = myAvatar->getTransform();
|
||||
palmPosition = avatarTransform.transform(camRelPos / myAvatar->getDomainLimitedScale());
|
||||
palmPosition = avatarTransform.transform(camRelPos);
|
||||
palmRotation = avatarTransform.getRotation() * camRelRot;
|
||||
} else {
|
||||
glm::vec3 avatarRigidBodyPosition;
|
||||
|
|
|
@ -2940,30 +2940,6 @@ glm::mat4 MyAvatar::computeCameraRelativeHandControllerMatrix(const glm::mat4& c
|
|||
return glm::inverse(avatarMatrix) * controllerWorldMatrix;
|
||||
}
|
||||
|
||||
glm::vec3 MyAvatar::getAbsoluteJointScaleInObjectFrame(int index) const {
|
||||
if (index < 0) {
|
||||
index += numeric_limits<unsigned short>::max() + 1; // 65536
|
||||
}
|
||||
|
||||
// only sensor to world matrix has non identity scale.
|
||||
switch (index) {
|
||||
case CAMERA_RELATIVE_CONTROLLER_LEFTHAND_INDEX: {
|
||||
auto pose = getControllerPoseInSensorFrame(controller::Action::LEFT_HAND);
|
||||
glm::mat4 controllerSensorMatrix = createMatFromQuatAndPos(pose.rotation, pose.translation);
|
||||
glm::mat4 result = computeCameraRelativeHandControllerMatrix(controllerSensorMatrix);
|
||||
return extractScale(result);
|
||||
}
|
||||
case CAMERA_RELATIVE_CONTROLLER_RIGHTHAND_INDEX: {
|
||||
auto pose = getControllerPoseInSensorFrame(controller::Action::RIGHT_HAND);
|
||||
glm::mat4 controllerSensorMatrix = createMatFromQuatAndPos(pose.rotation, pose.translation);
|
||||
glm::mat4 result = computeCameraRelativeHandControllerMatrix(controllerSensorMatrix);
|
||||
return extractScale(result);
|
||||
}
|
||||
default:
|
||||
return Avatar::getAbsoluteJointScaleInObjectFrame(index);
|
||||
}
|
||||
}
|
||||
|
||||
glm::quat MyAvatar::getAbsoluteJointRotationInObjectFrame(int index) const {
|
||||
if (index < 0) {
|
||||
index += numeric_limits<unsigned short>::max() + 1; // 65536
|
||||
|
|
|
@ -513,7 +513,6 @@ public:
|
|||
Q_INVOKABLE void setCharacterControllerEnabled(bool enabled); // deprecated
|
||||
Q_INVOKABLE bool getCharacterControllerEnabled(); // deprecated
|
||||
|
||||
virtual glm::vec3 getAbsoluteJointScaleInObjectFrame(int index) const override;
|
||||
virtual glm::quat getAbsoluteJointRotationInObjectFrame(int index) const override;
|
||||
virtual glm::vec3 getAbsoluteJointTranslationInObjectFrame(int index) const override;
|
||||
|
||||
|
|
|
@ -36,7 +36,7 @@ const PickRay JointRayPick::getPickRay(bool& valid) const {
|
|||
glm::quat rot = useAvatarHead ? jointRot * glm::angleAxis(-PI / 2.0f, Vectors::RIGHT) : avatarRot * jointRot;
|
||||
|
||||
// Apply offset
|
||||
pos = pos + (rot * _posOffset);
|
||||
pos = pos + (rot * (myAvatar->getSensorToWorldScale() * _posOffset));
|
||||
glm::vec3 dir = rot * glm::normalize(_dirOffset);
|
||||
|
||||
valid = true;
|
||||
|
|
|
@ -1184,7 +1184,7 @@ function MyController(hand) {
|
|||
joint: (hand == RIGHT_HAND) ? "_CAMERA_RELATIVE_CONTROLLER_RIGHTHAND" : "_CAMERA_RELATIVE_CONTROLLER_LEFTHAND",
|
||||
filter: RayPick.PICK_ENTITIES | RayPick.PICK_OVERLAYS | RayPick.PICK_INCLUDE_NONCOLLIDABLE,
|
||||
maxDistance: PICK_MAX_DISTANCE,
|
||||
posOffset: getGrabPointSphereOffset(this.handToController()),
|
||||
posOffset: getGrabPointSphereOffset(this.handToController(), true),
|
||||
renderStates: renderStates,
|
||||
faceAvatar: true,
|
||||
defaultRenderStates: defaultRenderStates
|
||||
|
|
|
@ -18,7 +18,7 @@ getGrabCommunications = function getFarGrabCommunications() {
|
|||
// this offset needs to match the one in libraries/display-plugins/src/display-plugins/hmd/HmdDisplayPlugin.cpp:378
|
||||
var GRAB_POINT_SPHERE_OFFSET = { x: 0.04, y: 0.13, z: 0.039 }; // x = upward, y = forward, z = lateral
|
||||
|
||||
getGrabPointSphereOffset = function(handController) {
|
||||
getGrabPointSphereOffset = function(handController, ignoreSensorToWorldScale) {
|
||||
var offset = GRAB_POINT_SPHERE_OFFSET;
|
||||
if (handController === Controller.Standard.LeftHand) {
|
||||
offset = {
|
||||
|
@ -27,7 +27,11 @@ getGrabPointSphereOffset = function(handController) {
|
|||
z: GRAB_POINT_SPHERE_OFFSET.z
|
||||
};
|
||||
}
|
||||
return Vec3.multiply(MyAvatar.sensorToWorldScale, offset);
|
||||
if (ignoreSensorToWorldScale) {
|
||||
return offset;
|
||||
} else {
|
||||
return Vec3.multiply(MyAvatar.sensorToWorldScale, offset);
|
||||
}
|
||||
};
|
||||
|
||||
// controllerWorldLocation is where the controller would be, in-world, with an added offset
|
||||
|
|
Loading…
Reference in a new issue