public unsafe void Init(MyCharacterBone[] bones, MyAnimationController controller) { List <MyAnimationStateMachine> list = new List <MyAnimationStateMachine>(controller.GetLayerCount()); for (int i = 0; i < controller.GetLayerCount(); i++) { list.Add(controller.GetLayerByIndex(i)); } this.m_boneIndexToData = new BoneData[bones.Length]; foreach (MyCharacterBone bone in bones) { BoneData *dataPtr1; BoneData data = new BoneData { WeightId = MyStringId.GetOrCompute("rd_weight_" + bone.Name), BlendTimeId = MyStringId.GetOrCompute("rd_blend_time_" + bone.Name), BlendTimeMs = -1.0, StartingWeight = 0f, TargetWeight = 0f, PrevWeight = 0f }; dataPtr1->Layers = (from layer in list where layer.BoneMask[bone.Index] select new LayerData { LayerId = MyStringId.GetOrCompute("rd_weight_" + layer.Name), LayerBlendTimeId = MyStringId.GetOrCompute("rd_blend_time_" + layer.Name) }).ToArray <LayerData>(); dataPtr1 = (BoneData *)ref data; this.m_boneIndexToData[bone.Index] = data; } this.m_defautlBlendTimeId = MyStringId.GetOrCompute("rd_default_blend_time"); this.Initialized = true; }
private void LiveDebugging_SendAnimationStateChangesToEditor(MyAnimationController animController) { if (animController == null) { return; } int layerCount = animController.GetLayerCount(); if (layerCount != m_debuggingAnimControllerCurrentNodes.Count) { m_debuggingAnimControllerCurrentNodes.Clear(); for (int i = 0; i < layerCount; i++) { m_debuggingAnimControllerCurrentNodes.Add(null); } m_debuggingAnimControllerTreePath.Clear(); for (int i = 0; i < layerCount; i++) { m_debuggingAnimControllerTreePath.Add(new int[animController.GetLayerByIndex(i).VisitedTreeNodesPath.Length]); } } for (int i = 0; i < layerCount; i++) { var layerVisitedTreeNodesPath = animController.GetLayerByIndex(i).VisitedTreeNodesPath; if (animController.GetLayerByIndex(i).CurrentNode != m_debuggingAnimControllerCurrentNodes[i] || !LiveDebugging_CompareAnimTreePathSeqs(layerVisitedTreeNodesPath, m_debuggingAnimControllerTreePath[i])) { Array.Copy(layerVisitedTreeNodesPath, m_debuggingAnimControllerTreePath[i], layerVisitedTreeNodesPath.Length); // local copy m_debuggingAnimControllerCurrentNodes[i] = animController.GetLayerByIndex(i).CurrentNode; if (m_debuggingAnimControllerCurrentNodes[i] != null) { var msg = MyExternalDebugStructures.ACSendStateToEditorMsg.Create(m_debuggingAnimControllerCurrentNodes[i].Name, m_debuggingAnimControllerTreePath[i]); MySessionComponentExtDebug.Static.SendMessageToClients(msg); } } } }