You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
the code used to generate the (vertex) normals gives a wrong result.
Original code :
def generateNormals(self):
"""If :attr:`normals` is `None` or you wish for normals to be
recomputed, call this method to recompute them."""
norms = numpy.zeros( self._vertex.shape, dtype=self._vertex.dtype )
tris = self._vertex[self._vertex_index]
n = numpy.cross( tris[::,1] - tris[::,0], tris[::,2] - tris[::,0] )
normalize_v3(n)
norms[ self._vertex_index[:,0] ] += n
norms[ self._vertex_index[:,1] ] += n
norms[ self._vertex_index[:,2] ] += n
normalize_v3(norms)
self._normal = norms
self._normal_index = self._vertex_index
Problem :
norms[ self._vertex_index[:,0] ] += n
norms[ self._vertex_index[:,1] ] += n
norms[ self._vertex_index[:,2] ] += n
Solution (naive implementation) :
for i, f in enumerate( self._vertex_index ) :
norms[ f ] += n[ i ]
The problem comes from the implementation norms[ self._vertex_index[:,0] ] += n where the face normal vector n is only added once per vertex (instead of a certain number).
Best regards !
The text was updated successfully, but these errors were encountered:
Hello,
the code used to generate the (vertex) normals gives a wrong result.
Original code :
Problem :
Solution (naive implementation) :
The problem comes from the implementation
norms[ self._vertex_index[:,0] ] += n
where the face normal vectorn
is only added once per vertex (instead of a certain number).Best regards !
The text was updated successfully, but these errors were encountered: