Tech ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES merged into tech ENABLE_WORLD_COORDINATE

This commit is contained in:
enricoturri1966 2022-02-14 11:06:16 +01:00
parent 6a7e32ad3e
commit a1f43f0611
11 changed files with 69 additions and 298 deletions

View File

@ -79,11 +79,9 @@
// Enable recalculating toolpaths when switching to/from volumetric rate visualization // Enable recalculating toolpaths when switching to/from volumetric rate visualization
#define ENABLE_VOLUMETRIC_RATE_TOOLPATHS_RECALC (1 && ENABLE_2_5_0_ALPHA1) #define ENABLE_VOLUMETRIC_RATE_TOOLPATHS_RECALC (1 && ENABLE_2_5_0_ALPHA1)
// Enable editing volumes transformation in world coordinates and instances in local coordinates // Enable editing volumes transformation in world coordinates and instances in local coordinates
#define ENABLE_WORLD_COORDINATE (1 && ENABLE_2_5_0_ALPHA1) #define ENABLE_WORLD_COORDINATE (0 && ENABLE_2_5_0_ALPHA1)
// Enable showing world coordinates of volumes' offset relative to the instance containing them // Enable showing world coordinates of volumes' offset relative to the instance containing them
#define ENABLE_WORLD_COORDINATE_VOLUMES_LOCAL_OFFSET (0 && ENABLE_WORLD_COORDINATE) #define ENABLE_WORLD_COORDINATE_VOLUMES_LOCAL_OFFSET (0 && ENABLE_WORLD_COORDINATE)
// Enable editing instance coordinates of volumes
#define ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES (1 && ENABLE_WORLD_COORDINATE)
#endif // _prusaslicer_technologies_h_ #endif // _prusaslicer_technologies_h_

View File

@ -4,7 +4,7 @@
namespace Slic3r { namespace Slic3r {
namespace GUI { namespace GUI {
#if ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES #if ENABLE_WORLD_COORDINATE
enum class ECoordinatesType : unsigned char enum class ECoordinatesType : unsigned char
{ {
World, World,
@ -72,7 +72,8 @@ private:
Enum m_value; Enum m_value;
}; };
#endif // ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES
#endif // ENABLE_WORLD_COORDINATE
} // namespace Slic3r } // namespace Slic3r
} // namespace GUI } // namespace GUI

View File

@ -52,7 +52,7 @@ static choice_ctrl* create_word_local_combo(wxWindow *parent)
temp->SetFont(Slic3r::GUI::wxGetApp().normal_font()); temp->SetFont(Slic3r::GUI::wxGetApp().normal_font());
if (!wxOSX) temp->SetBackgroundStyle(wxBG_STYLE_PAINT); if (!wxOSX) temp->SetBackgroundStyle(wxBG_STYLE_PAINT);
#if ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES #if ENABLE_WORLD_COORDINATE
temp->Append(ObjectManipulation::coordinate_type_str(ECoordinatesType::World)); temp->Append(ObjectManipulation::coordinate_type_str(ECoordinatesType::World));
temp->Append(ObjectManipulation::coordinate_type_str(ECoordinatesType::Instance)); temp->Append(ObjectManipulation::coordinate_type_str(ECoordinatesType::Instance));
temp->Append(ObjectManipulation::coordinate_type_str(ECoordinatesType::Local)); temp->Append(ObjectManipulation::coordinate_type_str(ECoordinatesType::Local));
@ -62,7 +62,7 @@ static choice_ctrl* create_word_local_combo(wxWindow *parent)
temp->Append(_L("Local coordinates")); temp->Append(_L("Local coordinates"));
temp->SetSelection(0); temp->SetSelection(0);
temp->SetValue(temp->GetString(0)); temp->SetValue(temp->GetString(0));
#endif // ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES #endif // ENABLE_WORLD_COORDINATE
temp->SetToolTip(_L("Select coordinate space, in which the transformation will be performed.")); temp->SetToolTip(_L("Select coordinate space, in which the transformation will be performed."));
return temp; return temp;
@ -88,14 +88,14 @@ void msw_rescale_word_local_combo(choice_ctrl* combo)
// Set rescaled size // Set rescaled size
combo->SetSize(size); combo->SetSize(size);
#if ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES #if ENABLE_WORLD_COORDINATE
combo->Append(ObjectManipulation::coordinate_type_str(ECoordinatesType::World)); combo->Append(ObjectManipulation::coordinate_type_str(ECoordinatesType::World));
combo->Append(ObjectManipulation::coordinate_type_str(ECoordinatesType::Instance)); combo->Append(ObjectManipulation::coordinate_type_str(ECoordinatesType::Instance));
combo->Append(ObjectManipulation::coordinate_type_str(ECoordinatesType::Local)); combo->Append(ObjectManipulation::coordinate_type_str(ECoordinatesType::Local));
#else #else
combo->Append(_L("World coordinates")); combo->Append(_L("World coordinates"));
combo->Append(_L("Local coordinates")); combo->Append(_L("Local coordinates"));
#endif // ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES #endif // ENABLE_WORLD_COORDINATE
combo->SetValue(selection); combo->SetValue(selection);
#else #else
@ -171,11 +171,11 @@ ObjectManipulation::ObjectManipulation(wxWindow* parent) :
// Add world local combobox // Add world local combobox
m_word_local_combo = create_word_local_combo(parent); m_word_local_combo = create_word_local_combo(parent);
m_word_local_combo->Bind(wxEVT_COMBOBOX, ([this](wxCommandEvent& evt) { m_word_local_combo->Bind(wxEVT_COMBOBOX, ([this](wxCommandEvent& evt) {
#if ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES #if ENABLE_WORLD_COORDINATE
this->set_coordinates_type(evt.GetString()); this->set_coordinates_type(evt.GetString());
#else #else
this->set_world_coordinates(evt.GetSelection() != 1); this->set_world_coordinates(evt.GetSelection() != 1);
#endif // ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES #endif // ENABLE_WORLD_COORDINATE
}), m_word_local_combo->GetId()); }), m_word_local_combo->GetId());
// Small trick to correct layouting in different view_mode : // Small trick to correct layouting in different view_mode :
@ -353,11 +353,7 @@ ObjectManipulation::ObjectManipulation(wxWindow* parent) :
if (selection.is_single_volume_or_modifier()) { if (selection.is_single_volume_or_modifier()) {
const GLVolume* volume = selection.get_volume(*selection.get_volume_idxs().begin()); const GLVolume* volume = selection.get_volume(*selection.get_volume_idxs().begin());
const double min_z = get_volume_min_z(*volume); const double min_z = get_volume_min_z(*volume);
#if ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES
if (!is_world_coordinates()) { if (!is_world_coordinates()) {
#else
if (!m_world_coordinates) {
#endif // ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES
const Vec3d diff = m_cache.position - volume->get_instance_transformation().get_matrix(true).inverse() * (min_z * Vec3d::UnitZ()); const Vec3d diff = m_cache.position - volume->get_instance_transformation().get_matrix(true).inverse() * (min_z * Vec3d::UnitZ());
Plater::TakeSnapshot snapshot(wxGetApp().plater(), _L("Drop to bed")); Plater::TakeSnapshot snapshot(wxGetApp().plater(), _L("Drop to bed"));
@ -383,11 +379,7 @@ ObjectManipulation::ObjectManipulation(wxWindow* parent) :
else if (selection.is_single_full_instance()) { else if (selection.is_single_full_instance()) {
#if ENABLE_WORLD_COORDINATE #if ENABLE_WORLD_COORDINATE
const double min_z = selection.get_scaled_instance_bounding_box().min.z(); const double min_z = selection.get_scaled_instance_bounding_box().min.z();
#if ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES
if (!is_world_coordinates()) { if (!is_world_coordinates()) {
#else
if (!m_world_coordinates) {
#endif // ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES
const GLVolume* volume = selection.get_volume(*selection.get_volume_idxs().begin()); const GLVolume* volume = selection.get_volume(*selection.get_volume_idxs().begin());
const Vec3d diff = m_cache.position - volume->get_instance_transformation().get_matrix(true).inverse() * (min_z * Vec3d::UnitZ()); const Vec3d diff = m_cache.position - volume->get_instance_transformation().get_matrix(true).inverse() * (min_z * Vec3d::UnitZ());
@ -513,7 +505,6 @@ void ObjectManipulation::Show(const bool show)
#if ENABLE_WORLD_COORDINATE #if ENABLE_WORLD_COORDINATE
const Selection& selection = wxGetApp().plater()->canvas3D()->get_selection(); const Selection& selection = wxGetApp().plater()->canvas3D()->get_selection();
bool show_world_local_combo = wxGetApp().get_mode() != comSimple && (selection.is_single_full_instance() || selection.is_single_volume_or_modifier()); bool show_world_local_combo = wxGetApp().get_mode() != comSimple && (selection.is_single_full_instance() || selection.is_single_volume_or_modifier());
#if ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES
if (selection.is_single_volume_or_modifier() && m_word_local_combo->GetCount() < 3) { if (selection.is_single_volume_or_modifier() && m_word_local_combo->GetCount() < 3) {
#ifdef __linux__ #ifdef __linux__
m_word_local_combo->Insert(coordinate_type_str(ECoordinatesType::Instance), 1); m_word_local_combo->Insert(coordinate_type_str(ECoordinatesType::Instance), 1);
@ -528,7 +519,6 @@ void ObjectManipulation::Show(const bool show)
m_word_local_combo->Select((int)ECoordinatesType::World); m_word_local_combo->Select((int)ECoordinatesType::World);
this->set_coordinates_type(m_word_local_combo->GetString(m_word_local_combo->GetSelection())); this->set_coordinates_type(m_word_local_combo->GetString(m_word_local_combo->GetSelection()));
} }
#endif // ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES
#else #else
bool show_world_local_combo = wxGetApp().plater()->canvas3D()->get_selection().is_single_full_instance() && wxGetApp().get_mode() != comSimple; bool show_world_local_combo = wxGetApp().plater()->canvas3D()->get_selection().is_single_full_instance() && wxGetApp().get_mode() != comSimple;
#endif // ENABLE_WORLD_COORDINATE #endif // ENABLE_WORLD_COORDINATE
@ -609,10 +599,10 @@ void ObjectManipulation::update_settings_value(const Selection& selection)
m_new_rotate_label_string = L("Rotation"); m_new_rotate_label_string = L("Rotation");
m_new_scale_label_string = L("Scale factors"); m_new_scale_label_string = L("Scale factors");
#if !ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES #if !ENABLE_WORLD_COORDINATE
if (wxGetApp().get_mode() == comSimple) if (wxGetApp().get_mode() == comSimple)
m_world_coordinates = true; m_world_coordinates = true;
#endif // !ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES #endif // !ENABLE_WORLD_COORDINATE
ObjectList* obj_list = wxGetApp().obj_list(); ObjectList* obj_list = wxGetApp().obj_list();
if (selection.is_single_full_instance()) { if (selection.is_single_full_instance()) {
@ -623,29 +613,25 @@ void ObjectManipulation::update_settings_value(const Selection& selection)
#endif // !ENABLE_WORLD_COORDINATE #endif // !ENABLE_WORLD_COORDINATE
// Verify whether the instance rotation is multiples of 90 degrees, so that the scaling in world coordinates is possible. // Verify whether the instance rotation is multiples of 90 degrees, so that the scaling in world coordinates is possible.
#if ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES #if ENABLE_WORLD_COORDINATE
if (is_world_coordinates() && !m_uniform_scale && if (is_world_coordinates() && !m_uniform_scale &&
#else #else
if (m_world_coordinates && ! m_uniform_scale && if (m_world_coordinates && ! m_uniform_scale &&
#endif // ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES #endif // ENABLE_WORLD_COORDINATE
! Geometry::is_rotation_ninety_degrees(volume->get_instance_rotation())) { ! Geometry::is_rotation_ninety_degrees(volume->get_instance_rotation())) {
// Manipulating an instance in the world coordinate system, rotation is not multiples of ninety degrees, therefore enforce uniform scaling. // Manipulating an instance in the world coordinate system, rotation is not multiples of ninety degrees, therefore enforce uniform scaling.
m_uniform_scale = true; m_uniform_scale = true;
m_lock_bnt->SetLock(true); m_lock_bnt->SetLock(true);
} }
#if ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES #if ENABLE_WORLD_COORDINATE
if (is_world_coordinates()) { if (is_world_coordinates()) {
#else
if (m_world_coordinates) {
#endif // ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES
#if ENABLE_WORLD_COORDINATE
m_new_position = volume->get_instance_offset(); m_new_position = volume->get_instance_offset();
#endif // ENABLE_WORLD_COORDINATE
m_new_rotate_label_string = L("Rotate"); m_new_rotate_label_string = L("Rotate");
#if ENABLE_WORLD_COORDINATE
m_new_rotation = volume->get_instance_rotation() * (180.0 / M_PI); m_new_rotation = volume->get_instance_rotation() * (180.0 / M_PI);
#else #else
if (m_world_coordinates) {
m_new_rotate_label_string = L("Rotate");
m_new_rotation = Vec3d::Zero(); m_new_rotation = Vec3d::Zero();
#endif // ENABLE_WORLD_COORDINATE #endif // ENABLE_WORLD_COORDINATE
m_new_size = selection.get_scaled_instance_bounding_box().size(); m_new_size = selection.get_scaled_instance_bounding_box().size();
@ -682,11 +668,7 @@ void ObjectManipulation::update_settings_value(const Selection& selection)
// the selection contains a single volume // the selection contains a single volume
const GLVolume* volume = selection.get_volume(*selection.get_volume_idxs().begin()); const GLVolume* volume = selection.get_volume(*selection.get_volume_idxs().begin());
#if ENABLE_WORLD_COORDINATE #if ENABLE_WORLD_COORDINATE
#if ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES
if (is_world_coordinates()) { if (is_world_coordinates()) {
#else
if (m_world_coordinates) {
#endif // ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES
const Geometry::Transformation trafo(volume->world_matrix()); const Geometry::Transformation trafo(volume->world_matrix());
#if ENABLE_WORLD_COORDINATE_VOLUMES_LOCAL_OFFSET #if ENABLE_WORLD_COORDINATE_VOLUMES_LOCAL_OFFSET
@ -701,27 +683,23 @@ void ObjectManipulation::update_settings_value(const Selection& selection)
m_new_size = volume->transformed_convex_hull_bounding_box(trafo.get_matrix()).size(); m_new_size = volume->transformed_convex_hull_bounding_box(trafo.get_matrix()).size();
m_new_scale = m_new_size.cwiseProduct(volume->transformed_convex_hull_bounding_box(volume->get_instance_transformation().get_matrix() * volume->get_volume_transformation().get_matrix(false, false, true, false)).size().cwiseInverse()) * 100.0; m_new_scale = m_new_size.cwiseProduct(volume->transformed_convex_hull_bounding_box(volume->get_instance_transformation().get_matrix() * volume->get_volume_transformation().get_matrix(false, false, true, false)).size().cwiseInverse()) * 100.0;
} }
#if ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES
else if (is_local_coordinates()) { else if (is_local_coordinates()) {
m_new_position = Vec3d::Zero(); m_new_position = Vec3d::Zero();
m_new_rotation = Vec3d::Zero(); m_new_rotation = Vec3d::Zero();
m_new_scale = volume->get_volume_scaling_factor() * 100.0; m_new_scale = volume->get_volume_scaling_factor() * 100.0;
m_new_size = volume->get_volume_scaling_factor().cwiseProduct(volume->bounding_box().size()); m_new_size = volume->get_volume_scaling_factor().cwiseProduct(volume->bounding_box().size());
} }
#endif // ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES
else { else {
#endif // ENABLE_WORLD_COORDINATE #endif // ENABLE_WORLD_COORDINATE
m_new_position = volume->get_volume_offset(); m_new_position = volume->get_volume_offset();
m_new_rotation = volume->get_volume_rotation() * (180.0 / M_PI); m_new_rotation = volume->get_volume_rotation() * (180.0 / M_PI);
#if ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES #if ENABLE_WORLD_COORDINATE
m_new_size = volume->transformed_convex_hull_bounding_box(volume->get_volume_transformation().get_matrix()).size(); m_new_size = volume->transformed_convex_hull_bounding_box(volume->get_volume_transformation().get_matrix()).size();
m_new_scale = m_new_size.cwiseProduct(volume->transformed_convex_hull_bounding_box(volume->get_volume_transformation().get_matrix(false, false, true, false)).size().cwiseInverse()) * 100.0; m_new_scale = m_new_size.cwiseProduct(volume->transformed_convex_hull_bounding_box(volume->get_volume_transformation().get_matrix(false, false, true, false)).size().cwiseInverse()) * 100.0;
}
#else #else
m_new_scale = volume->get_volume_scaling_factor() * 100.0; m_new_scale = volume->get_volume_scaling_factor() * 100.0;
m_new_size = volume->get_instance_scaling_factor().cwiseProduct(volume->get_volume_scaling_factor().cwiseProduct(volume->bounding_box().size())); m_new_size = volume->get_instance_scaling_factor().cwiseProduct(volume->get_volume_scaling_factor().cwiseProduct(volume->bounding_box().size()));
#endif // ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES
#if ENABLE_WORLD_COORDINATE
}
#endif // ENABLE_WORLD_COORDINATE #endif // ENABLE_WORLD_COORDINATE
m_new_enabled = true; m_new_enabled = true;
} }
@ -788,15 +766,14 @@ void ObjectManipulation::update_if_dirty()
update(m_cache.rotation, m_cache.rotation_rounded, meRotation, m_new_rotation); update(m_cache.rotation, m_cache.rotation_rounded, meRotation, m_new_rotation);
} }
#if ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES #if ENABLE_WORLD_COORDINATE
Selection::EUniformScaleRequiredReason reason; Selection::EUniformScaleRequiredReason reason;
if (selection.requires_uniform_scale(&reason)) { if (selection.requires_uniform_scale(&reason)) {
#else #else
if (selection.requires_uniform_scale()) { if (selection.requires_uniform_scale()) {
#endif // ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES #endif // ENABLE_WORLD_COORDINATE
m_lock_bnt->SetLock(true); m_lock_bnt->SetLock(true);
#if ENABLE_WORLD_COORDINATE #if ENABLE_WORLD_COORDINATE
#if ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES
wxString tooltip; wxString tooltip;
if (selection.is_single_volume_or_modifier()) { if (selection.is_single_volume_or_modifier()) {
if (reason == Selection::EUniformScaleRequiredReason::VolumeNotAxisAligned_Instance) if (reason == Selection::EUniformScaleRequiredReason::VolumeNotAxisAligned_Instance)
@ -814,9 +791,6 @@ void ObjectManipulation::update_if_dirty()
tooltip = _L("You cannot use non-uniform scaling mode for multiple objects/parts selection"); tooltip = _L("You cannot use non-uniform scaling mode for multiple objects/parts selection");
m_lock_bnt->SetToolTip(tooltip); m_lock_bnt->SetToolTip(tooltip);
#else
m_lock_bnt->SetToolTip(_L("You cannot use non-uniform scaling mode for multiple objects/parts selection or non axis-aligned objects/parts"));
#endif // ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES
#else #else
m_lock_bnt->SetToolTip(_L("You cannot use non-uniform scaling mode for multiple objects/parts selection")); m_lock_bnt->SetToolTip(_L("You cannot use non-uniform scaling mode for multiple objects/parts selection"));
#endif // ENABLE_WORLD_COORDINATE #endif // ENABLE_WORLD_COORDINATE
@ -828,13 +802,13 @@ void ObjectManipulation::update_if_dirty()
m_lock_bnt->enable(); m_lock_bnt->enable();
} }
#if !ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES #if !ENABLE_WORLD_COORDINATE
{ {
int new_selection = m_world_coordinates ? 0 : 1; int new_selection = m_world_coordinates ? 0 : 1;
if (m_word_local_combo->GetSelection() != new_selection) if (m_word_local_combo->GetSelection() != new_selection)
m_word_local_combo->SetSelection(new_selection); m_word_local_combo->SetSelection(new_selection);
} }
#endif // !ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES #endif // !ENABLE_WORLD_COORDINATE
if (m_new_enabled) if (m_new_enabled)
m_og->enable(); m_og->enable();
@ -863,11 +837,7 @@ void ObjectManipulation::update_reset_buttons_visibility()
bool show_drop_to_bed = false; bool show_drop_to_bed = false;
#if ENABLE_WORLD_COORDINATE #if ENABLE_WORLD_COORDINATE
#if ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES
if (m_coordinates_type != ECoordinatesType::Local && (selection.is_single_full_instance() || selection.is_single_volume_or_modifier())) { if (m_coordinates_type != ECoordinatesType::Local && (selection.is_single_full_instance() || selection.is_single_volume_or_modifier())) {
#else
if (selection.is_single_full_instance() || selection.is_single_volume_or_modifier()) {
#endif // ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES
const GLVolume* volume = selection.get_volume(*selection.get_volume_idxs().begin()); const GLVolume* volume = selection.get_volume(*selection.get_volume_idxs().begin());
Vec3d rotation = Vec3d::Zero(); Vec3d rotation = Vec3d::Zero();
Vec3d scale = Vec3d::Ones(); Vec3d scale = Vec3d::Ones();
@ -925,11 +895,11 @@ void ObjectManipulation::update_mirror_buttons_visibility()
Selection& selection = canvas->get_selection(); Selection& selection = canvas->get_selection();
std::array<MirrorButtonState, 3> new_states = {mbHidden, mbHidden, mbHidden}; std::array<MirrorButtonState, 3> new_states = {mbHidden, mbHidden, mbHidden};
#if ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES #if ENABLE_WORLD_COORDINATE
if (is_local_coordinates()) { if (is_local_coordinates()) {
#else #else
if (!m_world_coordinates) { if (!m_world_coordinates) {
#endif // ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES #endif // ENABLE_WORLD_COORDINATE
#if ENABLE_WORLD_COORDINATE #if ENABLE_WORLD_COORDINATE
if (selection.is_single_full_instance() || selection.is_single_volume_or_modifier()) { if (selection.is_single_full_instance() || selection.is_single_volume_or_modifier()) {
#else #else
@ -999,7 +969,7 @@ void ObjectManipulation::update_warning_icon_state(const MeshErrorsInfo& warning
m_fix_throught_netfab_bitmap->SetToolTip(tooltip); m_fix_throught_netfab_bitmap->SetToolTip(tooltip);
} }
#if ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES #if ENABLE_WORLD_COORDINATE
wxString ObjectManipulation::coordinate_type_str(ECoordinatesType type) wxString ObjectManipulation::coordinate_type_str(ECoordinatesType type)
{ {
switch (type) switch (type)
@ -1010,7 +980,7 @@ wxString ObjectManipulation::coordinate_type_str(ECoordinatesType type)
default: { assert(false); return _L("Unknown"); } default: { assert(false); return _L("Unknown"); }
} }
} }
#endif // ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES #endif // ENABLE_WORLD_COORDINATE
void ObjectManipulation::reset_settings_value() void ObjectManipulation::reset_settings_value()
{ {
@ -1036,11 +1006,7 @@ void ObjectManipulation::change_position_value(int axis, double value)
Selection& selection = canvas->get_selection(); Selection& selection = canvas->get_selection();
selection.start_dragging(); selection.start_dragging();
#if ENABLE_WORLD_COORDINATE #if ENABLE_WORLD_COORDINATE
#if ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES
selection.translate(position - m_cache.position, get_coordinates_type()); selection.translate(position - m_cache.position, get_coordinates_type());
#else
selection.translate(position - m_cache.position, !m_world_coordinates);
#endif // ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES
#else #else
selection.translate(position - m_cache.position, selection.requires_local_axes()); selection.translate(position - m_cache.position, selection.requires_local_axes());
#endif // ENABLE_WORLD_COORDINATE #endif // ENABLE_WORLD_COORDINATE
@ -1068,11 +1034,7 @@ void ObjectManipulation::change_rotation_value(int axis, double value)
if (selection.is_single_full_instance()) if (selection.is_single_full_instance())
transformation_type.set_independent(); transformation_type.set_independent();
#if ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES
if (!is_world_coordinates()) { if (!is_world_coordinates()) {
#else
if (!m_world_coordinates) {
#endif // ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES
//FIXME Selection::rotate() does not process absolute rotations correctly: It does not recognize the axis index, which was changed. //FIXME Selection::rotate() does not process absolute rotations correctly: It does not recognize the axis index, which was changed.
// transformation_type.set_absolute(); // transformation_type.set_absolute();
transformation_type.set_local(); transformation_type.set_local();
@ -1146,11 +1108,11 @@ void ObjectManipulation::change_size_value(int axis, double value)
ref_size = Vec3d::Ones(); ref_size = Vec3d::Ones();
} }
else if (selection.is_single_full_instance()) else if (selection.is_single_full_instance())
#if ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES #if ENABLE_WORLD_COORDINATE
ref_size = is_world_coordinates() ? ref_size = is_world_coordinates() ?
#else #else
ref_size = m_world_coordinates ? ref_size = m_world_coordinates ?
#endif // ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES #endif // ENABLE_WORLD_COORDINATE
selection.get_unscaled_instance_bounding_box().size() : selection.get_unscaled_instance_bounding_box().size() :
wxGetApp().model().objects[selection.get_volume(*selection.get_volume_idxs().begin())->object_idx()]->raw_mesh_bounding_box().size(); wxGetApp().model().objects[selection.get_volume(*selection.get_volume_idxs().begin())->object_idx()]->raw_mesh_bounding_box().size();
@ -1170,21 +1132,13 @@ void ObjectManipulation::do_scale(int axis, const Vec3d &scale) const
#if ENABLE_WORLD_COORDINATE #if ENABLE_WORLD_COORDINATE
TransformationType transformation_type; TransformationType transformation_type;
#if ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES
if (!is_world_coordinates()) if (!is_world_coordinates())
#else
if (!m_world_coordinates)
#endif // ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES
transformation_type.set_local(); transformation_type.set_local();
bool uniform_scale = m_uniform_scale || selection.requires_uniform_scale(); bool uniform_scale = m_uniform_scale || selection.requires_uniform_scale();
Vec3d scaling_factor = uniform_scale ? scale(axis) * Vec3d::Ones() : scale; Vec3d scaling_factor = uniform_scale ? scale(axis) * Vec3d::Ones() : scale;
#if ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES
if (!uniform_scale && is_world_coordinates()) { if (!uniform_scale && is_world_coordinates()) {
#else
if (!uniform_scale && m_world_coordinates) {
#endif // ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES
if (selection.is_single_full_instance()) if (selection.is_single_full_instance())
scaling_factor = (Geometry::assemble_transform(Vec3d::Zero(), selection.get_volume(*selection.get_volume_idxs().begin())->get_instance_rotation()).inverse() * scaling_factor).cwiseAbs(); scaling_factor = (Geometry::assemble_transform(Vec3d::Zero(), selection.get_volume(*selection.get_volume_idxs().begin())->get_instance_rotation()).inverse() * scaling_factor).cwiseAbs();
else if (selection.is_single_volume_or_modifier()) { else if (selection.is_single_volume_or_modifier()) {
@ -1248,11 +1202,11 @@ void ObjectManipulation::on_change(const std::string& opt_key, int axis, double
void ObjectManipulation::set_uniform_scaling(const bool new_value) void ObjectManipulation::set_uniform_scaling(const bool new_value)
{ {
const Selection &selection = wxGetApp().plater()->canvas3D()->get_selection(); const Selection &selection = wxGetApp().plater()->canvas3D()->get_selection();
#if ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES #if ENABLE_WORLD_COORDINATE
if (selection.is_single_full_instance() && is_world_coordinates() && !new_value) { if (selection.is_single_full_instance() && is_world_coordinates() && !new_value) {
#else #else
if (selection.is_single_full_instance() && m_world_coordinates && !new_value) { if (selection.is_single_full_instance() && m_world_coordinates && !new_value) {
#endif // ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES #endif // ENABLE_WORLD_COORDINATE
// Verify whether the instance rotation is multiples of 90 degrees, so that the scaling in world coordinates is possible. // Verify whether the instance rotation is multiples of 90 degrees, so that the scaling in world coordinates is possible.
// all volumes in the selection belongs to the same instance, any of them contains the needed instance data, so we take the first one // all volumes in the selection belongs to the same instance, any of them contains the needed instance data, so we take the first one
const GLVolume* volume = selection.get_volume(*selection.get_volume_idxs().begin()); const GLVolume* volume = selection.get_volume(*selection.get_volume_idxs().begin());
@ -1285,7 +1239,6 @@ void ObjectManipulation::set_uniform_scaling(const bool new_value)
} }
#if ENABLE_WORLD_COORDINATE #if ENABLE_WORLD_COORDINATE
#if ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES
void ObjectManipulation::set_coordinates_type(ECoordinatesType type) void ObjectManipulation::set_coordinates_type(ECoordinatesType type)
{ {
if (wxGetApp().get_mode() == comSimple) if (wxGetApp().get_mode() == comSimple)
@ -1301,24 +1254,6 @@ void ObjectManipulation::set_coordinates_type(ECoordinatesType type)
canvas->set_as_dirty(); canvas->set_as_dirty();
canvas->request_extra_frame(); canvas->request_extra_frame();
} }
#else
void ObjectManipulation::set_world_coordinates(const bool world_coordinates)
{
m_world_coordinates = world_coordinates;
this->UpdateAndShow(true);
GLCanvas3D* canvas = wxGetApp().plater()->canvas3D();
canvas->get_gizmos_manager().update_data();
canvas->set_as_dirty();
canvas->request_extra_frame();
}
bool ObjectManipulation::get_world_coordinates() const
{
const Selection& selection = wxGetApp().plater()->canvas3D()->get_selection();
return wxGetApp().get_mode() != comSimple && (selection.is_single_full_instance() || selection.is_single_volume() || selection.is_single_modifier()) ?
m_world_coordinates : true;
}
#endif // ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES
#endif // ENABLE_WORLD_COORDINATE #endif // ENABLE_WORLD_COORDINATE
void ObjectManipulation::msw_rescale() void ObjectManipulation::msw_rescale()
@ -1384,7 +1319,7 @@ void ObjectManipulation::sys_color_changed()
m_mirror_buttons[id].first->msw_rescale(); m_mirror_buttons[id].first->msw_rescale();
} }
#if ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES #if ENABLE_WORLD_COORDINATE
void ObjectManipulation::set_coordinates_type(const wxString& type_string) void ObjectManipulation::set_coordinates_type(const wxString& type_string)
{ {
ECoordinatesType type = ECoordinatesType::World; ECoordinatesType type = ECoordinatesType::World;
@ -1395,7 +1330,7 @@ void ObjectManipulation::set_coordinates_type(const wxString& type_string)
this->set_coordinates_type(type); this->set_coordinates_type(type);
} }
#endif // ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES #endif // ENABLE_WORLD_COORDINATE
static const char axes[] = { 'x', 'y', 'z' }; static const char axes[] = { 'x', 'y', 'z' };
ManipulationEditor::ManipulationEditor(ObjectManipulation* parent, ManipulationEditor::ManipulationEditor(ObjectManipulation* parent,

View File

@ -5,9 +5,9 @@
#include "GUI_ObjectSettings.hpp" #include "GUI_ObjectSettings.hpp"
#include "GUI_ObjectList.hpp" #include "GUI_ObjectList.hpp"
#if ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES #if ENABLE_WORLD_COORDINATE
#include "GUI_Geometry.hpp" #include "GUI_Geometry.hpp"
#endif // ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES #endif // ENABLE_WORLD_COORDINATE
#include "libslic3r/Point.hpp" #include "libslic3r/Point.hpp"
#include <float.h> #include <float.h>
@ -151,12 +151,12 @@ private:
Vec3d m_new_size; Vec3d m_new_size;
bool m_new_enabled {true}; bool m_new_enabled {true};
bool m_uniform_scale {true}; bool m_uniform_scale {true};
#if ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES #if ENABLE_WORLD_COORDINATE
ECoordinatesType m_coordinates_type{ ECoordinatesType::World }; ECoordinatesType m_coordinates_type{ ECoordinatesType::World };
#else #else
// Does the object manipulation panel work in World or Local coordinates? // Does the object manipulation panel work in World or Local coordinates?
bool m_world_coordinates = true; bool m_world_coordinates = true;
#endif // ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES #endif // ENABLE_WORLD_COORDINATE
LockButton* m_lock_bnt{ nullptr }; LockButton* m_lock_bnt{ nullptr };
choice_ctrl* m_word_local_combo { nullptr }; choice_ctrl* m_word_local_combo { nullptr };
@ -199,17 +199,11 @@ public:
void set_uniform_scaling(const bool uniform_scale); void set_uniform_scaling(const bool uniform_scale);
bool get_uniform_scaling() const { return m_uniform_scale; } bool get_uniform_scaling() const { return m_uniform_scale; }
#if ENABLE_WORLD_COORDINATE #if ENABLE_WORLD_COORDINATE
#if ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES
void set_coordinates_type(ECoordinatesType type); void set_coordinates_type(ECoordinatesType type);
ECoordinatesType get_coordinates_type() const { return m_coordinates_type; } ECoordinatesType get_coordinates_type() const { return m_coordinates_type; }
bool is_world_coordinates() const { return m_coordinates_type == ECoordinatesType::World; } bool is_world_coordinates() const { return m_coordinates_type == ECoordinatesType::World; }
bool is_instance_coordinates() const { return m_coordinates_type == ECoordinatesType::Instance; } bool is_instance_coordinates() const { return m_coordinates_type == ECoordinatesType::Instance; }
bool is_local_coordinates() const { return m_coordinates_type == ECoordinatesType::Local; } bool is_local_coordinates() const { return m_coordinates_type == ECoordinatesType::Local; }
#else
// Does the object manipulation panel work in World or Local coordinates?
void set_world_coordinates(const bool world_coordinates);
bool get_world_coordinates() const;
#endif // ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES
#else #else
// Does the object manipulation panel work in World or Local coordinates? // Does the object manipulation panel work in World or Local coordinates?
void set_world_coordinates(const bool world_coordinates) { m_world_coordinates = world_coordinates; this->UpdateAndShow(true); } void set_world_coordinates(const bool world_coordinates) { m_world_coordinates = world_coordinates; this->UpdateAndShow(true); }
@ -243,9 +237,9 @@ public:
ManipulationEditor* get_focused_editor() { return m_focused_editor; } ManipulationEditor* get_focused_editor() { return m_focused_editor; }
#endif // ENABLE_WORLD_COORDINATE #endif // ENABLE_WORLD_COORDINATE
#if ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES #if ENABLE_WORLD_COORDINATE
static wxString coordinate_type_str(ECoordinatesType type); static wxString coordinate_type_str(ECoordinatesType type);
#endif // ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES #endif // ENABLE_WORLD_COORDINATE
private: private:
void reset_settings_value(); void reset_settings_value();
@ -263,9 +257,9 @@ private:
void change_size_value(int axis, double value); void change_size_value(int axis, double value);
void do_scale(int axis, const Vec3d &scale) const; void do_scale(int axis, const Vec3d &scale) const;
#if ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES #if ENABLE_WORLD_COORDINATE
void set_coordinates_type(const wxString& type_string); void set_coordinates_type(const wxString& type_string);
#endif // ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES #endif // ENABLE_WORLD_COORDINATE
}; };
}} }}

View File

@ -73,19 +73,13 @@ void GLGizmoMove3D::on_start_dragging()
m_displacement = Vec3d::Zero(); m_displacement = Vec3d::Zero();
#if ENABLE_WORLD_COORDINATE #if ENABLE_WORLD_COORDINATE
const Selection& selection = m_parent.get_selection(); const Selection& selection = m_parent.get_selection();
#if ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES
const ECoordinatesType coordinates_type = wxGetApp().obj_manipul()->get_coordinates_type(); const ECoordinatesType coordinates_type = wxGetApp().obj_manipul()->get_coordinates_type();
if (coordinates_type == ECoordinatesType::World) if (coordinates_type == ECoordinatesType::World)
#else
if (wxGetApp().obj_manipul()->get_world_coordinates())
#endif // ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES
m_starting_drag_position = m_center + m_grabbers[m_hover_id].center; m_starting_drag_position = m_center + m_grabbers[m_hover_id].center;
#if ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES
else if (coordinates_type == ECoordinatesType::Local && selection.is_single_volume_or_modifier()) { else if (coordinates_type == ECoordinatesType::Local && selection.is_single_volume_or_modifier()) {
const GLVolume& v = *selection.get_volume(*selection.get_volume_idxs().begin()); const GLVolume& v = *selection.get_volume(*selection.get_volume_idxs().begin());
m_starting_drag_position = m_center + Geometry::assemble_transform(Vec3d::Zero(), v.get_instance_rotation()) * Geometry::assemble_transform(Vec3d::Zero(), v.get_volume_rotation()) * m_grabbers[m_hover_id].center; m_starting_drag_position = m_center + Geometry::assemble_transform(Vec3d::Zero(), v.get_instance_rotation()) * Geometry::assemble_transform(Vec3d::Zero(), v.get_volume_rotation()) * m_grabbers[m_hover_id].center;
} }
#endif // ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES
else { else {
const GLVolume& v = *selection.get_volume(*selection.get_volume_idxs().begin()); const GLVolume& v = *selection.get_volume(*selection.get_volume_idxs().begin());
m_starting_drag_position = m_center + Geometry::assemble_transform(Vec3d::Zero(), v.get_instance_rotation()) * m_grabbers[m_hover_id].center; m_starting_drag_position = m_center + Geometry::assemble_transform(Vec3d::Zero(), v.get_instance_rotation()) * m_grabbers[m_hover_id].center;
@ -397,7 +391,6 @@ void GLGizmoMove3D::transform_to_local(const Selection& selection) const
{ {
glsafe(::glTranslated(m_center.x(), m_center.y(), m_center.z())); glsafe(::glTranslated(m_center.x(), m_center.y(), m_center.z()));
#if ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES
if (!wxGetApp().obj_manipul()->is_world_coordinates()) { if (!wxGetApp().obj_manipul()->is_world_coordinates()) {
const GLVolume& v = *selection.get_volume(*selection.get_volume_idxs().begin()); const GLVolume& v = *selection.get_volume(*selection.get_volume_idxs().begin());
Transform3d orient_matrix = v.get_instance_transformation().get_matrix(true, false, true, true); Transform3d orient_matrix = v.get_instance_transformation().get_matrix(true, false, true, true);
@ -405,33 +398,21 @@ void GLGizmoMove3D::transform_to_local(const Selection& selection) const
orient_matrix = orient_matrix * v.get_volume_transformation().get_matrix(true, false, true, true); orient_matrix = orient_matrix * v.get_volume_transformation().get_matrix(true, false, true, true);
glsafe(::glMultMatrixd(orient_matrix.data())); glsafe(::glMultMatrixd(orient_matrix.data()));
} }
#else
if (!wxGetApp().obj_manipul()->get_world_coordinates()) {
const Transform3d orient_matrix = selection.get_volume(*selection.get_volume_idxs().begin())->get_instance_transformation().get_matrix(true, false, true, true);
glsafe(::glMultMatrixd(orient_matrix.data()));
}
#endif // ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES
} }
void GLGizmoMove3D::calc_selection_box_and_center() void GLGizmoMove3D::calc_selection_box_and_center()
{ {
const Selection& selection = m_parent.get_selection(); const Selection& selection = m_parent.get_selection();
#if ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES
const ECoordinatesType coordinates_type = wxGetApp().obj_manipul()->get_coordinates_type(); const ECoordinatesType coordinates_type = wxGetApp().obj_manipul()->get_coordinates_type();
if (coordinates_type == ECoordinatesType::World) { if (coordinates_type == ECoordinatesType::World) {
#else
if (wxGetApp().obj_manipul()->get_world_coordinates()) {
#endif // ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES
m_bounding_box = selection.get_bounding_box(); m_bounding_box = selection.get_bounding_box();
m_center = m_bounding_box.center(); m_center = m_bounding_box.center();
} }
#if ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES
else if (coordinates_type == ECoordinatesType::Local && selection.is_single_volume_or_modifier()) { else if (coordinates_type == ECoordinatesType::Local && selection.is_single_volume_or_modifier()) {
const GLVolume& v = *selection.get_volume(*selection.get_volume_idxs().begin()); const GLVolume& v = *selection.get_volume(*selection.get_volume_idxs().begin());
m_bounding_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)); m_bounding_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));
m_center = v.world_matrix() * m_bounding_box.center(); m_center = v.world_matrix() * m_bounding_box.center();
} }
#endif // ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES
else { else {
m_bounding_box.reset(); m_bounding_box.reset();
const Selection::IndicesList& ids = selection.get_volume_idxs(); const Selection::IndicesList& ids = selection.get_volume_idxs();

View File

@ -219,22 +219,16 @@ 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)
{ {
#if ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES
const ECoordinatesType coordinates_type = wxGetApp().obj_manipul()->get_coordinates_type(); const ECoordinatesType coordinates_type = wxGetApp().obj_manipul()->get_coordinates_type();
if (coordinates_type == ECoordinatesType::World) { if (coordinates_type == ECoordinatesType::World) {
#else
if (wxGetApp().obj_manipul()->get_world_coordinates()) {
#endif // ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES
m_bounding_box = selection.get_bounding_box(); m_bounding_box = selection.get_bounding_box();
m_center = m_bounding_box.center(); m_center = m_bounding_box.center();
} }
#if ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES
else if (coordinates_type == ECoordinatesType::Local && selection.is_single_volume_or_modifier()) { else if (coordinates_type == ECoordinatesType::Local && selection.is_single_volume_or_modifier()) {
const GLVolume& v = *selection.get_volume(*selection.get_volume_idxs().begin()); const GLVolume& v = *selection.get_volume(*selection.get_volume_idxs().begin());
m_bounding_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)); m_bounding_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));
m_center = v.world_matrix() * m_bounding_box.center(); m_center = v.world_matrix() * m_bounding_box.center();
} }
#endif // ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES
else { else {
m_bounding_box.reset(); m_bounding_box.reset();
const Selection::IndicesList& ids = selection.get_volume_idxs(); const Selection::IndicesList& ids = selection.get_volume_idxs();
@ -252,7 +246,6 @@ void GLGizmoRotate::init_data_from_selection(const Selection& selection)
m_snap_fine_in_radius = m_radius; m_snap_fine_in_radius = m_radius;
m_snap_fine_out_radius = m_snap_fine_in_radius + m_radius * ScaleLongTooth; m_snap_fine_out_radius = m_snap_fine_in_radius + m_radius * ScaleLongTooth;
#if ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES
if (coordinates_type == ECoordinatesType::World) if (coordinates_type == ECoordinatesType::World)
m_orient_matrix = Transform3d::Identity(); m_orient_matrix = Transform3d::Identity();
else if (coordinates_type == ECoordinatesType::Local && selection.is_single_volume_or_modifier()) { else if (coordinates_type == ECoordinatesType::Local && selection.is_single_volume_or_modifier()) {
@ -263,12 +256,6 @@ void GLGizmoRotate::init_data_from_selection(const Selection& selection)
const GLVolume& v = *selection.get_volume(*selection.get_volume_idxs().begin()); const GLVolume& v = *selection.get_volume(*selection.get_volume_idxs().begin());
m_orient_matrix = v.get_instance_transformation().get_matrix(true, false, true, true); m_orient_matrix = v.get_instance_transformation().get_matrix(true, false, true, true);
} }
#else
if (wxGetApp().obj_manipul()->get_world_coordinates())
m_orient_matrix = Transform3d::Identity();
else
m_orient_matrix = selection.get_volume(*selection.get_volume_idxs().begin())->get_instance_transformation().get_matrix(true, false, true, true);
#endif // ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES
} }
#endif // ENABLE_WORLD_COORDINATE #endif // ENABLE_WORLD_COORDINATE

View File

@ -144,12 +144,7 @@ void GLGizmoScale3D::on_render()
m_grabbers_transform = Transform3d::Identity(); m_grabbers_transform = Transform3d::Identity();
m_center = Vec3d::Zero(); m_center = Vec3d::Zero();
m_instance_center = Vec3d::Zero(); m_instance_center = Vec3d::Zero();
#if ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES
if (selection.is_single_full_instance() && !wxGetApp().obj_manipul()->is_world_coordinates()) { if (selection.is_single_full_instance() && !wxGetApp().obj_manipul()->is_world_coordinates()) {
#else
bool world_coordinates = wxGetApp().obj_manipul()->get_world_coordinates();
if (selection.is_single_full_instance() && !world_coordinates) {
#endif // ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES
#else #else
m_transform = Transform3d::Identity(); m_transform = Transform3d::Identity();
// Transforms grabbers' offsets to world refefence system // Transforms grabbers' offsets to world refefence system
@ -180,6 +175,8 @@ void GLGizmoScale3D::on_render()
m_grabbers_transform = v.get_instance_transformation().get_matrix(false, false, true) * Geometry::assemble_transform(m_bounding_box.center()); m_grabbers_transform = v.get_instance_transformation().get_matrix(false, false, true) * Geometry::assemble_transform(m_bounding_box.center());
m_center = selection.get_volume(*idxs.begin())->get_instance_transformation().get_matrix(false, false, true, false) * m_bounding_box.center(); m_center = selection.get_volume(*idxs.begin())->get_instance_transformation().get_matrix(false, false, true, false) * m_bounding_box.center();
m_instance_center = v.get_instance_offset(); m_instance_center = v.get_instance_offset();
}
else if (selection.is_single_volume_or_modifier() && wxGetApp().obj_manipul()->is_instance_coordinates()) {
#else #else
m_transform = v.get_instance_transformation().get_matrix(); m_transform = v.get_instance_transformation().get_matrix();
@ -188,32 +185,18 @@ void GLGizmoScale3D::on_render()
// consider rotation+mirror only components of the transform for offsets // consider rotation+mirror only components of the transform for offsets
offsets_transform = Geometry::assemble_transform(Vec3d::Zero(), angles, Vec3d::Ones(), v.get_instance_mirror()); offsets_transform = Geometry::assemble_transform(Vec3d::Zero(), angles, Vec3d::Ones(), v.get_instance_mirror());
m_offsets_transform = offsets_transform; m_offsets_transform = offsets_transform;
#endif // ENABLE_WORLD_COORDINATE
} }
#if ENABLE_WORLD_COORDINATE
#if ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES
else if (selection.is_single_volume_or_modifier() && wxGetApp().obj_manipul()->is_instance_coordinates()) {
#else
else if (selection.is_single_volume_or_modifier() && !world_coordinates) {
#endif // ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES
#else
else if (selection.is_single_modifier() || selection.is_single_volume()) { else if (selection.is_single_modifier() || selection.is_single_volume()) {
#endif // ENABLE_WORLD_COORDINATE #endif // ENABLE_WORLD_COORDINATE
const GLVolume& v = *selection.get_volume(*selection.get_volume_idxs().begin()); const GLVolume& v = *selection.get_volume(*selection.get_volume_idxs().begin());
#if ENABLE_WORLD_COORDINATE #if ENABLE_WORLD_COORDINATE
#if ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES
m_bounding_box.merge(v.transformed_convex_hull_bounding_box(v.get_instance_transformation().get_matrix(true, true, false, true) * v.get_volume_transformation().get_matrix(true, false, false, true))); m_bounding_box.merge(v.transformed_convex_hull_bounding_box(v.get_instance_transformation().get_matrix(true, true, false, true) * v.get_volume_transformation().get_matrix(true, false, false, true)));
Geometry::Transformation trafo(v.get_instance_transformation().get_matrix(true, false, true, true)); Geometry::Transformation trafo(v.get_instance_transformation().get_matrix(true, false, true, true));
#else
m_bounding_box.merge(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)));
Geometry::Transformation trafo(v.get_instance_transformation().get_matrix(true, false, true) * v.get_volume_transformation().get_matrix(true, false, true));
#endif // ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES
trafo.set_offset(v.world_matrix().translation()); trafo.set_offset(v.world_matrix().translation());
m_grabbers_transform = trafo.get_matrix(); m_grabbers_transform = trafo.get_matrix();
m_center = v.world_matrix() * m_bounding_box.center(); m_center = v.world_matrix() * m_bounding_box.center();
m_instance_center = m_center; m_instance_center = m_center;
} }
#if ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES
else if (selection.is_single_volume_or_modifier() && wxGetApp().obj_manipul()->is_local_coordinates()) { else if (selection.is_single_volume_or_modifier() && wxGetApp().obj_manipul()->is_local_coordinates()) {
const GLVolume& v = *selection.get_volume(*selection.get_volume_idxs().begin()); const GLVolume& v = *selection.get_volume(*selection.get_volume_idxs().begin());
m_bounding_box.merge(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))); m_bounding_box.merge(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)));
@ -223,7 +206,6 @@ void GLGizmoScale3D::on_render()
m_center = v.world_matrix() * m_bounding_box.center(); m_center = v.world_matrix() * m_bounding_box.center();
m_instance_center = m_center; m_instance_center = m_center;
} }
#endif // ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES
else { else {
m_bounding_box = selection.get_bounding_box(); m_bounding_box = selection.get_bounding_box();
m_grabbers_transform = Geometry::assemble_transform(m_bounding_box.center()); m_grabbers_transform = Geometry::assemble_transform(m_bounding_box.center());
@ -568,13 +550,8 @@ void GLGizmoScale3D::do_scale_along_axis(Axis axis, const UpdateData& data)
Vec3d curr_scale = m_scale; Vec3d curr_scale = m_scale;
Vec3d starting_scale = m_starting.scale; Vec3d starting_scale = m_starting.scale;
const Selection& selection = m_parent.get_selection(); const Selection& selection = m_parent.get_selection();
#if ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES
const ECoordinatesType coordinates_type = wxGetApp().obj_manipul()->get_coordinates_type(); const ECoordinatesType coordinates_type = wxGetApp().obj_manipul()->get_coordinates_type();
if (coordinates_type == ECoordinatesType::World) { if (coordinates_type == ECoordinatesType::World) {
#else
const bool world_coordinates = wxGetApp().obj_manipul()->get_world_coordinates();
if (world_coordinates) {
#endif // ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES
if (selection.is_single_full_instance()) { if (selection.is_single_full_instance()) {
const Transform3d m = Geometry::assemble_transform(Vec3d::Zero(), selection.get_volume(*selection.get_volume_idxs().begin())->get_instance_rotation()); const Transform3d m = Geometry::assemble_transform(Vec3d::Zero(), selection.get_volume(*selection.get_volume_idxs().begin())->get_instance_rotation());
curr_scale = (m * curr_scale).cwiseAbs(); curr_scale = (m * curr_scale).cwiseAbs();
@ -591,11 +568,7 @@ void GLGizmoScale3D::do_scale_along_axis(Axis axis, const UpdateData& data)
curr_scale(axis) = starting_scale(axis) * ratio; curr_scale(axis) = starting_scale(axis) * ratio;
#if ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES
if (coordinates_type == ECoordinatesType::World) { if (coordinates_type == ECoordinatesType::World) {
#else
if (world_coordinates) {
#endif // ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES
if (selection.is_single_full_instance()) if (selection.is_single_full_instance())
m_scale = (Geometry::assemble_transform(Vec3d::Zero(), selection.get_volume(*selection.get_volume_idxs().begin())->get_instance_rotation()).inverse() * curr_scale).cwiseAbs(); m_scale = (Geometry::assemble_transform(Vec3d::Zero(), selection.get_volume(*selection.get_volume_idxs().begin())->get_instance_rotation()).inverse() * curr_scale).cwiseAbs();
else if (selection.is_single_volume_or_modifier()) { else if (selection.is_single_volume_or_modifier()) {
@ -625,11 +598,7 @@ void GLGizmoScale3D::do_scale_along_axis(Axis axis, const UpdateData& data)
#if ENABLE_WORLD_COORDINATE #if ENABLE_WORLD_COORDINATE
Vec3d center_offset = m_starting.instance_center - m_starting.center; Vec3d center_offset = m_starting.instance_center - m_starting.center;
#if ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES
if (selection.is_single_full_instance() && coordinates_type != ECoordinatesType::World) { if (selection.is_single_full_instance() && coordinates_type != ECoordinatesType::World) {
#else
if (selection.is_single_full_instance() && !world_coordinates) {
#endif // ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES
const Transform3d m = Geometry::assemble_transform(Vec3d::Zero(), selection.get_volume(*selection.get_volume_idxs().begin())->get_instance_rotation()).inverse(); const Transform3d m = Geometry::assemble_transform(Vec3d::Zero(), selection.get_volume(*selection.get_volume_idxs().begin())->get_instance_rotation()).inverse();
center_offset = m * center_offset; center_offset = m * center_offset;
} }
@ -643,14 +612,6 @@ void GLGizmoScale3D::do_scale_along_axis(Axis axis, const UpdateData& data)
case Z: { m_offset = local_offset * Vec3d::UnitZ(); break; } case Z: { m_offset = local_offset * Vec3d::UnitZ(); break; }
default: { m_offset = Vec3d::Zero(); break; } default: { m_offset = Vec3d::Zero(); break; }
} }
#if !ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES
if (selection.is_single_volume_or_modifier() && !world_coordinates) {
const Transform3d mv = Geometry::assemble_transform(Vec3d::Zero(), selection.get_volume(*selection.get_volume_idxs().begin())->get_volume_rotation());
const Transform3d mi = Geometry::assemble_transform(Vec3d::Zero(), Vec3d::Zero(), selection.get_volume(*selection.get_volume_idxs().begin())->get_instance_scaling_factor()).inverse();
m_offset = mv * mi * m_offset;
}
#endif // !ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES
#else #else
Vec3d local_offset_vec; Vec3d local_offset_vec;
switch (axis) switch (axis)
@ -684,29 +645,14 @@ void GLGizmoScale3D::do_scale_uniform(const UpdateData& data)
m_offset.y() *= -1.0; m_offset.y() *= -1.0;
const Selection& selection = m_parent.get_selection(); const Selection& selection = m_parent.get_selection();
#if !ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES
const bool world_coordinates = wxGetApp().obj_manipul()->get_world_coordinates();
#endif // !ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES
Vec3d center_offset = m_starting.instance_center - m_starting.center; Vec3d center_offset = m_starting.instance_center - m_starting.center;
#if ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES
if (selection.is_single_full_instance() && !wxGetApp().obj_manipul()->is_world_coordinates()) { if (selection.is_single_full_instance() && !wxGetApp().obj_manipul()->is_world_coordinates()) {
#else
if (selection.is_single_full_instance() && !world_coordinates) {
#endif // ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES
const Transform3d m = Geometry::assemble_transform(Vec3d::Zero(), selection.get_volume(*selection.get_volume_idxs().begin())->get_instance_rotation()).inverse(); const Transform3d m = Geometry::assemble_transform(Vec3d::Zero(), selection.get_volume(*selection.get_volume_idxs().begin())->get_instance_rotation()).inverse();
center_offset = m * center_offset; center_offset = m * center_offset;
} }
m_offset += (ratio - 1.0) * center_offset; m_offset += (ratio - 1.0) * center_offset;
#if !ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES
if (selection.is_single_volume_or_modifier() && !world_coordinates) {
const Transform3d mv = Geometry::assemble_transform(Vec3d::Zero(), selection.get_volume(*selection.get_volume_idxs().begin())->get_volume_rotation());
const Transform3d mi = Geometry::assemble_transform(Vec3d::Zero(), Vec3d::Zero(), selection.get_volume(*selection.get_volume_idxs().begin())->get_instance_scaling_factor()).inverse();
m_offset = mv * mi * m_offset;
}
#endif // !ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES
} }
else else
#endif // ENABLE_WORLD_COORDINATE #endif // ENABLE_WORLD_COORDINATE
@ -754,17 +700,9 @@ void GLGizmoScale3D::transform_to_local(const Selection& selection) const
{ {
glsafe(::glTranslated(m_center.x(), m_center.y(), m_center.z())); glsafe(::glTranslated(m_center.x(), m_center.y(), m_center.z()));
#if ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES
if (!wxGetApp().obj_manipul()->is_world_coordinates()) { if (!wxGetApp().obj_manipul()->is_world_coordinates()) {
#else
if (!wxGetApp().obj_manipul()->get_world_coordinates()) {
#endif // ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES
Transform3d orient_matrix = selection.get_volume(*selection.get_volume_idxs().begin())->get_instance_transformation().get_matrix(true, false, true, true); Transform3d orient_matrix = selection.get_volume(*selection.get_volume_idxs().begin())->get_instance_transformation().get_matrix(true, false, true, true);
#if ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES
if (selection.is_single_volume_or_modifier() && wxGetApp().obj_manipul()->is_local_coordinates()) if (selection.is_single_volume_or_modifier() && wxGetApp().obj_manipul()->is_local_coordinates())
#else
if (selection.is_single_volume_or_modifier())
#endif // ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES
orient_matrix = orient_matrix * selection.get_volume(*selection.get_volume_idxs().begin())->get_volume_transformation().get_matrix(true, false, true, true); orient_matrix = orient_matrix * selection.get_volume(*selection.get_volume_idxs().begin())->get_volume_transformation().get_matrix(true, false, true, true);
glsafe(::glMultMatrixd(orient_matrix.data())); glsafe(::glMultMatrixd(orient_matrix.data()));
} }

View File

@ -621,11 +621,7 @@ bool GLGizmosManager::on_mouse(wxMouseEvent& evt)
{ {
// Apply new temporary offset // Apply new temporary offset
#if ENABLE_WORLD_COORDINATE #if ENABLE_WORLD_COORDINATE
#if ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES
selection.translate(get_displacement(), wxGetApp().obj_manipul()->get_coordinates_type()); selection.translate(get_displacement(), wxGetApp().obj_manipul()->get_coordinates_type());
#else
selection.translate(get_displacement(), !wxGetApp().obj_manipul()->get_world_coordinates());
#endif // ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES
#else #else
selection.translate(get_displacement()); selection.translate(get_displacement());
#endif // ENABLE_WORLD_COORDINATE #endif // ENABLE_WORLD_COORDINATE
@ -637,11 +633,7 @@ bool GLGizmosManager::on_mouse(wxMouseEvent& evt)
// Apply new temporary scale factors // Apply new temporary scale factors
#if ENABLE_WORLD_COORDINATE #if ENABLE_WORLD_COORDINATE
TransformationType transformation_type; TransformationType transformation_type;
#if ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES
if (!wxGetApp().obj_manipul()->is_world_coordinates()) if (!wxGetApp().obj_manipul()->is_world_coordinates())
#else
if (!wxGetApp().obj_manipul()->get_world_coordinates())
#endif // ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES
transformation_type.set_local(); transformation_type.set_local();
#else #else
TransformationType transformation_type(TransformationType::Local_Absolute_Joint); TransformationType transformation_type(TransformationType::Local_Absolute_Joint);
@ -651,11 +643,7 @@ bool GLGizmosManager::on_mouse(wxMouseEvent& evt)
selection.scale(get_scale(), transformation_type); selection.scale(get_scale(), transformation_type);
if (control_down) if (control_down)
#if ENABLE_WORLD_COORDINATE #if ENABLE_WORLD_COORDINATE
#if ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES
selection.translate(get_scale_offset(), wxGetApp().obj_manipul()->get_coordinates_type()); selection.translate(get_scale_offset(), wxGetApp().obj_manipul()->get_coordinates_type());
#else
selection.translate(get_scale_offset(), !wxGetApp().obj_manipul()->get_world_coordinates());
#endif // ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES
#else #else
selection.translate(get_scale_offset(), true); selection.translate(get_scale_offset(), true);
#endif // ENABLE_WORLD_COORDINATE #endif // ENABLE_WORLD_COORDINATE
@ -666,7 +654,6 @@ bool GLGizmosManager::on_mouse(wxMouseEvent& evt)
{ {
// Apply new temporary rotations // Apply new temporary rotations
#if ENABLE_WORLD_COORDINATE #if ENABLE_WORLD_COORDINATE
#if ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES
TransformationType transformation_type; TransformationType transformation_type;
switch (wxGetApp().obj_manipul()->get_coordinates_type()) switch (wxGetApp().obj_manipul()->get_coordinates_type())
{ {
@ -675,9 +662,6 @@ bool GLGizmosManager::on_mouse(wxMouseEvent& evt)
case ECoordinatesType::Instance: { transformation_type = TransformationType::Instance_Relative_Joint; break; } case ECoordinatesType::Instance: { transformation_type = TransformationType::Instance_Relative_Joint; break; }
case ECoordinatesType::Local: { transformation_type = TransformationType::Local_Relative_Joint; break; } case ECoordinatesType::Local: { transformation_type = TransformationType::Local_Relative_Joint; break; }
} }
#else
TransformationType transformation_type(wxGetApp().obj_manipul()->get_world_coordinates() ? TransformationType::World_Relative_Joint : TransformationType::Local_Relative_Joint);
#endif // ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES
#else #else
TransformationType transformation_type(TransformationType::World_Relative_Joint); TransformationType transformation_type(TransformationType::World_Relative_Joint);
#endif // ENABLE_WORLD_COORDINATE #endif // ENABLE_WORLD_COORDINATE

View File

@ -57,9 +57,9 @@
#include "GUI_ObjectManipulation.hpp" #include "GUI_ObjectManipulation.hpp"
#include "GUI_ObjectLayers.hpp" #include "GUI_ObjectLayers.hpp"
#include "GUI_Utils.hpp" #include "GUI_Utils.hpp"
#if ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES #if ENABLE_WORLD_COORDINATE
#include "GUI_Geometry.hpp" #include "GUI_Geometry.hpp"
#endif // ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES #endif // ENABLE_WORLD_COORDINATE
#include "GUI_Factories.hpp" #include "GUI_Factories.hpp"
#include "wxExtensions.hpp" #include "wxExtensions.hpp"
#include "MainFrame.hpp" #include "MainFrame.hpp"
@ -1521,10 +1521,10 @@ void Sidebar::update_mode()
wxWindowUpdateLocker noUpdates(this); wxWindowUpdateLocker noUpdates(this);
#if ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES #if ENABLE_WORLD_COORDINATE
if (m_mode == comSimple) if (m_mode == comSimple)
p->object_manipulation->set_coordinates_type(ECoordinatesType::World); p->object_manipulation->set_coordinates_type(ECoordinatesType::World);
#endif // ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES #endif // ENABLE_WORLD_COORDINATE
p->object_list->get_sizer()->Show(m_mode > comSimple); p->object_list->get_sizer()->Show(m_mode > comSimple);

View File

@ -592,19 +592,15 @@ bool Selection::matches(const std::vector<unsigned int>& volume_idxs) const
return count == (unsigned int)m_list.size(); return count == (unsigned int)m_list.size();
} }
#if ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES #if ENABLE_WORLD_COORDINATE
bool Selection::requires_uniform_scale(EUniformScaleRequiredReason* reason) const bool Selection::requires_uniform_scale(EUniformScaleRequiredReason* reason) const
#else #else
bool Selection::requires_uniform_scale() const bool Selection::requires_uniform_scale() const
#endif // ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES #endif // ENABLE_WORLD_COORDINATE
{ {
#if ENABLE_WORLD_COORDINATE #if ENABLE_WORLD_COORDINATE
#if ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES
ECoordinatesType coord_type = wxGetApp().obj_manipul()->get_coordinates_type(); ECoordinatesType coord_type = wxGetApp().obj_manipul()->get_coordinates_type();
#endif // ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES if (is_single_volume_or_modifier()) {
if (is_single_volume_or_modifier())
#if ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES
{
if (coord_type == ECoordinatesType::World) { if (coord_type == ECoordinatesType::World) {
if (!Geometry::is_rotation_ninety_degrees(Geometry::Transformation(get_volume(*m_list.begin())->world_matrix()).get_rotation())) { if (!Geometry::is_rotation_ninety_degrees(Geometry::Transformation(get_volume(*m_list.begin())->world_matrix()).get_rotation())) {
if (reason != nullptr) if (reason != nullptr)
@ -621,11 +617,7 @@ bool Selection::requires_uniform_scale() const
} }
return false; return false;
} }
#else
return !Geometry::is_rotation_ninety_degrees(Geometry::Transformation(get_volume(*m_list.begin())->world_matrix()).get_rotation());
#endif // ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES
else if (is_single_full_instance()) { else if (is_single_full_instance()) {
#if ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES
if (coord_type == ECoordinatesType::World) { if (coord_type == ECoordinatesType::World) {
if (!Geometry::is_rotation_ninety_degrees(get_volume(*m_list.begin())->get_instance_rotation())) { if (!Geometry::is_rotation_ninety_degrees(get_volume(*m_list.begin())->get_instance_rotation())) {
if (reason != nullptr) if (reason != nullptr)
@ -657,11 +649,6 @@ bool Selection::requires_uniform_scale() const
if (reason != nullptr) if (reason != nullptr)
*reason = EUniformScaleRequiredReason::MultipleSelection; *reason = EUniformScaleRequiredReason::MultipleSelection;
#else
return wxGetApp().obj_manipul()->get_world_coordinates() ?
!Geometry::is_rotation_ninety_degrees(get_volume(*m_list.begin())->get_instance_rotation()) : false;
}
#endif // ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES
return true; return true;
#else #else
@ -760,11 +747,11 @@ void Selection::start_dragging()
set_caches(); set_caches();
} }
#if ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES #if ENABLE_WORLD_COORDINATE
void Selection::translate(const Vec3d& displacement, ECoordinatesType type) void Selection::translate(const Vec3d& displacement, ECoordinatesType type)
#else #else
void Selection::translate(const Vec3d& displacement, bool local) void Selection::translate(const Vec3d& displacement, bool local)
#endif // ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES #endif // ENABLE_WORLD_COORDINATE
{ {
if (!m_valid) if (!m_valid)
return; return;
@ -774,19 +761,19 @@ void Selection::translate(const Vec3d& displacement, bool local)
for (unsigned int i : m_list) { for (unsigned int i : m_list) {
GLVolume& v = *(*m_volumes)[i]; GLVolume& v = *(*m_volumes)[i];
if (m_mode == Volume || v.is_wipe_tower) { if (m_mode == Volume || v.is_wipe_tower) {
#if ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES #if ENABLE_WORLD_COORDINATE
if (type == ECoordinatesType::Instance) if (type == ECoordinatesType::Instance)
#else #else
if (local) if (local)
#endif // ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES #endif // ENABLE_WORLD_COORDINATE
v.set_volume_offset(m_cache.volumes_data[i].get_volume_position() + displacement); v.set_volume_offset(m_cache.volumes_data[i].get_volume_position() + displacement);
#if ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES #if ENABLE_WORLD_COORDINATE
else if (type == ECoordinatesType::Local) { else if (type == ECoordinatesType::Local) {
const VolumeCache& volume_data = m_cache.volumes_data[i]; const VolumeCache& volume_data = m_cache.volumes_data[i];
const Vec3d local_displacement = volume_data.get_volume_rotation_matrix() * displacement; const Vec3d local_displacement = volume_data.get_volume_rotation_matrix() * displacement;
v.set_volume_offset(volume_data.get_volume_position() + local_displacement); v.set_volume_offset(volume_data.get_volume_position() + local_displacement);
} }
#endif // ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES #endif // ENABLE_WORLD_COORDINATE
else { else {
#if ENABLE_WORLD_COORDINATE #if ENABLE_WORLD_COORDINATE
const VolumeCache& volume_data = m_cache.volumes_data[i]; const VolumeCache& volume_data = m_cache.volumes_data[i];
@ -801,15 +788,9 @@ void Selection::translate(const Vec3d& displacement, bool local)
else if (m_mode == Instance) { else if (m_mode == Instance) {
#if ENABLE_WORLD_COORDINATE #if ENABLE_WORLD_COORDINATE
if (is_from_fully_selected_instance(i)) { if (is_from_fully_selected_instance(i)) {
#if ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES
if (type == ECoordinatesType::Local) { if (type == ECoordinatesType::Local) {
const VolumeCache& volume_data = m_cache.volumes_data[i]; const VolumeCache& volume_data = m_cache.volumes_data[i];
const Vec3d world_displacement = volume_data.get_instance_rotation_matrix() * displacement; const Vec3d world_displacement = volume_data.get_instance_rotation_matrix() * displacement;
#else
if (local) {
const VolumeCache& volume_data = m_cache.volumes_data[i];
const Vec3d world_displacement = (volume_data.get_instance_rotation_matrix() * volume_data.get_instance_mirror_matrix()) * displacement;
#endif // ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES
v.set_instance_offset(volume_data.get_instance_position() + world_displacement); v.set_instance_offset(volume_data.get_instance_position() + world_displacement);
} }
else else
@ -918,7 +899,6 @@ void Selection::rotate(const Vec3d& rotation, TransformationType transformation_
rotate_instance(v, i); rotate_instance(v, i);
#if ENABLE_WORLD_COORDINATE #if ENABLE_WORLD_COORDINATE
else if (is_single_volume_or_modifier()) { else if (is_single_volume_or_modifier()) {
#if ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES
if (transformation_type.local()) { if (transformation_type.local()) {
const Transform3d m = Geometry::assemble_transform(Vec3d::Zero(), rotation); const Transform3d m = Geometry::assemble_transform(Vec3d::Zero(), rotation);
v.set_volume_rotation(Geometry::extract_euler_angles(m_cache.volumes_data[i].get_volume_rotation_matrix() * m)); v.set_volume_rotation(Geometry::extract_euler_angles(m_cache.volumes_data[i].get_volume_rotation_matrix() * m));
@ -927,10 +907,6 @@ void Selection::rotate(const Vec3d& rotation, TransformationType transformation_
const Transform3d m = Geometry::assemble_transform(Vec3d::Zero(), rotation); const Transform3d m = Geometry::assemble_transform(Vec3d::Zero(), rotation);
v.set_volume_rotation(Geometry::extract_euler_angles(m * m_cache.volumes_data[i].get_volume_rotation_matrix())); v.set_volume_rotation(Geometry::extract_euler_angles(m * m_cache.volumes_data[i].get_volume_rotation_matrix()));
} }
#else
if (transformation_type.local())
v.set_volume_rotation(m_cache.volumes_data[i].get_volume_rotation() + rotation);
#endif // ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES
else { else {
Transform3d m = Geometry::assemble_transform(Vec3d::Zero(), rotation); Transform3d m = Geometry::assemble_transform(Vec3d::Zero(), rotation);
m = m * m_cache.volumes_data[i].get_instance_rotation_matrix(); m = m * m_cache.volumes_data[i].get_instance_rotation_matrix();
@ -1505,32 +1481,15 @@ void Selection::render_sidebar_hints(const std::string& sidebar_field)
if (!boost::starts_with(sidebar_field, "layer")) { if (!boost::starts_with(sidebar_field, "layer")) {
const Vec3d center = get_bounding_box().center(); const Vec3d center = get_bounding_box().center();
#if ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES #if ENABLE_WORLD_COORDINATE
if (is_single_full_instance() && !wxGetApp().obj_manipul()->is_world_coordinates()) { if (is_single_full_instance() && !wxGetApp().obj_manipul()->is_world_coordinates()) {
#else #else
if (is_single_full_instance() && !wxGetApp().obj_manipul()->get_world_coordinates()) { if (is_single_full_instance() && !wxGetApp().obj_manipul()->get_world_coordinates()) {
#endif // ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES #endif // ENABLE_WORLD_COORDINATE
glsafe(::glTranslated(center.x(), center.y(), center.z())); glsafe(::glTranslated(center.x(), center.y(), center.z()));
#if ENABLE_WORLD_COORDINATE #if ENABLE_WORLD_COORDINATE
Transform3d orient_matrix = Transform3d::Identity(); Transform3d orient_matrix = Transform3d::Identity();
#if ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES
orient_matrix = (*m_volumes)[*m_list.begin()]->get_instance_transformation().get_matrix(true, false, true, true); orient_matrix = (*m_volumes)[*m_list.begin()]->get_instance_transformation().get_matrix(true, false, true, true);
#else
if (boost::starts_with(sidebar_field, "position") || boost::starts_with(sidebar_field, "scale"))
orient_matrix = (*m_volumes)[*m_list.begin()]->get_instance_transformation().get_matrix(true, false, true, true);
else if (boost::starts_with(sidebar_field, "rotation")) {
if (boost::ends_with(sidebar_field, "x"))
orient_matrix = (*m_volumes)[*m_list.begin()]->get_instance_transformation().get_matrix(true, false, true, true);
else if (boost::ends_with(sidebar_field, "y")) {
const Vec3d& rotation = (*m_volumes)[*m_list.begin()]->get_instance_transformation().get_rotation();
if (rotation.x() == 0.0)
orient_matrix = (*m_volumes)[*m_list.begin()]->get_instance_transformation().get_matrix(true, false, true, true);
else
orient_matrix.rotate(Eigen::AngleAxisd(rotation.z(), Vec3d::UnitZ()));
}
}
#endif // ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES
glsafe(::glMultMatrixd(orient_matrix.data())); glsafe(::glMultMatrixd(orient_matrix.data()));
#else #else
if (!boost::starts_with(sidebar_field, "position")) { if (!boost::starts_with(sidebar_field, "position")) {
@ -1560,15 +1519,9 @@ void Selection::render_sidebar_hints(const std::string& sidebar_field)
#endif // ENABLE_WORLD_COORDINATE #endif // ENABLE_WORLD_COORDINATE
glsafe(::glTranslated(center.x(), center.y(), center.z())); glsafe(::glTranslated(center.x(), center.y(), center.z()));
#if ENABLE_WORLD_COORDINATE #if ENABLE_WORLD_COORDINATE
#if ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES
if (!wxGetApp().obj_manipul()->is_world_coordinates()) { if (!wxGetApp().obj_manipul()->is_world_coordinates()) {
Transform3d orient_matrix = Transform3d::Identity(); Transform3d orient_matrix = Transform3d::Identity();
if (wxGetApp().obj_manipul()->is_local_coordinates()) { if (wxGetApp().obj_manipul()->is_local_coordinates()) {
#else
if (!wxGetApp().obj_manipul()->get_world_coordinates()) {
Transform3d orient_matrix = Transform3d::Identity();
if (boost::starts_with(sidebar_field, "scale")) {
#endif // ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES
const GLVolume* v = (*m_volumes)[*m_list.begin()]; const GLVolume* v = (*m_volumes)[*m_list.begin()];
orient_matrix = v->get_instance_transformation().get_matrix(true, false, true, true) * v->get_volume_transformation().get_matrix(true, false, true, true); orient_matrix = v->get_instance_transformation().get_matrix(true, false, true, true) * v->get_volume_transformation().get_matrix(true, false, true, true);
} }

View File

@ -2,9 +2,9 @@
#define slic3r_GUI_Selection_hpp_ #define slic3r_GUI_Selection_hpp_
#include "libslic3r/Geometry.hpp" #include "libslic3r/Geometry.hpp"
#if ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES #if ENABLE_WORLD_COORDINATE
#include "slic3r/GUI/GUI_Geometry.hpp" #include "slic3r/GUI/GUI_Geometry.hpp"
#endif // ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES #endif // ENABLE_WORLD_COORDINATE
#include "GLModel.hpp" #include "GLModel.hpp"
#include <set> #include <set>
@ -27,7 +27,7 @@ using ModelObjectPtrs = std::vector<ModelObject*>;
namespace GUI { namespace GUI {
#if !ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES #if !ENABLE_WORLD_COORDINATE
class TransformationType class TransformationType
{ {
public: public:
@ -80,7 +80,7 @@ private:
Enum m_value; Enum m_value;
}; };
#endif // !ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES #endif // !ENABLE_WORLD_COORDINATE
class Selection class Selection
{ {
@ -308,7 +308,7 @@ public:
// returns true if the selection contains all and only the given indices // returns true if the selection contains all and only the given indices
bool matches(const std::vector<unsigned int>& volume_idxs) const; bool matches(const std::vector<unsigned int>& volume_idxs) const;
#if ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES #if ENABLE_WORLD_COORDINATE
enum class EUniformScaleRequiredReason : unsigned char enum class EUniformScaleRequiredReason : unsigned char
{ {
NotRequired, NotRequired,
@ -320,7 +320,7 @@ public:
bool requires_uniform_scale(EUniformScaleRequiredReason* reason = nullptr) const; bool requires_uniform_scale(EUniformScaleRequiredReason* reason = nullptr) const;
#else #else
bool requires_uniform_scale() const; bool requires_uniform_scale() const;
#endif // ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES #endif // ENABLE_WORLD_COORDINATE
// Returns the the object id if the selection is from a single object, otherwise is -1 // Returns the the object id if the selection is from a single object, otherwise is -1
int get_object_idx() const; int get_object_idx() const;
@ -346,11 +346,11 @@ public:
void stop_dragging() { m_dragging = false; } void stop_dragging() { m_dragging = false; }
bool is_dragging() const { return m_dragging; } bool is_dragging() const { return m_dragging; }
#if ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES #if ENABLE_WORLD_COORDINATE
void translate(const Vec3d& displacement, ECoordinatesType type = ECoordinatesType::World); void translate(const Vec3d& displacement, ECoordinatesType type = ECoordinatesType::World);
#else #else
void translate(const Vec3d& displacement, bool local = false); void translate(const Vec3d& displacement, bool local = false);
#endif // ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES #endif // ENABLE_WORLD_COORDINATE
void rotate(const Vec3d& rotation, TransformationType transformation_type); void rotate(const Vec3d& rotation, TransformationType transformation_type);
void flattening_rotate(const Vec3d& normal); void flattening_rotate(const Vec3d& normal);
void scale(const Vec3d& scale, TransformationType transformation_type); void scale(const Vec3d& scale, TransformationType transformation_type);