More adjustments ot prevent crash issues
This commit is contained in:
parent
8768f23c4e
commit
c648a78de9
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -862,6 +862,25 @@ namespace Bfres.Structs
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//Genericate indices
|
||||||
|
//Check for rigged bones
|
||||||
|
for (int ob = 0; ob < assimp.objects.Count; ob++)
|
||||||
|
{
|
||||||
|
foreach (string NewBone in assimp.objects[ob].boneList)
|
||||||
|
{
|
||||||
|
foreach (var bones in Skeleton.bones)
|
||||||
|
{
|
||||||
|
if (bones.Text == NewBone)
|
||||||
|
{
|
||||||
|
bones.SmoothMatrixIndex += 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Skeleton.CalculateIndices();
|
||||||
|
|
||||||
if (materials.Count <= 0)
|
if (materials.Count <= 0)
|
||||||
{
|
{
|
||||||
//Force material creation if there is none present
|
//Force material creation if there is none present
|
||||||
|
@ -49,41 +49,45 @@ namespace Bfres.Structs
|
|||||||
List<ushort> RigidIndices = new List<ushort>();
|
List<ushort> RigidIndices = new List<ushort>();
|
||||||
|
|
||||||
ushort SmoothIndex = 0;
|
ushort SmoothIndex = 0;
|
||||||
ushort BoneIndex = 0;
|
|
||||||
|
|
||||||
foreach (BfresBone bn in bones)
|
foreach (BfresBone bn in bones)
|
||||||
{
|
{
|
||||||
if (Skeleton.Bones.ContainsKey(bn.Text))
|
ushort BoneIndex = 0;
|
||||||
|
foreach (var Bone in Skeleton.Bones.Values)
|
||||||
{
|
{
|
||||||
var Bone = Skeleton.Bones[bn.Text];
|
if (bn.Text == Bone.Name)
|
||||||
if (bn.UseSmoothMatrix || bn.SmoothMatrixIndex != -1)
|
|
||||||
{
|
{
|
||||||
bn.SmoothMatrixIndex = (short)SmoothIndex++;
|
if (bn.UseSmoothMatrix || bn.SmoothMatrixIndex != -1)
|
||||||
Bone.SmoothMatrixIndex = bn.SmoothMatrixIndex;
|
{
|
||||||
SmoothIndices.Add(BoneIndex);
|
bn.SmoothMatrixIndex = (short)SmoothIndex++;
|
||||||
|
Bone.SmoothMatrixIndex = bn.SmoothMatrixIndex;
|
||||||
|
SmoothIndices.Add(BoneIndex);
|
||||||
|
|
||||||
var mat = MatrixExenstion.GetMatrixInverted(bn);
|
var mat = MatrixExenstion.GetMatrixInverted(bn);
|
||||||
SmoothMatrices.Add(mat);
|
SmoothMatrices.Add(mat);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
BoneIndex++;
|
BoneIndex++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
BoneIndex = 0;
|
|
||||||
|
|
||||||
//Rigid Indices come after smooth indices. Start from the last smooth index
|
//Rigid Indices come after smooth indices. Start from the last smooth index
|
||||||
ushort RigidIndex = (ushort)(SmoothIndices.Count);
|
ushort RigidIndex = (ushort)(SmoothIndices.Count);
|
||||||
foreach (BfresBone bn in bones)
|
foreach (BfresBone bn in bones)
|
||||||
{
|
{
|
||||||
var Bone = Skeleton.Bones[bn.Text];
|
ushort BoneIndex = 0;
|
||||||
if (bn.UseRigidMatrix || bn.RigidMatrixIndex != -1)
|
foreach (var Bone in Skeleton.Bones.Values)
|
||||||
{
|
{
|
||||||
bn.RigidMatrixIndex = (short)RigidIndex++;
|
if (bn.Text == Bone.Name)
|
||||||
Bone.RigidMatrixIndex = bn.RigidMatrixIndex;
|
{
|
||||||
RigidIndices.Add(BoneIndex);
|
if (bn.UseRigidMatrix || bn.RigidMatrixIndex != -1)
|
||||||
|
{
|
||||||
|
bn.RigidMatrixIndex = (short)RigidIndex++;
|
||||||
|
Bone.RigidMatrixIndex = bn.RigidMatrixIndex;
|
||||||
|
RigidIndices.Add(BoneIndex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
BoneIndex++;
|
||||||
}
|
}
|
||||||
|
|
||||||
BoneIndex++;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//Rigid indices at the end
|
//Rigid indices at the end
|
||||||
|
Binary file not shown.
Loading…
Reference in New Issue
Block a user