From 60612f6397c58782aa7cd7b99bab44d80e9564ea Mon Sep 17 00:00:00 2001 From: Andrew Meadows Date: Fri, 25 Jul 2014 15:23:12 -0700 Subject: [PATCH] implement VerletPoint::integrateForward() --- libraries/shared/src/VerletPoint.cpp | 6 ++++++ libraries/shared/src/VerletPoint.h | 2 ++ 2 files changed, 8 insertions(+) diff --git a/libraries/shared/src/VerletPoint.cpp b/libraries/shared/src/VerletPoint.cpp index ab0715fec1..641ac39341 100644 --- a/libraries/shared/src/VerletPoint.cpp +++ b/libraries/shared/src/VerletPoint.cpp @@ -11,6 +11,12 @@ #include "VerletPoint.h" +void VerletPoint::integrateForward() { + glm::vec3 oldPosition = _position; + _position += 0.6f * (_position - _lastPosition); + _lastPosition = oldPosition; +} + void VerletPoint::accumulateDelta(const glm::vec3& delta) { _accumulatedDelta += delta; ++_numDeltas; diff --git a/libraries/shared/src/VerletPoint.h b/libraries/shared/src/VerletPoint.h index f6f8fb6d95..076a624776 100644 --- a/libraries/shared/src/VerletPoint.h +++ b/libraries/shared/src/VerletPoint.h @@ -18,6 +18,8 @@ class VerletPoint { public: VerletPoint() : _position(0.0f), _lastPosition(0.0f), _mass(1.0f), _accumulatedDelta(0.0f), _numDeltas(0) {} + void initPosition(const glm::vec3& position) { _position = position; _lastPosition = position; } + void integrateForward(); void accumulateDelta(const glm::vec3& delta); void applyAccumulatedDelta();