mirror of
https://git.mirrors.martin98.com/https://github.com/prusa3d/PrusaSlicer.git
synced 2025-08-14 07:05:57 +08:00
Tech ENABLE_CGAL_BOUNDING_SPHERE set as default
This commit is contained in:
parent
6a9deeb080
commit
39a9b47b07
@ -61,7 +61,5 @@
|
||||
// Enable imgui dialog which allows to set the parameters used to export binarized gcode
|
||||
#define ENABLE_BINARIZED_GCODE_DEBUG_WINDOW 0
|
||||
|
||||
// Enable use selection's bounding sphere center as pivot for rotations
|
||||
#define ENABLE_CGAL_BOUNDING_SPHERE 1
|
||||
|
||||
#endif // _prusaslicer_technologies_h_
|
||||
|
@ -204,20 +204,11 @@ void GLGizmoRotate::init_data_from_selection(const Selection& selection)
|
||||
const auto [box, box_trafo] = m_force_local_coordinate ?
|
||||
selection.get_bounding_box_in_reference_system(ECoordinatesType::Local) : selection.get_bounding_box_in_current_reference_system();
|
||||
m_bounding_box = box;
|
||||
#if ENABLE_CGAL_BOUNDING_SPHERE
|
||||
const std::pair<Vec3d, double> sphere = selection.get_bounding_sphere();
|
||||
m_center = sphere.first;
|
||||
m_radius = Offset + sphere.second;
|
||||
#else
|
||||
m_center = box_trafo.translation();
|
||||
#endif // ENABLE_CGAL_BOUNDING_SPHERE
|
||||
m_orient_matrix = box_trafo;
|
||||
|
||||
#if ENABLE_CGAL_BOUNDING_SPHERE
|
||||
m_orient_matrix.translation() = m_center;
|
||||
#else
|
||||
m_radius = Offset + m_bounding_box.radius();
|
||||
#endif // ENABLE_CGAL_BOUNDING_SPHERE
|
||||
m_snap_coarse_in_radius = m_radius / 3.0f;
|
||||
m_snap_coarse_out_radius = 2.0f * m_snap_coarse_in_radius;
|
||||
m_snap_fine_in_radius = m_radius;
|
||||
|
@ -29,11 +29,9 @@
|
||||
#include <boost/algorithm/string/predicate.hpp>
|
||||
#include <boost/log/trivial.hpp>
|
||||
|
||||
#if ENABLE_CGAL_BOUNDING_SPHERE
|
||||
#include <CGAL/Simple_cartesian.h>
|
||||
#include <CGAL/Min_sphere_of_spheres_d.h>
|
||||
#include <CGAL/Min_sphere_of_points_d_traits_3.h>
|
||||
#endif // ENABLE_CGAL_BOUNDING_SPHERE
|
||||
|
||||
static const Slic3r::ColorRGBA UNIFORM_SCALE_COLOR = Slic3r::ColorRGBA::ORANGE();
|
||||
static const Slic3r::ColorRGBA SOLID_PLANE_COLOR = Slic3r::ColorRGBA::ORANGE();
|
||||
@ -912,7 +910,6 @@ BoundingBoxf Selection::get_screen_space_bounding_box()
|
||||
return ss_box;
|
||||
}
|
||||
|
||||
#if ENABLE_CGAL_BOUNDING_SPHERE
|
||||
const std::pair<Vec3d, double> Selection::get_bounding_sphere() const
|
||||
{
|
||||
if (!m_bounding_sphere.has_value()) {
|
||||
@ -947,7 +944,6 @@ const std::pair<Vec3d, double> Selection::get_bounding_sphere() const
|
||||
|
||||
return *m_bounding_sphere;
|
||||
}
|
||||
#endif // ENABLE_CGAL_BOUNDING_SPHERE
|
||||
|
||||
void Selection::setup_cache()
|
||||
{
|
||||
@ -1036,27 +1032,15 @@ void Selection::rotate(const Vec3d& rotation, TransformationType transformation_
|
||||
rotation_matrix = inst_matrix_no_offset.inverse() * inst_rotation_matrix * rotation_matrix * inst_rotation_matrix.inverse() * inst_matrix_no_offset;
|
||||
|
||||
// rotate around selection center
|
||||
#if ENABLE_CGAL_BOUNDING_SPHERE
|
||||
const Vec3d inst_pivot = inst_trafo.get_matrix_no_offset().inverse() * (m_cache.rotation_pivot - inst_trafo.get_offset());
|
||||
#else
|
||||
const Vec3d inst_pivot = inst_trafo.get_matrix_no_offset().inverse() * (m_cache.dragging_center - inst_trafo.get_offset());
|
||||
#endif // ENABLE_CGAL_BOUNDING_SPHERE
|
||||
rotation_matrix = Geometry::translation_transform(inst_pivot) * rotation_matrix * Geometry::translation_transform(-inst_pivot);
|
||||
}
|
||||
#if ENABLE_CGAL_BOUNDING_SPHERE
|
||||
transform_instance_relative(v, volume_data, transformation_type, rotation_matrix, m_cache.rotation_pivot);
|
||||
#else
|
||||
transform_instance_relative(v, volume_data, transformation_type, rotation_matrix, m_cache.dragging_center);
|
||||
#endif // ENABLE_CGAL_BOUNDING_SPHERE
|
||||
}
|
||||
else {
|
||||
if (!is_single_volume_or_modifier()) {
|
||||
assert(transformation_type.world());
|
||||
#if ENABLE_CGAL_BOUNDING_SPHERE
|
||||
transform_volume_relative(v, volume_data, transformation_type, rotation_matrix, m_cache.rotation_pivot);
|
||||
#else
|
||||
transform_volume_relative(v, volume_data, transformation_type, rotation_matrix, m_cache.dragging_center);
|
||||
#endif // ENABLE_CGAL_BOUNDING_SPHERE
|
||||
}
|
||||
else {
|
||||
if (transformation_type.instance()) {
|
||||
@ -1082,11 +1066,7 @@ void Selection::rotate(const Vec3d& rotation, TransformationType transformation_
|
||||
vol_rotation_matrix.inverse() * inst_scale_matrix * vol_matrix_no_offset;
|
||||
}
|
||||
}
|
||||
#if ENABLE_CGAL_BOUNDING_SPHERE
|
||||
transform_volume_relative(v, volume_data, transformation_type, rotation_matrix, m_cache.rotation_pivot);
|
||||
#else
|
||||
transform_volume_relative(v, volume_data, transformation_type, rotation_matrix, m_cache.dragging_center);
|
||||
#endif // ENABLE_CGAL_BOUNDING_SPHERE
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -2095,10 +2075,7 @@ void Selection::set_caches()
|
||||
m_cache.sinking_volumes.push_back(i);
|
||||
}
|
||||
m_cache.dragging_center = get_bounding_box().center();
|
||||
#if ENABLE_CGAL_BOUNDING_SPHERE
|
||||
m_cache.rotation_pivot = get_bounding_sphere().first;
|
||||
// m_cache.dragging_center = m_cache.rotation_pivot;
|
||||
#endif // ENABLE_CGAL_BOUNDING_SPHERE
|
||||
}
|
||||
|
||||
void Selection::do_add_volume(unsigned int volume_idx)
|
||||
|
@ -114,9 +114,7 @@ private:
|
||||
ObjectIdxsToInstanceIdxsMap content;
|
||||
// List of ids of the volumes which are sinking when starting dragging
|
||||
std::vector<unsigned int> sinking_volumes;
|
||||
#if ENABLE_CGAL_BOUNDING_SPHERE
|
||||
Vec3d rotation_pivot;
|
||||
#endif // ENABLE_CGAL_BOUNDING_SPHERE
|
||||
};
|
||||
|
||||
// Volumes owned by GLCanvas3D.
|
||||
@ -153,9 +151,7 @@ private:
|
||||
// and transform to place and orient it in world coordinates
|
||||
std::optional<std::pair<BoundingBoxf3, Transform3d>> m_bounding_box_in_current_reference_system;
|
||||
|
||||
#if ENABLE_CGAL_BOUNDING_SPHERE
|
||||
std::optional<std::pair<Vec3d, double>> m_bounding_sphere;
|
||||
#endif // ENABLE_CGAL_BOUNDING_SPHERE
|
||||
|
||||
#if ENABLE_RENDER_SELECTION_CENTER
|
||||
GLModel m_vbo_sphere;
|
||||
@ -302,10 +298,8 @@ public:
|
||||
// Returns the screen space bounding box
|
||||
BoundingBoxf get_screen_space_bounding_box();
|
||||
|
||||
#if ENABLE_CGAL_BOUNDING_SPHERE
|
||||
// Returns the bounding sphere
|
||||
// Returns the bounding sphere: first = center, second = radius
|
||||
const std::pair<Vec3d, double> get_bounding_sphere() const;
|
||||
#endif // ENABLE_CGAL_BOUNDING_SPHERE
|
||||
|
||||
void setup_cache();
|
||||
|
||||
@ -372,9 +366,7 @@ private:
|
||||
m_full_unscaled_instance_bounding_box.reset(); m_full_scaled_instance_bounding_box.reset();
|
||||
m_full_unscaled_instance_local_bounding_box.reset();
|
||||
m_bounding_box_in_current_reference_system.reset();
|
||||
#if ENABLE_CGAL_BOUNDING_SPHERE
|
||||
m_bounding_sphere.reset();
|
||||
#endif // ENABLE_CGAL_BOUNDING_SPHERE
|
||||
}
|
||||
void render_synchronized_volumes();
|
||||
void render_bounding_box(const BoundingBoxf3& box, const Transform3d& trafo, const ColorRGB& color);
|
||||
|
Loading…
x
Reference in New Issue
Block a user