Blender V5.3
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"_ustr).structure_type(StructureType::Field);
15 b.add_output<decl::Vector>("True Normal"_ustr)
16 .structure_type(StructureType::Field)
18 "For meshes, outputs normals without custom normal attributes taken into account");
19}
20
21static void node_layout_ex(ui::Layout &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"_ustr)) {
30 params.set_output(
31 "Normal"_ustr,
32 Field<float3>::from_input<bke::NormalFieldInput>(legacy_corner_normals, false));
33 }
34 if (params.output_is_required("True Normal"_ustr)) {
35 params.set_output("True Normal"_ustr,
37 }
38}
39
40static void node_register()
41{
42 static bke::bNodeType ntype;
43
44 geo_node_type_base(&ntype, "GeometryNodeInputNormal"_ustr, 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:478
#define GEO_NODE_INPUT_NORMAL
#define NOD_REGISTER_NODE(REGISTER_FUNC)
#define UI_ITEM_NONE
static Field from_input(Args &&...args)
bool output_is_required(const UString identifier) const
void set_output(const UString identifier, T &&value)
void node_register_type(bNodeType &ntype)
Definition node.cc:2920
static void node_layout_ex(ui::Layout &layout, bContext *, PointerRNA *ptr)
static void node_declare(NodeDeclarationBuilder &b)
static void node_geo_exec(GeoNodeExecParams params)
void geo_node_type_base(bke::bNodeType *ntype, UString idname, const std::optional< int16_t > legacy_type)
Defines a node type.
Definition BKE_node.hh:265
std::string ui_description
Definition BKE_node.hh:271
NodeGeometryExecFunction geometry_node_execute
Definition BKE_node.hh:385
void(*) draw_buttons_ex(ui::Layout &, bContext *C, PointerRNA *ptr)
Definition BKE_node.hh:292
const char * enum_name_legacy
Definition BKE_node.hh:274
NodeDeclareFunction declare
Definition BKE_node.hh:393
void prop(PointerRNA *ptr, PropertyRNA *prop, int index, int value, eUI_Item_Flag flag, std::optional< StringRef > name_opt, int icon, std::optional< StringRef > placeholder=std::nullopt)