Tech ENABLE_COORDINATE_DEPENDENT_SELECTION_BOX - Render the selection bounding box in the current reference system

Fixed conflicts during rebase with master
This commit is contained in:
enricoturri1966 2022-02-15 09:10:41 +01:00
parent 9706f16e69
commit 912d781446
3 changed files with 68 additions and 1 deletions

View File

@ -73,6 +73,8 @@
#define ENABLE_WORLD_COORDINATE (1 && ENABLE_2_5_0_ALPHA1)
// Enable showing world coordinates of volumes' offset relative to the instance containing them
#define ENABLE_WORLD_COORDINATE_VOLUMES_LOCAL_OFFSET (1 && ENABLE_WORLD_COORDINATE)
// Enable rendering the selection bounding box in the current reference system
#define ENABLE_COORDINATE_DEPENDENT_SELECTION_BOX (1 && ENABLE_WORLD_COORDINATE)
// Enable modified camera control using mouse
#define ENABLE_NEW_CAMERA_MOVEMENTS (1 && ENABLE_2_5_0_ALPHA1)
// Enable modified rectangle selection

View File

@ -919,7 +919,7 @@ void Selection::rotate(const Vec3d& rotation, TransformationType transformation_
#else
else if (is_single_volume() || is_single_modifier()) {
if (transformation_type.independent())
v.set_volume_rotation(v.get_volume_rotation() + rotation);
v.set_volume_rotation(m_cache.volumes_data[i].get_volume_rotation() + rotation);
else {
const Transform3d m = Geometry::assemble_transform(Vec3d::Zero(), rotation);
const Vec3d new_rotation = Geometry::extract_euler_angles(m * m_cache.volumes_data[i].get_volume_rotation_matrix());
@ -1409,7 +1409,33 @@ void Selection::render(float scale_factor)
m_scale_factor = scale_factor;
// render cumulative bounding box of selected volumes
#if ENABLE_LEGACY_OPENGL_REMOVAL
#if ENABLE_COORDINATE_DEPENDENT_SELECTION_BOX
BoundingBoxf3 box;
Transform3d trafo;
const ECoordinatesType coordinates_type = wxGetApp().obj_manipul()->get_coordinates_type();
if (coordinates_type == ECoordinatesType::World) {
box = get_bounding_box();
trafo = Transform3d::Identity();
}
else if (coordinates_type == ECoordinatesType::Local && is_single_volume_or_modifier()) {
const GLVolume& v = *get_volume(*get_volume_idxs().begin());
box = v.transformed_convex_hull_bounding_box(v.get_instance_transformation().get_matrix(true, true, false, true) * v.get_volume_transformation().get_matrix(true, true, false, true));
trafo = v.get_instance_transformation().get_matrix(false, false, true, false) * v.get_volume_transformation().get_matrix(false, false, true, false);
}
else {
const Selection::IndicesList& ids = get_volume_idxs();
for (unsigned int id : ids) {
const GLVolume& v = *get_volume(id);
box.merge(v.transformed_convex_hull_bounding_box(v.get_volume_transformation().get_matrix()));
}
box = box.transformed(get_volume(*ids.begin())->get_instance_transformation().get_matrix(true, true, false, true));
trafo = get_volume(*ids.begin())->get_instance_transformation().get_matrix(false, false, true, false);
}
render_bounding_box(box, trafo, ColorRGB::WHITE());
#else
render_bounding_box(get_bounding_box(), ColorRGB::WHITE());
#endif // ENABLE_COORDINATE_DEPENDENT_SELECTION_BOX
#else
render_selected_volumes();
#endif // ENABLE_LEGACY_OPENGL_REMOVAL
@ -2020,6 +2046,12 @@ void Selection::render_synchronized_volumes()
float color[3] = { 1.0f, 1.0f, 0.0f };
#endif // !ENABLE_LEGACY_OPENGL_REMOVAL
#if ENABLE_COORDINATE_DEPENDENT_SELECTION_BOX
const ECoordinatesType coordinates_type = wxGetApp().obj_manipul()->get_coordinates_type();
BoundingBoxf3 box;
Transform3d trafo;
#endif // ENABLE_COORDINATE_DEPENDENT_SELECTION_BOX
for (unsigned int i : m_list) {
const GLVolume& volume = *(*m_volumes)[i];
int object_idx = volume.object_idx();
@ -2033,7 +2065,23 @@ void Selection::render_synchronized_volumes()
continue;
#if ENABLE_LEGACY_OPENGL_REMOVAL
#if ENABLE_COORDINATE_DEPENDENT_SELECTION_BOX
if (coordinates_type == ECoordinatesType::World) {
box = v.transformed_convex_hull_bounding_box();
trafo = Transform3d::Identity();
}
else if (coordinates_type == ECoordinatesType::Local) {
box = v.bounding_box();
trafo = v.world_matrix();
}
else {
box = v.transformed_convex_hull_bounding_box(v.get_volume_transformation().get_matrix());
trafo = v.get_instance_transformation().get_matrix();
}
render_bounding_box(box, trafo, ColorRGB::YELLOW());
#else
render_bounding_box(v.transformed_convex_hull_bounding_box(), ColorRGB::YELLOW());
#endif // ENABLE_COORDINATE_DEPENDENT_SELECTION_BOX
#else
render_bounding_box(v.transformed_convex_hull_bounding_box(), color);
#endif // ENABLE_LEGACY_OPENGL_REMOVAL
@ -2042,7 +2090,11 @@ void Selection::render_synchronized_volumes()
}
#if ENABLE_LEGACY_OPENGL_REMOVAL
#if ENABLE_COORDINATE_DEPENDENT_SELECTION_BOX
void Selection::render_bounding_box(const BoundingBoxf3& box, const Transform3d& trafo, const ColorRGB& color)
#else
void Selection::render_bounding_box(const BoundingBoxf3& box, const ColorRGB& color)
#endif // ENABLE_COORDINATE_DEPENDENT_SELECTION_BOX
{
#else
void Selection::render_bounding_box(const BoundingBoxf3 & box, float* color) const
@ -2146,6 +2198,11 @@ void Selection::render_bounding_box(const BoundingBoxf3 & box, float* color) con
if (shader == nullptr)
return;
#if ENABLE_COORDINATE_DEPENDENT_SELECTION_BOX
glsafe(::glPushMatrix());
glsafe(::glMultMatrixd(trafo.data()));
#endif // ENABLE_COORDINATE_DEPENDENT_SELECTION_BOX
shader->start_using();
#if ENABLE_GL_SHADERS_ATTRIBUTES
const Camera& camera = wxGetApp().plater()->get_camera();
@ -2155,6 +2212,10 @@ void Selection::render_bounding_box(const BoundingBoxf3 & box, float* color) con
m_box.set_color(to_rgba(color));
m_box.render();
shader->stop_using();
#if ENABLE_COORDINATE_DEPENDENT_SELECTION_BOX
glsafe(::glPopMatrix());
#endif // ENABLE_COORDINATE_DEPENDENT_SELECTION_BOX
#else
::glBegin(GL_LINES);

View File

@ -395,7 +395,11 @@ private:
void set_bounding_boxes_dirty() { m_bounding_box.reset(); m_unscaled_instance_bounding_box.reset(); m_scaled_instance_bounding_box.reset(); }
void render_synchronized_volumes();
#if ENABLE_LEGACY_OPENGL_REMOVAL
#if ENABLE_COORDINATE_DEPENDENT_SELECTION_BOX
void render_bounding_box(const BoundingBoxf3& box, const Transform3d& trafo, const ColorRGB& color);
#else
void render_bounding_box(const BoundingBoxf3& box, const ColorRGB& color);
#endif // ENABLE_COORDINATE_DEPENDENT_SELECTION_BOX
#else
void render_selected_volumes() const;
void render_bounding_box(const BoundingBoxf3& box, float* color) const;