Skip to content

Commit b50f657

Browse files
committed
Amélioration des commentaires et optimisation du code
Ajout de commentaires dans `Application::Start()` pour clarifier l'exécution des opérations entre threads. Optimisation suggérée dans `ChunkManager::copy_to_render()` pour éviter les recherches répétées dans la carte des chunks et améliorer la gestion des chunks à supprimer.
1 parent f96cba9 commit b50f657

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

R3DVoxel/Application.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,12 +66,12 @@ void Application::Start()
6666

6767
do
6868
{
69-
const auto update_x = chunk_manager.compute_world_update_x(*mp_engine->GetMainCamera());
69+
const auto update_x = chunk_manager.compute_world_update_x(*mp_engine->GetMainCamera()); // secondary thread
7070
if (update_x.updated)
7171
{
72-
auto meshes = chunk_manager.compute_meshes(update_x.created, update_x.update_plus, update_x.update_min);
73-
chunk_manager.copy_to_render();
74-
chunk_manager.render_meshes(meshes, update_x.created, update_x.update_plus, update_x.update_min);
72+
auto meshes = chunk_manager.compute_meshes(update_x.created, update_x.update_plus, update_x.update_min); // secondary thread
73+
chunk_manager.copy_to_render(); // sync threads here
74+
chunk_manager.render_meshes(meshes, update_x.created, update_x.update_plus, update_x.update_min); // main thread
7575

7676
// chunk_manager.update_world_x(update_x.created, update_x.update_plus, update_x.update_min);
7777
}

R3DVoxel/VoxelEngine/ChunkManager.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -462,13 +462,13 @@ void ChunkManager::copy_to_render()
462462
{
463463
for (auto& [key, chunk] : _setup_list)
464464
{
465-
if (chunk && !m_chunk_map.contains(key))
465+
if (chunk && !m_chunk_map.contains(key)) // should make a simple list of keys of created chunks to prevent lookup
466466
{
467467
m_chunk_map.insert(std::pair<ChunkKey, std::unique_ptr<Chunk>>(key, std::move(chunk)));
468468
}
469469
}
470470

471-
for (auto& [key, chunk] : _destroy_list)
471+
for (auto& [key, chunk] : _destroy_list) // maybe store pointers to be deleted (prevents lookup in map)
472472
{
473473
if (chunk)
474474
{

0 commit comments

Comments
 (0)