mirror of
https://github.com/KillzXGaming/Switch-Toolbox
synced 2024-11-16 01:37:55 +00:00
Calculate rigid indices accurately
This commit is contained in:
parent
00362747fc
commit
53e64e1288
6 changed files with 15 additions and 9 deletions
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -58,7 +58,6 @@ namespace FirstPlugin
|
||||||
List<ushort> RigidIndices = new List<ushort>();
|
List<ushort> RigidIndices = new List<ushort>();
|
||||||
|
|
||||||
ushort SmoothIndex = 0;
|
ushort SmoothIndex = 0;
|
||||||
ushort RigidIndex = 0;
|
|
||||||
ushort BoneIndex = 0;
|
ushort BoneIndex = 0;
|
||||||
|
|
||||||
foreach (BfresBone bn in fmdl.Skeleton.bones)
|
foreach (BfresBone bn in fmdl.Skeleton.bones)
|
||||||
|
@ -66,12 +65,6 @@ namespace FirstPlugin
|
||||||
if (model.Skeleton.Bones.ContainsKey(bn.Text))
|
if (model.Skeleton.Bones.ContainsKey(bn.Text))
|
||||||
{
|
{
|
||||||
var Bone = model.Skeleton.Bones[bn.Text];
|
var Bone = model.Skeleton.Bones[bn.Text];
|
||||||
if (bn.UseRigidMatrix || bn.RigidMatrixIndex != -1)
|
|
||||||
{
|
|
||||||
bn.RigidMatrixIndex = (short)RigidIndex++;
|
|
||||||
Bone.RigidMatrixIndex = bn.RigidMatrixIndex;
|
|
||||||
RigidIndices.Add(BoneIndex);
|
|
||||||
}
|
|
||||||
if (bn.UseSmoothMatrix || bn.SmoothMatrixIndex != -1)
|
if (bn.UseSmoothMatrix || bn.SmoothMatrixIndex != -1)
|
||||||
{
|
{
|
||||||
bn.SmoothMatrixIndex = (short)SmoothIndex++;
|
bn.SmoothMatrixIndex = (short)SmoothIndex++;
|
||||||
|
@ -85,8 +78,21 @@ namespace FirstPlugin
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//Rigid indices at the end
|
//Rigid Indices come after smooth indices. Start from the last smooth index
|
||||||
var AllIndices = SmoothIndices.Concat(RigidIndices).ToList();
|
ushort RigidIndex = (ushort)(SmoothIndices.Count);
|
||||||
|
foreach (BfresBone bn in fmdl.Skeleton.bones)
|
||||||
|
{
|
||||||
|
var Bone = model.Skeleton.Bones[bn.Text];
|
||||||
|
if (bn.UseRigidMatrix || bn.RigidMatrixIndex != -1)
|
||||||
|
{
|
||||||
|
bn.RigidMatrixIndex = (short)RigidIndex++;
|
||||||
|
Bone.RigidMatrixIndex = bn.RigidMatrixIndex;
|
||||||
|
RigidIndices.Add(BoneIndex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//Rigid indices at the end
|
||||||
|
var AllIndices = SmoothIndices.Concat(RigidIndices).ToList();
|
||||||
model.Skeleton.MatrixToBoneList = AllIndices.ToArray();
|
model.Skeleton.MatrixToBoneList = AllIndices.ToArray();
|
||||||
model.Skeleton.InverseModelMatrices = SmoothMatrices;
|
model.Skeleton.InverseModelMatrices = SmoothMatrices;
|
||||||
|
|
||||||
|
|
Binary file not shown.
Binary file not shown.
Loading…
Reference in a new issue