mirror of
https://git.mirrors.martin98.com/https://github.com/prusa3d/PrusaSlicer.git
synced 2025-08-14 15:35:55 +08:00
Tech ENABLE_WORLD_COORDINATE - Resize Move and Rotate gizmos in dependence of the selected coordinate system
Fixed conflicts during rebase with master
This commit is contained in:
parent
ca5742c401
commit
c968ba05fb
@ -134,14 +134,23 @@ void GLGizmoMove3D::on_render()
|
|||||||
m_cone.init_from(its_make_cone(1.0, 1.0, double(PI) / 18.0));
|
m_cone.init_from(its_make_cone(1.0, 1.0, double(PI) / 18.0));
|
||||||
#endif // !ENABLE_GIZMO_GRABBER_REFACTOR
|
#endif // !ENABLE_GIZMO_GRABBER_REFACTOR
|
||||||
|
|
||||||
const Selection& selection = m_parent.get_selection();
|
|
||||||
|
|
||||||
glsafe(::glClear(GL_DEPTH_BUFFER_BIT));
|
glsafe(::glClear(GL_DEPTH_BUFFER_BIT));
|
||||||
glsafe(::glEnable(GL_DEPTH_TEST));
|
glsafe(::glEnable(GL_DEPTH_TEST));
|
||||||
|
|
||||||
const BoundingBoxf3& box = selection.get_bounding_box();
|
const Selection& selection = m_parent.get_selection();
|
||||||
const Vec3d& center = box.center();
|
|
||||||
#if ENABLE_WORLD_COORDINATE
|
#if ENABLE_WORLD_COORDINATE
|
||||||
|
BoundingBoxf3 box;
|
||||||
|
if (wxGetApp().obj_manipul()->get_world_coordinates())
|
||||||
|
box = selection.get_bounding_box();
|
||||||
|
else {
|
||||||
|
const Selection::IndicesList& ids = selection.get_volume_idxs();
|
||||||
|
for (unsigned int id : ids) {
|
||||||
|
const GLVolume* v = selection.get_volume(id);
|
||||||
|
box.merge(v->transformed_convex_hull_bounding_box(v->get_volume_transformation().get_matrix()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
glsafe(::glPushMatrix());
|
glsafe(::glPushMatrix());
|
||||||
transform_to_local(selection);
|
transform_to_local(selection);
|
||||||
|
|
||||||
@ -160,6 +169,8 @@ void GLGizmoMove3D::on_render()
|
|||||||
m_grabbers[2].center = { 0.0, 0.0, half_box_size.z() + Offset };
|
m_grabbers[2].center = { 0.0, 0.0, half_box_size.z() + Offset };
|
||||||
m_grabbers[2].color = AXES_COLOR[2];
|
m_grabbers[2].color = AXES_COLOR[2];
|
||||||
#else
|
#else
|
||||||
|
const Selection& selection = m_parent.get_selection();
|
||||||
|
const BoundingBoxf3& box = selection.get_bounding_box();
|
||||||
// x axis
|
// x axis
|
||||||
m_grabbers[0].center = { box.max.x() + Offset, center.y(), center.z() };
|
m_grabbers[0].center = { box.max.x() + Offset, center.y(), center.z() };
|
||||||
m_grabbers[0].color = AXES_COLOR[0];
|
m_grabbers[0].color = AXES_COLOR[0];
|
||||||
@ -176,10 +187,19 @@ void GLGizmoMove3D::on_render()
|
|||||||
glsafe(::glLineWidth((m_hover_id != -1) ? 2.0f : 1.5f));
|
glsafe(::glLineWidth((m_hover_id != -1) ? 2.0f : 1.5f));
|
||||||
|
|
||||||
#if ENABLE_LEGACY_OPENGL_REMOVAL
|
#if ENABLE_LEGACY_OPENGL_REMOVAL
|
||||||
|
#if ENABLE_WORLD_COORDINATE
|
||||||
|
auto render_grabber_connection = [this, &zero](unsigned int id) {
|
||||||
|
#else
|
||||||
auto render_grabber_connection = [this, ¢er](unsigned int id) {
|
auto render_grabber_connection = [this, ¢er](unsigned int id) {
|
||||||
|
#endif // ENABLE_WORLD_COORDINATE
|
||||||
if (m_grabbers[id].enabled) {
|
if (m_grabbers[id].enabled) {
|
||||||
|
#if ENABLE_WORLD_COORDINATE
|
||||||
|
if (!m_grabber_connections[id].model.is_initialized() || !m_grabber_connections[id].old_center.isApprox(m_grabbers[id].center)) {
|
||||||
|
m_grabber_connections[id].old_center = m_grabbers[id].center;
|
||||||
|
#else
|
||||||
if (!m_grabber_connections[id].model.is_initialized() || !m_grabber_connections[id].old_center.isApprox(center)) {
|
if (!m_grabber_connections[id].model.is_initialized() || !m_grabber_connections[id].old_center.isApprox(center)) {
|
||||||
m_grabber_connections[id].old_center = center;
|
m_grabber_connections[id].old_center = center;
|
||||||
|
#endif // ENABLE_WORLD_COORDINATE
|
||||||
m_grabber_connections[id].model.reset();
|
m_grabber_connections[id].model.reset();
|
||||||
|
|
||||||
GLModel::Geometry init_data;
|
GLModel::Geometry init_data;
|
||||||
@ -189,7 +209,11 @@ void GLGizmoMove3D::on_render()
|
|||||||
init_data.reserve_indices(2);
|
init_data.reserve_indices(2);
|
||||||
|
|
||||||
// vertices
|
// vertices
|
||||||
|
#if ENABLE_WORLD_COORDINATE
|
||||||
|
init_data.add_vertex((Vec3f)zero.cast<float>());
|
||||||
|
#else
|
||||||
init_data.add_vertex((Vec3f)center.cast<float>());
|
init_data.add_vertex((Vec3f)center.cast<float>());
|
||||||
|
#endif // ENABLE_WORLD_COORDINATE
|
||||||
init_data.add_vertex((Vec3f)m_grabbers[id].center.cast<float>());
|
init_data.add_vertex((Vec3f)m_grabbers[id].center.cast<float>());
|
||||||
|
|
||||||
// indices
|
// indices
|
||||||
|
@ -158,7 +158,9 @@ void GLGizmoRotate::on_render()
|
|||||||
#endif // !ENABLE_GIZMO_GRABBER_REFACTOR
|
#endif // !ENABLE_GIZMO_GRABBER_REFACTOR
|
||||||
|
|
||||||
const Selection& selection = m_parent.get_selection();
|
const Selection& selection = m_parent.get_selection();
|
||||||
|
#if !ENABLE_WORLD_COORDINATE
|
||||||
const BoundingBoxf3& box = selection.get_bounding_box();
|
const BoundingBoxf3& box = selection.get_bounding_box();
|
||||||
|
#endif // !ENABLE_WORLD_COORDINATE
|
||||||
|
|
||||||
if (m_hover_id != 0 && !m_grabbers.front().dragging) {
|
if (m_hover_id != 0 && !m_grabbers.front().dragging) {
|
||||||
#if ENABLE_WORLD_COORDINATE
|
#if ENABLE_WORLD_COORDINATE
|
||||||
@ -234,10 +236,17 @@ void GLGizmoRotate::on_render()
|
|||||||
render_angle();
|
render_angle();
|
||||||
#endif // ENABLE_LEGACY_OPENGL_REMOVAL
|
#endif // ENABLE_LEGACY_OPENGL_REMOVAL
|
||||||
|
|
||||||
|
#if ENABLE_WORLD_COORDINATE
|
||||||
|
render_grabber(m_bounding_box);
|
||||||
|
#if !ENABLE_GIZMO_GRABBER_REFACTOR
|
||||||
|
render_grabber_extension(m_bounding_box, false);
|
||||||
|
#endif // !ENABLE_GIZMO_GRABBER_REFACTOR
|
||||||
|
#else
|
||||||
render_grabber(box);
|
render_grabber(box);
|
||||||
#if !ENABLE_GIZMO_GRABBER_REFACTOR
|
#if !ENABLE_GIZMO_GRABBER_REFACTOR
|
||||||
render_grabber_extension(box, false);
|
render_grabber_extension(box, false);
|
||||||
#endif // !ENABLE_GIZMO_GRABBER_REFACTOR
|
#endif // !ENABLE_GIZMO_GRABBER_REFACTOR
|
||||||
|
#endif // ENABLE_WORLD_COORDINATE
|
||||||
|
|
||||||
#if !ENABLE_GL_SHADERS_ATTRIBUTES
|
#if !ENABLE_GL_SHADERS_ATTRIBUTES
|
||||||
glsafe(::glPopMatrix());
|
glsafe(::glPopMatrix());
|
||||||
@ -257,11 +266,18 @@ void GLGizmoRotate::on_render_for_picking()
|
|||||||
transform_to_local(selection);
|
transform_to_local(selection);
|
||||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||||
|
|
||||||
|
#if ENABLE_WORLD_COORDINATE
|
||||||
|
render_grabbers_for_picking(m_bounding_box);
|
||||||
|
#if !ENABLE_GIZMO_GRABBER_REFACTOR
|
||||||
|
render_grabber_extension(m_bounding_box, true);
|
||||||
|
#endif // !ENABLE_GIZMO_GRABBER_REFACTOR
|
||||||
|
#else
|
||||||
const BoundingBoxf3& box = selection.get_bounding_box();
|
const BoundingBoxf3& box = selection.get_bounding_box();
|
||||||
render_grabbers_for_picking(box);
|
render_grabbers_for_picking(box);
|
||||||
#if !ENABLE_GIZMO_GRABBER_REFACTOR
|
#if !ENABLE_GIZMO_GRABBER_REFACTOR
|
||||||
render_grabber_extension(box, true);
|
render_grabber_extension(box, true);
|
||||||
#endif // !ENABLE_GIZMO_GRABBER_REFACTOR
|
#endif // !ENABLE_GIZMO_GRABBER_REFACTOR
|
||||||
|
#endif // ENABLE_WORLD_COORDINATE
|
||||||
|
|
||||||
#if !ENABLE_GL_SHADERS_ATTRIBUTES
|
#if !ENABLE_GL_SHADERS_ATTRIBUTES
|
||||||
glsafe(::glPopMatrix());
|
glsafe(::glPopMatrix());
|
||||||
@ -271,9 +287,20 @@ void GLGizmoRotate::on_render_for_picking()
|
|||||||
#if ENABLE_WORLD_COORDINATE
|
#if ENABLE_WORLD_COORDINATE
|
||||||
void GLGizmoRotate::init_data_from_selection(const Selection& selection)
|
void GLGizmoRotate::init_data_from_selection(const Selection& selection)
|
||||||
{
|
{
|
||||||
const BoundingBoxf3& box = selection.get_bounding_box();
|
m_bounding_box.reset();
|
||||||
m_center = box.center();
|
if (wxGetApp().obj_manipul()->get_world_coordinates()) {
|
||||||
m_radius = Offset + box.radius();
|
m_bounding_box = selection.get_bounding_box();
|
||||||
|
m_center = m_bounding_box.center();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
const Selection::IndicesList& ids = selection.get_volume_idxs();
|
||||||
|
for (unsigned int id : ids) {
|
||||||
|
const GLVolume* v = selection.get_volume(id);
|
||||||
|
m_bounding_box.merge(v->transformed_convex_hull_bounding_box(v->get_volume_transformation().get_matrix()));
|
||||||
|
}
|
||||||
|
m_center = selection.get_volume(*ids.begin())->get_instance_transformation().get_matrix() * m_bounding_box.center();
|
||||||
|
}
|
||||||
|
m_radius = Offset + m_bounding_box.radius();
|
||||||
m_snap_coarse_in_radius = m_radius / 3.0f;
|
m_snap_coarse_in_radius = m_radius / 3.0f;
|
||||||
m_snap_coarse_out_radius = 2.0f * m_snap_coarse_in_radius;
|
m_snap_coarse_out_radius = 2.0f * m_snap_coarse_in_radius;
|
||||||
m_snap_fine_in_radius = m_radius;
|
m_snap_fine_in_radius = m_radius;
|
||||||
|
@ -35,6 +35,7 @@ private:
|
|||||||
float m_snap_fine_in_radius{ 0.0f };
|
float m_snap_fine_in_radius{ 0.0f };
|
||||||
float m_snap_fine_out_radius{ 0.0f };
|
float m_snap_fine_out_radius{ 0.0f };
|
||||||
#if ENABLE_WORLD_COORDINATE
|
#if ENABLE_WORLD_COORDINATE
|
||||||
|
BoundingBoxf3 m_bounding_box;
|
||||||
Transform3d m_orient_matrix{ Transform3d::Identity() };
|
Transform3d m_orient_matrix{ Transform3d::Identity() };
|
||||||
#endif // ENABLE_WORLD_COORDINATE
|
#endif // ENABLE_WORLD_COORDINATE
|
||||||
|
|
||||||
|
@ -851,7 +851,7 @@ void Selection::rotate(const Vec3d& rotation, TransformationType transformation_
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#if !DISABLE_INSTANCES_SYNCH
|
#if !DISABLE_INSTANCES_SYNCH
|
||||||
#if ENABLE_WORLD_COORDINATE
|
#if ENABLE_WORLD_COORDINATE
|
||||||
if (m_mode == Instance) {
|
if (m_mode == Instance) {
|
||||||
SyncRotationType synch;
|
SyncRotationType synch;
|
||||||
@ -877,7 +877,7 @@ void Selection::rotate(const Vec3d& rotation, TransformationType transformation_
|
|||||||
// make sure the wipe tower rotates around its center, not origin
|
// make sure the wipe tower rotates around its center, not origin
|
||||||
// we can assume that only Z rotation changes
|
// we can assume that only Z rotation changes
|
||||||
const Vec3d center_local = volume.transformed_bounding_box().center() - volume.get_volume_offset();
|
const Vec3d center_local = volume.transformed_bounding_box().center() - volume.get_volume_offset();
|
||||||
const Vec3d center_local_new = Eigen::AngleAxisd(rotation(2)-volume.get_volume_rotation()(2), Vec3d(0.0, 0.0, 1.0)) * center_local;
|
const Vec3d center_local_new = Eigen::AngleAxisd(rotation.z()-volume.get_volume_rotation().z(), Vec3d(0.0, 0.0, 1.0)) * center_local;
|
||||||
volume.set_volume_rotation(rotation);
|
volume.set_volume_rotation(rotation);
|
||||||
volume.set_volume_offset(volume.get_volume_offset() + center_local - center_local_new);
|
volume.set_volume_offset(volume.get_volume_offset() + center_local - center_local_new);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user