28 b.use_custom_socket_order();
29 b.allow_any_socket_order();
30 b.add_default_layout();
34 b.add_output<
decl::Geometry>(
"Mesh"_ustr).propagate_all_geometry().align_with_previous();
38 b.add_input<
decl::Bool>(
"Remove Custom"_ustr).default_value(
true);
39 b.add_input<
decl::Bool>(
"Edge Sharpness"_ustr).evaluated_geometry_field();
40 b.add_input<
decl::Bool>(
"Face Sharpness"_ustr).evaluated_geometry_field();
46 .evaluated_geometry_field()
74 bool add_sharpness_and_corner_fan_info =
false;
78 const bool remove_custom = params.
extract_input<
bool>(
"Remove Custom"_ustr);
89 edge_evaluator.
add(sharp_edge);
90 face_evaluator.
add(sharp_face);
97 attributes.
remove(
"sharp_edge");
99 else if (edge_values.
size() ==
mesh->edges_num) {
100 attributes.
remove(
"sharp_edge");
101 attributes.
add<
bool>(
111 attributes.
remove(
"sharp_face");
113 else if (face_values.
size() ==
mesh->faces_num) {
114 attributes.
remove(
"sharp_face");
115 attributes.
add<
bool>(
125 attributes.
remove(
"custom_normal");
128 if (
const std::optional<bke::AttributeMetaData> meta_data =
134 add_sharpness_and_corner_fan_info =
true;
144 "Custom Normal"_ustr);
160 "Custom Normal"_ustr);
168 mesh->attributes_for_write().remove(
"custom_normal");
176 if (add_sharpness_and_corner_fan_info) {
178 "Adjusting sharpness with \"Tangent Space\" custom normals "
179 "may lead to unexpected results");
182 params.
set_output(
"Mesh"_ustr, std::move(geometry_set));
192 "Store the sharpness of each face or edge. Similar to the \"Shade Smooth\" and \"Shade "
193 "Flat\" operators."},
198 "Store custom normals as simple vectors in the local space of the mesh. Values are not "
199 "necessarily updated automatically later on as the mesh is deformed."},
204 "Store normals in a deformation dependent custom transformation space. This method is "
205 "slower, but can be better when subsequent operations change the mesh without handling "
206 "normals specifically."},
207 {0,
nullptr, 0,
nullptr,
nullptr},
213 "Storage mode for custom normal data",
219 "Attribute domain to store free custom normals",
228 ntype.
ui_name =
"Set Mesh Normal";
229 ntype.
ui_description =
"Store a normal vector for each mesh element";
#define NODE_CLASS_GEOMETRY
#define NOD_REGISTER_NODE(REGISTER_FUNC)
#define NOD_inline_enum_accessors(member)
std::optional< AttributeMetaData > lookup_meta_data(StringRef name) const
bool add(const StringRef name, const AttrDomain domain, const AttrType data_type, const AttributeInit &initializer)
bool remove(const StringRef name)
GSpanAttributeWriter lookup_or_add_for_write_only_span(StringRef name, AttrDomain domain, AttrType data_type)
int add(GField field, GVArray *varray_ptr)
IndexMask get_evaluated_as_mask(int field_index)
int add_with_destination(GField field, GVMutableArray dst)
void to_bools(MutableSpan< bool > r_bools) const
void error_message_add(const NodeWarningType type, StringRef message) const
T extract_input(const UString identifier)
const bNode & node() const
void set_output(const UString identifier, T &&value)
NodeDefaultInputType default_input_type
bool try_capture_field_on_geometry(MutableAttributeAccessor attributes, const fn::FieldContext &field_context, const StringRef name, AttrDomain domain, const fn::Field< bool > &selection, const fn::GField &field)
void node_register_type(bNodeType &ntype)
void mesh_set_custom_normals(Mesh &mesh, MutableSpan< float3 > corner_normals)
void foreach_real_geometry(bke::GeometrySet &geometry, FunctionRef< void(bke::GeometrySet &geometry_set)> fn)
static void node_init(bNodeTree *, bNode *node)
static void node_rna(StructRNA *srna)
static void node_declare(NodeDeclarationBuilder &b)
static void node_geo_exec(GeoNodeExecParams params)
static void node_register()
static void node_layout(ui::Layout &layout, bContext *, PointerRNA *ptr)
PropertyRNA * RNA_def_node_enum(StructRNA *srna, const char *identifier, const char *ui_name, const char *ui_description, const EnumPropertyItem *static_items, const EnumRNAAccessors accessors, std::optional< int > default_value, const EnumPropertyItemFunc item_func, const bool allow_animation)
const EnumPropertyItem rna_enum_attribute_domain_only_mesh_no_edge_items[]
@ NODE_DEFAULT_INPUT_NORMAL_FIELD
VecBase< float, 3 > float3
void geo_node_type_base(bke::bNodeType *ntype, UString idname, const std::optional< int16_t > legacy_type)
Mesh * get_mesh_for_write()
MutableVArraySpan< T > span
void(*) draw_buttons(ui::Layout &, bContext *C, PointerRNA *ptr)
std::string ui_description
NodeGeometryExecFunction geometry_node_execute
void(*) initfunc(bNodeTree *ntree, bNode *node)
NodeDeclareFunction declare
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)