public int GetBoneIdx(string boneName) { if (BoneHashToIdx.TryGetValue(CraSettings.BoneHashFunction(boneName), out int idx)) { return(idx); } return(-1); }
public CraBone(string boneName, CraTransformCurve curve) { if (CraSettings.BoneHashFunction == null) { throw new Exception("CraSettings.BoneHashFunction is not assigned! You need to assign a custom hash function!"); } BoneHash = CraSettings.BoneHashFunction(boneName); Curve = curve; }
public CraMask(bool maskChildren, params string[] boneNames) { if (CraSettings.BoneHashFunction == null) { throw new Exception("CraSettings.BoneHashFunction is not assigned! You need to assign a custom hash function!"); } BoneHashes = new HashSet <int>(); for (int i = 0; i < boneNames.Length; ++i) { BoneHashes.Add(CraSettings.BoneHashFunction(boneNames[i])); } MaskChildren = maskChildren; }
void PlayerAssignInternal(List <int> assignedBones, CraClip clip, int clipIdx, Transform current, CraMask?mask = null, bool maskedChild = false) { void AddBone(int clipBoneIdx) { int allocIdx; if (!KnownBoneIndices.TryGetValue(current, out allocIdx)) { allocIdx = BoneData.Alloc(); KnownBoneIndices.Add(current, allocIdx); BonePlayerClipIndices.Add(new Dictionary <int, int>()); Bones.Add(current); Debug.Assert(KnownBoneIndices.Count == BoneData.GetNumAllocated()); Debug.Assert(BonePlayerClipIndices.Count == BoneData.GetNumAllocated()); Debug.Assert(Bones.length == BoneData.GetNumAllocated()); } BonePlayerClipIndices[allocIdx].Add(clipIdx, clipBoneIdx); assignedBones.Add(allocIdx); } int boneHash = CraSettings.BoneHashFunction(current.name); bool isMasked = false; if (clip.BoneHashToIdx.TryGetValue(boneHash, out int clipBoneIdx)) { if (mask.HasValue) { if (maskedChild || mask.Value.BoneHashes.Contains(boneHash)) { AddBone(clipBoneIdx); isMasked = mask.Value.MaskChildren; } } else { AddBone(clipBoneIdx); } } for (int i = 0; i < current.childCount; ++i) { PlayerAssignInternal(assignedBones, clip, clipIdx, current.GetChild(i), mask, isMasked); } }