VR-Engage  2.3
Loading...
Searching...
No Matches
vortexMovementActuator.h
Go to the documentation of this file.
1/*******************************************************************************
2** Copyright (c) 2024 MAK Technologies
3** All rights reserved.
4*******************************************************************************/
5
6//! \file vortexMovementActuator.h
7//! \brief Movement actuator that integrates Vortex physics for vehicle dynamics
8//! \ingroup vreVrfVortex
9
10#pragma once
11
12#include <vreVrfVortex/export.h>
13
14#include <vrfobjcore/actuatorComponent.h>
15#include <vrfobjcore/platformLocalObjectFacade.h>
16
17#include <string>
18
19#include <Vx/VxTransform.h>
20#include <Vx/VxPart.h>
21#include <VxSim/VxSmartInterface.h>
22#include <VxSim/VxVHLInterface.h>
23#include <VxSim/IDynamics.h>
24#include <VxSim/VxSimulationFileManagerFacade.h>
25#include <VxDynamics/Mechanism.h>
26#include <VxData/Delegate.h>
27
29
30#include <terrainInterface/terrainImplementation.h>
31
32#include <readerWriter/symbolString.h>
33#include <vrfobjcore/localObject.h>
34#include <vrftasks/vrfObjectMessageTypeTemplate.h>
35#include <vlpi/articulatedPartCollection.h>
36
37#include <boost/signals2/connection.hpp>
38
39// forward defs
41class DtUpdateRepositoryOutputPortGroup;
46
47class DtInputPortGroup;
48class DtOutputPortGroup;
49class DtAnalogInputPort;
50class DtBooleanInputPort;
51class DtSingleConnectionInputPort;
52class DtSingleConnectionOutputPort;
53class DtGroundVehicleStateRepository;
54
55class DtStringOutputPort;
56class DtMechAddon;
58
59namespace VxSim
60{
61class VxExtension;
62class VxPluginExtension;
63class VxVHLInterface;
64class VxSimulationState;
65} // namespace VxSim
66
67namespace VxData
68{
69class FieldBase;
70} // namespace VxData
71
72namespace makVre
73{
80} // namespace makVre
81
82namespace makVrf
83{
84class DtArticulatedPartStateRepository;
85} // namespace makVrf
86
87//! \brief Type identifier for the Vortex movement actuator
88const char DtVortexMovementActuatorType[] = "vortex-movement-actuator";
89
90//! \brief Actuator component that integrates Vortex physics for vehicle dynamics
91//!
92//! This actuator provides high-fidelity vehicle physics by connecting a VR-Forces
93//! entity to a Vortex physics model. It handles vehicle dynamics simulation,
94//! terrain interaction, articulated parts, and player control.
95//!
96//! Uses Descriptor Type: DtVortexMovementActuatorDescriptor
97class VREVRFVORTEX_DLL DtVortexMovementActuator : public DtActuatorComponent
98{
99public:
100 //! \brief Type definition for a map of Vortex interfaces by name
101 using VortexInterfaceMap = std::map<std::string, DtVortexInterface*>;
102
103public:
104 //! \brief Constructor
105 //!
106 //! Initializes the actuator with the specified parameters.
107 //!
108 //! \param name Component name
109 //! \param owner Owner local object
110 //! \param simManager Simulation services
111 //! \param desc Component descriptor
112 //! \param parentRegistry Parent reader/writer registry
113 DtVortexMovementActuator(const DtString& name,
114 DtLocalObject* owner,
115 DtSimulationServices* simManager,
116 DtComponentDescriptor* desc = 0,
117 DtReaderWriterRegistry* parentRegistry = 0);
118
119 //! \brief Destructor
120 virtual ~DtVortexMovementActuator() override;
121
122 //! \brief Assignment operator and copy constructor not implemented
125
126 //! \brief Initializes the actuator
127 //!
128 //! Registers set callbacks and queues the loading of the physics mechanism.
129 //!
130 //! \return True on success, false otherwise
131 virtual bool init() override;
132
133 //! \brief Updates the actuator each simulation frame
134 //!
135 //! Manages the state of the Vortex mechanism, updates input/output ports,
136 //! and synchronizes between VR-Forces and Vortex.
137 virtual void tick() override;
138
139 //! \brief Gets the type of this actuator
140 //!
141 //! \return DtVortexMovementActuatorType
142 virtual const char* type() const override;
143
144 //! \brief Creates the ports required for actuator operation
145 //!
146 //! Creates the ports from the VHL Interface.
147 //!
148 //! \return True on success, false otherwise
149 virtual bool createPorts() override;
150
151 //! \brief Creates the port groups for the actuator
152 //!
153 //! Creates the input and output port groups from the VHL Interface.
154 //!
155 //! \return True on success, false otherwise
156 virtual bool createPortGroups() override;
157
158 //! \brief Factory method for creating instances of this actuator
159 //!
160 //! \param name Component name
161 //! \param owner Owner local object
162 //! \param simManager Simulation services
163 //! \param desc Component descriptor
164 //! \param parentRegistry Parent reader/writer registry
165 //! \return New instance of this class
166 static DtSimComponent* creator(const DtString& name,
167 DtLocalObject* owner,
168 DtSimulationServices* simManager,
169 DtComponentDescriptor* desc = 0,
170 DtReaderWriterRegistry* parentRegistry = 0);
171
172 //! \brief Initializes the actuator before the first simulation tick
173 //!
174 //! Calls initializeMovementChooserName() and dropAboveTerrain() to initially place
175 //! the vehicle on the terrain. Also passes any specified Vortex parameters from the
176 //! system definition file.
177 virtual void preFirstTickInit() override;
178
179 //! \brief Gets the list of all Vortex parts in this actuator
180 //!
181 //! \return Vector of pointers to Vortex parts
182 virtual const std::vector<DtVortexBasePart*>& getParts() const;
183
184 //! \brief Checks if high-fidelity Vortex physics should be active
185 //!
186 //! Vortex should be active if the player is driving the vehicle OR if the vehicle
187 //! is stationary and high-fidelity collision physics are enabled for this vehicle.
188 //!
189 //! \return True if Vortex physics should be active, false otherwise
190 virtual bool isInVortexWorld() const;
191
192 //! \brief Checks if the entity is player controlled
193 //!
194 //! \return True if the entity is player controlled, false otherwise
195 virtual bool isVortexPlayerControlled() const;
196
197 //! \brief Checks if the entity is being towed by another Vortex entity
198 //!
199 //! \return True if the entity is being towed, false otherwise
200 virtual bool isBeingTowed() const;
201
202 //! \brief Gets the entity currently attached to this vehicle's tow hook
203 //!
204 //! \return Current hook target UUID, or null UUID if there is no target
205 virtual DtUUID towingTargetUuid() const;
206
207 //! \brief Converts a Vortex field value to a tow target UUID
208 //!
209 //! \param field Vortex field containing the hook target value
210 //! \return Current hook target UUID, or null UUID if the field has no valid target
211 virtual DtUUID towingTargetUuid(const VxData::FieldBase& field) const;
212
213 //! \brief Drops the vehicle above the terrain at a specified position
214 //!
215 //! Calculates the terrain height at the new location and positions the vehicle
216 //! at the appropriate height above the terrain. The additional height above terrain
217 //! is determined by the descriptor's additionalDropHeight() value (default: 0.5 meters).
218 //!
219 //! This method checks all bounding points of the vehicle mechanism to ensure no part
220 //! of the vehicle is placed below the terrain surface. The vehicle is positioned such
221 //! that its lowest point is at the terrain height plus the additional drop height.
222 //!
223 //! \param newLocalPosition Where to drop the vehicle (in local coordinates)
224 //! \param heading The heading to set the vehicle at (in radians)
225 //!
226 //! \note The additional height value is now configured via DtVortexMovementActuatorDescriptor::setAdditionalDropHeight()
227 //! \see DtVortexMovementActuatorDescriptor::additionalDropHeight()
228 virtual void dropAboveTerrain(const DtVector& newLocalPosition, double heading);
229
230 //! \brief Gets the next frame's location and orientation as a VxMatrix
231 //!
232 //! \return Matrix containing orientation and position in NWU coordinates
233 VxMath::Matrix44 getNextFrameVortexTransform() const;
234
235 //! \brief Gets the current mechanism associated with the actuator
236 //!
237 //! \return Smart interface to the current mechanism
238 VxSim::VxSmartInterface<VxDynamics::Mechanism> getMechanism();
239
240 //! \brief Gets the next frame Vortex location from the entity
241 //!
242 //! \return Location vector in Vortex coordinates
243 Vx::VxVector3 getNextFrameVortexPosition() const;
244
245 //! \brief Gets the next frame Vortex orientation from the entity
246 //!
247 //! \return Euler angles in Vortex coordinates
248 Vx::VxEulerAngles getNextFrameVortexOrientation() const;
249
250 //! \brief Disables the vehicle dynamics
251 //!
252 //! Sets the parts to static and disables vehicle dynamics.
254
255 //! \brief Enables the vehicle dynamics
256 //!
257 //! Sets the parts to dynamic and enables vehicle dynamics.
259
260 //! \brief Applies the deferred startup dynamics disable after one physics step
261 //!
262 //! Called from DtMechAddon::preStep() so the mechanism receives one warm-up step
263 //! after initial placement before dynamics are disabled.
265
266 //! \brief Initializes Vortex model parameters with data from VR-Forces
267 //!
268 //! Initializes vehicle mass and wheel articulated part positions from VR-Forces entity parameters.
269 //! Called by loadMechanism.
271
272 //! \brief Updates the chassis mass from entity parameters
273 //!
274 //! Finds the chassis part (part ID -1) in the Vortex mechanism and updates
275 //! its mass and inertia tensor based on the entity's mass parameter.
276 //! The center of mass offset is preserved during the inertia recomputation.
277 //!
278 //! \note This method iterates through all parts looking for DtVortexPart
279 //! instances with part ID -1 (chassis).
280 //! \see initParametersFromModel()
281 virtual void updateMassOfChassis();
282
283protected:
285 //! \brief Loads the Vortex mechanism
286 //!
287 //! Performs the main loading of the mechanism. Called by the Listener in Vortex
288 //! at a safe time.
290
291 //! \brief Static callback for terrain change notifications
292 //!
293 //! \param terrainChangeInfo Information about the terrain change
294 //! \param usr Pointer to this actuator
295 static void terrainChangeNotification(const DtTerrainChangeNotificationInfo& terrainChangeInfo, void* usr);
296
297 //! \brief Processes terrain change notifications
298 //!
299 //! Checks if the entity is within the spatial extents of the terrain change
300 //! notification and sets the terrain change flag if needed.
301 //!
302 //! \param terrainChangeInfo Information about the terrain change
303 void processTerrainChangeNotification(const DtTerrainChangeNotificationInfo& terrainChangeInfo);
304
305 //! \brief Tags the geometries of all dynamics parts for collision detection
307
308protected:
309 //! \brief Initializes Vortex vehicle-part positions from VR-Forces articulated parts
310 //!
311 //! Initializes conventional wheels and sprockets before processing track wheels and idlers,
312 //! which depend on their corresponding sprocket positions.
314
315 //! \brief Initializes tracked-vehicle wheel and idler positions
316 //!
317 //! \param didInitLeftSprocket True when the left sprocket position was initialized
318 //! \param didInitRightSprocket True when the right sprocket position was initialized
319 virtual void initTrackPartPositions(bool didInitLeftSprocket, bool didInitRightSprocket);
320
321 //! \brief Gets the Vortex track parameter name for a dynamics part
322 //!
323 //! \return The left or right track parameter name, or nullptr for an invalid side
324 virtual const char* trackNameForPart(const DtVortexDynamicsPart& dynamicsPart) const;
325
326 //! \brief Gets a named Vortex vehicle parameter
327 //!
328 //! Logs a warning if the parameter is unavailable.
329 virtual VxData::FieldBase* vehicleParameter(const std::string& parameterName) const;
330
331 //! \brief Initializes a Vortex position field from an articulated-part position
332 //!
333 //! \return True when the field was successfully initialized
334 virtual bool initFieldFromArticulatedPartPosition(VxData::FieldBase* field,
335 const makVrf::DtArticulatedPartStateRepository* partRepository,
336 const DtVortexDynamicsPart* dynamicsPart) const;
337
338 //! \brief Initializes a track-wheel position relative to its sprocket
339 //!
340 //! \return True when the field was successfully initialized
341 virtual bool initTrackWheelRelativeToSprocket(VxData::FieldBase* trackWheel,
342 VxData::FieldBase* sprocket,
343 const makVrf::DtArticulatedPartStateRepository* partRepository,
344 const DtVortexDynamicsPart* dynamicsPart) const;
345
346 //! \brief Initializes a conventional wheel position from an articulated part
347 //!
348 //! \return True when the wheel position was successfully initialized
350 const makVrf::DtArticulatedPartStateRepository* partRepository);
351
352 //! \brief Initializes a sprocket position from an articulated part
353 //!
354 //! \return True when the sprocket position was successfully initialized
356 const makVrf::DtArticulatedPartStateRepository* partRepository);
357
358 //! \brief Initializes a track-wheel position from an articulated part
360 const makVrf::DtArticulatedPartStateRepository* partRepository,
361 const char* trackName);
362
363 //! \brief Initializes a track idler's distance from its sprocket
365 const makVrf::DtArticulatedPartStateRepository* partRepository,
366 const char* trackName);
367
368 //! \brief Callback for scripted set data request message
369 //!
370 //! Calls processUseHiFiCollisionsInStationaryCgfState() to process the message.
371 //!
372 //! \param msg The message to process
373 //! \param usrData User data
374 static void setVortexWhileUntaskedCallback(DtSimMessage* msg, void* usrData);
375
376 //! \brief Gets the Vortex part associated with an articulated part ID
377 //!
378 //! \param partId The part ID of the Vortex part to look for
379 //! \return Pointer to the base part, or nullptr if not found
380 DtVortexBasePart* findPart(int partId) const;
381
382 //! \brief Checks if the Vortex mechanism is valid
383 //!
384 //! Valid means the following conditions are all true:
385 //! - myMechanism.getExtension() != nullptr
386 //! - myMechanism.getInterface() != nullptr
387 //! - myMechanism.getObject() != nullptr
388 //! - myMechanism.valid()
389 //!
390 //! \return True if the mechanism is valid, false otherwise
391 virtual bool isVortexMechanismValid() const;
392
393 //! \brief Gets the lowest bounding points of the current mechanism
394 //!
395 //! The values are returned in NWU (Vortex Coordinate System).
396 //!
397 //! \param outputPoints Vector to store the lowest bounding points in current world space
398 virtual void getLowestBoundingPointsOfMechanism(std::vector<DtVector>& outputPoints);
399
400 //! \brief Processes a set data request to enable/disable high-fidelity physics
401 //!
402 //! Sets the value for useHiFiCollisionInStationaryCgfState in the process state repository
403 //! from the incoming scripted set data request message.
404 //!
405 //! \param msg The message to process
406 virtual void processSetVortexWhileUntasked(DtSimMessage* msg);
407
408 //! \brief Creates a process state repository for this component
409 //!
410 //! Creates a DtVortexMovementPSR for holding state associated with this component,
411 //! specifically the useHiFiCollisionInStationaryCgfState flag.
412 //!
413 //! \return True on success, false otherwise
414 virtual bool createPSR();
415
416 //! \brief Checks whether Vortex While Untasked is enabled
417 //!
418 //! Returns the actuator's configured Vortex While Untasked state without
419 //! inspecting the entity's current task state.
420 //!
421 //! \return True when Vortex While Untasked is enabled and the process state
422 //! is available, false otherwise
423 virtual bool isHighFidelityCGF() const;
424
425 //! \brief Checks if the entity is player controlled in a specific role
426 //!
427 //! Note that there may be multiple roles associated with a vehicle, so
428 //! responsibilities for controlling the vehicle may be split across multiple role players,
429 //! and/or shared with CGF control.
430 //!
431 //! \param role The role to check (e.g., "Driver")
432 //! \return True if player controlled in the specified role, false otherwise
433 virtual bool isPlayerControlledAs(std::string role) const;
434
435 //! \brief Updates the Vortex state based on current conditions
436 //!
437 //! Adds or removes the Vortex mechanism from the Vortex scene and registers or unregisters
438 //! this entity as a Vortex entity in the Collision Proxy Generator, as appropriate for the
439 //! current Vortex Active state.
440 virtual void realizeVortexState();
441
442 //! \brief Checks if terrain is available below the vehicle
443 //!
444 //! \return True if terrain is available below the center of the vehicle, false otherwise
445 virtual bool isTerrainAvailable() const;
446
447 //! \brief Detects and logs terrain fall-through conditions
448 //!
449 //! Checks if the vehicle has fallen through the terrain when terrain data is not available.
450 //! Logs diagnostic information to help identify terrain loading issues.
451 //! Called when terrain is unavailable during Vortex simulation.
453
454 //! \brief Sets the Vortex mechanism's location and orientation
455 //!
456 //! Sets the Vortex mechanism's transform using the location and heading and
457 //! resets wheel parts to be attached to the mechanism.
458 //!
459 //! \param nwuLocation The location in NWU coordinates
460 //! \param heading The heading in radians
461 virtual void setVortexMechanismLocation(const Vx::VxVector3& nwuLocation, double heading);
462
463 //! \brief Converts local coordinates to Vortex coordinates
464 //!
465 //! \param inputCoords The coordinates in local database coordinates
466 //! \return The corresponding coordinates in NWU (Vortex) coordinates
467 Vx::VxVector3 getVortexLocation(const DtVector& inputCoords) const;
468
469 //! \brief Sends a vehicle dynamics update event
470 //!
471 //! Internal function that sends the vehicle dynamics update event to Vortex.
472 //!
473 //! \param enable True to enable dynamics, false to disable
474 virtual void sendVehicleDynamicsUpdate(bool enable);
475
476 //! \brief Sends a Vortex extension update event
477 //!
478 //! \param extension The extension to update
479 //! \param enable True to enable the extension, false to disable it
480 virtual void sendExtensionUpdate(VxSim::VxExtension* extension, bool enable);
481
482 //! \brief Connects to tow-hook target updates from the driver interface
484
485 //! \brief Processes tow-hook target field changes
486 //!
487 //! \param field Vortex field that changed
488 void processTowingTargetChanged(const VxData::FieldBase& field);
489
490 //! \brief Updates tow-hook group reset state based on the current hook target
491 //!
492 //! \param currentTowingTargetUuid Current hook target UUID
493 void updateTowingHookGroupState(const DtUUID& currentTowingTargetUuid);
494
495 //! \brief Resets the Vortex tow-hook group extension
497
498 //! \brief Enables or disables the Vortex tow-hook group extension
499 //!
500 //! Used to mirror the vehicle-extension in/out-of-world activation path so
501 //! towing behavior is inactive whenever this actuator is out of the Vortex world.
502 //!
503 //! \param enable True to enable the hook group, false to disable it
504 void sendTowingHookGroupUpdate(bool enable);
505
506 //! \brief Finds this mechanism's tow-hook group extension
507 //!
508 //! \return Hook-group extension, or nullptr when the mechanism has none
509 VxSim::VxExtension* findTowingHookGroupExtension();
510
511 //! \brief Cancels CGF tasks that conflict with Vortex control
512 //!
513 //! When Vortex is active and the entity is tasked, cancels each top-level
514 //! task for which taskConflictsWithVortex() returns true, so a CGF
515 //! controller does not compete with Vortex for vehicle or turret control.
516 //! Other tasks continue to run. Clears the independently tasked state only
517 //! when no top-level tasks remain.
518 //!
519 //! \param vortexActive True when Vortex control is active; false leaves task
520 //! state unchanged
521 virtual void checkTaskStatus(bool vortexActive);
522
523 //! \brief Determines whether a task type conflicts with Vortex control
524 //!
525 //! Reads the task categories from the scripted-task action categories and
526 //! the entity's task execution rule groups. A task conflicts when it is in
527 //! the \c Movement category, or when it is in the \c Weapon category and the
528 //! Vortex mechanism has a turret interface.
529 //!
530 //! \param taskType The task type to classify
531 //! \return True if Vortex control must cancel the task
532 virtual bool taskConflictsWithVortex(const DtSimTaskMessageType& taskType) const;
533
534 //! \brief Connects to the current tow target deletion signal
535 //!
536 //! \param targetUuid The current tow target UUID
537 virtual void connectTowingTargetDeletedSignal(const DtUUID& targetUuid);
538
539 //! \brief Processes removal of the currently tracked tow target
541
542 //! \brief Clears current tow target tracking
544
545 //! \brief Updates the control state of all vehicle parts
546 //!
547 //! Sets the control type of all parts to disable or enable collisions and simulation.
548 //!
549 //! \param control The control type (Static or Dynamic)
550 virtual void sendVehiclePartsUpdate(Vx::VxPart::EntityControlTypeEnum control);
551
552 //! \brief Adds set callbacks for location and heading
553 virtual void addSetCallbacks();
554
555 //! \brief Removes set callbacks for location and heading
556 virtual void removeSetCallbacks();
557
558 //! \brief Callback for heading changes
559 //!
560 //! \param heading The new heading
561 //! \param usrData User data
562 static void setHeadingCallback(DtReal heading, void* usrData);
563
564 //! \brief Callback for location changes
565 //!
566 //! \param location The new location
567 //! \param usrData User data
568 static void setLocationCallback(const DtVector& location, void* usrData);
569
570 //! \brief Handles a location change request
571 //!
572 //! \param location The new location
573 virtual void handleSetLocation(const DtVector& location);
574
575 //! \brief Handles a heading change request
576 //!
577 //! \param heading The new heading
578 virtual void handleSetHeading(DtReal heading);
579
580 //! \brief Resets wheel parts to their default positions
581 //!
582 //! Resets all wheel parts to zero position on the network.
583 virtual void resetWheelParts();
584
585 //! \brief Manages wheel part state transitions when entering or exiting Vortex world
586 //!
587 //! Handles the logic for resetting or restoring wheel parts based on whether the vehicle
588 //! is in the Vortex physics simulation. When exiting Vortex, resets wheel parts to prevent
589 //! network updates that interfere with VRV automatic wheel control. When entering Vortex,
590 //! restores the original wheel part collection.
591 //!
592 //! \param inVortexWorld True if the vehicle is currently in the Vortex physics world
593 virtual void manageWheelPartStateTransitions(bool inVortexWorld);
594
595 //! \brief Updates state properties
596 virtual void updateState();
597
598 //! \brief Restores wheel articulated parts
599 //!
600 //! Restores wheels in the articulated part collection.
601 virtual void restoreWheels();
602
603 //! \brief Automatically engages parking brake when disengaging from driver role
604 //!
605 //! Automatically engages the parking brake when a player disengages from the driver
606 //! role if the brake is not already engaged. Simulates a two-tick button press
607 //! (down then up) to activate the brake.
608 //!
609 //! \param isDriver True if currently controlled as driver, false otherwise
610 virtual void engageParkingBrakeOnDisengage(bool isDriver);
611
612 //! \brief Updates fuel level
613 virtual void updateFuel();
614
615 virtual void updateDestroyedState();
616
617 //! \brief Gets the current fuel level
618 //!
619 //! \return The amount of fuel left
620 virtual double fuelLeft() const;
621
622 //! \brief Consumes fuel
623 //!
624 //! \param fuelUsed The amount of fuel to consume
625 virtual void useFuel(double fuelUsed);
626
627 //! \brief Creates a Vortex part from a descriptor
628 //!
629 //! \param desc The part descriptor
630 //! \return Pointer to the created part
632
633 //! \brief Creates all Vortex parts defined in the descriptor
635
636 //! \brief Sets precision thresholds based on the descriptor
638
639 //! \brief Updates the ground interaction point under the vehicle
640 //!
641 //! This is used by the DtGroundVehicleTrailingEffectController to determine
642 //! the soil type under the vehicle.
643 //!
644 //! \param localOrientation Orientation relative to terrain or parent entity
645 //! \param localPosition Position relative to terrain or parent entity
646 //! \param terrain The attached terrain (database or parent entity)
647 //! \param dataAvailable Set to true if terrain data is available
648 virtual void updateGroundInteractionPoint(const DtDcm& localOrientation,
649 const DtVector& localPosition,
650 const DtAttachedTerrain& terrain,
651 bool& dataAvailable) const;
652
653 //! \brief Creates Vortex configurations from the descriptor
654 //!
655 //! Creates a Vortex Configuration from the configuration section of the descriptor.
657
658 //! \brief Creates Vortex interfaces defined in the descriptor
659 //!
660 //! Also creates input/output ports and port groups.
662
663 //! \brief Connects interfaces to ports
664 //!
665 //! Connects all the values defined in VHL interfaces to Vortex.
667
668 //! \brief Queues the mechanism for loading
669 //!
670 //! Queues the mechanism to load in a thread-safe manner.
671 virtual void queueMechanismLoad();
672
673 //! \brief Updates ports with data from Vortex interfaces
674 virtual void updatePorts();
675
677
678 //! \brief Recursively finds a part from a path
679 //!
680 //! \param objectToLookThroughWeak Object to search for the part
681 //! \param pathToLookForPart Path defined in the system definition file
682 //! \param index Current index in the path
683 //! \return Smart pointer to the part, or null if not found
684 VxSim::VxSmartInterface<VxDynamics::Part> findPartFromPathRecursive(
685 const VxSim::VxWeakInterface<VxSim::IObject>& objectToLookThroughWeak,
686 const std::vector<std::string>& pathToLookForPart,
687 int index);
688
689 //! \brief Checks if the incoming position is further than distance
690 //! \param position incoming position. Pass position in geocentric (DIS)
691 //! \param distance distance
692 //! \return True if enuPosition is further than distance
693 virtual bool checkDistanceFromCoordinateOriginOverLimit(const DtVector& position, double distance);
694
695protected:
696 // Descriptors and state repos
698 DtGroundVehicleStateRepository* myGroundVehicleState;
700 DtPlatformLocalObjectFacade myPlatformLocalObjectFacade;
701 DtArticulatedPartCollection myCollectionWithWheels;
702
703 // Vortex
704 VxSim::VxSmartInterface<VxDynamics::Mechanism> myMechanism;
705 VxSim::VxSmartInterface<DtMechAddon> myMechAddon;
706 VxSim::VxExtension* myVehicleExt;
707 std::vector<DtVortexBasePart*> myParts;
709 std::shared_ptr<VxSim::VxSimulationFileManagerFacade> mySimulationFileManagerFacade;
710 Vx::VxSmartPtr<DtVxSimulationFileManagerFacadeListener> myListener;
711
712 // Configuration
713 std::shared_ptr<makVre::DtVortexConfiguration> myConfiguration;
714
715 // Ports and Port Groups
716 DtUpdateRepositoryOutputPortGroup* myUpdateRepositoryOutputPortGroup;
717 DtStringOutputPort* myAimingModePort;
718
721 VxData::DelegateConnection myTowingTargetObserverConnection;
722 boost::signals2::scoped_connection myTowingTargetDeletedConnection;
724
729
735
736 // For mechanism loading
745
747
760
761 //! \brief Controls whether Vortex physics simulation continues for destroyed entities
762 //!
763 //! When true, allows Vortex physics to remain active even when the entity is
764 //! destroyed or mobility-killed. When false (default), Vortex control is disabled
765 //! for destroyed or mobility-killed entities.
766 //!
767 //! This flag is initialized from the descriptor's allowVortexWhileDestroyed setting
768 //! during the actuator initialization phase.
769 //!
770 //! \note Default value is false.
771 //! \see DtVortexMovementActuatorDescriptor::allowVortexWhileDestroyed()
773
774 //! \brief Controls whether terrain fallthrough detection is enabled
775 //!
776 //! When true, the actuator monitors for terrain availability issues during Vortex
777 //! simulation and logs diagnostic information when fallthrough conditions are detected.
778 //! When false (default), fallthrough detection is disabled.
779 //!
780 //! This flag is initialized from the descriptor's detectTerrainFallthrough setting
781 //! during the actuator initialization phase.
782 //!
783 //! \note Default value is false.
784 //! \see DtVortexMovementActuatorDescriptor::detectTerrainFallthrough()
786
789
791};
792
793//! \brief Listener for Vortex file loading events
794//!
795//! Handles callbacks for file loading operations and notifies the
796//! movement actuator when loading is complete.
797class DtVxSimulationFileManagerFacadeListener : public VxSim::VxSimulationFileManagerFacade::Listener
798{
799public:
800 //! \brief Constructor
801 //!
802 //! \param actuator Pointer to the movement actuator
804
805 //! \brief Destructor
807
808 //! \brief Called when a requested object has been loaded
809 //!
810 //! \param requestId Unique ID of the request
811 //! \param name Name of the loaded object
812 //! \param result Result of the loading operation
814 const VxSim::VxUuid& requestId, const std::string& name, RequestResult result) override;
815
816 //! \brief Called when a requested object has been unloaded
817 //!
818 //! \param requestId Unique ID of the request
819 //! \param name Name of the unloaded object
820 //! \param result Result of the unloading operation
822 const VxSim::VxUuid& requestId, const std::string& name, RequestResult result) override;
823
824protected:
825 DtVortexMovementActuator* myMovementActuator; //!< The movement actuator
826};
827
828//! \brief Addon extension for Vortex mechanisms
829//!
830//! Provides additional functionality for Vortex mechanisms,
831//! including pre-step callbacks for synchronizing with VR-Forces.
832class DtMechAddon : public VxSim::IExtension, public VxSim::IDynamics, public VxDynamics::IMechanismAddOn
833{
834public:
835 //! \brief Factory key for creating instances of this addon
836 static const VxSim::VxFactoryKey kFactoryKey;
837
838public:
839 //! \brief Constructor
840 //!
841 //! \param proxy Pointer to the extension proxy
842 explicit DtMechAddon(VxSim::VxExtension* proxy);
843
844 //! \brief Destructor
845 virtual ~DtMechAddon() override;
846
847 //! \brief Called before each physics step
848 //!
849 //! Updates the Vortex mechanism from VR-Forces data.
850 virtual void preStep() override;
851
852 //! \brief Sets the movement actuator to communicate with
853 //!
854 //! \param obj Pointer to the movement actuator
856
857 //! \brief Sets whether updates come from CGF
858 //!
859 //! \param cgfDriven True if driven by CGF, false if player-controlled
860 void setUpdatingFromCGF(bool cgfDriven);
861
862protected:
863 DtVortexMovementActuator* myMovementActuator; //!< The movement actuator
864 bool myUpdatingFromCGF; //!< Flag indicating if updates come from CGF
865};
Addon extension for Vortex mechanisms.
Definition vortexMovementActuator.h:833
void setUpdatingFromCGF(bool cgfDriven)
Sets whether updates come from CGF.
DtMechAddon(VxSim::VxExtension *proxy)
Constructor.
static const VxSim::VxFactoryKey kFactoryKey
Factory key for creating instances of this addon.
Definition vortexMovementActuator.h:836
void setVortexMovementActuator(DtVortexMovementActuator *obj)
Sets the movement actuator to communicate with.
virtual ~DtMechAddon() override
Destructor.
DtVortexMovementActuator * myMovementActuator
The movement actuator.
Definition vortexMovementActuator.h:863
bool myUpdatingFromCGF
Flag indicating if updates come from CGF.
Definition vortexMovementActuator.h:864
virtual void preStep() override
Called before each physics step.
Base class for Vortex parts in the physics simulation.
Definition vortexPart.h:87
Dynamics-based Vortex part implementation.
Definition vortexPart.h:314
Class for managing Vortex interfaces.
Definition vortexInterface.h:232
Descriptor for Vortex physics-based movement simulation.
Definition vortexMovementActuatorDescriptor.h:35
Actuator component that integrates Vortex physics for vehicle dynamics.
Definition vortexMovementActuator.h:98
virtual void setThresholdsFromDescriptor()
Sets precision thresholds based on the descriptor.
void processStartupDynamicsWarmupStep()
Applies the deferred startup dynamics disable after one physics step.
bool myAutoParkButtonDown
Definition vortexMovementActuator.h:726
virtual void processSetVortexWhileUntasked(DtSimMessage *msg)
Processes a set data request to enable/disable high-fidelity physics.
bool myWasInVortexWorldLastTick
Definition vortexMovementActuator.h:719
virtual void checkTaskStatus(bool vortexActive)
Cancels CGF tasks that conflict with Vortex control.
virtual double fuelLeft() const
Gets the current fuel level.
double myPartAngularVelocityThreshold
Definition vortexMovementActuator.h:756
void disableVehicleDynamics()
Disables the vehicle dynamics.
bool myWasBeingTowedLastTick
Definition vortexMovementActuator.h:720
VxMath::Matrix44 getNextFrameVortexTransform() const
Gets the next frame's location and orientation as a VxMatrix.
virtual void connectInterfacesToPorts()
Connects interfaces to ports.
static void setHeadingCallback(DtReal heading, void *usrData)
Callback for heading changes.
DtPlatformLocalObjectFacade myPlatformLocalObjectFacade
Definition vortexMovementActuator.h:700
virtual void addSetCallbacks()
Adds set callbacks for location and heading.
virtual bool createPortGroups() override
Creates the port groups for the actuator.
VxSim::VxSmartInterface< DtMechAddon > myMechAddon
Definition vortexMovementActuator.h:705
Vx::VxEulerAngles getNextFrameVortexOrientation() const
Gets the next frame Vortex orientation from the entity.
virtual void initTrackWheelPositionFromArticulatedPart(DtVortexDynamicsPart *dynamicsPart, const makVrf::DtArticulatedPartStateRepository *partRepository, const char *trackName)
Initializes a track-wheel position from an articulated part.
makVre::DtVortexPhysicalWorld * myVortexPhysicalWorld
Definition vortexMovementActuator.h:746
static void setLocationCallback(const DtVector &location, void *usrData)
Callback for location changes.
virtual void createVortexPartsFromDescriptor()
Creates all Vortex parts defined in the descriptor.
DtStringOutputPort * myAimingModePort
Definition vortexMovementActuator.h:717
virtual void initTrackIdlerDistanceFromArticulatedPart(DtVortexDynamicsPart *dynamicsPart, const makVrf::DtArticulatedPartStateRepository *partRepository, const char *trackName)
Initializes a track idler's distance from its sprocket.
std::shared_ptr< makVre::DtVortexConfiguration > myConfiguration
Definition vortexMovementActuator.h:713
virtual void createVortexConfigurationsFromDescriptor()
Creates Vortex configurations from the descriptor.
static DtSimComponent * creator(const DtString &name, DtLocalObject *owner, DtSimulationServices *simManager, DtComponentDescriptor *desc=0, DtReaderWriterRegistry *parentRegistry=0)
Factory method for creating instances of this actuator.
bool myPendingVortexPhysicsState
Definition vortexMovementActuator.h:732
MechanismLoadStatus myMechanismLoadStatus
Definition vortexMovementActuator.h:743
virtual void manageWheelPartStateTransitions(bool inVortexWorld)
Manages wheel part state transitions when entering or exiting Vortex world.
virtual DtUUID towingTargetUuid() const
Gets the entity currently attached to this vehicle's tow hook.
virtual void sendVehicleDynamicsUpdate(bool enable)
Sends a vehicle dynamics update event.
DtTaitBryan myPreviousOrientation
Definition vortexMovementActuator.h:788
double myPartPositionThreshold
Definition vortexMovementActuator.h:753
DtVortexStateRepository * myVehicleRepository
Definition vortexMovementActuator.h:699
virtual void handleSetHeading(DtReal heading)
Handles a heading change request.
void resetTowingHookGroup()
Resets the Vortex tow-hook group extension.
virtual const std::vector< DtVortexBasePart * > & getParts() const
Gets the list of all Vortex parts in this actuator.
DtVortexMovementActuator & operator=(const DtVortexMovementActuator &orig)=delete
Assignment operator and copy constructor not implemented.
bool myHaveVortexTurretInterface
Definition vortexMovementActuator.h:728
virtual void updateState()
Updates state properties.
void tagDynamicsPartGeometries()
Tags the geometries of all dynamics parts for collision detection.
virtual bool init() override
Initializes the actuator.
virtual const char * trackNameForPart(const DtVortexDynamicsPart &dynamicsPart) const
Gets the Vortex track parameter name for a dynamics part.
VxSim::VxUuid myLoadObjectRequestId
Definition vortexMovementActuator.h:744
double myVortexPhysicsDisableDelaySeconds
Definition vortexMovementActuator.h:758
VxSim::VxSmartInterface< VxDynamics::Mechanism > myMechanism
Definition vortexMovementActuator.h:704
VxSim::VxSmartInterface< VxDynamics::Mechanism > getMechanism()
Gets the current mechanism associated with the actuator.
virtual void sendExtensionUpdate(VxSim::VxExtension *extension, bool enable)
Sends a Vortex extension update event.
virtual bool isVortexMechanismValid() const
Checks if the Vortex mechanism is valid.
virtual bool initWheelPositionFromArticulatedPart(DtVortexDynamicsPart *dynamicsPart, const makVrf::DtArticulatedPartStateRepository *partRepository)
Initializes a conventional wheel position from an articulated part.
virtual void handleSetLocation(const DtVector &location)
Handles a location change request.
virtual bool createPorts() override
Creates the ports required for actuator operation.
DtUpdateRepositoryOutputPortGroup * myUpdateRepositoryOutputPortGroup
Definition vortexMovementActuator.h:716
virtual void useFuel(double fuelUsed)
Consumes fuel.
virtual bool taskConflictsWithVortex(const DtSimTaskMessageType &taskType) const
Determines whether a task type conflicts with Vortex control.
virtual void updateGroundInteractionPoint(const DtDcm &localOrientation, const DtVector &localPosition, const DtAttachedTerrain &terrain, bool &dataAvailable) const
Updates the ground interaction point under the vehicle.
DtGroundVehicleStateRepository * myGroundVehicleState
Definition vortexMovementActuator.h:698
VortexInterfaceMap myInterfaces
Definition vortexMovementActuator.h:708
bool myHasVortexPhysicsRequest
Definition vortexMovementActuator.h:733
void sendTowingHookGroupUpdate(bool enable)
Enables or disables the Vortex tow-hook group extension.
double myAngularVelocityThreshold
Definition vortexMovementActuator.h:751
bool myDetectTerrainFallthrough
Controls whether terrain fallthrough detection is enabled.
Definition vortexMovementActuator.h:785
friend class DtVxSimulationFileManagerFacadeListener
Definition vortexMovementActuator.h:284
virtual void realizeVortexState()
Updates the Vortex state based on current conditions.
virtual bool isTerrainAvailable() const
Checks if terrain is available below the vehicle.
virtual DtUUID towingTargetUuid(const VxData::FieldBase &field) const
Converts a Vortex field value to a tow target UUID.
virtual VxData::FieldBase * vehicleParameter(const std::string &parameterName) const
Gets a named Vortex vehicle parameter.
void processTerrainChangeNotification(const DtTerrainChangeNotificationInfo &terrainChangeInfo)
Processes terrain change notifications.
DtVortexMovementActuator(const DtString &name, DtLocalObject *owner, DtSimulationServices *simManager, DtComponentDescriptor *desc=0, DtReaderWriterRegistry *parentRegistry=0)
Constructor.
static void setVortexWhileUntaskedCallback(DtSimMessage *msg, void *usrData)
Callback for scripted set data request message.
void processTowingTargetChanged(const VxData::FieldBase &field)
Processes tow-hook target field changes.
virtual void getLowestBoundingPointsOfMechanism(std::vector< DtVector > &outputPoints)
Gets the lowest bounding points of the current mechanism.
double myPartLinearVelocityThreshold
Definition vortexMovementActuator.h:755
std::shared_ptr< VxSim::VxSimulationFileManagerFacade > mySimulationFileManagerFacade
Definition vortexMovementActuator.h:709
virtual bool isBeingTowed() const
Checks if the entity is being towed by another Vortex entity.
bool mySpawnedFromSpawnPoint
Definition vortexMovementActuator.h:734
makVre::DtVortexMovementPSR * myProcessState
Definition vortexMovementActuator.h:790
virtual void initParametersFromModel()
Initializes Vortex model parameters with data from VR-Forces.
virtual bool isHighFidelityCGF() const
Checks whether Vortex While Untasked is enabled.
virtual void restoreWheels()
Restores wheel articulated parts.
virtual bool initFieldFromArticulatedPartPosition(VxData::FieldBase *field, const makVrf::DtArticulatedPartStateRepository *partRepository, const DtVortexDynamicsPart *dynamicsPart) const
Initializes a Vortex position field from an articulated-part position.
virtual void tick() override
Updates the actuator each simulation frame.
virtual void updateFuel()
Updates fuel level.
Vx::VxVector3 getNextFrameVortexPosition() const
Gets the next frame Vortex location from the entity.
virtual void updateDestroyedState()
VxSim::VxExtension * findTowingHookGroupExtension()
Finds this mechanism's tow-hook group extension.
virtual bool isPlayerControlledAs(std::string role) const
Checks if the entity is player controlled in a specific role.
virtual bool isVortexPlayerControlled() const
Checks if the entity is player controlled.
DtVortexMovementActuator(const DtVortexMovementActuator &orig)=delete
virtual void initArticulatedPartPositions()
Initializes Vortex vehicle-part positions from VR-Forces articulated parts.
virtual void initTrackPartPositions(bool didInitLeftSprocket, bool didInitRightSprocket)
Initializes tracked-vehicle wheel and idler positions.
double myPositionThreshold
Definition vortexMovementActuator.h:748
virtual bool checkDistanceFromCoordinateOriginOverLimit(const DtVector &position, double distance)
Checks if the incoming position is further than distance.
virtual void sendVehiclePartsUpdate(Vx::VxPart::EntityControlTypeEnum control)
Updates the control state of all vehicle parts.
DtVector myPreviousPosition
Definition vortexMovementActuator.h:787
virtual void dropAboveTerrain(const DtVector &newLocalPosition, double heading)
Drops the vehicle above the terrain at a specified position.
std::map< std::string, DtVortexInterface * > VortexInterfaceMap
Type definition for a map of Vortex interfaces by name.
Definition vortexMovementActuator.h:101
VxData::DelegateConnection myTowingTargetObserverConnection
Definition vortexMovementActuator.h:721
virtual void engageParkingBrakeOnDisengage(bool isDriver)
Automatically engages parking brake when disengaging from driver role.
MechanismLoadStatus
Definition vortexMovementActuator.h:738
@ LOADED
Definition vortexMovementActuator.h:741
@ LOADING
Definition vortexMovementActuator.h:740
@ NOT_LOADED
Definition vortexMovementActuator.h:739
virtual bool initSprocketPositionFromArticulatedPart(DtVortexDynamicsPart *dynamicsPart, const makVrf::DtArticulatedPartStateRepository *partRepository)
Initializes a sprocket position from an articulated part.
double myVortexPhysicsDisableDelayElapsedSeconds
Definition vortexMovementActuator.h:759
const DtVortexMovementActuatorDescriptor * myDescriptor
Definition vortexMovementActuator.h:697
virtual void resetWheelParts()
Resets wheel parts to their default positions.
void enableVehicleDynamics()
Enables the vehicle dynamics.
double myVelocityThreshold
Definition vortexMovementActuator.h:750
double myPartOrientationThreshold
Definition vortexMovementActuator.h:754
DtVortexBasePart * createPart(makVre::DtVortexSimArtPartDescriptor *desc)
Creates a Vortex part from a descriptor.
virtual void preFirstTickInit() override
Initializes the actuator before the first simulation tick.
virtual bool createPSR()
Creates a process state repository for this component.
virtual void clearTowingTargetTracking()
Clears current tow target tracking.
bool myPendingDynamicsDisableAfterStartupStep
Definition vortexMovementActuator.h:731
DtUUID myTowingTargetUuid
Definition vortexMovementActuator.h:723
virtual void updateMassOfChassis()
Updates the chassis mass from entity parameters.
static void terrainChangeNotification(const DtTerrainChangeNotificationInfo &terrainChangeInfo, void *usr)
Static callback for terrain change notifications.
virtual const char * type() const override
Gets the type of this actuator.
virtual void queueMechanismLoad()
Queues the mechanism for loading.
virtual void detectTerrainFallthrough()
Detects and logs terrain fall-through conditions.
void connectTowingTargetObserver()
Connects to tow-hook target updates from the driver interface.
virtual void updatePorts()
Updates ports with data from Vortex interfaces.
bool myAllowVortexWhileDestroyed
Controls whether Vortex physics simulation continues for destroyed entities.
Definition vortexMovementActuator.h:772
double myDropTimer
Definition vortexMovementActuator.h:757
bool myIsVortexDynamicsActive
Definition vortexMovementActuator.h:730
virtual bool initTrackWheelRelativeToSprocket(VxData::FieldBase *trackWheel, VxData::FieldBase *sprocket, const makVrf::DtArticulatedPartStateRepository *partRepository, const DtVortexDynamicsPart *dynamicsPart) const
Initializes a track-wheel position relative to its sprocket.
virtual void connectTowingTargetDeletedSignal(const DtUUID &targetUuid)
Connects to the current tow target deletion signal.
double myOrientationThreshold
Definition vortexMovementActuator.h:749
Vx::VxVector3 getVortexLocation(const DtVector &inputCoords) const
Converts local coordinates to Vortex coordinates.
void updateTowingHookGroupState(const DtUUID &currentTowingTargetUuid)
Updates tow-hook group reset state based on the current hook target.
Vx::VxSmartPtr< DtVxSimulationFileManagerFacadeListener > myListener
Definition vortexMovementActuator.h:710
virtual bool isInVortexWorld() const
Checks if high-fidelity Vortex physics should be active.
DtArticulatedPartCollection myCollectionWithWheels
Definition vortexMovementActuator.h:701
bool myNeedsWheelPartRemoval
Definition vortexMovementActuator.h:727
virtual void setVortexMechanismLocation(const Vx::VxVector3 &nwuLocation, double heading)
Sets the Vortex mechanism's location and orientation.
bool myWasDriverLastTick
Definition vortexMovementActuator.h:725
void loadMechanism()
Loads the Vortex mechanism.
virtual ~DtVortexMovementActuator() override
Destructor.
virtual void createVortexInterfacesFromDescriptor()
Creates Vortex interfaces defined in the descriptor.
virtual void removeSetCallbacks()
Removes set callbacks for location and heading.
VxSim::VxSmartInterface< VxDynamics::Part > findPartFromPathRecursive(const VxSim::VxWeakInterface< VxSim::IObject > &objectToLookThroughWeak, const std::vector< std::string > &pathToLookForPart, int index)
Recursively finds a part from a path.
std::vector< DtVortexBasePart * > myParts
Definition vortexMovementActuator.h:707
virtual void populateArtPartMapProperty()
virtual void processTowingTargetDeleted()
Processes removal of the currently tracked tow target.
double myAccelerationThreshold
Definition vortexMovementActuator.h:752
boost::signals2::scoped_connection myTowingTargetDeletedConnection
Definition vortexMovementActuator.h:722
VxSim::VxExtension * myVehicleExt
Definition vortexMovementActuator.h:706
DtVortexBasePart * findPart(int partId) const
Gets the Vortex part associated with an articulated part ID.
State repository for Vortex physics entities.
Definition vortexStateRepository.h:54
Listener for Vortex file loading events.
Definition vortexMovementActuator.h:798
virtual ~DtVxSimulationFileManagerFacadeListener() override
Destructor.
virtual void onRequestedObjectUnloaded(const VxSim::VxUuid &requestId, const std::string &name, RequestResult result) override
Called when a requested object has been unloaded.
DtVxSimulationFileManagerFacadeListener(DtVortexMovementActuator *actuator)
Constructor.
DtVortexMovementActuator * myMovementActuator
The movement actuator.
Definition vortexMovementActuator.h:825
virtual void onRequestedObjectLoaded(const VxSim::VxUuid &requestId, const std::string &name, RequestResult result) override
Called when a requested object has been loaded.
Descriptor for Vortex physics engine configurations.
Definition vortexConfigurationDescriptor.h:27
Main class for managing Vortex configuration parameters.
Definition vortexConfiguration.h:146
Descriptor for Vortex physics engine interfaces.
Definition vortexInterfaceDescriptor.h:27
Process state repository for the Vortex movement actuator.
Definition vortexMovementPSR.h:31
Main class responsible for managing the Vortex physics simulation environment.
Definition vortexPhysicalWorld.h:65
Articulated part descriptor for Vortex physics simulation.
Definition vortexArtPartDescriptor.h:27
Provides coordinate conversion functionality between different coordinate systems.
Export macros for the VR-Forces Vortex extension library.
#define VREVRFVORTEX_DLL
Export macro for non-Windows platforms.
Definition export.h:30
Definition vortexConfiguration.h:24
Definition vortexConfiguration.h:29
!
Definition glsVreMessageUtil.h:50
Definition connectorAccessory.h:38
const char DtVortexMovementActuatorType[]
Type identifier for the Vortex movement actuator.
Definition vortexMovementActuator.h:88