]> git.lizzy.rs Git - dragonfireclient.git/commitdiff
Fix attached particle spawners far from spawn (#6479)
authorraymoo <raymoo@users.noreply.github.com>
Sat, 30 Sep 2017 13:23:52 +0000 (06:23 -0700)
committerLoïc Blot <nerzhul@users.noreply.github.com>
Sat, 30 Sep 2017 13:23:51 +0000 (15:23 +0200)
* Fix attached particle spawners far from spawn

When far from spawn, attached particle spawners
did not spawn particles.

src/particles.cpp

index faf8063edd4f72d025cabf957d06935465ece7f3..c588fa7a759ac2618731403f58ae1454478902a8 100644 (file)
@@ -317,6 +317,11 @@ void ParticleSpawner::step(float dtime, ClientEnvironment* env)
                                        v3f ppos = m_player->getPosition() / BS;
                                        v3f pos = random_v3f(m_minpos, m_maxpos);
 
+                                       // Need to apply this first or the following check
+                                       // will be wrong for attached spawners
+                                       if (is_attached)
+                                               pos += attached_pos;
+
                                        if (pos.getDistanceFrom(ppos) <= radius) {
                                                v3f vel = random_v3f(m_minvel, m_maxvel);
                                                v3f acc = random_v3f(m_minacc, m_maxacc);
@@ -324,7 +329,6 @@ void ParticleSpawner::step(float dtime, ClientEnvironment* env)
                                                if (is_attached) {
                                                        // Apply attachment yaw and position
                                                        pos.rotateXZBy(attached_yaw);
-                                                       pos += attached_pos;
                                                        vel.rotateXZBy(attached_yaw);
                                                        acc.rotateXZBy(attached_yaw);
                                                }
@@ -377,6 +381,11 @@ void ParticleSpawner::step(float dtime, ClientEnvironment* env)
                                v3f ppos = m_player->getPosition() / BS;
                                v3f pos = random_v3f(m_minpos, m_maxpos);
 
+                               // Need to apply this first or the following check
+                               // will be wrong for attached spawners
+                               if (is_attached)
+                                       pos += attached_pos;
+
                                if (pos.getDistanceFrom(ppos) <= radius) {
                                        v3f vel = random_v3f(m_minvel, m_maxvel);
                                        v3f acc = random_v3f(m_minacc, m_maxacc);
@@ -384,7 +393,6 @@ void ParticleSpawner::step(float dtime, ClientEnvironment* env)
                                        if (is_attached) {
                                                // Apply attachment yaw and position
                                                pos.rotateXZBy(attached_yaw);
-                                               pos += attached_pos;
                                                vel.rotateXZBy(attached_yaw);
                                                acc.rotateXZBy(attached_yaw);
                                        }