From 991ad2c8e1fd95b23f7fb3b3795412e54dac7e9c Mon Sep 17 00:00:00 2001 From: MaybeMaru <97055307+MaybeMaru@users.noreply.github.com> Date: Sat, 12 Jul 2025 14:11:01 +0200 Subject: [PATCH 1/2] Update FlxObject.hx --- flixel/FlxObject.hx | 49 ++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 48 insertions(+), 1 deletion(-) diff --git a/flixel/FlxObject.hx b/flixel/FlxObject.hx index 756d23a498..cd6724ddda 100644 --- a/flixel/FlxObject.hx +++ b/flixel/FlxObject.hx @@ -1255,6 +1255,53 @@ class FlxObject extends FlxBasic return; var rect = getBoundingBox(camera); + #if !flash + var viewLeft = camera.viewMarginLeft - 1; + var viewRight = camera.viewMarginRight + 1; + var viewTop = camera.viewMarginTop - 1; + var viewBottom = camera.viewMarginBottom + 1; + + // clamp the rect to the bounds of the camera + // this is neccesary to avoid big bitmaps when zoomed in + if (rect.x < viewLeft) + { + rect.width -= (viewLeft - rect.x); + rect.x = viewLeft; + } + else if (rect.x > viewRight) + { + rect.x = viewRight; + rect.width = 0; + } + + if (rect.right > viewRight) + { + rect.width = viewRight - rect.x; + } + + if (rect.y < viewTop) + { + rect.height -= (viewTop - rect.y); + rect.y = viewTop; + } + else if (rect.y > viewBottom) + { + rect.y = viewBottom; + rect.height = 0; + } + + if (rect.bottom > viewBottom) + { + rect.height = viewBottom - rect.y; + } + + rect.width = Math.max(0, rect.width); + rect.height = Math.max(0, rect.height); + + if (rect.isEmpty) + return; + #end + var gfx:Graphics = beginDrawDebug(camera); drawDebugBoundingBox(gfx, rect, allowCollisions, immovable); endDrawDebug(camera); @@ -1285,7 +1332,7 @@ class FlxObject extends FlxBasic function drawDebugBoundingBoxColor(gfx:Graphics, rect:FlxRect, color:FlxColor) { // fill static graphics object with square shape - gfx.lineStyle(1, color, 0.75); + gfx.lineStyle(1, color, 0.75, false, null, null, MITER, 255); gfx.drawRect(rect.x + 0.5, rect.y + 0.5, rect.width - 1.0, rect.height - 1.0); } From 2acef72f63b964dd0bf54c8d632c730db9437bfe Mon Sep 17 00:00:00 2001 From: MaybeMaru <97055307+MaybeMaru@users.noreply.github.com> Date: Wed, 16 Jul 2025 14:16:55 +0200 Subject: [PATCH 2/2] Small margin expansion Had to do this because of the current antialiasing problems with openfl issue, similarly to the problem resolved in https://github.com/HaxeFlixel/flixel/pull/3397 --- flixel/FlxObject.hx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/flixel/FlxObject.hx b/flixel/FlxObject.hx index cd6724ddda..7a099e08e9 100644 --- a/flixel/FlxObject.hx +++ b/flixel/FlxObject.hx @@ -1256,10 +1256,10 @@ class FlxObject extends FlxBasic var rect = getBoundingBox(camera); #if !flash - var viewLeft = camera.viewMarginLeft - 1; - var viewRight = camera.viewMarginRight + 1; - var viewTop = camera.viewMarginTop - 1; - var viewBottom = camera.viewMarginBottom + 1; + var viewLeft = camera.viewMarginLeft - 2; + var viewRight = camera.viewMarginRight + 2; + var viewTop = camera.viewMarginTop - 2; + var viewBottom = camera.viewMarginBottom + 2; // clamp the rect to the bounds of the camera // this is neccesary to avoid big bitmaps when zoomed in