mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-19 12:47:49 -06:00
Better handling of degenerate convex hull cases.
Contributes to CURA-1504
This commit is contained in:
parent
7e3dd3d443
commit
5f638f6e69
2 changed files with 42 additions and 38 deletions
|
@ -130,8 +130,8 @@ class ConvexHullDecorator(SceneNodeDecorator):
|
||||||
return rounded_hull
|
return rounded_hull
|
||||||
|
|
||||||
else:
|
else:
|
||||||
if not self._node.getMeshData():
|
rounded_hull = None
|
||||||
return None
|
if self._node.getMeshData():
|
||||||
mesh = self._node.getMeshData()
|
mesh = self._node.getMeshData()
|
||||||
world_transform = self._node.getWorldTransformation()
|
world_transform = self._node.getWorldTransformation()
|
||||||
|
|
||||||
|
@ -145,6 +145,7 @@ class ConvexHullDecorator(SceneNodeDecorator):
|
||||||
# TODO; We need a better check for this as this gives poor results for meshes with long edges.
|
# TODO; We need a better check for this as this gives poor results for meshes with long edges.
|
||||||
vertex_data = vertex_data[vertex_data[:,1] >= 0]
|
vertex_data = vertex_data[vertex_data[:,1] >= 0]
|
||||||
|
|
||||||
|
if len(vertex_data) >= 4:
|
||||||
# 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.
|
||||||
|
@ -164,6 +165,7 @@ class ConvexHullDecorator(SceneNodeDecorator):
|
||||||
|
|
||||||
hull = Polygon(vertex_data)
|
hull = Polygon(vertex_data)
|
||||||
|
|
||||||
|
if len(vertex_data) >= 4:
|
||||||
# First, calculate the normal convex hull around the points
|
# First, calculate the normal convex hull around the points
|
||||||
convex_hull = hull.getConvexHull()
|
convex_hull = hull.getConvexHull()
|
||||||
|
|
||||||
|
|
|
@ -39,6 +39,7 @@ class ConvexHullNode(SceneNode):
|
||||||
self._convex_hull_head_mesh = None
|
self._convex_hull_head_mesh = None
|
||||||
self._hull = hull
|
self._hull = hull
|
||||||
|
|
||||||
|
if self._hull:
|
||||||
hull_mesh = self.createHullMesh(self._hull.getPoints())
|
hull_mesh = self.createHullMesh(self._hull.getPoints())
|
||||||
if hull_mesh:
|
if hull_mesh:
|
||||||
self.setMeshData(hull_mesh)
|
self.setMeshData(hull_mesh)
|
||||||
|
@ -76,6 +77,7 @@ class ConvexHullNode(SceneNode):
|
||||||
self._shader.setUniformValue("u_color", self._color)
|
self._shader.setUniformValue("u_color", self._color)
|
||||||
|
|
||||||
if self.getParent():
|
if self.getParent():
|
||||||
|
if self.getMeshData():
|
||||||
renderer.queueNode(self, transparent = True, shader = self._shader, backface_cull = True, sort = -8)
|
renderer.queueNode(self, transparent = True, shader = self._shader, backface_cull = True, sort = -8)
|
||||||
if self._convex_hull_head_mesh:
|
if self._convex_hull_head_mesh:
|
||||||
renderer.queueNode(self, shader = self._shader, transparent = True, mesh = self._convex_hull_head_mesh, backface_cull = True, sort = -8)
|
renderer.queueNode(self, shader = self._shader, transparent = True, mesh = self._convex_hull_head_mesh, backface_cull = True, sort = -8)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue