Tech ENABLE_SINKING_CONTOURS -> Sinking contours updated during render pass and shown also while dragging an object
This commit is contained in:
parent
d99ea7c20f
commit
0146013b4e
4 changed files with 18 additions and 45 deletions
|
@ -335,6 +335,7 @@ void GLVolume::SinkingContours::update()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
m_model.init_from(init_data);
|
m_model.init_from(init_data);
|
||||||
|
set_color(m_parent.render_color);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
m_shift = box.center() - m_old_box.center();
|
m_shift = box.center() - m_old_box.center();
|
||||||
|
@ -348,8 +349,10 @@ void GLVolume::SinkingContours::set_color(const std::array<float, 4>& color)
|
||||||
m_model.set_color(-1, { 1.0f - color[0], 1.0f - color[1], 1.0f - color[2], color[3] });
|
m_model.set_color(-1, { 1.0f - color[0], 1.0f - color[1], 1.0f - color[2], color[3] });
|
||||||
}
|
}
|
||||||
|
|
||||||
void GLVolume::SinkingContours::render() const
|
void GLVolume::SinkingContours::render()
|
||||||
{
|
{
|
||||||
|
update();
|
||||||
|
|
||||||
glsafe(::glPushMatrix());
|
glsafe(::glPushMatrix());
|
||||||
glsafe(::glTranslated(m_shift.x(), m_shift.y(), m_shift.z()));
|
glsafe(::glTranslated(m_shift.x(), m_shift.y(), m_shift.z()));
|
||||||
m_model.render();
|
m_model.render();
|
||||||
|
@ -597,18 +600,9 @@ bool GLVolume::is_below_printbed() const
|
||||||
}
|
}
|
||||||
|
|
||||||
#if ENABLE_SINKING_CONTOURS
|
#if ENABLE_SINKING_CONTOURS
|
||||||
void GLVolume::update_sinking_contours()
|
|
||||||
{
|
|
||||||
m_sinking_contours.update();
|
|
||||||
}
|
|
||||||
|
|
||||||
void GLVolume::update_sinking_contours_color()
|
|
||||||
{
|
|
||||||
m_sinking_contours.set_color(render_color);
|
|
||||||
}
|
|
||||||
|
|
||||||
void GLVolume::render_sinking_contours()
|
void GLVolume::render_sinking_contours()
|
||||||
{
|
{
|
||||||
|
m_sinking_contours.set_color(render_color);
|
||||||
m_sinking_contours.render();
|
m_sinking_contours.render();
|
||||||
}
|
}
|
||||||
#endif // ENABLE_SINKING_CONTOURS
|
#endif // ENABLE_SINKING_CONTOURS
|
||||||
|
@ -857,7 +851,6 @@ void GLVolumeCollection::render(GLVolumeCollection::ERenderType type, bool disab
|
||||||
if (volume.first->is_sinking() && !volume.first->is_below_printbed() &&
|
if (volume.first->is_sinking() && !volume.first->is_below_printbed() &&
|
||||||
volume.first->hover == GLVolume::HS_None && !volume.first->force_sinking_contours) {
|
volume.first->hover == GLVolume::HS_None && !volume.first->force_sinking_contours) {
|
||||||
shader->stop_using();
|
shader->stop_using();
|
||||||
volume.first->update_sinking_contours_color();
|
|
||||||
volume.first->render_sinking_contours();
|
volume.first->render_sinking_contours();
|
||||||
shader->start_using();
|
shader->start_using();
|
||||||
}
|
}
|
||||||
|
@ -905,7 +898,6 @@ void GLVolumeCollection::render(GLVolumeCollection::ERenderType type, bool disab
|
||||||
(volume.first->hover != GLVolume::HS_None || volume.first->force_sinking_contours)) {
|
(volume.first->hover != GLVolume::HS_None || volume.first->force_sinking_contours)) {
|
||||||
shader->stop_using();
|
shader->stop_using();
|
||||||
glsafe(::glDepthFunc(GL_ALWAYS));
|
glsafe(::glDepthFunc(GL_ALWAYS));
|
||||||
volume.first->update_sinking_contours_color();
|
|
||||||
volume.first->render_sinking_contours();
|
volume.first->render_sinking_contours();
|
||||||
glsafe(::glDepthFunc(GL_LESS));
|
glsafe(::glDepthFunc(GL_LESS));
|
||||||
shader->start_using();
|
shader->start_using();
|
||||||
|
|
|
@ -294,7 +294,7 @@ private:
|
||||||
SinkingContours(GLVolume& volume) : m_parent(volume) {}
|
SinkingContours(GLVolume& volume) : m_parent(volume) {}
|
||||||
void update();
|
void update();
|
||||||
void set_color(const std::array<float, 4>& color);
|
void set_color(const std::array<float, 4>& color);
|
||||||
void render() const;
|
void render();
|
||||||
};
|
};
|
||||||
|
|
||||||
SinkingContours m_sinking_contours;
|
SinkingContours m_sinking_contours;
|
||||||
|
@ -492,8 +492,6 @@ public:
|
||||||
bool is_sinking() const;
|
bool is_sinking() const;
|
||||||
bool is_below_printbed() const;
|
bool is_below_printbed() const;
|
||||||
#if ENABLE_SINKING_CONTOURS
|
#if ENABLE_SINKING_CONTOURS
|
||||||
void update_sinking_contours();
|
|
||||||
void update_sinking_contours_color();
|
|
||||||
void render_sinking_contours();
|
void render_sinking_contours();
|
||||||
#endif // ENABLE_SINKING_CONTOURS
|
#endif // ENABLE_SINKING_CONTOURS
|
||||||
|
|
||||||
|
|
|
@ -2054,12 +2054,6 @@ void GLCanvas3D::reload_scene(bool refresh_immediately, bool force_full_scene_re
|
||||||
m_gizmos.update_data();
|
m_gizmos.update_data();
|
||||||
m_gizmos.refresh_on_off_state();
|
m_gizmos.refresh_on_off_state();
|
||||||
|
|
||||||
#if ENABLE_SINKING_CONTOURS
|
|
||||||
for (GLVolume* v : m_volumes.volumes) {
|
|
||||||
v->update_sinking_contours();
|
|
||||||
}
|
|
||||||
#endif // ENABLE_SINKING_CONTOURS
|
|
||||||
|
|
||||||
// Update the toolbar
|
// Update the toolbar
|
||||||
if (update_object_list)
|
if (update_object_list)
|
||||||
post_event(SimpleEvent(EVT_GLCANVAS_OBJECT_SELECT));
|
post_event(SimpleEvent(EVT_GLCANVAS_OBJECT_SELECT));
|
||||||
|
@ -2968,6 +2962,14 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt)
|
||||||
for (GLVolume* volume : m_volumes.volumes) {
|
for (GLVolume* volume : m_volumes.volumes) {
|
||||||
volume->force_sinking_contours = false;
|
volume->force_sinking_contours = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
auto show_sinking_contours = [this]() {
|
||||||
|
const Selection::IndicesList& idxs = m_selection.get_volume_idxs();
|
||||||
|
for (unsigned int idx : idxs) {
|
||||||
|
m_volumes.volumes[idx]->force_sinking_contours = true;
|
||||||
|
}
|
||||||
|
m_dirty = true;
|
||||||
|
};
|
||||||
#endif // ENABLE_SINKING_CONTOURS
|
#endif // ENABLE_SINKING_CONTOURS
|
||||||
|
|
||||||
if (m_gizmos.on_mouse(evt)) {
|
if (m_gizmos.on_mouse(evt)) {
|
||||||
|
@ -3002,11 +3004,7 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt)
|
||||||
case GLGizmosManager::EType::Scale:
|
case GLGizmosManager::EType::Scale:
|
||||||
case GLGizmosManager::EType::Rotate:
|
case GLGizmosManager::EType::Rotate:
|
||||||
{
|
{
|
||||||
const Selection::IndicesList& idxs = m_selection.get_volume_idxs();
|
show_sinking_contours();
|
||||||
for (unsigned int idx : idxs) {
|
|
||||||
m_volumes.volumes[idx]->force_sinking_contours = true;
|
|
||||||
}
|
|
||||||
m_dirty = true;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default: { break; }
|
default: { break; }
|
||||||
|
@ -3137,6 +3135,9 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt)
|
||||||
m_selection.start_dragging();
|
m_selection.start_dragging();
|
||||||
m_mouse.drag.start_position_3D = m_mouse.scene_position;
|
m_mouse.drag.start_position_3D = m_mouse.scene_position;
|
||||||
m_sequential_print_clearance_first_displacement = true;
|
m_sequential_print_clearance_first_displacement = true;
|
||||||
|
#if ENABLE_SINKING_CONTOURS
|
||||||
|
show_sinking_contours();
|
||||||
|
#endif // ENABLE_SINKING_CONTOURS
|
||||||
m_moving = true;
|
m_moving = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -674,9 +674,6 @@ void Selection::translate(const Vec3d& displacement, bool local)
|
||||||
translation_type = Volume;
|
translation_type = Volume;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#if ENABLE_SINKING_CONTOURS
|
|
||||||
v.update_sinking_contours();
|
|
||||||
#endif // ENABLE_SINKING_CONTOURS
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#if !DISABLE_INSTANCES_SYNCH
|
#if !DISABLE_INSTANCES_SYNCH
|
||||||
|
@ -711,9 +708,6 @@ void Selection::rotate(const Vec3d& rotation, TransformationType transformation_
|
||||||
v.set_volume_rotation(m_cache.volumes_data[i].get_volume_rotation());
|
v.set_volume_rotation(m_cache.volumes_data[i].get_volume_rotation());
|
||||||
v.set_volume_offset(m_cache.volumes_data[i].get_volume_position());
|
v.set_volume_offset(m_cache.volumes_data[i].get_volume_position());
|
||||||
}
|
}
|
||||||
#if ENABLE_SINKING_CONTOURS
|
|
||||||
v.update_sinking_contours();
|
|
||||||
#endif // ENABLE_SINKING_CONTOURS
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else { // this is not the wipe tower
|
else { // this is not the wipe tower
|
||||||
|
@ -781,9 +775,6 @@ void Selection::rotate(const Vec3d& rotation, TransformationType transformation_
|
||||||
v.set_volume_rotation(new_rotation);
|
v.set_volume_rotation(new_rotation);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#if ENABLE_SINKING_CONTOURS
|
|
||||||
v.update_sinking_contours();
|
|
||||||
#endif // ENABLE_SINKING_CONTOURS
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -828,9 +819,6 @@ void Selection::flattening_rotate(const Vec3d& normal)
|
||||||
// Additional rotation to align tnormal with the down vector in the world coordinate space.
|
// Additional rotation to align tnormal with the down vector in the world coordinate space.
|
||||||
auto extra_rotation = Eigen::Quaterniond().setFromTwoVectors(tnormal, - Vec3d::UnitZ());
|
auto extra_rotation = Eigen::Quaterniond().setFromTwoVectors(tnormal, - Vec3d::UnitZ());
|
||||||
v.set_instance_rotation(Geometry::extract_euler_angles(extra_rotation.toRotationMatrix() * m_cache.volumes_data[i].get_instance_rotation_matrix()));
|
v.set_instance_rotation(Geometry::extract_euler_angles(extra_rotation.toRotationMatrix() * m_cache.volumes_data[i].get_instance_rotation_matrix()));
|
||||||
#if ENABLE_SINKING_CONTOURS
|
|
||||||
v.update_sinking_contours();
|
|
||||||
#endif // ENABLE_SINKING_CONTOURS
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#if !DISABLE_INSTANCES_SYNCH
|
#if !DISABLE_INSTANCES_SYNCH
|
||||||
|
@ -901,9 +889,6 @@ void Selection::scale(const Vec3d& scale, TransformationType transformation_type
|
||||||
v.set_volume_scaling_factor(new_scale);
|
v.set_volume_scaling_factor(new_scale);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#if ENABLE_SINKING_CONTOURS
|
|
||||||
v.update_sinking_contours();
|
|
||||||
#endif // ENABLE_SINKING_CONTOURS
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#if !DISABLE_INSTANCES_SYNCH
|
#if !DISABLE_INSTANCES_SYNCH
|
||||||
|
@ -975,9 +960,6 @@ void Selection::mirror(Axis axis)
|
||||||
v.set_instance_mirror(axis, -(*m_volumes)[i]->get_instance_mirror(axis));
|
v.set_instance_mirror(axis, -(*m_volumes)[i]->get_instance_mirror(axis));
|
||||||
else if (m_mode == Volume)
|
else if (m_mode == Volume)
|
||||||
v.set_volume_mirror(axis, -(*m_volumes)[i]->get_volume_mirror(axis));
|
v.set_volume_mirror(axis, -(*m_volumes)[i]->get_volume_mirror(axis));
|
||||||
#if ENABLE_SINKING_CONTOURS
|
|
||||||
v.update_sinking_contours();
|
|
||||||
#endif // ENABLE_SINKING_CONTOURS
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#if !DISABLE_INSTANCES_SYNCH
|
#if !DISABLE_INSTANCES_SYNCH
|
||||||
|
|
Loading…
Reference in a new issue