From ab218ceca654831475c5f5ed272c8ff739ad3e73 Mon Sep 17 00:00:00 2001 From: fgenesis Date: Fri, 14 Jul 2023 01:33:59 +0200 Subject: [PATCH] tiles are now culled --- BBGE/TileRender.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/BBGE/TileRender.cpp b/BBGE/TileRender.cpp index ffa44cb..f2f62ce 100644 --- a/BBGE/TileRender.cpp +++ b/BBGE/TileRender.cpp @@ -75,6 +75,17 @@ void TileRender::onRender(const RenderState& rs) const } const ElementTemplate * const et = tile.et; + + // adapted from RenderObject::isOnScreen() + { + const float cw = et->w * tile.scalex; + const float ch = et->h * tile.scaley; + const float cullRadiusSqr = ((cw*cw + ch*ch) * core->invGlobalScaleSqr) + core->cullRadiusSqr; + + if ((pos - core->cullCenter).getSquaredLength2D() >= cullRadiusSqr) + continue; + } + if(const Texture * const tex = et->tex.content()) { unsigned texid = tex->gltexid;