summaryrefslogtreecommitdiff
path: root/src/particles.cpp
diff options
context:
space:
mode:
authorkhonkhortisan <khonkhortisan@gmail.com>2013-04-22 11:35:10 -0700
committerShadowNinja <shadowninja@minetest.net>2014-01-13 17:34:56 -0500
commit2b1eff772524fca8249fd64028e5cbfeabc127a0 (patch)
treef7d1a231de13db304a2ea1fb945e41b08b38f0f1 /src/particles.cpp
parenta4c5f10ecf4fd49cfbf73580b00c0b4f12ee40cf (diff)
downloadminetest-2b1eff772524fca8249fd64028e5cbfeabc127a0.tar.gz
minetest-2b1eff772524fca8249fd64028e5cbfeabc127a0.tar.bz2
minetest-2b1eff772524fca8249fd64028e5cbfeabc127a0.zip
Allow vertical axis particle rotation constraint
Use tables for adding particles, deprecate former way. separate particles(pawner) definition, add default values, work with no arguments
Diffstat (limited to 'src/particles.cpp')
-rw-r--r--src/particles.cpp17
1 files changed, 14 insertions, 3 deletions
diff --git a/src/particles.cpp b/src/particles.cpp
index ce5a4013f..19bdaf121 100644
--- a/src/particles.cpp
+++ b/src/particles.cpp
@@ -57,6 +57,7 @@ Particle::Particle(
float expirationtime,
float size,
bool collisiondetection,
+ bool vertical,
video::ITexture *texture,
v2f texpos,
v2f texsize
@@ -86,6 +87,7 @@ Particle::Particle(
m_player = player;
m_size = size;
m_collisiondetection = collisiondetection;
+ m_vertical = vertical;
// Irrlicht stuff
m_collisionbox = core::aabbox3d<f32>
@@ -199,8 +201,13 @@ void Particle::updateVertices()
for(u16 i=0; i<4; i++)
{
- m_vertices[i].Pos.rotateYZBy(m_player->getPitch());
- m_vertices[i].Pos.rotateXZBy(m_player->getYaw());
+ if (m_vertical) {
+ v3f ppos = m_player->getPosition()/BS;
+ m_vertices[i].Pos.rotateXZBy(atan2(ppos.Z-m_pos.Z, ppos.X-m_pos.X)/core::DEGTORAD+90);
+ } else {
+ m_vertices[i].Pos.rotateYZBy(m_player->getPitch());
+ m_vertices[i].Pos.rotateXZBy(m_player->getYaw());
+ }
m_box.addInternalPoint(m_vertices[i].Pos);
m_vertices[i].Pos += m_pos*BS;
}
@@ -293,6 +300,7 @@ void addNodeParticle(IGameDef* gamedef, scene::ISceneManager* smgr,
rand()%100/100., // expiration time
visual_size,
true,
+ false,
texture,
texpos,
texsize);
@@ -306,7 +314,7 @@ ParticleSpawner::ParticleSpawner(IGameDef* gamedef, scene::ISceneManager *smgr,
u16 amount, float time,
v3f minpos, v3f maxpos, v3f minvel, v3f maxvel, v3f minacc, v3f maxacc,
float minexptime, float maxexptime, float minsize, float maxsize,
- bool collisiondetection, video::ITexture *texture, u32 id)
+ bool collisiondetection, bool vertical, video::ITexture *texture, u32 id)
{
m_gamedef = gamedef;
m_smgr = smgr;
@@ -324,6 +332,7 @@ ParticleSpawner::ParticleSpawner(IGameDef* gamedef, scene::ISceneManager *smgr,
m_minsize = minsize;
m_maxsize = maxsize;
m_collisiondetection = collisiondetection;
+ m_vertical = vertical;
m_texture = texture;
m_time = 0;
@@ -372,6 +381,7 @@ void ParticleSpawner::step(float dtime, ClientEnvironment &env)
exptime,
size,
m_collisiondetection,
+ m_vertical,
m_texture,
v2f(0.0, 0.0),
v2f(1.0, 1.0));
@@ -410,6 +420,7 @@ void ParticleSpawner::step(float dtime, ClientEnvironment &env)
exptime,
size,
m_collisiondetection,
+ m_vertical,
m_texture,
v2f(0.0, 0.0),
v2f(1.0, 1.0));