mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-16 11:17:51 -06:00
Tech ENABLE_ALLOW_NEGATIVE_Z -> Shading of sinking instances
This commit is contained in:
parent
c8b83ae011
commit
8f385aac44
4 changed files with 67 additions and 12 deletions
|
@ -345,9 +345,16 @@ void GLVolume::set_render_color(const float* rgba, unsigned int size)
|
|||
|
||||
void GLVolume::set_render_color()
|
||||
{
|
||||
if (force_native_color || force_neutral_color)
|
||||
{
|
||||
#if ENABLE_ALLOW_NEGATIVE_Z
|
||||
bool outside = is_outside || is_below_printbed();
|
||||
#endif // ENABLE_ALLOW_NEGATIVE_Z
|
||||
|
||||
if (force_native_color || force_neutral_color) {
|
||||
#if ENABLE_ALLOW_NEGATIVE_Z
|
||||
if (outside && shader_outside_printer_detection_enabled)
|
||||
#else
|
||||
if (is_outside && shader_outside_printer_detection_enabled)
|
||||
#endif // ENABLE_ALLOW_NEGATIVE_Z
|
||||
set_render_color(OUTSIDE_COLOR, 4);
|
||||
else {
|
||||
if (force_native_color)
|
||||
|
@ -362,17 +369,24 @@ void GLVolume::set_render_color()
|
|||
else if (hover == HS_Deselect)
|
||||
set_render_color(HOVER_DESELECT_COLOR, 4);
|
||||
else if (selected)
|
||||
#if ENABLE_ALLOW_NEGATIVE_Z
|
||||
set_render_color(outside ? SELECTED_OUTSIDE_COLOR : SELECTED_COLOR, 4);
|
||||
#else
|
||||
set_render_color(is_outside ? SELECTED_OUTSIDE_COLOR : SELECTED_COLOR, 4);
|
||||
#endif // ENABLE_ALLOW_NEGATIVE_Z
|
||||
else if (disabled)
|
||||
set_render_color(DISABLED_COLOR, 4);
|
||||
#if ENABLE_ALLOW_NEGATIVE_Z
|
||||
else if (outside && shader_outside_printer_detection_enabled)
|
||||
#else
|
||||
else if (is_outside && shader_outside_printer_detection_enabled)
|
||||
#endif // ENABLE_ALLOW_NEGATIVE_Z
|
||||
set_render_color(OUTSIDE_COLOR, 4);
|
||||
else
|
||||
set_render_color(color, 4);
|
||||
}
|
||||
|
||||
if (!printable)
|
||||
{
|
||||
if (!printable) {
|
||||
render_color[0] /= 4;
|
||||
render_color[1] /= 4;
|
||||
render_color[2] /= 4;
|
||||
|
@ -504,6 +518,21 @@ void GLVolume::render() const
|
|||
bool GLVolume::is_sla_support() const { return this->composite_id.volume_id == -int(slaposSupportTree); }
|
||||
bool GLVolume::is_sla_pad() const { return this->composite_id.volume_id == -int(slaposPad); }
|
||||
|
||||
#if ENABLE_ALLOW_NEGATIVE_Z
|
||||
bool GLVolume::is_sinking() const
|
||||
{
|
||||
if (is_modifier)
|
||||
return false;
|
||||
const BoundingBoxf3& box = transformed_convex_hull_bounding_box();
|
||||
return box.min(2) < 0.0 && box.max(2) >= 0.0;
|
||||
}
|
||||
|
||||
bool GLVolume::is_below_printbed() const
|
||||
{
|
||||
return transformed_convex_hull_bounding_box().max(2) < 0.0;
|
||||
}
|
||||
#endif // ENABLE_ALLOW_NEGATIVE_Z
|
||||
|
||||
std::vector<int> GLVolumeCollection::load_object(
|
||||
const ModelObject *model_object,
|
||||
int obj_idx,
|
||||
|
@ -778,6 +807,9 @@ void GLVolumeCollection::render(GLVolumeCollection::ERenderType type, bool disab
|
|||
shader->set_uniform("print_box.volume_world_matrix", volume.first->world_matrix());
|
||||
shader->set_uniform("slope.actived", m_slope.active && !volume.first->is_modifier && !volume.first->is_wipe_tower);
|
||||
shader->set_uniform("slope.volume_world_normal_matrix", static_cast<Matrix3f>(volume.first->world_matrix().matrix().block(0, 0, 3, 3).inverse().transpose().cast<float>()));
|
||||
#if ENABLE_ALLOW_NEGATIVE_Z
|
||||
shader->set_uniform("sinking", volume.first->is_sinking());
|
||||
#endif // ENABLE_ALLOW_NEGATIVE_Z
|
||||
|
||||
volume.first->render();
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue