Skip to content

Commit

Permalink
Verified correct import for 90% of sample models
Browse files Browse the repository at this point in the history
  • Loading branch information
Siccity committed Sep 29, 2020
1 parent 8fa38e3 commit db09121
Showing 1 changed file with 17 additions and 16 deletions.
33 changes: 17 additions & 16 deletions Plugins/draco/GLTFUtilityDracoLoader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -270,22 +270,23 @@ public unsafe Mesh CreateUnityMesh(DracoMesh * dracoMesh) {
if (newColors != null) {
mesh.colors = newColors;
}
if (newJoints != null && newWeights != null && newJoints.Length == newWeights.Length) {
BoneWeight[] boneWeights = new BoneWeight[newWeights.Length];
for (int k = 0; k < boneWeights.Length; k++) {
NormalizeWeights(ref newWeights[k]);
boneWeights[k].weight0 = newWeights[k].x;
boneWeights[k].weight1 = newWeights[k].y;
boneWeights[k].weight2 = newWeights[k].z;
boneWeights[k].weight3 = newWeights[k].w;
boneWeights[k].boneIndex0 = Mathf.RoundToInt(newJoints[k].x);
boneWeights[k].boneIndex1 = Mathf.RoundToInt(newJoints[k].y);
boneWeights[k].boneIndex2 = Mathf.RoundToInt(newJoints[k].z);
boneWeights[k].boneIndex3 = Mathf.RoundToInt(newJoints[k].w);
}
mesh.boneWeights = boneWeights;
} else Debug.LogWarning("newJoints and newWeights not same length. Skipped");

if (newJoints != null && newWeights != null) {
if (newJoints.Length == newWeights.Length) {
BoneWeight[] boneWeights = new BoneWeight[newWeights.Length];
for (int k = 0; k < boneWeights.Length; k++) {
NormalizeWeights(ref newWeights[k]);
boneWeights[k].weight0 = newWeights[k].x;
boneWeights[k].weight1 = newWeights[k].y;
boneWeights[k].weight2 = newWeights[k].z;
boneWeights[k].weight3 = newWeights[k].w;
boneWeights[k].boneIndex0 = Mathf.RoundToInt(newJoints[k].x);
boneWeights[k].boneIndex1 = Mathf.RoundToInt(newJoints[k].y);
boneWeights[k].boneIndex2 = Mathf.RoundToInt(newJoints[k].z);
boneWeights[k].boneIndex3 = Mathf.RoundToInt(newJoints[k].w);
}
mesh.boneWeights = boneWeights;
} else Debug.LogWarning("Draco: joints and weights not same length. Skipped");
}
return mesh;
}

Expand Down

0 comments on commit db09121

Please sign in to comment.