Blender Git Loki

Git Commits -> Revision 70b1c09

Revision 70b1c09 by Sybren A. Stüvel (master)
July 7, 2020, 11:01 (GMT)
IO: Fix bug exporting dupli parent/child relations

Exporting a scene to USD or Alembic would fail when there are multiple
duplicates of parent & child objects, duplicated by the same object. For
example, this happens when such a hierarchy of objects is contained in a
collection, and that collection is instanced multiple times by mesh
vertices. The problem here is that the 'parent' pointer of each
duplicated object points to the real parent; Blender would not figure
out properly which duplicated parent should be used.

This is now resolved by keeping track of the persistent ID of each
duplicated instance, which makes it possible to reconstruct the
parent-child relations of duplicated objects. This does use up some
memory for each dupli, so it could be heavy to export a Spring scene
(with all the pebbles and leaves), but it's only a small addition on top
of the USD/Alembic writer objects that have to be created anyway. At
least with this patch, they're created correctly.

Code-wise, the following changes are made:

- The export graph (that maps export parent to its export children) used
to have as its key (Object, Duplicator). This is insufficient to
correctly distinguish between multiple duplis of the same object by
the same duplicator, so this is now extended to (Object, Duplicator,
Persistent ID). To make this possible, new classes `ObjectIdentifier`
and `PersistentID` are introduced.
- Finding the parent of a duplicated object is done via its persistent
ID. In Python notation, the code first tries to find the parent
instance where `child_persistent_id[1:] == parent_persistent_id[1:]`.
If that fails, the dupli with persistent ID `child_persistent_id[1:]`
is used as parent.

Reviewed By: sergey

Differential Revision: https://developer.blender.org/D8233

Commit Details:

Full Hash: 70b1c09d7a40912b5dccc69fc95cbee2e2388eab
Parent Commit: f2175e0
Lines Changed: +835, -52

6 Added Paths:

/source/blender/io/common/intern/dupli_parent_finder.cc (+104, -0) (View)
/source/blender/io/common/intern/dupli_parent_finder.hh (+62, -0) (View)
/source/blender/io/common/intern/dupli_persistent_id.cc (+144, -0) (View)
/source/blender/io/common/intern/object_identifier.cc (+116, -0) (View)
/source/blender/io/common/IO_dupli_persistent_id.hh (+61, -0) (View)
/tests/gtests/usd/object_identifier_test.cc (+203, -0) (View)

7 Modified Paths:

/source/blender/io/alembic/exporter/abc_hierarchy_iterator.cc (+7, -4) (Diff)
/source/blender/io/alembic/exporter/abc_hierarchy_iterator.h (+3, -1) (Diff)
/source/blender/io/common/CMakeLists.txt (+5, -0) (Diff)
/source/blender/io/common/intern/abstract_hierarchy_iterator.cc (+33, -39) (Diff)
/source/blender/io/common/IO_abstract_hierarchy_iterator.h (+39, -8) (Diff)
/tests/gtests/usd/CMakeLists.txt (+1, -0) (Diff)
/tests/python/alembic_tests.py (+57, -0) (Diff)
Tehnyt: Miika HämäläinenViimeksi päivitetty: 07.11.2014 14:18MiikaH:n Sivut a.k.a. MiikaHweb | 2003-2021