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:
authorAntonioya <blendergit@gmail.com>2018-08-30 12:06:44 +0300
committerAntonioya <blendergit@gmail.com>2018-08-30 12:11:47 +0300
commit0845b1c8c8da818607fcff0a1bdb2114a0cb9729 (patch)
tree42bcb0ce5d58457985edb14723ce874c9d226f18 /source/blender/gpencil_modifiers
parent3071d67c3aeba4e5bec73f88b24eed972424dae0 (diff)
GP: Improve Subdivide and Simplify
Now the weights are managed in the operators. The subdivide operator and modifier code have been replaced with a shared function. Some cleanup also.
Diffstat (limited to 'source/blender/gpencil_modifiers')
-rw-r--r--source/blender/gpencil_modifiers/intern/MOD_gpencilsubdiv.c94
1 files changed, 10 insertions, 84 deletions
diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpencilsubdiv.c b/source/blender/gpencil_modifiers/intern/MOD_gpencilsubdiv.c
index dba3e028904..3ba53250abd 100644
--- a/source/blender/gpencil_modifiers/intern/MOD_gpencilsubdiv.c
+++ b/source/blender/gpencil_modifiers/intern/MOD_gpencilsubdiv.c
@@ -24,9 +24,9 @@
*
*/
-/** \file blender/gpencil_modifiers/intern/MOD_gpencilsubdiv.c
- * \ingroup modifiers
- */
+ /** \file blender/gpencil_modifiers/intern/MOD_gpencilsubdiv.c
+ * \ingroup modifiers
+ */
#include <stdio.h>
@@ -65,98 +65,24 @@ static void copyData(const GpencilModifierData *md, GpencilModifierData *target)
/* subdivide stroke to get more control points */
static void deformStroke(
- GpencilModifierData *md, Depsgraph *UNUSED(depsgraph),
- Object *ob, bGPDlayer *gpl, bGPDstroke *gps)
+ GpencilModifierData *md, Depsgraph *UNUSED(depsgraph),
+ Object *ob, bGPDlayer *gpl, bGPDstroke *gps)
{
SubdivGpencilModifierData *mmd = (SubdivGpencilModifierData *)md;
- bGPDspoint *temp_points;
- int totnewpoints, oldtotpoints;
- int i2;
if (!is_stroke_affected_by_modifier(ob,
- mmd->layername, mmd->pass_index, 3, gpl, gps,
- mmd->flag & GP_SUBDIV_INVERT_LAYER, mmd->flag & GP_SUBDIV_INVERT_PASS))
+ mmd->layername, mmd->pass_index, 3, gpl, gps,
+ mmd->flag & GP_SUBDIV_INVERT_LAYER, mmd->flag & GP_SUBDIV_INVERT_PASS))
{
return;
}
- /* loop as many times as levels */
- for (int s = 0; s < mmd->level; s++) {
- totnewpoints = gps->totpoints - 1;
- /* duplicate points in a temp area */
- temp_points = MEM_dupallocN(gps->points);
- oldtotpoints = gps->totpoints;
-
- /* resize the points arrys */
- gps->totpoints += totnewpoints;
- gps->points = MEM_recallocN(gps->points, sizeof(*gps->points) * gps->totpoints);
- gps->dvert = MEM_recallocN(gps->dvert, sizeof(*gps->dvert) * gps->totpoints);
- gps->flag |= GP_STROKE_RECALC_CACHES;
-
- /* move points from last to first to new place */
- i2 = gps->totpoints - 1;
- for (int i = oldtotpoints - 1; i > 0; i--) {
- bGPDspoint *pt = &temp_points[i];
- bGPDspoint *pt_final = &gps->points[i2];
-
- MDeformVert *dvert = &gps->dvert[i];
- MDeformVert *dvert_final = &gps->dvert[i2];
-
- copy_v3_v3(&pt_final->x, &pt->x);
- pt_final->pressure = pt->pressure;
- pt_final->strength = pt->strength;
- pt_final->time = pt->time;
- pt_final->flag = pt->flag;
-
- dvert_final->totweight = dvert->totweight;
- dvert_final->dw = dvert->dw;
- i2 -= 2;
- }
- /* interpolate mid points */
- i2 = 1;
- for (int i = 0; i < oldtotpoints - 1; i++) {
- bGPDspoint *pt = &temp_points[i];
- bGPDspoint *next = &temp_points[i + 1];
- bGPDspoint *pt_final = &gps->points[i2];
- MDeformVert *dvert_final = &gps->dvert[i2];
-
- /* add a half way point */
- interp_v3_v3v3(&pt_final->x, &pt->x, &next->x, 0.5f);
- pt_final->pressure = interpf(pt->pressure, next->pressure, 0.5f);
- pt_final->strength = interpf(pt->strength, next->strength, 0.5f);
- CLAMP(pt_final->strength, GPENCIL_STRENGTH_MIN, 1.0f);
- pt_final->time = interpf(pt->time, next->time, 0.5f);
-
- dvert_final->totweight = 0;
- dvert_final->dw = NULL;
- i2 += 2;
- }
-
- MEM_SAFE_FREE(temp_points);
-
- /* move points to smooth stroke (not simple flag )*/
- if ((mmd->flag & GP_SUBDIV_SIMPLE) == 0) {
- /* duplicate points in a temp area with the new subdivide data */
- temp_points = MEM_dupallocN(gps->points);
-
- /* extreme points are not changed */
- for (int i = 0; i < gps->totpoints - 2; i++) {
- bGPDspoint *pt = &temp_points[i];
- bGPDspoint *next = &temp_points[i + 1];
- bGPDspoint *pt_final = &gps->points[i + 1];
-
- /* move point */
- interp_v3_v3v3(&pt_final->x, &pt->x, &next->x, 0.5f);
- }
- /* free temp memory */
- MEM_SAFE_FREE(temp_points);
- }
- }
+ BKE_gpencil_subdivide(gps, mmd->level, mmd->flag);
}
static void bakeModifier(
- struct Main *UNUSED(bmain), Depsgraph *depsgraph,
- GpencilModifierData *md, Object *ob)
+ struct Main *UNUSED(bmain), Depsgraph *depsgraph,
+ GpencilModifierData *md, Object *ob)
{
bGPdata *gpd = ob->data;