diff options
author | Hans Goudey <h.goudey@me.com> | 2020-09-16 18:20:38 +0300 |
---|---|---|
committer | Hans Goudey <h.goudey@me.com> | 2020-09-16 18:20:38 +0300 |
commit | 60fa80de0b2c7138fc86b8b688f22a9d2623e8ed (patch) | |
tree | 44d7acc6bf5022866f5369a0151c513d4dfd957e /source/blender/blenkernel/intern/curve.c | |
parent | 365271a5886e1678b41e636581616446766b5f85 (diff) |
Curves: Add custom profile bevel support
This adds support for the same custom bevel profile widget used in
the bevel tool and modifier to the geometry generation for curves.
This is expecially useful for text and 2D curves with extrusion, as
it works much better than a weld & bevel modifier combination.
It can also be useful for adding quick detail to pipe-like objects.
The curve holds the CurveProfile struct and a new "Bevel Mode"
property decides which type of bevel to build, round, object, or
custom profile.
Although curves can already use another curve to make the bevel
geometry, this is a quicker way, and it also defines the profile of
just one corner of the bevel, so it isn't redundant. It's also nice
to have the same custom profile functionality wherever there is bevel.
Differential Revision: https://developer.blender.org/D8402
Diffstat (limited to 'source/blender/blenkernel/intern/curve.c')
-rw-r--r-- | source/blender/blenkernel/intern/curve.c | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/source/blender/blenkernel/intern/curve.c b/source/blender/blenkernel/intern/curve.c index 74efa45cc73..24be6708785 100644 --- a/source/blender/blenkernel/intern/curve.c +++ b/source/blender/blenkernel/intern/curve.c @@ -50,6 +50,7 @@ #include "BKE_anim_data.h" #include "BKE_curve.h" +#include "BKE_curveprofile.h" #include "BKE_displist.h" #include "BKE_font.h" #include "BKE_idtype.h" @@ -95,6 +96,8 @@ static void curve_copy_data(Main *bmain, ID *id_dst, const ID *id_src, const int curve_dst->tb = MEM_dupallocN(curve_src->tb); curve_dst->batch_cache = NULL; + curve_dst->bevel_profile = BKE_curveprofile_copy(curve_src->bevel_profile); + if (curve_src->key && (flag & LIB_ID_COPY_SHAPEKEY)) { BKE_id_copy_ex(bmain, &curve_src->key->id, (ID **)&curve_dst->key, flag); /* XXX This is not nice, we need to make BKE_id_copy_ex fully re-entrant... */ @@ -116,6 +119,8 @@ static void curve_free_data(ID *id) BKE_curve_editNurb_free(curve); + BKE_curveprofile_free(curve->bevel_profile); + MEM_SAFE_FREE(curve->mat); MEM_SAFE_FREE(curve->str); MEM_SAFE_FREE(curve->strinfo); @@ -181,6 +186,10 @@ static void curve_blend_write(BlendWriter *writer, ID *id, const void *id_addres } } } + + if (cu->bevel_profile != NULL) { + BKE_curveprofile_blend_write(writer, cu->bevel_profile); + } } } } @@ -251,6 +260,11 @@ static void curve_blend_read_data(BlendDataReader *reader, ID *id) } } cu->texflag &= ~CU_AUTOSPACE_EVALUATED; + + BLO_read_data_address(reader, &cu->bevel_profile); + if (cu->bevel_profile != NULL) { + BKE_curveprofile_blend_read(reader, cu->bevel_profile); + } } static void curve_blend_read_lib(BlendLibReader *reader, ID *id) @@ -397,6 +411,7 @@ void BKE_curve_init(Curve *cu, const short curve_type) else if (cu->type == OB_SURF) { cu->resolv = 4; } + cu->bevel_profile = NULL; } Curve *BKE_curve_add(Main *bmain, const char *name, int type) |