Minor Update - Stats Widget + BigCube Generation WIP - V10.2.0
This commit is contained in:
parent
2744c809d3
commit
94fd900ce8
31
.idea/.idea.KhaoticEngineReborn/.idea/workspace.xml
generated
31
.idea/.idea.KhaoticEngineReborn/.idea/workspace.xml
generated
@ -7,8 +7,16 @@
|
|||||||
<list default="true" id="e81d6e08-efc7-40a0-909d-ec4943d948e9" name="Changes" comment="">
|
<list default="true" id="e81d6e08-efc7-40a0-909d-ec4943d948e9" name="Changes" comment="">
|
||||||
<change beforePath="$PROJECT_DIR$/.idea/.idea.KhaoticEngineReborn/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/.idea.KhaoticEngineReborn/.idea/workspace.xml" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/.idea/.idea.KhaoticEngineReborn/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/.idea.KhaoticEngineReborn/.idea/workspace.xml" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/enginecustom/assets/Texture/imgui.ini" beforeDir="false" afterPath="$PROJECT_DIR$/enginecustom/assets/Texture/imgui.ini" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/enginecustom/assets/Texture/imgui.ini" beforeDir="false" afterPath="$PROJECT_DIR$/enginecustom/assets/Texture/imgui.ini" afterDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/enginecustom/imgui.ini" beforeDir="false" afterPath="$PROJECT_DIR$/enginecustom/imgui.ini" afterDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/enginecustom/src/inc/system/applicationclass.h" beforeDir="false" afterPath="$PROJECT_DIR$/enginecustom/src/inc/system/applicationclass.h" afterDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/enginecustom/src/inc/system/fpsclass.h" beforeDir="false" afterPath="$PROJECT_DIR$/enginecustom/src/inc/system/fpsclass.h" afterDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/enginecustom/src/inc/system/imguiManager.h" beforeDir="false" afterPath="$PROJECT_DIR$/enginecustom/src/inc/system/imguiManager.h" afterDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/enginecustom/src/inc/system/modelclass.h" beforeDir="false" afterPath="$PROJECT_DIR$/enginecustom/src/inc/system/modelclass.h" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/enginecustom/src/inc/system/object.h" beforeDir="false" afterPath="$PROJECT_DIR$/enginecustom/src/inc/system/object.h" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/enginecustom/src/inc/system/object.h" beforeDir="false" afterPath="$PROJECT_DIR$/enginecustom/src/inc/system/object.h" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/enginecustom/src/src/system/applicationclass.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/enginecustom/src/src/system/applicationclass.cpp" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/enginecustom/src/src/system/applicationclass.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/enginecustom/src/src/system/applicationclass.cpp" afterDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/enginecustom/src/src/system/fpsclass.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/enginecustom/src/src/system/fpsclass.cpp" afterDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/enginecustom/src/src/system/imguiManager.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/enginecustom/src/src/system/imguiManager.cpp" afterDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/enginecustom/src/src/system/modelclass.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/enginecustom/src/src/system/modelclass.cpp" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/enginecustom/src/src/system/object.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/enginecustom/src/src/system/object.cpp" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/enginecustom/src/src/system/object.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/enginecustom/src/src/system/object.cpp" afterDir="false" />
|
||||||
</list>
|
</list>
|
||||||
<option name="SHOW_DIALOG" value="false" />
|
<option name="SHOW_DIALOG" value="false" />
|
||||||
@ -29,25 +37,7 @@
|
|||||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
<setting file="cidr-memory-view://4" root0="FORCE_HIGHLIGHTING" />
|
||||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
|
||||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
|
||||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
|
||||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
|
||||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
|
||||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
|
||||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
|
||||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
|
||||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
|
||||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
|
||||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
|
||||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
|
||||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
|
||||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
|
||||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
|
||||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
|
||||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
|
||||||
<setting file="cidr-memory-view://3" root0="FORCE_HIGHLIGHTING" />
|
|
||||||
<setting file="file://$PROJECT_DIR$/enginecustom/include/Vulkan/Include/vulkan/vulkan_core.h" root0="SKIP_HIGHLIGHTING" />
|
<setting file="file://$PROJECT_DIR$/enginecustom/include/Vulkan/Include/vulkan/vulkan_core.h" root0="SKIP_HIGHLIGHTING" />
|
||||||
<setting file="file://$PROJECT_DIR$/enginecustom/src/src/shader/CelShadingShader.cpp" root0="FORCE_HIGHLIGHTING" />
|
<setting file="file://$PROJECT_DIR$/enginecustom/src/src/shader/CelShadingShader.cpp" root0="FORCE_HIGHLIGHTING" />
|
||||||
<setting file="file://$PROJECT_DIR$/../../IDE_VS/VC/Tools/MSVC/14.38.33130/include/type_traits" root0="SKIP_HIGHLIGHTING" />
|
<setting file="file://$PROJECT_DIR$/../../IDE_VS/VC/Tools/MSVC/14.38.33130/include/type_traits" root0="SKIP_HIGHLIGHTING" />
|
||||||
@ -202,7 +192,8 @@
|
|||||||
<workItem from="1746526901276" duration="2023000" />
|
<workItem from="1746526901276" duration="2023000" />
|
||||||
<workItem from="1746536290167" duration="1908000" />
|
<workItem from="1746536290167" duration="1908000" />
|
||||||
<workItem from="1746538260893" duration="5781000" />
|
<workItem from="1746538260893" duration="5781000" />
|
||||||
<workItem from="1746546014271" duration="1490000" />
|
<workItem from="1746546014271" duration="1814000" />
|
||||||
|
<workItem from="1746619988287" duration="10779000" />
|
||||||
</task>
|
</task>
|
||||||
<task id="LOCAL-00001" summary="Minor update - viewport window tweak">
|
<task id="LOCAL-00001" summary="Minor update - viewport window tweak">
|
||||||
<option name="closed" value="true" />
|
<option name="closed" value="true" />
|
||||||
|
@ -35,9 +35,9 @@ DockId=0x00000001,2
|
|||||||
|
|
||||||
[Window][Engine Settings]
|
[Window][Engine Settings]
|
||||||
Pos=8,27
|
Pos=8,27
|
||||||
Size=289,826
|
Size=289,547
|
||||||
Collapsed=0
|
Collapsed=0
|
||||||
DockId=0x00000007,0
|
DockId=0x00000007,1
|
||||||
|
|
||||||
[Window][DockSpace Demo]
|
[Window][DockSpace Demo]
|
||||||
Size=1584,861
|
Size=1584,861
|
||||||
@ -78,7 +78,7 @@ DockSpace ID=0xC0DFADC4 Pos=8,27 Size=1568,826 Split=X
|
|||||||
DockSpace ID=0xCCBD8CF7 Window=0x3DA2F1DE Pos=8,27 Size=2032,1094 Split=Y
|
DockSpace ID=0xCCBD8CF7 Window=0x3DA2F1DE Pos=8,27 Size=2032,1094 Split=Y
|
||||||
DockNode ID=0x00000004 Parent=0xCCBD8CF7 SizeRef=1568,598 Split=X
|
DockNode ID=0x00000004 Parent=0xCCBD8CF7 SizeRef=1568,598 Split=X
|
||||||
DockNode ID=0x00000009 Parent=0x00000004 SizeRef=289,974 Split=Y Selected=0x031DC75C
|
DockNode ID=0x00000009 Parent=0x00000004 SizeRef=289,974 Split=Y Selected=0x031DC75C
|
||||||
DockNode ID=0x00000007 Parent=0x00000009 SizeRef=289,547 Selected=0x031DC75C
|
DockNode ID=0x00000007 Parent=0x00000009 SizeRef=289,547 Selected=0x0B098C4B
|
||||||
DockNode ID=0x00000008 Parent=0x00000009 SizeRef=289,545 Selected=0x393905AB
|
DockNode ID=0x00000008 Parent=0x00000009 SizeRef=289,545 Selected=0x393905AB
|
||||||
DockNode ID=0x0000000D Parent=0x00000004 SizeRef=1613,974 Split=X
|
DockNode ID=0x0000000D Parent=0x00000004 SizeRef=1613,974 Split=X
|
||||||
DockNode ID=0x00000002 Parent=0x0000000D SizeRef=1268,826 Split=Y
|
DockNode ID=0x00000002 Parent=0x0000000D SizeRef=1268,826 Split=Y
|
||||||
|
@ -11,21 +11,21 @@ DockId=0x00000005,0
|
|||||||
|
|
||||||
[Window][Objects]
|
[Window][Objects]
|
||||||
Pos=8,27
|
Pos=8,27
|
||||||
Size=289,826
|
Size=289,547
|
||||||
Collapsed=0
|
Collapsed=0
|
||||||
DockId=0x00000009,0
|
DockId=0x00000007,0
|
||||||
|
|
||||||
[Window][Terrain]
|
[Window][Terrain]
|
||||||
Pos=8,27
|
Pos=8,27
|
||||||
Size=250,826
|
Size=281,826
|
||||||
Collapsed=0
|
Collapsed=0
|
||||||
DockId=0x00000007,0
|
DockId=0x00000008,0
|
||||||
|
|
||||||
[Window][Light]
|
[Window][Light]
|
||||||
Pos=8,27
|
Pos=8,27
|
||||||
Size=290,866
|
Size=290,866
|
||||||
Collapsed=0
|
Collapsed=0
|
||||||
DockId=0x00000007,1
|
DockId=0x0000000B,1
|
||||||
|
|
||||||
[Window][Shader Manager]
|
[Window][Shader Manager]
|
||||||
Pos=8,27
|
Pos=8,27
|
||||||
@ -35,9 +35,9 @@ DockId=0x00000001,2
|
|||||||
|
|
||||||
[Window][Engine Settings]
|
[Window][Engine Settings]
|
||||||
Pos=8,27
|
Pos=8,27
|
||||||
Size=289,826
|
Size=289,547
|
||||||
Collapsed=0
|
Collapsed=0
|
||||||
DockId=0x00000009,0
|
DockId=0x00000007,1
|
||||||
|
|
||||||
[Window][DockSpace Demo]
|
[Window][DockSpace Demo]
|
||||||
Size=1584,861
|
Size=1584,861
|
||||||
@ -47,7 +47,7 @@ Collapsed=0
|
|||||||
Pos=8,27
|
Pos=8,27
|
||||||
Size=1559,974
|
Size=1559,974
|
||||||
Collapsed=0
|
Collapsed=0
|
||||||
DockId=0x00000009,0
|
DockId=0x00000007,0
|
||||||
|
|
||||||
[Window][DockSpace]
|
[Window][DockSpace]
|
||||||
Pos=0,0
|
Pos=0,0
|
||||||
@ -71,19 +71,27 @@ Size=16,19
|
|||||||
Collapsed=0
|
Collapsed=0
|
||||||
DockId=0x00000006,0
|
DockId=0x00000006,0
|
||||||
|
|
||||||
|
[Window][Render Stats]
|
||||||
|
Pos=8,628
|
||||||
|
Size=1568,225
|
||||||
|
Collapsed=0
|
||||||
|
DockId=0x0000000E,0
|
||||||
|
|
||||||
[Docking][Data]
|
[Docking][Data]
|
||||||
DockSpace ID=0xC0DFADC4 Pos=8,27 Size=1568,826 Split=X
|
DockSpace ID=0xC0DFADC4 Pos=8,27 Size=1568,826 Split=X
|
||||||
DockNode ID=0x00000001 Parent=0xC0DFADC4 SizeRef=330,1094 Selected=0x393905AB
|
DockNode ID=0x00000001 Parent=0xC0DFADC4 SizeRef=330,1094 Selected=0x393905AB
|
||||||
DockNode ID=0x00000003 Parent=0xC0DFADC4 SizeRef=1700,1094 CentralNode=1
|
DockNode ID=0x00000003 Parent=0xC0DFADC4 SizeRef=1700,1094 CentralNode=1
|
||||||
DockSpace ID=0xCCBD8CF7 Window=0x3DA2F1DE Pos=8,27 Size=1568,826 Split=Y
|
DockSpace ID=0xCCBD8CF7 Window=0x3DA2F1DE Pos=8,27 Size=1568,826 Split=Y
|
||||||
DockNode ID=0x00000004 Parent=0xCCBD8CF7 SizeRef=1568,598 Split=X
|
DockNode ID=0x0000000A Parent=0xCCBD8CF7 SizeRef=1568,599 Split=Y
|
||||||
DockNode ID=0x00000009 Parent=0x00000004 SizeRef=289,974 Selected=0x031DC75C
|
DockNode ID=0x00000004 Parent=0x0000000A SizeRef=1568,598 Split=X
|
||||||
DockNode ID=0x0000000D Parent=0x00000004 SizeRef=1613,974 Split=X
|
DockNode ID=0x00000009 Parent=0x00000004 SizeRef=281,974 Split=Y Selected=0x031DC75C
|
||||||
DockNode ID=0x00000002 Parent=0x0000000D SizeRef=1268,826 Split=Y
|
DockNode ID=0x00000007 Parent=0x00000009 SizeRef=289,547 Selected=0x031DC75C
|
||||||
DockNode ID=0x0000000B Parent=0x00000002 SizeRef=1568,637 Split=X
|
DockNode ID=0x00000008 Parent=0x00000009 SizeRef=289,545 Selected=0x393905AB
|
||||||
DockNode ID=0x00000007 Parent=0x0000000B SizeRef=250,826 Selected=0x393905AB
|
DockNode ID=0x0000000D Parent=0x00000004 SizeRef=1285,974 Split=X
|
||||||
DockNode ID=0x00000008 Parent=0x0000000B SizeRef=971,826 CentralNode=1 Selected=0x031DC75C
|
DockNode ID=0x00000002 Parent=0x0000000D SizeRef=940,826 Split=Y
|
||||||
DockNode ID=0x0000000C Parent=0x00000002 SizeRef=1568,335 Selected=0x139FDA3F
|
DockNode ID=0x0000000B Parent=0x00000002 SizeRef=1568,637 CentralNode=1
|
||||||
DockNode ID=0x00000005 Parent=0x0000000D SizeRef=343,826 Selected=0x9F035453
|
DockNode ID=0x0000000C Parent=0x00000002 SizeRef=1568,335 Selected=0x139FDA3F
|
||||||
DockNode ID=0x00000006 Parent=0xCCBD8CF7 SizeRef=1568,226 Selected=0xAB74BEE9
|
DockNode ID=0x00000005 Parent=0x0000000D SizeRef=343,826 Selected=0x9F035453
|
||||||
|
DockNode ID=0x00000006 Parent=0x0000000A SizeRef=1568,226 Selected=0xAB74BEE9
|
||||||
|
DockNode ID=0x0000000E Parent=0xCCBD8CF7 SizeRef=1568,225 Selected=0xD99DEA49
|
||||||
|
|
||||||
|
@ -41,6 +41,7 @@
|
|||||||
#include <map>
|
#include <map>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <DirectXMath.h>
|
#include <DirectXMath.h>
|
||||||
|
#include <mutex>
|
||||||
|
|
||||||
|
|
||||||
/////////////
|
/////////////
|
||||||
@ -67,12 +68,17 @@ public:
|
|||||||
ApplicationClass();
|
ApplicationClass();
|
||||||
~ApplicationClass();
|
~ApplicationClass();
|
||||||
D3DClass* GetDirect3D();
|
D3DClass* GetDirect3D();
|
||||||
|
|
||||||
RenderTextureClass* GetSceneTexture() const { return m_SceneTexture; };
|
RenderTextureClass* GetSceneTexture() const { return m_SceneTexture; };
|
||||||
RenderTextureClass* GetRenderTexture() const { return m_RenderTexture; };
|
RenderTextureClass* GetRenderTexture() const { return m_RenderTexture; };
|
||||||
RenderTextureClass* GetRefractionTexture() const { return m_RefractionTexture; };
|
RenderTextureClass* GetRefractionTexture() const { return m_RefractionTexture; };
|
||||||
RenderTextureClass* GetReflectionTexture() const { return m_ReflectionTexture; };
|
RenderTextureClass* GetReflectionTexture() const { return m_ReflectionTexture; };
|
||||||
|
|
||||||
|
|
||||||
|
int GetTotalVertexCount() const;
|
||||||
|
int GetTotalTriangleCount() const;
|
||||||
|
int GetVisibleTriangleCount() const;
|
||||||
|
|
||||||
|
void CreateBigCube(int sideCount);
|
||||||
bool Initialize(int, int, HWND, bool IsVulkan);
|
bool Initialize(int, int, HWND, bool IsVulkan);
|
||||||
void Shutdown();
|
void Shutdown();
|
||||||
bool Frame(InputClass*);
|
bool Frame(InputClass*);
|
||||||
@ -131,6 +137,19 @@ public:
|
|||||||
|
|
||||||
Physics* GetPhysics() const { return m_Physics; };
|
Physics* GetPhysics() const { return m_Physics; };
|
||||||
|
|
||||||
|
// ------------------------------------- //
|
||||||
|
// --------------- Stats --------------- //
|
||||||
|
// ------------------------------------- //
|
||||||
|
|
||||||
|
int GetCurrentFps() const;
|
||||||
|
int GetMinFps() const;
|
||||||
|
int GetMaxFps() const;
|
||||||
|
float GetFrameTime() const;
|
||||||
|
int GetDrawCalls() const;
|
||||||
|
void ResetFpsStats();
|
||||||
|
void IncrementDrawCallCount();
|
||||||
|
void ResetDrawCallCount();
|
||||||
|
|
||||||
// ----------------------------------- //
|
// ----------------------------------- //
|
||||||
// ------------- Culling ------------- //
|
// ------------- Culling ------------- //
|
||||||
// ----------------------------------- //
|
// ----------------------------------- //
|
||||||
@ -202,6 +221,7 @@ private :
|
|||||||
int m_screenWidth, m_screenHeight;
|
int m_screenWidth, m_screenHeight;
|
||||||
CameraClass* m_Camera;
|
CameraClass* m_Camera;
|
||||||
PositionClass* m_Position;
|
PositionClass* m_Position;
|
||||||
|
int m_drawcalls;
|
||||||
|
|
||||||
// ------------------------------------ //
|
// ------------------------------------ //
|
||||||
// ------------- OBJECTS -------------- //
|
// ------------- OBJECTS -------------- //
|
||||||
|
@ -28,9 +28,19 @@ public:
|
|||||||
void Frame();
|
void Frame();
|
||||||
int GetFps();
|
int GetFps();
|
||||||
|
|
||||||
|
int GetMinFps() const;
|
||||||
|
int GetMaxFps() const;
|
||||||
|
float GetFrameTime() const;
|
||||||
|
void ResetStats();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int m_fps, m_count;
|
int m_fps, m_count;
|
||||||
unsigned long m_startTime;
|
unsigned long m_startTime;
|
||||||
|
|
||||||
|
int m_minFps;
|
||||||
|
int m_maxFps;
|
||||||
|
float m_frameTime;
|
||||||
|
unsigned long m_previousTime;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
@ -38,6 +38,7 @@ public:
|
|||||||
void WidgetEngineSettingsWindow(ApplicationClass* app);
|
void WidgetEngineSettingsWindow(ApplicationClass* app);
|
||||||
void WidgetRenderWindow(ApplicationClass* app, ImVec2 availableSize);
|
void WidgetRenderWindow(ApplicationClass* app, ImVec2 availableSize);
|
||||||
void WidgetLogWindow(ApplicationClass* app);
|
void WidgetLogWindow(ApplicationClass* app);
|
||||||
|
void WidgetRenderStats(ApplicationClass* app);
|
||||||
|
|
||||||
bool ImGuiWidgetRenderer(ApplicationClass* app);
|
bool ImGuiWidgetRenderer(ApplicationClass* app);
|
||||||
|
|
||||||
@ -65,6 +66,11 @@ private:
|
|||||||
bool showOldSceneWindow;
|
bool showOldSceneWindow;
|
||||||
bool showEngineSettingsWindow;
|
bool showEngineSettingsWindow;
|
||||||
bool showLogWindow;
|
bool showLogWindow;
|
||||||
|
bool showStatsWindow;
|
||||||
|
|
||||||
|
static const int FRAME_HISTORY_COUNT = 3600; // 1min secondes à 60 FPS
|
||||||
|
float m_frameTimeHistory[FRAME_HISTORY_COUNT] = {};
|
||||||
|
int m_frameTimeHistoryIndex = 0;
|
||||||
|
|
||||||
bool m_isPhyiscsEnabled = false;
|
bool m_isPhyiscsEnabled = false;
|
||||||
bool m_isGravityEnabled = false;
|
bool m_isGravityEnabled = false;
|
||||||
|
@ -213,9 +213,13 @@ public:
|
|||||||
void Render(ID3D11DeviceContext*);
|
void Render(ID3D11DeviceContext*);
|
||||||
|
|
||||||
int GetIndexCount();
|
int GetIndexCount();
|
||||||
|
int GetVertexCount() const { return m_vertexCount; }
|
||||||
|
|
||||||
|
// TEXTURE //
|
||||||
|
|
||||||
//ID3D11ShaderResourceView* GetTexture(int index) const;
|
//ID3D11ShaderResourceView* GetTexture(int index) const;
|
||||||
ID3D11ShaderResourceView* GetTexture(TextureType type, int index) const;
|
ID3D11ShaderResourceView* GetTexture(TextureType type, int index) const;
|
||||||
|
|
||||||
//bool ChangeTexture(ID3D11Device* device, ID3D11DeviceContext* deviceContext, std::wstring filename, int index);
|
//bool ChangeTexture(ID3D11Device* device, ID3D11DeviceContext* deviceContext, std::wstring filename, int index);
|
||||||
bool ChangeTexture(ID3D11Device* device, ID3D11DeviceContext* deviceContext,std::wstring filename, TextureType type, int index);
|
bool ChangeTexture(ID3D11Device* device, ID3D11DeviceContext* deviceContext,std::wstring filename, TextureType type, int index);
|
||||||
|
|
||||||
@ -227,7 +231,11 @@ public:
|
|||||||
TextureContainer GetTextureContainer() const { return m_Textures; }
|
TextureContainer GetTextureContainer() const { return m_Textures; }
|
||||||
|
|
||||||
bool PreloadTextures(ID3D11Device* device, ID3D11DeviceContext* deviceContext, TextureContainer& textureContainer);
|
bool PreloadTextures(ID3D11Device* device, ID3D11DeviceContext* deviceContext, TextureContainer& textureContainer);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
int m_vertexCount, m_indexCount;
|
||||||
|
ID3D11Buffer* m_vertexBuffer, * m_indexBuffer;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool InitializeBuffers(ID3D11Device*);
|
bool InitializeBuffers(ID3D11Device*);
|
||||||
void ShutdownBuffers();
|
void ShutdownBuffers();
|
||||||
@ -243,8 +251,6 @@ private:
|
|||||||
void CalculateModelVectors();
|
void CalculateModelVectors();
|
||||||
void CalculateTangentBinormal(TempVertexType, TempVertexType, TempVertexType, VectorType&, VectorType&);
|
void CalculateTangentBinormal(TempVertexType, TempVertexType, TempVertexType, VectorType&, VectorType&);
|
||||||
|
|
||||||
ID3D11Buffer* m_vertexBuffer, * m_indexBuffer;
|
|
||||||
int m_vertexCount, m_indexCount;
|
|
||||||
TextureContainer m_Textures;
|
TextureContainer m_Textures;
|
||||||
ModelType* m_model;
|
ModelType* m_model;
|
||||||
};
|
};
|
||||||
|
@ -50,6 +50,7 @@ public:
|
|||||||
|
|
||||||
XMVECTOR GetPosition();
|
XMVECTOR GetPosition();
|
||||||
XMVECTOR GetRotation();
|
XMVECTOR GetRotation();
|
||||||
|
void Render(ID3D11DeviceContext* deviceContext);
|
||||||
XMVECTOR GetScale();
|
XMVECTOR GetScale();
|
||||||
|
|
||||||
void SetVelocity(XMVECTOR);
|
void SetVelocity(XMVECTOR);
|
||||||
@ -63,7 +64,8 @@ public:
|
|||||||
bool IsGrounded() const;
|
bool IsGrounded() const;
|
||||||
bool IsPhysicsEnabled() const;
|
bool IsPhysicsEnabled() const;
|
||||||
void SetPhysicsEnabled(bool state);
|
void SetPhysicsEnabled(bool state);
|
||||||
|
void SetVisible (bool state) { m_isVisible = state; }
|
||||||
|
bool IsVisible() const { return m_isVisible; }
|
||||||
|
|
||||||
void UpdateWorldMatrix();
|
void UpdateWorldMatrix();
|
||||||
void UpdateSRMatrix();
|
void UpdateSRMatrix();
|
||||||
@ -100,6 +102,12 @@ public:
|
|||||||
void LaunchObject();
|
void LaunchObject();
|
||||||
bool LoadTexturesFromPath(std::vector<std::wstring>& texturePaths, TextureContainer& texturesContainer,
|
bool LoadTexturesFromPath(std::vector<std::wstring>& texturePaths, TextureContainer& texturesContainer,
|
||||||
D3DClass* m_Direct3D);
|
D3DClass* m_Direct3D);
|
||||||
|
bool SetupInstancing(ID3D11Device* device, const std::vector<XMMATRIX>& instanceTransforms);
|
||||||
|
void EnableInstancing(bool enabled);
|
||||||
|
void SetInstanceCount(int count);
|
||||||
|
bool IsInstancingEnabled() const;
|
||||||
|
int GetInstanceCount() const;
|
||||||
|
ID3D11Buffer* GetInstanceBuffer() const;
|
||||||
void SetAlpha(float alpha) { m_alpha = alpha; }
|
void SetAlpha(float alpha) { m_alpha = alpha; }
|
||||||
float GetAlpha() const { return m_alpha; }
|
float GetAlpha() const { return m_alpha; }
|
||||||
void SetInitialStretch(float initialStretch) { m_initialStretch = initialStretch; }
|
void SetInitialStretch(float initialStretch) { m_initialStretch = initialStretch; }
|
||||||
@ -128,6 +136,7 @@ private:
|
|||||||
float m_mass;
|
float m_mass;
|
||||||
bool m_isGrounded;
|
bool m_isGrounded;
|
||||||
bool m_isPhysicsEnabled;
|
bool m_isPhysicsEnabled;
|
||||||
|
bool m_isVisible;
|
||||||
|
|
||||||
std::string m_name;
|
std::string m_name;
|
||||||
ObjectType m_type = ObjectType::Unknown;
|
ObjectType m_type = ObjectType::Unknown;
|
||||||
@ -140,5 +149,9 @@ private:
|
|||||||
float m_initialStretch = 0.0f;
|
float m_initialStretch = 0.0f;
|
||||||
float m_springConstant = 10.0f;
|
float m_springConstant = 10.0f;
|
||||||
|
|
||||||
|
bool m_instancingEnabled;
|
||||||
|
int m_instanceCount;
|
||||||
|
ID3D11Buffer* m_instanceBuffer;
|
||||||
|
std::vector<XMMATRIX> m_instanceTransforms;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
@ -48,6 +48,7 @@ ApplicationClass::ApplicationClass() : m_ShouldQuit(false)
|
|||||||
TrueLightPosition = XMFLOAT3(0.0f, 0.0f, 0.0f);
|
TrueLightPosition = XMFLOAT3(0.0f, 0.0f, 0.0f);
|
||||||
m_LightModel = nullptr;
|
m_LightModel = nullptr;
|
||||||
m_renderCount = 0;
|
m_renderCount = 0;
|
||||||
|
m_drawcalls = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
ApplicationClass::~ApplicationClass()
|
ApplicationClass::~ApplicationClass()
|
||||||
@ -708,6 +709,8 @@ void ApplicationClass::Shutdown()
|
|||||||
|
|
||||||
bool ApplicationClass::Frame(InputClass* Input)
|
bool ApplicationClass::Frame(InputClass* Input)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
ResetDrawCallCount();
|
||||||
|
|
||||||
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;
|
||||||
@ -1598,7 +1601,6 @@ bool ApplicationClass::RenderPass(const std::vector<std::reference_wrapper<std::
|
|||||||
|
|
||||||
ConstructFrustum();
|
ConstructFrustum();
|
||||||
|
|
||||||
|
|
||||||
for (const auto& RenderQueue : RenderQueues)
|
for (const auto& RenderQueue : RenderQueues)
|
||||||
{
|
{
|
||||||
// Désactiver le Z-buffer si la RenderQueue est m_Skybox
|
// Désactiver le Z-buffer si la RenderQueue est m_Skybox
|
||||||
@ -1631,9 +1633,10 @@ bool ApplicationClass::RenderPass(const std::vector<std::reference_wrapper<std::
|
|||||||
// Vérifie si l'objet est dans le frustum
|
// Vérifie si l'objet est dans le frustum
|
||||||
if (!m_FrustumCulling.CheckCube(x, y, z, radius, GetFrustumTolerance()))
|
if (!m_FrustumCulling.CheckCube(x, y, z, radius, GetFrustumTolerance()))
|
||||||
{
|
{
|
||||||
|
object->SetVisible(false);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
object->SetVisible(true); // L'objet est visible
|
||||||
renderCount++;
|
renderCount++;
|
||||||
|
|
||||||
scaleMatrix = object->GetScaleMatrix();
|
scaleMatrix = object->GetScaleMatrix();
|
||||||
@ -1828,6 +1831,8 @@ bool ApplicationClass::RenderPass(const std::vector<std::reference_wrapper<std::
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
IncrementDrawCallCount();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isSkybox)
|
if (isSkybox)
|
||||||
@ -2252,4 +2257,206 @@ std::wstring ApplicationClass::GetScenePath()
|
|||||||
return filepath.wstring();
|
return filepath.wstring();
|
||||||
}
|
}
|
||||||
return L"";
|
return L"";
|
||||||
|
}
|
||||||
|
|
||||||
|
int ApplicationClass::GetTotalVertexCount() const
|
||||||
|
{
|
||||||
|
int totalVertices = 0;
|
||||||
|
for (const auto& obj : m_object)
|
||||||
|
{
|
||||||
|
if (obj)
|
||||||
|
{
|
||||||
|
totalVertices += obj->GetVertexCount();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Ajoutez le nombre de sommets pour les cubes
|
||||||
|
for (const auto& cube : m_cubes)
|
||||||
|
{
|
||||||
|
if (cube)
|
||||||
|
{
|
||||||
|
totalVertices += cube->GetVertexCount();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Ajoutez le nombre de sommets pour le terrain
|
||||||
|
for (const auto& chunk : m_terrainChunk)
|
||||||
|
{
|
||||||
|
if (chunk)
|
||||||
|
{
|
||||||
|
totalVertices += chunk->GetVertexCount();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return totalVertices;
|
||||||
|
}
|
||||||
|
|
||||||
|
int ApplicationClass::GetTotalTriangleCount() const
|
||||||
|
{
|
||||||
|
int totalTriangles = 0;
|
||||||
|
for (const auto& obj : m_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 : m_cubes)
|
||||||
|
{
|
||||||
|
if (cube)
|
||||||
|
{
|
||||||
|
totalTriangles += cube->GetIndexCount() / 3;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Ajoutez le nombre de triangles pour le terrain
|
||||||
|
for (const auto& chunk : m_terrainChunk)
|
||||||
|
{
|
||||||
|
if (chunk)
|
||||||
|
{
|
||||||
|
totalTriangles += chunk->GetIndexCount() / 3;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return totalTriangles;
|
||||||
|
}
|
||||||
|
|
||||||
|
int ApplicationClass::GetVisibleTriangleCount() const
|
||||||
|
{
|
||||||
|
int visibleTriangles = 0;
|
||||||
|
for (const auto& obj : m_object)
|
||||||
|
{
|
||||||
|
if (obj && obj->IsVisible())
|
||||||
|
{
|
||||||
|
visibleTriangles += obj->GetIndexCount() / 3;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Ajoutez le nombre de triangles visibles pour les cubes
|
||||||
|
for (const auto& cube : m_cubes)
|
||||||
|
{
|
||||||
|
if (cube && cube->IsVisible())
|
||||||
|
{
|
||||||
|
visibleTriangles += cube->GetIndexCount() / 3;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Ajoutez le nombre de triangles visibles pour le terrain
|
||||||
|
for (const auto& chunk : m_terrainChunk)
|
||||||
|
{
|
||||||
|
if (chunk && chunk->IsVisible())
|
||||||
|
{
|
||||||
|
visibleTriangles += chunk->GetIndexCount() / 3;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return visibleTriangles;
|
||||||
|
}
|
||||||
|
|
||||||
|
int ApplicationClass::GetCurrentFps() const
|
||||||
|
{
|
||||||
|
return m_Fps->GetFps();
|
||||||
|
}
|
||||||
|
|
||||||
|
int ApplicationClass::GetMinFps() const
|
||||||
|
{
|
||||||
|
return m_Fps->GetMinFps();
|
||||||
|
}
|
||||||
|
|
||||||
|
int ApplicationClass::GetMaxFps() const
|
||||||
|
{
|
||||||
|
return m_Fps->GetMaxFps();
|
||||||
|
}
|
||||||
|
|
||||||
|
float ApplicationClass::GetFrameTime() const
|
||||||
|
{
|
||||||
|
return m_Fps->GetFrameTime();
|
||||||
|
}
|
||||||
|
|
||||||
|
int ApplicationClass::GetDrawCalls() const
|
||||||
|
{
|
||||||
|
return m_drawcalls;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ApplicationClass::ResetFpsStats()
|
||||||
|
{
|
||||||
|
m_Fps->ResetStats();
|
||||||
|
}
|
||||||
|
|
||||||
|
void ApplicationClass::IncrementDrawCallCount()
|
||||||
|
{
|
||||||
|
m_drawcalls++;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ApplicationClass::ResetDrawCallCount()
|
||||||
|
{
|
||||||
|
m_drawcalls = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ApplicationClass::CreateBigCube(int sideCount)
|
||||||
|
{
|
||||||
|
Logger::Get().Log("Génération du terrain avec instanciation", __FILE__, __LINE__, Logger::LogLevel::Info);
|
||||||
|
|
||||||
|
// Nettoyer les objets terrain existants pour éviter les fuites
|
||||||
|
for (auto* chunk : m_terrainChunk)
|
||||||
|
{
|
||||||
|
if (chunk)
|
||||||
|
{
|
||||||
|
chunk->Shutdown();
|
||||||
|
delete chunk;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
m_terrainChunk.clear();
|
||||||
|
|
||||||
|
// Dimensions du terrain
|
||||||
|
float scaleX = 1.0f;
|
||||||
|
float scaleY = 1.0f;
|
||||||
|
float scaleZ = 1.0f;
|
||||||
|
|
||||||
|
// Créer un conteneur de textures partagé
|
||||||
|
TextureContainer textureContainer;
|
||||||
|
textureContainer.diffusePaths.push_back(L"assets/Texture/Bricks2K.png");
|
||||||
|
textureContainer.normalPaths.push_back(L"assets/Texture/BricksNRM2K.png");
|
||||||
|
textureContainer.specularPaths.push_back(L"assets/Texture/BricksGLOSS2K.png");
|
||||||
|
|
||||||
|
// Précharger les textures une seule fois
|
||||||
|
ModelClass* sharedModel = new ModelClass();
|
||||||
|
sharedModel->PreloadTextures(m_Direct3D->GetDevice(), m_Direct3D->GetDeviceContext(), textureContainer);
|
||||||
|
|
||||||
|
char modelFilename[128];
|
||||||
|
strcpy_s(modelFilename, "assets/Model/TXT/cube.txt");
|
||||||
|
|
||||||
|
// Générer les tuiles de terrain
|
||||||
|
for (int i = 0; i < sideCount; i++)
|
||||||
|
{
|
||||||
|
for (int j = 0; j < sideCount; j++)
|
||||||
|
{
|
||||||
|
|
||||||
|
for (int k = 0; k < sideCount; k++)
|
||||||
|
{
|
||||||
|
// Créer un nouvel objet de terrain
|
||||||
|
Object* terrain = new Object();
|
||||||
|
|
||||||
|
// Initialiser avec le modèle et les textures préchargées
|
||||||
|
if (!terrain->Initialize(m_Direct3D->GetDevice(), m_Direct3D->GetDeviceContext(), modelFilename, textureContainer))
|
||||||
|
{
|
||||||
|
Logger::Get().Log("Échec de l'initialisation d'une tuile de terrain", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||||
|
delete terrain;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Définir la position dans la grille
|
||||||
|
XMFLOAT3 position(i * scaleX, k * scaleY, j * scaleZ);
|
||||||
|
XMFLOAT3 scale(scaleX, scaleY, scaleZ);
|
||||||
|
|
||||||
|
terrain->SetPosition(XMLoadFloat3(&position));
|
||||||
|
terrain->SetScale(XMLoadFloat3(&scale));
|
||||||
|
|
||||||
|
// Configurer les propriétés
|
||||||
|
terrain->SetName("TerrainTile_" + std::to_string(i) + "_" + std::to_string(j));
|
||||||
|
terrain->SetType(ObjectType::Cube);
|
||||||
|
terrain->SetActiveShader(ShaderType::TEXTURE);
|
||||||
|
terrain->SetId(m_ObjectId++);
|
||||||
|
|
||||||
|
// Ajouter à la liste des chunks de terrain
|
||||||
|
m_terrainChunk.push_back(terrain);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Logger::Get().Log("Terrain généré avec " + std::to_string(m_terrainChunk.size()) + " tuiles", __FILE__, __LINE__, Logger::LogLevel::Info);
|
||||||
}
|
}
|
@ -19,27 +19,63 @@ void FpsClass::Initialize()
|
|||||||
{
|
{
|
||||||
m_fps = 0;
|
m_fps = 0;
|
||||||
m_count = 0;
|
m_count = 0;
|
||||||
|
m_minFps = INT_MAX;
|
||||||
m_startTime = timeGetTime();
|
m_maxFps = 0;
|
||||||
|
m_frameTime = 0.0f;
|
||||||
|
m_previousTime = timeGetTime();
|
||||||
|
m_startTime = m_previousTime;
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
void FpsClass::Frame()
|
void FpsClass::Frame()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
unsigned int currentTime = timeGetTime();
|
||||||
|
|
||||||
|
m_frameTime = (currentTime - m_previousTime) * 0.001f;
|
||||||
|
m_previousTime = currentTime;
|
||||||
|
|
||||||
m_count++;
|
m_count++;
|
||||||
|
|
||||||
if (timeGetTime() >= (m_startTime + 1000))
|
if (timeGetTime() >= (m_startTime + 1000))
|
||||||
{
|
{
|
||||||
m_fps = m_count;
|
m_fps = m_count;
|
||||||
m_count = 0;
|
|
||||||
|
|
||||||
|
if (m_fps < m_minFps)
|
||||||
|
m_minFps = m_fps;
|
||||||
|
|
||||||
|
if (m_fps > m_maxFps)
|
||||||
|
m_maxFps = m_fps;
|
||||||
|
|
||||||
|
m_count = 0;
|
||||||
m_startTime = timeGetTime();
|
m_startTime = timeGetTime();
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int FpsClass::GetMinFps() const
|
||||||
|
{
|
||||||
|
return m_minFps;
|
||||||
|
}
|
||||||
|
|
||||||
|
int FpsClass::GetMaxFps() const
|
||||||
|
{
|
||||||
|
return m_maxFps;
|
||||||
|
}
|
||||||
|
|
||||||
|
float FpsClass::GetFrameTime() const
|
||||||
|
{
|
||||||
|
return m_frameTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
void FpsClass::ResetStats()
|
||||||
|
{
|
||||||
|
m_minFps = INT_MAX;
|
||||||
|
m_maxFps = 0;
|
||||||
|
}
|
||||||
|
|
||||||
int FpsClass::GetFps()
|
int FpsClass::GetFps()
|
||||||
{
|
{
|
||||||
return m_fps;
|
return m_fps;
|
||||||
|
@ -4,6 +4,13 @@
|
|||||||
imguiManager::imguiManager()
|
imguiManager::imguiManager()
|
||||||
{
|
{
|
||||||
io = nullptr;
|
io = nullptr;
|
||||||
|
m_frameTimeHistoryIndex = 0;
|
||||||
|
|
||||||
|
// Initialiser l'historique des frametimes à zéro
|
||||||
|
for (int i = 0; i < FRAME_HISTORY_COUNT; i++)
|
||||||
|
{
|
||||||
|
m_frameTimeHistory[i] = 0.0f;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
imguiManager::~imguiManager()
|
imguiManager::~imguiManager()
|
||||||
@ -94,6 +101,7 @@ void imguiManager::SetupDockspace(ApplicationClass* app) {
|
|||||||
ImGui::MenuItem("Light Window", NULL, &showLightWindow);
|
ImGui::MenuItem("Light Window", NULL, &showLightWindow);
|
||||||
ImGui::MenuItem("Engine Settings Window", NULL, &showEngineSettingsWindow);
|
ImGui::MenuItem("Engine Settings Window", NULL, &showEngineSettingsWindow);
|
||||||
ImGui::MenuItem("Log Window", NULL, &showLogWindow);
|
ImGui::MenuItem("Log Window", NULL, &showLogWindow);
|
||||||
|
ImGui::MenuItem("Render Stats", NULL, &showStatsWindow);
|
||||||
ImGui::EndMenu();
|
ImGui::EndMenu();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -134,11 +142,6 @@ void imguiManager::WidgetButton()
|
|||||||
ImGui::Text("counter = %d", counter);
|
ImGui::Text("counter = %d", counter);
|
||||||
}
|
}
|
||||||
|
|
||||||
void imguiManager::WidgetFPS()
|
|
||||||
{
|
|
||||||
ImGui::Text("Application average %.3f ms/frame (%.1f FPS)", 1000.0f / io->Framerate, io->Framerate);
|
|
||||||
}
|
|
||||||
|
|
||||||
void imguiManager::WidgetAddObject(ApplicationClass* app)
|
void imguiManager::WidgetAddObject(ApplicationClass* app)
|
||||||
{
|
{
|
||||||
if (ImGui::CollapsingHeader("Objects"))
|
if (ImGui::CollapsingHeader("Objects"))
|
||||||
@ -529,18 +532,36 @@ void imguiManager::WidgetTerrainWindow(ApplicationClass* app)
|
|||||||
|
|
||||||
ImGui::Separator();
|
ImGui::Separator();
|
||||||
|
|
||||||
if (ImGui::Button("Generate Terrain"))
|
if (ImGui::Button("Generate Flat Terrain"))
|
||||||
{
|
{
|
||||||
app->GenerateTerrain();
|
app->GenerateTerrain();
|
||||||
}
|
}
|
||||||
|
|
||||||
ImGui::SameLine();
|
ImGui::Separator();
|
||||||
|
|
||||||
|
// int input area for the number of cubes
|
||||||
|
static int numCubes = 10;
|
||||||
|
ImGui::InputInt("Number of Cubes", &numCubes);
|
||||||
|
if (numCubes < 1)
|
||||||
|
{
|
||||||
|
numCubes = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
ImGui::Separator();
|
||||||
|
|
||||||
|
if (ImGui::Button("Generate Big Cube Terrain"))
|
||||||
|
{
|
||||||
|
app->CreateBigCube(numCubes);
|
||||||
|
}
|
||||||
|
|
||||||
|
ImGui::Separator();
|
||||||
|
|
||||||
if (ImGui::Button("Delete All Terrain Cubes"))
|
if (ImGui::Button("Delete All Terrain Cubes"))
|
||||||
{
|
{
|
||||||
app->DeleteTerrain();
|
app->DeleteTerrain();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
ImGui::End();
|
ImGui::End();
|
||||||
}
|
}
|
||||||
@ -560,7 +581,7 @@ bool imguiManager::ImGuiWidgetRenderer(ApplicationClass* app)
|
|||||||
WidgetSpeedSlider(&speed);
|
WidgetSpeedSlider(&speed);
|
||||||
app->SetSpeed(speed);
|
app->SetSpeed(speed);
|
||||||
WidgetButton();
|
WidgetButton();
|
||||||
WidgetFPS();
|
// WidgetFPS();
|
||||||
WidgetAddObject(app);
|
WidgetAddObject(app);
|
||||||
|
|
||||||
ImGui::End();
|
ImGui::End();
|
||||||
@ -595,6 +616,11 @@ bool imguiManager::ImGuiWidgetRenderer(ApplicationClass* app)
|
|||||||
{
|
{
|
||||||
WidgetRenderWindow(app, ImVec2(800, 600));
|
WidgetRenderWindow(app, ImVec2(800, 600));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (showStatsWindow)
|
||||||
|
{
|
||||||
|
WidgetRenderStats(app);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//render imgui
|
//render imgui
|
||||||
@ -843,4 +869,64 @@ void imguiManager::WidgetRenderWindow(ApplicationClass* app, ImVec2 availableSiz
|
|||||||
}
|
}
|
||||||
|
|
||||||
ImGui::End();
|
ImGui::End();
|
||||||
|
}
|
||||||
|
|
||||||
|
void imguiManager::WidgetRenderStats(ApplicationClass* app)
|
||||||
|
{
|
||||||
|
ImGui::Begin("Render Stats");
|
||||||
|
|
||||||
|
// Récupérer le frametime actuel et le mettre dans l'historique
|
||||||
|
float currentFrameTime = app->GetFrameTime();
|
||||||
|
m_frameTimeHistory[m_frameTimeHistoryIndex] = currentFrameTime;
|
||||||
|
m_frameTimeHistoryIndex = (m_frameTimeHistoryIndex + 1) % FRAME_HISTORY_COUNT;
|
||||||
|
|
||||||
|
ImGui::Text("FPS: %d", app->GetCurrentFps());
|
||||||
|
ImGui::SameLine();
|
||||||
|
ImGui::Text("Min Fps: %d", app->GetMinFps());
|
||||||
|
ImGui::SameLine();
|
||||||
|
ImGui::Text("Max Fps: %d", app->GetMaxFps());
|
||||||
|
|
||||||
|
ImGui::Separator();
|
||||||
|
|
||||||
|
// Trouver les valeurs min/max pour l'échelle du graphique
|
||||||
|
float frameTimeMin = FLT_MAX;
|
||||||
|
float frameTimeMax = 0.0f;
|
||||||
|
for (int i = 0; i < FRAME_HISTORY_COUNT; i++) {
|
||||||
|
if (m_frameTimeHistory[i] > 0.0f) {
|
||||||
|
frameTimeMin = min(frameTimeMin, m_frameTimeHistory[i]);
|
||||||
|
frameTimeMax = max(frameTimeMax, m_frameTimeHistory[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// S'assurer d'avoir au moins une petite plage
|
||||||
|
if (frameTimeMax == 0.0f) frameTimeMax = 0.033f; // ~30 FPS
|
||||||
|
if (frameTimeMin == FLT_MAX) frameTimeMin = 0.0f;
|
||||||
|
|
||||||
|
// Ajouter 10% de marge pour la lisibilité
|
||||||
|
float margin = (frameTimeMax - frameTimeMin) * 0.1f;
|
||||||
|
frameTimeMin = max(0.0f, frameTimeMin - margin);
|
||||||
|
frameTimeMax += margin;
|
||||||
|
|
||||||
|
// Afficher le graphique
|
||||||
|
ImGui::Text("Frame Time: %.3f ms", currentFrameTime * 1000.0f);
|
||||||
|
ImGui::PlotLines("FrameTimeGraph", // Au lieu de chaîne vide ""
|
||||||
|
m_frameTimeHistory,
|
||||||
|
FRAME_HISTORY_COUNT,
|
||||||
|
m_frameTimeHistoryIndex,
|
||||||
|
"",
|
||||||
|
frameTimeMin,
|
||||||
|
frameTimeMax,
|
||||||
|
ImVec2(0, 80));
|
||||||
|
|
||||||
|
ImGui::Text("Draw Calls: %d", app->GetDrawCalls());
|
||||||
|
|
||||||
|
ImGui::Separator();
|
||||||
|
|
||||||
|
ImGui::Text("Statistiques de rendu:");
|
||||||
|
ImGui::Text("Vertices total: %d", app->GetTotalVertexCount());
|
||||||
|
|
||||||
|
ImGui::Text("Triangles total: %d", app->GetTotalTriangleCount());
|
||||||
|
ImGui::SameLine();
|
||||||
|
ImGui::Text("Triangles visibles: %d", app->GetVisibleTriangleCount());
|
||||||
|
|
||||||
|
ImGui::End();
|
||||||
}
|
}
|
@ -570,11 +570,6 @@ void ModelClass::ReleaseModel()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// bool ModelClass::ChangeTexture(ID3D11Device* device, ID3D11DeviceContext* deviceContext, std::wstring filename, int index) {
|
|
||||||
// // Pour compatibilité, utilise la texture diffuse par défaut
|
|
||||||
// return ChangeTexture(device, deviceContext, filename, TextureType::Diffuse, index);
|
|
||||||
// }
|
|
||||||
|
|
||||||
bool ModelClass::PreloadTextures(ID3D11Device* device, ID3D11DeviceContext* deviceContext, TextureContainer& textureContainer)
|
bool ModelClass::PreloadTextures(ID3D11Device* device, ID3D11DeviceContext* deviceContext, TextureContainer& textureContainer)
|
||||||
{
|
{
|
||||||
HRESULT hResult;
|
HRESULT hResult;
|
||||||
|
@ -18,11 +18,19 @@ Object::Object()// Initialize the reference here
|
|||||||
m_isGrounded = false;
|
m_isGrounded = false;
|
||||||
m_id = NULL;
|
m_id = NULL;
|
||||||
m_boundingRadius = 1.0f;
|
m_boundingRadius = 1.0f;
|
||||||
|
m_instancingEnabled = false;
|
||||||
|
m_instanceCount = 0;
|
||||||
|
m_instanceBuffer = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
Object::~Object()
|
Object::~Object()
|
||||||
{
|
{
|
||||||
|
// Libérer le buffer d'instances
|
||||||
|
if (m_instanceBuffer)
|
||||||
|
{
|
||||||
|
m_instanceBuffer->Release();
|
||||||
|
m_instanceBuffer = nullptr;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Object::SetScaleMatrix(XMMATRIX scaleMatrix)
|
void Object::SetScaleMatrix(XMMATRIX scaleMatrix)
|
||||||
@ -92,6 +100,44 @@ XMVECTOR Object::GetRotation()
|
|||||||
return XMVectorSet(rotationX, rotationY, rotationZ, 0.0f);
|
return XMVectorSet(rotationX, rotationY, rotationZ, 0.0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Object::Render(ID3D11DeviceContext* deviceContext)
|
||||||
|
{
|
||||||
|
unsigned int strides[2];
|
||||||
|
unsigned int offsets[2];
|
||||||
|
ID3D11Buffer* bufferPointers[2];
|
||||||
|
|
||||||
|
// Configurer les vertex et index buffers
|
||||||
|
strides[0] = sizeof(VertexType);
|
||||||
|
offsets[0] = 0;
|
||||||
|
bufferPointers[0] = m_vertexBuffer;
|
||||||
|
|
||||||
|
// Si l'instanciation est activée
|
||||||
|
if (m_instancingEnabled && m_instanceBuffer)
|
||||||
|
{
|
||||||
|
// Configurer le buffer d'instances
|
||||||
|
strides[1] = sizeof(XMMATRIX);
|
||||||
|
offsets[1] = 0;
|
||||||
|
bufferPointers[1] = m_instanceBuffer;
|
||||||
|
|
||||||
|
// Définir les deux buffers (vertex et instance) sur le pipeline
|
||||||
|
deviceContext->IASetVertexBuffers(0, 2, bufferPointers, strides, offsets);
|
||||||
|
deviceContext->IASetIndexBuffer(m_indexBuffer, DXGI_FORMAT_R32_UINT, 0);
|
||||||
|
deviceContext->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST);
|
||||||
|
|
||||||
|
// Dessiner les instances
|
||||||
|
deviceContext->DrawIndexedInstanced(m_indexCount, m_instanceCount, 0, 0, 0);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Rendu normal sans instanciation
|
||||||
|
deviceContext->IASetVertexBuffers(0, 1, bufferPointers, strides, offsets);
|
||||||
|
deviceContext->IASetIndexBuffer(m_indexBuffer, DXGI_FORMAT_R32_UINT, 0);
|
||||||
|
deviceContext->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST);
|
||||||
|
|
||||||
|
// Dessiner l'objet normalement
|
||||||
|
deviceContext->DrawIndexed(m_indexCount, 0, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
XMVECTOR Object::GetScale()
|
XMVECTOR Object::GetScale()
|
||||||
{
|
{
|
||||||
@ -389,4 +435,66 @@ bool Object::LoadTexturesFromPath(std::vector<std::wstring>& texturePaths, Textu
|
|||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Object::SetupInstancing(ID3D11Device* device, const std::vector<XMMATRIX>& instanceTransforms)
|
||||||
|
{
|
||||||
|
// Stocker les matrices de transformation
|
||||||
|
m_instanceTransforms = instanceTransforms;
|
||||||
|
m_instanceCount = static_cast<int>(instanceTransforms.size());
|
||||||
|
|
||||||
|
// Libérer le buffer d'instances existant si nécessaire
|
||||||
|
if (m_instanceBuffer)
|
||||||
|
{
|
||||||
|
m_instanceBuffer->Release();
|
||||||
|
m_instanceBuffer = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Créer le buffer d'instances
|
||||||
|
D3D11_BUFFER_DESC instanceBufferDesc;
|
||||||
|
ZeroMemory(&instanceBufferDesc, sizeof(instanceBufferDesc));
|
||||||
|
instanceBufferDesc.Usage = D3D11_USAGE_DYNAMIC;
|
||||||
|
instanceBufferDesc.ByteWidth = sizeof(XMMATRIX) * m_instanceCount;
|
||||||
|
instanceBufferDesc.BindFlags = D3D11_BIND_VERTEX_BUFFER;
|
||||||
|
instanceBufferDesc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
|
||||||
|
instanceBufferDesc.MiscFlags = 0;
|
||||||
|
instanceBufferDesc.StructureByteStride = 0;
|
||||||
|
|
||||||
|
D3D11_SUBRESOURCE_DATA instanceData;
|
||||||
|
ZeroMemory(&instanceData, sizeof(instanceData));
|
||||||
|
instanceData.pSysMem = instanceTransforms.data();
|
||||||
|
|
||||||
|
HRESULT result = device->CreateBuffer(&instanceBufferDesc, &instanceData, &m_instanceBuffer);
|
||||||
|
if (FAILED(result))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Object::EnableInstancing(bool enabled)
|
||||||
|
{
|
||||||
|
m_instancingEnabled = enabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Object::SetInstanceCount(int count)
|
||||||
|
{
|
||||||
|
m_instanceCount = count;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Ajoutez également ces méthodes pour accéder aux données d'instanciation
|
||||||
|
bool Object::IsInstancingEnabled() const
|
||||||
|
{
|
||||||
|
return m_instancingEnabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
int Object::GetInstanceCount() const
|
||||||
|
{
|
||||||
|
return m_instanceCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
ID3D11Buffer* Object::GetInstanceBuffer() const
|
||||||
|
{
|
||||||
|
return m_instanceBuffer;
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user