Skip to content

Commit

Permalink
Make FBX import use bone transforms of current ref shape
Browse files Browse the repository at this point in the history
  • Loading branch information
ousnius committed Nov 27, 2017
1 parent b4a1eaf commit b3c4485
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/components/Anim.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,15 @@ void AnimInfo::GetWeights(const std::string& shape, const std::string& boneName,
outVertWeights = *weights;
}

bool AnimInfo::GetShapeBoneXForm(const std::string& shape, const std::string& boneName, MatTransform& stransform) {
int b = GetShapeBoneIndex(shape, boneName);
if (b < 0)
return false;

stransform = shapeSkinning[shape].boneWeights[b].xform;
return true;
}

void AnimInfo::SetShapeBoneXForm(const std::string& shape, const std::string& boneName, MatTransform& stransform) {
int b = GetShapeBoneIndex(shape, boneName);
if (b < 0)
Expand Down
1 change: 1 addition & 0 deletions src/components/Anim.h
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ class AnimInfo {
void GetWeights(const std::string& shape, const std::string& boneName, std::unordered_map<ushort, float>& outVertWeights);
void GetBoneXForm(const std::string& boneName, MatTransform& stransform);
void SetWeights(const std::string& shape, const std::string& boneName, std::unordered_map<ushort, float>& inVertWeights);
bool GetShapeBoneXForm(const std::string& shape, const std::string& boneName, MatTransform& stransform);
void SetShapeBoneXForm(const std::string& shape, const std::string& boneName, MatTransform& stransform);
bool CalcShapeSkinBounds(const std::string& shape, const int& boneIndex);
void WriteToNif(NifFile* nif, const std::string& shapeException = "");
Expand Down
7 changes: 7 additions & 0 deletions src/program/OutfitProject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2292,6 +2292,13 @@ int OutfitProject::ImportFBX(const std::string& fileName, const std::string& sha
workAnim.shapeBones[useShapeName].push_back(bn);
workAnim.shapeSkinning[useShapeName].boneNames[bn] = slot;
workAnim.SetWeights(useShapeName, bn, shape->boneSkin[bn].GetWeights());

if (!baseShape.empty()) {
MatTransform xform;
if (workAnim.GetShapeBoneXForm(baseShape, bn, xform))
workAnim.SetShapeBoneXForm(useShapeName, bn, xform);
}

boneIndices.push_back(slot++);
}

Expand Down

0 comments on commit b3c4485

Please sign in to comment.