diff options
author | JAROWMR <jarorutjes07@gmail.com> | 2024-11-10 16:08:22 +0100 |
---|---|---|
committer | JAROWMR <jarorutjes07@gmail.com> | 2024-11-10 16:08:22 +0100 |
commit | b48773d19961be44bf9edd7a326dd85f304828f4 (patch) | |
tree | f6edeae71454018bf1301ce4b007833a2a1b0fc3 /src/crepe/system/ParticleSystem.cpp | |
parent | 556eb319c9e5c3f6b90e9533eadcdd5682a5d347 (diff) |
added tests and fixed bugs in system
Diffstat (limited to 'src/crepe/system/ParticleSystem.cpp')
-rw-r--r-- | src/crepe/system/ParticleSystem.cpp | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/src/crepe/system/ParticleSystem.cpp b/src/crepe/system/ParticleSystem.cpp index 85321f0..48fe1d7 100644 --- a/src/crepe/system/ParticleSystem.cpp +++ b/src/crepe/system/ParticleSystem.cpp @@ -52,8 +52,10 @@ void ParticleSystem::emit_particle(ParticleEmitter & emitter,const Transform& tr double min_angle = emitter.data.min_angle; double max_angle = emitter.data.max_angle; double random_angle; - - if (min_angle <= max_angle) { + if(min_angle == max_angle){ + random_angle = min_angle; + } + else if (min_angle <= max_angle) { // Standard range (e.g., 10 to 20 degrees) double angle_offset = max_angle - min_angle; random_angle = min_angle + static_cast<double>(std::rand() % static_cast<uint32_t>(angle_offset)); @@ -70,8 +72,15 @@ void ParticleSystem::emit_particle(ParticleEmitter & emitter,const Transform& tr // Generate a random speed between min_speed and max_speed double speed_offset = emitter.data.max_speed - emitter.data.min_speed; - double random_speed = emitter.data.min_speed + static_cast<double>(std::rand() % static_cast<uint32_t>(speed_offset)); - + double random_speed = 0.0; + if(emitter.data.max_speed == emitter.data.min_speed) + { + random_speed = emitter.data.min_speed; + } + else { + random_speed = emitter.data.min_speed + static_cast<double>(std::rand() % static_cast<uint32_t>(speed_offset)); + } + // Convert random_angle to radians double angle_radians = random_angle * DEG_TO_RAD; |