This commit is contained in:
DCFApixels 2025-10-12 22:13:01 +08:00
parent 5b64866ca4
commit ede7d5bb4d
3 changed files with 2 additions and 25 deletions

View File

@ -201,7 +201,7 @@ namespace DCFApixels
const float MinDistance = 2.5f; const float MinDistance = 2.5f;
Vector3 direction = end - start; Vector3 direction = end - start;
float distance = DebugXUtility.FastSqrt(direction.sqrMagnitude); float distance = direction.magnitude;
Quaternion rotation = direction == default ? Quaternion.identity : Quaternion.LookRotation(direction); Quaternion rotation = direction == default ? Quaternion.identity : Quaternion.LookRotation(direction);
var arrowSize = 0.5f; var arrowSize = 0.5f;

View File

@ -111,7 +111,7 @@ namespace DCFApixels
float x = sqrRadius * sqrRadius / sqrMagnitude; float x = sqrRadius * sqrRadius / sqrMagnitude;
if (x / sqrRadius < 1f) if (x / sqrRadius < 1f)
{ {
float resultSize = DebugXUtility.FastSqrt(sqrRadius - x); float resultSize = Mathf.Sqrt(sqrRadius - x);
_buffer[i] = new Gizmo<InstancingMeshGizmoLayout>( _buffer[i] = new Gizmo<InstancingMeshGizmoLayout>(
new InstancingMeshGizmoLayout( new InstancingMeshGizmoLayout(

View File

@ -92,29 +92,6 @@ namespace DCFApixels.DebugXCore
return isFull ? type.FullName : type.Name; return isFull ? type.FullName : type.Name;
#endif #endif
} }
[IN(LINE)]
public static float FastMagnitude(Vector3 v)
{
return FastSqrt(v.x * v.x + v.y * v.y + v.z * v.z);
}
[IN(LINE)]
public static unsafe float FastSqrt(float number)
{
long i;
float x2, y;
const float threehalfs = 1.5F;
x2 = number * 0.5F;
y = number;
i = *(long*)&y; // evil floating point bit level hacking
i = 0x5f3759df - (i >> 1); // what the fuck?
y = *(float*)&i;
y = y * (threehalfs - (x2 * y * y)); // 1st iteration
//y = y * ( threehalfs - ( x2 * y * y ) ); // 2nd iteration, this can be removed
return 1 / y;
}
[IN(LINE)] [IN(LINE)]
public static int NextPow2(int v) public static int NextPow2(int v)
{ {