Skip to content
Snippets Groups Projects
Commit dbb01513 authored by Paul McCarthy's avatar Paul McCarthy :mountain_bicyclist:
Browse files

BF: Make mesh.needsFixing a little more robust? To my knowledge there's no

methoed to do this which is both fast and foolproof
parent 1e9da99c
No related branches found
No related tags found
No related merge requests found
...@@ -758,15 +758,19 @@ def needsFixing(vertices, indices, fnormals, loBounds, hiBounds): ...@@ -758,15 +758,19 @@ def needsFixing(vertices, indices, fnormals, loBounds, hiBounds):
ivert = np.argmin(dists) ivert = np.argmin(dists)
vert = vertices[ivert] vert = vertices[ivert]
# Pick a triangle that # Get all the triangles
# this vertex is in and # that this vertex is in
# ges its face normal # and their face normals
itri = np.where(indices == ivert)[0][0] itris = np.where(indices == ivert)[0]
n = fnormals[itri, :] norms = fnormals[itris, :]
# Make sure the angle between the # Calculate the angle between each
# normal, and a vector from the # normal, and a vector from the
# vertex to the camera is positive # vertex to the camera. If more than
# If it isn't, we need to flip the # 50% of the angles are negative
# triangle winding order. # (== more than 90 degrees == the
return np.dot(n, affine.normalise(camera - vert)) < 0 # face is facing away from the
# camera), assume that we need to
# flip the triangle winding order.
angles = np.dot(norms, affine.normalise(camera - vert))
return ((angles > 0).sum() / len(itris)) < 0.5
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment