Bullet Collision Detection & Physics Library: btRaycastVehicle.cpp Source File

Bullet Collision Detection & Physics Library

btRaycastVehicle.cpp
Go to the documentation of this file.
1 /*
2 * Copyright (c) 2005 Erwin Coumans http://continuousphysics.com/Bullet/
3 *
4 * Permission to use, copy, modify, distribute and sell this software
5 * and its documentation for any purpose is hereby granted without fee,
6 * provided that the above copyright notice appear in all copies.
7 * Erwin Coumans makes no representations about the suitability
8 * of this software for any purpose.
9 * It is provided "as is" without express or implied warranty.
10 */
11
12 #include "LinearMath/btVector3.h"
13 #include "btRaycastVehicle.h"
14
15 #include "BulletDynamics/ConstraintSolver/btSolve2LinearConstraint.h"
16 #include "BulletDynamics/ConstraintSolver/btJacobianEntry.h"
17 #include "LinearMath/btQuaternion.h"
18 #include "BulletDynamics/Dynamics/btDynamicsWorld.h"
19 #include "btVehicleRaycaster.h"
20 #include "btWheelInfo.h"
21 #include "LinearMath/btMinMax.h"
22 #include "LinearMath/btIDebugDraw.h"
23 #include "BulletDynamics/ConstraintSolver/btContactConstraint.h"
24
25 #define ROLLING_INFLUENCE_FIX
26
27 btRigidBody& btActionInterface::getFixedBody()
28 {
29 static btRigidBody s_fixed(0, 0, 0);
30 s_fixed.setMassProps(btScalar(0.), btVector3(btScalar(0.), btScalar(0.), btScalar(0.)));
31 return s_fixed;
32 }
33
34 btRaycastVehicle::btRaycastVehicle(const btVehicleTuning& tuning, btRigidBody* chassis, btVehicleRaycaster* raycaster)
35 : m_vehicleRaycaster(raycaster),
36 m_pitchControl(btScalar(0.))
37 {
38 m_chassisBody = chassis;
39 m_indexRightAxis = 0;
40 m_indexUpAxis = 2;
41 m_indexForwardAxis = 1;
42 defaultInit(tuning);
43 }
44
45 void btRaycastVehicle::defaultInit(const btVehicleTuning& tuning)
46 {
47 (void)tuning;
48 m_currentVehicleSpeedKmHour = btScalar(0.);
49 m_steeringValue = btScalar(0.);
50 }
51
52 btRaycastVehicle::~btRaycastVehicle()
53 {
54 }
55
56 //
57 // basically most of the code is general for 2 or 4 wheel vehicles, but some of it needs to be reviewed
58 //
59 btWheelInfo& btRaycastVehicle::addWheel(const btVector3& connectionPointCS, const btVector3& wheelDirectionCS0, const btVector3& wheelAxleCS, btScalar suspensionRestLength, btScalar wheelRadius, const btVehicleTuning& tuning, bool isFrontWheel)
60 {
61 btWheelInfoConstructionInfo ci;
62
63 ci.m_chassisConnectionCS = connectionPointCS;
64 ci.m_wheelDirectionCS = wheelDirectionCS0;
65 ci.m_wheelAxleCS = wheelAxleCS;
66 ci.m_suspensionRestLength = suspensionRestLength;
67 ci.m_wheelRadius = wheelRadius;
68 ci.m_suspensionStiffness = tuning.m_suspensionStiffness;
69 ci.m_wheelsDampingCompression = tuning.m_suspensionCompression;
70 ci.m_wheelsDampingRelaxation = tuning.m_suspensionDamping;
71 ci.m_frictionSlip = tuning.m_frictionSlip;
72 ci.m_bIsFrontWheel = isFrontWheel;
73 ci.m_maxSuspensionTravelCm = tuning.m_maxSuspensionTravelCm;
74 ci.m_maxSuspensionForce = tuning.m_maxSuspensionForce;
75
76 m_wheelInfo.push_back(btWheelInfo(ci));
77
78 btWheelInfo& wheel = m_wheelInfo[getNumWheels() - 1];
79
80 updateWheelTransformsWS(wheel, false);
81 updateWheelTransform(getNumWheels() - 1, false);
82 return wheel;
83 }
84
85 const btTransform& btRaycastVehicle::getWheelTransformWS(int wheelIndex) const
86 {
87 btAssert(wheelIndex < getNumWheels());
88 const btWheelInfo& wheel = m_wheelInfo[wheelIndex];
89 return wheel.m_worldTransform;
90 }
91
92 void btRaycastVehicle::updateWheelTransform(int wheelIndex, bool interpolatedTransform)
93 {
94 btWheelInfo& wheel = m_wheelInfo[wheelIndex];
95 updateWheelTransformsWS(wheel, interpolatedTransform);
96 btVector3 up = -wheel.m_raycastInfo.m_wheelDirectionWS;
97 const btVector3& right = wheel.m_raycastInfo.m_wheelAxleWS;
98 btVector3 fwd = up.cross(right);
99 fwd = fwd.normalize();
100 // up = right.cross(fwd);
101 // up.normalize();
102
103 //rotate around steering over de wheelAxleWS
104 btScalar steering = wheel.m_steering;
105
106 btQuaternion steeringOrn(up, steering); //wheel.m_steering);
107 btMatrix3x3 steeringMat(steeringOrn);
108
109 btQuaternion rotatingOrn(right, -wheel.m_rotation);
110 btMatrix3x3 rotatingMat(rotatingOrn);
111
112 btMatrix3x3 basis2;
113 basis2[0][m_indexRightAxis] = -right[0];
114 basis2[1][m_indexRightAxis] = -right[1];
115 basis2[2][m_indexRightAxis] = -right[2];
116
117 basis2[0][m_indexUpAxis] = up[0];
118 basis2[1][m_indexUpAxis] = up[1];
119 basis2[2][m_indexUpAxis] = up[2];
120
121 basis2[0][m_indexForwardAxis] = fwd[0];
122 basis2[1][m_indexForwardAxis] = fwd[1];
123 basis2[2][m_indexForwardAxis] = fwd[2];
124
125 wheel.m_worldTransform.setBasis(steeringMat * rotatingMat * basis2);
126 wheel.m_worldTransform.setOrigin(
127 wheel.m_raycastInfo.m_hardPointWS + wheel.m_raycastInfo.m_wheelDirectionWS * wheel.m_raycastInfo.m_suspensionLength);
128 }
129
130 void btRaycastVehicle::resetSuspension()
131 {
132 int i;
133 for (i = 0; i < m_wheelInfo.size(); i++)
134 {
135 btWheelInfo& wheel = m_wheelInfo[i];
136 wheel.m_raycastInfo.m_suspensionLength = wheel.getSuspensionRestLength();
137 wheel.m_suspensionRelativeVelocity = btScalar(0.0);
138
139 wheel.m_raycastInfo.m_contactNormalWS = -wheel.m_raycastInfo.m_wheelDirectionWS;
140 //wheel_info.setContactFriction(btScalar(0.0));
141 wheel.m_clippedInvContactDotSuspension = btScalar(1.0);
142 }
143 }
144
145 void btRaycastVehicle::updateWheelTransformsWS(btWheelInfo& wheel, bool interpolatedTransform)
146 {
147 wheel.m_raycastInfo.m_isInContact = false;
148
149 btTransform chassisTrans = getChassisWorldTransform();
150 if (interpolatedTransform && (getRigidBody()->getMotionState()))
151 {
152 getRigidBody()->getMotionState()->getWorldTransform(chassisTrans);
153 }
154
155 wheel.m_raycastInfo.m_hardPointWS = chassisTrans(wheel.m_chassisConnectionPointCS);
156 wheel.m_raycastInfo.m_wheelDirectionWS = chassisTrans.getBasis() * wheel.m_wheelDirectionCS;
157 wheel.m_raycastInfo.m_wheelAxleWS = chassisTrans.getBasis() * wheel.m_wheelAxleCS;
158 }
159
160 btScalar btRaycastVehicle::rayCast(btWheelInfo& wheel)
161 {
162 updateWheelTransformsWS(wheel, false);
163
164 btScalar depth = -1;
165
166 btScalar raylen = wheel.getSuspensionRestLength() + wheel.m_wheelsRadius;
167
168 btVector3 rayvector = wheel.m_raycastInfo.m_wheelDirectionWS * (raylen);
169 const btVector3& source = wheel.m_raycastInfo.m_hardPointWS;
170 wheel.m_raycastInfo.m_contactPointWS = source + rayvector;
171 const btVector3& target = wheel.m_raycastInfo.m_contactPointWS;
172
173 btScalar param = btScalar(0.);
174
175 btVehicleRaycaster::btVehicleRaycasterResult rayResults;
176
177 btAssert(m_vehicleRaycaster);
178
179 void* object = m_vehicleRaycaster->castRay(source, target, rayResults);
180
181 wheel.m_raycastInfo.m_groundObject = 0;
182
183 if (object)
184 {
185 param = rayResults.m_distFraction;
186 depth = raylen * rayResults.m_distFraction;
187 wheel.m_raycastInfo.m_contactNormalWS = rayResults.m_hitNormalInWorld;
188 wheel.m_raycastInfo.m_isInContact = true;
189
190 wheel.m_raycastInfo.m_groundObject = &getFixedBody();
191 //wheel.m_raycastInfo.m_groundObject = object;
192
193 btScalar hitDistance = param * raylen;
194 wheel.m_raycastInfo.m_suspensionLength = hitDistance - wheel.m_wheelsRadius;
195 //clamp on max suspension travel
196
197 btScalar minSuspensionLength = wheel.getSuspensionRestLength() - wheel.m_maxSuspensionTravelCm * btScalar(0.01);
198 btScalar maxSuspensionLength = wheel.getSuspensionRestLength() + wheel.m_maxSuspensionTravelCm * btScalar(0.01);
199 if (wheel.m_raycastInfo.m_suspensionLength < minSuspensionLength)
200 {
201 wheel.m_raycastInfo.m_suspensionLength = minSuspensionLength;
202 }
203 if (wheel.m_raycastInfo.m_suspensionLength > maxSuspensionLength)
204 {
205 wheel.m_raycastInfo.m_suspensionLength = maxSuspensionLength;
206 }
207
208 wheel.m_raycastInfo.m_contactPointWS = rayResults.m_hitPointInWorld;
209
210 btScalar denominator = wheel.m_raycastInfo.m_contactNormalWS.dot(wheel.m_raycastInfo.m_wheelDirectionWS);
211
212 btVector3 chassis_velocity_at_contactPoint;
213 btVector3 relpos = wheel.m_raycastInfo.m_contactPointWS - getRigidBody()->getCenterOfMassPosition();
214
215 chassis_velocity_at_contactPoint = getRigidBody()->getVelocityInLocalPoint(relpos);
216
217 btScalar projVel = wheel.m_raycastInfo.m_contactNormalWS.dot(chassis_velocity_at_contactPoint);
218
219 if (denominator >= btScalar(-0.1))
220 {
221 wheel.m_suspensionRelativeVelocity = btScalar(0.0);
222 wheel.m_clippedInvContactDotSuspension = btScalar(1.0) / btScalar(0.1);
223 }
224 else
225 {
226 btScalar inv = btScalar(-1.) / denominator;
227 wheel.m_suspensionRelativeVelocity = projVel * inv;
228 wheel.m_clippedInvContactDotSuspension = inv;
229 }
230 }
231 else
232 {
233 //put wheel info as in rest position
234 wheel.m_raycastInfo.m_suspensionLength = wheel.getSuspensionRestLength();
235 wheel.m_suspensionRelativeVelocity = btScalar(0.0);
236 wheel.m_raycastInfo.m_contactNormalWS = -wheel.m_raycastInfo.m_wheelDirectionWS;
237 wheel.m_clippedInvContactDotSuspension = btScalar(1.0);
238 }
239
240 return depth;
241 }
242
243 const btTransform& btRaycastVehicle::getChassisWorldTransform() const
244 {
245 /*if (getRigidBody()->getMotionState())
246 {
247 btTransform chassisWorldTrans;
248 getRigidBody()->getMotionState()->getWorldTransform(chassisWorldTrans);
249 return chassisWorldTrans;
250 }
251 */
252
253 return getRigidBody()->getCenterOfMassTransform();
254 }
255
256 void btRaycastVehicle::updateVehicle(btScalar step)
257 {
258 {
259 for (int i = 0; i < getNumWheels(); i++)
260 {
261 updateWheelTransform(i, false);
262 }
263 }
264
265 m_currentVehicleSpeedKmHour = btScalar(3.6) * getRigidBody()->getLinearVelocity().length();
266
267 const btTransform& chassisTrans = getChassisWorldTransform();
268
269 btVector3 forwardW(
270 chassisTrans.getBasis()[0][m_indexForwardAxis],
271 chassisTrans.getBasis()[1][m_indexForwardAxis],
272 chassisTrans.getBasis()[2][m_indexForwardAxis]);
273
274 if (forwardW.dot(getRigidBody()->getLinearVelocity()) < btScalar(0.))
275 {
276 m_currentVehicleSpeedKmHour *= btScalar(-1.);
277 }
278
279 //
280 // simulate suspension
281 //
282
283 int i = 0;
284 for (i = 0; i < m_wheelInfo.size(); i++)
285 {
286 //btScalar depth;
287 //depth =
288 rayCast(m_wheelInfo[i]);
289 }
290
291 updateSuspension(step);
292
293 for (i = 0; i < m_wheelInfo.size(); i++)
294 {
295 //apply suspension force
296 btWheelInfo& wheel = m_wheelInfo[i];
297
298 btScalar suspensionForce = wheel.m_wheelsSuspensionForce;
299
300 if (suspensionForce > wheel.m_maxSuspensionForce)
301 {
302 suspensionForce = wheel.m_maxSuspensionForce;
303 }
304 btVector3 impulse = wheel.m_raycastInfo.m_contactNormalWS * suspensionForce * step;
305 btVector3 relpos = wheel.m_raycastInfo.m_contactPointWS - getRigidBody()->getCenterOfMassPosition();
306
307 getRigidBody()->applyImpulse(impulse, relpos);
308 }
309
310 updateFriction(step);
311
312 for (i = 0; i < m_wheelInfo.size(); i++)
313 {
314 btWheelInfo& wheel = m_wheelInfo[i];
315 btVector3 relpos = wheel.m_raycastInfo.m_hardPointWS - getRigidBody()->getCenterOfMassPosition();
316 btVector3 vel = getRigidBody()->getVelocityInLocalPoint(relpos);
317
318 if (wheel.m_raycastInfo.m_isInContact)
319 {
320 const btTransform& chassisWorldTransform = getChassisWorldTransform();
321
322 btVector3 fwd(
323 chassisWorldTransform.getBasis()[0][m_indexForwardAxis],
324 chassisWorldTransform.getBasis()[1][m_indexForwardAxis],
325 chassisWorldTransform.getBasis()[2][m_indexForwardAxis]);
326
327 btScalar proj = fwd.dot(wheel.m_raycastInfo.m_contactNormalWS);
328 fwd -= wheel.m_raycastInfo.m_contactNormalWS * proj;
329
330 btScalar proj2 = fwd.dot(vel);
331
332 wheel.m_deltaRotation = (proj2 * step) / (wheel.m_wheelsRadius);
333 wheel.m_rotation += wheel.m_deltaRotation;
334 }
335 else
336 {
337 wheel.m_rotation += wheel.m_deltaRotation;
338 }
339
340 wheel.m_deltaRotation *= btScalar(0.99); //damping of rotation when not in contact
341 }
342 }
343
344 void btRaycastVehicle::setSteeringValue(btScalar steering, int wheel)
345 {
346 btAssert(wheel >= 0 && wheel < getNumWheels());
347
348 btWheelInfo& wheelInfo = getWheelInfo(wheel);
349 wheelInfo.m_steering = steering;
350 }
351
352 btScalar btRaycastVehicle::getSteeringValue(int wheel) const
353 {
354 return getWheelInfo(wheel).m_steering;
355 }
356
357 void btRaycastVehicle::applyEngineForce(btScalar force, int wheel)
358 {
359 btAssert(wheel >= 0 && wheel < getNumWheels());
360 btWheelInfo& wheelInfo = getWheelInfo(wheel);
361 wheelInfo.m_engineForce = force;
362 }
363
364 const btWheelInfo& btRaycastVehicle::getWheelInfo(int index) const
365 {
366 btAssert((index >= 0) && (index < getNumWheels()));
367
368 return m_wheelInfo[index];
369 }
370
371 btWheelInfo& btRaycastVehicle::getWheelInfo(int index)
372 {
373 btAssert((index >= 0) && (index < getNumWheels()));
374
375 return m_wheelInfo[index];
376 }
377
378 void btRaycastVehicle::setBrake(btScalar brake, int wheelIndex)
379 {
380 btAssert((wheelIndex >= 0) && (wheelIndex < getNumWheels()));
381 getWheelInfo(wheelIndex).m_brake = brake;
382 }
383
384 void btRaycastVehicle::updateSuspension(btScalar deltaTime)
385 {
386 (void)deltaTime;
387
388 btScalar chassisMass = btScalar(1.) / m_chassisBody->getInvMass();
389
390 for (int w_it = 0; w_it < getNumWheels(); w_it++)
391 {
392 btWheelInfo& wheel_info = m_wheelInfo[w_it];
393
394 if (wheel_info.m_raycastInfo.m_isInContact)
395 {
396 btScalar force;
397 // Spring
398 {
399 btScalar susp_length = wheel_info.getSuspensionRestLength();
400 btScalar current_length = wheel_info.m_raycastInfo.m_suspensionLength;
401
402 btScalar length_diff = (susp_length - current_length);
403
404 force = wheel_info.m_suspensionStiffness * length_diff * wheel_info.m_clippedInvContactDotSuspension;
405 }
406
407 // Damper
408 {
409 btScalar projected_rel_vel = wheel_info.m_suspensionRelativeVelocity;
410 {
411 btScalar susp_damping;
412 if (projected_rel_vel < btScalar(0.0))
413 {
414 susp_damping = wheel_info.m_wheelsDampingCompression;
415 }
416 else
417 {
418 susp_damping = wheel_info.m_wheelsDampingRelaxation;
419 }
420 force -= susp_damping * projected_rel_vel;
421 }
422 }
423
424 // RESULT
425 wheel_info.m_wheelsSuspensionForce = force * chassisMass;
426 if (wheel_info.m_wheelsSuspensionForce < btScalar(0.))
427 {
428 wheel_info.m_wheelsSuspensionForce = btScalar(0.);
429 }
430 }
431 else
432 {
433 wheel_info.m_wheelsSuspensionForce = btScalar(0.0);
434 }
435 }
436 }
437
438 struct btWheelContactPoint
439 {
440 btRigidBody* m_body0;
441 btRigidBody* m_body1;
442 btVector3 m_frictionPositionWorld;
443 btVector3 m_frictionDirectionWorld;
444 btScalar m_jacDiagABInv;
445 btScalar m_maxImpulse;
446
447 btWheelContactPoint(btRigidBody* body0, btRigidBody* body1, const btVector3& frictionPosWorld, const btVector3& frictionDirectionWorld, btScalar maxImpulse)
448 : m_body0(body0),
449 m_body1(body1),
450 m_frictionPositionWorld(frictionPosWorld),
451 m_frictionDirectionWorld(frictionDirectionWorld),
452 m_maxImpulse(maxImpulse)
453 {
454 btScalar denom0 = body0->computeImpulseDenominator(frictionPosWorld, frictionDirectionWorld);
455 btScalar denom1 = body1->computeImpulseDenominator(frictionPosWorld, frictionDirectionWorld);
456 btScalar relaxation = 1.f;
457 m_jacDiagABInv = relaxation / (denom0 + denom1);
458 }
459 };
460
461 btScalar calcRollingFriction(btWheelContactPoint& contactPoint, int numWheelsOnGround);
462 btScalar calcRollingFriction(btWheelContactPoint& contactPoint, int numWheelsOnGround)
463 {
464 btScalar j1 = 0.f;
465
466 const btVector3& contactPosWorld = contactPoint.m_frictionPositionWorld;
467
468 btVector3 rel_pos1 = contactPosWorld - contactPoint.m_body0->getCenterOfMassPosition();
469 btVector3 rel_pos2 = contactPosWorld - contactPoint.m_body1->getCenterOfMassPosition();
470
471 btScalar maxImpulse = contactPoint.m_maxImpulse;
472
473 btVector3 vel1 = contactPoint.m_body0->getVelocityInLocalPoint(rel_pos1);
474 btVector3 vel2 = contactPoint.m_body1->getVelocityInLocalPoint(rel_pos2);
475 btVector3 vel = vel1 - vel2;
476
477 btScalar vrel = contactPoint.m_frictionDirectionWorld.dot(vel);
478
479 // calculate j that moves us to zero relative velocity
480 j1 = -vrel * contactPoint.m_jacDiagABInv / btScalar(numWheelsOnGround);
481 btSetMin(j1, maxImpulse);
482 btSetMax(j1, -maxImpulse);
483
484 return j1;
485 }
486
487 btScalar sideFrictionStiffness2 = btScalar(1.0);
488 void btRaycastVehicle::updateFriction(btScalar timeStep)
489 {
490 //calculate the impulse, so that the wheels don't move sidewards
491 int numWheel = getNumWheels();
492 if (!numWheel)
493 return;
494
495 m_forwardWS.resize(numWheel);
496 m_axle.resize(numWheel);
497 m_forwardImpulse.resize(numWheel);
498 m_sideImpulse.resize(numWheel);
499
500 int numWheelsOnGround = 0;
501
502 //collapse all those loops into one!
503 for (int i = 0; i < getNumWheels(); i++)
504 {
505 btWheelInfo& wheelInfo = m_wheelInfo[i];
506 class btRigidBody* groundObject = (class btRigidBody*)wheelInfo.m_raycastInfo.m_groundObject;
507 if (groundObject)
508 numWheelsOnGround++;
509 m_sideImpulse[i] = btScalar(0.);
510 m_forwardImpulse[i] = btScalar(0.);
511 }
512
513 {
514 for (int i = 0; i < getNumWheels(); i++)
515 {
516 btWheelInfo& wheelInfo = m_wheelInfo[i];
517
518 class btRigidBody* groundObject = (class btRigidBody*)wheelInfo.m_raycastInfo.m_groundObject;
519
520 if (groundObject)
521 {
522 const btTransform& wheelTrans = getWheelTransformWS(i);
523
524 btMatrix3x3 wheelBasis0 = wheelTrans.getBasis();
525 m_axle[i] = -btVector3(
526 wheelBasis0[0][m_indexRightAxis],
527 wheelBasis0[1][m_indexRightAxis],
528 wheelBasis0[2][m_indexRightAxis]);
529
530 const btVector3& surfNormalWS = wheelInfo.m_raycastInfo.m_contactNormalWS;
531 btScalar proj = m_axle[i].dot(surfNormalWS);
532 m_axle[i] -= surfNormalWS * proj;
533 m_axle[i] = m_axle[i].normalize();
534
535 m_forwardWS[i] = surfNormalWS.cross(m_axle[i]);
536 m_forwardWS[i].normalize();
537
538 resolveSingleBilateral(*m_chassisBody, wheelInfo.m_raycastInfo.m_contactPointWS,
539 *groundObject, wheelInfo.m_raycastInfo.m_contactPointWS,
540 btScalar(0.), m_axle[i], m_sideImpulse[i], timeStep);
541
542 m_sideImpulse[i] *= sideFrictionStiffness2;
543 }
544 }
545 }
546
547 btScalar sideFactor = btScalar(1.);
548 btScalar fwdFactor = 0.5;
549
550 bool sliding = false;
551 {
552 for (int wheel = 0; wheel < getNumWheels(); wheel++)
553 {
554 btWheelInfo& wheelInfo = m_wheelInfo[wheel];
555 class btRigidBody* groundObject = (class btRigidBody*)wheelInfo.m_raycastInfo.m_groundObject;
556
557 btScalar rollingFriction = 0.f;
558
559 if (groundObject)
560 {
561 if (wheelInfo.m_engineForce != 0.f)
562 {
563 rollingFriction = wheelInfo.m_engineForce * timeStep;
564 }
565 else
566 {
567 btScalar defaultRollingFrictionImpulse = 0.f;
568 btScalar maxImpulse = wheelInfo.m_brake ? wheelInfo.m_brake : defaultRollingFrictionImpulse;
569 btWheelContactPoint contactPt(m_chassisBody, groundObject, wheelInfo.m_raycastInfo.m_contactPointWS, m_forwardWS[wheel], maxImpulse);
570 btAssert(numWheelsOnGround > 0);
571 rollingFriction = calcRollingFriction(contactPt, numWheelsOnGround);
572 }
573 }
574
575 //switch between active rolling (throttle), braking and non-active rolling friction (no throttle/break)
576
577 m_forwardImpulse[wheel] = btScalar(0.);
578 m_wheelInfo[wheel].m_skidInfo = btScalar(1.);
579
580 if (groundObject)
581 {
582 m_wheelInfo[wheel].m_skidInfo = btScalar(1.);
583
584 btScalar maximp = wheelInfo.m_wheelsSuspensionForce * timeStep * wheelInfo.m_frictionSlip;
585 btScalar maximpSide = maximp;
586
587 btScalar maximpSquared = maximp * maximpSide;
588
589 m_forwardImpulse[wheel] = rollingFriction; //wheelInfo.m_engineForce* timeStep;
590
591 btScalar x = (m_forwardImpulse[wheel]) * fwdFactor;
592 btScalar y = (m_sideImpulse[wheel]) * sideFactor;
593
594 btScalar impulseSquared = (x * x + y * y);
595
596 if (impulseSquared > maximpSquared)
597 {
598 sliding = true;
599
600 btScalar factor = maximp / btSqrt(impulseSquared);
601
602 m_wheelInfo[wheel].m_skidInfo *= factor;
603 }
604 }
605 }
606 }
607
608 if (sliding)
609 {
610 for (int wheel = 0; wheel < getNumWheels(); wheel++)
611 {
612 if (m_sideImpulse[wheel] != btScalar(0.))
613 {
614 if (m_wheelInfo[wheel].m_skidInfo < btScalar(1.))
615 {
616 m_forwardImpulse[wheel] *= m_wheelInfo[wheel].m_skidInfo;
617 m_sideImpulse[wheel] *= m_wheelInfo[wheel].m_skidInfo;
618 }
619 }
620 }
621 }
622
623 // apply the impulses
624 {
625 for (int wheel = 0; wheel < getNumWheels(); wheel++)
626 {
627 btWheelInfo& wheelInfo = m_wheelInfo[wheel];
628
629 btVector3 rel_pos = wheelInfo.m_raycastInfo.m_contactPointWS -
630 m_chassisBody->getCenterOfMassPosition();
631
632 if (m_forwardImpulse[wheel] != btScalar(0.))
633 {
634 m_chassisBody->applyImpulse(m_forwardWS[wheel] * (m_forwardImpulse[wheel]), rel_pos);
635 }
636 if (m_sideImpulse[wheel] != btScalar(0.))
637 {
638 class btRigidBody* groundObject = (class btRigidBody*)m_wheelInfo[wheel].m_raycastInfo.m_groundObject;
639
640 btVector3 rel_pos2 = wheelInfo.m_raycastInfo.m_contactPointWS -
641 groundObject->getCenterOfMassPosition();
642
643 btVector3 sideImp = m_axle[wheel] * m_sideImpulse[wheel];
644
645 #if defined ROLLING_INFLUENCE_FIX // fix. It only worked if car's up was along Y - VT.
646 btVector3 vChassisWorldUp = getRigidBody()->getCenterOfMassTransform().getBasis().getColumn(m_indexUpAxis);
647 rel_pos -= vChassisWorldUp * (vChassisWorldUp.dot(rel_pos) * (1.f - wheelInfo.m_rollInfluence));
648 #else
649 rel_pos[m_indexUpAxis] *= wheelInfo.m_rollInfluence;
650 #endif
651 m_chassisBody->applyImpulse(sideImp, rel_pos);
652
653 //apply friction impulse on the ground
654 groundObject->applyImpulse(-sideImp, rel_pos2);
655 }
656 }
657 }
658 }
659
660 void btRaycastVehicle::debugDraw(btIDebugDraw* debugDrawer)
661 {
662 for (int v = 0; v < this->getNumWheels(); v++)
663 {
664 btVector3 wheelColor(0, 1, 1);
665 if (getWheelInfo(v).m_raycastInfo.m_isInContact)
666 {
667 wheelColor.setValue(0, 0, 1);
668 }
669 else
670 {
671 wheelColor.setValue(1, 0, 1);
672 }
673
674 btVector3 wheelPosWS = getWheelInfo(v).m_worldTransform.getOrigin();
675
676 btVector3 axle = btVector3(
677 getWheelInfo(v).m_worldTransform.getBasis()[0][getRightAxis()],
678 getWheelInfo(v).m_worldTransform.getBasis()[1][getRightAxis()],
679 getWheelInfo(v).m_worldTransform.getBasis()[2][getRightAxis()]);
680
681 //debug wheels (cylinders)
682 debugDrawer->drawLine(wheelPosWS, wheelPosWS + axle, wheelColor);
683 debugDrawer->drawLine(wheelPosWS, getWheelInfo(v).m_raycastInfo.m_contactPointWS, wheelColor);
684 }
685 }
686
687 void* btDefaultVehicleRaycaster::castRay(const btVector3& from, const btVector3& to, btVehicleRaycasterResult& result)
688 {
689 // RayResultCallback& resultCallback;
690
691 btCollisionWorld::ClosestRayResultCallback rayCallback(from, to);
692
693 m_dynamicsWorld->rayTest(from, to, rayCallback);
694
695 if (rayCallback.hasHit())
696 {
697 const btRigidBody* body = btRigidBody::upcast(rayCallback.m_collisionObject);
698 if (body && body->hasContactResponse())
699 {
700 result.m_hitPointInWorld = rayCallback.m_hitPointWorld;
701 result.m_hitNormalInWorld = rayCallback.m_hitNormalWorld;
702 result.m_hitNormalInWorld.normalize();
703 result.m_distFraction = rayCallback.m_closestHitFraction;
704 return (void*)body;
705 }
706 }
707 return 0;
708 }
btWheelInfo.h
btRaycastVehicle::getNumWheels
int getNumWheels() const
Definition: btRaycastVehicle.h:109
btWheelInfo::m_deltaRotation
btScalar m_deltaRotation
Definition: btWheelInfo.h:69
btWheelInfo::RaycastInfo::m_suspensionLength
btScalar m_suspensionLength
Definition: btWheelInfo.h:44
btDefaultVehicleRaycaster::castRay
virtual void * castRay(const btVector3 &from, const btVector3 &to, btVehicleRaycasterResult &result)
Definition: btRaycastVehicle.cpp:687
btSetMax
void btSetMax(T &a, const T &b)
Definition: btMinMax.h:48
btRaycastVehicle::m_wheelInfo
btAlignedObjectArray< btWheelInfo > m_wheelInfo
Definition: btRaycastVehicle.h:114
btRigidBody
The btRigidBody is the main class for rigid body objects.
Definition: btRigidBody.h:60
btWheelInfo::m_worldTransform
btTransform m_worldTransform
Definition: btWheelInfo.h:54
sideFrictionStiffness2
btScalar sideFrictionStiffness2
Definition: btRaycastVehicle.cpp:487
btWheelInfo::m_suspensionRelativeVelocity
btScalar m_suspensionRelativeVelocity
Definition: btWheelInfo.h:110
btQuaternion
The btQuaternion implements quaternion to perform linear algebra rotations in combination with btMatr...
Definition: btQuaternion.h:50
btVector3::length
btScalar length() const
Return the length of the vector.
Definition: btVector3.h:257
btWheelInfo::m_rollInfluence
btScalar m_rollInfluence
Definition: btWheelInfo.h:70
btRaycastVehicle::btVehicleTuning::m_maxSuspensionTravelCm
btScalar m_maxSuspensionTravelCm
Definition: btRaycastVehicle.h:52
btRaycastVehicle::m_steeringValue
btScalar m_steeringValue
Definition: btRaycastVehicle.h:60
btDefaultVehicleRaycaster::m_dynamicsWorld
btDynamicsWorld * m_dynamicsWorld
Definition: btRaycastVehicle.h:207
btVector3::setValue
void setValue(const btScalar &_x, const btScalar &_y, const btScalar &_z)
Definition: btVector3.h:640
btVehicleRaycaster
btVehicleRaycaster is provides interface for between vehicle simulation and raycasting
Definition: btVehicleRaycaster.h:18
btScalar
float btScalar
The btScalar type abstracts floating point numbers, to easily switch between double and single floati...
Definition: btScalar.h:314
btRaycastVehicle::m_forwardImpulse
btAlignedObjectArray< btScalar > m_forwardImpulse
Definition: btRaycastVehicle.h:29
btWheelInfoConstructionInfo::m_chassisConnectionCS
btVector3 m_chassisConnectionCS
Definition: btWheelInfo.h:21
btVehicleRaycaster::btVehicleRaycasterResult::m_hitNormalInWorld
btVector3 m_hitNormalInWorld
Definition: btVehicleRaycaster.h:26
btVector3::cross
btVector3 cross(const btVector3 &v) const
Return the cross product between this and another vector.
Definition: btVector3.h:380
btWheelInfoConstructionInfo::m_frictionSlip
btScalar m_frictionSlip
Definition: btWheelInfo.h:31
btCollisionWorld::RayResultCallback::hasHit
bool hasHit() const
Definition: btCollisionWorld.h:207
btTransform::setBasis
void setBasis(const btMatrix3x3 &basis)
Set the rotational element by btMatrix3x3.
Definition: btTransform.h:154
btRaycastVehicle::rayCast
btScalar rayCast(btWheelInfo &wheel)
Definition: btRaycastVehicle.cpp:160
btMotionState::getWorldTransform
virtual void getWorldTransform(btTransform &worldTrans) const =0
btRaycastVehicle::getChassisWorldTransform
const btTransform & getChassisWorldTransform() const
Definition: btRaycastVehicle.cpp:243
btWheelContactPoint::m_frictionDirectionWorld
btVector3 m_frictionDirectionWorld
Definition: btRaycastVehicle.cpp:443
btVector3::dot
btScalar dot(const btVector3 &v) const
Return the dot product.
Definition: btVector3.h:229
btRaycastVehicle::btVehicleTuning::m_suspensionStiffness
btScalar m_suspensionStiffness
Definition: btRaycastVehicle.h:49
btRaycastVehicle::m_forwardWS
btAlignedObjectArray< btVector3 > m_forwardWS
Definition: btRaycastVehicle.h:27
btCollisionObject::m_worldTransform
btTransform m_worldTransform
Definition: btCollisionObject.h:52
btRaycastVehicle::btVehicleTuning::m_frictionSlip
btScalar m_frictionSlip
Definition: btRaycastVehicle.h:53
btRaycastVehicle::updateSuspension
void updateSuspension(btScalar deltaTime)
Definition: btRaycastVehicle.cpp:384
btRaycastVehicle::getRigidBody
btRigidBody * getRigidBody()
Definition: btRaycastVehicle.h:133
btActionInterface::getFixedBody
static btRigidBody & getFixedBody()
Definition: btRaycastVehicle.cpp:27
calcRollingFriction
btScalar calcRollingFriction(btWheelContactPoint &contactPoint, int numWheelsOnGround)
Definition: btRaycastVehicle.cpp:462
btWheelInfo::m_rotation
btScalar m_rotation
Definition: btWheelInfo.h:68
btRigidBody::getCenterOfMassTransform
const btTransform & getCenterOfMassTransform() const
Definition: btRigidBody.h:429
btWheelInfo::RaycastInfo::m_contactNormalWS
btVector3 m_contactNormalWS
Definition: btWheelInfo.h:42
btWheelInfo::getSuspensionRestLength
btScalar getSuspensionRestLength() const
Definition: btWheelInfo.cpp:14
btJacobianEntry.h
btWheelInfoConstructionInfo::m_bIsFrontWheel
bool m_bIsFrontWheel
Definition: btWheelInfo.h:33
btWheelInfoConstructionInfo
Definition: btWheelInfo.h:20
btRaycastVehicle::btVehicleTuning::m_suspensionDamping
btScalar m_suspensionDamping
Definition: btRaycastVehicle.h:51
btRaycastVehicle::btVehicleTuning::m_maxSuspensionForce
btScalar m_maxSuspensionForce
Definition: btRaycastVehicle.h:54
btWheelInfoConstructionInfo::m_suspensionStiffness
btScalar m_suspensionStiffness
Definition: btWheelInfo.h:28
btWheelInfoConstructionInfo::m_suspensionRestLength
btScalar m_suspensionRestLength
Definition: btWheelInfo.h:24
btVector3.h
btAssert
#define btAssert(x)
Definition: btScalar.h:153
btWheelContactPoint::m_maxImpulse
btScalar m_maxImpulse
Definition: btRaycastVehicle.cpp:445
btCollisionWorld::RayResultCallback::m_closestHitFraction
btScalar m_closestHitFraction
Definition: btCollisionWorld.h:197
btIDebugDraw
The btIDebugDraw interface class allows hooking up a debug renderer to visually debug simulations.
Definition: btIDebugDraw.h:27
btRaycastVehicle::debugDraw
void debugDraw(btIDebugDraw *debugDrawer)
btActionInterface interface
Definition: btRaycastVehicle.cpp:660
btMinMax.h
btRaycastVehicle::m_indexUpAxis
int m_indexUpAxis
Definition: btRaycastVehicle.h:66
btWheelInfo::m_wheelsSuspensionForce
btScalar m_wheelsSuspensionForce
Definition: btWheelInfo.h:112
btWheelInfo::m_maxSuspensionTravelCm
btScalar m_maxSuspensionTravelCm
Definition: btWheelInfo.h:60
btWheelInfo::m_suspensionStiffness
btScalar m_suspensionStiffness
Definition: btWheelInfo.h:63
btWheelInfoConstructionInfo::m_wheelsDampingCompression
btScalar m_wheelsDampingCompression
Definition: btWheelInfo.h:29
btRaycastVehicle::updateWheelTransform
void updateWheelTransform(int wheelIndex, bool interpolatedTransform=true)
Definition: btRaycastVehicle.cpp:92
btCollisionWorld::ClosestRayResultCallback
Definition: btCollisionWorld.h:233
btAlignedObjectArray::resize
void resize(int newsize, const T &fillData=T())
Definition: btAlignedObjectArray.h:203
btWheelInfo::RaycastInfo::m_groundObject
void * m_groundObject
Definition: btWheelInfo.h:49
btTransform::getBasis
btMatrix3x3 & getBasis()
Return the basis matrix for the rotation.
Definition: btTransform.h:108
btWheelContactPoint::btWheelContactPoint
btWheelContactPoint(btRigidBody *body0, btRigidBody *body1, const btVector3 &frictionPosWorld, const btVector3 &frictionDirectionWorld, btScalar maxImpulse)
Definition: btRaycastVehicle.cpp:447
btRaycastVehicle::btRaycastVehicle
btRaycastVehicle(const btVehicleTuning &tuning, btRigidBody *chassis, btVehicleRaycaster *raycaster)
Definition: btRaycastVehicle.cpp:34
btMatrix3x3
The btMatrix3x3 class implements a 3x3 rotation matrix, to perform linear algebra in combination with...
Definition: btMatrix3x3.h:50
btWheelInfo::RaycastInfo::m_wheelDirectionWS
btVector3 m_wheelDirectionWS
Definition: btWheelInfo.h:46
btRigidBody::getInvMass
btScalar getInvMass() const
Definition: btRigidBody.h:263
btSetMin
void btSetMin(T &a, const T &b)
Definition: btMinMax.h:39
btWheelInfo::RaycastInfo::m_hardPointWS
btVector3 m_hardPointWS
Definition: btWheelInfo.h:45
btTransform
The btTransform class supports rigid transforms with only translation and rotation and no scaling/she...
Definition: btTransform.h:30
btRaycastVehicle::btVehicleTuning::m_suspensionCompression
btScalar m_suspensionCompression
Definition: btRaycastVehicle.h:50
btQuaternion.h
btMatrix3x3::getColumn
btVector3 getColumn(int i) const
Get a column of the matrix as a vector.
Definition: btMatrix3x3.h:142
btVehicleRaycaster::btVehicleRaycasterResult
Definition: btVehicleRaycaster.h:23
btRaycastVehicle::m_indexForwardAxis
int m_indexForwardAxis
Definition: btRaycastVehicle.h:67
btCollisionWorld::RayResultCallback::m_collisionObject
const btCollisionObject * m_collisionObject
Definition: btCollisionWorld.h:198
btVector3
btVector3 can be used to represent 3D points and vectors.
Definition: btVector3.h:82
btRaycastVehicle.h
btDynamicsWorld.h
btWheelInfoConstructionInfo::m_wheelsDampingRelaxation
btScalar m_wheelsDampingRelaxation
Definition: btWheelInfo.h:30
btTransform::getOrigin
btVector3 & getOrigin()
Return the origin vector translation.
Definition: btTransform.h:113
btRigidBody::getLinearVelocity
const btVector3 & getLinearVelocity() const
Definition: btRigidBody.h:433
btCollisionObject::hasContactResponse
bool hasContactResponse() const
Definition: btCollisionObject.h:211
btRigidBody::getVelocityInLocalPoint
btVector3 getVelocityInLocalPoint(const btVector3 &rel_pos) const
Definition: btRigidBody.h:460
btRaycastVehicle::btVehicleTuning
Definition: btRaycastVehicle.h:38
btVehicleRaycaster::castRay
virtual void * castRay(const btVector3 &from, const btVector3 &to, btVehicleRaycasterResult &result)=0
btWheelInfoConstructionInfo::m_wheelRadius
btScalar m_wheelRadius
Definition: btWheelInfo.h:26
btRaycastVehicle::addWheel
btWheelInfo & addWheel(const btVector3 &connectionPointCS0, const btVector3 &wheelDirectionCS0, const btVector3 &wheelAxleCS, btScalar suspensionRestLength, btScalar wheelRadius, const btVehicleTuning &tuning, bool isFrontWheel)
Definition: btRaycastVehicle.cpp:59
btRaycastVehicle::m_axle
btAlignedObjectArray< btVector3 > m_axle
Definition: btRaycastVehicle.h:28
btWheelInfo::m_brake
btScalar m_brake
Definition: btWheelInfo.h:75
btWheelContactPoint::m_body1
btRigidBody * m_body1
Definition: btRaycastVehicle.cpp:441
btRaycastVehicle::m_indexRightAxis
int m_indexRightAxis
Definition: btRaycastVehicle.h:65
btWheelInfo::m_maxSuspensionForce
btScalar m_maxSuspensionForce
Definition: btWheelInfo.h:71
btWheelInfo::m_chassisConnectionPointCS
btVector3 m_chassisConnectionPointCS
Definition: btWheelInfo.h:56
btRaycastVehicle::m_currentVehicleSpeedKmHour
btScalar m_currentVehicleSpeedKmHour
Definition: btRaycastVehicle.h:61
btVehicleRaycaster::btVehicleRaycasterResult::m_distFraction
btScalar m_distFraction
Definition: btVehicleRaycaster.h:27
btWheelContactPoint::m_body0
btRigidBody * m_body0
Definition: btRaycastVehicle.cpp:440
btIDebugDraw::drawLine
virtual void drawLine(const btVector3 &from, const btVector3 &to, const btVector3 &color)=0
btRaycastVehicle::setBrake
void setBrake(btScalar brake, int wheelIndex)
Definition: btRaycastVehicle.cpp:378
btRaycastVehicle::~btRaycastVehicle
virtual ~btRaycastVehicle()
Definition: btRaycastVehicle.cpp:52
btRaycastVehicle::updateFriction
virtual void updateFriction(btScalar timeStep)
Definition: btRaycastVehicle.cpp:488
btCollisionWorld::ClosestRayResultCallback::m_hitPointWorld
btVector3 m_hitPointWorld
Definition: btCollisionWorld.h:244
btWheelContactPoint
Definition: btRaycastVehicle.cpp:439
btRaycastVehicle::setSteeringValue
void setSteeringValue(btScalar steering, int wheel)
Definition: btRaycastVehicle.cpp:344
btWheelInfoConstructionInfo::m_maxSuspensionTravelCm
btScalar m_maxSuspensionTravelCm
Definition: btWheelInfo.h:25
btWheelInfo::m_frictionSlip
btScalar m_frictionSlip
Definition: btWheelInfo.h:66
btVehicleRaycaster::btVehicleRaycasterResult::m_hitPointInWorld
btVector3 m_hitPointInWorld
Definition: btVehicleRaycaster.h:24
btRaycastVehicle::updateVehicle
virtual void updateVehicle(btScalar step)
Definition: btRaycastVehicle.cpp:256
btRigidBody::setMassProps
void setMassProps(btScalar mass, const btVector3 &inertia)
Definition: btRigidBody.cpp:226
btRaycastVehicle::m_sideImpulse
btAlignedObjectArray< btScalar > m_sideImpulse
Definition: btRaycastVehicle.h:30
btWheelInfo::m_wheelsDampingCompression
btScalar m_wheelsDampingCompression
Definition: btWheelInfo.h:64
btWheelInfoConstructionInfo::m_wheelDirectionCS
btVector3 m_wheelDirectionCS
Definition: btWheelInfo.h:22
btWheelInfoConstructionInfo::m_wheelAxleCS
btVector3 m_wheelAxleCS
Definition: btWheelInfo.h:23
btIDebugDraw.h
btWheelInfoConstructionInfo::m_maxSuspensionForce
btScalar m_maxSuspensionForce
Definition: btWheelInfo.h:32
btRaycastVehicle::getRightAxis
int getRightAxis() const
Definition: btRaycastVehicle.h:143
btWheelInfo::m_wheelDirectionCS
btVector3 m_wheelDirectionCS
Definition: btWheelInfo.h:57
btWheelInfo::m_wheelsDampingRelaxation
btScalar m_wheelsDampingRelaxation
Definition: btWheelInfo.h:65
btWheelInfo::RaycastInfo::m_contactPointWS
btVector3 m_contactPointWS
Definition: btWheelInfo.h:43
btWheelInfo::m_steering
btScalar m_steering
Definition: btWheelInfo.h:67
btWheelInfo::m_engineForce
btScalar m_engineForce
Definition: btWheelInfo.h:73
btRigidBody::getCenterOfMassPosition
const btVector3 & getCenterOfMassPosition() const
Definition: btRigidBody.h:423
resolveSingleBilateral
void resolveSingleBilateral(btRigidBody &body1, const btVector3 &pos1, btRigidBody &body2, const btVector3 &pos2, btScalar distance, const btVector3 &normal, btScalar &impulse, btScalar timeStep)
resolveSingleBilateral is an obsolete methods used for vehicle friction between two dynamic objects
Definition: btContactConstraint.cpp:105
btRaycastVehicle::defaultInit
void defaultInit(const btVehicleTuning &tuning)
Definition: btRaycastVehicle.cpp:45
btCollisionWorld::ClosestRayResultCallback::m_hitNormalWorld
btVector3 m_hitNormalWorld
Definition: btCollisionWorld.h:243
btVehicleRaycaster.h
btWheelInfo::m_clippedInvContactDotSuspension
btScalar m_clippedInvContactDotSuspension
Definition: btWheelInfo.h:109
btRaycastVehicle::getWheelInfo
const btWheelInfo & getWheelInfo(int index) const
Definition: btRaycastVehicle.cpp:364
btWheelContactPoint::m_frictionPositionWorld
btVector3 m_frictionPositionWorld
Definition: btRaycastVehicle.cpp:442
btRaycastVehicle::resetSuspension
void resetSuspension()
Definition: btRaycastVehicle.cpp:130
btRigidBody::applyImpulse
void applyImpulse(const btVector3 &impulse, const btVector3 &rel_pos)
Definition: btRigidBody.h:335
btWheelInfo::RaycastInfo::m_wheelAxleWS
btVector3 m_wheelAxleWS
Definition: btWheelInfo.h:47
btAlignedObjectArray::push_back
void push_back(const T &_Val)
Definition: btAlignedObjectArray.h:257
btRaycastVehicle::m_vehicleRaycaster
btVehicleRaycaster * m_vehicleRaycaster
Definition: btRaycastVehicle.h:58
btWheelInfo
btWheelInfo contains information per wheel about friction and suspension.
Definition: btWheelInfo.h:38
btRigidBody::computeImpulseDenominator
btScalar computeImpulseDenominator(const btVector3 &pos, const btVector3 &normal) const
Definition: btRigidBody.h:482
btSqrt
btScalar btSqrt(btScalar y)
Definition: btScalar.h:466
btContactConstraint.h
btSolve2LinearConstraint.h
btTransform::setOrigin
void setOrigin(const btVector3 &origin)
Set the translational element.
Definition: btTransform.h:146
btWheelInfo::m_raycastInfo
RaycastInfo m_raycastInfo
Definition: btWheelInfo.h:52
btVector3::normalize
btVector3 & normalize()
Normalize this vector x^2 + y^2 + z^2 = 1.
Definition: btVector3.h:303
btWheelInfo::m_wheelAxleCS
btVector3 m_wheelAxleCS
Definition: btWheelInfo.h:58
btWheelInfo::m_wheelsRadius
btScalar m_wheelsRadius
Definition: btWheelInfo.h:62
btRigidBody::upcast
static const btRigidBody * upcast(const btCollisionObject *colObj)
to keep collision detection and dynamics separate we don't store a rigidbody pointer but a rigidbody ...
Definition: btRigidBody.h:189
btCollisionWorld::rayTest
virtual void rayTest(const btVector3 &rayFromWorld, const btVector3 &rayToWorld, RayResultCallback &resultCallback) const
rayTest performs a raycast on all objects in the btCollisionWorld, and calls the resultCallback This ...
Definition: btCollisionWorld.cpp:1004
btWheelContactPoint::m_jacDiagABInv
btScalar m_jacDiagABInv
Definition: btRaycastVehicle.cpp:444
btRaycastVehicle::updateWheelTransformsWS
void updateWheelTransformsWS(btWheelInfo &wheel, bool interpolatedTransform=true)
Definition: btRaycastVehicle.cpp:145
btRigidBody::getMotionState
btMotionState * getMotionState()
Definition: btRigidBody.h:549
btRaycastVehicle::m_chassisBody
btRigidBody * m_chassisBody
Definition: btRaycastVehicle.h:63
btRaycastVehicle::getSteeringValue
btScalar getSteeringValue(int wheel) const
Definition: btRaycastVehicle.cpp:352
btRaycastVehicle::getWheelTransformWS
const btTransform & getWheelTransformWS(int wheelIndex) const
Definition: btRaycastVehicle.cpp:85
btAlignedObjectArray::size
int size() const
return the number of elements in the array
Definition: btAlignedObjectArray.h:142
btWheelInfo::RaycastInfo::m_isInContact
bool m_isInContact
Definition: btWheelInfo.h:48
btRaycastVehicle::applyEngineForce
void applyEngineForce(btScalar force, int wheel)
Definition: btRaycastVehicle.cpp:357