Browse Source

Unroll the DX9 normal correction.

timeit indicates that this is a 43% improvement in performance.
pull/396/head
Adam Johnson 4 months ago
parent
commit
ccf7340123
Signed by: Hoikas
GPG Key ID: 0B6515D6FF6F271E
  1. 9
      korman/exporter/mesh.py

9
korman/exporter/mesh.py

@ -504,8 +504,13 @@ class MeshConverter(_MeshManager):
normal = source.normal if use_smooth else tessface.normal
# MOUL/DX9 craps its pants if any element of the normal is exactly 0.0
normal = map(lambda x: max(x, 0.01) if x >= 0.0 else min(x, -0.01), normal)
normal = hsVector3(*normal)
# Profiling indicates that unrolling this would give a performance penalty
# of roughly. Note: unrolling this calculation gives a 43% speedup.
normal = hsVector3(
max(normal[0], 0.01) if normal[0] >= 0.0 else min(normal[0], -0.01),
max(normal[1], 0.01) if normal[1] >= 0.0 else min(normal[1], -0.01),
max(normal[2], 0.01) if normal[2] >= 0.0 else min(normal[2], -0.01),
)
normal.normalize()
geoVertex.normal = normal

Loading…
Cancel
Save