Atoms Crowd
7.0.0
|
#include <AgentGroup.h>
Classes | |
class | Cache |
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< BehaviourModule > | behaviourModule (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::Matrix & | matrix () 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 (const 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 | removeLayoutGenerators () |
Remove all layout generators. | |
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... | |
Agent * | agent (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::AgentGroup > | parent () |
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::MapMetadata & | metadata () const |
Get agent group metadata. | |
AtomsCore::MapMetadata & | metadata () |
Get agent group metadata. | |
SimulationTime & | simulationTime () |
Return the internal simulation time. | |
const SimulationTime & | simulationTime () const |
Return the internal simulation time. | |
HeightFields & | heightFields () |
Return internal height fields. | |
const HeightFields & | heightFields () const |
Return internal height fields. | |
NavigationMeshes & | navigationMeshes () |
Return internal navigation meshes. | |
const NavigationMeshes & | navigationMeshes () const |
Return internal navigation meshes. | |
AtomsPhysx * | physics () |
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 Cache & | cache () const |
Get the cache object. | |
Cache & | cache () |
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::KdTreePoint & | positionsKdTree () const |
void | updatePositionsKdTree () |
void | setAgentInitializationCallback (std::function< void(Agent *)> &callback) |
bool | hasTag (const std::string &tag) const |
std::vector< std::string > & | tags () |
const std::vector< std::string > & | tags () const |
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.
void Atoms::AgentGroup::addBehaviourModule | ( | const std::string & | name, |
const std::string & | moduleTypeName | ||
) |
Adds a behaviour module.
name | behaviour module name |
module | Pointer to an allocated behaviour module |
AtomsCore::MapMetadata Atoms::AgentGroup::agentGroupData | ( | ) |
Gets all data in a MapMetadata.
const std::vector<Agent*>& Atoms::AgentGroup::agents | ( | ) | const |
Gets the group agents.
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
const std::unordered_map<std::string, std::vector<Agent*> > Atoms::AgentGroup::agentTypeMapper | ( | ) | const |
Gets the agent type.
const std::unordered_map<std::string, std::vector<Agent*> >& Atoms::AgentGroup::agentTypeMapperRef | ( | ) | const |
Gets the agent type.
AtomsPtr<BehaviourModule> Atoms::AgentGroup::behaviourModule | ( | const std::string & | name | ) |
Gets the behaviour module with the given name.
name | behaviour module name |
AtomsCore::MapMetadata Atoms::AgentGroup::behaviourModuleData | ( | const std::string & | name | ) |
Gets data of the behaviour module with the given name.
name | behaviour module name |
const std::vector<std::string>& Atoms::AgentGroup::behaviourModuleNames | ( | ) | const |
Gets the behaviour module names.
void Atoms::AgentGroup::clear | ( | ) |
Clears all data.
Clear the group data but without destroing the agents data
void Atoms::AgentGroup::clearAgents | ( | ) |
Clear agents.
Destroy the agents removing them also from the AgentsPool
void Atoms::AgentGroup::computePose | ( | ) |
Compute agent pose.
Triggers the agent behaviour networks to compute the pose
void Atoms::AgentGroup::endFrame | ( | ) |
End frame.
Called at the end of each frame after the agent pose is computed
void Atoms::AgentGroup::endSimulation | ( | ) |
End simulation.
Called at the end of the simulation
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.
void Atoms::AgentGroup::generateAgents | ( | double | time | ) |
Events.
Generates agents
void Atoms::AgentGroup::initFrame | ( | ) |
Init frame.
Called at the beginning of each frame before the agent pose is computed
void Atoms::AgentGroup::initSimulation | ( | ) |
Initializes the simulation.
Called one time at the beginning of the simulation, before the agents are created
void Atoms::AgentGroup::killAgents | ( | const std::vector< unsigned int > & | localIds | ) |
Register the agents to be killed at the end of the compute pose.
The agents
const std::unordered_map<int, Agent*>& Atoms::AgentGroup::localAgents | ( | ) | const |
Gets the local agents map.
const AtomsCore::Matrix& Atoms::AgentGroup::matrix | ( | ) | const |
Gets the agent group matrix.
bool Atoms::AgentGroup::multithread | ( | ) |
Gets the multithread state.
const std::string& Atoms::AgentGroup::name | ( | ) | const |
Gets the agent group name.
void Atoms::AgentGroup::postPhysics | ( | ) |
Post Physics.
Called after step physx
void Atoms::AgentGroup::preFrame | ( | ) |
Pre frame.
Called at the beginning of each frame before the agents are created
void Atoms::AgentGroup::prePhysics | ( | ) |
Pre Physics.
Called before step physx
void Atoms::AgentGroup::reloadBehaviourModule | ( | const std::string & | name | ) |
Reloads a behaviour module.
name | Module name |
void Atoms::AgentGroup::removeAgent | ( | Agent * | agent | ) |
Removes an agent from this agent group.
The agent is not destroyed but only removed from this agentGroup
void Atoms::AgentGroup::removeBehaviourModule | ( | const std::string & | name | ) |
Removes a behaviour module.
name | behaviour module name |
void Atoms::AgentGroup::reorderBehaviourModule | ( | const std::string & | name, |
unsigned int | newPosition | ||
) |
Moves a behaviour module to a different position in the behaviour list.
name | behaviour module name |
newPosition | New behaviour module position |
void Atoms::AgentGroup::resetSimulation | ( | ) |
Reset simulation.
Called after each simulation reset
void Atoms::AgentGroup::setActive | ( | bool | value | ) |
Sets the active state.
When an agent group is not active it's excluded form the computation
void Atoms::AgentGroup::setAgentsSelection | ( | std::unordered_map< int, int > & | selectionData | ) |
Sets the selected agents data.
selectionData | The key is the agent groupId while the value in the map is 1 if the agent is selected, 0 otherwise |
void Atoms::AgentGroup::setMultithread | ( | bool | value | ) |
Sets the multithread state.
value | Multithread |
const std::string& Atoms::AgentGroup::simulationName | ( | ) | const |
Gets the simulation pool name.