28 b.use_custom_socket_order();
29 b.allow_any_socket_order();
30 b.add_default_layout();
32 .supported_type(GeometryComponent::Type::Mesh)
34 b.add_output<
decl::Geometry>(
"Mesh").propagate_all().align_with_previous();
35 if (
const bNode *node =
b.node_or_null()) {
36 switch (
Mode(node->custom1)) {
38 b.add_input<
decl::Bool>(
"Remove Custom").default_value(
true);
39 b.add_input<
decl::Bool>(
"Edge Sharpness").field_on_all();
40 b.add_input<
decl::Bool>(
"Face Sharpness").field_on_all();
74 bool add_sharpness_and_corner_fan_info =
false;
78 const bool remove_custom =
params.extract_input<
bool>(
"Remove Custom");
89 edge_evaluator.
add(sharp_edge);
90 face_evaluator.
add(sharp_face);
97 attributes.
remove(
"sharp_edge");
106 attributes.
remove(
"sharp_face");
115 attributes.
remove(
"custom_normal");
118 if (
const std::optional<bke::AttributeMetaData> meta_data =
124 add_sharpness_and_corner_fan_info =
true;
156 mesh->attributes_for_write().remove(
"custom_normal");
164 if (add_sharpness_and_corner_fan_info) {
166 "Adjusting sharpness with \"Tangent Space\" custom normals "
167 "may lead to unexpected results");
170 params.set_output(
"Mesh", std::move(geometry_set));
180 "Store the sharpness of each face or edge. Similar to the \"Shade Smooth\" and \"Shade "
181 "Flat\" operators."},
186 "Store custom normals as simple vectors in the local space of the mesh. Values are not "
187 "necessarily updated automatically later on as the mesh is deformed."},
192 "Store normals in a deformation dependent custom transformation space. This method is "
193 "slower, but can be better when subsequent operations change the mesh without handling "
194 "normals specifically."},
195 {0,
nullptr, 0,
nullptr,
nullptr},
201 "Storage mode for custom normal data",
207 "Attribute domain to store free custom normals",
216 ntype.
ui_name =
"Set Mesh Normal";
217 ntype.
ui_description =
"Store a normal vector for each mesh element";
#define NODE_CLASS_GEOMETRY
@ NODE_DEFAULT_INPUT_NORMAL_FIELD
#define NOD_REGISTER_NODE(REGISTER_FUNC)
#define NOD_inline_enum_accessors(member)
std::optional< AttributeMetaData > lookup_meta_data(StringRef attribute_id) const
bool remove(const StringRef attribute_id)
GSpanAttributeWriter lookup_or_add_for_write_only_span(StringRef attribute_id, 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 node_register_type(bNodeType &ntype)
bool try_capture_field_on_geometry(MutableAttributeAccessor attributes, const fn::FieldContext &field_context, const StringRef attribute_id, AttrDomain domain, const fn::Field< bool > &selection, const fn::GField &field)
void mesh_set_custom_normals(Mesh &mesh, MutableSpan< float3 > corner_normals)
GField make_constant_field(const CPPType &type, const void *value)
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_layout(uiLayout *layout, bContext *, PointerRNA *ptr)
static void node_register()
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)
VecBase< float, 3 > float3
void geo_node_type_base(blender::bke::bNodeType *ntype, std::string idname, const std::optional< int16_t > legacy_type)
const EnumPropertyItem rna_enum_attribute_domain_only_mesh_no_edge_items[]
Mesh * get_mesh_for_write()
MutableVArraySpan< T > span
std::string ui_description
void(* initfunc)(bNodeTree *ntree, bNode *node)
NodeGeometryExecFunction geometry_node_execute
void(* draw_buttons)(uiLayout *, bContext *C, PointerRNA *ptr)
NodeDeclareFunction declare
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)