/// <summary> /// Removes the specified modifier and resets the affected bone to its original state /// </summary> /// <param name="modifier">Modifier added to this controller</param> public void RemoveModifier(BoneModifier modifier) { modifier.Reset(); Modifiers.Remove(modifier); ForceBodyRecalc(); }
/// <summary> /// Removes the specified modifier and resets the affected bone to its original state /// </summary> /// <param name="modifier">Modifier added to this controller</param> public void RemoveModifier(BoneModifier modifier) { modifier.Reset(); Modifiers.Remove(modifier); ChaControl.updateShapeFace = true; ChaControl.updateShapeBody = true; }
/// <summary> /// Add a new bone modifier. Make sure it doesn't exist yet. /// </summary> public void AddModifier(BoneModifier bone) { if (bone == null) { throw new ArgumentNullException(nameof(bone)); } Modifiers.Add(bone); ModifiersFillInTransforms(); bone.CollectBaseline(); }
private void ApplyEffects() { _effectsToUpdate.Clear(); foreach (var additionalBoneEffect in _additionalBoneEffects) { var affectedBones = additionalBoneEffect.GetAffectedBones(this); foreach (var affectedBone in affectedBones) { var effect = additionalBoneEffect.GetEffect(affectedBone, this, CurrentCoordinate.Value); if (effect != null && !effect.IsEmpty()) { var modifier = GetModifier(affectedBone); if (modifier == null) { modifier = new BoneModifier(affectedBone); AddModifier(modifier); } if (!_effectsToUpdate.TryGetValue(modifier, out var list)) { list = new List <BoneModifierData>(); _effectsToUpdate[modifier] = list; } list.Add(effect); } } } for (var i = 0; i < Modifiers.Count; i++) { var modifier = Modifiers[i]; if (!_effectsToUpdate.TryGetValue(modifier, out var list)) { // Clean up no longer necessary modifiers // not used to reduce per-frame perf hit //if (!GUI.KKABMX_AdvancedGUI.Enabled && modifier.IsEmpty()) // RemoveModifier(modifier); } HandleDynamicBoneModifiers(modifier); modifier.Apply(CurrentCoordinate.Value, list, _isDuringHScene); } // Fix some bust physics issues // bug - causes gravity issues on its own if (Modifiers.Count > 0) { ChaControl.UpdateBustGravity(); } }
private void ApplyEffects() { var toUpdate = new Dictionary <BoneModifier, List <BoneModifierData> >(); foreach (var additionalBoneEffect in _additionalBoneEffects) { var affectedBones = additionalBoneEffect.GetAffectedBones(this); foreach (var affectedBone in affectedBones) { var effect = additionalBoneEffect.GetEffect(affectedBone, this, CurrentCoordinate.Value); if (effect != null && !effect.IsEmpty()) { var modifier = Modifiers.Find(x => string.Equals(x.BoneName, affectedBone, StringComparison.Ordinal)); if (modifier == null) { modifier = new BoneModifier(affectedBone); AddModifier(modifier); } if (!toUpdate.TryGetValue(modifier, out var list)) { list = new List <BoneModifierData>(); toUpdate[modifier] = list; } list.Add(effect); } } } for (var i = 0; i < Modifiers.Count; i++) { var modifier = Modifiers[i]; if (!toUpdate.TryGetValue(modifier, out var list)) { // Clean up no longer necessary modifiers if (!GUI.KKABMX_AdvancedGUI.Enabled && modifier.IsEmpty()) { RemoveModifier(modifier); } } modifier.Apply(CurrentCoordinate.Value, list, _isDuringHScene); } // Fix some bust physics issues if (Modifiers.Count > 0) { ChaControl.UpdateBustGravity(); } }
protected override void OnCoordinateBeingLoaded(ChaFileCoordinate coordinate, bool maintainState) { if (maintainState) { return; } // Clear previous data for this coordinate from coord specific modifiers foreach (var modifier in Modifiers.Where(x => x.IsCoordinateSpecific())) { modifier.GetModifier(CurrentCoordinate.Value).Clear(); } var data = GetCoordinateExtendedData(coordinate); if (data != null) { try { if (data.version != 2) { throw new NotSupportedException($"Save version {data.version} is not supported"); } var boneData = LZ4MessagePackSerializer.Deserialize <Dictionary <string, BoneModifierData> >((byte[])data.data[ExtDataBoneDataKey]); if (boneData != null) { foreach (var modifier in boneData) { var target = GetModifier(modifier.Key); if (target == null) { // Add any missing modifiers target = new BoneModifier(modifier.Key); AddModifier(target); } target.MakeCoordinateSpecific(); target.CoordinateModifiers[(int)CurrentCoordinate.Value] = modifier.Value; } } } catch (Exception ex) { KKABMX_Core.Logger.LogError("[KKABMX] Failed to load coordinate extended data - " + ex); } } StartCoroutine(OnDataChangedCo()); }
private void ApplyEffects() { var toUpdate = new Dictionary <BoneModifier, List <BoneModifierData> >(); for (var i = 0; i < _additionalBoneEffects.Count; i++) { var additionalBoneEffect = _additionalBoneEffects[i]; var affectedBones = additionalBoneEffect.GetAffectedBones(this); foreach (var affectedBone in affectedBones) { var effect = additionalBoneEffect.GetEffect(affectedBone, this, CurrentCoordinate.Value); if (effect != null && !effect.IsEmpty()) { var modifier = Modifiers.Find(x => string.Equals(x.BoneName, affectedBone, StringComparison.Ordinal)); if (modifier == null) { modifier = new BoneModifier(affectedBone); AddModifier(modifier); } if (!toUpdate.TryGetValue(modifier, out var list)) { list = new List <BoneModifierData>(); toUpdate[modifier] = list; } list.Add(effect); } } } for (var i = 0; i < Modifiers.Count; i++) { var modifier = Modifiers[i]; if (!toUpdate.TryGetValue(modifier, out var list)) { // Clean up no longer necessary modifiers if (!MakerAPI.InsideMaker && modifier.IsEmpty()) { modifier.Reset(); Modifiers.Remove(modifier); } } modifier.Apply(CurrentCoordinate.Value, list, _isDuringHScene); } }
/// <summary> /// Force reset baseline of bones affected by dynamicbones /// to avoid overwriting dynamicbone animations /// </summary> private static void HandleDynamicBoneModifiers(BoneModifier modifier) { #if KK || KKS || EC if (modifier.BoneName.StartsWith("cf_d_sk_", StringComparison.Ordinal) || modifier.BoneName.StartsWith("cf_j_bust0", StringComparison.Ordinal) || modifier.BoneName.StartsWith("cf_d_siri01_", StringComparison.Ordinal) || modifier.BoneName.StartsWith("cf_j_siri_", StringComparison.Ordinal)) #elif AI || HS2 if (modifier.BoneName.StartsWith("cf_J_SiriDam", StringComparison.Ordinal) || modifier.BoneName.StartsWith("cf_J_Mune00", StringComparison.Ordinal)) #else todo fix #endif { modifier.Reset(); modifier.CollectBaseline(); } }