mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 01:58:19 +00:00
Merge pull request #8323 from Robyt3/Client-Particles-Smoke-Nudge
Fix smoke particles sometimes being stuck inside solid tiles
This commit is contained in:
commit
ae2c9e2999
|
@ -257,6 +257,28 @@ void CEffects::Explosion(vec2 Pos, float Alpha)
|
|||
p.m_StartAlpha = Alpha;
|
||||
m_pClient->m_Particles.Add(CParticles::GROUP_EXPLOSIONS, &p);
|
||||
|
||||
// Nudge position slightly to edge of closest tile so the
|
||||
// smoke doesn't get stuck inside the tile.
|
||||
if(Collision()->CheckPoint(Pos))
|
||||
{
|
||||
const vec2 DistanceToTopLeft = Pos - vec2(round_truncate(Pos.x / 32), round_truncate(Pos.y / 32)) * 32;
|
||||
|
||||
vec2 CheckOffset;
|
||||
CheckOffset.x = (DistanceToTopLeft.x > 16 ? 32 : -1);
|
||||
CheckOffset.y = (DistanceToTopLeft.y > 16 ? 32 : -1);
|
||||
CheckOffset -= DistanceToTopLeft;
|
||||
|
||||
for(vec2 Mask : {vec2(1.0f, 0.0f), vec2(0.0f, 1.0f), vec2(1.0f, 1.0f)})
|
||||
{
|
||||
const vec2 NewPos = Pos + CheckOffset * Mask;
|
||||
if(!Collision()->CheckPoint(NewPos))
|
||||
{
|
||||
Pos = NewPos;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// add the smoke
|
||||
for(int i = 0; i < 24; i++)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue