mirror of
https://github.com/luanti-org/luanti.git
synced 2025-06-27 16:36:03 +00:00
Fix rendering glitches when far from the center of the map
This commit is contained in:
parent
8e15179e7d
commit
062de11b4c
17 changed files with 112 additions and 35 deletions
|
@ -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++;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue