mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-08-07 21:20:17 +02:00
try not including the most recent sample in the smoothed velocity
This commit is contained in:
parent
53a366d4e8
commit
9c17890035
1 changed files with 9 additions and 6 deletions
|
@ -207,6 +207,15 @@ void AvatarActionHold::doKinematicUpdate(float deltaTimeStep) {
|
|||
}
|
||||
|
||||
withWriteLock([&]{
|
||||
glm::vec3 measuredLinearVelocity;
|
||||
// there is a bit of lag between when someone releases the trigger and the software reacts to
|
||||
// the release. we calculate the velocity from previous frames but not this frame (by having
|
||||
// this code before where _measuredLinearVelocities is set, below) in order to help mask this.
|
||||
for (int i = 0; i < AvatarActionHold::velocitySmoothFrames; i++) {
|
||||
measuredLinearVelocity += _measuredLinearVelocities[i];
|
||||
}
|
||||
measuredLinearVelocity /= (float)AvatarActionHold::velocitySmoothFrames;
|
||||
|
||||
if (_previousSet) {
|
||||
glm::vec3 oneFrameVelocity = (_positionalTarget - _previousPositionalTarget) / deltaTimeStep;
|
||||
_measuredLinearVelocities[_measuredLinearVelocitiesIndex++] = oneFrameVelocity;
|
||||
|
@ -215,12 +224,6 @@ void AvatarActionHold::doKinematicUpdate(float deltaTimeStep) {
|
|||
}
|
||||
}
|
||||
|
||||
glm::vec3 measuredLinearVelocity;
|
||||
for (int i = 0; i < AvatarActionHold::velocitySmoothFrames; i++) {
|
||||
measuredLinearVelocity += _measuredLinearVelocities[i];
|
||||
}
|
||||
measuredLinearVelocity /= (float)AvatarActionHold::velocitySmoothFrames;
|
||||
|
||||
if (_kinematicSetVelocity) {
|
||||
// rigidBody->setLinearVelocity(glmToBullet(_linearVelocityTarget));
|
||||
rigidBody->setLinearVelocity(glmToBullet(measuredLinearVelocity));
|
||||
|
|
Loading…
Reference in a new issue