Browse Source

Ensure that objects outside build volume are not added to thumbnail

CURA-6545
Jaime van Kessel 5 years ago
parent
commit
07ff08f6bb
2 changed files with 30 additions and 29 deletions
  1. 24 23
      cura/PreviewPass.py
  2. 6 6
      cura/Snapshot.py

+ 24 - 23
cura/PreviewPass.py

@@ -84,29 +84,30 @@ class PreviewPass(RenderPass):
 
         # Fill up the batch with objects that can be sliced.
         for node in DepthFirstIterator(self._scene.getRoot()): #type: ignore #Ignore type error because iter() should get called automatically by Python syntax.
-            if node.callDecoration("isSliceable") and node.getMeshData() and node.isVisible():
-                per_mesh_stack = node.callDecoration("getStack")
-                if node.callDecoration("isNonThumbnailVisibleMesh"):
-                    # Non printing mesh
-                    continue
-                elif per_mesh_stack is not None and per_mesh_stack.getProperty("support_mesh", "value"):
-                    # Support mesh
-                    uniforms = {}
-                    shade_factor = 0.6
-                    diffuse_color = node.getDiffuseColor()
-                    diffuse_color2 = [
-                        diffuse_color[0] * shade_factor,
-                        diffuse_color[1] * shade_factor,
-                        diffuse_color[2] * shade_factor,
-                        1.0]
-                    uniforms["diffuse_color"] = prettier_color(diffuse_color)
-                    uniforms["diffuse_color_2"] = diffuse_color2
-                    batch_support_mesh.addItem(node.getWorldTransformation(), node.getMeshData(), uniforms = uniforms)
-                else:
-                    # Normal scene node
-                    uniforms = {}
-                    uniforms["diffuse_color"] = prettier_color(node.getDiffuseColor())
-                    batch.addItem(node.getWorldTransformation(), node.getMeshData(), uniforms = uniforms)
+            if hasattr(node, "_outside_buildarea") and not node._outside_buildarea:
+                if node.callDecoration("isSliceable") and node.getMeshData() and node.isVisible():
+                    per_mesh_stack = node.callDecoration("getStack")
+                    if node.callDecoration("isNonThumbnailVisibleMesh"):
+                        # Non printing mesh
+                        continue
+                    elif per_mesh_stack is not None and per_mesh_stack.getProperty("support_mesh", "value"):
+                        # Support mesh
+                        uniforms = {}
+                        shade_factor = 0.6
+                        diffuse_color = node.getDiffuseColor()
+                        diffuse_color2 = [
+                            diffuse_color[0] * shade_factor,
+                            diffuse_color[1] * shade_factor,
+                            diffuse_color[2] * shade_factor,
+                            1.0]
+                        uniforms["diffuse_color"] = prettier_color(diffuse_color)
+                        uniforms["diffuse_color_2"] = diffuse_color2
+                        batch_support_mesh.addItem(node.getWorldTransformation(), node.getMeshData(), uniforms = uniforms)
+                    else:
+                        # Normal scene node
+                        uniforms = {}
+                        uniforms["diffuse_color"] = prettier_color(node.getDiffuseColor())
+                        batch.addItem(node.getWorldTransformation(), node.getMeshData(), uniforms = uniforms)
 
         self.bind()
 

+ 6 - 6
cura/Snapshot.py

@@ -48,12 +48,12 @@ class Snapshot:
         # determine zoom and look at
         bbox = None
         for node in DepthFirstIterator(root):
-            if node.callDecoration("isSliceable") and node.getMeshData() and node.isVisible() and not node.callDecoration("isNonThumbnailVisibleMesh"):
-                if bbox is None:
-                    bbox = node.getBoundingBox()
-                else:
-                    bbox = bbox + node.getBoundingBox()
-
+            if hasattr(node, "_outside_buildarea") and not node._outside_buildarea:
+                if node.callDecoration("isSliceable") and node.getMeshData() and node.isVisible() and not node.callDecoration("isNonThumbnailVisibleMesh"):
+                    if bbox is None:
+                        bbox = node.getBoundingBox()
+                    else:
+                        bbox = bbox + node.getBoundingBox()
         # If there is no bounding box, it means that there is no model in the buildplate
         if bbox is None:
             return None