add Shape::getVerletPoints()

This commit is contained in:
Andrew Meadows 2014-08-04 17:33:24 -07:00
parent d1b2ba4a43
commit 4beee3fecf
5 changed files with 16 additions and 0 deletions

View file

@ -15,8 +15,10 @@
#include <glm/glm.hpp>
#include <glm/gtc/quaternion.hpp>
#include <QtGlobal>
#include <QVector>
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<VerletPoint*>& 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() {

View file

@ -111,6 +111,11 @@ void VerletCapsuleShape::applyAccumulatedDelta() {
_endPoint->applyAccumulatedDelta();
}
void VerletCapsuleShape::getVerletPoints(QVector<VerletPoint*>& points) {
points.push_back(_startPoint);
points.push_back(_endPoint);
}
// virtual
float VerletCapsuleShape::getHalfHeight() const {
return 0.5f * glm::distance(_startPoint->_position, _endPoint->_position);

View file

@ -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<VerletPoint*>& points);
//float getRadius() const { return _radius; }
virtual float getHalfHeight() const;

View file

@ -48,3 +48,7 @@ void VerletSphereShape::accumulateDelta(float relativeMassFactor, const glm::vec
void VerletSphereShape::applyAccumulatedDelta() {
_point->applyAccumulatedDelta();
}
void VerletSphereShape::getVerletPoints(QVector<VerletPoint*>& points) {
points.push_back(_point);
}

View file

@ -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<VerletPoint*>& points);
protected:
// NOTE: VerletSphereShape does NOT own its _point