MCPcopy Create free account
hub / github.com/ddnet/ddnet / ParticleIsVisibleOnScreen

Method ParticleIsVisibleOnScreen

src/game/client/components/particles.cpp:194–207  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

192}
193
194bool CParticles::ParticleIsVisibleOnScreen(const vec2 &CurPos, float CurSize)
195{
196 float ScreenX0, ScreenY0, ScreenX1, ScreenY1;
197 Graphics()->GetScreen(&ScreenX0, &ScreenY0, &ScreenX1, &ScreenY1);
198
199 // for simplicity assume the worst case rotation, that increases the bounding box around the particle by its diagonal
200 const float SqrtOf2 = std::sqrt(2);
201 CurSize = SqrtOf2 * CurSize;
202
203 // always uses the mid of the particle
204 float SizeHalf = CurSize / 2;
205
206 return CurPos.x + SizeHalf >= ScreenX0 && CurPos.x - SizeHalf <= ScreenX1 && CurPos.y + SizeHalf >= ScreenY0 && CurPos.y - SizeHalf <= ScreenY1;
207}
208
209void CParticles::RenderGroup(int Group)
210{

Callers

nothing calls this directly

Calls 2

GraphicsFunction · 0.85
GetScreenMethod · 0.80

Tested by

no test coverage detected