feat: enable NPC helmet attachments with fallback logic for missing attachment points

Add fallback logic to use bone 0 for head attachment point (ID 11) when models
don't have it explicitly defined. This improves helmet rendering compatibility
on humanoid NPC models that lack explicit attachment 11 definitions. Re-enable
helmet attachments now that the fallback logic is in place.
This commit is contained in:
Kelsi 2026-03-11 09:56:04 -07:00
parent 176b8bdc3d
commit 0d002c9070
2 changed files with 13 additions and 4 deletions

View file

@ -3072,7 +3072,7 @@ bool CharacterRenderer::attachWeapon(uint32_t charInstanceId, uint32_t attachmen
}
}
}
// Fallback to key-bone lookup only for weapon hand attachment IDs.
// Fallback to key-bone lookup for weapon hand attachment IDs.
if (!found && (attachmentId == 1 || attachmentId == 2)) {
int32_t targetKeyBone = (attachmentId == 1) ? 26 : 27;
for (size_t i = 0; i < charModel.bones.size(); i++) {
@ -3084,6 +3084,14 @@ bool CharacterRenderer::attachWeapon(uint32_t charInstanceId, uint32_t attachmen
}
}
// Fallback for head attachment (ID 11): try common head bone indices
// Some models may not have attachment 11 defined, but have bone 0 or 1 as head
if (!found && attachmentId == 11 && charModel.bones.size() > 0) {
// Try bone 0 first (common for head in many humanoid models)
boneIndex = 0;
found = true;
}
// Validate bone index (bad attachment tables should not silently bind to origin)
if (found && boneIndex >= charModel.bones.size()) {
found = false;