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.
This commit is contained in:
2025-10-10 12:46:13 +02:00
parent 00339aa6c2
commit 7c6562719f
4 changed files with 25 additions and 39 deletions

View File

@@ -25,6 +25,17 @@
class input_class class input_class
{ {
public: public:
template<typename Container>
std::vector<bool> get_key_states(const Container& key) const
{
std::vector<bool> 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();
input_class(const input_class&); input_class(const input_class&);
~input_class(); ~input_class();
@@ -48,6 +59,8 @@ public:
bool IsKeyDown(unsigned int) const; bool IsKeyDown(unsigned int) const;
bool is_key_pressed(const unsigned int); bool is_key_pressed(const unsigned int);
private: private:
bool m_keys[256]; bool m_keys[256];

View File

@@ -160,3 +160,7 @@ inline bool TestPlaneCorner(
R_FALSE; \ R_FALSE; \
} \ } \
} while (0); } while (0);
// --------------------------------------- //
// --- Macros for the input processing --- //
// --------------------------------------- //

View File

@@ -873,9 +873,6 @@ bool application_class::frame(input_class* Input)
// Update the sun camera position and rotation based on the light position. // 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_position(sun_light_->GetPosition().x, sun_light_->GetPosition().y, sun_light_->GetPosition().z);
sun_camera_->set_rotation(pitch, yaw, roll); 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(); active_camera_->render();
@@ -915,6 +912,7 @@ bool application_class::frame(input_class* Input)
result = render_refraction_to_texture(); result = render_refraction_to_texture();
if (!result) if (!result)
{ {
LOG_ERROR("Could not render the refraction texture");
R_FALSE R_FALSE
} }
@@ -922,6 +920,7 @@ bool application_class::frame(input_class* Input)
result = render_reflection_to_texture(); result = render_reflection_to_texture();
if (!result) if (!result)
{ {
LOG_ERROR("Could not render the reflection texture");
R_FALSE 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); bath_model_->GetTexture(TextureType::Diffuse,0), lights_[0]->GetDirection(), ambientColor, diffuseColor, lightPosition, clipPlane);
if (!result) if (!result)
{ {
LOG_ERROR("Could not render the bath model using the refraction shader");
R_FALSE R_FALSE
} }
@@ -1058,6 +1058,7 @@ bool application_class::render_scene_to_texture(float rotation)
model_->GetTexture(TextureType::Diffuse,0)); model_->GetTexture(TextureType::Diffuse,0));
if (!result) if (!result)
{ {
LOG_ERROR("Could not render the model using the texture shader");
R_FALSE 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]; XMFLOAT4 diffuseColor[4], lightPosition[4], ambientColor[4];
int i; int i;
bool result; bool result;
float blendAmount;
// Set the blending amount to 10%.
blendAmount = 0.1f;
// Generate the view matrix based on the camera's position. // Generate the view matrix based on the camera's position.
active_camera_->render(); 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(); projectionMatrix = direct_3d_->get_projection_matrix();
orthoMatrix = direct_3d_->get_ortho_matrix(); orthoMatrix = direct_3d_->get_ortho_matrix();
//render Sky box
//RenderSkybox(viewMatrix, projectionMatrix);
// Get the light properties. // Get the light properties.
for (i = 0; i < num_lights_; i++) 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(); 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. scaleMatrix = XMMatrixScaling(0.5f, 0.5f, 0.5f); // Build the scaling matrix.
rotateMatrix = XMMatrixRotationY(rotation); // Build the rotation matrix. rotateMatrix = XMMatrixRotationY(rotation); // Build the rotation matrix.
translateMatrix = XMMatrixTranslation(x, y, z); // Build the translation matrix. translateMatrix = XMMatrixTranslation(x, y, z); // Build the translation matrix.
@@ -1146,11 +1134,6 @@ bool application_class::render(float rotation, float x, float y, float z, float
// ------------ render the object in the queue ------------ // // ------------ 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); result = render_pass(diffuseColor, lightPosition, ambientColor, viewMatrix, projectionMatrix);
if (!result) if (!result)
{ {
@@ -1158,21 +1141,6 @@ bool application_class::render(float rotation, float x, float y, float z, float
R_FALSE 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. // Update the render count text.
result = update_render_count_string(get_render_count()); result = update_render_count_string(get_render_count());
if (!result) 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); bath_model_->GetTexture(TextureType::Diffuse,0), diffuseColor, lightPosition, ambientColor);
if (!result) if (!result)
{ {
LOG_ERROR("Bath model could not be rendered using the light shader");
R_FALSE R_FALSE
} }

View File

@@ -999,12 +999,12 @@ void imguiManager::WidgetLogWindow()
S_LINE S_LINE
// Menu d<>roulant pour les niveaux de log // 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) for (size_t i = 0; i < Logger::LogLevelCount; ++i)
{ {
bool isVisible = !Logger::Get().m_disabledLogLevels[i]; bool isVisible = !Logger::Get().m_disabledLogLevels[i];
if (ImGui::Checkbox(Logger::Get().GetLogLevelInfo(static_cast<Logger::LogLevel>(i)).name, &isVisible)) if (C_BOX(Logger::Get().GetLogLevelInfo(static_cast<Logger::LogLevel>(i)).name, &isVisible))
{ {
Logger::Get().m_disabledLogLevels[i] = !isVisible; Logger::Get().m_disabledLogLevels[i] = !isVisible;
} }