@@ -666,9 +666,8 @@ namespace IMGUIZMO_NAMESPACE
666666
667667 struct Context
668668 {
669- Context () : mbUsing(false ), mbUsingViewManipulate(false ), mbEnable(true ), mbUsingBounds(false )
669+ Context () : mbUsing(false ), mbUsingViewManipulate(false ), mbEnable(true ), mIsViewManipulatorHovered ( false ), mbUsingBounds(false )
670670 {
671- mIDStack .push_back (-1 );
672671 }
673672
674673 ImDrawList* mDrawList ;
@@ -707,6 +706,7 @@ namespace IMGUIZMO_NAMESPACE
707706 bool mbEnable;
708707 bool mbMouseOver;
709708 bool mReversed ; // reversed projection matrix
709+ bool mIsViewManipulatorHovered ;
710710
711711 // translation
712712 vec_t mTranslationPlan ;
@@ -768,7 +768,14 @@ namespace IMGUIZMO_NAMESPACE
768768 bool mAllowAxisFlip = true ;
769769 float mGizmoSizeClipSpace = 0 .1f ;
770770
771- inline ImGuiID GetCurrentID () {return mIDStack .back ();}
771+ inline ImGuiID GetCurrentID ()
772+ {
773+ if (mIDStack .empty ())
774+ {
775+ mIDStack .push_back (-1 );
776+ }
777+ return mIDStack .back ();
778+ }
772779 };
773780
774781 static Context gContext ;
@@ -1007,6 +1014,11 @@ namespace IMGUIZMO_NAMESPACE
10071014 return gContext .mbUsingViewManipulate ;
10081015 }
10091016
1017+ bool IsViewManipulateHovered ()
1018+ {
1019+ return gContext .mIsViewManipulatorHovered ;
1020+ }
1021+
10101022 bool IsUsingAny ()
10111023 {
10121024 return gContext .mbUsing || gContext .mbUsingBounds ;
@@ -1094,7 +1106,6 @@ namespace IMGUIZMO_NAMESPACE
10941106 // compute scale from the size of camera right vector projected on screen at the matrix position
10951107 vec_t pointRight = viewInverse.v .right ;
10961108 pointRight.TransformPoint (gContext .mViewProjection );
1097- gContext .mScreenFactor = gContext .mGizmoSizeClipSpace / (pointRight.x / pointRight.w - gContext .mMVP .v .position .x / gContext .mMVP .v .position .w );
10981109
10991110 vec_t rightViewInverse = viewInverse.v .right ;
11001111 rightViewInverse.TransformVector (gContext .mModelInverse );
@@ -2543,12 +2554,16 @@ namespace IMGUIZMO_NAMESPACE
25432554
25442555 void SetID (int id)
25452556 {
2557+ if (gContext .mIDStack .empty ())
2558+ {
2559+ gContext .mIDStack .push_back (-1 );
2560+ }
25462561 gContext .mIDStack .back () = id;
25472562 }
25482563
25492564 ImGuiID GetID (const char * str, const char * str_end)
25502565 {
2551- ImGuiID seed = gContext .mIDStack . back ();
2566+ ImGuiID seed = gContext .GetCurrentID ();
25522567 ImGuiID id = ImHashStr (str, str_end ? (str_end - str) : 0 , seed);
25532568 return id;
25542569 }
@@ -2560,14 +2575,14 @@ namespace IMGUIZMO_NAMESPACE
25602575
25612576 ImGuiID GetID (const void * ptr)
25622577 {
2563- ImGuiID seed = gContext .mIDStack . back ();
2578+ ImGuiID seed = gContext .GetCurrentID ();
25642579 ImGuiID id = ImHashData (&ptr, sizeof (void *), seed);
25652580 return id;
25662581 }
25672582
25682583 ImGuiID GetID (int n)
25692584 {
2570- ImGuiID seed = gContext .mIDStack . back ();
2585+ ImGuiID seed = gContext .GetCurrentID ();
25712586 ImGuiID id = ImHashData (&n, sizeof (n), seed);
25722587 return id;
25732588 }
@@ -2907,7 +2922,6 @@ namespace IMGUIZMO_NAMESPACE
29072922 {
29082923 static bool isDraging = false ;
29092924 static bool isClicking = false ;
2910- static bool isInside = false ;
29112925 static vec_t interpolationUp;
29122926 static vec_t interpolationDir;
29132927 static int interpolationFrames = 0 ;
@@ -3020,7 +3034,7 @@ namespace IMGUIZMO_NAMESPACE
30203034 if (iPass)
30213035 {
30223036 ImU32 directionColor = GetColorU32 (DIRECTION_X + normalIndex);
3023- gContext .mDrawList ->AddConvexPolyFilled (faceCoordsScreen, 4 , (directionColor | IM_COL32 (0x80 , 0x80 , 0x80 , 0x80 )) | (isInside ? IM_COL32 (0x08 , 0x08 , 0x08 , 0 ) : 0 ));
3037+ gContext .mDrawList ->AddConvexPolyFilled (faceCoordsScreen, 4 , (directionColor | IM_COL32 (0x80 , 0x80 , 0x80 , 0x80 )) | (gContext . mIsViewManipulatorHovered ? IM_COL32 (0x08 , 0x08 , 0x08 , 0 ) : 0 ));
30243038 if (boxes[boxCoordInt])
30253039 {
30263040 gContext .mDrawList ->AddConvexPolyFilled (faceCoordsScreen, 4 , IM_COL32 (0xF0 , 0xA0 , 0x60 , 0x80 ));
@@ -3049,7 +3063,7 @@ namespace IMGUIZMO_NAMESPACE
30493063 vec_t newEye = camTarget + newDir * length;
30503064 LookAt (&newEye.x , &camTarget.x , &newUp.x , view);
30513065 }
3052- isInside = gContext .mbMouseOver && ImRect (position, position + size).Contains (io.MousePos );
3066+ gContext . mIsViewManipulatorHovered = gContext .mbMouseOver && ImRect (position, position + size).Contains (io.MousePos );
30533067
30543068 if (io.MouseDown [0 ] && (fabsf (io.MouseDelta [0 ]) || fabsf (io.MouseDelta [1 ])) && isClicking)
30553069 {
0 commit comments