Skip to content

Commit bfe614a

Browse files
committed
Fix character flashing in gpose when root bone is edited (disables position edits application in gpose)
1 parent 9fbcf68 commit bfe614a

File tree

2 files changed

+18
-7
lines changed

2 files changed

+18
-7
lines changed

CustomizePlus/Armatures/Data/Armature.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,8 +175,9 @@ public bool IsSkeletonUpdated(CharacterBase* cBase)
175175
var newPose = cBase->Skeleton->PartialSkeletons[i].GetHavokPose(Constants.TruePoseIndex);
176176

177177
if (newPose != null
178-
&& newPose->Skeleton->Bones.Length != _partialSkeletons[i].Length) //todo: same length but different bone names (fucking hair)
178+
&& newPose->Skeleton->Bones.Length != _partialSkeletons[i].Length)
179179
return true;
180+
//todo: compare bones for hair partial skeleton [2]
180181
}
181182
}
182183

CustomizePlus/Armatures/Services/ArmatureManager.cs

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,13 @@
77
using CustomizePlus.Core.Data;
88
using CustomizePlus.Core.Extensions;
99
using CustomizePlus.Game.Services;
10-
using CustomizePlus.GameData.Data;
10+
using CustomizePlus.Game.Services.GPose;
1111
using CustomizePlus.GameData.Extensions;
12-
using CustomizePlus.GameData.Services;
1312
using CustomizePlus.Profiles;
1413
using CustomizePlus.Profiles.Data;
1514
using CustomizePlus.Profiles.Events;
1615
using CustomizePlus.Templates.Events;
1716
using Dalamud.Plugin.Services;
18-
using Lumina.Excel.Sheets;
1917
using OtterGui.Classes;
2018
using OtterGui.Log;
2119
using Penumbra.GameData.Actors;
@@ -36,6 +34,7 @@ public unsafe sealed class ArmatureManager : IDisposable
3634
private readonly FrameworkManager _framework;
3735
private readonly ObjectManager _objectManager;
3836
private readonly ActorManager _actorManager;
37+
private readonly GPoseService _gposeService;
3938
private readonly ArmatureChanged _event;
4039

4140
/// <summary>
@@ -56,6 +55,7 @@ public ArmatureManager(
5655
FrameworkManager framework,
5756
ObjectManager objectManager,
5857
ActorManager actorManager,
58+
GPoseService gposeService,
5959
ArmatureChanged @event)
6060
{
6161
_profileManager = profileManager;
@@ -67,6 +67,7 @@ public ArmatureManager(
6767
_framework = framework;
6868
_objectManager = objectManager;
6969
_actorManager = actorManager;
70+
_gposeService = gposeService;
7071
_event = @event;
7172

7273
_templateChangedEvent.Subscribe(OnTemplateChange, TemplateChanged.Priority.ArmatureManager);
@@ -221,9 +222,16 @@ private unsafe void ApplyArmatureTransforms()
221222
ApplyPiecewiseTransformation(armature, actor, armature.ActorIdentifier);
222223

223224
if (!_objectMovementFlagsArr[actor.AsObject->ObjectIndex])
224-
ApplyRootTranslation(armature, actor);
225+
{
226+
//todo: ApplyRootTranslation causes character flashing in gpose
227+
//research if this can be fixed without breaking this functionality
228+
if (_gposeService.IsInGPose)
229+
continue;
225230

226-
_objectMovementFlagsArr[actor.AsObject->ObjectIndex] = false;
231+
ApplyRootTranslation(armature, actor);
232+
}
233+
else
234+
_objectMovementFlagsArr[actor.AsObject->ObjectIndex] = false;
227235
}
228236
}
229237
}
@@ -337,8 +345,10 @@ private void ApplyRootTranslation(Armature arm, Actor actor, bool reset = false)
337345
var cBase = actor.Model.AsCharacterBase;
338346
if (cBase != null)
339347
{
348+
//warn: hotpath for characters with n_root edits. IsApproximately might have some performance hit.
340349
var rootBoneTransform = arm.GetAppliedBoneTransform("n_root");
341-
if (rootBoneTransform == null)
350+
if (rootBoneTransform == null ||
351+
rootBoneTransform.Translation.IsApproximately(Vector3.Zero, 0.00001f))
342352
return;
343353

344354
if (reset)

0 commit comments

Comments
 (0)