mirror of
https://github.com/JulianGro/overte.git
synced 2025-04-25 22:55:06 +02:00
Merge pull request #6324 from sethalves/smooth-hold-action-velocity
smooth hold action velocity over 2 frames
This commit is contained in:
commit
5d80dc0c90
2 changed files with 8 additions and 1 deletions
|
@ -107,8 +107,12 @@ void AvatarActionHold::doKinematicUpdate(float deltaTimeStep) {
|
||||||
withWriteLock([&]{
|
withWriteLock([&]{
|
||||||
if (_kinematicSetVelocity) {
|
if (_kinematicSetVelocity) {
|
||||||
if (_previousSet) {
|
if (_previousSet) {
|
||||||
glm::vec3 positionalVelocity = (_positionalTarget - _previousPositionalTarget) / deltaTimeStep;
|
// smooth velocity over 2 frames
|
||||||
|
glm::vec3 positionalDelta = _positionalTarget - _previousPositionalTarget;
|
||||||
|
glm::vec3 positionalVelocity = (positionalDelta + _previousPositionalDelta) / (deltaTimeStep + _previousDeltaTimeStep);
|
||||||
rigidBody->setLinearVelocity(glmToBullet(positionalVelocity));
|
rigidBody->setLinearVelocity(glmToBullet(positionalVelocity));
|
||||||
|
_previousPositionalDelta = positionalDelta;
|
||||||
|
_previousDeltaTimeStep = deltaTimeStep;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -46,6 +46,9 @@ private:
|
||||||
bool _previousSet { false };
|
bool _previousSet { false };
|
||||||
glm::vec3 _previousPositionalTarget;
|
glm::vec3 _previousPositionalTarget;
|
||||||
glm::quat _previousRotationalTarget;
|
glm::quat _previousRotationalTarget;
|
||||||
|
|
||||||
|
float _previousDeltaTimeStep = 0.0f;
|
||||||
|
glm::vec3 _previousPositionalDelta;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // hifi_AvatarActionHold_h
|
#endif // hifi_AvatarActionHold_h
|
||||||
|
|
Loading…
Reference in a new issue