Changeset 188
- Timestamp:
- 02/27/2010 11:38:01 PM (2 years ago)
- Files:
-
- trunk/include/waterworld/config.h.in (modified) (1 diff)
- trunk/include/waterworld/sim2/IntrusivePtrBase.h (modified) (1 diff)
- trunk/include/waterworld/sim2/PhysicalBody.h (modified) (2 diffs)
- trunk/include/waterworld/sim2/World.h (modified) (3 diffs)
- trunk/src/CMakeLists.txt (modified) (1 diff)
- trunk/src/tests/CMakeLists.txt (modified) (1 diff)
- trunk/src/tests/test_sim2_collision_sensor.cpp (added)
- trunk/src/tests/test_sim2_sensor.cpp (added)
- trunk/src/tests/test_sim2_world.cpp (added)
- trunk/src/waterworld/sim2/IntrusivePtrBase.cpp (modified) (1 diff)
- trunk/src/waterworld/sim2/PhysicalBody.cpp (modified) (2 diffs)
- trunk/src/waterworld/sim2/World.cpp (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/include/waterworld/config.h.in
r110 r188 3 3 4 4 #cmakedefine WATERWORLD_WIN32 5 #cmakedefine USE_SIM2 5 6 6 7 #endif/*CONFIG_INCLUDED*/ trunk/include/waterworld/sim2/IntrusivePtrBase.h
r175 r188 23 23 IntrusivePtrBase &operator=(IntrusivePtrBase const &); 24 24 virtual ~IntrusivePtrBase(); 25 public: 26 uintmax_t getRefCount() const; 25 27 }; 26 28 trunk/include/waterworld/sim2/PhysicalBody.h
r185 r188 22 22 class PhysicalBody : public IntrusivePtrBase, private boost::noncopyable 23 23 { 24 boost::intrusive_ptr<Animat>m_animat;24 Animat *m_animat; 25 25 PhysicalBody(PhysicalBody const &body); 26 26 PhysicalBody &operator=(PhysicalBody const &body); … … 29 29 30 30 PhysicalBody(); 31 PhysicalBody( boost::intrusive_ptr<Animat>animat);31 PhysicalBody(Animat *animat); 32 32 /** 33 33 * \return Animat 34 34 */ 35 boost::intrusive_ptr<Animat>getAnimat() const;35 Animat *getAnimat() const; 36 36 /** 37 37 * Set animat 38 38 */ 39 void setAnimat( boost::intrusive_ptr<Animat>newAnimat);39 void setAnimat(Animat *newAnimat); 40 40 /** 41 41 * Set PAL body trunk/include/waterworld/sim2/World.h
r186 r188 4 4 namespace waterworld 5 5 { 6 /** 7 * \class World 8 * \brief World class containing all animats - 9 * only 1 World instance at the same time is supported 10 */ 6 11 class World; 7 12 } … … 16 21 17 22 /** 18 * PAL classes23 * PAL Physics class 19 24 */ 20 25 class palPhysics; 26 /** 27 * PAL collision detection class 28 */ 21 29 class palCollisionDetection; 22 30 … … 26 34 { 27 35 Animats m_animats; 28 //Bodies m_bodies;29 36 World(); 30 37 World(World const &); 31 38 World &operator=(World const &); 32 39 public: 40 /** 41 * \return Animats (read-only) 42 */ 33 43 Animats const &getAnimats() const; 44 /** 45 * \return Animats 46 */ 34 47 Animats &getAnimats(); 48 /** 49 * Starts events thread 50 */ 35 51 void startEventsThread(); 52 /** 53 * Stops events thread 54 */ 36 55 void stopEventsThread(); 56 /** 57 * Simulation step 58 * \param dt delta time 59 */ 37 60 void step(real_t dt); 61 /** 62 * \return PAL Physics object 63 */ 38 64 palPhysics *getPhysics() const; 65 /** 66 * \return PAL Collision Detection object 67 */ 39 68 palCollisionDetection *getCollisionDetection() const; 69 /** 70 * Create animats body 71 * \param animat Which animat should have this body 72 * \param radius radius of new body ( of new sphere ) 73 * \param mass Mass of new body 74 * \param position Position of new body 75 */ 40 76 boost::intrusive_ptr<PhysicalBody> createAnimatsBody( 41 77 boost::intrusive_ptr<Animat> animat, 42 78 Radius radius, Mass mass, Position position); 79 /** 80 * \return Events queue 81 */ 43 82 boost::intrusive_ptr<EventsQueue<Event> > getEventsQueue(); 83 /** 84 * \return Handlers registry 85 */ 44 86 boost::intrusive_ptr<HandlersRegistry> getHandlersRegistry(); 87 /** 88 * Create new world ( only 1 world at a time is supported ) 89 * \return new world 90 */ 45 91 static boost::intrusive_ptr<World> createWorld(); 92 /** 93 * Remove animats body 94 */ 95 void removeAnimatsBody(boost::intrusive_ptr<Animat> animat); 96 /** 97 * Remove animat 98 */ 99 void removeAnimat(boost::intrusive_ptr<Animat> animat); 46 100 virtual ~World(); 47 101 private: trunk/src/CMakeLists.txt
r186 r188 45 45 TARGET_LINK_LIBRARIES(WaterWorldGUI ${WATERWORLD_LIBRARY} ${WATERWORLD_LIBRARIES} ${WATERWORLD_GUI_LIBRARIES}) 46 46 ELSE(USE_SIM2) 47 47 48 SET(WATERWORLD_GUI_SOURCES 48 49 waterworld.cpp init_sdl.cpp trunk/src/tests/CMakeLists.txt
r175 r188 19 19 20 20 ADD_TEST(Events TestEvents) 21 22 SET(TEST_WORLD_SOURCES test_sim2_world.cpp) 23 ADD_EXECUTABLE(TestWorld ${TEST_WORLD_SOURCES}) 24 TARGET_LINK_LIBRARIES(TestWorld ${TESTS_LIBRARIES}) 25 26 ADD_TEST(World TestWorld) 27 28 SET(TEST_SENSOR_SOURCES test_sim2_sensor.cpp) 29 ADD_EXECUTABLE(TestSensor ${TEST_SENSOR_SOURCES}) 30 TARGET_LINK_LIBRARIES(TestSensor ${TESTS_LIBRARIES}) 31 32 ADD_TEST(Sensor TestSensor) 33 34 SET(TEST_COLLISION_SENSOR_SOURCES test_sim2_collision_sensor.cpp) 35 ADD_EXECUTABLE(TestCollisionSensor ${TEST_COLLISION_SENSOR_SOURCES}) 36 TARGET_LINK_LIBRARIES(TestCollisionSensor ${TESTS_LIBRARIES}) 37 38 ADD_TEST(CollisionSensor TestCollisionSensor) 21 39 22 40 ELSE(USE_SIM2) trunk/src/waterworld/sim2/IntrusivePtrBase.cpp
r175 r188 10 10 { 11 11 return *this; 12 } 13 14 uintmax_t IntrusivePtrBase::getRefCount() const 15 { 16 return m_refCount; 12 17 } 13 18 trunk/src/waterworld/sim2/PhysicalBody.cpp
r175 r188 10 10 } 11 11 12 PhysicalBody::PhysicalBody( boost::intrusive_ptr<Animat>animat) :12 PhysicalBody::PhysicalBody(Animat *animat) : 13 13 m_animat(animat), 14 14 m_body(NULL) … … 37 37 */ 38 38 39 boost::intrusive_ptr<Animat>PhysicalBody::getAnimat() const39 Animat *PhysicalBody::getAnimat() const 40 40 { 41 41 return m_animat; 42 42 } 43 43 44 void PhysicalBody::setAnimat( boost::intrusive_ptr<Animat>newAnimat)44 void PhysicalBody::setAnimat(Animat *newAnimat) 45 45 { 46 46 m_animat = newAnimat; trunk/src/waterworld/sim2/World.cpp
r186 r188 42 42 return g_pcd; 43 43 } 44 45 static void cleanupPhysics() 46 { 47 PF->Cleanup(); 48 g_pcd = NULL; 49 g_physics = NULL; 50 } 44 51 } 45 52 … … 72 79 boost::intrusive_ptr<World> World::createWorld() 73 80 { 74 initPhysics(); 81 if(g_physics==NULL) 82 initPhysics(); 75 83 return new World(); 76 84 } … … 104 112 Radius radius, Mass mass, Position p) 105 113 { 106 boost::intrusive_ptr<PhysicalBody> body = new PhysicalBody(animat );114 boost::intrusive_ptr<PhysicalBody> body = new PhysicalBody(animat.get()); 107 115 palSphere *sphere = PF->CreateSphere(); 108 116 sphere->Init(p(0),p(1),p(2),radius,mass); … … 122 130 } 123 131 132 void World::removeAnimatsBody(boost::intrusive_ptr<Animat> animat) 133 { 134 animat->setPhysicalBody(NULL); 135 } 136 137 void World::removeAnimat(boost::intrusive_ptr<Animat> animat) 138 { 139 m_animats.erase(animat); 140 removeAnimatsBody(animat); 141 } 142 124 143 World::~World() 125 144 { 126 145 stopEventsThread(); 127 PF->Cleanup();146 cleanupPhysics(); 128 147 } 129 148 }
