diff --git a/.idea/.idea.KhaoticEngineReborn/.idea/workspace.xml b/.idea/.idea.KhaoticEngineReborn/.idea/workspace.xml
index c5ee642..4910b96 100644
--- a/.idea/.idea.KhaoticEngineReborn/.idea/workspace.xml
+++ b/.idea/.idea.KhaoticEngineReborn/.idea/workspace.xml
@@ -6,10 +6,8 @@
-
-
@@ -23,13 +21,8 @@
-
-
-
-
-
-
-
+
+
@@ -46,25 +39,25 @@
- {
+ "keyToString": {
+ "ASKED_SHARE_PROJECT_CONFIGURATION_FILES": "true",
+ "C++ Project.enginecustom.executor": "Run",
+ "C/C++ Project.enginecustom.executor": "Run",
+ "RunOnceActivity.ShowReadmeOnStart": "true",
+ "RunOnceActivity.git.unshallow": "true",
+ "SHARE_PROJECT_CONFIGURATION_FILES": "true",
+ "git-widget-placeholder": "main",
+ "ignore.virus.scanning.warn.message": "true",
+ "node.js.detected.package.eslint": "true",
+ "node.js.detected.package.tslint": "true",
+ "node.js.selected.package.eslint": "(autodetect)",
+ "node.js.selected.package.tslint": "(autodetect)",
+ "nodejs_package_manager_path": "npm",
+ "settings.editor.selected.configurable": "preferences.build.unityPlugin",
+ "vue.rearranger.settings.migration": "true"
}
-}]]>
+}
@@ -186,6 +179,7 @@
+
diff --git a/enginecustom/src/inc/system/applicationclass.h b/enginecustom/src/inc/system/applicationclass.h
index f8b92a0..e3fef64 100644
--- a/enginecustom/src/inc/system/applicationclass.h
+++ b/enginecustom/src/inc/system/applicationclass.h
@@ -196,6 +196,12 @@ public :
private :
+ // Thread de culling
+ std::thread m_CullingThread;
+ std::atomic m_CullingActive;
+ std::mutex m_ObjectsMutex;
+ void CullingThreadFunction();
+
std::mutex m_TerrainMutex;
std::vector> m_TerrainGenerationData;
diff --git a/enginecustom/src/src/system/applicationclass.cpp b/enginecustom/src/src/system/applicationclass.cpp
index 0daf827..1e39ab8 100644
--- a/enginecustom/src/src/system/applicationclass.cpp
+++ b/enginecustom/src/src/system/applicationclass.cpp
@@ -54,12 +54,18 @@ ApplicationClass::ApplicationClass() : m_ShouldQuit(false)
ApplicationClass::~ApplicationClass()
{
m_ShouldQuit = true;
+ m_CullingActive = false;
- // Joindre le thread pour s'assurer qu'il se termine correctement
+ // Joindre les threads pour s'assurer qu'ils se terminent correctement
if (m_PhysicsThread.joinable())
{
m_PhysicsThread.join();
}
+
+ if (m_CullingThread.joinable())
+ {
+ m_CullingThread.join();
+ }
}
@@ -468,6 +474,9 @@ bool ApplicationClass::Initialize(int screenWidth, int screenHeight, HWND hwnd,
skybox->Initialize(m_Direct3D);
m_Skybox.push_back(skybox->ConstructSkybox());
+ m_CullingActive = true;
+ m_CullingThread = std::thread(&ApplicationClass::CullingThreadFunction, this);
+
}
catch (const std::exception& e)
{
@@ -1593,9 +1602,72 @@ void ApplicationClass::SetScreenWidth(int width)
m_screenWidth = width;
}
+void ApplicationClass::CullingThreadFunction()
+{
+ Logger::Get().Log("Thread de culling démarré", __FILE__, __LINE__, Logger::LogLevel::Info);
+
+ while (m_CullingActive)
+ {
+ // Construction du frustum une fois par cycle de culling
+ ConstructFrustum();
+
+ // S'assurer que la skybox est toujours visible
+ {
+ std::lock_guard lock(m_ObjectsMutex);
+ for (auto* skyboxObject : m_Skybox)
+ {
+ if (skyboxObject)
+ {
+ skyboxObject->SetVisible(true);
+ }
+ }
+ }
+
+ // Traitement des files d'objets normaux (sans la skybox)
+ std::vector>> queues = {
+ std::ref(m_object), std::ref(m_cubes), std::ref(m_terrainChunk)
+ };
+
+ for (auto& queueRef : queues)
+ {
+ std::vector