[Bf-blender-cvs] [10c81747feb] functions: splitup remainings of core.hpp

Jacques Lucke noreply at git.blender.org
Thu Jul 18 18:19:57 CEST 2019


Commit: 10c81747febf5106dd803d3b93a655d952ac58b8
Author: Jacques Lucke
Date:   Thu Jul 18 17:16:40 2019 +0200
Branches: functions
https://developer.blender.org/rB10c81747febf5106dd803d3b93a655d952ac58b8

splitup remainings of core.hpp

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

M	source/blender/simulations/CMakeLists.txt
M	source/blender/simulations/bparticles/action_interface.hpp
M	source/blender/simulations/bparticles/c_wrapper.cpp
M	source/blender/simulations/bparticles/emitters.hpp
M	source/blender/simulations/bparticles/events.hpp
M	source/blender/simulations/bparticles/forces.hpp
M	source/blender/simulations/bparticles/inserters.cpp
M	source/blender/simulations/bparticles/integrator.hpp
M	source/blender/simulations/bparticles/simulate.hpp
A	source/blender/simulations/bparticles/step_description.cpp
M	source/blender/simulations/bparticles/step_description.hpp
R070	source/blender/simulations/bparticles/core.cpp	source/blender/simulations/bparticles/step_description_interfaces.cpp
R066	source/blender/simulations/bparticles/core.hpp	source/blender/simulations/bparticles/step_description_interfaces.hpp

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

diff --git a/source/blender/simulations/CMakeLists.txt b/source/blender/simulations/CMakeLists.txt
index 76ce0a44c0b..cae36d8c2f6 100644
--- a/source/blender/simulations/CMakeLists.txt
+++ b/source/blender/simulations/CMakeLists.txt
@@ -16,8 +16,6 @@ set(INC_SYS
 set(SRC
   BParticles.h
 
-  bparticles/core.hpp
-  bparticles/core.cpp
   bparticles/particles_container.hpp
   bparticles/particles_container.cpp
   bparticles/simulate.hpp
@@ -36,6 +34,9 @@ set(SRC
   bparticles/attributes.cpp
   bparticles/c_wrapper.cpp
   bparticles/step_description.hpp
+  bparticles/step_description.cpp
+  bparticles/step_description_interfaces.hpp
+  bparticles/step_description_interfaces.cpp
   bparticles/world_state.hpp
   bparticles/integrator.hpp
   bparticles/integrator.cpp
diff --git a/source/blender/simulations/bparticles/action_interface.hpp b/source/blender/simulations/bparticles/action_interface.hpp
index 4f425365d71..d6c98b8af0d 100644
--- a/source/blender/simulations/bparticles/action_interface.hpp
+++ b/source/blender/simulations/bparticles/action_interface.hpp
@@ -2,7 +2,7 @@
 
 #include "FN_tuple_call.hpp"
 
-#include "core.hpp"
+#include "step_description.hpp"
 
 namespace BParticles {
 
diff --git a/source/blender/simulations/bparticles/c_wrapper.cpp b/source/blender/simulations/bparticles/c_wrapper.cpp
index f624db181ed..4dcb603e654 100644
--- a/source/blender/simulations/bparticles/c_wrapper.cpp
+++ b/source/blender/simulations/bparticles/c_wrapper.cpp
@@ -1,5 +1,5 @@
 #include "BParticles.h"
-#include "core.hpp"
+#include "step_description.hpp"
 #include "simulate.hpp"
 #include "world_state.hpp"
 #include "node_frontend.hpp"
diff --git a/source/blender/simulations/bparticles/emitters.hpp b/source/blender/simulations/bparticles/emitters.hpp
index 789a4d0277e..5d86f536dc5 100644
--- a/source/blender/simulations/bparticles/emitters.hpp
+++ b/source/blender/simulations/bparticles/emitters.hpp
@@ -2,7 +2,7 @@
 
 #include "FN_tuple_call.hpp"
 
-#include "core.hpp"
+#include "step_description.hpp"
 #include "world_state.hpp"
 #include "action_interface.hpp"
 
diff --git a/source/blender/simulations/bparticles/events.hpp b/source/blender/simulations/bparticles/events.hpp
index e125dedd4f2..473c6ac4178 100644
--- a/source/blender/simulations/bparticles/events.hpp
+++ b/source/blender/simulations/bparticles/events.hpp
@@ -1,6 +1,6 @@
 #pragma once
 
-#include "core.hpp"
+#include "step_description.hpp"
 #include "actions.hpp"
 
 #include "BKE_bvhutils.h"
diff --git a/source/blender/simulations/bparticles/forces.hpp b/source/blender/simulations/bparticles/forces.hpp
index 119a7fb7fcb..6ad7cbbbe2a 100644
--- a/source/blender/simulations/bparticles/forces.hpp
+++ b/source/blender/simulations/bparticles/forces.hpp
@@ -1,6 +1,6 @@
 #pragma once
 
-#include "core.hpp"
+#include "step_description.hpp"
 #include "actions.hpp"
 
 namespace BParticles {
diff --git a/source/blender/simulations/bparticles/inserters.cpp b/source/blender/simulations/bparticles/inserters.cpp
index 2c6f8645d03..239e6d86741 100644
--- a/source/blender/simulations/bparticles/inserters.cpp
+++ b/source/blender/simulations/bparticles/inserters.cpp
@@ -8,7 +8,7 @@
 #include "BLI_lazy_init.hpp"
 
 #include "inserters.hpp"
-#include "core.hpp"
+#include "step_description.hpp"
 #include "actions.hpp"
 #include "emitters.hpp"
 #include "events.hpp"
diff --git a/source/blender/simulations/bparticles/integrator.hpp b/source/blender/simulations/bparticles/integrator.hpp
index d45d39cc566..c3a21b3c91c 100644
--- a/source/blender/simulations/bparticles/integrator.hpp
+++ b/source/blender/simulations/bparticles/integrator.hpp
@@ -1,7 +1,7 @@
 #pragma once
 
 #include "forces.hpp"
-#include "core.hpp"
+#include "step_description.hpp"
 
 namespace BParticles {
 
diff --git a/source/blender/simulations/bparticles/simulate.hpp b/source/blender/simulations/bparticles/simulate.hpp
index c74b0baf62f..7d95e44c6d5 100644
--- a/source/blender/simulations/bparticles/simulate.hpp
+++ b/source/blender/simulations/bparticles/simulate.hpp
@@ -1,6 +1,6 @@
 #pragma once
 
-#include "core.hpp"
+#include "step_description.hpp"
 
 namespace BParticles {
 void simulate_step(ParticlesState &state, StepDescription &description);
diff --git a/source/blender/simulations/bparticles/step_description.cpp b/source/blender/simulations/bparticles/step_description.cpp
new file mode 100644
index 00000000000..d22d168f12f
--- /dev/null
+++ b/source/blender/simulations/bparticles/step_description.cpp
@@ -0,0 +1,47 @@
+#include "step_description.hpp"
+
+namespace BParticles {
+
+Emitter::~Emitter()
+{
+}
+
+Integrator::~Integrator()
+{
+}
+
+Event::~Event()
+{
+}
+
+void Event::attributes(AttributesDeclaration &UNUSED(interface))
+{
+}
+
+OffsetHandler::~OffsetHandler()
+{
+}
+
+ParticleType::~ParticleType()
+{
+  delete m_integrator;
+
+  for (Event *event : m_events) {
+    delete event;
+  }
+  for (OffsetHandler *handler : m_offset_handlers) {
+    delete handler;
+  }
+}
+
+StepDescription::~StepDescription()
+{
+  for (auto *type : m_types.values()) {
+    delete type;
+  }
+  for (Emitter *emitter : m_emitters) {
+    delete emitter;
+  }
+}
+
+}  // namespace BParticles
diff --git a/source/blender/simulations/bparticles/step_description.hpp b/source/blender/simulations/bparticles/step_description.hpp
index 1b973c971b7..66305feb2bc 100644
--- a/source/blender/simulations/bparticles/step_description.hpp
+++ b/source/blender/simulations/bparticles/step_description.hpp
@@ -1,9 +1,181 @@
 #pragma once
 
-#include "core.hpp"
+#include "step_description_interfaces.hpp"
 
 namespace BParticles {
 
+/**
+ * An event consists of two parts.
+ *   1. Filter the particles that trigger the event within a specific time span.
+ *   2. Modify the particles that were triggered.
+ *
+ * In some cases it is necessary to pass data from the filter to the execute function (e.g. the
+ * normal of the surface at a collision point). So that is supported as well. Currently, only
+ * POD (plain-old-data / simple C structs) can be used.
+ */
+class Event {
+ public:
+  virtual ~Event();
+
+  /**
+   * Return how many bytes this event wants to pass between the filter and execute function.
+   */
+  virtual uint storage_size()
+  {
+    return 0;
+  }
+
+  /**
+   * Gets a set of particles and checks which of those trigger the event.
+   */
+  virtual void filter(EventFilterInterface &interface) = 0;
+
+  /**
+   * Gets a set of particles that trigger this event and can do the following operations:
+   *   - Change any attribute of the particles.
+   *   - Change the remaining integrated attribute offsets of the particles.
+   *   - Kill the particles.
+   *   - Spawn new particles of any type.
+   *
+   * Currently, it is not supported to change the attributes of other particles, that exist
+   * already. However, the attributes of new particles can be changed.
+   */
+  virtual void execute(EventExecuteInterface &interface) = 0;
+
+  /**
+   * Allows to define which attributes are required by the event.
+   */
+  virtual void attributes(AttributesDeclaration &interface);
+};
+
+/**
+ * An emitter creates new particles of possibly different types within a certain time span.
+ */
+class Emitter {
+ public:
+  virtual ~Emitter();
+
+  /**
+   * Create new particles within a time span.
+   *
+   * In general it works like so:
+   *   1. Prepare vectors with attribute values for e.g. position and velocity of the new
+   *      particles.
+   *   2. Request an emit target that can contain a given amount of particles of a specific type.
+   *   3. Copy the prepared attribute arrays into the target. Other attributes are initialized with
+   *      some default value.
+   *   4. Specify the exact birth times of every particle within the time span. This will allow the
+   *      framework to simulate the new particles for partial time steps to avoid stepping.
+   *
+   * To create particles of different types, multiple emit targets have to be requested.
+   */
+  virtual void emit(EmitterInterface &interface) = 0;
+};
+
+/**
+ * The integrator is the core of the particle system. It's main task is to determine how the
+ * simulation would go if there were no events.
+ */
+class Integrator {
+ public:
+  virtual ~Integrator();
+
+  /**
+   * Specify which attributes are integrated (usually Position and Velocity).
+   */
+  virtual AttributesInfo &offset_attributes_info() = 0;
+
+  /**
+   * Compute the offsets for all integrated attributes. Those are not applied immediately, because
+   * there might be events that modify the attributes within a time step.
+   */
+  virtual void integrate(IntegratorInterface &interface) = 0;
+};
+
+class OffsetHandler {
+ public:
+  virtual ~OffsetHandler();
+
+  virtual void execute(OffsetHandlerInterface &interface) = 0;
+};
+
+/**
+ * Describes how one type of particle behaves and which attributes it has.
+ */
+class ParticleType {
+ private:
+  AttributesDeclaration m_attributes;
+  Integrator *m_integrator;
+  SmallVector<Event *> m_events;
+  SmallVector<OffsetHandler *> m_offset_handlers;
+
+ public:
+  ParticleType(AttributesDeclaration &attributes,
+               Integrator *integrator,
+               ArrayRef<Event *> events,
+               ArrayRef<OffsetHandler *> offset_handlers)
+      : m_attributes(attributes),
+        m_integrator(integrator),
+        m_events(events),
+        m_offset_handlers(offset_handlers)
+  {
+  }
+
+  ~ParticleType();
+
+  Integrator &integrator()
+  {
+    return *m_integrator;
+  }
+
+  ArrayRef<OffsetHandler *> offset_handlers()
+  {
+    return m_offset_handlers;
+  }
+
+  ArrayRef<Event *> events()
+  {
+    return m_events;
+  }
+
+  AttributesDeclaration &attributes()
+  {
+    return m_attributes;
+  }
+};
+
+/**
+ * Describes how the current state of a particle system transitions to the next state.
+ */
+class StepDescription {
+  float m_duration;
+  StringMap<ParticleType *> m_types;
+  SmallVector<Emitter *> m_emitters;
+
+ public:
+  StepDescription(float duration, StringMap<ParticleType *> types, ArrayRef<Emitter *> emitters)
+      : m_duration(duration), m_types(types), m_emitters(emitters)
+  {
+  }
+
+  ~StepDescription();
+
+  float step_duration()
+  {
+    return m_

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list