[Bf-blender-cvs] [ab51c0e7dcd] functions: initial particle type intermediate class

Jacques Lucke noreply at git.blender.org
Fri Jun 21 16:56:31 CEST 2019


Commit: ab51c0e7dcd3c0ce1296f559fe909b5b977ba8a4
Author: Jacques Lucke
Date:   Fri Jun 21 15:10:23 2019 +0200
Branches: functions
https://developer.blender.org/rBab51c0e7dcd3c0ce1296f559fe909b5b977ba8a4

initial particle type intermediate class

===================================================================

M	source/blender/simulations/bparticles/c_wrapper.cpp
M	source/blender/simulations/bparticles/core.cpp
M	source/blender/simulations/bparticles/core.hpp
M	source/blender/simulations/bparticles/simulate.cpp

===================================================================

diff --git a/source/blender/simulations/bparticles/c_wrapper.cpp b/source/blender/simulations/bparticles/c_wrapper.cpp
index 2b5a7f86af7..a7258526bf4 100644
--- a/source/blender/simulations/bparticles/c_wrapper.cpp
+++ b/source/blender/simulations/bparticles/c_wrapper.cpp
@@ -88,24 +88,18 @@ class ModifierStepParticleInfluences : public ParticleInfluences {
   }
 };
 
-class ModifierStepDescription : public StepDescription {
+class ModifierParticleType : public ParticleType {
  public:
-  float m_duration;
   SmallVector<Emitter *> m_emitters;
   ModifierStepParticleInfluences m_influences;
 
-  ~ModifierStepDescription()
+  ~ModifierParticleType()
   {
     for (Emitter *emitter : m_emitters) {
       delete emitter;
     }
   }
 
-  float step_duration() override
-  {
-    return m_duration;
-  }
-
   ArrayRef<Emitter *> emitters() override
   {
     return m_emitters;
@@ -117,6 +111,22 @@ class ModifierStepDescription : public StepDescription {
   }
 };
 
+class ModifierStepDescription : public StepDescription {
+ public:
+  float m_duration;
+  ModifierParticleType m_type;
+
+  float step_duration() override
+  {
+    return m_duration;
+  }
+
+  ParticleType &particle_type() override
+  {
+    return m_type;
+  }
+};
+
 void BParticles_simulate_modifier(NodeParticlesModifierData *npmd,
                                   Depsgraph *UNUSED(depsgraph),
                                   BParticlesState state_c)
@@ -127,22 +137,22 @@ void BParticles_simulate_modifier(NodeParticlesModifierData *npmd,
   ModifierStepDescription description;
   description.m_duration = 1.0f / 24.0f;
   if (npmd->emitter_object) {
-    description.m_emitters.append(EMITTER_mesh_surface((Mesh *)npmd->emitter_object->data,
-                                                       npmd->emitter_object->obmat,
-                                                       npmd->control1)
-                                      .release());
+    description.m_type.m_emitters.append(EMITTER_mesh_surface((Mesh *)npmd->emitter_object->data,
+                                                              npmd->emitter_object->obmat,
+                                                              npmd->control1)
+                                             .release());
   }
   BVHTreeFromMesh treedata = {0};
   if (npmd->collision_object) {
     BKE_bvhtree_from_mesh_get(
         &treedata, (Mesh *)npmd->collision_object->data, BVHTREE_FROM_LOOPTRI, 4);
-    description.m_influences.m_events.append(
+    description.m_type.m_influences.m_events.append(
         EVENT_mesh_collection(&treedata, npmd->collision_object->obmat).release());
-    description.m_influences.m_actions.append(ACTION_kill().release());
+    description.m_type.m_influences.m_actions.append(ACTION_kill().release());
   }
-  description.m_influences.m_forces.append(FORCE_directional({0, 0, -2}).release());
-  description.m_influences.m_events.append(EVENT_age_reached(3.0f).release());
-  description.m_influences.m_actions.append(ACTION_move({0, 1, 0}).release());
+  description.m_type.m_influences.m_forces.append(FORCE_directional({0, 0, -2}).release());
+  description.m_type.m_influences.m_events.append(EVENT_age_reached(3.0f).release());
+  description.m_type.m_influences.m_actions.append(ACTION_move({0, 1, 0}).release());
   simulate_step(state, description);
 
   if (npmd->collision_object) {
diff --git a/source/blender/simulations/bparticles/core.cpp b/source/blender/simulations/bparticles/core.cpp
index d4340ee0046..d1658691e11 100644
--- a/source/blender/simulations/bparticles/core.cpp
+++ b/source/blender/simulations/bparticles/core.cpp
@@ -22,6 +22,10 @@ ParticleInfluences::~ParticleInfluences()
 {
 }
 
+ParticleType::~ParticleType()
+{
+}
+
 StepDescription::~StepDescription()
 {
 }
diff --git a/source/blender/simulations/bparticles/core.hpp b/source/blender/simulations/bparticles/core.hpp
index d192b19cf25..187fe4bf110 100644
--- a/source/blender/simulations/bparticles/core.hpp
+++ b/source/blender/simulations/bparticles/core.hpp
@@ -183,13 +183,20 @@ class ParticleInfluences {
   virtual ArrayRef<Action *> action_per_event() = 0;
 };
 
+class ParticleType {
+ public:
+  virtual ~ParticleType();
+
+  virtual ArrayRef<Emitter *> emitters() = 0;
+  virtual ParticleInfluences &influences() = 0;
+};
+
 class StepDescription {
  public:
   virtual ~StepDescription();
 
   virtual float step_duration() = 0;
-  virtual ArrayRef<Emitter *> emitters() = 0;
-  virtual ParticleInfluences &influences() = 0;
+  virtual ParticleType &particle_type() = 0;
 };
 
 class ParticlesState {
diff --git a/source/blender/simulations/bparticles/simulate.cpp b/source/blender/simulations/bparticles/simulate.cpp
index 755507b932a..2c58dc024c9 100644
--- a/source/blender/simulations/bparticles/simulate.cpp
+++ b/source/blender/simulations/bparticles/simulate.cpp
@@ -438,11 +438,11 @@ void simulate_step(ParticlesState &state, StepDescription &description)
   state.m_current_time = time_span.end();
 
   ParticlesContainer &particles = *state.m_container;
+  ParticleType &type = description.particle_type();
 
   step_individual_particles(
-      particles.active_blocks().to_small_vector(), time_span, description.influences());
-  emit_new_particles_from_emitters(
-      particles, description.emitters(), description.influences(), time_span);
+      particles.active_blocks().to_small_vector(), time_span, type.influences());
+  emit_new_particles_from_emitters(particles, type.emitters(), type.influences(), time_span);
   delete_tagged_particles(particles.active_blocks().to_small_vector());
   compress_all_blocks(particles);
 }



More information about the Bf-blender-cvs mailing list