mirror of
https://github.com/overte-org/overte.git
synced 2025-08-08 08:17:35 +02:00
code review
This commit is contained in:
parent
f3adb8a2f7
commit
b80fa1c806
2 changed files with 27 additions and 5 deletions
|
@ -78,8 +78,16 @@ void AvatarActionHold::prepareForPhysicsSimulation() {
|
||||||
// bullet has moved the av's rigid body but the rigid body's location has not yet been
|
// bullet has moved the av's rigid body but the rigid body's location has not yet been
|
||||||
// copied out into the Avatar class.
|
// copied out into the Avatar class.
|
||||||
glm::quat avatarRotationInverse = glm::inverse(avatarRigidBodyRotation);
|
glm::quat avatarRotationInverse = glm::inverse(avatarRigidBodyRotation);
|
||||||
_palmOffsetFromRigidBody = avatarRotationInverse * (palmPosition - avatarRigidBodyPosition);
|
|
||||||
_palmRotationFromRigidBody = avatarRotationInverse * palmRotation;
|
// the offset should be in the frame of the avatar, but something about the order
|
||||||
|
// things are updated makes this wrong:
|
||||||
|
// _palmOffsetFromRigidBody = avatarRotationInverse * (palmPosition - avatarRigidBodyPosition);
|
||||||
|
// I'll leave it here as a comment in case avatar handling changes.
|
||||||
|
_palmOffsetFromRigidBody = palmPosition - avatarRigidBodyPosition;
|
||||||
|
|
||||||
|
// rotation should also be needed, but again, the order of updates makes this unneeded. leaving
|
||||||
|
// code here for future reference.
|
||||||
|
// _palmRotationFromRigidBody = avatarRotationInverse * palmRotation;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -116,8 +124,21 @@ std::shared_ptr<Avatar> AvatarActionHold::getTarget(glm::quat& rotation, glm::ve
|
||||||
// and the data in the Avatar class is stale. This means that the result of get*PalmPosition will
|
// and the data in the Avatar class is stale. This means that the result of get*PalmPosition will
|
||||||
// be stale. Instead, determine the current palm position with the current avatar's rigid body
|
// be stale. Instead, determine the current palm position with the current avatar's rigid body
|
||||||
// location and the saved offsets.
|
// location and the saved offsets.
|
||||||
palmPosition = avatarRigidBodyPosition + avatarRigidBodyRotation * _palmOffsetFromRigidBody;
|
|
||||||
palmRotation = avatarRigidBodyRotation * _palmRotationFromRigidBody;
|
// this line is more correct but breaks for the current way avatar data is updated.
|
||||||
|
// palmPosition = avatarRigidBodyPosition + avatarRigidBodyRotation * _palmOffsetFromRigidBody;
|
||||||
|
// instead, use this for now:
|
||||||
|
palmPosition = avatarRigidBodyPosition + _palmOffsetFromRigidBody;
|
||||||
|
|
||||||
|
// the item jitters the least by getting the rotation based on the opinion of Avatar.h rather
|
||||||
|
// than that of the rigid body. leaving this next line here for future reference:
|
||||||
|
// palmRotation = avatarRigidBodyRotation * _palmRotationFromRigidBody;
|
||||||
|
|
||||||
|
if (isRightHand) {
|
||||||
|
palmRotation = holdingAvatar->getRightPalmRotation();
|
||||||
|
} else {
|
||||||
|
palmRotation = holdingAvatar->getLeftPalmRotation();
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
if (isRightHand) {
|
if (isRightHand) {
|
||||||
palmPosition = holdingAvatar->getRightPalmPosition();
|
palmPosition = holdingAvatar->getRightPalmPosition();
|
||||||
|
|
|
@ -61,7 +61,8 @@ private:
|
||||||
glm::vec3 _previousPositionalDelta;
|
glm::vec3 _previousPositionalDelta;
|
||||||
|
|
||||||
glm::vec3 _palmOffsetFromRigidBody;
|
glm::vec3 _palmOffsetFromRigidBody;
|
||||||
glm::quat _palmRotationFromRigidBody;
|
// leaving this here for future refernece.
|
||||||
|
// glm::quat _palmRotationFromRigidBody;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // hifi_AvatarActionHold_h
|
#endif // hifi_AvatarActionHold_h
|
||||||
|
|
Loading…
Reference in a new issue