diff options
author | Jacques Lucke <jacques@blender.org> | 2020-07-21 18:20:05 +0300 |
---|---|---|
committer | Jacques Lucke <jacques@blender.org> | 2020-07-21 18:35:09 +0300 |
commit | 8369adabc0ec7a1fce248b688bf20860ae0434bb (patch) | |
tree | af767efe8c6765c5876391a5eb96923fc8d6ac68 /source/blender/blenloader | |
parent | 6c7e62ef9be564fbee279c7467c9b6adaf51b6c8 (diff) |
Particles: initial object socket and emitter node support
Object sockets work now, but only the new Object Transforms and the
Particle Mesh Emitter node use it. The emitter does not actually
use the mesh surface yet. Instead, new particles are just emitted around
the origin of the object.
Internally, handles to object data blocks are passed around in the network,
instead of raw object pointers. Using handles has a couple of benefits:
* The caller of the function has control over which handles can be resolved
and therefore limit access to specific data. The set of data blocks that
is accessed by a node tree should be known statically. This is necessary
for a proper integration with the dependency graph.
* When the pointer to an object changes (e.g. after restarting Blender),
all handles are still valid.
* When an object is deleted, the handle is invalidated without causing crashes.
* The handle is just an integer that can be stored per particle and can be cached easily.
The mapping between handles and their corresponding data blocks is
stored in the Simulation data block.
Diffstat (limited to 'source/blender/blenloader')
-rw-r--r-- | source/blender/blenloader/intern/readfile.c | 12 | ||||
-rw-r--r-- | source/blender/blenloader/intern/writefile.c | 2 |
2 files changed, 13 insertions, 1 deletions
diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index 8bfab730313..f443859e62c 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -8675,8 +8675,12 @@ static void direct_link_volume(BlendDataReader *reader, Volume *volume) /** \name Read ID: Simulation * \{ */ -static void lib_link_simulation(BlendLibReader *UNUSED(reader), Simulation *UNUSED(simulation)) +static void lib_link_simulation(BlendLibReader *reader, Simulation *simulation) { + LISTBASE_FOREACH ( + PersistentDataHandleItem *, handle_item, &simulation->persistent_data_handles) { + BLO_read_id_address(reader, simulation->id.lib, &handle_item->id); + } } static void direct_link_simulation(BlendDataReader *reader, Simulation *simulation) @@ -8697,6 +8701,8 @@ static void direct_link_simulation(BlendDataReader *reader, Simulation *simulati }; } } + + BLO_read_list(reader, &simulation->persistent_data_handles); } /** \} */ @@ -11105,6 +11111,10 @@ static void expand_simulation(BlendExpander *expander, Simulation *simulation) if (simulation->adt) { expand_animdata(expander, simulation->adt); } + LISTBASE_FOREACH ( + PersistentDataHandleItem *, handle_item, &simulation->persistent_data_handles) { + BLO_expand(expander, handle_item->id); + } } /** diff --git a/source/blender/blenloader/intern/writefile.c b/source/blender/blenloader/intern/writefile.c index 8b9de3eea24..d33d8032ed1 100644 --- a/source/blender/blenloader/intern/writefile.c +++ b/source/blender/blenloader/intern/writefile.c @@ -3859,6 +3859,8 @@ static void write_simulation(BlendWriter *writer, Simulation *simulation, const } } } + + BLO_write_struct_list(writer, PersistentDataHandleItem, &simulation->persistent_data_handles); } } |