mirror of
https://github.com/Ottermandias/Glamourer.git
synced 2025-12-14 04:34:19 +01:00
Fix problem with mare colors not resetting, reduce redraws again, use material texture instead of GPU.
This commit is contained in:
parent
d36e4f891b
commit
80a6e89aa5
8 changed files with 20 additions and 26 deletions
|
|
@ -163,7 +163,7 @@ public partial class GlamourerIpc
|
||||||
if ((hasModelId || state.ModelData.ModelId == 0) && state.CanUnlock(lockCode))
|
if ((hasModelId || state.ModelData.ModelId == 0) && state.CanUnlock(lockCode))
|
||||||
{
|
{
|
||||||
_stateManager.ApplyDesign(state, design,
|
_stateManager.ApplyDesign(state, design,
|
||||||
new ApplySettings(Source: once ? StateSource.IpcManual : StateSource.IpcFixed, Key: lockCode, MergeLinks: true));
|
new ApplySettings(Source: once ? StateSource.IpcManual : StateSource.IpcFixed, Key: lockCode, MergeLinks: true, ResetMaterials: !once && lockCode != 0));
|
||||||
state.Lock(lockCode);
|
state.Lock(lockCode);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -254,7 +254,7 @@ public sealed class AutoDesignApplier : IDisposable
|
||||||
|
|
||||||
private unsafe void Reduce(Actor actor, ActorState state, AutoDesignSet set, bool respectManual, bool fromJobChange)
|
private unsafe void Reduce(Actor actor, ActorState state, AutoDesignSet set, bool respectManual, bool fromJobChange)
|
||||||
{
|
{
|
||||||
if (set.BaseState == AutoDesignSet.Base.Game)
|
if (set.BaseState is AutoDesignSet.Base.Game)
|
||||||
_state.ResetStateFixed(state, respectManual);
|
_state.ResetStateFixed(state, respectManual);
|
||||||
else if (!respectManual)
|
else if (!respectManual)
|
||||||
state.Sources.RemoveFixedDesignSources();
|
state.Sources.RemoveFixedDesignSources();
|
||||||
|
|
@ -265,7 +265,7 @@ public sealed class AutoDesignApplier : IDisposable
|
||||||
var mergedDesign = _designMerger.Merge(
|
var mergedDesign = _designMerger.Merge(
|
||||||
set.Designs.Where(d => d.IsActive(actor)).SelectMany(d => d.Design?.AllLinks.Select(l => (l.Design, l.Flags & d.Type)) ?? [(d.Design, d.Type)]),
|
set.Designs.Where(d => d.IsActive(actor)).SelectMany(d => d.Design?.AllLinks.Select(l => (l.Design, l.Flags & d.Type)) ?? [(d.Design, d.Type)]),
|
||||||
state.ModelData.Customize, state.BaseData, true, _config.AlwaysApplyAssociatedMods);
|
state.ModelData.Customize, state.BaseData, true, _config.AlwaysApplyAssociatedMods);
|
||||||
_state.ApplyDesign(state, mergedDesign, new ApplySettings(0, StateSource.Fixed, respectManual, fromJobChange, false));
|
_state.ApplyDesign(state, mergedDesign, new ApplySettings(0, StateSource.Fixed, respectManual, fromJobChange, false, false, set.BaseState is AutoDesignSet.Base.Game));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary> Get world-specific first and all-world afterward. </summary>
|
/// <summary> Get world-specific first and all-world afterward. </summary>
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,8 @@ public readonly record struct ApplySettings(
|
||||||
bool RespectManual = false,
|
bool RespectManual = false,
|
||||||
bool FromJobChange = false,
|
bool FromJobChange = false,
|
||||||
bool UseSingleSource = false,
|
bool UseSingleSource = false,
|
||||||
bool MergeLinks = false)
|
bool MergeLinks = false,
|
||||||
|
bool ResetMaterials = false)
|
||||||
{
|
{
|
||||||
public static readonly ApplySettings Manual = new()
|
public static readonly ApplySettings Manual = new()
|
||||||
{
|
{
|
||||||
|
|
@ -22,6 +23,7 @@ public readonly record struct ApplySettings(
|
||||||
RespectManual = false,
|
RespectManual = false,
|
||||||
UseSingleSource = false,
|
UseSingleSource = false,
|
||||||
MergeLinks = false,
|
MergeLinks = false,
|
||||||
|
ResetMaterials = false,
|
||||||
};
|
};
|
||||||
|
|
||||||
public static readonly ApplySettings ManualWithLinks = new()
|
public static readonly ApplySettings ManualWithLinks = new()
|
||||||
|
|
@ -32,6 +34,7 @@ public readonly record struct ApplySettings(
|
||||||
RespectManual = false,
|
RespectManual = false,
|
||||||
UseSingleSource = false,
|
UseSingleSource = false,
|
||||||
MergeLinks = true,
|
MergeLinks = true,
|
||||||
|
ResetMaterials = false,
|
||||||
};
|
};
|
||||||
|
|
||||||
public static readonly ApplySettings Game = new()
|
public static readonly ApplySettings Game = new()
|
||||||
|
|
@ -42,6 +45,7 @@ public readonly record struct ApplySettings(
|
||||||
RespectManual = false,
|
RespectManual = false,
|
||||||
UseSingleSource = false,
|
UseSingleSource = false,
|
||||||
MergeLinks = false,
|
MergeLinks = false,
|
||||||
|
ResetMaterials = true,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,6 @@ namespace Glamourer.Interop.Material;
|
||||||
public unsafe class DirectXService(IFramework framework) : IService
|
public unsafe class DirectXService(IFramework framework) : IService
|
||||||
{
|
{
|
||||||
private readonly object _lock = new();
|
private readonly object _lock = new();
|
||||||
|
|
||||||
private readonly ConcurrentDictionary<nint, (DateTime Update, ColorTable Table)> _textures = [];
|
private readonly ConcurrentDictionary<nint, (DateTime Update, ColorTable Table)> _textures = [];
|
||||||
|
|
||||||
/// <summary> Generate a color table the way the game does inside the original texture, and release the original. </summary>
|
/// <summary> Generate a color table the way the game does inside the original texture, and release the original. </summary>
|
||||||
|
|
|
||||||
|
|
@ -110,9 +110,9 @@ public sealed unsafe class LiveColorTablePreviewer : IService, IDisposable
|
||||||
|
|
||||||
private static Vector3 CalculateDiffuse()
|
private static Vector3 CalculateDiffuse()
|
||||||
{
|
{
|
||||||
const int frameLength = 1;
|
const long frameLength = TimeSpan.TicksPerMillisecond * 5;
|
||||||
const int steps = 64;
|
const long steps = 2000;
|
||||||
var frame = ImGui.GetFrameCount();
|
var frame = DateTimeOffset.UtcNow.UtcTicks;
|
||||||
var hueByte = frame % (steps * frameLength) / frameLength;
|
var hueByte = frame % (steps * frameLength) / frameLength;
|
||||||
var hue = (float)hueByte / steps;
|
var hue = (float)hueByte / steps;
|
||||||
ImGui.ColorConvertHSVtoRGB(hue, 1, 1, out var r, out var g, out var b);
|
ImGui.ColorConvertHSVtoRGB(hue, 1, 1, out var r, out var g, out var b);
|
||||||
|
|
|
||||||
|
|
@ -301,11 +301,11 @@ public class StateApplier(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public ActorData ChangeMaterialValues(ActorState state, bool apply)
|
public ActorData ChangeMaterialValue(ActorState state, MaterialValueIndex index, bool apply)
|
||||||
{
|
{
|
||||||
var data = GetData(state);
|
var data = GetData(state);
|
||||||
if (apply)
|
if (apply)
|
||||||
ChangeMaterialValues(data, state.Materials, state.IsLocked);
|
ChangeMaterialValue(data, index, state.Materials.TryGetValue(index, out var v) ? v.Model : null, state.IsLocked);
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -326,7 +326,7 @@ public class StateApplier(
|
||||||
if (!mainKey.TryGetTexture(actor, out var texture))
|
if (!mainKey.TryGetTexture(actor, out var texture))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (!_directX.TryGetColorTable(*texture, out var table))
|
if (!PrepareColorSet.TryGetColorTable(actor, mainKey, out var table))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
foreach (var (key, value) in values)
|
foreach (var (key, value) in values)
|
||||||
|
|
@ -337,14 +337,6 @@ public class StateApplier(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public ActorData ChangeMaterialValue(ActorState state, MaterialValueIndex index, bool apply)
|
|
||||||
{
|
|
||||||
var data = GetData(state);
|
|
||||||
if (apply)
|
|
||||||
ChangeMaterialValue(data, index, state.Materials.TryGetValue(index, out var v) ? v.Model : null, state.IsLocked);
|
|
||||||
return data;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary> Apply the entire state of an actor to all relevant actors, either via immediate redraw or piecewise. </summary>
|
/// <summary> Apply the entire state of an actor to all relevant actors, either via immediate redraw or piecewise. </summary>
|
||||||
/// <param name="state"> The state to apply. </param>
|
/// <param name="state"> The state to apply. </param>
|
||||||
/// <param name="redraw"> Whether a redraw should be forced. </param>
|
/// <param name="redraw"> Whether a redraw should be forced. </param>
|
||||||
|
|
@ -377,7 +369,6 @@ public class StateApplier(
|
||||||
ChangeMetaState(actors, MetaIndex.VisorState, state.ModelData.IsVisorToggled());
|
ChangeMetaState(actors, MetaIndex.VisorState, state.ModelData.IsVisorToggled());
|
||||||
ChangeCrests(actors, state.ModelData.CrestVisibility);
|
ChangeCrests(actors, state.ModelData.CrestVisibility);
|
||||||
ChangeParameters(actors, state.OnlyChangedParameters(), state.ModelData.Parameters, state.IsLocked);
|
ChangeParameters(actors, state.OnlyChangedParameters(), state.ModelData.Parameters, state.IsLocked);
|
||||||
// This should never be applied when caused through IPC, then redraw should be true.
|
|
||||||
ChangeMaterialValues(actors, state.Materials, state.IsLocked);
|
ChangeMaterialValues(actors, state.Materials, state.IsLocked);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -296,6 +296,9 @@ public class StateEditor(
|
||||||
Editor.ChangeMetaState(state, meta, mergedDesign.Design.DesignData.GetMeta(meta), Source(meta), out _, settings.Key);
|
Editor.ChangeMetaState(state, meta, mergedDesign.Design.DesignData.GetMeta(meta), Source(meta), out _, settings.Key);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (settings.ResetMaterials)
|
||||||
|
state.Materials.Clear();
|
||||||
|
|
||||||
foreach (var (key, value) in mergedDesign.Design.Materials)
|
foreach (var (key, value) in mergedDesign.Design.Materials)
|
||||||
{
|
{
|
||||||
if (!value.Enabled)
|
if (!value.Enabled)
|
||||||
|
|
@ -321,8 +324,6 @@ public class StateEditor(
|
||||||
settings.Source, out _, settings.Key);
|
settings.Source, out _, settings.Key);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
requiresRedraw |= mergedDesign.Design.Materials.Count > 0 && settings.Source.IsIpc();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var actors = settings.Source.RequiresChange()
|
var actors = settings.Source.RequiresChange()
|
||||||
|
|
|
||||||
|
|
@ -224,7 +224,6 @@ public sealed class StateManager(
|
||||||
|| !state.ModelData.IsHuman
|
|| !state.ModelData.IsHuman
|
||||||
|| CustomizeArray.Compare(state.ModelData.Customize, state.BaseData.Customize).RequiresRedraw();
|
|| CustomizeArray.Compare(state.ModelData.Customize, state.BaseData.Customize).RequiresRedraw();
|
||||||
|
|
||||||
redraw |= state.Materials.Values.Count > 0 && source.IsIpc();
|
|
||||||
state.ModelData = state.BaseData;
|
state.ModelData = state.BaseData;
|
||||||
state.ModelData.SetIsWet(false);
|
state.ModelData.SetIsWet(false);
|
||||||
foreach (var index in Enum.GetValues<CustomizeIndex>())
|
foreach (var index in Enum.GetValues<CustomizeIndex>())
|
||||||
|
|
@ -346,7 +345,7 @@ public sealed class StateManager(
|
||||||
public void ReapplyState(Actor actor, ActorState state, StateSource source)
|
public void ReapplyState(Actor actor, ActorState state, StateSource source)
|
||||||
{
|
{
|
||||||
var data = Applier.ApplyAll(state,
|
var data = Applier.ApplyAll(state,
|
||||||
!actor.Model.IsHuman || CustomizeArray.Compare(actor.Model.GetCustomize(), state.ModelData.Customize).RequiresRedraw() || state.Materials.Values.Count > 0 && source.IsIpc(), false);
|
!actor.Model.IsHuman || CustomizeArray.Compare(actor.Model.GetCustomize(), state.ModelData.Customize).RequiresRedraw(), false);
|
||||||
StateChanged.Invoke(StateChanged.Type.Reapply, source, state, data, null);
|
StateChanged.Invoke(StateChanged.Type.Reapply, source, state, data, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue