77using CustomizePlus . Core . Data ;
88using CustomizePlus . Core . Extensions ;
99using CustomizePlus . Game . Services ;
10- using CustomizePlus . GameData . Data ;
10+ using CustomizePlus . Game . Services . GPose ;
1111using CustomizePlus . GameData . Extensions ;
12- using CustomizePlus . GameData . Services ;
1312using CustomizePlus . Profiles ;
1413using CustomizePlus . Profiles . Data ;
1514using CustomizePlus . Profiles . Events ;
1615using CustomizePlus . Templates . Events ;
1716using Dalamud . Plugin . Services ;
18- using Lumina . Excel . Sheets ;
1917using OtterGui . Classes ;
2018using OtterGui . Log ;
2119using 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