Changeset 192
- Timestamp:
- 03/02/2010 04:12:58 PM (2 years ago)
- Files:
-
- trunk/include/waterworld/sim2/Animat.h (modified) (3 diffs)
- trunk/include/waterworld/sim2/AnimatController.h (added)
- trunk/src/waterworld/sim2/Animat.cpp (modified) (3 diffs)
- trunk/src/waterworld/sim2/AnimatController.cpp (added)
- trunk/src/waterworld/sim2/CMakeLists.txt (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/include/waterworld/sim2/Animat.h
r186 r192 15 15 #include "IntrusivePtrBase.h" 16 16 #include "ChemicalSignals.h" 17 #include "AnimatController.h" 17 18 #include "Actuators.h" 18 19 #include "Sensors.h" … … 59 60 */ 60 61 boost::intrusive_ptr<PhysicalBody> m_body; 62 /** 63 * Animat controller - updates actuators using sensors input 64 */ 65 boost::intrusive_ptr<AnimatController> m_controller; 61 66 /** 62 67 * True if collisions are enabled ... … … 125 130 bool hasEnabledCollisions() const; 126 131 /** 127 * Control animat ( invoked after updated sensors and before updating actuators ) 128 * Default implementation does nothing. 129 * \param world Animats world/environment 130 * \param dt elapsed time 132 * Sets Animat controller 133 * \param controller new AnimatController 131 134 */ 132 virtual void control(boost::intrusive_ptr<World> world, real_t dt); 135 void setController(boost::intrusive_ptr<AnimatController> controller); 136 /** 137 * \return Current Animat controller 138 */ 139 boost::intrusive_ptr<AnimatController> getController() const; 133 140 /** 134 141 * Update animat trunk/src/waterworld/sim2/Animat.cpp
r186 r192 49 49 m_contact_points(animat.m_contact_points), 50 50 m_body(animat.m_body), 51 m_controller(animat.m_controller), 51 52 m_enabled_collisions(animat.m_enabled_collisions) 52 53 { … … 150 151 } 151 152 152 void Animat::control(boost::intrusive_ptr<World> world, real_t dt) 153 { 153 void Animat::setController(boost::intrusive_ptr<AnimatController> controller) 154 { 155 m_controller = controller; 156 } 157 158 boost::intrusive_ptr<AnimatController> Animat::getController() const 159 { 160 return m_controller; 154 161 } 155 162 … … 172 179 for(Sensors::iterator i=m_sensors.begin();i!=m_sensors.end();++i) 173 180 (*i)->update(this, world, dt); 174 control(world, dt); 181 if (m_controller) 182 (*m_controller)(this,world,dt); 175 183 for(Actuators::iterator i=m_actuators.begin();i!=m_actuators.end();++i) 176 184 (*i)->update(this, world, dt); trunk/src/waterworld/sim2/CMakeLists.txt
r185 r192 3 3 ${S}/IntrusivePtrBase.cpp 4 4 ${S}/Animat.cpp 5 ${S}/AnimatController.cpp 5 6 ${S}/Actuator.cpp 6 7 ${S}/Sensor.cpp
