[Bf-blender-cvs] [2202b9f] temp_merge_gooseberry_hair: Use separate flags to enable/disable clump and roughness curves for child hairs.

Lukas Tönne noreply at git.blender.org
Mon Jan 19 20:52:17 CET 2015


Commit: 2202b9f06aa826b2ba17426a445237c9860f9545
Author: Lukas Tönne
Date:   Mon Jan 19 13:32:53 2015 +0100
Branches: temp_merge_gooseberry_hair
https://developer.blender.org/rB2202b9f06aa826b2ba17426a445237c9860f9545

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

This allows disabling the curves temporarily without losing the setup.

Conflicts:
	source/blender/blenkernel/BKE_blender.h

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

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 4c333c8..8cd4e25 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         272
-#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 5bee342..efa3258 100644
--- a/source/blender/blenkernel/intern/particle.c
+++ b/source/blender/blenkernel/intern/particle.c
@@ -1753,6 +1753,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;
@@ -1820,10 +1822,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;
@@ -1835,7 +1837,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);
 		}
 		
@@ -2040,9 +2042,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 3238b6c..7196f16 100644
--- a/source/blender/blenloader/intern/versioning_270.c
+++ b/source/blender/blenloader/intern/versioning_270.c
@@ -483,4 +483,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 4f8b14a..0440819 100644
--- a/source/blender/makesdna/DNA_particle_types.h
+++ b/source/blender/makesdna/DNA_particle_types.h
@@ -428,9 +428,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 b69ede9..36444b2 100644
--- a/source/blender/makesrna/intern/rna_particle.c
+++ b/source/blender/makesrna/intern/rna_particle.c
@@ -877,50 +877,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)
@@ -2859,9 +2839,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");
@@ -2979,9 +2959,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");




More information about the Bf-blender-cvs mailing list