Core: SOme code cleanup, more to follow.

This commit is contained in:
hondacrx
2021-03-20 22:48:48 -04:00
parent 62f554f2e0
commit 62ec699ec6
318 changed files with 5080 additions and 5125 deletions
@@ -25,7 +25,7 @@ namespace Game.Collision
{
public class StaticModelList
{
public static Dictionary<uint, GameobjectModelData> models = new Dictionary<uint, GameobjectModelData>();
public static Dictionary<uint, GameobjectModelData> models = new();
}
public abstract class GameObjectModelOwnerBase
@@ -47,7 +47,7 @@ namespace Game.Collision
if (modelData == null)
return false;
AxisAlignedBox mdl_box = new AxisAlignedBox(modelData.bound);
AxisAlignedBox mdl_box = new(modelData.bound);
// ignore models with no bounds
if (mdl_box == AxisAlignedBox.Zero())
{
@@ -69,7 +69,7 @@ namespace Game.Collision
iInvRot = iRotation.inverse();
// transform bounding box:
mdl_box = new AxisAlignedBox(mdl_box.Lo * iScale, mdl_box.Hi * iScale);
AxisAlignedBox rotated_bounds = new AxisAlignedBox();
AxisAlignedBox rotated_bounds = new();
for (int i = 0; i < 8; ++i)
rotated_bounds.merge(iRotation * mdl_box.corner(i));
@@ -81,7 +81,7 @@ namespace Game.Collision
public static GameObjectModel Create(GameObjectModelOwnerBase modelOwner)
{
GameObjectModel mdl = new GameObjectModel();
GameObjectModel mdl = new();
if (!mdl.Initialize(modelOwner))
return null;
@@ -102,7 +102,7 @@ namespace Game.Collision
// child bounds are defined in object space:
Vector3 p = iInvRot * (ray.Origin - iPos) * iInvScale;
Ray modRay = new Ray(p, iInvRot * ray.Direction);
Ray modRay = new(p, iInvRot * ray.Direction);
float distance = maxDist * iInvScale;
bool hit = iModel.IntersectRay(modRay, ref distance, stopAtFirstHit, ignoreFlags);
if (hit)
@@ -149,7 +149,7 @@ namespace Game.Collision
if (it == null)
return false;
AxisAlignedBox mdl_box = new AxisAlignedBox(it.bound);
AxisAlignedBox mdl_box = new(it.bound);
// ignore models with no bounds
if (mdl_box == AxisAlignedBox.Zero())
{
@@ -163,7 +163,7 @@ namespace Game.Collision
iInvRot = iRotation.inverse();
// transform bounding box:
mdl_box = new AxisAlignedBox(mdl_box.Lo * iScale, mdl_box.Hi * iScale);
AxisAlignedBox rotated_bounds = new AxisAlignedBox();
AxisAlignedBox rotated_bounds = new();
for (int i = 0; i < 8; ++i)
rotated_bounds.merge(iRotation * mdl_box.corner(i));
@@ -190,7 +190,7 @@ namespace Game.Collision
}
try
{
using (BinaryReader reader = new BinaryReader(new FileStream(filename, FileMode.Open, FileAccess.Read)))
using (BinaryReader reader = new(new FileStream(filename, FileMode.Open, FileAccess.Read)))
{
string magic = reader.ReadStringFromChars(8);
if (magic != MapConst.VMapMagic)
@@ -105,7 +105,7 @@ namespace Game.Collision
// child bounds are defined in object space:
Vector3 p = iInvRot * (pRay.Origin - iPos) * iInvScale;
Ray modRay = new Ray(p, iInvRot * pRay.Direction);
Ray modRay = new(p, iInvRot * pRay.Direction);
float distance = pMaxDist * iInvScale;
bool hit = iModel.IntersectRay(modRay, ref distance, pStopAtFirstHit, ignoreFlags);
if (hit)
+13 -13
View File
@@ -130,7 +130,7 @@ namespace Game.Collision
public static WmoLiquid ReadFromFile(BinaryReader reader)
{
WmoLiquid liquid = new WmoLiquid();
WmoLiquid liquid = new();
liquid.iTilesX = reader.ReadUInt32();
liquid.iTilesY = reader.ReadUInt32();
@@ -254,7 +254,7 @@ namespace Game.Collision
if (triangles.Empty())
return false;
GModelRayCallback callback = new GModelRayCallback(triangles, vertices);
GModelRayCallback callback = new(triangles, vertices);
meshTree.IntersectRay(ray, callback, ref distance, stopAtFirstHit);
return callback.hit;
}
@@ -267,7 +267,7 @@ namespace Game.Collision
Vector3 rPos = pos - 0.1f * down;
float dist = float.PositiveInfinity;
Ray ray = new Ray(rPos, down);
Ray ray = new(rPos, down);
bool hit = IntersectRay(ray, ref dist, false);
if (hit)
z_dist = dist - 0.1f;
@@ -298,9 +298,9 @@ namespace Game.Collision
AxisAlignedBox iBound;
uint iMogpFlags;
uint iGroupWMOID;
List<Vector3> vertices = new List<Vector3>();
List<MeshTriangle> triangles = new List<MeshTriangle>();
BIH meshTree = new BIH();
List<Vector3> vertices = new();
List<MeshTriangle> triangles = new();
BIH meshTree = new();
WmoLiquid iLiquid;
}
@@ -326,7 +326,7 @@ namespace Game.Collision
if (groupModels.Count == 1)
return groupModels[0].IntersectRay(ray, ref distance, stopAtFirstHit);
WModelRayCallBack isc = new WModelRayCallBack(groupModels);
WModelRayCallBack isc = new(groupModels);
groupTree.IntersectRay(ray, isc, ref distance, stopAtFirstHit);
return isc.hit;
}
@@ -337,7 +337,7 @@ namespace Game.Collision
if (groupModels.Empty())
return false;
WModelAreaCallback callback = new WModelAreaCallback(groupModels, down);
WModelAreaCallback callback = new(groupModels, down);
groupTree.IntersectPoint(p, callback);
if (callback.hit != null)
{
@@ -357,7 +357,7 @@ namespace Game.Collision
if (groupModels.Empty())
return false;
WModelAreaCallback callback = new WModelAreaCallback(groupModels, down);
WModelAreaCallback callback = new(groupModels, down);
groupTree.IntersectPoint(p, callback);
if (callback.hit != null)
{
@@ -378,7 +378,7 @@ namespace Game.Collision
return false;
}
using (BinaryReader reader = new BinaryReader(new FileStream(filename, FileMode.Open, FileAccess.Read)))
using (BinaryReader reader = new(new FileStream(filename, FileMode.Open, FileAccess.Read)))
{
if (reader.ReadStringFromChars(8) != MapConst.VMapMagic)
return false;
@@ -396,7 +396,7 @@ namespace Game.Collision
uint count = reader.ReadUInt32();
for (var i = 0; i < count; ++i)
{
GroupModel group = new GroupModel();
GroupModel group = new();
group.ReadFromFile(reader);
groupModels.Add(group);
}
@@ -409,8 +409,8 @@ namespace Game.Collision
}
}
List<GroupModel> groupModels = new List<GroupModel>();
BIH groupTree = new BIH();
List<GroupModel> groupModels = new();
BIH groupTree = new();
uint RootWMOID;
public uint Flags;
}