USD export: access deform verts as custom data.

Due to a recent Blender API change, MDeformVert entries
must be read as custom data.
This commit is contained in:
Michael Kowalski 2022-11-07 22:34:26 -05:00
parent 0f7433a4c8
commit 4d8c634820
1 changed files with 7 additions and 7 deletions

View File

@ -194,7 +194,7 @@ void USDSkinnedMeshWriter::write_weights(const Object *ob,
const pxr::UsdSkelBindingAPI &skel_api,
const std::vector<std::string> &bone_names) const
{
if (!(skel_api && ob && mesh && mesh->dvert && mesh->totvert > 0)) {
if (!(skel_api && ob && mesh && mesh->totvert > 0)) {
return;
}
@ -223,16 +223,17 @@ void USDSkinnedMeshWriter::write_weights(const Object *ob,
return;
}
const Span<MDeformVert> dverts = mesh->deform_verts();
int max_totweight = 1;
for (int i = 0; i < mesh->totvert; ++i) {
MDeformVert &vert = mesh->dvert[i];
for (const int i : dverts.index_range()) {
const MDeformVert &vert = dverts[i];
if (vert.totweight > max_totweight) {
max_totweight = vert.totweight;
}
}
const int ELEM_SIZE = max_totweight;
int num_points = mesh->totvert;
pxr::VtArray<int> joint_indices(num_points * ELEM_SIZE, 0);
@ -244,9 +245,8 @@ void USDSkinnedMeshWriter::write_weights(const Object *ob,
/* Record number of out of bounds vert group indices, for error reporting. */
int num_out_of_bounds = 0;
for (int i = 0; i < mesh->totvert; ++i) {
MDeformVert &vert = mesh->dvert[i];
for (const int i : dverts.index_range()) {
const MDeformVert &vert = dverts[i];
/* Sum of the weights, for normalizing. */
float sum_weights = 0.0f;