Skip to content

Commit dc0d21f

Browse files
Some fixes, including an out of bounds error in ProcessVerticesWithoutWeights() and DAE skinning with only fully-weighted meshes.
1 parent b66b270 commit dc0d21f

File tree

4 files changed

+14
-5
lines changed

4 files changed

+14
-5
lines changed

SuperBMDLib/source/BMD/MAT3.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -439,7 +439,12 @@ private void LoadInitData(EndianBinaryReader reader)
439439
if ((tevSwapModeTableIndex < 0) || (tevSwapModeTableIndex > m_SwapTableBlock.Count))
440440
continue;
441441
else
442+
{
443+
if (tevSwapModeTableIndex >= m_SwapTableBlock.Count)
444+
continue;
445+
442446
mat.SwapTables[i] = m_SwapTableBlock[tevSwapModeTableIndex];
447+
}
443448
}
444449

445450
mat.FogInfo = m_FogBlock[reader.ReadInt16()];

SuperBMDLib/source/BMD/TEX1.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,12 @@ public TEX1(EndianBinaryReader reader, int offset)
4444
public TEX1(Assimp.Scene scene, Arguments args)
4545
{
4646
Textures = new List<BinaryTextureImage>();
47-
string dir_path = Path.GetDirectoryName(args.texheaders_path);
4847

4948
if (args.texheaders_path != "")
49+
{
50+
string dir_path = Path.GetDirectoryName(args.texheaders_path);
5051
LoadTexturesFromJson(args.texheaders_path, dir_path);
52+
}
5153
else
5254
LoadTexturesFromScene(scene, Path.GetDirectoryName(args.input_path));
5355
}

SuperBMDLib/source/Geometry/Shape.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ public void ProcessVerticesWithoutWeights(Mesh mesh, VertexData vertData)
7979

8080
foreach (Face face in mesh.Faces)
8181
{
82-
for (int i = 3; i > 0; i--)
82+
for (int i = 2; i > 0; i--)
8383
{
8484
Vertex vert = new Vertex();
8585

@@ -268,7 +268,7 @@ public void ProcessVerticesWithWeights(Mesh mesh, VertexData vertData, Dictionar
268268
switch (attrib)
269269
{
270270
case Enums.GXVertexAttribute.PositionMatrixIdx:
271-
int newMatrixIndex = -1;
271+
int newMatrixIndex = 0;
272272

273273
if (curWeight.WeightCount == 1)
274274
{
@@ -281,6 +281,8 @@ public void ProcessVerticesWithWeights(Mesh mesh, VertexData vertData, Dictionar
281281

282282
int envIndex = envelopes.Weights.IndexOf(curWeight);
283283
int drwIndex = partialWeight.MeshWeights.IndexOf(curWeight);
284+
if (drwIndex == -1)
285+
drwIndex = 0;
284286

285287
newMatrixIndex = drwIndex;
286288
partialWeight.Indices[drwIndex] = envIndex;

SuperBMDLib/source/Model.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -184,8 +184,8 @@ public void ExportAssImp(string fileName, string modelType, ExportSettings setti
184184
AssimpContext cont = new AssimpContext();
185185
cont.ExportFile(outScene, fileName, "collada", PostProcessSteps.ValidateDataStructure);
186186

187-
if (SkinningEnvelopes.Weights.Count == 0)
188-
return; // There's no skinning information, so we can stop here
187+
//if (SkinningEnvelopes.Weights.Count == 0)
188+
//return; // There's no skinning information, so we can stop here
189189

190190
// Now we need to add some skinning info, since AssImp doesn't do it for some bizarre reason
191191

0 commit comments

Comments
 (0)