Fix BSGeometry virtual overrides and SkinAttach bone fallback#60
Merged
ousnius merged 1 commit intoMay 14, 2026
Merged
Conversation
… fallback BSGeometry had skinInstanceRef, shaderPropertyRef, and alphaPropertyRef members and read them in Sync(), but never overrode the virtual accessors inherited from NiShape. This caused SkinInstanceRef(), IsSkinned(), HasShaderProperty(), etc. to return null/false for all Starfield BSGeometry shapes, breaking skinning, bone loading, and shader/alpha property access. GetShapeBoneList now falls back to SkinAttach extra data when boneRefs yield no bone NiNodes. Starfield NIFs store bone names as strings in SkinAttach instead of NiNode block references (all boneRefs are 0xFFFFFFFF). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
DJLegends1011
added a commit
to DJLegends1011/BodySlide-and-Outfit-Studio
that referenced
this pull request
May 11, 2026
Starfield meshes appeared rotated and mispositioned because: 1. BSGeometry was missing virtual overrides for SkinInstanceRef(), IsSkinned(), etc. — fixed in nifly (ousnius/nifly#60). Without these, the skinned render path was skipped entirely. 2. SF NIFs store bone names in SkinAttach extra data instead of NiNode block references. AnimSkin::LoadFromNif now falls back to name-based bone lookup via GetShapeBoneList when block IDs yield no NiNodes. 3. SF body NIFs contain no bone NiNodes, so LoadCustomBoneFromNif fails. Added fallback to look up bones in the reference skeleton NIF. 4. SF skeleton/skin transforms are in meters, but mesh vertices are scaled by havokScale (69.969) during BSGeometryMeshData loading. The computed globalToSkin translation is now scaled to match. Tested on: naked_f.nif, naked_f_swimsuit.nif, Outfit_Ajun_Torso_f.nif, redeemed_armor.nif (multi-shape). All display upright and centered. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Open
6 tasks
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes two Starfield-specific issues in BSGeometry handling. First, BSGeometry was missing virtual overrides for skin instance, shader, and alpha property accessors (although it stored those refs and serialized them), causing all NiShape-based skinning and shader logic to silently fail. Second, Starfield NIFs store bone names in a SkinAttach extra data block rather than as NiNode references, so GetShapeBoneList needs a fallback to read from there.
Changes:
- Add
IsSkinned/HasSkinInstance/SkinInstanceRef/HasShaderProperty/ShaderPropertyRef/HasAlphaProperty/AlphaPropertyRefoverrides onBSGeometry, mirroring theBSTriShapepattern. - In
NifFile::GetShapeBoneList, fall back toSkinAttachextra data whenboneRefsyields no bone NiNodes.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| include/Geometry.hpp | Adds the missing virtual accessor overrides on BSGeometry for skin instance, shader, and alpha property refs. |
| src/NifFile.cpp | Adds a Starfield SkinAttach extra-data fallback to populate bone name lists when boneRefs contains no resolvable NiNodes. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
BSGeometryhadskinInstanceRef,shaderPropertyRef, andalphaPropertyRefmembers and read them inSync(), but never overrode the virtual accessors fromNiShape. This causedSkinInstanceRef(),IsSkinned(),HasShaderProperty(), etc. to return null/false for all Starfield BSGeometry shapes — breaking skinning, bone loading, and shader/alpha property access.GetShapeBoneListnow falls back toSkinAttachextra data whenboneRefsyield no bone NiNodes. Starfield NIFs store bone names as strings inSkinAttachinstead of NiNode block references (all boneRefs are0xFFFFFFFF).Context
These two changes are required for Starfield mesh loading in Outfit Studio. Without the virtual overrides, no code path using the
NiShapeinterface (skinning, shaders, alpha) works on BSGeometry shapes. Without the SkinAttach fallback, bone lists are empty for SF meshes.Test plan
naked_f.nif) — 38 bones loaded via SkinAttachIsSkinned()returns true for skinned BSGeometry shapesSkinInstanceRef()returns valid ref for BSGeometry with BSSkinInstance🤖 Generated with Claude Code