From 351f537fa832c50971454af304a071c096427e71 Mon Sep 17 00:00:00 2001 From: Antonioya Date: Sat, 15 Dec 2018 17:21:47 +0100 Subject: GP: New Curve primitive and other primitive improvements This commit adds support for new curve tool and adds more functionalities to the existing primitives, including new handles, editing, stroke thickness curve, noise, preview of the real stroke, etc. Thanks to @charlie for his great contribution to this improvement. --- source/blender/blenkernel/intern/colortools.c | 11 +++++++++++ source/blender/blenkernel/intern/scene.c | 12 ++++++++++++ 2 files changed, 23 insertions(+) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/colortools.c b/source/blender/blenkernel/intern/colortools.c index aad59e32187..bc34b24c8f2 100644 --- a/source/blender/blenkernel/intern/colortools.c +++ b/source/blender/blenkernel/intern/colortools.c @@ -283,6 +283,7 @@ void curvemap_reset(CurveMap *cuma, const rctf *clipr, int preset, int slope) case CURVE_PRESET_ROUND: cuma->totpoint = 4; break; case CURVE_PRESET_ROOT: cuma->totpoint = 4; break; case CURVE_PRESET_GAUSS: cuma->totpoint = 7; break; + case CURVE_PRESET_BELL: cuma->totpoint = 3; break; } cuma->curve = MEM_callocN(cuma->totpoint * sizeof(CurveMapPoint), "curve points"); @@ -371,6 +372,16 @@ void curvemap_reset(CurveMap *cuma, const rctf *clipr, int preset, int slope) cuma->curve[6].x = 1.0f; cuma->curve[6].y = 0.025f; break; + case CURVE_PRESET_BELL: + cuma->curve[0].x = 0; + cuma->curve[0].y = 0.025f; + + cuma->curve[1].x = 0.50f; + cuma->curve[1].y = 1.0f; + + cuma->curve[2].x = 1.0f; + cuma->curve[2].y = 0.025f; + break; } /* mirror curve in x direction to have positive slope diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c index a070bf97317..3894d83c169 100644 --- a/source/blender/blenkernel/intern/scene.c +++ b/source/blender/blenkernel/intern/scene.c @@ -188,6 +188,7 @@ ToolSettings *BKE_toolsettings_copy(ToolSettings *toolsettings, const int flag) ts->gp_interpolate.custom_ipo = curvemapping_copy(ts->gp_interpolate.custom_ipo); /* duplicate Grease Pencil multiframe fallof */ ts->gp_sculpt.cur_falloff = curvemapping_copy(ts->gp_sculpt.cur_falloff); + ts->gp_sculpt.cur_primitive = curvemapping_copy(ts->gp_sculpt.cur_primitive); return ts; } @@ -226,6 +227,9 @@ void BKE_toolsettings_free(ToolSettings *toolsettings) if (toolsettings->gp_sculpt.cur_falloff) { curvemapping_free(toolsettings->gp_sculpt.cur_falloff); } + if (toolsettings->gp_sculpt.cur_primitive) { + curvemapping_free(toolsettings->gp_sculpt.cur_primitive); + } MEM_freeN(toolsettings); } @@ -699,6 +703,14 @@ void BKE_scene_init(Scene *sce) CURVE_PRESET_GAUSS, CURVEMAP_SLOPE_POSITIVE); + sce->toolsettings->gp_sculpt.cur_primitive = curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f); + CurveMapping *gp_primitive_curve = sce->toolsettings->gp_sculpt.cur_primitive; + curvemapping_initialize(gp_primitive_curve); + curvemap_reset(gp_primitive_curve->cm, + &gp_primitive_curve->clipr, + CURVE_PRESET_BELL, + CURVEMAP_SLOPE_POSITIVE); + sce->physics_settings.gravity[0] = 0.0f; sce->physics_settings.gravity[1] = 0.0f; sce->physics_settings.gravity[2] = -9.81f; -- cgit v1.2.3