fix spoopy skellingtons

This commit is contained in:
rootdarkarchon
2024-03-30 01:50:11 +01:00
parent 004f50123c
commit e9721a6c59
2 changed files with 8 additions and 6 deletions

View File

@@ -142,7 +142,7 @@ public class PlayerDataFactory
Dictionary<string, List<ushort>>? boneIndices = Dictionary<string, List<ushort>>? boneIndices =
objectKind != ObjectKind.Player objectKind != ObjectKind.Player
? null ? null
: await _dalamudUtil.RunOnFrameworkThread(() => _modelAnalyzer.GetSkeletonBoneIndices(playerRelatedObject.Address)).ConfigureAwait(false); : await _dalamudUtil.RunOnFrameworkThread(() => _modelAnalyzer.GetSkeletonBoneIndices(playerRelatedObject)).ConfigureAwait(false);
DateTime start = DateTime.UtcNow; DateTime start = DateTime.UtcNow;

View File

@@ -6,6 +6,7 @@ using Lumina;
using Lumina.Data.Files; using Lumina.Data.Files;
using MareSynchronos.FileCache; using MareSynchronos.FileCache;
using MareSynchronos.MareConfiguration; using MareSynchronos.MareConfiguration;
using MareSynchronos.PlayerData.Handlers;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
@@ -27,19 +28,20 @@ public sealed class XivDataAnalyzer
_luminaGameData = new GameData(gameData.GameData.DataPath.FullName); _luminaGameData = new GameData(gameData.GameData.DataPath.FullName);
} }
public unsafe Dictionary<string, List<ushort>>? GetSkeletonBoneIndices(nint charaPtr) public unsafe Dictionary<string, List<ushort>>? GetSkeletonBoneIndices(GameObjectHandler handler)
{ {
if (charaPtr == nint.Zero) return null; if (handler.Address == nint.Zero) return null;
var chara = (CharacterBase*)(((Character*)charaPtr)->GameObject.DrawObject); var chara = (CharacterBase*)(((Character*)handler.Address)->GameObject.DrawObject);
if (chara->GetModelType() != CharacterBase.ModelType.Human) return null; if (chara->GetModelType() != CharacterBase.ModelType.Human) return null;
var resHandles = chara->Skeleton->SkeletonResourceHandles; var resHandles = chara->Skeleton->SkeletonResourceHandles;
int i = -1;
Dictionary<string, List<ushort>> outputIndices = []; Dictionary<string, List<ushort>> outputIndices = [];
try try
{ {
while (*(resHandles + ++i) != null) for (int i = 0; i < chara->Skeleton->PartialSkeletonCount; i++)
{ {
var handle = *(resHandles + i); var handle = *(resHandles + i);
_logger.LogTrace("Iterating over SkeletonResourceHandle #{i}:{x}", i, ((nint)handle).ToString("X"));
if ((nint)handle == nint.Zero) continue;
var curBones = handle->BoneCount; var curBones = handle->BoneCount;
// this is unrealistic, the filename shouldn't ever be that long // this is unrealistic, the filename shouldn't ever be that long
if (handle->ResourceHandle.FileName.Length > 1024) continue; if (handle->ResourceHandle.FileName.Length > 1024) continue;