[Bf-blender-cvs] [9fecdb3a45b] functions: use reference to indicate that action cannot be null

Jacques Lucke noreply at git.blender.org
Tue Sep 17 14:09:11 CEST 2019


Commit: 9fecdb3a45bbe03967d19d485e458729fd5c06f9
Author: Jacques Lucke
Date:   Tue Sep 17 12:43:59 2019 +0200
Branches: functions
https://developer.blender.org/rB9fecdb3a45bbe03967d19d485e458729fd5c06f9

use reference to indicate that action cannot be null

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

M	source/blender/simulations/bparticles/actions.cpp
M	source/blender/simulations/bparticles/actions.hpp
M	source/blender/simulations/bparticles/emitters.cpp
M	source/blender/simulations/bparticles/emitters.hpp
M	source/blender/simulations/bparticles/events.cpp
M	source/blender/simulations/bparticles/events.hpp
M	source/blender/simulations/bparticles/node_frontend.cpp
M	source/blender/simulations/bparticles/offset_handlers.cpp
M	source/blender/simulations/bparticles/offset_handlers.hpp

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

diff --git a/source/blender/simulations/bparticles/actions.cpp b/source/blender/simulations/bparticles/actions.cpp
index 72b04c978a5..35cf68a1a6a 100644
--- a/source/blender/simulations/bparticles/actions.cpp
+++ b/source/blender/simulations/bparticles/actions.cpp
@@ -155,7 +155,7 @@ void ExplodeAction::execute(ActionInterface &interface)
 
     SourceParticleActionContext source_context(source_particles, &interface.context());
 
-    m_on_birth_action->execute_for_new_particles(new_particles, interface, &source_context);
+    m_on_birth_action.execute_for_new_particles(new_particles, interface, &source_context);
   }
 }
 
@@ -173,8 +173,8 @@ void ConditionAction::execute(ActionInterface &interface)
     }
   }
 
-  m_true_action->execute_for_subset(true_pindices, interface);
-  m_false_action->execute_for_subset(false_pindices, interface);
+  m_true_action.execute_for_subset(true_pindices, interface);
+  m_false_action.execute_for_subset(false_pindices, interface);
 }
 
 }  // namespace BParticles
diff --git a/source/blender/simulations/bparticles/actions.hpp b/source/blender/simulations/bparticles/actions.hpp
index 31f77aa8fcc..53afbd00b62 100644
--- a/source/blender/simulations/bparticles/actions.hpp
+++ b/source/blender/simulations/bparticles/actions.hpp
@@ -89,12 +89,12 @@ class ExplodeAction : public Action {
  private:
   ArrayRef<std::string> m_systems_to_emit;
   ParticleFunction *m_inputs_fn;
-  Action *m_on_birth_action;
+  Action &m_on_birth_action;
 
  public:
   ExplodeAction(ArrayRef<std::string> systems_to_emit,
                 ParticleFunction *inputs_fn,
-                Action *on_birth_action)
+                Action &on_birth_action)
       : m_systems_to_emit(systems_to_emit),
         m_inputs_fn(inputs_fn),
         m_on_birth_action(on_birth_action)
@@ -107,11 +107,11 @@ class ExplodeAction : public Action {
 class ConditionAction : public Action {
  private:
   ParticleFunction *m_inputs_fn;
-  Action *m_true_action;
-  Action *m_false_action;
+  Action &m_true_action;
+  Action &m_false_action;
 
  public:
-  ConditionAction(ParticleFunction *inputs_fn, Action *true_action, Action *false_action)
+  ConditionAction(ParticleFunction *inputs_fn, Action &true_action, Action &false_action)
       : m_inputs_fn(inputs_fn), m_true_action(true_action), m_false_action(false_action)
   {
   }
diff --git a/source/blender/simulations/bparticles/emitters.cpp b/source/blender/simulations/bparticles/emitters.cpp
index e1acc998770..5efa16fbd51 100644
--- a/source/blender/simulations/bparticles/emitters.cpp
+++ b/source/blender/simulations/bparticles/emitters.cpp
@@ -49,7 +49,7 @@ void PointEmitter::emit(EmitterInterface &interface)
     new_particles.set<float>("Size", new_sizes);
     new_particles.set<float>("Birth Time", birth_times);
 
-    m_action->execute_from_emitter(new_particles, interface);
+    m_action.execute_from_emitter(new_particles, interface);
   }
 }
 
@@ -302,7 +302,7 @@ void SurfaceEmitter::emit(EmitterInterface &interface)
     new_particles.set<float3>("Position", positions_at_birth);
     new_particles.set<float>("Birth Time", birth_times);
 
-    m_on_birth_action->execute_from_emitter<MeshSurfaceContext>(
+    m_on_birth_action.execute_from_emitter<MeshSurfaceContext>(
         new_particles, interface, [&](IndexRange range, void *dst) {
           new (dst) MeshSurfaceContext(m_object,
                                        transforms_at_birth.as_ref().slice(range),
@@ -338,7 +338,7 @@ void InitialGridEmitter::emit(EmitterInterface &interface)
     new_particles.fill<float>("Birth Time", interface.time_span().start());
     new_particles.fill<float>("Size", m_size);
 
-    m_action->execute_from_emitter(new_particles, interface);
+    m_action.execute_from_emitter(new_particles, interface);
   }
 }
 
diff --git a/source/blender/simulations/bparticles/emitters.hpp b/source/blender/simulations/bparticles/emitters.hpp
index dd56939f82e..f10e48e1082 100644
--- a/source/blender/simulations/bparticles/emitters.hpp
+++ b/source/blender/simulations/bparticles/emitters.hpp
@@ -14,7 +14,7 @@ using FN::TupleCallBody;
 class SurfaceEmitter : public Emitter {
  private:
   ArrayRef<std::string> m_systems_to_emit;
-  Action *m_on_birth_action;
+  Action &m_on_birth_action;
 
   Object *m_object;
   VaryingFloat4x4 m_transform;
@@ -24,7 +24,7 @@ class SurfaceEmitter : public Emitter {
 
  public:
   SurfaceEmitter(ArrayRef<std::string> systems_to_emit,
-                 Action *on_birth_action,
+                 Action &on_birth_action,
                  Object *object,
                  VaryingFloat4x4 transform,
                  float rate,
@@ -47,14 +47,14 @@ class PointEmitter : public Emitter {
   VaryingFloat3 m_position;
   VaryingFloat3 m_velocity;
   VaryingFloat m_size;
-  Action *m_action;
+  Action &m_action;
 
  public:
   PointEmitter(ArrayRef<std::string> systems_to_emit,
                VaryingFloat3 position,
                VaryingFloat3 velocity,
                VaryingFloat size,
-               Action *action)
+               Action &action)
       : m_systems_to_emit(systems_to_emit),
         m_position(position),
         m_velocity(velocity),
@@ -74,7 +74,7 @@ class InitialGridEmitter : public Emitter {
   float m_step_x;
   float m_step_y;
   float m_size;
-  Action *m_action;
+  Action &m_action;
 
  public:
   InitialGridEmitter(ArrayRef<std::string> systems_to_emit,
@@ -83,7 +83,7 @@ class InitialGridEmitter : public Emitter {
                      float step_x,
                      float step_y,
                      float size,
-                     Action *action)
+                     Action &action)
       : m_systems_to_emit(systems_to_emit),
         m_amount_x(amount_x),
         m_amount_y(amount_y),
diff --git a/source/blender/simulations/bparticles/events.cpp b/source/blender/simulations/bparticles/events.cpp
index 116e5e8d380..5c3d8fc055f 100644
--- a/source/blender/simulations/bparticles/events.cpp
+++ b/source/blender/simulations/bparticles/events.cpp
@@ -66,7 +66,7 @@ void AgeReachedEvent::execute(EventExecuteInterface &interface)
     was_activated_before[pindex] = true;
   }
 
-  m_action->execute_from_event(interface);
+  m_action.execute_from_event(interface);
 }
 
 /* Custom Event
@@ -112,7 +112,7 @@ void CustomEvent::execute(EventExecuteInterface &interface)
     was_activated_before[pindex] = true;
   }
 
-  m_action->execute_from_event(interface);
+  m_action.execute_from_event(interface);
 }
 
 /* Collision Event
@@ -200,7 +200,7 @@ void MeshCollisionEvent::execute(EventExecuteInterface &interface)
                                      local_normals,
                                      looptri_indices);
 
-  m_action->execute_from_event(interface, &surface_context);
+  m_action.execute_from_event(interface, &surface_context);
 }
 
 }  // namespace BParticles
diff --git a/source/blender/simulations/bparticles/events.hpp b/source/blender/simulations/bparticles/events.hpp
index 6bb93026d09..f576b008a29 100644
--- a/source/blender/simulations/bparticles/events.hpp
+++ b/source/blender/simulations/bparticles/events.hpp
@@ -20,10 +20,10 @@ class AgeReachedEvent : public Event {
  private:
   std::string m_identifier;
   ParticleFunction *m_inputs_fn;
-  Action *m_action;
+  Action &m_action;
 
  public:
-  AgeReachedEvent(StringRef identifier, ParticleFunction *inputs_fn, Action *action)
+  AgeReachedEvent(StringRef identifier, ParticleFunction *inputs_fn, Action &action)
       : m_identifier(identifier), m_inputs_fn(inputs_fn), m_action(action)
   {
   }
@@ -37,10 +37,10 @@ class CustomEvent : public Event {
  private:
   std::string m_identifier;
   ParticleFunction *m_inputs_fn;
-  Action *m_action;
+  Action &m_action;
 
  public:
-  CustomEvent(StringRef identifier, ParticleFunction *inputs_fn, Action *action)
+  CustomEvent(StringRef identifier, ParticleFunction *inputs_fn, Action &action)
       : m_identifier(identifier), m_inputs_fn(inputs_fn), m_action(action)
   {
   }
@@ -57,7 +57,7 @@ class MeshCollisionEvent : public Event {
   BVHTreeFromMesh m_bvhtree_data;
   float4x4 m_local_to_world;
   float4x4 m_world_to_local;
-  Action *m_action;
+  Action &m_action;
 
   struct RayCastResult {
     bool success;
@@ -73,7 +73,7 @@ class MeshCollisionEvent : public Event {
   };
 
  public:
-  MeshCollisionEvent(StringRef identifier, Object *object, Action *action)
+  MeshCollisionEvent(StringRef identifier, Object *object, Action &action)
       : m_identifier(identifier), m_object(object), m_action(action)
   {
     BLI_assert(object->type == OB_MESH);
diff --git a/source/blender/simulations/bparticles/node_frontend.cpp b/source/blender/simulations/bparticles/node_frontend.cpp
index 89e3fe7b7ad..f5be1e5db52 100644
--- a/source/blender/simulations/bparticles/node_frontend.cpp
+++ b/source/blender/simulations/bparticles/node_frontend.cpp
@@ -156,7 +156,7 @@ class VTreeData {
     return action_ptr;
   }
 
-  Action *build_action_list(VirtualNode *start_vnode, StringRef name)
+  Action &build_action_list(VirtualNode *start_vnode, StringRef name)
   {
     Vector<VirtualSocket *> execute_sockets = this->find_execute_sockets(start_vnode, name);
     Vector<Action *> actions;
@@ -168,7 +168,7 @@ class VTreeData {
     }
     Action *sequence = new ActionSequence(std::move(actions));
     m_actions.append(std::unique_ptr<Action>(sequence));
-    return sequence;
+    return *sequence;
   }
 
  private:
@@ -275,7 +275,7 @@ static std::unique_ptr<Action> ACTION_explode(VTreeData &vtree_data,
     return {};
   }
 
-  Action *on_birth_action = vtree_data.build_action_list(vnode, "Execute on Birth");
+  Action &on_birth_action = vtree_data.build_action_list(vnode, "Execute on Birth");
   ArrayRef<std::string> system_names = vtree_data.find_target_system_names(
       vnode->output(1, "Explode System"));
 
@@ -293,8 +293,8 @@ static std::unique_ptr<Action> ACTION_condition(VTreeData &vtree_data,
     return {};
   }
 
-  Action *action_true = vtree_data.build_action_list(vnode, "Execute If True");
-  Action *action_false = vtree_data.build_action_list(vnode, "Execute If False");
+  Action &action_true = vtree_data.build_action_list(vnode, "Execute If True");
+  Action &act

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list