Rendering Engine 0.2.9
Modular Graphics Rendering Engine | v0.2.9
actor.cpp
Go to the documentation of this file.
1#include "actor.hpp"
2#include "scene.hpp"
3#include "scene_manager.hpp"
4#include "drawable_3d.hpp"
5
6namespace rendering_engine
7{
8
10 :
11 mScene(scene),
12 bUpdateOnTick(true)
13{
14 mRenderContext = mScene.GetSceneManager().GetRenderResourceContext();
15}
16
18{
19}
20
22{
23}
24
25void Actor::SetPosition(const glm::vec3& position)
26{
28}
29
30void Actor::SetRotation(const glm::vec3& rotation)
31{
33
34}
35
36void Actor::SetScale(const glm::vec3& scale)
37{
39}
40
41const glm::vec3& Actor::GetPosition() const
42{
44}
45
46const glm::vec3& Actor::GetRotation() const
47{
49}
50
51const glm::vec3& Actor::GetScale() const
52{
53 return mRootComponent.GetScale();
54}
55
57{
58 return mRootComponent;
59}
60
62{
63 return mRootComponent;
64}
65
66void Actor::Update(float deltaTime)
67{
68 if (!bUpdateOnTick)
69 return;
70
72}
73
75{
76 return mRenderContext;
77}
78
80{
82 return;
83
84 bPendingDestroy = true;
85
86 // Detach wards while they are still valid objects
87 for (auto* ward : mWards)
88 {
89 if (ward)
90 ward->GetTransform().AttachTo(nullptr);
91 }
92
93 // Now schedule ward destruction
94 for (auto* ward : mWards)
95 {
96 if (ward)
97 ward->Destroy();
98 }
99
100 mScene.DestroyActor(this);
101}
102
104{
105 mWards.clear();
106
107 mRootComponent.AttachTo(nullptr);
108}
109
110
111
112} // namespace rendering_engine
RenderResourceContext GetRenderContext() const
Returns the render resource context associated with this actor.
Definition: actor.cpp:74
virtual void Update(float deltaTime)
Updates actor logic and root transform state.
Definition: actor.cpp:66
void SetScale(const glm::vec3 &scale)
Sets the actor's scale along each axis.
Definition: actor.cpp:36
SceneComponent & GetTransform()
Access to the underlying SceneComponent (transform).
Definition: actor.cpp:56
SceneComponent mRootComponent
Definition: actor.hpp:190
void SetRotation(const glm::vec3 &rotation)
Sets the actor's rotation in degrees.
Definition: actor.cpp:30
void Destroy()
Requests deferred destruction of this actor.
Definition: actor.cpp:79
virtual void Initialize()
Initializes the actor after creation.
Definition: actor.cpp:21
void SetPosition(const glm::vec3 &position)
Sets the actor's position in world space.
Definition: actor.cpp:25
const glm::vec3 & GetRotation() const
Gets the actor's rotation (pitch, yaw, roll in degrees).
Definition: actor.cpp:46
virtual void Shutdown()
Performs internal cleanup before destruction.
Definition: actor.cpp:103
const glm::vec3 & GetPosition() const
Gets the actor's position.
Definition: actor.cpp:41
Actor(Scene &scene)
Constructs an Actor associated with a Scene.
Definition: actor.cpp:9
const glm::vec3 & GetScale() const
Gets the actor's scale.
Definition: actor.cpp:51
Represents a 3D transformable scene component with position, rotation, and scale.
const glm::vec3 & GetPosition() const
Gets the current position.
void AttachTo(SceneComponent *parent)
Attaches this scene component to a parent scene component.
const glm::vec3 & GetRotation() const
Gets the current rotation as Euler angles (in radians).
void SetRotation(const glm::quat &rotation)
Sets the rotation using a quaternion.
void SetPosition(const glm::vec3 &position)
Sets the position of the component in world space.
const glm::vec3 & GetScale() const
Gets the current scale.
void SetScale(const glm::vec3 &scale)
Sets the scale for each dimension.
RenderResourceContext GetRenderResourceContext() const
Retrieves the current RenderResourceContext.
Base class representing a renderable scene.
Definition: scene.hpp:44
SceneManager & GetSceneManager()
Gets a reference to the SceneManager that owns this scene.
Definition: scene.cpp:129
void DestroyActor(Actor *actor)
Schedules a 3D actor for deferred destruction.
Definition: scene.cpp:159
Aggregates pointers to global rendering resource managers.