Changeset 185
- Timestamp:
- 02/27/2010 09:37:51 PM (2 years ago)
- Files:
-
- trunk/include/waterworld/sim2/Animat.h (modified) (7 diffs)
- trunk/include/waterworld/sim2/CollisionSensor.h (added)
- trunk/include/waterworld/sim2/ContactPoint.h (added)
- trunk/include/waterworld/sim2/ContactPoints.h (added)
- trunk/include/waterworld/sim2/PhysicalBody.h (modified) (1 diff)
- trunk/include/waterworld/sim2/Sensor.h (modified) (1 diff)
- trunk/src/waterworld/sim2/Animat.cpp (modified) (7 diffs)
- trunk/src/waterworld/sim2/CMakeLists.txt (modified) (1 diff)
- trunk/src/waterworld/sim2/CollisionSensor.cpp (added)
- trunk/src/waterworld/sim2/ContactPoint.cpp (added)
- trunk/src/waterworld/sim2/Sensor.cpp (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/include/waterworld/sim2/Animat.h
r184 r185 13 13 #include "Types.h" 14 14 #include "ID.h" 15 #include "IntrusivePtrBase.h" 15 16 #include "ChemicalSignals.h" 16 17 #include "Actuators.h" 17 18 #include "Sensors.h" 19 #include "ContactPoints.h" 18 20 #include "PhysicalBody.h" 19 #include "IntrusivePtrBase.h"20 21 21 22 namespace waterworld … … 51 52 Sensors m_sensors; 52 53 /** 54 * Contact points with other animats 55 */ 56 ContactPoints m_contact_points; 57 /** 53 58 * Physical body of animat ( "oriented" sphere ) 54 59 */ 55 60 boost::intrusive_ptr<PhysicalBody> m_body; 56 57 61 /** 58 62 * Pointer to a function called on collision detect 59 63 */ 60 64 void (*collision)(); 61 62 65 /** 63 66 * On/Off collision detection for this body/animat 64 67 */ 65 68 bool cde; //CollisiondDetectionEnabled 69 /** 70 * True if collisions are enabled ... 71 */ 72 bool m_enabled_collisions; 66 73 public: 67 74 /** … … 86 93 87 94 /** 88 * \return constant chemical signals that this animat "emits" 95 * \return constant chemical signals that this animat "emits" ( read-only ) 89 96 */ 90 97 ChemicalSignals const &getChemicalSignals() const; 91 98 /** 92 * \return constant actuators 99 * \return constant actuators ( read-only ) 93 100 */ 94 101 Actuators const &getActuators() const; 95 102 /** 96 * \return constant sensors 103 * \return constant sensors ( read-only ) 97 104 */ 98 105 Sensors const &getSensors() const; 106 /** 107 * \return contact points ( read-only ) 108 */ 109 ContactPoints const &getContactPoints() const; 99 110 /** 100 111 * \return chemical signals that this animat "emits" … … 109 120 */ 110 121 Sensors &getSensors(); 122 /** 123 * \return contact points 124 */ 125 ContactPoints &getContactPoints(); 111 126 /** 112 127 * \return physical body … … 126 141 const AnimatID &getParentID() const; 127 142 /** 143 * Enable collisions - use getContactPoints method to access collision points 144 */ 145 void enableCollisions(); 146 /** 147 * Disable collisions 148 */ 149 void disableCollisions(); 150 /** 151 * \return True if detection of collisions for this animat is enabled 152 */ 153 bool hasEnabledCollisions() const; 154 /** 128 155 * Control animat ( invoked after updated sensors and before updating actuators ) 129 156 * Default implementation does nothing. … … 131 158 * \param dt elapsed time 132 159 */ 133 virtual void control( World *world, real_t dt);160 virtual void control(boost::intrusive_ptr<World> world, real_t dt); 134 161 /** 135 162 * Update animat … … 137 164 * \param dt elapsed time 138 165 */ 139 void update( World *world, real_t dt);166 void update(boost::intrusive_ptr<World> world, real_t dt); 140 167 Animat(ID const &id); 141 168 Animat(ID const &id,ID const &parentid); trunk/include/waterworld/sim2/PhysicalBody.h
r182 r185 30 30 PhysicalBody(); 31 31 PhysicalBody(boost::intrusive_ptr<Animat> animat); 32 /** 33 * \return Animat 34 */ 32 35 boost::intrusive_ptr<Animat> getAnimat() const; 36 /** 37 * Set animat 38 */ 33 39 void setAnimat(boost::intrusive_ptr<Animat> newAnimat); 40 /** 41 * Set PAL body 42 */ 34 43 void setBody(palBody *body); 44 /** 45 * \return PAL body 46 */ 35 47 palBody *getBody() const; 48 /** 49 * Applies force 50 */ 36 51 void applyForce(Force const &force, Position const &position); 52 /** 53 * Sets position 54 */ 37 55 void setPosition(Position const &); 56 /** 57 * \return position 58 */ 38 59 Position getPosition() const; 39 60 virtual ~PhysicalBody(); trunk/include/waterworld/sim2/Sensor.h
r175 r185 19 19 Sensor(); 20 20 Sensor(Sensor const &sensor); 21 Sensor &operator=(Sensor const &sensor); 21 22 virtual void update(boost::intrusive_ptr<Animat> animat, 22 23 boost::intrusive_ptr<World> world, real_t dt); trunk/src/waterworld/sim2/Animat.cpp
r184 r185 5 5 6 6 Animat::Animat(ID const &id) : 7 m_id(id), m_parent_id() 7 m_id(id), m_parent_id(), 8 m_enabled_collisions(false) 8 9 { 9 10 } 10 11 11 12 Animat::Animat(ID const &id, ID const &parentid) : 12 m_id(id), m_parent_id(parentid) 13 m_id(id), m_parent_id(parentid), 14 m_enabled_collisions(false) 13 15 { 14 16 } … … 21 23 m_signals(chemicalSignals), 22 24 m_actuators(actuators), 23 m_sensors(sensors) 25 m_sensors(sensors), 26 m_enabled_collisions(false) 24 27 { 25 28 } … … 32 35 m_signals(chemicalSignals), 33 36 m_actuators(actuators), 34 m_sensors(sensors) 37 m_sensors(sensors), 38 m_enabled_collisions(false) 35 39 { 36 40 } … … 42 46 m_actuators(animat.m_actuators), 43 47 m_sensors(animat.m_sensors), 44 m_body(animat.m_body) 48 m_contact_points(animat.m_contact_points), 49 m_body(animat.m_body), 50 m_enabled_collisions(animat.m_enabled_collisions) 45 51 { 46 52 } … … 81 87 } 82 88 89 ContactPoints const &Animat::getContactPoints() const 90 { 91 return m_contact_points; 92 } 93 83 94 ChemicalSignals &Animat::getChemicalSignals() 84 95 { … … 94 105 { 95 106 return m_sensors; 107 } 108 109 ContactPoints &Animat::getContactPoints() 110 { 111 return m_contact_points; 96 112 } 97 113 … … 120 136 } 121 137 122 void Animat::control(World *world, real_t dt) 138 void Animat::enableCollisions() 139 { 140 m_enabled_collisions = true; 141 } 142 143 void Animat::disableCollisions() 144 { 145 m_enabled_collisions = false; 146 } 147 148 bool Animat::hasEnabledCollisions() const 149 { 150 return m_enabled_collisions; 151 } 152 153 void Animat::control(boost::intrusive_ptr<World> world, real_t dt) 123 154 { 124 155 } 125 156 126 void Animat::update( World *world, real_t dt)157 void Animat::update(boost::intrusive_ptr<World> world, real_t dt) 127 158 { 128 159 for(Sensors::iterator i=m_sensors.begin();i!=m_sensors.end();++i) trunk/src/waterworld/sim2/CMakeLists.txt
r175 r185 14 14 ${S}/EventsThread.cpp 15 15 ${S}/ID.cpp 16 ${S}/ContactPoint.cpp 17 ${S}/CollisionSensor.cpp 16 18 ) 17 19 trunk/src/waterworld/sim2/Sensor.cpp
r175 r185 13 13 } 14 14 15 Sensor &Sensor::operator=(Sensor const &sensor) 16 { 17 IntrusivePtrBase::operator=(sensor); 18 return *this; 19 } 20 15 21 void Sensor::update(boost::intrusive_ptr<Animat> animat, boost::intrusive_ptr<World> world, real_t dt) 16 22 {
