mirror of
https://github.com/celisej567/LibBSP.git
synced 2026-09-23 20:08:40 +03:00
Rather large refactor:
Most changes were just small adjustments for coding style. Made "using" statements for Unity, rather than non-Unity compiles. So in Unity "Vector3d" is an alias for "Vector3", instead of the other way around. Restrict CountAttribute and IndexAttribute to apply to properties and fields only. Removed Rect and RectExtensions, Rect was never used anywhere and was leftover from a long-gone part of this project. Remove unnecessary "this" references and refactor Int32, Single, etc. to int, float, etc. (I might have missed a few of these). Refactor MAPBrushSide to use a TextureInfo rather than duplicating many fields. Make Terrain and Displacement formats use two-dimensional arrays rather than arrays of arrays. Rename UIVertex to Vertex.
This commit is contained in:
@@ -9,8 +9,8 @@ using UnityEngine;
|
||||
#endif
|
||||
|
||||
namespace LibBSP {
|
||||
#if !UNITY
|
||||
using Vector2 = Vector2d;
|
||||
#if UNITY
|
||||
using Vector2d = Vector2;
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
@@ -20,7 +20,7 @@ namespace LibBSP {
|
||||
|
||||
public short shader { get; private set; }
|
||||
public short type { get; private set; }
|
||||
public Vector2 dimensions { get; private set; }
|
||||
public Vector2d dimensions { get; private set; }
|
||||
public int flags { get; private set; }
|
||||
[Index("patchVerts")] public int firstVertex { get; private set; }
|
||||
[Count("patchVerts")] public int numVertices { get; private set; }
|
||||
@@ -46,7 +46,7 @@ namespace LibBSP {
|
||||
if (this.type == 0) { // Patch
|
||||
short x = BitConverter.ToInt16(data, 4);
|
||||
short y = BitConverter.ToInt16(data, 6);
|
||||
dimensions = new Vector2(x, y);
|
||||
dimensions = new Vector2d(x, y);
|
||||
flags = BitConverter.ToInt32(data, 8);
|
||||
firstVertex = BitConverter.ToInt32(data, 12);
|
||||
numVertices = x * y;
|
||||
@@ -87,9 +87,10 @@ namespace LibBSP {
|
||||
throw new ArgumentException("Map type " + type + " isn't supported by the Patch lump factory.");
|
||||
}
|
||||
}
|
||||
List<Patch> lump = new List<Patch>(data.Length / structLength);
|
||||
int numObjects = data.Length / structLength;
|
||||
List<Patch> lump = new List<Patch>(numObjects);
|
||||
byte[] bytes = new byte[structLength];
|
||||
for (int i = 0; i < data.Length / structLength; ++i) {
|
||||
for (int i = 0; i < numObjects; ++i) {
|
||||
Array.Copy(data, (i * structLength), bytes, 0, structLength);
|
||||
lump.Add(new Patch(bytes, type, version));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user