mirror of
https://mirror.ghproxy.com/https://github.com/dexyfex/CodeWalker
synced 2026-05-14 08:34:44 +08:00
Import scenario chain CSV, PathBVH overflow bug fix.
This commit is contained in:
@@ -632,7 +632,7 @@ namespace CodeWalker.GameFiles
|
||||
|
||||
public void BuildBVH()
|
||||
{
|
||||
BVH = new PathBVH(Nodes, 10);
|
||||
BVH = new PathBVH(Nodes, 10, 10);
|
||||
}
|
||||
|
||||
|
||||
@@ -1217,6 +1217,8 @@ namespace CodeWalker.GameFiles
|
||||
|
||||
public class PathBVHNode
|
||||
{
|
||||
public int Depth;
|
||||
public int MaxDepth;
|
||||
public int Threshold;
|
||||
public List<BasePathNode> Nodes;
|
||||
public BoundingBox Box;
|
||||
@@ -1243,7 +1245,7 @@ namespace CodeWalker.GameFiles
|
||||
|
||||
public void Build()
|
||||
{
|
||||
if ((Nodes == null) || (Nodes.Count <= Threshold)) return;
|
||||
if ((Nodes == null) || (Nodes.Count <= Threshold) || (Depth >= MaxDepth)) return;
|
||||
|
||||
Vector3 avgsum = Vector3.Zero;
|
||||
foreach (var node in Nodes)
|
||||
@@ -1287,14 +1289,19 @@ namespace CodeWalker.GameFiles
|
||||
else l2.Add(node);
|
||||
}
|
||||
|
||||
var cdepth = Depth + 1;
|
||||
|
||||
Node1 = new PathBVHNode();
|
||||
Node1.Depth = cdepth;
|
||||
Node1.MaxDepth = MaxDepth;
|
||||
Node1.Threshold = Threshold;
|
||||
Node1.Nodes = new List<BasePathNode>(l1);
|
||||
Node1.CalcBounds();
|
||||
Node1.Build();
|
||||
|
||||
Node2 = new PathBVHNode();
|
||||
Node2.Depth = cdepth;
|
||||
Node2.MaxDepth = MaxDepth;
|
||||
Node2.Threshold = Threshold;
|
||||
Node2.Nodes = new List<BasePathNode>(l2);
|
||||
Node2.CalcBounds();
|
||||
@@ -1317,9 +1324,10 @@ namespace CodeWalker.GameFiles
|
||||
public class PathBVH : PathBVHNode
|
||||
{
|
||||
|
||||
public PathBVH(IEnumerable<BasePathNode> nodes, int threshold)
|
||||
public PathBVH(IEnumerable<BasePathNode> nodes, int threshold, int maxdepth)
|
||||
{
|
||||
Threshold = threshold;
|
||||
MaxDepth = maxdepth;
|
||||
Nodes = (nodes != null) ? new List<BasePathNode>(nodes) : new List<BasePathNode>();
|
||||
CalcBounds();
|
||||
Build();
|
||||
|
||||
@@ -3374,6 +3374,10 @@ namespace CodeWalker.GameFiles
|
||||
vfxPedInfos = 1918175602,
|
||||
|
||||
|
||||
CPedModelInfo__InitData = 3949383814,
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -511,17 +511,17 @@ namespace CodeWalker.GameFiles
|
||||
WriteArrayNode(sb, cind, cont, blockId, offset, entry, structInfo, ename);
|
||||
|
||||
break;
|
||||
case PsoDataType.Boolean:
|
||||
case PsoDataType.Bool:
|
||||
var boolVal = BitConverter.ToBoolean(data, eoffset);
|
||||
ValueTag(sb, cind, ename, boolVal?"true":"false");
|
||||
break;
|
||||
case PsoDataType.Byte1: //was LONG_01h //signed byte?
|
||||
case PsoDataType.SByte: //was LONG_01h //signed byte?
|
||||
//var long1Val = MetaTypes.SwapBytes(BitConverter.ToUInt64(data, eoffset));
|
||||
//ValueTag(sb, cind, ename, long1Val.ToString());
|
||||
var byte1Val = (sbyte)data[eoffset];
|
||||
ValueTag(sb, cind, ename, byte1Val.ToString());
|
||||
break;
|
||||
case PsoDataType.Byte2:
|
||||
case PsoDataType.UByte:
|
||||
var byte2Val = data[eoffset];
|
||||
ValueTag(sb, cind, ename, byte2Val.ToString());
|
||||
break;
|
||||
@@ -614,7 +614,7 @@ namespace CodeWalker.GameFiles
|
||||
var v3a = MetaTypes.SwapBytes(MetaTypes.ConvertData<Vector3>(data, eoffset));
|
||||
SelfClosingTag(sb, cind, ename + " x=\"" + FloatUtil.ToString(v3a.X) + "\" y=\"" + FloatUtil.ToString(v3a.Y) + "\" z=\"" + FloatUtil.ToString(v3a.Z) + "\"");
|
||||
break;
|
||||
case PsoDataType.Float3b: //TODO: check this! //...why are there 3 different types of float3?
|
||||
case PsoDataType.Float4a: //TODO: check this! //...why are there 3 different types of float3?
|
||||
var v3b = MetaTypes.SwapBytes(MetaTypes.ConvertData<Vector3>(data, eoffset));
|
||||
SelfClosingTag(sb, cind, ename + " x=\"" + FloatUtil.ToString(v3b.X) + "\" y=\"" + FloatUtil.ToString(v3b.Y) + "\" z=\"" + FloatUtil.ToString(v3b.Z) + "\"");
|
||||
break;
|
||||
@@ -622,11 +622,11 @@ namespace CodeWalker.GameFiles
|
||||
var v4 = MetaTypes.SwapBytes(MetaTypes.ConvertData<Vector4>(data, eoffset));
|
||||
SelfClosingTag(sb, cind, ename + " x=\"" + FloatUtil.ToString(v4.X) + "\" y=\"" + FloatUtil.ToString(v4.Y) + "\" z=\"" + FloatUtil.ToString(v4.Z) + "\" w=\"" + FloatUtil.ToString(v4.W) + "\"");
|
||||
break;
|
||||
case PsoDataType.INT_05h: //TODO: convert hashes?
|
||||
case PsoDataType.SInt: //TODO: convert hashes?
|
||||
var int5Val = MetaTypes.SwapBytes(BitConverter.ToInt32(data, eoffset));
|
||||
ValueTag(sb, cind, ename, int5Val.ToString());
|
||||
break;
|
||||
case PsoDataType.Integer:
|
||||
case PsoDataType.UInt:
|
||||
switch (entry.Unk_5h)
|
||||
{
|
||||
default:
|
||||
@@ -642,7 +642,7 @@ namespace CodeWalker.GameFiles
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case PsoDataType.LONG_20h:
|
||||
case PsoDataType.Long:
|
||||
var long2Val = MetaTypes.SwapBytes(BitConverter.ToUInt64(data, eoffset));
|
||||
ValueTag(sb, cind, ename, long2Val.ToString());
|
||||
break;
|
||||
@@ -651,15 +651,15 @@ namespace CodeWalker.GameFiles
|
||||
WriteMapNode(sb, indent, cont, eoffset, entry, structInfo, ename);
|
||||
|
||||
break;
|
||||
case PsoDataType.SHORT_03h:
|
||||
case PsoDataType.SShort:
|
||||
var short3Val = (short)MetaTypes.SwapBytes(BitConverter.ToUInt16(data, eoffset));
|
||||
ValueTag(sb, cind, ename, short3Val.ToString());
|
||||
break;
|
||||
case PsoDataType.SHORT_04h:
|
||||
case PsoDataType.UShort:
|
||||
var short4Val = MetaTypes.SwapBytes(BitConverter.ToUInt16(data, eoffset));
|
||||
ValueTag(sb, cind, ename, short4Val.ToString());
|
||||
break;
|
||||
case PsoDataType.SHORT_1Eh://half float?
|
||||
case PsoDataType.HFloat://half float?
|
||||
var short1EVal = MetaTypes.SwapBytes(BitConverter.ToUInt16(data, eoffset));
|
||||
ValueTag(sb, cind, ename, short1EVal.ToString());
|
||||
break;
|
||||
@@ -896,7 +896,7 @@ namespace CodeWalker.GameFiles
|
||||
var v4Arr = MetaTypes.ConvertDataArray<Vector4>(data, eoffset, (int)aCount);
|
||||
WriteRawArray(sb, v4Arr, indent, ename, "Vector3", FormatVector4SwapXYZOnly, 1);
|
||||
break;
|
||||
case PsoDataType.Byte2:
|
||||
case PsoDataType.UByte:
|
||||
var barr = new byte[aCount];
|
||||
if (aCount > 0)
|
||||
{
|
||||
@@ -906,7 +906,7 @@ namespace CodeWalker.GameFiles
|
||||
}
|
||||
WriteRawArray(sb, barr, indent, ename, "byte");
|
||||
break;
|
||||
case PsoDataType.Boolean:
|
||||
case PsoDataType.Bool:
|
||||
var barr2 = new byte[aCount];
|
||||
if (aCount > 0)
|
||||
{
|
||||
@@ -922,17 +922,17 @@ namespace CodeWalker.GameFiles
|
||||
var floatArr = PsoTypes.GetFloatArray(cont.Pso, arrFloat);
|
||||
WriteRawArray(sb, floatArr, indent, ename, "float");
|
||||
break;
|
||||
case PsoDataType.SHORT_04h:
|
||||
case PsoDataType.UShort:
|
||||
var arrShort = MetaTypes.ConvertData<Array_Structure>(data, eoffset);
|
||||
arrShort.SwapEnd();
|
||||
var shortArr = PsoTypes.GetUShortArray(cont.Pso, arrShort);
|
||||
WriteRawArray(sb, shortArr, indent, ename, "ushort");
|
||||
break;
|
||||
case PsoDataType.Integer:
|
||||
case PsoDataType.UInt:
|
||||
var intArr = MetaTypes.ConvertDataArray<int>(data, eoffset, (int)aCount);
|
||||
WriteRawArray(sb, intArr, indent, ename, "int");
|
||||
break;
|
||||
case PsoDataType.INT_05h:
|
||||
case PsoDataType.SInt:
|
||||
var arrUint2 = MetaTypes.ConvertData<Array_uint>(data, eoffset);
|
||||
arrUint2.SwapEnd();
|
||||
var intArr2 = PsoTypes.GetUintArray(cont.Pso, arrUint2);
|
||||
|
||||
+20
-72
@@ -49,35 +49,13 @@ namespace CodeWalker.GameFiles
|
||||
|
||||
public enum PsoDataType : byte
|
||||
{
|
||||
//BYTE_00h = 0x00,
|
||||
//LONG_01h = 0x01,
|
||||
//BYTE_02h = 0x02,
|
||||
//SHORT_03h = 0x03,
|
||||
//SHORT_04h = 0x04,
|
||||
//INT_05h = 0x05,
|
||||
//INT_06h = 0x06,
|
||||
//Float = 0x07,
|
||||
//LONG_08h = 0x08,
|
||||
//TYPE_09h = 0x09,
|
||||
//TYPE_0Ah = 0x0a,
|
||||
//INT_0Bh = 0x0b, //Hash? Name
|
||||
//Structure = 0x0c,
|
||||
//Array = 0x0d,
|
||||
//BYTE_ENUM_VALUE = 0x0e,
|
||||
//SHORT_0Fh = 0x0f, //short flags
|
||||
//TYPE_10h = 0x10,
|
||||
//TYPE_14h = 0x14,
|
||||
//Vector4 = 0x15,
|
||||
//SHORT_1Eh = 0x1e,
|
||||
//LONG_20h = 0x20
|
||||
|
||||
Boolean = 0x00,
|
||||
Byte1 = 0x01, //signed byte..
|
||||
Byte2 = 0x02,
|
||||
SHORT_03h = 0x03, //signed short?
|
||||
SHORT_04h = 0x04,
|
||||
INT_05h = 0x05, //signed int?
|
||||
Integer = 0x06, //...unsigned?
|
||||
Bool = 0x00,
|
||||
SByte = 0x01,
|
||||
UByte = 0x02,
|
||||
SShort = 0x03,
|
||||
UShort = 0x04,
|
||||
SInt = 0x05,
|
||||
UInt = 0x06,
|
||||
Float = 0x07,
|
||||
Float2 = 0x08,
|
||||
Float3 = 0x09,
|
||||
@@ -89,69 +67,39 @@ namespace CodeWalker.GameFiles
|
||||
Flags = 0x0f,
|
||||
Map = 0x10,
|
||||
Float3a = 0x14,
|
||||
Float3b = 0x15,
|
||||
SHORT_1Eh = 0x1e,
|
||||
LONG_20h = 0x20
|
||||
|
||||
Float4a = 0x15,
|
||||
HFloat = 0x1e,
|
||||
Long = 0x20,
|
||||
}
|
||||
public static class PsoDataTypes
|
||||
{
|
||||
public static string GetCSharpTypeName(PsoDataType t)
|
||||
{
|
||||
//MetaStructureEntryDataType mdt = (MetaStructureEntryDataType)t;
|
||||
switch (t)
|
||||
{
|
||||
case PsoDataType.Boolean: return "bool";
|
||||
case PsoDataType.Byte1: return "sbyte"; //was LONG_01h.. why?
|
||||
case PsoDataType.Byte2: return "byte";
|
||||
case PsoDataType.SHORT_03h: return "short";
|
||||
case PsoDataType.SHORT_04h: return "short";
|
||||
case PsoDataType.INT_05h: return "int";
|
||||
case PsoDataType.Integer: return "int";
|
||||
case PsoDataType.Bool: return "bool";
|
||||
case PsoDataType.SByte: return "sbyte";
|
||||
case PsoDataType.UByte: return "byte";
|
||||
case PsoDataType.SShort: return "short";
|
||||
case PsoDataType.UShort: return "ushort";
|
||||
case PsoDataType.SInt: return "int";
|
||||
case PsoDataType.UInt: return "int";
|
||||
case PsoDataType.Float: return "float";
|
||||
case PsoDataType.Float2: return "long";
|
||||
case PsoDataType.String: return "uint"; //hash? NEEDS WORK?
|
||||
case PsoDataType.Enum: return "byte";
|
||||
case PsoDataType.Flags: return "short";
|
||||
case PsoDataType.SHORT_1Eh: return "short";
|
||||
case PsoDataType.LONG_20h: return "long";
|
||||
case PsoDataType.HFloat: return "short";
|
||||
case PsoDataType.Long: return "long";
|
||||
case PsoDataType.Float3:
|
||||
case PsoDataType.Float4:
|
||||
case PsoDataType.Map:
|
||||
case PsoDataType.Float3a:
|
||||
case PsoDataType.Float3b:
|
||||
case PsoDataType.Float4a:
|
||||
case PsoDataType.Structure:
|
||||
case PsoDataType.Array:
|
||||
default:
|
||||
return t.ToString();
|
||||
|
||||
//case MetaStructureEntryDataType.Boolean: return "bool";
|
||||
//case MetaStructureEntryDataType.SignedByte: return "sbyte";
|
||||
//case MetaStructureEntryDataType.UnsignedByte: return "byte";
|
||||
//case MetaStructureEntryDataType.SignedShort: return "short";
|
||||
//case MetaStructureEntryDataType.UnsignedShort: return "ushort";
|
||||
//case MetaStructureEntryDataType.SignedInt: return "int";
|
||||
//case MetaStructureEntryDataType.UnsignedInt: return "uint";
|
||||
//case MetaStructureEntryDataType.Float: return "float";
|
||||
//case MetaStructureEntryDataType.Float_XYZ: return "Vector3";
|
||||
//case MetaStructureEntryDataType.Float_XYZW: return "Vector4";
|
||||
|
||||
//case MetaStructureEntryDataType.Hash: return "uint"; //uint hashes...
|
||||
//case MetaStructureEntryDataType.ByteEnum: return "byte"; //convert to enum later..
|
||||
//case MetaStructureEntryDataType.IntEnum: return "int";
|
||||
//case MetaStructureEntryDataType.ShortFlags: return "short";
|
||||
//case MetaStructureEntryDataType.IntFlags1: return "int";
|
||||
//case MetaStructureEntryDataType.IntFlags2: return "int";
|
||||
|
||||
//case MetaStructureEntryDataType.Array:
|
||||
//case MetaStructureEntryDataType.ArrayOfChars:
|
||||
//case MetaStructureEntryDataType.ArrayOfBytes:
|
||||
//case MetaStructureEntryDataType.DataBlockPointer:
|
||||
//case MetaStructureEntryDataType.CharPointer:
|
||||
//case MetaStructureEntryDataType.StructurePointer:
|
||||
//case MetaStructureEntryDataType.Structure:
|
||||
//default:
|
||||
// return t.ToString();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user