Optimize vectors normalization

This commit is contained in:
Wojtek Figat
2023-04-17 11:10:14 +02:00
parent c3cc78b7c2
commit b85184eee0
13 changed files with 80 additions and 72 deletions

View File

@@ -2,8 +2,10 @@
#if USE_LARGE_WORLDS
using Real = System.Double;
using Mathr = FlaxEngine.Mathd;
#else
using Real = System.Single;
using Mathr = FlaxEngine.Mathf;
#endif
// -----------------------------------------------------------------------------
@@ -175,7 +177,7 @@ namespace FlaxEngine
public void Normalize()
{
Real length = Normal.Length;
if (!Mathf.IsZero(length))
if (length >= Mathr.Epsilon)
{
Real rcp = 1.0f / length;
Normal.X *= rcp;