MCPcopy Create free account
hub / github.com/bfbbdecomp/bfbb / xVec3Normalize

Function xVec3Normalize

src/SB/Core/x/xVec3.cpp:14–49  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

12const xVec3 xVec3::m_UnitAxisY = { 0.0f, 1.0f, 0.0f };
13
14F32 xVec3Normalize(xVec3* o, const xVec3* v)
15{
16 F32 x = v->x;
17 F32 x2 = SQR(v->x);
18 F32 y = v->y;
19 F32 y2 = SQR(v->y);
20 F32 z = v->z;
21 F32 z2 = SQR(v->z);
22
23 F32 len;
24 F32 len2 = x2 + y2 + z2;
25
26 if ((F32)iabs(len2 - 1.0f) <= 0.00001f)
27 {
28 o->x = x;
29 o->y = y;
30 o->z = z;
31 len = 1.0f;
32 }
33 else if ((F32)iabs(len2) <= 0.00001f)
34 {
35 o->x = 0.0f;
36 o->y = 1.0f;
37 o->z = 0.0f;
38 len = 0.0f;
39 }
40 else
41 {
42 len = xsqrt(len2);
43 F32 inv_len = 1.0f / len;
44 o->x = v->x * inv_len;
45 o->y = v->y * inv_len;
46 o->z = v->z * inv_len;
47 }
48 return len;
49}
50
51F32 xVec3NormalizeFast(xVec3* o, const xVec3* v)
52{

Callers 15

xEntBoulder_UpdateFunction · 0.70
xEntBoulder_BubbleBowlFunction · 0.70
xBoulderGenerator_InitFunction · 0.70
shadowRayCBFunction · 0.70
xScrFXGlareRenderFunction · 0.70
xSphereHitsSphereFunction · 0.70
xSphereHitsBoxFunction · 0.70
xParabolaEnvCBFunction · 0.70
xBoxHitsSphereFunction · 0.70
xSweptSphereGetResultsFunction · 0.70
xSweptSphereToBoxFunction · 0.70

Calls 1

xsqrtFunction · 0.85

Tested by

no test coverage detected