mirror of
https://github.com/Caraxi/mare.client.git
synced 2025-12-14 06:24:14 +01:00
fix my own mistakes
This commit is contained in:
parent
c1f70cd47c
commit
f25f2cb861
2 changed files with 20 additions and 14 deletions
|
|
@ -139,6 +139,7 @@ public class PlayerDataFactory
|
||||||
await Task.Delay(50, token).ConfigureAwait(false);
|
await Task.Delay(50, token).ConfigureAwait(false);
|
||||||
totalWaitTime -= 50;
|
totalWaitTime -= 50;
|
||||||
}
|
}
|
||||||
|
var boneIndices = await _dalamudUtil.RunOnFrameworkThread(() => _modelAnalyzer.GetSkeletonBoneIndices(charaPointer)).ConfigureAwait(false);
|
||||||
|
|
||||||
DateTime start = DateTime.UtcNow;
|
DateTime start = DateTime.UtcNow;
|
||||||
|
|
||||||
|
|
@ -236,7 +237,14 @@ public class PlayerDataFactory
|
||||||
|
|
||||||
if (objectKind == ObjectKind.Player)
|
if (objectKind == ObjectKind.Player)
|
||||||
{
|
{
|
||||||
await VerifyPlayerAnimationBones(previousData, objectKind, charaPointer).ConfigureAwait(false);
|
try
|
||||||
|
{
|
||||||
|
await VerifyPlayerAnimationBones(boneIndices, previousData, objectKind).ConfigureAwait(false);
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
_logger.LogWarning(e, "Failed to verify player animations, continuing");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_logger.LogInformation("Building character data for {obj} took {time}ms", objectKind, TimeSpan.FromTicks(DateTime.UtcNow.Ticks - start.Ticks).TotalMilliseconds);
|
_logger.LogInformation("Building character data for {obj} took {time}ms", objectKind, TimeSpan.FromTicks(DateTime.UtcNow.Ticks - start.Ticks).TotalMilliseconds);
|
||||||
|
|
@ -244,14 +252,13 @@ public class PlayerDataFactory
|
||||||
return previousData;
|
return previousData;
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task VerifyPlayerAnimationBones(CharacterData previousData, ObjectKind objectKind, nint charaPointer)
|
private async Task VerifyPlayerAnimationBones(Dictionary<string, List<ushort>>? boneIndices, CharacterData previousData, ObjectKind objectKind)
|
||||||
{
|
{
|
||||||
var boneIndices = _modelAnalyzer.GetSkeletonBoneIndices(charaPointer);
|
|
||||||
if (boneIndices != null)
|
if (boneIndices != null)
|
||||||
{
|
{
|
||||||
foreach (var kvp in boneIndices)
|
foreach (var kvp in boneIndices)
|
||||||
{
|
{
|
||||||
_logger.LogDebug("Found {skellyname} ({idx} bone indices) on player: {bones}", kvp.Key, kvp.Value.Max(), string.Join(',', kvp.Value));
|
_logger.LogDebug("Found {skellyname} ({idx} bone indices) on player: {bones}", kvp.Key, kvp.Value.Any() ? kvp.Value.Max() : 0, string.Join(',', kvp.Value));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (boneIndices.All(u => u.Value.Count == 0)) return;
|
if (boneIndices.All(u => u.Value.Count == 0)) return;
|
||||||
|
|
|
||||||
|
|
@ -35,15 +35,14 @@ public sealed class XivDataAnalyzer
|
||||||
var resHandles = chara->Skeleton->SkeletonResourceHandles;
|
var resHandles = chara->Skeleton->SkeletonResourceHandles;
|
||||||
int i = 0;
|
int i = 0;
|
||||||
Dictionary<string, List<ushort>> outputIndices = [];
|
Dictionary<string, List<ushort>> outputIndices = [];
|
||||||
while (*(resHandles + i) != null)
|
|
||||||
{
|
|
||||||
string skeletonName = "unknown";
|
|
||||||
|
|
||||||
try
|
try
|
||||||
|
{
|
||||||
|
while (*(resHandles + i) != null)
|
||||||
{
|
{
|
||||||
var handle = *(resHandles + i);
|
var handle = *(resHandles + i);
|
||||||
var curBones = handle->BoneCount;
|
var curBones = handle->BoneCount;
|
||||||
skeletonName = handle->ResourceHandle.FileName.ToString();
|
var skeletonName = handle->ResourceHandle.FileName.ToString();
|
||||||
|
if (string.IsNullOrEmpty(skeletonName)) continue;
|
||||||
outputIndices[skeletonName] = new();
|
outputIndices[skeletonName] = new();
|
||||||
for (ushort boneIdx = 0; boneIdx < curBones; boneIdx++)
|
for (ushort boneIdx = 0; boneIdx < curBones; boneIdx++)
|
||||||
{
|
{
|
||||||
|
|
@ -53,12 +52,12 @@ public sealed class XivDataAnalyzer
|
||||||
outputIndices[skeletonName].Add(boneIdx);
|
outputIndices[skeletonName].Add(boneIdx);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
i++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
_logger.LogWarning(ex, "Could procss skeleton {skl}", skeletonName);
|
_logger.LogWarning(ex, "Could not process skeleton data");
|
||||||
}
|
|
||||||
i++;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return outputIndices;
|
return outputIndices;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue