Cleaning up for release

This commit is contained in:
samcake 2015-10-23 18:09:54 -07:00
parent be843a0035
commit d400c694f6
3 changed files with 18 additions and 12 deletions
examples/controllers
libraries/input-plugins/src/input-plugins

View file

@ -51,8 +51,7 @@ function setup() {
}
}
function updateHand(handNum) {
function updateHand(handNum, deltaTime) {
var pose;
var handName = "right";
if (handNum == LEFT_HAND) {
@ -69,7 +68,7 @@ function updateHand(handNum) {
position: pose.translation,
visible: true,
});
var vpos = Vec3.sum(pose.velocity, pose.translation);
var vpos = Vec3.sum(Vec3.multiply(10 * deltaTime, pose.velocity), pose.translation);
Overlays.editOverlay(app.spheres[index(handNum, 1)], {
position: vpos,
visible: true,
@ -85,9 +84,9 @@ function updateHand(handNum) {
}
}
function update() {
updateHand(LEFT_HAND);
updateHand(RIGHT_HAND);
function update(deltaTime) {
updateHand(LEFT_HAND, deltaTime);
updateHand(RIGHT_HAND, deltaTime);
}
function scriptEnding() {

View file

@ -240,7 +240,8 @@ void SixenseManager::update(float deltaTime, bool jointsCaptured) {
} else {
auto hand = left ? controller::StandardPoseChannel::LEFT_HAND : controller::StandardPoseChannel::RIGHT_HAND;
_poseStateMap[hand] = controller::Pose();
_collectedSamples[hand].clear();
_collectedSamples[hand].first.clear();
_collectedSamples[hand].second.clear();
}
}
@ -467,10 +468,15 @@ void SixenseManager::handlePoseEvent(float deltaTime, glm::vec3 position, glm::q
// Average
auto& samples = _collectedSamples[hand];
samples.addSample(velocity);
velocity = samples.average;
samples.first.addSample(velocity);
velocity = samples.first.average;
// FIXME: // Not using quaternion average yet for angular velocity because it s probably wrong but keep the MovingAverage in place
//samples.second.addSample(glm::vec4(angularVelocity.x, angularVelocity.y, angularVelocity.z, angularVelocity.w));
//angularVelocity = glm::quat(samples.second.average.w, samples.second.average.x, samples.second.average.y, samples.second.average.z);
} else if (!prevPose.isValid()) {
_collectedSamples[hand].clear();
_collectedSamples[hand].first.clear();
_collectedSamples[hand].second.clear();
}
_poseStateMap[hand] = controller::Pose(position, rotation, velocity, angularVelocity);

View file

@ -121,8 +121,9 @@ private:
}
};
static const int MAX_NUM_AVERAGING_SAMPLES = 1000; // At ~100 updates per seconds this means averaging over ~.1s
using MovingAverageMap = std::map< int, MovingAverage< glm::vec3, MAX_NUM_AVERAGING_SAMPLES> >;
static const int MAX_NUM_AVERAGING_SAMPLES = 50; // At ~100 updates per seconds this means averaging over ~.5s
using Samples = std::pair< MovingAverage< glm::vec3, MAX_NUM_AVERAGING_SAMPLES>, MovingAverage< glm::vec4, MAX_NUM_AVERAGING_SAMPLES> >;
using MovingAverageMap = std::map< int, Samples >;
MovingAverageMap _collectedSamples;
#ifdef __APPLE__