Divide Framework 0.1
A free and open-source 3D Framework under heavy development
Loading...
Searching...
No Matches
Divide::AI::AIManager Class Referencefinal

#include <AIManager.h>

+ Inheritance diagram for Divide::AI::AIManager:

Public Types

using AITeamMap = hashMap< U32, std::unique_ptr< AITeam > >
 
using NavMeshMap = hashMap< AIEntity::PresetAgentRadius, std::unique_ptr< Navigation::NavigationMesh > >
 

Public Member Functions

 AIManager (Scene &parentScene, TaskPool &pool)
 
 ~AIManager ()
 
void destroy ()
 Clear all AI related data (teams, entities, NavMeshes, etc);.
 
void update (U64 deltaTimeUS)
 Called at a fixed interval (preferably in a separate thread);.
 
bool registerEntity (U32 teamID, AIEntity *entity)
 
void unregisterEntity (U32 teamID, AIEntity *entity)
 
void unregisterEntity (AIEntity *entity)
 
AITeamgetTeamByID (const U32 AITeamID)
 
Navigation::NavigationMeshaddNavMesh (PlatformContext &context, Navigation::DivideRecast &recastInterface, Scene &parentScene, AIEntity::PresetAgentRadius radius)
 Add a NavMesh.
 
bool destroyNavMesh (AIEntity::PresetAgentRadius radius)
 
Navigation::NavigationMeshgetNavMesh (const AIEntity::PresetAgentRadius radius) const
 
void setSceneCallback (const DELEGATE< void > &callback)
 Remove a NavMesh.
 
void pauseUpdate (const bool state) noexcept
 
bool updatePaused () const noexcept
 
bool updating () const noexcept
 
void debugDraw (GFX::CommandBuffer &bufferInOut, GFX::MemoryBarrierCommand &memCmdInOut, bool forceAll=true)
 
bool isDebugDraw () const noexcept
 
void toggleNavMeshDebugDraw (bool state)
 Toggle debug draw for all NavMeshes.
 
bool navMeshDebugDraw () const noexcept
 
void stop () noexcept
 
bool running () const noexcept
 
AITeamregisterTeam (U32 id)
 Register an AI Team.
 
bool unregisterTeam (U32 id)
 Unregister an AI Team.
 
- Public Member Functions inherited from Divide::SceneComponent
 SceneComponent (Scene &parentScene) noexcept
 
SceneparentScene () noexcept
 
const SceneparentScene () const noexcept
 

Protected Member Functions

bool shouldStop () const noexcept
 

Private Member Functions

bool processInput (U64 deltaTimeUS)
 sensors
 
bool processData (U64 deltaTimeUS)
 think
 
bool updateEntities (U64 deltaTimeUS)
 react
 

Private Attributes

TaskPool_parentPool
 
U64 _deltaTimeUS
 
U64 _currentTimeUS
 
U64 _previousTimeUS
 
std::atomic_bool _navMeshDebugDraw
 
std::atomic_bool _pauseUpdate
 
std::atomic_bool _updating
 
std::atomic_bool _shouldStop
 
std::atomic_bool _running
 
NavMeshMap _navMeshes
 
AITeamMap _aiTeams
 
Mutex _updateMutex
 
SharedMutex _navMeshMutex
 
DELEGATE< void > _sceneCallback
 

Friends

class AITeam
 

Additional Inherited Members

- Protected Attributes inherited from Divide::SceneComponent
Scene_parentScene
 

Detailed Description

Definition at line 57 of file AIManager.h.

Member Typedef Documentation

◆ AITeamMap

using Divide::AI::AIManager::AITeamMap = hashMap<U32, std::unique_ptr<AITeam> >

Definition at line 60 of file AIManager.h.

◆ NavMeshMap

Constructor & Destructor Documentation

◆ AIManager()

Divide::AIManager::AIManager ( Scene parentScene,
TaskPool pool 
)
explicit

Definition at line 14 of file AIManager.cpp.

◆ ~AIManager()

Divide::AIManager::~AIManager ( )

Definition at line 28 of file AIManager.cpp.

Member Function Documentation

◆ addNavMesh()

Navigation::NavigationMesh * Divide::AIManager::addNavMesh ( PlatformContext context,
Navigation::DivideRecast recastInterface,
Scene parentScene,
AIEntity::PresetAgentRadius  radius 
)

Add a NavMesh.

Definition at line 130 of file AIManager.cpp.

◆ debugDraw()

void Divide::AIManager::debugDraw ( GFX::CommandBuffer bufferInOut,
GFX::MemoryBarrierCommand memCmdInOut,
bool  forceAll = true 
)

Handle any debug information rendering (nav meshes, AI paths, etc). Called by Scene::postRender after depth map preview call

Definition at line 212 of file AIManager.cpp.

◆ destroy()

void Divide::AIManager::destroy ( )

Clear all AI related data (teams, entities, NavMeshes, etc);.

Clear up any remaining AIEntities.

Definition at line 34 of file AIManager.cpp.

◆ destroyNavMesh()

bool Divide::AIManager::destroyNavMesh ( AIEntity::PresetAgentRadius  radius)

Definition at line 152 of file AIManager.cpp.

◆ getNavMesh()

Navigation::NavigationMesh * Divide::AI::AIManager::getNavMesh ( const AIEntity::PresetAgentRadius  radius) const
inline

Definition at line 96 of file AIManager.h.

◆ getTeamByID()

AITeam * Divide::AI::AIManager::getTeamByID ( const U32  AITeamID)
inline

Definition at line 80 of file AIManager.h.

◆ isDebugDraw()

bool Divide::AI::AIManager::isDebugDraw ( ) const
inlinenoexcept

Definition at line 120 of file AIManager.h.

◆ navMeshDebugDraw()

bool Divide::AI::AIManager::navMeshDebugDraw ( ) const
inlinenoexcept

Definition at line 123 of file AIManager.h.

◆ pauseUpdate()

void Divide::AI::AIManager::pauseUpdate ( const bool  state)
inlinenoexcept

Definition at line 112 of file AIManager.h.

◆ processData()

bool Divide::AIManager::processData ( U64  deltaTimeUS)
private

think

Definition at line 87 of file AIManager.cpp.

◆ processInput()

bool Divide::AIManager::processInput ( U64  deltaTimeUS)
private

sensors

Definition at line 78 of file AIManager.cpp.

◆ registerEntity()

bool Divide::AIManager::registerEntity ( U32  teamID,
AIEntity entity 
)

Add an AI Entity to a specific team. Entities can be added to multiple teams. Caller is responsible for the lifetime of entity

Definition at line 105 of file AIManager.cpp.

◆ registerTeam()

AITeam * Divide::AIManager::registerTeam ( U32  id)

Register an AI Team.

Definition at line 176 of file AIManager.cpp.

◆ running()

bool Divide::AI::AIManager::running ( ) const
inlinenoexcept

Definition at line 127 of file AIManager.h.

◆ setSceneCallback()

void Divide::AI::AIManager::setSceneCallback ( const DELEGATE< void > &  callback)
inline

Remove a NavMesh.

Definition at line 107 of file AIManager.h.

◆ shouldStop()

bool Divide::AIManager::shouldStop ( ) const
protectednoexcept

Definition at line 226 of file AIManager.cpp.

◆ stop()

void Divide::AI::AIManager::stop ( )
inlinenoexcept

Definition at line 125 of file AIManager.h.

◆ toggleNavMeshDebugDraw()

void Divide::AIManager::toggleNavMeshDebugDraw ( bool  state)

Toggle debug draw for all NavMeshes.

Definition at line 203 of file AIManager.cpp.

◆ unregisterEntity() [1/2]

void Divide::AIManager::unregisterEntity ( AIEntity entity)

Remove an AI Entity from all teams. Entities can be added to multiple teams. Caller is responsible for the lifetime of entity

Definition at line 115 of file AIManager.cpp.

◆ unregisterEntity() [2/2]

void Divide::AIManager::unregisterEntity ( U32  teamID,
AIEntity entity 
)

Remove an AI Entity from a specific teams. Entities can be added to multiple teams. Caller is responsible for the lifetime of entity

Definition at line 121 of file AIManager.cpp.

◆ unregisterTeam()

bool Divide::AIManager::unregisterTeam ( U32  id)

Unregister an AI Team.

Definition at line 189 of file AIManager.cpp.

◆ update()

void Divide::AIManager::update ( U64  deltaTimeUS)

Called at a fixed interval (preferably in a separate thread);.

use internal delta time calculations

Lock the entities during update() adding or deleting entities is suspended until this returns

Definition at line 46 of file AIManager.cpp.

◆ updateEntities()

bool Divide::AIManager::updateEntities ( U64  deltaTimeUS)
private

react

Definition at line 96 of file AIManager.cpp.

◆ updatePaused()

bool Divide::AI::AIManager::updatePaused ( ) const
inlinenoexcept

Definition at line 113 of file AIManager.h.

◆ updating()

bool Divide::AI::AIManager::updating ( ) const
inlinenoexcept

Definition at line 114 of file AIManager.h.

Friends And Related Function Documentation

◆ AITeam

friend class AITeam
friend

Definition at line 135 of file AIManager.h.

Member Data Documentation

◆ _aiTeams

AITeamMap Divide::AI::AIManager::_aiTeams
private

Definition at line 153 of file AIManager.h.

◆ _currentTimeUS

U64 Divide::AI::AIManager::_currentTimeUS
private

Definition at line 146 of file AIManager.h.

◆ _deltaTimeUS

U64 Divide::AI::AIManager::_deltaTimeUS
private

Definition at line 146 of file AIManager.h.

◆ _navMeshDebugDraw

std::atomic_bool Divide::AI::AIManager::_navMeshDebugDraw
private

Definition at line 147 of file AIManager.h.

◆ _navMeshes

NavMeshMap Divide::AI::AIManager::_navMeshes
private

Definition at line 152 of file AIManager.h.

◆ _navMeshMutex

SharedMutex Divide::AI::AIManager::_navMeshMutex
mutableprivate

Definition at line 155 of file AIManager.h.

◆ _parentPool

TaskPool& Divide::AI::AIManager::_parentPool
private

Definition at line 145 of file AIManager.h.

◆ _pauseUpdate

std::atomic_bool Divide::AI::AIManager::_pauseUpdate
private

Definition at line 148 of file AIManager.h.

◆ _previousTimeUS

U64 Divide::AI::AIManager::_previousTimeUS
private

Definition at line 146 of file AIManager.h.

◆ _running

std::atomic_bool Divide::AI::AIManager::_running
private

Definition at line 151 of file AIManager.h.

◆ _sceneCallback

DELEGATE<void> Divide::AI::AIManager::_sceneCallback
private

Definition at line 156 of file AIManager.h.

◆ _shouldStop

std::atomic_bool Divide::AI::AIManager::_shouldStop
private

Definition at line 150 of file AIManager.h.

◆ _updateMutex

Mutex Divide::AI::AIManager::_updateMutex
mutableprivate

Definition at line 154 of file AIManager.h.

◆ _updating

std::atomic_bool Divide::AI::AIManager::_updating
private

Definition at line 149 of file AIManager.h.


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