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 | Protected Member Functions | Protected Attributes | Private Member Functions
DtDetonationManager Class Reference

The DtDetonationManager class exists to centralize the processing of detonation interactions. Components register with the detonation manager, providing a pointer to a DtSimObject as well as the objects global designator, and a damage adjudication function to call when the detonation affects the registered sim object. The detonation manager determines the entity or entities the detonation affects, and notifies them and only them through the supplied callback functions.

With regards to detonation interactions, for a result of "entity proximate", where the entity is specified as the target, or for a result of simply "detonation", the range to the detonation is determined, and the damage probability is determined using a surface of "front" and an angle of incidence of 0. The detonation manager fills in a detonation context with all the appropriate information, and looks up the entity to see if it has registered a callback. If so, it calls the registered callback, supplying the detonation context.

When a detonation manager receives a detonation of type DtDetResDetonation (sent by the indirect fire actuator for artillery), it again fills in the detonation context, but then calls all appropriate entities with registered callbacks.

Inheritance diagram for DtDetonationManager:
Inheritance graph
[legend]

Classes

struct  DtCollateralDetonationTargetInfo
 
struct  DtDetonationCallbackInfo
 
struct  DtDirectDetonationTargetInfo
 
struct  DtQueuedDetonationCallbackInfo
 

Public Types

typedef std::shared_ptr
< DtDetonationContext
DtDetonationContextPtr
 
typedef std::map
< DtSimMunition, double
DtMunitionDamageMap
 
typedef DtMunitionDamageMap DtMunitionMaxRangeMap
 
typedef std::map< DtString,
double
DtPowerDamageMap
 
typedef std::list
< DtDetonationCallbackInfo
DtDetonationCallbackInfoList
 
typedef DtBoost::shared_ptr
< DtDirectDetonationTargetInfo
DtDirectDetonationTargetInfoPtr
 
typedef std::list
< DtDirectDetonationTargetInfoPtr
DtDirectDetonationTargetList
 
typedef std::map< DtUUID,
DtDirectDetonationTargetInfoPtr
DtDirectDetonationTargetMap
 
typedef DtBoost::shared_ptr
< DtCollateralDetonationTargetInfo
DtCollateralDetonationTargetInfoPtr
 
typedef std::list
< DtCollateralDetonationTargetInfoPtr
DtCollateralDetonationTargetList
 
typedef std::map< DtUUID,
DtCollateralDetonationTargetInfoPtr
DtCollateralDetonationTargetMap
 
- Public Types inherited from DtDetonationServiceInterface
typedef bool(* DtDamageAdjudicationFunction )(const DtDetonationContext &detonationContext, void *usr)
 

Public Member Functions

 DtDetonationManager (DtSimulationServices *simManager)
 
virtual ~DtDetonationManager ()
 
virtual bool init ()
 
virtual bool reinitialize ()
 
virtual void tick ()
 
virtual bool registerDirectDetonation (const DtUUID &entityId, void *callbackObject, DtDamageAdjudicationFunction func)
 
virtual bool registerCollateralDetonation (const DtUUID &entityId, DtSimMunition munition, double maxDamageRadius, void *callbackObject, DtDamageAdjudicationFunction func)
 
virtual bool registerCollateralDetonationByPower (const DtUUID &entityId, const DtString &powerType, double minDamagePower, void *callbackObject, DtDamageAdjudicationFunction func)
 
virtual bool unRegisterDirectDetonationTarget (const DtUUID &entity)
 
virtual bool unRegisterCollateralDetonationTarget (const DtUUID &entity)
 
virtual bool unRegisterCollateralDetonationCallback (const DtUUID &entity, void *callbackObject, DtDamageAdjudicationFunction func)
 
virtual bool isTargetInterestedInCollateralDetonation (const DtDetonationCallbackInfo &detonationCbs, double impactRange, double shooterRange, DtDetonationContext &detonationContext) const
 
virtual void sendDetonationInteraction (const makVrfEvents::DtDetonationEvent &detonation)
 
virtual bool loadParametersFromFile (const DtFilename &filename)
 
virtual bool loadDeformationParametersFromFile (const DtFilename &filename)
 
virtual double detonationPower (const DtSimMunition &munition, double rangeFromShooter, double rangeFromImpact, const DtString &powerType) const
 
virtual
DtTerrainDeformationParams
terrainDeformationParameters ()
 
virtual const
DtTerrainDeformationParams
terrainDeformationParameters () const
 
virtual void resetParameters ()
 
virtual bool parametersLoaded () const
 
virtual const DtFilename & parametersFile () const
 
virtual const DtFilename & deformationParametersFile () const
 
virtual void processDetonation (const makVrfEvents::DtDetonationEvent &detonation)
 
virtual DtDetonationResult detonationResult (const DtSimMunition &munition, DtDetonatorFuze fuze, const DtEntityType &targetEntityType, const DtVector &localPosition) const
 
virtual DtDetonationResult detonationResult (const DtSimMunition &munition, DtDetonatorFuze fuze, const DtSurface &terrainSurface, const DtVector &localPosition) const
 
virtual DtDetonationResult detonationResultMidAir (const DtSimMunition &munition, const DtVector &localPosition) const
 
virtual DtDetonationParamsparameters ()
 
virtual const DtDetonationParamsparameters () const
 
- Public Member Functions inherited from DtDetonationServiceInterface
 DtDetonationServiceInterface ()
 

Protected Member Functions

virtual double lookupMunitionInMap (const DtMunitionDamageMap &munitionMap, const DtSimMunition &munition) const
 
virtual void processUUIDChanged (const DtUUID &oldUUID, const DtUUID &newUUID)
 
virtual const DtPhysicalWorldphysicalWorld () const
 
virtual DtPhysicalWorldphysicalWorld ()
 
virtual Coordinate_SystemcoordinateSystem ()
 
virtual const Coordinate_SystemcoordinateSystem () const
 
virtual void processCollateralDetonationForEntitiesInRange (DtDetonationContext &detonationContext)
 
virtual DtDetonationResult defaultDetonationResult () const
 
void cleanOutDeadEntities ()
 
virtual DtDetonationParamscreateParameters ()
 
virtual
DtTerrainDeformationParams
createDeformationParameters ()
 
virtual void detonationEvent (const makVrfEvents::DtEvent &)
 

Protected Attributes

DtDirectDetonationTargetMap myDirectDetonationTargetMap
 
DtCollateralDetonationTargetMap myCollateralDetonationTargetMap
 
double myMinPowerForDamage
 
DtMunitionMaxRangeMap myMaxRangeForSpecificMunitionDamage
 
bool myQueueEntitiesToBeRemoved
 
std::list< DtUUIDmyEntitiesQueuedToBeRemovedList
 
DtSimulationServicesmySimulationServices
 
DtFilename myParametersFile
 
DtFilename myDeformationParamsFile
 
DtDetonationParamsmyParameters
 
DtTerrainDeformationParamsmyDeformationParams
 
tbb::recursive_mutex myMutex
 
bool myCreatedConnections = false
 
tbb::concurrent_queue
< DtQueuedDetonationCallbackInfo
myDetonationCallbackQueue
 
tbb::concurrent_queue
< SimObjectDetonationCallback * > 
myParallelDetonationQueue
 

Private Member Functions

 DtDetonationManager (const DtDetonationManager &orig)
 
DtDetonationManageroperator= (const DtDetonationManager &other)
 

Member Typedef Documentation

Constructor & Destructor Documentation

DtDetonationManager::DtDetonationManager ( DtSimulationServices simManager)

Constructs the detonation manager.

Parameters
simManagerA pointer to the simulation manager for the simulation.
virtual DtDetonationManager::~DtDetonationManager ( )
virtual

The destructor. Removes the DtDetonationEvent::removeCallback from the exercise connection.

DtDetonationManager::DtDetonationManager ( const DtDetonationManager orig)
private

Not defined! copy constructor.

Member Function Documentation

virtual bool DtDetonationManager::init ( )
virtual

Initializes the detonation manager.

  • clears all managed lists
  • registers for detonation callbacks with the exercise connection
Returns
a boolean signifying success or failure.
virtual bool DtDetonationManager::reinitialize ( )
virtual

Resets the detonation manager to initial state.

  • Removes any registered callbacks from the exercise connection
  • calls init to initialize the manager.
Returns
a boolean signifying success or failure.
See Also
init

Implements DtDetonationServiceInterface.

virtual void DtDetonationManager::tick ( )
virtual

Tick the detonation manager.

Implements DtDetonationServiceInterface.

virtual bool DtDetonationManager::registerDirectDetonation ( const DtUUID entityId,
void *  callbackObject,
DtDamageAdjudicationFunction  func 
)
virtual

Entities that wish to receive detonation notifications (technically, it is usually the actuators which register for the entity) call these functions.

Use this function to register interest in direct detonations ie entity impact or entity proximate detonations. Supplies the entity, the entity ID, a callback function and a pointer to the actuator (void *)

Implements DtDetonationServiceInterface.

virtual bool DtDetonationManager::registerCollateralDetonation ( const DtUUID entityId,
DtSimMunition  munition,
double  maxDamageRadius,
void *  callbackObject,
DtDamageAdjudicationFunction  func 
)
virtual

Use this function to register interest in collateral detonations ie ground detonations from indirect fire, missile detonations or direct fire detonations that would cause collateral damage to nearby entities. Supplies the entity, the entity ID, the munition being used, it's maximum radius that it can cause damage to the entity, a callback function, and a pointer to the actuator (void *). The munition and maximum damage radius are stored in the collateralDetonationTargetInfoPtr's damageMap keyed by munition.

Implements DtDetonationServiceInterface.

virtual bool DtDetonationManager::registerCollateralDetonationByPower ( const DtUUID entityId,
const DtString powerType,
double  minDamagePower,
void *  callbackObject,
DtDamageAdjudicationFunction  func 
)
virtual

Use this function to register interest in collateral detonations ie ground detonations from indirect fire, missile detonations or direct fire detonations that would cause collateral damage to nearby entities. Supplies the entity, the entity ID, the type of detonation power (e.g. "explosive"), the minimum power that can cause damage to the entity, a callback function, and a pointer to the actuator (void *).

Implements DtDetonationServiceInterface.

virtual bool DtDetonationManager::unRegisterDirectDetonationTarget ( const DtUUID entity)
virtual

Removes the entity from the detonation manager's container of detonation targets.

Parameters
entitythe address of the entity to be unregistered.
Note
If the entity pointer is NULL, then nothing is unregistered.
Returns
a boolean indicating the success or failure of the unregistration.

Implements DtDetonationServiceInterface.

virtual bool DtDetonationManager::unRegisterCollateralDetonationTarget ( const DtUUID entity)
virtual
virtual bool DtDetonationManager::unRegisterCollateralDetonationCallback ( const DtUUID entity,
void *  callbackObject,
DtDamageAdjudicationFunction  func 
)
virtual

Removes the given entity callback from the detonation manager's container of detonation target callbacks.

Implements DtDetonationServiceInterface.

virtual bool DtDetonationManager::isTargetInterestedInCollateralDetonation ( const DtDetonationCallbackInfo detonationCbs,
double  impactRange,
double  shooterRange,
DtDetonationContext detonationContext 
) const
virtual

Returns true if the entity has registered interest in the given detonation at the given range. If true, fills in the detonation context with the range and power information.

virtual void DtDetonationManager::sendDetonationInteraction ( const makVrfEvents::DtDetonationEvent detonation)
virtual

Send the fully initialized detonation interaction.

Implements DtDetonationServiceInterface.

virtual bool DtDetonationManager::loadParametersFromFile ( const DtFilename &  filename)
virtual

Calls createParameters() to get a new instance of the parameter object, and calls getSelf() on the parameters to load them from the file. Assigns the newly loaded parameters to myParameters and processes parameters specified.

Returns
True on success.
virtual bool DtDetonationManager::loadDeformationParametersFromFile ( const DtFilename &  filename)
virtual
virtual double DtDetonationManager::detonationPower ( const DtSimMunition munition,
double  rangeFromShooter,
double  rangeFromImpact,
const DtString powerType 
) const
virtual

Returns the detonation power for the specified munition, range from shooter, range from impact, and power type.

virtual DtDetonationResult DtDetonationManager::detonationResult ( const DtSimMunition munition,
DtDetonatorFuze  fuze,
const DtEntityType &  targetEntityType,
const DtVector localPosition 
) const
virtual

Determines the detonation result based on the munition and other factors.

Returns the detonation result when a munition of the given type hits an entity of the given type. In the default implementation, localPosition is not used, but can be in custom implementations.

Implements DtDetonationServiceInterface.

virtual DtDetonationResult DtDetonationManager::detonationResult ( const DtSimMunition munition,
DtDetonatorFuze  fuze,
const DtSurface terrainSurface,
const DtVector localPosition 
) const
virtual

Returns the detonation result when a munition of the given type hits the terrain with the given surface type. If the surface type is null, then the default detonation result is used. In the default implementation, localPosition is not used, but can be in custom implementations.

Implements DtDetonationServiceInterface.

virtual DtDetonationResult DtDetonationManager::detonationResultMidAir ( const DtSimMunition munition,
const DtVector localPosition 
) const
virtual

Returns the detonation result for a munition of the given type that when it detonates in mid-air. In the default implementation, localPosition is not used, but can be in custom implementations.

Implements DtDetonationServiceInterface.

virtual DtDetonationParams* DtDetonationManager::parameters ( )
virtual
Returns
The parameters for this DtDetonationManager.
virtual const DtDetonationParams* DtDetonationManager::parameters ( ) const
virtual
Returns
The parameters for this DtDetonationManager.

Implements DtDetonationServiceInterface.

virtual DtTerrainDeformationParams* DtDetonationManager::terrainDeformationParameters ( )
virtual
virtual const DtTerrainDeformationParams* DtDetonationManager::terrainDeformationParameters ( ) const
virtual
Returns
The parameters for this DtDetonationManager.

Implements DtDetonationServiceInterface.

virtual void DtDetonationManager::resetParameters ( )
virtual

Resets the parameters.

virtual bool DtDetonationManager::parametersLoaded ( ) const
virtual
Returns
true if a parameter set has been loaded.
virtual const DtFilename& DtDetonationManager::parametersFile ( ) const
virtual
Returns
The name of the detonation parameters file that was loaded.
virtual const DtFilename& DtDetonationManager::deformationParametersFile ( ) const
virtual
virtual void DtDetonationManager::processDetonation ( const makVrfEvents::DtDetonationEvent detonation)
virtual

Process the detonation interaction by properly creating a detonation context for the interaction, and then notifying all the appropriate entities of the detonation.

For entity impact and proximate detonations, only the specified entity is notified. For detonation and ground proximate interactions, all entities within range are notified. For ground impacts, entities in range are only notified if the munition was a missile.

See Also
getDirectFireSurfaceAndAngleOfIncidence
processIndirectFire
virtual double DtDetonationManager::lookupMunitionInMap ( const DtMunitionDamageMap munitionMap,
const DtSimMunition munition 
) const
protectedvirtual

If the munition is found returns the associated power or range value.

virtual void DtDetonationManager::processUUIDChanged ( const DtUUID oldUUID,
const DtUUID newUUID 
)
protectedvirtual
virtual const DtPhysicalWorld* DtDetonationManager::physicalWorld ( ) const
protectedvirtual
Returns
A pointer to the current physical world. This is guaranteed to either be a valid pointer or 0.
virtual DtPhysicalWorld* DtDetonationManager::physicalWorld ( )
protectedvirtual
virtual Coordinate_System* DtDetonationManager::coordinateSystem ( )
protectedvirtual
Returns
A pointer to the current coordinate system object to use. This is guaranteed to either be a valid pointer or 0.
virtual const Coordinate_System* DtDetonationManager::coordinateSystem ( ) const
protectedvirtual
virtual void DtDetonationManager::processCollateralDetonationForEntitiesInRange ( DtDetonationContext detonationContext)
protectedvirtual

Checks all entities who've registered interest in the munition in detonation context Checks the range of the detonation to the entity against the entity's maximumDamageRadius for that munition. If the detonation is within that range then tell that entity to process this detonation and determine any collateral damage from it.

virtual DtDetonationResult DtDetonationManager::defaultDetonationResult ( ) const
protectedvirtual

Returns the default detonation result. Default implementation returns DtDetResDetonation.

void DtDetonationManager::cleanOutDeadEntities ( )
protected
virtual DtDetonationParams* DtDetonationManager::createParameters ( )
protectedvirtual
Returns
A new instance of DtDetonationParams. If new parameters are used in a derived version of this class, override this method to return a derived version of DtDetonationParams.
virtual DtTerrainDeformationParams* DtDetonationManager::createDeformationParameters ( )
protectedvirtual
virtual void DtDetonationManager::detonationEvent ( const makVrfEvents::DtEvent )
protectedvirtual

Called for detonation event.

DtDetonationManager& DtDetonationManager::operator= ( const DtDetonationManager other)
private

assignment operator

Member Data Documentation

DtDirectDetonationTargetMap DtDetonationManager::myDirectDetonationTargetMap
protected
DtCollateralDetonationTargetMap DtDetonationManager::myCollateralDetonationTargetMap
protected
double DtDetonationManager::myMinPowerForDamage
protected
DtMunitionMaxRangeMap DtDetonationManager::myMaxRangeForSpecificMunitionDamage
protected
bool DtDetonationManager::myQueueEntitiesToBeRemoved
protected

After all the callbacks have been made those who've been destroyed or asked to unregistered need to be removed from the collateral target map.

std::list<DtUUID> DtDetonationManager::myEntitiesQueuedToBeRemovedList
protected
DtSimulationServices* DtDetonationManager::mySimulationServices
protected
DtFilename DtDetonationManager::myParametersFile
protected
DtFilename DtDetonationManager::myDeformationParamsFile
protected
DtDetonationParams* DtDetonationManager::myParameters
protected

Parameters for this detonation manager.

DtTerrainDeformationParams* DtDetonationManager::myDeformationParams
protected
tbb::recursive_mutex DtDetonationManager::myMutex
protected
bool DtDetonationManager::myCreatedConnections = false
protected
tbb::concurrent_queue<DtQueuedDetonationCallbackInfo> DtDetonationManager::myDetonationCallbackQueue
protected
tbb::concurrent_queue<SimObjectDetonationCallback*> DtDetonationManager::myParallelDetonationQueue
protected

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

Document ID: Generated on Wed Mar 27 22:49:11 EDT 2024 from SVN revision 264633
Copyright © 2005-2024 MAK Technologies. All Rights Reserved (www.mak.com)