![]() |
VR-Forces Developer's Guide
|
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.

Classes | |
| struct | DtBallisticBurstRecord |
| struct | DtBallisticProjectileInstance |
Public Types | |
| using | BallisticGeometryMap = tbb::concurrent_unordered_map< unsigned int, DtBallisticGeometry * > |
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) | |
| using makVrv::DtOsgBallisticManager::BallisticGeometryMap = tbb::concurrent_unordered_map<unsigned int, DtBallisticGeometry*> |
Type definition for the ballistic geometry map, which maps unique integer IDs to geometry instances.
|
protected |
Map of unique firing-event identifiers to their projectile instance records.
|
virtual |
Destructor.
|
protected |
Constructor.
|
protecteddelete |
Default construction is not supported.
|
protecteddelete |
Copy construction is not supported.
|
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.
| n | Maximum number of results. |
|
static |
Registers this manager on the given simulation environment.
| de | Simulation environment to register with. |
|
static |
Returns the registered instance from the given simulation environment.
| de | Simulation environment to query. |
| If | no instance is registered. |
|
protecteddelete |
Copy assignment is not supported.
|
overridevirtual |
Advances the ballistic simulation by one frame.
Implements makVrv::DtBallisticManager.
|
overridevirtual |
Creates projectiles for the given ballistic identifier and data.
| id | Identifier for the firing event. |
| data | Ballistic parameters for this firing event. |
Implements makVrv::DtBallisticManager.
|
overridevirtual |
Removes all projectiles associated with the given identifier.
| id | Identifier of the firing event to remove. |
Implements makVrv::DtBallisticManager.
|
virtual |
Handles the global alpha-to-coverage enable/disable signal.
|
virtual |
Releases all GPU and scene-graph resources held by this manager.
|
virtual |
Handles the post-tick signal.
|
virtual |
Handles the post-initialization signal.
|
virtual |
Updates the cached observer pointer when the active observer changes. Connected to DtInputDriverSignaler::signal_currentObserverChanged in slot_postInit().
| observer | New active observer, or null if all observers were destroyed. |
|
virtual |
Handles a wind speed change.
| metersPerSecond | New wind speed in metres per second. |
|
virtual |
Handles a wind direction change.
| radians | New 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.
| seconds | Lifetime in seconds. Must be > 0. |
|
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.
| pipFilename | Pip filename key; empty string is the default fallback. |
| perObjectData | SensorFX 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.
| index | Zero-based position in the internal entry table. |
| 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.
| index | Zero-based position in the internal entry table. |
|
protectedvirtual |
Computes local direction vectors for the given world position.
| position | World-space position. |
| east | Receives the east unit vector. |
| north | Receives the north unit vector. |
| up | Receives the up unit vector. |
|
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.
| request | Fire parameters. |
| instance | Projectile instance record to associate with this burst. |
| geometry | Cell geometry that will own all slots for this burst. |
|
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.
| handle | Handle returned by a prior fire() call. |
|
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.
| record | The burst record this round belongs to. |
| currentSimTime | Absolute simulation time at the moment of spawn. |
|
protectedvirtual |
Releases all resources and resets all bookkeeping to the initial state.
|
protected |
Sets up the scene-graph root nodes for all geometry grids.
|
protectedvirtual |
Updates indirect-entity statistics; called each post-tick.
|
protectedvirtual |
Enables or disables alpha-to-coverage on the given node.
| node | The node to modify. |
| on | True 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.
|
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).
|
inline |
Returns the cached observer world-space position.
Only valid to read while holding observerPositionMutex().
|
inline |
Returns true if the cached observer position is valid (observer exists).
Only valid to read while holding observerPositionMutex().
| 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()).
|
protected |
Manages signal/slot lifetime connections.
|
protected |
Current wind speed in metres per second.
|
protected |
Current wind direction in radians.
|
protected |
Connection for the post-init signal; disconnected when slot_postInit() fires.
|
protected |
Reference to the active ballistic runtime settings.
|
protected |
Shared pool that supplies GPU slots for all active projectiles.
|
protected |
Shared compute component responsible for all trajectory computation.
|
protected |
Spatial grid routing per-camera cull, draw, and proximity queries.
|
protected |
Map of geometry cell index to active ballistic geometry. Supports concurrent traversal; removal is single-threaded.
|
protected |
|
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.
|
protected |
Simulation time at the last tick, or -1 if not yet ticked.
|
protected |
Fallback projectile lifetime in seconds.
|
protected |
Maps pip filename to the SensorFX per-object data vec4.
|
protected |
One DtTracerEffectEntry per unique non-empty pip filename encountered during createProjectiles(). Keyed by pip filename string.
|
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.
|
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.
|
protected |
Sound coupling proxy: query settings, index resolver, and trigger signal.
|
protected |
Active observer, updated via DtInputDriverSignaler::signal_currentObserverChanged. Accessed only from the simulation thread; no additional mutex required.
|
protected |
Mutex protecting myObserverWorldPosition and myObserverPositionValid.
|
protected |
Cached observer world-space position, updated each simulation tick.
|
protected |
True when myObserverWorldPosition holds a valid observer position.