Atoms Crowd  4.1.0
Atoms::AgentGroup Class Reference

Agent group. More...

#include <AgentGroup.h>

Classes

class  Cache
 

Public Types

enum  ProfileType {
  kInitSimulation = 0, kPreFrame, kAgentsCreated, kInitFrame,
  kEndFrame, kPrePhysics, kPostPhysics, kAgentsKilled,
  kEndSimulation, kResetSimulation, kComputePose, kGenerateAgents,
  kClearAgents
}
 

Public Member Functions

 AgentGroup ()
 Constructor.
 
 ~AgentGroup ()
 Destructor.
 
void addBehaviourModule (const std::string &name, const std::string &moduleTypeName)
 Adds a behaviour module. More...
 
void addBehaviourModule (const std::string &name, AtomsPtr< BehaviourModule > &module)
 
void removeBehaviourModule (const std::string &name)
 Removes a behaviour module. More...
 
void reorderBehaviourModule (const std::string &name, unsigned int newPosition)
 Moves a behaviour module to a different position in the behaviour list. More...
 
const std::vector< std::string > & behaviourModuleNames () const
 Gets the behaviour module names. More...
 
AtomsPtr< BehaviourModulebehaviourModule (const std::string &name)
 Gets the behaviour module with the given name. More...
 
AtomsCore::MapMetadata agentGroupData ()
 Gets all data in a MapMetadata. More...
 
AtomsCore::MapMetadata behaviourModuleData (const std::string &name)
 Gets data of the behaviour module with the given name. More...
 
void reloadBehaviourModule (const std::string &name)
 Reloads a behaviour module. More...
 
const std::vector< Agent * > & agents () const
 Gets the group agents. More...
 
void removeAgent (Agent *agent)
 Removes an agent from this agent group. More...
 
const std::string & name () const
 Gets the agent group name. More...
 
void setName (const std::string &name)
 Sets the agent group name.
 
const std::string & simulationName () const
 Gets the simulation pool name. More...
 
void setSimulationName (const std::string &name)
 Sets the simulation pool name.
 
const AtomsCore::Matrixmatrix () const
 Gets the agent group matrix. More...
 
void setMatrix (const AtomsCore::Matrix &matrix)
 Sets the agent group matrix.
 
void initializeNewAgents (std::vector< AgentInitData > &newAgentsData)
 Initializes new agents with the given data.
 
void runAgentsCreatedOnAgent (Atoms::Agent *agent, const std::string &breakAtModuleName)
 Runs the agentsCreated module methods on the given agent.
 
void killAgents (std::vector< unsigned int > &localIds)
 Register the agents to be killed at the end of the compute pose. More...
 
void generateAgents (double time)
 Events. More...
 
void initSimulation ()
 Initializes the simulation. More...
 
void preFrame ()
 Pre frame. More...
 
void initFrame ()
 Init frame. More...
 
void computePose ()
 Compute agent pose. More...
 
void endFrame ()
 End frame. More...
 
void prePhysics ()
 Pre Physics. More...
 
void postPhysics ()
 Post Physics. More...
 
void endSimulation ()
 End simulation. More...
 
void resetSimulation ()
 Reset simulation. More...
 
void setLayoutGenerator (LayoutGeneratorPtr &layoutGen)
 Sets the layout generator.
 
void addLayoutGenerator (LayoutGeneratorPtr &layoutGen)
 Sets the layout generator.
 
const std::vector< LayoutGeneratorPtr > & layoutGenerators ()
 Returns the layout generator.
 
LayoutGeneratorPtr getLayoutGenerator (const std::string &name) const
 Returns the layout generator with the given name.
 
void clear ()
 Clears all data. More...
 
void clearAgents ()
 Clear agents. More...
 
void reset ()
 Delete everything.
 
bool multithread ()
 Gets the multithread state. More...
 
void setMultithread (bool value)
 Sets the multithread state. More...
 
const std::unordered_map< std::string, std::vector< Agent * > > agentTypeMapper () const
 Gets the agent type. More...
 
const std::unordered_map< std::string, std::vector< Agent * > > & agentTypeMapperRef () const
 Gets the agent type. More...
 
void updateAgentTypeMapper ()
 Update the agent type mapper.
 
const std::unordered_map< int, int > & agentsSelection () const
 Gets the selected agents data. More...
 
void setAgentsSelection (std::unordered_map< int, int > &selectionData)
 Sets the selected agents data. More...
 
void setActive (bool value)
 Sets the active state. More...
 
bool isActive () const
 CHeck if the agent group is active.
 
const std::unordered_map< int, Agent * > & localAgents () const
 Gets the local agents map. More...
 
Agentagent (unsigned int groupId)
 Gets an agent using its local id.
 
void filterAgent (unsigned int agentId)
 Filter an agent. More...
 
void filterAgents (const std::vector< int > &agentIds, bool invert=false)
 Filter some agents.
 
bool isAgentFilterInverted () const
 Check if the agent filter is inverted.
 
void setAgentFilterMap (const std::unordered_map< int, bool > &data, bool invert=false)
 Sets the agent filter map.
 
const std::unordered_map< int, bool > & agentFilter () const
 Gets the agent filter map.
 
void clearAgentFilter ()
 Clear the agent filter.
 
AtomsPtr< Atoms::AgentGroupparent ()
 Gets the parent.
 
void setParent (AtomsPtr< Atoms::AgentGroup > &parent)
 Sets the parent.
 
const std::vector< unsigned int > & agentsCreated () const
 Get the agents goupdId that are created at the current frame.
 
const std::vector< unsigned int > & agentsKilled () const
 Get the agents goupdId that are killed at the current frame.
 
void setCacheData (const std::vector< Agent * > &agents, const std::vector< unsigned int > &agentsCreated, const std::vector< unsigned int > &agentsKilled)
 
const AtomsCore::MapMetadatametadata () const
 Get agent group metadata.
 
AtomsCore::MapMetadatametadata ()
 Get agent group metadata.
 
SimulationTimesimulationTime ()
 Return the internal simulation time.
 
const SimulationTimesimulationTime () const
 Return the internal simulation time.
 
HeightFieldsheightFields ()
 Return internal height fields.
 
const HeightFieldsheightFields () const
 Return internal height fields.
 
NavigationMeshesnavigationMeshes ()
 Return internal navigation meshes.
 
const NavigationMeshesnavigationMeshes () const
 Return internal navigation meshes.
 
AtomsPhysxphysics ()
 
void setPhysics (AtomsPhysx *physic)
 
size_t profileTime (unsigned short index) const
 Get profile time.
 
void setProfileTime (unsigned short index, size_t us)
 
void lock () const
 Lock mutex.
 
void unlock () const
 Unlock mutex.
 
void enableCache (bool value)
 Enable or disable the sim cache.
 
bool isCacheEnabled () const
 Return the cache enable flag.
 
void clearCache ()
 Clear the sim cache.
 
const Cachecache () const
 Get the cache object.
 
Cachecache ()
 Get the cache object.
 
void enablePositionsKdtree (bool value)
 
void enablePositionsKdTreeCache (bool value)
 Enables caching the internal kd tree so that it is not updated at every frame.
 
const AtomsUtils::KdTreePointpositionsKdTree () const
 
void updatePositionsKdTree ()
 

Detailed Description

Agent group.

An agent group is a collection of agents. It stores a list of behaviour modules which then are used for modifying the agent networks and metadatas.

Member Function Documentation

◆ addBehaviourModule()

void Atoms::AgentGroup::addBehaviourModule ( const std::string &  name,
const std::string &  moduleTypeName 
)

Adds a behaviour module.

Parameters
namebehaviour module name
modulePointer to an allocated behaviour module

◆ agentGroupData()

AtomsCore::MapMetadata Atoms::AgentGroup::agentGroupData ( )

Gets all data in a MapMetadata.

Returns
agent group data

◆ agents()

const std::vector<Agent*>& Atoms::AgentGroup::agents ( ) const

Gets the group agents.

Returns
vector fo agents

◆ agentsSelection()

const std::unordered_map<int, int>& Atoms::AgentGroup::agentsSelection ( ) const

Gets the selected agents data.

The key is the agent groupId while the value in the map is 1 if the agent is selected, 0 otherwise

◆ agentTypeMapper()

const std::unordered_map<std::string, std::vector<Agent*> > Atoms::AgentGroup::agentTypeMapper ( ) const

Gets the agent type.

Returns
Return the agent type mapper, return the cached one if tha cache is enabled

◆ agentTypeMapperRef()

const std::unordered_map<std::string, std::vector<Agent*> >& Atoms::AgentGroup::agentTypeMapperRef ( ) const

Gets the agent type.

Returns
Return the agent type mapper

◆ behaviourModule()

AtomsPtr<BehaviourModule> Atoms::AgentGroup::behaviourModule ( const std::string &  name)

Gets the behaviour module with the given name.

Parameters
namebehaviour module name
Returns
Behaviour module

◆ behaviourModuleData()

AtomsCore::MapMetadata Atoms::AgentGroup::behaviourModuleData ( const std::string &  name)

Gets data of the behaviour module with the given name.

Parameters
namebehaviour module name
Returns
Behaviour module data

◆ behaviourModuleNames()

const std::vector<std::string>& Atoms::AgentGroup::behaviourModuleNames ( ) const

Gets the behaviour module names.

Returns
Behaviour module names

◆ clear()

void Atoms::AgentGroup::clear ( )

Clears all data.

Clear the group data but without destroing the agents data

◆ clearAgents()

void Atoms::AgentGroup::clearAgents ( )

Clear agents.

Destroy the agents removing them also from the AgentsPool

◆ computePose()

void Atoms::AgentGroup::computePose ( )

Compute agent pose.

Triggers the agent behaviour networks to compute the pose

◆ endFrame()

void Atoms::AgentGroup::endFrame ( )

End frame.

Called at the end of each frame after the agent pose is computed

◆ endSimulation()

void Atoms::AgentGroup::endSimulation ( )

End simulation.

Called at the end of the simulation

◆ filterAgent()

void Atoms::AgentGroup::filterAgent ( unsigned int  agentId)

Filter an agent.

The agent id is added to the agent filter map. When an id is inside the filter map the agent using this id is no created.

◆ generateAgents()

void Atoms::AgentGroup::generateAgents ( double  time)

Events.

Generates agents

◆ initFrame()

void Atoms::AgentGroup::initFrame ( )

Init frame.

Called at the beginning of each frame before the agent pose is computed

◆ initSimulation()

void Atoms::AgentGroup::initSimulation ( )

Initializes the simulation.

Called one time at the beginning of the simulation, before the agents are created

◆ killAgents()

void Atoms::AgentGroup::killAgents ( std::vector< unsigned int > &  localIds)

Register the agents to be killed at the end of the compute pose.

The agents

◆ localAgents()

const std::unordered_map<int, Agent*>& Atoms::AgentGroup::localAgents ( ) const

Gets the local agents map.

Returns
Return the local agents map. The key is the agent groupId while the value is a pointer to the agent

◆ matrix()

const AtomsCore::Matrix& Atoms::AgentGroup::matrix ( ) const

Gets the agent group matrix.

Returns
matrix

◆ multithread()

bool Atoms::AgentGroup::multithread ( )

Gets the multithread state.

Returns
True if the agent group is using multiple threads

◆ name()

const std::string& Atoms::AgentGroup::name ( ) const

Gets the agent group name.

Returns
name

◆ postPhysics()

void Atoms::AgentGroup::postPhysics ( )

Post Physics.

Called after step physx

◆ preFrame()

void Atoms::AgentGroup::preFrame ( )

Pre frame.

Called at the beginning of each frame before the agents are created

◆ prePhysics()

void Atoms::AgentGroup::prePhysics ( )

Pre Physics.

Called before step physx

◆ reloadBehaviourModule()

void Atoms::AgentGroup::reloadBehaviourModule ( const std::string &  name)

Reloads a behaviour module.

Parameters
nameModule name

◆ removeAgent()

void Atoms::AgentGroup::removeAgent ( Agent agent)

Removes an agent from this agent group.

The agent is not destroyed but only removed from this agentGroup

◆ removeBehaviourModule()

void Atoms::AgentGroup::removeBehaviourModule ( const std::string &  name)

Removes a behaviour module.

Parameters
namebehaviour module name

◆ reorderBehaviourModule()

void Atoms::AgentGroup::reorderBehaviourModule ( const std::string &  name,
unsigned int  newPosition 
)

Moves a behaviour module to a different position in the behaviour list.

Parameters
namebehaviour module name
newPositionNew behaviour module position

◆ resetSimulation()

void Atoms::AgentGroup::resetSimulation ( )

Reset simulation.

Called after each simulation reset

◆ setActive()

void Atoms::AgentGroup::setActive ( bool  value)

Sets the active state.

When an agent group is not active it's excluded form the computation

◆ setAgentsSelection()

void Atoms::AgentGroup::setAgentsSelection ( std::unordered_map< int, int > &  selectionData)

Sets the selected agents data.

Parameters
selectionDataThe key is the agent groupId while the value in the map is 1 if the agent is selected, 0 otherwise

◆ setMultithread()

void Atoms::AgentGroup::setMultithread ( bool  value)

Sets the multithread state.

Parameters
valueMultithread

◆ simulationName()

const std::string& Atoms::AgentGroup::simulationName ( ) const

Gets the simulation pool name.

Returns
name

The documentation for this class was generated from the following file: