VR-Engage  2.3
Loading...
Searching...
No Matches
updateVisualsConnector.h
Go to the documentation of this file.
1/******************************************************************************
2** Copyright (c) 2025 MAK Technologies
3** All rights reserved.
4******************************************************************************/
5
6//! \file updateVisualsConnector.h
7//! \brief Defines the DtUpdateVisualsConnector class for handling visual model updates
8//!
9//! Class DtUpdateVisualsConnector is an event connector that handles
10//! VisualsLoaded events. These are events indicating that the visual
11//! definition/mapping data associated with a simulation model set (SMS) has
12//! been loaded. In response to such events, it recreates the DtVrlinkElement
13//! objects (entities, aggregates, and tactical graphics), based on the updated
14//! visual model definition data. This happens any time the visual
15//! definition/mapping data associated with an SMS changes (i.e., when a different
16//! SMS with visual definition/mapping data gets loaded).
17
18#pragma once
19
20#include "export.h"
21
23
25
26namespace makVre
27{
28//! \brief Connector for handling visual model definition updates
29//!
30//! DtUpdateVisualsConnector responds to visual model definition changes by
31//! recreating and updating DtVrlinkElement objects to reflect the new visual
32//! definitions. It handles entities, aggregates, and tactical graphics,
33//! ensuring they use the latest visual model definitions from the current
34//! simulation model set (SMS).
36{
37public:
38 //! \brief Default constructor
39 //!
40 //! Initializes the connector with name "UpdateVisuals"
42
43 //! \brief Virtual destructor
44 virtual ~DtUpdateVisualsConnector() override;
45
46 //! \brief Installs the visual update connector with a VR-Link connection.
47 //!
48 //! \param connection Non-owning pointer to the protocol-specific VR-Link connection.
49 //!
50 //! Registers message handlers for VisualModelDefinitionsLoadedMessage messages
51 virtual void install( makVrv::DT_PROTOCOL_NAMESPACE::DtVrlinkConnection* connection) override;
52
53 //! \brief Performs periodic processing of entity reparenting
54 //!
55 //! Handles re-parenting of embarked entities that were discovered during SMS reload
56 //! by attempting to re-establish parent-child relationships over several ticks
57 //!
58 //! \param dt The elapsed time in seconds since the last tick
59 virtual void tick(double dt) override;
60
61 //! \brief Shuts down the visual update connector
62 //!
63 //! Removes message handlers for visual model definition updates
64 virtual void shutdown() override;
65
66protected:
67 //! \brief Map of entities that need to be reparented
68 //!
69 //! Map of entity global designators to their parent entity global designators
70 //! Used to track entities that need to be reparented after SMS reload
71 std::map<DtGlobalObjectDesignator, DtGlobalObjectDesignator> myEntitiesToReparent;
72
73 //! \brief Counter for reparenting attempts
74 //!
75 //! Number of ticks remaining to attempt reparenting of entities
76 //! When this reaches zero, any remaining entities will have warning messages logged
78
79 //! \brief Handles visual model definition loaded messages
80 //! \param msg Pointer to the visual model definitions loaded message
81 //! \return Message result indicating how the message was handled
82 //!
83 //! Updates all visual DtVrlinkElements (entities, aggregates, tactical graphics)
84 //! with the latest visual model definitions/mappings. For each element, it disables
85 //! and re-enables the model sets, updates the element definition, and then
86 //! re-visualizes the element using the new definitions.
88
89 //! \brief Handles SMS load complete messages
90 //! \param msg Pointer to the SMS load complete message
91 //! \return Message result indicating how the message was handled
92 //!
93 //! Sets up the reparenting process after SMS reload by initializing the
94 //! myTicksToReparent counter and removing the handler since it's only needed once per reload
96};
97} // namespace makVre
Base class for all simulation event connectors in VREngage.
Definition simEventConnector.h:53
virtual void install(makVrv::DT_PROTOCOL_NAMESPACE::DtVrlinkConnection *connection) override
Installs the visual update connector with a VR-Link connection.
virtual void shutdown() override
Shuts down the visual update connector.
std::map< DtGlobalObjectDesignator, DtGlobalObjectDesignator > myEntitiesToReparent
Map of entities that need to be reparented.
Definition updateVisualsConnector.h:71
virtual ~DtUpdateVisualsConnector() override
Virtual destructor.
DtUpdateVisualsConnector()
Default constructor.
int myTicksToReparent
Counter for reparenting attempts.
Definition updateVisualsConnector.h:77
virtual makVre::DtVreMessageResult handleVisualModelDefinitionsLoaded(makVre::DtVreMessage *msg)
Handles visual model definition loaded messages.
virtual makVre::DtVreMessageResult handleSmsLoadComplete(makVre::DtVreMessage *msg)
Handles SMS load complete messages.
virtual void tick(double dt) override
Performs periodic processing of entity reparenting.
Abstract base class for all VREngage messages.
Definition vreMessage.h:50
Defines export macros and protocol namespace for vrePlayerStationConnector.
#define VRL_DLL
Empty definition for non-Windows platforms.
Definition export.h:52
!
Definition glsVreMessageUtil.h:50
DtVreMessageResult
Enumeration of possible message handling results.
Definition vreMessage.h:33
Defines the base DtSimEventConnector class for VREngage simulation events.
Defines the base class for all VREngage messages.