mirror of
https://github.com/aelurum/AssetStudio.git
synced 2025-05-25 05:40:21 -04:00
Fixed bug
This commit is contained in:
parent
0dbd5b52f0
commit
1e9b8037ab
@ -477,13 +477,35 @@ namespace AssetStudio
|
||||
public class StreamedCurveKey
|
||||
{
|
||||
public int index { get; set; }
|
||||
public Vector3 tcb { get; set; }
|
||||
public float value { get; set; }
|
||||
public float[] coeff { get; set; }
|
||||
|
||||
public float value;
|
||||
public float outSlope;
|
||||
public float inSlope;
|
||||
|
||||
public StreamedCurveKey(BinaryReader reader)
|
||||
{
|
||||
index = reader.ReadInt32();
|
||||
tcb = reader.ReadVector3();
|
||||
value = reader.ReadSingle();
|
||||
coeff = reader.ReadSingleArray(4);
|
||||
|
||||
outSlope = coeff[2];
|
||||
value = coeff[3];
|
||||
}
|
||||
|
||||
public float CalculateNextInSlope(float dx, StreamedCurveKey rhs)
|
||||
{
|
||||
//Stepped
|
||||
if (coeff[0] == 0f && coeff[1] == 0f && coeff[2] == 0f)
|
||||
{
|
||||
return float.PositiveInfinity;
|
||||
}
|
||||
|
||||
dx = Math.Max(dx, 0.0001f);
|
||||
var dy = rhs.value - value;
|
||||
var length = 1.0f / (dx * dx);
|
||||
var d1 = outSlope * dx;
|
||||
var d2 = dy + dy + dy - d1 - d1 - coeff[1] / length;
|
||||
return d2 / dx;
|
||||
}
|
||||
}
|
||||
|
||||
@ -507,7 +529,7 @@ namespace AssetStudio
|
||||
|
||||
public List<StreamedFrame> ReadData()
|
||||
{
|
||||
List<StreamedFrame> frameList = new List<StreamedFrame>();
|
||||
var frameList = new List<StreamedFrame>();
|
||||
using (Stream stream = new MemoryStream())
|
||||
{
|
||||
BinaryWriter writer = new BinaryWriter(stream);
|
||||
@ -518,6 +540,24 @@ namespace AssetStudio
|
||||
frameList.Add(new StreamedFrame(new BinaryReader(stream)));
|
||||
}
|
||||
}
|
||||
|
||||
for (int frameIndex = 2; frameIndex < frameList.Count - 1; frameIndex++)
|
||||
{
|
||||
var frame = frameList[frameIndex];
|
||||
foreach (var curveKey in frame.keyList)
|
||||
{
|
||||
for (int i = frameIndex - 1; i >= 0; i--)
|
||||
{
|
||||
var preFrame = frameList[i];
|
||||
var preCurveKey = preFrame.keyList.Find(x => x.index == curveKey.index);
|
||||
if (preCurveKey != null)
|
||||
{
|
||||
curveKey.inSlope = preCurveKey.CalculateNextInSlope(frame.time - preFrame.time, preCurveKey);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return frameList;
|
||||
}
|
||||
}
|
||||
|
@ -61,7 +61,7 @@ namespace AssetStudio
|
||||
|
||||
public bool HasStructMember(string name)
|
||||
{
|
||||
return serializedType.m_Nodes != null && serializedType.m_Nodes.Any(x => x.m_Name == name);
|
||||
return serializedType?.m_Nodes != null && serializedType.m_Nodes.Any(x => x.m_Name == name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -91,10 +91,11 @@ namespace AssetStudio
|
||||
else
|
||||
{
|
||||
var frameList = new List<ImportedFrame>();
|
||||
while (rootTransform.m_Father.TryGetTransform(out var m_Father))
|
||||
var tempTransform = rootTransform;
|
||||
while (tempTransform.m_Father.TryGetTransform(out var m_Father))
|
||||
{
|
||||
frameList.Add(ConvertFrame(m_Father));
|
||||
rootTransform = m_Father;
|
||||
tempTransform = m_Father;
|
||||
}
|
||||
if (frameList.Count > 0)
|
||||
{
|
||||
@ -537,28 +538,24 @@ namespace AssetStudio
|
||||
if (combine)
|
||||
{
|
||||
meshR.m_GameObject.TryGetGameObject(out var m_GameObject);
|
||||
foreach (var root in FrameList)
|
||||
var frame = ImportedHelpers.FindFrame(m_GameObject.m_Name, FrameList[0]);
|
||||
if (frame?.Parent != null)
|
||||
{
|
||||
var frame = ImportedHelpers.FindFrame(m_GameObject.m_Name, root);
|
||||
if (frame?.Parent != null)
|
||||
var parent = frame;
|
||||
while (true)
|
||||
{
|
||||
var parent = frame;
|
||||
while (true)
|
||||
if (parent.Parent != null)
|
||||
{
|
||||
if (parent.Parent != null)
|
||||
{
|
||||
parent = parent.Parent;
|
||||
}
|
||||
else
|
||||
{
|
||||
frame.LocalRotation = parent.LocalRotation;
|
||||
frame.LocalScale = parent.LocalScale;
|
||||
frame.LocalPosition = parent.LocalPosition;
|
||||
break;
|
||||
}
|
||||
parent = parent.Parent;
|
||||
}
|
||||
else
|
||||
{
|
||||
frame.LocalRotation = parent.LocalRotation;
|
||||
frame.LocalScale = parent.LocalScale;
|
||||
frame.LocalPosition = parent.LocalPosition;
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@ -826,7 +823,7 @@ namespace AssetStudio
|
||||
var streamCount = m_Clip.m_StreamedClip.curveCount;
|
||||
for (int frameIndex = 0; frameIndex < m_DenseClip.m_FrameCount; frameIndex++)
|
||||
{
|
||||
var time = frameIndex / m_DenseClip.m_SampleRate;
|
||||
var time = m_DenseClip.m_BeginTime + frameIndex / m_DenseClip.m_SampleRate;
|
||||
var frameOffset = frameIndex * m_DenseClip.m_CurveCount;
|
||||
for (int curveIndex = 0; curveIndex < m_DenseClip.m_CurveCount;)
|
||||
{
|
||||
@ -834,17 +831,20 @@ namespace AssetStudio
|
||||
ReadCurveData(iAnim, m_ClipBindingConstant, (int)index, time, m_DenseClip.m_SampleArray, (int)frameOffset, ref curveIndex);
|
||||
}
|
||||
}
|
||||
var m_ConstantClip = m_Clip.m_ConstantClip;
|
||||
var denseCount = m_Clip.m_DenseClip.m_CurveCount;
|
||||
var time2 = 0.0f;
|
||||
for (int i = 0; i < 2; i++)
|
||||
if (m_Clip.m_ConstantClip != null)
|
||||
{
|
||||
for (int curveIndex = 0; curveIndex < m_ConstantClip.data.Length;)
|
||||
var m_ConstantClip = m_Clip.m_ConstantClip;
|
||||
var denseCount = m_Clip.m_DenseClip.m_CurveCount;
|
||||
var time2 = 0.0f;
|
||||
for (int i = 0; i < 2; i++)
|
||||
{
|
||||
var index = streamCount + denseCount + curveIndex;
|
||||
ReadCurveData(iAnim, m_ClipBindingConstant, (int)index, time2, m_ConstantClip.data, 0, ref curveIndex);
|
||||
for (int curveIndex = 0; curveIndex < m_ConstantClip.data.Length;)
|
||||
{
|
||||
var index = streamCount + denseCount + curveIndex;
|
||||
ReadCurveData(iAnim, m_ClipBindingConstant, (int)index, time2, m_ConstantClip.data, 0, ref curveIndex);
|
||||
}
|
||||
time2 = animationClip.m_MuscleClip.m_StopTime;
|
||||
}
|
||||
time2 = animationClip.m_MuscleClip.m_StopTime;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -41,29 +41,6 @@ namespace AssetStudio
|
||||
obj.Parent = this;
|
||||
}
|
||||
|
||||
public void InsertChild(int i, ImportedFrame obj)
|
||||
{
|
||||
children.Insert(i, obj);
|
||||
obj.Parent = this;
|
||||
}
|
||||
|
||||
public void RemoveChild(ImportedFrame obj)
|
||||
{
|
||||
obj.Parent = null;
|
||||
children.Remove(obj);
|
||||
}
|
||||
|
||||
public void RemoveChild(int i)
|
||||
{
|
||||
children[i].Parent = null;
|
||||
children.RemoveAt(i);
|
||||
}
|
||||
|
||||
public int IndexOf(ImportedFrame obj)
|
||||
{
|
||||
return children.IndexOf(obj);
|
||||
}
|
||||
|
||||
public void ClearChild()
|
||||
{
|
||||
children.Clear();
|
||||
@ -177,6 +154,8 @@ namespace AssetStudio
|
||||
{
|
||||
public float time { get; set; }
|
||||
public T value { get; set; }
|
||||
public T inSlope { get; set; }
|
||||
public T outSlope { get; set; }
|
||||
|
||||
public ImportedKeyframe(float time, T value)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user