Skip to content

Commit

Permalink
ImDrawList, ImDrawListSplitter, Columns: Fixed an issue where changin…
Browse files Browse the repository at this point in the history
…g channels with different TextureId, VtxOffset would incorrectly apply new settings to draw channels. (#3129, #3163)
  • Loading branch information
ocornut committed Jun 8, 2020
1 parent 3bef743 commit 84862ec
Showing 2 changed files with 17 additions and 2 deletions.
3 changes: 3 additions & 0 deletions docs/CHANGELOG.txt
Original file line number Diff line number Diff line change
@@ -59,6 +59,9 @@ Other Changes:
- ImDrawList: Fixed an issue where draw command merging or primitive unreserve while crossing the
VtxOffset boundary would lead to draw commands with wrong VtxOffset. (#3129, #3163, #3232, #2591)
[@thedmd, @Shironekoben, @sergeyn, @ocornut]
- ImDrawList, ImDrawListSplitter, Columns: Fixed an issue where changing channels with different
TextureId, VtxOffset would incorrectly apply new settings to draw channels. (#3129, #3163)
[@ocornut, @thedmd, @Shironekoben]
- ImDrawList, ImDrawListSplitter, Columns: Fixed an issue where starting a split when current
VtxOffset was not zero would lead to draw commands with wrong VtxOffset. (#2591)
- ImDrawList, ImDrawListSplitter, Columns: Fixed an issue where starting a split right after
16 changes: 14 additions & 2 deletions imgui_draw.cpp
Original file line number Diff line number Diff line change
@@ -1435,8 +1435,13 @@ void ImDrawListSplitter::Merge(ImDrawList* draw_list)
if (draw_list->CmdBuffer.Size == 0 || draw_list->CmdBuffer.back().UserCallback != NULL)
draw_list->AddDrawCmd();

draw_list->_OnChangedClipRect(); // We call this instead of AddDrawCmd(), so that empty channels won't produce an extra draw call.
draw_list->_OnChangedTextureID();
// If current command is used with different settings we need to add a new command
ImDrawCmd* curr_cmd = &draw_list->CmdBuffer.Data[draw_list->CmdBuffer.Size - 1];
if (curr_cmd->ElemCount == 0)
ImDrawCmd_HeaderCopy(curr_cmd, &draw_list->_CmdHeader); // Copy ClipRect, TextureId, VtxOffset
else if (ImDrawCmd_HeaderCompare(curr_cmd, &draw_list->_CmdHeader) != 0)
draw_list->AddDrawCmd();

_Count = 1;
}

@@ -1453,6 +1458,13 @@ void ImDrawListSplitter::SetCurrentChannel(ImDrawList* draw_list, int idx)
memcpy(&draw_list->CmdBuffer, &_Channels.Data[idx]._CmdBuffer, sizeof(draw_list->CmdBuffer));
memcpy(&draw_list->IdxBuffer, &_Channels.Data[idx]._IdxBuffer, sizeof(draw_list->IdxBuffer));
draw_list->_IdxWritePtr = draw_list->IdxBuffer.Data + draw_list->IdxBuffer.Size;

// If current command is used with different settings we need to add a new command
ImDrawCmd* curr_cmd = &draw_list->CmdBuffer.Data[draw_list->CmdBuffer.Size - 1];
if (curr_cmd->ElemCount == 0)
ImDrawCmd_HeaderCopy(curr_cmd, &draw_list->_CmdHeader); // Copy ClipRect, TextureId, VtxOffset
else if (ImDrawCmd_HeaderCompare(curr_cmd, &draw_list->_CmdHeader) != 0)
draw_list->AddDrawCmd();
}

//-----------------------------------------------------------------------------

0 comments on commit 84862ec

Please sign in to comment.