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/simulation/intern/simulation_solver.hh | |
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/simulation/intern/simulation_solver.hh')
-rw-r--r-- | source/blender/simulation/intern/simulation_solver.hh | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/source/blender/simulation/intern/simulation_solver.hh b/source/blender/simulation/intern/simulation_solver.hh index b5e42b53846..1d1b9935661 100644 --- a/source/blender/simulation/intern/simulation_solver.hh +++ b/source/blender/simulation/intern/simulation_solver.hh @@ -24,6 +24,8 @@ #include "FN_attributes_ref.hh" +#include "BKE_persistent_data_handle.hh" + #include "particle_allocator.hh" #include "time_interval.hh" @@ -50,6 +52,7 @@ struct SimulationInfluences { Map<std::string, Vector<const ParticleForce *>> particle_forces; Map<std::string, fn::AttributesInfoBuilder *> particle_attributes_builder; Vector<const ParticleEmitter *> particle_emitters; + VectorSet<ID *> used_data_blocks; }; class SimulationSolveContext { @@ -58,16 +61,19 @@ class SimulationSolveContext { Depsgraph &depsgraph_; const SimulationInfluences &influences_; TimeInterval solve_interval_; + const bke::PersistentDataHandleMap &id_handle_map_; public: SimulationSolveContext(Simulation &simulation, Depsgraph &depsgraph, const SimulationInfluences &influences, - TimeInterval solve_interval) + TimeInterval solve_interval, + const bke::PersistentDataHandleMap &handle_map) : simulation_(simulation), depsgraph_(depsgraph), influences_(influences), - solve_interval_(solve_interval) + solve_interval_(solve_interval), + id_handle_map_(handle_map) { } @@ -80,6 +86,11 @@ class SimulationSolveContext { { return influences_; } + + const bke::PersistentDataHandleMap &handle_map() const + { + return id_handle_map_; + } }; class ParticleAllocators { @@ -147,6 +158,11 @@ class ParticleEmitterContext { { } + SimulationSolveContext &solve_context() + { + return solve_context_; + } + ParticleAllocator *try_get_particle_allocator(StringRef particle_simulation_name) { return particle_allocators_.try_get_allocator(particle_simulation_name); @@ -174,6 +190,11 @@ class ParticleForceContext { { } + SimulationSolveContext &solve_context() + { + return solve_context_; + } + const ParticleChunkContext &particle_chunk() const { return particle_chunk_context_; |