From 5af0840bc5f001550166be83bb510d3c39e96a88 Mon Sep 17 00:00:00 2001 From: GeoKureli-BlackbookPro Date: Fri, 13 Mar 2026 15:39:37 -0500 Subject: [PATCH 1/3] add FlxVector2d wrapper for openfl.Vector --- flixel/system/render/FlxCameraView.hx | 2 +- flixel/system/render/FlxVector2d.hx | 47 ++++++++++++++++++++++++ flixel/system/render/blit/FlxBlitView.hx | 19 ++++------ flixel/system/render/quad/FlxQuadView.hx | 2 +- 4 files changed, 57 insertions(+), 13 deletions(-) create mode 100644 flixel/system/render/FlxVector2d.hx diff --git a/flixel/system/render/FlxCameraView.hx b/flixel/system/render/FlxCameraView.hx index 4ae557934a..46b3545004 100644 --- a/flixel/system/render/FlxCameraView.hx +++ b/flixel/system/render/FlxCameraView.hx @@ -192,7 +192,7 @@ abstract class FlxCameraView implements IFlxDestroyable * @param transform The color transform to use, optional. * @param shader The shader to use, optional (used only with the DRAW_TILES renderer). */ - public function drawTriangles(graphic:FlxGraphic, vertices:DrawData, indices:DrawData, uvtData:DrawData, ?colors:DrawData, + public function drawTriangles(graphic:FlxGraphic, vertices:FlxVector2d, indices:FlxVector2d, uvtData:FlxVector2d, ?colors:FlxVector2d, ?position:FlxPoint, ?blend:BlendMode, repeat:Bool = false, smoothing:Bool = false, ?transform:ColorTransform, ?shader:FlxShader) { throw "Not implemented"; diff --git a/flixel/system/render/FlxVector2d.hx b/flixel/system/render/FlxVector2d.hx new file mode 100644 index 0000000000..99459525cc --- /dev/null +++ b/flixel/system/render/FlxVector2d.hx @@ -0,0 +1,47 @@ +package flixel.system.render; + +import openfl.Vector; + +/** + * An `openfl.Vector` disguised as a `openfl.Vector<{ x:T, y:T }>` objects, but without the performance hit + */ +@:multiType(T) +abstract FlxVector2d(Vector) from Vector +{ + // This is needed to get around openfl's complicated Vector class + @:to static function ofInt(_:Vector) { return new FlxIntVector2d(0, false, new Array()); } + @:to static function ofFloat(_:Vector) { return new FlxFloatVector2d(0, false, new Array()); } + @:to static function ofBool(_:Vector) { return new FlxBoolVector2d(0, false, new Array()); } + + // Note: must be inlined + @:to inline function toVector():Vector { return this; } + + public var length(get, never):Int; + inline function get_length() return this.length >> 1; + + public function new(); + + public inline function set(index:Int, x:T, y:T) + { + this[index << 1 + 0] = x; + this[index << 1 + 1] = y; + } + + public inline function getX(index:Int) return this[index << 1 + 0]; + public inline function getY(index:Int) return this[index << 1 + 1]; + + public inline function push(x:T, y:T) + { + this.push(x); + this.push(y); + } + + public inline function clear() + { + this.slice(0, this.length); + } +} + +@:forward @:forward.new abstract FlxIntVector2d(Vector) from Vector to Vector {} +@:forward @:forward.new abstract FlxFloatVector2d(Vector) from Vector to Vector {} +@:forward @:forward.new abstract FlxBoolVector2d(Vector) from Vector to Vector {} \ No newline at end of file diff --git a/flixel/system/render/blit/FlxBlitView.hx b/flixel/system/render/blit/FlxBlitView.hx index da30f52847..fec7e5708c 100644 --- a/flixel/system/render/blit/FlxBlitView.hx +++ b/flixel/system/render/blit/FlxBlitView.hx @@ -249,8 +249,8 @@ class FlxBlitView extends FlxCameraView static final _trianglesSprite = new Sprite(); @:noCompletion - static final drawVertices = new DrawData(); - override function drawTriangles(graphic:FlxGraphic, vertices:DrawData, indices:DrawData, uvtData:DrawData, ?colors:DrawData, + static final drawVertices = new FlxVector2d(); + override function drawTriangles(graphic:FlxGraphic, vertices:FlxVector2d, indices:FlxVector2d, uvtData:FlxVector2d, ?colors:FlxVector2d, ?position, ?blend, repeat = false, smoothing = false, ?transform, ?shader) { // super.drawTriangles(graphic, vertices, indices, uvtData, colors, position, blend, repeat, smoothing, transform, shader); @@ -260,18 +260,15 @@ class FlxBlitView extends FlxCameraView if (position == null) position = FlxPoint.weak(); - final verticesLength:Int = vertices.length >> 1; - final bounds = FlxRect.get(); - drawVertices.splice(0, drawVertices.length); + drawVertices.clear(); - for (i in 0...verticesLength) + for (i in 0...vertices.length) { - final tempX = position.x + vertices[(i << 1) + 0]; - final tempY = position.y + vertices[(i << 1) + 1]; + final tempX = position.x + vertices.getX(i); + final tempY = position.y + vertices.getY(i); - drawVertices.push(tempX); - drawVertices.push(tempY); + drawVertices.push(tempX, tempY); if (i == 0) { @@ -290,7 +287,7 @@ class FlxBlitView extends FlxCameraView if (!overlaps) { - drawVertices.splice(drawVertices.length - verticesLength, verticesLength); + drawVertices.clear(); return; } diff --git a/flixel/system/render/quad/FlxQuadView.hx b/flixel/system/render/quad/FlxQuadView.hx index fc239c3fdb..956040c9ab 100644 --- a/flixel/system/render/quad/FlxQuadView.hx +++ b/flixel/system/render/quad/FlxQuadView.hx @@ -240,7 +240,7 @@ class FlxQuadView extends FlxCameraView drawItem.addQuad(frame, _helperMatrix, transform); } - override function drawTriangles(graphic:FlxGraphic, vertices:DrawData, indices:DrawData, uvtData:DrawData, ?colors:DrawData, + override function drawTriangles(graphic:FlxGraphic, vertices:FlxVector2d, indices:FlxVector2d, uvtData:FlxVector2d, ?colors:FlxVector2d, ?position:FlxPoint, ?blend:BlendMode, repeat = false, smoothing = false, ?transform:ColorTransform, ?shader:FlxShader) { // super.drawTriangles(graphic, vertices, indices, uvtData, colors, position, blend, repeat, smoothing, transform, shader); From a4ab01ffc04bff53b0b21b6cf8423f6c19e487b6 Mon Sep 17 00:00:00 2001 From: GeoKureli-BlackbookPro Date: Fri, 13 Mar 2026 23:07:56 -0500 Subject: [PATCH 2/3] fix warning --- flixel/graphics/tile/FlxDrawTrianglesItem.hx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/flixel/graphics/tile/FlxDrawTrianglesItem.hx b/flixel/graphics/tile/FlxDrawTrianglesItem.hx index c98efdf407..795c220a99 100644 --- a/flixel/graphics/tile/FlxDrawTrianglesItem.hx +++ b/flixel/graphics/tile/FlxDrawTrianglesItem.hx @@ -82,7 +82,7 @@ class FlxDrawTrianglesItem extends FlxDrawBaseItem view.canvas.graphics.beginShaderFill(shader); #else - view.canvas.graphics.beginBitmapFill(graphics.bitmap, null, true, (camera.antialiasing || antialiasing)); + view.canvas.graphics.beginBitmapFill(graphics.bitmap, null, true, (camera.view.antialiasing || antialiasing)); #end view.canvas.graphics.drawTriangles(vertices, indices, uvtData, TriangleCulling.NONE); From 15c7a0027c5bbe377858deca2d54307788075b0d Mon Sep 17 00:00:00 2001 From: GeoKureli-BlackbookPro Date: Tue, 17 Mar 2026 10:34:33 -0500 Subject: [PATCH 3/3] fix typo --- flixel/system/render/quad/FlxQuadView.hx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/flixel/system/render/quad/FlxQuadView.hx b/flixel/system/render/quad/FlxQuadView.hx index fc239c3fdb..bfe5916819 100644 --- a/flixel/system/render/quad/FlxQuadView.hx +++ b/flixel/system/render/quad/FlxQuadView.hx @@ -341,7 +341,7 @@ class FlxQuadView extends FlxCameraView override function set_alpha(value:Float):Float { - canvas.alpha = alpha; + canvas.alpha = value; return super.set_alpha(value); }