FIX:Rotation gizmo coincides with the cut coordinate system in cut gizmo

jira: STUDIO-10868
Change-Id: Ifec448e4d0bab518c07c9d198304daa8c0e95999
This commit is contained in:
zhou.xu 2025-03-14 19:43:25 +08:00 committed by lane.wei
parent 06a50c35fe
commit 1f41a3da7a
3 changed files with 24 additions and 6 deletions

View File

@ -1390,6 +1390,10 @@ void GLGizmoAdvancedCut::on_render_rotate_gizmos() {
m_gizmos[Z].render();
}
else {
Transform3d rotate_tran = Geometry::translation_transform(m_plane_center) * m_rotate_matrix;
for (int i = 0; i < 3; i++) {
m_gizmos[i].set_custom_tran(rotate_tran);
}
m_gizmos[X].render();
m_gizmos[Y].render();
m_gizmos[Z].render();

View File

@ -539,9 +539,16 @@ void GLGizmoRotate::init_data_from_selection(const Selection &selection) {
selection.get_bounding_box_in_current_reference_system();
m_bounding_box = box;
const std::pair<Vec3d, double> sphere = selection.get_bounding_sphere();
if (m_custom_tran.has_value()) {
Geometry::Transformation tran(m_custom_tran.value());
m_center = tran.get_offset();
m_orient_matrix = tran.get_matrix();
} else {
m_center = sphere.first;
m_radius = Offset +sphere.second;
m_orient_matrix = box_trafo;
}
m_radius = Offset + sphere.second;
m_orient_matrix.translation() = m_center;
m_snap_coarse_in_radius = 1.0f / 3.0f;
m_snap_coarse_out_radius = 2.0f * m_snap_coarse_in_radius;
@ -550,6 +557,10 @@ void GLGizmoRotate::init_data_from_selection(const Selection &selection) {
}
void GLGizmoRotate::set_custom_tran(const Transform3d &tran) {
m_custom_tran = tran;
}
BoundingBoxf3 GLGizmoRotate::get_bounding_box() const
{
BoundingBoxf3 t_aabb;

View File

@ -74,7 +74,7 @@ public:
void set_center(const Vec3d &point) { m_custom_center = point; }
void set_force_local_coordinate(bool use) { m_force_local_coordinate = use; }
void init_data_from_selection(const Selection &selection);
void set_custom_tran(const Transform3d &tran);
BoundingBoxf3 get_bounding_box() const override;
protected:
@ -98,6 +98,9 @@ private:
Transform3d transform_to_local(const Selection& selection) const;
// returns the intersection of the mouse ray with the plane perpendicular to the gizmo axis, in local coordinate
Vec3d mouse_position_in_local_plane(const Linef3& mouse_ray, const Selection& selection) const;
private:
std::optional<Transform3d> m_custom_tran;
};
class GLGizmoRotate3D : public GLGizmoBase