Changed internal coordinates of drain holes

Drain holes reference position was saved slightly above the mesh to avoid problem when the hole is placed on flat or nearly flat surface
The depth of the hole was internally bigger than what the user has set to compensato for it
However, this leads to problem with scaling and makes reprojection of the holes on the mesh complicated

This commit changes the reference point to the point on the mesh and the extra elevation is handled when rendering and drilling the hole.
The change is reflected in 3MF drain holes versioning so that old 3MFs are loaded correctly.
Reprojection on the mesh after reload from disk/fix through netfabb has been enabled.
This commit is contained in:
Lukas Matena 2020-08-19 15:24:55 +02:00
parent ba03429679
commit a95509ce36
8 changed files with 43 additions and 33 deletions

View file

@ -1103,7 +1103,7 @@ namespace Slic3r {
sla::DrainHoles sla_drain_holes;
if (version == 1) {
if (version == 1 || version == 2) {
for (unsigned int i=0; i<object_data_points.size(); i+=8)
sla_drain_holes.emplace_back(Vec3f{float(std::atof(object_data_points[i+0].c_str())),
float(std::atof(object_data_points[i+1].c_str())),
@ -1114,6 +1114,16 @@ namespace Slic3r {
float(std::atof(object_data_points[i+6].c_str())),
float(std::atof(object_data_points[i+7].c_str())));
}
if (version == 1) {
// In this version the holes were saved elevated above the mesh and deeper (bad idea indeed).
// Place the hole to the mesh and make it shallower to compensate.
// The offset was 1 mm above the mesh.
for (sla::DrainHole& hole : sla_drain_holes) {
hole.pos += hole.normal.normalized();
hole.height -= 1.f;
}
}
if (!sla_drain_holes.empty())
m_sla_drain_holes.insert(IdToSlaDrainHolesMap::value_type(object_id, sla_drain_holes));