Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/blender/modifiers/intern/MOD_bevel.c')
-rw-r--r--source/blender/modifiers/intern/MOD_bevel.c168
1 files changed, 99 insertions, 69 deletions
diff --git a/source/blender/modifiers/intern/MOD_bevel.c b/source/blender/modifiers/intern/MOD_bevel.c
index 76b8985975e..c0428785009 100644
--- a/source/blender/modifiers/intern/MOD_bevel.c
+++ b/source/blender/modifiers/intern/MOD_bevel.c
@@ -51,6 +51,8 @@
#include "MOD_ui_common.h"
#include "MOD_util.h"
+#include "BLO_read_write.h"
+
#include "BKE_curveprofile.h"
#include "bmesh.h"
#include "bmesh_tools.h"
@@ -71,6 +73,7 @@ static void initData(ModifierData *md)
bmd->face_str_mode = MOD_BEVEL_FACE_STRENGTH_NONE;
bmd->miter_inner = MOD_BEVEL_MITER_SHARP;
bmd->miter_outer = MOD_BEVEL_MITER_SHARP;
+ bmd->affect_type = MOD_BEVEL_AFFECT_EDGES;
bmd->spread = 0.1f;
bmd->mat = -1;
bmd->profile = 0.5f;
@@ -115,9 +118,9 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh *
MDeformVert *dvert = NULL;
BevelModifierData *bmd = (BevelModifierData *)md;
const float threshold = cosf(bmd->bevel_angle + 0.000000175f);
- const bool vertex_only = (bmd->flags & MOD_BEVEL_VERT) != 0;
const bool do_clamp = !(bmd->flags & MOD_BEVEL_OVERLAP_OK);
const int offset_type = bmd->val_flags;
+ const int profile_type = bmd->profile_type;
const float value = bmd->value;
const int mat = CLAMPIS(bmd->mat, -1, ctx->object->totcol - 1);
const bool loop_slide = (bmd->flags & MOD_BEVEL_EVEN_WIDTHS) == 0;
@@ -128,8 +131,6 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh *
const int miter_outer = bmd->miter_outer;
const int miter_inner = bmd->miter_inner;
const float spread = bmd->spread;
- const bool use_custom_profile = (bmd->flags & MOD_BEVEL_CUSTOM_PROFILE);
- const int vmesh_method = bmd->vmesh_method;
const bool invert_vgroup = (bmd->flags & MOD_BEVEL_INVERT_VGROUP) != 0;
bm = BKE_mesh_to_bmesh_ex(mesh,
@@ -150,7 +151,7 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh *
MOD_get_vgroup(ctx->object, mesh, bmd->defgrp_name, &dvert, &vgroup);
}
- if (vertex_only) {
+ if (bmd->affect_type == MOD_BEVEL_AFFECT_VERTICES) {
BM_ITER_MESH (v, &iter, bm, BM_VERTS_OF_MESH) {
if (bmd->lim_flags & MOD_BEVEL_WEIGHT) {
weight = BM_elem_float_data_get(&bm->vdata, v, CD_BWEIGHT);
@@ -225,9 +226,10 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh *
BM_mesh_bevel(bm,
value,
offset_type,
+ profile_type,
bmd->res,
bmd->profile,
- vertex_only,
+ bmd->affect_type,
bmd->lim_flags & MOD_BEVEL_WEIGHT,
do_clamp,
dvert,
@@ -242,9 +244,8 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh *
miter_inner,
spread,
mesh->smoothresh,
- use_custom_profile,
bmd->custom_profile,
- vmesh_method);
+ bmd->vmesh_method);
result = BKE_mesh_from_bmesh_for_eval_nomain(bm, NULL, mesh);
@@ -277,48 +278,38 @@ static bool isDisabled(const Scene *UNUSED(scene), ModifierData *md, bool UNUSED
static void panel_draw(const bContext *C, Panel *panel)
{
- uiLayout *col;
+ uiLayout *col, *sub;
uiLayout *layout = panel->layout;
PointerRNA ptr;
PointerRNA ob_ptr;
modifier_panel_get_property_pointers(C, panel, &ob_ptr, &ptr);
+ bool edge_bevel = RNA_enum_get(&ptr, "affect") != MOD_BEVEL_AFFECT_VERTICES;
+
+ uiItemR(layout, &ptr, "affect", UI_ITEM_R_EXPAND, NULL, ICON_NONE);
+
uiLayoutSetPropSep(layout, true);
col = uiLayoutColumn(layout, false);
- const char *offset_name = "";
+ uiItemR(col, &ptr, "offset_type", 0, NULL, ICON_NONE);
if (RNA_enum_get(&ptr, "offset_type") == BEVEL_AMT_PERCENT) {
uiItemR(col, &ptr, "width_pct", 0, NULL, ICON_NONE);
}
else {
- switch (RNA_enum_get(&ptr, "offset_type")) {
- case BEVEL_AMT_DEPTH:
- offset_name = "Depth";
- break;
- case BEVEL_AMT_WIDTH:
- offset_name = "Width";
- break;
- case BEVEL_AMT_OFFSET:
- offset_name = "Offset";
- break;
- }
- uiItemR(col, &ptr, "width", 0, IFACE_(offset_name), ICON_NONE);
+ uiItemR(col, &ptr, "width", 0, IFACE_("Amount"), ICON_NONE);
}
- uiItemR(col, &ptr, "offset_type", 0, NULL, ICON_NONE);
uiItemR(layout, &ptr, "segments", 0, NULL, ICON_NONE);
uiItemS(layout);
- uiItemR(layout, &ptr, "affect", UI_ITEM_R_EXPAND, NULL, ICON_NONE);
-
- uiItemS(layout);
-
col = uiLayoutColumn(layout, false);
uiItemR(col, &ptr, "limit_method", 0, NULL, ICON_NONE);
int limit_method = RNA_enum_get(&ptr, "limit_method");
if (limit_method == MOD_BEVEL_ANGLE) {
+ sub = uiLayoutColumn(col, false);
+ uiLayoutSetActive(sub, edge_bevel);
uiItemR(col, &ptr, "angle_limit", 0, NULL, ICON_NONE);
}
else if (limit_method == MOD_BEVEL_VGROUP) {
@@ -328,25 +319,78 @@ static void panel_draw(const bContext *C, Panel *panel)
modifier_panel_end(layout, &ptr);
}
+static void profile_panel_draw(const bContext *C, Panel *panel)
+{
+ uiLayout *row;
+ uiLayout *layout = panel->layout;
+
+ PointerRNA ptr;
+ modifier_panel_get_property_pointers(C, panel, NULL, &ptr);
+
+ int profile_type = RNA_enum_get(&ptr, "profile_type");
+ int miter_inner = RNA_enum_get(&ptr, "miter_inner");
+ int miter_outer = RNA_enum_get(&ptr, "miter_outer");
+ bool edge_bevel = RNA_enum_get(&ptr, "affect") != MOD_BEVEL_AFFECT_VERTICES;
+
+ uiItemR(layout, &ptr, "profile_type", UI_ITEM_R_EXPAND, NULL, ICON_NONE);
+
+ uiLayoutSetPropSep(layout, true);
+
+ if (ELEM(profile_type, MOD_BEVEL_PROFILE_SUPERELLIPSE, MOD_BEVEL_PROFILE_CUSTOM)) {
+ row = uiLayoutRow(layout, false);
+ uiLayoutSetActive(
+ row,
+ profile_type == MOD_BEVEL_PROFILE_SUPERELLIPSE ||
+ (profile_type == MOD_BEVEL_PROFILE_CUSTOM && edge_bevel &&
+ !((miter_inner == MOD_BEVEL_MITER_SHARP) && (miter_outer == MOD_BEVEL_MITER_SHARP))));
+ uiItemR(row,
+ &ptr,
+ "profile",
+ UI_ITEM_R_SLIDER,
+ (profile_type == MOD_BEVEL_PROFILE_SUPERELLIPSE) ? IFACE_("Shape") :
+ IFACE_("Miter Shape"),
+ ICON_NONE);
+
+ if (profile_type == MOD_BEVEL_PROFILE_CUSTOM) {
+ uiLayout *sub = uiLayoutColumn(layout, false);
+ uiLayoutSetPropDecorate(sub, false);
+ uiTemplateCurveProfile(sub, &ptr, "custom_profile");
+ }
+ }
+}
+
static void geometry_panel_draw(const bContext *C, Panel *panel)
{
+ uiLayout *row;
uiLayout *layout = panel->layout;
PointerRNA ptr;
modifier_panel_get_property_pointers(C, panel, NULL, &ptr);
+ bool edge_bevel = RNA_enum_get(&ptr, "affect") != MOD_BEVEL_AFFECT_VERTICES;
+
uiLayoutSetPropSep(layout, true);
- uiItemR(layout, &ptr, "miter_inner", 0, IFACE_("Miter Inner"), ICON_NONE);
- uiItemR(layout, &ptr, "miter_outer", 0, IFACE_("Outer"), ICON_NONE);
+ row = uiLayoutRow(layout, false);
+ uiLayoutSetActive(row, edge_bevel);
+ uiItemR(row, &ptr, "miter_outer", 0, IFACE_("Miter Outer"), ICON_NONE);
+ row = uiLayoutRow(layout, false);
+ uiLayoutSetActive(row, edge_bevel);
+ uiItemR(row, &ptr, "miter_inner", 0, IFACE_("Inner"), ICON_NONE);
if (RNA_enum_get(&ptr, "miter_inner") == BEVEL_MITER_ARC) {
- uiItemR(layout, &ptr, "spread", 0, NULL, ICON_NONE);
+ row = uiLayoutRow(layout, false);
+ uiLayoutSetActive(row, edge_bevel);
+ uiItemR(row, &ptr, "spread", 0, NULL, ICON_NONE);
}
uiItemS(layout);
- uiItemR(layout, &ptr, "vmesh_method", 0, IFACE_("Intersections"), ICON_NONE);
+ row = uiLayoutRow(layout, false);
+ uiLayoutSetActive(row, edge_bevel);
+ uiItemR(row, &ptr, "vmesh_method", 0, IFACE_("Intersections"), ICON_NONE);
uiItemR(layout, &ptr, "use_clamp_overlap", 0, NULL, ICON_NONE);
- uiItemR(layout, &ptr, "loop_slide", 0, NULL, ICON_NONE);
+ row = uiLayoutRow(layout, false);
+ uiLayoutSetActive(row, edge_bevel);
+ uiItemR(row, &ptr, "loop_slide", 0, NULL, ICON_NONE);
}
static void shading_panel_draw(const bContext *C, Panel *panel)
@@ -357,11 +401,14 @@ static void shading_panel_draw(const bContext *C, Panel *panel)
PointerRNA ptr;
modifier_panel_get_property_pointers(C, panel, NULL, &ptr);
+ bool edge_bevel = RNA_enum_get(&ptr, "affect") != MOD_BEVEL_AFFECT_VERTICES;
+
uiLayoutSetPropSep(layout, true);
uiItemR(layout, &ptr, "harden_normals", 0, NULL, ICON_NONE);
col = uiLayoutColumnWithHeading(layout, true, IFACE_("Mark"));
+ uiLayoutSetActive(col, edge_bevel);
uiItemR(col, &ptr, "mark_seam", 0, IFACE_("Seam"), ICON_NONE);
uiItemR(col, &ptr, "mark_sharp", 0, IFACE_("Sharp"), ICON_NONE);
@@ -369,53 +416,34 @@ static void shading_panel_draw(const bContext *C, Panel *panel)
uiItemR(layout, &ptr, "face_strength_mode", 0, NULL, ICON_NONE);
}
-static void profile_panel_draw(const bContext *C, Panel *panel)
+static void panelRegister(ARegionType *region_type)
{
- PointerRNA ptr;
- modifier_panel_get_property_pointers(C, panel, NULL, &ptr);
- uiLayout *layout = panel->layout;
-
- uiLayoutSetPropSep(layout, true);
-
- uiItemR(layout, &ptr, "profile", UI_ITEM_R_SLIDER, IFACE_("Shape"), ICON_NONE);
+ PanelType *panel_type = modifier_panel_register(region_type, eModifierType_Bevel, panel_draw);
+ modifier_subpanel_register(
+ region_type, "profile", "Profile", NULL, profile_panel_draw, panel_type);
+ modifier_subpanel_register(
+ region_type, "geometry", "Geometry", NULL, geometry_panel_draw, panel_type);
+ modifier_subpanel_register(
+ region_type, "shading", "Shading", NULL, shading_panel_draw, panel_type);
}
-static void custom_profile_panel_draw_header(const bContext *C, Panel *panel)
+static void blendWrite(BlendWriter *writer, const ModifierData *md)
{
- uiLayout *layout = panel->layout;
+ const BevelModifierData *bmd = (const BevelModifierData *)md;
- PointerRNA ptr;
- modifier_panel_get_property_pointers(C, panel, NULL, &ptr);
-
- uiItemR(layout, &ptr, "use_custom_profile", 0, NULL, ICON_NONE);
+ if (bmd->custom_profile) {
+ BKE_curveprofile_blend_write(writer, bmd->custom_profile);
+ }
}
-static void custom_profile_panel_draw(const bContext *C, Panel *panel)
+static void blendRead(BlendDataReader *reader, ModifierData *md)
{
- PointerRNA ptr;
- modifier_panel_get_property_pointers(C, panel, NULL, &ptr);
- uiLayout *layout = panel->layout;
-
- uiLayoutSetActive(layout, RNA_boolean_get(&ptr, "use_custom_profile"));
-
- uiTemplateCurveProfile(layout, &ptr, "custom_profile");
-}
+ BevelModifierData *bmd = (BevelModifierData *)md;
-static void panelRegister(ARegionType *region_type)
-{
- PanelType *panel_type = modifier_panel_register(region_type, eModifierType_Bevel, panel_draw);
- PanelType *bevel_profil_panel = modifier_subpanel_register(
- region_type, "profile", "Profile", NULL, profile_panel_draw, panel_type);
- modifier_subpanel_register(region_type,
- "custom",
- "",
- custom_profile_panel_draw_header,
- custom_profile_panel_draw,
- bevel_profil_panel);
- modifier_subpanel_register(
- region_type, "geometry", "Geometry", NULL, geometry_panel_draw, panel_type);
- modifier_subpanel_register(
- region_type, "shading", "Shading", NULL, shading_panel_draw, panel_type);
+ BLO_read_data_address(reader, &bmd->custom_profile);
+ if (bmd->custom_profile) {
+ BKE_curveprofile_blend_read(reader, bmd->custom_profile);
+ }
}
ModifierTypeInfo modifierType_Bevel = {
@@ -446,4 +474,6 @@ ModifierTypeInfo modifierType_Bevel = {
/* foreachTexLink */ NULL,
/* freeRuntimeData */ NULL,
/* uiPanel */ panelRegister,
+ /* blendWrite */ blendWrite,
+ /* blendRead */ blendRead,
};