/** @file * Original ReactPhysics3D C++ library by Daniel Chappuis This code is re-licensed with permission from ReactPhysics3D author. * @author Daniel CHAPPUIS * @author Edouard DUPIN * @copyright 2010-2016, Daniel Chappuis * @copyright 2017, Edouard DUPIN * @license MPL v2.0 (see license file) */ #pragma once #include #include namespace ephysics { /** * @breif The CollisionShape instances are supposed to be unique for memory optimization. For instance, * consider two rigid bodies with the same sphere collision shape. In this situation, we will have * a unique instance of SphereShape but we need to differentiate between the two instances during * the collision detection. They do not have the same position in the world and they do not * belong to the same rigid body. The ProxyShape class is used for that purpose by attaching a * rigid body with one of its collision shape. A body can have multiple proxy shapes (one for * each collision shape attached to the body). */ class ProxyShape { protected: CollisionBody* this.body; //!< Pointer to the parent body CollisionShape* this.collisionShape; //!< Internal collision shape etk::Transform3D this.localToBodyTransform; //!< Local-space to parent body-space transform (does not change over time) float this.mass; //!< Mass (in kilogramms) of the corresponding collision shape ProxyShape* this.next; //!< Pointer to the next proxy shape of the body (linked list) int this.broadPhaseID; //!< Broad-phase ID (node ID in the dynamic AABB tree) void* this.cachedCollisionData; //!< Cached collision data void* this.userData; //!< Pointer to user data /** * @brief Bits used to define the collision category of this shape. * You can set a single bit to one to define a category value for this * shape. This value is one (0x0001) by default. This variable can be used * together with the this.collideWithMaskBits variable so that given * categories of shapes collide with each other and do not collide with * other categories. */ unsigned short this.collisionCategoryBits; /** * @brief Bits mask used to state which collision categories this shape can * collide with. This value is 0xFFFF by default. It means that this * proxy shape will collide with every collision categories by default. */ unsigned short this.collideWithMaskBits; /// Private copy-ructor ProxyShape( ProxyShape) = delete; /// Private assignment operator ProxyShape operator=( ProxyShape) = delete; public: /// Constructor ProxyShape(CollisionBody* body, CollisionShape* shape, etk::Transform3D transform, float mass); /// Destructor virtual ~ProxyShape(); /// Return the collision shape CollisionShape* getCollisionShape() ; /// Return the parent body CollisionBody* getBody() ; /// Return the mass of the collision shape float getMass() ; /// Return a pointer to the user data attached to this body void* getUserData() ; /// Attach user data to this body void setUserData(void* userData); /// Return the local to parent body transform etk::Transform3D getLocalToBodyTransform() ; /// Set the local to parent body transform void setLocalToBodyTransform( etk::Transform3D transform); /// Return the local to world transform etk::Transform3D getLocalToWorldTransform() ; /// Return true if a point is inside the collision shape boolean testPointInside( vec3 worldPoint); /// Raycast method with feedback information boolean raycast( Ray ray, RaycastInfo raycastInfo); /// Return the collision bits mask unsigned short getCollideWithMaskBits() ; /// Set the collision bits mask void setCollideWithMaskBits(unsigned short collideWithMaskBits); /// Return the collision category bits unsigned short getCollisionCategoryBits() ; /// Set the collision category bits void setCollisionCategoryBits(unsigned short collisionCategoryBits); /// Return the next proxy shape in the linked list of proxy shapes ProxyShape* getNext(); /// Return the next proxy shape in the linked list of proxy shapes ProxyShape* getNext() ; /// Return the pointer to the cached collision data void** getCachedCollisionData(); /// Return the local scaling vector of the collision shape vec3 getLocalScaling() ; /// Set the local scaling vector of the collision shape virtual void setLocalScaling( vec3 scaling); friend class OverlappingPair; friend class CollisionBody; friend class RigidBody; friend class BroadPhaseAlgorithm; friend class DynamicAABBTree; friend class CollisionDetection; friend class CollisionWorld; friend class DynamicsWorld; friend class EPAAlgorithm; friend class GJKAlgorithm; friend class ConvexMeshShape; }; }