My Project
Loading...
Searching...
No Matches
CBulletWorld.h
Go to the documentation of this file.
1//==============================================================================
2/*
3 Software License Agreement (BSD License)
4 Copyright (c) 2003-2024, CHAI3D
5 (www.chai3d.org)
6
7 All rights reserved.
8
9 Redistribution and use in source and binary forms, with or without
10 modification, are permitted provided that the following conditions
11 are met:
12
13 * Redistributions of source code must retain the above copyright
14 notice, this list of conditions and the following disclaimer.
15
16 * Redistributions in binary form must reproduce the above
17 copyright notice, this list of conditions and the following
18 disclaimer in the documentation and/or other materials provided
19 with the distribution.
20
21 * Neither the name of CHAI3D nor the names of its contributors may
22 be used to endorse or promote products derived from this software
23 without specific prior written permission.
24
25 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
26 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
27 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
28 FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
29 COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
30 INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
31 BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
32 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
33 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
34 LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
35 ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36 POSSIBILITY OF SUCH DAMAGE.
37
38 \author <http://www.chai3d.org>
39 \author Francois Conti
40 \version 1.0.0
41*/
42//==============================================================================
43//------------------------------------------------------------------------------
44#ifndef CBulletWorldH
45#define CBulletWorldH
46//------------------------------------------------------------------------------
47#include "chai3d.h"
49//------------------------------------------------------------------------------
50#include "btBulletDynamicsCommon.h"
51#include "BulletCollision/Gimpact/btGImpactCollisionAlgorithm.h"
52//------------------------------------------------------------------------------
53
54//------------------------------------------------------------------------------
55namespace chai3d {
56//------------------------------------------------------------------------------
57
58//==============================================================================
65//==============================================================================
66
67
68//==============================================================================
80//==============================================================================
82{
83 //--------------------------------------------------------------------------
84 // CONSTRUCTOR & DESTRUCTOR:
85 //--------------------------------------------------------------------------
86
87public:
88
91
93 virtual ~cBulletWorld();
94
95
96 //--------------------------------------------------------------------------
97 // PUBLIC MEMBERS:
98 //--------------------------------------------------------------------------
99
100public:
101
103 std::list<cBulletGenericObject*> m_bodies;
104
105
106 //--------------------------------------------------------------------------
107 // PUBLIC METHODS:
108 //--------------------------------------------------------------------------
109
110public:
111
113 btDiscreteDynamicsWorld* getBulletWorld() { return (m_bulletWorld); }
114
116 void setIntegrationSettings(const double a_integrationTimeStep = 0.001, const int a_integrationMaxIterations = 1) { setIntegrationTimeStep(a_integrationTimeStep); setIntegrationMaxIterations(a_integrationMaxIterations); }
117
119 void setIntegrationTimeStep(const double a_integrationTimeStep = 0.001) { m_integrationTimeStep = chai3d::cMax(a_integrationTimeStep, 0.000001); };
120
123
125 void setIntegrationMaxIterations(const int a_integrationMaxIterations = 1) { m_integrationMaxIterations = chai3d::cMax(a_integrationMaxIterations, 1); };
126
129
131 void setGravity(const double& a_x, const double& a_y, const double& a_z) { setGravity(cVector3d(a_x, a_y, a_z)); }
132
134 void setGravity(const cVector3d& a_gravity);
135
138
140 void updateDynamics(double a_interval);
141
144
145
146 //--------------------------------------------------------------------------
147 // PUBLIC MEMBERS:
148 //--------------------------------------------------------------------------
149
150public:
151
153 btDiscreteDynamicsWorld* m_bulletWorld;
154
156 btBroadphaseInterface* m_bulletBroadphase;
157
159 btCollisionConfiguration* m_bulletCollisionConfiguration;
160
162 btCollisionDispatcher* m_bulletCollisionDispatcher;
163
165 btConstraintSolver* m_bulletSolver;
166
167
168 //--------------------------------------------------------------------------
169 // PROTECTED MEMBERS:
170 //--------------------------------------------------------------------------
171
172protected:
173
176
179
182};
183
184//------------------------------------------------------------------------------
185} // namespace chai3d
186//------------------------------------------------------------------------------
187
188//------------------------------------------------------------------------------
189#endif
190//------------------------------------------------------------------------------
Bullet Module Bullet Generic Object.
This class implements an Bullet dynamic world.
Definition CBulletWorld.h:82
void updateDynamics(double a_interval)
This method updates the simulation over a time interval.
Definition CBulletWorld.cpp:148
btCollisionConfiguration * m_bulletCollisionConfiguration
Bullet collision configuration.
Definition CBulletWorld.h:159
double getIntegrationTimeStep()
The method returns the integration time step of the simulation.
Definition CBulletWorld.h:122
void setIntegrationSettings(const double a_integrationTimeStep=0.001, const int a_integrationMaxIterations=1)
This method assigns integration settings of simulator.
Definition CBulletWorld.h:116
void setIntegrationMaxIterations(const int a_integrationMaxIterations=1)
This method sets the maximum number of iteration per integration time step.
Definition CBulletWorld.h:125
void setIntegrationTimeStep(const double a_integrationTimeStep=0.001)
This method sets the internal integration time step of the simulation.
Definition CBulletWorld.h:119
btBroadphaseInterface * m_bulletBroadphase
Bullet broad phase collision detection algorithm.
Definition CBulletWorld.h:156
virtual ~cBulletWorld()
Destructor of cBulletWorld.
Definition CBulletWorld.cpp:98
btConstraintSolver * m_bulletSolver
Bullet physics solver.
Definition CBulletWorld.h:165
double m_integrationTimeStep
Integration time step.
Definition CBulletWorld.h:178
btDiscreteDynamicsWorld * getBulletWorld()
This method returns a point to the Bullet world object.
Definition CBulletWorld.h:113
cBulletWorld()
Constructor of cBulletWorld.
Definition CBulletWorld.cpp:59
std::list< cBulletGenericObject * > m_bodies
List of all Bullet dynamic bodies in world.
Definition CBulletWorld.h:103
int getIntegrationMaxIterations()
This method returns the maximum number of iteration per integration time step.
Definition CBulletWorld.h:128
btCollisionDispatcher * m_bulletCollisionDispatcher
Bullet collision dispatcher.
Definition CBulletWorld.h:162
void setGravity(const double &a_x, const double &a_y, const double &a_z)
This method sets the gravity field vector.
Definition CBulletWorld.h:131
void updatePositionFromDynamics(void)
This method updates the position and orientation from Bullet models to CHAI3D models.
Definition CBulletWorld.cpp:170
btDiscreteDynamicsWorld * m_bulletWorld
Bullet dynamics world.
Definition CBulletWorld.h:153
double m_simulationTime
Current time of simulation.
Definition CBulletWorld.h:175
int m_integrationMaxIterations
Maximum number of iterations.
Definition CBulletWorld.h:181
chai3d::cVector3d getGravity()
This method returns the gravity field vector.
Definition CBulletWorld.cpp:132
T cMax(const T &a_value1, const T &a_value2)