mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 10:47:11 +02:00
fix low velocity filter
This commit is contained in:
parent
90ddc16d09
commit
78f6d2e850
2 changed files with 12 additions and 9 deletions
|
@ -45,17 +45,19 @@
|
||||||
|
|
||||||
{
|
{
|
||||||
"from": "Vive.RightFoot", "to" : "Standard.RightFoot",
|
"from": "Vive.RightFoot", "to" : "Standard.RightFoot",
|
||||||
"filters" : [{"type" : "lowVelocity", "rotation" : 1.0, "translation": 1.0}]
|
"filters" : [{"type" : "lowVelocity", "rotation" : 1.0, "translation": 1.0}],
|
||||||
,"when": [ "Application.InHMD"]
|
"when": [ "Application.InHMD"]
|
||||||
},
|
},
|
||||||
|
|
||||||
{
|
{
|
||||||
"from": "Vive.Hips", "to" : "Standard.Hips",
|
"from": "Vive.Hips", "to" : "Standard.Hips",
|
||||||
|
"filters" : [{"type" : "lowVelocity", "rotation" : 0.01, "translation": 0.01}],
|
||||||
"when": [ "Application.InHMD"]
|
"when": [ "Application.InHMD"]
|
||||||
},
|
},
|
||||||
|
|
||||||
{
|
{
|
||||||
"from": "Vive.Spine2", "to" : "Standard.Spine2",
|
"from": "Vive.Spine2", "to" : "Standard.Spine2",
|
||||||
|
"filters" : [{"type" : "lowVelocity", "rotation" : 0.01, "translation": 0.01}],
|
||||||
"when": [ "Application.InHMD"]
|
"when": [ "Application.InHMD"]
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
@ -22,20 +22,21 @@ namespace controller {
|
||||||
Pose LowVelocityFilter::apply(Pose newPose) const {
|
Pose LowVelocityFilter::apply(Pose newPose) const {
|
||||||
auto userInputMapper = DependencyManager::get<UserInputMapper>();
|
auto userInputMapper = DependencyManager::get<UserInputMapper>();
|
||||||
const InputCalibrationData calibrationData = userInputMapper->getInputCalibrationData();
|
const InputCalibrationData calibrationData = userInputMapper->getInputCalibrationData();
|
||||||
|
glm::mat4 sensorToAvatarMat = glm::inverse(calibrationData.avatarMat) * calibrationData.sensorToWorldMat;
|
||||||
|
glm::mat4 avatarToSensorMat = glm::inverse(calibrationData.sensorToWorldMat) * calibrationData.avatarMat;
|
||||||
Pose finalPose = newPose;
|
Pose finalPose = newPose;
|
||||||
if (finalPose.isValid() && _oldPose.isValid()) {
|
if (finalPose.isValid() && _oldPose.isValid()) {
|
||||||
Pose sensorPose = finalPose.transform(calibrationData.avatarMat);
|
Pose sensorPose = finalPose.transform(avatarToSensorMat);
|
||||||
Pose lastPose = _oldPose.transform(calibrationData.avatarMat);
|
Pose lastPose = _oldPose;
|
||||||
|
|
||||||
float rotationFilter = glm::clamp(1.0f - (glm::length(lastPose.getVelocity() / _rotationConstant)), 0.0f, 1.0f);
|
float rotationFilter = glm::clamp(1.0f - (glm::length(lastPose.getVelocity() / _rotationConstant)), 0.0f, 1.0f);
|
||||||
float translationFilter = glm::clamp(1.0f - (glm::length(lastPose.getVelocity() / _translationConstant)), 0.0f, 1.0f);
|
float translationFilter = glm::clamp(1.0f - (glm::length(lastPose.getVelocity() / _translationConstant)), 0.0f, 1.0f);
|
||||||
sensorPose.translation = lastPose.getTranslation() * translationFilter + sensorPose.getTranslation() * (1.0f - translationFilter);
|
sensorPose.translation = lastPose.getTranslation() * translationFilter + sensorPose.getTranslation() * (1.0f - translationFilter);
|
||||||
sensorPose.rotation = safeMix(lastPose.getRotation(), sensorPose.getRotation(), 1.0f - rotationFilter);
|
sensorPose.rotation = safeMix(lastPose.getRotation(), sensorPose.getRotation(), 1.0f - rotationFilter);
|
||||||
|
|
||||||
finalPose = sensorPose.transform(glm::inverse(calibrationData.avatarMat));
|
finalPose = sensorPose.transform(sensorToAvatarMat);
|
||||||
finalPose.valid = true;
|
|
||||||
}
|
}
|
||||||
_oldPose = finalPose;
|
_oldPose = finalPose.transform(avatarToSensorMat);
|
||||||
return finalPose;
|
return finalPose;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -51,5 +52,5 @@ namespace controller {
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue