Changeset View
Standalone View
source/blender/nodes/function/nodes/node_fn_rotate_euler.cc
- This file was added.
| /* | |||||
| * This program is free software; you can redistribute it and/or | |||||
| * modify it under the terms of the GNU General Public License | |||||
| * as published by the Free Software Foundation; either version 2 | |||||
| * of the License, or (at your option) any later version. | |||||
| * | |||||
| * This program is distributed in the hope that it will be useful, | |||||
| * but WITHOUT ANY WARRANTY; without even the implied warranty of | |||||
| * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |||||
| * GNU General Public License for more details. | |||||
| * | |||||
| * You should have received a copy of the GNU General Public License | |||||
| * along with this program; if not, write to the Free Software Foundation, | |||||
| * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |||||
| */ | |||||
| #include "BLI_listbase.h" | |||||
| #include "BLI_string.h" | |||||
| #include "RNA_enum_types.h" | |||||
| #include "UI_interface.h" | |||||
| #include "UI_resources.h" | |||||
| #include "node_function_util.hh" | |||||
| namespace blender::nodes { | |||||
| static void fn_node_rotate_euler_declare(NodeDeclarationBuilder &b) | |||||
| { | |||||
| b.is_function_node(); | |||||
| b.add_input<decl::Vector>("Rotation", "Rotation").subtype(PROP_EULER).hide_value(); | |||||
| b.add_input<decl::Vector>("Rotate By", "Rotation_001").subtype(PROP_EULER); | |||||
JacquesLucke: No need to specify socket identifiers (second input) when the names are different. | |||||
Done Inline ActionsThe identifier can be removed here as well. Identifiers only need to be unique on one side of the node (e.g. among all inputs). JacquesLucke: The identifier can be removed here as well. Identifiers only need to be unique on one side of… | |||||
| b.add_output<decl::Vector>("Rotation"); | |||||
| }; | |||||
| } // namespace blender::nodes | |||||
JacquesLuckeUnsubmitted Done Inline ActionsPut everything except register_node_type_fn_rotate_euler in the namespace and remove the unnecessary blender:: prefixes. JacquesLucke: Put everything except `register_node_type_fn_rotate_euler` in the namespace and remove the… | |||||
| static void fn_node_rotate_euler_layout(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr) | |||||
| { | |||||
| uiItemR(layout, ptr, "operation", 0, "", ICON_NONE); | |||||
JacquesLuckeUnsubmitted Done Inline ActionsWhat is the operation? JacquesLucke: What is the operation? | |||||
| } | |||||
| static void node_rotate_euler_update(bNodeTree *UNUSED(ntree), bNode *node) | |||||
JacquesLuckeUnsubmitted Done Inline ActionsThis function is not necessary. JacquesLucke: This function is not necessary. | |||||
| { | |||||
| bNodeSocket *sockB = (bNodeSocket *)BLI_findlink(&node->inputs, 1); | |||||
Done Inline ActionsYou are treating the rotation input as vector, not as a euler. Changing an euler with such a matrix multiplication does not seem to make sense, does it? You'll probably have to convert both eulers to a matrix, then perform a matrix multiplication and then convert back. JacquesLucke: You are treating the rotation input as vector, not as a euler. Changing an euler with such a… | |||||
Done Inline ActionsThanks. I was going to bring this up later today after work (I submitted this patch a bit prematurely--I tried to abort from arc diff but it went through instead). Rotating it did not seem to make any sense, but this explains a lot why. jarrett.johnson: Thanks. I was going to bring this up later today after work (I submitted this patch a bit… | |||||
| } | |||||
| static const blender::fn::MultiFunction *get_multi_function(bNode &bnode) | |||||
| { | |||||
| static blender::fn::CustomMF_SI_SI_SO<blender::float3, blender::float3, blender::float3> | |||||
| euler_rot{"Rotate Euler", [](const blender::float3 &input, const blender::float3 &rotation) { | |||||
| float mat[3][3]; | |||||
| blender::float3 result = input; | |||||
| eul_to_mat3(mat, rotation); | |||||
| mul_m3_v3(mat, result); | |||||
| return result; | |||||
| }}; | |||||
| return &euler_rot; | |||||
| BLI_assert_unreachable(); | |||||
JacquesLuckeUnsubmitted Done Inline ActionsThis is dead code. JacquesLucke: This is dead code. | |||||
| return nullptr; | |||||
| } | |||||
| static void fn_node_rotate_euler_build_multi_function( | |||||
| blender::nodes::NodeMultiFunctionBuilder &builder) | |||||
| { | |||||
| const blender::fn::MultiFunction *fn = get_multi_function(builder.node()); | |||||
| builder.set_matching_fn(fn); | |||||
| } | |||||
| void register_node_type_fn_rotate_euler() | |||||
| { | |||||
| static bNodeType ntype; | |||||
| fn_node_type_base(&ntype, FN_NODE_ROTATE_EULER, "Rotate Euler", NODE_CLASS_CONVERTER, 0); | |||||
| ntype.declare = blender::nodes::fn_node_rotate_euler_declare; | |||||
| ntype.build_multi_function = fn_node_rotate_euler_build_multi_function; | |||||
| nodeRegisterType(&ntype); | |||||
| } | |||||
Done Inline ActionsNo need to use auto here. JacquesLucke: No need to use `auto` here. | |||||
No need to specify socket identifiers (second input) when the names are different.