2017-08-01 14:30:58 +02:00
/*
Bullet Continuous Collision Detection and Physics Library
Copyright ( c ) 2003 - 2006 Erwin Coumans http : //continuousphysics.com/Bullet/
This software is provided ' as - is ' , without any express or implied warranty .
In no event will the authors be held liable for any damages arising from the use of this software .
Permission is granted to anyone to use this software for any purpose ,
including commercial applications , and to alter it and redistribute it freely ,
subject to the following restrictions :
1. The origin of this software must not be misrepresented ; you must not claim that you wrote the original software . If you use this software in a product , an acknowledgment in the product documentation would be appreciated but is not required .
2. Altered source versions must be plainly marked as such , and must not be misrepresented as being the original software .
3. This notice may not be removed or altered from any source distribution .
*/
# ifndef BT_COLLISION_OBJECT_H
# define BT_COLLISION_OBJECT_H
# include "LinearMath/btTransform.h"
//island management, m_activationState1
# define ACTIVE_TAG 1
# define ISLAND_SLEEPING 2
# define WANTS_DEACTIVATION 3
# define DISABLE_DEACTIVATION 4
# define DISABLE_SIMULATION 5
2019-01-03 14:26:51 +01:00
struct btBroadphaseProxy ;
class btCollisionShape ;
2017-08-01 14:30:58 +02:00
struct btCollisionShapeData ;
# include "LinearMath/btMotionState.h"
# include "LinearMath/btAlignedAllocator.h"
# include "LinearMath/btAlignedObjectArray.h"
typedef btAlignedObjectArray < class btCollisionObject * > btCollisionObjectArray ;
# ifdef BT_USE_DOUBLE_PRECISION
# define btCollisionObjectData btCollisionObjectDoubleData
# define btCollisionObjectDataName "btCollisionObjectDoubleData"
# else
# define btCollisionObjectData btCollisionObjectFloatData
# define btCollisionObjectDataName "btCollisionObjectFloatData"
# endif
2019-01-03 14:26:51 +01:00
/// btCollisionObject can be used to manage collision detection objects.
2017-08-01 14:30:58 +02:00
/// btCollisionObject maintains all information that is needed for a collision detection: Shape, Transform and AABB proxy.
/// They can be added to the btCollisionWorld.
2019-01-03 14:26:51 +01:00
ATTRIBUTE_ALIGNED16 ( class )
btCollisionObject
2017-08-01 14:30:58 +02:00
{
protected :
2019-01-03 14:26:51 +01:00
btTransform m_worldTransform ;
2017-08-01 14:30:58 +02:00
///m_interpolationWorldTransform is used for CCD and interpolation
///it can be either previous or future (predicted) transform
2019-01-03 14:26:51 +01:00
btTransform m_interpolationWorldTransform ;
//those two are experimental: just added for bullet time effect, so you can still apply impulses (directly modifying velocities)
2017-08-01 14:30:58 +02:00
//without destroying the continuous interpolated motion (which uses this interpolation velocities)
2019-01-03 14:26:51 +01:00
btVector3 m_interpolationLinearVelocity ;
btVector3 m_interpolationAngularVelocity ;
btVector3 m_anisotropicFriction ;
int m_hasAnisotropicFriction ;
btScalar m_contactProcessingThreshold ;
btBroadphaseProxy * m_broadphaseHandle ;
btCollisionShape * m_collisionShape ;
2017-08-01 14:30:58 +02:00
///m_extensionPointer is used by some internal low-level Bullet extensions.
2019-01-03 14:26:51 +01:00
void * m_extensionPointer ;
2017-08-01 14:30:58 +02:00
///m_rootCollisionShape is temporarily used to store the original collision shape
///The m_collisionShape might be temporarily replaced by a child collision shape during collision detection purposes
///If it is NULL, the m_collisionShape is not temporarily replaced.
2019-01-03 14:26:51 +01:00
btCollisionShape * m_rootCollisionShape ;
2017-08-01 14:30:58 +02:00
2019-01-03 14:26:51 +01:00
int m_collisionFlags ;
2017-08-01 14:30:58 +02:00
2019-01-03 14:26:51 +01:00
int m_islandTag1 ;
int m_companionId ;
int m_worldArrayIndex ; // index of object in world's collisionObjects array
2017-08-01 14:30:58 +02:00
2019-01-03 14:26:51 +01:00
mutable int m_activationState1 ;
mutable btScalar m_deactivationTime ;
2017-08-01 14:30:58 +02:00
2019-01-03 14:26:51 +01:00
btScalar m_friction ;
btScalar m_restitution ;
btScalar m_rollingFriction ; //torsional friction orthogonal to contact normal (useful to stop spheres rolling forever)
btScalar m_spinningFriction ; // torsional friction around the contact normal (useful for grasping)
btScalar m_contactDamping ;
btScalar m_contactStiffness ;
2017-08-01 14:30:58 +02:00
///m_internalType is reserved to distinguish Bullet's btCollisionObject, btRigidBody, btSoftBody, btGhostObject etc.
///do not assign your own m_internalType unless you write a new dynamics object class.
2019-01-03 14:26:51 +01:00
int m_internalType ;
2017-08-01 14:30:58 +02:00
///users can point to their objects, m_userPointer is not used by Bullet, see setUserPointer/getUserPointer
2019-01-03 14:26:51 +01:00
void * m_userObjectPointer ;
2017-08-01 14:30:58 +02:00
2019-01-03 14:26:51 +01:00
int m_userIndex2 ;
int m_userIndex ;
2017-08-01 14:30:58 +02:00
2019-06-11 13:18:05 +02:00
int m_userIndex3 ;
2017-08-01 14:30:58 +02:00
///time of impact calculation
2019-01-03 14:26:51 +01:00
btScalar m_hitFraction ;
2017-08-01 14:30:58 +02:00
///Swept sphere radius (0.0 by default), see btConvexConvexAlgorithm::
2019-01-03 14:26:51 +01:00
btScalar m_ccdSweptSphereRadius ;
2017-08-01 14:30:58 +02:00
/// Don't do continuous collision detection if the motion (in one step) is less then m_ccdMotionThreshold
2019-01-03 14:26:51 +01:00
btScalar m_ccdMotionThreshold ;
2017-08-01 14:30:58 +02:00
/// If some object should have elaborate collision filtering by sub-classes
2019-01-03 14:26:51 +01:00
int m_checkCollideWith ;
2017-08-01 14:30:58 +02:00
btAlignedObjectArray < const btCollisionObject * > m_objectsWithoutCollisionCheck ;
///internal update revision number. It will be increased when the object changes. This allows some subsystems to perform lazy evaluation.
2019-01-03 14:26:51 +01:00
int m_updateRevision ;
2017-08-01 14:30:58 +02:00
2019-01-03 14:26:51 +01:00
btVector3 m_customDebugColorRGB ;
2017-08-01 14:30:58 +02:00
public :
BT_DECLARE_ALIGNED_ALLOCATOR ( ) ;
enum CollisionFlags
{
2020-12-17 13:51:12 +01:00
CF_DYNAMIC_OBJECT = 0 ,
2019-01-03 14:26:51 +01:00
CF_STATIC_OBJECT = 1 ,
CF_KINEMATIC_OBJECT = 2 ,
2017-08-01 14:30:58 +02:00
CF_NO_CONTACT_RESPONSE = 4 ,
2019-01-03 14:26:51 +01:00
CF_CUSTOM_MATERIAL_CALLBACK = 8 , //this allows per-triangle material (friction/restitution)
2017-08-01 14:30:58 +02:00
CF_CHARACTER_OBJECT = 16 ,
2019-01-03 14:26:51 +01:00
CF_DISABLE_VISUALIZE_OBJECT = 32 , //disable debug drawing
CF_DISABLE_SPU_COLLISION_PROCESSING = 64 , //disable parallel/SPU processing
2017-08-01 14:30:58 +02:00
CF_HAS_CONTACT_STIFFNESS_DAMPING = 128 ,
CF_HAS_CUSTOM_DEBUG_RENDERING_COLOR = 256 ,
CF_HAS_FRICTION_ANCHOR = 512 ,
CF_HAS_COLLISION_SOUND_TRIGGER = 1024
} ;
2019-01-03 14:26:51 +01:00
enum CollisionObjectTypes
2017-08-01 14:30:58 +02:00
{
2019-01-03 14:26:51 +01:00
CO_COLLISION_OBJECT = 1 ,
CO_RIGID_BODY = 2 ,
2017-08-01 14:30:58 +02:00
///CO_GHOST_OBJECT keeps track of all objects overlapping its AABB and that pass its collision filter
///It is useful for collision sensors, explosion objects, character controller etc.
2019-01-03 14:26:51 +01:00
CO_GHOST_OBJECT = 4 ,
CO_SOFT_BODY = 8 ,
CO_HF_FLUID = 16 ,
CO_USER_TYPE = 32 ,
CO_FEATHERSTONE_LINK = 64
2017-08-01 14:30:58 +02:00
} ;
enum AnisotropicFrictionFlags
{
2019-01-03 14:26:51 +01:00
CF_ANISOTROPIC_FRICTION_DISABLED = 0 ,
2017-08-01 14:30:58 +02:00
CF_ANISOTROPIC_FRICTION = 1 ,
CF_ANISOTROPIC_ROLLING_FRICTION = 2
} ;
SIMD_FORCE_INLINE bool mergesSimulationIslands ( ) const
{
///static objects, kinematic and object without contact response don't merge islands
2019-01-03 14:26:51 +01:00
return ( ( m_collisionFlags & ( CF_STATIC_OBJECT | CF_KINEMATIC_OBJECT | CF_NO_CONTACT_RESPONSE ) ) = = 0 ) ;
2017-08-01 14:30:58 +02:00
}
const btVector3 & getAnisotropicFriction ( ) const
{
return m_anisotropicFriction ;
}
2019-01-03 14:26:51 +01:00
void setAnisotropicFriction ( const btVector3 & anisotropicFriction , int frictionMode = CF_ANISOTROPIC_FRICTION )
2017-08-01 14:30:58 +02:00
{
m_anisotropicFriction = anisotropicFriction ;
2019-01-03 14:26:51 +01:00
bool isUnity = ( anisotropicFriction [ 0 ] ! = 1.f ) | | ( anisotropicFriction [ 1 ] ! = 1.f ) | | ( anisotropicFriction [ 2 ] ! = 1.f ) ;
m_hasAnisotropicFriction = isUnity ? frictionMode : 0 ;
2017-08-01 14:30:58 +02:00
}
2019-01-03 14:26:51 +01:00
bool hasAnisotropicFriction ( int frictionMode = CF_ANISOTROPIC_FRICTION ) const
2017-08-01 14:30:58 +02:00
{
2019-01-03 14:26:51 +01:00
return ( m_hasAnisotropicFriction & frictionMode ) ! = 0 ;
2017-08-01 14:30:58 +02:00
}
///the constraint solver can discard solving contacts, if the distance is above this threshold. 0 by default.
///Note that using contacts with positive distance can improve stability. It increases, however, the chance of colliding with degerate contacts, such as 'interior' triangle edges
2019-01-03 14:26:51 +01:00
void setContactProcessingThreshold ( btScalar contactProcessingThreshold )
2017-08-01 14:30:58 +02:00
{
m_contactProcessingThreshold = contactProcessingThreshold ;
}
2019-01-03 14:26:51 +01:00
btScalar getContactProcessingThreshold ( ) const
2017-08-01 14:30:58 +02:00
{
return m_contactProcessingThreshold ;
}
2019-01-03 14:26:51 +01:00
SIMD_FORCE_INLINE bool isStaticObject ( ) const
{
2017-08-01 14:30:58 +02:00
return ( m_collisionFlags & CF_STATIC_OBJECT ) ! = 0 ;
}
2019-01-03 14:26:51 +01:00
SIMD_FORCE_INLINE bool isKinematicObject ( ) const
2017-08-01 14:30:58 +02:00
{
return ( m_collisionFlags & CF_KINEMATIC_OBJECT ) ! = 0 ;
}
2019-01-03 14:26:51 +01:00
SIMD_FORCE_INLINE bool isStaticOrKinematicObject ( ) const
2017-08-01 14:30:58 +02:00
{
2019-01-03 14:26:51 +01:00
return ( m_collisionFlags & ( CF_KINEMATIC_OBJECT | CF_STATIC_OBJECT ) ) ! = 0 ;
2017-08-01 14:30:58 +02:00
}
2019-01-03 14:26:51 +01:00
SIMD_FORCE_INLINE bool hasContactResponse ( ) const
{
return ( m_collisionFlags & CF_NO_CONTACT_RESPONSE ) = = 0 ;
2017-08-01 14:30:58 +02:00
}
btCollisionObject ( ) ;
virtual ~ btCollisionObject ( ) ;
2019-01-03 14:26:51 +01:00
virtual void setCollisionShape ( btCollisionShape * collisionShape )
2017-08-01 14:30:58 +02:00
{
m_updateRevision + + ;
m_collisionShape = collisionShape ;
m_rootCollisionShape = collisionShape ;
}
2019-01-03 14:26:51 +01:00
SIMD_FORCE_INLINE const btCollisionShape * getCollisionShape ( ) const
2017-08-01 14:30:58 +02:00
{
return m_collisionShape ;
}
2019-01-03 14:26:51 +01:00
SIMD_FORCE_INLINE btCollisionShape * getCollisionShape ( )
2017-08-01 14:30:58 +02:00
{
return m_collisionShape ;
}
2019-01-03 14:26:51 +01:00
void setIgnoreCollisionCheck ( const btCollisionObject * co , bool ignoreCollisionCheck )
2017-08-01 14:30:58 +02:00
{
if ( ignoreCollisionCheck )
{
//We don't check for duplicates. Is it ok to leave that up to the user of this API?
//int index = m_objectsWithoutCollisionCheck.findLinearSearch(co);
//if (index == m_objectsWithoutCollisionCheck.size())
//{
m_objectsWithoutCollisionCheck . push_back ( co ) ;
//}
}
else
{
m_objectsWithoutCollisionCheck . remove ( co ) ;
}
m_checkCollideWith = m_objectsWithoutCollisionCheck . size ( ) > 0 ;
}
2020-12-17 13:51:12 +01:00
int getNumObjectsWithoutCollision ( ) const
{
return m_objectsWithoutCollisionCheck . size ( ) ;
}
const btCollisionObject * getObjectWithoutCollision ( int index )
{
return m_objectsWithoutCollisionCheck [ index ] ;
}
2019-01-03 14:26:51 +01:00
virtual bool checkCollideWithOverride ( const btCollisionObject * co ) const
2017-08-01 14:30:58 +02:00
{
int index = m_objectsWithoutCollisionCheck . findLinearSearch ( co ) ;
if ( index < m_objectsWithoutCollisionCheck . size ( ) )
{
return false ;
}
return true ;
}
2019-01-03 14:26:51 +01:00
///Avoid using this internal API call, the extension pointer is used by some Bullet extensions.
2017-08-01 14:30:58 +02:00
///If you need to store your own user pointer, use 'setUserPointer/getUserPointer' instead.
2019-01-03 14:26:51 +01:00
void * internalGetExtensionPointer ( ) const
2017-08-01 14:30:58 +02:00
{
return m_extensionPointer ;
}
///Avoid using this internal API call, the extension pointer is used by some Bullet extensions
///If you need to store your own user pointer, use 'setUserPointer/getUserPointer' instead.
2019-01-03 14:26:51 +01:00
void internalSetExtensionPointer ( void * pointer )
2017-08-01 14:30:58 +02:00
{
m_extensionPointer = pointer ;
}
2019-01-03 14:26:51 +01:00
SIMD_FORCE_INLINE int getActivationState ( ) const { return m_activationState1 ; }
2017-08-01 14:30:58 +02:00
void setActivationState ( int newState ) const ;
2019-01-03 14:26:51 +01:00
void setDeactivationTime ( btScalar time )
2017-08-01 14:30:58 +02:00
{
m_deactivationTime = time ;
}
2019-01-03 14:26:51 +01:00
btScalar getDeactivationTime ( ) const
2017-08-01 14:30:58 +02:00
{
return m_deactivationTime ;
}
void forceActivationState ( int newState ) const ;
2019-01-03 14:26:51 +01:00
void activate ( bool forceActivation = false ) const ;
2017-08-01 14:30:58 +02:00
SIMD_FORCE_INLINE bool isActive ( ) const
{
return ( ( getActivationState ( ) ! = ISLAND_SLEEPING ) & & ( getActivationState ( ) ! = DISABLE_SIMULATION ) ) ;
}
2019-01-03 14:26:51 +01:00
void setRestitution ( btScalar rest )
2017-08-01 14:30:58 +02:00
{
m_updateRevision + + ;
m_restitution = rest ;
}
2019-01-03 14:26:51 +01:00
btScalar getRestitution ( ) const
2017-08-01 14:30:58 +02:00
{
return m_restitution ;
}
2019-01-03 14:26:51 +01:00
void setFriction ( btScalar frict )
2017-08-01 14:30:58 +02:00
{
m_updateRevision + + ;
m_friction = frict ;
}
2019-01-03 14:26:51 +01:00
btScalar getFriction ( ) const
2017-08-01 14:30:58 +02:00
{
return m_friction ;
}
2019-01-03 14:26:51 +01:00
void setRollingFriction ( btScalar frict )
2017-08-01 14:30:58 +02:00
{
m_updateRevision + + ;
m_rollingFriction = frict ;
}
2019-01-03 14:26:51 +01:00
btScalar getRollingFriction ( ) const
2017-08-01 14:30:58 +02:00
{
return m_rollingFriction ;
}
2019-01-03 14:26:51 +01:00
void setSpinningFriction ( btScalar frict )
{
m_updateRevision + + ;
m_spinningFriction = frict ;
}
btScalar getSpinningFriction ( ) const
{
return m_spinningFriction ;
}
void setContactStiffnessAndDamping ( btScalar stiffness , btScalar damping )
2017-08-01 14:30:58 +02:00
{
m_updateRevision + + ;
m_contactStiffness = stiffness ;
m_contactDamping = damping ;
2019-01-03 14:26:51 +01:00
m_collisionFlags | = CF_HAS_CONTACT_STIFFNESS_DAMPING ;
//avoid divisions by zero...
if ( m_contactStiffness < SIMD_EPSILON )
{
m_contactStiffness = SIMD_EPSILON ;
}
}
btScalar getContactStiffness ( ) const
2017-08-01 14:30:58 +02:00
{
return m_contactStiffness ;
}
2019-01-03 14:26:51 +01:00
btScalar getContactDamping ( ) const
2017-08-01 14:30:58 +02:00
{
return m_contactDamping ;
}
2019-01-03 14:26:51 +01:00
2017-08-01 14:30:58 +02:00
///reserved for Bullet internal usage
2019-01-03 14:26:51 +01:00
int getInternalType ( ) const
2017-08-01 14:30:58 +02:00
{
return m_internalType ;
}
2019-01-03 14:26:51 +01:00
btTransform & getWorldTransform ( )
2017-08-01 14:30:58 +02:00
{
return m_worldTransform ;
}
2019-01-03 14:26:51 +01:00
const btTransform & getWorldTransform ( ) const
2017-08-01 14:30:58 +02:00
{
return m_worldTransform ;
}
2019-01-03 14:26:51 +01:00
void setWorldTransform ( const btTransform & worldTrans )
2017-08-01 14:30:58 +02:00
{
m_updateRevision + + ;
m_worldTransform = worldTrans ;
}
2019-01-03 14:26:51 +01:00
SIMD_FORCE_INLINE btBroadphaseProxy * getBroadphaseHandle ( )
2017-08-01 14:30:58 +02:00
{
return m_broadphaseHandle ;
}
2019-01-03 14:26:51 +01:00
SIMD_FORCE_INLINE const btBroadphaseProxy * getBroadphaseHandle ( ) const
2017-08-01 14:30:58 +02:00
{
return m_broadphaseHandle ;
}
2019-01-03 14:26:51 +01:00
void setBroadphaseHandle ( btBroadphaseProxy * handle )
2017-08-01 14:30:58 +02:00
{
m_broadphaseHandle = handle ;
}
2019-01-03 14:26:51 +01:00
const btTransform & getInterpolationWorldTransform ( ) const
2017-08-01 14:30:58 +02:00
{
return m_interpolationWorldTransform ;
}
2019-01-03 14:26:51 +01:00
btTransform & getInterpolationWorldTransform ( )
2017-08-01 14:30:58 +02:00
{
return m_interpolationWorldTransform ;
}
2019-01-03 14:26:51 +01:00
void setInterpolationWorldTransform ( const btTransform & trans )
2017-08-01 14:30:58 +02:00
{
m_updateRevision + + ;
m_interpolationWorldTransform = trans ;
}
2019-01-03 14:26:51 +01:00
void setInterpolationLinearVelocity ( const btVector3 & linvel )
2017-08-01 14:30:58 +02:00
{
m_updateRevision + + ;
m_interpolationLinearVelocity = linvel ;
}
2019-01-03 14:26:51 +01:00
void setInterpolationAngularVelocity ( const btVector3 & angvel )
2017-08-01 14:30:58 +02:00
{
m_updateRevision + + ;
m_interpolationAngularVelocity = angvel ;
}
2019-01-03 14:26:51 +01:00
const btVector3 & getInterpolationLinearVelocity ( ) const
2017-08-01 14:30:58 +02:00
{
return m_interpolationLinearVelocity ;
}
2019-01-03 14:26:51 +01:00
const btVector3 & getInterpolationAngularVelocity ( ) const
2017-08-01 14:30:58 +02:00
{
return m_interpolationAngularVelocity ;
}
SIMD_FORCE_INLINE int getIslandTag ( ) const
{
2019-01-03 14:26:51 +01:00
return m_islandTag1 ;
2017-08-01 14:30:58 +02:00
}
2019-01-03 14:26:51 +01:00
void setIslandTag ( int tag )
2017-08-01 14:30:58 +02:00
{
m_islandTag1 = tag ;
}
SIMD_FORCE_INLINE int getCompanionId ( ) const
{
2019-01-03 14:26:51 +01:00
return m_companionId ;
2017-08-01 14:30:58 +02:00
}
2019-01-03 14:26:51 +01:00
void setCompanionId ( int id )
2017-08-01 14:30:58 +02:00
{
m_companionId = id ;
}
2019-01-03 14:26:51 +01:00
SIMD_FORCE_INLINE int getWorldArrayIndex ( ) const
{
return m_worldArrayIndex ;
}
2017-08-01 14:30:58 +02:00
2019-01-03 14:26:51 +01:00
// only should be called by CollisionWorld
void setWorldArrayIndex ( int ix )
{
m_worldArrayIndex = ix ;
}
2017-08-01 14:30:58 +02:00
2019-01-03 14:26:51 +01:00
SIMD_FORCE_INLINE btScalar getHitFraction ( ) const
2017-08-01 14:30:58 +02:00
{
2019-01-03 14:26:51 +01:00
return m_hitFraction ;
2017-08-01 14:30:58 +02:00
}
2019-01-03 14:26:51 +01:00
void setHitFraction ( btScalar hitFraction )
2017-08-01 14:30:58 +02:00
{
m_hitFraction = hitFraction ;
}
2019-01-03 14:26:51 +01:00
SIMD_FORCE_INLINE int getCollisionFlags ( ) const
2017-08-01 14:30:58 +02:00
{
return m_collisionFlags ;
}
2019-01-03 14:26:51 +01:00
void setCollisionFlags ( int flags )
2017-08-01 14:30:58 +02:00
{
m_collisionFlags = flags ;
}
2019-01-03 14:26:51 +01:00
2017-08-01 14:30:58 +02:00
///Swept sphere radius (0.0 by default), see btConvexConvexAlgorithm::
2019-01-03 14:26:51 +01:00
btScalar getCcdSweptSphereRadius ( ) const
2017-08-01 14:30:58 +02:00
{
return m_ccdSweptSphereRadius ;
}
///Swept sphere radius (0.0 by default), see btConvexConvexAlgorithm::
2019-01-03 14:26:51 +01:00
void setCcdSweptSphereRadius ( btScalar radius )
2017-08-01 14:30:58 +02:00
{
m_ccdSweptSphereRadius = radius ;
}
2019-01-03 14:26:51 +01:00
btScalar getCcdMotionThreshold ( ) const
2017-08-01 14:30:58 +02:00
{
return m_ccdMotionThreshold ;
}
2019-01-03 14:26:51 +01:00
btScalar getCcdSquareMotionThreshold ( ) const
2017-08-01 14:30:58 +02:00
{
2019-01-03 14:26:51 +01:00
return m_ccdMotionThreshold * m_ccdMotionThreshold ;
2017-08-01 14:30:58 +02:00
}
/// Don't do continuous collision detection if the motion (in one step) is less then m_ccdMotionThreshold
2019-01-03 14:26:51 +01:00
void setCcdMotionThreshold ( btScalar ccdMotionThreshold )
2017-08-01 14:30:58 +02:00
{
m_ccdMotionThreshold = ccdMotionThreshold ;
}
///users can point to their objects, userPointer is not used by Bullet
2019-01-03 14:26:51 +01:00
void * getUserPointer ( ) const
2017-08-01 14:30:58 +02:00
{
return m_userObjectPointer ;
}
2019-01-03 14:26:51 +01:00
int getUserIndex ( ) const
2017-08-01 14:30:58 +02:00
{
return m_userIndex ;
}
2019-01-03 14:26:51 +01:00
int getUserIndex2 ( ) const
2017-08-01 14:30:58 +02:00
{
return m_userIndex2 ;
}
2019-01-03 14:26:51 +01:00
2019-06-11 13:18:05 +02:00
int getUserIndex3 ( ) const
{
return m_userIndex3 ;
}
2017-08-01 14:30:58 +02:00
///users can point to their objects, userPointer is not used by Bullet
2019-01-03 14:26:51 +01:00
void setUserPointer ( void * userPointer )
2017-08-01 14:30:58 +02:00
{
m_userObjectPointer = userPointer ;
}
///users can point to their objects, userPointer is not used by Bullet
2019-01-03 14:26:51 +01:00
void setUserIndex ( int index )
2017-08-01 14:30:58 +02:00
{
m_userIndex = index ;
}
2019-01-03 14:26:51 +01:00
void setUserIndex2 ( int index )
2017-08-01 14:30:58 +02:00
{
m_userIndex2 = index ;
}
2019-06-11 13:18:05 +02:00
void setUserIndex3 ( int index )
{
m_userIndex3 = index ;
}
2019-01-03 14:26:51 +01:00
int getUpdateRevisionInternal ( ) const
2017-08-01 14:30:58 +02:00
{
return m_updateRevision ;
}
2019-01-03 14:26:51 +01:00
void setCustomDebugColor ( const btVector3 & colorRGB )
2017-08-01 14:30:58 +02:00
{
m_customDebugColorRGB = colorRGB ;
m_collisionFlags | = CF_HAS_CUSTOM_DEBUG_RENDERING_COLOR ;
}
2019-01-03 14:26:51 +01:00
void removeCustomDebugColor ( )
2017-08-01 14:30:58 +02:00
{
m_collisionFlags & = ~ CF_HAS_CUSTOM_DEBUG_RENDERING_COLOR ;
}
2019-01-03 14:26:51 +01:00
bool getCustomDebugColor ( btVector3 & colorRGB ) const
2017-08-01 14:30:58 +02:00
{
2019-01-03 14:26:51 +01:00
bool hasCustomColor = ( 0 ! = ( m_collisionFlags & CF_HAS_CUSTOM_DEBUG_RENDERING_COLOR ) ) ;
2017-08-01 14:30:58 +02:00
if ( hasCustomColor )
{
colorRGB = m_customDebugColorRGB ;
}
return hasCustomColor ;
}
inline bool checkCollideWith ( const btCollisionObject * co ) const
{
if ( m_checkCollideWith )
return checkCollideWithOverride ( co ) ;
return true ;
}
2019-01-03 14:26:51 +01:00
virtual int calculateSerializeBufferSize ( ) const ;
2017-08-01 14:30:58 +02:00
///fills the dataBuffer and returns the struct name (and 0 on failure)
2019-01-03 14:26:51 +01:00
virtual const char * serialize ( void * dataBuffer , class btSerializer * serializer ) const ;
2017-08-01 14:30:58 +02:00
2019-01-03 14:26:51 +01:00
virtual void serializeSingleObject ( class btSerializer * serializer ) const ;
2017-08-01 14:30:58 +02:00
} ;
2019-01-03 14:26:51 +01:00
// clang-format off
2017-08-01 14:30:58 +02:00
///do not change those serialization structures, it requires an updated sBulletDNAstr/sBulletDNAstr64
struct btCollisionObjectDoubleData
{
void * m_broadphaseHandle ;
void * m_collisionShape ;
btCollisionShapeData * m_rootCollisionShape ;
char * m_name ;
btTransformDoubleData m_worldTransform ;
btTransformDoubleData m_interpolationWorldTransform ;
btVector3DoubleData m_interpolationLinearVelocity ;
btVector3DoubleData m_interpolationAngularVelocity ;
btVector3DoubleData m_anisotropicFriction ;
double m_contactProcessingThreshold ;
double m_deactivationTime ;
double m_friction ;
double m_rollingFriction ;
double m_contactDamping ;
double m_contactStiffness ;
double m_restitution ;
double m_hitFraction ;
double m_ccdSweptSphereRadius ;
double m_ccdMotionThreshold ;
int m_hasAnisotropicFriction ;
int m_collisionFlags ;
int m_islandTag1 ;
int m_companionId ;
int m_activationState1 ;
int m_internalType ;
int m_checkCollideWith ;
2018-09-07 16:11:04 +02:00
int m_collisionFilterGroup ;
int m_collisionFilterMask ;
int m_uniqueId ; //m_uniqueId is introduced for paircache. could get rid of this, by calculating the address offset etc.
2017-08-01 14:30:58 +02:00
} ;
///do not change those serialization structures, it requires an updated sBulletDNAstr/sBulletDNAstr64
struct btCollisionObjectFloatData
{
void * m_broadphaseHandle ;
void * m_collisionShape ;
btCollisionShapeData * m_rootCollisionShape ;
char * m_name ;
btTransformFloatData m_worldTransform ;
btTransformFloatData m_interpolationWorldTransform ;
btVector3FloatData m_interpolationLinearVelocity ;
btVector3FloatData m_interpolationAngularVelocity ;
btVector3FloatData m_anisotropicFriction ;
float m_contactProcessingThreshold ;
float m_deactivationTime ;
float m_friction ;
float m_rollingFriction ;
2018-09-07 16:11:04 +02:00
float m_contactDamping ;
2017-08-01 14:30:58 +02:00
float m_contactStiffness ;
float m_restitution ;
float m_hitFraction ;
float m_ccdSweptSphereRadius ;
float m_ccdMotionThreshold ;
int m_hasAnisotropicFriction ;
int m_collisionFlags ;
int m_islandTag1 ;
int m_companionId ;
int m_activationState1 ;
int m_internalType ;
int m_checkCollideWith ;
2018-09-07 16:11:04 +02:00
int m_collisionFilterGroup ;
int m_collisionFilterMask ;
int m_uniqueId ;
2017-08-01 14:30:58 +02:00
} ;
2019-01-03 14:26:51 +01:00
// clang-format on
2017-08-01 14:30:58 +02:00
2019-01-03 14:26:51 +01:00
SIMD_FORCE_INLINE int btCollisionObject : : calculateSerializeBufferSize ( ) const
2017-08-01 14:30:58 +02:00
{
return sizeof ( btCollisionObjectData ) ;
}
2019-01-03 14:26:51 +01:00
# endif //BT_COLLISION_OBJECT_H