Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Mar 31, 2009, 8:05:51 PM (16 years ago)
Author:
rgrieder
Message:

Update from Bullet 2.73 to 2.74.

Location:
code/trunk/src/bullet/BulletDynamics/Character
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • code/trunk/src/bullet/BulletDynamics/Character/btCharacterControllerInterface.h

    r2662 r2882  
    1818
    1919#include "LinearMath/btVector3.h"
     20#include "BulletDynamics/Dynamics/btActionInterface.h"
    2021
    2122class btCollisionShape;
     
    2324class btCollisionWorld;
    2425
    25 class btCharacterControllerInterface
     26class btCharacterControllerInterface : public btActionInterface
    2627{
    2728public:
  • code/trunk/src/bullet/BulletDynamics/Character/btKinematicCharacterController.cpp

    r2662 r2882  
    2323#include "btKinematicCharacterController.h"
    2424
     25static 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
    2527///@todo Interact with dynamic objects,
    2628///Ride kinematicly animated platforms properly
     
    9496}
    9597
    96 btKinematicCharacterController::btKinematicCharacterController (btPairCachingGhostObject* ghostObject,btConvexShape* convexShape,btScalar stepHeight)
    97 {
     98btKinematicCharacterController::btKinematicCharacterController (btPairCachingGhostObject* ghostObject,btConvexShape* convexShape,btScalar stepHeight, int upAxis)
     99{
     100        m_upAxis = upAxis;
    98101        m_addedMargin = 0.02f;
    99102        m_walkDirection.setValue(0,0,0);
     
    102105        m_stepHeight = stepHeight;
    103106        m_turnAngle = btScalar(0.0);
    104         m_convexShape=convexShape;
    105        
     107        m_convexShape=convexShape;     
    106108}
    107109
     
    110112}
    111113
    112 
    113114btPairCachingGhostObject* btKinematicCharacterController::getGhostObject()
    114115{
     
    116117}
    117118
    118 bool btKinematicCharacterController::recoverFromPenetration (btCollisionWorld* collisionWorld)
     119bool btKinematicCharacterController::recoverFromPenetration ( btCollisionWorld* collisionWorld)
    119120{
    120121
     
    173174        // phase 1: up
    174175        btTransform start, end;
    175         m_targetPosition = m_currentPosition + btVector3 (btScalar(0.0), m_stepHeight, btScalar(0.0));
     176        m_targetPosition = m_currentPosition + upAxisDirection[m_upAxis] * m_stepHeight;
    176177
    177178        start.setIdentity ();
     
    179180
    180181        /* FIXME: Handle penetration properly */
    181         start.setOrigin (m_currentPosition + btVector3(btScalar(0.0), btScalar(0.1), btScalar(0.0)));
     182        start.setOrigin (m_currentPosition + upAxisDirection[m_upAxis] * btScalar(0.1f));
    182183        end.setOrigin (m_targetPosition);
    183184
     
    344345
    345346        // phase 3: down
    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));
     347        btVector3 step_drop = upAxisDirection[m_upAxis] * m_currentStepOffset;
     348        btVector3 gravity_drop = upAxisDirection[m_upAxis] * m_stepHeight;
    348349        m_targetPosition -= (step_drop + gravity_drop);
    349350
     
    390391
    391392
    392 void btKinematicCharacterController::preStep ( btCollisionWorld* collisionWorld)
     393void btKinematicCharacterController::preStep (  btCollisionWorld* collisionWorld)
    393394{
    394395       
     
    413414}
    414415
    415 void btKinematicCharacterController::playerStep ( btCollisionWorld* collisionWorld, btScalar dt)
     416void btKinematicCharacterController::playerStep (  btCollisionWorld* collisionWorld, btScalar dt)
    416417{
    417418        btTransform xform;
     
    469470        return true;
    470471}
     472
     473
     474void    btKinematicCharacterController::debugDraw(btIDebugDraw* debugDrawer)
     475{
     476}
  • code/trunk/src/bullet/BulletDynamics/Character/btKinematicCharacterController.h

    r2662 r2882  
    6363
    6464        bool    m_useGhostObjectSweepTest;
     65
     66        int m_upAxis;
    6567       
    6668        btVector3 computeReflectionDirection (const btVector3& direction, const btVector3& normal);
     
    6870        btVector3 perpindicularComponent (const btVector3& direction, const btVector3& normal);
    6971
    70         bool recoverFromPenetration (btCollisionWorld* collisionWorld);
     72        bool recoverFromPenetration ( btCollisionWorld* collisionWorld);
    7173        void stepUp (btCollisionWorld* collisionWorld);
    7274        void updateTargetPositionBasedOnCollision (const btVector3& hit_normal, btScalar tangentMag = btScalar(0.0), btScalar normalMag = btScalar(1.0));
     
    7476        void stepDown (btCollisionWorld* collisionWorld, btScalar dt);
    7577public:
    76         btKinematicCharacterController (btPairCachingGhostObject* ghostObject,btConvexShape* convexShape,btScalar stepHeight);
     78        btKinematicCharacterController (btPairCachingGhostObject* ghostObject,btConvexShape* convexShape,btScalar stepHeight, int upAxis = 1);
    7779        ~btKinematicCharacterController ();
    7880       
     81
     82        ///btActionInterface interface
     83        virtual void updateAction( btCollisionWorld* collisionWorld,btScalar deltaTime)
     84        {
     85                preStep ( collisionWorld);
     86                playerStep (collisionWorld, deltaTime);
     87        }
     88       
     89        ///btActionInterface interface
     90        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
    79101        virtual void    setWalkDirection(const btVector3& walkDirection)
    80102        {
     
    85107        void warp (const btVector3& origin);
    86108
    87         void preStep ( btCollisionWorld* collisionWorld);
    88         void playerStep (btCollisionWorld* collisionWorld, btScalar dt);
     109        void preStep (  btCollisionWorld* collisionWorld);
     110        void playerStep ( btCollisionWorld* collisionWorld, btScalar dt);
    89111
    90112        void setFallSpeed (btScalar fallSpeed);
Note: See TracChangeset for help on using the changeset viewer.