Minor - Improves scene loading and audio component - V13.6.0

Refactors scene loading to properly initialize models and textures from the scene file.

Adds audio component deserialization and file path handling.

Fixes model loading and texture application in scene manager.
Addresses potential issues with missing components during scene loading.
This commit is contained in:
2025-09-17 00:01:13 +02:00
parent de05631608
commit 7fc4b08808
7 changed files with 223 additions and 171 deletions

View File

@@ -18,6 +18,14 @@ class AudioComponent : public Component {
public:
AudioComponent() : m_sound(nullptr), m_channel(nullptr) {}
~AudioComponent() override {
// stop the sound if it's playing
if (m_channel) {
bool isPlaying = false;
m_channel->isPlaying(&isPlaying);
if (isPlaying) {
m_channel->stop();
}
}
if (m_sound) m_sound->release();
// Ne pas lib<69>rer m_system ici car il peut <20>tre partag<61>
}
@@ -51,10 +59,13 @@ public:
if (!m_system) return false;
}
Logger::Get().Log("Loading audio file: " + path, __FILE__, __LINE__, Logger::LogLevel::Info);
m_soundPath = path;
if (!std::filesystem::exists(path)) {
m_lastError = "Fichier non trouv<75>: " + path;
Logger::Get().Log(m_lastError, __FILE__, __LINE__, Logger::LogLevel::Error);
return false;
}
@@ -437,7 +448,7 @@ public:
std::string Serialize() const override {
std::stringstream ss;
ss << "AudioComponent:"
<< m_soundPath << ":"
<< m_soundPath << ";"
<< m_volume << ":"
<< m_pan << ":"
<< m_pitch << ":"
@@ -465,7 +476,7 @@ public:
std::string s_volume, s_pan, s_pitch, s_looping, s_muted, s_paused, s_priority, s_spatialized, s_use_velocity;
std::getline(ss, m_soundPath, ':');
std::getline(ss, m_soundPath, ';');
std::getline(ss, s_volume, ':');
std::getline(ss, s_pan, ':');
std::getline(ss, s_pitch, ':');
@@ -476,6 +487,8 @@ public:
std::getline(ss, s_spatialized, ':');
std::getline(ss, s_use_velocity, ':');
Logger::Get().Log("Deserializing AudioComponent: path=" + m_soundPath, __FILE__, __LINE__, Logger::LogLevel::Warning);
m_volume = std::stof(s_volume);
m_pan = std::stof(s_pan);
m_pitch = std::stof(s_pitch);