Fixed bug that caused crash when object was entirely below platform

This commit is contained in:
Jaime van Kessel 2015-08-13 13:35:51 +02:00
parent a63d08288a
commit ddc34eaa3a
3 changed files with 9 additions and 8 deletions

View file

@ -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

View file

@ -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()
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])

View file

@ -115,6 +115,8 @@ class PlatformPhysics:
move_vector.setZ(overlap[1] * 1.1)
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)