internal void UpdateSpriteDeform() { if (sprite == null) { m_SpriteVertices = NativeCustomSlice <Vector3> .Default(); m_SpriteTangents = NativeCustomSlice <Vector4> .Default(); m_SpriteBoneWeights = NativeCustomSlice <BoneWeight> .Default(); m_SpriteBindPoses = NativeCustomSlice <Matrix4x4> .Default(); m_SpriteHasTangents = false; m_SpriteVertexStreamSize = 0; m_SpriteVertexCount = 0; m_SpriteTangentVertexOffset = 0; } else { m_SpriteVertices = new NativeCustomSlice <Vector3>(sprite.GetVertexAttribute <Vector3>(UnityEngine.Rendering.VertexAttribute.Position)); m_SpriteTangents = new NativeCustomSlice <Vector4>(sprite.GetVertexAttribute <Vector4>(UnityEngine.Rendering.VertexAttribute.Tangent)); m_SpriteBoneWeights = new NativeCustomSlice <BoneWeight>(sprite.GetVertexAttribute <BoneWeight>(UnityEngine.Rendering.VertexAttribute.BlendWeight)); m_SpriteBindPoses = new NativeCustomSlice <Matrix4x4>(sprite.GetBindPoses()); m_SpriteHasTangents = sprite.HasVertexAttribute(Rendering.VertexAttribute.Tangent); m_SpriteVertexStreamSize = sprite.GetVertexStreamSize(); m_SpriteVertexCount = sprite.GetVertexCount(); m_SpriteTangentVertexOffset = sprite.GetVertexStreamOffset(Rendering.VertexAttribute.Tangent); } }
void CacheBatchBoneTransform() { if (boneTransforms != null) { int boneCount = 0; for (int i = 0; i < boneTransforms.Length; ++i) { if (boneTransforms[i] != null) { ++boneCount; } } if (m_BoneTransformId.IsCreated) { for (int i = 0; i < m_BoneTransformId.Length; ++i) { SpriteSkinComposite.instance.RemoveTransformById(m_BoneTransformId[i]); } NativeArrayHelpers.ResizeIfNeeded(ref m_BoneTransformId, boneCount); } else { m_BoneTransformId = new NativeArray <int>(boneCount, Allocator.Persistent); } m_BoneTransformIdNativeSlice = new NativeCustomSlice <int>(m_BoneTransformId); for (int i = 0, j = 0; i < m_BoneTransformId.Length; ++i) { if (boneTransforms[i] != null) { m_BoneTransformId[j] = boneTransforms[i].GetInstanceID(); ++j; } } if (this.enabled) { SpriteSkinComposite.instance.AddSpriteSkinBoneTransform(this); } } else { if (m_BoneTransformId.IsCreated) { NativeArrayHelpers.ResizeIfNeeded(ref m_BoneTransformId, 0); } else { m_BoneTransformId = new NativeArray <int>(0, Allocator.Persistent); } } }
internal NativeCustomSliceEnumerator(NativeSlice <byte> slice, int length, int stride) { nativeCustomSlice = new NativeCustomSlice <T>(slice, length, stride); index = -1; Reset(); }
void CacheBoneTransformIds(bool forceUpdate = false) { if (!m_BoneCacheUpdateToDate || forceUpdate) { SpriteSkinComposite.instance.RemoveTransformById(m_RootBoneTransformId); if (rootBone != null) { m_RootBoneTransformId = rootBone.GetInstanceID(); if (this.enabled) { SpriteSkinComposite.instance.AddSpriteSkinRootBoneTransform(this); } } else { m_RootBoneTransformId = 0; } if (boneTransforms != null) { int boneCount = 0; for (int i = 0; i < boneTransforms.Length; ++i) { if (boneTransforms[i] != null) { ++boneCount; } } if (m_BoneTransformId.IsCreated) { for (int i = 0; i < m_BoneTransformId.Length; ++i) { SpriteSkinComposite.instance.RemoveTransformById(m_BoneTransformId[i]); } NativeArrayHelpers.ResizeIfNeeded(ref m_BoneTransformId, boneCount); } else { m_BoneTransformId = new NativeArray <int>(boneCount, Allocator.Persistent); } m_BoneTransformIdNativeSlice = new NativeCustomSlice <int>(m_BoneTransformId); for (int i = 0, j = 0; i < boneTransforms.Length; ++i) { if (boneTransforms[i] != null) { m_BoneTransformId[j] = boneTransforms[i].GetInstanceID(); ++j; } } if (this.enabled) { SpriteSkinComposite.instance.AddSpriteSkinBoneTransform(this); } } else { if (m_BoneTransformId.IsCreated) { NativeArrayHelpers.ResizeIfNeeded(ref m_BoneTransformId, 0); } else { m_BoneTransformId = new NativeArray <int>(0, Allocator.Persistent); } } CacheValidFlag(); m_BoneCacheUpdateToDate = true; SpriteSkinComposite.instance.CopyToSpriteSkinData(this); } }