Skip to content

Rewrite SegmentSet as a Mesh - #72

Open
player-03 wants to merge 42 commits into
openfl:masterfrom
player-03:SegmentSet_Mesh
Open

player-03 wants to merge 42 commits into
openfl:masterfrom
player-03:SegmentSet_Mesh

Conversation

@player-03

Copy link
Copy Markdown
Collaborator

This allows applying custom materials and/or effects to your line segments, and fixes some bugs related to line width. Previously, lines were always drawn at twice the requested width, and would get even wider if stage.height > stage.width.

The "Lines," "ParticleTrails," and "MouseInteraction" samples work as-is, albeit with thinner lines than before. ParticleTrails looks better now, IMO, but the others need updating to fix that.

This PR includes #66, which allows CompactSubGeometry to include a vertex color attribute.

…es `CompactSubGeometry` includes.

Most users likely don't need "secondary UVs", for instance, and could save memory by omitting them. Others might want to add a custom 4-length attribute.
Without that, the clone will interpret all its data incorrectly.
This reduces duplicate code and allows activating custom attributes.
Methods can use this to alert other classes that they require certain custom attributes. These attributes will also automatically be tracked and deduplicated.
This version avoids unnecessary allocations, and can be chained.
Technically, the register only contains the first part of the matrix, and the next three registers contain the rest, but I didn't want to make the comment longer.
This currently doesn't matter because compilers are never reused, but that could change someday.
This allows applying other materials and methods to the set, though these interactions are untested and not well supported. Per-segment colors are temporarily disabled, though `ColorMaterial` can be used to set a color globally.

This also fixes some bugs with the line width. This means the lines are no longer twice as wide as `thickness` (though a temporary `-D away3d_double_line_width` flag exists to reverse this).
@player-03
player-03 marked this pull request as ready for review October 4, 2026 02:20
@player-03

Copy link
Copy Markdown
Collaborator Author

Here's the Lines sample in action. I updated the line thickness and used FogMethod for the green lines, though it also works without any changes.

Lines.mp4

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.

1 participant