From 7c6562719ff3f7f8f10644a2b89e3e9ee81c54f8 Mon Sep 17 00:00:00 2001 From: CatChow0 Date: Fri, 10 Oct 2025 12:46:13 +0200 Subject: [PATCH] Patch - Adds utility and improves error handling - V14.5.31 Adds a utility function to retrieve key states for a given container of keys, enhancing input processing capabilities. Improves error handling by adding more logging for render failures, giving the development team better insights into potential issues and aiding debugging efforts. --- enginecustom/src/inc/system/input_class.h | 13 ++++++ enginecustom/src/inc/system/macro.h | 4 ++ .../src/src/system/application_class.cpp | 43 +++---------------- enginecustom/src/src/system/imguiManager.cpp | 4 +- 4 files changed, 25 insertions(+), 39 deletions(-) diff --git a/enginecustom/src/inc/system/input_class.h b/enginecustom/src/inc/system/input_class.h index 1777d28..7d31c9c 100644 --- a/enginecustom/src/inc/system/input_class.h +++ b/enginecustom/src/inc/system/input_class.h @@ -25,6 +25,17 @@ class input_class { public: + + template + std::vector get_key_states(const Container& key) const + { + std::vector key_states; + key_states.reserve(key.size()); + for (auto k : key) + key_states.push_back(this->is_key_pressed(k)); + return key_states; + } + input_class(); input_class(const input_class&); ~input_class(); @@ -48,6 +59,8 @@ public: bool IsKeyDown(unsigned int) const; bool is_key_pressed(const unsigned int); + + private: bool m_keys[256]; diff --git a/enginecustom/src/inc/system/macro.h b/enginecustom/src/inc/system/macro.h index 986bd4d..3b3ad0e 100644 --- a/enginecustom/src/inc/system/macro.h +++ b/enginecustom/src/inc/system/macro.h @@ -160,3 +160,7 @@ inline bool TestPlaneCorner( R_FALSE; \ } \ } while (0); + +// --------------------------------------- // +// --- Macros for the input processing --- // +// --------------------------------------- // diff --git a/enginecustom/src/src/system/application_class.cpp b/enginecustom/src/src/system/application_class.cpp index f916a3f..cb27bd5 100644 --- a/enginecustom/src/src/system/application_class.cpp +++ b/enginecustom/src/src/system/application_class.cpp @@ -873,9 +873,6 @@ bool application_class::frame(input_class* Input) // Update the sun camera position and rotation based on the light position. sun_camera_->set_position(sun_light_->GetPosition().x, sun_light_->GetPosition().y, sun_light_->GetPosition().z); sun_camera_->set_rotation(pitch, yaw, roll); - - // sun_camera_->set_position(positionX, positionY, positionZ); - // sun_camera_->set_rotation(rotationX, rotationY, 0.0f); } active_camera_->render(); @@ -915,6 +912,7 @@ bool application_class::frame(input_class* Input) result = render_refraction_to_texture(); if (!result) { + LOG_ERROR("Could not render the refraction texture"); R_FALSE } @@ -922,6 +920,7 @@ bool application_class::frame(input_class* Input) result = render_reflection_to_texture(); if (!result) { + LOG_ERROR("Could not render the reflection texture"); R_FALSE } @@ -1002,6 +1001,7 @@ bool application_class::render_refraction_to_texture() bath_model_->GetTexture(TextureType::Diffuse,0), lights_[0]->GetDirection(), ambientColor, diffuseColor, lightPosition, clipPlane); if (!result) { + LOG_ERROR("Could not render the bath model using the refraction shader"); R_FALSE } @@ -1058,6 +1058,7 @@ bool application_class::render_scene_to_texture(float rotation) model_->GetTexture(TextureType::Diffuse,0)); if (!result) { + LOG_ERROR("Could not render the model using the texture shader"); R_FALSE } @@ -1074,10 +1075,6 @@ bool application_class::render(float rotation, float x, float y, float z, float XMFLOAT4 diffuseColor[4], lightPosition[4], ambientColor[4]; int i; bool result; - float blendAmount; - - // Set the blending amount to 10%. - blendAmount = 0.1f; // Generate the view matrix based on the camera's position. active_camera_->render(); @@ -1088,9 +1085,6 @@ bool application_class::render(float rotation, float x, float y, float z, float projectionMatrix = direct_3d_->get_projection_matrix(); orthoMatrix = direct_3d_->get_ortho_matrix(); - //render Sky box - //RenderSkybox(viewMatrix, projectionMatrix); - // Get the light properties. for (i = 0; i < num_lights_; i++) { @@ -1117,12 +1111,6 @@ bool application_class::render(float rotation, float x, float y, float z, float direct_3d_->reset_viewport(); } - /// CPT ALED C'EST ICI QUE CA SE PASSE /// - - - //scene_texture_->SetRenderTarget(direct_3d_->get_device_context()); - //scene_texture_->ClearRenderTarget(direct_3d_->get_device_context(), 0.0f, 0.0f, 0.0f, 0.0f); - scaleMatrix = XMMatrixScaling(0.5f, 0.5f, 0.5f); // Build the scaling matrix. rotateMatrix = XMMatrixRotationY(rotation); // Build the rotation matrix. translateMatrix = XMMatrixTranslation(x, y, z); // Build the translation matrix. @@ -1145,12 +1133,7 @@ bool application_class::render(float rotation, float x, float y, float z, float // -------------------------------------------------------- // // ------------ render the object in the queue ------------ // // -------------------------------------------------------- // - - // set the active camera to the sun camera for rendering the shadow map. - // active_camera_ = sun_camera_; - // active_camera_->render(); - // // Render the objects in the render queues. with depth only pass. - // active_camera_->get_view_matrix(viewMatrix); + result = render_pass(diffuseColor, lightPosition, ambientColor, viewMatrix, projectionMatrix); if (!result) { @@ -1158,21 +1141,6 @@ bool application_class::render(float rotation, float x, float y, float z, float R_FALSE } - // Reset the active camera to the main camera. - // active_camera_ = camera_; - // active_camera_->render(); - // active_camera_->get_view_matrix(viewMatrix); - // - // // render the objects in the render queues. with standard pass. - // result = render_pass(render_queues_, diffuseColor, lightPosition, ambientColor, viewMatrix, projectionMatrix); - // if (!result) - // { - // LOG_ERROR("Could not render the model using any shader"); - // R_FALSE - // } - - // stats_->update_geometric_stats(); - // Update the render count text. result = update_render_count_string(get_render_count()); if (!result) @@ -1193,6 +1161,7 @@ bool application_class::render(float rotation, float x, float y, float z, float bath_model_->GetTexture(TextureType::Diffuse,0), diffuseColor, lightPosition, ambientColor); if (!result) { + LOG_ERROR("Bath model could not be rendered using the light shader"); R_FALSE } diff --git a/enginecustom/src/src/system/imguiManager.cpp b/enginecustom/src/src/system/imguiManager.cpp index acb221c..6613bfd 100644 --- a/enginecustom/src/src/system/imguiManager.cpp +++ b/enginecustom/src/src/system/imguiManager.cpp @@ -999,12 +999,12 @@ void imguiManager::WidgetLogWindow() S_LINE // Menu d�roulant pour les niveaux de log - if (ImGui::BeginMenu("Log Levels")) + if (B_MENU("Log Levels")) { for (size_t i = 0; i < Logger::LogLevelCount; ++i) { bool isVisible = !Logger::Get().m_disabledLogLevels[i]; - if (ImGui::Checkbox(Logger::Get().GetLogLevelInfo(static_cast(i)).name, &isVisible)) + if (C_BOX(Logger::Get().GetLogLevelInfo(static_cast(i)).name, &isVisible)) { Logger::Get().m_disabledLogLevels[i] = !isVisible; }