Mesh: Replace auto smooth with node group #108014
|
@ -2573,7 +2573,7 @@ class VIEW3D_MT_object(Menu):
|
|||
layout.separator()
|
||||
|
||||
layout.operator("object.shade_smooth")
|
||||
layout.operator("object.shade_smooth", text="Shade Auto Smooth").use_auto_smooth = True
|
||||
layout.operator("object.shade_smooth_by_angle")
|
||||
layout.operator("object.shade_flat")
|
||||
|
||||
layout.separator()
|
||||
|
@ -2817,8 +2817,8 @@ class VIEW3D_MT_object_context_menu(Menu):
|
|||
if obj is not None:
|
||||
if obj.type in {'MESH', 'CURVE', 'SURFACE'}:
|
||||
layout.operator("object.shade_smooth")
|
||||
layout.operator("object.shade_smooth", text="Shade Auto Smooth").use_auto_smooth = True
|
||||
layout.operator("object.shade_flat", text="Shade Flat")
|
||||
layout.operator("object.shade_smooth_by_angle")
|
||||
HooglyBoogly marked this conversation as resolved
Outdated
|
||||
layout.operator("object.shade_flat")
|
||||
|
||||
layout.separator()
|
||||
|
||||
|
|
|
@ -1125,7 +1125,6 @@ void ED_mesh_split_faces(Mesh *mesh)
|
|||
{
|
||||
using namespace blender;
|
||||
const OffsetIndices polys = mesh->faces();
|
||||
const Span<int> corner_verts = mesh->corner_verts();
|
||||
const Span<int> corner_edges = mesh->corner_edges();
|
||||
const bke::AttributeAccessor attributes = mesh->attributes();
|
||||
const VArray<bool> mesh_sharp_edges = *attributes.lookup_or_default<bool>(
|
||||
|
|
|
@ -1556,6 +1556,7 @@ void OBJECT_OT_paths_clear(wmOperatorType *ot)
|
|||
static int shade_smooth_exec(bContext *C, wmOperator *op)
|
||||
{
|
||||
const bool use_smooth = STREQ(op->idname, "OBJECT_OT_shade_smooth");
|
||||
const bool use_smooth_by_angle = STREQ(op->idname, "OBJECT_OT_shade_smooth_by_angle");
|
||||
bool changed_multi = false;
|
||||
bool has_linked_data = false;
|
||||
|
||||
|
@ -1604,12 +1605,11 @@ static int shade_smooth_exec(bContext *C, wmOperator *op)
|
|||
|
||||
bool changed = false;
|
||||
if (ob->type == OB_MESH) {
|
||||
BKE_mesh_smooth_flag_set(static_cast<Mesh *>(ob->data), use_smooth);
|
||||
if (use_smooth) {
|
||||
const bool use_auto_smooth = RNA_boolean_get(op->ptr, "use_auto_smooth");
|
||||
if (use_auto_smooth) {
|
||||
const float auto_smooth_angle = RNA_float_get(op->ptr, "auto_smooth_angle");
|
||||
BKE_mesh_sharp_edges_set_from_angle(static_cast<Mesh *>(ob->data), auto_smooth_angle);
|
||||
BKE_mesh_smooth_flag_set(static_cast<Mesh *>(ob->data), use_smooth || use_smooth_by_angle);
|
||||
if (use_smooth || use_smooth_by_angle) {
|
||||
if (use_smooth_by_angle) {
|
||||
const float angle = RNA_float_get(op->ptr, "angle");
|
||||
BKE_mesh_sharp_edges_set_from_angle(static_cast<Mesh *>(ob->data), angle);
|
||||
}
|
||||
}
|
||||
BKE_mesh_batch_cache_dirty_tag(static_cast<Mesh *>(ob->data), BKE_MESH_BATCH_DIRTY_ALL);
|
||||
|
@ -1684,25 +1684,25 @@ void OBJECT_OT_shade_smooth(wmOperatorType *ot)
|
|||
|
||||
/* flags */
|
||||
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
||||
}
|
||||
|
||||
/* properties */
|
||||
PropertyRNA *prop;
|
||||
void OBJECT_OT_shade_smooth_by_angle(wmOperatorType *ot)
|
||||
{
|
||||
ot->name = "Shade Smooth by Angle";
|
||||
ot->description =
|
||||
"Set the sharpness of mesh edges based on the angle between the neighboring faces";
|
||||
ot->idname = "OBJECT_OT_shade_smooth_by_angle";
|
||||
|
||||
prop = RNA_def_boolean(
|
||||
ot->srna,
|
||||
"use_auto_smooth",
|
||||
false,
|
||||
"Auto Smooth",
|
||||
"Enable automatic smooth based on smooth/sharp faces/edges and angle between faces");
|
||||
RNA_def_property_flag(prop, PROP_SKIP_SAVE);
|
||||
ot->poll = shade_poll;
|
||||
ot->exec = shade_smooth_exec;
|
||||
|
||||
prop = RNA_def_property(ot->srna, "auto_smooth_angle", PROP_FLOAT, PROP_ANGLE);
|
||||
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
||||
|
||||
PropertyRNA *prop = RNA_def_property(ot->srna, "angle", PROP_FLOAT, PROP_ANGLE);
|
||||
RNA_def_property_range(prop, 0.0f, DEG2RADF(180.0f));
|
||||
RNA_def_property_float_default(prop, DEG2RADF(30.0f));
|
||||
RNA_def_property_ui_text(prop,
|
||||
"Angle",
|
||||
"Maximum angle between face normals that will be considered as smooth "
|
||||
"(unused if custom split normals data are available)");
|
||||
RNA_def_property_ui_text(
|
||||
prop, "Angle", "Maximum angle between face normals that will be considered as smooth");
|
||||
}
|
||||
|
||||
/** \} */
|
||||
|
|
|
@ -83,6 +83,7 @@ void OBJECT_OT_mode_set_with_submode(struct wmOperatorType *ot);
|
|||
void OBJECT_OT_editmode_toggle(struct wmOperatorType *ot);
|
||||
void OBJECT_OT_posemode_toggle(struct wmOperatorType *ot);
|
||||
void OBJECT_OT_shade_smooth(struct wmOperatorType *ot);
|
||||
void OBJECT_OT_shade_smooth_by_angle(struct wmOperatorType *ot);
|
||||
void OBJECT_OT_shade_flat(struct wmOperatorType *ot);
|
||||
void OBJECT_OT_paths_calculate(struct wmOperatorType *ot);
|
||||
void OBJECT_OT_paths_update(struct wmOperatorType *ot);
|
||||
|
|
|
@ -43,6 +43,7 @@ void ED_operatortypes_object()
|
|||
WM_operatortype_append(OBJECT_OT_editmode_toggle);
|
||||
WM_operatortype_append(OBJECT_OT_posemode_toggle);
|
||||
WM_operatortype_append(OBJECT_OT_shade_smooth);
|
||||
WM_operatortype_append(OBJECT_OT_shade_smooth_by_angle);
|
||||
WM_operatortype_append(OBJECT_OT_shade_flat);
|
||||
WM_operatortype_append(OBJECT_OT_paths_calculate);
|
||||
WM_operatortype_append(OBJECT_OT_paths_update);
|
||||
|
|
Loading…
Reference in New Issue
Shouldn't the
by_angle
operator only be shown for mesh objects? (the operator looks only to deal with meshes).