diff --git a/GameFiles/FileTypes/CacheDatFile.cs b/GameFiles/FileTypes/CacheDatFile.cs index 5d3e2c6..a42b209 100644 --- a/GameFiles/FileTypes/CacheDatFile.cs +++ b/GameFiles/FileTypes/CacheDatFile.cs @@ -360,11 +360,11 @@ namespace CodeWalker.GameFiles public Quaternion Orientation { get; set; } public Vector3 BBMin { get; set; } public Vector3 BBMax { get; set; } - public uint Unk11 { get; set; } + public float Unk11 { get; set; } public uint Unk12 { get; set; } - public uint Unk13 { get; set; } + public float Unk13 { get; set; } public uint Unk14 { get; set; } - public uint Unk15 { get; set; } + public float Unk15 { get; set; } public uint Unk16 { get; set; } public uint Unk17 { get; set; } public uint Unk18 { get; set; } @@ -380,11 +380,11 @@ namespace CodeWalker.GameFiles Orientation = new Quaternion(br.ReadSingle(), br.ReadSingle(), br.ReadSingle(), br.ReadSingle()); BBMin = new Vector3(br.ReadSingle(), br.ReadSingle(), br.ReadSingle()); BBMax = new Vector3(br.ReadSingle(), br.ReadSingle(), br.ReadSingle()); - Unk11 = br.ReadUInt32();//could be float + Unk11 = br.ReadSingle(); Unk12 = br.ReadUInt32(); - Unk13 = br.ReadUInt32();//could be float + Unk13 = br.ReadSingle(); Unk14 = br.ReadUInt32(); - Unk15 = br.ReadUInt32();//could be float + Unk15 = br.ReadSingle(); Unk16 = br.ReadUInt32(); Unk17 = br.ReadUInt32();//could be float Unk18 = br.ReadUInt32(); diff --git a/World/Space.cs b/World/Space.cs index 78d069d..7657d0b 100644 --- a/World/Space.cs +++ b/World/Space.cs @@ -22,6 +22,8 @@ namespace CodeWalker.World private Dictionary visibleBoundsDict = new Dictionary(); private Dictionary interiorLookup = new Dictionary(); + private Dictionary interiorManifest = new Dictionary(); + private Dictionary interiorProxies = new Dictionary(); private Dictionary dataGroupDict = new Dictionary(); private Dictionary nodedict = new Dictionary(); private Dictionary boundsdict = new Dictionary(); @@ -79,6 +81,7 @@ namespace CodeWalker.World private void InitManifestData() { interiorLookup.Clear(); + interiorManifest.Clear(); ymaptimes.Clear(); ymapweathertypes.Clear(); dataGroupDict.Clear(); @@ -91,13 +94,18 @@ namespace CodeWalker.World { foreach (var interior in manifest.Interiors) { + var intname = interior.Interior.Name; + if (interiorManifest.ContainsKey(intname)) + { } + interiorManifest[intname] = interior; + if (interior.Bounds != null) { foreach (var intbound in interior.Bounds) { if (interiorLookup.ContainsKey(intbound)) { }//updates can hit here - interiorLookup[intbound] = interior.Interior.Name; + interiorLookup[intbound] = intname; } } else @@ -163,6 +171,7 @@ namespace CodeWalker.World List intlist = new List(); boundsdict = new Dictionary(); usedboundsdict = new Dictionary(); + interiorProxies = new Dictionary(); Dictionary filedates = new Dictionary(); Dictionary filedates2 = new Dictionary(); @@ -217,6 +226,10 @@ namespace CodeWalker.World { //these might need to go into the grid. which grid..? //but might need to map back to the bounds store... this has more info though! + SpaceBoundsKey key = new SpaceBoundsKey(intprx.Name, intprx.Position); + if (interiorProxies.ContainsKey(key)) + { }//updates/dlc hit here + interiorProxies[key] = intprx; } foreach (var item in cache.AllBoundsStoreItems) @@ -305,15 +318,15 @@ namespace CodeWalker.World Grid = new SpaceGrid(); - List containers = new List(); - List critnodes = new List(); - List hdnodes = new List(); - List lodnodes = new List(); - List strmnodes = new List(); - List intnodes = new List(); - List occlnodes = new List(); - List grassnodes = new List(); - List lodlightsnodes = new List(); + //List containers = new List(); + //List critnodes = new List(); + //List hdnodes = new List(); + //List lodnodes = new List(); + //List strmnodes = new List(); + //List intnodes = new List(); + //List occlnodes = new List(); + //List grassnodes = new List(); + //List lodlightsnodes = new List(); foreach (var node in nodedict.Values) { @@ -321,51 +334,51 @@ namespace CodeWalker.World byte t = (byte)(node.ContentFlags & 0xFF); switch (node.ContentFlags)// t) { - case 0: - addtogrid = true; //for mods/unused stuff? could be interesting. + case 0: //for mods/unused stuff? could be interesting. + addtogrid = true; break; case 16://"container" node? - containers.Add(node); + //containers.Add(node); break; case 18: - case 82: - hdnodes.Add(node); + case 82: //HD nodes + //hdnodes.Add(node); addtogrid = true; break; case 1: - case 65: - strmnodes.Add(node); + case 65: //Stream nodes + //strmnodes.Add(node); addtogrid = true; break; case 513: - case 577: - critnodes.Add(node); + case 577: //critical nodes + //critnodes.Add(node); addtogrid = true; break; case 9: - case 73: - intnodes.Add(node); + case 73: //interior nodes + //intnodes.Add(node); addtogrid = true; break; case 2: case 4: case 20: case 66: - case 514: - lodnodes.Add(node); + case 514: //LOD nodes + //lodnodes.Add(node); addtogrid = true; break; case 128: - case 256: - lodlightsnodes.Add(node); + case 256: //LOD lights nodes + //lodlightsnodes.Add(node); addtogrid = true; break; - case 32: - occlnodes.Add(node); + case 32: //occlusion nodes + //occlnodes.Add(node); addtogrid = true; break; - case 1088: - grassnodes.Add(node); + case 1088: //grass nodes + //grassnodes.Add(node); addtogrid = true; break; default: @@ -387,6 +400,11 @@ namespace CodeWalker.World Grid.AddBounds(item); } + foreach (var intprx in interiorProxies.Values) + { + Grid.AddInterior(intprx); + } + } @@ -441,13 +459,14 @@ namespace CodeWalker.World AllYnds[fnhash] = cell.Ynd; - if (cell.Ynd == null) continue; - if (cell.Ynd.NodeDictionary == null) continue; - if (cell.Ynd.NodeDictionary.Nodes == null) continue; - var na = cell.Ynd.NodeDictionary.Nodes; #region node flags test + //if (cell.Ynd == null) continue; + //if (cell.Ynd.NodeDictionary == null) continue; + //if (cell.Ynd.NodeDictionary.Nodes == null) continue; + //var na = cell.Ynd.NodeDictionary.Nodes; + //for (int i = 0; i < na.Length; i++) //{ // var node = na[i]; @@ -1727,6 +1746,11 @@ namespace CodeWalker.World public int MaxNodesInCell = 0; //biggest number of nodes added to a single cell private SpaceGridCell DensestNodeCell = null; + public int TotalInteriorCount = 0; + public int TotalInteriorRefCount = 0; + public int MaxInteriorsInCell = 0; + private SpaceGridCell DensestInteriorCell = null; + public SpaceGridCell[,] Cells { get; set; } = new SpaceGridCell[CellCount, CellCount]; @@ -1835,12 +1859,38 @@ namespace CodeWalker.World TotalNodeCount++; } + public void AddInterior(CInteriorProxy intprx) + { + Vector2I min = GetCellPos(intprx.BBMin); + Vector2I max = GetCellPos(intprx.BBMax); + + int cellcount = 0; + for (int x = min.X; x <= max.X; x++) + { + for (int y = min.Y; y <= max.Y; y++) + { + var cell = GetCell(new Vector2I(x, y)); + cell.AddInterior(intprx); + TotalInteriorRefCount++; + if (cell.InteriorList.Count > MaxInteriorsInCell) + { + MaxInteriorsInCell = cell.InteriorList.Count; + DensestInteriorCell = cell; + } + cellcount++; + } + } + if (cellcount == 0) + { } + + TotalInteriorCount++; + } } public class SpaceGridCell { public List NodesList; public List BoundsList; - + public List InteriorList; public void AddNode(MapDataStoreNode node) { @@ -1866,6 +1916,15 @@ namespace CodeWalker.World BoundsList.Remove(item); } } + + public void AddInterior(CInteriorProxy intprx) + { + if (InteriorList == null) + { + InteriorList = new List(5); + } + InteriorList.Add(intprx); + } } public struct SpaceBoundsKey {