35 #include "LinearMath/btQuickprof.h"
51 tgSimulation::~tgSimulation()
55 for (std::size_t i = 0; i < m_models.size(); i++)
60 for (std::size_t i=0; i < m_dataManagers.size(); i++) {
61 delete m_dataManagers[i];
70 throw std::invalid_argument(
"NULL pointer to tgModel");
76 m_models.push_back(pModel);
81 assert(!m_models.empty());
87 if (pObstacle == NULL)
89 throw std::invalid_argument(
"NULL pointer to tgModel");
95 m_obstacles.push_back(pObstacle);
100 assert(!m_obstacles.empty());
107 if( pDataManager == NULL){
108 throw std::invalid_argument(
"NULL pointer to data manager, in tgSimulation.");
113 pDataManager->
setup();
114 m_dataManagers.push_back(pDataManager);
118 assert(!m_dataManagers.empty());
123 #ifndef BT_NO_PROFILE
124 BT_PROFILE(
"tgSimulation::onVisit");
125 #endif //BT_NO_PROFILE
128 for (std::size_t i = 0; i < m_models.size(); i++) {
129 m_models[i]->onVisit(r);
131 for (std::size_t i = 0; i < m_obstacles.size(); i++) {
132 m_obstacles[i]->onVisit(r);
142 for (std::size_t i = 0; i != m_models.size(); i++)
145 m_models[i]->setup(m_view.
world());
151 for (std::size_t i = 0; i < m_dataManagers.size(); i++) {
153 m_dataManagers[i]->setup();
168 for (std::size_t i = 0; i != m_models.size(); i++)
171 m_models[i]->setup(m_view.
world());
177 for (std::size_t i = 0; i < m_dataManagers.size(); i++) {
179 m_dataManagers[i]->setup();
190 return m_view.
world();
199 throw std::invalid_argument(
"dt for step is not positive");
208 for (std::size_t i = 0; i < m_models.size(); i++)
210 m_models[i]->step(dt);
215 for (std::size_t i = 0; i < m_obstacles.size(); i++)
217 m_obstacles[i]->step(dt);
221 for (std::size_t i = 0; i < m_dataManagers.size(); i++) {
222 m_dataManagers[i]->step(dt);
227 void tgSimulation::teardown()
229 const size_t n = m_models.size();
230 for (std::size_t i = 0; i < n; i++)
232 tgModel *
const pModel = m_models[i];
233 assert(pModel != NULL);
238 while(m_obstacles.size() != 0)
240 tgModel *
const pModel = m_obstacles.back();
241 assert(pModel != NULL);
247 m_obstacles.pop_back();
249 assert(m_obstacles.empty());
252 const size_t num_DM = m_dataManagers.size();
253 for (std::size_t i = 0; i < num_DM; i++) {
255 assert(pDataManager != NULL);
277 bool tgSimulation::invariant()
const
void addDataManager(tgDataManager *pDataManager)
void addObstacle(tgModel *pObstacle)
virtual void setup(tgWorld &world)
void bindToSimulation(tgSimulation &simulation)
void releaseFromSimulation()
tgWorld & getWorld() const
void addModel(tgModel *pModel)
Contains the definition of class tgDataManager.
Contains the definition of class tgModel.
Contains the definition of class tgSimulation.
Contains the definition of class tgSimViewGraphics.
void step(double dt) const
Contains the definition of class tgWorld $Id$.
tgSimulation(tgSimView &view)
void onVisit(const tgModelVisitor &r) const
Contains the definition of class tgSimView.
void step(double dt) const