Fixed volume transformations in SLA:

Volume transformations were ignored in SLA mode. This did not matter for plain STLs
and PS own 3MF, because in those cases, the volume trafo was identity. Importing
a 3rd party 3MF leads to issues with support/holes placement and generation.
Fixes #6100 and #6744.
This commit is contained in:
Lukas Matena 2021-09-24 09:58:17 +02:00
parent fec5d92bc8
commit 6b25a9c836
4 changed files with 68 additions and 31 deletions

View file

@ -35,11 +35,24 @@ inline void reproject_points_and_holes(ModelObject *object)
TriangleMesh rmsh = object->raw_mesh();
IndexedMesh emesh{rmsh};
if (has_sppoints)
reproject_support_points(emesh, object->sla_support_points);
const Transform3f& tr = object->volumes.front()->get_matrix().cast<float>();
if (has_holes)
reproject_support_points(emesh, object->sla_drain_holes);
if (has_sppoints) {
SupportPoints transformed_points = object->sla_support_points;
for (SupportPoint& pt : transformed_points)
pt.pos = tr * pt.pos;
reproject_support_points(emesh, transformed_points);
}
if (has_holes) {
DrainHoles transformed_holes = object->sla_drain_holes;
for (DrainHole& hole : transformed_holes) {
// Hole normals are not transformed here, but the reprojection
// does not use them.
hole.pos = tr * hole.pos;
}
reproject_support_points(emesh, transformed_holes);
}
}
}}

View file

@ -1167,7 +1167,9 @@ sla::SupportPoints SLAPrintObject::transformed_support_points() const
{
assert(m_model_object != nullptr);
auto spts = m_model_object->sla_support_points;
auto tr = trafo().cast<float>();
auto tr = (trafo() * m_model_object->volumes.front()->get_transformation().get_matrix()).cast<float>();
for (sla::SupportPoint& suppt : spts) {
suppt.pos = tr * suppt.pos;
}
@ -1179,8 +1181,8 @@ sla::DrainHoles SLAPrintObject::transformed_drainhole_points() const
{
assert(m_model_object != nullptr);
auto pts = m_model_object->sla_drain_holes;
auto tr = trafo().cast<float>();
auto sc = m_model_object->instances.front()->get_scaling_factor().cast<float>();
Transform3f tr = (trafo() * m_model_object->volumes.front()->get_matrix()).cast<float>();
Vec3f sc = Geometry::Transformation(tr.cast<double>()).get_scaling_factor().cast<float>();
for (sla::DrainHole &hl : pts) {
hl.pos = tr * hl.pos;
hl.normal = tr * hl.normal - tr.translation();