diff --git a/cura/ConvexHullJob.py b/cura/ConvexHullJob.py index 3832e53df6..8369d050c8 100644 --- a/cura/ConvexHullJob.py +++ b/cura/ConvexHullJob.py @@ -38,7 +38,6 @@ class ConvexHullJob(Job): vertex_data = mesh.getTransformed(self._node.getWorldTransformation()).getVertices() # Don't use data below 0. 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] - hull = Polygon(numpy.rint(vertex_data[:, [0, 2]]).astype(int)) # First, calculate the normal convex hull around the points @@ -59,7 +58,7 @@ class ConvexHullJob(Job): self._node.callDecoration("setConvexHullNode", hull_node) self._node.callDecoration("setConvexHull", hull) self._node.callDecoration("setConvexHullJob", None) - + if self._node.getParent().callDecoration("isGroup"): job = self._node.getParent().callDecoration("getConvexHullJob") if job: diff --git a/cura/ConvexHullNode.py b/cura/ConvexHullNode.py index e24d79522c..d610149072 100644 --- a/cura/ConvexHullNode.py +++ b/cura/ConvexHullNode.py @@ -30,14 +30,14 @@ class ConvexHullNode(SceneNode): self._hull = hull hull_points = self._hull.getPoints() - center = (hull_points.min(0) + hull_points.max(0)) / 2.0 - mesh = MeshData() - mesh.addVertex(center[0], 0.1, center[1]) - + if len(hull_points) > 3: + center = (hull_points.min(0) + hull_points.max(0)) / 2.0 + mesh.addVertex(center[0], 0.1, center[1]) + else: #Hull has not enough points + return for point in hull_points: mesh.addVertex(point[0], 0.1, point[1]) - indices = [] for i in range(len(hull_points) - 1): indices.append([0, i + 1, i + 2]) diff --git a/cura/PlatformPhysics.py b/cura/PlatformPhysics.py index f1fc7fd0b1..ee6e39f03b 100644 --- a/cura/PlatformPhysics.py +++ b/cura/PlatformPhysics.py @@ -113,8 +113,10 @@ class PlatformPhysics: move_vector.setX(overlap[0] * 1.1) move_vector.setZ(overlap[1] * 1.1) - convex_hull = node.callDecoration("getConvexHull") + convex_hull = node.callDecoration("getConvexHull") if convex_hull: + if not convex_hull.isValid(): + return # Check for collisions between disallowed areas and the object for area in self._build_volume.getDisallowedAreas(): overlap = convex_hull.intersectsPolygon(area)