joint_index_by_def_index.push_back(-1);
}
+ int oob_counter = 0;
for (i = 0; i < me->totvert; i++) {
MDeformVert *vert = &me->dvert[i];
std::map<int, float> jw;
for (j = 0; j < vert->totweight; j++) {
int idx = vert->dw[j].def_nr;
- if (idx >= 0) {
- int joint_index = joint_index_by_def_index[idx];
- if (joint_index != -1 && vert->dw[j].weight > 0.0f) {
- jw[joint_index] += vert->dw[j].weight;
- sumw += vert->dw[j].weight;
+ if (idx >= joint_index_by_def_index.size()) {
+ // XXX: Maybe better find out where and
+ // why the Out Of Bound indexes get created ?
+ oob_counter += 1;
+ }
+ else {
+ if (idx >= 0) {
+ int joint_index = joint_index_by_def_index[idx];
+ if (joint_index != -1 && vert->dw[j].weight > 0.0f) {
+ jw[joint_index] += vert->dw[j].weight;
+ sumw += vert->dw[j].weight;
+ }
}
}
}
#endif
}
}
+
+ if (oob_counter > 0) {
+ fprintf(stderr, "Ignored %d Vertex weigths which use index to non existing VGroup.\n", oob_counter, joint_index_by_def_index.size());
+ }
}
std::string weights_source_id = add_weights_source(me, controller_id, weights);