Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/gameengine/Physics/Bullet/CcdPhysicsController.cpp')
-rw-r--r--source/gameengine/Physics/Bullet/CcdPhysicsController.cpp73
1 files changed, 55 insertions, 18 deletions
diff --git a/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp b/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp
index cf96f22a345..0de21e33eff 100644
--- a/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp
+++ b/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp
@@ -78,6 +78,9 @@ BlenderBulletCharacterController::BlenderBulletCharacterController(btMotionState
void BlenderBulletCharacterController::updateAction(btCollisionWorld *collisionWorld, btScalar dt)
{
+ if (onGround())
+ m_jumps = 0;
+
btKinematicCharacterController::updateAction(collisionWorld,dt);
m_motionState->setWorldTransform(getGhostObject()->getWorldTransform());
}
@@ -104,9 +107,6 @@ bool BlenderBulletCharacterController::canJump() const
void BlenderBulletCharacterController::jump()
{
- if (onGround())
- m_jumps = 0;
-
if (!canJump())
return;
@@ -115,6 +115,11 @@ void BlenderBulletCharacterController::jump()
m_jumps++;
}
+const btVector3& BlenderBulletCharacterController::getWalkDirection()
+{
+ return m_walkDirection;
+}
+
CcdPhysicsController::CcdPhysicsController (const CcdConstructionInfo& ci)
:m_cci(ci)
{
@@ -670,9 +675,9 @@ CcdPhysicsController::~CcdPhysicsController()
}
- /**
- SynchronizeMotionStates ynchronizes dynas, kinematic and deformable entities (and do 'late binding')
- */
+/**
+ * SynchronizeMotionStates ynchronizes dynas, kinematic and deformable entities (and do 'late binding')
+ */
bool CcdPhysicsController::SynchronizeMotionStates(float time)
{
//sync non-static to motionstate, and static from motionstate (todo: add kinematic etc.)
@@ -755,8 +760,8 @@ bool CcdPhysicsController::SynchronizeMotionStates(float time)
}
/**
- WriteMotionStateToDynamics synchronizes dynas, kinematic and deformable entities (and do 'late binding')
- */
+ * WriteMotionStateToDynamics synchronizes dynas, kinematic and deformable entities (and do 'late binding')
+ */
void CcdPhysicsController::WriteMotionStateToDynamics(bool nondynaonly)
{
@@ -926,20 +931,27 @@ void CcdPhysicsController::RelativeTranslate(float dlocX,float dlocY,float dloc
if (local)
dloc = xform.getBasis()*dloc;
- if (m_characterController)
- {
- m_characterController->setWalkDirection(dloc/GetPhysicsEnvironment()->getNumTimeSubSteps());
- }
- else
- {
-
- xform.setOrigin(xform.getOrigin() + dloc);
- SetCenterOfMassTransform(xform);
- }
+ xform.setOrigin(xform.getOrigin() + dloc);
+ SetCenterOfMassTransform(xform);
}
}
+void CcdPhysicsController::SetWalkDirection(float dirX,float dirY,float dirZ,bool local)
+{
+
+ if (m_object && m_characterController)
+ {
+ btVector3 dir(dirX,dirY,dirZ);
+ btTransform xform = m_object->getWorldTransform();
+
+ if (local)
+ dir = xform.getBasis()*dir;
+
+ m_characterController->setWalkDirection(dir/GetPhysicsEnvironment()->getNumTimeSubSteps());
+ }
+}
+
void CcdPhysicsController::RelativeRotate(const float rotval[9],bool local)
{
if (m_object)
@@ -1267,6 +1279,13 @@ void CcdPhysicsController::applyImpulse(float attachX,float attachY,float attac
}
}
+
+void CcdPhysicsController::Jump()
+{
+ if (m_object && m_characterController)
+ m_characterController->jump();
+}
+
void CcdPhysicsController::SetActive(bool active)
{
}
@@ -1323,6 +1342,24 @@ void CcdPhysicsController::GetVelocity(const float posX,const float posY,const
linvZ = 0.f;
}
}
+
+void CcdPhysicsController::GetWalkDirection(float& dirX,float& dirY,float& dirZ)
+{
+ if (m_object && m_characterController)
+ {
+ const btVector3 dir = m_characterController->getWalkDirection();
+ dirX = dir.x();
+ dirY = dir.y();
+ dirZ = dir.z();
+ }
+ else
+ {
+ dirX = 0.f;
+ dirY = 0.f;
+ dirZ = 0.f;
+ }
+}
+
void CcdPhysicsController::getReactionForce(float& forceX,float& forceY,float& forceZ)
{
}