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(); | |||||
JacquesLucke: The identifier can be removed here as well. Identifiers only need to be unique on one side of… | |||||
| b.add_input<decl::Vector>("Rotate By").subtype(PROP_EULER); | |||||
| b.add_output<decl::Vector>("Rotation"); | |||||
Done Inline ActionsNo need to specify socket identifiers (second input) when the names are different. JacquesLucke: No need to specify socket identifiers (second input) when the names are different. | |||||
| }; | |||||
| static const fn::MultiFunction *get_multi_function(bNode &bnode) | |||||
| { | |||||
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 fn::CustomMF_SI_SI_SO<float3, float3, float3> euler_rot{ | |||||
| "Rotate Euler", [](const float3 &input, const float3 &rotation) { | |||||
| float mat[3][3]; | |||||
| float3 result = input; | |||||
Done Inline ActionsWhat is the operation? JacquesLucke: What is the operation? | |||||
| eul_to_mat3(mat, rotation); | |||||
| mul_m3_v3(mat, result); | |||||
Done Inline ActionsThis function is not necessary. JacquesLucke: This function is not necessary. | |||||
JacquesLuckeUnsubmitted 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… | |||||
jarrett.johnsonAuthorUnsubmitted 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… | |||||
| return result; | |||||
| }}; | |||||
| return &euler_rot; | |||||
| } | |||||
| static void fn_node_rotate_euler_build_multi_function(NodeMultiFunctionBuilder &builder) | |||||
| { | |||||
| const fn::MultiFunction *fn = get_multi_function(builder.node()); | |||||
| builder.set_matching_fn(fn); | |||||
| } | |||||
| } // namespace blender::nodes | |||||
| void register_node_type_fn_rotate_euler() | |||||
| { | |||||
Done Inline ActionsThis is dead code. JacquesLucke: This is dead code. | |||||
| 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 = blender::nodes::fn_node_rotate_euler_build_multi_function; | |||||
| nodeRegisterType(&ntype); | |||||
| } | |||||
Done Inline ActionsNo need to use auto here. JacquesLucke: No need to use `auto` here. | |||||
The identifier can be removed here as well. Identifiers only need to be unique on one side of the node (e.g. among all inputs).