[Bf-blender-cvs] [90e46ae] master: Optional randomization factors for the spiral radius and axis orientation.

Lukas Tönne noreply at git.blender.org
Tue Jan 20 09:53:40 CET 2015


Commit: 90e46ae6c007b30f1b2d124a5561ec4fbbf35bdf
Author: Lukas Tönne
Date:   Tue Jan 13 19:41:25 2015 +0100
Branches: master
https://developer.blender.org/rB90e46ae6c007b30f1b2d124a5561ec4fbbf35bdf

Optional randomization factors for the spiral radius and axis orientation.

===================================================================

M	release/scripts/startup/bl_ui/properties_particle.py
M	source/blender/blenkernel/intern/particle_child.c
M	source/blender/makesdna/DNA_particle_types.h
M	source/blender/makesrna/intern/rna_particle.c

===================================================================

diff --git a/release/scripts/startup/bl_ui/properties_particle.py b/release/scripts/startup/bl_ui/properties_particle.py
index 0bf7926..fe40973 100644
--- a/release/scripts/startup/bl_ui/properties_particle.py
+++ b/release/scripts/startup/bl_ui/properties_particle.py
@@ -1232,8 +1232,12 @@ class PARTICLE_PT_children(ParticleButtonsPanel, Panel):
 
         if part.kink in {'SPIRAL'}:
             col = split.column()
-            col.prop(part, "kink_amplitude", text="Radius")
-            col.prop(part, "kink_axis")
+            sub = col.column(align=True)
+            sub.prop(part, "kink_amplitude", text="Radius")
+            sub.prop(part, "kink_amplitude_random", text="Random", slider=True)
+            sub = col.column(align=True)
+            sub.prop(part, "kink_axis")
+            sub.prop(part, "kink_axis_random", text="Random", slider=True)
             col = split.column(align=True)
             col.prop(part, "kink_frequency", text="Frequency")
             col.prop(part, "kink_shape", text="Shape", slider=True)
diff --git a/source/blender/blenkernel/intern/particle_child.c b/source/blender/blenkernel/intern/particle_child.c
index 589f4ce..79ae34f 100644
--- a/source/blender/blenkernel/intern/particle_child.c
+++ b/source/blender/blenkernel/intern/particle_child.c
@@ -175,12 +175,15 @@ static void do_kink_spiral(ParticleThreadContext *ctx, ParticleTexture *ptex, co
                            ParticleCacheKey *keys, int *r_totkeys, float *r_max_length)
 {
 	struct ParticleSettings *part = ctx->sim.psys->part;
+	const int seed = ctx->sim.psys->child_seed + (int)(cpa - ctx->sim.psys->child);
 	const int totkeys = ctx->segments + 1;
 	const int extrakeys = ctx->extra_segments;
 	
-	float kink_amp = part->kink_amp;
+	float kink_amp_random = part->kink_amp_random;
+	float kink_amp = part->kink_amp * (1.0f - kink_amp_random * psys_frand(ctx->sim.psys, 93541 + seed));
 	float kink_freq = part->kink_freq;
 	float kink_shape = part->kink_shape;
+	float kink_axis_random = part->kink_axis_random;
 	float rough1 = part->rough1;
 	float rough2 = part->rough2;
 	float rough_end = part->rough_end;
@@ -244,6 +247,14 @@ static void do_kink_spiral(ParticleThreadContext *ctx, ParticleTexture *ptex, co
 			sub_v3_v3v3(kink, kink_base, tmp);
 			normalize_v3(kink);
 			
+			if (kink_axis_random > 0.0f) {
+				float a = kink_axis_random * (psys_frand(ctx->sim.psys, 7112 + seed) * 2.0f - 1.0f) * M_PI;
+				float rot[3][3];
+				
+				axis_angle_normalized_to_mat3(rot, dir, a);
+				mul_m3_v3(rot, kink);
+			}
+			
 			do_kink_spiral_deform((ParticleKey *)key, dir, kink, spiral_time, kink_freq, kink_shape, kink_amp, spiral_start);
 		}
 		
diff --git a/source/blender/makesdna/DNA_particle_types.h b/source/blender/makesdna/DNA_particle_types.h
index ffe1a8d..819e310 100644
--- a/source/blender/makesdna/DNA_particle_types.h
+++ b/source/blender/makesdna/DNA_particle_types.h
@@ -219,6 +219,7 @@ typedef struct ParticleSettings {
 	float kink_amp, kink_freq, kink_shape, kink_flat;
 	float kink_amp_clump;
 	int kink_extra_steps, pad;
+	float kink_axis_random, kink_amp_random;
 	/* rough */
 	float rough1, rough1_size;
 	float rough2, rough2_size, rough2_thres;
diff --git a/source/blender/makesrna/intern/rna_particle.c b/source/blender/makesrna/intern/rna_particle.c
index d1daa7d..a687086 100644
--- a/source/blender/makesrna/intern/rna_particle.c
+++ b/source/blender/makesrna/intern/rna_particle.c
@@ -2885,6 +2885,12 @@ static void rna_def_particle_settings(BlenderRNA *brna)
 	RNA_def_property_ui_text(prop, "Amplitude Clump", "How much clump affects kink amplitude");
 	RNA_def_property_update(prop, 0, "rna_Particle_redo_child");
 
+	prop = RNA_def_property(srna, "kink_amplitude_random", PROP_FLOAT, PROP_NONE);
+	RNA_def_property_float_sdna(prop, NULL, "kink_amp_random");
+	RNA_def_property_range(prop, 0.0f, 1.0f);
+	RNA_def_property_ui_text(prop, "Amplitude Random", "Random variation of the amplitude");
+	RNA_def_property_update(prop, 0, "rna_Particle_redo_child");
+
 	prop = RNA_def_property(srna, "kink_frequency", PROP_FLOAT, PROP_NONE);
 	RNA_def_property_float_sdna(prop, NULL, "kink_freq");
 	RNA_def_property_range(prop, -100000.0f, 100000.0f);
@@ -2908,6 +2914,11 @@ static void rna_def_particle_settings(BlenderRNA *brna)
 	RNA_def_property_ui_text(prop, "Extra Steps", "Extra steps for resolution of special kink features");
 	RNA_def_property_update(prop, 0, "rna_Particle_redo_child");
 
+	prop = RNA_def_property(srna, "kink_axis_random", PROP_FLOAT, PROP_NONE);
+	RNA_def_property_range(prop, 0.0f, 1.0f);
+	RNA_def_property_ui_text(prop, "Axis Random", "Random variation of the orientation");
+	RNA_def_property_update(prop, 0, "rna_Particle_redo_child");
+
 	/* rough */
 	prop = RNA_def_property(srna, "roughness_1", PROP_FLOAT, PROP_NONE);
 	RNA_def_property_float_sdna(prop, NULL, "rough1");




More information about the Bf-blender-cvs mailing list