private void Render() { foreach (var obj in vertexCachePool) { VertexCache vertexCache = obj.Value; for (int k = 0; k != vertexCache.packageList.Length; ++k) { for (int i = 0; i != vertexCache.packageList[k].Count; ++i) { VertexCache.InstancingPackage package = vertexCache.packageList[k][i]; if (package.instancingCount == 0) { continue; } for (int j = 0; j != package.subMeshCount; ++j) { if (UseInstancing) { #if UNITY_EDITOR PreparePackageMaterial(package, vertexCache, k); #endif package.propertyBlock.SetFloatArray("frameIndex", vertexCache.instanceData.FrameIndex[k][i]); package.propertyBlock.SetFloatArray("preFrameIndex", vertexCache.instanceData.PreFrameIndex[k][i]); package.propertyBlock.SetFloatArray("transitionProgress", vertexCache.instanceData.TransitionProgress[k][i]); Graphics.DrawMeshInstanced(vertexCache.mesh, j, package.material[j], vertexCache.instanceData.WorldMatrix[k][i], package.instancingCount, package.propertyBlock, ShadowCastingMode.On, true, 0); } else { package.material[j].SetFloat("frameIndex", vertexCache.instanceData.FrameIndex[k][i][0]); package.material[j].SetFloat("preFrameIndex", vertexCache.instanceData.PreFrameIndex[k][i][0]); package.material[j].SetFloat("transitionProgress", vertexCache.instanceData.TransitionProgress[k][i][0]); Graphics.DrawMesh(vertexCache.mesh, vertexCache.instanceData.WorldMatrix[k][i][0], package.material[j], 0, null, j); } } package.instancingCount = 0; } vertexCache.runtimePackageIndex[k] = 0; } } }
public VertexCache.InstancingPackage CreatePackage(InstanceData data, Mesh mesh, Material[] originalMaterial, int index) { VertexCache.InstancingPackage package = new VertexCache.InstancingPackage(); package.material = new Material[mesh.subMeshCount]; package.subMeshCount = mesh.subMeshCount; package.size = 1; for (int i = 0; i != mesh.subMeshCount; ++i) { #if USE_CONSTANT_BUFFER package.material[i] = new Material(originalMaterial[i]); //package.material[i].name = "AniInstancing"; #if UNITY_5_6_OR_NEWER package.material[i].enableInstancing = UseInstancing; #endif if (UseInstancing) { package.material[i].EnableKeyword("INSTANCING_ON"); } else { package.material[i].DisableKeyword("INSTANCING_ON"); } package.propertyBlock = new MaterialPropertyBlock(); package.material[i].EnableKeyword("USE_CONSTANT_BUFFER"); package.material[i].DisableKeyword("USE_COMPUTE_BUFFER"); #endif } Matrix4x4[] mat = new Matrix4x4[instancingPackageSize]; float[] frameIndex = new float[instancingPackageSize]; data.worldMatrix[index].Add(mat); data.frameIndex[index].Add(frameIndex); return(package); }
private void SetupVertexCache(VertexCache vertexCache, MeshRenderer render, Mesh mesh, Transform[] boneTransform, int bonePerVertex) { int boneIndex = -1; if (boneTransform != null) { for (int k = 0; k != boneTransform.Length; ++k) { if (render.transform.parent.name.GetHashCode() == boneTransform[k].name.GetHashCode()) { boneIndex = k; break; } } } #if USE_CONSTANT_BUFFER if (boneIndex >= 0) { BindAttachment(vertexCache, vertexCache.mesh, boneIndex); } #else for (int j = 0; j != mesh.vertexCount; ++j) { vertexCache.vertex[j].weight.x = 1.0f; vertexCache.vertex[j].weight.y = -0.1f; vertexCache.vertex[j].weight.z = -0.1f; vertexCache.vertex[j].weight.w = -0.1f; vertexCache.vertex[j].boneIndex1 = boneIndex[0]; } #endif if (vertexCache.materials == null) { vertexCache.materials = render.materials; } #if USE_CONSTANT_BUFFER SetupAdditionalData(vertexCache); for (int i = 0; i != vertexCache.packageList.Length; ++i) { VertexCache.InstancingPackage package = CreatePackage(vertexCache.instanceData, vertexCache.mesh, render.materials, i); vertexCache.packageList[i].Add(package); PreparePackageMaterial(package, vertexCache, i); } #else vertexCache.bufVertex = new ComputeBuffer(vertexCache.vertex.Length, 16 + 16); vertexCache.bufVertex.SetData(vertexCache.vertex); #endif }
public void PreparePackageMaterial(VertexCache.InstancingPackage package, VertexCache vertexCache, int aniTextureIndex) { if (vertexCache.boneTextureIndex < 0) { return; } for (int i = 0; i != package.subMeshCount; ++i) { AnimationTexture texture = animationTextureList[vertexCache.boneTextureIndex]; package.material[i].SetTexture("_boneTexture", texture.boneTexture[aniTextureIndex]); package.material[i].SetInt("_boneTextureWidth", texture.boneTexture[aniTextureIndex].width); package.material[i].SetInt("_boneTextureHeight", texture.boneTexture[aniTextureIndex].height); package.material[i].SetInt("_boneTextureBlockWidth", texture.blockWidth); package.material[i].SetInt("_boneTextureBlockHeight", texture.blockHeight); } }
void RefreshMaterial() { if (vertexCachePool == null) { return; } foreach (var obj in vertexCachePool) { VertexCache cache = obj.Value; for (int j = 0; j != cache.packageList.Length; ++j) { for (int k = 0; k != cache.packageList[j].Count; ++k) { VertexCache.InstancingPackage package = cache.packageList[j][k]; PreparePackageMaterial(package, cache, j); } } } }
//SetupVertexCache(vertexCache, lod.meshRenderer[i], m, bones, bonePerVertex); private void SetupVertexCache(VertexCache vertexCache, MeshRenderer render, Mesh mesh, Transform[] boneTransform, int bonePerVertex) { int boneIndex = -1; if (boneTransform != null) { for (int k = 0; k != boneTransform.Length; ++k) { //找到vertexCache对应render的parent在boneTransform中的对应序号。 if (render.transform.parent.name.GetHashCode() == boneTransform[k].name.GetHashCode()) { boneIndex = k; break; } } } if (boneIndex >= 0) { BindAttachment(vertexCache, vertexCache.mesh, boneIndex); } if (vertexCache.materials == null) { vertexCache.materials = render.sharedMaterials; //材质从render.sharedMaterials里面获得,来自于prefab的materials,故需要在prefab中就对Materials更改为InstacingShader。 } SetupAdditionalData(vertexCache); for (int i = 0; i != vertexCache.packageList.Length; ++i) { VertexCache.InstancingPackage package = CreatePackage(vertexCache.instanceData, vertexCache.mesh, render.sharedMaterials, i); vertexCache.packageList[i].Add(package); PreparePackageMaterial(package, vertexCache, i); } }
private void SetupVertexCache(VertexCache vertexCache, SkinnedMeshRenderer render, Transform[] boneTransform, int bonePerVertex) { int[] boneIndex = null; if (render.bones.Length != boneTransform.Length) { if (render.bones.Length == 0) { boneIndex = new int[1]; int hashRenderParentName = render.transform.parent.name.GetHashCode(); for (int k = 0; k != boneTransform.Length; ++k) { if (hashRenderParentName == boneTransform[k].name.GetHashCode()) { boneIndex[0] = k; break; } } } else { boneIndex = new int[render.bones.Length]; for (int j = 0; j != render.bones.Length; ++j) { boneIndex[j] = -1; Transform trans = render.bones[j]; int hashTransformName = trans.name.GetHashCode(); for (int k = 0; k != boneTransform.Length; ++k) { if (hashTransformName == boneTransform[k].name.GetHashCode()) { boneIndex[j] = k; break; } } } if (boneIndex.Length == 0) { boneIndex = null; } } } UnityEngine.Profiling.Profiler.BeginSample("Copy the vertex data in SetupVertexCache()"); Mesh m = render.sharedMesh; BoneWeight[] boneWeights = m.boneWeights; Debug.Assert(boneWeights.Length > 0); #if USE_CONSTANT_BUFFER for (int j = 0; j != m.vertexCount; ++j) { vertexCache.weight[j].x = boneWeights[j].weight0; Debug.Assert(vertexCache.weight[j].x > 0.0f); vertexCache.weight[j].y = boneWeights[j].weight1; vertexCache.weight[j].z = boneWeights[j].weight2; vertexCache.weight[j].w = boneWeights[j].weight3; vertexCache.boneIndex[j].x = boneIndex == null ? boneWeights[j].boneIndex0 : boneIndex[boneWeights[j].boneIndex0]; vertexCache.boneIndex[j].y = boneIndex == null ? boneWeights[j].boneIndex1 : boneIndex[boneWeights[j].boneIndex1]; vertexCache.boneIndex[j].z = boneIndex == null ? boneWeights[j].boneIndex2 : boneIndex[boneWeights[j].boneIndex2]; vertexCache.boneIndex[j].w = boneIndex == null ? boneWeights[j].boneIndex3 : boneIndex[boneWeights[j].boneIndex3]; Debug.Assert(vertexCache.boneIndex[j].x >= 0); if (bonePerVertex == 3) { float rate = 1.0f / (vertexCache.weight[j].x + vertexCache.weight[j].y + vertexCache.weight[j].z); vertexCache.weight[j].x = vertexCache.weight[j].x * rate; vertexCache.weight[j].y = vertexCache.weight[j].y * rate; vertexCache.weight[j].z = vertexCache.weight[j].z * rate; vertexCache.weight[j].w = -0.1f; } else if (bonePerVertex == 2) { float rate = 1.0f / (vertexCache.weight[j].x + vertexCache.weight[j].y); vertexCache.weight[j].x = vertexCache.weight[j].x * rate; vertexCache.weight[j].y = vertexCache.weight[j].y * rate; vertexCache.weight[j].z = -0.1f; vertexCache.weight[j].w = -0.1f; } else if (bonePerVertex == 1) { vertexCache.weight[j].x = 1.0f; vertexCache.weight[j].y = -0.1f; vertexCache.weight[j].z = -0.1f; vertexCache.weight[j].w = -0.1f; } } #else for (int j = 0; j != m.vertexCount; ++j) { if (boneWeights.Length == 0) { vertexCache.vertex[j].weight.x = 1.0f; vertexCache.vertex[j].weight.y = -0.1f; vertexCache.vertex[j].weight.z = -0.1f; vertexCache.vertex[j].weight.w = -0.1f; vertexCache.vertex[j].boneIndex1 = boneIndex[0]; continue; } vertexCache.vertex[j].weight.x = boneWeights[j].weight0; vertexCache.vertex[j].weight.y = boneWeights[j].weight1; vertexCache.vertex[j].weight.z = boneWeights[j].weight2; vertexCache.vertex[j].weight.w = boneWeights[j].weight3; vertexCache.vertex[j].boneIndex1 = boneIndex == null || boneIndex[boneWeights[j].boneIndex0] < 0 ? boneWeights[j].boneIndex0 : boneIndex[boneWeights[j].boneIndex0]; vertexCache.vertex[j].boneIndex2 = boneIndex == null || boneIndex[boneWeights[j].boneIndex1] < 0 ? boneWeights[j].boneIndex1 : boneIndex[boneWeights[j].boneIndex1]; vertexCache.vertex[j].boneIndex3 = boneIndex == null || boneIndex[boneWeights[j].boneIndex2] < 0 ? boneWeights[j].boneIndex2 : boneIndex[boneWeights[j].boneIndex2]; vertexCache.vertex[j].boneIndex4 = boneIndex == null || boneIndex[boneWeights[j].boneIndex3] < 0 ? boneWeights[j].boneIndex3 : boneIndex[boneWeights[j].boneIndex3]; if (bonePerVertex == 3) { float rate = 1.0f / (vertexCache.vertex[j].weight.x + vertexCache.vertex[j].weight.y + vertexCache.vertex[j].weight.z); vertexCache.vertex[j].weight.x = vertexCache.vertex[j].weight.x * rate; vertexCache.vertex[j].weight.y = vertexCache.vertex[j].weight.y * rate; vertexCache.vertex[j].weight.z = vertexCache.vertex[j].weight.z * rate; vertexCache.vertex[j].weight.w = -0.1f; } else if (bonePerVertex == 2) { float rate = 1.0f / (vertexCache.vertex[j].weight.x + vertexCache.vertex[j].weight.y); vertexCache.vertex[j].weight.x = vertexCache.vertex[j].weight.x * rate; vertexCache.vertex[j].weight.y = vertexCache.vertex[j].weight.y * rate; vertexCache.vertex[j].weight.z = -0.1f; vertexCache.vertex[j].weight.w = -0.1f; } else if (bonePerVertex == 1) { vertexCache.vertex[j].weight.x = 1.0f; vertexCache.vertex[j].weight.y = -0.1f; vertexCache.vertex[j].weight.z = -0.1f; vertexCache.vertex[j].weight.w = -0.1f; } } #endif UnityEngine.Profiling.Profiler.EndSample(); if (vertexCache.materials == null) { vertexCache.materials = render.materials; } #if USE_CONSTANT_BUFFER SetupAdditionalData(vertexCache); for (int i = 0; i != vertexCache.packageList.Length; ++i) { VertexCache.InstancingPackage package = CreatePackage(vertexCache.instanceData, vertexCache.mesh, render.materials, i); vertexCache.packageList[i].Add(package); PreparePackageMaterial(package, vertexCache, i); } #else vertexCache.bufVertex = new ComputeBuffer(vertexCache.vertex.Length, 16 + 16); vertexCache.bufVertex.SetData(vertexCache.vertex); #endif }
void ApplyBoneMatrix() { Vector3 cameraPosition = cameraTransform.position; for (int i = 0; i != aniInstancingList.Count; ++i) { AnimationInstancing instance = aniInstancingList[i]; if (!instance.IsPlaying()) { continue; } if (instance.aniIndex < 0 && instance.parentInstance == null) { continue; } instance.UpdateAnimation(); if (!instance.visible) { continue; } if (instance.applyRootMotion) { ApplyRootMotion(instance); } instance.UpdateLod(cameraPosition); AnimationInstancing.LodInfo lod = instance.lodInfo[instance.lodLevel]; #if USE_CONSTANT_BUFFER VertexCache vertexCache = lod.vertexCacheList[0]; InstanceData data = vertexCache.instanceData; int aniTextureIndex = -1; if (instance.parentInstance != null) { aniTextureIndex = instance.parentInstance.aniTextureIndex; } else { aniTextureIndex = instance.aniTextureIndex; } int index = vertexCache.runtimePackageIndex[aniTextureIndex]; VertexCache.InstancingPackage pkg = vertexCache.packageList[aniTextureIndex][index]; int count = pkg.instancingCount - 1; if (count >= 0) { Matrix4x4 worldMat = instance.worldTransform.localToWorldMatrix; Matrix4x4[] arrayMat = data.worldMatrix[aniTextureIndex][index]; arrayMat[count].m00 = worldMat.m00; arrayMat[count].m01 = worldMat.m01; arrayMat[count].m02 = worldMat.m02; arrayMat[count].m03 = worldMat.m03; arrayMat[count].m10 = worldMat.m10; arrayMat[count].m11 = worldMat.m11; arrayMat[count].m12 = worldMat.m12; arrayMat[count].m13 = worldMat.m13; arrayMat[count].m20 = worldMat.m20; arrayMat[count].m21 = worldMat.m21; arrayMat[count].m22 = worldMat.m22; arrayMat[count].m23 = worldMat.m23; arrayMat[count].m30 = worldMat.m30; arrayMat[count].m31 = worldMat.m31; arrayMat[count].m32 = worldMat.m32; arrayMat[count].m33 = worldMat.m33; float frameIndex = 0; if (instance.parentInstance != null) { frameIndex = instance.parentInstance.aniInfo[instance.parentInstance.aniIndex].animationIndex + instance.parentInstance.curFrame; } else { frameIndex = instance.aniInfo[instance.aniIndex].animationIndex + instance.curFrame; } data.frameIndex[aniTextureIndex][index][count] = frameIndex; instance.boundingSpere.position.x = worldMat.m03; instance.boundingSpere.position.y = worldMat.m13; instance.boundingSpere.position.z = worldMat.m23; boundingSphere[i] = instance.boundingSpere; } for (int j = 0; j != lod.vertexCacheList.Length; ++j) { VertexCache cache = lod.vertexCacheList[j] as VertexCache; int packageIndex = cache.runtimePackageIndex[aniTextureIndex]; Debug.Assert(packageIndex < cache.packageList[aniTextureIndex].Count); VertexCache.InstancingPackage package = cache.packageList[aniTextureIndex][packageIndex]; if (package.instancingCount + 1 > instancingPackageSize) { ++cache.runtimePackageIndex[aniTextureIndex]; packageIndex = cache.runtimePackageIndex[aniTextureIndex]; if (packageIndex >= cache.packageList[aniTextureIndex].Count) { VertexCache.InstancingPackage newPackage = CreatePackage(cache.instanceData, cache.mesh, vertexCache.materials, aniTextureIndex); cache.packageList[aniTextureIndex].Add(newPackage); PreparePackageMaterial(newPackage, cache, aniTextureIndex); newPackage.instancingCount = 1; } } else { ++package.instancingCount; } } #else for (int j = 0; j != lod.vertexCacheList.Length; ++j) { VertexCache cache = lod.vertexCacheList[j] as VertexCache; if (cache.instancingData == null) { cache.instancingData = new InstancingData[cache.instancingCount]; cache.bufInstance = new ComputeBuffer((int)cache.instancingCount, 64 + 4 + 4 + 8); } Matrix4x4 worldMat = instance.worldTransform.localToWorldMatrix; cache.instancingData[cache.currentInstancingIndex].worldMatrix.m00 = worldMat.m00; cache.instancingData[cache.currentInstancingIndex].worldMatrix.m01 = worldMat.m01; cache.instancingData[cache.currentInstancingIndex].worldMatrix.m02 = worldMat.m02; cache.instancingData[cache.currentInstancingIndex].worldMatrix.m03 = worldMat.m03; cache.instancingData[cache.currentInstancingIndex].worldMatrix.m10 = worldMat.m10; cache.instancingData[cache.currentInstancingIndex].worldMatrix.m11 = worldMat.m11; cache.instancingData[cache.currentInstancingIndex].worldMatrix.m12 = worldMat.m12; cache.instancingData[cache.currentInstancingIndex].worldMatrix.m13 = worldMat.m13; cache.instancingData[cache.currentInstancingIndex].worldMatrix.m20 = worldMat.m20; cache.instancingData[cache.currentInstancingIndex].worldMatrix.m21 = worldMat.m21; cache.instancingData[cache.currentInstancingIndex].worldMatrix.m22 = worldMat.m22; cache.instancingData[cache.currentInstancingIndex].worldMatrix.m23 = worldMat.m23; cache.instancingData[cache.currentInstancingIndex].worldMatrix.m30 = worldMat.m30; cache.instancingData[cache.currentInstancingIndex].worldMatrix.m31 = worldMat.m31; cache.instancingData[cache.currentInstancingIndex].worldMatrix.m32 = worldMat.m32; cache.instancingData[cache.currentInstancingIndex].worldMatrix.m33 = worldMat.m33; cache.instancingData[cache.currentInstancingIndex].frameIndex = instance.aniInfo[animationIndex].animationIndex + instance.curFrame; cache.instancingData[cache.currentInstancingIndex].animationIndex = 0; ++cache.currentInstancingIndex; } #endif } }
private void Render() { foreach (var obj in vertexCachePool) { VertexCache vertexCache = obj.Value; #if USE_CONSTANT_BUFFER for (int k = 0; k != vertexCache.packageList.Length; ++k) { for (int i = 0; i != vertexCache.packageList[k].Count; ++i) { VertexCache.InstancingPackage package = vertexCache.packageList[k][i]; if (package.instancingCount == 0) { continue; } for (int j = 0; j != package.subMeshCount; ++j) { if (useInstancing) { #if UNITY_EDITOR PreparePackageMaterial(package, vertexCache, k); #endif package.propertyBlock.SetFloatArray("frameIndex", vertexCache.instanceData.frameIndex[k][i]); Graphics.DrawMeshInstanced(vertexCache.mesh, j, package.material[j], vertexCache.instanceData.worldMatrix[k][i], package.instancingCount, package.propertyBlock); } else { package.material[j].SetFloat("frameIndex", vertexCache.instanceData.frameIndex[k][i][0]); Graphics.DrawMesh(vertexCache.mesh, vertexCache.instanceData.worldMatrix[k][i][0], package.material[j], 0, null, j); } } package.instancingCount = 1; } vertexCache.runtimePackageIndex[k] = 0; } #else if (obj.Value.instancingData == null) { continue; } vertexCache.bufInstance.SetData(obj.Value.instancingData); for (int i = 0; i != vertexCache.subMeshCount; ++i) { Material material = vertexCache.instanceMaterial[i]; material.SetBuffer("buf_InstanceMatrices", vertexCache.bufInstance); vertexCache.args[i][1] = (uint)vertexCache.currentInstancingIndex; vertexCache.bufArgs[i].SetData(vertexCache.args[i]); Graphics.DrawMeshInstancedIndirect(vertexCache.mesh, i, vertexCache.instanceMaterial[i], new Bounds(Vector3.zero, new Vector3(10000.0f, 10000.0f, 10000.0f)), vertexCache.bufArgs[i]); } vertexCache.currentInstancingIndex = 0; #endif } }
private void generateBoneMatrixData() { Vector3 cameraPosition = cameraTransform.position; for (int i = 0; i != _InstancingData.Count; ++i) //对列表中每个对象做Instancing。 { Instancing instance = _InstancingData[i]; //if (!instance.IsPlaying()) // continue; //if (instance.aniIndex < 0 && instance.parentInstance == null) // continue; instance.UpdateAnimation(); //if (!instance.visible) // continue; //here only one Lod //instance.UpdateLod(cameraPosition); //Instancing.LodInfo lod = instance.lodInfo[instance.lodLevel]; Instancing.LodInfo lod = instance.lodInfo[0]; int aniTextureIndex = -1; //if (instance.parentInstance != null) // aniTextureIndex = instance.parentInstance.aniTextureIndex; //else aniTextureIndex = instance.aniTextureIndex; for (int j = 0; j != lod.vertexCacheList.Length; ++j) { VertexCache cache = lod.vertexCacheList[j] as VertexCache; int packageIndex = cache.runtimePackageIndex[aniTextureIndex]; Debug.Assert(packageIndex < cache.packageList[aniTextureIndex].Count); VertexCache.InstancingPackage package = cache.packageList[aniTextureIndex][packageIndex]; if (package.instancingCount + 1 > instancingPackageSize) { ++cache.runtimePackageIndex[aniTextureIndex]; packageIndex = cache.runtimePackageIndex[aniTextureIndex]; if (packageIndex >= cache.packageList[aniTextureIndex].Count) { VertexCache.InstancingPackage newPackage = CreatePackage(cache.instanceData, cache.mesh, cache.materials, aniTextureIndex); cache.packageList[aniTextureIndex].Add(newPackage); PreparePackageMaterial(newPackage, cache, aniTextureIndex); newPackage.instancingCount = 1; } } else { ++package.instancingCount; } } VertexCache vertexCache = lod.vertexCacheList[0]; InstanceData data = vertexCache.instanceData; int index = vertexCache.runtimePackageIndex[aniTextureIndex]; VertexCache.InstancingPackage pkg = vertexCache.packageList[aniTextureIndex][index]; int count = pkg.instancingCount - 1; if (count >= 0) { Matrix4x4 worldMat = instance.worldTransform.localToWorldMatrix; Matrix4x4[] arrayMat = data.WorldMatrix[aniTextureIndex][index]; arrayMat[count].m00 = worldMat.m00; arrayMat[count].m01 = worldMat.m01; arrayMat[count].m02 = worldMat.m02; arrayMat[count].m03 = worldMat.m03; arrayMat[count].m10 = worldMat.m10; arrayMat[count].m11 = worldMat.m11; arrayMat[count].m12 = worldMat.m12; arrayMat[count].m13 = worldMat.m13; arrayMat[count].m20 = worldMat.m20; arrayMat[count].m21 = worldMat.m21; arrayMat[count].m22 = worldMat.m22; arrayMat[count].m23 = worldMat.m23; arrayMat[count].m30 = worldMat.m30; arrayMat[count].m31 = worldMat.m31; arrayMat[count].m32 = worldMat.m32; arrayMat[count].m33 = worldMat.m33; float frameIndex = 0, preFrameIndex = -1; //if (instance.parentInstance != null) //{ // frameIndex = instance.parentInstance.aniInfo[instance.parentInstance.aniIndex].animationIndex + // instance.parentInstance.curFrame; // if (instance.parentInstance.preAniIndex >= 0) // preFrameIndex = // instance.parentInstance.aniInfo[instance.parentInstance.preAniIndex].animationIndex + // instance.parentInstance.preAniFrame; //} //else //{ //frameIndex = instance.aniInfo[instance.aniIndex].animationIndex + instance.curFrame; //if (instance.preAniIndex >= 0) // preFrameIndex = instance.aniInfo[instance.preAniIndex].animationIndex + instance.preAniFrame; frameIndex = instance.curFrame; if (instance.preAniIndex >= 0) { preFrameIndex = instance.preAniFrame; } //} data.FrameIndex[aniTextureIndex][index][count] = frameIndex; data.PreFrameIndex[aniTextureIndex][index][count] = preFrameIndex; data.TransitionProgress[aniTextureIndex][index][count] = instance.transitionProgress; } } }