Alembic export: avoid infinite loops trying to find parent objects.

Also added some assertions for debugging purposes

Reviewed by: Kévin Dietrich
This commit is contained in:
Sybren A. Stüvel 2017-02-08 11:50:21 +01:00
parent 95e7f93fa2
commit ac38d5652b
1 changed files with 12 additions and 0 deletions

View File

@ -413,6 +413,10 @@ void AbcExporter::createTransformWriter(Object *ob, Object *parent, Object *dupl
{
const std::string name = get_object_dag_path_name(ob, dupliObParent);
/* An object should not be its own parent, or we'll get infinite loops. */
BLI_assert(ob != parent);
BLI_assert(ob != dupliObParent);
/* check if we have already created a transform writer for this object */
if (getXForm(name) != NULL){
std::cerr << "xform " << name << " already exists\n";
@ -429,6 +433,14 @@ void AbcExporter::createTransformWriter(Object *ob, Object *parent, Object *dupl
if (parent->parent) {
createTransformWriter(parent, parent->parent, dupliObParent);
}
else if (parent == dupliObParent) {
if (dupliObParent->parent == NULL) {
createTransformWriter(parent, NULL, NULL);
}
else {
createTransformWriter(parent, dupliObParent->parent, dupliObParent->parent);
}
}
else {
createTransformWriter(parent, dupliObParent, dupliObParent);
}