Commit: c55d20b3017e5279766de3a05d1ffc03034da162
Author: Lukas Tönne
Date:   Mon Jan 19 13:32:53 2015 +0100
Branches: gooseberry
https://developer.blender.org/rBc55d20b3017e5279766de3a05d1ffc03034da162

Use separate flags to enable/disable clump and roughness curves for
child hairs.

This allows disabling the curves temporarily without losing the setup.

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

M       source/blender/blenkernel/BKE_blender.h
M       source/blender/blenkernel/intern/particle.c
M       source/blender/blenkernel/intern/particle_child.c
M       source/blender/blenloader/intern/versioning_270.c
M       source/blender/makesdna/DNA_particle_types.h
M       source/blender/makesrna/intern/rna_particle.c

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

diff --git a/source/blender/blenkernel/BKE_blender.h 
b/source/blender/blenkernel/BKE_blender.h
index 0215bec..3053c99 100644
--- a/source/blender/blenkernel/BKE_blender.h
+++ b/source/blender/blenkernel/BKE_blender.h
@@ -42,7 +42,7 @@ extern "C" {
  * and keep comment above the defines.
  * Use STRINGIFY() rather than defining with quotes */
 #define BLENDER_VERSION         273
-#define BLENDER_SUBVERSION      2
+#define BLENDER_SUBVERSION      3
 /* 262 was the last editmesh release but it has compatibility code for bmesh 
data */
 #define BLENDER_MINVERSION      270
 #define BLENDER_MINSUBVERSION   5
diff --git a/source/blender/blenkernel/intern/particle.c 
b/source/blender/blenkernel/intern/particle.c
index 22ce12b..c5bd232 100644
--- a/source/blender/blenkernel/intern/particle.c
+++ b/source/blender/blenkernel/intern/particle.c
@@ -1786,6 +1786,8 @@ void precalc_guides(ParticleSimulationData *sim, ListBase 
*effectors)
 
 int do_guides(ParticleSettings *part, ListBase *effectors, ParticleKey *state, 
int index, float time)
 {
+       CurveMapping *clumpcurve = (part->child_flag & 
PART_CHILD_USE_CLUMP_CURVE) ? part->clumpcurve : NULL;
+       CurveMapping *roughcurve = (part->child_flag & 
PART_CHILD_USE_ROUGH_CURVE) ? part->roughcurve : NULL;
        EffectorCache *eff;
        PartDeflect *pd;
        Curve *cu;
@@ -1853,10 +1855,10 @@ int do_guides(ParticleSettings *part, ListBase 
*effectors, ParticleKey *state, i
                        }
                }
                
-               if (part->clumpcurve)
-                       curvemapping_changed_all(part->clumpcurve);
-               if (part->roughcurve)
-                       curvemapping_changed_all(part->roughcurve);
+               if (clumpcurve)
+                       curvemapping_changed_all(clumpcurve);
+               if (roughcurve)
+                       curvemapping_changed_all(roughcurve);
                
                {
                        ParticleKey key;
@@ -1868,7 +1870,7 @@ 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, part->clumpcurve);
+                                part->child_flag & PART_CHILD_USE_CLUMP_NOISE, 
part->clump_noise_size, clumpcurve);
                        copy_v3_v3(vec_to_point, key.co);
                }
                
@@ -2073,9 +2075,9 @@ static bool 
psys_thread_context_init_path(ParticleThreadContext *ctx, ParticleSi
                ctx->vg_effector = psys_cache_vgroup(ctx->dm, psys, 
PSYS_VG_EFFECTOR);
 
        /* prepare curvemapping tables */
-       if (part->clumpcurve)
+       if ((part->child_flag & PART_CHILD_USE_CLUMP_CURVE) && part->clumpcurve)
                curvemapping_changed_all(part->clumpcurve);
-       if (part->roughcurve)
+       if ((part->child_flag & PART_CHILD_USE_ROUGH_CURVE) && part->roughcurve)
                curvemapping_changed_all(part->roughcurve);
 
        return true;
diff --git a/source/blender/blenkernel/intern/particle_child.c 
b/source/blender/blenkernel/intern/particle_child.c
index fb877e4..df03f39 100644
--- a/source/blender/blenkernel/intern/particle_child.c
+++ b/source/blender/blenkernel/intern/particle_child.c
@@ -661,6 +661,8 @@ void do_child_modifiers(ParticleSimulationData *sim, 
ParticleTexture *ptex, cons
                         ChildParticle *cpa, const float orco[3], float 
mat[4][4], ParticleKey *state, float t)
 {
        ParticleSettings *part = sim->psys->part;
+       CurveMapping *clumpcurve = (part->child_flag & 
PART_CHILD_USE_CLUMP_CURVE) ? part->clumpcurve : NULL;
+       CurveMapping *roughcurve = (part->child_flag & 
PART_CHILD_USE_ROUGH_CURVE) ? part->roughcurve : NULL;
        int i = cpa - sim->psys->child;
        int guided = 0;
 
@@ -690,7 +692,7 @@ 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, part->clumpcurve);
+                                part->child_flag & PART_CHILD_USE_CLUMP_NOISE, 
part->clump_noise_size, clumpcurve);
 
                if (kink_freq != 0.f) {
                        kink_amp *= (1.f - kink_amp_clump * clump);
@@ -702,7 +704,7 @@ void do_child_modifiers(ParticleSimulationData *sim, 
ParticleTexture *ptex, cons
        }
 
        if (part->roughcurve) {
-               do_rough_curve(orco, mat, t, rough1, part->rough1_size, 
part->roughcurve, state);
+               do_rough_curve(orco, mat, t, rough1, part->rough1_size, 
roughcurve, state);
        }
        else {
                if (rough1 > 0.f)
diff --git a/source/blender/blenloader/intern/versioning_270.c 
b/source/blender/blenloader/intern/versioning_270.c
index ca54f06..4bedcc6 100644
--- a/source/blender/blenloader/intern/versioning_270.c
+++ b/source/blender/blenloader/intern/versioning_270.c
@@ -535,4 +535,14 @@ void blo_do_versions_270(FileData *fd, Library 
*UNUSED(lib), Main *main)
                        }
                }
        }
+
+       if (!MAIN_VERSION_ATLEAST(main, 273, 3)) {
+               ParticleSettings *part;
+               for (part = main->particle.first; part; part = part->id.next) {
+                       if (part->clumpcurve)
+                               part->child_flag |= PART_CHILD_USE_CLUMP_CURVE;
+                       if (part->roughcurve)
+                               part->child_flag |= PART_CHILD_USE_ROUGH_CURVE;
+               }
+       }
 }
diff --git a/source/blender/makesdna/DNA_particle_types.h 
b/source/blender/makesdna/DNA_particle_types.h
index d0455a4..a289487 100644
--- a/source/blender/makesdna/DNA_particle_types.h
+++ b/source/blender/makesdna/DNA_particle_types.h
@@ -436,9 +436,11 @@ typedef enum eParticleKink {
        PART_KINK_SPIRAL        = 5,
 } eParticleKink;
 
-/* part->kink_flag */
+/* part->child_flag */
 typedef enum eParticleChildFlag {
-       PART_CHILD_USE_CLUMP_NOISE  = 1,
+       PART_CHILD_USE_CLUMP_NOISE  = (1<<0),
+       PART_CHILD_USE_CLUMP_CURVE  = (1<<1),
+       PART_CHILD_USE_ROUGH_CURVE  = (1<<2),
 } eParticleChildFlag;
 
 /* part->draw_col */
diff --git a/source/blender/makesrna/intern/rna_particle.c 
b/source/blender/makesrna/intern/rna_particle.c
index 4ecfe34..a5ed3ff 100644
--- a/source/blender/makesrna/intern/rna_particle.c
+++ b/source/blender/makesrna/intern/rna_particle.c
@@ -959,50 +959,30 @@ static int rna_PartSettings_is_fluid_get(PointerRNA *ptr)
        return part->type == PART_FLUID;
 }
 
-int rna_ParticleSettings_use_clump_curve_get(PointerRNA *ptr)
-{
-       ParticleSettings *part = ptr->data;
-       return part->clumpcurve != NULL;
-}
-
-void rna_ParticleSettings_use_clump_curve_set(PointerRNA *ptr, int value)
+static void rna_ParticleSettings_use_clump_curve_update(Main *bmain, Scene 
*scene, PointerRNA *ptr)
 {
        ParticleSettings *part = ptr->data;
        
-       if (!value) {
-               if (part->clumpcurve) {
-                       curvemapping_free(part->clumpcurve);
-                       part->clumpcurve = NULL;
-               }
-       }
-       else {
+       if (part->child_flag & PART_CHILD_USE_CLUMP_CURVE) {
                if (!part->clumpcurve) {
                        BKE_particlesettings_clump_curve_init(part);
                }
        }
+       
+       rna_Particle_redo_child(bmain, scene, ptr);
 }
 
-int rna_ParticleSettings_use_roughness_curve_get(PointerRNA *ptr)
-{
-       ParticleSettings *part = ptr->data;
-       return part->roughcurve != NULL;
-}
-
-void rna_ParticleSettings_use_roughness_curve_set(PointerRNA *ptr, int value)
+static void rna_ParticleSettings_use_roughness_curve_update(Main *bmain, Scene 
*scene, PointerRNA *ptr)
 {
        ParticleSettings *part = ptr->data;
        
-       if (!value) {
-               if (part->roughcurve) {
-                       curvemapping_free(part->roughcurve);
-                       part->roughcurve = NULL;
-               }
-       }
-       else {
+       if (part->child_flag & PART_CHILD_USE_ROUGH_CURVE) {
                if (!part->roughcurve) {
                        BKE_particlesettings_rough_curve_init(part);
                }
        }
+       
+       rna_Particle_redo_child(bmain, scene, ptr);
 }
 
 static void rna_ParticleSystem_name_set(PointerRNA *ptr, const char *value)
@@ -2941,9 +2921,9 @@ static void rna_def_particle_settings(BlenderRNA *brna)
        RNA_def_property_update(prop, 0, "rna_Particle_redo_child");
 
        prop = RNA_def_property(srna, "use_clump_curve", PROP_BOOLEAN, 
PROP_NONE);
-       RNA_def_property_boolean_funcs(prop, 
"rna_ParticleSettings_use_clump_curve_get", 
"rna_ParticleSettings_use_clump_curve_set");
+       RNA_def_property_boolean_sdna(prop, NULL, "child_flag", 
PART_CHILD_USE_CLUMP_CURVE);
        RNA_def_property_ui_text(prop, "Use Clump Curve", "Use a curve to 
define clump tapering");
-       RNA_def_property_update(prop, 0, "rna_Particle_redo_child");
+       RNA_def_property_update(prop, 0, 
"rna_ParticleSettings_use_clump_curve_update");
 
        prop = RNA_def_property(srna, "clump_curve", PROP_POINTER, PROP_NONE);
        RNA_def_property_pointer_sdna(prop, NULL, "clumpcurve");
@@ -3061,9 +3041,9 @@ static void rna_def_particle_settings(BlenderRNA *brna)
        RNA_def_property_update(prop, 0, "rna_Particle_redo_child");
 
        prop = RNA_def_property(srna, "use_roughness_curve", PROP_BOOLEAN, 
PROP_NONE);
-       RNA_def_property_boolean_funcs(prop, 
"rna_ParticleSettings_use_roughness_curve_get", 
"rna_ParticleSettings_use_roughness_curve_set");
+       RNA_def_property_boolean_sdna(prop, NULL, "child_flag", 
PART_CHILD_USE_ROUGH_CURVE);
        RNA_def_property_ui_text(prop, "Use Roughness Curve", "Use a curve to 
define roughness");
-       RNA_def_property_update(prop, 0, "rna_Particle_redo_child");
+       RNA_def_property_update(prop, 0, 
"rna_ParticleSettings_use_roughness_curve_update");
 
        prop = RNA_def_property(srna, "roughness_curve", PROP_POINTER, 
PROP_NONE);
        RNA_def_property_pointer_sdna(prop, NULL, "roughcurve");

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

Reply via email to