10 #include <Atoms/Globals.h>
11 #include <Atoms/BehaviourModule.h>
12 #include <Atoms/LayoutGenerators/LayoutGenerator.h>
13 #include <Atoms/Agent.h>
14 #include <Atoms/SimulationTime.h>
15 #include <Atoms/HeightFields.h>
16 #include <Atoms/NavigationMeshes.h>
17 #include <Atoms/Graph/OperatorComputeData.h>
18 #include <AtomsUtils/KdTreePoint.h>
19 #include <AtomsCore/Metadata/MapMetadata.h>
20 #include <AtomsCore/Metadata/ArrayMetadata.h>
72 std::vector<Atoms::Agent*> agents;
73 std::vector<unsigned int> agentsCreated;
74 std::vector<unsigned int> agentsKilled;
76 std::unordered_map<std::string, std::vector<Agent*>> agentTypeMapper;
77 std::unordered_map<int, Agent*> localAgents;
78 std::map<size_t, AtomsPtr<Atoms::Agent>> agentsCached;
88 void setCacheState(
short value);
90 short cacheState()
const;
92 std::vector<int> cacheFrames()
const;
96 std::map<long, Frame> frames;
99 double m_prevCacheFrame;
101 int m_oldEnableCacheValue;
102 bool m_isCachePlaying;
119 void addBehaviourModule(
const std::string& name, AtomsPtr<BehaviourModule>& module);
170 const std::vector<Agent*>&
agents()
const;
181 const std::string&
name()
const;
366 void filterAgents(
const std::vector<int>& agentIds,
bool invert =
false);
392 void setCacheData(
const std::vector<Agent*>& agents,
393 const std::vector<unsigned int>& agentsCreated,
394 const std::vector<unsigned int>& agentsKilled);
427 void setProfileTime(
unsigned short index,
size_t us);
450 void enablePositionsKdtree(
bool value);
457 void updatePositionsKdTree();
459 void setAgentInitializationCallback(std::function<
void(
Agent*)>& callback);
461 bool hasTag(
const std::string& tag)
const;
463 inline std::vector<std::string>& tags() {
return m_tags; }
465 inline const std::vector<std::string>& tags()
const {
return m_tags; }
469 std::function<void(Agent*)> m_agentInitializationCallBack;
481 std::map<std::string, AtomsPtr<BehaviourModule>> m_behaviourModules;
486 std::vector<std::string> m_moduleOrder;
489 std::vector<Agent*> m_agents;
494 std::unordered_map<std::string, std::vector<Agent*>> m_agentTypeMapper;
497 std::unordered_map<int, int> m_agentsSelection;
500 std::unordered_map<int, Agent*> m_localAgents;
503 std::unordered_map<int, bool> m_agentFilter;
506 std::vector<unsigned int> m_agentsCreated;
509 std::vector<unsigned int> m_agentsKilled;
515 std::string m_simulationName;
521 std::vector<LayoutGeneratorPtr> m_layoutGenerators;
524 std::atomic<size_t> m_localIdCounter;
527 AtomsPtr<AgentGroup> m_parent;
530 SimulationTime m_simTime;
533 HeightFields m_heightFields;
536 NavigationMeshes m_navigationMeshes;
542 OperatorComputeData m_computeData;
545 std::vector<std::string> m_tags;
548 size_t m_profileTime[14];
551 mutable std::mutex m_mutex;
566 bool m_invertAgentFilter;
576 #include "AgentGroup.impl.h"
Definition: AgentGroup.h:70
Definition: AgentGroup.h:59
Agent group.
Definition: AgentGroup.h:36
void enableCache(bool value)
Enable or disable the sim cache.
void reorderBehaviourModule(const std::string &name, unsigned int newPosition)
Moves a behaviour module to a different position in the behaviour list.
void setAgentFilterMap(const std::unordered_map< int, bool > &data, bool invert=false)
Sets the agent filter map.
void setName(const std::string &name)
Sets the agent group name.
void reloadBehaviourModule(const std::string &name)
Reloads a behaviour module.
void filterAgent(unsigned int agentId)
Filter an agent.
void initFrame()
Init frame.
void postPhysics()
Post Physics.
bool multithread()
Gets the multithread state.
const std::unordered_map< std::string, std::vector< Agent * > > & agentTypeMapperRef() const
Gets the agent type.
void addLayoutGenerator(LayoutGeneratorPtr &layoutGen)
Sets the layout generator.
void setLayoutGenerator(LayoutGeneratorPtr &layoutGen)
Sets the layout generator.
const SimulationTime & simulationTime() const
Return the internal simulation time.
const std::unordered_map< std::string, std::vector< Agent * > > agentTypeMapper() const
Gets the agent type.
Cache & cache()
Get the cache object.
const std::unordered_map< int, bool > & agentFilter() const
Gets the agent filter map.
void clearAgents()
Clear agents.
const AtomsCore::Matrix & matrix() const
Gets the agent group matrix.
void endFrame()
End frame.
bool isAgentFilterInverted() const
Check if the agent filter is inverted.
void clearAgentFilter()
Clear the agent filter.
bool isActive() const
CHeck if the agent group is active.
void killAgents(const std::vector< unsigned int > &localIds)
Register the agents to be killed at the end of the compute pose.
void setSimulationName(const std::string &name)
Sets the simulation pool name.
void prePhysics()
Pre Physics.
const std::vector< LayoutGeneratorPtr > & layoutGenerators()
Returns the layout generator.
const AtomsCore::MapMetadata & metadata() const
Get agent group metadata.
void addBehaviourModule(const std::string &name, const std::string &moduleTypeName)
Adds a behaviour module.
AtomsCore::MapMetadata & metadata()
Get agent group metadata.
void computePose()
Compute agent pose.
const std::vector< unsigned int > & agentsKilled() const
Get the agents goupdId that are killed at the current frame.
void clear()
Clears all data.
void runAgentsCreatedOnAgent(Atoms::Agent *agent, const std::string &breakAtModuleName)
Runs the agentsCreated module methods on the given agent.
size_t profileTime(unsigned short index) const
Get profile time.
const std::unordered_map< int, Agent * > & localAgents() const
Gets the local agents map.
const std::vector< unsigned int > & agentsCreated() const
Get the agents goupdId that are created at the current frame.
void removeAgent(Agent *agent)
Removes an agent from this agent group.
void setMultithread(bool value)
Sets the multithread state.
SimulationTime & simulationTime()
Return the internal simulation time.
LayoutGeneratorPtr getLayoutGenerator(const std::string &name) const
Returns the layout generator with the given name.
HeightFields & heightFields()
Return internal height fields.
void lock() const
Lock mutex.
const std::unordered_map< int, int > & agentsSelection() const
Gets the selected agents data.
void updateAgentTypeMapper()
Update the agent type mapper.
void resetSimulation()
Reset simulation.
AtomsCore::MapMetadata agentGroupData()
Gets all data in a MapMetadata.
const std::string & simulationName() const
Gets the simulation pool name.
AtomsCore::MapMetadata behaviourModuleData(const std::string &name)
Gets data of the behaviour module with the given name.
void clearCache()
Clear the sim cache.
NavigationMeshes & navigationMeshes()
Return internal navigation meshes.
void setMatrix(const AtomsCore::Matrix &matrix)
Sets the agent group matrix.
AtomsPtr< BehaviourModule > behaviourModule(const std::string &name)
Gets the behaviour module with the given name.
const std::vector< Agent * > & agents() const
Gets the group agents.
Agent * agent(unsigned int groupId)
Gets an agent using its local id.
void endSimulation()
End simulation.
const HeightFields & heightFields() const
Return internal height fields.
bool isCacheEnabled() const
Return the cache enable flag.
void initSimulation()
Initializes the simulation.
AtomsPtr< Atoms::AgentGroup > parent()
Gets the parent.
void setParent(AtomsPtr< Atoms::AgentGroup > &parent)
Sets the parent.
void removeBehaviourModule(const std::string &name)
Removes a behaviour module.
const Cache & cache() const
Get the cache object.
void setAgentsSelection(std::unordered_map< int, int > &selectionData)
Sets the selected agents data.
void filterAgents(const std::vector< int > &agentIds, bool invert=false)
Filter some agents.
const NavigationMeshes & navigationMeshes() const
Return internal navigation meshes.
void preFrame()
Pre frame.
void removeLayoutGenerators()
Remove all layout generators.
const std::string & name() const
Gets the agent group name.
void reset()
Delete everything.
void enablePositionsKdTreeCache(bool value)
Enables caching the internal kd tree so that it is not updated at every frame.
void unlock() const
Unlock mutex.
const std::vector< std::string > & behaviourModuleNames() const
Gets the behaviour module names.
void initializeNewAgents(std::vector< AgentInitData > &newAgentsData)
Initializes new agents with the given data.
void setActive(bool value)
Sets the active state.
void generateAgents(double time)
Events.
Agent.
Definition: Agent.h:44
Definition: AtomsPhysx.h:40
Container for all agent types.
Definition: HeightFields.h:19
Container for all agent types.
Definition: NavigationMeshes.h:20
Global simulation time.
Definition: SimulationTime.h:21
Definition: KdTreePoint.h:19
AtomsMath::Matrix Matrix
Matrix class.
Definition: AtomsMath.h:63
Atoms namespace.
Definition: Agent.h:29