Added member m_sla_shift_z to GLVolume
This commit is contained in:
parent
233c1593f1
commit
3b3eab2e84
@ -216,6 +216,7 @@ GLVolume::GLVolume(float r, float g, float b, float a)
|
||||
, m_world_matrix_dirty(true)
|
||||
, m_transformed_bounding_box_dirty(true)
|
||||
#endif // ENABLE_MODELVOLUME_TRANSFORM
|
||||
, m_sla_shift_z(0.0)
|
||||
, m_transformed_convex_hull_bounding_box_dirty(true)
|
||||
, m_convex_hull(nullptr)
|
||||
, m_convex_hull_owned(false)
|
||||
@ -380,7 +381,14 @@ void GLVolume::set_convex_hull(const TriangleMesh *convex_hull, bool owned)
|
||||
m_convex_hull_owned = owned;
|
||||
}
|
||||
|
||||
#if !ENABLE_MODELVOLUME_TRANSFORM
|
||||
#if ENABLE_MODELVOLUME_TRANSFORM
|
||||
Transform3d GLVolume::world_matrix() const
|
||||
{
|
||||
Transform3d m = m_instance_transformation.get_matrix() * m_volume_transformation.get_matrix();
|
||||
m.translation()(2) += m_sla_shift_z;
|
||||
return m;
|
||||
}
|
||||
#else
|
||||
const Transform3f& GLVolume::world_matrix() const
|
||||
{
|
||||
if (m_world_matrix_dirty)
|
||||
@ -390,7 +398,7 @@ const Transform3f& GLVolume::world_matrix() const
|
||||
}
|
||||
return m_world_matrix;
|
||||
}
|
||||
#endif // !ENABLE_MODELVOLUME_TRANSFORM
|
||||
#endif // ENABLE_MODELVOLUME_TRANSFORM
|
||||
|
||||
const BoundingBoxf3& GLVolume::transformed_bounding_box() const
|
||||
{
|
||||
|
@ -278,6 +278,8 @@ private:
|
||||
// Whether or not is needed to recalculate the world matrix.
|
||||
mutable bool m_world_matrix_dirty;
|
||||
#endif // ENABLE_MODELVOLUME_TRANSFORM
|
||||
// Shift in z required by sla supports+pad
|
||||
double m_sla_shift_z;
|
||||
// Bounding box of this volume, in unscaled coordinates.
|
||||
mutable BoundingBoxf3 m_transformed_bounding_box;
|
||||
// Whether or not is needed to recalculate the transformed bounding box.
|
||||
@ -427,6 +429,9 @@ public:
|
||||
void set_offset(const Vec3d& offset);
|
||||
#endif // ENABLE_MODELVOLUME_TRANSFORM
|
||||
|
||||
double get_sla_shift_z() const { return m_sla_shift_z; }
|
||||
void set_sla_shift_z(double z) { m_sla_shift_z = z; }
|
||||
|
||||
void set_convex_hull(const TriangleMesh *convex_hull, bool owned);
|
||||
|
||||
int object_idx() const { return this->composite_id.object_id; }
|
||||
@ -434,7 +439,7 @@ public:
|
||||
int instance_idx() const { return this->composite_id.instance_id; }
|
||||
|
||||
#if ENABLE_MODELVOLUME_TRANSFORM
|
||||
Transform3d world_matrix() const { return m_instance_transformation.get_matrix() * m_volume_transformation.get_matrix(); }
|
||||
Transform3d world_matrix() const;
|
||||
#else
|
||||
const Transform3f& world_matrix() const;
|
||||
#endif // ENABLE_MODELVOLUME_TRANSFORM
|
||||
|
@ -3937,6 +3937,7 @@ void GLCanvas3D::reload_scene(bool refresh_immediately, bool force_full_scene_re
|
||||
delete volume;
|
||||
} else {
|
||||
// This GLVolume will be reused.
|
||||
volume->set_sla_shift_z(0.0);
|
||||
map_glvolume_old_to_new[volume_id] = glvolumes_new.size();
|
||||
mvs->volume_idx = glvolumes_new.size();
|
||||
glvolumes_new.emplace_back(volume);
|
||||
@ -4045,7 +4046,7 @@ void GLCanvas3D::reload_scene(bool refresh_immediately, bool force_full_scene_re
|
||||
instances[istep].emplace_back(std::pair<size_t, size_t>(instance_idx, print_instance_idx));
|
||||
else
|
||||
// Recycling an old GLVolume. Update the Object/Instance indices into the current Model.
|
||||
m_volumes.volumes[it->volume_idx]->composite_id = GLVolume::CompositeID(object_idx, -1, instance_idx);
|
||||
m_volumes.volumes[it->volume_idx]->composite_id = GLVolume::CompositeID(object_idx, m_volumes.volumes[it->volume_idx]->volume_idx(), instance_idx);
|
||||
}
|
||||
}
|
||||
|
||||
@ -4060,11 +4061,11 @@ void GLCanvas3D::reload_scene(bool refresh_immediately, bool force_full_scene_re
|
||||
{
|
||||
// If any volume has been added
|
||||
// Shift-up all volumes of the object so that it has the right elevation with respect to the print bed
|
||||
Vec3d shift_z(0.0, 0.0, print_object->get_elevation());
|
||||
double shift_z = print_object->get_elevation();
|
||||
for (GLVolume* volume : m_volumes.volumes)
|
||||
{
|
||||
if (volume->object_idx() == object_idx)
|
||||
volume->set_instance_offset(volume->get_instance_offset() + shift_z);
|
||||
volume->set_sla_shift_z(shift_z);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user