aboutsummaryrefslogtreecommitdiff
path: root/src/particles.cpp
diff options
context:
space:
mode:
authorNovatux <nathanael.courant@laposte.net>2014-01-26 11:40:21 +0100
committerNovatux <nathanael.courant@laposte.net>2014-03-04 20:12:10 +0100
commit062de11b4cff30861dd4e9eb56f131d821f34b51 (patch)
tree37bdcbacb355abfe1f8091307222e430e58b78d8 /src/particles.cpp
parent8e15179e7d896851c6f5814fc6524c86b26ce2e3 (diff)
downloadminetest-062de11b4cff30861dd4e9eb56f131d821f34b51.tar.gz
minetest-062de11b4cff30861dd4e9eb56f131d821f34b51.tar.bz2
minetest-062de11b4cff30861dd4e9eb56f131d821f34b51.zip
Fix rendering glitches when far from the center of the map
Diffstat (limited to 'src/particles.cpp')
-rw-r--r--src/particles.cpp25
1 files changed, 13 insertions, 12 deletions
diff --git a/src/particles.cpp b/src/particles.cpp
index 19bdaf121..5a3056c32 100644
--- a/src/particles.cpp
+++ b/src/particles.cpp
@@ -66,6 +66,7 @@ Particle::Particle(
{
// Misc
m_gamedef = gamedef;
+ m_env = &env;
// Texture
m_material.setFlag(video::EMF_LIGHTING, false);
@@ -95,7 +96,7 @@ Particle::Particle(
this->setAutomaticCulling(scene::EAC_OFF);
// Init lighting
- updateLight(env);
+ updateLight();
// Init model
updateVertices();
@@ -134,7 +135,7 @@ void Particle::render()
scene::EPT_TRIANGLES, video::EIT_16BIT);
}
-void Particle::step(float dtime, ClientEnvironment &env)
+void Particle::step(float dtime)
{
m_time += dtime;
if (m_collisiondetection)
@@ -143,7 +144,7 @@ void Particle::step(float dtime, ClientEnvironment &env)
v3f p_pos = m_pos*BS;
v3f p_velocity = m_velocity*BS;
v3f p_acceleration = m_acceleration*BS;
- collisionMoveSimple(&env, m_gamedef,
+ collisionMoveSimple(m_env, m_gamedef,
BS*0.5, box,
0, dtime,
p_pos, p_velocity, p_acceleration);
@@ -158,13 +159,13 @@ void Particle::step(float dtime, ClientEnvironment &env)
}
// Update lighting
- updateLight(env);
+ updateLight();
// Update model
updateVertices();
}
-void Particle::updateLight(ClientEnvironment &env)
+void Particle::updateLight()
{
u8 light = 0;
try{
@@ -173,11 +174,11 @@ void Particle::updateLight(ClientEnvironment &env)
floor(m_pos.Y+0.5),
floor(m_pos.Z+0.5)
);
- MapNode n = env.getClientMap().getNode(p);
- light = n.getLightBlend(env.getDayNightRatio(), m_gamedef->ndef());
+ MapNode n = m_env->getClientMap().getNode(p);
+ light = n.getLightBlend(m_env->getDayNightRatio(), m_gamedef->ndef());
}
catch(InvalidPositionException &e){
- light = blend_light(env.getDayNightRatio(), LIGHT_SUN, 0);
+ light = blend_light(m_env->getDayNightRatio(), LIGHT_SUN, 0);
}
m_light = decode_light(light);
}
@@ -199,6 +200,7 @@ void Particle::updateVertices()
m_vertices[3] = video::S3DVertex(-m_size/2,m_size/2,0, 0,0,0,
c, tx0, ty0);
+ v3s16 camera_offset = m_env->getCameraOffset();
for(u16 i=0; i<4; i++)
{
if (m_vertical) {
@@ -209,17 +211,16 @@ void Particle::updateVertices()
m_vertices[i].Pos.rotateXZBy(m_player->getYaw());
}
m_box.addInternalPoint(m_vertices[i].Pos);
- m_vertices[i].Pos += m_pos*BS;
+ m_vertices[i].Pos += m_pos*BS - intToFloat(camera_offset, BS);
}
}
-
/*
Helpers
*/
-void allparticles_step (float dtime, ClientEnvironment &env)
+void allparticles_step (float dtime)
{
for(std::vector<Particle*>::iterator i = all_particles.begin();
i != all_particles.end();)
@@ -232,7 +233,7 @@ void allparticles_step (float dtime, ClientEnvironment &env)
}
else
{
- (*i)->step(dtime, env);
+ (*i)->step(dtime);
i++;
}
}