From ccd9a17be40bb2917082d336d13465c32d33e773 Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Tue, 30 Jun 2020 13:22:45 +0200 Subject: [PATCH 1/2] Remove normals for ConvexHullNode They are rendered flat, so no need to store the normals CURA-7106 --- cura/Scene/ConvexHullNode.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cura/Scene/ConvexHullNode.py b/cura/Scene/ConvexHullNode.py index cb4cffca12..f8a284bebe 100644 --- a/cura/Scene/ConvexHullNode.py +++ b/cura/Scene/ConvexHullNode.py @@ -61,6 +61,7 @@ class ConvexHullNode(SceneNode): if hull_mesh_builder.addConvexPolygon( self._hull.getPoints()[::], # bottom layer is reversed self._mesh_height, color = self._color): + hull_mesh_builder.resetNormals() hull_mesh = hull_mesh_builder.build() self.setMeshData(hull_mesh) @@ -68,7 +69,7 @@ class ConvexHullNode(SceneNode): if hull_mesh_builder.addConvexPolygonExtrusion( self._hull.getPoints()[::-1], # bottom layer is reversed self._mesh_height - thickness, self._mesh_height, color = self._color): - + hull_mesh_builder.resetNormals() hull_mesh = hull_mesh_builder.build() self.setMeshData(hull_mesh) From 440474b1e84d1f68a9e20499537bd7805cf5822b Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Tue, 30 Jun 2020 13:39:32 +0200 Subject: [PATCH 2/2] Pass the cached normal transformation to the rendere CURA-7106 --- cura/PickingPass.py | 2 +- cura/XRayPass.py | 2 +- plugins/SolidView/SolidView.py | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/cura/PickingPass.py b/cura/PickingPass.py index 6ffc63cbd4..eb190be16d 100644 --- a/cura/PickingPass.py +++ b/cura/PickingPass.py @@ -54,7 +54,7 @@ class PickingPass(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(): - batch.addItem(node.getWorldTransformation(copy = False), node.getMeshData()) + batch.addItem(node.getWorldTransformation(copy = False), node.getMeshData(), normal_transformation=node.getCachedNormalMatrix()) self.bind() batch.render(self._scene.getActiveCamera()) diff --git a/cura/XRayPass.py b/cura/XRayPass.py index eb5f33cea2..965294ba89 100644 --- a/cura/XRayPass.py +++ b/cura/XRayPass.py @@ -29,7 +29,7 @@ class XRayPass(RenderPass): batch = RenderBatch(self._shader, type = RenderBatch.RenderType.NoType, backface_cull = False, blend_mode = RenderBatch.BlendMode.Additive) for node in DepthFirstIterator(self._scene.getRoot()): if isinstance(node, CuraSceneNode) and node.getMeshData() and node.isVisible(): - batch.addItem(node.getWorldTransformation(copy = False), node.getMeshData()) + batch.addItem(node.getWorldTransformation(copy = False), node.getMeshData(), normal_transformation=node.getCachedNormalMatrix()) self.bind() diff --git a/plugins/SolidView/SolidView.py b/plugins/SolidView/SolidView.py index 48bd704ccb..08085871c0 100644 --- a/plugins/SolidView/SolidView.py +++ b/plugins/SolidView/SolidView.py @@ -244,7 +244,7 @@ class SolidView(View): else: renderer.queueNode(node, shader = self._non_printing_shader, transparent = True) elif getattr(node, "_outside_buildarea", False): - disabled_batch.addItem(node.getWorldTransformation(copy = False), node.getMeshData()) + disabled_batch.addItem(node.getWorldTransformation(copy = False), node.getMeshData(), normal_transformation = node.getCachedNormalMatrix()) elif per_mesh_stack and node.callDecoration("isSupportMesh"): # Render support meshes with a vertical stripe that is darker shade_factor = 0.6 @@ -256,7 +256,7 @@ class SolidView(View): ] renderer.queueNode(node, shader = self._support_mesh_shader, uniforms = uniforms) else: - normal_object_batch.addItem(node.getWorldTransformation(copy=False), node.getMeshData(), uniforms=uniforms) + normal_object_batch.addItem(node.getWorldTransformation(copy=False), node.getMeshData(), uniforms=uniforms, normal_transformation = node.getCachedNormalMatrix()) if node.callDecoration("isGroup") and Selection.isSelected(node): renderer.queueNode(scene.getRoot(), mesh = node.getBoundingBoxMesh(), mode = RenderBatch.RenderMode.LineLoop)