Bullet Collision Detection & Physics Library
Main Page
Namespaces
Classes
Files
File List
File Members
src
BulletDynamics
Vehicle
btWheelInfo.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
#include "
btWheelInfo.h
"
12
#include "
BulletDynamics/Dynamics/btRigidBody.h
"
// for pointvelocity
13
14
15
btScalar
btWheelInfo::getSuspensionRestLength
()
const
16
{
17
18
return
m_suspensionRestLength1
;
19
20
}
21
22
void
btWheelInfo::updateWheel
(
const
btRigidBody
&
chassis
,
RaycastInfo
&
raycastInfo
)
23
{
24
(
void
)
raycastInfo
;
25
26
27
if
(
m_raycastInfo
.
m_isInContact
)
28
29
{
30
btScalar
project=
m_raycastInfo
.
m_contactNormalWS
.
dot
(
m_raycastInfo
.
m_wheelDirectionWS
);
31
btVector3
chassis_velocity_at_contactPoint
;
32
btVector3
relpos
=
m_raycastInfo
.
m_contactPointWS
-
chassis
.getCenterOfMassPosition();
33
chassis_velocity_at_contactPoint
=
chassis
.getVelocityInLocalPoint(
relpos
);
34
btScalar
projVel
=
m_raycastInfo
.
m_contactNormalWS
.
dot
(
chassis_velocity_at_contactPoint
);
35
if
( project >=
btScalar
(-0.1))
36
{
37
m_suspensionRelativeVelocity
=
btScalar
(0.0);
38
m_clippedInvContactDotSuspension
=
btScalar
(1.0) /
btScalar
(0.1);
39
}
40
else
41
{
42
btScalar
inv
=
btScalar
(-1.) / project;
43
m_suspensionRelativeVelocity
=
projVel
*
inv
;
44
m_clippedInvContactDotSuspension
=
inv
;
45
}
46
47
}
48
49
else
// Not in contact : position wheel in a nice (rest length) position
50
{
51
m_raycastInfo
.
m_suspensionLength
= this->
getSuspensionRestLength
();
52
m_suspensionRelativeVelocity
=
btScalar
(0.0);
53
m_raycastInfo
.
m_contactNormalWS
= -
m_raycastInfo
.
m_wheelDirectionWS
;
54
m_clippedInvContactDotSuspension
=
btScalar
(1.0);
55
}
56
}
btMax
const T & btMax(const T &a, const T &b)
Definition
btMinMax.h:29
btRigidBody.h
btScalar
float btScalar
The btScalar type abstracts floating point numbers, to easily switch between double and single floati...
Definition
btScalar.h:292
btWheelInfo.h
btRigidBody
The btRigidBody is the main class for rigid body objects.
Definition
btRigidBody.h:63
btVector3
btVector3 can be used to represent 3D points and vectors.
Definition
btVector3.h:84
btVector3::dot
btScalar dot(const btVector3 &v) const
Return the dot product.
Definition
btVector3.h:235
btWheelInfo::RaycastInfo
Definition
btWheelInfo.h:41
btWheelInfo::RaycastInfo::m_suspensionLength
btScalar m_suspensionLength
Definition
btWheelInfo.h:45
btWheelInfo::RaycastInfo::m_contactPointWS
btVector3 m_contactPointWS
Definition
btWheelInfo.h:44
btWheelInfo::RaycastInfo::m_isInContact
bool m_isInContact
Definition
btWheelInfo.h:49
btWheelInfo::RaycastInfo::m_wheelDirectionWS
btVector3 m_wheelDirectionWS
Definition
btWheelInfo.h:47
btWheelInfo::RaycastInfo::m_contactNormalWS
btVector3 m_contactNormalWS
Definition
btWheelInfo.h:43
btWheelInfo::m_clippedInvContactDotSuspension
btScalar m_clippedInvContactDotSuspension
Definition
btWheelInfo.h:112
btWheelInfo::updateWheel
void updateWheel(const btRigidBody &chassis, RaycastInfo &raycastInfo)
Definition
btWheelInfo.cpp:22
btWheelInfo::getSuspensionRestLength
btScalar getSuspensionRestLength() const
Definition
btWheelInfo.cpp:15
btWheelInfo::m_suspensionRestLength1
btScalar m_suspensionRestLength1
Definition
btWheelInfo.h:60
btWheelInfo::m_suspensionRelativeVelocity
btScalar m_suspensionRelativeVelocity
Definition
btWheelInfo.h:113
btWheelInfo::m_raycastInfo
RaycastInfo m_raycastInfo
Definition
btWheelInfo.h:53
Generated by
1.10.0