cirnogodot/Scripts/Utils/QuakeTools.cs

30 lines
742 B
C#
Raw Normal View History

2025-06-28 13:59:12 +02:00
using Godot;
namespace Cirno.Scripts.Utils;
public static class QuakeTools
{
// Common inverse scale. Calculated as 1.0 / Inverse Scale Factor.
// Used to help translate properties using Quake Units into Godot Units.
public const float InverseScale = 0.03125f;
public static Vector3 IdVecToGodotVec(Variant vec)
{
var org = Vector3.Zero;
if (vec.Obj is Vector3 vec3)
{
org = vec3;
}
else if (vec.Obj is string vecs)
{
var arr = vecs.SplitFloats(" ");
for (int i = 0; i < Mathf.Max(arr.Length, 3); i++)
{
org[i] = arr[i];
}
}
return new Vector3(org.Y, org.Z, org.X);
}
}