diff --git a/CMCore b/CMCore index f1a36055..dd01d191 160000 --- a/CMCore +++ b/CMCore @@ -1 +1 @@ -Subproject commit f1a36055e430e110e3ac1ff643920715b9efeb2d +Subproject commit dd01d1919a119d1aeac74dd4d4994ba45c0144ad diff --git a/CMPlatform b/CMPlatform index 5c4851e5..eec230df 160000 --- a/CMPlatform +++ b/CMPlatform @@ -1 +1 @@ -Subproject commit 5c4851e586b97f96f17180ba2574f02857be298a +Subproject commit eec230df6c48d55ea11d096dba34bbd0499a0d42 diff --git a/example/Gizmo/Gizmo3DMove.cpp b/example/Gizmo/Gizmo3DMove.cpp index 5645c8f8..4befa128 100644 --- a/example/Gizmo/Gizmo3DMove.cpp +++ b/example/Gizmo/Gizmo3DMove.cpp @@ -54,11 +54,15 @@ namespace MeshComponent *sphere=nullptr; GizmoMoveAxis axis[3]{}; //X,Y,Z 三个轴 - int CurAXIS=-1; //当前鼠标选中轴 - float CurDist=0; //当前距离 + protected: - int PickAXIS=-1; //拾取轴 - float PickDist=0; //拾取辆距离轴心的距离 + int CurAXIS=-1; //当前鼠标选中轴 + float CurDist=0; //当前距离 + + int PickAXIS=-1; //拾取轴 + float PickDist=0; //拾取辆距离轴心的距离 + + TransformTranslate3f CurTranslate; public: @@ -205,10 +209,12 @@ namespace { GizmoMoveNode::OnMove(mp); - if(CurAXIS>0&&CurAXIS<3) + if(CurAXIS>=0&&CurAXIS<3) { PickAXIS=CurAXIS; PickDist=CurDist; + + CurTranslate.SetOffset(Vector3f(0,0,0)); //重置当前平移偏移 } return io::EventProcResult::Continue; @@ -269,6 +275,12 @@ namespace CurAXIS=i; CurDist=glm::length(p_ls); //计算线段上的点与原点的距离 + + if(CurAXIS==PickAXIS) //如果当前轴与拾取轴相同 + { + //如果当前轴与拾取轴相同,则计算平移偏移 + CurTranslate.SetOffset(axis_vector*(CurDist-PickDist)); + } } else {