Add Character control to btDiscreteDynamicsWorld (moved btCharacterControllerInterface/btKinematicCharacterController functionality from demo)
Remove ibmsdk from CcdPhysicsDemo and CollisionDemo
This commit is contained in:
@@ -51,6 +51,9 @@ subject to the following restrictions:
|
||||
#include "BulletDynamics/Vehicle/btRaycastVehicle.h"
|
||||
#include "BulletDynamics/Vehicle/btVehicleRaycaster.h"
|
||||
#include "BulletDynamics/Vehicle/btWheelInfo.h"
|
||||
//character
|
||||
#include "BulletDynamics/Character/btCharacterControllerInterface.h"
|
||||
|
||||
#include "LinearMath/btIDebugDraw.h"
|
||||
#include "LinearMath/btQuickprof.h"
|
||||
#include "LinearMath/btMotionState.h"
|
||||
@@ -403,7 +406,8 @@ void btDiscreteDynamicsWorld::internalSingleStepSimulation(btScalar timeStep)
|
||||
|
||||
///update vehicle simulation
|
||||
updateVehicles(timeStep);
|
||||
|
||||
|
||||
updateCharacters(timeStep);
|
||||
|
||||
updateActivationState( timeStep );
|
||||
|
||||
@@ -479,6 +483,20 @@ void btDiscreteDynamicsWorld::updateVehicles(btScalar timeStep)
|
||||
}
|
||||
}
|
||||
|
||||
void btDiscreteDynamicsWorld::updateCharacters(btScalar timeStep)
|
||||
{
|
||||
BT_PROFILE("updateCharacters");
|
||||
|
||||
for ( int i=0;i<m_characters.size();i++)
|
||||
{
|
||||
btCharacterControllerInterface* character = m_characters[i];
|
||||
character->preStep (this);
|
||||
character->playerStep (this,timeStep);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void btDiscreteDynamicsWorld::updateActivationState(btScalar timeStep)
|
||||
{
|
||||
BT_PROFILE("updateActivationState");
|
||||
@@ -543,6 +561,17 @@ void btDiscreteDynamicsWorld::removeVehicle(btRaycastVehicle* vehicle)
|
||||
m_vehicles.remove(vehicle);
|
||||
}
|
||||
|
||||
void btDiscreteDynamicsWorld::addCharacter(btCharacterControllerInterface* character)
|
||||
{
|
||||
m_characters.push_back(character);
|
||||
}
|
||||
|
||||
void btDiscreteDynamicsWorld::removeCharacter(btCharacterControllerInterface* character)
|
||||
{
|
||||
m_characters.remove(character);
|
||||
}
|
||||
|
||||
|
||||
SIMD_FORCE_INLINE int btGetConstraintIslandId(const btTypedConstraint* lhs)
|
||||
{
|
||||
int islandId;
|
||||
|
||||
@@ -26,6 +26,7 @@ class btTypedConstraint;
|
||||
|
||||
|
||||
class btRaycastVehicle;
|
||||
class btCharacterControllerInterface;
|
||||
class btIDebugDraw;
|
||||
#include "LinearMath/btAlignedObjectArray.h"
|
||||
|
||||
@@ -53,6 +54,9 @@ protected:
|
||||
|
||||
|
||||
btAlignedObjectArray<btRaycastVehicle*> m_vehicles;
|
||||
|
||||
btAlignedObjectArray<btCharacterControllerInterface*> m_characters;
|
||||
|
||||
|
||||
int m_profileTimings;
|
||||
|
||||
@@ -68,6 +72,8 @@ protected:
|
||||
|
||||
void updateVehicles(btScalar timeStep);
|
||||
|
||||
void updateCharacters(btScalar timeStep);
|
||||
|
||||
void startProfiling(btScalar timeStep);
|
||||
|
||||
virtual void internalSingleStepSimulation( btScalar timeStep);
|
||||
@@ -95,13 +101,18 @@ public:
|
||||
///this can be useful to synchronize a single rigid body -> graphics object
|
||||
void synchronizeSingleMotionState(btRigidBody* body);
|
||||
|
||||
void addConstraint(btTypedConstraint* constraint, bool disableCollisionsBetweenLinkedBodies=false);
|
||||
virtual void addConstraint(btTypedConstraint* constraint, bool disableCollisionsBetweenLinkedBodies=false);
|
||||
|
||||
void removeConstraint(btTypedConstraint* constraint);
|
||||
virtual void removeConstraint(btTypedConstraint* constraint);
|
||||
|
||||
void addVehicle(btRaycastVehicle* vehicle);
|
||||
virtual void addVehicle(btRaycastVehicle* vehicle);
|
||||
|
||||
void removeVehicle(btRaycastVehicle* vehicle);
|
||||
virtual void removeVehicle(btRaycastVehicle* vehicle);
|
||||
|
||||
virtual void addCharacter(btCharacterControllerInterface* character);
|
||||
|
||||
virtual void removeCharacter(btCharacterControllerInterface* character);
|
||||
|
||||
|
||||
btSimulationIslandManager* getSimulationIslandManager()
|
||||
{
|
||||
|
||||
@@ -23,6 +23,7 @@ class btTypedConstraint;
|
||||
class btRaycastVehicle;
|
||||
class btConstraintSolver;
|
||||
class btDynamicsWorld;
|
||||
class btCharacterControllerInterface;
|
||||
|
||||
/// Type for the callback for each tick
|
||||
typedef void (*btInternalTickCallback)(btDynamicsWorld *world, btScalar timeStep);
|
||||
@@ -75,6 +76,11 @@ public:
|
||||
|
||||
virtual void removeVehicle(btRaycastVehicle* vehicle) {(void)vehicle;}
|
||||
|
||||
virtual void addCharacter(btCharacterControllerInterface* character) {(void)character;}
|
||||
|
||||
virtual void removeCharacter(btCharacterControllerInterface* character) {(void)character;}
|
||||
|
||||
|
||||
//once a rigidbody is added to the dynamics world, it will get this gravity assigned
|
||||
//existing rigidbodies in the world get gravity assigned too, during this method
|
||||
virtual void setGravity(const btVector3& gravity) = 0;
|
||||
|
||||
Reference in New Issue
Block a user