7 Commits

Author SHA1 Message Date
9aaa2786b6 Merge branch 'Shipping-Build-Overhaul' 2025-11-14 12:59:53 +01:00
e3bb138cb2 Patch - Git LFS More file type - V14.10.1 2025-11-14 12:58:23 +01:00
040d919b69 Minor - Optimise l'accès aux ressources D3D - V14.10.0
Refactorise l'accès aux interfaces Direct3D pour plus de clarté et d'efficacité, en utilisant des accesseurs `const` et en déplaçant certaines fonctions directement dans l'en-tête.

Cela simplifie l'utilisation des ressources D3D et améliore la lisibilité du code.
2025-11-02 01:22:50 +01:00
1a92ac64d7 Patch - Désactive les logs en build shipping - V
Désactive complètement les logs en build shipping
pour améliorer les performances et réduire la taille
du binaire final.
2025-10-31 19:36:48 +01:00
145a1b323f Merge branch 'ImGui-Perf-Fix' 2025-10-24 17:48:22 +02:00
2e33adf4a9 Minor - Améliore la gestion des entités ImGui - V14.9.0
Optimizes entity management in ImGui by deferring updates to the entity list until necessary.

Changes include:
- Sets the entity list as dirty upon adding or deleting entities to ensure the list is only updated when needed
- Changes the type of entity ID stored in CachedEntity
- Adjusts ImGui window size
2025-10-24 17:47:54 +02:00
c67a805bd7 Minor - Améliore la gestion des entités ImGui - V14.8.0
Optimizes entity list updates in the ImGui interface by caching entity names and IDs.

This reduces unnecessary string operations during rendering and improves performance, especially when dealing with a large number of entities.

The initial ImGui window size has also been reduced for performance reasons.
2025-10-24 12:00:26 +02:00
51 changed files with 124 additions and 15406 deletions

8
.gitattributes vendored
View File

@@ -8,3 +8,11 @@ x64/Debug/lua54.dll filter=lfs diff=lfs merge=lfs -text
x64/Release/lua54.dll filter=lfs diff=lfs merge=lfs -text
x64/Debug/config.txt filter=lfs diff=lfs merge=lfs -text
x64/Release/config.txt filter=lfs diff=lfs merge=lfs -text
enginecustom/assets/Skybox/*.png filter=lfs diff=lfs merge=lfs -text
enginecustom/assets/sounds/*.mp3 filter=lfs diff=lfs merge=lfs -text
enginecustom/assets/sounds/*.opus filter=lfs diff=lfs merge=lfs -text
enginecustom/assets/Texture/*.png filter=lfs diff=lfs merge=lfs -text
enginecustom/assets/Texture/*.jpg filter=lfs diff=lfs merge=lfs -text
enginecustom/assets/Texture/*.tga filter=lfs diff=lfs merge=lfs -text
enginecustom/assets/Model/TXT/* filter=lfs diff=lfs merge=lfs -text
enginecustom/assets/Model/OBJ/* filter=lfs diff=lfs merge=lfs -text

BIN
enginecustom/assets/Model/TXT/bath.txt (Stored with Git LFS)

Binary file not shown.

BIN
enginecustom/assets/Model/TXT/chunk.txt (Stored with Git LFS)

Binary file not shown.

BIN
enginecustom/assets/Model/TXT/cube.txt (Stored with Git LFS)

Binary file not shown.

BIN
enginecustom/assets/Model/TXT/ground.txt (Stored with Git LFS)

Binary file not shown.

BIN
enginecustom/assets/Model/TXT/plane.txt (Stored with Git LFS)

Binary file not shown.

File diff suppressed because it is too large Load Diff

BIN
enginecustom/assets/Model/TXT/square.txt (Stored with Git LFS)

Binary file not shown.

BIN
enginecustom/assets/Model/TXT/wall.txt (Stored with Git LFS)

Binary file not shown.

BIN
enginecustom/assets/Model/TXT/water.txt (Stored with Git LFS)

Binary file not shown.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 MiB

After

Width:  |  Height:  |  Size: 133 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 331 KiB

After

Width:  |  Height:  |  Size: 131 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 273 KiB

After

Width:  |  Height:  |  Size: 131 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 493 KiB

After

Width:  |  Height:  |  Size: 131 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 510 KiB

After

Width:  |  Height:  |  Size: 131 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 498 KiB

After

Width:  |  Height:  |  Size: 131 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 422 KiB

After

Width:  |  Height:  |  Size: 131 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.5 MiB

After

Width:  |  Height:  |  Size: 132 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.1 MiB

After

Width:  |  Height:  |  Size: 132 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.4 MiB

After

Width:  |  Height:  |  Size: 132 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 81 KiB

After

Width:  |  Height:  |  Size: 130 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 128 KiB

After

Width:  |  Height:  |  Size: 131 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 588 KiB

After

Width:  |  Height:  |  Size: 131 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.5 KiB

After

Width:  |  Height:  |  Size: 129 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.6 MiB

After

Width:  |  Height:  |  Size: 132 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 164 KiB

After

Width:  |  Height:  |  Size: 131 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.7 MiB

After

Width:  |  Height:  |  Size: 132 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.9 MiB

After

Width:  |  Height:  |  Size: 132 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 599 KiB

After

Width:  |  Height:  |  Size: 131 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 148 KiB

After

Width:  |  Height:  |  Size: 131 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.6 KiB

After

Width:  |  Height:  |  Size: 129 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.6 KiB

After

Width:  |  Height:  |  Size: 129 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.6 KiB

After

Width:  |  Height:  |  Size: 129 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.6 KiB

After

Width:  |  Height:  |  Size: 129 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 917 KiB

After

Width:  |  Height:  |  Size: 131 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.0 MiB

After

Width:  |  Height:  |  Size: 132 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 934 KiB

After

Width:  |  Height:  |  Size: 131 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.8 MiB

After

Width:  |  Height:  |  Size: 132 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 161 KiB

After

Width:  |  Height:  |  Size: 131 B

View File

@@ -22,15 +22,15 @@ DockId=0x00000009,0
[Window][Objects]
Pos=0,19
Size=251,774
Size=15,22
Collapsed=0
DockId=0x0000000B,1
DockId=0x0000000B,0
[Window][Terrain]
Pos=0,19
Size=251,774
Size=15,22
Collapsed=0
DockId=0x0000000B,0
DockId=0x0000000B,1
[Window][Log Window]
Pos=0,630

View File

@@ -75,20 +75,20 @@ public:
*
* @return Pointer to the ID3D11Device interface.
*/
ID3D11Device* get_device();
ID3D11Device* get_device() const { return device_; };
/**
* @brief Gets the Direct3D device context.
*
* @return Pointer to the ID3D11DeviceContext interface.
*/
ID3D11DeviceContext* get_device_context();
ID3D11DeviceContext* get_device_context() const { return device_context_; };
//XMMATRIX get_projection_matrix(XMMATRIX& projectionMatrix);
IDXGISwapChain* swap_chain;
/**
* Get the swap chain associated with the Direct3D device.
* @return Pointer to the IDXGISwapChain interface.
*/
IDXGISwapChain* get_swap_chain();
IDXGISwapChain* get_swap_chain() const { return swap_chain; };
/**
* Resizes the swap chain to the specified width and height.
* @param width New width of the swap chain.
@@ -100,7 +100,7 @@ public:
*
* @param vsync True to enable vertical sync, false to disable.
*/
void set_vsync(bool vsync);
void set_vsync(bool vsync) { vsync_enabled_ = vsync; };
/**
* Get the projection matrix.
@@ -135,7 +135,10 @@ public:
/**
* Resets the viewport to the default settings.
*/
void reset_viewport();
void reset_viewport() const
{
device_context_->RSSetViewports(1, &viewport_);
}
/**
* Release all Direct3D resources.
@@ -151,11 +154,17 @@ public:
/**
* Turn on the Z-buffer to enable depth.
*/
void turn_z_buffer_on();
void turn_z_buffer_on()const
{
device_context_->OMSetDepthStencilState(depth_stencil_state_, 1);
}
/**
* Turn off the Z-buffer to disable depth.
*/
void turn_z_buffer_off();
void turn_z_buffer_off() const
{
device_context_->OMSetDepthStencilState(depth_disabled_stencil_state_, 1);
}
/**
* Turn on alpha blending for transparency effects.

View File

@@ -39,6 +39,12 @@ struct ComponentEntry {
std::function<void()> addFunc;
};
struct CachedEntity
{
std::string name;
int id;
};
class imguiManager
{
public:
@@ -175,6 +181,10 @@ private:
// --------------------------------------------- //
// ----------------- Functions ----------------- //
// --------------------------------------------- //
/**
* Update the cached entity list if there is a new, delete or rename entity
*/
void UpdateCachedEntitiesIfNeeded();
// --------------------------------------------- //
// ----------------- Variables ----------------- //
@@ -232,6 +242,8 @@ private:
std::string version_driver_;
ecs::EntityID m_selected_entity_id = 0; // ID of the currently selected entity
std::vector<CachedEntity> cachedEntities_;
bool entityListDirty = true;
int BUILD_VERSION_VER = -1;
};

View File

@@ -44,6 +44,7 @@ inline int size_t_to_int(size_t x)
// --- Macros for logging with different severity levels --- //
// --------------------------------------------------------- //
#ifdef _DEBUG
#define LOG(msg, level) Logger::Get().Log(msg, __FILE__, __LINE__, level)
#define LOG_INFO(msg) Logger::Get().Log(msg, __FILE__, __LINE__, Logger::LogLevel::Info)
#define LOG_WARNING(msg) Logger::Get().Log(msg, __FILE__, __LINE__, Logger::LogLevel::Warning)
@@ -58,6 +59,20 @@ inline int size_t_to_int(size_t x)
return false; \
}
#else
#define LOG(msg, level) ((void)0)
#define LOG_INFO(msg) ((void)0)
#define LOG_WARNING(msg)((void)0)
#define LOG_ERROR(msg) ((void)0)
#define LOG_DEBUG(msg) ((void)0)
#define LOG_SHUTDOWN(msg) ((void)0)
#define LOG_INIT(msg) ((void)0)
#define R_LOG_ERROR(result,msg) ((void)0);
#endif
// ---------------------------------------------------- //
// --- Macros for the Entity Component System (ECS) --- //
// ---------------------------------------------------- //

View File

@@ -3,8 +3,6 @@
#define WIN32_LEAN_AND_MEAN
static bool DEBUG_MODE = true;
#include "Logger.h"
#include "input_class.h"

View File

@@ -555,21 +555,9 @@ void d_3d_class::end_scene()
return;
}
ID3D11Device* d_3d_class::get_device()
void d_3d_class::get_video_card_info(char* description, int& memory)
{
return device_;
}
ID3D11DeviceContext* d_3d_class::get_device_context()
{
return device_context_;
}
void d_3d_class::get_video_card_info(char* cardName, int& memory)
{
strcpy_s(cardName, 128, video_card_description_);
strcpy_s(description, 128, video_card_description_);
memory = video_card_memory_;
return;
}
@@ -583,15 +571,6 @@ void d_3d_class::set_back_buffer_render_target()
return;
}
void d_3d_class::reset_viewport()
{
// Set the viewport.
device_context_->RSSetViewports(1, &viewport_);
return;
}
void d_3d_class::release_resources()
{
LOG_SHUTDOWN("Releasing D3D resources");
@@ -689,11 +668,6 @@ void d_3d_class::reset_resources(int newWidth, int newHeight)
device_context_->OMSetRenderTargets(1, &render_target_view_, depth_stencil_view_);
}
IDXGISwapChain* d_3d_class::get_swap_chain()
{
return swap_chain;
}
void d_3d_class::resize_swap_chain(int newWidth, int newHeight)
{
LOG_INFO("Resizing swap chain to " + std::to_string(newWidth) + "x" + std::to_string(newHeight));
@@ -721,19 +695,6 @@ void d_3d_class::resize_swap_chain(int newWidth, int newHeight)
device_context_->RSSetViewports(1, &viewport_);
}
void d_3d_class::turn_z_buffer_on()
{
device_context_->OMSetDepthStencilState(depth_stencil_state_, 1);
return;
}
void d_3d_class::turn_z_buffer_off()
{
device_context_->OMSetDepthStencilState(depth_disabled_stencil_state_, 1);
return;
}
void d_3d_class::enable_alpha_blending()
{
float blendFactor[4];
@@ -768,11 +729,6 @@ void d_3d_class::disable_alpha_blending()
return;
}
void d_3d_class::set_vsync(bool vsync)
{
vsync_enabled_ = vsync;
}
bool d_3d_class::set_projection_params(int width, int height, float screenDepth, float screenNear)
{
float fieldOfView, screenAspect;

View File

@@ -502,6 +502,8 @@ void imguiManager::WidgetAddObject()
// Remplacer les antislashs par des slashs
std::replace(relativePath.begin(), relativePath.end(), L'\\', L'/');
app_->add_kobject(relativePath);
// set entities list as dirty
entityListDirty = true;
}
}
@@ -596,32 +598,26 @@ void imguiManager::WidgetObjectWindow()
// Remplacer les antislashs par des slashs
std::replace(relativePath.begin(), relativePath.end(), L'\\', L'/');
app_->add_kobject(relativePath);
// set list as dirty since new entity has been added to the scene
entityListDirty = true;
}
}
}
S_LINE
TEXT_V("Number of cubes: %d", entity_manager_->GetEntityCount())
SEP
auto entities = entity_manager_->GetAllEntities();
UpdateCachedEntitiesIfNeeded();
ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing,ImVec2(4,2));
for (auto& entity : entities)
for (auto& cachedEntitie : cachedEntities_)
{
auto identity = entity->GetComponent<ecs::IdentityComponent>();
if (identity)
bool isSelected = (cachedEntitie.id == m_selected_entity_id);
if (SEL(cachedEntitie.name.c_str(), isSelected))
{
std::string name = identity->GetName();
if (name.empty()) name = "Entity #" + std::to_string(identity->GetId());
// avoid same label by adding the ID at the end
name += "##" + std::to_string(identity->GetId());
bool isSelected = (entity->GetID() == m_selected_entity_id);
if (SEL(name.c_str(), isSelected))
{
m_selected_entity_id = entity->GetID();
show_inspector_window_ = true;
}
m_selected_entity_id = cachedEntitie.id;
show_inspector_window_ = true;
}
}
@@ -668,6 +664,7 @@ void imguiManager::WidgetInspectorWindow()
entity_manager_->DestroyEntity(m_selected_entity_id);
m_selected_entity_id = -1;
show_inspector_window_ = false;
entityListDirty = true;
}
S_LINE
@@ -1223,3 +1220,19 @@ void imguiManager::WidgetRenderStats()
END
}
void imguiManager::UpdateCachedEntitiesIfNeeded() {
if (!entityListDirty) return;
cachedEntities_.clear();
auto entities = entity_manager_->GetAllEntities();
for (auto& entity : entities) {
auto identity = entity->GetComponent<ecs::IdentityComponent>();
if (identity) {
std::string name = identity->GetName();
auto id = identity->GetId();
if (name.empty())
name = "Entity " + std::to_string(identity->GetId());
cachedEntities_.push_back({name,id});
}
}
entityListDirty = false;
}

View File

@@ -61,17 +61,16 @@ bool system_class::initialize()
application_->get_direct_3d()->resize_swap_chain(initial_window_width_, initial_window_height_);
}
#ifdef _DEBUG
// initialize imgui
if(DEBUG_MODE)
imgui_manager_ = std::make_shared<imguiManager>();
imgui_manager_->SetApp(application_);
result = imgui_manager_->Initialize(hwnd_, application_->get_direct_3d()->get_device(), application_->get_direct_3d()->get_device_context());
if (!result)
{
imgui_manager_ = std::make_shared<imguiManager>();
imgui_manager_->SetApp(application_);
result = imgui_manager_->Initialize(hwnd_, application_->get_direct_3d()->get_device(), application_->get_direct_3d()->get_device_context());
if (!result)
{
R_FALSE
}
R_FALSE
}
#endif
}
catch (const std::exception& e)
@@ -177,19 +176,8 @@ bool system_class::frame()
R_FALSE
}
if(!input_->IsKeyDown(222))
{
//log the key press
is_debug_key_pressed_ = false;
}
else if (input_->IsKeyDown(222) && !is_debug_key_pressed_)
{
// Log the key release state
is_debug_key_pressed_ = true;
DEBUG_MODE = !DEBUG_MODE;
}
if (DEBUG_MODE)
#ifdef _DEBUG
if (input_->IsKeyDown(DIK_F1))
{
// render ImGui
result = imgui_manager_->ImGuiWidgetRenderer();
@@ -199,6 +187,7 @@ bool system_class::frame()
R_FALSE
}
}
#endif
application_->get_direct_3d()->end_scene();

BIN
x64/Debug/config.txt (Stored with Git LFS)

Binary file not shown.

BIN
x64/Release/config.txt (Stored with Git LFS)

Binary file not shown.