GPencil Array - Add option for uniform random scaling
This patch adds the option to make the random scaling from the grease pencil array modifier uniform. The current settings allow a separate value for each of the 3 scaling axis. The modifier also creates different seed values for each axis so there is no way to keep the random scaling uniform. This patch creates 1 random seed value and applies it to each of the scaling axis. Here is a demonstration of the previous behavior and the new optional behavior. {F9485973} {F9485981} {F9485798} Reviewed By: #grease_pencil, antoniov, pepeland Differential Revision: https://developer.blender.org/D9764
This commit is contained in:
parent
9e4a4c2e99
commit
5535b0b887
|
@ -237,9 +237,17 @@ static void generate_geometry(GpencilModifierData *md,
|
|||
/* To ensure a nice distribution, we use halton sequence and offset using the seed. */
|
||||
BLI_halton_3d(primes, offset, x, r);
|
||||
|
||||
for (int i = 0; i < 3; i++) {
|
||||
rand[j][i] = fmodf(r[i] * 2.0 - 1.0 + rand_offset, 1.0f);
|
||||
rand[j][i] = fmodf(sin(rand[j][i] * 12.9898 + j * 78.233) * 43758.5453, 1.0f);
|
||||
if ((mmd->flag & GP_ARRAY_UNIFORM_RANDOM_SCALE) && j == 2) {
|
||||
float rand_value;
|
||||
rand_value = fmodf(r[0] * 2.0 - 1.0 + rand_offset, 1.0f);
|
||||
rand_value = fmodf(sin(rand_value * 12.9898 + j * 78.233) * 43758.5453, 1.0f);
|
||||
copy_v3_fl(rand[j] , rand_value);
|
||||
}
|
||||
else {
|
||||
for (int i = 0; i < 3; i++) {
|
||||
rand[j][i] = fmodf(r[i] * 2.0 - 1.0 + rand_offset, 1.0f);
|
||||
rand[j][i] = fmodf(sin(rand[j][i] * 12.9898 + j * 78.233) * 43758.5453, 1.0f);
|
||||
}
|
||||
}
|
||||
}
|
||||
/* Calculate Random matrix. */
|
||||
|
@ -425,6 +433,7 @@ static void random_panel_draw(const bContext *UNUSED(C), Panel *panel)
|
|||
uiItemR(layout, ptr, "random_offset", 0, IFACE_("Offset"), ICON_NONE);
|
||||
uiItemR(layout, ptr, "random_rotation", 0, IFACE_("Rotation"), ICON_NONE);
|
||||
uiItemR(layout, ptr, "random_scale", 0, IFACE_("Scale"), ICON_NONE);
|
||||
uiItemR(layout, ptr, "use_uniform_random_scale", 0, NULL, ICON_NONE);
|
||||
uiItemR(layout, ptr, "seed", 0, NULL, ICON_NONE);
|
||||
}
|
||||
|
||||
|
|
|
@ -351,6 +351,7 @@ typedef enum eArrayGpencil_Flag {
|
|||
GP_ARRAY_USE_OFFSET = (1 << 7),
|
||||
GP_ARRAY_USE_RELATIVE = (1 << 8),
|
||||
GP_ARRAY_USE_OB_OFFSET = (1 << 9),
|
||||
GP_ARRAY_UNIFORM_RANDOM_SCALE = (1 << 10),
|
||||
} eArrayGpencil_Flag;
|
||||
|
||||
typedef struct BuildGpencilModifierData {
|
||||
|
|
|
@ -1560,6 +1560,11 @@ static void rna_def_modifier_gpencilarray(BlenderRNA *brna)
|
|||
RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_ARRAY_USE_RELATIVE);
|
||||
RNA_def_property_ui_text(prop, "Shift", "Enable shift");
|
||||
RNA_def_property_update(prop, 0, "rna_GpencilModifier_update");
|
||||
|
||||
prop = RNA_def_property(srna, "use_uniform_random_scale", PROP_BOOLEAN, PROP_NONE);
|
||||
RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_ARRAY_UNIFORM_RANDOM_SCALE);
|
||||
RNA_def_property_ui_text(prop, "Uniform Scale", "Use the same random seed for each scale axis for a uniform scale");
|
||||
RNA_def_property_update(prop, 0, "rna_GpencilModifier_update");
|
||||
}
|
||||
|
||||
static void rna_def_modifier_gpencilbuild(BlenderRNA *brna)
|
||||
|
|
Loading…
Reference in New Issue