Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion flixel/graphics/tile/FlxDrawTrianglesItem.hx
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ class FlxDrawTrianglesItem extends FlxDrawBaseItem<FlxDrawTrianglesItem>

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);
Expand Down
2 changes: 1 addition & 1 deletion flixel/system/render/FlxCameraView.hx
Original file line number Diff line number Diff line change
Expand Up @@ -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<Float>, indices:DrawData<Int>, uvtData:DrawData<Float>, ?colors:DrawData<Int>,
public function drawTriangles(graphic:FlxGraphic, vertices:FlxVector2d<Float>, indices:FlxVector2d<Int>, uvtData:FlxVector2d<Float>, ?colors:FlxVector2d<Int>,
?position:FlxPoint, ?blend:BlendMode, repeat:Bool = false, smoothing:Bool = false, ?transform:ColorTransform, ?shader:FlxShader)
{
throw "Not implemented";
Expand Down
47 changes: 47 additions & 0 deletions flixel/system/render/FlxVector2d.hx
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
package flixel.system.render;

import openfl.Vector;

/**
* An `openfl.Vector<T>` disguised as a `openfl.Vector<{ x:T, y:T }>` objects, but without the performance hit
*/
@:multiType(T)
abstract FlxVector2d<T>(Vector<T>) from Vector<T>
{
// This is needed to get around openfl's complicated Vector class
@:to static function ofInt(_:Vector<Int>) { return new FlxIntVector2d(0, false, new Array<Int>()); }
@:to static function ofFloat(_:Vector<Float>) { return new FlxFloatVector2d(0, false, new Array<Float>()); }
@:to static function ofBool(_:Vector<Bool>) { return new FlxBoolVector2d(0, false, new Array<Bool>()); }

// Note: must be inlined
@:to inline function toVector():Vector<T> { 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<Int>) from Vector<Int> to Vector<Int> {}
@:forward @:forward.new abstract FlxFloatVector2d(Vector<Float>) from Vector<Float> to Vector<Float> {}
@:forward @:forward.new abstract FlxBoolVector2d(Vector<Bool>) from Vector<Bool> to Vector<Bool> {}
19 changes: 8 additions & 11 deletions flixel/system/render/blit/FlxBlitView.hx
Original file line number Diff line number Diff line change
Expand Up @@ -249,8 +249,8 @@ class FlxBlitView extends FlxCameraView
static final _trianglesSprite = new Sprite();

@:noCompletion
static final drawVertices = new DrawData<Float>();
override function drawTriangles(graphic:FlxGraphic, vertices:DrawData<Float>, indices:DrawData<Int>, uvtData:DrawData<Float>, ?colors:DrawData<Int>,
static final drawVertices = new FlxVector2d<Float>();
override function drawTriangles(graphic:FlxGraphic, vertices:FlxVector2d<Float>, indices:FlxVector2d<Int>, uvtData:FlxVector2d<Float>, ?colors:FlxVector2d<Int>,
?position, ?blend, repeat = false, smoothing = false, ?transform, ?shader)
{
// super.drawTriangles(graphic, vertices, indices, uvtData, colors, position, blend, repeat, smoothing, transform, shader);
Expand All @@ -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)
{
Expand All @@ -290,7 +287,7 @@ class FlxBlitView extends FlxCameraView

if (!overlaps)
{
drawVertices.splice(drawVertices.length - verticesLength, verticesLength);
drawVertices.clear();
return;
}

Expand Down
4 changes: 2 additions & 2 deletions flixel/system/render/quad/FlxQuadView.hx
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ class FlxQuadView extends FlxCameraView
drawItem.addQuad(frame, _helperMatrix, transform);
}

override function drawTriangles(graphic:FlxGraphic, vertices:DrawData<Float>, indices:DrawData<Int>, uvtData:DrawData<Float>, ?colors:DrawData<Int>,
override function drawTriangles(graphic:FlxGraphic, vertices:FlxVector2d<Float>, indices:FlxVector2d<Int>, uvtData:FlxVector2d<Float>, ?colors:FlxVector2d<Int>,
?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);
Expand Down Expand Up @@ -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);
}

Expand Down
Loading