Blender V4.5
node_geo_input_normal.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2023 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
6
7#include "UI_interface.hh"
8
10
12{
13 b.add_output<decl::Vector>("Normal").field_source();
14 b.add_output<decl::Vector>("True Normal")
15 .field_source()
17 "For meshes, outputs normals without custom normal attributes taken into account");
18}
19
20static void node_layout_ex(uiLayout *layout, bContext * /*C*/, PointerRNA *ptr)
21{
22 layout->prop(ptr, "legacy_corner_normals", UI_ITEM_NONE, std::nullopt, ICON_NONE);
23}
24
26{
27 const bool legacy_corner_normals = bool(params.node().custom1);
28 if (params.output_is_required("Normal")) {
29 params.set_output(
30 "Normal",
31 Field<float3>{std::make_shared<bke::NormalFieldInput>(legacy_corner_normals, false)});
32 }
33 if (params.output_is_required("True Normal")) {
34 params.set_output("True Normal",
35 Field<float3>{std::make_shared<bke::NormalFieldInput>(false, true)});
36 }
37}
38
39static void node_register()
40{
41 static blender::bke::bNodeType ntype;
42
43 geo_node_type_base(&ntype, "GeometryNodeInputNormal", GEO_NODE_INPUT_NORMAL);
44 ntype.ui_name = "Normal";
45 ntype.ui_description =
46 "Retrieve a unit length vector indicating the direction pointing away from the geometry at "
47 "each element";
48 ntype.enum_name_legacy = "INPUT_NORMAL";
51 ntype.declare = node_declare;
54}
56
57} // namespace blender::nodes::node_geo_input_normal_cc
#define NODE_CLASS_INPUT
Definition BKE_node.hh:433
#define GEO_NODE_INPUT_NORMAL
#define NOD_REGISTER_NODE(REGISTER_FUNC)
#define UI_ITEM_NONE
uiWidgetBaseParameters params[MAX_WIDGET_BASE_BATCH]
void node_register_type(bNodeType &ntype)
Definition node.cc:2748
static void node_declare(NodeDeclarationBuilder &b)
static void node_layout_ex(uiLayout *layout, bContext *, PointerRNA *ptr)
static void node_geo_exec(GeoNodeExecParams params)
void geo_node_type_base(blender::bke::bNodeType *ntype, std::string idname, const std::optional< int16_t > legacy_type)
Defines a node type.
Definition BKE_node.hh:226
std::string ui_description
Definition BKE_node.hh:232
void(* draw_buttons_ex)(uiLayout *, bContext *C, PointerRNA *ptr)
Definition BKE_node.hh:249
NodeGeometryExecFunction geometry_node_execute
Definition BKE_node.hh:347
const char * enum_name_legacy
Definition BKE_node.hh:235
NodeDeclareFunction declare
Definition BKE_node.hh:355
void prop(PointerRNA *ptr, PropertyRNA *prop, int index, int value, eUI_Item_Flag flag, std::optional< blender::StringRef > name_opt, int icon, std::optional< blender::StringRef > placeholder=std::nullopt)
PointerRNA * ptr
Definition wm_files.cc:4227