This is a legacy Trac instance left read-only for reference purposes. More info. dev main | home

Changeset 192

Show
Ignore:
Timestamp:
03/02/2010 04:12:58 PM (2 years ago)
Author:
mceier
Message:

AnimatController? - updates actuators using sensors input

Signed-off-by: Mariusz Ceier <mceier@gmail.com>

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/include/waterworld/sim2/Animat.h

    r186 r192  
    1515#include "IntrusivePtrBase.h" 
    1616#include "ChemicalSignals.h" 
     17#include "AnimatController.h" 
    1718#include "Actuators.h" 
    1819#include "Sensors.h" 
     
    5960                 */ 
    6061                boost::intrusive_ptr<PhysicalBody> m_body; 
     62                /** 
     63                 * Animat controller - updates actuators using sensors input 
     64                 */ 
     65                boost::intrusive_ptr<AnimatController> m_controller; 
    6166                /** 
    6267                 * True if collisions are enabled ... 
     
    125130                bool hasEnabledCollisions() const; 
    126131                /** 
    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 
    131134                 */ 
    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; 
    133140                /** 
    134141                 * Update animat 
  • trunk/src/waterworld/sim2/Animat.cpp

    r186 r192  
    4949                m_contact_points(animat.m_contact_points), 
    5050                m_body(animat.m_body), 
     51                m_controller(animat.m_controller), 
    5152                m_enabled_collisions(animat.m_enabled_collisions) 
    5253        { 
     
    150151        } 
    151152 
    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; 
    154161        } 
    155162 
     
    172179                for(Sensors::iterator i=m_sensors.begin();i!=m_sensors.end();++i) 
    173180                        (*i)->update(this, world, dt); 
    174                 control(world, dt); 
     181                if (m_controller) 
     182                        (*m_controller)(this,world,dt); 
    175183                for(Actuators::iterator i=m_actuators.begin();i!=m_actuators.end();++i) 
    176184                        (*i)->update(this, world, dt); 
  • trunk/src/waterworld/sim2/CMakeLists.txt

    r185 r192  
    33        ${S}/IntrusivePtrBase.cpp 
    44        ${S}/Animat.cpp 
     5        ${S}/AnimatController.cpp 
    56        ${S}/Actuator.cpp 
    67        ${S}/Sensor.cpp