- [Core] Fix bug with assets parsing.
This commit is contained in:
@@ -225,7 +225,7 @@ namespace AssetStudio
|
||||
|
||||
private ImportedFrame ConvertTransform(Transform trans)
|
||||
{
|
||||
var frame = new ImportedFrame(trans.m_Children.Length);
|
||||
var frame = new ImportedFrame(trans.m_Children.Count);
|
||||
transformDictionary.Add(trans, frame);
|
||||
trans.m_GameObject.TryGet(out var m_GameObject);
|
||||
frame.Name = m_GameObject.m_Name;
|
||||
@@ -308,7 +308,7 @@ namespace AssetStudio
|
||||
iMesh.hasColor = mesh.m_Colors?.Length > 0;
|
||||
|
||||
int firstFace = 0;
|
||||
for (int i = 0; i < mesh.m_SubMeshes.Length; i++)
|
||||
for (int i = 0; i < mesh.m_SubMeshes.Count; i++)
|
||||
{
|
||||
int numFaces = (int)mesh.m_SubMeshes[i].indexCount / 3;
|
||||
if (subHashSet.Count > 0 && !subHashSet.Contains(i))
|
||||
@@ -319,7 +319,7 @@ namespace AssetStudio
|
||||
var submesh = mesh.m_SubMeshes[i];
|
||||
var iSubmesh = new ImportedSubmesh();
|
||||
Material mat = null;
|
||||
if (i - firstSubMesh < meshR.m_Materials.Length)
|
||||
if (i - firstSubMesh < meshR.m_Materials.Count)
|
||||
{
|
||||
if (meshR.m_Materials[i - firstSubMesh].TryGet(out var m_Material))
|
||||
{
|
||||
@@ -408,7 +408,7 @@ namespace AssetStudio
|
||||
}
|
||||
}
|
||||
//BoneInfluence
|
||||
if (mesh.m_Skin?.Length > 0)
|
||||
if (mesh.m_Skin?.Count > 0)
|
||||
{
|
||||
var inf = mesh.m_Skin[j];
|
||||
iVertex.BoneIndices = new int[4];
|
||||
@@ -431,16 +431,16 @@ namespace AssetStudio
|
||||
* 2 - m_BoneNameHashes
|
||||
*/
|
||||
var boneType = 0;
|
||||
if (sMesh.m_Bones.Length > 0)
|
||||
if (sMesh.m_Bones.Count > 0)
|
||||
{
|
||||
if (sMesh.m_Bones.Length == mesh.m_BindPose.Length)
|
||||
if (sMesh.m_Bones.Count == mesh.m_BindPose.Length)
|
||||
{
|
||||
var verifiedBoneCount = sMesh.m_Bones.Count(x => x.TryGet(out _));
|
||||
if (verifiedBoneCount > 0)
|
||||
{
|
||||
boneType = 1;
|
||||
}
|
||||
if (verifiedBoneCount != sMesh.m_Bones.Length)
|
||||
if (verifiedBoneCount != sMesh.m_Bones.Count)
|
||||
{
|
||||
//尝试使用m_BoneNameHashes 4.3 and up
|
||||
if (mesh.m_BindPose.Length > 0 && (mesh.m_BindPose.Length == mesh.m_BoneNameHashes?.Length))
|
||||
@@ -470,7 +470,7 @@ namespace AssetStudio
|
||||
|
||||
if (boneType == 1)
|
||||
{
|
||||
var boneCount = sMesh.m_Bones.Length;
|
||||
var boneCount = sMesh.m_Bones.Count;
|
||||
iMesh.BoneList = new List<ImportedBone>(boneCount);
|
||||
for (int i = 0; i < boneCount; i++)
|
||||
{
|
||||
@@ -501,13 +501,13 @@ namespace AssetStudio
|
||||
}
|
||||
|
||||
//Morphs
|
||||
if (mesh.m_Shapes?.channels?.Length > 0)
|
||||
if (mesh.m_Shapes?.channels?.Count > 0)
|
||||
{
|
||||
var morph = new ImportedMorph();
|
||||
MorphList.Add(morph);
|
||||
morph.Path = iMesh.Path;
|
||||
morph.Channels = new List<ImportedMorphChannel>(mesh.m_Shapes.channels.Length);
|
||||
for (int i = 0; i < mesh.m_Shapes.channels.Length; i++)
|
||||
morph.Channels = new List<ImportedMorphChannel>(mesh.m_Shapes.channels.Count);
|
||||
for (int i = 0; i < mesh.m_Shapes.channels.Count; i++)
|
||||
{
|
||||
var channel = new ImportedMorphChannel();
|
||||
morph.Channels.Add(channel);
|
||||
@@ -534,7 +534,7 @@ namespace AssetStudio
|
||||
keyframe.hasTangents = shape.hasTangents;
|
||||
keyframe.VertexList = new List<ImportedMorphVertex>((int)shape.vertexCount);
|
||||
var vertexEnd = shape.firstVertex + shape.vertexCount;
|
||||
for (uint j = shape.firstVertex; j < vertexEnd; j++)
|
||||
for (int j = (int)shape.firstVertex; j < vertexEnd; j++)
|
||||
{
|
||||
var destVertex = new ImportedMorphVertex();
|
||||
keyframe.VertexList.Add(destVertex);
|
||||
@@ -918,7 +918,7 @@ namespace AssetStudio
|
||||
{
|
||||
var frame = streamedFrames[frameIndex];
|
||||
var streamedValues = frame.keyList.Select(x => x.value).ToArray();
|
||||
for (int curveIndex = 0; curveIndex < frame.keyList.Length;)
|
||||
for (int curveIndex = 0; curveIndex < frame.keyList.Count;)
|
||||
{
|
||||
var index = frame.keyList[curveIndex].index;
|
||||
if (!Game.Type.IsSRGroup())
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using SpirV;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
@@ -153,42 +154,42 @@ namespace AssetStudio
|
||||
{
|
||||
sb.Append(ConvertSerializedShaderState(m_Passe.m_State));
|
||||
|
||||
if (m_Passe.progVertex.m_SubPrograms.Length > 0)
|
||||
if (m_Passe.progVertex.m_SubPrograms.Count > 0)
|
||||
{
|
||||
sb.Append("Program \"vp\" {\n");
|
||||
sb.Append(ConvertSerializedSubPrograms(m_Passe.progVertex.m_SubPrograms, platforms, shaderPrograms));
|
||||
sb.Append("}\n");
|
||||
}
|
||||
|
||||
if (m_Passe.progFragment.m_SubPrograms.Length > 0)
|
||||
if (m_Passe.progFragment.m_SubPrograms.Count > 0)
|
||||
{
|
||||
sb.Append("Program \"fp\" {\n");
|
||||
sb.Append(ConvertSerializedSubPrograms(m_Passe.progFragment.m_SubPrograms, platforms, shaderPrograms));
|
||||
sb.Append("}\n");
|
||||
}
|
||||
|
||||
if (m_Passe.progGeometry.m_SubPrograms.Length > 0)
|
||||
if (m_Passe.progGeometry.m_SubPrograms.Count > 0)
|
||||
{
|
||||
sb.Append("Program \"gp\" {\n");
|
||||
sb.Append(ConvertSerializedSubPrograms(m_Passe.progGeometry.m_SubPrograms, platforms, shaderPrograms));
|
||||
sb.Append("}\n");
|
||||
}
|
||||
|
||||
if (m_Passe.progHull.m_SubPrograms.Length > 0)
|
||||
if (m_Passe.progHull.m_SubPrograms.Count > 0)
|
||||
{
|
||||
sb.Append("Program \"hp\" {\n");
|
||||
sb.Append(ConvertSerializedSubPrograms(m_Passe.progHull.m_SubPrograms, platforms, shaderPrograms));
|
||||
sb.Append("}\n");
|
||||
}
|
||||
|
||||
if (m_Passe.progDomain.m_SubPrograms.Length > 0)
|
||||
if (m_Passe.progDomain.m_SubPrograms.Count > 0)
|
||||
{
|
||||
sb.Append("Program \"dp\" {\n");
|
||||
sb.Append(ConvertSerializedSubPrograms(m_Passe.progDomain.m_SubPrograms, platforms, shaderPrograms));
|
||||
sb.Append("}\n");
|
||||
}
|
||||
|
||||
if (m_Passe.progRayTracing?.m_SubPrograms.Length > 0)
|
||||
if (m_Passe.progRayTracing?.m_SubPrograms.Count > 0)
|
||||
{
|
||||
sb.Append("Program \"rtp\" {\n");
|
||||
sb.Append(ConvertSerializedSubPrograms(m_Passe.progRayTracing.m_SubPrograms, platforms, shaderPrograms));
|
||||
@@ -200,7 +201,7 @@ namespace AssetStudio
|
||||
return sb.ToString();
|
||||
}
|
||||
|
||||
private static string ConvertSerializedSubPrograms(SerializedSubProgram[] m_SubPrograms, ShaderCompilerPlatform[] platforms, ShaderProgram[] shaderPrograms)
|
||||
private static string ConvertSerializedSubPrograms(List<SerializedSubProgram> m_SubPrograms, ShaderCompilerPlatform[] platforms, ShaderProgram[] shaderPrograms)
|
||||
{
|
||||
var sb = new StringBuilder();
|
||||
var groups = m_SubPrograms.GroupBy(x => x.m_BlobIndex);
|
||||
@@ -496,10 +497,10 @@ namespace AssetStudio
|
||||
}
|
||||
}
|
||||
|
||||
private static string ConvertSerializedShaderRTBlendState(SerializedShaderRTBlendState[] rtBlend, bool rtSeparateBlend)
|
||||
private static string ConvertSerializedShaderRTBlendState(List<SerializedShaderRTBlendState> rtBlend, bool rtSeparateBlend)
|
||||
{
|
||||
var sb = new StringBuilder();
|
||||
for (var i = 0; i < rtBlend.Length; i++)
|
||||
for (var i = 0; i < rtBlend.Count; i++)
|
||||
{
|
||||
var blend = rtBlend[i];
|
||||
if (blend.srcBlend.val != 1f ||
|
||||
@@ -653,7 +654,7 @@ namespace AssetStudio
|
||||
private static string ConvertSerializedTagMap(SerializedTagMap m_Tags, int intent)
|
||||
{
|
||||
var sb = new StringBuilder();
|
||||
if (m_Tags.tags.Length > 0)
|
||||
if (m_Tags.tags.Count > 0)
|
||||
{
|
||||
sb.Append(new string(' ', intent));
|
||||
sb.Append("Tags { ");
|
||||
|
||||
@@ -150,7 +150,7 @@ namespace AssetStudio
|
||||
var vertices = new Vector2[subMesh.vertexCount];
|
||||
for (int v = 0; v < subMesh.vertexCount; v++)
|
||||
{
|
||||
vertices[v] = vertexReader.ReadVector3();
|
||||
vertices[v] = new Vector3(vertexReader.ReadSingle(), vertexReader.ReadSingle(), vertexReader.ReadSingle());
|
||||
vertexReader.BaseStream.Position += m_Stream.stride - 12;
|
||||
}
|
||||
|
||||
|
||||
@@ -26,12 +26,12 @@ namespace AssetStudio
|
||||
private readonly Dictionary<FloatCurve, List<Keyframe<Float>>> m_floats = new Dictionary<FloatCurve, List<Keyframe<Float>>>();
|
||||
private readonly Dictionary<PPtrCurve, List<PPtrKeyframe>> m_pptrs = new Dictionary<PPtrCurve, List<PPtrKeyframe>>();
|
||||
|
||||
public Vector3Curve[] Translations { get; private set; }
|
||||
public QuaternionCurve[] Rotations { get; private set; }
|
||||
public Vector3Curve[] Scales { get; private set; }
|
||||
public Vector3Curve[] Eulers { get; private set; }
|
||||
public FloatCurve[] Floats { get; private set; }
|
||||
public PPtrCurve[] PPtrs { get; private set; }
|
||||
public List<Vector3Curve> Translations { get; private set; }
|
||||
public List<QuaternionCurve> Rotations { get; private set; }
|
||||
public List<Vector3Curve> Scales { get; private set; }
|
||||
public List<Vector3Curve> Eulers { get; private set; }
|
||||
public List<FloatCurve> Floats { get; private set; }
|
||||
public List<PPtrCurve> PPtrs { get; private set; }
|
||||
|
||||
public AnimationClipConverter(AnimationClip clip)
|
||||
{
|
||||
@@ -81,17 +81,17 @@ namespace AssetStudio
|
||||
private void CreateCurves()
|
||||
{
|
||||
m_translations.AsEnumerable().ToList().ForEach(x => x.Key.curve.m_Curve.AddRange(x.Value));
|
||||
Translations = m_translations.Keys.ToArray();
|
||||
Translations = m_translations.Keys.ToList();
|
||||
m_rotations.AsEnumerable().ToList().ForEach(x => x.Key.curve.m_Curve.AddRange(x.Value));
|
||||
Rotations = m_rotations.Keys.ToArray();
|
||||
Rotations = m_rotations.Keys.ToList();
|
||||
m_scales.AsEnumerable().ToList().ForEach(x => x.Key.curve.m_Curve.AddRange(x.Value));
|
||||
Scales = m_scales.Keys.ToArray();
|
||||
Scales = m_scales.Keys.ToList();
|
||||
m_eulers.AsEnumerable().ToList().ForEach(x => x.Key.curve.m_Curve.AddRange(x.Value));
|
||||
Eulers = m_eulers.Keys.ToArray();
|
||||
Eulers = m_eulers.Keys.ToList();
|
||||
m_floats.AsEnumerable().ToList().ForEach(x => x.Key.curve.m_Curve.AddRange(x.Value));
|
||||
Floats = m_floats.Keys.ToArray();
|
||||
Floats = m_floats.Keys.ToList();
|
||||
m_pptrs.AsEnumerable().ToList().ForEach(x => x.Key.curve.AddRange(x.Value));
|
||||
PPtrs = m_pptrs.Keys.ToArray();
|
||||
PPtrs = m_pptrs.Keys.ToList();
|
||||
}
|
||||
|
||||
private void ProcessStreams(List<StreamedClip.StreamedFrame> streamFrames, AnimationClipBindingConstant bindings, Dictionary<uint, string> tos, float sampleRate)
|
||||
@@ -107,7 +107,7 @@ namespace AssetStudio
|
||||
for (var frameIndex = 1; frameIndex < streamFrames.Count - 1; frameIndex++)
|
||||
{
|
||||
var frame = streamFrames[frameIndex];
|
||||
for (var curveIndex = 0; curveIndex < frame.keyList.Length;)
|
||||
for (var curveIndex = 0; curveIndex < frame.keyList.Count;)
|
||||
{
|
||||
var curve = frame.keyList[curveIndex];
|
||||
var index = curve.index;
|
||||
@@ -496,7 +496,7 @@ namespace AssetStudio
|
||||
for (frameIndex = currentFrame - 1; frameIndex >= 0; frameIndex--)
|
||||
{
|
||||
var frame = streamFrames[frameIndex];
|
||||
for (curveIndex = 0; curveIndex < frame.keyList.Length; curveIndex++)
|
||||
for (curveIndex = 0; curveIndex < frame.keyList.Count; curveIndex++)
|
||||
{
|
||||
var curve = frame.keyList[curveIndex];
|
||||
if (curve.index == curveID)
|
||||
@@ -512,7 +512,7 @@ namespace AssetStudio
|
||||
{
|
||||
var curve = frame.keyList[currentCurve];
|
||||
int i = currentCurve + 1;
|
||||
for (; i < frame.keyList.Length; i++)
|
||||
for (; i < frame.keyList.Count; i++)
|
||||
{
|
||||
if (frame.keyList[i].index != curve.index)
|
||||
{
|
||||
|
||||
@@ -112,10 +112,10 @@ namespace AssetStudio
|
||||
}
|
||||
private static bool AddTOS(this AnimationClip clip, Dictionary<uint, string> src, Dictionary<uint, string> dest)
|
||||
{
|
||||
int tosCount = clip.m_ClipBindingConstant.genericBindings.Length;
|
||||
int tosCount = clip.m_ClipBindingConstant.genericBindings.Count;
|
||||
for (int i = 0; i < tosCount; i++)
|
||||
{
|
||||
ref GenericBinding binding = ref clip.m_ClipBindingConstant.genericBindings[i];
|
||||
var binding = clip.m_ClipBindingConstant.genericBindings[i];
|
||||
if (src.TryGetValue(binding.path, out string path))
|
||||
{
|
||||
dest[binding.path] = path;
|
||||
@@ -147,12 +147,12 @@ namespace AssetStudio
|
||||
if (!clip.m_Legacy || clip.m_MuscleClip != null)
|
||||
{
|
||||
var converter = AnimationClipConverter.Process(clip);
|
||||
clip.m_RotationCurves = converter.Rotations.Union(clip.m_RotationCurves).ToArray();
|
||||
clip.m_EulerCurves = converter.Eulers.Union(clip.m_EulerCurves).ToArray();
|
||||
clip.m_PositionCurves = converter.Translations.Union(clip.m_PositionCurves).ToArray();
|
||||
clip.m_ScaleCurves = converter.Scales.Union(clip.m_ScaleCurves).ToArray();
|
||||
clip.m_FloatCurves = converter.Floats.Union(clip.m_FloatCurves).ToArray();
|
||||
clip.m_PPtrCurves = converter.PPtrs.Union(clip.m_PPtrCurves).ToArray();
|
||||
clip.m_RotationCurves = converter.Rotations.Union(clip.m_RotationCurves).ToList();
|
||||
clip.m_EulerCurves = converter.Eulers.Union(clip.m_EulerCurves).ToList();
|
||||
clip.m_PositionCurves = converter.Translations.Union(clip.m_PositionCurves).ToList();
|
||||
clip.m_ScaleCurves = converter.Scales.Union(clip.m_ScaleCurves).ToList();
|
||||
clip.m_FloatCurves = converter.Floats.Union(clip.m_FloatCurves).ToList();
|
||||
clip.m_PPtrCurves = converter.PPtrs.Union(clip.m_PPtrCurves).ToList();
|
||||
}
|
||||
return ConvertSerializedAnimationClip(clip);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user