Skip to content

Commit

Permalink
fix normal
Browse files Browse the repository at this point in the history
  • Loading branch information
yfeng95 committed Jul 18, 2018
1 parent 9e2aaf0 commit fcb4e6a
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions face3d/mesh_cython/light.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@ def get_normal(vertices, triangles):
pt2 = vertices[triangles[:, 2], :] # [ntri, 3]
tri_normal = np.cross(pt0 - pt1, pt0 - pt2) # [ntri, 3]. normal of each triangle

normal = np.zeros_like(vertices, dtype = np.float32) # [nver, 3]
normal = np.zeros_like(vertices, dtype = np.float32).copy() # [nver, 3]
# for i in range(triangles.shape[0]):
# normal[triangles[i, 0], :] = normal[triangles[i, 0], :] + tri_normal[i, :]
# normal[triangles[i, 1], :] = normal[triangles[i, 1], :] + tri_normal[i, :]
# normal[triangles[i, 2], :] = normal[triangles[i, 2], :] + tri_normal[i, :]
mesh_core_cython.get_normal_core(normal.copy(), tri_normal.astype(np.float32).copy(), triangles.copy(), triangles.shape[0])
mesh_core_cython.get_normal_core(normal, tri_normal.astype(np.float32).copy(), triangles.copy(), triangles.shape[0])

# normalize to unit length
mag = np.sum(normal**2, 1) # [nver]
Expand Down

0 comments on commit fcb4e6a

Please sign in to comment.