diff options
author | Hans Goudey <h.goudey@me.com> | 2019-11-21 00:12:32 +0300 |
---|---|---|
committer | Hans Goudey <h.goudey@me.com> | 2019-11-21 00:25:28 +0300 |
commit | ba1e9ae4733ae956331c7e8899f6939997205298 (patch) | |
tree | 007362ed2c9ee4564b67404f552906d6e66848db /source/blender/blenloader | |
parent | 8c6ce742391b2b8798143a4a2c2224ebbeb7f1ec (diff) |
Bevel: Custom Profile and CurveProfile Widget
Custom profiles in bevel allows the profile curve to be controlled by
manually placed control points. Orientation is regularized along
groups of edges, and the 'pipe case' is updated. This commit includes
many updates to comments and changed variable names as well.
A 'cutoff' vertex mesh method is added to bevel in addition to the
existing grid fill option for replacing vertices.
The UI of the bevel modifier and tool are updated and unified.
Also, a 'CurveProfile' widget is added to BKE for defining the profile
in the interface, which may be useful in other situations.
Many thanks to Howard, my mentor for this GSoC project.
Reviewers: howardt, campbellbarton
Differential Revision: https://developer.blender.org/D5516
Diffstat (limited to 'source/blender/blenloader')
-rw-r--r-- | source/blender/blenloader/intern/readfile.c | 29 | ||||
-rw-r--r-- | source/blender/blenloader/intern/versioning_280.c | 27 | ||||
-rw-r--r-- | source/blender/blenloader/intern/versioning_defaults.c | 7 | ||||
-rw-r--r-- | source/blender/blenloader/intern/writefile.c | 17 |
4 files changed, 80 insertions, 0 deletions
diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index 167917f7b6a..f6c1cd0380a 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -74,6 +74,7 @@ #include "DNA_object_types.h" #include "DNA_packedFile_types.h" #include "DNA_particle_types.h" +#include "DNA_curveprofile_types.h" #include "DNA_lightprobe_types.h" #include "DNA_rigidbody_types.h" #include "DNA_text_types.h" @@ -132,6 +133,7 @@ #include "BKE_paint.h" #include "BKE_particle.h" #include "BKE_pointcache.h" +#include "BKE_curveprofile.h" #include "BKE_report.h" #include "BKE_scene.h" #include "BKE_screen.h" @@ -2698,6 +2700,19 @@ static void direct_link_curvemapping(FileData *fd, CurveMapping *cumap) /** \} */ /* -------------------------------------------------------------------- */ +/** \name Read CurveProfile + * \{ */ + +static void direct_link_curveprofile(FileData *fd, CurveProfile *profile) +{ + profile->path = newdataadr(fd, profile->path); + profile->table = NULL; + profile->segments = NULL; +} + +/** \} */ + +/* -------------------------------------------------------------------- */ /** \name Read ID: Brush * \{ */ @@ -5802,6 +5817,13 @@ static void direct_link_modifiers(FileData *fd, ListBase *lb) } } } + else if (md->type == eModifierType_Bevel) { + BevelModifierData *bmd = (BevelModifierData *)md; + bmd->custom_profile = newdataadr(fd, bmd->custom_profile); + if (bmd->custom_profile) { + direct_link_curveprofile(fd, bmd->custom_profile); + } + } } } @@ -6758,6 +6780,13 @@ static void direct_link_scene(FileData *fd, Scene *sce) if (sce->toolsettings->gp_sculpt.cur_primitive) { direct_link_curvemapping(fd, sce->toolsettings->gp_sculpt.cur_primitive); } + + /* Relink toolsettings curve profile */ + sce->toolsettings->custom_bevel_profile_preset = newdataadr( + fd, sce->toolsettings->custom_bevel_profile_preset); + if (sce->toolsettings->custom_bevel_profile_preset) { + direct_link_curveprofile(fd, sce->toolsettings->custom_bevel_profile_preset); + } } if (sce->ed) { diff --git a/source/blender/blenloader/intern/versioning_280.c b/source/blender/blenloader/intern/versioning_280.c index 50363e3f42a..761424a5879 100644 --- a/source/blender/blenloader/intern/versioning_280.c +++ b/source/blender/blenloader/intern/versioning_280.c @@ -36,6 +36,7 @@ #include "DNA_cloth_types.h" #include "DNA_collection_types.h" #include "DNA_constraint_types.h" +#include "DNA_curveprofile_types.h" #include "DNA_gpu_types.h" #include "DNA_light_types.h" #include "DNA_layer_types.h" @@ -74,6 +75,7 @@ #include "BKE_node.h" #include "BKE_paint.h" #include "BKE_pointcache.h" +#include "BKE_curveprofile.h" #include "BKE_report.h" #include "BKE_rigidbody.h" #include "BKE_screen.h" @@ -3932,10 +3934,35 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain) { /* Versioning code until next subversion bump goes here. */ + for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) { for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) { sa->flag &= ~AREA_FLAG_UNUSED_6; } } + + /* Add custom curve profile to toolsettings for bevel tool */ + if (!DNA_struct_elem_find(fd->filesdna, "ToolSettings", "CurveProfile", "custom_profile")) { + for (Scene *scene = bmain->scenes.first; scene; scene = scene->id.next) { + ToolSettings *ts = scene->toolsettings; + if ((ts) && (ts->custom_bevel_profile_preset == NULL)) { + ts->custom_bevel_profile_preset = BKE_curveprofile_add(PROF_PRESET_LINE); + } + } + } + + /* Add custom curve profile to bevel modifier */ + if (!DNA_struct_elem_find(fd->filesdna, "BevelModifier", "CurveProfile", "custom_profile")) { + for (Object *object = bmain->objects.first; object != NULL; object = object->id.next) { + for (ModifierData *md = object->modifiers.first; md; md = md->next) { + if (md->type == eModifierType_Bevel) { + BevelModifierData *bmd = (BevelModifierData *)md; + if (!bmd->custom_profile) { + bmd->custom_profile = BKE_curveprofile_add(PROF_PRESET_LINE); + } + } + } + } + } } } diff --git a/source/blender/blenloader/intern/versioning_defaults.c b/source/blender/blenloader/intern/versioning_defaults.c index 45fb62a4ac0..05758b446ad 100644 --- a/source/blender/blenloader/intern/versioning_defaults.c +++ b/source/blender/blenloader/intern/versioning_defaults.c @@ -27,6 +27,7 @@ #include "BLI_system.h" #include "DNA_camera_types.h" +#include "DNA_curveprofile_types.h" #include "DNA_gpencil_types.h" #include "DNA_mesh_types.h" #include "DNA_object_types.h" @@ -51,6 +52,7 @@ #include "BKE_paint.h" #include "BKE_screen.h" #include "BKE_workspace.h" +#include "BKE_curveprofile.h" #include "BLO_readfile.h" @@ -324,6 +326,11 @@ static void blo_update_defaults_scene(Main *bmain, Scene *scene) copy_v2_v2(me->mloopuv[i].uv, uv_values[i]); } } + + /* Make sure that the curve profile is initialized */ + if (ts->custom_bevel_profile_preset == NULL) { + ts->custom_bevel_profile_preset = BKE_curveprofile_add(PROF_PRESET_LINE); + } } /** diff --git a/source/blender/blenloader/intern/writefile.c b/source/blender/blenloader/intern/writefile.c index 2966a030f63..3390d30ad5d 100644 --- a/source/blender/blenloader/intern/writefile.c +++ b/source/blender/blenloader/intern/writefile.c @@ -139,6 +139,7 @@ #include "DNA_workspace_types.h" #include "DNA_movieclip_types.h" #include "DNA_mask_types.h" +#include "DNA_curveprofile_types.h" #include "MEM_guardedalloc.h" // MEM_freeN #include "BLI_bitmap.h" @@ -953,6 +954,12 @@ static void write_curvemapping(WriteData *wd, CurveMapping *cumap) write_curvemapping_curves(wd, cumap); } +static void write_CurveProfile(WriteData *wd, CurveProfile *profile) +{ + writestruct(wd, DATA, CurveProfile, 1, profile); + writestruct(wd, DATA, CurveProfilePoint, profile->path_len, profile->path); +} + static void write_node_socket(WriteData *wd, bNodeSocket *sock) { /* actual socket writing */ @@ -1759,6 +1766,12 @@ static void write_modifiers(WriteData *wd, ListBase *modbase) } } } + else if (md->type == eModifierType_Bevel) { + BevelModifierData *bmd = (BevelModifierData *)md; + if (bmd->custom_profile) { + write_CurveProfile(wd, bmd->custom_profile); + } + } } } @@ -2533,6 +2546,10 @@ static void write_scene(WriteData *wd, Scene *sce) if (tos->gp_sculpt.cur_primitive) { write_curvemapping(wd, tos->gp_sculpt.cur_primitive); } + /* Write the curve profile to the file. */ + if (tos->custom_bevel_profile_preset) { + write_CurveProfile(wd, tos->custom_bevel_profile_preset); + } write_paint(wd, &tos->imapaint.paint); |