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

guizmo is out of the box if I'm far away

HODAKdev opened this issue · comments

commented

Hi, the closer I am to the object, the more guizmo is centered and the further I go backwards, the more it bends, it is normal?
https://user-images.githubusercontent.com/82084934/129267758-0bd2f7b1-8049-43bb-9cab-d2ba7d119795.mp4

That's an interesting issue! thank you for reporting.. I'm taking a look

I could not repro the issue. Are you sure the rectangle/view sizes are properly set? It's the only way I see such issue can happen

commented

Thank you for your response, I think everything is right.
look
I render the scene to a framebuffer and apply it to the ImGui::Image(...);
This is how I set the ImGuizmo..

ImGuizmo::Enable(true);
ImGuizmo::SetOrthographic(false);
ImGuizmo::SetDrawlist();
// window pos, window size
ImGuizmo::SetRect(pos.x, pos.y, framebuffer::mSize.x, framebuffer::mSize.y);
ImGuizmo::Manipulate(glm::value_ptr(sceneCamera::view),
                glm::value_ptr(sceneCamera::projection),
mCurrentGizmoOperation, mCurrentGizmoMode,
glm::value_ptr(model),
NULL, useSnap ? &snap[0] : NULL);

I have all matrices as glm::mat4.
I also tried &...[0][0] without glm::value_ptr and the same.
I also tried to draw a grid and it worked exactly like guizmo.

Can you provide an example on github that I can clone and test?

commented

Can you provide an example on github that I can clone and test?

Of course, I'm working on that.

I think the size (and aspect ratio) provided to glViewPort here:
https://github.com/HODAKdev/imguizmo_bug/blob/563221d25b58bc710832f079ced25f81bbedee5d/vega/engine/vega/vega.h#L170

do not correspond to the size here :

https://github.com/HODAKdev/imguizmo_bug/blob/563221d25b58bc710832f079ced25f81bbedee5d/vega/engine/vega/layout.h#L101

The effect is more visible when the window get resized.
You should get the content size available for the docked window before calling glViewPort.

commented

I think the size (and aspect ratio) provided to glViewPort here:
https://github.com/HODAKdev/imguizmo_bug/blob/563221d25b58bc710832f079ced25f81bbedee5d/vega/engine/vega/vega.h#L170

do not correspond to the size here :

https://github.com/HODAKdev/imguizmo_bug/blob/563221d25b58bc710832f079ced25f81bbedee5d/vega/engine/vega/layout.h#L101

The effect is more visible when the window get resized.
You should get the content size available for the docked window before calling glViewPort.

Why isn't it correspond when mSize.x & mSize.y has the same size?

You should get the content size available for the docked window before calling glViewPort.

I've tried it and it's always the same, i think the problem is in this: https://github.com/HODAKdev/imguizmo_bug/blob/563221d25b58bc710832f079ced25f81bbedee5d/vega/engine/vega/vega.h#L176

the glviewport call for displaying 3D should correspond to the imgui window content size

commented

the glviewport call for displaying 3D should correspond to the imgui window content size

I tried it but it didn't help :(
I looked at some game engines that use imgui and imguizmo and it works exactly like mine.

I did a quick and dirty fix : https://github.com/HODAKdev/imguizmo_bug/pull/1
the position/size for the 3d content glviewport did not correspond to the window size. it must be the same as setrect for the gizmo or 3d and gizmo viewport are out of sync.

commented

Thank you for fixing this.
image1
Oh, I should have used ImGui::GetCursorPos() and apply to glViewport, it works great but when I apply multiple windows it looks like this:
image2

Did you try to call BeginFrame(); for each view?

commented

yes but doesn't help...
img1
GetCursorPos().x is at 0 so it screen doesn't shift:
img2
If you put it on the lava side then it works well, i tried to move it with GetWindowPos() but we are where we were:
img3

Also, take a look at window mode :

if (useWindow)

commented

I tried it and it's better but still escapes guizmo..
img1
code..
img2

commented

Never mind I'll leave it like this and thank you very much for your help.