mirror of
https://github.com/lubosz/overte.git
synced 2025-04-18 04:18:17 +02:00
add Shape::getVerletPoints()
This commit is contained in:
parent
d1b2ba4a43
commit
4beee3fecf
5 changed files with 16 additions and 0 deletions
|
@ -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() {
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue