[Bf-blender-cvs] [a8473ead9e8] functions: new emitter for testing

Jacques Lucke noreply at git.blender.org
Sun Jun 30 16:00:28 CEST 2019


Commit: a8473ead9e886839b6d39f0a45afddfb33160488
Author: Jacques Lucke
Date:   Sun Jun 30 09:21:56 2019 +0200
Branches: functions
https://developer.blender.org/rBa8473ead9e886839b6d39f0a45afddfb33160488

new emitter for testing

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

M	source/blender/simulations/bparticles/core.hpp
M	source/blender/simulations/bparticles/emitters.cpp
M	source/blender/simulations/bparticles/emitters.hpp

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

diff --git a/source/blender/simulations/bparticles/core.hpp b/source/blender/simulations/bparticles/core.hpp
index 5f159172133..ce767a2aa65 100644
--- a/source/blender/simulations/bparticles/core.hpp
+++ b/source/blender/simulations/bparticles/core.hpp
@@ -213,6 +213,16 @@ class EmitterInterface {
   }
 
   TimeSpanEmitTarget &request(uint particle_type_id, uint size);
+
+  TimeSpan time_span()
+  {
+    return m_time_span;
+  }
+
+  bool is_first_step()
+  {
+    return m_time_span.start() < 0.00001f;
+  }
 };
 
 struct ParticleSet {
diff --git a/source/blender/simulations/bparticles/emitters.cpp b/source/blender/simulations/bparticles/emitters.cpp
index 5022dcc0a9a..c604589055d 100644
--- a/source/blender/simulations/bparticles/emitters.cpp
+++ b/source/blender/simulations/bparticles/emitters.cpp
@@ -109,6 +109,24 @@ class PathEmitter : public Emitter {
   }
 };
 
+class EmitAtStartEmitter : public Emitter {
+  void emit(EmitterInterface &interface) override
+  {
+    if (!interface.is_first_step()) {
+      return;
+    }
+
+    SmallVector<float3> positions;
+    for (uint i = 0; i < 10000; i++) {
+      positions.append(float3(i / 1000.0f, 0, 0));
+    }
+
+    auto &target = interface.request(0, positions.size());
+    target.set_float3("Position", positions);
+    target.set_birth_moment(0.0f);
+  }
+};
+
 Emitter *EMITTER_point(float3 point)
 {
   return new PointEmitter(point);
@@ -128,4 +146,9 @@ Emitter *EMITTER_path(Path *path, float4x4 transform)
   return new PathEmitter(*path, transform);
 }
 
+Emitter *EMITTER_emit_at_start()
+{
+  return new EmitAtStartEmitter();
+}
+
 }  // namespace BParticles
diff --git a/source/blender/simulations/bparticles/emitters.hpp b/source/blender/simulations/bparticles/emitters.hpp
index 19c0692f8ba..7a77daac899 100644
--- a/source/blender/simulations/bparticles/emitters.hpp
+++ b/source/blender/simulations/bparticles/emitters.hpp
@@ -13,5 +13,6 @@ Emitter *EMITTER_mesh_surface(uint particle_type_id,
                               const float4x4 &transform,
                               float normal_velocity);
 Emitter *EMITTER_path(struct Path *path, float4x4 transform);
+Emitter *EMITTER_emit_at_start();
 
 }  // namespace BParticles



More information about the Bf-blender-cvs mailing list