mirror of
https://mirror.ghproxy.com/https://github.com/dexyfex/CodeWalker
synced 2024-11-26 08:52:52 +08:00
Fix for bones on peds drawables with existing skeletons. Also included code to use geometry-specific bone matrices where boneIds array is used, but commented out since it never seems necessary (leaving in for reference)
This commit is contained in:
parent
20545145a5
commit
03fa5575bf
@ -924,7 +924,7 @@ namespace CodeWalker.GameFiles
|
|||||||
var pbone = Parent;
|
var pbone = Parent;
|
||||||
while (pbone != null)
|
while (pbone != null)
|
||||||
{
|
{
|
||||||
pos = pbone.AnimRotation.Multiply(pos) + pbone.AnimTranslation;
|
pos = pbone.AnimRotation.Multiply(pos * pbone.AnimScale) + pbone.AnimTranslation;
|
||||||
ori = pbone.AnimRotation * ori;
|
ori = pbone.AnimRotation * ori;
|
||||||
pbone = pbone.Parent;
|
pbone = pbone.Parent;
|
||||||
}
|
}
|
||||||
|
@ -1197,7 +1197,25 @@ namespace CodeWalker.Peds
|
|||||||
var skel = SelectedPed.Yft?.Fragment?.Drawable?.Skeleton;
|
var skel = SelectedPed.Yft?.Fragment?.Drawable?.Skeleton;
|
||||||
if (skel != null)
|
if (skel != null)
|
||||||
{
|
{
|
||||||
drawable.Skeleton = skel;//force the drawable to use this skeleton.
|
if (drawable.Skeleton == null)
|
||||||
|
{
|
||||||
|
drawable.Skeleton = skel;//force the drawable to use this skeleton.
|
||||||
|
}
|
||||||
|
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++)
|
||||||
|
{
|
||||||
|
var srcbone = skel.Bones[b];
|
||||||
|
var dstbone = srcbone;
|
||||||
|
if (dskel.BonesMap.TryGetValue(srcbone.Tag, out dstbone))
|
||||||
|
{
|
||||||
|
if (srcbone == dstbone) break; //bone reassignment already done!
|
||||||
|
dskel.Bones[dstbone.Index] = srcbone;
|
||||||
|
dskel.BonesMap[srcbone.Tag] = srcbone;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -384,6 +384,41 @@ namespace CodeWalker.Rendering
|
|||||||
bt.Row3 = b.Column3;
|
bt.Row3 = b.Column3;
|
||||||
BoneTransforms[i] = bt;
|
BoneTransforms[i] = bt;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//var drawbl = Key;
|
||||||
|
//if (AllModels == null) return;
|
||||||
|
//for (int i = 0; i < AllModels.Length; i++)
|
||||||
|
//{
|
||||||
|
// var model = AllModels[i];
|
||||||
|
// if (model?.Geometries == null) continue;
|
||||||
|
// for (int g = 0; g < model.Geometries.Length; g++)
|
||||||
|
// {
|
||||||
|
// var geom = model.Geometries[g];
|
||||||
|
// var boneids = geom?.DrawableGeom?.BoneIds;
|
||||||
|
// if (boneids == null) continue;
|
||||||
|
// if (boneids.Length != Bones.Count)
|
||||||
|
// {
|
||||||
|
// var idc = boneids.Length;
|
||||||
|
// if (geom.BoneTransforms == null)
|
||||||
|
// {
|
||||||
|
// geom.BoneTransforms = new Matrix3_s[idc];
|
||||||
|
// }
|
||||||
|
// for (int b = 0; b < idc; b++)
|
||||||
|
// {
|
||||||
|
// var id = boneids[b];
|
||||||
|
// if (id < BoneTransforms.Length)
|
||||||
|
// {
|
||||||
|
// geom.BoneTransforms[b] = BoneTransforms[id];
|
||||||
|
// if (id != b)
|
||||||
|
// { }
|
||||||
|
// }
|
||||||
|
// else
|
||||||
|
// { }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -756,6 +791,8 @@ namespace CodeWalker.Rendering
|
|||||||
public bool isHair = false;
|
public bool isHair = false;
|
||||||
public bool disableRendering = false;
|
public bool disableRendering = false;
|
||||||
|
|
||||||
|
//public Matrix3_s[] BoneTransforms = null;
|
||||||
|
|
||||||
public static ShaderParamNames[] GetTextureSamplerList()
|
public static ShaderParamNames[] GetTextureSamplerList()
|
||||||
{
|
{
|
||||||
return new ShaderParamNames[]
|
return new ShaderParamNames[]
|
||||||
|
@ -796,6 +796,14 @@ namespace CodeWalker.Rendering
|
|||||||
{
|
{
|
||||||
tintpal.SetVSResource(context, 0);
|
tintpal.SetVSResource(context, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//if (geom.BoneTransforms != null)
|
||||||
|
//{
|
||||||
|
// SetBoneMatrices(context, geom.BoneTransforms);
|
||||||
|
// defaultBoneMatricesBound = false;
|
||||||
|
//}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetBoneMatrices(DeviceContext context, Matrix3_s[] matrices)
|
public void SetBoneMatrices(DeviceContext context, Matrix3_s[] matrices)
|
||||||
|
@ -356,6 +356,14 @@ namespace CodeWalker.Rendering
|
|||||||
{
|
{
|
||||||
texture.SetPSResource(context, 0);
|
texture.SetPSResource(context, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//if (geom.BoneTransforms != null)
|
||||||
|
//{
|
||||||
|
// SetBoneMatrices(context, geom.BoneTransforms);
|
||||||
|
// defaultBoneMatricesBound = false;
|
||||||
|
//}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetBoneMatrices(DeviceContext context, Matrix3_s[] matrices)
|
public void SetBoneMatrices(DeviceContext context, Matrix3_s[] matrices)
|
||||||
|
Loading…
Reference in New Issue
Block a user