Skip to content

Commit 8c16f18

Browse files
raymoonerzhul
authored andcommittedSep 30, 2017
Fix attached particle spawners far from spawn (#6479)
* Fix attached particle spawners far from spawn When far from spawn, attached particle spawners did not spawn particles.
1 parent be10c08 commit 8c16f18

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed
 

Diff for: ‎src/particles.cpp

+10-2
Original file line numberDiff line numberDiff line change
@@ -317,14 +317,18 @@ void ParticleSpawner::step(float dtime, ClientEnvironment* env)
317317
v3f ppos = m_player->getPosition() / BS;
318318
v3f pos = random_v3f(m_minpos, m_maxpos);
319319

320+
// Need to apply this first or the following check
321+
// will be wrong for attached spawners
322+
if (is_attached)
323+
pos += attached_pos;
324+
320325
if (pos.getDistanceFrom(ppos) <= radius) {
321326
v3f vel = random_v3f(m_minvel, m_maxvel);
322327
v3f acc = random_v3f(m_minacc, m_maxacc);
323328

324329
if (is_attached) {
325330
// Apply attachment yaw and position
326331
pos.rotateXZBy(attached_yaw);
327-
pos += attached_pos;
328332
vel.rotateXZBy(attached_yaw);
329333
acc.rotateXZBy(attached_yaw);
330334
}
@@ -377,14 +381,18 @@ void ParticleSpawner::step(float dtime, ClientEnvironment* env)
377381
v3f ppos = m_player->getPosition() / BS;
378382
v3f pos = random_v3f(m_minpos, m_maxpos);
379383

384+
// Need to apply this first or the following check
385+
// will be wrong for attached spawners
386+
if (is_attached)
387+
pos += attached_pos;
388+
380389
if (pos.getDistanceFrom(ppos) <= radius) {
381390
v3f vel = random_v3f(m_minvel, m_maxvel);
382391
v3f acc = random_v3f(m_minacc, m_maxacc);
383392

384393
if (is_attached) {
385394
// Apply attachment yaw and position
386395
pos.rotateXZBy(attached_yaw);
387-
pos += attached_pos;
388396
vel.rotateXZBy(attached_yaw);
389397
acc.rotateXZBy(attached_yaw);
390398
}

4 commit comments

Comments
 (4)

orwell96 commented on Sep 30, 2017

@orwell96
Contributor

You also need to move the pos.rotateXZBy() instruction, or the resulting position will be wrong when the object has a yaw !=0
(The rotation has to be done BEFORE the attached position is applied!

raymoo commented on Sep 30, 2017

@raymoo
ContributorAuthor

@orwell96 Thanks for catching.

orwell96 commented on Sep 30, 2017

@orwell96
Contributor

I committed this change... nevermind

orwell96 commented on Oct 2, 2017

@orwell96
Contributor

Fixed in b9fb3ce.

Please sign in to comment.