VR-Forces Developer's Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
List of all members | Classes | Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | Protected Types | Protected Member Functions | Protected Attributes
makVrv::DtOsgBallisticManager Class Reference

Ballistic manager that owns the projectile pool, compute component, and spatial grid.

Implements the DtBallisticManager interface for the OSG-based renderer. Responsible for spawning, updating, and retiring ballistic projectiles each tick.

Inheritance diagram for makVrv::DtOsgBallisticManager:
Inheritance graph
[legend]

Classes

struct  DtBallisticBurstRecord
 
struct  DtBallisticProjectileInstance
 

Public Types

using BallisticGeometryMap = tbb::concurrent_unordered_map< unsigned int, DtBallisticGeometry * >
 

Public Member Functions

DtBallisticSoundProxy & soundProxy ()
 
void setSoundQueryMaxResults (int n)
 
virtual ~DtOsgBallisticManager ()
 
virtual void tick (void) override
 
virtual void createProjectiles (const BallisticIdentifier &id, const BallisticData &data) override
 
virtual void removeProjectiles (const BallisticIdentifier &id) override
 
virtual void slot_atcGlobalModelEnableChanged ()
 
virtual void slot_releaseResources ()
 
virtual void slot_postTick ()
 
virtual void slot_postInit ()
 
virtual void slot_currentObserverChanged (DtObserver *observer)
 
virtual void slot_windSpeedChanged (float metersPerSecond)
 
virtual void slot_windDirectionChanged (float radians)
 
const BallisticGeometryMap & ballisticGeometryMap () const
 
void setDefaultProjectileLifetime (double seconds)
 
virtual double defaultProjectileLifetime () const
 
osg::Node * ballisticRenderNode () const
 
void registerPipPerObjectData (const std::string &pipFilename, const osg::Vec4 &perObjectData)
 
int tracerEffectEntryCount () const
 
DtTracerEffectEntry * tracerEffectEntryAt (int index)
 
const DtTracerEffectEntry * tracerEffectEntryAt (int index) const
 
DtBallisticComputeComponent * computeComponent () const
 
DtBallisticSpatialGrid * grid () const
 
std::mutex & observerPositionMutex ()
 
DtVector observerWorldPosition () const
 
bool observerPositionValid () const
 
- Public Member Functions inherited from makVrv::DtBallisticManager
virtual ~DtBallisticManager ()
 
 DtBallisticManager ()=delete
 
 DtBallisticManager (const DtBallisticManager &)=delete
 
DtBallisticManager & operator= (const DtBallisticManager &)=delete
 
- Public Member Functions inherited from makVrv::DtVirtualBaseClass
 DtVirtualBaseClass ()
 
virtual ~DtVirtualBaseClass ()
 

Static Public Member Functions

static const std::string & theClassName ()
 
static void registerInstance (DtDe &de)
 
static DtOsgBallisticManager & instance (DtDe &de)
 
- Static Public Member Functions inherited from makVrv::DtBallisticManager
static DtBallisticManager & instance (DtDe &de)
 

Public Attributes

boost::signalslib::signal
< void(osg::Node *)> 
signal_ballisticRenderNodeAdded
 
boost::signalslib::signal
< void(osg::Node *)> 
signal_ballisticRenderNodeToBeRemoved
 
boost::signalslib::signal
< void(DtTracerEffectEntry &)> 
signal_tracerEffectEntryAdded
 
boost::signalslib::signal
< void(DtTracerEffectEntry &)> 
signal_tracerEffectEntryToBeRemoved
 

Protected Types

using MapUniqueIdsToBallisticProjectileInstances = tbb::concurrent_hash_map< DtUniqueID, DtBallisticProjectileInstance >
 

Protected Member Functions

 DtOsgBallisticManager (DtDe &de)
 
 DtOsgBallisticManager ()=delete
 
 DtOsgBallisticManager (const DtOsgBallisticManager &)=delete
 
DtOsgBallisticManager & operator= (const DtOsgBallisticManager &)=delete
 
virtual void computeDirectionVectors (DtVector position, DtVector &east, DtVector &north, DtVector &up)
 
virtual DtBallisticBurstHandle fire (const DtBallisticFireRequest &request, DtBallisticProjectileInstance &instance, DtBallisticGeometry *geometry)
 
virtual void cancelBurst (const DtBallisticBurstHandle &handle)
 
virtual DtBallisticProjectile * spawnOneRound (DtBallisticBurstRecord &record, double currentSimTime)
 
virtual void reset ()
 
void setupRootNodes ()
 
virtual void updateStats ()
 
virtual void setAlpha2Coverage (osg::Node *node, bool on)
 
- Protected Member Functions inherited from makVrv::DtBallisticManager
 DtBallisticManager (DtDe &de)
 

Protected Attributes

DtSignalConnectionManager myConnections
 
float myWindSpeed
 
float myWindDirection
 
boost::signalslib::connection myPostInitializeConnection
 
const DtBallisticRunTimeSettings & myBallisticRunTimeSettings
 
std::unique_ptr
< DtBallisticProjectilePool > 
myProjectilePool
 
DtBallisticComputeComponent * myComputeComponent
 
DtBallisticSpatialGrid * myGrid
 
BallisticGeometryMap myBallisticGeometryMap
 
MapUniqueIdsToBallisticProjectileInstances myMapUniqueIdsToBallisticProjectileInstances
 
std::deque
< DtBallisticBurstRecord > 
myBurstRecords
 
double myLastTickTime
 
double myDefaultProjectileLifetime
 
std::unordered_map
< std::string, osg::Vec4 > 
myPipFilenameToPerObjectData
 
std::unordered_map
< std::string, std::unique_ptr
< DtTracerEffectEntry > > 
myTracerEffectEntries
 
osg::ref_ptr
< DtBallisticDebugGeometry > 
myDebugGeometry
 
osg::ref_ptr< osg::Group > myDebugGroup
 
DtBallisticSoundProxy mySoundProxy
 
DtObserver * myCurrentObserver
 
std::mutex myObserverPositionMutex
 
DtVector myObserverWorldPosition
 
bool myObserverPositionValid
 
- Protected Attributes inherited from makVrv::DtBallisticManager
DtDe & myDe
 

Member Typedef Documentation

Type definition for the ballistic geometry map, which maps unique integer IDs to geometry instances.

Map of unique firing-event identifiers to their projectile instance records.

Constructor & Destructor Documentation

virtual makVrv::DtOsgBallisticManager::~DtOsgBallisticManager ( )
virtual

Destructor.

makVrv::DtOsgBallisticManager::DtOsgBallisticManager ( DtDe &  de)
protected

Constructor.

makVrv::DtOsgBallisticManager::DtOsgBallisticManager ( )
protecteddelete

Default construction is not supported.

makVrv::DtOsgBallisticManager::DtOsgBallisticManager ( const DtOsgBallisticManager &  )
protecteddelete

Copy construction is not supported.

Member Function Documentation

static const std::string& makVrv::DtOsgBallisticManager::theClassName ( )
static

Returns the DtDe registration key used by registerInstance() and instance().

DtBallisticSoundProxy& makVrv::DtOsgBallisticManager::soundProxy ( )

Returns the sound coupling proxy.

void makVrv::DtOsgBallisticManager::setSoundQueryMaxResults ( int  n)

Sets the maximum number of sound query results per frame.

Caches the value in the proxy and, if the compute component is already live, forwards it immediately to DtBallisticComputeComponent.

Parameters
nMaximum number of results.
static void makVrv::DtOsgBallisticManager::registerInstance ( DtDe &  de)
static

Registers this manager on the given simulation environment.

Parameters
deSimulation environment to register with.
static DtOsgBallisticManager& makVrv::DtOsgBallisticManager::instance ( DtDe &  de)
static

Returns the registered instance from the given simulation environment.

Parameters
deSimulation environment to query.
Exceptions
Ifno instance is registered.
DtOsgBallisticManager& makVrv::DtOsgBallisticManager::operator= ( const DtOsgBallisticManager &  )
protecteddelete

Copy assignment is not supported.

virtual void makVrv::DtOsgBallisticManager::tick ( void  )
overridevirtual

Advances the ballistic simulation by one frame.

Implements makVrv::DtBallisticManager.

virtual void makVrv::DtOsgBallisticManager::createProjectiles ( const BallisticIdentifier &  id,
const BallisticData &  data 
)
overridevirtual

Creates projectiles for the given ballistic identifier and data.

Parameters
idIdentifier for the firing event.
dataBallistic parameters for this firing event.

Implements makVrv::DtBallisticManager.

virtual void makVrv::DtOsgBallisticManager::removeProjectiles ( const BallisticIdentifier &  id)
overridevirtual

Removes all projectiles associated with the given identifier.

Parameters
idIdentifier of the firing event to remove.

Implements makVrv::DtBallisticManager.

virtual void makVrv::DtOsgBallisticManager::slot_atcGlobalModelEnableChanged ( )
virtual

Handles the global alpha-to-coverage enable/disable signal.

virtual void makVrv::DtOsgBallisticManager::slot_releaseResources ( )
virtual

Releases all GPU and scene-graph resources held by this manager.

virtual void makVrv::DtOsgBallisticManager::slot_postTick ( )
virtual

Handles the post-tick signal.

virtual void makVrv::DtOsgBallisticManager::slot_postInit ( )
virtual

Handles the post-initialization signal.

virtual void makVrv::DtOsgBallisticManager::slot_currentObserverChanged ( DtObserver *  observer)
virtual

Updates the cached observer pointer when the active observer changes. Connected to DtInputDriverSignaler::signal_currentObserverChanged in slot_postInit().

Parameters
observerNew active observer, or null if all observers were destroyed.
virtual void makVrv::DtOsgBallisticManager::slot_windSpeedChanged ( float  metersPerSecond)
virtual

Handles a wind speed change.

Parameters
metersPerSecondNew wind speed in metres per second.
virtual void makVrv::DtOsgBallisticManager::slot_windDirectionChanged ( float  radians)
virtual

Handles a wind direction change.

Parameters
radiansNew wind direction in radians.
const BallisticGeometryMap& makVrv::DtOsgBallisticManager::ballisticGeometryMap ( ) const

Returns the live ballistic geometry map.

void makVrv::DtOsgBallisticManager::setDefaultProjectileLifetime ( double  seconds)

Sets the fallback projectile lifetime used when a bullet definition provides no max lifetime.

Parameters
secondsLifetime in seconds. Must be > 0.
virtual double makVrv::DtOsgBallisticManager::defaultProjectileLifetime ( ) const
virtual

Returns the fallback lifetime (seconds) when a bullet definition provides no max lifetime. Subclasses may override to customize.

osg::Node* makVrv::DtOsgBallisticManager::ballisticRenderNode ( ) const

Returns the ballistic grid renderer node, or null if setupRootNodes() has not yet been called. The caller must not delete the returned pointer.

void makVrv::DtOsgBallisticManager::registerPipPerObjectData ( const std::string &  pipFilename,
const osg::Vec4 &  perObjectData 
)

Stores the SensorFX per-object data vec4 for the given pip filename. Called by JrmSensorModule after registering a node with SensorRender. An empty pipFilename key means the default fallback for unspecified pips. Must be called from the main thread only.

Parameters
pipFilenamePip filename key; empty string is the default fallback.
perObjectDataSensorFX per-object data vec4.
int makVrv::DtOsgBallisticManager::tracerEffectEntryCount ( ) const

Returns the number of DtTracerEffectEntry instances currently managed. Must be called from the simulation thread only.

DtTracerEffectEntry* makVrv::DtOsgBallisticManager::tracerEffectEntryAt ( int  index)

Returns the DtTracerEffectEntry at the given index, or null if out of range. Index range is [0, tracerEffectEntryCount()). The caller must not delete it. Must be called from the simulation thread only.

Parameters
indexZero-based position in the internal entry table.
Returns
Non-owning pointer to the entry, or null if index is out of range.
const DtTracerEffectEntry* makVrv::DtOsgBallisticManager::tracerEffectEntryAt ( int  index) const

Returns the DtTracerEffectEntry at the given index, or null if out of range. Index range is [0, tracerEffectEntryCount()). The caller must not delete it. Must be called from the simulation thread only.

Parameters
indexZero-based position in the internal entry table.
Returns
Non-owning pointer to the entry, or null if index is out of range.
virtual void makVrv::DtOsgBallisticManager::computeDirectionVectors ( DtVector  position,
DtVector &  east,
DtVector &  north,
DtVector &  up 
)
protectedvirtual

Computes local direction vectors for the given world position.

Parameters
positionWorld-space position.
eastReceives the east unit vector.
northReceives the north unit vector.
upReceives the up unit vector.
virtual DtBallisticBurstHandle makVrv::DtOsgBallisticManager::fire ( const DtBallisticFireRequest &  request,
DtBallisticProjectileInstance &  instance,
DtBallisticGeometry *  geometry 
)
protectedvirtual

Schedules and starts a burst-fire sequence.

The first round is spawned synchronously. Subsequent rounds are queued and spawned in future tick() calls as inter-round intervals elapse. Returns an invalid handle if the request is malformed or the pool is exhausted.

Parameters
requestFire parameters.
instanceProjectile instance record to associate with this burst.
geometryCell geometry that will own all slots for this burst.
Returns
Handle identifying this burst.
virtual void makVrv::DtOsgBallisticManager::cancelBurst ( const DtBallisticBurstHandle &  handle)
protectedvirtual

Cancels all pending rounds for the given burst.

Already-live projectiles continue to simulate to their natural expiry. No-op for an invalid or already-completed handle.

Parameters
handleHandle returned by a prior fire() call.
virtual DtBallisticProjectile* makVrv::DtOsgBallisticManager::spawnOneRound ( DtBallisticBurstRecord &  record,
double  currentSimTime 
)
protectedvirtual

Spawns a single round from the given burst record.

Acquires a pool slot, initialises spawn data, and adds the projectile to the spatial grid. Returns null if the pool is exhausted.

Parameters
recordThe burst record this round belongs to.
currentSimTimeAbsolute simulation time at the moment of spawn.
Returns
Pointer to the spawned projectile, or null if the pool is exhausted.
virtual void makVrv::DtOsgBallisticManager::reset ( )
protectedvirtual

Releases all resources and resets all bookkeeping to the initial state.

void makVrv::DtOsgBallisticManager::setupRootNodes ( )
protected

Sets up the scene-graph root nodes for all geometry grids.

virtual void makVrv::DtOsgBallisticManager::updateStats ( )
protectedvirtual

Updates indirect-entity statistics; called each post-tick.

virtual void makVrv::DtOsgBallisticManager::setAlpha2Coverage ( osg::Node *  node,
bool  on 
)
protectedvirtual

Enables or disables alpha-to-coverage on the given node.

Parameters
nodeThe node to modify.
onTrue to enable alpha-to-coverage; false to disable.
DtBallisticComputeComponent* makVrv::DtOsgBallisticManager::computeComponent ( ) const

Returns the compute component.

DtBallisticSpatialGrid* makVrv::DtOsgBallisticManager::grid ( ) const

Returns the spatial grid.

std::mutex& makVrv::DtOsgBallisticManager::observerPositionMutex ( )
inline

Returns the mutex guarding the cached observer world-space position.

Used by DtBallisticComputeComponent::dispatchSoundQuery() (render thread) to safely read the observer position cached by slot_postTick() (sim thread).

DtVector makVrv::DtOsgBallisticManager::observerWorldPosition ( ) const
inline

Returns the cached observer world-space position.

Only valid to read while holding observerPositionMutex().

bool makVrv::DtOsgBallisticManager::observerPositionValid ( ) const
inline

Returns true if the cached observer position is valid (observer exists).

Only valid to read while holding observerPositionMutex().

Member Data Documentation

boost::signalslib::signal<void(osg::Node*)> makVrv::DtOsgBallisticManager::signal_ballisticRenderNodeAdded

Signal emitted from setupRootNodes() after the ballistic grid renderer node has been added to the scene graph. Argument is the renderer node pointer. JrmSensorModule connects to register the node with SensorRender and store the visible tracer pip per-object data.

boost::signalslib::signal<void(osg::Node*)> makVrv::DtOsgBallisticManager::signal_ballisticRenderNodeToBeRemoved

Signal emitted from reset() before the ballistic grid renderer node is removed from the scene graph and the grid is deleted. Argument is the renderer node pointer. JrmSensorModule connects to call sensorRender->removeNodeObject() on the node.

boost::signalslib::signal<void(DtTracerEffectEntry&)> makVrv::DtOsgBallisticManager::signal_tracerEffectEntryAdded

Signal emitted from fire() the first time a new pip filename is encountered. JrmSensorModule connects to call sensorRender->addObject(node.proxyNode(), params) and then node.setOtherData0(sgObj->getPerObjectData()).

boost::signalslib::signal<void(DtTracerEffectEntry&)> makVrv::DtOsgBallisticManager::signal_tracerEffectEntryToBeRemoved

Signal emitted from reset() before each DtTracerEffectEntry is destroyed. JrmSensorModule connects to call sensorRender->removeNodeObject(node.proxyNode()).

DtSignalConnectionManager makVrv::DtOsgBallisticManager::myConnections
protected

Manages signal/slot lifetime connections.

float makVrv::DtOsgBallisticManager::myWindSpeed
protected

Current wind speed in metres per second.

float makVrv::DtOsgBallisticManager::myWindDirection
protected

Current wind direction in radians.

boost::signalslib::connection makVrv::DtOsgBallisticManager::myPostInitializeConnection
protected

Connection for the post-init signal; disconnected when slot_postInit() fires.

const DtBallisticRunTimeSettings& makVrv::DtOsgBallisticManager::myBallisticRunTimeSettings
protected

Reference to the active ballistic runtime settings.

std::unique_ptr<DtBallisticProjectilePool> makVrv::DtOsgBallisticManager::myProjectilePool
protected

Shared pool that supplies GPU slots for all active projectiles.

DtBallisticComputeComponent* makVrv::DtOsgBallisticManager::myComputeComponent
protected

Shared compute component responsible for all trajectory computation.

DtBallisticSpatialGrid* makVrv::DtOsgBallisticManager::myGrid
protected

Spatial grid routing per-camera cull, draw, and proximity queries.

BallisticGeometryMap makVrv::DtOsgBallisticManager::myBallisticGeometryMap
protected

Map of geometry cell index to active ballistic geometry. Supports concurrent traversal; removal is single-threaded.

MapUniqueIdsToBallisticProjectileInstances makVrv::DtOsgBallisticManager::myMapUniqueIdsToBallisticProjectileInstances
protected
std::deque<DtBallisticBurstRecord> makVrv::DtOsgBallisticManager::myBurstRecords
protected

Active bursts with rounds still pending. NOT thread-safe: accessed only from the simulation thread (tick, fire, cancelBurst, reset). Do not call these methods from other threads without adding synchronization.

double makVrv::DtOsgBallisticManager::myLastTickTime
protected

Simulation time at the last tick, or -1 if not yet ticked.

double makVrv::DtOsgBallisticManager::myDefaultProjectileLifetime
protected

Fallback projectile lifetime in seconds.

std::unordered_map<std::string, osg::Vec4> makVrv::DtOsgBallisticManager::myPipFilenameToPerObjectData
protected

Maps pip filename to the SensorFX per-object data vec4.

std::unordered_map<std::string, std::unique_ptr<DtTracerEffectEntry> > makVrv::DtOsgBallisticManager::myTracerEffectEntries
protected

One DtTracerEffectEntry per unique non-empty pip filename encountered during createProjectiles(). Keyed by pip filename string.

osg::ref_ptr<DtBallisticDebugGeometry> makVrv::DtOsgBallisticManager::myDebugGeometry
protected

Always-on debug geometry node that draws position-only green spheres for all active projectiles when DebugTrajectoryVis is set. Registered before the ShowTracers visualizer roots so that when ShowTracers is enabled, debugDrawCullResults() overwrites the green spheres with color-coded ones.

osg::ref_ptr<osg::Group> makVrv::DtOsgBallisticManager::myDebugGroup
protected

Owning group that parents myDebugGeometry under the model-set roots. Held as a member (not a local) so slot_releaseResources() can remove it from the persistent scene graph on a display-config reload; otherwise each reload would leak a stale debug group as a new sibling.

DtBallisticSoundProxy makVrv::DtOsgBallisticManager::mySoundProxy
protected

Sound coupling proxy: query settings, index resolver, and trigger signal.

DtObserver* makVrv::DtOsgBallisticManager::myCurrentObserver
protected

Active observer, updated via DtInputDriverSignaler::signal_currentObserverChanged. Accessed only from the simulation thread; no additional mutex required.

std::mutex makVrv::DtOsgBallisticManager::myObserverPositionMutex
protected

Mutex protecting myObserverWorldPosition and myObserverPositionValid.

DtVector makVrv::DtOsgBallisticManager::myObserverWorldPosition
protected

Cached observer world-space position, updated each simulation tick.

bool makVrv::DtOsgBallisticManager::myObserverPositionValid
protected

True when myObserverWorldPosition holds a valid observer position.


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

Document ID: Generated on Thu Oct 15 21:27:02 EDT 2026 from SVN revision 296421
Copyright © 2005-2026 MAK Technologies. All Rights Reserved (www.mak.com)