internal void CopyToSpriteSkinData(ref SpriteSkinData data, int spriteSkinIndex)
        {
            CacheBoneTransformIds();
            CacheCurrentSprite(m_AutoRebind);

            data.vertices               = m_SpriteVertices;
            data.boneWeights            = m_SpriteBoneWeights;
            data.bindPoses              = m_SpriteBindPoses;
            data.tangents               = m_SpriteTangents;
            data.hasTangents            = m_SpriteHasTangents;
            data.spriteVertexStreamSize = m_SpriteVertexStreamSize;
            data.spriteVertexCount      = m_SpriteVertexCount;
            data.tangentVertexOffset    = m_SpriteTangentVertexOffset;
            data.transformId            = m_TransformId;
            data.boneTransformId        = m_BoneTransformIdNativeSlice;
            m_DataIndex = spriteSkinIndex;
        }
示例#2
0
        internal bool GetSpriteSkinBatchData(ref NativeArray <SpriteSkinData> data, ref SpriteSkinBatchProcessData batchProcessData, ref PerSkinJobData perskinJobData, ref int vertexBufferSize, int index, int spriteSkinIndex)
        {
            if (m_CurrentDeformSprite != sprite)
            {
                DeactivateSkinning();
                m_CurrentDeformSprite = sprite;
                UpdateSpriteDeform();
                CacheValidFlag();
            }
            if (m_IsValid)
            {
                Profiler.BeginSample("SpriteSkinData");
                data[index] = new SpriteSkinData()
                {
                    vertices               = m_SpriteVertices,
                    boneWeights            = m_SpriteBoneWeights,
                    bindPoses              = m_SpriteBindPoses,
                    tangents               = m_SpriteTangents,
                    hasTangents            = m_SpriteHasTangents,
                    spriteVertexStreamSize = m_SpriteVertexStreamSize,
                    spriteVertexCount      = m_SpriteVertexCount,
                    tangentVertexOffset    = m_SpriteTangentVertexOffset,
                    spriteSkinIndex        = spriteSkinIndex,
                    deformVerticesStartPos = vertexBufferSize,
                    rootBoneTransformId    = m_RootBoneTransformId,
                    transformId            = m_TransformId,
                    boneTransformId        = m_BoneTransformIdNativeSlice
                };
                Profiler.EndSample();
                Profiler.BeginSample("BatchProcessData");
                batchProcessData.rootBoneTransformId[index] = m_RootBoneTransformId;
                batchProcessData.rootTransformId[index]     = m_TransformId;
                batchProcessData.spriteBound[index]         = bounds;
                Profiler.EndSample();

                Profiler.BeginSample("PerskinJobData");
                perskinJobData.verticesIndex.x = perskinJobData.verticesIndex.y;
                perskinJobData.verticesIndex.y = perskinJobData.verticesIndex.x + m_SpriteVertexCount;
                vertexBufferSize += m_SpriteVertexCount * m_SpriteVertexStreamSize;
                perskinJobData.bindPosesIndex.x = perskinJobData.bindPosesIndex.y;
                perskinJobData.bindPosesIndex.y = perskinJobData.bindPosesIndex.x + m_SpriteBindPoses.Length;
                Profiler.EndSample();
                return(true);
            }
            return(false);
        }
        internal bool GetSpriteSkinBatchData(ref NativeArray <SpriteSkinData> data, ref SpriteSkinBatchProcessData batchProcessData, ref PerSkinJobData perskinJobData, ref int vertexBufferSize, int dataIndex, int spriteSkinIndex)
        {
            CacheBoneTransformIds();
            CacheCurrentSprite();
            if (m_IsValid && (alwaysUpdate || spriteRenderer.isVisible) && spriteRenderer.enabled)
            {
                Profiler.BeginSample("SpriteSkinData");
                m_DataIndex = dataIndex;
                m_CurrentDeformVerticesLength = m_SpriteVertexCount * m_SpriteVertexStreamSize;
                data[dataIndex] = new SpriteSkinData()
                {
                    vertices               = m_SpriteVertices,
                    boneWeights            = m_SpriteBoneWeights,
                    bindPoses              = m_SpriteBindPoses,
                    tangents               = m_SpriteTangents,
                    hasTangents            = m_SpriteHasTangents,
                    spriteVertexStreamSize = m_SpriteVertexStreamSize,
                    spriteVertexCount      = m_SpriteVertexCount,
                    tangentVertexOffset    = m_SpriteTangentVertexOffset,
                    spriteSkinIndex        = spriteSkinIndex,
                    deformVerticesStartPos = vertexBufferSize,
                    rootBoneTransformId    = m_RootBoneTransformId,
                    transformId            = m_TransformId,
                    boneTransformId        = m_BoneTransformIdNativeSlice
                };
                Profiler.EndSample();
                Profiler.BeginSample("BatchProcessData");
                batchProcessData.rootBoneTransformId[dataIndex] = m_RootBoneTransformId;
                batchProcessData.rootTransformId[dataIndex]     = m_TransformId;
                batchProcessData.spriteBound[dataIndex]         = bounds;
                Profiler.EndSample();

                Profiler.BeginSample("PerskinJobData");
                perskinJobData.verticesIndex.x = perskinJobData.verticesIndex.y;
                perskinJobData.verticesIndex.y = perskinJobData.verticesIndex.x + m_SpriteVertexCount;
                vertexBufferSize += m_CurrentDeformVerticesLength;
                perskinJobData.bindPosesIndex.x = perskinJobData.bindPosesIndex.y;
                perskinJobData.bindPosesIndex.y = perskinJobData.bindPosesIndex.x + m_SpriteBindPoses.Length;
                Profiler.EndSample();
                return(true);
            }
            m_DataIndex = -1;
            return(false);
        }