From 46b79b3d4a8a6f684f2879f82c0123b8d972d6e2 Mon Sep 17 00:00:00 2001 From: Jacques Lucke Date: Sat, 11 Jul 2020 16:55:57 +0200 Subject: Nodes: support vector math node in simulation node tree --- .../nodes/shader/nodes/node_shader_vector_math.cc | 38 ++++++++++++++++++++++ 1 file changed, 38 insertions(+) (limited to 'source/blender') diff --git a/source/blender/nodes/shader/nodes/node_shader_vector_math.cc b/source/blender/nodes/shader/nodes/node_shader_vector_math.cc index 96cf64b7ea9..414d05e996a 100644 --- a/source/blender/nodes/shader/nodes/node_shader_vector_math.cc +++ b/source/blender/nodes/shader/nodes/node_shader_vector_math.cc @@ -160,6 +160,43 @@ static void node_shader_update_vector_math(bNodeTree *UNUSED(ntree), bNode *node } } +static void sh_node_vector_math_expand_in_mf_network(blender::bke::NodeMFNetworkBuilder &builder) +{ + using blender::float3; + + /* TODO: Implement other operations. */ + const int mode = builder.bnode().custom1; + switch (mode) { + case NODE_VECTOR_MATH_ADD: { + static blender::fn::CustomMF_SI_SI_SO fn{ + "Add", [](float3 a, float3 b) { return a + b; }}; + builder.set_matching_fn(fn); + break; + } + case NODE_VECTOR_MATH_SUBTRACT: { + static blender::fn::CustomMF_SI_SI_SO fn{ + "Subtract", [](float3 a, float3 b) { return a - b; }}; + builder.set_matching_fn(fn); + break; + } + case NODE_VECTOR_MATH_MULTIPLY: { + static blender::fn::CustomMF_SI_SI_SO fn{ + "Multiply", [](float3 a, float3 b) { return a * b; }}; + builder.set_matching_fn(fn); + break; + } + case NODE_VECTOR_MATH_DIVIDE: { + static blender::fn::CustomMF_SI_SI_SO fn{ + "Divide", [](float3 a, float3 b) { return float3::safe_divide(a, b); }}; + builder.set_matching_fn(fn); + break; + } + default: + BLI_assert(false); + break; + }; +} + void register_node_type_sh_vect_math(void) { static bNodeType ntype; @@ -169,6 +206,7 @@ void register_node_type_sh_vect_math(void) node_type_label(&ntype, node_vector_math_label); node_type_gpu(&ntype, gpu_shader_vector_math); node_type_update(&ntype, node_shader_update_vector_math); + ntype.expand_in_mf_network = sh_node_vector_math_expand_in_mf_network; nodeRegisterType(&ntype); } -- cgit v1.2.3