summaryrefslogtreecommitdiff
path: root/src/particles.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/particles.cpp')
-rw-r--r--src/particles.cpp36
1 files changed, 28 insertions, 8 deletions
diff --git a/src/particles.cpp b/src/particles.cpp
index f20fb4083..acf9cc815 100644
--- a/src/particles.cpp
+++ b/src/particles.cpp
@@ -253,12 +253,17 @@ void ParticleSpawner::step(float dtime, ClientEnvironment* env)
m_time += dtime;
bool unloaded = false;
- v3f attached_offset = v3f(0,0,0);
+ bool is_attached = false;
+ v3f attached_pos = v3f(0,0,0);
+ float attached_yaw = 0;
if (m_attached_id != 0) {
- if (ClientActiveObject *attached = env->getActiveObject(m_attached_id))
- attached_offset = attached->getPosition() / BS;
- else
+ if (ClientActiveObject *attached = env->getActiveObject(m_attached_id)) {
+ attached_pos = attached->getPosition() / BS;
+ attached_yaw = attached->getYaw();
+ is_attached = true;
+ } else {
unloaded = true;
+ }
}
if (m_spawntime != 0) // Spawner exists for a predefined timespan
@@ -277,8 +282,15 @@ void ParticleSpawner::step(float dtime, ClientEnvironment* env)
v3f pos = random_v3f(m_minpos, m_maxpos);
v3f vel = random_v3f(m_minvel, m_maxvel);
v3f acc = random_v3f(m_minacc, m_maxacc);
- // Make relative to offest
- pos += attached_offset;
+
+ if (is_attached) {
+ // Apply attachment yaw and position
+ pos.rotateXZBy(attached_yaw);
+ pos += attached_pos;
+ vel.rotateXZBy(attached_yaw);
+ acc.rotateXZBy(attached_yaw);
+ }
+
float exptime = rand()/(float)RAND_MAX
*(m_maxexptime-m_minexptime)
+m_minexptime;
@@ -321,10 +333,18 @@ void ParticleSpawner::step(float dtime, ClientEnvironment* env)
{
if (rand()/(float)RAND_MAX < dtime)
{
- v3f pos = random_v3f(m_minpos, m_maxpos)
- + attached_offset;
+ v3f pos = random_v3f(m_minpos, m_maxpos);
v3f vel = random_v3f(m_minvel, m_maxvel);
v3f acc = random_v3f(m_minacc, m_maxacc);
+
+ if (is_attached) {
+ // Apply attachment yaw and position
+ pos.rotateXZBy(attached_yaw);
+ pos += attached_pos;
+ vel.rotateXZBy(attached_yaw);
+ acc.rotateXZBy(attached_yaw);
+ }
+
float exptime = rand()/(float)RAND_MAX
*(m_maxexptime-m_minexptime)
+m_minexptime;