Minor - architecture rework pt.2 - V11.1.0
This commit is contained in:
parent
d364517633
commit
2a1b474df0
1437
.idea/.idea.KhaoticEngineReborn/.idea/workspace.xml
generated
1437
.idea/.idea.KhaoticEngineReborn/.idea/workspace.xml
generated
File diff suppressed because it is too large
Load Diff
@ -73,6 +73,7 @@
|
|||||||
<ClCompile Include="src\src\system\shadow_map.cpp" />
|
<ClCompile Include="src\src\system\shadow_map.cpp" />
|
||||||
<ClCompile Include="src\src\system\Skybox.cpp" />
|
<ClCompile Include="src\src\system\Skybox.cpp" />
|
||||||
<ClCompile Include="src\src\system\sprite_class.cpp" />
|
<ClCompile Include="src\src\system\sprite_class.cpp" />
|
||||||
|
<ClCompile Include="src\src\system\stats.cpp" />
|
||||||
<ClCompile Include="src\src\system\system_class.cpp" />
|
<ClCompile Include="src\src\system\system_class.cpp" />
|
||||||
<ClCompile Include="src\src\system\text_class.cpp" />
|
<ClCompile Include="src\src\system\text_class.cpp" />
|
||||||
<ClCompile Include="src\src\system\texture_class.cpp" />
|
<ClCompile Include="src\src\system\texture_class.cpp" />
|
||||||
@ -138,6 +139,7 @@
|
|||||||
<ClInclude Include="src\inc\system\shadow_map.h" />
|
<ClInclude Include="src\inc\system\shadow_map.h" />
|
||||||
<ClInclude Include="src\inc\system\Skybox.h" />
|
<ClInclude Include="src\inc\system\Skybox.h" />
|
||||||
<ClInclude Include="src\inc\system\sprite_class.h" />
|
<ClInclude Include="src\inc\system\sprite_class.h" />
|
||||||
|
<ClInclude Include="src\inc\system\stats.h" />
|
||||||
<ClInclude Include="src\inc\system\system_class.h" />
|
<ClInclude Include="src\inc\system\system_class.h" />
|
||||||
<ClInclude Include="src\inc\system\text_class.h" />
|
<ClInclude Include="src\inc\system\text_class.h" />
|
||||||
<ClInclude Include="src\inc\system\texture_class.h" />
|
<ClInclude Include="src\inc\system\texture_class.h" />
|
||||||
|
@ -5,7 +5,7 @@ Collapsed=0
|
|||||||
|
|
||||||
[Window][Khaotic Engine]
|
[Window][Khaotic Engine]
|
||||||
Pos=1281,19
|
Pos=1281,19
|
||||||
Size=303,842
|
Size=303,631
|
||||||
Collapsed=0
|
Collapsed=0
|
||||||
DockId=0x0000000F,0
|
DockId=0x0000000F,0
|
||||||
|
|
||||||
@ -82,25 +82,33 @@ Pos=16,718
|
|||||||
Size=997,758
|
Size=997,758
|
||||||
Collapsed=1
|
Collapsed=1
|
||||||
|
|
||||||
[Docking][Data]
|
[Window][render Stats]
|
||||||
DockSpace ID=0xC0DFADC4 Pos=8,27 Size=1568,826 Split=X
|
Pos=0,652
|
||||||
DockNode ID=0x00000001 Parent=0xC0DFADC4 SizeRef=330,1094 Selected=0x393905AB
|
Size=1584,209
|
||||||
DockNode ID=0x00000003 Parent=0xC0DFADC4 SizeRef=1700,1094 CentralNode=1
|
Collapsed=0
|
||||||
DockSpace ID=0xCCBD8CF7 Window=0x3DA2F1DE Pos=0,19 Size=1584,842 Split=X
|
DockId=0x00000014,0
|
||||||
DockNode ID=0x00000002 Parent=0xCCBD8CF7 SizeRef=1743,826 Split=Y
|
|
||||||
DockNode ID=0x0000000A Parent=0x00000002 SizeRef=1568,599 Split=X
|
[Docking][Data]
|
||||||
DockNode ID=0x00000009 Parent=0x0000000A SizeRef=281,974 Split=Y Selected=0x031DC75C
|
DockSpace ID=0xC0DFADC4 Pos=8,27 Size=1568,826 Split=X
|
||||||
DockNode ID=0x00000011 Parent=0x00000009 SizeRef=281,441 Selected=0x031DC75C
|
DockNode ID=0x00000001 Parent=0xC0DFADC4 SizeRef=330,1094 Selected=0x393905AB
|
||||||
DockNode ID=0x00000012 Parent=0x00000009 SizeRef=281,440 Selected=0x321620B2
|
DockNode ID=0x00000003 Parent=0xC0DFADC4 SizeRef=1700,1094 CentralNode=1
|
||||||
DockNode ID=0x0000000D Parent=0x0000000A SizeRef=1460,974 Split=Y
|
DockSpace ID=0xCCBD8CF7 Window=0x3DA2F1DE Pos=0,19 Size=1584,842 Split=Y
|
||||||
DockNode ID=0x0000000B Parent=0x0000000D SizeRef=1568,637 Split=X Selected=0x321620B2
|
DockNode ID=0x00000013 Parent=0xCCBD8CF7 SizeRef=1584,631 Split=X
|
||||||
DockNode ID=0x00000007 Parent=0x0000000B SizeRef=280,883 Selected=0x393905AB
|
DockNode ID=0x00000002 Parent=0x00000013 SizeRef=1743,826 Split=Y
|
||||||
DockNode ID=0x00000008 Parent=0x0000000B SizeRef=1178,883 CentralNode=1 Selected=0x4FC83240
|
DockNode ID=0x0000000A Parent=0x00000002 SizeRef=1568,599 Split=X
|
||||||
DockNode ID=0x0000000C Parent=0x0000000D SizeRef=1568,335 Selected=0x139FDA3F
|
DockNode ID=0x00000009 Parent=0x0000000A SizeRef=281,974 Split=Y Selected=0x031DC75C
|
||||||
DockNode ID=0x0000000E Parent=0x00000002 SizeRef=1568,225 Split=X Selected=0xD99DEA49
|
DockNode ID=0x00000011 Parent=0x00000009 SizeRef=281,441 Selected=0x031DC75C
|
||||||
DockNode ID=0x00000004 Parent=0x0000000E SizeRef=871,225 Selected=0xD99DEA49
|
DockNode ID=0x00000012 Parent=0x00000009 SizeRef=281,440 Selected=0x321620B2
|
||||||
DockNode ID=0x00000006 Parent=0x0000000E SizeRef=870,225 Selected=0xAB74BEE9
|
DockNode ID=0x0000000D Parent=0x0000000A SizeRef=1460,974 Split=Y
|
||||||
DockNode ID=0x00000005 Parent=0xCCBD8CF7 SizeRef=303,826 Split=Y Selected=0x9F035453
|
DockNode ID=0x0000000B Parent=0x0000000D SizeRef=1568,637 Split=X Selected=0x321620B2
|
||||||
DockNode ID=0x0000000F Parent=0x00000005 SizeRef=303,667 Selected=0x9F035453
|
DockNode ID=0x00000007 Parent=0x0000000B SizeRef=280,883 Selected=0x393905AB
|
||||||
DockNode ID=0x00000010 Parent=0x00000005 SizeRef=303,441 Selected=0x0B098C4B
|
DockNode ID=0x00000008 Parent=0x0000000B SizeRef=1178,883 CentralNode=1 Selected=0x4FC83240
|
||||||
|
DockNode ID=0x0000000C Parent=0x0000000D SizeRef=1568,335 Selected=0x139FDA3F
|
||||||
|
DockNode ID=0x0000000E Parent=0x00000002 SizeRef=1568,225 Split=X Selected=0xD99DEA49
|
||||||
|
DockNode ID=0x00000004 Parent=0x0000000E SizeRef=871,225 Selected=0xD99DEA49
|
||||||
|
DockNode ID=0x00000006 Parent=0x0000000E SizeRef=870,225 Selected=0xAB74BEE9
|
||||||
|
DockNode ID=0x00000005 Parent=0x00000013 SizeRef=303,826 Split=Y Selected=0x9F035453
|
||||||
|
DockNode ID=0x0000000F Parent=0x00000005 SizeRef=303,667 Selected=0x9F035453
|
||||||
|
DockNode ID=0x00000010 Parent=0x00000005 SizeRef=303,441 Selected=0x0B098C4B
|
||||||
|
DockNode ID=0x00000014 Parent=0xCCBD8CF7 SizeRef=1584,209 Selected=0xF5D1BB37
|
||||||
|
|
||||||
|
@ -44,6 +44,7 @@
|
|||||||
#include <mutex>
|
#include <mutex>
|
||||||
|
|
||||||
#include "shadow_map.h"
|
#include "shadow_map.h"
|
||||||
|
#include "stats.h"
|
||||||
|
|
||||||
|
|
||||||
/////////////
|
/////////////
|
||||||
@ -77,10 +78,6 @@ public:
|
|||||||
render_texture_class* get_refraction_texture() const { return refraction_texture_; };
|
render_texture_class* get_refraction_texture() const { return refraction_texture_; };
|
||||||
render_texture_class* get_reflection_texture() const { return reflection_texture_; };
|
render_texture_class* get_reflection_texture() const { return reflection_texture_; };
|
||||||
|
|
||||||
int get_total_vertex_count() const;
|
|
||||||
int get_total_triangle_count() const;
|
|
||||||
int get_visible_triangle_count() const;
|
|
||||||
|
|
||||||
void create_big_cube(int side_count);
|
void create_big_cube(int side_count);
|
||||||
void process_terrain_generation();
|
void process_terrain_generation();
|
||||||
virtual bool initialize(int, int, HWND, bool is_vulkan);
|
virtual bool initialize(int, int, HWND, bool is_vulkan);
|
||||||
@ -144,18 +141,6 @@ public:
|
|||||||
|
|
||||||
physics* get_physics() const { return physics_; };
|
physics* get_physics() const { return physics_; };
|
||||||
|
|
||||||
// ------------------------------------- //
|
|
||||||
// --------------- Stats --------------- //
|
|
||||||
// ------------------------------------- //
|
|
||||||
|
|
||||||
int get_current_fps() const { return fps_ ? fps_->GetFps() : 0; };
|
|
||||||
int get_min_fps() const { return fps_ ? fps_->GetMinFps() : 0; };
|
|
||||||
int get_max_fps() const { return fps_ ? fps_->GetMaxFps() : 0; };
|
|
||||||
float get_frame_time() const { return fps_ ? fps_->GetFrameTime() : 0.0f; };
|
|
||||||
int get_draw_calls() const { return drawcalls_; };
|
|
||||||
void increment_draw_call_count() { drawcalls_++; };
|
|
||||||
void reset_draw_call_count() { drawcalls_ = 0; };
|
|
||||||
|
|
||||||
// ----------------------------------- //
|
// ----------------------------------- //
|
||||||
// ------------- Culling ------------- //
|
// ------------- Culling ------------- //
|
||||||
// ----------------------------------- //
|
// ----------------------------------- //
|
||||||
@ -173,6 +158,8 @@ public:
|
|||||||
void set_can_fixed_update(bool can_fixed_update) { can_fixed_update_ = can_fixed_update; };
|
void set_can_fixed_update(bool can_fixed_update) { can_fixed_update_ = can_fixed_update; };
|
||||||
|
|
||||||
ID3D11ShaderResourceView* get_back_buffer_srv() const {return back_buffer_srv_;};
|
ID3D11ShaderResourceView* get_back_buffer_srv() const {return back_buffer_srv_;};
|
||||||
|
|
||||||
|
stats* get_stats() const { return stats_; };
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool render(float, float, float, float, float);
|
bool render(float, float, float, float, float);
|
||||||
@ -230,7 +217,6 @@ private :
|
|||||||
camera_class* sun_camera_;
|
camera_class* sun_camera_;
|
||||||
camera_class* active_camera_;
|
camera_class* active_camera_;
|
||||||
position_class* position_;
|
position_class* position_;
|
||||||
int drawcalls_;
|
|
||||||
|
|
||||||
shadow_map* shadow_map_;
|
shadow_map* shadow_map_;
|
||||||
ID3D11ShaderResourceView* shadow_map_srv_;
|
ID3D11ShaderResourceView* shadow_map_srv_;
|
||||||
@ -306,6 +292,8 @@ private :
|
|||||||
ID3D11Texture2D* back_buffer_texture_;
|
ID3D11Texture2D* back_buffer_texture_;
|
||||||
ID3D11ShaderResourceView* back_buffer_srv_;
|
ID3D11ShaderResourceView* back_buffer_srv_;
|
||||||
|
|
||||||
|
stats* stats_;
|
||||||
|
|
||||||
// ------------------------------------------------- //
|
// ------------------------------------------------- //
|
||||||
// ------------------- Culling --------------------- //
|
// ------------------- Culling --------------------- //
|
||||||
// ------------------------------------------------- //
|
// ------------------------------------------------- //
|
||||||
|
@ -17,6 +17,7 @@
|
|||||||
#include "scene_manager.h"
|
#include "scene_manager.h"
|
||||||
|
|
||||||
class application_class;
|
class application_class;
|
||||||
|
class stats;
|
||||||
|
|
||||||
struct widget_entry
|
struct widget_entry
|
||||||
{
|
{
|
||||||
@ -76,6 +77,7 @@ private:
|
|||||||
|
|
||||||
application_class* app_;
|
application_class* app_;
|
||||||
scene_manager* scene_manager_;
|
scene_manager* scene_manager_;
|
||||||
|
stats* stats_;
|
||||||
|
|
||||||
bool showObjectWindow;
|
bool showObjectWindow;
|
||||||
bool showTerrainWindow;
|
bool showTerrainWindow;
|
||||||
|
48
enginecustom/src/inc/system/stats.h
Normal file
48
enginecustom/src/inc/system/stats.h
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
#pragma once
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
#include "fps_class.h"
|
||||||
|
#include "object.h"
|
||||||
|
|
||||||
|
class stats
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
|
||||||
|
stats();
|
||||||
|
~stats();
|
||||||
|
|
||||||
|
bool initialize(fps_class* fps, application_class* app);
|
||||||
|
void update_stats();
|
||||||
|
void update();
|
||||||
|
|
||||||
|
int get_total_vertex_count() const;
|
||||||
|
int get_total_triangle_count() const;
|
||||||
|
int get_visible_triangle_count() const;
|
||||||
|
|
||||||
|
int get_current_fps() const { return current_fps_; };
|
||||||
|
int get_min_fps() const { return min_fps_; };
|
||||||
|
int get_max_fps() const { return max_fps_; };
|
||||||
|
float get_frame_time() const { return current_frame_time_;};
|
||||||
|
int get_draw_calls() const { return drawcalls_; };
|
||||||
|
|
||||||
|
void increment_draw_call_count() { drawcalls_++; };
|
||||||
|
void reset_draw_call_count() { drawcalls_ = 0; };
|
||||||
|
|
||||||
|
private:
|
||||||
|
fps_class* fps_;
|
||||||
|
int drawcalls_;
|
||||||
|
application_class* app_;
|
||||||
|
|
||||||
|
std::vector<object*> object_vec_;
|
||||||
|
std::vector<object*> cubes_vec_;
|
||||||
|
std::vector<object*> terrain_chunk_vec_;
|
||||||
|
|
||||||
|
int total_vertex_count_;
|
||||||
|
int total_triangle_count_;
|
||||||
|
int visible_triangle_count_ = 0;
|
||||||
|
int current_fps_ = 0;
|
||||||
|
int min_fps_ = 0;
|
||||||
|
int max_fps_ = 0;
|
||||||
|
float current_frame_time_ = 0.0f;
|
||||||
|
|
||||||
|
};
|
@ -49,7 +49,6 @@ application_class::application_class() : should_quit_(false)
|
|||||||
true_light_position_ = XMFLOAT3(0.0f, 0.0f, 0.0f);
|
true_light_position_ = XMFLOAT3(0.0f, 0.0f, 0.0f);
|
||||||
light_model_ = nullptr;
|
light_model_ = nullptr;
|
||||||
render_count_ = 0;
|
render_count_ = 0;
|
||||||
drawcalls_ = 0;
|
|
||||||
tab_was_pressed_ = false;
|
tab_was_pressed_ = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -492,6 +491,13 @@ bool application_class::initialize(int screenWidth, int screenHeight, HWND hwnd,
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
stats_ = new stats();
|
||||||
|
if (!stats_->initialize(fps_, this))
|
||||||
|
{
|
||||||
|
Logger::Get().Log("Could not initialize the stats object", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
physics_ = new physics;
|
physics_ = new physics;
|
||||||
|
|
||||||
physics_thread_ = std::thread(&application_class::physics_thread_function, this);
|
physics_thread_ = std::thread(&application_class::physics_thread_function, this);
|
||||||
@ -761,7 +767,7 @@ bool application_class::frame(input_class* Input)
|
|||||||
{
|
{
|
||||||
|
|
||||||
process_terrain_generation();
|
process_terrain_generation();
|
||||||
reset_draw_call_count();
|
stats_->reset_draw_call_count();
|
||||||
|
|
||||||
int mouseX, mouseY, currentMouseX, currentMouseY;
|
int mouseX, mouseY, currentMouseX, currentMouseY;
|
||||||
bool result, leftMouseDown, rightMouseDown, buttonQ, buttonD, buttonZ, buttonS, buttonA, buttonE, scrollUp, scrollDown;
|
bool result, leftMouseDown, rightMouseDown, buttonQ, buttonD, buttonZ, buttonS, buttonA, buttonE, scrollUp, scrollDown;
|
||||||
@ -2010,7 +2016,7 @@ bool application_class::render_pass(const std::vector<std::reference_wrapper<std
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
increment_draw_call_count();
|
stats_->increment_draw_call_count();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isSkybox)
|
if (isSkybox)
|
||||||
@ -2160,94 +2166,6 @@ void application_class::physics_thread_function()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int application_class::get_total_vertex_count() const
|
|
||||||
{
|
|
||||||
int totalVertices = 0;
|
|
||||||
for (const auto& obj : object_)
|
|
||||||
{
|
|
||||||
if (obj)
|
|
||||||
{
|
|
||||||
totalVertices += obj->GetVertexCount();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// Ajoutez le nombre de sommets pour les cubes
|
|
||||||
for (const auto& cube : cubes_)
|
|
||||||
{
|
|
||||||
if (cube)
|
|
||||||
{
|
|
||||||
totalVertices += cube->GetVertexCount();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// Ajoutez le nombre de sommets pour le terrain
|
|
||||||
for (const auto& chunk : terrain_chunk_)
|
|
||||||
{
|
|
||||||
if (chunk)
|
|
||||||
{
|
|
||||||
totalVertices += chunk->GetVertexCount();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return totalVertices;
|
|
||||||
}
|
|
||||||
|
|
||||||
int application_class::get_total_triangle_count() const
|
|
||||||
{
|
|
||||||
int totalTriangles = 0;
|
|
||||||
for (const auto& obj : object_)
|
|
||||||
{
|
|
||||||
if (obj)
|
|
||||||
{
|
|
||||||
// Dans une topologie de liste de triangles, chaque triangle utilise 3 indices
|
|
||||||
totalTriangles += obj->GetIndexCount() / 3;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// Ajoutez le nombre de triangles pour les cubes
|
|
||||||
for (const auto& cube : cubes_)
|
|
||||||
{
|
|
||||||
if (cube)
|
|
||||||
{
|
|
||||||
totalTriangles += cube->GetIndexCount() / 3;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// Ajoutez le nombre de triangles pour le terrain
|
|
||||||
for (const auto& chunk : terrain_chunk_)
|
|
||||||
{
|
|
||||||
if (chunk)
|
|
||||||
{
|
|
||||||
totalTriangles += chunk->GetIndexCount() / 3;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return totalTriangles;
|
|
||||||
}
|
|
||||||
|
|
||||||
int application_class::get_visible_triangle_count() const
|
|
||||||
{
|
|
||||||
int visibleTriangles = 0;
|
|
||||||
for (const auto& obj : object_)
|
|
||||||
{
|
|
||||||
if (obj && obj->IsVisible())
|
|
||||||
{
|
|
||||||
visibleTriangles += obj->GetIndexCount() / 3;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// Ajoutez le nombre de triangles visibles pour les cubes
|
|
||||||
for (const auto& cube : cubes_)
|
|
||||||
{
|
|
||||||
if (cube && cube->IsVisible())
|
|
||||||
{
|
|
||||||
visibleTriangles += cube->GetIndexCount() / 3;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// Ajoutez le nombre de triangles visibles pour le terrain
|
|
||||||
for (const auto& chunk : terrain_chunk_)
|
|
||||||
{
|
|
||||||
if (chunk && chunk->IsVisible())
|
|
||||||
{
|
|
||||||
visibleTriangles += chunk->GetIndexCount() / 3;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return visibleTriangles;
|
|
||||||
}
|
|
||||||
|
|
||||||
void application_class::create_big_cube(int side_count)
|
void application_class::create_big_cube(int side_count)
|
||||||
{
|
{
|
||||||
Logger::Get().Log("Lancement de la génération du terrain dans un thread séparé", __FILE__, __LINE__, Logger::LogLevel::Info);
|
Logger::Get().Log("Lancement de la génération du terrain dans un thread séparé", __FILE__, __LINE__, Logger::LogLevel::Info);
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
#include "imguiManager.h"
|
#include "imguiManager.h"
|
||||||
#include "application_class.h"
|
#include "application_class.h"
|
||||||
|
#include "stats.h"
|
||||||
|
|
||||||
static fps_limiter fpsLimiter(60.0f);
|
static fps_limiter fpsLimiter(60.0f);
|
||||||
|
|
||||||
@ -167,6 +168,8 @@ bool imguiManager::Initialize(HWND hwnd, ID3D11Device* device, ID3D11DeviceConte
|
|||||||
Logger::Get().Log("Failed to initialize scene manager", __FILE__, __LINE__, Logger::LogLevel::Error);
|
Logger::Get().Log("Failed to initialize scene manager", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
stats_ = app_->get_stats();
|
||||||
|
|
||||||
Logger::Get().Log("imgui initialized", __FILE__, __LINE__, Logger::LogLevel::Initialize);
|
Logger::Get().Log("imgui initialized", __FILE__, __LINE__, Logger::LogLevel::Initialize);
|
||||||
|
|
||||||
@ -981,15 +984,14 @@ void imguiManager::WidgetRenderStats()
|
|||||||
{
|
{
|
||||||
ImGui::Begin("render Stats");
|
ImGui::Begin("render Stats");
|
||||||
|
|
||||||
|
current_fps_ = stats_->get_current_fps();
|
||||||
current_fps_ = app_->get_current_fps();
|
min_fps_ = stats_->get_min_fps();
|
||||||
min_fps_ = app_->get_min_fps();
|
max_fps_ = stats_->get_max_fps();
|
||||||
max_fps_ = app_->get_max_fps();
|
draw_calls_ = stats_->get_draw_calls();
|
||||||
draw_calls_ = app_->get_draw_calls();
|
total_vertex_count_ = stats_->get_total_vertex_count();
|
||||||
total_vertex_count_ = app_->get_total_vertex_count();
|
total_triangle_count_ = stats_->get_total_triangle_count();
|
||||||
total_triangle_count_ = app_->get_total_triangle_count();
|
visible_triangle_count_ = stats_->get_visible_triangle_count();
|
||||||
visible_triangle_count_ = app_->get_visible_triangle_count();
|
current_frame_time_ = stats_->get_frame_time();
|
||||||
current_frame_time_ = app_->get_frame_time();
|
|
||||||
|
|
||||||
m_frameTimeHistory[m_frameTimeHistoryIndex] = current_frame_time_;
|
m_frameTimeHistory[m_frameTimeHistoryIndex] = current_frame_time_;
|
||||||
m_frameTimeHistoryIndex = (m_frameTimeHistoryIndex + 1) % FRAME_HISTORY_COUNT;
|
m_frameTimeHistoryIndex = (m_frameTimeHistoryIndex + 1) % FRAME_HISTORY_COUNT;
|
||||||
|
144
enginecustom/src/src/system/stats.cpp
Normal file
144
enginecustom/src/src/system/stats.cpp
Normal file
@ -0,0 +1,144 @@
|
|||||||
|
#include "stats.h"
|
||||||
|
#include "application_class.h"
|
||||||
|
|
||||||
|
stats::stats() : fps_(nullptr), drawcalls_(0)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
stats::~stats()
|
||||||
|
{
|
||||||
|
fps_ = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool stats::initialize(fps_class* fps, application_class* app)
|
||||||
|
{
|
||||||
|
if (!fps) {
|
||||||
|
Logger::Get().Log("FPS pointer is null", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
fps_ = fps;
|
||||||
|
drawcalls_ = 0;
|
||||||
|
app_ = app;
|
||||||
|
|
||||||
|
// call update() in a separate thread
|
||||||
|
std::thread updateThread(&stats::update, this);
|
||||||
|
updateThread.detach(); // Detach the thread to run independently
|
||||||
|
Logger::Get().Log("Stats initialized successfully", __FILE__, __LINE__, Logger::LogLevel::Initialize);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void stats::update()
|
||||||
|
{
|
||||||
|
while (true)
|
||||||
|
{
|
||||||
|
// call update_stats() every second
|
||||||
|
std::this_thread::sleep_for(std::chrono::seconds(1));
|
||||||
|
update_stats();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void stats::update_stats()
|
||||||
|
{
|
||||||
|
object_vec_ = app_->get_kobjects();
|
||||||
|
cubes_vec_ = app_->get_cubes();
|
||||||
|
terrain_chunk_vec_ = app_->get_terrain_cubes();
|
||||||
|
|
||||||
|
current_fps_ = get_current_fps();
|
||||||
|
min_fps_ = get_min_fps();
|
||||||
|
max_fps_ = get_max_fps();
|
||||||
|
drawcalls_ = get_draw_calls();
|
||||||
|
total_vertex_count_ = get_total_vertex_count();
|
||||||
|
total_triangle_count_ = get_total_triangle_count();
|
||||||
|
visible_triangle_count_ = get_visible_triangle_count();
|
||||||
|
current_frame_time_ = get_frame_time();
|
||||||
|
}
|
||||||
|
|
||||||
|
int stats::get_total_vertex_count() const
|
||||||
|
{
|
||||||
|
int totalVertices = 0;
|
||||||
|
for (const auto& obj : object_vec_)
|
||||||
|
{
|
||||||
|
if (obj)
|
||||||
|
{
|
||||||
|
totalVertices += obj->GetVertexCount();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Ajoutez le nombre de sommets pour les cubes
|
||||||
|
for (const auto& cube : cubes_vec_)
|
||||||
|
{
|
||||||
|
if (cube)
|
||||||
|
{
|
||||||
|
totalVertices += cube->GetVertexCount();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Ajoutez le nombre de sommets pour le terrain
|
||||||
|
for (const auto& chunk : terrain_chunk_vec_)
|
||||||
|
{
|
||||||
|
if (chunk)
|
||||||
|
{
|
||||||
|
totalVertices += chunk->GetVertexCount();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return totalVertices;
|
||||||
|
}
|
||||||
|
|
||||||
|
int stats::get_total_triangle_count() const
|
||||||
|
{
|
||||||
|
int totalTriangles = 0;
|
||||||
|
for (const auto& obj : object_vec_)
|
||||||
|
{
|
||||||
|
if (obj)
|
||||||
|
{
|
||||||
|
// Dans une topologie de liste de triangles, chaque triangle utilise 3 indices
|
||||||
|
totalTriangles += obj->GetIndexCount() / 3;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Ajoutez le nombre de triangles pour les cubes
|
||||||
|
for (const auto& cube : cubes_vec_)
|
||||||
|
{
|
||||||
|
if (cube)
|
||||||
|
{
|
||||||
|
totalTriangles += cube->GetIndexCount() / 3;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Ajoutez le nombre de triangles pour le terrain
|
||||||
|
for (const auto& chunk : terrain_chunk_vec_)
|
||||||
|
{
|
||||||
|
if (chunk)
|
||||||
|
{
|
||||||
|
totalTriangles += chunk->GetIndexCount() / 3;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return totalTriangles;
|
||||||
|
}
|
||||||
|
|
||||||
|
int stats::get_visible_triangle_count() const
|
||||||
|
{
|
||||||
|
int visibleTriangles = 0;
|
||||||
|
for (const auto& obj : object_vec_)
|
||||||
|
{
|
||||||
|
if (obj && obj->IsVisible())
|
||||||
|
{
|
||||||
|
visibleTriangles += obj->GetIndexCount() / 3;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Ajoutez le nombre de triangles visibles pour les cubes
|
||||||
|
for (const auto& cube : cubes_vec_)
|
||||||
|
{
|
||||||
|
if (cube && cube->IsVisible())
|
||||||
|
{
|
||||||
|
visibleTriangles += cube->GetIndexCount() / 3;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Ajoutez le nombre de triangles visibles pour le terrain
|
||||||
|
for (const auto& chunk : terrain_chunk_vec_)
|
||||||
|
{
|
||||||
|
if (chunk && chunk->IsVisible())
|
||||||
|
{
|
||||||
|
visibleTriangles += chunk->GetIndexCount() / 3;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return visibleTriangles;
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user