Skip to content

Conversation

richTrash21
Copy link
Contributor

@richTrash21 richTrash21 commented Sep 4, 2025

Changes list:

Main changes (FlxDrawTrianglesItem)

colors vector is a part of openfl-legacy Graphics API that Flixel used to apply color transformation to traingles on FlxG.renderTile. Right now coloring on FlxG.renderTile is handled by shader, but addTriangles and addQuad hasn't been updated for this, resulting in addTriangles just "ignoring" colors (#2263) and addQuad (used for FLX_RENDER_TRIANGLE) being completely broken (#3169). Both functions were updated to fix respective issues: addTriangles now accounts for colors alsongside regular color transformation (Note: in flixel-addons some classes still use colors the old way, so this will need a fix pr when merged) and addQuad now properly stores color transformation.

Also deprecated colors and colorsPosition for not being used and verticesPosition and indicesPosition for being pretty much pointless.

TODO (?)

  • Deprecate FlxStrip.repeat since FlxDrawTrianglesItem just ignores it and uses REPEAT for shader anyway. 🤷‍♂️🤷‍♂️
  • ... or make draw items respect repeat property.

NOTE

Turns out camera.alpha doesn't affect transparency of triangles due to openfl bug. Might need workaround for that until it's fixed.
Update: in progress of being fixed. Thanks Redar! (openfl/openfl#2799)

richTrash21 and others added 5 commits September 3, 2025 03:19
- fixed FLX_RENDER_TRIANGLE not rendering anything
- fixed FlxCamera.drawTtriangles not accounting for color transformation on FlxG.renderBlit
- removed flash conditionals in FlxStip, FlxCamera and FlxDrawTrianglesItem
- deprecated "colors" in FlxStrip
- deprecated "colors", "verticesPosition", "indicesPosition" and "colorsPosition" in FlxDrawTrianglesItem
@@ -835,7 +835,7 @@ class FlxCamera extends FlxBasic
position = renderPoint.set();

drawVertices.length = 0;
final verticesLength = vertices.length;
final verticesLength = Std.int(vertices.length / 2) * 2;
Copy link
Member

@Geokureli Geokureli Sep 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you know of a case where we would need to round to the nearest multiple? is it possible to add an incorrect multiple? if so we shouldn't allow that, assume it was a mistake and throw an error then, rather than accounting for it everywhere.

Also, are you sure that in the case where vertices is not the correct length, will this code not malfunction? I imagine it would hit an out of range error

This goes for all cases

@Geokureli
Copy link
Member

Geokureli commented Sep 6, 2025

Also Making 8 sweeping changes in one PR is often 16 times more work for us to verify rather than making separate PRs for each change. This is huge and there's a ton of code style changes adding noise and I don't really know how to test all this

LeonGamerPS1 added a commit to Graveyard-Forks/snowgraved-flixel that referenced this pull request Sep 7, 2025
LeonGamerPS1 added a commit to Graveyard-Forks/snowgraved-flixel that referenced this pull request Sep 7, 2025
@Geokureli
Copy link
Member

Geokureli commented Sep 12, 2025

Since this is a crucial and simple fix, I went and made a solo PR for it.

Copy link
Member

@Geokureli Geokureli left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would close this and try again. Any feature/fix in here that does not have an individual issue, please make one and discuss the need for this change (please include examples). There's a ton of changes here that I'm not a fan of, as well as some general code style/refactoring and you mention "optimizations", all of these are making it really difficult to determine whats actually needed, and why.

  • FlxCamera.drawTriangles now correctly accounts for camera bounds.

Make an issue with a snippet that reproduces this problem.

  • FlxCamera.drawTriangles now accounts for color transformation on FlxG.renderBlit.

This needs as issue as well, if one doesn't exist (it might). I see a lot of #if flash taken out but Note that renderBlit may be true for targets other than flash. This also needs an reproducing snippet

@@ -571,16 +571,15 @@ class FlxCamera extends FlxBasic
static var renderPoint:FlxPoint = FlxPoint.get();

static var renderRect:FlxRect = FlxRect.get();

@:noCompletion
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These shouldn't be exposed by default, I think they'll just confuse 99% of devs and should be reserved for internal use or people who know what they are messing with, eventually we should try and separate the "backend" rendering features from the front-end camera object functionality, but for now, let's leave this

Comment on lines +677 to +680
// TODO: catch this error when the dev actually messes up, not in the draw phase
if (graphic.isDestroyed)
throw 'Cannot queue ${graphic.key}. This sprite was destroyed.';

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you share a case that this guards against? Since this is function is supposed to be used internally I imagine there's a better place to check this

@@ -663,6 +663,9 @@ class FlxFrame implements IFlxDestroyable
cacheFrameMatrix();
}

// update uv
frame = frame;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In general, self referential statements like this should be avoided. Stuff like this make me regret adding getters/setters

Comment on lines -57 to +55
var rect = frame.frame;
rects.push(rect.x);
rects.push(rect.y);
rects.push(rect.width);
rects.push(rect.height);

rects.push(frame.frame.x);
rects.push(frame.frame.y);
rects.push(frame.frame.width);
rects.push(frame.frame.height);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why?

@richTrash21
Copy link
Contributor Author

Closing this, need to rethink changes that i made.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants