/** * @private */ internal void _updateFFDTimelineStates() { var time = _time; if (!_animationData.hasAsynchronyTimeline) { time = _timeline._currentTime; } var ffdTimelineStates = new Dictionary <string, FFDTimelineState>(); foreach (var ffdTimelineState in _ffdTimelines) // Create ffd timelines map. { ffdTimelineStates[ffdTimelineState.slot.name] = ffdTimelineState; } foreach (var slot in _armature.GetSlots()) { var slotTimelineName = slot.name; var parentTimelineName = slot.parent.name; if (slot._meshData != null) { var displayIndex = slot.displayIndex; var rawMeshData = displayIndex < slot._displayDataSet.displays.Count ? slot._displayDataSet.displays[displayIndex].mesh : null; if (slot._meshData == rawMeshData) { var ffdTimelineData = _animationData.GetFFDTimeline(_armature._skinData.name, slotTimelineName, displayIndex); if (ffdTimelineData != null && ContainsBoneMask(parentTimelineName)) // && !_isFadeOut { var ffdTimelineState = ffdTimelineStates.ContainsKey(slotTimelineName) ? ffdTimelineStates[slotTimelineName] : null; if (ffdTimelineState != null && ffdTimelineState._timeline == ffdTimelineData) // Remove ffd timeline from map. { ffdTimelineStates.Remove(slotTimelineName); } else // Create new ffd timeline. { ffdTimelineState = BaseObject.BorrowObject <FFDTimelineState>(); ffdTimelineState.slot = slot; ffdTimelineState.FadeIn(_armature, this, ffdTimelineData, time); _ffdTimelines.Add(ffdTimelineState); } } else { for (int i = 0, l = slot._ffdVertices.Count; i < l; ++i) // Clear slot ffd. { slot._ffdVertices[i] = 0.0f; } slot._ffdDirty = true; } } } } foreach (var ffdTimelineState in ffdTimelineStates.Values)// Remove ffd timelines. { //ffdTimelineState.slot._ffdDirty = true; _ffdTimelines.Remove(ffdTimelineState); ffdTimelineState.ReturnToPool(); } }
static int GetFFDTimeline(IntPtr L) { try { ToLua.CheckArgsCount(L, 3); DragonBones.AnimationData obj = (DragonBones.AnimationData)ToLua.CheckObject(L, 1, typeof(DragonBones.AnimationData)); string arg0 = ToLua.CheckString(L, 2); string arg1 = ToLua.CheckString(L, 3); System.Collections.Generic.Dictionary <string, DragonBones.FFDTimelineData> o = obj.GetFFDTimeline(arg0, arg1); ToLua.PushObject(L, o); return(1); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e)); } }
/** * @private */ internal void _updateTimelineStates() { var boneTimelineStates = new Dictionary <string, BoneTimelineState>(); var slotTimelineStates = new Dictionary <string, SlotTimelineState>(); var ffdTimelineStates = new Dictionary <string, FFDTimelineState>(); for (int i = 0, l = _boneTimelines.Count; i < l; ++i) // Creat bone timelines map. { var boneTimelineState = _boneTimelines[i]; boneTimelineStates[boneTimelineState.bone.name] = boneTimelineState; } var bones = _armature.GetBones(); for (int i = 0, l = bones.Count; i < l; ++i) { var bone = bones[i]; var boneTimelineName = bone.name; if (ContainsBoneMask(boneTimelineName)) { var boneTimelineData = _animationData.GetBoneTimeline(boneTimelineName); if (boneTimelineData != null) { if (boneTimelineStates.ContainsKey(boneTimelineName)) // Remove bone timeline from map. { boneTimelineStates.Remove(boneTimelineName); } else // Create new bone timeline. { var boneTimelineState = BaseObject.BorrowObject <BoneTimelineState>(); boneTimelineState.bone = bone; boneTimelineState._init(_armature, this, boneTimelineData); _boneTimelines.Add(boneTimelineState); } } } } foreach (var boneTimelineState in boneTimelineStates.Values) // Remove bone timelines. { boneTimelineState.bone.InvalidUpdate(); // _boneTimelines.Remove(boneTimelineState); boneTimelineState.ReturnToPool(); } for (int i = 0, l = _slotTimelines.Count; i < l; ++i) // Creat slot timelines map. { var slotTimelineState = _slotTimelines[i]; slotTimelineStates[slotTimelineState.slot.name] = slotTimelineState; } for (int i = 0, l = _ffdTimelines.Count; i < l; ++i) // Creat ffd timelines map. { var ffdTimelineState = _ffdTimelines[i]; var display = ffdTimelineState._timelineData.display; var meshName = display.inheritAnimation ? display.mesh.name : display.name; ffdTimelineStates[meshName] = ffdTimelineState; } var slots = _armature.GetSlots(); for (int i = 0, l = slots.Count; i < l; ++i) { var slot = slots[i]; var slotTimelineName = slot.name; var parentTimelineName = slot.parent.name; var resetFFDVertices = false; if (ContainsBoneMask(parentTimelineName)) { var slotTimelineData = _animationData.GetSlotTimeline(slotTimelineName); if (slotTimelineData != null) { if (slotTimelineStates.ContainsKey(slotTimelineName)) // Remove slot timeline from map. { slotTimelineStates.Remove(slotTimelineName); } else // Create new slot timeline. { var slotTimelineState = BaseObject.BorrowObject <SlotTimelineState>(); slotTimelineState.slot = slot; slotTimelineState._init(_armature, this, slotTimelineData); _slotTimelines.Add(slotTimelineState); } } var ffdTimelineDatas = _animationData.GetFFDTimeline(_armature._skinData.name, slotTimelineName); if (ffdTimelineDatas != null) { foreach (var pair in ffdTimelineDatas) { if (ffdTimelineStates.ContainsKey(pair.Key)) // Remove ffd timeline from map. { ffdTimelineStates.Remove(pair.Key); } else // Create new ffd timeline. { var ffdTimelineState = BaseObject.BorrowObject <FFDTimelineState>(); ffdTimelineState.slot = slot; ffdTimelineState._init(_armature, this, pair.Value); _ffdTimelines.Add(ffdTimelineState); } } } else { resetFFDVertices = true; } } else { resetFFDVertices = true; } if (resetFFDVertices) { for (int iA = 0, lA = slot._ffdVertices.Count; iA < lA; ++iA) { slot._ffdVertices[iA] = 0.0f; } slot._meshDirty = true; } } foreach (var slotTimelineState in slotTimelineStates.Values) // Remove slot timelines. { _slotTimelines.Remove(slotTimelineState); slotTimelineState.ReturnToPool(); } foreach (var ffdTimelineState in ffdTimelineStates.Values)// Remove ffd timelines. { _ffdTimelines.Remove(ffdTimelineState); ffdTimelineState.ReturnToPool(); } }