Skip to content

Commit

Permalink
Fix flxstrip color-not reset causing not rendering for batches sharin…
Browse files Browse the repository at this point in the history
…g the same shader.
  • Loading branch information
davidetan committed Jul 19, 2024
1 parent ac488bf commit 5e5dc07
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions flixel/graphics/tile/FlxDrawTrianglesItem.hx
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,11 @@ class FlxDrawTrianglesItem extends FlxDrawBaseItem<FlxDrawTrianglesItem>
shader.colorMultiplier.value = colorMultipliers;
shader.colorOffset.value = colorOffsets;
}
else
{
shader.colorMultiplier.value = null;
shader.colorOffset.value = null;
}

setParameterValue(shader.hasTransform, true);
setParameterValue(shader.hasColorTransform, colored || hasColorOffsets);
Expand Down Expand Up @@ -175,6 +180,7 @@ class FlxDrawTrianglesItem extends FlxDrawBaseItem<FlxDrawTrianglesItem>
i += 2;
}

var indicesLength:Int = indices.length;
if (!cameraBounds.overlaps(bounds))
{
this.vertices.splice(this.vertices.length - verticesLength, verticesLength);
Expand All @@ -187,7 +193,6 @@ class FlxDrawTrianglesItem extends FlxDrawBaseItem<FlxDrawTrianglesItem>
this.uvtData[prevUVTDataLength + i] = uvtData[i];
}

var indicesLength:Int = indices.length;
for (i in 0...indicesLength)
{
this.indices[prevIndicesLength + i] = indices[i] + prevNumberOfVertices;
Expand All @@ -211,11 +216,9 @@ class FlxDrawTrianglesItem extends FlxDrawBaseItem<FlxDrawTrianglesItem>
cameraBounds.putWeak();

#if !flash
for (_ in 0...numTriangles)
for (_ in 0...indicesLength)
{
alphas.push(transform != null ? transform.alphaMultiplier : 1.0);
alphas.push(transform != null ? transform.alphaMultiplier : 1.0);
alphas.push(transform != null ? transform.alphaMultiplier : 1.0);
}

if (colored || hasColorOffsets)
Expand All @@ -226,7 +229,7 @@ class FlxDrawTrianglesItem extends FlxDrawBaseItem<FlxDrawTrianglesItem>
if (colorOffsets == null)
colorOffsets = [];

for (_ in 0...(numTriangles * 3))
for (_ in 0...indicesLength)
{
if(transform != null)
{
Expand Down

0 comments on commit 5e5dc07

Please sign in to comment.