Closed Makogan closed 2 years ago
I added these 2 lines to the code:
ImGui::Text(ImGuizmo::IsOver()?"Over gizmo":"");
ImGui::Text(ImGuizmo::IsOver(ImGuizmo::TRANSLATE) ? "Over translate gizmo" : "not");
as far as the libraries are concerned the mouse is never hovering over the gizmo.
Did you check it might be caused by a Y flip?
I am using vulkan so the Y is indeed flipped, but to fix it normally you just have to negate the 1, 1 entry of the projection matrix, which I did. Whether I leave or take out the proj(1, 1) *= -1;
I don;t see a difference.
I have carefully stepped through the code using GDB and ran into a very, very, very, bizarre situation.
Inside:
static void ComputeCameraRay(vec_t& rayOrigin, vec_t& rayDir, ImVec2 position = ImVec2(gContext.mX, gContext.mY), ImVec2 size = ImVec2(gContext.mWidth, gContext.mHeight))
{
ImGuiIO& io = ImGui::GetIO();
matrix_t mViewProjInverse;
mViewProjInverse.Inverse(gContext.mViewMat * gContext.mProjectionMat);
const float mox = ((io.MousePos.x - position.x) / size.x) * 2.f - 1.f;
const float moy = (1.f - ((io.MousePos.y - position.y) / size.y)) * 2.f - 1.f;
const float zNear = gContext.mReversed ? (1.f - FLT_EPSILON) : 0.f;
const float zFar = gContext.mReversed ? 0.f : (1.f - FLT_EPSILON);
rayOrigin.Transform(makeVect(mox, moy, zNear, 1.f), mViewProjInverse);
rayOrigin *= 1.f / rayOrigin.w;
vec_t rayEnd;
rayEnd.Transform(makeVect(mox, moy, zFar, 1.f), mViewProjInverse);
rayEnd *= 1.f / rayEnd.w;
rayDir = Normalized(rayEnd - rayOrigin);
}
i put a breakpoint on the line ImGuiIO& io = ImGui::GetIO();
. This is what gdb says:
(gdb) p io.MousePos.x
$15 = 0
(gdb) p ImGui::GetIO().MousePos.x
$16 = 73
So the assignment is somehow failing?
If anyone ever runs into something like this in the future:
Sorry to bother again, I managed to get the guizmos rendered but I have tried for a couple of hours to manupulate them without success:
As you can see the guizmo appears on the screen, but there is no highlighting of any sorte when the mouse is right on top of the guizmo.
This is my Imgui function:
All imgui proper widgets do behave normally, i.e. I can drag and scale windows as well as editing text parameters, this is a problem only with the ImGuizmo widgets.
I also tried copy pasting the
EditTransform
function from the readme and tweak it the least possible so that it compiles on my codebase, same problem, the guizmos are unresponsive.