summaryrefslogtreecommitdiff
path: root/src/particles.cpp
diff options
context:
space:
mode:
authorKahrl <kahrl@gmx.net>2013-06-24 04:17:50 +0200
committerKahrl <kahrl@gmx.net>2013-07-02 03:03:10 +0200
commit8161ab573fd6f8a45b3986278ce7fc1596140526 (patch)
tree0aea4fce4e14e035b386ee773e8abd68bc51bea6 /src/particles.cpp
parentcaf0b67e47fd4c6b2a2bc61c36010e2adf9db388 (diff)
downloadminetest-8161ab573fd6f8a45b3986278ce7fc1596140526.tar.gz
minetest-8161ab573fd6f8a45b3986278ce7fc1596140526.tar.bz2
minetest-8161ab573fd6f8a45b3986278ce7fc1596140526.zip
Remove texture atlas / AtlasPointer, rename getTextureRaw to getTexture
Diffstat (limited to 'src/particles.cpp')
-rw-r--r--src/particles.cpp60
1 files changed, 37 insertions, 23 deletions
diff --git a/src/particles.cpp b/src/particles.cpp
index 1d814f619..88905d40d 100644
--- a/src/particles.cpp
+++ b/src/particles.cpp
@@ -57,7 +57,9 @@ Particle::Particle(
float expirationtime,
float size,
bool collisiondetection,
- AtlasPointer ap
+ video::ITexture *texture,
+ v2f texpos,
+ v2f texsize
):
scene::ISceneNode(smgr->getRootSceneNode(), smgr)
{
@@ -70,8 +72,9 @@ Particle::Particle(
m_material.setFlag(video::EMF_BILINEAR_FILTER, false);
m_material.setFlag(video::EMF_FOG_ENABLE, true);
m_material.MaterialType = video::EMT_TRANSPARENT_ALPHA_CHANNEL;
- m_material.setTexture(0, ap.atlas);
- m_ap = ap;
+ m_material.setTexture(0, texture);
+ m_texpos = texpos;
+ m_texsize = texsize;
// Particle related
@@ -180,14 +183,19 @@ void Particle::updateLight(ClientEnvironment &env)
void Particle::updateVertices()
{
video::SColor c(255, m_light, m_light, m_light);
+ f32 tx0 = m_texpos.X;
+ f32 tx1 = m_texpos.X + m_texsize.X;
+ f32 ty0 = m_texpos.Y;
+ f32 ty1 = m_texpos.Y + m_texsize.Y;
+
m_vertices[0] = video::S3DVertex(-m_size/2,-m_size/2,0, 0,0,0,
- c, m_ap.x0(), m_ap.y1());
+ c, tx0, ty1);
m_vertices[1] = video::S3DVertex(m_size/2,-m_size/2,0, 0,0,0,
- c, m_ap.x1(), m_ap.y1());
+ c, tx1, ty1);
m_vertices[2] = video::S3DVertex(m_size/2,m_size/2,0, 0,0,0,
- c, m_ap.x1(), m_ap.y0());
+ c, tx1, ty0);
m_vertices[3] = video::S3DVertex(-m_size/2,m_size/2,0, 0,0,0,
- c ,m_ap.x0(), m_ap.y0());
+ c, tx0, ty0);
for(u16 i=0; i<4; i++)
{
@@ -248,19 +256,19 @@ void addNodeParticle(IGameDef* gamedef, scene::ISceneManager* smgr,
{
// Texture
u8 texid = myrand_range(0,5);
- AtlasPointer ap = tiles[texid].texture;
- float size = rand()%64/512.;
- float visual_size = BS*size;
- float texsize = size*2;
+ video::ITexture *texture = tiles[texid].texture;
- float x1 = ap.x1();
- float y1 = ap.y1();
+ // Only use first frame of animated texture
+ f32 ymax = 1;
+ if(tiles[texid].material_flags & MATERIAL_FLAG_ANIMATION_VERTICAL_FRAMES)
+ ymax /= tiles[texid].animation_frame_count;
- ap.size.X = (ap.x1() - ap.x0()) * texsize;
- ap.size.Y = (ap.x1() - ap.x0()) * texsize;
-
- ap.pos.X = ap.x0() + (x1 - ap.x0()) * ((rand()%64)/64.-texsize);
- ap.pos.Y = ap.y0() + (y1 - ap.y0()) * ((rand()%64)/64.-texsize);
+ float size = rand()%64/512.;
+ float visual_size = BS*size;
+ v2f texsize(size*2, ymax*size*2);
+ v2f texpos;
+ texpos.X = ((rand()%64)/64.-texsize.X);
+ texpos.Y = ymax*((rand()%64)/64.-texsize.Y);
// Physics
v3f velocity( (rand()%100/50.-1)/1.5,
@@ -285,7 +293,9 @@ void addNodeParticle(IGameDef* gamedef, scene::ISceneManager* smgr,
rand()%100/100., // expiration time
visual_size,
true,
- ap);
+ texture,
+ texpos,
+ texsize);
}
/*
@@ -296,7 +306,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, AtlasPointer ap, u32 id)
+ bool collisiondetection, video::ITexture *texture, u32 id)
{
m_gamedef = gamedef;
m_smgr = smgr;
@@ -314,7 +324,7 @@ ParticleSpawner::ParticleSpawner(IGameDef* gamedef, scene::ISceneManager *smgr,
m_minsize = minsize;
m_maxsize = maxsize;
m_collisiondetection = collisiondetection;
- m_ap = ap;
+ m_texture = texture;
m_time = 0;
for (u16 i = 0; i<=m_amount; i++)
@@ -362,7 +372,9 @@ void ParticleSpawner::step(float dtime, ClientEnvironment &env)
exptime,
size,
m_collisiondetection,
- m_ap);
+ m_texture,
+ v2f(0.0, 0.0),
+ v2f(1.0, 1.0));
m_spawntimes.erase(i);
}
else
@@ -398,7 +410,9 @@ void ParticleSpawner::step(float dtime, ClientEnvironment &env)
exptime,
size,
m_collisiondetection,
- m_ap);
+ m_texture,
+ v2f(0.0, 0.0),
+ v2f(1.0, 1.0));
}
}
}