|
VR-Engage
2.2
|
DtVreHumanMovementActuator handles movement for human entities in the simulation. It moves the entity at the requested speed (clamped by the maximum speed limit) and direction, with appropriate terrain interaction and collision detection. The actuator also models fatigue effects, health impacts on mobility, and terrain suitability for different postures.
The implementation includes realistic limitations based on terrain slope, soil type, entity health status, and obstacles. It also handles special cases like ladder climbing and entity embarkation.
Uses Descriptor Type: DtVreHumanMovementActuatorDescriptor
#include <vreHumanMovementActuator.h>
Public Member Functions | |
| DtVreHumanMovementActuator (const DtString &name, DtLocalObject *owner, DtSimulationServices *simManager, DtComponentDescriptor *desc=0, DtReaderWriterRegistry *parentRegistry=0) | |
| virtual | ~DtVreHumanMovementActuator () override |
| virtual const char * | type () const override |
| virtual bool | init () override |
| virtual void | tick () override |
| virtual bool | canBlockMovement (const DtSimObject *object) const |
Public Member Functions inherited from makVre::DtVreSimComponent< DtHumanMovementActuator > | |
| DtVreSimComponent (const DtString &name, DtLocalObject *owner, DtSimulationServices *simManager, DtComponentDescriptor *desc=0, DtReaderWriterRegistry *parentRegistry=0) | |
| virtual | ~DtVreSimComponent () |
| bool | isPlayerControlled (const std::string &role="") const |
| DtString | entitySystemName () const |
Static Public Member Functions | |
| static DtSimComponent * | creator (const DtString &name, DtLocalObject *owner, DtSimulationServices *simManager, DtComponentDescriptor *desc=0, DtReaderWriterRegistry *parentRegistry=0) |
| static void | setRestoredCallback (DtSimMessage *msg, void *usrData) |
Protected Member Functions | |
| virtual DtLifeformStaticPosture | restrictPostureForTerrain (DtLifeformStaticPosture desiredPosture) override |
| virtual bool | checkIfMoveOntoEmbarked (const DtVector &localPosition) override |
| bool | vrfObjectCheckIfMoveOntoEmbarked (const DtVector &localPosition, const DtSimObject *&hit, const std::list< DtUUID > &additionalIgnore) |
| virtual void | setRadio (DtSimRadio *radio) override |
| virtual void | setRestored () |
| virtual void | modulateDesiredSpeed (double &newDesiredSpeed, double &newMaxSpeed, double desiredSpeed) |
| virtual bool | checkForTerrainCollisions () const override |
| virtual bool | checkBlockedByTerrain (const DtVector &oldLocalPosition, DtVector &newLocalProjectedLocation, double heightFraction=-1.0) override |
| virtual bool | checkBlockedByEntities (const DtVector &oldLocalPosition, DtVector &newLocalProjectedLocation) override |
| virtual bool | checkForEntityCollisions () const override |
| virtual bool | canIgnoreCollisionWith (const DtSimObject &hitObject) const |
| virtual void | calculateOrientationAndPosition (const DtVector &newLocalProjectedLocation, double newHeading, double newFacingOrientation, DtDcm &newLocalOrientation, DtDcm &newLocalDirectionOfMovement, DtVector &newLocalPosition) override |
| virtual DtChord | movementChord (const DtVector &oldLocalPosition, const DtVector &newLocalProjectedLocation, DtVector &intersectionVec, DtVector &bvCenterStartFromOldPos) override |
| virtual DtChord | movementChordAtHeight (const DtVector &oldLocalPosition, const DtVector &newLocalProjectedLocation, double heightFraction, DtVector &intersectionVec, DtVector &offsetFromOldPosition) override |
| virtual bool | initializeAglPort () override |
| virtual bool | shouldFatigueChange (FatigueEffect &fatigueEffect, double desiredSpeed, double maxSpeed) const |
| virtual double | computeFatigueIncrease (FatigueEffect fatigueEffect, double currentTopSpeed, double maxSpeed) const |
| virtual double | computeFatigueDecrease (FatigueEffect fatigueEffect) const |
| virtual void | computeAllHealthEffectsOnSpeed (double &newDesiredSpeed, double &newMaxSpeed, double desiredSpeed, double maxSpeed) const |
| virtual bool | shouldAllowMovement () |
| virtual void | updateFatigue (FatigueEffect fatigueEffect, double newDesiredSpeed, double newMaxSpeed) const |
| void | processVreTerrainChangeNotification (const DtTerrainChangeNotificationInfo &terrainChangeInfo) |
Static Protected Member Functions | |
| static void | vreTerrainChangeNotification (const DtTerrainChangeNotificationInfo &terrainChangeInfo, void *usr) |
Protected Attributes | |
| DtVreHumanMovementActuatorDescriptor * | myVreHumanMovementDescriptor |
| DtVector | myDesiredVelocity |
| DtRwInt * | myMobilityHealth |
| DtRwReal * | myFatigue |
| DtRwReal * | myPercentOfMaxSpeed |
| DtRwInt * | myFirepowerHealth |
| DtRwInt * | myOverallHealth |
| DtCompositePredicate | myObjectsToCheckForMovementBlock |
Private Member Functions | |
| DtVreHumanMovementActuator & | operator= (const DtVreHumanMovementActuator &orig) |
| DtVreHumanMovementActuator (const DtVreHumanMovementActuator &orig) | |
Enumeration of different fatigue modification rates.
Defines different rates at which fatigue can be modified based on activity level and recovery. These rates are configured in the human.sysdef file. The decrease amounts are for recovery when resting or moving slowly. The increase amounts are for when the human is exerting and becoming tired.
|
private |
Copy constructor (not implemented)
Copy constructor is private and not implemented to prevent copy construction.
References DtVreHumanMovementActuator().
Referenced by DtVreHumanMovementActuator(), and operator=().
| makVre::DtVreHumanMovementActuator::DtVreHumanMovementActuator | ( | const DtString & | name, |
| DtLocalObject * | owner, | ||
| DtSimulationServices * | simManager, | ||
| DtComponentDescriptor * | desc = 0, | ||
| DtReaderWriterRegistry * | parentRegistry = 0 ) |
Constructor.
| name | The name of this component |
| owner | The local object that owns this component |
| simManager | The simulation services manager |
| desc | Component descriptor with configuration parameters |
| parentRegistry | Optional parent registry for reader/writer functionality |
Creates a new human movement actuator component with the specified parameters.
|
overridevirtual |
Virtual destructor.
Cleans up resources used by the human movement actuator component.
|
private |
Assignment operator (not implemented)
Assignment operator is private and not implemented to prevent assignment.
References DtVreHumanMovementActuator().
|
overridevirtual |
Gets the type identifier for this component.
Implements the DtSimComponent::type() method to return the type identifier for this component.
|
overridevirtual |
Initializes the human movement actuator.
Looks up and caches health-related state properties including "MobilityHealth", "FirepowerHealth", "OverallHealth", and "Fatigue". These properties are used to modulate movement capabilities based on entity status.
|
overridevirtual |
Updates the actuator state each simulation frame.
Processes movement for the human entity during each simulation frame. This includes calculating appropriate speed based on health status, terrain conditions, and fatigue. Overridden to set the maximum speed to 9.0 m/s for better user experience in first-person mode.
|
static |
Factory method to create a new instance of this component.
| name | The name for the new component |
| owner | The local object that will own this component |
| simManager | The simulation services manager |
| desc | Optional component descriptor |
| parentRegistry | Optional parent registry for reader/writer functionality |
Static factory method used by the component creation system to instantiate new instances of this component type.
|
static |
Callback for entity restoration events.
| msg | The message containing restoration information |
| usrData | User data pointer, typically pointing to the instance of this class |
Static callback function invoked when an entity is restored (e.g., after being damaged). This function calls the instance's setRestored() method to reinitialize health properties.
|
virtual |
Checks if this entity can block other entities' movement.
| object | Pointer to the object to check against |
Determines whether this entity should be considered a physical obstacle that can block the movement of other entities in the simulation.
|
overrideprotectedvirtual |
Restricts posture based on terrain conditions.
| desiredPosture | The posture the entity wants to adopt |
Determines if the desired posture is appropriate for the current terrain. For example, standing upright on a steep hill is not allowed, so the return would be prone. This ensures realistic posture constraints based on environmental conditions.
|
overrideprotectedvirtual |
Checks if entity can embark onto another entity at the given position.
| localPosition | The local position to check for embarkation opportunities |
Checks if there are any entities at the given location that can be moved onto for embarkation. If such entities exist, checks if the current entity intersects with them, which would allow embarkation.
|
protected |
Performs embarkation check against specific objects.
| localPosition | The local position to check for embarkation opportunities |
| hit | Output parameter that will contain the hit object if one is found |
| additionalIgnore | List of object UUIDs to ignore during the check |
Implementation method that performs the detailed embarkation check against specific objects. It allows for additional objects to be ignored in the check and returns the hit object through an output parameter.
|
overrideprotectedvirtual |
Sets the radio receiver for simulation messages.
| radio | Pointer to the simulation radio for message communication |
Overrides the base class implementation to register interest in the set restored message. This allows the component to receive notifications when the entity is restored after being damaged.
|
protectedvirtual |
Handles entity restoration after damage.
Overridden to look up myMobilityHealth and other health-related state properties again. State properties are reset when an entity is damaged and then restored, so this method re-caches the necessary properties to ensure correct health-based movement modulation after restoration.
|
protectedvirtual |
Modulates the desired speed based on environmental factors.
| [out] | newDesiredSpeed | Output parameter that will contain the modulated desired speed |
| [out] | newMaxSpeed | Output parameter that will contain the modulated maximum speed |
| [in] | desiredSpeed | The current desired speed of the human |
Calculates the current maximum speed based on terrain pitch, soil type, and capabilities of the entity. Modifies both the desired speed and maximum speed to account for these environmental factors.
|
overrideprotectedvirtual |
Determines if terrain collision checks should be performed.
Always returns true if the entity is player-controlled, ensuring that player-controlled entities always check for terrain collisions. For non-player entities, delegates to the base class implementation.
|
overrideprotectedvirtual |
Checks if movement is blocked by terrain features.
| oldLocalPosition | The current position of the entity |
| newLocalProjectedLocation | The desired new position (modified if blocked) |
| heightFraction | Optional fraction of entity height to use for collision check |
Checks for terrain polygons between the specified old and new positions. If blocking terrain is found, the newLocalProjectedLocation parameter is modified to position the entity just before the collision would occur.
|
overrideprotectedvirtual |
Checks if movement is blocked by other entities.
| oldLocalPosition | The current position of the entity |
| newLocalProjectedLocation | The desired new position (modified if blocked) |
Checks for other entities between the specified old and new positions. If blocking entities are found, the newLocalProjectedLocation parameter is modified to position the entity just before the collision would occur.
|
overrideprotectedvirtual |
Determines if entity collision checks should be performed.
Overridden to return false when non-player-controlled and embarked on air objects. This special case allows entities to disembark past other lifeforms on aircraft like the Chinook helicopter, preventing entities from getting stuck during disembarkation.
|
protectedvirtual |
Determines if a specific object can be ignored for collision detection.
| hitObject | The object to check for collision ignorability |
Returns true if the given object can be safely ignored for collisions. This includes the entity that the current entity is embarked on, and tactical ladders (which need to be approachable for climbing, handled by a different movement actuator). Returns false for all other objects. This method is called by checkForEntityCollision().
|
overrideprotectedvirtual |
Calculates new orientation and position for the entity.
| newLocalProjectedLocation | The target projected location for the entity |
| newHeading | The new heading direction |
| newFacingOrientation | The new facing orientation |
| newLocalOrientation | Output parameter for the calculated orientation |
| newLocalDirectionOfMovement | Output parameter for the calculated movement direction |
| newLocalPosition | Output parameter for the calculated position |
Calculates the new orientation and position for the entity based on the projected location and heading information. This method handles the proper calculation of orientation matrices and position vectors for entity movement.
|
overrideprotectedvirtual |
Calculates a movement chord considering entity bounding volume.
| oldLocalPosition | The current position of the entity |
| newLocalProjectedLocation | The desired new position |
| intersectionVec | Output parameter for the vector between positions in local coordinates |
| bvCenterStartFromOldPos | Output parameter for the vector from old position to chord start |
Calculates a movement vector based on the two input positions, using the bounding volume of the entity. The resulting vector is not directly between the positions, but rather offset to the front face of the bounding volume. This method helps determine the actual movement path considering the entity's physical dimensions.
|
overrideprotectedvirtual |
Calculates a movement chord at a specific height fraction.
| oldLocalPosition | The current position of the entity |
| newLocalProjectedLocation | The desired new position |
| heightFraction | The fraction of entity height to use for chord calculation |
| intersectionVec | Output parameter for the vector between positions in local coordinates |
| offsetFromOldPosition | Output parameter for the vector from old position to chord start |
Similar to movementChord, but rather than using the bounding volume center to define the height of the chord, this method uses a specified fraction of the entity height. This allows for more precise collision detection at different heights of the entity.
|
overrideprotectedvirtual |
Initializes the Above Ground Level (AGL) port.
Overridden to use closestIntersection instead of terrainHeight when determining the entity's height above ground. This is because terrainHeight doesn't take into account geometry from feature replacement, which can lead to inaccurate height calculations in areas with complex terrain features.
|
protectedvirtual |
Determines if and how fatigue should change based on movement.
| [out] | fatigueEffect | Output parameter that will contain the type of fatigue change |
| desiredSpeed | The speed after health effects have modified the original desired speed | |
| maxSpeed | The maximum speed after health effects have modified the original max speed |
Evaluates current movement conditions to determine if fatigue should change, and if so, what type of change should occur. The desiredSpeed and maxSpeed parameters reflect speeds after health effects have already been applied. These values must remain relative to each other so a percentage can be calculated to determine if the human is running or walking. If the return value is true, fatigue should increase or decrease based on the value of the fatigueEffect parameter.
|
protectedvirtual |
Computes the increase in fatigue based on movement speed.
| fatigueEffect | The type of fatigue change to apply |
| currentTopSpeed | The current computed speed for the entity |
| maxSpeed | The fastest speed this entity can move |
Calculates the increase in fatigue based on the entity's movement speed relative to its maximum speed. Fatigue is used to realistically modify the speed at which an entity can move over time. The fatigue rate is calibrated based on movement at maximum speed, with reduced fatigue effects for lower speeds. The function returns the new fatigue value after applying the appropriate increase based on the specified fatigueEffect and the entity's movement parameters.
|
protectedvirtual |
Computes the decrease in fatigue during recovery.
| fatigueEffect | The type of fatigue recovery to apply |
Calculates the decrease in fatigue when the entity is resting or moving slowly. The rate of recovery depends on the specified fatigueEffect parameter, which determines how quickly the entity recovers from fatigue. This function is typically called when the entity is stationary or moving at low speeds.
|
protectedvirtual |
Computes speed modifications based on all health effects.
| [out] | newDesiredSpeed | Output parameter for the new desired speed after health effects |
| [out] | newMaxSpeed | Output parameter for the new maximum speed after health effects |
| desiredSpeed | The input desired speed after terrain factors | |
| maxSpeed | The input maximum speed before fatigue effects |
Computes modifications to both desired and maximum speed based on all factors that affect entity performance: overall health, mobility health, and accumulated fatigue. Both output speed values are modified proportionally to maintain their relationship, ensuring that percentage calculations (like determining if the entity is running or walking) remain valid. The input desiredSpeed parameter already accounts for terrain type and slope effects.
|
protectedvirtual |
Determines if movement should be allowed based on injury state.
Evaluates whether the entity should be allowed to move based on its injury state. When a human entity is severely injured and on the ground, it should not be able to crawl or rotate. This method enforces realistic movement limitations for injured entities.
|
protectedvirtual |
Updates the entity's fatigue level.
| fatigueEffect | How fatigue should increase/decrease and by how much |
| newDesiredSpeed | The speed after damage model and fatigue effects |
| newMaxSpeed | The maximum speed after damage model and fatigue effects |
Updates the entity's fatigue level based on the specified fatigueEffect and current movement parameters. The newDesiredSpeed and newMaxSpeed parameters reflect speeds after both damage model and existing fatigue effects have been applied. These parameters are used to determine the percentage of maximum speed the entity is moving at, which affects how quickly fatigue changes.
|
staticprotected |
Callback for terrain change notifications.
| terrainChangeInfo | Information about the terrain change |
| usr | User data pointer, typically pointing to the instance of this class |
Static callback function invoked when terrain changes occur in the simulation. This allows the movement actuator to respond to changes in the terrain that might affect movement capabilities, such as new obstacles or changes in terrain slope or soil type.
|
protected |
Processes terrain change notifications.
| terrainChangeInfo | Information about the terrain change |
Instance method that processes terrain change notifications received through the static callback. This method analyzes the terrain changes and updates the movement capabilities accordingly, such as adjusting available postures or movement speeds based on new terrain conditions.
|
protected |
Pointer to the human movement actuator descriptor.
Contains the configuration parameters for this human movement actuator.
|
protected |
Desired velocity vector for the entity.
Stores the current desired velocity vector for the entity, which is used to determine movement direction and speed.
|
protected |
Entity's mobility health value.
References the entity's mobility health state property, which affects movement speed and capabilities.
|
protected |
Entity's fatigue value.
References the entity's fatigue state property, which represents accumulated exertion and affects movement speed.
|
protected |
Entity's percentage of maximum speed.
References the state property that tracks what percentage of maximum speed the entity is currently moving at.
|
protected |
Entity's firepower health value.
References the entity's firepower health state property, which affects weapon capabilities but may also influence overall movement.
|
protected |
Entity's overall health value.
References the entity's overall health state property, which provides a general indication of the entity's condition.
|
protected |
Predicate for movement blocking object types.
Composite predicate that defines which types of objects should be checked for movement blocking during collision detection.