mirror of
https://github.com/JulianGro/overte.git
synced 2025-04-14 21:06:54 +02:00
add calibration data to filters
This commit is contained in:
parent
a18940142e
commit
90ddc16d09
4 changed files with 23 additions and 8 deletions
|
@ -39,25 +39,23 @@
|
|||
|
||||
{
|
||||
"from": "Vive.LeftFoot", "to" : "Standard.LeftFoot",
|
||||
"filters" : [{"type" : "lowVelocity", "rotation" : 9.0, "translation": 9.0 }],
|
||||
"filters" : [{"type" : "lowVelocity", "rotation" : 1.0, "translation": 1.0}],
|
||||
"when": [ "Application.InHMD"]
|
||||
},
|
||||
|
||||
{
|
||||
"from": "Vive.RightFoot", "to" : "Standard.RightFoot",
|
||||
"filters" : [{"type" : "lowVelocity", "rotation" : 9.0, "translation": 9.0}]
|
||||
"filters" : [{"type" : "lowVelocity", "rotation" : 1.0, "translation": 1.0}]
|
||||
,"when": [ "Application.InHMD"]
|
||||
},
|
||||
|
||||
{
|
||||
"from": "Vive.Hips", "to" : "Standard.Hips",
|
||||
"filters" : [{"type" : "lowVelocity", "rotation" : 10.0, "translation": 10.0}],
|
||||
"when": [ "Application.InHMD"]
|
||||
},
|
||||
|
||||
{
|
||||
"from": "Vive.Spine2", "to" : "Standard.Spine2",
|
||||
"filters" : [{"type" : "lowVelocity", "rotation" : 10.0, "translation": 10.0}],
|
||||
"when": [ "Application.InHMD"]
|
||||
},
|
||||
|
||||
|
|
|
@ -4376,6 +4376,7 @@ void Application::update(float deltaTime) {
|
|||
}
|
||||
}
|
||||
|
||||
userInputMapper->setInputCalibrationData(calibrationData);
|
||||
userInputMapper->update(deltaTime);
|
||||
|
||||
if (keyboardMousePlugin && keyboardMousePlugin->isActive()) {
|
||||
|
|
|
@ -114,6 +114,9 @@ namespace controller {
|
|||
void loadDefaultMapping(uint16 deviceID);
|
||||
void enableMapping(const QString& mappingName, bool enable = true);
|
||||
|
||||
void setInputCalibrationData(const InputCalibrationData& data) { inputCalibrationData = data; }
|
||||
const InputCalibrationData& getInputCalibrationData() { return inputCalibrationData; }
|
||||
|
||||
void unloadMappings(const QStringList& jsonFiles);
|
||||
void unloadMapping(const QString& jsonFile);
|
||||
|
||||
|
@ -187,6 +190,8 @@ namespace controller {
|
|||
|
||||
QSet<QString> _loadedRouteJsonFiles;
|
||||
|
||||
InputCalibrationData inputCalibrationData;
|
||||
|
||||
mutable std::recursive_mutex _lock;
|
||||
};
|
||||
|
||||
|
|
|
@ -11,18 +11,29 @@
|
|||
|
||||
#include <QtCore/QJsonObject>
|
||||
#include <QtCore/QJsonArray>
|
||||
#include "../../UserInputMapper.h"
|
||||
#include "../../Input.h"
|
||||
#include <DependencyManager.h>
|
||||
|
||||
static const QString JSON_ROTATION = QStringLiteral("rotation");
|
||||
static const QString JSON_TRANSLATION = QStringLiteral("translation");
|
||||
namespace controller {
|
||||
|
||||
Pose LowVelocityFilter::apply(Pose newPose) const {
|
||||
auto userInputMapper = DependencyManager::get<UserInputMapper>();
|
||||
const InputCalibrationData calibrationData = userInputMapper->getInputCalibrationData();
|
||||
Pose finalPose = newPose;
|
||||
if (finalPose.isValid() && _oldPose.isValid()) {
|
||||
float rotationFilter = glm::clamp(1.0f - (glm::length(_oldPose.getVelocity() / _rotationConstant)), 0.0f, 1.0f);
|
||||
float translationFilter = glm::clamp(1.0f - (glm::length(_oldPose.getVelocity() / _translationConstant)), 0.0f, 1.0f);
|
||||
finalPose.translation = _oldPose.getTranslation() * translationFilter + newPose.getTranslation() * (1.0f - translationFilter);
|
||||
finalPose.rotation = safeMix(_oldPose.getRotation(), newPose.getRotation(), 1.0f - rotationFilter);
|
||||
Pose sensorPose = finalPose.transform(calibrationData.avatarMat);
|
||||
Pose lastPose = _oldPose.transform(calibrationData.avatarMat);
|
||||
|
||||
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);
|
||||
sensorPose.translation = lastPose.getTranslation() * translationFilter + sensorPose.getTranslation() * (1.0f - translationFilter);
|
||||
sensorPose.rotation = safeMix(lastPose.getRotation(), sensorPose.getRotation(), 1.0f - rotationFilter);
|
||||
|
||||
finalPose = sensorPose.transform(glm::inverse(calibrationData.avatarMat));
|
||||
finalPose.valid = true;
|
||||
}
|
||||
_oldPose = finalPose;
|
||||
return finalPose;
|
||||
|
|
Loading…
Reference in a new issue