mirror of
https://mirror.ghproxy.com/https://github.com/dexyfex/CodeWalker
synced 2026-05-14 12:44:44 +08:00
Nav mesh editing improvements
This commit is contained in:
@@ -14,6 +14,7 @@ namespace CodeWalker.GameFiles
|
||||
|
||||
public List<Vector3> Vertices { get; set; }
|
||||
public List<ushort> Indices { get; set; }
|
||||
public List<NavMeshAdjPoly> AdjPolys { get; set; }
|
||||
public List<YnvPoly> Polys { get; set; }
|
||||
|
||||
|
||||
@@ -97,6 +98,10 @@ namespace CodeWalker.GameFiles
|
||||
{
|
||||
Indices = Nav.Indices.GetFullList();
|
||||
}
|
||||
if (Nav.AdjPolys != null)
|
||||
{
|
||||
AdjPolys = Nav.AdjPolys.GetFullList();
|
||||
}
|
||||
if (Nav.Polys != null)
|
||||
{
|
||||
var polys = Nav.Polys.GetFullList();
|
||||
@@ -171,24 +176,9 @@ namespace CodeWalker.GameFiles
|
||||
{
|
||||
for (int i = 0; i < Vertices.Count; i++)
|
||||
{
|
||||
var ov = (Vertices[i] - posoffset) * aabbsizeinv;
|
||||
vertlist.Add(NavMeshVertex.Create(ov));
|
||||
vertlist.Add(NavMeshVertex.Create((Vertices[i] - posoffset) * aabbsizeinv));
|
||||
}
|
||||
}
|
||||
if (Nav.Vertices == null)
|
||||
{
|
||||
Nav.Vertices = new NavMeshList<NavMeshVertex>();
|
||||
Nav.Vertices.VFT = 1080158456;
|
||||
}
|
||||
Nav.Vertices.RebuildList(vertlist);
|
||||
|
||||
if (Nav.Indices == null)
|
||||
{
|
||||
Nav.Indices = new NavMeshList<ushort>();
|
||||
Nav.Indices.VFT = 1080158424;
|
||||
}
|
||||
Nav.Indices.RebuildList(Indices);
|
||||
|
||||
var polylist = new List<NavMeshPoly>();
|
||||
if (Polys != null)
|
||||
{
|
||||
@@ -197,20 +187,51 @@ namespace CodeWalker.GameFiles
|
||||
polylist.Add(Polys[i].RawData);
|
||||
}
|
||||
}
|
||||
if (Nav.Polys == null)
|
||||
|
||||
|
||||
if (Nav.Vertices == null)
|
||||
{
|
||||
Nav.Polys = new NavMeshList<NavMeshPoly>();
|
||||
Nav.Polys.VFT = 1080158408;
|
||||
Nav.Vertices = new NavMeshList<NavMeshVertex>();
|
||||
Nav.Vertices.VFT = 1080158456;
|
||||
}
|
||||
if (Nav.Indices == null)
|
||||
{
|
||||
Nav.Indices = new NavMeshList<ushort>();
|
||||
Nav.Indices.VFT = 1080158424;
|
||||
}
|
||||
Nav.Polys.RebuildList(polylist);
|
||||
|
||||
|
||||
if (Nav.AdjPolys == null)
|
||||
{
|
||||
Nav.AdjPolys = new NavMeshList<NavMeshAdjPoly>();
|
||||
Nav.AdjPolys.VFT = 1080158440;
|
||||
}
|
||||
//Nav.AdjPolys.RebuildList(...)
|
||||
if (Nav.Polys == null)
|
||||
{
|
||||
Nav.Polys = new NavMeshList<NavMeshPoly>();
|
||||
Nav.Polys.VFT = 1080158408;
|
||||
}
|
||||
|
||||
|
||||
Nav.Vertices.RebuildList(vertlist);
|
||||
|
||||
Nav.Indices.RebuildList(Indices);
|
||||
|
||||
Nav.AdjPolys.RebuildList(AdjPolys);
|
||||
|
||||
Nav.Polys.RebuildList(polylist);
|
||||
|
||||
|
||||
|
||||
for (int i = 0; i < Nav.Polys.ListParts.Count; i++) //reassign part id's on all the polys...
|
||||
{
|
||||
var listpart = Nav.Polys.ListParts[i];
|
||||
var partitems = listpart?.Items;
|
||||
if (partitems == null) continue;
|
||||
ushort iu = (ushort)i;
|
||||
for (int j = 0; j < partitems.Length; j++)
|
||||
{
|
||||
partitems[j].PartID = iu;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -415,6 +436,7 @@ namespace CodeWalker.GameFiles
|
||||
public ushort AreaID { get { return _RawData.AreaID; } set { _RawData.AreaID = value; } }
|
||||
public ushort PartID { get { return _RawData.PartID; } set { _RawData.PartID = value; } }
|
||||
public ushort PortalID { get { return _RawData.PortalID; } set { _RawData.PortalID = value; } }
|
||||
public byte PortalUnk { get { return _RawData.PortalUnk; } set { _RawData.PortalUnk = value; } }
|
||||
public byte Flags1 { get { return (byte)(_RawData.Unknown_00h & 0xFF); } set { _RawData.Unknown_00h = (ushort)((_RawData.Unknown_00h & 0xFF00) | (value & 0xFF)); } }
|
||||
public byte Flags2 { get { return (byte)((_RawData.Unknown_24h.Value >> 0) & 0xFF); } set { _RawData.Unknown_24h = ((_RawData.Unknown_24h.Value & 0xFFFFFF00u) | ((value & 0xFFu) << 0)); } }
|
||||
public byte Flags3 { get { return (byte)((_RawData.Unknown_24h.Value >> 9) & 0xFF); } set { _RawData.Unknown_24h = ((_RawData.Unknown_24h.Value & 0xFFFE01FFu) | ((value & 0xFFu) << 9)); } }
|
||||
@@ -452,10 +474,10 @@ namespace CodeWalker.GameFiles
|
||||
public bool B30_SlopeNorthWest { get { return (_RawData.Unknown_28h.Value & 2097152) > 0; } set { _RawData.Unknown_28h = BitUtil.UpdateBit(_RawData.Unknown_28h.Value, 21, value); } }
|
||||
public bool B31_SlopeWest { get { return (_RawData.Unknown_28h.Value & 4194304) > 0; } set { _RawData.Unknown_28h = BitUtil.UpdateBit(_RawData.Unknown_28h.Value, 22, value); } }
|
||||
public bool B32_SlopeSouthWest { get { return (_RawData.Unknown_28h.Value & 8388608) > 0; } set { _RawData.Unknown_28h = BitUtil.UpdateBit(_RawData.Unknown_28h.Value, 23, value); } }
|
||||
//public bool B33_PortalUnk1 { get { return (_RawData.PartUnk2 & 1) > 0; } }
|
||||
//public bool B34_PortalUnk2 { get { return (_RawData.PartUnk2 & 2) > 0; } }
|
||||
//public bool B35_PortalUnk3 { get { return (_RawData.PartUnk2 & 4) > 0; } }
|
||||
//public bool B36_PortalUnk4 { get { return (_RawData.PartUnk2 & 8) > 0; } }
|
||||
//public bool B33_PortalUnk1 { get { return (_RawData.PortalUnk & 1) > 0; } }
|
||||
//public bool B34_PortalUnk2 { get { return (_RawData.PortalUnk & 2) > 0; } }
|
||||
//public bool B35_PortalUnk3 { get { return (_RawData.PortalUnk & 4) > 0; } }
|
||||
//public bool B36_PortalUnk4 { get { return (_RawData.PortalUnk & 8) > 0; } }
|
||||
public byte UnkX { get { return _RawData.Unknown_28h_8a; } set { _RawData.Unknown_28h_8a = value; } }
|
||||
public byte UnkY { get { return _RawData.Unknown_28h_8b; } set { _RawData.Unknown_28h_8b = value; } }
|
||||
|
||||
@@ -520,7 +542,7 @@ namespace CodeWalker.GameFiles
|
||||
//if ((u5 & 8388608) > 0) colour.Red += 1.0f; //slope facing -X,-Y (southwest)
|
||||
//if (u5 >= 16777216) { } //other bits unused
|
||||
|
||||
var u1 = _RawData.PartUnk2;
|
||||
var u1 = _RawData.PortalUnk;
|
||||
//if ((u1 & 1) > 0) colour.Red += 1.0f; //portal - don't interact?
|
||||
//if ((u1 & 2) > 0) colour.Green += 1.0f; //portal - ladder/fence interaction?
|
||||
//if ((u1 & 4) > 0) colour.Blue += 1.0f; //portal - fence interaction / go away from?
|
||||
|
||||
@@ -356,7 +356,6 @@ namespace CodeWalker.GameFiles
|
||||
|
||||
private ResourceSystemStructBlock<uint> ListOffsetsBlock = null;
|
||||
public int ItemSize { get { return System.Runtime.InteropServices.Marshal.SizeOf<T>(); } }
|
||||
//public int BytesPerPart { get; private set; }
|
||||
|
||||
public override void Read(ResourceDataReader reader, params object[] parameters)
|
||||
{
|
||||
@@ -374,11 +373,6 @@ namespace CodeWalker.GameFiles
|
||||
ListParts = reader.ReadBlockAt<ResourceSimpleArray<NavMeshListPart<T>>>(ListPartsPointer, ListPartsCount);
|
||||
ListOffsets = reader.ReadUintsAt(ListOffsetsPointer, ListPartsCount);
|
||||
|
||||
//if (ListParts.Count > 0)
|
||||
//{
|
||||
// BytesPerPart = (int)ListParts[0].Count * ItemSize;
|
||||
//}
|
||||
|
||||
}
|
||||
|
||||
public override void Write(ResourceDataWriter writer, params object[] parameters)
|
||||
@@ -649,7 +643,7 @@ namespace CodeWalker.GameFiles
|
||||
|
||||
//public int PartUnk1 { get { return (PartFlags >> 0) & 0xF; } } //always 0
|
||||
public ushort PartID { get { return (ushort)((PartFlags >> 4) & 0xFF); } set { PartFlags = (ushort)((PartFlags & 0xF00F) | ((value & 0xFF) << 4)); } }
|
||||
public byte PartUnk2 { get { return (byte)((PartFlags >> 12) & 0xF); } set { PartFlags = (ushort)((PartFlags & 0x0FFF) | ((value & 0xF) << 12)); } }
|
||||
public byte PortalUnk { get { return (byte)((PartFlags >> 12) & 0xF); } set { PartFlags = (ushort)((PartFlags & 0x0FFF) | ((value & 0xF) << 12)); } }
|
||||
|
||||
|
||||
public ushort Unknown_28h_16 { get { return (ushort)((Unknown_28h.Value & 0xFFFF)); } set { Unknown_28h = (Unknown_28h.Value & 0xFFFF0000) | (value & 0xFFFFu); } }
|
||||
@@ -670,7 +664,7 @@ namespace CodeWalker.GameFiles
|
||||
Unknown_28h.Hex + ", " +
|
||||
//PartFlags.ToString() + ", " + //PartUnk1.ToString() + ", " +
|
||||
PartID.ToString() + ", " +
|
||||
PartUnk2.ToString() + ", " +
|
||||
PortalUnk.ToString() + ", " +
|
||||
PortalID.ToString();
|
||||
}
|
||||
}
|
||||
@@ -857,31 +851,31 @@ namespace CodeWalker.GameFiles
|
||||
|
||||
[TypeConverter(typeof(ExpandableObjectConverter))] public struct NavMeshPortal
|
||||
{
|
||||
public uint Unknown_00h { get; set; }
|
||||
public uint TypeFlags { get; set; }
|
||||
public NavMeshVertex Position1 { get; set; }
|
||||
public NavMeshVertex Position2 { get; set; }
|
||||
public ushort Unknown_10h { get; set; }
|
||||
public ushort Unknown_12h { get; set; }
|
||||
public ushort Unknown_14h { get; set; }
|
||||
public ushort Unknown_16h { get; set; }
|
||||
public ushort Unknown_18h { get; set; }
|
||||
public ushort Unknown_1Ah { get; set; }
|
||||
//public NavMeshAABB AABB { get; set; }
|
||||
public ushort PolyID1a { get; set; }
|
||||
public ushort PolyID1b { get; set; }
|
||||
public ushort PolyID2a { get; set; }
|
||||
public ushort PolyID2b { get; set; }
|
||||
public uint AreaFlags { get; set; }
|
||||
|
||||
public uint Type1 { get { return Unknown_00h & 0xFF; } }
|
||||
public uint Type2 { get { return (Unknown_00h >> 8) & 0xF; } }
|
||||
public uint Type3 { get { return (Unknown_00h >> 12) & 0xF; } }
|
||||
public uint Type4 { get { return (Unknown_00h >> 16) & 0xFFFF; } }
|
||||
public uint Type1 { get { return TypeFlags & 0xFF; } }
|
||||
public uint Type2 { get { return (TypeFlags >> 8) & 0xF; } }
|
||||
public uint Type3 { get { return (TypeFlags >> 12) & 0xF; } }
|
||||
public uint Type4 { get { return (TypeFlags >> 16) & 0xFFFF; } }
|
||||
|
||||
public ushort AreaID1 { get { return (ushort)(AreaFlags & 0x3FFF); } }
|
||||
public ushort AreaID2 { get { return (ushort)((AreaFlags >> 14) & 0x3FFF); } }
|
||||
public byte AreaUnk { get { return (byte)((AreaFlags >> 28) & 0xF); } }
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return //Unknown_00h.ToString() + ", " + Unknown_01h.ToString() + ", " + Unknown_02h.ToString() + ", " +
|
||||
return AreaID1.ToString() + ", " + AreaID2.ToString() + ", " + AreaUnk.ToString() + ", " +
|
||||
PolyID1a.ToString() + ", " + PolyID1b.ToString() + ", " +
|
||||
PolyID2a.ToString() + ", " + PolyID2b.ToString() + ", " +
|
||||
Type1.ToString() + ", " + Type2.ToString() + ", " + Type3.ToString() + ", " + Type4.ToString() + ", " +
|
||||
Position1.ToString() + ", " + Position2.ToString() + ", " +
|
||||
Unknown_10h.ToString() + ", " + Unknown_12h.ToString() + ", " +
|
||||
Unknown_14h.ToString() + ", " + Unknown_16h.ToString() + ", " +
|
||||
Unknown_18h.ToString() + ", " + Unknown_1Ah.ToString();
|
||||
//AABB.ToString();
|
||||
"(" + Position1.ToString() + " | " + Position2.ToString() + ")";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user