Skip to content

Commit

Permalink
fix(statics): fix statics not working in post-bl
Browse files Browse the repository at this point in the history
  • Loading branch information
MontagueM committed Aug 14, 2023
1 parent 222f39d commit 2e2e01f
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 30 deletions.
2 changes: 1 addition & 1 deletion Tiger/Schema/Static/StaticMeshData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -151,8 +151,8 @@ private List<StaticPart> GenerateParts(Dictionary<int, SStaticMeshPart> staticPa
if (materialMap.ContainsKey(i))
{
StaticPart part = new StaticPart(staticPartEntry);
part.GetAllData(mesh, parent);
part.Material = materialMap[i];
part.GetAllData(mesh, parent);
parts.Add(part);
}
}
Expand Down
65 changes: 36 additions & 29 deletions Tiger/Schema/Static/StaticPart.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,40 +40,47 @@ public void GetAllData(SStaticMeshBuffers buffers, SStaticMesh container)
VertexIndices = uniqueVertexIndices.ToList();
// Have to call it like this b/c we don't know the format of the vertex data here

List<InputSignature> inputSignatures = Material.VertexShader.InputSignatures;
int b0Stride = buffers.Vertices0.TagData.Stride;
int b1Stride = buffers.Vertices1?.TagData.Stride ?? 0;
List<InputSignature> inputSignatures0 = new();
List<InputSignature> inputSignatures1 = new();
int stride = 0;
foreach (InputSignature inputSignature in inputSignatures)
if (Strategy.CurrentStrategy <= TigerStrategy.DESTINY2_SHADOWKEEP_2999)
{
if (stride < b0Stride)
List<InputSignature> inputSignatures = Material.VertexShader.InputSignatures;
int b0Stride = buffers.Vertices0.TagData.Stride;
int b1Stride = buffers.Vertices1?.TagData.Stride ?? 0;
List<InputSignature> inputSignatures0 = new();
List<InputSignature> inputSignatures1 = new();
int stride = 0;
foreach (InputSignature inputSignature in inputSignatures)
{
inputSignatures0.Add(inputSignature);
}
else
{
inputSignatures1.Add(inputSignature);
if (stride < b0Stride)
{
inputSignatures0.Add(inputSignature);
}
else
{
inputSignatures1.Add(inputSignature);
}

if (inputSignature.Semantic == InputSemantic.Colour)
{
stride += inputSignature.GetNumberOfComponents() * 1; // 1 byte per component
}
else
{
stride += inputSignature.GetNumberOfComponents() * 2; // 2 bytes per component
}
// todo entities can have 4 bytes per component, although its isolated for cloth so we can probably account for it
}
Debug.Assert(b0Stride + b1Stride == stride);

if (inputSignature.Semantic == InputSemantic.Colour)
{
stride += inputSignature.GetNumberOfComponents() * 1; // 1 byte per component
}
else
{
stride += inputSignature.GetNumberOfComponents() * 2; // 2 bytes per component
}
// todo entities can have 4 bytes per component, although its isolated for cloth so we can probably account for it
Log.Debug($"Reading vertex buffers {buffers.Vertices0.Hash}/{b0Stride}/{inputSignatures0.DebugString()} and {buffers.Vertices1?.Hash}/{b1Stride}/{inputSignatures1.DebugString()}");
buffers.Vertices0.ReadVertexDataSignatures(this, uniqueVertexIndices, inputSignatures0);
buffers.Vertices1?.ReadVertexDataSignatures(this, uniqueVertexIndices, inputSignatures1);
}
else
{
buffers.Vertices0.ReadVertexData(this, uniqueVertexIndices);
buffers.Vertices1?.ReadVertexData(this, uniqueVertexIndices);
buffers.Vertices2?.ReadVertexData(this, uniqueVertexIndices);
}
Debug.Assert(b0Stride + b1Stride == stride);

Log.Debug($"Reading vertex buffers {buffers.Vertices0.Hash}/{b0Stride}/{inputSignatures0.DebugString()} and {buffers.Vertices1?.Hash}/{b1Stride}/{inputSignatures1.DebugString()}");
buffers.Vertices0.ReadVertexDataSignatures(this, uniqueVertexIndices, inputSignatures0);
buffers.Vertices1?.ReadVertexDataSignatures(this, uniqueVertexIndices, inputSignatures1);

// todo wait what happened to the wq stuff? they have vertices2 no?

Debug.Assert(VertexPositions.Count == VertexTexcoords0.Count && VertexPositions.Count == VertexNormals.Count);

Expand Down
5 changes: 5 additions & 0 deletions Tiger/Schema/Static/Terrain.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ public Terrain(FileHash hash) : base(hash)
// To test use edz.strike_hmyn and alleys_a adf6ae80
public void LoadIntoFbxScene(FbxHandler fbxHandler, string saveDirectory, bool bSaveShaders, D2Class_7D6C8080 parentResource, bool exportStatic = false)
{
// todo fix terrain
if (Strategy.CurrentStrategy <= TigerStrategy.DESTINY2_SHADOWKEEP_2999)
{
return;
}
// Directory.CreateDirectory(saveDirectory + "/Textures/Terrain/");
// Directory.CreateDirectory(saveDirectory + "/Shaders/Terrain/");

Expand Down

0 comments on commit 2e2e01f

Please sign in to comment.