Ensure that objects outside build volume are not added to thumbnail

CURA-6545
This commit is contained in:
Jaime van Kessel 2019-05-29 15:53:23 +02:00
parent f6627daa49
commit 07ff08f6bb
2 changed files with 30 additions and 29 deletions

View File

@ -84,29 +84,30 @@ class PreviewPass(RenderPass):
# Fill up the batch with objects that can be sliced. # 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. 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(): if hasattr(node, "_outside_buildarea") and not node._outside_buildarea:
per_mesh_stack = node.callDecoration("getStack") if node.callDecoration("isSliceable") and node.getMeshData() and node.isVisible():
if node.callDecoration("isNonThumbnailVisibleMesh"): per_mesh_stack = node.callDecoration("getStack")
# Non printing mesh if node.callDecoration("isNonThumbnailVisibleMesh"):
continue # Non printing mesh
elif per_mesh_stack is not None and per_mesh_stack.getProperty("support_mesh", "value"): continue
# Support mesh elif per_mesh_stack is not None and per_mesh_stack.getProperty("support_mesh", "value"):
uniforms = {} # Support mesh
shade_factor = 0.6 uniforms = {}
diffuse_color = node.getDiffuseColor() shade_factor = 0.6
diffuse_color2 = [ diffuse_color = node.getDiffuseColor()
diffuse_color[0] * shade_factor, diffuse_color2 = [
diffuse_color[1] * shade_factor, diffuse_color[0] * shade_factor,
diffuse_color[2] * shade_factor, diffuse_color[1] * shade_factor,
1.0] diffuse_color[2] * shade_factor,
uniforms["diffuse_color"] = prettier_color(diffuse_color) 1.0]
uniforms["diffuse_color_2"] = diffuse_color2 uniforms["diffuse_color"] = prettier_color(diffuse_color)
batch_support_mesh.addItem(node.getWorldTransformation(), node.getMeshData(), uniforms = uniforms) uniforms["diffuse_color_2"] = diffuse_color2
else: batch_support_mesh.addItem(node.getWorldTransformation(), node.getMeshData(), uniforms = uniforms)
# Normal scene node else:
uniforms = {} # Normal scene node
uniforms["diffuse_color"] = prettier_color(node.getDiffuseColor()) uniforms = {}
batch.addItem(node.getWorldTransformation(), node.getMeshData(), uniforms = uniforms) uniforms["diffuse_color"] = prettier_color(node.getDiffuseColor())
batch.addItem(node.getWorldTransformation(), node.getMeshData(), uniforms = uniforms)
self.bind() self.bind()

View File

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