imgui-node-editor: Clipping is not related to the window with the latest imgui

I have updated imgui from 1.88dock to 1.89.3dock. The screen is cut, depending on the position. It seems the editor has the size of the window but its clipping is not related to the window but rather to the world space (?).

The recording should explain what’s going on, notice the huge black parts around the editor:

https://user-images.githubusercontent.com/31058/222499397-e62c3d76-0906-4719-9eea-b4b0b03a02d2.mp4

What’s interesting though, I’ve found this code in the imgui_canvas.cpp:

    // #debug: Canvas content.
    //m_DrawList->AddRectFilled(m_StartPos, m_StartPos + m_CurrentSize, IM_COL32(0, 0, 0, 64));
    //m_DrawList->AddRect(m_WidgetRect.Min, m_WidgetRect.Max, IM_COL32(255, 0, 255, 64));

I have uncommented the last line and it seems to fix everything (it is, remove the black parts and not crop the content): obraz

However, it doesn’t seem to be a proper fix since it is commented as debug code.

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Comments: 24 (12 by maintainers)

Commits related to this issue

Most upvoted comments

Thank you @Namek, @pthom, @ocornut all for takin time to investigate the issue.

@pthom This is most awesome repro I saw so far. Thank you very much it was very helpful.

Fixes for all issues listed here were pushed to develop.

Thank you @ocornut for taking a time to investigate. I appreciate that.

You’re correct. Canvas did made some assumption about how ImGui deal with ImDrawCmd. If I can recall correctly there was always an empty one ready in the buffer.

I will investigate the issue.

Bonjour @ocornut 😃 , hi @thedmd and @Namek

Took me 30 mins to figure out how to build and run this but since pthom made the effort to make it I went ahead.

I’m sorry it took you so long to build the example. I think it was an error on my side to use a third party such as HelloImGui.


I rewrote the minimal repro repository so that it uses only ImGui, imgui-node-editor and SDL (and nothing else).

This demo is able to trigger different subtle issues that arise when using docked windows, and/or windows whose size is unknown at the first frame (so that the canvas does not know its size)

They are detailed in the Readme.

Also, I made a short video in order to demonstrate them, as well as the use of the repo (in the hope to make it easier to setup). I think the video is a good way to get a more complete picture of the issue.

thanks


Note: I can confirm that the issue seems to be absent with ImGui docking v1.88 (commit 58eb40db76783f5da09e592ca3eb421f4f2197e3). I’m not sure if that helps, though. Anyhow, I created a branch imgui_1_88 in the repository. It uses the SDL2 branch of SDL (you will need to remove external/ and re-run fetch_external.sh).

I’ll need to let @thedmd finish this investigation, but I looked at iteration into CmdBuffer[] and noticed they started from m_DrawListCommadBufferSize and wanted to see how it was setup:

# if IMGUI_EX_CANVAS_DEFERED()
    m_Ranges.resize(m_Ranges.Size + 1);
    m_CurrentRange = &m_Ranges.back();
    m_CurrentRange->BeginComandIndex = ImMax(m_DrawList->CmdBuffer.Size - 1, 0);
    m_CurrentRange->BeginVertexIndex = m_DrawList->_VtxCurrentIdx + ImVtxOffsetRef(m_DrawList);
# endif
    m_DrawListCommadBufferSize       = ImMax(m_DrawList->CmdBuffer.Size - 1, 0);
    m_DrawListStartVertexIndex       = m_DrawList->_VtxCurrentIdx + ImVtxOffsetRef(m_DrawList);

Since the value is set multiple times every frame, to visualize I use this neat trick:

ImGui::Begin("DEBUG");
ImGui::Text("m_DrawListCommadBufferSize = %d", m_DrawListCommadBufferSize);
ImGui::End();

Creating and appending into a window declared locally inside that function.

When the bug appears a third line appears: image

I suspect changing m_DrawListCommadBufferSize = ImMax(m_DrawList->CmdBuffer.Size - 1, 0); to m_DrawListCommadBufferSize = ImMax(m_DrawList->CmdBuffer.Size, 0); Might be the correct fix for this, but I’ll need @thedmd to investigate and confirm. It certainly appears to fix the issue but I don’t know if that’s the correct fix.

FIx should be applied from IMGUI_VERSION_NUM > 18913.

Just checked with latest imgui from git and the issue is still present.

@Namek I created a minimal reproducible example in this repository

This code is self-contained in a short file: node_clipping_issue.cpp

However it was not possible to use the ImGui version inside node editor, since it is outdated, and adds stack layout patches to ImGui which are not trivial to rebase. So it uses HelloImGui, which is based on a quite recent version of the ImGui docking branch.

I tried to rebase the stack-layout imgui/, checked out imgui-node-editor/develop, updated the copy with latest rebased imgui + stack-layout (with few fixes pushed to https://github.com/thedmd/imgui-node-editor/pull/208) and couldn’t see an issue.

Please actually provide details as to how to reproduce the issue in imgui-node-editor . I don’t even know what example of node-editor looks like the one you posted screenshot of above.