Skip to content

Commit c4cc07c

Browse files
MaybeMaruGeokureli
andauthored
Improve zoomed debug hitboxes performance (#3449)
* Update FlxObject.hx * Small margin expansion Had to do this because of the current antialiasing problems with openfl issue, similarly to the problem resolved in #3397 * fix non-flash blit targets + simplify --------- Co-authored-by: GeoKureli-BlackbookPro <[email protected]>
1 parent ce80660 commit c4cc07c

File tree

1 file changed

+20
-5
lines changed

1 file changed

+20
-5
lines changed

flixel/FlxObject.hx

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1254,10 +1254,25 @@ class FlxObject extends FlxBasic
12541254
if (!camera.visible || !camera.exists || !isOnScreen(camera))
12551255
return;
12561256

1257-
var rect = getBoundingBox(camera);
1258-
var gfx:Graphics = beginDrawDebug(camera);
1259-
drawDebugBoundingBox(gfx, rect, allowCollisions, immovable);
1260-
endDrawDebug(camera);
1257+
final rect = getBoundingBox(camera);
1258+
if (FlxG.renderTile)
1259+
{
1260+
final PAD = 2;
1261+
final view = camera.getViewMarginRect();
1262+
view.left -= PAD;
1263+
view.top -= PAD;
1264+
view.right += PAD;
1265+
view.bottom += PAD;
1266+
rect.clipTo(view);
1267+
view.put();
1268+
}
1269+
1270+
if (rect.width > 0 && rect.height > 0)
1271+
{
1272+
final gfx = beginDrawDebug(camera);
1273+
drawDebugBoundingBox(gfx, rect, allowCollisions, immovable);
1274+
endDrawDebug(camera);
1275+
}
12611276
}
12621277

12631278
function drawDebugBoundingBox(gfx:Graphics, rect:FlxRect, allowCollisions:FlxDirectionFlags, partial:Bool)
@@ -1285,7 +1300,7 @@ class FlxObject extends FlxBasic
12851300
function drawDebugBoundingBoxColor(gfx:Graphics, rect:FlxRect, color:FlxColor)
12861301
{
12871302
// fill static graphics object with square shape
1288-
gfx.lineStyle(1, color, 0.75);
1303+
gfx.lineStyle(1, color, 0.75, false, null, null, MITER, 255);
12891304
gfx.drawRect(rect.x + 0.5, rect.y + 0.5, rect.width - 1.0, rect.height - 1.0);
12901305
}
12911306

0 commit comments

Comments
 (0)