MCPcopy Create free account
hub / github.com/DescentDevelopers/Descent3 / vm_GetMagnitudeFast

Function vm_GetMagnitudeFast

scripts/osiris_vector.h:465–493  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

463}
464
465float vm_GetMagnitudeFast(vector *v) {
466 float a, b, c, bc;
467
468 a = fabs(v->x);
469 b = fabs(v->y);
470 c = fabs(v->z);
471
472 if (a < b) {
473 float t = a;
474 a = b;
475 b = t;
476 }
477
478 if (b < c) {
479 float t = b;
480 b = c;
481 c = t;
482
483 if (a < b) {
484 float t = a;
485 a = b;
486 b = t;
487 }
488 }
489
490 bc = (b / 4) + (c / 8);
491
492 return a + bc + (bc / 2);
493}
494
495// Normalize a vector using an approximation of the magnitude
496// Returns: the magnitude before normalization

Callers 3

vm_VectorDistanceQuickFunction · 0.70
vm_VectorNormalizeFastFunction · 0.70
vm_GetCentroidFastFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected