[Bf-blender-cvs] [9c46c784d5d] functions: move attributes declaration out of simulate code
Jacques Lucke
noreply at git.blender.org
Fri Sep 20 16:38:28 CEST 2019
Commit: 9c46c784d5d2e6d5699a805a21d522cfe59d787d
Author: Jacques Lucke
Date: Fri Sep 20 16:21:02 2019 +0200
Branches: functions
https://developer.blender.org/rB9c46c784d5d2e6d5699a805a21d522cfe59d787d
move attributes declaration out of simulate code
===================================================================
M source/blender/simulations/bparticles/node_frontend.cpp
M source/blender/simulations/bparticles/simulate.cpp
===================================================================
diff --git a/source/blender/simulations/bparticles/node_frontend.cpp b/source/blender/simulations/bparticles/node_frontend.cpp
index d5285c4685e..69d2f86279e 100644
--- a/source/blender/simulations/bparticles/node_frontend.cpp
+++ b/source/blender/simulations/bparticles/node_frontend.cpp
@@ -787,6 +787,10 @@ static void collect_influences(VTreeData &vtree_data,
attributes.add<float>("Size", 0.05f);
attributes.add<rgba_f>("Color", rgba_f(1, 1, 1, 1));
+ for (Event *event : r_events_per_type.lookup_default(system_name)) {
+ event->attributes(attributes);
+ }
+
ArrayRef<Force *> forces = collector.m_forces.lookup_default(system_name);
EulerIntegrator *integrator = new EulerIntegrator(forces);
@@ -813,6 +817,8 @@ class NodeTreeStepSimulator : public StepSimulator {
WorldState new_world_state;
WorldTransition world_transition = {old_world_state, new_world_state};
+ ParticlesState &particles_state = simulation_state.particles();
+
Vector<std::string> system_names;
Vector<Emitter *> emitters;
MultiMap<std::string, Event *> events;
@@ -836,10 +842,20 @@ class NodeTreeStepSimulator : public StepSimulator {
attributes,
integrators);
+ auto &containers = particles_state.particle_containers();
+
StringMap<ParticleSystemInfo> systems_to_simulate;
for (std::string name : system_names) {
+ AttributesDeclaration &system_attributes = attributes.lookup(name);
+
+ /* Keep old attributes. */
+ AttributesBlockContainer *container = containers.lookup_default(name, nullptr);
+ if (container != nullptr) {
+ system_attributes.join(container->attributes_info());
+ }
+
ParticleSystemInfo type_info = {
- &attributes.lookup(name),
+ &system_attributes,
integrators.lookup(name),
events.lookup_default(name),
offset_handlers.lookup_default(name),
diff --git a/source/blender/simulations/bparticles/simulate.cpp b/source/blender/simulations/bparticles/simulate.cpp
index 943ed2ff7f0..c22bbd5bd31 100644
--- a/source/blender/simulations/bparticles/simulate.cpp
+++ b/source/blender/simulations/bparticles/simulate.cpp
@@ -469,32 +469,17 @@ BLI_NOINLINE static void ensure_required_containers_exist(
});
}
-BLI_NOINLINE static AttributesInfo build_attribute_info_for_system(ParticleSystemInfo &system_info,
- const AttributesInfo &last_info)
-{
- AttributesDeclaration builder;
- builder.join(last_info);
- builder.join(*system_info.attributes_declaration);
-
- for (Event *event : system_info.events) {
- event->attributes(builder);
- }
-
- return AttributesInfo(builder);
-}
-
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(
- [&containers](StringRefNull system_name, ParticleSystemInfo &system_info) {
+ [&](StringRefNull system_name, ParticleSystemInfo &system_info) {
AttributesBlockContainer &container = *containers.lookup(system_name);
- AttributesInfo new_attributes_info = build_attribute_info_for_system(
- system_info, container.attributes_info());
- container.update_attributes(new_attributes_info);
+ AttributesInfo new_attributes_info(*system_info.attributes_declaration);
+ container.update_attributes(std::move(new_attributes_info));
});
}
More information about the Bf-blender-cvs
mailing list