55 int firstHit=startHit;
76 int rIslandId0,lIslandId0;
79 return lIslandId0 < rIslandId0;
141 int numCurConstraints = 0;
168 for (i=0;i<numBodies;i++)
170 for (i=0;i<numManifolds;i++)
172 for (i=0;i<numCurConstraints;i++)
204 m_sortedConstraints (),
205 m_solverIslandCallback ( NULL ),
206 m_constraintSolver(constraintSolver),
209 m_synchronizeAllMotionStates(false),
210 m_applySpeculativeContactRestitution(false),
213 m_latencyMotionStateInterpolation(true)
288 bool drawConstraints =
false;
294 drawConstraints =
true;
364 interpolatedTransform);
403 int numSimulationSubSteps = 0;
412 numSimulationSubSteps = int(
m_localTime / fixedTimeStep);
413 m_localTime -= numSimulationSubSteps * fixedTimeStep;
418 fixedTimeStep = timeStep;
423 numSimulationSubSteps = 0;
427 numSimulationSubSteps = 1;
438 if (numSimulationSubSteps)
442 int clampedSimulationSteps = (numSimulationSubSteps > maxSubSteps)? maxSubSteps : numSimulationSubSteps;
450 for (
int i=0;i<clampedSimulationSteps;i++)
463 #ifndef BT_NO_PROFILE
465 #endif //BT_NO_PROFILE
467 return numSimulationSubSteps;
476 (*m_internalPreTickCallback)(
this, timeStep);
516 (*m_internalTickCallback)(
this, timeStep);
612 m_actions[i]->updateAction(
this, timeStep);
656 if (disableCollisionsBetweenLinkedBodies)
750 if (((colObj0) && (!(colObj0)->isStaticOrKinematicObject())) &&
751 ((colObj1) && (!(colObj1)->isStaticOrKinematicObject())))
761 for (i=0;i< numConstraints ; i++ )
769 if (((colObj0) && (!(colObj0)->isStaticOrKinematicObject())) &&
770 ((colObj1) && (!(colObj1)->isStaticOrKinematicObject())))
819 btVector3 relativeVelocity = (linVelA-linVelB);
824 return ClosestConvexResultCallback::addSingleResult (convexResult, normalInWorldSpace);
834 if (!ClosestConvexResultCallback::needsCollision(proxy0))
852 for (
int j=0;j<manifoldArray.
size();j++)
879 BT_PROFILE(
"release predictive contact manifolds");
908 #ifdef PREDICTIVE_CONTACT_USE_STATIC_ONLY
937 btTransform modifiedPredictedTrans = predictedTrans;
941 if (sweepResults.hasHit() && (sweepResults.m_closestHitFraction < 1.f))
945 btScalar distance = distVec.
dot(-sweepResults.m_hitNormalWorld);
952 btVector3 localPointB = sweepResults.m_hitCollisionObject->getWorldTransform().inverse()*worldPointB;
956 bool isPredictive =
true;
994 #ifdef USE_STATIC_ONLY
1023 btTransform modifiedPredictedTrans = predictedTrans;
1027 if (sweepResults.hasHit() && (sweepResults.m_closestHitFraction < 1.f))
1040 btScalar maxSpeedSqr = maxSpeed*maxSpeed;
1041 if (linVel.
length2()>maxSpeedSqr)
1051 printf(
"sm2=%f\n",sm2);
1079 BT_PROFILE(
"apply speculative contact restitution");
1100 btVector3 rel_pos1 = pos2 - body1->getWorldTransform().getOrigin();
1105 body1->applyImpulse(-imp,rel_pos1);
1140 #ifndef BT_NO_PROFILE
1142 #endif //BT_NO_PROFILE
1188 if(minAng == maxAng)
1192 bool drawSect =
true;
1204 getDebugDrawer()->
drawArc(center, normal, axis, dbgDrawSize, dbgDrawSize, minAng, maxAng,
btVector3(0,0,0), drawSect);
1219 static int nSegments = 8*4;
1223 for (
int i=0; i<nSegments; i++)
1230 if (i%(nSegments/8) == 0)
1249 getDebugDrawer()->
drawArc(pivot, normal, axis1, dbgDrawSize, dbgDrawSize, -twa-tws, -twa+tws,
btVector3(0,0,0),
true);
1272 getDebugDrawer()->
drawSpherePatch(center, up, axis, dbgDrawSize *
btScalar(.9f), minTh, maxTh, minPs, maxPs,
btVector3(0,0,0));
1281 ref[0] = cy*cz*axis[0] + cy*sz*axis[1] - sy*axis[2];
1282 ref[1] = -sz*axis[0] + cz*axis[1];
1283 ref[2] = cz*sy*axis[0] + sz*sy*axis[1] + cy*axis[2];
1290 getDebugDrawer()->
drawArc(center, normal, ref, dbgDrawSize, dbgDrawSize, -
SIMD_PI,
SIMD_PI,
btVector3(0,0,0),
false);
1292 else if(minFi < maxFi)
1294 getDebugDrawer()->
drawArc(center, normal, ref, dbgDrawSize, dbgDrawSize, minFi, maxFi,
btVector3(0,0,0),
true);
1321 getDebugDrawer()->
drawArc(center, normal, axis, dbgDrawSize, dbgDrawSize, a_min, a_max,
btVector3(0,0,0),
true);
1398 #ifdef BT_USE_DOUBLE_PRECISION
1408 memset(worldInfo ,0x00,len);
1438 #ifdef BT_USE_DOUBLE_PRECISION
1439 const char* structType =
"btDynamicsWorldDoubleData";
1440 #else//BT_USE_DOUBLE_PRECISION
1441 const char* structType =
"btDynamicsWorldFloatData";
1442 #endif//BT_USE_DOUBLE_PRECISION
btScalar getInvMass() const
virtual void setConstraintSolver(btConstraintSolver *solver)
const btCollisionShape * getCollisionShape() const
virtual void internalSingleStepSimulation(btScalar timeStep)
virtual void finishSerialization()=0
static const btRigidBody * upcast(const btCollisionObject *colObj)
to keep collision detection and dynamics separate we don't store a rigidbody pointer but a rigidbody ...
void serializeDynamicsWorldInfo(btSerializer *serializer)
void startProfiling(btScalar timeStep)
btContactSolverInfo * m_solverInfo
virtual void releaseManifold(btPersistentManifold *manifold)=0
btScalar getCcdMotionThreshold() const
virtual void clearForces()
the forces on each rigidbody is accumulating together with gravity. clear this after each timestep...
const btTransform & getAFrame() const
void serializeCollisionObjects(btSerializer *serializer)
btScalar length(const btQuaternion &q)
Return the length of a quaternion.
btOverlappingPairCache * m_pairCache
btPersistentManifold is a contact point cache, it stays persistent as long as objects are overlapping...
void setup(btContactSolverInfo *solverInfo, btTypedConstraint **sortedConstraints, int numConstraints, btIDebugDraw *debugDrawer)
void push_back(const T &_Val)
const btTransform & getCalculatedTransformA() const
virtual void addAction(btActionInterface *)
virtual void solveConstraints(btContactSolverInfo &solverInfo)
point to point constraint between two rigidbodies each with a pivotpoint that descibes the 'ballsocke...
btTypedConstraintType getConstraintType() const
const btTransform & getCalculatedTransformB() const
virtual void addConstraint(btTypedConstraint *constraint, bool disableCollisionsBetweenLinkedBodies=false)
btScalar getCcdSweptSphereRadius() const
Swept sphere radius (0.0 by default), see btConvexConvexAlgorithm::
virtual void removeVehicle(btActionInterface *vehicle)
obsolete, use removeAction instead
virtual btVector3 getGravity() const
int btGetConstraintIslandId(const btTypedConstraint *lhs)
btIDebugDraw * m_debugDrawer
#define BT_CONSTRAINT_CODE
btSimulationIslandManager * m_islandManager
const btTransform & getCalculatedTransformA() const
Gets the global transform of the offset for body A.
btAlignedObjectArray< btRigidBody * > m_nonStaticRigidBodies
void predictIntegratedTransform(btScalar step, btTransform &predictedTransform)
continuous collision detection needs prediction
virtual void addRigidBody(btRigidBody *body)
btScalar btSin(btScalar x)
do not change those serialization structures, it requires an updated sBulletDNAstr/sBulletDNAstr64 ...
btScalar m_loLimit
limit_parameters
virtual void setGravity(const btVector3 &gravity)
const btTransform & getCalculatedTransformB() const
Gets the global transform of the offset for body B.
const btRigidBody & getRigidBodyB() const
btAlignedObjectArray< btTypedConstraint * > m_sortedConstraints
btScalar m_combinedRestitution
virtual void removeCharacter(btActionInterface *character)
obsolete, use removeAction instead
short int m_collisionFilterGroup
virtual void drawLine(const btVector3 &from, const btVector3 &to, const btVector3 &color)=0
virtual void startSerialization()=0
btTranslationalLimitMotor * getTranslationalLimitMotor()
Retrieves the limit informacion.
int getInternalType() const
reserved for Bullet internal usage
const btVector3 & getInterpolationAngularVelocity() const
btGeneric6DofConstraint between two rigidbodies each with a pivotpoint that descibes the axis locatio...
virtual int calculateSerializeBufferSize() const
bool gDisableDeactivation
virtual void drawBox(const btVector3 &bbMin, const btVector3 &bbMax, const btVector3 &color)
SimulationIslandManager creates and handles simulation islands, using btUnionFind.
virtual void addCollisionObject(btCollisionObject *collisionObject, short int collisionFilterGroup=btBroadphaseProxy::DefaultFilter, short int collisionFilterMask=btBroadphaseProxy::AllFilter)
static DBVT_INLINE btScalar size(const btDbvtVolume &a)
const btTransform & getBFrame() const
btScalar m_appliedImpulse
btInternalTickCallback m_internalTickCallback
btVector3 m_convexToWorld
The btDynamicsWorld is the interface class for several dynamics implementation, basic, discrete, parallel, and continuous etc.
btCollisionConfiguration allows to configure Bullet collision detection stack allocator size...
void buildAndProcessIslands(btDispatcher *dispatcher, btCollisionWorld *collisionWorld, IslandCallback *callback)
btAlignedObjectArray< btActionInterface * > m_actions
virtual void processIsland(btCollisionObject **bodies, int numBodies, btPersistentManifold **manifolds, int numManifolds, int islandId)
void setHitFraction(btScalar hitFraction)
#define BT_DYNAMICSWORLD_CODE
virtual btScalar solveGroup(btCollisionObject **bodies, int numBodies, btPersistentManifold **manifold, int numManifolds, btTypedConstraint **constraints, int numConstraints, const btContactSolverInfo &info, class btIDebugDraw *debugDrawer, btDispatcher *dispatcher)=0
solve a group of constraints
btSimulationIslandManager * getSimulationIslandManager()
btScalar getLowerLinLimit()
virtual void removeCollisionObject(btCollisionObject *collisionObject)
removeCollisionObject will first check if it is a rigid body, if so call removeRigidBody otherwise ca...
#define SIMD_FORCE_INLINE
int getNumCollisionObjects() const
virtual void removeAction(btActionInterface *)
bool m_ownsConstraintSolver
The btSphereShape implements an implicit sphere, centered around a local origin with radius...
virtual void drawArc(const btVector3 ¢er, const btVector3 &normal, const btVector3 &axis, btScalar radiusA, btScalar radiusB, btScalar minAngle, btScalar maxAngle, const btVector3 &color, bool drawSect, btScalar stepDegrees=btScalar(10.f))
Basic interface to allow actions such as vehicles and characters to be updated inside a btDynamicsWor...
btVector3 m_upperLimit
the constraint upper limits
ManifoldContactPoint collects and maintains persistent contactpoints.
btVector3 m_convexFromWorld
const btCollisionObject * getBody0() const
btDispatcher * m_dispatcher1
btVector3 getColumn(int i) const
Get a column of the matrix as a vector.
const btRigidBody & getRigidBodyA() const
class btIDebugDraw * m_debugDraw
virtual void updateActivationState(btCollisionWorld *colWorld, btDispatcher *dispatcher)
virtual bool needsCollision(btBroadphaseProxy *proxy0) const
virtual void addCollisionObject(btCollisionObject *collisionObject, short int collisionFilterGroup=btBroadphaseProxy::StaticFilter, short int collisionFilterMask=btBroadphaseProxy::AllFilter^btBroadphaseProxy::StaticFilter)
const btVector3 & getInterpolationLinearVelocity() const
hinge constraint between two rigidbodies each with a pivotpoint that descibes the axis location in lo...
btScalar dot(const btVector3 &v) const
Return the dot product.
bool hasContactResponse() const
btVector3FloatData m_gravity
The StackAlloc class provides some fast stack-based memory allocator (LIFO last-in first-out) ...
btVector3 & normalize()
Normalize this vector x^2 + y^2 + z^2 = 1.
btScalar getCcdSquareMotionThreshold() const
const btTransform & getInterpolationWorldTransform() const
void clear()
clear the array, deallocated memory. Generally it is better to use array.resize(0), to reduce performance overhead of run-time memory (de)allocations.
btDispatcher * m_dispatcher
The btOverlappingPairCache provides an interface for overlapping pair management (add, remove, storage), used by the btBroadphaseInterface broadphases.
btContactSolverInfoFloatData m_solverInfo
void updateDeactivation(btScalar timeStep)
const btCollisionObject * m_hitCollisionObject
virtual void drawSpherePatch(const btVector3 ¢er, const btVector3 &up, const btVector3 &axis, btScalar radius, btScalar minTh, btScalar maxTh, btScalar minPs, btScalar maxPs, const btVector3 &color, btScalar stepDegrees=btScalar(10.f), bool drawCenter=true)
virtual const char * serialize(void *dataBuffer, class btSerializer *serializer) const
fills the dataBuffer and returns the struct name (and 0 on failure)
virtual btOverlappingPairCache * getOverlappingPairCache()=0
btCollisionWorld * getCollisionWorld()
void setActivationState(int newState) const
btTransform & getWorldTransform()
btVector3 m_normalWorldOnB
btScalar getUpperAngLimit()
btVector3 m_positionWorldOnB
btInternalTickCallback m_internalPreTickCallback
void processConstraints()
int size() const
return the number of elements in the array
btBroadphaseProxy * getBroadphaseHandle()
virtual void serialize(btSerializer *serializer)
Preliminary serialization test for Bullet 2.76. Loading those files requires a separate parser (see B...
btScalar getUpperLimit() const
btIDebugDraw * m_debugDrawer
btAlignedObjectArray< btCollisionObject * > m_bodies
virtual btIDebugDraw * getDebugDrawer()
const btTransform & getCenterOfMassTransform() const
bool isKinematicObject() const
btConstraintSolver * m_solver
virtual void debugDrawWorld()
btVector3 m_hitNormalLocal
virtual btBroadphasePair * findPair(btBroadphaseProxy *proxy0, btBroadphaseProxy *proxy1)=0
void addConstraintRef(btTypedConstraint *c)
bool isStaticObject() const
const btVector3 & getPivotInA() const
btScalar getAngle(int axis_index) const
Get the relative Euler angle.
ClosestConvexResultCallback(const btVector3 &convexFromWorld, const btVector3 &convexToWorld)
virtual void predictUnconstraintMotion(btScalar timeStep)
btDispatcher * m_dispatcher
bool isStaticOrKinematicObject() const
void serialize(struct btVector3Data &dataOut) const
#define btAlignedFree(ptr)
btCollisionObject can be used to manage collision detection objects.
virtual void saveKinematicState(btScalar timeStep)
virtual ~btDiscreteDynamicsWorld()
btScalar getLowerLimit() const
The btIDebugDraw interface class allows hooking up a debug renderer to visually debug simulations...
void setLinearVelocity(const btVector3 &lin_vel)
btAlignedObjectArray< btPersistentManifold * > m_predictiveManifolds
The btRigidBody is the main class for rigid body objects.
btVector3 m_positionWorldOnA
m_positionWorldOnA is redundant information, see getPositionWorldOnA(), but for clarity ...
virtual void removeCollisionObject(btCollisionObject *collisionObject)
btVector3 m_lowerLimit
the constraint lower limits
virtual btPersistentManifold * getNewManifold(const btCollisionObject *b0, const btCollisionObject *b1)=0
The btBroadphaseInterface class provides an interface to detect aabb-overlapping object pairs...
void proceedToTransform(const btTransform &newTrans)
const btManifoldPoint & getContactPoint(int index) const
btDispatcher * getDispatcher()
virtual btConstraintSolver * getConstraintSolver()
virtual btScalar addSingleResult(btCollisionWorld::LocalConvexResult &convexResult, bool normalInWorldSpace)
int gNumClampedCcdMotions
internal debugging variable. this value shouldn't be too high
btScalar getUpperLinLimit()
btAlignedObjectArray< btPersistentManifold * > m_manifolds
The btBroadphaseProxy is the main class that can be used with the Bullet broadphases.
virtual int stepSimulation(btScalar timeStep, int maxSubSteps=1, btScalar fixedTimeStep=btScalar(1.)/btScalar(60.))
if maxSubSteps > 0, it will interpolate motion between fixedTimeStep's
void createPredictiveContacts(btScalar timeStep)
btCollisionAlgorithm * m_algorithm
virtual void applyGravity()
apply gravity, call this once per timestep
The btSequentialImpulseConstraintSolver is a fast SIMD implementation of the Projected Gauss Seidel (...
InplaceSolverIslandCallback(btConstraintSolver *solver, btStackAlloc *stackAlloc, btDispatcher *dispatcher)
btScalar getHitFraction() const
static btScalar calculateCombinedFriction(const btCollisionObject *body0, const btCollisionObject *body1)
User can override this material combiner by implementing gContactAddedCallback and setting body0->m_c...
const btTransform & getAFrame()
const btVector3 & getPositionWorldOnB() const
btVector3 can be used to represent 3D points and vectors.
virtual void getAllContactManifolds(btManifoldArray &manifoldArray)=0
btScalar length2() const
Return the length of the vector squared.
void debugDrawConstraint(btTypedConstraint *constraint)
const btBroadphaseInterface * getBroadphase() const
bool getUseLinearReferenceFrameA()
btConeTwistConstraint can be used to simulate ragdoll joints (upper arm, leg etc) ...
virtual void calculateSimulationIslands()
virtual int getNumConstraints() const
bool operator()(const btTypedConstraint *lhs, const btTypedConstraint *rhs) const
virtual void removeConstraint(btTypedConstraint *constraint)
virtual void finalizeChunk(btChunk *chunk, const char *structType, int chunkCode, void *oldPtr)=0
static void Increment_Frame_Counter(void)
btScalar m_hiLimit
joint limit
CollisionWorld is interface and container for the collision detection.
virtual void allSolved(const btContactSolverInfo &, class btIDebugDraw *)
void updateActions(btScalar timeStep)
void applyDamping(btScalar timeStep)
applyDamping damps the velocity, using the given m_linearDamping and m_angularDamping ...
virtual btTypedConstraint * getConstraint(int index)
btDispatcherInfo & getDispatchInfo()
const btTransform & getBFrame()
bool m_latencyMotionStateInterpolation
virtual void prepareSolve(int, int)
#define WANTS_DEACTIVATION
void remove(const T &key)
btScalar m_allowedCcdPenetration
virtual void drawTransform(const btTransform &transform, btScalar orthoLen)
TypedConstraint is the baseclass for Bullet constraints and vehicles.
void synchronizeSingleMotionState(btRigidBody *body)
this can be useful to synchronize a single rigid body -> graphics object
void saveKinematicState(btScalar step)
void resize(int newsize, const T &fillData=T())
bool btFuzzyZero(btScalar x)
int getNumContacts() const
bool m_synchronizeAllMotionStates
virtual void integrateTransforms(btScalar timeStep)
btRotationalLimitMotor * getRotationalLimitMotor(int index)
Retrieves the angular limit informacion.
const btRigidBody & getRigidBodyA() const
void setAngularVelocity(const btVector3 &ang_vel)
virtual int getDebugMode() const =0
btClosestNotMeConvexResultCallback(btCollisionObject *me, const btVector3 &fromA, const btVector3 &toA, btOverlappingPairCache *pairCache, btDispatcher *dispatcher)
btAlignedObjectArray< btCollisionObject * > m_collisionObjects
virtual void synchronizeMotionStates()
btDiscreteDynamicsWorld(btDispatcher *dispatcher, btBroadphaseInterface *pairCache, btConstraintSolver *constraintSolver, btCollisionConfiguration *collisionConfiguration)
this btDiscreteDynamicsWorld constructor gets created objects from the user, and will not delete thos...
#define BT_RIGIDBODY_CODE
virtual void storeIslandActivationState(btCollisionWorld *world)
virtual bool needsResponse(const btCollisionObject *body0, const btCollisionObject *body1)=0
#define DISABLE_DEACTIVATION
virtual const char * serialize(void *dataBuffer, btSerializer *serializer) const
fills the dataBuffer and returns the struct name (and 0 on failure)
virtual int calculateSerializeBufferSize() const
virtual void performDiscreteCollisionDetection()
const btBroadphaseProxy * getBroadphaseProxy() const
btScalar m_combinedFriction
btUnionFind & getUnionFind()
InplaceSolverIslandCallback * m_solverIslandCallback
const btVector3 & getPositionWorldOnA() const
virtual void addCharacter(btActionInterface *character)
obsolete, use addAction instead
#define btAlignedAlloc(size, alignment)
short int m_collisionFilterMask
btVector3 GetPointForAngle(btScalar fAngleInRadians, btScalar fLength) const
bool m_applySpeculativeContactRestitution
do not change those serialization structures, it requires an updated sBulletDNAstr/sBulletDNAstr64 ...
btConstraintSolver * m_constraintSolver
btMotionState * getMotionState()
const btRigidBody & getRigidBodyA() const
const btVector3 & getLinearVelocity() const
const btVector3 & getPivotInB() const
void applyImpulse(const btVector3 &impulse, const btVector3 &rel_pos)
btScalar getLowerAngLimit()
void serializeRigidBodies(btSerializer *serializer)
btScalar m_allowedPenetration
virtual void updateActivationState(btScalar timeStep)
btAlignedObjectArray< btTypedConstraint * > m_constraints
void convexSweepTest(const btConvexShape *castShape, const btTransform &from, const btTransform &to, ConvexResultCallback &resultCallback, btScalar allowedCcdPenetration=btScalar(0.)) const
convexTest performs a swept convex cast on all objects in the btCollisionWorld, and calls the resultC...
const btRigidBody & getRigidBodyB() const
virtual void addVehicle(btActionInterface *vehicle)
obsolete, use addAction instead
InplaceSolverIslandCallback & operator=(InplaceSolverIslandCallback &other)
virtual void removeRigidBody(btRigidBody *body)
virtual void debugDrawWorld()
The btDispatcher interface class can be used in combination with broadphase to dispatch calculations ...
void removeConstraintRef(btTypedConstraint *c)
static btScalar calculateCombinedRestitution(const btCollisionObject *body0, const btCollisionObject *body1)
in the future we can let the user override the methods to combine restitution and friction ...
btScalar getDbgDrawSize()
int getActivationState() const
btContactSolverInfo & getSolverInfo()
const btRigidBody & getRigidBodyB() const
virtual void setWorldTransform(const btTransform &worldTrans)=0
const btCollisionObject * getBody1() const
int addManifoldPoint(const btManifoldPoint &newPoint, bool isPredictive=false)
virtual btChunk * allocate(size_t size, int numElements)=0
float btScalar
The btScalar type abstracts floating point numbers, to easily switch between double and single floati...
void quickSort(const L &CompareFunc)
btScalar btCos(btScalar x)
virtual ~btSimulationIslandManager()
virtual ~btConstraintSolver()
btAlignedObjectArray< btTypedConstraint * > m_constraints
void setGravity(const btVector3 &acceleration)
btTypedConstraint ** m_sortedConstraints
The btBroadphasePair class contains a pair of aabb-overlapping objects.