mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-24 07:03:59 -06:00
Mirror component of transformations set as default
This commit is contained in:
parent
da37094a09
commit
00222226ed
15 changed files with 10 additions and 246 deletions
|
@ -201,9 +201,7 @@ GLVolume::GLVolume(float r, float g, float b, float a)
|
|||
: m_offset(Vec3d::Zero())
|
||||
, m_rotation(Vec3d::Zero())
|
||||
, m_scaling_factor(Vec3d::Ones())
|
||||
#if ENABLE_MIRROR
|
||||
, m_mirror(Vec3d::Ones())
|
||||
#endif // ENABLE_MIRROR
|
||||
, m_world_matrix(Transform3f::Identity())
|
||||
, m_world_matrix_dirty(true)
|
||||
, m_transformed_bounding_box_dirty(true)
|
||||
|
@ -332,7 +330,6 @@ void GLVolume::set_scaling_factor(const Vec3d& scaling_factor)
|
|||
}
|
||||
}
|
||||
|
||||
#if ENABLE_MIRROR
|
||||
const Vec3d& GLVolume::get_mirror() const
|
||||
{
|
||||
return m_mirror;
|
||||
|
@ -364,7 +361,6 @@ void GLVolume::set_mirror(Axis axis, double mirror)
|
|||
m_transformed_convex_hull_bounding_box_dirty = true;
|
||||
}
|
||||
}
|
||||
#endif // ENABLE_MIRROR
|
||||
#endif // !ENABLE_MODELVOLUME_TRANSFORM
|
||||
|
||||
void GLVolume::set_convex_hull(const TriangleMesh& convex_hull)
|
||||
|
@ -397,11 +393,7 @@ const Transform3f& GLVolume::world_matrix() const
|
|||
{
|
||||
if (m_world_matrix_dirty)
|
||||
{
|
||||
#if ENABLE_MIRROR
|
||||
m_world_matrix = Geometry::assemble_transform(m_offset, m_rotation, m_scaling_factor, m_mirror).cast<float>();
|
||||
#else
|
||||
m_world_matrix = Geometry::assemble_transform(m_offset, m_rotation, m_scaling_factor).cast<float>();
|
||||
#endif // ENABLE_MIRROR
|
||||
m_world_matrix_dirty = false;
|
||||
}
|
||||
return m_world_matrix;
|
||||
|
@ -816,9 +808,7 @@ std::vector<int> GLVolumeCollection::load_object(
|
|||
v.set_offset(instance->get_offset());
|
||||
v.set_rotation(instance->get_rotation());
|
||||
v.set_scaling_factor(instance->get_scaling_factor());
|
||||
#if ENABLE_MIRROR
|
||||
v.set_mirror(instance->get_mirror());
|
||||
#endif // ENABLE_MIRROR
|
||||
#endif // ENABLE_MODELVOLUME_TRANSFORM
|
||||
}
|
||||
}
|
||||
|
@ -2167,14 +2157,12 @@ int _3DScene::get_in_object_volume_id(wxGLCanvas* canvas, int scene_vol_idx)
|
|||
return s_canvas_mgr.get_in_object_volume_id(canvas, scene_vol_idx);
|
||||
}
|
||||
|
||||
#if ENABLE_MIRROR
|
||||
#if ENABLE_EXTENDED_SELECTION
|
||||
void _3DScene::mirror_selection(wxGLCanvas* canvas, Axis axis)
|
||||
{
|
||||
s_canvas_mgr.mirror_selection(canvas, axis);
|
||||
}
|
||||
#endif // ENABLE_EXTENDED_SELECTION
|
||||
#endif // ENABLE_MIRROR
|
||||
|
||||
void _3DScene::reload_scene(wxGLCanvas* canvas, bool force)
|
||||
{
|
||||
|
|
|
@ -263,10 +263,8 @@ private:
|
|||
Vec3d m_rotation;
|
||||
// Scale factor along the three axes of the volume to be rendered.
|
||||
Vec3d m_scaling_factor;
|
||||
#if ENABLE_MIRROR
|
||||
// Mirroring along the three axes of the volume to be rendered.
|
||||
Vec3d m_mirror;
|
||||
#endif // ENABLE_MIRROR
|
||||
// World matrix of the volume to be rendered.
|
||||
mutable Transform3f m_world_matrix;
|
||||
// Whether or not is needed to recalculate the world matrix.
|
||||
|
@ -358,13 +356,11 @@ public:
|
|||
void set_scaling_factor(const Vec3d& scaling_factor) { m_transformation.set_scaling_factor(scaling_factor); set_bounding_boxes_as_dirty(); }
|
||||
void set_scaling_factor(Axis axis, double scaling_factor) { m_transformation.set_scaling_factor(axis, scaling_factor); set_bounding_boxes_as_dirty(); }
|
||||
|
||||
#if ENABLE_MIRROR
|
||||
const Vec3d& get_mirror() const { return m_transformation.get_mirror(); }
|
||||
double get_mirror(Axis axis) const { return m_transformation.get_mirror(axis); }
|
||||
|
||||
void set_mirror(const Vec3d& mirror) { m_transformation.set_mirror(mirror); set_bounding_boxes_as_dirty(); }
|
||||
void set_mirror(Axis axis, double mirror) { m_transformation.set_mirror(axis, mirror); set_bounding_boxes_as_dirty(); }
|
||||
#endif // ENABLE_MIRROR
|
||||
#else
|
||||
const Vec3d& get_rotation() const;
|
||||
void set_rotation(const Vec3d& rotation);
|
||||
|
@ -374,12 +370,10 @@ public:
|
|||
#endif // ENABLE_EXTENDED_SELECTION
|
||||
void set_scaling_factor(const Vec3d& scaling_factor);
|
||||
|
||||
#if ENABLE_MIRROR
|
||||
const Vec3d& get_mirror() const;
|
||||
double get_mirror(Axis axis) const;
|
||||
void set_mirror(const Vec3d& mirror);
|
||||
void set_mirror(Axis axis, double mirror);
|
||||
#endif // ENABLE_MIRROR
|
||||
|
||||
const Vec3d& get_offset() const;
|
||||
void set_offset(const Vec3d& offset);
|
||||
|
@ -397,7 +391,7 @@ public:
|
|||
int instance_idx() const { return this->composite_id % 1000; }
|
||||
|
||||
#if ENABLE_MODELVOLUME_TRANSFORM
|
||||
const Transform3d& world_matrix() const { return m_transformation.world_matrix(); }
|
||||
const Transform3d& world_matrix() const { return m_transformation.get_matrix(); }
|
||||
#else
|
||||
const Transform3f& world_matrix() const;
|
||||
#endif // ENABLE_MODELVOLUME_TRANSFORM
|
||||
|
@ -634,11 +628,9 @@ public:
|
|||
static int get_first_volume_id(wxGLCanvas* canvas, int obj_idx);
|
||||
static int get_in_object_volume_id(wxGLCanvas* canvas, int scene_vol_idx);
|
||||
|
||||
#if ENABLE_MIRROR
|
||||
#if ENABLE_EXTENDED_SELECTION
|
||||
static void mirror_selection(wxGLCanvas* canvas, Axis axis);
|
||||
#endif // ENABLE_EXTENDED_SELECTION
|
||||
#endif // ENABLE_MIRROR
|
||||
|
||||
static void reload_scene(wxGLCanvas* canvas, bool force);
|
||||
|
||||
|
|
|
@ -1463,7 +1463,6 @@ void GLCanvas3D::Selection::scale(const Vec3d& scale)
|
|||
m_bounding_box_dirty = true;
|
||||
}
|
||||
|
||||
#if ENABLE_MIRROR
|
||||
void GLCanvas3D::Selection::mirror(Axis axis)
|
||||
{
|
||||
if (!m_valid)
|
||||
|
@ -1482,7 +1481,6 @@ void GLCanvas3D::Selection::mirror(Axis axis)
|
|||
|
||||
m_bounding_box_dirty = true;
|
||||
}
|
||||
#endif // ENABLE_MIRROR
|
||||
|
||||
void GLCanvas3D::Selection::translate(unsigned int object_idx, const Vec3d& displacement)
|
||||
{
|
||||
|
@ -1897,9 +1895,7 @@ void GLCanvas3D::Selection::_synchronize_unselected_instances()
|
|||
int instance_idx = volume->instance_idx();
|
||||
const Vec3d& rotation = volume->get_rotation();
|
||||
const Vec3d& scaling_factor = volume->get_scaling_factor();
|
||||
#if ENABLE_MIRROR
|
||||
const Vec3d& mirror = volume->get_mirror();
|
||||
#endif // ENABLE_MIRROR
|
||||
|
||||
// Process unselected instances.
|
||||
for (unsigned int j = 0; j < (unsigned int)m_volumes->size(); ++j)
|
||||
|
@ -1916,9 +1912,7 @@ void GLCanvas3D::Selection::_synchronize_unselected_instances()
|
|||
|
||||
v->set_rotation(rotation);
|
||||
v->set_scaling_factor(scaling_factor);
|
||||
#if ENABLE_MIRROR
|
||||
v->set_mirror(mirror);
|
||||
#endif // ENABLE_MIRROR
|
||||
|
||||
done.insert(j);
|
||||
}
|
||||
|
@ -3608,7 +3602,6 @@ int GLCanvas3D::get_in_object_volume_id(int scene_vol_idx) const
|
|||
return ((0 <= scene_vol_idx) && (scene_vol_idx < (int)m_volumes.volumes.size())) ? m_volumes.volumes[scene_vol_idx]->volume_idx() : -1;
|
||||
}
|
||||
|
||||
#if ENABLE_MIRROR
|
||||
#if ENABLE_EXTENDED_SELECTION
|
||||
void GLCanvas3D::mirror_selection(Axis axis)
|
||||
{
|
||||
|
@ -3617,7 +3610,6 @@ void GLCanvas3D::mirror_selection(Axis axis)
|
|||
wxGetApp().obj_manipul()->update_settings_value(m_selection);
|
||||
}
|
||||
#endif // ENABLE_EXTENDED_SELECTION
|
||||
#endif // ENABLE_MIRROR
|
||||
|
||||
void GLCanvas3D::reload_scene(bool force)
|
||||
{
|
||||
|
@ -6868,7 +6860,6 @@ void GLCanvas3D::_on_flatten()
|
|||
_on_rotate();
|
||||
}
|
||||
|
||||
#if ENABLE_MIRROR
|
||||
void GLCanvas3D::_on_mirror()
|
||||
{
|
||||
if (m_model == nullptr)
|
||||
|
@ -6902,7 +6893,6 @@ void GLCanvas3D::_on_mirror()
|
|||
|
||||
post_event(SimpleEvent(EVT_GLCANVAS_SCHEDULE_BACKGROUND_PROCESS));
|
||||
}
|
||||
#endif // ENABLE_MIRROR
|
||||
#else
|
||||
void GLCanvas3D::_on_move(const std::vector<int>& volume_idxs)
|
||||
{
|
||||
|
|
|
@ -504,9 +504,7 @@ public:
|
|||
void translate(const Vec3d& displacement);
|
||||
void rotate(const Vec3d& rotation);
|
||||
void scale(const Vec3d& scale);
|
||||
#if ENABLE_MIRROR
|
||||
void mirror(Axis axis);
|
||||
#endif // ENABLE_MIRROR
|
||||
|
||||
void translate(unsigned int object_idx, const Vec3d& displacement);
|
||||
void translate(unsigned int object_idx, unsigned int instance_idx, const Vec3d& displacement);
|
||||
|
@ -855,11 +853,9 @@ public:
|
|||
int get_first_volume_id(int obj_idx) const;
|
||||
int get_in_object_volume_id(int scene_vol_idx) const;
|
||||
|
||||
#if ENABLE_MIRROR
|
||||
#if ENABLE_EXTENDED_SELECTION
|
||||
void mirror_selection(Axis axis);
|
||||
#endif // ENABLE_EXTENDED_SELECTION
|
||||
#endif // ENABLE_MIRROR
|
||||
|
||||
void reload_scene(bool force);
|
||||
|
||||
|
@ -986,9 +982,7 @@ private:
|
|||
void _on_rotate();
|
||||
void _on_scale();
|
||||
void _on_flatten();
|
||||
#if ENABLE_MIRROR
|
||||
void _on_mirror();
|
||||
#endif // ENABLE_MIRROR
|
||||
#else
|
||||
void _on_move(const std::vector<int>& volume_idxs);
|
||||
#endif // ENABLE_EXTENDED_SELECTION
|
||||
|
|
|
@ -596,7 +596,6 @@ int GLCanvas3DManager::get_in_object_volume_id(wxGLCanvas* canvas, int scene_vol
|
|||
return (it != m_canvases.end()) ? it->second->get_in_object_volume_id(scene_vol_idx) : -1;
|
||||
}
|
||||
|
||||
#if ENABLE_MIRROR
|
||||
#if ENABLE_EXTENDED_SELECTION
|
||||
void GLCanvas3DManager::mirror_selection(wxGLCanvas* canvas, Axis axis)
|
||||
{
|
||||
|
@ -605,7 +604,6 @@ void GLCanvas3DManager::mirror_selection(wxGLCanvas* canvas, Axis axis)
|
|||
it->second->mirror_selection(axis);
|
||||
}
|
||||
#endif // ENABLE_EXTENDED_SELECTION
|
||||
#endif // ENABLE_MIRROR
|
||||
|
||||
void GLCanvas3DManager::reload_scene(wxGLCanvas* canvas, bool force)
|
||||
{
|
||||
|
|
|
@ -163,11 +163,9 @@ public:
|
|||
int get_first_volume_id(wxGLCanvas* canvas, int obj_idx) const;
|
||||
int get_in_object_volume_id(wxGLCanvas* canvas, int scene_vol_idx) const;
|
||||
|
||||
#if ENABLE_MIRROR
|
||||
#if ENABLE_EXTENDED_SELECTION
|
||||
void mirror_selection(wxGLCanvas* canvas, Axis axis);
|
||||
#endif // ENABLE_EXTENDED_SELECTION
|
||||
#endif // ENABLE_MIRROR
|
||||
|
||||
void reload_scene(wxGLCanvas* canvas, bool force);
|
||||
|
||||
|
|
|
@ -935,13 +935,8 @@ void GLGizmoScale3D::on_render(const BoundingBoxf3& box) const
|
|||
// gets angles from first selected volume
|
||||
angles = v->get_rotation();
|
||||
|
||||
#if ENABLE_MIRROR
|
||||
// consider rotation+mirror only components of the transform for offsets
|
||||
offsets_transform = Geometry::assemble_transform(Vec3d::Zero(), angles, Vec3d::Ones(), v->get_mirror());
|
||||
#else
|
||||
// set rotation-only component of transform
|
||||
offsets_transform = Geometry::assemble_transform(Vec3d::Zero(), angles);
|
||||
#endif // ENABLE_MIRROR
|
||||
}
|
||||
else
|
||||
box = selection.get_bounding_box();
|
||||
|
|
|
@ -932,9 +932,7 @@ private:
|
|||
bool layers_height_allowed() const;
|
||||
bool can_delete_all() const;
|
||||
bool can_arrange() const;
|
||||
#if ENABLE_MIRROR
|
||||
bool can_mirror() const;
|
||||
#endif // ENABLE_MIRROR
|
||||
#endif // ENABLE_EXTENDED_SELECTION
|
||||
};
|
||||
|
||||
|
@ -1617,38 +1615,9 @@ void Plater::priv::rotate()
|
|||
|
||||
void Plater::priv::mirror(Axis axis)
|
||||
{
|
||||
#if ENABLE_MIRROR
|
||||
#if ENABLE_EXTENDED_SELECTION
|
||||
_3DScene::mirror_selection(canvas3D, axis);
|
||||
#endif // ENABLE_EXTENDED_SELECTION
|
||||
#else
|
||||
#if ENABLE_EXTENDED_SELECTION
|
||||
int obj_idx = get_selected_object_idx();
|
||||
if (obj_idx == -1)
|
||||
return;
|
||||
|
||||
ModelObject* model_object = model.objects[obj_idx];
|
||||
ModelInstance* model_instance = model_object->instances.front();
|
||||
#else
|
||||
const auto obj_idx = selected_object();
|
||||
if (! obj_idx) { return; }
|
||||
|
||||
auto *model_object = model.objects[*obj_idx];
|
||||
auto *model_instance = model_object->instances[0];
|
||||
#endif // ENABLE_EXTENDED_SELECTION
|
||||
|
||||
// XXX: ?
|
||||
// # apply Z rotation before mirroring
|
||||
// if ($model_instance->rotation != 0) {
|
||||
// $model_object->rotate($model_instance->rotation, Slic3r::Pointf3->new(0, 0, 1));
|
||||
// $_->set_rotation(0) for @{ $model_object->instances };
|
||||
// }
|
||||
|
||||
model_object->mirror(axis);
|
||||
|
||||
selection_changed();
|
||||
update();
|
||||
#endif // ENABLE_MIRROR
|
||||
}
|
||||
|
||||
#if !ENABLE_EXTENDED_SELECTION
|
||||
|
@ -2109,7 +2078,6 @@ bool Plater::priv::init_object_menu()
|
|||
|
||||
object_menu.AppendSeparator();
|
||||
|
||||
#if ENABLE_MIRROR
|
||||
wxMenu* mirror_menu = new wxMenu();
|
||||
if (mirror_menu == nullptr)
|
||||
return false;
|
||||
|
@ -2122,7 +2090,6 @@ bool Plater::priv::init_object_menu()
|
|||
[this](wxCommandEvent&) { mirror(Z); }, "bullet_blue.png", &object_menu);
|
||||
|
||||
wxMenuItem* item_mirror = append_submenu(&object_menu, mirror_menu, wxID_ANY, _(L("Mirror")), _(L("Mirror the selected object")));
|
||||
#endif // ENABLE_MIRROR
|
||||
|
||||
wxMenu* split_menu = new wxMenu();
|
||||
if (split_menu == nullptr)
|
||||
|
@ -2139,9 +2106,7 @@ bool Plater::priv::init_object_menu()
|
|||
// ui updates needs to be binded to the parent panel
|
||||
if (q != nullptr)
|
||||
{
|
||||
#if ENABLE_MIRROR
|
||||
q->Bind(wxEVT_UPDATE_UI, [this](wxUpdateUIEvent& evt) { evt.Enable(can_mirror()); }, item_mirror->GetId());
|
||||
#endif // ENABLE_MIRROR
|
||||
q->Bind(wxEVT_UPDATE_UI, [this](wxUpdateUIEvent& evt) { evt.Enable(can_delete_object()); }, item_delete->GetId());
|
||||
q->Bind(wxEVT_UPDATE_UI, [this](wxUpdateUIEvent& evt) { evt.Enable(can_increase_instances()); }, item_increase->GetId());
|
||||
q->Bind(wxEVT_UPDATE_UI, [this](wxUpdateUIEvent& evt) { evt.Enable(can_decrease_instances()); }, item_decrease->GetId());
|
||||
|
@ -2208,12 +2173,10 @@ bool Plater::priv::can_arrange() const
|
|||
return !model.objects.empty();
|
||||
}
|
||||
|
||||
#if ENABLE_MIRROR
|
||||
bool Plater::priv::can_mirror() const
|
||||
{
|
||||
return get_selection().is_from_single_instance();
|
||||
}
|
||||
#endif // ENABLE_MIRROR
|
||||
#endif // ENABLE_EXTENDED_SELECTION
|
||||
|
||||
// Plater / Public
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue