From d623b13dab63408cf5e99dbc453636f174bc6fe8 Mon Sep 17 00:00:00 2001 From: heavydemon21 Date: Wed, 20 Nov 2024 14:33:08 +0100 Subject: fixxed bug with particleemiiter and sprite in single component --- src/crepe/system/RenderSystem.cpp | 4 ++-- src/example/rendering_particle.cpp | 8 ++++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/crepe/system/RenderSystem.cpp b/src/crepe/system/RenderSystem.cpp index 28bcf56..c137de1 100644 --- a/src/crepe/system/RenderSystem.cpp +++ b/src/crepe/system/RenderSystem.cpp @@ -36,10 +36,10 @@ bool RenderSystem::render_particle(const Sprite & sprite, const double & scale) bool rendering_particles = false; for (const ParticleEmitter & em : emitters) { + if (!(&em.data.sprite == &sprite)) continue; + rendering_particles = true; if (!em.active) continue; - if (!(em.data.sprite.game_object_id == sprite.game_object_id)) continue; - rendering_particles = true; for (const Particle & p : em.data.particles) { if (!p.active) continue; diff --git a/src/example/rendering_particle.cpp b/src/example/rendering_particle.cpp index 3f71750..bcf95b8 100644 --- a/src/example/rendering_particle.cpp +++ b/src/example/rendering_particle.cpp @@ -15,6 +15,7 @@ #include #include +#include using namespace crepe; using namespace std; @@ -26,10 +27,12 @@ int main(int argc, char * argv[]) { ParticleSystem psys{mgr}; Color color(255, 255, 255, 255); + game_object.add_component(make_shared("../asset/texture/img.png"), color, FlipSettings{false,false}); + Sprite test_sprite = game_object.add_component( make_shared("../asset/texture/img.png"), color, FlipSettings{false, false}); game_object.add_component(ParticleEmitter::Data{ - .position = {0, 0}, + .position = {100, 0}, .max_particles = 10, .emission_rate = 0.1, .min_speed = 6, @@ -46,9 +49,10 @@ int main(int argc, char * argv[]) { .reset_on_exit = false, }, .sprite = test_sprite, - }); + }).active = false; game_object.add_component(Color::get_white()); + auto start = std::chrono::steady_clock::now(); while (std::chrono::steady_clock::now() - start < std::chrono::seconds(5)) { psys.update(); -- cgit v1.2.3