large worlds engine compat refactor, change vector -> float

This commit is contained in:
2022-06-13 22:06:37 +03:00
parent 3b6b5686d0
commit a0d2b127de
18 changed files with 389 additions and 389 deletions

View File

@@ -11,12 +11,12 @@ namespace Game
{
public struct MapFacePlane
{
public Vector3 v1, v2, v3;
public Float3 v1, v2, v3;
public Plane plane;
public string texture;
public Vector2 offset;
public Float2 offset;
public float rotation;
public Vector2 scale;
public Float2 scale;
public int contentFlags, surfaceFlags, surfaceValue;
}
@@ -32,8 +32,8 @@ namespace Game
public struct PatchVertex
{
public Vector3 v;
public Vector2 uv;
public Float3 v;
public Float2 uv;
}
public class MapEntity
@@ -245,24 +245,24 @@ namespace Game
throw new Exception("failed to ParseInt: " + fs);
}
private static Vector3 ParseVector3(byte[] data, ref int index)
private static Float3 ParseFloat3(byte[] data, ref int index)
{
return new Vector3(
return new Float3(
ParseFloat(data, ref index),
ParseFloat(data, ref index),
ParseFloat(data, ref index)
);
}
private static Vector2 ParseVector2(byte[] data, ref int index)
private static Float2 ParseFloat2(byte[] data, ref int index)
{
return new Vector2(
return new Float2(
ParseFloat(data, ref index),
ParseFloat(data, ref index)
);
}
private static Vector3 ParsePlaneVector3(byte[] data, ref int index)
private static Float3 ParsePlaneFloat3(byte[] data, ref int index)
{
index++;
while (index < data.Length)
@@ -272,7 +272,7 @@ namespace Game
index++;
}
Vector3 vector = ParseVector3(data, ref index);
Float3 vector = ParseFloat3(data, ref index);
// rounding
/*float temp = vector.Z;
vector.Z = vector.Y;
@@ -328,16 +328,16 @@ namespace Game
case '(':
{
MapFacePlane plane = new MapFacePlane();
plane.v1 = ParsePlaneVector3(data, ref index);
plane.v2 = ParsePlaneVector3(data, ref index);
plane.v3 = ParsePlaneVector3(data, ref index);
plane.v1 = ParsePlaneFloat3(data, ref index);
plane.v2 = ParsePlaneFloat3(data, ref index);
plane.v3 = ParsePlaneFloat3(data, ref index);
plane.texture = ParseString(data, ref index);
if (true) // quake or quake3 format
{
plane.offset = ParseVector2(data, ref index);
plane.offset = ParseFloat2(data, ref index);
plane.rotation = ParseFloat(data, ref index);
plane.scale = ParseVector2(data, ref index);
plane.scale = ParseFloat2(data, ref index);
char peekChar = (char)data[index];
if (peekChar != '\n') // quake3 format
@@ -349,9 +349,9 @@ namespace Game
}
// Flip Y and Z
plane.v1 = new Vector3(plane.v1.X, plane.v1.Z, plane.v1.Y);
plane.v2 = new Vector3(plane.v2.X, plane.v2.Z, plane.v2.Y);
plane.v3 = new Vector3(plane.v3.X, plane.v3.Z, plane.v3.Y);
plane.v1 = new Float3(plane.v1.X, plane.v1.Z, plane.v1.Y);
plane.v2 = new Float3(plane.v2.X, plane.v2.Z, plane.v2.Y);
plane.v3 = new Float3(plane.v3.X, plane.v3.Z, plane.v3.Y);
plane.plane = new Plane(plane.v1, plane.v2, plane.v3);
@@ -494,9 +494,9 @@ namespace Game
index++;
}
vertices[vertexIndex].v = ParseVector3(data, ref index);
vertices[vertexIndex].v = ParseFloat3(data, ref index);
vertices[vertexIndex].uv =
new Vector2(ParseFloat(data, ref index), ParseFloat(data, ref index));
new Float2(ParseFloat(data, ref index), ParseFloat(data, ref index));
vertexIndex++;
while (index < data.Length)