Remove no longer needed helpers.

This commit is contained in:
Ottermandias 2024-07-26 15:06:29 +02:00
parent d256702005
commit fb2b676ff0
3 changed files with 9 additions and 21 deletions

View file

@ -1,6 +1,7 @@
using Dalamud.Interface;
using Dalamud.Interface.Utility;
using FFXIVClientStructs.FFXIV.Client.Graphics.Kernel;
using FFXIVClientStructs.FFXIV.Client.System.Resource.Handle;
using FFXIVClientStructs.Interop;
using Glamourer.Designs;
using Glamourer.Interop.Material;
@ -79,8 +80,7 @@ public sealed unsafe class AdvancedDyePopup(
private (string Path, string GamePath) ResourceName(MaterialValueIndex index)
{
var materialHandle =
_actor.Model.AsCharacterBase->Materials()[index.MaterialIndex + index.SlotIndex * MaterialService.MaterialsPerModel].Value;
var materialHandle = (MaterialResourceHandle*)_actor.Model.AsCharacterBase->MaterialsSpan[index.MaterialIndex + index.SlotIndex * MaterialService.MaterialsPerModel].Value;
var model = _actor.Model.AsCharacterBase->ModelsSpan[index.SlotIndex].Value;
var modelHandle = model == null ? null : model->ModelResourceHandle;
var path = materialHandle == null

View file

@ -41,10 +41,10 @@ public static unsafe class MaterialService
return null;
var index = modelSlot * MaterialsPerModel + materialSlot;
if (index < 0 || index >= model.AsCharacterBase->ColorTableTextures().Length)
if (index < 0 || index >= model.AsCharacterBase->ColorTableTexturesSpan.Length)
return null;
var texture = (Texture**)Unsafe.AsPointer(ref model.AsCharacterBase->ColorTableTextures()[index]);
var texture = (Texture**)Unsafe.AsPointer(ref model.AsCharacterBase->ColorTableTexturesSpan[index]);
return texture;
}
@ -59,10 +59,10 @@ public static unsafe class MaterialService
return null;
var index = modelSlot * MaterialsPerModel + materialSlot;
if (index < 0 || index >= model.AsCharacterBase->Materials().Length)
if (index < 0 || index >= model.AsCharacterBase->MaterialsSpan.Length)
return null;
var material = model.AsCharacterBase->Materials()[index].Value;
var material = (MaterialResourceHandle*) model.AsCharacterBase->MaterialsSpan[index].Value;
if (material == null || material->ColorTable == null)
return null;

View file

@ -1,6 +1,4 @@
using FFXIVClientStructs.FFXIV.Client.Graphics.Kernel;
using FFXIVClientStructs.FFXIV.Client.Graphics.Scene;
using FFXIVClientStructs.FFXIV.Client.System.Resource.Handle;
using FFXIVClientStructs.Interop;
using Newtonsoft.Json;
using Penumbra.GameData.Enums;
@ -81,13 +79,13 @@ public readonly record struct MaterialValueIndex(
{
if (!TryGetModel(actor, out var model)
|| SlotIndex >= model.AsCharacterBase->SlotCount
|| model.AsCharacterBase->ColorTableTextures().Length < (SlotIndex + 1) * MaterialService.MaterialsPerModel)
|| model.AsCharacterBase->ColorTableTexturesSpan.Length < (SlotIndex + 1) * MaterialService.MaterialsPerModel)
{
textures = [];
return false;
}
textures = model.AsCharacterBase->ColorTableTextures().Slice(SlotIndex * MaterialService.MaterialsPerModel,
textures = model.AsCharacterBase->ColorTableTexturesSpan.Slice(SlotIndex * MaterialService.MaterialsPerModel,
MaterialService.MaterialsPerModel);
return true;
}
@ -193,13 +191,3 @@ public readonly record struct MaterialValueIndex(
=> FromKey(serializer.Deserialize<uint>(reader), out var value) ? value : throw new Exception($"Invalid material key {value.Key}.");
}
}
// TODO Remove when fixed in CS.
public static class ColorTableExtension
{
public static unsafe Span<Pointer<MaterialResourceHandle>> Materials(this ref CharacterBase character)
=> new(character.Materials, character.SlotCount * MaterialService.MaterialsPerModel);
public static unsafe Span<Pointer<Texture>> ColorTableTextures(this ref CharacterBase character)
=> new(character.ColorTableTextures, character.SlotCount * MaterialService.MaterialsPerModel);
}