Commit: c5d18a0a8acea18b01fd1c1391a44f3a4c730d3f
Author: Jacques Lucke
Date:   Mon Jul 15 17:09:32 2019 +0200
Branches: functions
https://developer.blender.org/rBc5d18a0a8acea18b01fd1c1391a44f3a4c730d3f

check that indices correspond to correct outputs in debug build

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

M       source/blender/functions/backends/tuple_call/tuple_call.hpp
M       source/blender/simulations/bparticles/inserters.cpp

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

diff --git a/source/blender/functions/backends/tuple_call/tuple_call.hpp 
b/source/blender/functions/backends/tuple_call/tuple_call.hpp
index 2d347efc671..4397c644c31 100644
--- a/source/blender/functions/backends/tuple_call/tuple_call.hpp
+++ b/source/blender/functions/backends/tuple_call/tuple_call.hpp
@@ -39,6 +39,19 @@ class TupleCallBodyBase : public FunctionBody {
   {
     return m_meta_out;
   }
+
+  /**
+   * Same as tuple.get<T>(index), but checks if the name is correct in debug 
builds.
+   */
+  template<typename T> T get_output(Tuple &tuple, uint index, StringRef 
expected_name)
+  {
+#ifdef DEBUG
+    StringRef real_name = this->owner()->output_name(index);
+    BLI_assert(real_name == expected_name);
+#endif
+    UNUSED_VARS_NDEBUG(expected_name);
+    return tuple.get<T>(index);
+  }
 };
 
 class TupleCallBody : public TupleCallBodyBase {
diff --git a/source/blender/simulations/bparticles/inserters.cpp 
b/source/blender/simulations/bparticles/inserters.cpp
index 358037e0395..b5887aa472a 100644
--- a/source/blender/simulations/bparticles/inserters.cpp
+++ b/source/blender/simulations/bparticles/inserters.cpp
@@ -239,18 +239,19 @@ static std::unique_ptr<Emitter> 
BUILD_EMITTER_mesh_surface(BuildContext &ctx,
 
   auto on_birth_action = build_action(ctx, 
{bSocketList(bnode->outputs).get(0), bnode});
 
-  Object *object = fn_out.get<Object *>(0);
+  Object *object = body->get_output<Object *>(fn_out, 0, "Object");
   InterpolatedFloat4x4 transform = 
ctx.world_state.get_interpolated_value(bnode->name,
                                                                           
object->obmat);
 
-  return std::unique_ptr<SurfaceEmitter>(new SurfaceEmitter(particle_type_name,
-                                                            
std::move(on_birth_action),
-                                                            object,
-                                                            transform,
-                                                            
fn_out.get<float>(1),
-                                                            
fn_out.get<float>(2),
-                                                            
fn_out.get<float>(3),
-                                                            
fn_out.get<float>(4)));
+  return std::unique_ptr<SurfaceEmitter>(
+      new SurfaceEmitter(particle_type_name,
+                         std::move(on_birth_action),
+                         object,
+                         transform,
+                         body->get_output<float>(fn_out, 1, "Rate"),
+                         body->get_output<float>(fn_out, 2, "Normal Velocity"),
+                         body->get_output<float>(fn_out, 3, "Emitter 
Velocity"),
+                         body->get_output<float>(fn_out, 4, "Size")));
 }
 
 static std::unique_ptr<Emitter> BUILD_EMITTER_moving_point(BuildContext &ctx,
@@ -264,7 +265,8 @@ static std::unique_ptr<Emitter> 
BUILD_EMITTER_moving_point(BuildContext &ctx,
   FN_TUPLE_CALL_ALLOC_TUPLES(body, fn_in, fn_out);
   body->call__setup_execution_context(fn_in, fn_out);
 
-  auto point = ctx.world_state.get_interpolated_value(bnode->name, 
fn_out.get<float3>(0));
+  auto point = ctx.world_state.get_interpolated_value(
+      bnode->name, body->get_output<float3>(fn_out, 0, "Position"));
   return std::unique_ptr<PointEmitter>(new PointEmitter(particle_type_name, 
point, 10));
 }

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
https://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to