Fixed incorrect hole normal transformation when the object is anisotropically scaled

This commit is contained in:
Lukas Matena 2020-01-23 12:14:43 +01:00
parent 022cc0871a
commit d58ee47e4d

View file

@ -1182,11 +1182,18 @@ 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>();
for (sla::DrainHole &hl : pts) {
hl.pos = tr * hl.pos;
hl.normal = tr * hl.normal - tr.translation();
// The normal scales as a covector (and we must also
// undo the damage already done).
hl.normal = Vec3f(hl.normal(0)/(sc(0)*sc(0)),
hl.normal(1)/(sc(1)*sc(1)),
hl.normal(2)/(sc(2)*sc(2)));
}
return pts;
}