move static globals inside static member functions, to avoid hassle with C#/CLI/C++ managed code, compile error C3820

This commit is contained in:
erwin.coumans
2010-02-03 23:27:22 +00:00
parent c1e20e98c7
commit 219517db2d
8 changed files with 152 additions and 116 deletions

View File

@@ -23,8 +23,6 @@ subject to the following restrictions:
#include "LinearMath/btDefaultMotionState.h"
#include "btKinematicCharacterController.h"
static btVector3 upAxisDirection[3] = { btVector3(1.0f, 0.0f, 0.0f), btVector3(0.0f, 1.0f, 0.0f), btVector3(0.0f, 0.0f, 1.0f) };
// static helper method
static btVector3
@@ -189,13 +187,13 @@ void btKinematicCharacterController::stepUp ( btCollisionWorld* world)
{
// phase 1: up
btTransform start, end;
m_targetPosition = m_currentPosition + upAxisDirection[m_upAxis] * m_stepHeight;
m_targetPosition = m_currentPosition + getUpAxisDirections()[m_upAxis] * m_stepHeight;
start.setIdentity ();
end.setIdentity ();
/* FIXME: Handle penetration properly */
start.setOrigin (m_currentPosition + upAxisDirection[m_upAxis] * btScalar(0.1f));
start.setOrigin (m_currentPosition + getUpAxisDirections()[m_upAxis] * btScalar(0.1f));
end.setOrigin (m_targetPosition);
btKinematicClosestNotMeConvexResultCallback callback (m_ghostObject);
@@ -355,8 +353,8 @@ void btKinematicCharacterController::stepDown ( btCollisionWorld* collisionWorld
btTransform start, end;
// phase 3: down
btVector3 step_drop = upAxisDirection[m_upAxis] * m_currentStepOffset;
btVector3 gravity_drop = upAxisDirection[m_upAxis] * m_stepHeight;
btVector3 step_drop = getUpAxisDirections()[m_upAxis] * m_currentStepOffset;
btVector3 gravity_drop = getUpAxisDirections()[m_upAxis] * m_stepHeight;
m_targetPosition -= (step_drop + gravity_drop);
start.setIdentity ();
@@ -545,3 +543,11 @@ bool btKinematicCharacterController::onGround () const
void btKinematicCharacterController::debugDraw(btIDebugDraw* debugDrawer)
{
}
btVector3* btKinematicCharacterController::getUpAxisDirections()
{
static btVector3 sUpAxisDirection[3] = { btVector3(1.0f, 0.0f, 0.0f), btVector3(0.0f, 1.0f, 0.0f), btVector3(0.0f, 0.0f, 1.0f) };
return sUpAxisDirection;
}

View File

@@ -35,6 +35,7 @@ class btPairCachingGhostObject;
class btKinematicCharacterController : public btCharacterControllerInterface
{
protected:
btScalar m_halfHeight;
btPairCachingGhostObject* m_ghostObject;
@@ -69,7 +70,9 @@ protected:
bool m_useWalkDirection;
btScalar m_velocityTimeInterval;
int m_upAxis;
static btVector3* getUpAxisDirections();
btVector3 computeReflectionDirection (const btVector3& direction, const btVector3& normal);
btVector3 parallelComponent (const btVector3& direction, const btVector3& normal);
btVector3 perpindicularComponent (const btVector3& direction, const btVector3& normal);