Some updates.

This commit is contained in:
Ottermandias 2023-10-04 20:30:04 +02:00
parent c21cbcdcd3
commit 069929ce24
3 changed files with 18 additions and 13 deletions

View file

@ -81,7 +81,7 @@ public sealed unsafe class LiveMaterialPreviewer : LiveMaterialPreviewerBase
for (var i = 0; i < _shaderPackage->MaterialElementCount; ++i)
{
// TODO fix when CS updated
ref var parameter = ref ((ShaderPackage.MaterialElement*) ((byte*)_shaderPackage + 0xA0))[i];
ref var parameter = ref ((ShaderPackage.MaterialElement*) ((byte*)_shaderPackage + 0x98))[i];
if (parameter.CRC == parameterCrc)
{
if ((parameter.Offset & 0x3) != 0

View file

@ -33,9 +33,9 @@ public readonly record struct MaterialInfo(ObjectIndex ObjectIndex, DrawObjectTy
return type switch
{
DrawObjectType.Character => (nint)gameObject->GameObject.GetDrawObject(),
DrawObjectType.Mainhand => *((nint*)&gameObject->DrawData.MainHand + 1),
DrawObjectType.Offhand => *((nint*)&gameObject->DrawData.OffHand + 1),
DrawObjectType.Vfx => *((nint*)&gameObject->DrawData.UnkF0 + 1),
DrawObjectType.Mainhand => (nint)gameObject->DrawData.Weapon(DrawDataContainer.WeaponSlot.MainHand).DrawObject,
DrawObjectType.Offhand => (nint)gameObject->DrawData.Weapon(DrawDataContainer.WeaponSlot.OffHand).DrawObject,
DrawObjectType.Vfx => (nint)gameObject->DrawData.Weapon(DrawDataContainer.WeaponSlot.Unk).DrawObject,
_ => nint.Zero,
};
}
@ -72,7 +72,7 @@ public readonly record struct MaterialInfo(ObjectIndex ObjectIndex, DrawObjectTy
if (gameObject == null)
continue;
var index = (ObjectIndex) gameObject->GameObject.ObjectIndex;
var index = (ObjectIndex)gameObject->GameObject.ObjectIndex;
foreach (var type in Enum.GetValues<DrawObjectType>())
{

View file

@ -2,6 +2,7 @@ using Dalamud.Game.ClientState.Conditions;
using Dalamud.Hooking;
using Dalamud.Plugin.Services;
using Dalamud.Utility.Signatures;
using FFXIVClientStructs.FFXIV.Client.Game;
using FFXIVClientStructs.FFXIV.Client.Graphics.Scene;
using Penumbra.Collections;
using Penumbra.Api.Enums;
@ -37,6 +38,10 @@ public unsafe class AnimationHookService : IDisposable
_conditions = conditions;
interop.InitializeFromAttributes(this);
_loadCharacterSoundHook =
interop.HookFromAddress<LoadCharacterSound>(
(nint)FFXIVClientStructs.FFXIV.Client.Game.Character.Character.VfxContainer.MemberFunctionPointers.LoadCharacterSound,
LoadCharacterSoundDetour);
_loadCharacterSoundHook.Enable();
_loadTimelineResourcesHook.Enable();
@ -113,9 +118,7 @@ public unsafe class AnimationHookService : IDisposable
/// <summary> Characters load some of their voice lines or whatever with this function. </summary>
private delegate nint LoadCharacterSound(nint character, int unk1, int unk2, nint unk3, ulong unk4, int unk5, int unk6, ulong unk7);
// TODO: Use ClientStructs
[Signature(Sigs.LoadCharacterSound, DetourName = nameof(LoadCharacterSoundDetour))]
private readonly Hook<LoadCharacterSound> _loadCharacterSoundHook = null!;
private readonly Hook<LoadCharacterSound> _loadCharacterSoundHook;
private nint LoadCharacterSoundDetour(nint container, int unk1, int unk2, nint unk3, ulong unk4, int unk5, int unk6, ulong unk7)
{
@ -194,16 +197,18 @@ public unsafe class AnimationHookService : IDisposable
_animationLoadData.Value = last;
}
private delegate void SomeActionLoadDelegate(ActionTimelineManager* timelineManager);
/// <summary> Seems to load character actions when zoning or changing class, maybe. </summary>
[Signature(Sigs.LoadSomeAction, DetourName = nameof(SomeActionLoadDetour))]
private readonly Hook<CharacterBaseNoArgumentDelegate> _someActionLoadHook = null!;
private readonly Hook<SomeActionLoadDelegate> _someActionLoadHook = null!;
private void SomeActionLoadDetour(nint gameObject)
private void SomeActionLoadDetour(ActionTimelineManager* timelineManager)
{
using var performance = _performance.Measure(PerformanceType.LoadAction);
var last = _animationLoadData.Value;
_animationLoadData.Value = _collectionResolver.IdentifyCollection((GameObject*)gameObject, true);
_someActionLoadHook.Original(gameObject);
_animationLoadData.Value = _collectionResolver.IdentifyCollection((GameObject*)timelineManager->Parent, true);
_someActionLoadHook.Original(timelineManager);
_animationLoadData.Value = last;
}