[DEV] start to be good
This commit is contained in:
parent
aa25f1fd11
commit
0d7b7b7465
@ -32,9 +32,9 @@ namespace ephysics {
|
|||||||
float m_sleepTime; //!< Elapsed time since the body velocity was bellow the sleep velocity
|
float m_sleepTime; //!< Elapsed time since the body velocity was bellow the sleep velocity
|
||||||
void* m_userData; //!< Pointer that can be used to attach user data to the body
|
void* m_userData; //!< Pointer that can be used to attach user data to the body
|
||||||
/// Private copy-constructor
|
/// Private copy-constructor
|
||||||
Body(const Body& body);
|
Body(const Body& body) = delete;
|
||||||
/// Private assignment operator
|
/// Private assignment operator
|
||||||
Body& operator=(const Body& body);
|
Body& operator=(const Body& body) = delete;
|
||||||
public :
|
public :
|
||||||
/**
|
/**
|
||||||
* @brief Constructor
|
* @brief Constructor
|
||||||
|
@ -122,7 +122,7 @@ namespace ephysics {
|
|||||||
* @param[in] transform The transformation of the collision shape that transforms the local-space of the collision shape int32_to the local-space of the body
|
* @param[in] transform The transformation of the collision shape that transforms the local-space of the collision shape int32_to the local-space of the body
|
||||||
* @return A pointer to the proxy shape that has been created to link the body to the new collision shape you have added.
|
* @return A pointer to the proxy shape that has been created to link the body to the new collision shape you have added.
|
||||||
*/
|
*/
|
||||||
virtual ProxyShape* addCollisionShape(CollisionShape* _collisionShape, const etk::Transform3D& _transform);
|
ProxyShape* addCollisionShape(CollisionShape* _collisionShape, const etk::Transform3D& _transform);
|
||||||
/**
|
/**
|
||||||
* @brief Remove a collision shape from the body
|
* @brief Remove a collision shape from the body
|
||||||
* To remove a collision shape, you need to specify the pointer to the proxy shape that has been returned when you have added the collision shape to the body
|
* To remove a collision shape, you need to specify the pointer to the proxy shape that has been returned when you have added the collision shape to the body
|
||||||
|
@ -56,10 +56,7 @@ namespace ephysics {
|
|||||||
// Translate the body according to the translation of the center of mass position
|
// Translate the body according to the translation of the center of mass position
|
||||||
m_transform.setPosition(m_centerOfMassWorld - m_transform.getOrientation() * m_centerOfMassLocal);
|
m_transform.setPosition(m_centerOfMassWorld - m_transform.getOrientation() * m_centerOfMassLocal);
|
||||||
}
|
}
|
||||||
/**
|
void updateBroadPhaseState() const override;
|
||||||
* @brief Update the broad-phase state for this body (because it has moved for instance)
|
|
||||||
*/
|
|
||||||
virtual void updateBroadPhaseState() const;
|
|
||||||
public :
|
public :
|
||||||
/**
|
/**
|
||||||
* @brief Constructor
|
* @brief Constructor
|
||||||
@ -72,7 +69,7 @@ namespace ephysics {
|
|||||||
* @brief Virtual Destructor
|
* @brief Virtual Destructor
|
||||||
*/
|
*/
|
||||||
virtual ~RigidBody();
|
virtual ~RigidBody();
|
||||||
void setType(BodyType _type); // TODO: override
|
void setType(BodyType _type) override;
|
||||||
/**
|
/**
|
||||||
* @brief Set the current position and orientation
|
* @brief Set the current position and orientation
|
||||||
* @param[in] _transform The transformation of the body that transforms the local-space of the body int32_to world-space
|
* @param[in] _transform The transformation of the body that transforms the local-space of the body int32_to world-space
|
||||||
@ -279,15 +276,10 @@ namespace ephysics {
|
|||||||
* @param[in] _mass Mass (in kilograms) of the collision shape you want to add
|
* @param[in] _mass Mass (in kilograms) of the collision shape you want to add
|
||||||
* @return A pointer to the proxy shape that has been created to link the body to the new collision shape you have added.
|
* @return A pointer to the proxy shape that has been created to link the body to the new collision shape you have added.
|
||||||
*/
|
*/
|
||||||
virtual ProxyShape* addCollisionShape(CollisionShape* _collisionShape,
|
ProxyShape* addCollisionShape(CollisionShape* _collisionShape,
|
||||||
const etk::Transform3D& _transform,
|
const etk::Transform3D& _transform,
|
||||||
float _mass);
|
float _mass);
|
||||||
/**
|
virtual void removeCollisionShape(const ProxyShape* _proxyShape) override;
|
||||||
* @brief Remove a collision shape from the body
|
|
||||||
* To remove a collision shape, you need to specify the pointer to the proxy shape that has been returned when you have added the collision shape to the body
|
|
||||||
* @param[in] _proxyShape The pointer of the proxy shape you want to remove
|
|
||||||
*/
|
|
||||||
virtual void removeCollisionShape(const ProxyShape* _proxyShape);
|
|
||||||
/**
|
/**
|
||||||
* @brief Recompute the center of mass, total mass and inertia tensor of the body using all the collision shapes attached to the body.
|
* @brief Recompute the center of mass, total mass and inertia tensor of the body using all the collision shapes attached to the body.
|
||||||
*/
|
*/
|
||||||
|
@ -133,7 +133,7 @@ namespace ephysics {
|
|||||||
/// Return a reference to the world memory allocator
|
/// Return a reference to the world memory allocator
|
||||||
MemoryAllocator& getWorldMemoryAllocator();
|
MemoryAllocator& getWorldMemoryAllocator();
|
||||||
/// Called by a narrow-phase collision algorithm when a new contact has been found
|
/// Called by a narrow-phase collision algorithm when a new contact has been found
|
||||||
virtual void notifyContact(OverlappingPair* _overlappingPair, const ContactPointInfo& _contactInfo);
|
virtual void notifyContact(OverlappingPair* _overlappingPair, const ContactPointInfo& _contactInfo) override;
|
||||||
/// Create a new contact
|
/// Create a new contact
|
||||||
void createContact(OverlappingPair* _overlappingPair, const ContactPointInfo& _contactInfo);
|
void createContact(OverlappingPair* _overlappingPair, const ContactPointInfo& _contactInfo);
|
||||||
friend class DynamicsWorld;
|
friend class DynamicsWorld;
|
||||||
|
@ -15,11 +15,6 @@ DefaultCollisionDispatch::DefaultCollisionDispatch() {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Destructor
|
|
||||||
DefaultCollisionDispatch::~DefaultCollisionDispatch() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Initialize the collision dispatch configuration
|
/// Initialize the collision dispatch configuration
|
||||||
void DefaultCollisionDispatch::init(CollisionDetection* collisionDetection,
|
void DefaultCollisionDispatch::init(CollisionDetection* collisionDetection,
|
||||||
MemoryAllocator* memoryAllocator) {
|
MemoryAllocator* memoryAllocator) {
|
||||||
|
@ -24,13 +24,8 @@ class DefaultCollisionDispatch : public CollisionDispatch {
|
|||||||
public:
|
public:
|
||||||
/// Constructor
|
/// Constructor
|
||||||
DefaultCollisionDispatch();
|
DefaultCollisionDispatch();
|
||||||
/// Destructor
|
void init(CollisionDetection* _collisionDetection, MemoryAllocator* _memoryAllocator) override;
|
||||||
virtual ~DefaultCollisionDispatch();
|
NarrowPhaseAlgorithm* selectAlgorithm(int32_t _type1, int32_t _type2) override;
|
||||||
/// Initialize the collision dispatch configuration
|
|
||||||
virtual void init(CollisionDetection* _collisionDetection, MemoryAllocator* _memoryAllocator);
|
|
||||||
/// Select and return the narrow-phase collision detection algorithm to
|
|
||||||
/// use between two types of collision shapes.
|
|
||||||
virtual NarrowPhaseAlgorithm* selectAlgorithm(int32_t _type1, int32_t _type2);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -29,31 +29,21 @@ class BoxShape : public ConvexShape {
|
|||||||
protected :
|
protected :
|
||||||
vec3 m_extent; //!< Extent sizes of the box in the x, y and z direction
|
vec3 m_extent; //!< Extent sizes of the box in the x, y and z direction
|
||||||
/// Private copy-constructor
|
/// Private copy-constructor
|
||||||
BoxShape(const BoxShape& shape);
|
BoxShape(const BoxShape& _shape) = delete;
|
||||||
/// Private assignment operator
|
/// Private assignment operator
|
||||||
BoxShape& operator=(const BoxShape& shape);
|
BoxShape& operator=(const BoxShape& _shape) = delete;
|
||||||
/// Return a local support point in a given direction without the object margin
|
vec3 getLocalSupportPointWithoutMargin(const vec3& _direction, void** _cachedCollisionData) const override;
|
||||||
virtual vec3 getLocalSupportPointWithoutMargin(const vec3& direction,
|
bool testPointInside(const vec3& _localPoint, ProxyShape* _proxyShape) const override;
|
||||||
void** cachedCollisionData) const;
|
bool raycast(const Ray& _ray, RaycastInfo& _raycastInfo, ProxyShape* _proxyShape) const override;
|
||||||
/// Return true if a point is inside the collision shape
|
size_t getSizeInBytes() const override;
|
||||||
virtual bool testPointInside(const vec3& localPoint, ProxyShape* proxyShape) const;
|
|
||||||
/// Raycast method with feedback information
|
|
||||||
virtual bool raycast(const Ray& ray, RaycastInfo& raycastInfo, ProxyShape* proxyShape) const;
|
|
||||||
/// Return the number of bytes used by the collision shape
|
|
||||||
virtual size_t getSizeInBytes() const;
|
|
||||||
public :
|
public :
|
||||||
/// Constructor
|
/// Constructor
|
||||||
BoxShape(const vec3& extent, float margin = OBJECT_MARGIN);
|
BoxShape(const vec3& _extent, float _margin = OBJECT_MARGIN);
|
||||||
/// Destructor
|
|
||||||
virtual ~BoxShape() = default;
|
|
||||||
/// Return the extents of the box
|
/// Return the extents of the box
|
||||||
vec3 getExtent() const;
|
vec3 getExtent() const;
|
||||||
/// Set the scaling vector of the collision shape
|
void setLocalScaling(const vec3& _scaling) override;
|
||||||
virtual void setLocalScaling(const vec3& scaling);
|
void getLocalBounds(vec3& _min, vec3& _max) const override;
|
||||||
/// Return the local bounds of the shape in x, y and z directions
|
void computeLocalInertiaTensor(etk::Matrix3x3& _tensor, float _mass) const override;
|
||||||
virtual void getLocalBounds(vec3& _min, vec3& _max) const;
|
|
||||||
/// Return the local inertia tensor of the collision shape
|
|
||||||
virtual void computeLocalInertiaTensor(etk::Matrix3x3& tensor, float mass) const;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -23,22 +23,17 @@ namespace ephysics {
|
|||||||
protected:
|
protected:
|
||||||
float m_halfHeight; //!< Half height of the capsule (height = distance between the centers of the two spheres)
|
float m_halfHeight; //!< Half height of the capsule (height = distance between the centers of the two spheres)
|
||||||
/// Private copy-constructor
|
/// Private copy-constructor
|
||||||
CapsuleShape(const CapsuleShape& shape);
|
CapsuleShape(const CapsuleShape& _shape);
|
||||||
/// Private assignment operator
|
/// Private assignment operator
|
||||||
CapsuleShape& operator=(const CapsuleShape& shape);
|
CapsuleShape& operator=(const CapsuleShape& _shape);
|
||||||
/// Return a local support point in a given direction without the object margin
|
vec3 getLocalSupportPointWithoutMargin(const vec3& _direction, void** _cachedCollisionData) const override;
|
||||||
virtual vec3 getLocalSupportPointWithoutMargin(const vec3& direction,
|
bool testPointInside(const vec3& _localPoint, ProxyShape* _proxyShape) const override;
|
||||||
void** cachedCollisionData) const;
|
bool raycast(const Ray& _ray, RaycastInfo& _raycastInfo, ProxyShape* _proxyShape) const override;
|
||||||
/// Return true if a point is inside the collision shape
|
|
||||||
virtual bool testPointInside(const vec3& localPoint, ProxyShape* proxyShape) const;
|
|
||||||
/// Raycast method with feedback information
|
|
||||||
virtual bool raycast(const Ray& ray, RaycastInfo& raycastInfo, ProxyShape* proxyShape) const;
|
|
||||||
/// Raycasting method between a ray one of the two spheres end cap of the capsule
|
/// Raycasting method between a ray one of the two spheres end cap of the capsule
|
||||||
bool raycastWithSphereEndCap(const vec3& point1, const vec3& point2,
|
bool raycastWithSphereEndCap(const vec3& _point1, const vec3& _point2,
|
||||||
const vec3& sphereCenter, float maxFraction,
|
const vec3& _sphereCenter, float _maxFraction,
|
||||||
vec3& hitLocalPoint, float& hitFraction) const;
|
vec3& _hitLocalPoint, float& _hitFraction) const;
|
||||||
/// Return the number of bytes used by the collision shape
|
size_t getSizeInBytes() const override;
|
||||||
virtual size_t getSizeInBytes() const;
|
|
||||||
public :
|
public :
|
||||||
/// Constructor
|
/// Constructor
|
||||||
CapsuleShape(float _radius, float _height);
|
CapsuleShape(float _radius, float _height);
|
||||||
@ -48,11 +43,8 @@ namespace ephysics {
|
|||||||
float getRadius() const;
|
float getRadius() const;
|
||||||
/// Return the height of the capsule
|
/// Return the height of the capsule
|
||||||
float getHeight() const;
|
float getHeight() const;
|
||||||
/// Set the scaling vector of the collision shape
|
void setLocalScaling(const vec3& _scaling) override;
|
||||||
virtual void setLocalScaling(const vec3& scaling);
|
void getLocalBounds(vec3& _min, vec3& _max) const override;
|
||||||
/// Return the local bounds of the shape in x, y and z directions
|
void computeLocalInertiaTensor(etk::Matrix3x3& _tensor, float _mass) const override;
|
||||||
virtual void getLocalBounds(vec3& min, vec3& max) const;
|
|
||||||
/// Return the local inertia tensor of the collision shape
|
|
||||||
virtual void computeLocalInertiaTensor(etk::Matrix3x3& tensor, float mass) const;
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -58,19 +58,34 @@ class CollisionShape {
|
|||||||
* @return false If it is concave
|
* @return false If it is concave
|
||||||
*/
|
*/
|
||||||
virtual bool isConvex() const = 0;
|
virtual bool isConvex() const = 0;
|
||||||
/// Return the local bounds of the shape in x, y and z directions
|
/**
|
||||||
|
* @brief Get the local bounds of the shape in x, y and z directions.
|
||||||
|
* This method is used to compute the AABB of the box
|
||||||
|
* @param _min The minimum bounds of the shape in local-space coordinates
|
||||||
|
* @param _max The maximum bounds of the shape in local-space coordinates
|
||||||
|
*/
|
||||||
virtual void getLocalBounds(vec3& _min, vec3& _max) const=0;
|
virtual void getLocalBounds(vec3& _min, vec3& _max) const=0;
|
||||||
/// Return the scaling vector of the collision shape
|
/// Return the scaling vector of the collision shape
|
||||||
vec3 getScaling() const {
|
vec3 getScaling() const {
|
||||||
return m_scaling;
|
return m_scaling;
|
||||||
}
|
}
|
||||||
/// Set the local scaling vector of the collision shape
|
/**
|
||||||
|
* @brief Set the scaling vector of the collision shape
|
||||||
|
*/
|
||||||
virtual void setLocalScaling(const vec3& _scaling) {
|
virtual void setLocalScaling(const vec3& _scaling) {
|
||||||
m_scaling = _scaling;
|
m_scaling = _scaling;
|
||||||
}
|
}
|
||||||
/// Return the local inertia tensor of the collision shapes
|
/**
|
||||||
|
* @brief Compute the local inertia tensor of the sphere
|
||||||
|
* @param[out] _tensor The 3x3 inertia tensor matrix of the shape in local-space coordinates
|
||||||
|
* @param[in] _mass Mass to use to compute the inertia tensor of the collision shape
|
||||||
|
*/
|
||||||
virtual void computeLocalInertiaTensor(etk::Matrix3x3& _tensor, float _mass) const=0;
|
virtual void computeLocalInertiaTensor(etk::Matrix3x3& _tensor, float _mass) const=0;
|
||||||
/// Compute the world-space AABB of the collision shape given a transform
|
/**
|
||||||
|
* @brief Update the AABB of a body using its collision shape
|
||||||
|
* @param[out] _aabb The axis-aligned bounding box (AABB) of the collision shape computed in world-space coordinates
|
||||||
|
* @param[in] _transform etk::Transform3D used to compute the AABB of the collision shape
|
||||||
|
*/
|
||||||
virtual void computeAABB(AABB& _aabb, const etk::Transform3D& _transform) const;
|
virtual void computeAABB(AABB& _aabb, const etk::Transform3D& _transform) const;
|
||||||
/**
|
/**
|
||||||
* @brief Check if the shape is convex
|
* @brief Check if the shape is convex
|
||||||
|
@ -33,8 +33,7 @@ namespace ephysics {
|
|||||||
ConcaveShape(const ConcaveShape& _shape) = delete;
|
ConcaveShape(const ConcaveShape& _shape) = delete;
|
||||||
/// Private assignment operator
|
/// Private assignment operator
|
||||||
ConcaveShape& operator=(const ConcaveShape& _shape) = delete;
|
ConcaveShape& operator=(const ConcaveShape& _shape) = delete;
|
||||||
/// Return true if a point is inside the collision shape
|
virtual bool testPointInside(const vec3& _localPoint, ProxyShape* _proxyShape) const override;
|
||||||
virtual bool testPointInside(const vec3& _localPoint, ProxyShape* _proxyShape) const;
|
|
||||||
public :
|
public :
|
||||||
/// Constructor
|
/// Constructor
|
||||||
ConcaveShape(CollisionShapeType _type);
|
ConcaveShape(CollisionShapeType _type);
|
||||||
@ -47,7 +46,7 @@ namespace ephysics {
|
|||||||
// Set the raycast test type (front, back, front-back)
|
// Set the raycast test type (front, back, front-back)
|
||||||
void setRaycastTestType(TriangleRaycastSide _testType);
|
void setRaycastTestType(TriangleRaycastSide _testType);
|
||||||
/// Return true if the collision shape is convex, false if it is concave
|
/// Return true if the collision shape is convex, false if it is concave
|
||||||
virtual bool isConvex() const;
|
virtual bool isConvex() const override;
|
||||||
/// Use a callback method on all triangles of the concave shape inside a given AABB
|
/// Use a callback method on all triangles of the concave shape inside a given AABB
|
||||||
virtual void testAllTriangles(TriangleCallback& _callback, const AABB& _localAABB) const=0;
|
virtual void testAllTriangles(TriangleCallback& _callback, const AABB& _localAABB) const=0;
|
||||||
/// Return true if the smooth mesh collision is enabled
|
/// Return true if the smooth mesh collision is enabled
|
||||||
|
@ -33,15 +33,10 @@ namespace ephysics {
|
|||||||
ConeShape(const ConeShape& _shape) = delete;
|
ConeShape(const ConeShape& _shape) = delete;
|
||||||
/// Private assignment operator
|
/// Private assignment operator
|
||||||
ConeShape& operator=(const ConeShape& _shape) = delete;
|
ConeShape& operator=(const ConeShape& _shape) = delete;
|
||||||
/// Return a local support point in a given direction without the object margin
|
virtual vec3 getLocalSupportPointWithoutMargin(const vec3& _direction, void** _cachedCollisionData) const override;
|
||||||
virtual vec3 getLocalSupportPointWithoutMargin(const vec3& _direction,
|
bool testPointInside(const vec3& _localPoint, ProxyShape* _proxyShape) const override;
|
||||||
void** _cachedCollisionData) const;
|
bool raycast(const Ray& _ray, RaycastInfo& _raycastInfo, ProxyShape* _proxyShape) const override;
|
||||||
/// Return true if a point is inside the collision shape
|
size_t getSizeInBytes() const override;
|
||||||
virtual bool testPointInside(const vec3& _localPoint, ProxyShape* _proxyShape) const;
|
|
||||||
/// Raycast method with feedback information
|
|
||||||
virtual bool raycast(const Ray& _ray, RaycastInfo& _raycastInfo, ProxyShape* _proxyShape) const;
|
|
||||||
/// Return the number of bytes used by the collision shape
|
|
||||||
virtual size_t getSizeInBytes() const;
|
|
||||||
public :
|
public :
|
||||||
/// Constructor
|
/// Constructor
|
||||||
ConeShape(float _radius, float _height, float _margin = OBJECT_MARGIN);
|
ConeShape(float _radius, float _height, float _margin = OBJECT_MARGIN);
|
||||||
@ -49,11 +44,9 @@ namespace ephysics {
|
|||||||
float getRadius() const;
|
float getRadius() const;
|
||||||
/// Return the height
|
/// Return the height
|
||||||
float getHeight() const;
|
float getHeight() const;
|
||||||
/// Set the scaling vector of the collision shape
|
|
||||||
virtual void setLocalScaling(const vec3& _scaling);
|
void setLocalScaling(const vec3& _scaling) override;
|
||||||
/// Return the local bounds of the shape in x, y and z directions
|
void getLocalBounds(vec3& _min, vec3& _max) const override;
|
||||||
virtual void getLocalBounds(vec3& _min, vec3& _max) const;
|
void computeLocalInertiaTensor(etk::Matrix3x3& _tensor, float _mass) const override;
|
||||||
/// Return the local inertia tensor of the collision shape
|
|
||||||
virtual void computeLocalInertiaTensor(etk::Matrix3x3& _tensor, float _mass) const;
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -120,12 +120,6 @@ ConvexMeshShape::ConvexMeshShape(float margin)
|
|||||||
m_maxBounds(0, 0, 0), m_isEdgesInformationUsed(false) {
|
m_maxBounds(0, 0, 0), m_isEdgesInformationUsed(false) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Destructor
|
|
||||||
ConvexMeshShape::~ConvexMeshShape() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
// Return a local support point in a given direction without the object margin.
|
// Return a local support point in a given direction without the object margin.
|
||||||
/// If the edges information is not used for collision detection, this method will go through
|
/// If the edges information is not used for collision detection, this method will go through
|
||||||
/// the whole vertices list and pick up the vertex with the largest dot product in the support
|
/// the whole vertices list and pick up the vertex with the largest dot product in the support
|
||||||
|
@ -40,46 +40,39 @@ namespace ephysics {
|
|||||||
bool m_isEdgesInformationUsed; //!< True if the shape contains the edges of the convex mesh in order to make the collision detection faster
|
bool m_isEdgesInformationUsed; //!< True if the shape contains the edges of the convex mesh in order to make the collision detection faster
|
||||||
std::map<uint32_t, std::set<uint32_t> > m_edgesAdjacencyList; //!< Adjacency list representing the edges of the mesh
|
std::map<uint32_t, std::set<uint32_t> > m_edgesAdjacencyList; //!< Adjacency list representing the edges of the mesh
|
||||||
/// Private copy-constructor
|
/// Private copy-constructor
|
||||||
ConvexMeshShape(const ConvexMeshShape& shape);
|
ConvexMeshShape(const ConvexMeshShape& _shape);
|
||||||
/// Private assignment operator
|
/// Private assignment operator
|
||||||
ConvexMeshShape& operator=(const ConvexMeshShape& shape);
|
ConvexMeshShape& operator=(const ConvexMeshShape& _shape);
|
||||||
/// Recompute the bounds of the mesh
|
/// Recompute the bounds of the mesh
|
||||||
void recalculateBounds();
|
void recalculateBounds();
|
||||||
/// Set the scaling vector of the collision shape
|
void setLocalScaling(const vec3& _scaling) override;
|
||||||
virtual void setLocalScaling(const vec3& scaling);
|
vec3 getLocalSupportPointWithoutMargin(const vec3& _direction, void** _cachedCollisionData) const override;
|
||||||
/// Return a local support point in a given direction without the object margin.
|
bool testPointInside(const vec3& _localPoint, ProxyShape* _proxyShape) const override;
|
||||||
virtual vec3 getLocalSupportPointWithoutMargin(const vec3& direction,
|
bool raycast(const Ray& _ray, RaycastInfo& _raycastInfo, ProxyShape* _proxyShape) const override;
|
||||||
void** cachedCollisionData) const;
|
size_t getSizeInBytes() const override;
|
||||||
/// Return true if a point is inside the collision shape
|
|
||||||
virtual bool testPointInside(const vec3& localPoint, ProxyShape* proxyShape) const;
|
|
||||||
/// Raycast method with feedback information
|
|
||||||
virtual bool raycast(const Ray& ray, RaycastInfo& raycastInfo, ProxyShape* proxyShape) const;
|
|
||||||
/// Return the number of bytes used by the collision shape
|
|
||||||
virtual size_t getSizeInBytes() const;
|
|
||||||
public :
|
public :
|
||||||
/// Constructor to initialize with an array of 3D vertices.
|
/// Constructor to initialize with an array of 3D vertices.
|
||||||
ConvexMeshShape(const float* arrayVertices, uint32_t nbVertices, int32_t stride,
|
ConvexMeshShape(const float* _arrayVertices,
|
||||||
float margin = OBJECT_MARGIN);
|
uint32_t _nbVertices,
|
||||||
|
int32_t _stride,
|
||||||
|
float _margin = OBJECT_MARGIN);
|
||||||
/// Constructor to initialize with a triangle vertex array
|
/// Constructor to initialize with a triangle vertex array
|
||||||
ConvexMeshShape(TriangleVertexArray* triangleVertexArray, bool isEdgesInformationUsed = true,
|
ConvexMeshShape(TriangleVertexArray* _triangleVertexArray,
|
||||||
float margin = OBJECT_MARGIN);
|
bool _isEdgesInformationUsed = true,
|
||||||
|
float _margin = OBJECT_MARGIN);
|
||||||
/// Constructor.
|
/// Constructor.
|
||||||
ConvexMeshShape(float margin = OBJECT_MARGIN);
|
ConvexMeshShape(float _margin = OBJECT_MARGIN);
|
||||||
/// Destructor
|
void getLocalBounds(vec3& _min, vec3& _max) const override;
|
||||||
virtual ~ConvexMeshShape();
|
void computeLocalInertiaTensor(etk::Matrix3x3& _tensor, float _mass) const override;
|
||||||
/// Return the local bounds of the shape in x, y and z directions
|
|
||||||
virtual void getLocalBounds(vec3& min, vec3& max) const;
|
|
||||||
/// Return the local inertia tensor of the collision shape.
|
|
||||||
virtual void computeLocalInertiaTensor(etk::Matrix3x3& tensor, float mass) const;
|
|
||||||
/// Add a vertex int32_to the convex mesh
|
/// Add a vertex int32_to the convex mesh
|
||||||
void addVertex(const vec3& vertex);
|
void addVertex(const vec3& _vertex);
|
||||||
/// Add an edge int32_to the convex mesh by specifying the two vertex indices of the edge.
|
/// Add an edge int32_to the convex mesh by specifying the two vertex indices of the edge.
|
||||||
void addEdge(uint32_t v1, uint32_t v2);
|
void addEdge(uint32_t _v1, uint32_t _v2);
|
||||||
/// Return true if the edges information is used to speed up the collision detection
|
/// Return true if the edges information is used to speed up the collision detection
|
||||||
bool isEdgesInformationUsed() const;
|
bool isEdgesInformationUsed() const;
|
||||||
/// Set the variable to know if the edges information is used to speed up the
|
/// Set the variable to know if the edges information is used to speed up the
|
||||||
/// collision detection
|
/// collision detection
|
||||||
void setIsEdgesInformationUsed(bool isEdgesUsed);
|
void setIsEdgesInformationUsed(bool _isEdgesUsed);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -15,17 +15,14 @@ class ConvexShape : public CollisionShape {
|
|||||||
protected :
|
protected :
|
||||||
float m_margin; //!< Margin used for the GJK collision detection algorithm
|
float m_margin; //!< Margin used for the GJK collision detection algorithm
|
||||||
/// Private copy-constructor
|
/// Private copy-constructor
|
||||||
ConvexShape(const ConvexShape& shape);
|
ConvexShape(const ConvexShape& shape) = delete;
|
||||||
/// Private assignment operator
|
/// Private assignment operator
|
||||||
ConvexShape& operator=(const ConvexShape& shape);
|
ConvexShape& operator=(const ConvexShape& shape) = delete;
|
||||||
// Return a local support point in a given direction with the object margin
|
// Return a local support point in a given direction with the object margin
|
||||||
vec3 getLocalSupportPointWithMargin(const vec3& direction,
|
virtual vec3 getLocalSupportPointWithMargin(const vec3& _direction, void** _cachedCollisionData) const;
|
||||||
void** cachedCollisionData) const;
|
|
||||||
/// Return a local support point in a given direction without the object margin
|
/// Return a local support point in a given direction without the object margin
|
||||||
virtual vec3 getLocalSupportPointWithoutMargin(const vec3& direction,
|
virtual vec3 getLocalSupportPointWithoutMargin(const vec3& _direction, void** _cachedCollisionData) const=0;
|
||||||
void** cachedCollisionData) const=0;
|
bool testPointInside(const vec3& _worldPoint, ProxyShape* _proxyShape) const override = 0;
|
||||||
/// Return true if a point is inside the collision shape
|
|
||||||
virtual bool testPointInside(const vec3& worldPoint, ProxyShape* proxyShape) const=0;
|
|
||||||
public :
|
public :
|
||||||
/// Constructor
|
/// Constructor
|
||||||
ConvexShape(CollisionShapeType type, float margin);
|
ConvexShape(CollisionShapeType type, float margin);
|
||||||
|
@ -4,14 +4,12 @@
|
|||||||
* @license BSD 3 clauses (see license file)
|
* @license BSD 3 clauses (see license file)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// Libraries
|
|
||||||
#include <ephysics/collision/shapes/CylinderShape.hpp>
|
#include <ephysics/collision/shapes/CylinderShape.hpp>
|
||||||
#include <ephysics/collision/ProxyShape.hpp>
|
#include <ephysics/collision/ProxyShape.hpp>
|
||||||
#include <ephysics/configuration.hpp>
|
#include <ephysics/configuration.hpp>
|
||||||
|
|
||||||
using namespace ephysics;
|
using namespace ephysics;
|
||||||
|
|
||||||
// Constructor
|
|
||||||
/**
|
/**
|
||||||
* @param radius Radius of the cylinder (in meters)
|
* @param radius Radius of the cylinder (in meters)
|
||||||
* @param height Height of the cylinder (in meters)
|
* @param height Height of the cylinder (in meters)
|
||||||
@ -24,10 +22,6 @@ CylinderShape::CylinderShape(float radius, float height, float margin)
|
|||||||
assert(height > 0.0f);
|
assert(height > 0.0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Destructor
|
|
||||||
CylinderShape::~CylinderShape() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
// Return a local support point in a given direction without the object margin
|
// Return a local support point in a given direction without the object margin
|
||||||
vec3 CylinderShape::getLocalSupportPointWithoutMargin(const vec3& _direction, void** _cachedCollisionData) const {
|
vec3 CylinderShape::getLocalSupportPointWithoutMargin(const vec3& _direction, void** _cachedCollisionData) const {
|
||||||
|
@ -28,33 +28,23 @@ class CylinderShape : public ConvexShape {
|
|||||||
float mRadius; //!< Radius of the base
|
float mRadius; //!< Radius of the base
|
||||||
float m_halfHeight; //!< Half height of the cylinder
|
float m_halfHeight; //!< Half height of the cylinder
|
||||||
/// Private copy-constructor
|
/// Private copy-constructor
|
||||||
CylinderShape(const CylinderShape& shape);
|
CylinderShape(const CylinderShape&) = delete;
|
||||||
/// Private assignment operator
|
/// Private assignment operator
|
||||||
CylinderShape& operator=(const CylinderShape& shape);
|
CylinderShape& operator=(const CylinderShape&) = delete;
|
||||||
/// Return a local support point in a given direction without the object margin
|
vec3 getLocalSupportPointWithoutMargin(const vec3& _direction, void** _cachedCollisionData) const override;
|
||||||
virtual vec3 getLocalSupportPointWithoutMargin(const vec3& direction,
|
bool testPointInside(const vec3& _localPoint, ProxyShape* _proxyShape) const override;
|
||||||
void** cachedCollisionData) const;
|
bool raycast(const Ray& _ray, RaycastInfo& _raycastInfo, ProxyShape* _proxyShape) const override;
|
||||||
/// Return true if a point is inside the collision shape
|
size_t getSizeInBytes() const override;
|
||||||
virtual bool testPointInside(const vec3& localPoint, ProxyShape* proxyShape) const;
|
|
||||||
/// Raycast method with feedback information
|
|
||||||
virtual bool raycast(const Ray& ray, RaycastInfo& raycastInfo, ProxyShape* proxyShape) const;
|
|
||||||
/// Return the number of bytes used by the collision shape
|
|
||||||
virtual size_t getSizeInBytes() const;
|
|
||||||
public :
|
public :
|
||||||
/// Constructor
|
/// Constructor
|
||||||
CylinderShape(float radius, float height, float margin = OBJECT_MARGIN);
|
CylinderShape(float _radius, float _height, float _margin = OBJECT_MARGIN);
|
||||||
/// Destructor
|
|
||||||
virtual ~CylinderShape();
|
|
||||||
/// Return the radius
|
/// Return the radius
|
||||||
float getRadius() const;
|
float getRadius() const;
|
||||||
/// Return the height
|
/// Return the height
|
||||||
float getHeight() const;
|
float getHeight() const;
|
||||||
/// Set the scaling vector of the collision shape
|
void setLocalScaling(const vec3& _scaling) override;
|
||||||
virtual void setLocalScaling(const vec3& scaling);
|
void getLocalBounds(vec3& _min, vec3& _max) const override;
|
||||||
/// Return the local bounds of the shape in x, y and z directions
|
void computeLocalInertiaTensor(etk::Matrix3x3& _tensor, float _mass) const override;
|
||||||
virtual void getLocalBounds(vec3& min, vec3& max) const;
|
|
||||||
/// Return the local inertia tensor of the collision shape
|
|
||||||
virtual void computeLocalInertiaTensor(etk::Matrix3x3& tensor, float mass) const;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -55,10 +55,6 @@ HeightFieldShape::HeightFieldShape(int32_t nbGridColumns, int32_t nbGridRows, fl
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Destructor
|
|
||||||
HeightFieldShape::~HeightFieldShape() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
// Return the local bounds of the shape in x, y and z directions.
|
// Return the local bounds of the shape in x, y and z directions.
|
||||||
// This method is used to compute the AABB of the box
|
// This method is used to compute the AABB of the box
|
||||||
|
@ -75,13 +75,11 @@ namespace ephysics {
|
|||||||
const void* m_heightFieldData; //!< Array of data with all the height values of the height field
|
const void* m_heightFieldData; //!< Array of data with all the height values of the height field
|
||||||
AABB m_AABB; //!< Local AABB of the height field (without scaling)
|
AABB m_AABB; //!< Local AABB of the height field (without scaling)
|
||||||
/// Private copy-constructor
|
/// Private copy-constructor
|
||||||
HeightFieldShape(const HeightFieldShape& _shape);
|
HeightFieldShape(const HeightFieldShape&) = delete;
|
||||||
/// Private assignment operator
|
/// Private assignment operator
|
||||||
HeightFieldShape& operator=(const HeightFieldShape& _shape);
|
HeightFieldShape& operator=(const HeightFieldShape&) = delete;
|
||||||
/// Raycast method with feedback information
|
bool raycast(const Ray& _ray, RaycastInfo& _raycastInfo, ProxyShape* _proxyShape) const override;
|
||||||
virtual bool raycast(const Ray& _ray, RaycastInfo& _raycastInfo, ProxyShape* _proxyShape) const;
|
size_t getSizeInBytes() const override;
|
||||||
/// Return the number of bytes used by the collision shape
|
|
||||||
virtual size_t getSizeInBytes() const;
|
|
||||||
/// Insert all the triangles int32_to the dynamic AABB tree
|
/// Insert all the triangles int32_to the dynamic AABB tree
|
||||||
void initBVHTree();
|
void initBVHTree();
|
||||||
/// Return the three vertices coordinates (in the array outTriangleVertices) of a triangle
|
/// Return the three vertices coordinates (in the array outTriangleVertices) of a triangle
|
||||||
@ -106,22 +104,16 @@ namespace ephysics {
|
|||||||
const void* _heightFieldData,
|
const void* _heightFieldData,
|
||||||
HeightDataType _dataType,
|
HeightDataType _dataType,
|
||||||
int32_t _upAxis = 1, float _integerHeightScale = 1.0f);
|
int32_t _upAxis = 1, float _integerHeightScale = 1.0f);
|
||||||
/// Destructor
|
|
||||||
~HeightFieldShape();
|
|
||||||
/// Return the number of rows in the height field
|
/// Return the number of rows in the height field
|
||||||
int32_t getNbRows() const;
|
int32_t getNbRows() const;
|
||||||
/// Return the number of columns in the height field
|
/// Return the number of columns in the height field
|
||||||
int32_t getNbColumns() const;
|
int32_t getNbColumns() const;
|
||||||
/// Return the type of height value in the height field
|
/// Return the type of height value in the height field
|
||||||
HeightDataType getHeightDataType() const;
|
HeightDataType getHeightDataType() const;
|
||||||
/// Return the local bounds of the shape in x, y and z directions.
|
void getLocalBounds(vec3& _min, vec3& _max) const override;
|
||||||
virtual void getLocalBounds(vec3& _min, vec3& _max) const;
|
void setLocalScaling(const vec3& _scaling) override;
|
||||||
/// Set the local scaling vector of the collision shape
|
void computeLocalInertiaTensor(etk::Matrix3x3& _tensor, float _mass) const override;
|
||||||
virtual void setLocalScaling(const vec3& _scaling);
|
virtual void testAllTriangles(TriangleCallback& _callback, const AABB& _localAABB) const override;
|
||||||
/// Return the local inertia tensor of the collision shape
|
|
||||||
virtual void computeLocalInertiaTensor(etk::Matrix3x3& _tensor, float _mass) const;
|
|
||||||
/// Use a callback method on all triangles of the concave shape inside a given AABB
|
|
||||||
virtual void testAllTriangles(TriangleCallback& _callback, const AABB& _localAABB) const;
|
|
||||||
friend class ConvexTriangleAABBOverlapCallback;
|
friend class ConvexTriangleAABBOverlapCallback;
|
||||||
friend class ConcaveMeshRaycastCallback;
|
friend class ConcaveMeshRaycastCallback;
|
||||||
};
|
};
|
||||||
|
@ -20,11 +20,6 @@ SphereShape::SphereShape(float radius) : ConvexShape(SPHERE, radius) {
|
|||||||
assert(radius > 0.0f);
|
assert(radius > 0.0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Destructor
|
|
||||||
SphereShape::~SphereShape() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void SphereShape::setLocalScaling(const vec3& _scaling) {
|
void SphereShape::setLocalScaling(const vec3& _scaling) {
|
||||||
m_margin = (m_margin / m_scaling.x()) * _scaling.x();
|
m_margin = (m_margin / m_scaling.x()) * _scaling.x();
|
||||||
|
@ -22,37 +22,19 @@ namespace ephysics {
|
|||||||
protected :
|
protected :
|
||||||
SphereShape(const SphereShape& _shape);
|
SphereShape(const SphereShape& _shape);
|
||||||
SphereShape& operator=(const SphereShape& _shape) = delete;
|
SphereShape& operator=(const SphereShape& _shape) = delete;
|
||||||
/**
|
vec3 getLocalSupportPointWithoutMargin(const vec3& _direction, void** _cachedCollisionData) const override {
|
||||||
* @brief Get a local support point in a given direction without the object margin
|
|
||||||
* @param[in] _direction
|
|
||||||
* @param[in] _cachedCollisionData
|
|
||||||
* @return the center of the sphere (the radius is taken int32_to account in the object margin)
|
|
||||||
*/
|
|
||||||
vec3 getLocalSupportPointWithoutMargin(const vec3& _direction, void** _cachedCollisionData) const {
|
|
||||||
return vec3(0.0, 0.0, 0.0);
|
return vec3(0.0, 0.0, 0.0);
|
||||||
}
|
}
|
||||||
/**
|
bool testPointInside(const vec3& _localPoint, ProxyShape* _proxyShape) const override {
|
||||||
* @brief Test if a point is inside a shape
|
|
||||||
* @param[in] _localPoint Point to check
|
|
||||||
* @param[in] _proxyShape Shape to check
|
|
||||||
* @return true if a point is inside the collision shape
|
|
||||||
*/
|
|
||||||
bool testPointInside(const vec3& _localPoint, ProxyShape* _proxyShape) const {
|
|
||||||
return (_localPoint.length2() < m_margin * m_margin);
|
return (_localPoint.length2() < m_margin * m_margin);
|
||||||
}
|
}
|
||||||
/// Raycast method with feedback information
|
bool raycast(const Ray& _ray, RaycastInfo& _raycastInfo, ProxyShape* _proxyShape) const override;
|
||||||
virtual bool raycast(const Ray& _ray, RaycastInfo& _raycastInfo, ProxyShape* _proxyShape) const;
|
size_t getSizeInBytes() const override {
|
||||||
/**
|
|
||||||
* @brief Return the number of bytes used by the collision shape
|
|
||||||
*/
|
|
||||||
virtual size_t getSizeInBytes() const {
|
|
||||||
return sizeof(SphereShape);
|
return sizeof(SphereShape);
|
||||||
}
|
}
|
||||||
public :
|
public :
|
||||||
/// Constructor
|
/// Constructor
|
||||||
SphereShape(float _radius);
|
SphereShape(float _radius);
|
||||||
/// Destructor
|
|
||||||
virtual ~SphereShape();
|
|
||||||
/**
|
/**
|
||||||
* @brief Get the radius of the sphere
|
* @brief Get the radius of the sphere
|
||||||
* @return Radius of the sphere (in meters)
|
* @return Radius of the sphere (in meters)
|
||||||
@ -60,29 +42,10 @@ namespace ephysics {
|
|||||||
float getRadius() const {
|
float getRadius() const {
|
||||||
return m_margin;
|
return m_margin;
|
||||||
}
|
}
|
||||||
/**
|
void setLocalScaling(const vec3& _scaling) override;
|
||||||
* @brief Set the scaling vector of the collision shape
|
void getLocalBounds(vec3& _min, vec3& _max) const override;
|
||||||
*/
|
void computeLocalInertiaTensor(etk::Matrix3x3& _tensor, float _mass) const override;
|
||||||
virtual void setLocalScaling(const vec3& _scaling);
|
void computeAABB(AABB& _aabb, const etk::Transform3D& _transform) const override;
|
||||||
/**
|
|
||||||
* @brief Get the local bounds of the shape in x, y and z directions.
|
|
||||||
* This method is used to compute the AABB of the box
|
|
||||||
* @param _min The minimum bounds of the shape in local-space coordinates
|
|
||||||
* @param _max The maximum bounds of the shape in local-space coordinates
|
|
||||||
*/
|
|
||||||
virtual void getLocalBounds(vec3& _min, vec3& _max) const;
|
|
||||||
/**
|
|
||||||
* @brief Compute the local inertia tensor of the sphere
|
|
||||||
* @param[out] _tensor The 3x3 inertia tensor matrix of the shape in local-space coordinates
|
|
||||||
* @param[in] _mass Mass to use to compute the inertia tensor of the collision shape
|
|
||||||
*/
|
|
||||||
virtual void computeLocalInertiaTensor(etk::Matrix3x3& _tensor, float _mass) const;
|
|
||||||
/**
|
|
||||||
* @brief Update the AABB of a body using its collision shape
|
|
||||||
* @param[out] _aabb The axis-aligned bounding box (AABB) of the collision shape computed in world-space coordinates
|
|
||||||
* @param[in] _transform etk::Transform3D used to compute the AABB of the collision shape
|
|
||||||
*/
|
|
||||||
virtual void computeAABB(AABB& _aabb, const etk::Transform3D& _transform) const;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -30,29 +30,20 @@ namespace ephysics {
|
|||||||
TriangleShape(const TriangleShape& shape);
|
TriangleShape(const TriangleShape& shape);
|
||||||
/// Private assignment operator
|
/// Private assignment operator
|
||||||
TriangleShape& operator=(const TriangleShape& shape);
|
TriangleShape& operator=(const TriangleShape& shape);
|
||||||
/// Return a local support point in a given direction without the object margin
|
vec3 getLocalSupportPointWithoutMargin(const vec3& _direction, void** _cachedCollisionData) const override;
|
||||||
virtual vec3 getLocalSupportPointWithoutMargin(const vec3& direction,
|
bool testPointInside(const vec3& _localPoint, ProxyShape* _proxyShape) const override;
|
||||||
void** cachedCollisionData) const;
|
bool raycast(const Ray& ray, RaycastInfo& raycastInfo, ProxyShape* proxyShape) const override;
|
||||||
/// Return true if a point is inside the collision shape
|
size_t getSizeInBytes() const override;
|
||||||
virtual bool testPointInside(const vec3& localPoint, ProxyShape* proxyShape) const;
|
|
||||||
/// Raycast method with feedback information
|
|
||||||
virtual bool raycast(const Ray& ray, RaycastInfo& raycastInfo, ProxyShape* proxyShape) const;
|
|
||||||
/// Return the number of bytes used by the collision shape
|
|
||||||
virtual size_t getSizeInBytes() const;
|
|
||||||
public:
|
public:
|
||||||
/// Constructor
|
/// Constructor
|
||||||
TriangleShape(const vec3& point1, const vec3& point2, const vec3& point3,
|
TriangleShape(const vec3& point1, const vec3& point2, const vec3& point3,
|
||||||
float margin = OBJECT_MARGIN);
|
float margin = OBJECT_MARGIN);
|
||||||
/// Destructor
|
/// Destructor
|
||||||
virtual ~TriangleShape();
|
virtual ~TriangleShape();
|
||||||
/// Return the local bounds of the shape in x, y and z directions.
|
void getLocalBounds(vec3& min, vec3& max) const override;
|
||||||
virtual void getLocalBounds(vec3& min, vec3& max) const;
|
void setLocalScaling(const vec3& scaling) override;
|
||||||
/// Set the local scaling vector of the collision shape
|
void computeLocalInertiaTensor(etk::Matrix3x3& tensor, float mass) const override;
|
||||||
virtual void setLocalScaling(const vec3& scaling);
|
void computeAABB(AABB& aabb, const etk::Transform3D& transform) const override;
|
||||||
/// Return the local inertia tensor of the collision shape
|
|
||||||
virtual void computeLocalInertiaTensor(etk::Matrix3x3& tensor, float mass) const;
|
|
||||||
/// Update the AABB of a body using its collision shape
|
|
||||||
virtual void computeAABB(AABB& aabb, const etk::Transform3D& transform) const;
|
|
||||||
/// Return the raycast test type (front, back, front-back)
|
/// Return the raycast test type (front, back, front-back)
|
||||||
TriangleRaycastSide getRaycastTestType() const;
|
TriangleRaycastSide getRaycastTestType() const;
|
||||||
// Set the raycast test type (front, back, front-back)
|
// Set the raycast test type (front, back, front-back)
|
||||||
|
@ -22,11 +22,6 @@ BallAndSocketJoint::BallAndSocketJoint(const BallAndSocketJointInfo& jointInfo)
|
|||||||
m_localAnchorPointBody2 = m_body2->getTransform().getInverse() * jointInfo.m_anchorPointWorldSpace;
|
m_localAnchorPointBody2 = m_body2->getTransform().getInverse() * jointInfo.m_anchorPointWorldSpace;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Destructor
|
|
||||||
BallAndSocketJoint::~BallAndSocketJoint() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
// Initialize before solving the constraint
|
// Initialize before solving the constraint
|
||||||
void BallAndSocketJoint::initBeforeSolve(const ConstraintSolverData& constraintSolverData) {
|
void BallAndSocketJoint::initBeforeSolve(const ConstraintSolverData& constraintSolverData) {
|
||||||
|
|
||||||
|
@ -51,22 +51,15 @@ namespace ephysics {
|
|||||||
BallAndSocketJoint(const BallAndSocketJoint& constraint);
|
BallAndSocketJoint(const BallAndSocketJoint& constraint);
|
||||||
/// Private assignment operator
|
/// Private assignment operator
|
||||||
BallAndSocketJoint& operator=(const BallAndSocketJoint& constraint);
|
BallAndSocketJoint& operator=(const BallAndSocketJoint& constraint);
|
||||||
/// Return the number of bytes used by the joint
|
size_t getSizeInBytes() const override {
|
||||||
virtual size_t getSizeInBytes() const {
|
|
||||||
return sizeof(BallAndSocketJoint);
|
return sizeof(BallAndSocketJoint);
|
||||||
}
|
}
|
||||||
/// Initialize before solving the constraint
|
void initBeforeSolve(const ConstraintSolverData& _constraintSolverData) override;
|
||||||
virtual void initBeforeSolve(const ConstraintSolverData& constraintSolverData);
|
void warmstart(const ConstraintSolverData& _constraintSolverData) override;
|
||||||
/// Warm start the constraint (apply the previous impulse at the beginning of the step)
|
void solveVelocityConstraint(const ConstraintSolverData& _constraintSolverData) override;
|
||||||
virtual void warmstart(const ConstraintSolverData& constraintSolverData);
|
void solvePositionConstraint(const ConstraintSolverData& _constraintSolverData) override;
|
||||||
/// Solve the velocity constraint
|
|
||||||
virtual void solveVelocityConstraint(const ConstraintSolverData& constraintSolverData);
|
|
||||||
/// Solve the position constraint (for position error correction)
|
|
||||||
virtual void solvePositionConstraint(const ConstraintSolverData& constraintSolverData);
|
|
||||||
public:
|
public:
|
||||||
/// Constructor
|
/// Constructor
|
||||||
BallAndSocketJoint(const BallAndSocketJointInfo& jointInfo);
|
BallAndSocketJoint(const BallAndSocketJointInfo& _jointInfo);
|
||||||
/// Destructor
|
|
||||||
virtual ~BallAndSocketJoint();
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,6 @@
|
|||||||
* @license BSD 3 clauses (see license file)
|
* @license BSD 3 clauses (see license file)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// Libraries
|
|
||||||
#include <ephysics/constraint/FixedJoint.hpp>
|
#include <ephysics/constraint/FixedJoint.hpp>
|
||||||
#include <ephysics/engine/ConstraintSolver.hpp>
|
#include <ephysics/engine/ConstraintSolver.hpp>
|
||||||
|
|
||||||
|
@ -38,7 +38,7 @@ namespace ephysics {
|
|||||||
* between two bodies.
|
* between two bodies.
|
||||||
*/
|
*/
|
||||||
class FixedJoint : public Joint {
|
class FixedJoint : public Joint {
|
||||||
private :
|
private:
|
||||||
static const float BETA; //!< Beta value for the bias factor of position correction
|
static const float BETA; //!< Beta value for the bias factor of position correction
|
||||||
vec3 m_localAnchorPointBody1; //!< Anchor point of body 1 (in local-space coordinates of body 1)
|
vec3 m_localAnchorPointBody1; //!< Anchor point of body 1 (in local-space coordinates of body 1)
|
||||||
vec3 m_localAnchorPointBody2; //!< Anchor point of body 2 (in local-space coordinates of body 2)
|
vec3 m_localAnchorPointBody2; //!< Anchor point of body 2 (in local-space coordinates of body 2)
|
||||||
@ -54,24 +54,20 @@ namespace ephysics {
|
|||||||
vec3 m_biasRotation; //!< Bias vector for the 3 rotation constraints
|
vec3 m_biasRotation; //!< Bias vector for the 3 rotation constraints
|
||||||
etk::Quaternion m_initOrientationDifferenceInv; //!< Inverse of the initial orientation difference between the two bodies
|
etk::Quaternion m_initOrientationDifferenceInv; //!< Inverse of the initial orientation difference between the two bodies
|
||||||
/// Private copy-constructor
|
/// Private copy-constructor
|
||||||
FixedJoint(const FixedJoint& constraint);
|
FixedJoint(const FixedJoint& _constraint) = delete;
|
||||||
/// Private assignment operator
|
/// Private assignment operator
|
||||||
FixedJoint& operator=(const FixedJoint& constraint);
|
FixedJoint& operator=(const FixedJoint& _constraint) = delete;
|
||||||
/// Return the number of bytes used by the joint
|
|
||||||
virtual size_t getSizeInBytes() const override {
|
size_t getSizeInBytes() const override {
|
||||||
return sizeof(FixedJoint);
|
return sizeof(FixedJoint);
|
||||||
}
|
}
|
||||||
/// Initialize before solving the constraint
|
void initBeforeSolve(const ConstraintSolverData& _constraintSolverData) override;
|
||||||
virtual void initBeforeSolve(const ConstraintSolverData& constraintSolverData);
|
void warmstart(const ConstraintSolverData& _constraintSolverData) override;
|
||||||
/// Warm start the constraint (apply the previous impulse at the beginning of the step)
|
void solveVelocityConstraint(const ConstraintSolverData& _constraintSolverData) override;
|
||||||
virtual void warmstart(const ConstraintSolverData& constraintSolverData);
|
void solvePositionConstraint(const ConstraintSolverData& _constraintSolverData) override;
|
||||||
/// Solve the velocity constraint
|
public:
|
||||||
virtual void solveVelocityConstraint(const ConstraintSolverData& constraintSolverData);
|
|
||||||
/// Solve the position constraint (for position error correction)
|
|
||||||
virtual void solvePositionConstraint(const ConstraintSolverData& constraintSolverData);
|
|
||||||
public :
|
|
||||||
/// Constructor
|
/// Constructor
|
||||||
FixedJoint(const FixedJointInfo& jointInfo);
|
FixedJoint(const FixedJointInfo& _jointInfo);
|
||||||
/// Destructor
|
/// Destructor
|
||||||
virtual ~FixedJoint();
|
virtual ~FixedJoint();
|
||||||
};
|
};
|
||||||
|
@ -160,18 +160,12 @@ namespace ephysics {
|
|||||||
float _lowerLimitAngle,
|
float _lowerLimitAngle,
|
||||||
float _upperLimitAngle) const;
|
float _upperLimitAngle) const;
|
||||||
/// Compute the current angle around the hinge axis
|
/// Compute the current angle around the hinge axis
|
||||||
float computeCurrentHingeAngle(const etk::Quaternion& _orientationBody1,
|
float computeCurrentHingeAngle(const etk::Quaternion& _orientationBody1, const etk::Quaternion& _orientationBody2);
|
||||||
const etk::Quaternion& _orientationBody2);
|
size_t getSizeInBytes() const override;
|
||||||
/// Return the number of bytes used by the joint
|
void initBeforeSolve(const ConstraintSolverData& _constraintSolverData) override;
|
||||||
virtual size_t getSizeInBytes() const;
|
void warmstart(const ConstraintSolverData& _constraintSolverData) override;
|
||||||
/// Initialize before solving the constraint
|
void solveVelocityConstraint(const ConstraintSolverData& _constraintSolverData) override;
|
||||||
virtual void initBeforeSolve(const ConstraintSolverData& _constraintSolverData);
|
void solvePositionConstraint(const ConstraintSolverData& _constraintSolverData) override;
|
||||||
/// Warm start the constraint (apply the previous impulse at the beginning of the step)
|
|
||||||
virtual void warmstart(const ConstraintSolverData& _constraintSolverData);
|
|
||||||
/// Solve the velocity constraint
|
|
||||||
virtual void solveVelocityConstraint(const ConstraintSolverData& _constraintSolverData);
|
|
||||||
/// Solve the position constraint (for position error correction)
|
|
||||||
virtual void solvePositionConstraint(const ConstraintSolverData& _constraintSolverData);
|
|
||||||
public :
|
public :
|
||||||
/// Constructor
|
/// Constructor
|
||||||
HingeJoint(const HingeJointInfo& _jointInfo);
|
HingeJoint(const HingeJointInfo& _jointInfo);
|
||||||
|
@ -3,24 +3,19 @@
|
|||||||
* @copyright 2010-2016 Daniel Chappuis
|
* @copyright 2010-2016 Daniel Chappuis
|
||||||
* @license BSD 3 clauses (see license file)
|
* @license BSD 3 clauses (see license file)
|
||||||
*/
|
*/
|
||||||
#pragma once
|
|
||||||
|
|
||||||
// Libraries
|
|
||||||
#include <ephysics/constraint/Joint.hpp>
|
#include <ephysics/constraint/Joint.hpp>
|
||||||
|
|
||||||
using namespace ephysics;
|
using namespace ephysics;
|
||||||
|
|
||||||
// Constructor
|
|
||||||
Joint::Joint(const JointInfo& jointInfo)
|
Joint::Joint(const JointInfo& jointInfo)
|
||||||
:m_body1(jointInfo.body1), m_body2(jointInfo.body2), m_type(jointInfo.type),
|
:m_body1(jointInfo.body1), m_body2(jointInfo.body2), m_type(jointInfo.type),
|
||||||
m_positionCorrectionTechnique(jointInfo.positionCorrectionTechnique),
|
m_positionCorrectionTechnique(jointInfo.positionCorrectionTechnique),
|
||||||
m_isCollisionEnabled(jointInfo.isCollisionEnabled), m_isAlreadyInIsland(false) {
|
m_isCollisionEnabled(jointInfo.isCollisionEnabled), m_isAlreadyInIsland(false) {
|
||||||
|
|
||||||
assert(m_body1 != NULL);
|
assert(m_body1 != nullptr);
|
||||||
assert(m_body2 != NULL);
|
assert(m_body2 != nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Destructor
|
|
||||||
Joint::~Joint() {
|
Joint::~Joint() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -156,16 +156,11 @@ namespace ephysics {
|
|||||||
SliderJoint& operator=(const SliderJoint& _constraint);
|
SliderJoint& operator=(const SliderJoint& _constraint);
|
||||||
/// Reset the limits
|
/// Reset the limits
|
||||||
void resetLimits();
|
void resetLimits();
|
||||||
/// Return the number of bytes used by the joint
|
size_t getSizeInBytes() const override;
|
||||||
virtual size_t getSizeInBytes() const;
|
void initBeforeSolve(const ConstraintSolverData& _constraintSolverData) override;
|
||||||
/// Initialize before solving the constraint
|
void warmstart(const ConstraintSolverData& _constraintSolverData) override;
|
||||||
virtual void initBeforeSolve(const ConstraintSolverData& _constraintSolverData);
|
void solveVelocityConstraint(const ConstraintSolverData& _constraintSolverData) override;
|
||||||
/// Warm start the constraint (apply the previous impulse at the beginning of the step)
|
void solvePositionConstraint(const ConstraintSolverData& _constraintSolverData) override;
|
||||||
virtual void warmstart(const ConstraintSolverData& _constraintSolverData);
|
|
||||||
/// Solve the velocity constraint
|
|
||||||
virtual void solveVelocityConstraint(const ConstraintSolverData& _constraintSolverData);
|
|
||||||
/// Solve the position constraint (for position error correction)
|
|
||||||
virtual void solvePositionConstraint(const ConstraintSolverData& _constraintSolverData);
|
|
||||||
public :
|
public :
|
||||||
/// Constructor
|
/// Constructor
|
||||||
SliderJoint(const SliderJointInfo& _jointInfo);
|
SliderJoint(const SliderJointInfo& _jointInfo);
|
||||||
|
@ -142,24 +142,18 @@ namespace ephysics {
|
|||||||
void setTimeBeforeSleep(float timeBeforeSleep);
|
void setTimeBeforeSleep(float timeBeforeSleep);
|
||||||
/// Set an event listener object to receive events callbacks.
|
/// Set an event listener object to receive events callbacks.
|
||||||
void setEventListener(EventListener* eventListener);
|
void setEventListener(EventListener* eventListener);
|
||||||
/// Test and report collisions between a given shape and all the others
|
void testCollision(const ProxyShape* _shape,
|
||||||
/// shapes of the world
|
CollisionCallback* _callback) override;
|
||||||
virtual void testCollision(const ProxyShape* shape,
|
virtual void testCollision(const ProxyShape* _shape1,
|
||||||
CollisionCallback* callback);
|
const ProxyShape* _shape2,
|
||||||
/// Test and report collisions between two given shapes
|
CollisionCallback* _callback) override;
|
||||||
virtual void testCollision(const ProxyShape* shape1,
|
virtual void testCollision(const CollisionBody* _body,
|
||||||
const ProxyShape* shape2,
|
CollisionCallback* _callback) override;
|
||||||
CollisionCallback* callback);
|
virtual void testCollision(const CollisionBody* _body1,
|
||||||
/// Test and report collisions between a body and all
|
const CollisionBody* _body2,
|
||||||
/// the others bodies of the world
|
CollisionCallback* _callback) override;
|
||||||
virtual void testCollision(const CollisionBody* body,
|
|
||||||
CollisionCallback* callback);
|
|
||||||
/// Test and report collisions between two bodies
|
|
||||||
virtual void testCollision(const CollisionBody* body1,
|
|
||||||
const CollisionBody* body2,
|
|
||||||
CollisionCallback* callback);
|
|
||||||
/// Test and report collisions between all shapes of the world
|
/// Test and report collisions between all shapes of the world
|
||||||
virtual void testCollision(CollisionCallback* callback);
|
virtual void testCollision(CollisionCallback* _callback) override;
|
||||||
/// Return the list of all contacts of the world
|
/// Return the list of all contacts of the world
|
||||||
std::vector<const ContactManifold*> getContactsList() const;
|
std::vector<const ContactManifold*> getContactsList() const;
|
||||||
friend class RigidBody;
|
friend class RigidBody;
|
||||||
|
@ -16,3 +16,73 @@ OverlappingPair::OverlappingPair(ProxyShape* shape1, ProxyShape* shape2, int32_t
|
|||||||
m_cachedSeparatingAxis(1.0, 1.0, 1.0) {
|
m_cachedSeparatingAxis(1.0, 1.0, 1.0) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Return the pointer to first body
|
||||||
|
ProxyShape* OverlappingPair::getShape1() const {
|
||||||
|
return m_contactManifoldSet.getShape1();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Return the pointer to second body
|
||||||
|
ProxyShape* OverlappingPair::getShape2() const {
|
||||||
|
return m_contactManifoldSet.getShape2();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add a contact to the contact manifold
|
||||||
|
void OverlappingPair::addContact(ContactPoint* contact) {
|
||||||
|
m_contactManifoldSet.addContactPoint(contact);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update the contact manifold
|
||||||
|
void OverlappingPair::update() {
|
||||||
|
m_contactManifoldSet.update();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Return the cached separating axis
|
||||||
|
vec3 OverlappingPair::getCachedSeparatingAxis() const {
|
||||||
|
return m_cachedSeparatingAxis;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Set the cached separating axis
|
||||||
|
void OverlappingPair::setCachedSeparatingAxis(const vec3& _axis) {
|
||||||
|
m_cachedSeparatingAxis = _axis;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Return the number of contact points in the contact manifold
|
||||||
|
uint32_t OverlappingPair::getNbContactPoints() const {
|
||||||
|
return m_contactManifoldSet.getTotalNbContactPoints();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Return the contact manifold
|
||||||
|
const ContactManifoldSet& OverlappingPair::getContactManifoldSet() {
|
||||||
|
return m_contactManifoldSet;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Return the pair of bodies index
|
||||||
|
overlappingpairid OverlappingPair::computeID(ProxyShape* _shape1, ProxyShape* _shape2) {
|
||||||
|
assert( _shape1->m_broadPhaseID >= 0
|
||||||
|
&& _shape2->m_broadPhaseID >= 0);
|
||||||
|
|
||||||
|
// Construct the pair of body index
|
||||||
|
overlappingpairid pairID = _shape1->m_broadPhaseID < _shape2->m_broadPhaseID ?
|
||||||
|
std::make_pair(_shape1->m_broadPhaseID, _shape2->m_broadPhaseID) :
|
||||||
|
std::make_pair(_shape2->m_broadPhaseID, _shape1->m_broadPhaseID);
|
||||||
|
assert(pairID.first != pairID.second);
|
||||||
|
return pairID;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Return the pair of bodies index
|
||||||
|
bodyindexpair OverlappingPair::computeBodiesIndexPair(CollisionBody* _body1,
|
||||||
|
CollisionBody* _body2) {
|
||||||
|
|
||||||
|
// Construct the pair of body index
|
||||||
|
bodyindexpair indexPair = _body1->getID() < _body2->getID() ?
|
||||||
|
std::make_pair(_body1->getID(), _body2->getID()) :
|
||||||
|
std::make_pair(_body2->getID(), _body1->getID());
|
||||||
|
assert(indexPair.first != indexPair.second);
|
||||||
|
return indexPair;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Clear the contact points of the contact manifold
|
||||||
|
void OverlappingPair::clearContactPoints() {
|
||||||
|
m_contactManifoldSet.clear();
|
||||||
|
}
|
||||||
|
@ -159,8 +159,8 @@ def configure(target, my_module):
|
|||||||
'ememory'
|
'ememory'
|
||||||
])
|
])
|
||||||
# TODO: Remove this ...
|
# TODO: Remove this ...
|
||||||
my_module.add_flag('c++', "-Wno-overloaded-virtual", export=True)
|
#my_module.add_flag('c++', "-Wno-overloaded-virtual", export=True)
|
||||||
my_module.add_path(".")
|
#my_module.add_path(".")
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user