Core: SOme code cleanup, more to follow.
This commit is contained in:
@@ -46,7 +46,7 @@ namespace Game.Collision
|
||||
tempTree.Add(0);
|
||||
|
||||
// seed bbox
|
||||
AABound gridBox = new AABound();
|
||||
AABound gridBox = new();
|
||||
gridBox.lo = bounds.Lo;
|
||||
gridBox.hi = bounds.Hi;
|
||||
AABound nodeBox = gridBox;
|
||||
@@ -303,8 +303,8 @@ namespace Game.Collision
|
||||
dat.primBound[i] = primitives[i].GetBounds();
|
||||
bounds.merge(dat.primBound[i]);
|
||||
}
|
||||
List<uint> tempTree = new List<uint>();
|
||||
BuildStats stats = new BuildStats();
|
||||
List<uint> tempTree = new();
|
||||
BuildStats stats = new();
|
||||
BuildHierarchy(tempTree, dat, stats);
|
||||
|
||||
objects = new uint[dat.numPrims];
|
||||
@@ -322,7 +322,7 @@ namespace Game.Collision
|
||||
float intervalMax = -1.0f;
|
||||
Vector3 org = r.Origin;
|
||||
Vector3 dir = r.Direction;
|
||||
Vector3 invDir = new Vector3();
|
||||
Vector3 invDir = new();
|
||||
for (int i = 0; i < 3; ++i)
|
||||
{
|
||||
invDir[i] = 1.0f / dir[i];
|
||||
@@ -621,13 +621,13 @@ namespace Game.Collision
|
||||
|
||||
uint FloatToRawIntBits(float f)
|
||||
{
|
||||
FloatToIntConverter converter = new FloatToIntConverter();
|
||||
FloatToIntConverter converter = new();
|
||||
converter.FloatValue = f;
|
||||
return converter.IntValue;
|
||||
}
|
||||
float IntBitsToFloat(uint i)
|
||||
{
|
||||
FloatToIntConverter converter = new FloatToIntConverter();
|
||||
FloatToIntConverter converter = new();
|
||||
converter.IntValue = i;
|
||||
return converter.FloatValue;
|
||||
}
|
||||
|
||||
@@ -53,21 +53,21 @@ namespace Game.Collision
|
||||
public void IntersectRay(Ray ray, WorkerCallback intersectCallback, ref float maxDist)
|
||||
{
|
||||
Balance();
|
||||
MDLCallback temp_cb = new MDLCallback(intersectCallback, m_objects.ToArray(), (uint)m_objects.Count);
|
||||
MDLCallback temp_cb = new(intersectCallback, m_objects.ToArray(), (uint)m_objects.Count);
|
||||
m_tree.IntersectRay(ray, temp_cb, ref maxDist, true);
|
||||
}
|
||||
|
||||
public void IntersectPoint(Vector3 point, WorkerCallback intersectCallback)
|
||||
{
|
||||
Balance();
|
||||
MDLCallback callback = new MDLCallback(intersectCallback, m_objects.ToArray(), (uint)m_objects.Count);
|
||||
MDLCallback callback = new(intersectCallback, m_objects.ToArray(), (uint)m_objects.Count);
|
||||
m_tree.IntersectPoint(point, callback);
|
||||
}
|
||||
|
||||
BIH m_tree = new BIH();
|
||||
List<T> m_objects = new List<T>();
|
||||
Dictionary<T, uint> m_obj2Idx = new Dictionary<T, uint>();
|
||||
HashSet<T> m_objects_to_push = new HashSet<T>();
|
||||
BIH m_tree = new();
|
||||
List<T> m_objects = new();
|
||||
Dictionary<T, uint> m_obj2Idx = new();
|
||||
HashSet<T> m_objects_to_push = new();
|
||||
int unbalanced_times;
|
||||
|
||||
public class MDLCallback : WorkerCallback
|
||||
|
||||
@@ -121,7 +121,7 @@ namespace Game.Collision
|
||||
|
||||
Vector3 e1 = points[(int)tri.idx1] - points[(int)tri.idx0];
|
||||
Vector3 e2 = points[(int)tri.idx2] - points[(int)tri.idx0];
|
||||
Vector3 p = new Vector3(ray.Direction.cross(e2));
|
||||
Vector3 p = new(ray.Direction.cross(e2));
|
||||
float a = e1.dot(p);
|
||||
|
||||
if (Math.Abs(a) < EPS)
|
||||
@@ -131,7 +131,7 @@ namespace Game.Collision
|
||||
}
|
||||
|
||||
float f = 1.0f / a;
|
||||
Vector3 s = new Vector3(ray.Origin - points[(int)tri.idx0]);
|
||||
Vector3 s = new(ray.Origin - points[(int)tri.idx0]);
|
||||
float u = f * s.dot(p);
|
||||
|
||||
if ((u < 0.0f) || (u > 1.0f))
|
||||
@@ -140,7 +140,7 @@ namespace Game.Collision
|
||||
return false;
|
||||
}
|
||||
|
||||
Vector3 q = new Vector3(s.cross(e1));
|
||||
Vector3 q = new(s.cross(e1));
|
||||
float v = f * ray.Direction.dot(q);
|
||||
|
||||
if ((v < 0.0f) || ((u + v) > 1.0f))
|
||||
@@ -205,7 +205,7 @@ namespace Game.Collision
|
||||
}
|
||||
|
||||
ModelInstance[] prims;
|
||||
public AreaInfo aInfo = new AreaInfo();
|
||||
public AreaInfo aInfo = new();
|
||||
}
|
||||
|
||||
public class LocationInfoCallback : WorkerCallback
|
||||
|
||||
@@ -54,7 +54,7 @@ namespace Game.Collision
|
||||
public bool GetIntersectionTime(Ray ray, Vector3 endPos, PhaseShift phaseShift, float maxDist)
|
||||
{
|
||||
float distance = maxDist;
|
||||
DynamicTreeIntersectionCallback callback = new DynamicTreeIntersectionCallback(phaseShift);
|
||||
DynamicTreeIntersectionCallback callback = new(phaseShift);
|
||||
impl.IntersectRay(ray, callback, ref distance, endPos);
|
||||
if (callback.DidHit())
|
||||
maxDist = distance;
|
||||
@@ -74,7 +74,7 @@ namespace Game.Collision
|
||||
return false;
|
||||
}
|
||||
Vector3 dir = (endPos - startPos) / maxDist; // direction with length of 1
|
||||
Ray ray = new Ray(startPos, dir);
|
||||
Ray ray = new(startPos, dir);
|
||||
float dist = maxDist;
|
||||
if (GetIntersectionTime(ray, endPos, phaseShift, dist))
|
||||
{
|
||||
@@ -106,8 +106,8 @@ namespace Game.Collision
|
||||
if (!MathFunctions.fuzzyGt(maxDist, 0))
|
||||
return true;
|
||||
|
||||
Ray r = new Ray(startPos, (endPos - startPos) / maxDist);
|
||||
DynamicTreeIntersectionCallback callback = new DynamicTreeIntersectionCallback(phaseShift);
|
||||
Ray r = new(startPos, (endPos - startPos) / maxDist);
|
||||
DynamicTreeIntersectionCallback callback = new(phaseShift);
|
||||
impl.IntersectRay(r, callback, ref maxDist, endPos);
|
||||
|
||||
return !callback.DidHit();
|
||||
@@ -115,9 +115,9 @@ namespace Game.Collision
|
||||
|
||||
public float GetHeight(float x, float y, float z, float maxSearchDist, PhaseShift phaseShift)
|
||||
{
|
||||
Vector3 v = new Vector3(x, y, z + 0.5f);
|
||||
Ray r = new Ray(v, new Vector3(0, 0, -1));
|
||||
DynamicTreeIntersectionCallback callback = new DynamicTreeIntersectionCallback(phaseShift);
|
||||
Vector3 v = new(x, y, z + 0.5f);
|
||||
Ray r = new(v, new Vector3(0, 0, -1));
|
||||
DynamicTreeIntersectionCallback callback = new(phaseShift);
|
||||
impl.IntersectZAllignedRay(r, callback, ref maxSearchDist);
|
||||
|
||||
if (callback.DidHit())
|
||||
@@ -133,8 +133,8 @@ namespace Game.Collision
|
||||
rootId = 0;
|
||||
groupId = 0;
|
||||
|
||||
Vector3 v = new Vector3(x, y, z + 0.5f);
|
||||
DynamicTreeAreaInfoCallback intersectionCallBack = new DynamicTreeAreaInfoCallback(phaseShift);
|
||||
Vector3 v = new(x, y, z + 0.5f);
|
||||
DynamicTreeAreaInfoCallback intersectionCallBack = new(phaseShift);
|
||||
impl.IntersectPoint(v, intersectionCallBack);
|
||||
if (intersectionCallBack.GetAreaInfo().result)
|
||||
{
|
||||
|
||||
@@ -84,7 +84,7 @@ namespace Game.Collision
|
||||
if (instanceTree == null)
|
||||
{
|
||||
string filename = VMapPath + GetMapFileName(mapId);
|
||||
StaticMapTree newTree = new StaticMapTree(mapId);
|
||||
StaticMapTree newTree = new(mapId);
|
||||
LoadResult treeInitResult = newTree.InitMap(filename);
|
||||
if (treeInitResult != LoadResult.Success)
|
||||
return treeInitResult;
|
||||
@@ -232,7 +232,7 @@ namespace Game.Collision
|
||||
var instanceTree = iInstanceMapTrees.LookupByKey(mapId);
|
||||
if (instanceTree != null)
|
||||
{
|
||||
LocationInfo info = new LocationInfo();
|
||||
LocationInfo info = new();
|
||||
Vector3 pos = ConvertPositionToInternalRep(x, y, z);
|
||||
if (instanceTree.GetLocationInfo(pos, info))
|
||||
{
|
||||
@@ -265,7 +265,7 @@ namespace Game.Collision
|
||||
var instanceTree = iInstanceMapTrees.LookupByKey(mapId);
|
||||
if (instanceTree != null)
|
||||
{
|
||||
LocationInfo info = new LocationInfo();
|
||||
LocationInfo info = new();
|
||||
Vector3 pos = ConvertPositionToInternalRep(x, y, z);
|
||||
if (instanceTree.GetLocationInfo(pos, info))
|
||||
{
|
||||
@@ -292,7 +292,7 @@ namespace Game.Collision
|
||||
var model = iLoadedModelFiles.LookupByKey(filename);
|
||||
if (model == null)
|
||||
{
|
||||
WorldModel worldmodel = new WorldModel();
|
||||
WorldModel worldmodel = new();
|
||||
if (!worldmodel.ReadFile(VMapPath + filename))
|
||||
{
|
||||
Log.outError(LogFilter.Server, "VMapManager: could not load '{0}'", filename);
|
||||
@@ -347,7 +347,7 @@ namespace Game.Collision
|
||||
|
||||
Vector3 ConvertPositionToInternalRep(float x, float y, float z)
|
||||
{
|
||||
Vector3 pos = new Vector3();
|
||||
Vector3 pos = new();
|
||||
float mid = 0.5f * 64.0f * 533.33333333f;
|
||||
pos.X = mid - x;
|
||||
pos.Y = mid - y;
|
||||
@@ -368,14 +368,14 @@ namespace Game.Collision
|
||||
public bool IsHeightCalcEnabled() { return _enableHeightCalc; }
|
||||
public bool IsMapLoadingEnabled() { return _enableLineOfSightCalc || _enableHeightCalc; }
|
||||
|
||||
Dictionary<string, ManagedModel> iLoadedModelFiles = new Dictionary<string, ManagedModel>();
|
||||
Dictionary<uint, StaticMapTree> iInstanceMapTrees = new Dictionary<uint, StaticMapTree>();
|
||||
MultiMap<uint, uint> iChildMapData = new MultiMap<uint, uint>();
|
||||
Dictionary<uint, uint> iParentMapData = new Dictionary<uint, uint>();
|
||||
Dictionary<string, ManagedModel> iLoadedModelFiles = new();
|
||||
Dictionary<uint, StaticMapTree> iInstanceMapTrees = new();
|
||||
MultiMap<uint, uint> iChildMapData = new();
|
||||
Dictionary<uint, uint> iParentMapData = new();
|
||||
bool _enableLineOfSightCalc;
|
||||
bool _enableHeightCalc;
|
||||
|
||||
object LoadedModelFilesLock = new object();
|
||||
object LoadedModelFilesLock = new();
|
||||
}
|
||||
|
||||
public class ManagedModel
|
||||
|
||||
@@ -64,7 +64,7 @@ namespace Game.Collision
|
||||
if (!File.Exists(fname))
|
||||
return LoadResult.FileNotFound;
|
||||
|
||||
using (BinaryReader reader = new BinaryReader(new FileStream(fname, FileMode.Open, FileAccess.Read)))
|
||||
using (BinaryReader reader = new(new FileStream(fname, FileMode.Open, FileAccess.Read)))
|
||||
{
|
||||
var magic = reader.ReadStringFromChars(8);
|
||||
if (magic != MapConst.VMapMagic)
|
||||
@@ -120,7 +120,7 @@ namespace Game.Collision
|
||||
if (fileResult.File != null)
|
||||
{
|
||||
result = LoadResult.Success;
|
||||
using (BinaryReader reader = new BinaryReader(fileResult.File))
|
||||
using (BinaryReader reader = new(fileResult.File))
|
||||
{
|
||||
if (reader.ReadStringFromChars(8) != MapConst.VMapMagic)
|
||||
result = LoadResult.VersionMismatch;
|
||||
@@ -196,7 +196,7 @@ namespace Game.Collision
|
||||
TileFileOpenResult fileResult = OpenMapTileFile(VMapManager.VMapPath, iMapID, tileX, tileY, vm);
|
||||
if (fileResult.File != null)
|
||||
{
|
||||
using (BinaryReader reader = new BinaryReader(fileResult.File))
|
||||
using (BinaryReader reader = new(fileResult.File))
|
||||
{
|
||||
bool result = true;
|
||||
if (reader.ReadStringFromChars(8) != MapConst.VMapMagic)
|
||||
@@ -240,7 +240,7 @@ namespace Game.Collision
|
||||
|
||||
static TileFileOpenResult OpenMapTileFile(string vmapPath, uint mapID, uint tileX, uint tileY, VMapManager vm)
|
||||
{
|
||||
TileFileOpenResult result = new TileFileOpenResult();
|
||||
TileFileOpenResult result = new();
|
||||
result.Name = vmapPath + GetTileFileName(mapID, tileX, tileY);
|
||||
|
||||
if (File.Exists(result.Name))
|
||||
@@ -273,7 +273,7 @@ namespace Game.Collision
|
||||
if (!File.Exists(fullname))
|
||||
return LoadResult.FileNotFound;
|
||||
|
||||
using (BinaryReader reader = new BinaryReader(new FileStream(fullname, FileMode.Open, FileAccess.Read)))
|
||||
using (BinaryReader reader = new(new FileStream(fullname, FileMode.Open, FileAccess.Read)))
|
||||
{
|
||||
if (reader.ReadStringFromChars(8) != MapConst.VMapMagic)
|
||||
return LoadResult.VersionMismatch;
|
||||
@@ -283,7 +283,7 @@ namespace Game.Collision
|
||||
if (stream == null)
|
||||
return LoadResult.FileNotFound;
|
||||
|
||||
using (BinaryReader reader = new BinaryReader(stream))
|
||||
using (BinaryReader reader = new(stream))
|
||||
{
|
||||
if (reader.ReadStringFromChars(8) != MapConst.VMapMagic)
|
||||
return LoadResult.VersionMismatch;
|
||||
@@ -304,7 +304,7 @@ namespace Game.Collision
|
||||
rootId = 0;
|
||||
groupId = 0;
|
||||
|
||||
AreaInfoCallback intersectionCallBack = new AreaInfoCallback(iTreeValues);
|
||||
AreaInfoCallback intersectionCallBack = new(iTreeValues);
|
||||
iTree.IntersectPoint(pos, intersectionCallBack);
|
||||
if (intersectionCallBack.aInfo.result)
|
||||
{
|
||||
@@ -320,7 +320,7 @@ namespace Game.Collision
|
||||
|
||||
public bool GetLocationInfo(Vector3 pos, LocationInfo info)
|
||||
{
|
||||
LocationInfoCallback intersectionCallBack = new LocationInfoCallback(iTreeValues, info);
|
||||
LocationInfoCallback intersectionCallBack = new(iTreeValues, info);
|
||||
iTree.IntersectPoint(pos, intersectionCallBack);
|
||||
return intersectionCallBack.result;
|
||||
}
|
||||
@@ -328,8 +328,8 @@ namespace Game.Collision
|
||||
public float GetHeight(Vector3 pPos, float maxSearchDist)
|
||||
{
|
||||
float height = float.PositiveInfinity;
|
||||
Vector3 dir = new Vector3(0, 0, -1);
|
||||
Ray ray = new Ray(pPos, dir); // direction with length of 1
|
||||
Vector3 dir = new(0, 0, -1);
|
||||
Ray ray = new(pPos, dir); // direction with length of 1
|
||||
float maxDist = maxSearchDist;
|
||||
if (GetIntersectionTime(ray, ref maxDist, false, ModelIgnoreFlags.Nothing))
|
||||
height = pPos.Z - maxDist;
|
||||
@@ -339,7 +339,7 @@ namespace Game.Collision
|
||||
bool GetIntersectionTime(Ray pRay, ref float pMaxDist, bool pStopAtFirstHit, ModelIgnoreFlags ignoreFlags)
|
||||
{
|
||||
float distance = pMaxDist;
|
||||
MapRayCallback intersectionCallBack = new MapRayCallback(iTreeValues, ignoreFlags);
|
||||
MapRayCallback intersectionCallBack = new(iTreeValues, ignoreFlags);
|
||||
iTree.IntersectRay(pRay, intersectionCallBack, ref distance, pStopAtFirstHit);
|
||||
if (intersectionCallBack.DidHit())
|
||||
pMaxDist = distance;
|
||||
@@ -359,7 +359,7 @@ namespace Game.Collision
|
||||
return false;
|
||||
}
|
||||
Vector3 dir = (pPos2 - pPos1) / maxDist; // direction with length of 1
|
||||
Ray ray = new Ray(pPos1, dir);
|
||||
Ray ray = new(pPos1, dir);
|
||||
float dist = maxDist;
|
||||
if (GetIntersectionTime(ray, ref dist, false, ModelIgnoreFlags.Nothing))
|
||||
{
|
||||
@@ -403,7 +403,7 @@ namespace Game.Collision
|
||||
if (maxDist < 1e-10f)
|
||||
return true;
|
||||
// direction with length of 1
|
||||
Ray ray = new Ray(pos1, (pos2 - pos1) / maxDist);
|
||||
Ray ray = new(pos1, (pos2 - pos1) / maxDist);
|
||||
if (GetIntersectionTime(ray, ref maxDist, true, ignoreFlags))
|
||||
return false;
|
||||
|
||||
@@ -413,13 +413,13 @@ namespace Game.Collision
|
||||
public int NumLoadedTiles() { return iLoadedTiles.Count; }
|
||||
|
||||
uint iMapID;
|
||||
BIH iTree = new BIH();
|
||||
BIH iTree = new();
|
||||
ModelInstance[] iTreeValues;
|
||||
uint iNTreeValues;
|
||||
Dictionary<uint, uint> iSpawnIndices = new Dictionary<uint, uint>();
|
||||
Dictionary<uint, uint> iSpawnIndices = new();
|
||||
|
||||
Dictionary<uint, bool> iLoadedTiles = new Dictionary<uint, bool>();
|
||||
Dictionary<uint, uint> iLoadedSpawns = new Dictionary<uint, uint>();
|
||||
Dictionary<uint, bool> iLoadedTiles = new();
|
||||
Dictionary<uint, uint> iLoadedSpawns = new();
|
||||
}
|
||||
|
||||
class TileFileOpenResult
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -89,7 +89,7 @@ namespace Game.Collision
|
||||
|
||||
public static Cell ComputeCell(float fx, float fy)
|
||||
{
|
||||
Cell c = new Cell();
|
||||
Cell c = new();
|
||||
c.x = (int)(fx * (1.0f / CELL_SIZE) + (CELL_NUMBER / 2f));
|
||||
c.y = (int)(fy * (1.0f / CELL_SIZE) + (CELL_NUMBER / 2f));
|
||||
return c;
|
||||
@@ -206,7 +206,7 @@ namespace Game.Collision
|
||||
node.IntersectRay(ray, intersectCallback, ref max_dist);
|
||||
}
|
||||
|
||||
MultiMap<T, Node> memberTable = new MultiMap<T, Node>();
|
||||
MultiMap<T, Node> memberTable = new();
|
||||
Node[][] nodes = new Node[CELL_NUMBER][];
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user