[Bf-blender-cvs] [1c8c537] gooseberry: New texture influence option for particle kink amplitude (as opposed to frequency).

Lukas Tönne noreply at git.blender.org
Wed Jan 14 12:30:03 CET 2015


Commit: 1c8c53767d12b85c376278c6049e1778e55aff90
Author: Lukas Tönne
Date:   Wed Jan 14 12:29:19 2015 +0100
Branches: gooseberry
https://developer.blender.org/rB1c8c53767d12b85c376278c6049e1778e55aff90

New texture influence option for particle kink amplitude (as opposed to
frequency).

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

M	release/scripts/startup/bl_ui/properties_texture.py
M	source/blender/blenkernel/BKE_particle.h
M	source/blender/blenkernel/intern/particle.c
M	source/blender/blenkernel/intern/particle_child.c
M	source/blender/blenkernel/intern/texture.c
M	source/blender/blenloader/intern/versioning_270.c
M	source/blender/makesdna/DNA_particle_types.h
M	source/blender/makesdna/DNA_texture_types.h
M	source/blender/makesrna/intern/rna_particle.c

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

diff --git a/release/scripts/startup/bl_ui/properties_texture.py b/release/scripts/startup/bl_ui/properties_texture.py
index f7c0408..22e3152 100644
--- a/release/scripts/startup/bl_ui/properties_texture.py
+++ b/release/scripts/startup/bl_ui/properties_texture.py
@@ -1164,6 +1164,7 @@ class TEXTURE_PT_influence(TextureSlotPanel, Panel):
             factor_but(col, "use_map_clump", "clump_factor", "Clump")
 
             col = split.column()
+            factor_but(col, "use_map_kink_amp", "kink_amp_factor", "Kink Amplitude")
             factor_but(col, "use_map_kink_freq", "kink_freq_factor", "Kink Frequency")
             factor_but(col, "use_map_rough", "rough_factor", "Rough")
 
diff --git a/source/blender/blenkernel/BKE_particle.h b/source/blender/blenkernel/BKE_particle.h
index 71e88fb..9028871 100644
--- a/source/blender/blenkernel/BKE_particle.h
+++ b/source/blender/blenkernel/BKE_particle.h
@@ -113,7 +113,7 @@ typedef struct ParticleTexture {
 	float ivel;                           /* used in reset */
 	float time, life, exist, size;        /* used in init */
 	float damp, gravity, field;           /* used in physics */
-	float length, clump, kink_freq, effector;  /* used in path caching */
+	float length, clump, kink_freq, kink_amp, effector;  /* used in path caching */
 	float rough1, rough2, roughe;         /* used in path caching */
 } ParticleTexture;
 
diff --git a/source/blender/blenkernel/intern/particle.c b/source/blender/blenkernel/intern/particle.c
index 3f73c0d..dba5f07 100644
--- a/source/blender/blenkernel/intern/particle.c
+++ b/source/blender/blenkernel/intern/particle.c
@@ -3381,7 +3381,7 @@ static void get_cpa_texture(DerivedMesh *dm, ParticleSystem *psys, ParticleSetti
 	float value, rgba[4], texvec[3];
 
 	ptex->ivel = ptex->life = ptex->exist = ptex->size = ptex->damp =
-	ptex->gravity = ptex->field = ptex->time = ptex->clump = ptex->kink_freq =
+	ptex->gravity = ptex->field = ptex->time = ptex->clump = ptex->kink_freq = ptex->kink_amp =
 	ptex->effector = ptex->rough1 = ptex->rough2 = ptex->roughe = 1.0f;
 
 	ptex->length = 1.0f - part->randlength * psys_frand(psys, child_index + 26);
@@ -3428,6 +3428,7 @@ static void get_cpa_texture(DerivedMesh *dm, ParticleSystem *psys, ParticleSetti
 
 			SET_PARTICLE_TEXTURE(PAMAP_LENGTH, ptex->length, mtex->lengthfac);
 			SET_PARTICLE_TEXTURE(PAMAP_CLUMP, ptex->clump, mtex->clumpfac);
+			SET_PARTICLE_TEXTURE(PAMAP_KINK_AMP, ptex->kink_amp, mtex->kinkampfac);
 			SET_PARTICLE_TEXTURE(PAMAP_KINK_FREQ, ptex->kink_freq, mtex->kinkfac);
 			SET_PARTICLE_TEXTURE(PAMAP_DENS, ptex->exist, mtex->padensfac);
 		}
@@ -3435,6 +3436,7 @@ static void get_cpa_texture(DerivedMesh *dm, ParticleSystem *psys, ParticleSetti
 
 	CLAMP_PARTICLE_TEXTURE_POS(PAMAP_LENGTH, ptex->length);
 	CLAMP_PARTICLE_TEXTURE_POS(PAMAP_CLUMP, ptex->clump);
+	CLAMP_PARTICLE_TEXTURE_POS(PAMAP_KINK_AMP, ptex->kink_amp);
 	CLAMP_PARTICLE_TEXTURE_POS(PAMAP_KINK_FREQ, ptex->kink_freq);
 	CLAMP_PARTICLE_TEXTURE_POS(PAMAP_ROUGH, ptex->rough1);
 	CLAMP_PARTICLE_TEXTURE_POS(PAMAP_DENS, ptex->exist);
@@ -3452,7 +3454,7 @@ void psys_get_texture(ParticleSimulationData *sim, ParticleData *pa, ParticleTex
 
 	/* initialize ptex */
 	ptex->ivel = ptex->life = ptex->exist = ptex->size = ptex->damp =
-	ptex->gravity = ptex->field = ptex->length = ptex->clump = ptex->kink_freq =
+	ptex->gravity = ptex->field = ptex->length = ptex->clump = ptex->kink_freq = ptex->kink_amp =
 	ptex->effector = ptex->rough1 = ptex->rough2 = ptex->roughe = 1.0f;
 
 	ptex->time = (float)(pa - sim->psys->particles) / (float)sim->psys->totpart;
diff --git a/source/blender/blenkernel/intern/particle_child.c b/source/blender/blenkernel/intern/particle_child.c
index d79dd91..5bc79d1 100644
--- a/source/blender/blenkernel/intern/particle_child.c
+++ b/source/blender/blenkernel/intern/particle_child.c
@@ -204,6 +204,7 @@ static void do_kink_spiral(ParticleThreadContext *ctx, ParticleTexture *ptex, co
 	float kink_base[3];
 
 	if (ptex) {
+		kink_amp *= ptex->kink_amp;
 		kink_freq *= ptex->kink_freq;
 		rough1 *= ptex->rough1;
 		rough2 *= ptex->rough2;
@@ -670,6 +671,8 @@ void do_child_modifiers(ParticleSimulationData *sim, ParticleTexture *ptex, cons
 	int i = cpa - sim->psys->child;
 	int guided = 0;
 
+	float kink_amp = part->kink_amp;
+	float kink_amp_clump = part->kink_amp_clump;
 	float kink_freq = part->kink_freq;
 	float rough1 = part->rough1;
 	float rough2 = part->rough2;
@@ -677,6 +680,7 @@ void do_child_modifiers(ParticleSimulationData *sim, ParticleTexture *ptex, cons
 	const bool smooth_start = (sim->psys->part->childtype == PART_CHILD_FACES);
 
 	if (ptex) {
+		kink_amp *= ptex->kink_amp;
 		kink_freq *= ptex->kink_freq;
 		rough1 *= ptex->rough1;
 		rough2 *= ptex->rough2;
@@ -696,13 +700,8 @@ void do_child_modifiers(ParticleSimulationData *sim, ParticleTexture *ptex, cons
 		                 part->child_flag & PART_CHILD_USE_CLUMP_NOISE, part->clump_noise_size, part->clumpcurve);
 
 		if (kink_freq != 0.f) {
-			float kink_amp;
-			/* seriously ... */
-			if (ELEM(part->kink, PART_KINK_SPIRAL))
-				kink_amp = part->kink_amp;
-			else
-				kink_amp = part->kink_amp * (1.f - part->kink_amp_clump * clump);
-
+			kink_amp *= (1.f - kink_amp_clump * clump);
+			
 			do_kink(state, par_co, par_vel, par_rot, t, kink_freq, part->kink_shape,
 			        kink_amp, part->kink_flat, part->kink, part->kink_axis,
 			        sim->ob->obmat, smooth_start);
diff --git a/source/blender/blenkernel/intern/texture.c b/source/blender/blenkernel/intern/texture.c
index dce6584..91ca21a 100644
--- a/source/blender/blenkernel/intern/texture.c
+++ b/source/blender/blenkernel/intern/texture.c
@@ -745,6 +745,7 @@ void default_mtex(MTex *mtex)
 	mtex->lengthfac = 1.0f;
 	mtex->clumpfac = 1.0f;
 	mtex->kinkfac = 1.0f;
+	mtex->kinkampfac = 1.0f;
 	mtex->roughfac = 1.0f;
 	mtex->padensfac = 1.0f;
 	mtex->lifefac = 1.0f;
diff --git a/source/blender/blenloader/intern/versioning_270.c b/source/blender/blenloader/intern/versioning_270.c
index 24e2530..ca54f06 100644
--- a/source/blender/blenloader/intern/versioning_270.c
+++ b/source/blender/blenloader/intern/versioning_270.c
@@ -522,4 +522,17 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *main)
 			part->kink_extra_steps = 4;
 		}
 	}
+
+	if (!DNA_struct_elem_find(fd->filesdna, "MTex", "float", "kinkampfac")) {
+		ParticleSettings *part;
+		for (part = main->particle.first; part; part = part->id.next) {
+			int a;
+			for (a = 0; a < MAX_MTEX; a++) {
+				MTex *mtex = part->mtex[a];
+				if (mtex) {
+					mtex->kinkampfac = 1.0f;
+				}
+			}
+		}
+	}
 }
diff --git a/source/blender/makesdna/DNA_particle_types.h b/source/blender/makesdna/DNA_particle_types.h
index 8184ab1..d0455a4 100644
--- a/source/blender/makesdna/DNA_particle_types.h
+++ b/source/blender/makesdna/DNA_particle_types.h
@@ -609,10 +609,11 @@ typedef enum eParticleTextureInfluence {
 	PAMAP_PHYSICS	= (PAMAP_FIELD | PAMAP_GRAVITY | PAMAP_DAMP),
 	/* children */
 	PAMAP_CLUMP		= (1<<7),
-	PAMAP_KINK_FREQ		= (1<<8),
+	PAMAP_KINK_FREQ	= (1<<8),
+	PAMAP_KINK_AMP	= (1<<12),
 	PAMAP_ROUGH		= (1<<9),
 	PAMAP_LENGTH	= (1<<4),
-	PAMAP_CHILD		= (PAMAP_CLUMP | PAMAP_KINK_FREQ | PAMAP_ROUGH | PAMAP_LENGTH),
+	PAMAP_CHILD		= (PAMAP_CLUMP | PAMAP_KINK_FREQ | PAMAP_KINK_AMP | PAMAP_ROUGH | PAMAP_LENGTH),
 } eParticleTextureInfluence;
 
 #endif
diff --git a/source/blender/makesdna/DNA_texture_types.h b/source/blender/makesdna/DNA_texture_types.h
index 78e3aeb..af6adbe 100644
--- a/source/blender/makesdna/DNA_texture_types.h
+++ b/source/blender/makesdna/DNA_texture_types.h
@@ -84,8 +84,9 @@ typedef struct MTex {
 
 	/* particles */
 	float timefac, lengthfac, clumpfac, dampfac;
-	float kinkfac, roughfac, padensfac, gravityfac;
+	float kinkfac, kinkampfac, roughfac, padensfac, gravityfac;
 	float lifefac, sizefac, ivelfac, fieldfac;
+	int pad2;
 
 	/* lamp */
 	float shadowfac;
diff --git a/source/blender/makesrna/intern/rna_particle.c b/source/blender/makesrna/intern/rna_particle.c
index f65b2d1..4ecfe34 100644
--- a/source/blender/makesrna/intern/rna_particle.c
+++ b/source/blender/makesrna/intern/rna_particle.c
@@ -1917,6 +1917,11 @@ static void rna_def_particle_settings_mtex(BlenderRNA *brna)
 	RNA_def_property_ui_text(prop, "Clump", "Affect the child clumping");
 	RNA_def_property_update(prop, 0, "rna_Particle_reset");
 
+	prop = RNA_def_property(srna, "use_map_kink_amp", PROP_BOOLEAN, PROP_NONE);
+	RNA_def_property_boolean_sdna(prop, NULL, "mapto", PAMAP_KINK_AMP);
+	RNA_def_property_ui_text(prop, "Kink Amplitude", "Affect the child kink amplitude");
+	RNA_def_property_update(prop, 0, "rna_Particle_redo_child");
+
 	prop = RNA_def_property(srna, "use_map_kink_freq", PROP_BOOLEAN, PROP_NONE);
 	RNA_def_property_boolean_sdna(prop, NULL, "mapto", PAMAP_KINK_FREQ);
 	RNA_def_property_ui_text(prop, "Kink Frequency", "Affect the child kink frequency");
@@ -1996,6 +2001,12 @@ static void rna_def_particle_settings_mtex(BlenderRNA *brna)
 	RNA_def_property_ui_text(prop, "Clump Factor", "Amount texture affects child clump");
 	RNA_def_property_update(prop, 0, "rna_Particle_redo_child");
 
+	prop = RNA_def_property(srna, "kink_amp_factor", PROP_FLOAT, PROP_NONE);
+	RNA_def_property_float_sdna(prop, NULL, "kinkampfac");
+	RNA_def_property_ui_range(prop, 0, 1, 10, 3);
+	RNA_def_property_ui_text(prop, "Kink Amplitude Factor", "Amount texture affects child kink amplitude");
+	RNA_def_property_update(prop, 0, "rna_Particle_redo_child");
+
 	prop = RNA_def_property(srna, "kink_freq_factor", PROP_FLOAT, PROP_NONE);
 	RNA_def_property_float_sdna(prop, NULL, "kinkfac");
 	RNA_def_property_ui_range(prop, 0, 1, 10, 3);




More information about the Bf-blender-cvs mailing list