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 Member Functions | Protected Types | Protected Member Functions | Protected Attributes
DtFormationState Class Reference

Classes

struct  DerivedOffsets
 

Public Member Functions

 DtFormationState ()
 
 DtFormationState (const DtFormationState &orig)
 
DtFormationStateoperator= (const DtFormationState &orig)
 
virtual ~DtFormationState ()
 
virtual bool setFormation (const DtFormation &formation)
 
virtual bool assignEntitiesToFormation (const std::vector< DtUUID > entityList, const std::vector< int > promotionIds)
 
virtual void setEntityListAndFormation (const std::vector< DtUUID > &entityList, const DtFormation &formation, const std::vector< int > &promotionIds)
 
virtual bool lookup (const DtUUID &subordinate, DtFormationQueryResult &result) const
 
virtual int lookupFormationPromotionIDByEntity (const DtUUID &subordinate) const
 
virtual void queryAll (DtFormationQueryResultList &resultList) const
 
virtual const std::vector< DtUUIDentityList () const
 
virtual DtUUID formationLeader () const
 
virtual double formationHalfLength () const
 
virtual DtExtent formationBodyExtent () const
 
virtual void print () const
 
virtual void addFormationStateChangedCallback (DtFormationStateCallbackFcn fcn, void *userData)
 
virtual void removeFormationStateChangedCallback (DtFormationStateCallbackFcn fcn, void *userData)
 
virtual void enableFormationCallbacks ()
 
virtual void disableFormationCallbacks ()
 
virtual void clearEntityList ()
 
void markModified ()
 
void clearModified ()
 
bool isModified () const
 
virtual void invokeFormationStateChangedCallbacks () const
 

Protected Types

typedef boost::shared_ptr
< const DtFormationRecord
SharedFormationRecord
 

Protected Member Functions

virtual const DtFormationRecordlookupFormationRecord (int promotionId) const
 
virtual DtVector lookupFollowOffset (const DtUUID &subordinate) const
 
virtual DtUUID lookupLeaderOfEntity (const DtUUID &subordinate) const
 
virtual void rebuildEntityToPositionInUnitMap ()
 
virtual const DtFormationRecordgenerateAdditionalFormationRecord (int promotionId) const
 
void emptyFormationIndexToFormationRecordMap ()
 
virtual void createFormationRecords (const DtFormation &formation)
 
virtual void resetFormationMap ()
 

Protected Attributes

DtFormation myFormation
 
double myCurrentFormationSpacing
 
std::vector
< DtFormationStateCallbackInfo
myFormationStateChangedCallbackList
 
bool myCallbacksAreEnabled
 
bool myModified = false
 
Formation Data Indexed by Formation Promotion ID.

"FormPromId" is the promotion ID for the formation, i.e. from the data in the formation parameters (not necessarily the subordinate entity's rank in the unit, although for the default unit configuration these are the same).

std::map< int,
SharedFormationRecord
myFormPromIdToFormationRecordMap
 
std::map< DtUUID, DerivedOffsetsmyEntityToDerivedOffsetsMap
 
std::map< int, DtUUIDmyFormPromIdToEntityMap
 
std::map< DtUUID, intmyEntityToFormPromIdMap
 

Member Typedef Documentation

typedef boost::shared_ptr<const DtFormationRecord> DtFormationState::SharedFormationRecord
protected

Constructor & Destructor Documentation

DtFormationState::DtFormationState ( )
DtFormationState::DtFormationState ( const DtFormationState orig)
virtual DtFormationState::~DtFormationState ( )
virtual

Member Function Documentation

DtFormationState& DtFormationState::operator= ( const DtFormationState orig)
virtual bool DtFormationState::setFormation ( const DtFormation formation)
virtual

Sets a new formation in the formation state. This sets myFormation and calls resetFormationMap so that all of the offset data for the current set of subordinates are recomputed. The promotion IDs assignment to subordinates remains the same.

virtual bool DtFormationState::assignEntitiesToFormation ( const std::vector< DtUUID entityList,
const std::vector< int promotionIds 
)
virtual

Sets the entity-to-promotion ID maps. If the biggest promotion ID is > the size of myFormation, then myFormation is expanded using default offsets. The intent is for the caller to also set the formation, with the right number of entries. Returns true if all goes well, and false if the data was invalid.

Parameters
entityListis a list of subordinates, in any order.
promotionIdsis a list of promotion IDs that correspond to the entities in entityList. The two lists must be the same size.
virtual void DtFormationState::setEntityListAndFormation ( const std::vector< DtUUID > &  entityList,
const DtFormation formation,
const std::vector< int > &  promotionIds 
)
virtual

Sets the entire formation state.

Parameters
entityListis a list of the subordinates that can currently be moved in formation, i.e. pass the DtFormationableSubordinatePredicate filter.
formationIndicesis a list of indices corresponding to the entities in the entityList – the two vectors must be the same size. formationPosition[i] indicates the "unit index" of the subordinate, i.e. the rank order of the subordinate in the unit definition. For a unit that has not been reorganized, this will be the same as the "designator" - 1. (See subordinateManager.) The values in formationPosition do not have to be consecutive, and may skip values if subordinates are missing because of destruction, external tasking, etc.
doAutoPromote,iftrue, causes the n entities in the list to use the formation slots that have the first n formation promotion IDs.
virtual bool DtFormationState::lookup ( const DtUUID subordinate,
DtFormationQueryResult result 
) const
virtual

Get the formation query data for a single entity.

virtual int DtFormationState::lookupFormationPromotionIDByEntity ( const DtUUID subordinate) const
virtual
Returns
The current promotion index (position index) of the subordinate. Returns -1 if the entity is not in the formation.
virtual void DtFormationState::queryAll ( DtFormationQueryResultList resultList) const
virtual

Returns formation state associated with each entity in formation. It is up to the caller to delete the memory associated with each DtFormationQueryResult item returned in the vector.

virtual const std::vector<DtUUID> DtFormationState::entityList ( ) const
virtual

Provides a list of the entities currently in the formation.

virtual DtUUID DtFormationState::formationLeader ( ) const
virtual

Returns the entity with the lowest formation promotion ID among the current subordinates.

virtual double DtFormationState::formationHalfLength ( ) const
virtual

Returns the half-length of the formation.

virtual DtExtent DtFormationState::formationBodyExtent ( ) const
virtual

Returns an extent in the body coordinates of the unit, centered on the unit center of mass.

virtual void DtFormationState::print ( ) const
virtual

For debugging.

virtual void DtFormationState::addFormationStateChangedCallback ( DtFormationStateCallbackFcn  fcn,
void *  userData 
)
virtual

Registers callback for notification of any change to the formation state.

virtual void DtFormationState::removeFormationStateChangedCallback ( DtFormationStateCallbackFcn  fcn,
void *  userData 
)
virtual

Removes callback for notification of any change to the formation state.

virtual void DtFormationState::enableFormationCallbacks ( )
virtual

Control whether or not formation callbacks are invoked. By default, they are enabled. Only the DtFormationController should ever call these functions.

virtual void DtFormationState::disableFormationCallbacks ( )
virtual
virtual void DtFormationState::clearEntityList ( )
virtual

Clears all information out of the state except myFormation. Thus a new state can be built be calling assign... without setting the formation.

void DtFormationState::markModified ( )
void DtFormationState::clearModified ( )
bool DtFormationState::isModified ( ) const
inline
virtual void DtFormationState::invokeFormationStateChangedCallbacks ( ) const
virtual

Call the registered callbacks.

virtual const DtFormationRecord* DtFormationState::lookupFormationRecord ( int  promotionId) const
protectedvirtual

Looks up the record for this promotion ID. If not found, returns NULL.

virtual DtVector DtFormationState::lookupFollowOffset ( const DtUUID subordinate) const
protectedvirtual

Gets the offset relative to the entity's leader entity. If this entity is not in the formation, returns (0,0,0).

virtual DtUUID DtFormationState::lookupLeaderOfEntity ( const DtUUID subordinate) const
protectedvirtual

Returns the leader of the given subordinate. If either is not found int the formation, returns a nullUUID.

virtual void DtFormationState::rebuildEntityToPositionInUnitMap ( )
protectedvirtual

Computes the positions of the subordinate entities relative to the unit center (instead of relative to their immediate leader) and current formation leader. Saved in myEntityToDerivedOffsetsMap and myFormationLeader. This information is returned as part of a DtFormationQueryResult.

virtual const DtFormationRecord* DtFormationState::generateAdditionalFormationRecord ( int  promotionId) const
protectedvirtual

Gets the formationRecord associated with the given formation order index. Returns a new instance of a DtFormationRecord. It is up to the caller to delete the memory associated with the record. //! TODO – remove.

void DtFormationState::emptyFormationIndexToFormationRecordMap ( )
protected

Deletes all DtFormationRecord entries in myPositionIndexToFormationRecordMap and clears out all entries from map.

virtual void DtFormationState::createFormationRecords ( const DtFormation formation)
protectedvirtual

Rebuilds myFormPromIdToFormationRecordMap to include the formation info corresponding to the formationEntries with promotion IDs in the myEntityToFormPromIdMap. Computes unit center given the entries in myEntityToFormPromIdMap; then for each record computes the formation leader offset and the unit offset.

virtual void DtFormationState::resetFormationMap ( )
protectedvirtual

Calls createFormationRecords with myFormation as the argument.

Member Data Documentation

DtFormation DtFormationState::myFormation
protected

This is the current formation definition for the formation state. This is a copy of a formation obtained from entity params. It may be expanded for additional subordinates if there are more than the number of formation positions defined in the params. Having a DtFormation allows the FormationState to get information using the DtFormation member functions.

std::map<int, SharedFormationRecord> DtFormationState::myFormPromIdToFormationRecordMap
mutableprotected

Formation records hold the definition of the formation slots. The map key, FormPromId, is the promotion index in the formation defintion; 0 is the formation leader. This information is a duplicate of what is in myFormation, but it is organized in a map for easy access by promotion ID rather than being in a list. Mutable: to allow change in lookupFormationRecord.

std::map<DtUUID, DerivedOffsets> DtFormationState::myEntityToDerivedOffsetsMap
protected

Formation records hold the definition of the formation slots. The map key, FormPromId, is the promotion index in the formation defintion; 0 is the formation leader. This information is a duplicate of what is in myFormation, but it is organized in a map for easy access by promotion ID rather than being in a list. Mutable: to allow change in lookupFormationRecord.

std::map<int, DtUUID> DtFormationState::myFormPromIdToEntityMap
protected

Maps between the subordinate entity and its formation promotion ID in the current formation.

std::map<DtUUID, int> DtFormationState::myEntityToFormPromIdMap
protected

Formation records hold the definition of the formation slots. The map key, FormPromId, is the promotion index in the formation defintion; 0 is the formation leader. This information is a duplicate of what is in myFormation, but it is organized in a map for easy access by promotion ID rather than being in a list. Mutable: to allow change in lookupFormationRecord.

double DtFormationState::myCurrentFormationSpacing
protected

The current spacing of the formation. This is the space between the positions of promotion ID 0 and its closest follower. 0.0 means to use the default formation spacing. Otherwise the minimum value in 1.0.

std::vector<DtFormationStateCallbackInfo> DtFormationState::myFormationStateChangedCallbackList
protected

List of DtFormationStateCallbackFcns. Clients register callback functions on this list for notification when the formation state has changed for some reason.

bool DtFormationState::myCallbacksAreEnabled
protected
bool DtFormationState::myModified = false
protected

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

Document ID: Generated on Tue Sep 24 19:28:17 EDT 2024 from SVN revision 269799
Copyright © 2005-2024 MAK Technologies. All Rights Reserved (www.mak.com)