private void CharacterPartChanged(CharacterPartCache characterPart) { var meshPreview = characterPart.sprite.GetMeshPreview(); Debug.Assert(meshPreview != null); meshPreview.SetSkinningDirty(); }
void OnCharacterPartChanged(CharacterPartCache part) { SetAnimationEvent(new AnimationEvent() { sub_type = AnimationEventType.CharacterPartChanged, data = "" }); }
private TreeViewItem CreateTreeViewItem(CharacterPartCache part, CharacterGroupCache[] groups, int depth) { var name = part.sprite.name; return(new TreeViewItemBase <ISpriteVisibilityItem>(part.sprite.GetInstanceID(), depth, name, new SpriteVisibilitySpriteItem() { sprite = part, })); }
private bool NeedsAssociateBones(CharacterPartCache characterPart) { if (characterPart == null) { return(false); } var skeleton = characterPart.skinningCache.character.skeleton; return(characterPart.BoneCount == 0 || (characterPart.BoneCount == 1 && characterPart.GetBone(0) == skeleton.GetBone(0))); }
private void CharacterPartChanged(CharacterPartCache characterPart) { var character = skinningCache.character; Debug.Assert(character != null); using (new DefaultPoseScope(character.skeleton)) { skinningCache.CreateSpriteSheetSkeleton(characterPart); DataModified(); } if (skinningCache.mode == SkinningMode.Character) { characterPart.SyncSpriteSheetSkeleton(); } }
private void UpdateCharacterPart(CharacterPartCache characterPart) { var sprite = characterPart.sprite; var characterPartBones = characterPart.bones; var newBones = new List <BoneCache>(characterPartBones); var hasNullBones = newBones.Contains(null); newBones.RemoveAll(b => IsRemoved(b)); characterPartBones = newBones.ToArray(); characterPart.bones = characterPartBones; sprite.UpdateMesh(characterPartBones); if (hasNullBones) { sprite.SmoothFill(); } }
public void CreateSpriteSheetSkeleton(CharacterPartCache characterPart) { UpdateCharacterPart(characterPart); Debug.Assert(character != null); Debug.Assert(character.skeleton != null); Debug.Assert(character.skeleton.isPosePreview == false); var sprite = characterPart.sprite; var characterPartBones = characterPart.bones; var skeleton = sprite.GetSkeleton(); Debug.Assert(skeleton != null); var spriteBones = characterPartBones.ToSpriteBone(characterPart.localToWorldMatrix); skeleton.SetBones(CreateBoneCacheFromSpriteBones(spriteBones, 1.0f), false); events.skeletonTopologyChanged.Invoke(skeleton); }
private void UpdateCharacterPart(CharacterPartCache characterPart) { var sprite = characterPart.sprite; var characterPartBones = characterPart.bones; var newBones = new List <BoneCache>(characterPartBones); newBones.RemoveAll(b => { return(b == null || IsRemoved(b) || b.skeleton != character.skeleton); }); var removedBonesCount = characterPartBones.Length - newBones.Count; characterPartBones = newBones.ToArray(); characterPart.bones = characterPartBones; sprite.UpdateMesh(characterPartBones); if (removedBonesCount > 0) { sprite.SmoothFill(); } }
public static void DeassociateUnusedBones(this CharacterPartCache characterPart) { var skinningCache = characterPart.skinningCache; var bones = characterPart.bones; if (bones.Length == 0) { return; } Debug.Assert(characterPart.sprite != null); var mesh = characterPart.sprite.GetMesh(); Debug.Assert(mesh != null); var vertices = mesh.vertices; var newBonesSet = new HashSet <BoneCache>(); foreach (var vertex in vertices) { var boneWeight = vertex.editableBoneWeight; foreach (BoneWeightChannel channel in boneWeight) { if (channel.enabled) { newBonesSet.Add(bones[channel.boneIndex]); } } } bones = new List <BoneCache>(newBonesSet).ToArray(); characterPart.bones = bones; characterPart.sprite.UpdateMesh(bones); skinningCache.events.characterPartChanged.Invoke(characterPart); }
public static void SyncSpriteSheetSkeleton(this CharacterPartCache characterPart) { var skinningCache = characterPart.skinningCache; var character = skinningCache.character; var characterSkeleton = character.skeleton; var spriteSkeleton = characterPart.sprite.GetSkeleton(); var spriteSkeletonBones = spriteSkeleton.bones; var characterPartBones = characterPart.bones; Debug.Assert(spriteSkeletonBones.Length == characterPartBones.Length); for (var i = 0; i < characterPartBones.Length; ++i) { var spriteBone = spriteSkeletonBones[i]; var characterBone = characterPartBones[i]; var childWorldPose = spriteBone.GetChildrenWoldPose(); spriteBone.position = spriteSkeleton.localToWorldMatrix.MultiplyPoint3x4( characterPart.worldToLocalMatrix.MultiplyPoint3x4(characterBone.position)); spriteBone.rotation = characterBone.rotation; spriteBone.length = characterBone.length; spriteBone.name = characterBone.name; spriteBone.depth = characterBone.depth; spriteBone.bindPoseColor = characterBone.bindPoseColor; spriteBone.SetChildrenWorldPose(childWorldPose); } if (characterSkeleton.isPosePreview) { spriteSkeleton.SetPosePreview(); } else { spriteSkeleton.SetDefaultPose(); } }
private TreeViewItem CreateTreeViewItem(CharacterPartCache part) { var name = part.sprite.name; return(new TreeViewItemBase <CharacterPartCache>(part.GetInstanceID(), 0, name, part)); }