[Bf-blender-cvs] [d3013152ce5] functions: little bit more interesting particle movement

Jacques Lucke noreply at git.blender.org
Fri Jun 7 12:34:39 CEST 2019


Commit: d3013152ce5425ad1f9cfae3cd5015f339b36946
Author: Jacques Lucke
Date:   Fri Jun 7 12:24:28 2019 +0200
Branches: functions
https://developer.blender.org/rBd3013152ce5425ad1f9cfae3cd5015f339b36946

little bit more interesting particle movement

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

M	source/blender/simulations/bparticles/playground_solver.cpp

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

diff --git a/source/blender/simulations/bparticles/playground_solver.cpp b/source/blender/simulations/bparticles/playground_solver.cpp
index 1ed0d92deb6..9b2e5d70b46 100644
--- a/source/blender/simulations/bparticles/playground_solver.cpp
+++ b/source/blender/simulations/bparticles/playground_solver.cpp
@@ -14,6 +14,7 @@ class SimpleSolver : public Solver {
 
   struct MyState : StateBase {
     SmallVector<Vector> positions;
+    SmallVector<Vector> velocities;
   };
 
  public:
@@ -30,10 +31,21 @@ class SimpleSolver : public Solver {
   void step(WrappedState &wrapped_state) override
   {
     MyState &state = wrapped_state.state<MyState>();
-    for (Vector &position : state.positions) {
-      position.x += 0.1f;
+
+    for (uint i = 0; i < state.positions.size(); i++) {
+      Vector &position = state.positions[i];
+      Vector &velocity = state.velocities[i];
+      position.x += velocity.x;
+      position.y += velocity.y;
+      position.z += velocity.z;
+    }
+
+    for (Vector &velocity : state.velocities) {
+      velocity.z -= 0.001f;
     }
-    state.positions.append({0, 0, 1});
+
+    state.positions.append({(float)(rand() % 100) / 100.0f, 0, 1});
+    state.velocities.append({0, 0.1, 0});
   }
 
   uint particle_amount(WrappedState &wrapped_state) override



More information about the Bf-blender-cvs mailing list