mirror of
https://github.com/overte-org/overte.git
synced 2025-07-29 15:17:33 +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([&]{
|
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;
|
glm::vec3 oneFrameVelocity = (_positionalTarget - _previousPositionalTarget) / deltaTimeStep;
|
||||||
|
|
||||||
_measuredLinearVelocities[_measuredLinearVelocitiesIndex++] = oneFrameVelocity;
|
_measuredLinearVelocities[_measuredLinearVelocitiesIndex++] = oneFrameVelocity;
|
||||||
if (_measuredLinearVelocitiesIndex >= AvatarActionHold::velocitySmoothFrames) {
|
if (_measuredLinearVelocitiesIndex >= AvatarActionHold::velocitySmoothFrames) {
|
||||||
_measuredLinearVelocitiesIndex = 0;
|
_measuredLinearVelocitiesIndex = 0;
|
||||||
|
@ -228,9 +230,9 @@ void AvatarActionHold::doKinematicUpdate(float deltaTimeStep) {
|
||||||
// 3 -- ignore i of 0 1 2
|
// 3 -- ignore i of 0 1 2
|
||||||
// 4 -- ignore i of 1 2 3
|
// 4 -- ignore i of 1 2 3
|
||||||
// 5 -- ignore i of 2 3 4
|
// 5 -- ignore i of 2 3 4
|
||||||
if ((i + 1) % 6 == _measuredLinearVelocitiesIndex ||
|
if ((i + 1) % AvatarActionHold::velocitySmoothFrames == _measuredLinearVelocitiesIndex ||
|
||||||
(i + 2) % 6 == _measuredLinearVelocitiesIndex ||
|
(i + 2) % AvatarActionHold::velocitySmoothFrames == _measuredLinearVelocitiesIndex ||
|
||||||
(i + 3) % 6 == _measuredLinearVelocitiesIndex) {
|
(i + 3) % AvatarActionHold::velocitySmoothFrames == _measuredLinearVelocitiesIndex) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
measuredLinearVelocity += _measuredLinearVelocities[i];
|
measuredLinearVelocity += _measuredLinearVelocities[i];
|
||||||
|
|
Loading…
Reference in a new issue