Blender V5.0
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
8#include "UI_resources.hh"
9
11
13{
14 b.add_output<decl::Vector>("Normal").field_source();
15 b.add_output<decl::Vector>("True Normal")
16 .field_source()
18 "For meshes, outputs normals without custom normal attributes taken into account");
19}
20
21static void node_layout_ex(uiLayout *layout, bContext * /*C*/, PointerRNA *ptr)
22{
23 layout->prop(ptr, "legacy_corner_normals", UI_ITEM_NONE, std::nullopt, ICON_NONE);
24}
25
27{
28 const bool legacy_corner_normals = bool(params.node().custom1);
29 if (params.output_is_required("Normal")) {
30 params.set_output(
31 "Normal",
32 Field<float3>{std::make_shared<bke::NormalFieldInput>(legacy_corner_normals, false)});
33 }
34 if (params.output_is_required("True Normal")) {
35 params.set_output("True Normal",
36 Field<float3>{std::make_shared<bke::NormalFieldInput>(false, true)});
37 }
38}
39
40static void node_register()
41{
42 static blender::bke::bNodeType ntype;
43
44 geo_node_type_base(&ntype, "GeometryNodeInputNormal", GEO_NODE_INPUT_NORMAL);
45 ntype.ui_name = "Normal";
46 ntype.ui_description =
47 "Retrieve a unit length vector indicating the direction pointing away from the geometry at "
48 "each element";
49 ntype.enum_name_legacy = "INPUT_NORMAL";
52 ntype.declare = node_declare;
55}
57
58} // namespace blender::nodes::node_geo_input_normal_cc
#define NODE_CLASS_INPUT
Definition BKE_node.hh:447
#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:2416
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:238
std::string ui_description
Definition BKE_node.hh:244
void(* draw_buttons_ex)(uiLayout *, bContext *C, PointerRNA *ptr)
Definition BKE_node.hh:261
NodeGeometryExecFunction geometry_node_execute
Definition BKE_node.hh:354
const char * enum_name_legacy
Definition BKE_node.hh:247
NodeDeclareFunction declare
Definition BKE_node.hh:362
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:4238