mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-08 15:37:27 -06:00
Simplify code flow a bit
Use if branches for the unhappy flow, so that it's clear that this behaves as an early-out. This also prevents the need for declaring variables out of scope, which is not an issue with Python anyway.
This commit is contained in:
parent
564a97d5a8
commit
2c45efb70d
1 changed files with 33 additions and 34 deletions
|
@ -160,10 +160,10 @@ class ConvexHullDecorator(SceneNodeDecorator):
|
||||||
return offset_hull
|
return offset_hull
|
||||||
|
|
||||||
else:
|
else:
|
||||||
|
if not self._node.getMeshData(): #Node has no mesh data, so just return an empty Polygon.
|
||||||
|
return Polygon([])
|
||||||
|
|
||||||
offset_hull = None
|
offset_hull = None
|
||||||
mesh = None
|
|
||||||
world_transform = None
|
|
||||||
if self._node.getMeshData():
|
|
||||||
mesh = self._node.getMeshData()
|
mesh = self._node.getMeshData()
|
||||||
world_transform = self._node.getWorldTransformation()
|
world_transform = self._node.getWorldTransformation()
|
||||||
|
|
||||||
|
@ -177,7 +177,8 @@ class ConvexHullDecorator(SceneNodeDecorator):
|
||||||
# Do not throw away vertices: the convex hull may be too small and objects can collide.
|
# Do not throw away vertices: the convex hull may be too small and objects can collide.
|
||||||
# vertex_data = vertex_data[vertex_data[:,1] >= -0.01]
|
# vertex_data = vertex_data[vertex_data[:,1] >= -0.01]
|
||||||
|
|
||||||
if vertex_data and len(vertex_data) >= 4:
|
if not vertex_data or len(vertex_data) < 4:
|
||||||
|
return Polygon([])
|
||||||
# Round the vertex data to 1/10th of a mm, then remove all duplicate vertices
|
# Round the vertex data to 1/10th of a mm, then remove all duplicate vertices
|
||||||
# This is done to greatly speed up further convex hull calculations as the convex hull
|
# This is done to greatly speed up further convex hull calculations as the convex hull
|
||||||
# becomes much less complex when dealing with highly detailed models.
|
# becomes much less complex when dealing with highly detailed models.
|
||||||
|
@ -200,8 +201,6 @@ class ConvexHullDecorator(SceneNodeDecorator):
|
||||||
if len(vertex_data) >= 3:
|
if len(vertex_data) >= 3:
|
||||||
convex_hull = hull.getConvexHull()
|
convex_hull = hull.getConvexHull()
|
||||||
offset_hull = self._offsetHull(convex_hull)
|
offset_hull = self._offsetHull(convex_hull)
|
||||||
else:
|
|
||||||
return Polygon([]) # Node has no mesh data, so just return an empty Polygon.
|
|
||||||
|
|
||||||
# Store the result in the cache
|
# Store the result in the cache
|
||||||
self._2d_convex_hull_mesh = mesh
|
self._2d_convex_hull_mesh = mesh
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue