diff --git a/src/libslic3r/Fill/FillAdaptive.cpp b/src/libslic3r/Fill/FillAdaptive.cpp index 0563b612ab..62c4a3af7b 100644 --- a/src/libslic3r/Fill/FillAdaptive.cpp +++ b/src/libslic3r/Fill/FillAdaptive.cpp @@ -142,9 +142,8 @@ void FillAdaptive::merge_polylines(Polylines &polylines, const Line &new_line) std::unique_ptr FillAdaptive::build_octree( - TriangleMesh &triangleMesh, + TriangleMesh &triangle_mesh, coordf_t line_spacing, - const BoundingBoxf3 &printer_volume, const Vec3d &cube_center) { using namespace FillAdaptive_Internal; @@ -154,10 +153,11 @@ std::unique_ptr FillAdaptive::build_octree( return nullptr; } - // The furthest point from center of bed. - double furthest_point = std::sqrt(((printer_volume.size()[0] * printer_volume.size()[0]) / 4.0) + - ((printer_volume.size()[1] * printer_volume.size()[1]) / 4.0) + - (printer_volume.size()[2] * printer_volume.size()[2])); + Vec3d bb_size = triangle_mesh.bounding_box().size(); + // The furthest point from the center of the bottom of the mesh bounding box. + double furthest_point = std::sqrt(((bb_size.x() * bb_size.x()) / 4.0) + + ((bb_size.y() * bb_size.y()) / 4.0) + + (bb_size.z() * bb_size.z())); double max_cube_edge_length = furthest_point * 2; std::vector cubes_properties; @@ -172,19 +172,20 @@ std::unique_ptr FillAdaptive::build_octree( cubes_properties.push_back(props); } - if (triangleMesh.its.vertices.empty()) + if (triangle_mesh.its.vertices.empty()) { - triangleMesh.require_shared_vertices(); + triangle_mesh.require_shared_vertices(); } Vec3d rotation = Vec3d(Geometry::deg2rad(225.0), Geometry::deg2rad(215.264), Geometry::deg2rad(30.0)); Transform3d rotation_matrix = Geometry::assemble_transform(Vec3d::Zero(), rotation, Vec3d::Ones(), Vec3d::Ones()); - AABBTreeIndirect::Tree3f aabbTree = AABBTreeIndirect::build_aabb_tree_over_indexed_triangle_set(triangleMesh.its.vertices, triangleMesh.its.indices); + AABBTreeIndirect::Tree3f aabbTree = AABBTreeIndirect::build_aabb_tree_over_indexed_triangle_set( + triangle_mesh.its.vertices, triangle_mesh.its.indices); std::unique_ptr octree = std::unique_ptr( new Octree{std::unique_ptr(new Cube{cube_center, cubes_properties.size() - 1, cubes_properties.back()}), cube_center}); - FillAdaptive::expand_cube(octree->root_cube.get(), cubes_properties, rotation_matrix, aabbTree, triangleMesh); + FillAdaptive::expand_cube(octree->root_cube.get(), cubes_properties, rotation_matrix, aabbTree, triangle_mesh); return octree; } diff --git a/src/libslic3r/Fill/FillAdaptive.hpp b/src/libslic3r/Fill/FillAdaptive.hpp index fb1f2da8e3..c7539df5a7 100644 --- a/src/libslic3r/Fill/FillAdaptive.hpp +++ b/src/libslic3r/Fill/FillAdaptive.hpp @@ -60,9 +60,8 @@ protected: public: static std::unique_ptr build_octree( - TriangleMesh &triangleMesh, + TriangleMesh &triangle_mesh, coordf_t line_spacing, - const BoundingBoxf3 &printer_volume, const Vec3d &cube_center); static void expand_cube( diff --git a/src/libslic3r/PrintObject.cpp b/src/libslic3r/PrintObject.cpp index 1699cd5ad3..1236a297fc 100644 --- a/src/libslic3r/PrintObject.cpp +++ b/src/libslic3r/PrintObject.cpp @@ -447,16 +447,11 @@ std::unique_ptr PrintObject::prepare_adaptive_inf coordf_t line_spacing = infill_extrusion_width / ((fill_density / 100.0f) * 0.333333333f); - BoundingBoxf bed_shape(this->print()->config().bed_shape.values); - BoundingBoxf3 printer_volume(Vec3d(bed_shape.min.x(), bed_shape.min.y(), 0), - Vec3d(bed_shape.max.x(), bed_shape.max.y(), this->print()->config().max_print_height)); - - Vec3d model_center = this->model_object()->bounding_box().center(); - model_center.z() = 0.0f; // Set position in Z axis to 0 // Center of the first cube in octree + Vec3d model_center = this->model_object()->bounding_box().center(); TriangleMesh mesh = this->model_object()->mesh(); - return FillAdaptive::build_octree(mesh, line_spacing, printer_volume, model_center); + return FillAdaptive::build_octree(mesh, line_spacing, model_center); } void PrintObject::clear_layers()