|
Atoms Crowd
4.1.0
|
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>
71 std::vector<Atoms::Agent*> agents;
72 std::vector<unsigned int> agentsCreated;
73 std::vector<unsigned int> agentsKilled;
75 std::unordered_map<std::string, std::vector<Agent*>> agentTypeMapper;
76 std::unordered_map<int, Agent*> localAgents;
77 std::map<size_t, AtomsPtr<Atoms::Agent>> agentsCached;
87 void setCacheState(
short value);
89 short cacheState()
const;
91 std::vector<int> cacheFrames()
const;
95 std::map<long, Frame> frames;
98 double m_prevCacheFrame;
100 int m_oldEnableCacheValue;
101 bool m_isCachePlaying;
118 void addBehaviourModule(
const std::string& name, AtomsPtr<BehaviourModule>& module);
169 const std::vector<Agent*>&
agents()
const;
180 const std::string&
name()
const;
362 void filterAgents(
const std::vector<int>& agentIds,
bool invert =
false);
388 void setCacheData(
const std::vector<Agent*>& agents,
389 const std::vector<unsigned int>& agentsCreated,
390 const std::vector<unsigned int>& agentsKilled);
423 void setProfileTime(
unsigned short index,
size_t us);
446 void enablePositionsKdtree(
bool value);
453 void updatePositionsKdTree();
467 std::map<std::string, AtomsPtr<BehaviourModule>> m_behaviourModules;
472 std::vector<std::string> m_moduleOrder;
475 std::vector<Agent*> m_agents;
480 std::unordered_map<std::string, std::vector<Agent*>> m_agentTypeMapper;
483 std::unordered_map<int, int> m_agentsSelection;
486 std::unordered_map<int, Agent*> m_localAgents;
489 std::unordered_map<int, bool> m_agentFilter;
492 std::vector<unsigned int> m_agentsCreated;
495 std::vector<unsigned int> m_agentsKilled;
501 std::string m_simulationName;
507 std::vector<LayoutGeneratorPtr> m_layoutGenerators;
510 std::atomic<size_t> m_localIdCounter;
513 AtomsPtr<AgentGroup> m_parent;
531 size_t m_profileTime[14];
534 mutable std::mutex m_mutex;
549 bool m_invertAgentFilter;
559 #include "AgentGroup.impl.h"
const std::unordered_map< std::string, std::vector< Agent * > > & agentTypeMapperRef() const
Gets the agent type.
Definition: AgentGroup.h:58
void reloadBehaviourModule(const std::string &name)
Reloads a behaviour module.
Definition: OperatorComputeData.h:20
void updateAgentTypeMapper()
Update the agent type mapper.
void postPhysics()
Post Physics.
size_t profileTime(unsigned short index) const
Get profile time.
void killAgents(std::vector< unsigned int > &localIds)
Register the agents to be killed at the end of the compute pose.
Container for all agent types.
Definition: HeightFields.h:19
void initSimulation()
Initializes the simulation.
void setActive(bool value)
Sets the active state.
Agent group.
Definition: AgentGroup.h:35
bool multithread()
Gets the multithread state.
void reset()
Delete everything.
void clearCache()
Clear the sim cache.
void clearAgentFilter()
Clear the agent filter.
const NavigationMeshes & navigationMeshes() const
Return internal navigation meshes.
const std::unordered_map< std::string, std::vector< Agent * > > agentTypeMapper() const
Gets the agent type.
void clearAgents()
Clear agents.
const std::string & name() const
Gets the agent group name.
void addBehaviourModule(const std::string &name, const std::string &moduleTypeName)
Adds a behaviour module.
Container for all agent types.
Definition: NavigationMeshes.h:20
AtomsPtr< Atoms::AgentGroup > parent()
Gets the parent.
void enablePositionsKdTreeCache(bool value)
Enables caching the internal kd tree so that it is not updated at every frame.
bool isCacheEnabled() const
Return the cache enable flag.
void endSimulation()
End simulation.
void removeAgent(Agent *agent)
Removes an agent from this agent group.
void lock() const
Lock mutex.
Global simulation time.
Definition: SimulationTime.h:21
void generateAgents(double time)
Events.
Agent.
Definition: Agent.h:38
void setAgentFilterMap(const std::unordered_map< int, bool > &data, bool invert=false)
Sets the agent filter map.
const std::unordered_map< int, int > & agentsSelection() const
Gets the selected agents data.
void preFrame()
Pre frame.
Definition: KdTreePoint.h:19
HeightFields & heightFields()
Return internal height fields.
void addLayoutGenerator(LayoutGeneratorPtr &layoutGen)
Sets the layout generator.
AtomsMath::Matrix Matrix
Matrix class.
Definition: AtomsMath.h:63
const Cache & cache() const
Get the cache object.
void runAgentsCreatedOnAgent(Atoms::Agent *agent, const std::string &breakAtModuleName)
Runs the agentsCreated module methods on the given agent.
void removeBehaviourModule(const std::string &name)
Removes a behaviour module.
Agent * agent(unsigned int groupId)
Gets an agent using its local id.
void initializeNewAgents(std::vector< AgentInitData > &newAgentsData)
Initializes new agents with the given data.
const SimulationTime & simulationTime() const
Return the internal simulation time.
const AtomsCore::Matrix & matrix() const
Gets the agent group matrix.
LayoutGeneratorPtr getLayoutGenerator(const std::string &name) const
Returns the layout generator with the given name.
void clear()
Clears all data.
void unlock() const
Unlock mutex.
void setSimulationName(const std::string &name)
Sets the simulation pool name.
const std::unordered_map< int, bool > & agentFilter() const
Gets the agent filter map.
const std::string & simulationName() const
Gets the simulation pool name.
void endFrame()
End frame.
AtomsCore::MapMetadata behaviourModuleData(const std::string &name)
Gets data of the behaviour module with the given name.
Atoms namespace.
Definition: Agent.h:28
SimulationTime & simulationTime()
Return the internal simulation time.
void reorderBehaviourModule(const std::string &name, unsigned int newPosition)
Moves a behaviour module to a different position in the behaviour list.
AtomsCore::MapMetadata & metadata()
Get agent group metadata.
const std::vector< std::string > & behaviourModuleNames() const
Gets the behaviour module names.
const HeightFields & heightFields() const
Return internal height fields.
void prePhysics()
Pre Physics.
const std::vector< unsigned int > & agentsKilled() const
Get the agents goupdId that are killed at the current frame.
const AtomsCore::MapMetadata & metadata() const
Get agent group metadata.
const std::vector< LayoutGeneratorPtr > & layoutGenerators()
Returns the layout generator.
void setMatrix(const AtomsCore::Matrix &matrix)
Sets the agent group matrix.
void setName(const std::string &name)
Sets the agent group name.
const std::unordered_map< int, Agent * > & localAgents() const
Gets the local agents map.
void filterAgent(unsigned int agentId)
Filter an agent.
Definition: AtomsPhysx.h:40
bool isAgentFilterInverted() const
Check if the agent filter is inverted.
Definition: AgentGroup.h:69
void setAgentsSelection(std::unordered_map< int, int > &selectionData)
Sets the selected agents data.
void initFrame()
Init frame.
bool isActive() const
CHeck if the agent group is active.
NavigationMeshes & navigationMeshes()
Return internal navigation meshes.
AtomsPtr< BehaviourModule > behaviourModule(const std::string &name)
Gets the behaviour module with the given name.
void setLayoutGenerator(LayoutGeneratorPtr &layoutGen)
Sets the layout generator.
const std::vector< Agent * > & agents() const
Gets the group agents.
void computePose()
Compute agent pose.
const std::vector< unsigned int > & agentsCreated() const
Get the agents goupdId that are created at the current frame.
void setMultithread(bool value)
Sets the multithread state.
AtomsCore::MapMetadata agentGroupData()
Gets all data in a MapMetadata.
void resetSimulation()
Reset simulation.
Cache & cache()
Get the cache object.
void enableCache(bool value)
Enable or disable the sim cache.
void filterAgents(const std::vector< int > &agentIds, bool invert=false)
Filter some agents.
void setParent(AtomsPtr< Atoms::AgentGroup > &parent)
Sets the parent.