From 4beee3fecfbd51bb9ac0f4ef666c5545a9e4d122 Mon Sep 17 00:00:00 2001 From: Andrew Meadows Date: Mon, 4 Aug 2014 17:33:24 -0700 Subject: [PATCH] add Shape::getVerletPoints() --- libraries/shared/src/Shape.h | 4 ++++ libraries/shared/src/VerletCapsuleShape.cpp | 5 +++++ libraries/shared/src/VerletCapsuleShape.h | 1 + libraries/shared/src/VerletSphereShape.cpp | 4 ++++ libraries/shared/src/VerletSphereShape.h | 2 ++ 5 files changed, 16 insertions(+) diff --git a/libraries/shared/src/Shape.h b/libraries/shared/src/Shape.h index b1efe6d9ce..2efa5b824f 100644 --- a/libraries/shared/src/Shape.h +++ b/libraries/shared/src/Shape.h @@ -15,8 +15,10 @@ #include #include #include +#include class PhysicsEntity; +class VerletPoint; const float MAX_SHAPE_MASS = 1.0e18f; // something less than sqrt(FLT_MAX) @@ -73,6 +75,8 @@ public: /// \return volume of shape in cubic meters virtual float getVolume() const { return 1.0; } + virtual void getVerletPoints(QVector& points) {} + protected: // these ctors are protected (used by derived classes only) Shape(Type type) : _type(type), _owningEntity(NULL), _boundingRadius(0.f), _translation(0.f), _rotation() { diff --git a/libraries/shared/src/VerletCapsuleShape.cpp b/libraries/shared/src/VerletCapsuleShape.cpp index ab956264b5..6f547d2048 100644 --- a/libraries/shared/src/VerletCapsuleShape.cpp +++ b/libraries/shared/src/VerletCapsuleShape.cpp @@ -111,6 +111,11 @@ void VerletCapsuleShape::applyAccumulatedDelta() { _endPoint->applyAccumulatedDelta(); } +void VerletCapsuleShape::getVerletPoints(QVector& points) { + points.push_back(_startPoint); + points.push_back(_endPoint); +} + // virtual float VerletCapsuleShape::getHalfHeight() const { return 0.5f * glm::distance(_startPoint->_position, _endPoint->_position); diff --git a/libraries/shared/src/VerletCapsuleShape.h b/libraries/shared/src/VerletCapsuleShape.h index 1fd84f5b1e..828e5def6c 100644 --- a/libraries/shared/src/VerletCapsuleShape.h +++ b/libraries/shared/src/VerletCapsuleShape.h @@ -47,6 +47,7 @@ public: float computeEffectiveMass(const glm::vec3& penetration, const glm::vec3& contactPoint); void accumulateDelta(float relativeMassFactor, const glm::vec3& penetration); void applyAccumulatedDelta(); + virtual void getVerletPoints(QVector& points); //float getRadius() const { return _radius; } virtual float getHalfHeight() const; diff --git a/libraries/shared/src/VerletSphereShape.cpp b/libraries/shared/src/VerletSphereShape.cpp index 10c40c6611..e24465fd89 100644 --- a/libraries/shared/src/VerletSphereShape.cpp +++ b/libraries/shared/src/VerletSphereShape.cpp @@ -48,3 +48,7 @@ void VerletSphereShape::accumulateDelta(float relativeMassFactor, const glm::vec void VerletSphereShape::applyAccumulatedDelta() { _point->applyAccumulatedDelta(); } + +void VerletSphereShape::getVerletPoints(QVector& points) { + points.push_back(_point); +} diff --git a/libraries/shared/src/VerletSphereShape.h b/libraries/shared/src/VerletSphereShape.h index 65da3b2597..c9a23faef2 100644 --- a/libraries/shared/src/VerletSphereShape.h +++ b/libraries/shared/src/VerletSphereShape.h @@ -38,6 +38,8 @@ public: float computeEffectiveMass(const glm::vec3& penetration, const glm::vec3& contactPoint); void accumulateDelta(float relativeMassFactor, const glm::vec3& penetration); void applyAccumulatedDelta(); + void getVerletPoints(QVector& points); + protected: // NOTE: VerletSphereShape does NOT own its _point