CedricGuillemet / ImGuizmo

Immediate mode 3D gizmo for scene editing and other controls based on Dear Imgui
MIT License
3.2k stars 902 forks source link

Weird mouse detection problem #110

Closed MC-117 closed 4 years ago

MC-117 commented 4 years ago

Hello, thank you for the great manipulater. However, I meet a weird mouse detection problem related to the viewpoint (view matrix). There are 3 situation for the detection.

  1. The manipulater can work prefectly in some specific viewpoints. (Figure 1)
  2. The manipulater cannot detect the mouse hovering for most of the viewpoints except for the center point. (Figure 2)
  3. The manipulater can detect the hovering but move target object in inversed direction. (Figure 2)

Figure1 Figure 1 Figure2 Figure 2

CedricGuillemet commented 4 years ago

Hi ! Thank you for your feedback! Can you dump the matrix values for view/projection/model when you get the issue in fig 2? And rectangle x,y width, height as well.

MC-117 commented 4 years ago

Common:

Screen Rect: [ 0, 0, 1920, 1080 ] zNear: 0.1 zFar: 10000000 ModelM: Identity

ProjM 0.562500, 0.000000, 0.000000, 0.000000 0.000000, 1.000000, 0.000000, 0.000000 0.000000, 0.000000, -1.000000, -0.200000 0.000000, 0.000000, -1.000000, 0.000000

Situation 1:

ViewM 0.882988274, -0.469395131, -1.15633075e-05, 8.27197838 0.156591877, 0.294544756, 0.942720711, -0.404474497 -0.442505121, -0.832413137, 0.333583057, -28.8341942 0.000000000, 0.000000000, 0.000000000, 1.00000000

Situation 2:

ViewM 0.707106769, -0.707106769, 5.56433077e-09, -0.000000 -3.93457578e-09, 3.93457578e-09, 1.000000, -10.0000000 -0.707106769, -0.707106769, -0.000000000, -28.2842712 0.000000000, 0.000000000, 0.000000000, 1.00000000

Situation 3:

ViewM 0.796562731, -0.604555845, -6.39259497e-06, 3.84020138 0.137807116, 0.181564331, 0.973675251, -3.34932351 -0.588639915, -0.775594354, 0.227939501, -29.5640812 0.000000000, 0.000000000, 0.000000000, 1.00000000

CedricGuillemet commented 4 years ago

I've found a fix and pushed the change in master. Let me know how it goes for you.

MC-117 commented 4 years ago

That really works fine for me. Thank you very much! But I found another small bug. When I use snapping for rotation, Guizmo will automaticly add an offset which value is 0.81. Capture Capture

CedricGuillemet commented 4 years ago

I'm taking a look!

CedricGuillemet commented 4 years ago

I improved the precision with a better clamp.

MC-117 commented 4 years ago

Everything goes fine now. Thank you very much!