Skip to content

Commit

Permalink
fix ordering objects by min y
Browse files Browse the repository at this point in the history
  • Loading branch information
supermerill committed Feb 28, 2024
1 parent 477378a commit d39f80e
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions src/libslic3r/GCode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1248,16 +1248,18 @@ static inline std::vector<const PrintInstance*> sort_object_instances_by_max_y(c
instances.emplace_back(&object->instances()[i]);
// Calculate the convex hull of a printable object.
Polygon poly = object->model_object()->convex_hull_2d(
Geometry::assemble_transform(Vec3d::Zero(),
object->instances()[i].model_instance->get_rotation(),
object->instances()[i].model_instance->get_scaling_factor(),
object->instances()[i].model_instance->get_mirror()));
poly.translate(object->instances()[i].shift - object->center_offset());
coord_t min_y = poly.first_point().y();
for (const Point& point : poly.points)
if (point.y() < min_y)
min_y = point.y();
map_min_y[instances.back()] = min_y;
object->trafo()
// already in object->trafo()
//* Geometry::assemble_transform(Vec3d::Zero(),
// object->instances()[i].model_instance->get_rotation(),
// object->instances()[i].model_instance->get_scaling_factor(),
// object->instances()[i].model_instance->get_mirror())
);
BoundingBox bb(poly.points);
Vec2crd offset = object->instances()[i].shift - object->center_offset();
bb.translate(offset.x(), offset.y());
std::cout<<"bbobj (mod*inst) "<<i<<" : x:"<<unscaled(bb.min.x())<<"->"<<unscaled(bb.max.x())<<" ; y:"<<unscaled(bb.min.y())<<"->"<<unscaled(bb.max.y())<<"\n";
map_min_y[instances.back()] = bb.min.y();
}
}
std::sort(instances.begin(), instances.end(), [&map_min_y](const PrintInstance* po1, const PrintInstance* po2) { return map_min_y[po1] < map_min_y[po2]; });
Expand Down

0 comments on commit d39f80e

Please sign in to comment.