fix: #34427: Collada export crash with armature
This commit is contained in:
@@ -239,6 +239,7 @@ void ControllerExporter::export_skin_controller(Object *ob, Object *ob_arm)
|
|||||||
joint_index_by_def_index.push_back(-1);
|
joint_index_by_def_index.push_back(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int oob_counter = 0;
|
||||||
for (i = 0; i < me->totvert; i++) {
|
for (i = 0; i < me->totvert; i++) {
|
||||||
MDeformVert *vert = &me->dvert[i];
|
MDeformVert *vert = &me->dvert[i];
|
||||||
std::map<int, float> jw;
|
std::map<int, float> jw;
|
||||||
@@ -248,11 +249,18 @@ void ControllerExporter::export_skin_controller(Object *ob, Object *ob_arm)
|
|||||||
|
|
||||||
for (j = 0; j < vert->totweight; j++) {
|
for (j = 0; j < vert->totweight; j++) {
|
||||||
int idx = vert->dw[j].def_nr;
|
int idx = vert->dw[j].def_nr;
|
||||||
if (idx >= 0) {
|
if (idx >= joint_index_by_def_index.size()) {
|
||||||
int joint_index = joint_index_by_def_index[idx];
|
// XXX: Maybe better find out where and
|
||||||
if (joint_index != -1 && vert->dw[j].weight > 0.0f) {
|
// why the Out Of Bound indexes get created ?
|
||||||
jw[joint_index] += vert->dw[j].weight;
|
oob_counter += 1;
|
||||||
sumw += vert->dw[j].weight;
|
}
|
||||||
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -274,6 +282,10 @@ void ControllerExporter::export_skin_controller(Object *ob, Object *ob_arm)
|
|||||||
#endif
|
#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);
|
std::string weights_source_id = add_weights_source(me, controller_id, weights);
|
||||||
|
Reference in New Issue
Block a user