diff --git a/CustomizePlus/Armatures/Data/Armature.cs b/CustomizePlus/Armatures/Data/Armature.cs index 42e3557..4584386 100644 --- a/CustomizePlus/Armatures/Data/Armature.cs +++ b/CustomizePlus/Armatures/Data/Armature.cs @@ -162,26 +162,21 @@ public unsafe class Armature : $"Armature (#{_localId}) on {ActorIdentifier.IncognitoDebug()} ({Profile}) with no skeleton reference"; } - public bool NewBonesAvailable(CharacterBase* cBase) + public bool IsSkeletonUpdated(CharacterBase* cBase) { if (cBase == null) - { return false; - } - else if (cBase->Skeleton->PartialSkeletonCount > _partialSkeletons.Length) - { + else if (cBase->Skeleton->PartialSkeletonCount != _partialSkeletons.Length) return true; - } else { for (var i = 0; i < cBase->Skeleton->PartialSkeletonCount; ++i) { var newPose = cBase->Skeleton->PartialSkeletons[i].GetHavokPose(Constants.TruePoseIndex); + if (newPose != null - && newPose->Skeleton->Bones.Length > _partialSkeletons[i].Length) - { + && newPose->Skeleton->Bones.Length != _partialSkeletons[i].Length) return true; - } } } @@ -205,43 +200,6 @@ public unsafe class Armature Plugin.Logger.Debug($"Rebuilt {this}"); } - public void AugmentSkeleton(CharacterBase* cBase) - { - if (cBase == null) - return; - - var oldPartials = _partialSkeletons.Select(x => x.ToList()).ToList(); - var newPartials = ParseBonesFromObject(this, cBase); - - //for each of the new partial skeletons discovered... - for (var i = 0; i < newPartials.Count; ++i) - { - //if the old skeleton doesn't contain the new partial at all, add the whole thing - if (i > oldPartials.Count) - { - oldPartials.Add(newPartials[i]); - } - //otherwise, add every model bone the new partial has that the old one doesn't - else - { - //Case: get carbuncle, enable profile for it, turn carbuncle into human via glamourer - if (oldPartials.Count <= i) - oldPartials.Add(new List()); - - for (var j = oldPartials[i].Count; j < newPartials[i].Count; ++j) - { - oldPartials[i].Add(newPartials[i][j]); - } - } - } - - _partialSkeletons = oldPartials.Select(x => x.ToArray()).ToArray(); - - RebuildBoneTemplateBinding(); //todo: intentionally not calling ArmatureChanged.Type.Updated because this is pending rewrite - - Plugin.Logger.Debug($"Augmented {this} with new bones"); - } - public BoneTransform? GetAppliedBoneTransform(string boneName) { if (BoneTemplateBinding.TryGetValue(boneName, out var template) diff --git a/CustomizePlus/Armatures/Services/ArmatureManager.cs b/CustomizePlus/Armatures/Services/ArmatureManager.cs index 7575350..c885ab7 100644 --- a/CustomizePlus/Armatures/Services/ArmatureManager.cs +++ b/CustomizePlus/Armatures/Services/ArmatureManager.cs @@ -184,7 +184,7 @@ public unsafe sealed class ArmatureManager : IDisposable } //Needed because skeleton sometimes appears to be not ready when armature is created - //and also because we want to augment armature with new bones if they are available + //and also because we want to keep armature up to date with any character skeleton changes TryLinkSkeleton(armature); } } @@ -207,38 +207,22 @@ public unsafe sealed class ArmatureManager : IDisposable /// Returns whether or not a link can be established between the armature and an in-game object. /// If unbuilt, the armature will be rebuilded. /// - private bool TryLinkSkeleton(Armature armature, bool forceRebuild = false) + private bool TryLinkSkeleton(Armature armature) { _objectManager.Update(); - try + if (!_objectManager.Identifiers.ContainsKey(armature.ActorIdentifier)) + return false; + + var actor = _objectManager[armature.ActorIdentifier].Objects[0]; + + if (!armature.IsBuilt || armature.IsSkeletonUpdated(actor.Model.AsCharacterBase)) { - if (!_objectManager.Identifiers.ContainsKey(armature.ActorIdentifier)) - return false; - - var actor = _objectManager[armature.ActorIdentifier].Objects[0]; - - if (!armature.IsBuilt || forceRebuild) - { - armature.RebuildSkeleton(actor.Model.AsCharacterBase); - } - else if (armature.NewBonesAvailable(actor.Model.AsCharacterBase)) - { - armature.AugmentSkeleton(actor.Model.AsCharacterBase); - } - - return true; + _logger.Debug($"Skeleton for actor #{actor.AsObject->ObjectIndex} tied to \"{armature}\" has changed"); + armature.RebuildSkeleton(actor.Model.AsCharacterBase); } - catch (Exception ex) - { - // This is on wait until isse #191 on Github responds. Keeping it in code, delete it if I forget and this is longer then a month ago. - // Disabling this if its any Default Profile due to Log spam. A bit crazy but hey, if its for me id Remove Default profiles all together so this is as much as ill do for now! :) - //if(!(Profile.CharacterName.Equals(Constants.DefaultProfileCharacterName) || Profile.CharacterName.Equals("DefaultCutscene"))) { - _logger.Error($"Error occured while attempting to link skeleton: {armature}"); - throw; - //} - } + return true; } /// diff --git a/CustomizePlus/UI/Windows/MainWindow/Tabs/Debug/StateMonitoringTab.cs b/CustomizePlus/UI/Windows/MainWindow/Tabs/Debug/StateMonitoringTab.cs index 4163770..f07f3d6 100644 --- a/CustomizePlus/UI/Windows/MainWindow/Tabs/Debug/StateMonitoringTab.cs +++ b/CustomizePlus/UI/Windows/MainWindow/Tabs/Debug/StateMonitoringTab.cs @@ -212,10 +212,27 @@ public class StateMonitoringTab //ImGui.Text("Profile:"); //DrawSingleProfile($"armature-{armature.GetHashCode()}", armature.Profile); - ImGui.Text($"Bone template bindings:"); - foreach (var kvPair in armature.BoneTemplateBinding) + var bindingsShow = ImGui.CollapsingHeader($"Bone template bindings ({armature.BoneTemplateBinding.Count})###{prefix}-armature-{armature.GetHashCode()}-bindings"); + + if (bindingsShow) { - ImGui.Text($"{BoneData.GetBoneDisplayName(kvPair.Key)} ({kvPair.Key}) -> {kvPair.Value.Name.Text.Incognify()} ({kvPair.Value.UniqueId})"); + foreach (var kvPair in armature.BoneTemplateBinding) + { + ImGui.Text($"{BoneData.GetBoneDisplayName(kvPair.Key)} ({kvPair.Key}) -> {kvPair.Value.Name.Text.Incognify()} ({kvPair.Value.UniqueId})"); + } + } + + var bonesShow = ImGui.CollapsingHeader($"Armature bones###{prefix}-armature-{armature.GetHashCode()}-bones"); + + if (!bonesShow) + return; + + var bones = armature.GetAllBones().ToList(); + ImGui.Text($"{bones.Count} bones"); + + foreach (var bone in bones) + { + ImGui.Text($"{(bone.IsActive ? "[A] " : "")}{BoneData.GetBoneDisplayName(bone.BoneName)} [{bone.BoneName}] ({bone.PartialSkeletonIndex}-{bone.BoneIndex})"); } } } diff --git a/repo.json b/repo.json index 2931a5a..fda4ade 100644 --- a/repo.json +++ b/repo.json @@ -6,7 +6,7 @@ "Punchline": "Customize your character beyond FFXIV's limitations.", "InternalName": "CustomizePlus", "AssemblyVersion": "2.0.6.5", - "TestingAssemblyVersion": "2.0.6.5", + "TestingAssemblyVersion": "2.0.6.6", "RepoUrl": "https://github.com/Aether-Tools/CustomizePlus", "ApplicableVersion": "any", "DalamudApiLevel": 10, @@ -17,7 +17,7 @@ "LoadPriority": 0, "DownloadLinkInstall": "https://github.com/Aether-Tools/CustomizePlus/releases/download/2.0.6.5/CustomizePlus.zip", "DownloadLinkUpdate": "https://github.com/Aether-Tools/CustomizePlus/releases/download/2.0.6.5/CustomizePlus.zip", - "DownloadLinkTesting": "https://github.com/Aether-Tools/CustomizePlus/releases/download/2.0.6.5/CustomizePlus.zip", + "DownloadLinkTesting": "https://github.com/Aether-Tools/CustomizePlus/releases/download/testing_2.0.6.6/CustomizePlus.zip", "IconUrl": "https://raw.githubusercontent.com/Aether-Tools/CustomizePlus/main/Data/icon.png", "Tags": [ "Anamnesis", diff --git a/submodules/ECommons b/submodules/ECommons index 147e12e..3570e20 160000 --- a/submodules/ECommons +++ b/submodules/ECommons @@ -1 +1 @@ -Subproject commit 147e12e95f2fb781f2c8ddac31d948700ed9051c +Subproject commit 3570e207259c54e6b3460f9013b36b592f4bcac0 diff --git a/submodules/Penumbra.GameData b/submodules/Penumbra.GameData index 66bc00d..63cbf82 160000 --- a/submodules/Penumbra.GameData +++ b/submodules/Penumbra.GameData @@ -1 +1 @@ -Subproject commit 66bc00dc8517204e58c6515af5aec0ba6d196716 +Subproject commit 63cbf824178b5b1f91fd9edc22a6c2bbc2e1cd23