Hand low velocity filter as a menu option

This commit is contained in:
Philip Rosedale 2014-07-08 22:22:27 -07:00
parent b2912552f6
commit c50d9ae3e4
6 changed files with 31 additions and 7 deletions

View file

@ -354,6 +354,9 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) :
// Set the sixense filtering
_sixenseManager.setFilter(Menu::getInstance()->isOptionChecked(MenuOption::FilterSixense));
// Set hand controller velocity filtering
_sixenseManager.setLowVelocityFilter(Menu::getInstance()->isOptionChecked(MenuOption::LowVelocityFilter));
checkVersion();
@ -1426,6 +1429,10 @@ void Application::setRenderVoxels(bool voxelRender) {
}
}
void Application::setLowVelocityFilter(bool lowVelocityFilter) {
getSixenseManager()->setLowVelocityFilter(lowVelocityFilter);
}
void Application::doKillLocalVoxels() {
_wantToKillLocalVoxels = true;
}

View file

@ -317,6 +317,7 @@ public slots:
void nudgeVoxelsByVector(const VoxelDetail& sourceVoxel, const glm::vec3& nudgeVec);
void setRenderVoxels(bool renderVoxels);
void setLowVelocityFilter(bool lowVelocityFilter);
void doKillLocalVoxels();
void loadDialog();
void loadScriptURLDialog();

View file

@ -421,6 +421,13 @@ Menu::Menu() :
true,
appInstance->getSixenseManager(),
SLOT(setFilter(bool)));
addCheckableActionToQMenuAndActionHash(handOptionsMenu,
MenuOption::LowVelocityFilter,
0,
true,
appInstance,
SLOT(setLowVelocityFilter(bool)));
addCheckableActionToQMenuAndActionHash(handOptionsMenu, MenuOption::DisplayHands, 0, true);
addCheckableActionToQMenuAndActionHash(handOptionsMenu, MenuOption::DisplayHandTargets, 0, false);
addCheckableActionToQMenuAndActionHash(handOptionsMenu, MenuOption::HandsCollideWithSelf, 0, false);

View file

@ -368,6 +368,7 @@ namespace MenuOption {
const QString Faceplus = "Faceplus";
const QString Faceshift = "Faceshift";
const QString FilterSixense = "Smooth Sixense Movement";
const QString LowVelocityFilter = "Low Velocity Filter";
const QString FirstPerson = "First Person";
const QString FrameTimer = "Show Timer";
const QString FrustumRenderMode = "Render Mode";

View file

@ -32,6 +32,7 @@ SixenseManager::SixenseManager() {
#ifdef HAVE_SIXENSE
_lastMovement = 0;
_amountMoved = glm::vec3(0.0f);
_lowVelocityFilter = false;
_calibrationState = CALIBRATION_STATE_IDLE;
// By default we assume the _neckBase (in orb frame) is as high above the orb
@ -160,17 +161,21 @@ void SixenseManager::update(float deltaTime) {
}
palm->setRawVelocity(rawVelocity); // meters/sec
// Use a velocity sensitive filter to damp small motions and preserve large ones with
// no latency.
float velocityFilter = glm::clamp(1.0f - glm::length(rawVelocity), 0.0f, 1.0f);
palm->setRawPosition(palm->getRawPosition() * velocityFilter + position * (1.0f - velocityFilter));
// adjustment for hydra controllers fit into hands
float sign = (i == 0) ? -1.0f : 1.0f;
rotation *= glm::angleAxis(sign * PI/4.0f, glm::vec3(0.0f, 0.0f, 1.0f));
palm->setRawRotation(safeMix(palm->getRawRotation(), rotation, 1.0f - velocityFilter));
if (_lowVelocityFilter) {
// Use a velocity sensitive filter to damp small motions and preserve large ones with
// no latency.
float velocityFilter = glm::clamp(1.0f - glm::length(rawVelocity), 0.0f, 1.0f);
palm->setRawPosition(palm->getRawPosition() * velocityFilter + position * (1.0f - velocityFilter));
palm->setRawRotation(safeMix(palm->getRawRotation(), rotation, 1.0f - velocityFilter));
} else {
palm->setRawPosition(position);
palm->setRawRotation(rotation);
}
// use the velocity to determine whether there's any movement (if the hand isn't new)
const float MOVEMENT_DISTANCE_THRESHOLD = 0.003f;
_amountMoved += rawVelocity * deltaTime;

View file

@ -47,6 +47,7 @@ public:
public slots:
void setFilter(bool filter);
void setLowVelocityFilter(bool lowVelocityFilter) { _lowVelocityFilter = lowVelocityFilter; };
private:
#ifdef HAVE_SIXENSE
@ -80,6 +81,8 @@ private:
bool _bumperPressed[2];
int _oldX[2];
int _oldY[2];
bool _lowVelocityFilter;
};
#endif // hifi_SixenseManager_h