Mesh: Replace auto smooth with node group #108014
|
@ -2573,7 +2573,7 @@ class VIEW3D_MT_object(Menu):
|
||||||
layout.separator()
|
layout.separator()
|
||||||
|
|
||||||
layout.operator("object.shade_smooth")
|
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.operator("object.shade_flat")
|
||||||
|
|
||||||
layout.separator()
|
layout.separator()
|
||||||
|
@ -2817,8 +2817,8 @@ class VIEW3D_MT_object_context_menu(Menu):
|
||||||
if obj is not None:
|
if obj is not None:
|
||||||
if obj.type in {'MESH', 'CURVE', 'SURFACE'}:
|
if obj.type in {'MESH', 'CURVE', 'SURFACE'}:
|
||||||
layout.operator("object.shade_smooth")
|
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", text="Shade Flat")
|
layout.operator("object.shade_flat")
|
||||||
|
|
||||||
layout.separator()
|
layout.separator()
|
||||||
|
|
||||||
|
|
|
@ -1125,7 +1125,6 @@ void ED_mesh_split_faces(Mesh *mesh)
|
||||||
{
|
{
|
||||||
using namespace blender;
|
using namespace blender;
|
||||||
const OffsetIndices polys = mesh->faces();
|
const OffsetIndices polys = mesh->faces();
|
||||||
const Span<int> corner_verts = mesh->corner_verts();
|
|
||||||
const Span<int> corner_edges = mesh->corner_edges();
|
const Span<int> corner_edges = mesh->corner_edges();
|
||||||
const bke::AttributeAccessor attributes = mesh->attributes();
|
const bke::AttributeAccessor attributes = mesh->attributes();
|
||||||
const VArray<bool> mesh_sharp_edges = *attributes.lookup_or_default<bool>(
|
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)
|
static int shade_smooth_exec(bContext *C, wmOperator *op)
|
||||||
{
|
{
|
||||||
const bool use_smooth = STREQ(op->idname, "OBJECT_OT_shade_smooth");
|
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 changed_multi = false;
|
||||||
bool has_linked_data = false;
|
bool has_linked_data = false;
|
||||||
|
|
||||||
|
@ -1604,12 +1605,11 @@ static int shade_smooth_exec(bContext *C, wmOperator *op)
|
||||||
|
|
||||||
bool changed = false;
|
bool changed = false;
|
||||||
if (ob->type == OB_MESH) {
|
if (ob->type == OB_MESH) {
|
||||||
BKE_mesh_smooth_flag_set(static_cast<Mesh *>(ob->data), use_smooth);
|
BKE_mesh_smooth_flag_set(static_cast<Mesh *>(ob->data), use_smooth || use_smooth_by_angle);
|
||||||
if (use_smooth) {
|
if (use_smooth || use_smooth_by_angle) {
|
||||||
const bool use_auto_smooth = RNA_boolean_get(op->ptr, "use_auto_smooth");
|
if (use_smooth_by_angle) {
|
||||||
if (use_auto_smooth) {
|
const float angle = RNA_float_get(op->ptr, "angle");
|
||||||
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), angle);
|
||||||
BKE_mesh_sharp_edges_set_from_angle(static_cast<Mesh *>(ob->data), auto_smooth_angle);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
BKE_mesh_batch_cache_dirty_tag(static_cast<Mesh *>(ob->data), BKE_MESH_BATCH_DIRTY_ALL);
|
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 */
|
/* flags */
|
||||||
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
||||||
|
}
|
||||||
|
|
||||||
/* properties */
|
void OBJECT_OT_shade_smooth_by_angle(wmOperatorType *ot)
|
||||||
PropertyRNA *prop;
|
{
|
||||||
|
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->poll = shade_poll;
|
||||||
ot->srna,
|
ot->exec = shade_smooth_exec;
|
||||||
"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);
|
|
||||||
|
|
||||||
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_range(prop, 0.0f, DEG2RADF(180.0f));
|
||||||
RNA_def_property_float_default(prop, DEG2RADF(30.0f));
|
RNA_def_property_float_default(prop, DEG2RADF(30.0f));
|
||||||
RNA_def_property_ui_text(prop,
|
RNA_def_property_ui_text(
|
||||||
"Angle",
|
prop, "Angle", "Maximum angle between face normals that will be considered as smooth");
|
||||||
"Maximum angle between face normals that will be considered as smooth "
|
|
||||||
"(unused if custom split normals data are available)");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** \} */
|
/** \} */
|
||||||
|
|
|
@ -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_editmode_toggle(struct wmOperatorType *ot);
|
||||||
void OBJECT_OT_posemode_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(struct wmOperatorType *ot);
|
||||||
|
void OBJECT_OT_shade_smooth_by_angle(struct wmOperatorType *ot);
|
||||||
void OBJECT_OT_shade_flat(struct wmOperatorType *ot);
|
void OBJECT_OT_shade_flat(struct wmOperatorType *ot);
|
||||||
void OBJECT_OT_paths_calculate(struct wmOperatorType *ot);
|
void OBJECT_OT_paths_calculate(struct wmOperatorType *ot);
|
||||||
void OBJECT_OT_paths_update(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_editmode_toggle);
|
||||||
WM_operatortype_append(OBJECT_OT_posemode_toggle);
|
WM_operatortype_append(OBJECT_OT_posemode_toggle);
|
||||||
WM_operatortype_append(OBJECT_OT_shade_smooth);
|
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_shade_flat);
|
||||||
WM_operatortype_append(OBJECT_OT_paths_calculate);
|
WM_operatortype_append(OBJECT_OT_paths_calculate);
|
||||||
WM_operatortype_append(OBJECT_OT_paths_update);
|
WM_operatortype_append(OBJECT_OT_paths_update);
|
||||||
|
|
Loading…
Reference in New Issue