mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-10-22 08:11:11 -06:00
Merge branch 'scene_manipulators' of https://github.com/prusa3d/Slic3r into scene_manipulators
This commit is contained in:
commit
4579b71a66
9 changed files with 67 additions and 29 deletions
|
@ -749,7 +749,7 @@ void GLVolumeCollection::render_legacy() const
|
|||
glDisable(GL_BLEND);
|
||||
}
|
||||
|
||||
bool GLVolumeCollection::check_outside_state(const DynamicPrintConfig* config)
|
||||
bool GLVolumeCollection::check_outside_state(const DynamicPrintConfig* config, ModelInstance::EPrintVolumeState* out_state)
|
||||
{
|
||||
if (config == nullptr)
|
||||
return false;
|
||||
|
@ -763,18 +763,31 @@ bool GLVolumeCollection::check_outside_state(const DynamicPrintConfig* config)
|
|||
// Allow the objects to protrude below the print bed
|
||||
print_volume.min.z = -1e10;
|
||||
|
||||
bool contained = true;
|
||||
ModelInstance::EPrintVolumeState state = ModelInstance::PVS_Inside;
|
||||
bool all_contained = true;
|
||||
|
||||
for (GLVolume* volume : this->volumes)
|
||||
{
|
||||
if ((volume != nullptr) && !volume->is_modifier)
|
||||
{
|
||||
bool state = print_volume.contains(volume->transformed_bounding_box());
|
||||
contained &= state;
|
||||
volume->is_outside = !state;
|
||||
const BoundingBoxf3& bb = volume->transformed_bounding_box();
|
||||
bool contained = print_volume.contains(bb);
|
||||
all_contained &= contained;
|
||||
|
||||
volume->is_outside = !contained;
|
||||
|
||||
if ((state == ModelInstance::PVS_Inside) && volume->is_outside)
|
||||
state = ModelInstance::PVS_Fully_Outside;
|
||||
|
||||
if ((state == ModelInstance::PVS_Fully_Outside) && volume->is_outside && print_volume.intersects(bb))
|
||||
state = ModelInstance::PVS_Partly_Outside;
|
||||
}
|
||||
}
|
||||
|
||||
return contained;
|
||||
if (out_state != nullptr)
|
||||
*out_state = state;
|
||||
|
||||
return all_contained;
|
||||
}
|
||||
|
||||
void GLVolumeCollection::reset_outside_state()
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
#include "../../libslic3r/Line.hpp"
|
||||
#include "../../libslic3r/TriangleMesh.hpp"
|
||||
#include "../../libslic3r/Utils.hpp"
|
||||
#include "../../libslic3r/Model.hpp"
|
||||
#include "../../slic3r/GUI/GLCanvas3DManager.hpp"
|
||||
//#################################################################################################################################
|
||||
#include "../../slic3r/GUI/GLTexture.hpp"
|
||||
|
@ -434,7 +435,9 @@ public:
|
|||
print_box_max[0] = max_x; print_box_max[1] = max_y; print_box_max[2] = max_z;
|
||||
}
|
||||
|
||||
bool check_outside_state(const DynamicPrintConfig* config);
|
||||
// returns true if all the volumes are completely contained in the print volume
|
||||
// returns the containment state in the given out_state, if non-null
|
||||
bool check_outside_state(const DynamicPrintConfig* config, ModelInstance::EPrintVolumeState* out_state);
|
||||
void reset_outside_state();
|
||||
|
||||
void update_colors_by_extruder(const DynamicPrintConfig* config);
|
||||
|
|
|
@ -1381,7 +1381,8 @@ void GLCanvas3D::Gizmos::render(const GLCanvas3D& canvas, const BoundingBoxf3& b
|
|||
|
||||
::glDisable(GL_DEPTH_TEST);
|
||||
|
||||
_render_current_gizmo(box);
|
||||
if (box.radius() > 0.0)
|
||||
_render_current_gizmo(box);
|
||||
|
||||
::glPushMatrix();
|
||||
::glLoadIdentity();
|
||||
|
@ -1657,7 +1658,7 @@ void GLCanvas3D::update_volumes_selection(const std::vector<int>& selections)
|
|||
|
||||
bool GLCanvas3D::check_volumes_outside_state(const DynamicPrintConfig* config) const
|
||||
{
|
||||
return m_volumes.check_outside_state(config);
|
||||
return m_volumes.check_outside_state(config, nullptr);
|
||||
}
|
||||
|
||||
bool GLCanvas3D::move_volume_up(unsigned int id)
|
||||
|
@ -2082,19 +2083,22 @@ void GLCanvas3D::reload_scene(bool force)
|
|||
// checks for geometry outside the print volume to render it accordingly
|
||||
if (!m_volumes.empty())
|
||||
{
|
||||
bool contained = m_volumes.check_outside_state(m_config);
|
||||
ModelInstance::EPrintVolumeState state;
|
||||
bool contained = m_volumes.check_outside_state(m_config, &state);
|
||||
|
||||
if (!contained)
|
||||
{
|
||||
enable_warning_texture(true);
|
||||
_3DScene::generate_warning_texture(L("Detected object outside print volume"));
|
||||
m_on_enable_action_buttons_callback.call(state == ModelInstance::PVS_Fully_Outside);
|
||||
}
|
||||
else
|
||||
{
|
||||
enable_warning_texture(false);
|
||||
m_volumes.reset_outside_state();
|
||||
_3DScene::reset_warning_texture();
|
||||
m_on_enable_action_buttons_callback.call(!m_model->objects.empty());
|
||||
}
|
||||
m_on_enable_action_buttons_callback.call(!m_model->objects.empty());
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -3130,6 +3134,7 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt)
|
|||
m_mouse.set_start_position_3D_as_invalid();
|
||||
m_mouse.set_start_position_2D_as_invalid();
|
||||
m_mouse.dragging = false;
|
||||
m_dirty = true;
|
||||
}
|
||||
else if (evt.Moving())
|
||||
{
|
||||
|
@ -3272,7 +3277,7 @@ BoundingBoxf3 GLCanvas3D::_selected_volumes_bounding_box() const
|
|||
BoundingBoxf3 bb;
|
||||
for (const GLVolume* volume : m_volumes.volumes)
|
||||
{
|
||||
if ((volume != nullptr) && volume->selected)
|
||||
if ((volume != nullptr) && !volume->is_wipe_tower && volume->selected)
|
||||
bb.merge(volume->transformed_bounding_box());
|
||||
}
|
||||
return bb;
|
||||
|
@ -3549,7 +3554,7 @@ void GLCanvas3D::_render_objects() const
|
|||
{
|
||||
const BoundingBoxf3& bed_bb = m_bed.get_bounding_box();
|
||||
m_volumes.set_print_box((float)bed_bb.min.x, (float)bed_bb.min.y, 0.0f, (float)bed_bb.max.x, (float)bed_bb.max.y, (float)m_config->opt_float("max_print_height"));
|
||||
m_volumes.check_outside_state(m_config);
|
||||
m_volumes.check_outside_state(m_config, nullptr);
|
||||
}
|
||||
// do not cull backfaces to show broken geometry, if any
|
||||
::glDisable(GL_CULL_FACE);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue