Optional randomization factors for the spiral radius and axis orientation.
authorLukas Tönne <lukas.toenne@gmail.com>
Tue, 13 Jan 2015 18:41:25 +0000 (19:41 +0100)
committerLukas Tönne <lukas.toenne@gmail.com>
Tue, 20 Jan 2015 08:30:10 +0000 (09:30 +0100)
release/scripts/startup/bl_ui/properties_particle.py
source/blender/blenkernel/intern/particle_child.c
source/blender/makesdna/DNA_particle_types.h
source/blender/makesrna/intern/rna_particle.c

index 0bf79261f3af3021669e84292e715361741d977d..fe40973e3e320dc17d547d54ffb66a0810006ec4 100644 (file)
@@ -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)
index 589f4cef30e475e7239001f796527e52da328e93..79ae34f702a4bfe2e26a3182407be7490f9e4b54 100644 (file)
@@ -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);
                }
                
index ffe1a8dba05f51ca45bf862b744755cbd3b9b05b..819e3109d6dd90d0ec74a54ad2e637ad318a3014 100644 (file)
@@ -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;
index d1daa7d651dcaae9d5895a1f9e8dc37436fd127d..a687086e4806158fa74fcaf035ca7afa821ae97d 100644 (file)
@@ -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");