From b48773d19961be44bf9edd7a326dd85f304828f4 Mon Sep 17 00:00:00 2001 From: JAROWMR Date: Sun, 10 Nov 2024 16:08:22 +0100 Subject: added tests and fixed bugs in system --- src/crepe/system/ParticleSystem.cpp | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'src/crepe/system') 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(std::rand() % static_cast(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(std::rand() % static_cast(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(std::rand() % static_cast(speed_offset)); + } + // Convert random_angle to radians double angle_radians = random_angle * DEG_TO_RAD; -- cgit v1.2.3