[Bf-blender-cvs] [97da5f31d4d] functions: move responsibility to ensure that attributes exist out of simulator
Jacques Lucke
noreply at git.blender.org
Fri Sep 20 16:38:31 CEST 2019
Commit: 97da5f31d4d7834dccbecddb66d3d6d387801c35
Author: Jacques Lucke
Date: Fri Sep 20 16:32:59 2019 +0200
Branches: functions
https://developer.blender.org/rB97da5f31d4d7834dccbecddb66d3d6d387801c35
move responsibility to ensure that attributes exist out of simulator
===================================================================
M source/blender/simulations/bparticles/node_frontend.cpp
M source/blender/simulations/bparticles/simulate.cpp
M source/blender/simulations/bparticles/simulate.hpp
===================================================================
diff --git a/source/blender/simulations/bparticles/node_frontend.cpp b/source/blender/simulations/bparticles/node_frontend.cpp
index 69d2f86279e..63d43e68953 100644
--- a/source/blender/simulations/bparticles/node_frontend.cpp
+++ b/source/blender/simulations/bparticles/node_frontend.cpp
@@ -854,8 +854,10 @@ class NodeTreeStepSimulator : public StepSimulator {
system_attributes.join(container->attributes_info());
}
+ this->ensure_particle_container_exist_and_has_attributes(
+ particles_state, name, AttributesInfo(system_attributes));
+
ParticleSystemInfo type_info = {
- &system_attributes,
integrators.lookup(name),
events.lookup_default(name),
offset_handlers.lookup_default(name),
@@ -874,6 +876,23 @@ class NodeTreeStepSimulator : public StepSimulator {
simulation_state.world() = std::move(new_world_state);
}
+
+ private:
+ void ensure_particle_container_exist_and_has_attributes(ParticlesState &particles_state,
+ StringRef name,
+ AttributesInfo attributes_info)
+ {
+ auto &containers = particles_state.particle_containers();
+ AttributesBlockContainer *container = containers.lookup_default(name, nullptr);
+ if (container == nullptr) {
+ AttributesBlockContainer *container = new AttributesBlockContainer(
+ std::move(attributes_info), 1000);
+ containers.add_new(name, container);
+ }
+ else {
+ container->update_attributes(std::move(attributes_info));
+ }
+ }
};
std::unique_ptr<StepSimulator> simulator_from_node_tree(bNodeTree *btree)
diff --git a/source/blender/simulations/bparticles/simulate.cpp b/source/blender/simulations/bparticles/simulate.cpp
index c22bbd5bd31..e2924eb07b2 100644
--- a/source/blender/simulations/bparticles/simulate.cpp
+++ b/source/blender/simulations/bparticles/simulate.cpp
@@ -456,33 +456,6 @@ BLI_NOINLINE static void compress_all_containers(ParticlesState &state)
[](AttributesBlockContainer *container) { compress_all_blocks(*container); });
}
-BLI_NOINLINE static void ensure_required_containers_exist(
- ParticlesState &state, StringMap<ParticleSystemInfo> &systems_to_simulate)
-{
- auto &containers = state.particle_containers();
-
- systems_to_simulate.foreach_key([&containers](StringRefNull system_name) {
- if (!containers.contains(system_name)) {
- AttributesBlockContainer *container = new AttributesBlockContainer(AttributesInfo(), 1000);
- containers.add_new(system_name, container);
- }
- });
-}
-
-BLI_NOINLINE static void ensure_required_attributes_exist(
- ParticlesState &state, StringMap<ParticleSystemInfo> systems_to_simulate)
-{
- auto &containers = state.particle_containers();
-
- systems_to_simulate.foreach_key_value_pair(
- [&](StringRefNull system_name, ParticleSystemInfo &system_info) {
- AttributesBlockContainer &container = *containers.lookup(system_name);
-
- AttributesInfo new_attributes_info(*system_info.attributes_declaration);
- container.update_attributes(std::move(new_attributes_info));
- });
-}
-
BLI_NOINLINE static void simulate_all_existing_blocks(
ParticlesState &state,
StringMap<ParticleSystemInfo> &systems_to_simulate,
@@ -534,9 +507,6 @@ void simulate_particles(SimulationState &state,
ParticlesState &particles_state = state.particles();
- ensure_required_containers_exist(particles_state, systems_to_simulate);
- ensure_required_attributes_exist(particles_state, systems_to_simulate);
-
emit_and_simulate_particles(
particles_state, state.time().current_update_time(), emitters, systems_to_simulate);
diff --git a/source/blender/simulations/bparticles/simulate.hpp b/source/blender/simulations/bparticles/simulate.hpp
index 2936fe4dfc7..a3c7f120925 100644
--- a/source/blender/simulations/bparticles/simulate.hpp
+++ b/source/blender/simulations/bparticles/simulate.hpp
@@ -9,8 +9,6 @@
namespace BParticles {
struct ParticleSystemInfo {
- AttributesDeclaration *attributes_declaration;
-
Integrator *integrator;
ArrayRef<Event *> events;
ArrayRef<OffsetHandler *> offset_handlers;
More information about the Bf-blender-cvs
mailing list