-
Notifications
You must be signed in to change notification settings - Fork 485
Fix FLX_RENDER_TRIANGLE not rendering anything
#3505
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 5 commits
e0bd735
0dcd6bb
4ad77fc
a0d7539
4be6fd0
8060c67
b4c59d0
f7c178d
902fbdb
69fbedb
4ac7fd9
abc1236
1a18bf8
362931d
8665091
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -20,6 +20,7 @@ typedef DrawData<T> = openfl.Vector<T>; | |
| */ | ||
| class FlxDrawTrianglesItem extends FlxDrawBaseItem<FlxDrawTrianglesItem> | ||
| { | ||
| static inline final INDICES_PER_QUAD = 6; | ||
| static var point:FlxPoint = FlxPoint.get(); | ||
| static var rect:FlxRect = FlxRect.get(); | ||
|
|
||
|
|
@@ -280,12 +281,11 @@ class FlxDrawTrianglesItem extends FlxDrawBaseItem<FlxDrawTrianglesItem> | |
|
|
||
| override public function addQuad(frame:FlxFrame, matrix:FlxMatrix, ?transform:ColorTransform):Void | ||
| { | ||
| var prevVerticesPos:Int = verticesPosition; | ||
| var prevIndicesPos:Int = indicesPosition; | ||
| var prevColorsPos:Int = colorsPosition; | ||
| var prevNumberOfVertices:Int = numVertices; | ||
| final prevVerticesPos = verticesPosition; | ||
| final prevIndicesPos = indicesPosition; | ||
| final prevNumberOfVertices = numVertices; | ||
|
|
||
| var point = FlxPoint.get(); | ||
| point.set(0, 0); | ||
richTrash21 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| point.transform(matrix); | ||
|
|
||
| vertices[prevVerticesPos] = point.x; | ||
|
|
@@ -303,59 +303,70 @@ class FlxDrawTrianglesItem extends FlxDrawBaseItem<FlxDrawTrianglesItem> | |
| uvtData[prevVerticesPos + 2] = frame.uv.right; | ||
| uvtData[prevVerticesPos + 3] = frame.uv.top; | ||
|
|
||
| point.set(frame.frame.width, frame.frame.height); | ||
| point.set(0, frame.frame.height); | ||
| point.transform(matrix); | ||
|
|
||
| vertices[prevVerticesPos + 4] = point.x; | ||
| vertices[prevVerticesPos + 5] = point.y; | ||
|
|
||
| uvtData[prevVerticesPos + 4] = frame.uv.right; | ||
| uvtData[prevVerticesPos + 4] = frame.uv.left; | ||
| uvtData[prevVerticesPos + 5] = frame.uv.bottom; | ||
|
|
||
| point.set(0, frame.frame.height); | ||
| point.set(frame.frame.width, frame.frame.height); | ||
| point.transform(matrix); | ||
|
|
||
| vertices[prevVerticesPos + 6] = point.x; | ||
| vertices[prevVerticesPos + 7] = point.y; | ||
|
|
||
| point.put(); | ||
|
|
||
| uvtData[prevVerticesPos + 6] = frame.uv.left; | ||
| uvtData[prevVerticesPos + 6] = frame.uv.right; | ||
| uvtData[prevVerticesPos + 7] = frame.uv.bottom; | ||
|
|
||
| indices[prevIndicesPos] = prevNumberOfVertices; | ||
| indices[prevIndicesPos + 1] = prevNumberOfVertices + 1; | ||
| indices[prevIndicesPos + 2] = prevNumberOfVertices + 2; | ||
| indices[prevIndicesPos + 3] = prevNumberOfVertices + 2; | ||
| indices[prevIndicesPos + 4] = prevNumberOfVertices + 3; | ||
| indices[prevIndicesPos + 5] = prevNumberOfVertices; | ||
| indices[prevIndicesPos + 3] = prevNumberOfVertices + 1; | ||
| indices[prevIndicesPos + 4] = prevNumberOfVertices + 2; | ||
| indices[prevIndicesPos + 5] = prevNumberOfVertices + 3; | ||
Geokureli marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| if (colored) | ||
| final alphaMultiplier = transform != null ? transform.alphaMultiplier : 1.0; | ||
| for (i in 0...INDICES_PER_QUAD) | ||
| alphas.push(alphaMultiplier); | ||
|
|
||
| if (colored || hasColorOffsets) | ||
| { | ||
| var red = 1.0; | ||
| var green = 1.0; | ||
| var blue = 1.0; | ||
| var alpha = 1.0; | ||
|
|
||
| if (transform != null) | ||
| if (colorMultipliers == null) | ||
| colorMultipliers = []; | ||
|
|
||
| if (colorOffsets == null) | ||
| colorOffsets = []; | ||
|
|
||
| for (i in 0...INDICES_PER_QUAD) | ||
| { | ||
| red = transform.redMultiplier; | ||
| green = transform.greenMultiplier; | ||
| blue = transform.blueMultiplier; | ||
|
|
||
| #if !neko | ||
| alpha = transform.alphaMultiplier; | ||
| #end | ||
| if (transform != null) | ||
| { | ||
| colorMultipliers.push(transform.redMultiplier); | ||
| colorMultipliers.push(transform.greenMultiplier); | ||
| colorMultipliers.push(transform.blueMultiplier); | ||
|
|
||
| colorOffsets.push(transform.redOffset); | ||
| colorOffsets.push(transform.greenOffset); | ||
| colorOffsets.push(transform.blueOffset); | ||
| colorOffsets.push(transform.alphaOffset); | ||
| } | ||
| else | ||
| { | ||
| colorMultipliers.push(1); | ||
| colorMultipliers.push(1); | ||
| colorMultipliers.push(1); | ||
|
|
||
| colorOffsets.push(0); | ||
| colorOffsets.push(0); | ||
| colorOffsets.push(0); | ||
| colorOffsets.push(0); | ||
| } | ||
|
|
||
| colorMultipliers.push(1); | ||
| } | ||
|
|
||
| var color = FlxColor.fromRGBFloat(red, green, blue, alpha); | ||
|
|
||
| colors[prevColorsPos] = color; | ||
| colors[prevColorsPos + 1] = color; | ||
| colors[prevColorsPos + 2] = color; | ||
| colors[prevColorsPos + 3] = color; | ||
|
Comment on lines
-353
to
-356
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we deprecate There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I notice colors is still used in There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Yes, but only in triangle draw item. I think
FYI, this is explained this in the description. This was also originally adressed in #3472, where There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Care to make an issue detailing the ideal implementation of |
||
|
|
||
| colorsPosition += 4; | ||
| } | ||
|
|
||
| verticesPosition += 8; | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.