Commit: e7d57e84bbfb57e3eb81306c539060eecdc5d014 Author: Hans Goudey Date: Tue Aug 3 15:07:46 2021 -0400 Branches: temp-geometry-nodes-fields-prototype https://developer.blender.org/rBe7d57e84bbfb57e3eb81306c539060eecdc5d014
Move "Align Rotation to Vector" to a function node without geometry The node is still slightly finnicky, I may have done something wrong here. But it generally works. =================================================================== M release/scripts/startup/nodeitems_builtins.py M source/blender/blenkernel/BKE_node.h M source/blender/blenkernel/intern/node.cc M source/blender/makesdna/DNA_node_types.h M source/blender/makesrna/intern/rna_nodetree.c M source/blender/nodes/CMakeLists.txt M source/blender/nodes/NOD_function.h M source/blender/nodes/NOD_geometry.h M source/blender/nodes/NOD_static_types.h A source/blender/nodes/function/nodes/node_fn_align_rotation_to_vector.cc D source/blender/nodes/geometry/nodes/node_geo_align_rotation_to_vector.cc =================================================================== diff --git a/release/scripts/startup/nodeitems_builtins.py b/release/scripts/startup/nodeitems_builtins.py index 0df9f3f99d9..29a77df71a0 100644 --- a/release/scripts/startup/nodeitems_builtins.py +++ b/release/scripts/startup/nodeitems_builtins.py @@ -572,7 +572,6 @@ geometry_node_categories = [ NodeItem("GeometryNodePointScale"), NodeItem("GeometryNodePointTranslate"), NodeItem("GeometryNodeRotatePoints"), - NodeItem("GeometryNodeAlignRotationToVector"), ]), GeometryNodeCategory("GEO_UTILITIES", "Utilities", items=[ NodeItem("ShaderNodeMapRange"), @@ -590,6 +589,7 @@ geometry_node_categories = [ NodeItem("ShaderNodeCombineXYZ"), NodeItem("ShaderNodeVectorMath"), NodeItem("ShaderNodeVectorRotate"), + NodeItem("FunctionNodeAlignRotationToVector"), ]), GeometryNodeCategory("GEO_OUTPUT", "Output", items=[ NodeItem("GeometryNodeViewer"), diff --git a/source/blender/blenkernel/BKE_node.h b/source/blender/blenkernel/BKE_node.h index acbbd110219..b98077b1d9c 100644 --- a/source/blender/blenkernel/BKE_node.h +++ b/source/blender/blenkernel/BKE_node.h @@ -1420,7 +1420,7 @@ int ntreeTexExecTree(struct bNodeTree *ntree, #define GEO_NODE_ATTRIBUTE_COMPARE 1015 #define GEO_NODE_POINT_ROTATE 1016 #define GEO_NODE_ATTRIBUTE_VECTOR_MATH 1017 -#define GEO_NODE_ALIGN_ROTATION_TO_VECTOR 1018 +// #define GEO_NODE_ALIGN_ROTATION_TO_VECTOR 1018 #define GEO_NODE_POINT_TRANSLATE 1019 #define GEO_NODE_POINT_SCALE 1020 #define GEO_NODE_ATTRIBUTE_SAMPLE_TEXTURE 1021 @@ -1490,6 +1490,7 @@ int ntreeTexExecTree(struct bNodeTree *ntree, #define FN_NODE_INPUT_VECTOR 1207 #define FN_NODE_INPUT_STRING 1208 #define FN_NODE_FLOAT_TO_INT 1209 +#define FN_NODE_ALIGN_ROTATION_TO_VECTOR 1210 /** \} */ diff --git a/source/blender/blenkernel/intern/node.cc b/source/blender/blenkernel/intern/node.cc index 39498ad0772..213a1d3f64d 100644 --- a/source/blender/blenkernel/intern/node.cc +++ b/source/blender/blenkernel/intern/node.cc @@ -5115,7 +5115,6 @@ static void registerGeometryNodes() { register_node_type_geo_group(); - register_node_type_geo_align_rotation_to_vector(); register_node_type_geo_attribute(); register_node_type_geo_attribute_clamp(); register_node_type_geo_attribute_color_ramp(); @@ -5199,6 +5198,7 @@ static void registerFunctionNodes() register_node_type_fn_float_to_int(); register_node_type_fn_input_string(); register_node_type_fn_input_vector(); + register_node_type_fn_align_rotation_to_vector(); register_node_type_fn_random_float(); } diff --git a/source/blender/makesdna/DNA_node_types.h b/source/blender/makesdna/DNA_node_types.h index 75613de6d16..6d42e76abe0 100644 --- a/source/blender/makesdna/DNA_node_types.h +++ b/source/blender/makesdna/DNA_node_types.h @@ -1252,16 +1252,12 @@ typedef struct NodeGeometryRotatePoints { char _pad[3]; } NodeGeometryRotatePoints; -typedef struct NodeGeometryAlignRotationToVector { +typedef struct FunctionNodeAlignRotationToVector { /* GeometryNodeAlignRotationToVectorAxis */ uint8_t axis; /* GeometryNodeAlignRotationToVectorPivotAxis */ uint8_t pivot_axis; - - /* GeometryNodeAttributeInputMode */ - uint8_t input_type_factor; - uint8_t input_type_vector; -} NodeGeometryAlignRotationToVector; +} FunctionNodeAlignRotationToVector; typedef struct NodeGeometryPointScale { /* GeometryNodeAttributeInputMode */ diff --git a/source/blender/makesrna/intern/rna_nodetree.c b/source/blender/makesrna/intern/rna_nodetree.c index b7b2c19211b..53d34bf8f5e 100644 --- a/source/blender/makesrna/intern/rna_nodetree.c +++ b/source/blender/makesrna/intern/rna_nodetree.c @@ -9627,7 +9627,7 @@ static void def_geo_point_rotate(StructRNA *srna) RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_socket_update"); } -static void def_geo_align_rotation_to_vector(StructRNA *srna) +static void def_fn_align_rotation_to_vector(StructRNA *srna) { static const EnumPropertyItem axis_items[] = { {GEO_NODE_ALIGN_ROTATION_TO_VECTOR_AXIS_X, @@ -9674,7 +9674,7 @@ static void def_geo_align_rotation_to_vector(StructRNA *srna) PropertyRNA *prop; - RNA_def_struct_sdna_from(srna, "NodeGeometryAlignRotationToVector", "storage"); + RNA_def_struct_sdna_from(srna, "FunctionNodeAlignRotationToVector", "storage"); prop = RNA_def_property(srna, "axis", PROP_ENUM, PROP_NONE); RNA_def_property_enum_items(prop, axis_items); @@ -9685,16 +9685,6 @@ static void def_geo_align_rotation_to_vector(StructRNA *srna) RNA_def_property_enum_items(prop, pivot_axis_items); RNA_def_property_ui_text(prop, "Pivot Axis", "Axis to rotate around"); RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update"); - - prop = RNA_def_property(srna, "input_type_factor", PROP_ENUM, PROP_NONE); - RNA_def_property_enum_items(prop, rna_node_geometry_attribute_input_type_items_float); - RNA_def_property_ui_text(prop, "Input Type Factor", ""); - RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_socket_update"); - - prop = RNA_def_property(srna, "input_type_vector", PROP_ENUM, PROP_NONE); - RNA_def_property_enum_items(prop, rna_node_geometry_attribute_input_type_items_vector); - RNA_def_property_ui_text(prop, "Input Type Vector", ""); - RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_socket_update"); } static void def_geo_point_scale(StructRNA *srna) diff --git a/source/blender/nodes/CMakeLists.txt b/source/blender/nodes/CMakeLists.txt index e7311210ead..be8833e3710 100644 --- a/source/blender/nodes/CMakeLists.txt +++ b/source/blender/nodes/CMakeLists.txt @@ -138,9 +138,9 @@ set(SRC function/nodes/node_fn_input_string.cc function/nodes/node_fn_input_vector.cc function/nodes/node_fn_random_float.cc + function/nodes/node_fn_align_rotation_to_vector.cc function/node_function_util.cc - geometry/nodes/node_geo_align_rotation_to_vector.cc geometry/nodes/node_geo_attribute.cc geometry/nodes/node_geo_attribute_clamp.cc geometry/nodes/node_geo_attribute_color_ramp.cc diff --git a/source/blender/nodes/NOD_function.h b/source/blender/nodes/NOD_function.h index 29f1a465491..ec0c2fcdc10 100644 --- a/source/blender/nodes/NOD_function.h +++ b/source/blender/nodes/NOD_function.h @@ -26,6 +26,7 @@ void register_node_type_fn_float_to_int(void); void register_node_type_fn_input_string(void); void register_node_type_fn_input_vector(void); void register_node_type_fn_random_float(void); +void register_node_type_fn_align_rotation_to_vector(void); #ifdef __cplusplus } diff --git a/source/blender/nodes/NOD_geometry.h b/source/blender/nodes/NOD_geometry.h index a48aff08748..019f2c1d4bf 100644 --- a/source/blender/nodes/NOD_geometry.h +++ b/source/blender/nodes/NOD_geometry.h @@ -29,7 +29,6 @@ void register_node_tree_type_geo(void); void register_node_type_geo_group(void); void register_node_type_geo_custom_group(bNodeType *ntype); -void register_node_type_geo_align_rotation_to_vector(void); void register_node_type_geo_attribute(void); void register_node_type_geo_attribute_clamp(void); void register_node_type_geo_attribute_color_ramp(void); diff --git a/source/blender/nodes/NOD_static_types.h b/source/blender/nodes/NOD_static_types.h index 0d94fd5625a..1bd66f9a4c0 100644 --- a/source/blender/nodes/NOD_static_types.h +++ b/source/blender/nodes/NOD_static_types.h @@ -267,8 +267,8 @@ DefNode(FunctionNode, FN_NODE_FLOAT_TO_INT, def_float_to_int, "FLOAT_TO_INT", Fl DefNode(FunctionNode, FN_NODE_INPUT_STRING, def_fn_input_string, "INPUT_STRING", InputString, "String", "") DefNode(FunctionNode, FN_NODE_INPUT_VECTOR, def_fn_input_vector, "INPUT_VECTOR", InputVector, "Vector", "") DefNode(FunctionNode, FN_NODE_RANDOM_FLOAT, 0, "RANDOM_FLOAT", RandomFloat, "Random Float", "") +DefNode(FunctionNode, FN_NODE_ALIGN_ROTATION_TO_VECTOR, def_fn_align_rotation_to_vector, "ALIGN_ROTATION_TO_VECTOR", AlignRotationToVector, "Align Rotation to Vector", "") -DefNode(GeometryNode, GEO_NODE_ALIGN_ROTATION_TO_VECTOR, def_geo_align_rotation_to_vector, "ALIGN_ROTATION_TO_VECTOR", AlignRotationToVector, "Align Rotation to Vector", "") DefNode(GeometryNode, GEO_NODE_ATTRIBUTE, def_geo_attribute, "ATTRIBUTE", Attribute, "Attribute", "") DefNode(GeometryNode, GEO_NODE_ATTRIBUTE_CLAMP, def_geo_attribute_clamp, "ATTRIBUTE_CLAMP", AttributeClamp, "Attribute Clamp", "") DefNode(GeometryNode, GEO_NODE_ATTRIBUTE_COLOR_RAMP, def_geo_attribute_color_ramp, "ATTRIBUTE_COLOR_RAMP", AttributeColorRamp, "Attribute Color Ramp", "") diff --git a/source/blender/nodes/function/nodes/node_fn_align_rotation_to_vector.cc b/source/blender/nodes/function/nodes/node_fn_align_rotation_to_vector.cc new file mode 100644 index 00000000000..7501202c3a8 --- /dev/null +++ b/source/blender/nodes/function/nodes/node_fn_align_rotation_to_vector.cc @@ -0,0 +1,195 @@ +/* + * 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_math_rotation.h" +#include "BLI_task.hh" + +#include "UI_interface.h" +#include "UI_resources.h" + +#include "node_function_util.hh" + +using blender::float3; + +static bNodeSocketTemplate fn_node_align_rotation_to_vector_in[] = { + {SOCK_VECTOR, N_("Rotation"), 1.0, 0.0, 0.0, 0.0, -FLT_MAX, FLT_MAX, PROP_EULER}, + {SOCK_FLOAT, N_("Factor"), 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, PROP_FACTOR}, + {SOCK_VECTOR, N_("Vector"), 0.0, 0.0, 1.0, 0.0, -FLT_MAX, FLT_MAX}, + {-1, ""}, +}; + +static bNodeSocketTemplate fn_node_align_rotation_to_vector_out[] = { + {SOCK_VECTOR, N_( @@ Diff output truncated at 10240 characters. @@ _______________________________________________ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs