mirror of
https://mirror.ghproxy.com/https://github.com/dexyfex/CodeWalker
synced 2024-11-26 08:52:52 +08:00
Improved animations game replication and performance
This commit is contained in:
parent
73402373e3
commit
bc14a1fd22
@ -922,7 +922,7 @@ namespace CodeWalker.GameFiles
|
||||
var aseq = seq.Sequences[boneIndex];
|
||||
var q0 = aseq.EvaluateQuaternion(f0);
|
||||
var q1 = aseq.EvaluateQuaternion(f1);
|
||||
var q = interpolate ? Quaternion.Slerp(q0, q1, frame.Alpha1) : q0;
|
||||
var q = interpolate ? QuaternionExtension.FastLerp(q0, q1, frame.Alpha1) : q0;
|
||||
return q;
|
||||
}
|
||||
|
||||
|
@ -2233,19 +2233,27 @@ namespace CodeWalker.GameFiles
|
||||
|
||||
public void UpdateAnimTransform()
|
||||
{
|
||||
//AnimTransform = Matrix.AffineTransformation(1.0f, AnimRotation, AnimTranslation);//(local transform)
|
||||
var pos = AnimTranslation;
|
||||
var ori = AnimRotation;
|
||||
var sca = AnimScale;
|
||||
var pbone = Parent;
|
||||
while (pbone != null)
|
||||
AnimTransform = Matrix.AffineTransformation(1.0f, AnimRotation, AnimTranslation);
|
||||
AnimTransform.ScaleVector *= AnimScale;
|
||||
if (Parent != null)
|
||||
{
|
||||
pos = pbone.AnimRotation.Multiply(pos /** pbone.AnimScale*/) + pbone.AnimTranslation;
|
||||
ori = pbone.AnimRotation * ori;
|
||||
pbone = pbone.Parent;
|
||||
AnimTransform = AnimTransform * Parent.AnimTransform;
|
||||
}
|
||||
AnimTransform = Matrix.AffineTransformation(1.0f, ori, pos);//(global transform)
|
||||
AnimTransform.ScaleVector *= sca;
|
||||
|
||||
////AnimTransform = Matrix.AffineTransformation(1.0f, AnimRotation, AnimTranslation);//(local transform)
|
||||
|
||||
//var pos = AnimTranslation;
|
||||
//var ori = AnimRotation;
|
||||
//var sca = AnimScale;
|
||||
//var pbone = Parent;
|
||||
//while (pbone != null)
|
||||
//{
|
||||
// pos = pbone.AnimRotation.Multiply(pos /** pbone.AnimScale*/) + pbone.AnimTranslation;
|
||||
// ori = pbone.AnimRotation * ori;
|
||||
// pbone = pbone.Parent;
|
||||
//}
|
||||
//AnimTransform = Matrix.AffineTransformation(1.0f, ori, pos);//(global transform)
|
||||
//AnimTransform.ScaleVector *= sca;
|
||||
}
|
||||
public void UpdateSkinTransform()
|
||||
{
|
||||
|
@ -67,6 +67,17 @@ namespace CodeWalker
|
||||
return new Vector4(q.X, q.Y, q.Z, q.W);
|
||||
}
|
||||
|
||||
public static Quaternion FastLerp(Quaternion a, Quaternion b, float v)
|
||||
{
|
||||
var r = new Quaternion();
|
||||
var vi = 1.0f - v;
|
||||
r.X = vi * a.X + v * b.X;
|
||||
r.Y = vi * a.Y + v * b.Y;
|
||||
r.Z = vi * a.Z + v * b.Z;
|
||||
r.W = vi * a.W + v * b.W;
|
||||
r.Normalize();
|
||||
return r;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user