- Timestamp:
- Apr 8, 2009, 12:58:47 AM (16 years ago)
- Location:
- code/branches/questsystem5
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/questsystem5
- Property svn:mergeinfo changed
-
code/branches/questsystem5/src/bullet/BulletDynamics/Character/btCharacterControllerInterface.h
r2907 r2908 18 18 19 19 #include "LinearMath/btVector3.h" 20 #include "BulletDynamics/Dynamics/btActionInterface.h"21 20 22 21 class btCollisionShape; … … 24 23 class btCollisionWorld; 25 24 26 class btCharacterControllerInterface : public btActionInterface25 class btCharacterControllerInterface 27 26 { 28 27 public: -
code/branches/questsystem5/src/bullet/BulletDynamics/Character/btKinematicCharacterController.cpp
r2907 r2908 23 23 #include "btKinematicCharacterController.h" 24 24 25 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) };26 27 25 ///@todo Interact with dynamic objects, 28 26 ///Ride kinematicly animated platforms properly … … 96 94 } 97 95 98 btKinematicCharacterController::btKinematicCharacterController (btPairCachingGhostObject* ghostObject,btConvexShape* convexShape,btScalar stepHeight, int upAxis) 99 { 100 m_upAxis = upAxis; 96 btKinematicCharacterController::btKinematicCharacterController (btPairCachingGhostObject* ghostObject,btConvexShape* convexShape,btScalar stepHeight) 97 { 101 98 m_addedMargin = 0.02f; 102 99 m_walkDirection.setValue(0,0,0); … … 105 102 m_stepHeight = stepHeight; 106 103 m_turnAngle = btScalar(0.0); 107 m_convexShape=convexShape; 104 m_convexShape=convexShape; 105 108 106 } 109 107 … … 112 110 } 113 111 112 114 113 btPairCachingGhostObject* btKinematicCharacterController::getGhostObject() 115 114 { … … 117 116 } 118 117 119 bool btKinematicCharacterController::recoverFromPenetration ( 118 bool btKinematicCharacterController::recoverFromPenetration (btCollisionWorld* collisionWorld) 120 119 { 121 120 … … 174 173 // phase 1: up 175 174 btTransform start, end; 176 m_targetPosition = m_currentPosition + upAxisDirection[m_upAxis] * m_stepHeight;175 m_targetPosition = m_currentPosition + btVector3 (btScalar(0.0), m_stepHeight, btScalar(0.0)); 177 176 178 177 start.setIdentity (); … … 180 179 181 180 /* FIXME: Handle penetration properly */ 182 start.setOrigin (m_currentPosition + upAxisDirection[m_upAxis] * btScalar(0.1f));181 start.setOrigin (m_currentPosition + btVector3(btScalar(0.0), btScalar(0.1), btScalar(0.0))); 183 182 end.setOrigin (m_targetPosition); 184 183 … … 345 344 346 345 // phase 3: down 347 btVector3 step_drop = upAxisDirection[m_upAxis] * m_currentStepOffset;348 btVector3 gravity_drop = upAxisDirection[m_upAxis] * m_stepHeight;346 btVector3 step_drop = btVector3(btScalar(0.0), m_currentStepOffset, btScalar(0.0)); 347 btVector3 gravity_drop = btVector3(btScalar(0.0), m_stepHeight, btScalar(0.0)); 349 348 m_targetPosition -= (step_drop + gravity_drop); 350 349 … … 391 390 392 391 393 void btKinematicCharacterController::preStep ( 392 void btKinematicCharacterController::preStep ( btCollisionWorld* collisionWorld) 394 393 { 395 394 … … 414 413 } 415 414 416 void btKinematicCharacterController::playerStep ( 415 void btKinematicCharacterController::playerStep ( btCollisionWorld* collisionWorld, btScalar dt) 417 416 { 418 417 btTransform xform; … … 470 469 return true; 471 470 } 472 473 474 void btKinematicCharacterController::debugDraw(btIDebugDraw* debugDrawer)475 {476 } -
code/branches/questsystem5/src/bullet/BulletDynamics/Character/btKinematicCharacterController.h
r2907 r2908 63 63 64 64 bool m_useGhostObjectSweepTest; 65 66 int m_upAxis;67 65 68 66 btVector3 computeReflectionDirection (const btVector3& direction, const btVector3& normal); … … 70 68 btVector3 perpindicularComponent (const btVector3& direction, const btVector3& normal); 71 69 72 bool recoverFromPenetration ( 70 bool recoverFromPenetration (btCollisionWorld* collisionWorld); 73 71 void stepUp (btCollisionWorld* collisionWorld); 74 72 void updateTargetPositionBasedOnCollision (const btVector3& hit_normal, btScalar tangentMag = btScalar(0.0), btScalar normalMag = btScalar(1.0)); … … 76 74 void stepDown (btCollisionWorld* collisionWorld, btScalar dt); 77 75 public: 78 btKinematicCharacterController (btPairCachingGhostObject* ghostObject,btConvexShape* convexShape,btScalar stepHeight , int upAxis = 1);76 btKinematicCharacterController (btPairCachingGhostObject* ghostObject,btConvexShape* convexShape,btScalar stepHeight); 79 77 ~btKinematicCharacterController (); 80 78 81 82 ///btActionInterface interface83 virtual void updateAction( btCollisionWorld* collisionWorld,btScalar deltaTime)84 {85 preStep ( collisionWorld);86 playerStep (collisionWorld, deltaTime);87 }88 89 ///btActionInterface interface90 void debugDraw(btIDebugDraw* debugDrawer);91 92 void setUpAxis (int axis)93 {94 if (axis < 0)95 axis = 0;96 if (axis > 2)97 axis = 2;98 m_upAxis = axis;99 }100 101 79 virtual void setWalkDirection(const btVector3& walkDirection) 102 80 { … … 107 85 void warp (const btVector3& origin); 108 86 109 void preStep ( 110 void playerStep ( 87 void preStep ( btCollisionWorld* collisionWorld); 88 void playerStep (btCollisionWorld* collisionWorld, btScalar dt); 111 89 112 90 void setFallSpeed (btScalar fallSpeed);
Note: See TracChangeset
for help on using the changeset viewer.