Merge pull request #38019 from lawnjelly/kessel_zindex_batchbreak

Fixes incorrectly joining batch items from earlier z_index layers
This commit is contained in:
Rémi Verschelde 2020-04-19 21:38:33 +02:00 committed by GitHub
commit 2a10e30119
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 4 deletions

View File

@ -1620,7 +1620,8 @@ void RasterizerCanvasGLES2::join_items(Item *p_item_list, int p_z) {
// join is whether to join to the previous batch. // join is whether to join to the previous batch.
// batch_break is whether to PREVENT the next batch from joining with us // batch_break is whether to PREVENT the next batch from joining with us
bool batch_break = false; // batch_break must be preserved over z_indices,
// so is stored in _render_item_state.join_batch_break
while (p_item_list) { while (p_item_list) {
@ -1628,7 +1629,7 @@ void RasterizerCanvasGLES2::join_items(Item *p_item_list, int p_z) {
bool join; bool join;
if (batch_break) { if (_render_item_state.join_batch_break) {
// always start a new batch for this item // always start a new batch for this item
join = false; join = false;
@ -1637,9 +1638,9 @@ void RasterizerCanvasGLES2::join_items(Item *p_item_list, int p_z) {
// even though we know join is false. // even though we know join is false.
// also we need to run try_join_item for every item because it keeps the state up to date, // also we need to run try_join_item for every item because it keeps the state up to date,
// if we didn't run it the state would be out of date. // if we didn't run it the state would be out of date.
try_join_item(ci, _render_item_state, batch_break); try_join_item(ci, _render_item_state, _render_item_state.join_batch_break);
} else { } else {
join = try_join_item(ci, _render_item_state, batch_break); join = try_join_item(ci, _render_item_state, _render_item_state.join_batch_break);
} }
// assume the first item will always return no join // assume the first item will always return no join
@ -1720,6 +1721,10 @@ void RasterizerCanvasGLES2::canvas_render_items_begin(const Color &p_modulate, L
_render_item_state.item_group_modulate = p_modulate; _render_item_state.item_group_modulate = p_modulate;
_render_item_state.item_group_light = p_light; _render_item_state.item_group_light = p_light;
_render_item_state.item_group_base_transform = p_base_transform; _render_item_state.item_group_base_transform = p_base_transform;
// batch break must be preserved over the different z indices,
// to prevent joining to an item on a previous index if not allowed
_render_item_state.join_batch_break = false;
} }
void RasterizerCanvasGLES2::canvas_render_items_end() { void RasterizerCanvasGLES2::canvas_render_items_end() {

View File

@ -200,6 +200,7 @@ class RasterizerCanvasGLES2 : public RasterizerCanvasBaseGLES2 {
// used for joining items only // used for joining items only
BItemJoined *joined_item; BItemJoined *joined_item;
bool join_batch_break;
// 'item group' is data over a single call to canvas_render_items // 'item group' is data over a single call to canvas_render_items
int item_group_z; int item_group_z;