-
Notifications
You must be signed in to change notification settings - Fork 479
Breaking Change: Rendering cleanup #3488
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
base: dev
Are you sure you want to change the base?
Changes from all commits
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 |
---|---|---|
|
@@ -35,11 +35,11 @@ class FlxDrawQuadsItem extends FlxDrawBaseItem<FlxDrawQuadsItem> | |
super.reset(); | ||
rects.length = 0; | ||
transforms.length = 0; | ||
alphas.splice(0, alphas.length); | ||
alphas.resize(0); | ||
if (colorMultipliers != null) | ||
colorMultipliers.splice(0, colorMultipliers.length); | ||
colorMultipliers.resize(0); | ||
if (colorOffsets != null) | ||
colorOffsets.splice(0, colorOffsets.length); | ||
colorOffsets.resize(0); | ||
} | ||
|
||
override public function dispose():Void | ||
|
@@ -71,40 +71,36 @@ class FlxDrawQuadsItem extends FlxDrawBaseItem<FlxDrawQuadsItem> | |
for (i in 0...VERTICES_PER_QUAD) | ||
alphas.push(alphaMultiplier); | ||
|
||
if (colored || hasColorOffsets) | ||
if (colored) | ||
{ | ||
if (colorMultipliers == null) | ||
colorMultipliers = []; | ||
|
||
if (colorOffsets == null) | ||
colorOffsets = []; | ||
|
||
for (i in 0...VERTICES_PER_QUAD) | ||
if (transform != null) | ||
{ | ||
if (transform != null) | ||
for (i in 0...VERTICES_PER_QUAD) | ||
{ | ||
colorMultipliers.push(transform.redMultiplier); | ||
colorMultipliers.push(transform.greenMultiplier); | ||
colorMultipliers.push(transform.blueMultiplier); | ||
colorMultipliers.push(1); | ||
|
||
colorOffsets.push(transform.redOffset); | ||
colorOffsets.push(transform.greenOffset); | ||
colorOffsets.push(transform.blueOffset); | ||
colorOffsets.push(transform.alphaOffset); | ||
} | ||
else | ||
} | ||
else | ||
{ | ||
for (i in 0...(VERTICES_PER_QUAD * 4)) | ||
{ | ||
colorMultipliers.push(1); | ||
colorMultipliers.push(1); | ||
colorMultipliers.push(1); | ||
|
||
colorOffsets.push(0); | ||
colorOffsets.push(0); | ||
colorOffsets.push(0); | ||
colorOffsets.push(0); | ||
} | ||
|
||
colorMultipliers.push(1); | ||
} | ||
} | ||
} | ||
|
@@ -114,24 +110,28 @@ class FlxDrawQuadsItem extends FlxDrawBaseItem<FlxDrawQuadsItem> | |
{ | ||
if (rects.length == 0) | ||
return; | ||
|
||
// TODO: catch this error when the dev actually messes up, not in the draw phase | ||
if (shader == null && graphics.isDestroyed) | ||
throw 'Attempted to render an invalid FlxDrawItem, did you destroy a cached sprite?'; | ||
|
||
final shader = shader != null ? shader : graphics.shader; | ||
shader.bitmap.input = graphics.bitmap; | ||
shader.bitmap.filter = (camera.antialiasing || antialiasing) ? LINEAR : NEAREST; | ||
shader.alpha.value = alphas; | ||
|
||
if (colored || hasColorOffsets) | ||
if (colored) | ||
Comment on lines
-127
to
+123
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 wanna say I tried this before and got unexpected issues in some cases. I'll try and find it. 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. Please do let me know if it causes any issues, I've tried in many of my projects and its not causing any problems on my part. |
||
{ | ||
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); | ||
setParameterValue(shader.hasColorTransform, colored); | ||
|
||
camera.canvas.graphics.overrideBlendMode(blend); | ||
camera.canvas.graphics.beginShaderFill(shader); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't like change the default value of args, even if it is in a major release there's no good way to broadcast this to devs and they end up having either unknown bugs, or hard to track down bugs in their game.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's why I believe this part would be more fit for a major version change, though for this part in particular its mandatory, as the repeat being set to false by default would result in more broken visual behaviour with the repeat wrap mode actually being added as a setting for tile rendering.