CedricGuillemet / ImGuizmo

Immediate mode 3D gizmo for scene editing and other controls based on Dear Imgui

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Is there a way to always draw the gizmo in the background?

AndreiDespinoiu opened this issue · comments

I have this issue:

overlap2

The "properties" window is drawn using the ImGuiWindowFlags_NoBringToFrontOnFocus flag:

ImGui::Begin("Properties", nullptr,
	  ImGuiWindowFlags_NoSavedSettings
	| ImGuiWindowFlags_NoTitleBar
	| ImGuiWindowFlags_NoResize
	| ImGuiWindowFlags_NoMove
	| ImGuiWindowFlags_NoBringToFrontOnFocus);

This flag is needed to keep other window decorations in check. Sure, it causes some issues with other windows, but they're much less distracting than this since they almost never intersect, but the gizmo frequently intersects with the window and it bothers me that it's being drawn on top.

Any suggestions?

I tried replacing ImGui::GetWindowDrawList() with GetBackgroundDrawList() in ImGuizmo.cpp but it didn't seem to have any effect.

Can you call imguizmo::Manipulate before any other imgui call? I don't think drawlist data arre reordered. So, drawcalls happening anytime earlier would be better.

Problem solved. There were two instances of GetWindowDrawList() in ImGuizmo.cpp. I must have not replaced them both or maybe I didn't rebuild it for both Debug and Release (since I'm linking Dear ImGui statically). Then I noticed there's a function for that, that I can call in my UI code without modifying the library:

ImGuizmo::SetDrawlist(ImGui::GetBackgroundDrawList());

It works correctly now. Displaying it behind the window. I just have to call it every frame before ImGuizmo::Manipulate().

I think regardless of where you call ImGuizmo::Manipulate(), as long as any window is set to the "background", the gizmo will be displayed on top if the gizmo isn't using a background drawlist.

I think I understand why GetWindowDrawList() is used by default. If you have an ImGui::Image() as your viewport, you don't want the gizmo behind it.