ousnius / BodySlide-and-Outfit-Studio

BodySlide and Outfit Studio, a tool to convert, create, and customize outfits and bodies for Bethesda games.
GNU General Public License v3.0
286 stars 63 forks source link

Accessors for transforms between shape and global #439

Closed sts1skj closed 2 years ago

sts1skj commented 2 years ago

The new accessor functions are in AnimInfo. If the shape is skinned, they access AnimSkin::xformGlobalToSkin. If the shape is unskinned, they access the shape's node-to-global transform from workNif. The purpose of this is so that skinned and unskinned meshes can be treated the same when it comes to this important transform.

The reason these accessor functions need to be in AnimInfo and not, say, OutfitProject, is that some of the places where this information is needed (Automorph and FBXWrangler) don't have access to OutfitProject but do have access to AnimInfo.

I searched for all instances of xformGlobalToSkin outside Anim.{h,cpp} and replaced them with calls of the accessor functions. This had the following benefits:

I also added CreateSkinning and RemoveSkinning functions to OutfitProject that wrap the NifFile functions CreateSkinning and DeleteSkinning. These functions make sure the transforms between shape and global coordinates do not change when the shape is skinned and unskinned. I searched for all calls of the NifFile functions and replaced them.

I also made sure AnimInfo::refNif is initialized on construction and never set to nullptr.

While this PR does not directly fix issue #429 , it does open up new options: