Skip to content

Commit 828442d

Browse files
committed
Simplification of normal calculation
There's no need to individually scale the face normals. Skipping this automatically reduces the influence of small triangles and stops degenerate triangles (with a zero-length side) from blowing up the normal completely.
1 parent 344a8ab commit 828442d

File tree

1 file changed

+0
-4
lines changed

1 file changed

+0
-4
lines changed

src/flitter/render/window/models.pyx

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -85,10 +85,6 @@ cpdef void fill_in_normals(vertices_array, faces_array):
8585
Ax, Ay, Az = vertices[c, 0]-vertices[b, 0], vertices[c, 1]-vertices[b, 1], vertices[c, 2]-vertices[b, 2]
8686
Bx, By, Bz = vertices[a, 0]-vertices[b, 0], vertices[a, 1]-vertices[b, 1], vertices[a, 2]-vertices[b, 2]
8787
Nx, Ny, Nz = Ay*Bz-Az*By, Az*Bx-Ax*Bz, Ax*By-Ay*Bx
88-
f = 1.0 / sqrt(Nx*Nx + Ny*Ny + Nz*Nz)
89-
Nx *= f
90-
Ny *= f
91-
Nz *= f
9288
vertices[a, 3] += Nx
9389
vertices[a, 4] += Ny
9490
vertices[a, 5] += Nz

0 commit comments

Comments
 (0)