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

View file

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

View file

@ -240,7 +240,8 @@ void SixenseManager::update(float deltaTime, bool jointsCaptured) {
} else { } else {
auto hand = left ? controller::StandardPoseChannel::LEFT_HAND : controller::StandardPoseChannel::RIGHT_HAND; auto hand = left ? controller::StandardPoseChannel::LEFT_HAND : controller::StandardPoseChannel::RIGHT_HAND;
_poseStateMap[hand] = controller::Pose(); _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 // Average
auto& samples = _collectedSamples[hand]; auto& samples = _collectedSamples[hand];
samples.addSample(velocity); samples.first.addSample(velocity);
velocity = samples.average; 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()) { } else if (!prevPose.isValid()) {
_collectedSamples[hand].clear(); _collectedSamples[hand].first.clear();
_collectedSamples[hand].second.clear();
} }
_poseStateMap[hand] = controller::Pose(position, rotation, velocity, angularVelocity); _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 static const int MAX_NUM_AVERAGING_SAMPLES = 50; // At ~100 updates per seconds this means averaging over ~.5s
using MovingAverageMap = std::map< int, MovingAverage< glm::vec3, MAX_NUM_AVERAGING_SAMPLES> >; 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; MovingAverageMap _collectedSamples;
#ifdef __APPLE__ #ifdef __APPLE__