mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-10-24 17:21:11 -06:00
Fixed flatten gizmo's flattening normal
This commit is contained in:
parent
407aee9942
commit
011281068b
3 changed files with 5 additions and 8 deletions
|
|
@ -2999,9 +2999,9 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt)
|
|||
if (m_gizmos.get_current_type() == Gizmos::Flatten) {
|
||||
// Rotate the object so the normal points downward:
|
||||
Vec3d normal = m_gizmos.get_flattening_normal();
|
||||
if (normal != Vec3d::Zero()) {
|
||||
Vec3d axis = normal(2) > 0.999f ? Vec3d::UnitX() : normal.cross(-Vec3d::UnitZ());
|
||||
float angle = acos(-normal(2));
|
||||
if (normal(0) != 0.0 || normal(1) != 0.0 || normal(2) != 0.0) {
|
||||
Vec3d axis = normal(2) > 0.999 ? Vec3d::UnitX() : normal.cross(-Vec3d::UnitZ()).normalized();
|
||||
float angle = acos(clamp(-1.0, 1.0, -normal(2)));
|
||||
m_on_gizmo_rotate_callback.call(angle, (float)axis(0), (float)axis(1), (float)axis(2));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1282,7 +1282,7 @@ bool GLGizmoFlatten::is_plane_update_necessary() const
|
|||
Vec3d GLGizmoFlatten::get_flattening_normal() const {
|
||||
Vec3d normal = m_model_object->instances.front()->world_matrix().matrix().block(0, 0, 3, 3) * m_normal;
|
||||
m_normal = Vec3d::Zero();
|
||||
return normal;
|
||||
return normal.normalized();
|
||||
}
|
||||
|
||||
} // namespace GUI
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue