VR-Engage  2.2
Loading...
Searching...
No Matches
aglUpdater.h
Go to the documentation of this file.
1/*******************************************************************************
2** Copyright (c) 2025 MAK Technologies
3** All rights reserved.
4*******************************************************************************/
5
6//! \file aglUpdater.h
7//! \ingroup vreVrfmodel
8//! \brief Component for updating the above-ground-level altitude for entities
9//!
10//! This file defines the DtAglUpdater class, which calculates and maintains the
11//! above-ground-level (AGL) altitude for entities. It provides accurate terrain
12//! intersection calculations for HUD displays and other systems that need AGL data.
13
14#pragma once
15
16#include "vreVrfmodel/export.h"
18#include <vrfobjcore/simComponent.h>
20
21namespace makVre
22{
23//! \brief Type identifier for the AGL updater component
24constexpr char DtAglUpdaterType[] = "agl-updater";
25
26//! \brief Component that updates the above-ground-level altitude for entities
27//!
28//! The DtAglUpdater exists to set the altitude-agl extended data, which is used by
29//! the aircraft HUD and other systems. It performs terrain intersections in the simulation
30//! which are more precise than those performed in the GUI, as GUI intersections
31//! depend on the level of detail (LOD) of the terrain that is currently loaded.
32class VREVRFMODEL_DLL DtAglUpdater : public DtVreSimComponent<DtSimComponent>
33{
34public:
35 //! \brief Constructor
36 //! \param name The name of this component
37 //! \param owner The local object that owns this component
38 //! \param simManager The simulation services manager
39 //! \param desc Optional component descriptor
40 //! \param parentRegistry Optional parent registry for reader/writer functionality
41 //!
42 //! Creates a new AGL updater component with the specified parameters.
43 DtAglUpdater(const DtString& name,
44 DtLocalObject* owner,
45 DtSimulationServices* simManager,
46 DtComponentDescriptor* desc = nullptr,
47 DtReaderWriterRegistry* parentRegistry = nullptr);
48
49 //! \brief Default constructor (not implemented)
50 //!
51 //! Default constructor is private and not implemented to prevent
52 //! creation of instances without proper initialization.
53 DtAglUpdater() = delete;
54
55 //! \brief Copy constructor (not implemented)
56 //!
57 //! Copy constructor is private and not implemented to prevent
58 //! copy construction.
59 DtAglUpdater(const DtAglUpdater& orig) = delete;
60
61 //! \brief Assignment operator (not implemented)
62 //! \return Reference to this object
63 //!
64 //! Assignment operator is private and not implemented to prevent
65 //! assignment.
66 const DtAglUpdater& operator=(const DtAglUpdater& orig) = delete;
67
68 //! \brief Virtual destructor
69 //!
70 //! Cleans up resources used by the AGL updater component.
71 virtual ~DtAglUpdater() override;
72
73 //! \brief Update method called each simulation frame
74 //!
75 //! If the entity is player-controlled and myRequireAgl is true,
76 //! this method will update the AGL altitude by calling updateAglAltitude().
77 //! This ensures the AGL data is refreshed only when needed, to optimize performance.
78 virtual void tick() override;
79
80 //! \brief Gets the type identifier for this component
81 //! \return String identifying the component type (DtAglUpdaterType)
82 //!
83 //! Implements the DtSimComponent::type() method to return the
84 //! type identifier for this component.
85 virtual const char* type() const override;
86
87 //! \brief Updates the AGL altitude value for the entity
88 //!
89 //! Calculates and sets the "altitude-agl" extended data value to be
90 //! the difference between the entity's altitude and the terrain height
91 //! at the entity's current location. This provides an accurate above-ground-level
92 //! altitude value that can be used by HUDs and other systems.
93 virtual void updateAglAltitude();
94
95 //! \brief Handles AGL subscription messages
96 //! \param msg The subscription message to process
97 //! \return The message processing result
98 //!
99 //! Processes messages that request subscription to AGL updates.
100 //! When a system subscribes, the myRequireAgl flag is set to true,
101 //! indicating that AGL updates should be performed each frame.
103
104 //! \brief Handles AGL unsubscription messages
105 //! \param msg The unsubscription message to process
106 //! \return The message processing result
107 //!
108 //! Processes messages that request unsubscription from AGL updates.
109 //! When the last system unsubscribes, the myRequireAgl flag may be
110 //! set to false to stop performing AGL updates each frame.
112
113 //! \brief Factory method to create a new instance of this component
114 //! \param name The name for the new component
115 //! \param owner The local object that will own this component
116 //! \param simManager The simulation services manager
117 //! \param desc Optional component descriptor
118 //! \param parentRegistry Optional parent registry for reader/writer functionality
119 //! \return Pointer to the newly created component
120 //!
121 //! Static factory method used by the component creation system to instantiate
122 //! new instances of this component type.
123 static DtSimComponent* creator(const DtString& name,
124 DtLocalObject* owner,
125 DtSimulationServices* simManager,
126 DtComponentDescriptor* desc,
127 DtReaderWriterRegistry* parentRegistry);
128
130
131protected:
132 //! \brief Flag indicating whether AGL updates are required
133 //!
134 //! When true, AGL altitude is updated every tick. This flag is set
135 //! when systems subscribe to AGL updates and cleared when all subscribers
136 //! have unsubscribed.
137 bool myRequireAgl = false;
138};
139} // namespace makVre
const DtAglUpdater & operator=(const DtAglUpdater &orig)=delete
Assignment operator (not implemented)
virtual void updateAglAltitude()
Updates the AGL altitude value for the entity.
DtAglUpdater(const DtString &name, DtLocalObject *owner, DtSimulationServices *simManager, DtComponentDescriptor *desc=nullptr, DtReaderWriterRegistry *parentRegistry=nullptr)
Constructor.
virtual const char * type() const override
Gets the type identifier for this component.
DtAglUpdater()=delete
Default constructor (not implemented)
virtual ~DtAglUpdater() override
Virtual destructor.
DtAglUpdater(const DtAglUpdater &orig)=delete
Copy constructor (not implemented)
bool myRequireAgl
Flag indicating whether AGL updates are required.
Definition aglUpdater.h:137
static DtSimComponent * creator(const DtString &name, DtLocalObject *owner, DtSimulationServices *simManager, DtComponentDescriptor *desc, DtReaderWriterRegistry *parentRegistry)
Factory method to create a new instance of this component.
virtual void tick() override
Update method called each simulation frame.
virtual DtVreMessageResult handleAglSubscription(DtVreMessage *msg)
Handles AGL subscription messages.
virtual DtVreMessageResult handleAglUnsubscription(DtVreMessage *msg)
Handles AGL unsubscription messages.
void initializeMessageHandlers()
Abstract base class for all VREngage messages.
Definition vreMessage.h:50
DtVreSimComponent(const DtString &name, DtLocalObject *owner, DtSimulationServices *simManager, DtComponentDescriptor *desc=0, DtReaderWriterRegistry *parentRegistry=0)
Definition vreSimComponent.h:54
Defines export macros for the vreVrfmodel library.
#define VREVRFMODEL_DLL
Definition export.h:22
Include export definitions for this library.
Definition glsVreMessageUtil.h:49
constexpr char DtAglUpdaterType[]
Type identifier for the AGL updater component.
Definition aglUpdater.h:24
DtVreMessageResult
Enumeration of possible message handling results.
Definition vreMessage.h:33
Defines the base class for all VREngage messages.
Base template class for VR-Engage simulation components.