Skip to content

Commit

Permalink
Fixed maya get data
Browse files Browse the repository at this point in the history
Will now correctly assign the weights to the correct influence index
  • Loading branch information
munkybutt committed Sep 30, 2023
1 parent 9d6e3f8 commit e58fa36
Show file tree
Hide file tree
Showing 8 changed files with 7 additions and 8 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -445,7 +445,8 @@ PyProjects/source/vcpkg_installed/
PyProjects/venv37/
PyProjects/venv39/
PyProjects/.venvs/
/pypi/*
build/
pypi/
temp.cpp
*.exp
*.max
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified PYProjects/skin_plus_plus/py/39/skin_plus_plus_py.pyd
Binary file not shown.
2 changes: 1 addition & 1 deletion PYProjects/skin_plus_plus_test/skin_plus_plus_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -677,7 +677,7 @@ def add_bones():

if __name__ == "__main__":
pass
skin_plus_plus.io.max_to_maya(file_type=skin_plus_plus.FileType.json)
skin_plus_plus.io.maya_to_max(file_type=skin_plus_plus.FileType.json)
# skin_plus_plus
# bones = ["one", "two"]
# ids = np.array([[0, 1], [1, 0]], dtype=np.float64)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -202,16 +202,15 @@ PySkinData SkinManagerMaya::getData()
{
throw std::exception("SkinData object is invalid. Cannot get skin weights.");
}
UINT vertexCount = this->fnMesh.numVertices();
const UINT vertexCount = this->fnMesh.numVertices();
if (vertexCount == 0)
{
throw std::exception("Mesh has no vertices!");
}
MDoubleArray weights;
unsigned boneCount;
UINT boneCount;
this->fnSkinCluster.getWeights(this->dagPath, this->component, weights, boneCount);
PySkinData pySkinData = PySkinData(vertexCount, this->maximumVertexWeightCount);

MDagPathArray skinnedBones;
MStatus status;
this->fnSkinCluster.influenceObjects(skinnedBones, &status);
Expand All @@ -229,10 +228,10 @@ PySkinData SkinManagerMaya::getData()
for (UINT vertexIndex = 0; vertexIndex < vertexCount; vertexIndex++)
{
UINT influenceIndex = 0;
UINT weightIndex = vertexIndex * boneCount;
UINT weightIndexBase = vertexIndex * boneCount;
for (UINT boneIndex = 0; boneIndex < boneCount; boneIndex++)
{
weightIndex += boneIndex;
UINT weightIndex = weightIndexBase + boneIndex;
double influenceWeight = weights[weightIndex];
pySkinData.weights(vertexIndex, influenceIndex) = influenceWeight;
pySkinData.boneIDs(vertexIndex, influenceIndex) = boneIndex;
Expand Down Expand Up @@ -328,7 +327,6 @@ MDoubleArray getWeightsAsMDoubleArray(BoneIDsMatrix boneIDs, WeightsMatrix weigh
}



bool SkinManagerMaya::setSkinWeights(PySkinData& skinData)
{
auto vertexCount = skinData.boneIDs.rows();
Expand Down

0 comments on commit e58fa36

Please sign in to comment.