Merge remote-tracking branch 'origin/main' into new_actor_assignment_ui

This commit is contained in:
RisaDev
2024-10-12 22:41:52 +03:00
6 changed files with 39 additions and 80 deletions

View File

@@ -162,26 +162,21 @@ public unsafe class Armature
: $"Armature (#{_localId}) on {ActorIdentifier.IncognitoDebug()} ({Profile}) with no skeleton reference"; : $"Armature (#{_localId}) on {ActorIdentifier.IncognitoDebug()} ({Profile}) with no skeleton reference";
} }
public bool NewBonesAvailable(CharacterBase* cBase) public bool IsSkeletonUpdated(CharacterBase* cBase)
{ {
if (cBase == null) if (cBase == null)
{
return false; return false;
} else if (cBase->Skeleton->PartialSkeletonCount != _partialSkeletons.Length)
else if (cBase->Skeleton->PartialSkeletonCount > _partialSkeletons.Length)
{
return true; return true;
}
else else
{ {
for (var i = 0; i < cBase->Skeleton->PartialSkeletonCount; ++i) for (var i = 0; i < cBase->Skeleton->PartialSkeletonCount; ++i)
{ {
var newPose = cBase->Skeleton->PartialSkeletons[i].GetHavokPose(Constants.TruePoseIndex); var newPose = cBase->Skeleton->PartialSkeletons[i].GetHavokPose(Constants.TruePoseIndex);
if (newPose != null if (newPose != null
&& newPose->Skeleton->Bones.Length > _partialSkeletons[i].Length) && newPose->Skeleton->Bones.Length != _partialSkeletons[i].Length)
{
return true; return true;
}
} }
} }
@@ -205,43 +200,6 @@ public unsafe class Armature
Plugin.Logger.Debug($"Rebuilt {this}"); 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<ModelBone>());
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) public BoneTransform? GetAppliedBoneTransform(string boneName)
{ {
if (BoneTemplateBinding.TryGetValue(boneName, out var template) if (BoneTemplateBinding.TryGetValue(boneName, out var template)

View File

@@ -184,7 +184,7 @@ public unsafe sealed class ArmatureManager : IDisposable
} }
//Needed because skeleton sometimes appears to be not ready when armature is created //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); 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. /// Returns whether or not a link can be established between the armature and an in-game object.
/// If unbuilt, the armature will be rebuilded. /// If unbuilt, the armature will be rebuilded.
/// </summary> /// </summary>
private bool TryLinkSkeleton(Armature armature, bool forceRebuild = false) private bool TryLinkSkeleton(Armature armature)
{ {
_objectManager.Update(); _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)) _logger.Debug($"Skeleton for actor #{actor.AsObject->ObjectIndex} tied to \"{armature}\" has changed");
return false; armature.RebuildSkeleton(actor.Model.AsCharacterBase);
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;
} }
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! :) return true;
//if(!(Profile.CharacterName.Equals(Constants.DefaultProfileCharacterName) || Profile.CharacterName.Equals("DefaultCutscene"))) {
_logger.Error($"Error occured while attempting to link skeleton: {armature}");
throw;
//}
}
} }
/// <summary> /// <summary>

View File

@@ -212,10 +212,27 @@ public class StateMonitoringTab
//ImGui.Text("Profile:"); //ImGui.Text("Profile:");
//DrawSingleProfile($"armature-{armature.GetHashCode()}", armature.Profile); //DrawSingleProfile($"armature-{armature.GetHashCode()}", armature.Profile);
ImGui.Text($"Bone template bindings:"); var bindingsShow = ImGui.CollapsingHeader($"Bone template bindings ({armature.BoneTemplateBinding.Count})###{prefix}-armature-{armature.GetHashCode()}-bindings");
foreach (var kvPair in armature.BoneTemplateBinding)
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})");
} }
} }
} }

View File

@@ -6,7 +6,7 @@
"Punchline": "Customize your character beyond FFXIV's limitations.", "Punchline": "Customize your character beyond FFXIV's limitations.",
"InternalName": "CustomizePlus", "InternalName": "CustomizePlus",
"AssemblyVersion": "2.0.6.5", "AssemblyVersion": "2.0.6.5",
"TestingAssemblyVersion": "2.0.6.5", "TestingAssemblyVersion": "2.0.6.6",
"RepoUrl": "https://github.com/Aether-Tools/CustomizePlus", "RepoUrl": "https://github.com/Aether-Tools/CustomizePlus",
"ApplicableVersion": "any", "ApplicableVersion": "any",
"DalamudApiLevel": 10, "DalamudApiLevel": 10,
@@ -17,7 +17,7 @@
"LoadPriority": 0, "LoadPriority": 0,
"DownloadLinkInstall": "https://github.com/Aether-Tools/CustomizePlus/releases/download/2.0.6.5/CustomizePlus.zip", "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", "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", "IconUrl": "https://raw.githubusercontent.com/Aether-Tools/CustomizePlus/main/Data/icon.png",
"Tags": [ "Tags": [
"Anamnesis", "Anamnesis",