Skip to content

Commit

Permalink
Made bounds info be robust to a mesh that has no points
Browse files Browse the repository at this point in the history
  • Loading branch information
jterrace committed Aug 8, 2012
1 parent cde3db3 commit 86667e2
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion meshtool/filters/print_filters/print_bounds.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ def centerFromBounds(bounds):
return numpy.array([x,y,z], dtype=numpy.float32)

def iter_prims(mesh):
if mesh.scene is None:
return

for boundobj in itertools.chain(mesh.scene.objects('geometry'), mesh.scene.objects('controller')):
if isinstance(boundobj, collada.geometry.BoundGeometry):
boundgeom = boundobj
Expand Down Expand Up @@ -67,7 +70,11 @@ def getBoundsInfo(mesh):
maxx = max(maxx, verts[:,:,0].max())
maxy = max(maxy, verts[:,:,1].max())
maxz = max(maxz, verts[:,:,2].max())


pts = [minx, maxx, miny, maxy, minz, maxz]
if INF in pts or NEGINF in pts:
minx, maxx, miny, maxy, minz, maxz = 0, 0, 0, 0, 0, 0

minpt = numpy.array([minx, miny, minz], dtype=numpy.float32)
maxpt = numpy.array([maxx, maxy, maxz], dtype=numpy.float32)
bounds = (minpt, maxpt)
Expand All @@ -84,6 +91,11 @@ def getBoundsInfo(mesh):
maxdist = dists[maxidx]
maxpt = verts[maxidx]

pts = [maxdist, maxpt[0], maxpt[1], maxpt[2]]
if INF in pts or NEGINF in pts:
maxdist = 0
maxpt[:] = 0

return {
'bounds': bounds,
'center': center,
Expand Down

0 comments on commit 86667e2

Please sign in to comment.