[Bf-blender-cvs] [8364c3aafc7] functions: move step description to separate file

Jacques Lucke noreply at git.blender.org
Tue Jul 9 18:01:15 CEST 2019


Commit: 8364c3aafc76f87b8e372391b75d67f575d6cbe1
Author: Jacques Lucke
Date:   Tue Jul 9 11:53:36 2019 +0200
Branches: functions
https://developer.blender.org/rB8364c3aafc76f87b8e372391b75d67f575d6cbe1

move step description to separate file

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

M	source/blender/simulations/CMakeLists.txt
M	source/blender/simulations/bparticles/c_wrapper.cpp
A	source/blender/simulations/bparticles/step_description.hpp

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

diff --git a/source/blender/simulations/CMakeLists.txt b/source/blender/simulations/CMakeLists.txt
index ef9e04f4ab0..dbbbfa4cff5 100644
--- a/source/blender/simulations/CMakeLists.txt
+++ b/source/blender/simulations/CMakeLists.txt
@@ -35,6 +35,8 @@ set(SRC
   bparticles/attributes.hpp
   bparticles/attributes.cpp
   bparticles/c_wrapper.cpp
+  bparticles/step_description.hpp
+  bparticles/world_state.hpp
 )
 
 set(LIB
diff --git a/source/blender/simulations/bparticles/c_wrapper.cpp b/source/blender/simulations/bparticles/c_wrapper.cpp
index 58a5b074223..3aacb7eb699 100644
--- a/source/blender/simulations/bparticles/c_wrapper.cpp
+++ b/source/blender/simulations/bparticles/c_wrapper.cpp
@@ -7,6 +7,7 @@
 #include "actions.hpp"
 #include "simulate.hpp"
 #include "world_state.hpp"
+#include "step_description.hpp"
 
 #include "BLI_timeit.hpp"
 #include "BLI_listbase.h"
@@ -144,75 +145,6 @@ class EulerIntegrator : public Integrator {
   }
 };
 
-class ModifierParticleType : public ParticleType {
- public:
-  SmallVector<Event *> m_events;
-  EulerIntegrator *m_integrator;
-
-  ~ModifierParticleType()
-  {
-    delete m_integrator;
-
-    for (Event *event : m_events) {
-      delete event;
-    }
-  }
-
-  ArrayRef<Event *> events() override
-  {
-    return m_events;
-  }
-
-  Integrator &integrator() override
-  {
-    return *m_integrator;
-  }
-
-  void attributes(TypeAttributeInterface &interface) override
-  {
-    interface.use(AttributeType::Float3, "Position");
-    interface.use(AttributeType::Float3, "Velocity");
-  }
-};
-
-class ModifierStepDescription : public StepDescription {
- public:
-  float m_duration;
-  SmallMap<std::string, ModifierParticleType *> m_types;
-  SmallVector<Emitter *> m_emitters;
-  SmallVector<std::string> m_particle_type_names;
-
-  ~ModifierStepDescription()
-  {
-    for (auto *type : m_types.values()) {
-      delete type;
-    }
-    for (Emitter *emitter : m_emitters) {
-      delete emitter;
-    }
-  }
-
-  float step_duration() override
-  {
-    return m_duration;
-  }
-
-  ArrayRef<Emitter *> emitters() override
-  {
-    return m_emitters;
-  }
-
-  ArrayRef<std::string> particle_type_names() override
-  {
-    return m_particle_type_names;
-  }
-
-  ParticleType &particle_type(StringRef type_name) override
-  {
-    return *m_types.lookup(type_name.to_std_string());
-  }
-};
-
 using EmitterInserter = std::function<void(bNode *bnode,
                                            IndexedNodeTree &indexed_tree,
                                            FN::DataFlowNodes::GeneratedGraph &data_graph,
@@ -509,7 +441,9 @@ static void INSERT_FORCE_gravity(bNode *force_node,
     Force *force = FORCE_gravity(fn);
 
     bNode *type_node = linked.node;
-    step_description.m_types.lookup_ref(type_node->name)->m_integrator->m_forces.append(force);
+    EulerIntegrator *integrator = reinterpret_cast<EulerIntegrator *>(
+        step_description.m_types.lookup_ref(type_node->name)->m_integrator);
+    integrator->m_forces.append(force);
   }
 }
 
@@ -534,7 +468,9 @@ static void INSERT_FORCE_turbulence(bNode *force_node,
     Force *force = FORCE_turbulence(fn);
 
     bNode *type_node = linked.node;
-    step_description.m_types.lookup_ref(type_node->name)->m_integrator->m_forces.append(force);
+    EulerIntegrator *integrator = reinterpret_cast<EulerIntegrator *>(
+        step_description.m_types.lookup_ref(type_node->name)->m_integrator);
+    integrator->m_forces.append(force);
   }
 }
 
diff --git a/source/blender/simulations/bparticles/step_description.hpp b/source/blender/simulations/bparticles/step_description.hpp
new file mode 100644
index 00000000000..42ec49ce1bd
--- /dev/null
+++ b/source/blender/simulations/bparticles/step_description.hpp
@@ -0,0 +1,76 @@
+#pragma once
+
+#include "core.hpp"
+
+namespace BParticles {
+
+class ModifierParticleType : public ParticleType {
+ public:
+  SmallVector<Event *> m_events;
+  Integrator *m_integrator;
+
+  ~ModifierParticleType()
+  {
+    delete m_integrator;
+
+    for (Event *event : m_events) {
+      delete event;
+    }
+  }
+
+  ArrayRef<Event *> events() override
+  {
+    return m_events;
+  }
+
+  Integrator &integrator() override
+  {
+    return *m_integrator;
+  }
+
+  void attributes(TypeAttributeInterface &interface) override
+  {
+    interface.use(AttributeType::Float3, "Position");
+    interface.use(AttributeType::Float3, "Velocity");
+  }
+};
+
+class ModifierStepDescription : public StepDescription {
+ public:
+  float m_duration;
+  SmallMap<std::string, ModifierParticleType *> m_types;
+  SmallVector<Emitter *> m_emitters;
+  SmallVector<std::string> m_particle_type_names;
+
+  ~ModifierStepDescription()
+  {
+    for (auto *type : m_types.values()) {
+      delete type;
+    }
+    for (Emitter *emitter : m_emitters) {
+      delete emitter;
+    }
+  }
+
+  float step_duration() override
+  {
+    return m_duration;
+  }
+
+  ArrayRef<Emitter *> emitters() override
+  {
+    return m_emitters;
+  }
+
+  ArrayRef<std::string> particle_type_names() override
+  {
+    return m_particle_type_names;
+  }
+
+  ParticleType &particle_type(StringRef type_name) override
+  {
+    return *m_types.lookup(type_name.to_std_string());
+  }
+};
+
+}  // namespace BParticles



More information about the Bf-blender-cvs mailing list