[Bf-blender-cvs] [d30979dddb3] functions: new Constant Falloff node

Jacques Lucke noreply at git.blender.org
Fri Sep 6 16:56:07 CEST 2019


Commit: d30979dddb30390986b23c7d9bdfe621ce401181
Author: Jacques Lucke
Date:   Fri Sep 6 15:51:03 2019 +0200
Branches: functions
https://developer.blender.org/rBd30979dddb30390986b23c7d9bdfe621ce401181

new Constant Falloff node

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

M	release/scripts/startup/nodes/function_nodes/falloffs.py
M	source/blender/functions/frontends/data_flow_nodes/mappings/node_inserters.cpp
M	source/blender/functions/functions/falloffs.cpp
M	source/blender/functions/functions/falloffs.hpp

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

diff --git a/release/scripts/startup/nodes/function_nodes/falloffs.py b/release/scripts/startup/nodes/function_nodes/falloffs.py
index f63014b0bff..0ff01b8d906 100644
--- a/release/scripts/startup/nodes/function_nodes/falloffs.py
+++ b/release/scripts/startup/nodes/function_nodes/falloffs.py
@@ -2,6 +2,16 @@ import bpy
 from .. node_builder import NodeBuilder
 from .. base import FunctionNode
 
+
+class ConstantFalloffNode(bpy.types.Node, FunctionNode):
+    bl_idname = "fn_ConstantFalloffNode"
+    bl_label = "Constant Falloff"
+
+    def declaration(self, builder: NodeBuilder):
+        builder.fixed_input("weight", "Weight", "Float", default=1.0)
+        builder.fixed_output("falloff", "Falloff", "Falloff")
+
+
 class PointDistanceFalloffNode(bpy.types.Node, FunctionNode):
     bl_idname = "fn_PointDistanceFalloffNode"
     bl_label = "Point Distance Falloff"
diff --git a/source/blender/functions/frontends/data_flow_nodes/mappings/node_inserters.cpp b/source/blender/functions/frontends/data_flow_nodes/mappings/node_inserters.cpp
index 5f1eef87082..ca370466f27 100644
--- a/source/blender/functions/frontends/data_flow_nodes/mappings/node_inserters.cpp
+++ b/source/blender/functions/frontends/data_flow_nodes/mappings/node_inserters.cpp
@@ -401,6 +401,7 @@ void REGISTER_node_inserters(std::unique_ptr<NodeInserters> &inserters)
   REGISTER_FUNCTION("fn_VectorDistanceNode", vector_distance);
   REGISTER_FUNCTION("fn_TextLengthNode", string_length);
   REGISTER_FUNCTION("fn_PointDistanceFalloffNode", point_distance_falloff);
+  REGISTER_FUNCTION("fn_ConstantFalloffNode", constant_falloff);
 
   REGISTER_INSERTER("fn_CallNode", INSERT_call);
   REGISTER_INSERTER("fn_ClampNode", INSERT_clamp);
diff --git a/source/blender/functions/functions/falloffs.cpp b/source/blender/functions/functions/falloffs.cpp
index 863f74915de..12dcb321c11 100644
--- a/source/blender/functions/functions/falloffs.cpp
+++ b/source/blender/functions/functions/falloffs.cpp
@@ -34,5 +34,26 @@ BLI_LAZY_INIT(SharedFunction, GET_FN_point_distance_falloff)
   return fn;
 }
 
+class ConstantFalloff : public TupleCallBody {
+  void call(Tuple &fn_in, Tuple &fn_out, ExecutionContext &UNUSED(ctx)) const override
+  {
+    float weight = this->get_input<float>(fn_in, 0, "Weight");
+
+    FalloffW falloff = new BKE::ConstantFalloff(weight);
+    fn_out.move_in(0, falloff);
+  }
+};
+
+BLI_LAZY_INIT(SharedFunction, GET_FN_constant_falloff)
+{
+  FunctionBuilder builder;
+  builder.add_input("Weight", TYPE_float);
+  builder.add_output("Falloff", TYPE_falloff);
+
+  auto fn = builder.build("Constant Falloff");
+  fn->add_body<ConstantFalloff>();
+  return fn;
+}
+
 }  // namespace Functions
 }  // namespace FN
diff --git a/source/blender/functions/functions/falloffs.hpp b/source/blender/functions/functions/falloffs.hpp
index b963d773c83..eac9e872d2c 100644
--- a/source/blender/functions/functions/falloffs.hpp
+++ b/source/blender/functions/functions/falloffs.hpp
@@ -6,6 +6,7 @@ namespace FN {
 namespace Functions {
 
 SharedFunction &GET_FN_point_distance_falloff();
+SharedFunction &GET_FN_constant_falloff();
 
 }  // namespace Functions
 }  // namespace FN



More information about the Bf-blender-cvs mailing list