From acedb66cdc5abb6d5f9c2d575eefb9a4f834a00a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Luk=C3=A1=C5=A1=20Hejl?= <hejl.lukas@gmail.com>
Date: Thu, 3 Sep 2020 16:08:40 +0200
Subject: [PATCH] Change to using raw_mesh instead of mesh

---
 src/libslic3r/PrintObject.cpp | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/src/libslic3r/PrintObject.cpp b/src/libslic3r/PrintObject.cpp
index 1236a297f..d9c533939 100644
--- a/src/libslic3r/PrintObject.cpp
+++ b/src/libslic3r/PrintObject.cpp
@@ -447,11 +447,14 @@ std::unique_ptr<FillAdaptive_Internal::Octree> PrintObject::prepare_adaptive_inf
 
     coordf_t line_spacing = infill_extrusion_width / ((fill_density / 100.0f) * 0.333333333f);
 
-    // Center of the first cube in octree
-    Vec3d model_center = this->model_object()->bounding_box().center();
+    TriangleMesh mesh = this->model_object()->raw_mesh();
+    mesh.transform(m_trafo, true);
+    // Apply XY shift
+    mesh.translate(- unscale<float>(m_center_offset.x()), - unscale<float>(m_center_offset.y()), 0);
 
-    TriangleMesh mesh = this->model_object()->mesh();
-    return FillAdaptive::build_octree(mesh, line_spacing, model_center);
+    // Center of the first cube in octree
+    Vec3d mesh_origin = mesh.bounding_box().center();
+    return FillAdaptive::build_octree(mesh, line_spacing, mesh_origin);
 }
 
 void PrintObject::clear_layers()