Commit: 9e95e65be88b5f131d26848f2d3cc7ba76417e10
Author: Lukas Tönne
Date:   Tue Jan 13 19:41:25 2015 +0100
Branches: gooseberry
https://developer.blender.org/rB9e95e65be88b5f131d26848f2d3cc7ba76417e10

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 f573f8c..6c0664a 100644
--- a/release/scripts/startup/bl_ui/properties_particle.py
+++ b/release/scripts/startup/bl_ui/properties_particle.py
@@ -1340,8 +1340,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 cb2b02a..c6376b6 100644
--- a/source/blender/makesdna/DNA_particle_types.h
+++ b/source/blender/makesdna/DNA_particle_types.h
@@ -222,6 +222,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 c2b5420..5aaee8d 100644
--- a/source/blender/makesrna/intern/rna_particle.c
+++ b/source/blender/makesrna/intern/rna_particle.c
@@ -2967,6 +2967,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);
@@ -2990,6 +2996,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");

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to