Commit: c74934cbf92b777c396f704a03508a8c7da21938
Author: Jacques Lucke
Date:   Thu Jun 20 10:17:09 2019 +0200
Branches: functions
https://developer.blender.org/rBc74934cbf92b777c396f704a03508a8c7da21938

remove abstractions that are wrong for now

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

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/emitters.cpp
M       source/blender/simulations/bparticles/playground_solver.cpp

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

diff --git a/source/blender/simulations/bparticles/c_wrapper.cpp 
b/source/blender/simulations/bparticles/c_wrapper.cpp
index 1df8dd8c89b..238961a7c18 100644
--- a/source/blender/simulations/bparticles/c_wrapper.cpp
+++ b/source/blender/simulations/bparticles/c_wrapper.cpp
@@ -28,7 +28,6 @@ using BParticles::AttributeType;
 using BParticles::Description;
 using BParticles::Emitter;
 using BParticles::EmitterHelper;
-using BParticles::EmitterInfoBuilder;
 using BParticles::EmitterTarget;
 using BParticles::ParticlesBlock;
 using BParticles::Solver;
diff --git a/source/blender/simulations/bparticles/core.cpp 
b/source/blender/simulations/bparticles/core.cpp
index 9acd6cae267..a70a809a241 100644
--- a/source/blender/simulations/bparticles/core.cpp
+++ b/source/blender/simulations/bparticles/core.cpp
@@ -32,7 +32,7 @@ Action::~Action()
 {
 }
 
-PositionalEvent::~PositionalEvent()
+Event::~Event()
 {
 }
 
diff --git a/source/blender/simulations/bparticles/core.hpp 
b/source/blender/simulations/bparticles/core.hpp
index 4786f4947bf..87d37b1f9aa 100644
--- a/source/blender/simulations/bparticles/core.hpp
+++ b/source/blender/simulations/bparticles/core.hpp
@@ -18,8 +18,6 @@ class Solver;
 class WrappedState;
 class StateBase;
 class Emitter;
-class EmitterInfo;
-class EmitterInfoBuilder;
 
 using BLI::ArrayRef;
 using BLI::float3;
@@ -37,16 +35,9 @@ class Force {
                          ArrayRef<float3> dst) = 0;
 };
 
-class Action {
- public:
-  virtual ~Action();
-
-  virtual void execute(AttributeArrays attributes, ArrayRef<uint> 
indices_mask) = 0;
-};
-
-class PositionalEvent {
+class Event {
  public:
-  virtual ~PositionalEvent();
+  virtual ~Event();
 
   virtual void filter(AttributeArrays attributes,
                       ArrayRef<uint> indices_mask,
@@ -55,94 +46,11 @@ class PositionalEvent {
                       SmallVector<float> &r_time_factors) = 0;
 };
 
-class EmitterInfo {
- private:
-  EmitterInfo()
-  {
-  }
-
-  Emitter *m_emitter;
-  SmallSetVector<std::string> m_used_float_attributes;
-  SmallSetVector<std::string> m_used_float3_attributes;
-  SmallSetVector<std::string> m_used_byte_attributes;
-
-  friend EmitterInfoBuilder;
-
- public:
-  Emitter &emitter()
-  {
-    return *m_emitter;
-  }
-
-  ArrayRef<std::string> used_float_attributes()
-  {
-    return m_used_float_attributes.values();
-  }
-
-  ArrayRef<std::string> used_float3_attributes()
-  {
-    return m_used_float3_attributes.values();
-  }
-
-  ArrayRef<std::string> used_byte_attributes()
-  {
-    return m_used_byte_attributes.values();
-  }
-
-  bool uses_float_attribute(StringRef name)
-  {
-    return m_used_float_attributes.contains(name.to_std_string());
-  }
-
-  bool uses_float3_attribute(StringRef name)
-  {
-    return m_used_float3_attributes.contains(name.to_std_string());
-  }
-
-  bool uses_byte_attribute(StringRef name)
-  {
-    return m_used_byte_attributes.contains(name.to_std_string());
-  }
-};
-
-class EmitterInfoBuilder {
- private:
-  Emitter *m_emitter;
-  SmallSetVector<std::string> m_used_byte_attributes;
-  SmallSetVector<std::string> m_used_float_attributes;
-  SmallSetVector<std::string> m_used_float3_attributes;
-
+class Action {
  public:
-  EmitterInfoBuilder(Emitter *emitter) : m_emitter(emitter)
-  {
-  }
-
-  void inits_attribute(StringRef name, AttributeType type)
-  {
-    switch (type) {
-      case AttributeType::Byte:
-        m_used_byte_attributes.add(name.to_std_string());
-        break;
-      case AttributeType::Float:
-        m_used_float_attributes.add(name.to_std_string());
-        break;
-      case AttributeType::Float3:
-        m_used_float3_attributes.add(name.to_std_string());
-        break;
-      default:
-        BLI_assert(false);
-    }
-  }
+  virtual ~Action();
 
-  EmitterInfo build()
-  {
-    EmitterInfo info;
-    info.m_emitter = m_emitter;
-    info.m_used_byte_attributes = m_used_byte_attributes;
-    info.m_used_float_attributes = m_used_float_attributes;
-    info.m_used_float3_attributes = m_used_float3_attributes;
-    return info;
-  }
+  virtual void execute(AttributeArrays attributes, ArrayRef<uint> 
indices_mask) = 0;
 };
 
 class EmitterTarget {
@@ -219,7 +127,6 @@ class Emitter {
  public:
   virtual ~Emitter();
 
-  virtual void info(EmitterInfoBuilder &info) const = 0;
   virtual void emit(EmitterHelper helper) = 0;
 };
 
diff --git a/source/blender/simulations/bparticles/emitters.cpp 
b/source/blender/simulations/bparticles/emitters.cpp
index 1c64f6f90a6..94a6beb1469 100644
--- a/source/blender/simulations/bparticles/emitters.cpp
+++ b/source/blender/simulations/bparticles/emitters.cpp
@@ -20,12 +20,6 @@ class PointEmitter : public Emitter {
   {
   }
 
-  void info(EmitterInfoBuilder &builder) const override
-  {
-    builder.inits_attribute("Position", AttributeType::Float3);
-    builder.inits_attribute("Velocity", AttributeType::Float3);
-  }
-
   void emit(EmitterHelper helper) override
   {
     auto &target = helper.request_raw();
@@ -49,12 +43,6 @@ class SurfaceEmitter : public Emitter {
   {
   }
 
-  void info(EmitterInfoBuilder &builder) const override
-  {
-    builder.inits_attribute("Position", AttributeType::Float3);
-    builder.inits_attribute("Velocity", AttributeType::Float3);
-  }
-
   void emit(EmitterHelper helper) override
   {
     MLoop *loops = m_mesh->mloop;
@@ -96,12 +84,6 @@ class PathEmitter : public Emitter {
   {
   }
 
-  void info(EmitterInfoBuilder &builder) const override
-  {
-    builder.inits_attribute("Position", AttributeType::Float3);
-    builder.inits_attribute("Velocity", AttributeType::Float3);
-  }
-
   void emit(EmitterHelper helper) override
   {
     SmallVector<float3> positions;
@@ -109,7 +91,7 @@ class PathEmitter : public Emitter {
       float3 pos1 = m_path.data[i].vec;
       float3 pos2 = m_path.data[i + 1].vec;
 
-      for (uint j = 0; j < 100; j++) {
+      for (uint j = 0; j < 10; j++) {
         float factor = (float)j / 100.0f;
         float3 pos = pos1 * (1.0f - factor) + pos2 * factor;
         pos = m_transform.transform_position(pos);
diff --git a/source/blender/simulations/bparticles/playground_solver.cpp 
b/source/blender/simulations/bparticles/playground_solver.cpp
index eb1ecb7683a..7c341b1963d 100644
--- a/source/blender/simulations/bparticles/playground_solver.cpp
+++ b/source/blender/simulations/bparticles/playground_solver.cpp
@@ -25,7 +25,7 @@ class MoveAction : public BParticles::Action {
   }
 };
 
-class HitPlaneEvent : public PositionalEvent {
+class HitPlaneEvent : public Event {
  private:
   float m_value;
 
@@ -69,10 +69,9 @@ class SimpleSolver : public Solver {
   static const uint m_block_size = 1000;
   Description &m_description;
   AttributesInfo m_attributes;
-  SmallVector<EmitterInfo> m_emitter_infos;
 
   struct EventWithAction {
-    PositionalEvent *event;
+    Event *event;
     Action *action;
   };
 
@@ -81,21 +80,9 @@ class SimpleSolver : public Solver {
  public:
   SimpleSolver(Description &description) : m_description(description)
   {
-    for (Emitter *emitter : m_description.emitters()) {
-      EmitterInfoBuilder builder{emitter};
-      emitter->info(builder);
-      m_emitter_infos.append(builder.build());
-    }
-
     SmallSetVector<std::string> byte_attributes = {"Kill State"};
     SmallSetVector<std::string> float_attributes = {"Birth Time"};
-    SmallSetVector<std::string> float3_attributes;
-
-    for (EmitterInfo &emitter : m_emitter_infos) {
-      byte_attributes.add_multiple(emitter.used_byte_attributes());
-      float_attributes.add_multiple(emitter.used_float_attributes());
-      float3_attributes.add_multiple(emitter.used_float3_attributes());
-    }
+    SmallSetVector<std::string> float3_attributes = {"Position", "Velocity"};
 
     m_attributes = AttributesInfo(
         byte_attributes.values(), float_attributes.values(), 
float3_attributes.values());
@@ -409,12 +396,12 @@ class SimpleSolver : public Solver {
 
   BLI_NOINLINE void emit_new_particles(MyState &state, float elapsed_seconds)
   {
-    for (EmitterInfo &emitter : m_emitter_infos) {
+    for (Emitter *emitter : m_description.emitters()) {
       this->emit_from_emitter(state, emitter, elapsed_seconds);
     }
   }
 
-  void emit_from_emitter(MyState &state, EmitterInfo &emitter, float 
elapsed_seconds)
+  void emit_from_emitter(MyState &state, Emitter *emitter, float 
elapsed_seconds)
   {
     SmallVector<EmitterTarget> targets;
     SmallVector<ParticlesBlock *> blocks;
@@ -426,28 +413,14 @@ class SimpleSolver : public Solver {
       return targets.last();
     };
 
-    emitter.emitter().emit(EmitterHelper{request_target});
+    emitter->emit(EmitterHelper{request_target});
 
     for (uint i = 0; i < targets.size(); i++) {
       EmitterTarget &target = targets[i];
       ParticlesBlock *block = blocks[i];
       AttributeArrays emitted_data = 
target.attributes().take_front(target.emitted_amount());
 
-      for (uint i : m_attributes.byte_attributes()) {
-        if (!emitter.uses_byte_attribute(m_attributes.name_of(i))) {
-          emitted_data.get_byte(i).fill(0);
-        }
-      }
-      for (uint i : m_attributes.float_attributes()) {
-        if (!emitter.uses_float_attribute(m_attributes.name_of(i))) {
-          emitted_data.get_float(i).fill(0);
-        }
-      }
-      for (uint i : m_attributes.float3_attributes()) {
-        if (!emitter.uses_float3_attribute(m_attributes.name_of(i))) {
-          emitted_data.get_float3(i).fill({0, 0, 0});
-        }
-      }
+      emitted_data.get_byte("Kill State").fill(0);
 
       auto birth_times = emitted_data.get_float("Birth Time");
       for (float &birth_time : birth_times) {

_______________________________________________
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to