mirror of
https://github.com/JulianGro/overte.git
synced 2025-04-15 13:39:05 +02:00
when deciding on the release velocity of something thrown, don't include a zero velocity caused by seeing the same controller data as last frame
This commit is contained in:
parent
2cd38064a5
commit
2d73b23c56
1 changed files with 6 additions and 4 deletions
|
@ -207,8 +207,10 @@ void AvatarActionHold::doKinematicUpdate(float deltaTimeStep) {
|
|||
}
|
||||
|
||||
withWriteLock([&]{
|
||||
if (_previousSet) {
|
||||
if (_previousSet &&
|
||||
_positionalTarget != _previousPositionalTarget) { // don't average in a zero velocity if we get the same data
|
||||
glm::vec3 oneFrameVelocity = (_positionalTarget - _previousPositionalTarget) / deltaTimeStep;
|
||||
|
||||
_measuredLinearVelocities[_measuredLinearVelocitiesIndex++] = oneFrameVelocity;
|
||||
if (_measuredLinearVelocitiesIndex >= AvatarActionHold::velocitySmoothFrames) {
|
||||
_measuredLinearVelocitiesIndex = 0;
|
||||
|
@ -228,9 +230,9 @@ void AvatarActionHold::doKinematicUpdate(float deltaTimeStep) {
|
|||
// 3 -- ignore i of 0 1 2
|
||||
// 4 -- ignore i of 1 2 3
|
||||
// 5 -- ignore i of 2 3 4
|
||||
if ((i + 1) % 6 == _measuredLinearVelocitiesIndex ||
|
||||
(i + 2) % 6 == _measuredLinearVelocitiesIndex ||
|
||||
(i + 3) % 6 == _measuredLinearVelocitiesIndex) {
|
||||
if ((i + 1) % AvatarActionHold::velocitySmoothFrames == _measuredLinearVelocitiesIndex ||
|
||||
(i + 2) % AvatarActionHold::velocitySmoothFrames == _measuredLinearVelocitiesIndex ||
|
||||
(i + 3) % AvatarActionHold::velocitySmoothFrames == _measuredLinearVelocitiesIndex) {
|
||||
continue;
|
||||
}
|
||||
measuredLinearVelocity += _measuredLinearVelocities[i];
|
||||
|
|
Loading…
Reference in a new issue