mirror of
https://github.com/overte-org/overte.git
synced 2025-04-08 07:12:40 +02:00
Merge pull request #6302 from AndrewMeadows/fix-avatar-drift
fix slow drift of avatar when wearing HMD
This commit is contained in:
commit
275b248547
2 changed files with 5 additions and 4 deletions
|
@ -1284,11 +1284,11 @@ void MyAvatar::prepareForPhysicsSimulation() {
|
|||
_characterController.setAvatarPositionAndOrientation(getPosition(), getOrientation());
|
||||
if (qApp->isHMDMode()) {
|
||||
updateHMDFollowVelocity();
|
||||
_characterController.setHMDVelocity(_hmdFollowVelocity);
|
||||
} else {
|
||||
_characterController.setHMDVelocity(Vectors::ZERO);
|
||||
} else if (_isFollowingHMD) {
|
||||
_isFollowingHMD = false;
|
||||
_hmdFollowVelocity = Vectors::ZERO;
|
||||
}
|
||||
_characterController.setHMDVelocity(_hmdFollowVelocity);
|
||||
}
|
||||
|
||||
void MyAvatar::harvestResultsFromPhysicsSimulation() {
|
||||
|
@ -1324,6 +1324,7 @@ void MyAvatar::adjustSensorTransform(glm::vec3 hmdShift) {
|
|||
// the "adjustment" is more or less complete so stop following
|
||||
_isFollowingHMD = false;
|
||||
_hmdFollowSpeed = 0.0f;
|
||||
_hmdFollowVelocity = Vectors::ZERO;
|
||||
// and slam the body's transform anyway to eliminate any slight errors
|
||||
glm::vec3 finalBodyPosition = extractTranslation(worldBodyMatrix);
|
||||
nextAttitude(finalBodyPosition, finalBodyRotation);
|
||||
|
|
|
@ -32,7 +32,7 @@ void AtRestDetector::reset(const glm::vec3& startPosition, const glm::quat& star
|
|||
|
||||
bool AtRestDetector::update(const glm::vec3& position, const glm::quat& rotation) {
|
||||
uint64_t now = usecTimestampNow();
|
||||
float dt = (float)(_lastUpdateTime - now) / (float)USECS_PER_SECOND;
|
||||
float dt = (float)(now - _lastUpdateTime) / (float)USECS_PER_SECOND;
|
||||
_lastUpdateTime = now;
|
||||
const float TAU = 1.0f;
|
||||
float delta = glm::min(dt / TAU, 1.0f);
|
||||
|
|
Loading…
Reference in a new issue