Example #1
0
        void LateUpdate()
#endif
        {
            if (m_SpriteRenderer.isVisible)
            {
                if (m_CurrentDeformSprite != sprite)
                {
                    DeactivateSkinning();
                    m_CurrentDeformSprite = sprite;
                    UpdateSpriteDeform();
                }
                if (isValid && !batchSkinning && this.enabled)
                {
                    var transformHash     = SpriteSkinUtility.CalculateTransformHash(this);
                    var spriteVertexCount = sprite.GetVertexStreamSize() * sprite.GetVertexCount();
                    if (spriteVertexCount > 0 && m_TransformsHash != transformHash)
                    {
                        var inputVertices = GetDeformedVertices(spriteVertexCount);
                        SpriteSkinUtility.Deform(sprite, gameObject.transform.worldToLocalMatrix, boneTransforms, ref inputVertices);
                        SpriteSkinUtility.UpdateBounds(this, transform.worldToLocalMatrix, rootBone.localToWorldMatrix);
                        InternalEngineBridge.SetDeformableBuffer(spriteRenderer, inputVertices);
                        m_TransformsHash      = transformHash;
                        m_CurrentDeformSprite = sprite;
                    }
                }
            }
        }
            public void Execute(int i)
            {
                var rootTransformId    = localToWorldArray[i].Value;
                var boneTransforms     = boneTransformArray[entities[i]].Reinterpret <float4x4>().AsNativeArray();
                var deformableVertices = deformedArray[entities[i]].Reinterpret <float3>().AsNativeArray();

                SpriteSkinUtility.Deform(rootTransformId, vertices, boneWeights, boneTransforms, bindPoses, deformableVertices);
            }
Example #3
0
        public unsafe void Execute(int i)
        {
            var   spriteSkin        = spriteSkinData[i];
            byte *deformedPosOffset = (byte *)vertices.GetUnsafePtr();
            NativeSlice <float3> deformableVerticesFloat3 = NativeSliceUnsafeUtility.ConvertExistingDataToNativeSlice <float3>(deformedPosOffset + spriteSkin.deformVerticesStartPos, spriteSkin.spriteVertexStreamSize, spriteSkin.spriteVertexCount);

#if ENABLE_UNITY_COLLECTIONS_CHECKS
            NativeSliceUnsafeUtility.SetAtomicSafetyHandle(ref deformableVerticesFloat3, NativeSliceUnsafeUtility.GetAtomicSafetyHandle(vertices));
#endif

            bounds[i] = SpriteSkinUtility.CalculateSpriteSkinBounds(deformableVerticesFloat3);
        }
Example #4
0
        void LateUpdate()
#endif
        {
            CacheCurrentSprite();
            if (isValid && !batchSkinning && this.enabled && (this.alwaysUpdate || this.spriteRenderer.isVisible))
            {
                var transformHash     = SpriteSkinUtility.CalculateTransformHash(this);
                var spriteVertexCount = sprite.GetVertexStreamSize() * sprite.GetVertexCount();
                if (spriteVertexCount > 0 && m_TransformsHash != transformHash)
                {
                    var inputVertices = GetDeformedVertices(spriteVertexCount);
                    SpriteSkinUtility.Deform(sprite, gameObject.transform.worldToLocalMatrix, boneTransforms, inputVertices.array);
                    SpriteSkinUtility.UpdateBounds(this, inputVertices.array);
                    InternalEngineBridge.SetDeformableBuffer(spriteRenderer, inputVertices.array);
                    m_TransformsHash      = transformHash;
                    m_CurrentDeformSprite = GetSpriteInstanceID();
                }
            }
        }