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>2019-01-23 12:36:52 +0300
committerAntonioya <blendergit@gmail.com>2019-01-23 12:37:08 +0300
commit9ff73e61b1a3c825fec5c2daffbe017c6cd7377d (patch)
treec6f689cb76aa56a77ba52fa625549037c9d7a6ad /source/blender/gpencil_modifiers
parentbaa5fe1bfcdecc6a2697c2629dae6ff24e217877 (diff)
Fix T60778: Grease pencil Hook modifieronly affects strokes with more than 2 points
Also fixed Lattice and Noise modifier.
Diffstat (limited to 'source/blender/gpencil_modifiers')
-rw-r--r--source/blender/gpencil_modifiers/intern/MOD_gpencilhook.c2
-rw-r--r--source/blender/gpencil_modifiers/intern/MOD_gpencillattice.c2
-rw-r--r--source/blender/gpencil_modifiers/intern/MOD_gpencilnoise.c33
3 files changed, 25 insertions, 12 deletions
diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpencilhook.c b/source/blender/gpencil_modifiers/intern/MOD_gpencilhook.c
index 97f260f307f..06cdbfcbbce 100644
--- a/source/blender/gpencil_modifiers/intern/MOD_gpencilhook.c
+++ b/source/blender/gpencil_modifiers/intern/MOD_gpencilhook.c
@@ -210,7 +210,7 @@ static void deformStroke(
if (!is_stroke_affected_by_modifier(
ob,
- mmd->layername, mmd->pass_index, mmd->layer_pass, 3, gpl, gps,
+ mmd->layername, mmd->pass_index, mmd->layer_pass, 1, gpl, gps,
mmd->flag & GP_HOOK_INVERT_LAYER, mmd->flag & GP_HOOK_INVERT_PASS,
mmd->flag & GP_HOOK_INVERT_LAYERPASS))
{
diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpencillattice.c b/source/blender/gpencil_modifiers/intern/MOD_gpencillattice.c
index 1d8f2c20b59..c938446a623 100644
--- a/source/blender/gpencil_modifiers/intern/MOD_gpencillattice.c
+++ b/source/blender/gpencil_modifiers/intern/MOD_gpencillattice.c
@@ -83,7 +83,7 @@ static void deformStroke(
if (!is_stroke_affected_by_modifier(
ob,
- mmd->layername, mmd->pass_index, mmd->layer_pass, 3, gpl, gps,
+ mmd->layername, mmd->pass_index, mmd->layer_pass, 1, gpl, gps,
mmd->flag & GP_LATTICE_INVERT_LAYER, mmd->flag & GP_LATTICE_INVERT_PASS,
mmd->flag & GP_LATTICE_INVERT_LAYERPASS))
{
diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpencilnoise.c b/source/blender/gpencil_modifiers/intern/MOD_gpencilnoise.c
index e25908d2d01..94f83f10fb5 100644
--- a/source/blender/gpencil_modifiers/intern/MOD_gpencilnoise.c
+++ b/source/blender/gpencil_modifiers/intern/MOD_gpencilnoise.c
@@ -96,8 +96,8 @@ static bool dependsOnTime(GpencilModifierData *md)
/* aply noise effect based on stroke direction */
static void deformStroke(
- GpencilModifierData *md, Depsgraph *depsgraph,
- Object *ob, bGPDlayer *gpl, bGPDstroke *gps)
+ GpencilModifierData *md, Depsgraph *depsgraph,
+ Object *ob, bGPDlayer *gpl, bGPDstroke *gps)
{
NoiseGpencilModifierData *mmd = (NoiseGpencilModifierData *)md;
bGPDspoint *pt0, *pt1;
@@ -108,6 +108,7 @@ static void deformStroke(
int sc_frame = 0;
int sc_diff = 0;
const int def_nr = defgroup_name_index(ob, mmd->vgname);
+ const float unit_v3[3] = { 1.0f, 1.0f, 1.0f };
/* Random generator, only init once. */
if (mmd->rng == NULL) {
@@ -117,10 +118,10 @@ static void deformStroke(
}
if (!is_stroke_affected_by_modifier(
- ob,
- mmd->layername, mmd->pass_index, mmd->layer_pass, 3, gpl, gps,
- mmd->flag & GP_NOISE_INVERT_LAYER, mmd->flag & GP_NOISE_INVERT_PASS,
- mmd->flag & GP_NOISE_INVERT_LAYERPASS))
+ ob,
+ mmd->layername, mmd->pass_index, mmd->layer_pass, 1, gpl, gps,
+ mmd->flag & GP_NOISE_INVERT_LAYER, mmd->flag & GP_NOISE_INVERT_PASS,
+ mmd->flag & GP_NOISE_INVERT_LAYERPASS))
{
return;
}
@@ -130,7 +131,12 @@ static void deformStroke(
zero_v3(vec2);
/* calculate stroke normal*/
- BKE_gpencil_stroke_normal(gps, normal);
+ if (gps->totpoints > 2) {
+ BKE_gpencil_stroke_normal(gps, normal);
+ }
+ else {
+ copy_v3_v3(normal, unit_v3);
+ }
/* move points */
for (int i = 0; i < gps->totpoints; i++) {
@@ -143,7 +149,7 @@ static void deformStroke(
if (gps->dvert) {
dvert = &gps->dvert[0];
}
- pt0 = &gps->points[1];
+ pt0 = (gps->totpoints > 1) ? &gps->points[1] : &gps->points[0];
pt1 = &gps->points[0];
}
else {
@@ -174,7 +180,7 @@ static void deformStroke(
sc_diff = abs(mmd->scene_frame - sc_frame);
/* only recalc if the gp frame change or the number of scene frames is bigger than step */
if ((!gpl->actframe) || (mmd->gp_frame != gpl->actframe->framenum) ||
- (sc_diff >= mmd->step))
+ (sc_diff >= mmd->step))
{
vran = mmd->vrand1 = BLI_rng_get_float(mmd->rng);
vdir = mmd->vrand2 = BLI_rng_get_float(mmd->rng);
@@ -203,7 +209,14 @@ static void deformStroke(
mmd->gp_frame = -999999;
}
- /* apply randomness to location of the point */
+ /* if vec2 is zero, set to something */
+ if (gps->totpoints < 3) {
+ if ((vec2[0] == 0.0f) && (vec2[1] == 0.0f) && (vec2[2] == 0.0f)) {
+ copy_v3_v3(vec2, unit_v3);
+ }
+ }
+
+ /* apply randomness to location of the point */
if (mmd->flag & GP_NOISE_MOD_LOCATION) {
/* factor is too sensitive, so need divide */
shift = ((vran * mmd->factor) / 1000.0f) * weight;