Skip to content

Commit 916078b

Browse files
author
Dan Liebault
committed
Amélioration des accesseurs et gestion de la caméra
Modification des accesseurs de la classe `Camera` pour les rendre `const`, permettant leur utilisation sur des instances constantes. Changement du passage de la caméra à `ChunkManager` pour utiliser une référence constante, améliorant ainsi la gestion de la mémoire. Mise à jour des signatures de méthode et de constructeur dans les fichiers d'en-tête pour refléter ces changements.
1 parent 85bdd49 commit 916078b

5 files changed

Lines changed: 12 additions & 12 deletions

File tree

Engine/cameras/Camera.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ void Camera::SetPosition(const glm::vec3& position)
9393
m_position = position;
9494
}
9595

96-
const glm::vec3& Camera::GetPosition()
96+
const glm::vec3& Camera::GetPosition() const
9797
{
9898
return m_position;
9999
}
@@ -103,7 +103,7 @@ void Camera::SetRotation(const glm::vec3& rotation)
103103
m_rotation = rotation;
104104
}
105105

106-
const glm::vec3& Camera::GetRotation()
106+
const glm::vec3& Camera::GetRotation() const
107107
{
108108
return m_rotation;
109109
}
@@ -113,7 +113,7 @@ void Camera::setPitch(const float& pitch)
113113
m_pitch = pitch;
114114
}
115115

116-
const float& Camera::getPitch()
116+
const float& Camera::getPitch() const
117117
{
118118
return m_pitch;
119119
}
@@ -123,7 +123,7 @@ void Camera::setYaw(const float& yaw)
123123
m_yaw = yaw;
124124
}
125125

126-
const float& Camera::getYaw()
126+
const float& Camera::getYaw() const
127127
{
128128
return m_yaw;
129129
}

Engine/cameras/Camera.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,16 +28,16 @@ class Camera
2828
void MoveDown(const float& speed);
2929

3030
void SetPosition(const glm::vec3& position);
31-
const glm::vec3& GetPosition();
31+
const glm::vec3& GetPosition() const;
3232

3333
void SetRotation(const glm::vec3& rotation);
34-
const glm::vec3& GetRotation();
34+
const glm::vec3& GetRotation() const;
3535

3636
void setPitch(const float& pitch);
37-
const float& getPitch();
37+
const float& getPitch() const;
3838

3939
void setYaw(const float& yaw);
40-
const float& getYaw();
40+
const float& getYaw() const;
4141

4242
UniformBufferObject& GetUBO(const int32_t frame);
4343

R3DVoxel/Application.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ void Application::Start()
3030

3131
mp_engine->GetMainCamera()->SetPosition({ 0.f, 10.f, 0.f });
3232

33-
ChunkManager chunk_manager(world, world_mat, mp_engine->GetMainCamera());
33+
ChunkManager chunk_manager(world, world_mat, *mp_engine->GetMainCamera());
3434
chunk_manager.CreateWorld();
3535

3636
glm::vec3 lposition = { 50.0f, 10.0f, 0.0f };

R3DVoxel/VoxelEngine/ChunkManager.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@
33
#include <utility>
44
#include <barrier>
55

6-
ChunkManager::ChunkManager(std::shared_ptr<GameObject> pworld, std::shared_ptr<Material> p_world_mat, std::shared_ptr<Camera> p_camera) :
6+
ChunkManager::ChunkManager(std::shared_ptr<GameObject> pworld, std::shared_ptr<Material> p_world_mat, const Camera& camera) :
77
mp_world(std::move(pworld)), mp_world_mat(std::move(p_world_mat)), m_worldmenu(m_load_radius)
88
{
99
mp_terrain_generator = std::make_unique<TerrainGenerator>();
10-
m_render_position = p_camera->GetPosition();
10+
m_render_position = camera.GetPosition();
1111
m_render_max = { m_render_position.x + m_load_radius, m_render_position.y + m_load_radius, m_render_position.z + m_load_radius };
1212
m_render_min = { m_render_position.x - m_load_radius, m_render_position.y - m_load_radius, m_render_position.z - m_load_radius };
1313
}

R3DVoxel/VoxelEngine/ChunkManager.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
class ChunkManager
1313
{
1414
public:
15-
ChunkManager(std::shared_ptr<GameObject> pworld, std::shared_ptr<Material> p_world_mat, std::shared_ptr<Camera> p_camera);
15+
ChunkManager(std::shared_ptr<GameObject> pworld, std::shared_ptr<Material> p_world_mat, const Camera& camera);
1616
~ChunkManager() = default;
1717

1818
void CreateWorld();

0 commit comments

Comments
 (0)