mirror of
https://mirror.ghproxy.com/https://github.com/dexyfex/CodeWalker
synced 2026-05-14 11:42:46 +08:00
Changed Skeleton Bones into array and added SkeletonBonesBlock
This commit is contained in:
@@ -149,11 +149,11 @@ namespace CodeWalker.Project.Panels
|
||||
Matrix xform = Matrix.Identity;
|
||||
int boneidx = 0;
|
||||
var skeleton = dwbl.Skeleton;
|
||||
if (skeleton?.Bones?.Data != null)
|
||||
if (skeleton?.Bones?.Items != null)
|
||||
{
|
||||
for (int j = 0; j < skeleton.Bones.Data.Count; j++)
|
||||
for (int j = 0; j < skeleton.Bones.Items.Length; j++)
|
||||
{
|
||||
var tbone = skeleton.Bones.Data[j];
|
||||
var tbone = skeleton.Bones.Items[j];
|
||||
if (tbone.Tag == la.BoneId)
|
||||
{
|
||||
boneidx = j;
|
||||
|
||||
@@ -170,7 +170,7 @@ namespace CodeWalker.Rendering
|
||||
Matrix[] fragtransforms = null;
|
||||
Vector4 fragoffset = Vector4.Zero;
|
||||
int fragtransformid = 0;
|
||||
List<Bone> bones = null;
|
||||
Bone[] bones = null;
|
||||
bool usepose = false;
|
||||
if (skeleton != null)
|
||||
{
|
||||
@@ -246,8 +246,8 @@ namespace CodeWalker.Rendering
|
||||
}
|
||||
|
||||
hastransforms = (modeltransforms != null) || (fragtransforms != null);
|
||||
hasbones = ((skeleton.Bones != null) && (skeleton.Bones.Data != null));
|
||||
bones = hasbones ? skeleton.Bones.Data : null;
|
||||
hasbones = ((skeleton.Bones != null) && (skeleton.Bones.Items != null));
|
||||
bones = hasbones ? skeleton.Bones.Items : null;
|
||||
}
|
||||
|
||||
HasSkeleton = hasskeleton;
|
||||
@@ -268,7 +268,7 @@ namespace CodeWalker.Rendering
|
||||
int boneidx = model.BoneIndex;
|
||||
|
||||
Matrix trans = (boneidx < modeltransforms.Length) ? modeltransforms[boneidx] : Matrix.Identity;
|
||||
Bone bone = (hasbones && (boneidx < bones.Count)) ? bones[boneidx] : null;
|
||||
Bone bone = (hasbones && (boneidx < bones.Length)) ? bones[boneidx] : null;
|
||||
|
||||
if (mi < HDModels.Length) //populate bone links map for hd models
|
||||
{
|
||||
@@ -398,11 +398,11 @@ namespace CodeWalker.Rendering
|
||||
}
|
||||
private void UpdateBoneTransforms()
|
||||
{
|
||||
if (Skeleton?.Bones?.Data == null) return;
|
||||
if (Skeleton?.Bones?.Items == null) return;
|
||||
|
||||
Skeleton.UpdateBoneTransforms();
|
||||
|
||||
var bones = Skeleton.Bones?.Data;
|
||||
var bones = Skeleton.Bones?.Items;
|
||||
var bonetransforms = Skeleton.BoneTransforms;
|
||||
|
||||
var drawbl = Key;
|
||||
@@ -416,7 +416,7 @@ namespace CodeWalker.Rendering
|
||||
var geom = model.Geometries[g];
|
||||
var boneids = geom?.DrawableGeom?.BoneIds;
|
||||
if (boneids == null) continue;
|
||||
if (boneids.Length != bones.Count)
|
||||
if (boneids.Length != bones.Length)
|
||||
{
|
||||
var idc = boneids.Length;
|
||||
if (geom.BoneTransforms == null)
|
||||
@@ -511,7 +511,7 @@ namespace CodeWalker.Rendering
|
||||
|
||||
var dwbl = this.Key;
|
||||
var skel = Skeleton;
|
||||
var bones = skel?.Bones;
|
||||
var bones = skel?.Bones?.Items;
|
||||
if (bones == null)
|
||||
{ return; }
|
||||
|
||||
@@ -615,7 +615,7 @@ namespace CodeWalker.Rendering
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < bones.Count; i++)
|
||||
for (int i = 0; i < bones.Length; i++)
|
||||
{
|
||||
var bone = bones[i];
|
||||
var tag = bone.Tag;
|
||||
@@ -636,7 +636,7 @@ namespace CodeWalker.Rendering
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < bones.Count; i++)
|
||||
for (int i = 0; i < bones.Length; i++)
|
||||
{
|
||||
var bone = bones[i];
|
||||
bone.UpdateAnimTransform();
|
||||
|
||||
@@ -1263,11 +1263,11 @@ namespace CodeWalker.Rendering
|
||||
Vector3 campos = camera.Position - (entity?.Position ?? Vector3.Zero);
|
||||
|
||||
var pinds = skeleton.ParentIndices;
|
||||
var bones = skeleton.Bones;
|
||||
var bones = skeleton.Bones?.Items;
|
||||
if ((pinds == null) || (bones == null)) continue;
|
||||
var xforms = skeleton.Transformations;
|
||||
|
||||
int cnt = Math.Min(pinds.Length, bones.Count);
|
||||
int cnt = Math.Min(pinds.Length, bones.Length);
|
||||
for (int i = 0; i < cnt; i++)
|
||||
{
|
||||
var pind = pinds[i];
|
||||
@@ -3172,15 +3172,18 @@ namespace CodeWalker.Rendering
|
||||
else if (drawable.Skeleton != skel)
|
||||
{
|
||||
var dskel = drawable.Skeleton; //put the bones of the fragment into the drawable. drawable's bones in this case seem messed up!
|
||||
for (int b = 0; b < skel.Bones.Count; b++)
|
||||
if (skel.Bones?.Items != null)
|
||||
{
|
||||
var srcbone = skel.Bones[b];
|
||||
var dstbone = srcbone;
|
||||
if (dskel.BonesMap.TryGetValue(srcbone.Tag, out dstbone))
|
||||
for (int b = 0; b < skel.Bones.Items.Length; b++)
|
||||
{
|
||||
if (srcbone == dstbone) break; //bone reassignment already done!
|
||||
dskel.Bones[dstbone.Index] = srcbone;
|
||||
dskel.BonesMap[srcbone.Tag] = srcbone;
|
||||
var srcbone = skel.Bones.Items[b];
|
||||
var dstbone = srcbone;
|
||||
if (dskel.BonesMap.TryGetValue(srcbone.Tag, out dstbone))
|
||||
{
|
||||
if (srcbone == dstbone) break; //bone reassignment already done!
|
||||
dskel.Bones.Items[dstbone.Index] = srcbone;
|
||||
dskel.BonesMap[srcbone.Tag] = srcbone;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user