diff options
author | RĂ©mi Verschelde <rverschelde@gmail.com> | 2019-01-07 15:08:41 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-01-07 15:08:41 +0100 |
commit | dab650fcaa3eb37deee5118d678a3763ac78a58a (patch) | |
tree | 3131df01280f91a61b4721eed132a5b6b21881ba /thirdparty/bullet/BulletDynamics/Vehicle/btRaycastVehicle.h | |
parent | a3a537c2cf86ff4bf82385bbd17606654f8013c4 (diff) | |
parent | 22b7c9dfa80d0f7abca40f061865c2ab3c136a74 (diff) |
Merge pull request #24740 from OBKF/update-bullet-physics
Update Bullet physics to commit 126b676
Diffstat (limited to 'thirdparty/bullet/BulletDynamics/Vehicle/btRaycastVehicle.h')
-rw-r--r-- | thirdparty/bullet/BulletDynamics/Vehicle/btRaycastVehicle.h | 158 |
1 files changed, 71 insertions, 87 deletions
diff --git a/thirdparty/bullet/BulletDynamics/Vehicle/btRaycastVehicle.h b/thirdparty/bullet/BulletDynamics/Vehicle/btRaycastVehicle.h index 04656b912c..99d6894e56 100644 --- a/thirdparty/bullet/BulletDynamics/Vehicle/btRaycastVehicle.h +++ b/thirdparty/bullet/BulletDynamics/Vehicle/btRaycastVehicle.h @@ -24,122 +24,111 @@ class btDynamicsWorld; ///rayCast vehicle, very special constraint that turn a rigidbody into a vehicle. class btRaycastVehicle : public btActionInterface { + btAlignedObjectArray<btVector3> m_forwardWS; + btAlignedObjectArray<btVector3> m_axle; + btAlignedObjectArray<btScalar> m_forwardImpulse; + btAlignedObjectArray<btScalar> m_sideImpulse; - btAlignedObjectArray<btVector3> m_forwardWS; - btAlignedObjectArray<btVector3> m_axle; - btAlignedObjectArray<btScalar> m_forwardImpulse; - btAlignedObjectArray<btScalar> m_sideImpulse; - - ///backwards compatibility - int m_userConstraintType; - int m_userConstraintId; + ///backwards compatibility + int m_userConstraintType; + int m_userConstraintId; public: class btVehicleTuning + { + public: + btVehicleTuning() + : m_suspensionStiffness(btScalar(5.88)), + m_suspensionCompression(btScalar(0.83)), + m_suspensionDamping(btScalar(0.88)), + m_maxSuspensionTravelCm(btScalar(500.)), + m_frictionSlip(btScalar(10.5)), + m_maxSuspensionForce(btScalar(6000.)) { - public: - - btVehicleTuning() - :m_suspensionStiffness(btScalar(5.88)), - m_suspensionCompression(btScalar(0.83)), - m_suspensionDamping(btScalar(0.88)), - m_maxSuspensionTravelCm(btScalar(500.)), - m_frictionSlip(btScalar(10.5)), - m_maxSuspensionForce(btScalar(6000.)) - { - } - btScalar m_suspensionStiffness; - btScalar m_suspensionCompression; - btScalar m_suspensionDamping; - btScalar m_maxSuspensionTravelCm; - btScalar m_frictionSlip; - btScalar m_maxSuspensionForce; - - }; -private: + } + btScalar m_suspensionStiffness; + btScalar m_suspensionCompression; + btScalar m_suspensionDamping; + btScalar m_maxSuspensionTravelCm; + btScalar m_frictionSlip; + btScalar m_maxSuspensionForce; + }; - btVehicleRaycaster* m_vehicleRaycaster; - btScalar m_pitchControl; - btScalar m_steeringValue; +private: + btVehicleRaycaster* m_vehicleRaycaster; + btScalar m_pitchControl; + btScalar m_steeringValue; btScalar m_currentVehicleSpeedKmHour; btRigidBody* m_chassisBody; int m_indexRightAxis; int m_indexUpAxis; - int m_indexForwardAxis; + int m_indexForwardAxis; void defaultInit(const btVehicleTuning& tuning); public: - //constructor to create a car from an existing rigidbody - btRaycastVehicle(const btVehicleTuning& tuning,btRigidBody* chassis, btVehicleRaycaster* raycaster ); - - virtual ~btRaycastVehicle() ; + btRaycastVehicle(const btVehicleTuning& tuning, btRigidBody* chassis, btVehicleRaycaster* raycaster); + virtual ~btRaycastVehicle(); ///btActionInterface interface - virtual void updateAction( btCollisionWorld* collisionWorld, btScalar step) + virtual void updateAction(btCollisionWorld* collisionWorld, btScalar step) { - (void) collisionWorld; + (void)collisionWorld; updateVehicle(step); } - ///btActionInterface interface - void debugDraw(btIDebugDraw* debugDrawer); - + void debugDraw(btIDebugDraw* debugDrawer); + const btTransform& getChassisWorldTransform() const; - + btScalar rayCast(btWheelInfo& wheel); virtual void updateVehicle(btScalar step); - - + void resetSuspension(); - btScalar getSteeringValue(int wheel) const; + btScalar getSteeringValue(int wheel) const; - void setSteeringValue(btScalar steering,int wheel); + void setSteeringValue(btScalar steering, int wheel); + void applyEngineForce(btScalar force, int wheel); - void applyEngineForce(btScalar force, int wheel); + const btTransform& getWheelTransformWS(int wheelIndex) const; - const btTransform& getWheelTransformWS( int wheelIndex ) const; + void updateWheelTransform(int wheelIndex, bool interpolatedTransform = true); - void updateWheelTransform( int wheelIndex, bool interpolatedTransform = true ); - -// void setRaycastWheelInfo( int wheelIndex , bool isInContact, const btVector3& hitPoint, const btVector3& hitNormal,btScalar depth); + // void setRaycastWheelInfo( int wheelIndex , bool isInContact, const btVector3& hitPoint, const btVector3& hitNormal,btScalar depth); - btWheelInfo& addWheel( const btVector3& connectionPointCS0, const btVector3& wheelDirectionCS0,const btVector3& wheelAxleCS,btScalar suspensionRestLength,btScalar wheelRadius,const btVehicleTuning& tuning, bool isFrontWheel); + btWheelInfo& addWheel(const btVector3& connectionPointCS0, const btVector3& wheelDirectionCS0, const btVector3& wheelAxleCS, btScalar suspensionRestLength, btScalar wheelRadius, const btVehicleTuning& tuning, bool isFrontWheel); - inline int getNumWheels() const { - return int (m_wheelInfo.size()); + inline int getNumWheels() const + { + return int(m_wheelInfo.size()); } - - btAlignedObjectArray<btWheelInfo> m_wheelInfo; + btAlignedObjectArray<btWheelInfo> m_wheelInfo; - const btWheelInfo& getWheelInfo(int index) const; + const btWheelInfo& getWheelInfo(int index) const; - btWheelInfo& getWheelInfo(int index); + btWheelInfo& getWheelInfo(int index); - void updateWheelTransformsWS(btWheelInfo& wheel , bool interpolatedTransform = true); + void updateWheelTransformsWS(btWheelInfo& wheel, bool interpolatedTransform = true); - - void setBrake(btScalar brake,int wheelIndex); + void setBrake(btScalar brake, int wheelIndex); - void setPitchControl(btScalar pitch) + void setPitchControl(btScalar pitch) { m_pitchControl = pitch; } - - void updateSuspension(btScalar deltaTime); - - virtual void updateFriction(btScalar timeStep); + void updateSuspension(btScalar deltaTime); + virtual void updateFriction(btScalar timeStep); inline btRigidBody* getRigidBody() { @@ -151,7 +140,7 @@ public: return m_chassisBody; } - inline int getRightAxis() const + inline int getRightAxis() const { return m_indexRightAxis; } @@ -165,46 +154,44 @@ public: return m_indexForwardAxis; } - ///Worldspace forward vector btVector3 getForwardVector() const { - const btTransform& chassisTrans = getChassisWorldTransform(); + const btTransform& chassisTrans = getChassisWorldTransform(); - btVector3 forwardW ( - chassisTrans.getBasis()[0][m_indexForwardAxis], - chassisTrans.getBasis()[1][m_indexForwardAxis], - chassisTrans.getBasis()[2][m_indexForwardAxis]); + btVector3 forwardW( + chassisTrans.getBasis()[0][m_indexForwardAxis], + chassisTrans.getBasis()[1][m_indexForwardAxis], + chassisTrans.getBasis()[2][m_indexForwardAxis]); return forwardW; } ///Velocity of vehicle (positive if velocity vector has same direction as foward vector) - btScalar getCurrentSpeedKmHour() const + btScalar getCurrentSpeedKmHour() const { return m_currentVehicleSpeedKmHour; } - virtual void setCoordinateSystem(int rightIndex,int upIndex,int forwardIndex) + virtual void setCoordinateSystem(int rightIndex, int upIndex, int forwardIndex) { m_indexRightAxis = rightIndex; m_indexUpAxis = upIndex; m_indexForwardAxis = forwardIndex; } - ///backwards compatibility int getUserConstraintType() const { - return m_userConstraintType ; + return m_userConstraintType; } - void setUserConstraintType(int userConstraintType) + void setUserConstraintType(int userConstraintType) { m_userConstraintType = userConstraintType; }; - void setUserConstraintId(int uid) + void setUserConstraintId(int uid) { m_userConstraintId = uid; } @@ -213,22 +200,19 @@ public: { return m_userConstraintId; } - }; class btDefaultVehicleRaycaster : public btVehicleRaycaster { - btDynamicsWorld* m_dynamicsWorld; + btDynamicsWorld* m_dynamicsWorld; + public: btDefaultVehicleRaycaster(btDynamicsWorld* world) - :m_dynamicsWorld(world) + : m_dynamicsWorld(world) { } - virtual void* castRay(const btVector3& from,const btVector3& to, btVehicleRaycasterResult& result); - + virtual void* castRay(const btVector3& from, const btVector3& to, btVehicleRaycasterResult& result); }; - -#endif //BT_RAYCASTVEHICLE_H - +#endif //BT_RAYCASTVEHICLE_H |