diff options
author | Antonio Vazquez <blendergit@gmail.com> | 2021-07-03 18:33:13 +0300 |
---|---|---|
committer | Antonio Vazquez <blendergit@gmail.com> | 2021-07-03 18:41:12 +0300 |
commit | b73dc36859e03845f702a3e985b536ac9afef63a (patch) | |
tree | 53c125edc4dd49c879a3d6b06bd92ba078c15449 /source/blender/gpencil_modifiers | |
parent | 9b89de2571b0c3fa2276b5c2ae589e0ec831d1f5 (diff) |
GPencil: Add weight factor to Offset randomize
Now, The weight is used in the randomize parameters of the offset modifier.
This is useful to generate effects like explosions.
Related to the new Vertex Weight modifiers.
Diffstat (limited to 'source/blender/gpencil_modifiers')
-rw-r--r-- | source/blender/gpencil_modifiers/intern/MOD_gpenciloffset.c | 23 |
1 files changed, 15 insertions, 8 deletions
diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpenciloffset.c b/source/blender/gpencil_modifiers/intern/MOD_gpenciloffset.c index cd29a006aae..1a38b91a18b 100644 --- a/source/blender/gpencil_modifiers/intern/MOD_gpenciloffset.c +++ b/source/blender/gpencil_modifiers/intern/MOD_gpenciloffset.c @@ -129,14 +129,6 @@ static void deformStroke(GpencilModifierData *md, } } } - /* Calculate Random matrix. */ - float mat_rnd[4][4]; - float rnd_loc[3], rnd_rot[3]; - float rnd_scale[3] = {1.0f, 1.0f, 1.0f}; - mul_v3_v3v3(rnd_loc, mmd->rnd_offset, rand[0]); - mul_v3_v3v3(rnd_rot, mmd->rnd_rot, rand[1]); - madd_v3_v3v3(rnd_scale, mmd->rnd_scale, rand[2]); - loc_eul_size_to_mat4(mat_rnd, rnd_loc, rnd_rot, rnd_scale); bGPdata *gpd = ob->data; @@ -150,6 +142,21 @@ static void deformStroke(GpencilModifierData *md, if (weight < 0.0f) { continue; } + + /* Calculate Random matrix. */ + float mat_rnd[4][4]; + float rnd_loc[3], rnd_rot[3], rnd_scale_weight[3]; + float rnd_scale[3] = {1.0f, 1.0f, 1.0f}; + + mul_v3_v3fl(rnd_loc, rand[0], weight); + mul_v3_v3fl(rnd_rot, rand[1], weight); + mul_v3_v3fl(rnd_scale_weight, rand[2], weight); + + mul_v3_v3v3(rnd_loc, mmd->rnd_offset, rnd_loc); + mul_v3_v3v3(rnd_rot, mmd->rnd_rot, rnd_rot); + madd_v3_v3v3(rnd_scale, mmd->rnd_scale, rnd_scale_weight); + + loc_eul_size_to_mat4(mat_rnd, rnd_loc, rnd_rot, rnd_scale); /* Apply randomness matrix. */ mul_m4_v3(mat_rnd, &pt->x); |