VR-Engage  2.2
Loading...
Searching...
No Matches
vreSpawnController.h
Go to the documentation of this file.
1/*******************************************************************************
2** Copyright (c) 2025 MAK Technologies
3** All rights reserved.
4*******************************************************************************/
5
6//! \file vreSpawnController.h
7//! \ingroup vreVrfmodel
8//! \brief Controller for optimized entity spawning
9//!
10//! This file defines the DtVreSpawnController class which extends the base
11//! spawn controller to provide performance optimizations for vehicle creation.
12//! It modifies the entity creation process to avoid automatically adding spawned
13//! vehicles to the Vortex physics world until needed, significantly improving
14//! performance when creating vehicles at spawn points.
15//!
16//! The controller passes context information indicating that a vehicle is being
17//! created at a spawn point, ensuring it doesn't incur the performance penalty
18//! of Vortex world integration (which can take seconds) unless the vehicle is
19//! actually player controlled. When a player does take control of a spawn-point
20//! generated vehicle, the Vortex world integration occurs at that time.
21
22#pragma once
23
24#include "vreVrfmodel/export.h"
25
26#include <vrfmodel/spawnController.h>
27
28namespace makVre
29{
30//! \brief Controller for optimized entity spawning
31//!
32//! DtVreSpawnController extends the base spawn controller to provide
33//! performance optimizations for vehicle creation. It modifies the entity
34//! creation process to avoid automatically adding spawned vehicles to the
35//! Vortex physics world until needed, which significantly improves performance
36//! when creating vehicles at spawn points.
37class VREVRFMODEL_DLL DtVreSpawnController : public DtSpawnController
38{
39public:
40 //! \brief Constructor
41 //! \param name The name of this component
42 //! \param owner The local object that owns this component
43 //! \param simManager The simulation services manager
44 //! \param desc Component descriptor with configuration parameters
45 //! \param parentRegistry Optional parent registry for reader/writer functionality
46 //!
47 //! Creates a new spawn controller component with the specified parameters.
48 DtVreSpawnController(const DtString& name, DtLocalObject* owner, DtSimulationServices* simManager,
49 DtComponentDescriptor* desc, DtReaderWriterRegistry* parentRegistry);
50
51 //! \brief Factory method to create a new instance of this component
52 //! \param name The name for the new component
53 //! \param owner The local object that will own this component
54 //! \param simManager The simulation services manager
55 //! \param desc Optional component descriptor
56 //! \param parentRegistry Optional parent registry for reader/writer functionality
57 //! \return Pointer to the newly created component
58 //!
59 //! Static factory method used by the component creation system to instantiate
60 //! new instances of this component type.
61 static DtSimComponent* creator(const DtString& name, DtLocalObject* owner, DtSimulationServices* simManager,
62 DtComponentDescriptor* desc, DtReaderWriterRegistry* parentRegistry);
63
64protected:
65 //! \brief Creates an object with spawn point context information
66 //! \param spawnObjectUUID UUID of the object to spawn
67 //! \param sinkPoint The sink point where the object will be spawned
68 //! \param spawnData Spawn configuration data
69 //! \param dataAvailable Output parameter indicating if required data was available
70 //! \param entityPlan The plan to assign to the spawned entity
71 //! \return Handle to the created object
72 //!
73 //! Overridden to pass context information that the vehicle is being created
74 //! at a spawn point. Sets an entry with the keyword "DtSpawnedBy" in the
75 //! extended data map, where the value is the UUID of the spawning entity.
76 //! The presence of this keyword indicates that the entity was created via
77 //! a spawn point, which prevents automatic Vortex world integration until needed.
78 virtual DtCreateObjectHandle createObject(const DtUUID& spawnObjectUUID, const DtSimObject* sinkPoint,
79 const DtRwSpawnData* spawnData, bool& dataAvailable, const DtPlan& entityPlan) override;
80
81private:
82 //! \brief Default constructor (not implemented)
83 //!
84 //! Default constructor is private and not implemented to prevent
85 //! creation of instances without proper initialization.
87
88 //! \brief Copy constructor (not implemented)
89 //!
90 //! Copy constructor is private and not implemented to prevent
91 //! copy construction.
93
94 //! \brief Assignment operator (not implemented)
95 //! \return Reference to this object
96 //!
97 //! Assignment operator is private and not implemented to prevent assignment.
99};
100
101} // namespace makVre
static DtSimComponent * creator(const DtString &name, DtLocalObject *owner, DtSimulationServices *simManager, DtComponentDescriptor *desc, DtReaderWriterRegistry *parentRegistry)
Factory method to create a new instance of this component.
DtVreSpawnController(const DtString &name, DtLocalObject *owner, DtSimulationServices *simManager, DtComponentDescriptor *desc, DtReaderWriterRegistry *parentRegistry)
Constructor.
virtual DtCreateObjectHandle createObject(const DtUUID &spawnObjectUUID, const DtSimObject *sinkPoint, const DtRwSpawnData *spawnData, bool &dataAvailable, const DtPlan &entityPlan) override
Creates an object with spawn point context information.
DtVreSpawnController()
Default constructor (not implemented)
DtVreSpawnController(const DtVreSpawnController &other)
Copy constructor (not implemented)
DtVreSpawnController & operator=(const DtVreSpawnController &other)
Assignment operator (not implemented)
Defines export macros for the vreVrfmodel library.
#define VREVRFMODEL_DLL
Definition export.h:22
Include export definitions for this library.
Definition glsVreMessageUtil.h:49