Fix issue with unnecessary redrawing during GPose when using redraw-requiring changes.

This commit is contained in:
Ottermandias 2023-09-27 18:31:41 +02:00
parent b42900e05b
commit bd21425fdf
3 changed files with 29 additions and 4 deletions

View file

@ -526,7 +526,7 @@ public unsafe class DebugTab : ITab
using (var disabled = ImRaii.Disabled(!_penumbra.Available)) using (var disabled = ImRaii.Disabled(!_penumbra.Available))
{ {
if (ImGui.SmallButton("Redraw")) if (ImGui.SmallButton("Redraw"))
_penumbra.RedrawObject(_objectManager.Objects.GetObjectAddress(_gameObjectIndex), RedrawType.Redraw); _penumbra.RedrawObject((ObjectIndex) _gameObjectIndex, RedrawType.Redraw);
} }
ImGuiUtil.DrawTableColumn("Last Tooltip Date"); ImGuiUtil.DrawTableColumn("Last Tooltip Date");

View file

@ -11,6 +11,7 @@ using Glamourer.Interop.Structs;
using Penumbra.Api; using Penumbra.Api;
using Penumbra.Api.Enums; using Penumbra.Api.Enums;
using Penumbra.Api.Helpers; using Penumbra.Api.Helpers;
using Penumbra.GameData.Structs;
namespace Glamourer.Interop.Penumbra; namespace Glamourer.Interop.Penumbra;
@ -239,6 +240,19 @@ public unsafe class PenumbraService : IDisposable
} }
} }
/// <summary> Try to redraw the given actor. </summary>
public void RedrawObject(ObjectIndex index, RedrawType settings)
{
try
{
_redrawSubscriber.Invoke(index.Index, settings);
}
catch (Exception e)
{
PluginLog.Debug($"Failure redrawing object:\n{e}");
}
}
/// <summary> Reattach to the currently running Penumbra IPC provider. Unattaches before if necessary. </summary> /// <summary> Reattach to the currently running Penumbra IPC provider. Unattaches before if necessary. </summary>
public void Reattach() public void Reattach()
{ {

View file

@ -1,4 +1,5 @@
using System.Linq; using System.Linq;
using FFXIVClientStructs.FFXIV.Client.Graphics.Scene;
using Glamourer.Customization; using Glamourer.Customization;
using Glamourer.Events; using Glamourer.Events;
using Glamourer.Interop; using Glamourer.Interop;
@ -61,7 +62,7 @@ public class StateApplier
/// Change the customization values of actors either by applying them via update or redrawing, /// Change the customization values of actors either by applying them via update or redrawing,
/// this depends on whether the changes include changes to Race, Gender, Body Type or Face. /// this depends on whether the changes include changes to Race, Gender, Body Type or Face.
/// </summary> /// </summary>
public void ChangeCustomize(ActorData data, in Customize customize, ActorState? state = null) public unsafe void ChangeCustomize(ActorData data, in Customize customize, ActorState? state = null)
{ {
foreach (var actor in data.Objects) foreach (var actor in data.Objects)
{ {
@ -71,13 +72,22 @@ public class StateApplier
var flags = Customize.Compare(mdl.GetCustomize(), customize); var flags = Customize.Compare(mdl.GetCustomize(), customize);
if (!flags.RequiresRedraw() || !mdl.IsHuman) if (!flags.RequiresRedraw() || !mdl.IsHuman)
{
_changeCustomize.UpdateCustomize(mdl, customize.Data); _changeCustomize.UpdateCustomize(mdl, customize.Data);
}
else if (data.Objects.Count > 1 && _objects.IsInGPose && !actor.IsGPoseOrCutscene)
{
var mdlCustomize = (Customize*)&mdl.AsHuman->Customize;
mdlCustomize->Load(customize);
}
else else
{
_penumbra.RedrawObject(actor, RedrawType.Redraw); _penumbra.RedrawObject(actor, RedrawType.Redraw);
}
} }
} }
/// <inheritdoc cref="ChangeCustomize(ActorData, in Customize)"/> /// <inheritdoc cref="ChangeCustomize(ActorData, in Customize, ActorState?)"/>
public ActorData ChangeCustomize(ActorState state, bool apply) public ActorData ChangeCustomize(ActorState state, bool apply)
{ {
var data = GetData(state); var data = GetData(state);
@ -122,7 +132,8 @@ public class StateApplier
// If the source is not IPC we do not want to apply restrictions. // If the source is not IPC we do not want to apply restrictions.
var data = GetData(state); var data = GetData(state);
if (apply) if (apply)
ChangeArmor(data, slot, state.ModelData.Armor(slot), state[slot, false] is not StateChanged.Source.Ipc, state.ModelData.IsHatVisible()); ChangeArmor(data, slot, state.ModelData.Armor(slot), state[slot, false] is not StateChanged.Source.Ipc,
state.ModelData.IsHatVisible());
return data; return data;
} }