mirror of
https://github.com/overte-org/overte.git
synced 2025-08-10 02:52:57 +02:00
cleanup and minor optimizations
This commit is contained in:
parent
d948168727
commit
160bef8f23
1 changed files with 27 additions and 29 deletions
|
@ -288,13 +288,12 @@ void AvatarActionHold::doKinematicUpdate(float deltaTimeStep) {
|
||||||
glm::vec3 oneFrameVelocity = (_positionalTarget - _previousPositionalTarget) / deltaTimeStep;
|
glm::vec3 oneFrameVelocity = (_positionalTarget - _previousPositionalTarget) / deltaTimeStep;
|
||||||
|
|
||||||
_measuredLinearVelocities[_measuredLinearVelocitiesIndex++] = oneFrameVelocity;
|
_measuredLinearVelocities[_measuredLinearVelocitiesIndex++] = oneFrameVelocity;
|
||||||
if (_measuredLinearVelocitiesIndex >= AvatarActionHold::velocitySmoothFrames) {
|
_measuredLinearVelocitiesIndex %= AvatarActionHold::velocitySmoothFrames;
|
||||||
_measuredLinearVelocitiesIndex = 0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
glm::vec3 measuredLinearVelocity;
|
if (_kinematicSetVelocity) {
|
||||||
for (int i = 0; i < AvatarActionHold::velocitySmoothFrames; i++) {
|
glm::vec3 measuredLinearVelocity = _measuredLinearVelocities[0];
|
||||||
|
for (int i = 1; i < AvatarActionHold::velocitySmoothFrames; i++) {
|
||||||
// there is a bit of lag between when someone releases the trigger and when the software reacts to
|
// there is a bit of lag between when someone releases the trigger and when the software reacts to
|
||||||
// the release. we calculate the velocity from previous frames but we don't include several
|
// the release. we calculate the velocity from previous frames but we don't include several
|
||||||
// of the most recent.
|
// of the most recent.
|
||||||
|
@ -320,7 +319,6 @@ void AvatarActionHold::doKinematicUpdate(float deltaTimeStep) {
|
||||||
// - 3 // 3 because of the 3 we skipped, above
|
// - 3 // 3 because of the 3 we skipped, above
|
||||||
);
|
);
|
||||||
|
|
||||||
if (_kinematicSetVelocity) {
|
|
||||||
rigidBody->setLinearVelocity(glmToBullet(measuredLinearVelocity));
|
rigidBody->setLinearVelocity(glmToBullet(measuredLinearVelocity));
|
||||||
rigidBody->setAngularVelocity(glmToBullet(_angularVelocityTarget));
|
rigidBody->setAngularVelocity(glmToBullet(_angularVelocityTarget));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue