Commit: 322cf7cf4e2445d4048ee3c2e763ce44d3a144d5
Author: Lukas Tönne
Date:   Tue Feb 3 18:33:22 2015 +0100
Branches: gooseberry
https://developer.blender.org/rB322cf7cf4e2445d4048ee3c2e763ce44d3a144d5

More roughness options for offsetting child clumping.

This is obviously total madness, this feature is totally unusable when
the coder is not sitting next to you ... But so are the rest of particle
settings, the only solution is a future node system.

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

M       release/scripts/startup/bl_ui/properties_particle.py
M       source/blender/blenkernel/intern/particle.c
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 dfa6999..6a902c0 100644
--- a/release/scripts/startup/bl_ui/properties_particle.py
+++ b/release/scripts/startup/bl_ui/properties_particle.py
@@ -1334,6 +1334,9 @@ class PARTICLE_PT_children(ParticleButtonsPanel, Panel):
         subsub = sub.column()
         subsub.enabled = part.use_clump_noise
         subsub.prop(part, "clump_noise_size")
+        subsubsub = subsub.column(align=True)
+        subsubsub.prop(part, "clump_noise_random_size")
+        subsubsub.prop(part, "clump_noise_random")
 
         sub = col.column(align=True)
         sub.prop(part, "child_length", slider=True)
diff --git a/source/blender/blenkernel/intern/particle.c 
b/source/blender/blenkernel/intern/particle.c
index 7cf4eef..3ffc05f 100644
--- a/source/blender/blenkernel/intern/particle.c
+++ b/source/blender/blenkernel/intern/particle.c
@@ -1363,7 +1363,7 @@ void psys_particle_on_emitter(ParticleSystemModifierData 
*psmd, int from, int in
 extern void do_kink(ParticleKey *state, const float par_co[3], const float 
par_vel[3], const float par_rot[4], float time, float freq, float shape, float 
amplitude, float flat,
                     short type, short axis, float obmat[4][4], int 
smooth_start);
 extern float do_clump(ParticleKey *state, const float par_co[3], float time, 
const float orco_offset[3], float clumpfac, float clumppow, float pa_clump,
-                      bool use_clump_noise, float clump_noise_size, 
CurveMapping *clumpcurve);
+                      bool use_clump_noise, float clump_noise_size, 
CurveMapping *clumpcurve, float clump_noise_random, float 
clump_noise_random_size, float mat[4][4]);
 
 void precalc_guides(ParticleSimulationData *sim, ListBase *effectors)
 {
@@ -1492,7 +1492,8 @@ int do_guides(ParticleSettings *part, ListBase 
*effectors, ParticleKey *state, i
                        copy_v3_v3(key.co, vec_to_point);
                        do_kink(&key, par_co, par_vel, par_rot, guidetime, 
pd->kink_freq, pd->kink_shape, pd->kink_amp, 0.f, pd->kink, pd->kink_axis, 0, 
0);
                        do_clump(&key, par_co, guidetime, orco_offset, 
pd->clump_fac, pd->clump_pow, 1.0f,
-                                part->child_flag & PART_CHILD_USE_CLUMP_NOISE, 
part->clump_noise_size, clumpcurve);
+                                part->child_flag & PART_CHILD_USE_CLUMP_NOISE, 
part->clump_noise_size, clumpcurve,
+                                part->clump_noise_random, 
part->clump_noise_random_size, NULL);
                        copy_v3_v3(vec_to_point, key.co);
                }
                
diff --git a/source/blender/blenkernel/intern/particle_child.c 
b/source/blender/blenkernel/intern/particle_child.c
index 33541c3..966107e 100644
--- a/source/blender/blenkernel/intern/particle_child.c
+++ b/source/blender/blenkernel/intern/particle_child.c
@@ -42,7 +42,7 @@ struct Material;
 void do_kink(ParticleKey *state, const float par_co[3], const float 
par_vel[3], const float par_rot[4], float time, float freq, float shape, float 
amplitude, float flat,
              short type, short axis, float obmat[4][4], int smooth_start);
 float do_clump(ParticleKey *state, const float par_co[3], float time, const 
float orco_offset[3], float clumpfac, float clumppow, float pa_clump,
-               bool use_clump_noise, float clump_noise_size, CurveMapping 
*clumpcurve);
+               bool use_clump_noise, float clump_noise_size, CurveMapping 
*clumpcurve, float clump_noise_random, float clump_noise_random_size, float 
mat[4][4]);
 void do_child_modifiers(ParticleSimulationData *sim,
                         ParticleTexture *ptex, const float par_co[3], const 
float par_vel[3], const float par_rot[4], const float par_orco[3],
                         ChildParticle *cpa, const float orco[3], float 
mat[4][4], ParticleKey *state, float t);
@@ -578,10 +578,27 @@ static float do_clump_level(float result[3], const float 
co[3], const float par_
        return clump;
 }
 
+BLI_INLINE void simple_roughness(float mat[4][4], float size, float factor, 
const float loc[3], float time, float result[3])
+{
+       float turbloc[3], rough[3];
+       
+       mul_v3_v3fl(turbloc, loc, time);
+       rough[0] = -1.0f + 2.0f * BLI_gTurbulence(size, turbloc[0], turbloc[1], 
turbloc[2], 2, 0, 2);
+       rough[1] = -1.0f + 2.0f * BLI_gTurbulence(size, turbloc[1], turbloc[2], 
turbloc[0], 2, 0, 2);
+       rough[2] = -1.0f + 2.0f * BLI_gTurbulence(size, turbloc[2], turbloc[0], 
turbloc[1], 2, 0, 2);
+
+       madd_v3_v3fl(result, mat[0], factor * rough[0]);
+       madd_v3_v3fl(result, mat[1], factor * rough[1]);
+       madd_v3_v3fl(result, mat[2], factor * rough[2]);
+}
+
 float do_clump(ParticleKey *state, const float par_co[3], float time, const 
float orco_offset[3], float clumpfac, float clumppow, float pa_clump,
-               bool use_clump_noise, float clump_noise_size, CurveMapping 
*clumpcurve)
+               bool use_clump_noise, float clump_noise_size, CurveMapping 
*clumpcurve, float clump_noise_random, float clump_noise_random_size, float 
mat[4][4])
 {
        float clump;
+       float rough_offset[3];
+       
+       zero_v3(rough_offset);
        
        if (use_clump_noise && clump_noise_size != 0.0f) {
                float center[3], noisevec[3];
@@ -592,34 +609,31 @@ float do_clump(ParticleKey *state, const float par_co[3], 
float time, const floa
                mul_v3_fl(&pa[0], clump_noise_size);
                add_v3_v3v3(center, par_co, &pa[0]);
                
+               if (clump_noise_random != 0.0f && mat) {
+                       simple_roughness(mat, clump_noise_random_size, 
clump_noise_random, center, 1.0f, rough_offset);
+               }
+               
                do_clump_level(state->co, state->co, center, time, clumpfac, 
clumppow, pa_clump, clumpcurve);
        }
        
        clump = do_clump_level(state->co, state->co, par_co, time, clumpfac, 
clumppow, pa_clump, clumpcurve);
        
+       if (use_clump_noise && clump_noise_size != 0.0f && clump_noise_random 
!= 0.0f && mat) {
+               add_v3_v3(state->co, rough_offset);
+       }
+       
        return clump;
 }
 
 static void do_rough(const float loc[3], float mat[4][4], float t, float fac, 
float size, float thres, ParticleKey *state)
 {
-       float rough[3];
-       float rco[3];
-
        if (thres != 0.0f) {
                if (fabsf((float)(-1.5f + loc[0] + loc[1] + loc[2])) < 1.5f * 
thres) {
                        return;
                }
        }
 
-       copy_v3_v3(rco, loc);
-       mul_v3_fl(rco, t);
-       rough[0] = -1.0f + 2.0f * BLI_gTurbulence(size, rco[0], rco[1], rco[2], 
2, 0, 2);
-       rough[1] = -1.0f + 2.0f * BLI_gTurbulence(size, rco[1], rco[2], rco[0], 
2, 0, 2);
-       rough[2] = -1.0f + 2.0f * BLI_gTurbulence(size, rco[2], rco[0], rco[1], 
2, 0, 2);
-
-       madd_v3_v3fl(state->co, mat[0], fac * rough[0]);
-       madd_v3_v3fl(state->co, mat[1], fac * rough[1]);
-       madd_v3_v3fl(state->co, mat[2], fac * rough[2]);
+       simple_roughness(mat, size, fac, loc, t, state->co);
 }
 
 static void do_rough_end(const float loc[3], float mat[4][4], float t, float 
fac, float shape, ParticleKey *state)
@@ -639,23 +653,12 @@ static void do_rough_end(const float loc[3], float 
mat[4][4], float t, float fac
 
 static void do_rough_curve(const float loc[3], float mat[4][4], float time, 
float fac, float size, CurveMapping *roughcurve, ParticleKey *state)
 {
-       float rough[3];
-       float rco[3];
-       
        if (!roughcurve)
                return;
        
        fac *= CLAMPIS(curvemapping_evaluateF(roughcurve, 0, time), 0.0f, 1.0f);
        
-       copy_v3_v3(rco, loc);
-       mul_v3_fl(rco, time);
-       rough[0] = -1.0f + 2.0f * BLI_gTurbulence(size, rco[0], rco[1], rco[2], 
2, 0, 2);
-       rough[1] = -1.0f + 2.0f * BLI_gTurbulence(size, rco[1], rco[2], rco[0], 
2, 0, 2);
-       rough[2] = -1.0f + 2.0f * BLI_gTurbulence(size, rco[2], rco[0], rco[1], 
2, 0, 2);
-       
-       madd_v3_v3fl(state->co, mat[0], fac * rough[0]);
-       madd_v3_v3fl(state->co, mat[1], fac * rough[1]);
-       madd_v3_v3fl(state->co, mat[2], fac * rough[2]);
+       simple_roughness(mat, size, fac, loc, time, state->co);
 }
 
 void do_child_modifiers(ParticleSimulationData *sim, ParticleTexture *ptex, 
const float par_co[3], const float par_vel[3], const float par_rot[4], const 
float par_orco[3],
@@ -693,7 +696,8 @@ void do_child_modifiers(ParticleSimulationData *sim, 
ParticleTexture *ptex, cons
                
                sub_v3_v3v3(orco_offset, orco, par_orco);
                clump = do_clump(state, par_co, t, orco_offset, part->clumpfac, 
part->clumppow, ptex ? ptex->clump : 1.f,
-                                part->child_flag & PART_CHILD_USE_CLUMP_NOISE, 
part->clump_noise_size, clumpcurve);
+                                part->child_flag & PART_CHILD_USE_CLUMP_NOISE, 
part->clump_noise_size, clumpcurve,
+                                part->clump_noise_random, 
part->clump_noise_random_size, mat);
 
                if (kink_freq != 0.f) {
                        kink_amp *= (1.f - kink_amp_clump * clump);
diff --git a/source/blender/makesdna/DNA_particle_types.h 
b/source/blender/makesdna/DNA_particle_types.h
index f551d9e..0994db8 100644
--- a/source/blender/makesdna/DNA_particle_types.h
+++ b/source/blender/makesdna/DNA_particle_types.h
@@ -244,6 +244,7 @@ typedef struct ParticleSettings {
        struct CurveMapping *clumpcurve;
        struct CurveMapping *roughcurve;
        float clump_noise_size;
+       float clump_noise_random, clump_noise_random_size;
 
        /* hair dynamics */
        float bending_random;
diff --git a/source/blender/makesrna/intern/rna_particle.c 
b/source/blender/makesrna/intern/rna_particle.c
index 99981ee..c387672 100644
--- a/source/blender/makesrna/intern/rna_particle.c
+++ b/source/blender/makesrna/intern/rna_particle.c
@@ -2934,6 +2934,20 @@ static void rna_def_particle_settings(BlenderRNA *brna)
        RNA_def_property_ui_text(prop, "Clump Noise Size", "Size of clump 
noise");
        RNA_def_property_update(prop, 0, "rna_Particle_redo_child");
 
+       prop = RNA_def_property(srna, "clump_noise_random", PROP_FLOAT, 
PROP_NONE);
+       RNA_def_property_float_sdna(prop, NULL, "clump_noise_random");
+       RNA_def_property_range(prop, -100000.0f, 100000.0f);
+       RNA_def_property_ui_range(prop, 0.0f, 10.0f, 0.1f, 3);
+       RNA_def_property_ui_text(prop, "Clump Noise Random", "Random offset of 
clump noise");
+       RNA_def_property_update(prop, 0, "rna_Particle_redo_child");
+
+       prop = RNA_def_property(srna, "clump_noise_random_size", PROP_FLOAT, 
PROP_NONE);
+       RNA_def_property_float_sdna(prop, NULL, "clump_noise_random_size");
+       RNA_def_property_range(prop, 0.00001f, 100000.0f);
+       RNA_def_property_ui_range(prop, 0.01f, 10.0f, 0.1f, 3);
+       RNA_def_property_ui_text(prop, "Clump Noise Random Size", "Size of 
clump noise offset");
+       RNA_def_property_update(prop, 0, "rna_Particle_redo_child");
+
        /* kink */
        prop = RNA_def_property(srna, "kink_

@@ Diff output truncated at 10240 characters. @@

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

Reply via email to