Patch - Improves code and UI for better engine stability - V14.5.30

Addresses minor issues across the engine to improve stability and UI.

- Updates ImGui window size for better rendering
- Adds macro for boolean returns (R_TRUE and R_FALSE)
- Adds missing includes and removes unused code
- Updates shader code to use the new macros and improve readability
This commit is contained in:
2025-10-10 00:32:19 +02:00
parent 2b8e222d7c
commit 00339aa6c2
60 changed files with 1064 additions and 1022 deletions

View File

@@ -55,7 +55,7 @@ public:
* @param data The string data to deserialize from.
* @return True if deserialization was successful, otherwise false.
*/
virtual bool Deserialize(const std::string& data) { return false;}
virtual bool Deserialize(const std::string& data) { R_FALSE}
/**
* Virtual function to render ImGui controls for the component.

View File

@@ -77,7 +77,7 @@ public:
bool Load(const std::string& path) {
if (!m_system) {
Initialize();
if (!m_system) return false;
if (!m_system) R_FALSE
}
LOG_INFO("Loading audio file: " + path);
@@ -87,7 +87,7 @@ public:
if (!std::filesystem::exists(path)) {
m_lastError = "Fichier non trouv<75>: " + path;
LOG_ERROR(m_lastError);
return false;
R_FALSE
}
if (m_sound) {
@@ -110,10 +110,10 @@ public:
m_lastError = "<EFBFBD>chec du chargement du son: " + std::to_string(result) +
" (chemin: " + absolutePath.string() + ")";
LOG_ERROR(m_lastError);
return false;
R_FALSE
}
return true;
R_TRUE
}
/**
@@ -495,7 +495,7 @@ public:
std::stringstream ss(data);
std::string type;
std::getline(ss, type, ':');
if (type != "AudioComponent") return false;
if (type != "AudioComponent") R_FALSE
std::string s_volume, s_pan, s_pitch, s_looping, s_muted, s_paused, s_priority, s_spatialized, s_use_velocity;
@@ -525,7 +525,7 @@ public:
Load(m_soundPath);
}
return true;
R_TRUE
}
private:

View File

@@ -119,7 +119,7 @@ public:
std::string type;
std::getline(ss, type, ':');
if (type != "IdentityComponent") return false;
if (type != "IdentityComponent") R_FALSE
std::string token, name, objectTypeStr;
int id;
@@ -131,7 +131,7 @@ public:
SetId(id);
SetName(name);
SetType(StringToObjectType(objectTypeStr));
return true;
R_TRUE
}
void OnImGuiRender() override {

View File

@@ -65,7 +65,7 @@ private:
bool CreateScriptFile() {
if (strlen(scriptNameBuffer) == 0)
return false;
R_FALSE
scriptName = scriptNameBuffer;
if (scriptName.length() < 4 || scriptName.substr(scriptName.length() - 4) != ".lua") {
@@ -81,19 +81,19 @@ private:
std::filesystem::create_directories(scriptFolder, ec);
if (ec) {
// Log erreur
return false;
R_FALSE
}
std::string fullPath = scriptFolder + scriptName;
// Cr<43>er un fichier script vide ou template simple
std::ofstream ofs(fullPath);
if (!ofs) return false;
if (!ofs) R_FALSE
ofs << "-- Script Lua vide pour ECS\n\nfunction on_update(dt)\n -- Code ici\nend\n";
ofs.close();
return true;
R_TRUE
}
};

View File

@@ -46,13 +46,13 @@ public:
std::string type;
std::getline(ss, type, ':');
if (type != "ModelPathComponent") return false;
if (type != "ModelPathComponent") R_FALSE
std::string modelPath;
std::getline(ss, modelPath);
SetPath(std::wstring(modelPath.begin(), modelPath.end()));
return true;
R_TRUE
}
void OnImGuiRender() override {

View File

@@ -213,7 +213,7 @@ public:
std::string type;
std::getline(ss, type, ':');
if (type != "PhysicsComponent") return false;
if (type != "PhysicsComponent") R_FALSE
std::string token;
float mass, boundingRadius;
@@ -230,7 +230,7 @@ public:
SetPhysicsEnabled(physicsEnabled);
SetGravityEnabled(gravityEnabled);
SetGrounded(isGrounded);
return true;
R_TRUE
}
void OnImGuiRender() override {

View File

@@ -48,9 +48,9 @@ public:
* @return True if initialization was successful, false otherwise.
*/
bool InitializeWithModel(std::shared_ptr<model_class> model) {
if (!model) return false;
if (!model) R_FALSE
m_model = model;
return true;
R_TRUE
}
/**
@@ -73,14 +73,14 @@ public:
// Cr<43>er un nouveau mod<6F>le
auto new_model = std::make_shared<model_class>();
if (!new_model->Initialize(device, deviceContext, const_cast<char*>(modelFilename), textureContainer)) {
return false;
R_FALSE
}
g_model_cache[filename] = new_model;
m_model = new_model;
}
m_modelFilePath = modelFilename;
return true;
R_TRUE
}
/**
@@ -101,13 +101,13 @@ public:
ID3D11ShaderResourceView* texture = nullptr;
result = DirectX::CreateWICTextureFromFile(device, deviceContext, texturePath.c_str(), nullptr, &texture);
if (FAILED(result)) {
return false;
R_FALSE
}
texturesContainer.AssignTexture(texturesContainer, texture, texturePath, i);
i++;
}
return true;
R_TRUE
}
/**
@@ -245,12 +245,12 @@ public:
std::string type;
if (!std::getline(ss, type, ':') || type != "RenderComponent")
return false;
R_FALSE
std::string token;
if (!std::getline(ss, token, ':') || token != "HasModel")
return false;
R_FALSE
int diffuse_count = 0, normal_count = 0, specular_count = 0, alpha_count = 0;
@@ -258,14 +258,14 @@ public:
auto read_count = [&](int& count) -> bool {
if (!std::getline(ss, token, ':'))
return false;
R_FALSE
try {
count = std::stoi(token);
}
catch (...) {
return false;
R_FALSE
}
return true;
R_TRUE
};
auto clean_token = [](std::string& str) {
@@ -278,7 +278,7 @@ public:
auto read_paths = [&](int count, std::vector<std::wstring>& paths) -> bool {
for (int i = 0; i < count; ++i) {
if (!std::getline(ss, token, ':'))
return false;
R_FALSE
clean_token(token);
@@ -287,20 +287,20 @@ public:
LOG_INFO("Loaded path: " + std::string(token.begin(), token.end()));
}
}
return true;
R_TRUE
};
if (!read_count(diffuse_count)) return false;
if (!read_paths(diffuse_count, paths_diffuse)) return false;
if (!read_count(diffuse_count)) R_FALSE
if (!read_paths(diffuse_count, paths_diffuse)) R_FALSE
if (!read_count(normal_count)) return false;
if (!read_paths(normal_count, paths_normal)) return false;
if (!read_count(normal_count)) R_FALSE
if (!read_paths(normal_count, paths_normal)) R_FALSE
if (!read_count(specular_count)) return false;
if (!read_paths(specular_count, paths_specular)) return false;
if (!read_count(specular_count)) R_FALSE
if (!read_paths(specular_count, paths_specular)) R_FALSE
if (!read_count(alpha_count)) return false;
if (!read_paths(alpha_count, paths_alpha)) return false;
if (!read_count(alpha_count)) R_FALSE
if (!read_paths(alpha_count, paths_alpha)) R_FALSE
// Lib<69>rer textures existantes
for (auto& tex : texture_container_buffer.diffuse) if (tex) { tex->Release(); tex = nullptr; }
@@ -318,7 +318,7 @@ public:
texture_container_buffer.specularPaths = std::move(paths_specular);
texture_container_buffer.alphaPaths = std::move(paths_alpha);
return true;
R_TRUE
}
/**

View File

@@ -53,17 +53,17 @@ public:
* @return The ShaderType enum corresponding to the provided string.
*/
static ShaderType StringToShaderType(const std::string& str) {
if (str == "ALPHA_MAPPING") return ShaderType::ALPHA_MAPPING;
if (str == "CEL_SHADING") return ShaderType::CEL_SHADING;
if (str == "NORMAL_MAPPING") return ShaderType::NORMAL_MAPPING;
if (str == "SPECULAR_MAPPING") return ShaderType::SPECULAR_MAPPING;
if (str == "TEXTURE") return ShaderType::TEXTURE;
if (str == "LIGHTING") return ShaderType::LIGHTING;
if (str == "SUNLIGHT") return ShaderType::SUNLIGHT;
if (str == "SKYBOX") return ShaderType::SKYBOX;
if (str == "REFLECTION") return ShaderType::REFLECTION;
if (str == "REFRACTION") return ShaderType::REFRACTION;
return ShaderType::TEXTURE;
if (str == "ALPHA_MAPPING") return SHD_ALPHA;
if (str == "CEL_SHADING") return SHD_CEL;
if (str == "NORMAL_MAPPING") return SHD_NORM;
if (str == "SPECULAR_MAPPING") return SHD_SPEC;
if (str == "TEXTURE") return SHD_TEX;
if (str == "LIGHTING") return SHD_LIGHT;
if (str == "SUNLIGHT") return SHD_SUN;
if (str == "SKYBOX") return SHD_SKYBOX;
if (str == "REFLECTION") return SHD_REFL;
if (str == "REFRACTION") return SHD_REFR;
return SHD_TEX;
}
/**
@@ -74,17 +74,17 @@ public:
*/
static std::string ShaderTypeToString(ShaderType type) {
switch (type) {
case ShaderType::ALPHA_MAPPING: return "ALPHA_MAPPING";
case ShaderType::CEL_SHADING: return "CEL_SHADING";
case ShaderType::NORMAL_MAPPING: return "NORMAL_MAPPING";
case ShaderType::SPECULAR_MAPPING: return "SPECULAR_MAPPING";
case ShaderType::TEXTURE: return "TEXTURE";
case ShaderType::LIGHTING: return "LIGHTING";
case ShaderType::SUNLIGHT: return "SUNLIGHT";
case ShaderType::SKYBOX: return "SKYBOX";
case ShaderType::REFLECTION: return "REFLECTION";
case ShaderType::REFRACTION: return "REFRACTION";
default: return "TEXTURE";
case SHD_ALPHA: return "ALPHA_MAPPING";
case SHD_CEL: return "CEL_SHADING";
case SHD_NORM: return "NORMAL_MAPPING";
case SHD_SPEC: return "SPECULAR_MAPPING";
case SHD_TEX: return "TEXTURE";
case SHD_LIGHT: return "LIGHTING";
case SHD_SUN: return "SUNLIGHT";
case SHD_SKYBOX: return "SKYBOX";
case SHD_REFL: return "REFLECTION";
case SHD_REFR: return "REFRACTION";
default: return "TEXTURE";
}
}
@@ -101,13 +101,13 @@ public:
std::string type;
std::getline(ss, type, ':');
if (type != "ShaderComponent") return false;
if (type != "ShaderComponent") R_FALSE
std::string shaderTypeStr;
std::getline(ss, shaderTypeStr);
SetActiveShader(StringToShaderType(shaderTypeStr));
return true;
R_TRUE
}
void OnImGuiRender() override {

View File

@@ -186,7 +186,7 @@ public:
std::string type;
std::getline(ss, type, ':');
if (type != "TransformComponent") return false;
if (type != "TransformComponent") R_FALSE
std::string token;
XMFLOAT3 position, rotation, scale;
@@ -206,7 +206,7 @@ public:
SetPosition(XMLoadFloat3(&position));
SetRotation(XMLoadFloat3(&rotation));
SetScale(XMLoadFloat3(&scale));
return true;
R_TRUE
}
/**

View File

@@ -53,7 +53,7 @@ public:
auto shader = entity->GetComponent<ShaderComponent>();
if (!transform || !render || !shader || !render->GetModel())
return false;
R_FALSE
// Calculer la matrice monde
XMMATRIX scaleMatrix = transform->GetScaleMatrix();