25 #define ROLLING_INFLUENCE_FIX
35 : m_vehicleRaycaster(raycaster),
38 m_chassisBody = chassis;
41 m_indexForwardAxis = 1;
45 void btRaycastVehicle::defaultInit(
const btVehicleTuning& tuning)
48 m_currentVehicleSpeedKmHour =
btScalar(0.);
99 fwd = fwd.normalize();
113 basis2[0][m_indexRightAxis] = -
right[0];
114 basis2[1][m_indexRightAxis] = -
right[1];
115 basis2[2][m_indexRightAxis] = -
right[2];
117 basis2[0][m_indexUpAxis] = up[0];
118 basis2[1][m_indexUpAxis] = up[1];
119 basis2[2][m_indexUpAxis] = up[2];
121 basis2[0][m_indexForwardAxis] = fwd[0];
122 basis2[1][m_indexForwardAxis] = fwd[1];
123 basis2[2][m_indexForwardAxis] = fwd[2];
150 if (interpolatedTransform && (
getRigidBody()->getMotionState()))
179 void*
object = m_vehicleRaycaster->
castRay(source, target, rayResults);
193 btScalar hitDistance = param * raylen;
212 btVector3 chassis_velocity_at_contactPoint;
270 chassisTrans.getBasis()[0][m_indexForwardAxis],
271 chassisTrans.getBasis()[1][m_indexForwardAxis],
272 chassisTrans.getBasis()[2][m_indexForwardAxis]);
276 m_currentVehicleSpeedKmHour *=
btScalar(-1.);
323 chassisWorldTransform.getBasis()[0][m_indexForwardAxis],
324 chassisWorldTransform.getBasis()[1][m_indexForwardAxis],
325 chassisWorldTransform.getBasis()[2][m_indexForwardAxis]);
402 btScalar length_diff = (susp_length - current_length);
412 if (projected_rel_vel <
btScalar(0.0))
420 force -= susp_damping * projected_rel_vel;
495 m_forwardWS.
resize(numWheel);
497 m_forwardImpulse.
resize(numWheel);
498 m_sideImpulse.
resize(numWheel);
500 int numWheelsOnGround = 0;
526 wheelBasis0[0][m_indexRightAxis],
527 wheelBasis0[1][m_indexRightAxis],
528 wheelBasis0[2][m_indexRightAxis]);
531 btScalar proj = m_axle[i].dot(surfNormalWS);
532 m_axle[i] -= surfNormalWS * proj;
533 m_axle[i] = m_axle[i].normalize();
535 m_forwardWS[i] = surfNormalWS.cross(m_axle[i]);
536 m_forwardWS[i].normalize();
540 btScalar(0.), m_axle[i], m_sideImpulse[i], timeStep);
550 bool sliding =
false;
567 btScalar defaultRollingFrictionImpulse = 0.f;
577 m_forwardImpulse[wheel] =
btScalar(0.);
587 btScalar maximpSquared = maximp * maximpSide;
589 m_forwardImpulse[wheel] = rollingFriction;
591 btScalar x = (m_forwardImpulse[wheel]) * fwdFactor;
592 btScalar y = (m_sideImpulse[wheel]) * sideFactor;
596 if (impulseSquared > maximpSquared)
612 if (m_sideImpulse[wheel] !=
btScalar(0.))
616 m_forwardImpulse[wheel] *=
m_wheelInfo[wheel].m_skidInfo;
617 m_sideImpulse[wheel] *=
m_wheelInfo[wheel].m_skidInfo;
632 if (m_forwardImpulse[wheel] !=
btScalar(0.))
634 m_chassisBody->
applyImpulse(m_forwardWS[wheel] * (m_forwardImpulse[wheel]), rel_pos);
636 if (m_sideImpulse[wheel] !=
btScalar(0.))
643 btVector3 sideImp = m_axle[wheel] * m_sideImpulse[wheel];
645 #if defined ROLLING_INFLUENCE_FIX
647 rel_pos -= vChassisWorldUp * (vChassisWorldUp.dot(rel_pos) * (1.f - wheelInfo.
m_rollInfluence));
667 wheelColor.setValue(0, 0, 1);
671 wheelColor.setValue(1, 0, 1);
682 debugDrawer->
drawLine(wheelPosWS, wheelPosWS + axle, wheelColor);
698 if (body && body->hasContactResponse())
702 result.m_hitNormalInWorld.normalize();
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint y
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint GLsizei GLsizei GLenum type _GL_VOID_RET _GL_VOID GLsizei GLenum GLenum const void *pixels _GL_VOID_RET _GL_VOID const void *pointer _GL_VOID_RET _GL_VOID GLdouble v _GL_VOID_RET _GL_VOID GLfloat v _GL_VOID_RET _GL_VOID GLint GLint i2 _GL_VOID_RET _GL_VOID GLint j _GL_VOID_RET _GL_VOID GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLdouble right
ATTR_WARN_UNUSED_RESULT const BMVert * v
virtual btVector3 getLinearVelocity() const
btMatrix3x3
The btMatrix3x3 class implements a 3x3 rotation matrix, to perform linear algebra in combination with...
SIMD_FORCE_INLINE void btSetMin(T &a, const T &b)
SIMD_FORCE_INLINE void btSetMax(T &a, const T &b)
btScalar calcRollingFriction(btWheelContactPoint &contactPoint, int numWheelsOnGround)
btScalar sideFrictionStiffness2
float btScalar
The btScalar type abstracts floating point numbers, to easily switch between double and single floati...
SIMD_FORCE_INLINE btScalar btSqrt(btScalar y)
btTransform m_worldTransform
btVector3
btVector3 can be used to represent 3D points and vectors. It has an un-used w component to suit 16-by...
static btRigidBody & getFixedBody()
SIMD_FORCE_INLINE int size() const
return the number of elements in the array
SIMD_FORCE_INLINE void resize(int newsize, const T &fillData=T())
SIMD_FORCE_INLINE void push_back(const T &_Val)
virtual void rayTest(const btVector3 &rayFromWorld, const btVector3 &rayToWorld, RayResultCallback &resultCallback) const
virtual void * castRay(const btVector3 &from, const btVector3 &to, btVehicleRaycasterResult &result)
virtual void drawLine(const btVector3 &from, const btVector3 &to, const btVector3 &color)=0
virtual void getWorldTransform(btTransform &worldTrans) const =0
The btQuaternion implements quaternion to perform linear algebra rotations in combination with btMatr...
btScalar m_maxSuspensionTravelCm
btScalar m_suspensionStiffness
btScalar m_maxSuspensionForce
btScalar m_suspensionDamping
btScalar m_suspensionCompression
virtual void updateFriction(btScalar timeStep)
void updateWheelTransformsWS(btWheelInfo &wheel, bool interpolatedTransform=true)
const btTransform & getWheelTransformWS(int wheelIndex) const
btScalar rayCast(btWheelInfo &wheel)
btScalar getSteeringValue(int wheel) const
void setBrake(btScalar brake, int wheelIndex)
void updateSuspension(btScalar deltaTime)
virtual ~btRaycastVehicle()
btRaycastVehicle(const btVehicleTuning &tuning, btRigidBody *chassis, btVehicleRaycaster *raycaster)
virtual void updateVehicle(btScalar step)
btAlignedObjectArray< btWheelInfo > m_wheelInfo
void applyEngineForce(btScalar force, int wheel)
btWheelInfo & addWheel(const btVector3 &connectionPointCS0, const btVector3 &wheelDirectionCS0, const btVector3 &wheelAxleCS, btScalar suspensionRestLength, btScalar wheelRadius, const btVehicleTuning &tuning, bool isFrontWheel)
void debugDraw(btIDebugDraw *debugDrawer)
btActionInterface interface
const btTransform & getChassisWorldTransform() const
void updateWheelTransform(int wheelIndex, bool interpolatedTransform=true)
const btWheelInfo & getWheelInfo(int index) const
btRigidBody * getRigidBody()
void setSteeringValue(btScalar steering, int wheel)
btVector3 getVelocityInLocalPoint(const btVector3 &rel_pos) const
btMotionState * getMotionState()
btScalar getInvMass() const
static const btRigidBody * upcast(const btCollisionObject *colObj)
void applyImpulse(const btVector3 &impulse, const btVector3 &rel_pos)
SIMD_FORCE_INLINE btScalar computeImpulseDenominator(const btVector3 &pos, const btVector3 &normal) const
void setMassProps(btScalar mass, const btVector3 &inertia)
const btTransform & getCenterOfMassTransform() const
const btVector3 & getLinearVelocity() const
const btVector3 & getCenterOfMassPosition() const
SyclQueue void void size_t num_bytes void
btVector3 m_hitPointWorld
btVector3 m_hitNormalWorld
btScalar m_closestHitFraction
const btCollisionObject * m_collisionObject
btVector3 m_hitNormalInWorld
btVector3 m_hitPointInWorld
btVehicleRaycaster is provides interface for between vehicle simulation and raycasting
virtual void * castRay(const btVector3 &from, const btVector3 &to, btVehicleRaycasterResult &result)=0
btScalar m_suspensionRestLength
btScalar m_wheelsDampingRelaxation
btVector3 m_wheelDirectionCS
btScalar m_wheelsDampingCompression
btScalar m_maxSuspensionForce
btScalar m_maxSuspensionTravelCm
btScalar m_suspensionStiffness
btVector3 m_chassisConnectionCS
btScalar m_suspensionLength
btVector3 m_contactPointWS
btVector3 m_wheelDirectionWS
btVector3 m_contactNormalWS
btWheelInfo contains information per wheel about friction and suspension.
btScalar m_clippedInvContactDotSuspension
btScalar m_suspensionStiffness
btVector3 m_wheelDirectionCS
btScalar getSuspensionRestLength() const
btScalar m_maxSuspensionForce
btScalar m_maxSuspensionTravelCm
btScalar m_wheelsSuspensionForce
btVector3 m_chassisConnectionPointCS
btScalar m_wheelsDampingCompression
btScalar m_suspensionRelativeVelocity
btScalar m_wheelsDampingRelaxation
btTransform m_worldTransform
RaycastInfo m_raycastInfo