mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-15 02:37:51 -06:00
Lay flat gizmo should work correctly with multiple instances and modifier meshes
This commit is contained in:
parent
d28d4823e0
commit
9f2fdfabb9
1 changed files with 17 additions and 14 deletions
|
@ -1312,16 +1312,18 @@ void GLGizmoFlatten::on_render(const GLCanvas3D::Selection& selection) const
|
||||||
if (dragged_offset.norm() > 0.001)
|
if (dragged_offset.norm() > 0.001)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
::glEnable(GL_BLEND);
|
|
||||||
|
#if ENABLE_GIZMOS_ON_TOP
|
||||||
|
::glClear(GL_DEPTH_BUFFER_BIT);
|
||||||
|
#endif // ENABLE_GIZMOS_ON_TOP
|
||||||
::glEnable(GL_DEPTH_TEST);
|
::glEnable(GL_DEPTH_TEST);
|
||||||
::glDisable(GL_CULL_FACE);
|
::glEnable(GL_BLEND);
|
||||||
|
|
||||||
if (selection.is_from_single_object()) {
|
if (selection.is_from_single_object()) {
|
||||||
const std::set<int>& instances_list = selection.get_instance_idxs();
|
if (m_model_object) {
|
||||||
|
//for (const int instance_idx : instances_list) {
|
||||||
if (!instances_list.empty() && m_model_object) {
|
for (const ModelInstance* inst : m_model_object->instances) {
|
||||||
for (const int instance_idx : instances_list) {
|
Transform3d m = inst->get_matrix();
|
||||||
Transform3d m = m_model_object->instances[instance_idx]->get_matrix();
|
|
||||||
for (int i=0; i<(int)m_planes.size(); ++i) {
|
for (int i=0; i<(int)m_planes.size(); ++i) {
|
||||||
if (i == m_hover_id)
|
if (i == m_hover_id)
|
||||||
::glColor4f(0.9f, 0.9f, 0.9f, 0.75f);
|
::glColor4f(0.9f, 0.9f, 0.9f, 0.75f);
|
||||||
|
@ -1347,16 +1349,16 @@ void GLGizmoFlatten::on_render(const GLCanvas3D::Selection& selection) const
|
||||||
|
|
||||||
void GLGizmoFlatten::on_render_for_picking(const GLCanvas3D::Selection& selection) const
|
void GLGizmoFlatten::on_render_for_picking(const GLCanvas3D::Selection& selection) const
|
||||||
{
|
{
|
||||||
::glEnable(GL_DEPTH_TEST);
|
::glDisable(GL_DEPTH_TEST);
|
||||||
::glDisable(GL_CULL_FACE);
|
::glDisable(GL_BLEND);
|
||||||
|
|
||||||
if (selection.is_from_single_object()) {
|
if (selection.is_from_single_object()) {
|
||||||
const std::set<int>& instances_list = selection.get_instance_idxs();
|
if (m_model_object)
|
||||||
if (!instances_list.empty() && m_model_object) {
|
for (const ModelInstance* inst : m_model_object->instances) {
|
||||||
for (const int instance_idx : instances_list) {
|
|
||||||
for (int i=0; i<(int)m_planes.size(); ++i) {
|
for (int i=0; i<(int)m_planes.size(); ++i) {
|
||||||
::glColor3f(1.0f, 1.0f, picking_color_component(i));
|
::glColor3f(1.0f, 1.0f, picking_color_component(i));
|
||||||
::glPushMatrix();
|
::glPushMatrix();
|
||||||
::glMultMatrixd(m_model_object->instances[instance_idx]->get_matrix().data());
|
::glMultMatrixd(inst->get_matrix().data());
|
||||||
::glBegin(GL_POLYGON);
|
::glBegin(GL_POLYGON);
|
||||||
for (const Vec3d& vertex : m_planes[i].vertices)
|
for (const Vec3d& vertex : m_planes[i].vertices)
|
||||||
::glVertex3dv(vertex.data());
|
::glVertex3dv(vertex.data());
|
||||||
|
@ -1364,7 +1366,6 @@ void GLGizmoFlatten::on_render_for_picking(const GLCanvas3D::Selection& selectio
|
||||||
::glPopMatrix();
|
::glPopMatrix();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
::glEnable(GL_CULL_FACE);
|
::glEnable(GL_CULL_FACE);
|
||||||
|
@ -1386,6 +1387,8 @@ void GLGizmoFlatten::update_planes()
|
||||||
for (const ModelVolume* vol : m_model_object->volumes)
|
for (const ModelVolume* vol : m_model_object->volumes)
|
||||||
#if ENABLE_MODELVOLUME_TRANSFORM
|
#if ENABLE_MODELVOLUME_TRANSFORM
|
||||||
{
|
{
|
||||||
|
if (vol->type() != ModelVolume::Type::MODEL_PART)
|
||||||
|
continue;
|
||||||
TriangleMesh vol_ch = vol->get_convex_hull();
|
TriangleMesh vol_ch = vol->get_convex_hull();
|
||||||
vol_ch.transform(vol->get_matrix());
|
vol_ch.transform(vol->get_matrix());
|
||||||
ch.merge(vol_ch);
|
ch.merge(vol_ch);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue