[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [14296] trunk/blender/source/blender: Fix for bug: [#8302] Particle atributes (Materials) wrong behavior

Janne Karhu jhkarh at utu.fi
Mon Mar 31 21:57:45 CEST 2008


Revision: 14296
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=14296
Author:   jhk
Date:     2008-03-31 21:57:40 +0200 (Mon, 31 Mar 2008)

Log Message:
-----------
Fix for bug: [#8302] Particle atributes (Materials) wrong behavior
-Particle texture calculations weren't using the mtex->def_var properly
-Texture buttons didn't set proper update flags for hair

Modified Paths:
--------------
    trunk/blender/source/blender/blenkernel/intern/particle.c
    trunk/blender/source/blender/src/buttons_shading.c

Modified: trunk/blender/source/blender/blenkernel/intern/particle.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/particle.c	2008-03-31 19:03:18 UTC (rev 14295)
+++ trunk/blender/source/blender/blenkernel/intern/particle.c	2008-03-31 19:57:40 UTC (rev 14296)
@@ -3092,6 +3092,7 @@
 	if(ma) for(m=0; m<MAX_MTEX; m++){
 		mtex=ma->mtex[m];
 		if(mtex && (ma->septex & (1<<m))==0){
+			float def=mtex->def_var;
 			float var=mtex->varfac;
 			short blend=mtex->blendtype;
 			short neg=mtex->pmaptoneg;
@@ -3126,13 +3127,13 @@
 				ptex->time= texture_value_blend(mtex->def_var,ptex->time,value,var,blend,neg & MAP_PA_TIME);
 			}
 			if((event & mtex->pmapto) & MAP_PA_LENGTH)
-				ptex->length= texture_value_blend(value,ptex->length,value,var,blend,neg & MAP_PA_LENGTH);
+				ptex->length= texture_value_blend(def,ptex->length,value,var,blend,neg & MAP_PA_LENGTH);
 			if((event & mtex->pmapto) & MAP_PA_CLUMP)
-				ptex->clump= texture_value_blend(value,ptex->clump,value,var,blend,neg & MAP_PA_CLUMP);
+				ptex->clump= texture_value_blend(def,ptex->clump,value,var,blend,neg & MAP_PA_CLUMP);
 			if((event & mtex->pmapto) & MAP_PA_KINK)
-				ptex->kink= texture_value_blend(value,ptex->kink,value,var,blend,neg & MAP_PA_KINK);
+				ptex->kink= texture_value_blend(def,ptex->kink,value,var,blend,neg & MAP_PA_KINK);
 			if((event & mtex->pmapto) & MAP_PA_ROUGH)
-				ptex->rough= texture_value_blend(value,ptex->rough,value,var,blend,neg & MAP_PA_ROUGH);
+				ptex->rough= texture_value_blend(def,ptex->rough,value,var,blend,neg & MAP_PA_ROUGH);
 		}
 	}
 	if(event & MAP_PA_TIME) { CLAMP(ptex->time,0.0,1.0); }
@@ -3152,6 +3153,7 @@
 		mtex=ma->mtex[m];
 		if(mtex && (ma->septex & (1<<m))==0){
 			float var=mtex->varfac;
+			float def=mtex->def_var;
 			short blend=mtex->blendtype;
 			short neg=mtex->pmaptoneg;
 
@@ -3192,24 +3194,24 @@
 					setvars |= MAP_PA_TIME;
 				}
 				else
-					ptex->time= texture_value_blend(mtex->def_var,ptex->time,value,var,blend,neg & MAP_PA_TIME);
+					ptex->time= texture_value_blend(def,ptex->time,value,var,blend,neg & MAP_PA_TIME);
 			}
 			if((event & mtex->pmapto) & MAP_PA_LIFE)
-				ptex->life= texture_value_blend(mtex->def_var,ptex->life,value,var,blend,neg & MAP_PA_LIFE);
+				ptex->life= texture_value_blend(def,ptex->life,value,var,blend,neg & MAP_PA_LIFE);
 			if((event & mtex->pmapto) & MAP_PA_DENS)
-				ptex->exist= texture_value_blend(mtex->def_var,ptex->exist,value,var,blend,neg & MAP_PA_DENS);
+				ptex->exist= texture_value_blend(def,ptex->exist,value,var,blend,neg & MAP_PA_DENS);
 			if((event & mtex->pmapto) & MAP_PA_SIZE)
-				ptex->size= texture_value_blend(mtex->def_var,ptex->size,value,var,blend,neg & MAP_PA_SIZE);
+				ptex->size= texture_value_blend(def,ptex->size,value,var,blend,neg & MAP_PA_SIZE);
 			if((event & mtex->pmapto) & MAP_PA_IVEL)
-				ptex->ivel= texture_value_blend(mtex->def_var,ptex->ivel,value,var,blend,neg & MAP_PA_IVEL);
+				ptex->ivel= texture_value_blend(def,ptex->ivel,value,var,blend,neg & MAP_PA_IVEL);
 			if((event & mtex->pmapto) & MAP_PA_PVEL)
 				texture_rgb_blend(ptex->pvel,rgba,ptex->pvel,value,var,blend);
 			if((event & mtex->pmapto) & MAP_PA_LENGTH)
-				ptex->length= texture_value_blend(mtex->def_var,ptex->length,value,var,blend,neg & MAP_PA_LENGTH);
+				ptex->length= texture_value_blend(def,ptex->length,value,var,blend,neg & MAP_PA_LENGTH);
 			if((event & mtex->pmapto) & MAP_PA_CLUMP)
-				ptex->clump= texture_value_blend(mtex->def_var,ptex->clump,value,var,blend,neg & MAP_PA_CLUMP);
+				ptex->clump= texture_value_blend(def,ptex->clump,value,var,blend,neg & MAP_PA_CLUMP);
 			if((event & mtex->pmapto) & MAP_PA_KINK)
-				ptex->kink= texture_value_blend(mtex->def_var,ptex->kink,value,var,blend,neg & MAP_PA_CLUMP);
+				ptex->kink= texture_value_blend(def,ptex->kink,value,var,blend,neg & MAP_PA_CLUMP);
 		}
 	}
 	if(event & MAP_PA_TIME) { CLAMP(ptex->time,0.0,1.0); }

Modified: trunk/blender/source/blender/src/buttons_shading.c
===================================================================
--- trunk/blender/source/blender/src/buttons_shading.c	2008-03-31 19:03:18 UTC (rev 14295)
+++ trunk/blender/source/blender/src/buttons_shading.c	2008-03-31 19:57:40 UTC (rev 14296)
@@ -3167,7 +3167,7 @@
 					ob=base->object;
 					for(psys=ob->particlesystem.first; psys; psys=psys->next) {
 						if(psys && ma==give_current_material(ob,psys->part->omat)) {
-							psys->recalc |= PSYS_INIT;
+							psys->recalc |= PSYS_INIT | PSYS_RECALC_HAIR;
 
 							DAG_object_flush_update(G.scene, ob, OB_RECALC_DATA);
 						}
@@ -3193,7 +3193,7 @@
 			ob=base->object;
 			for(psys=ob->particlesystem.first; psys; psys=psys->next){
 				if(psys && ma==give_current_material(ob,psys->part->omat)){
-					psys->recalc |= PSYS_INIT;
+					psys->recalc |= PSYS_INIT | PSYS_RECALC_HAIR;
 
 					DAG_object_flush_update(G.scene, ob, OB_RECALC_DATA);
 				}
@@ -3249,17 +3249,19 @@
 		uiDefButF(block, NUMSLI, B_MATPRV, "B ",		10,40,135,19, &(mtex->b), 0.0, 1.0, B_MTEXCOL, 0, "The default color for textures that don't return RGB");
 	}
 	uiBlockEndAlign(block);
-	
-	uiDefButF(block, NUMSLI, B_MATPRV, "DVar ",			10,10,135,19, &(mtex->def_var), 0.0, 1.0, 0, 0, "Value to use for Ref, Spec, Amb, Emit, Alpha, RayMir, TransLu and Hard");
-	
-	/* MAP TO */
-	uiBlockBeginAlign(block);
 
 	/*check if material is being used by particles*/
 	for(psys=ob->particlesystem.first; psys; psys=psys->next)
 		if(psys->part->omat==ob->actcol)
 			psys_mapto=1;
+	
+	but = uiDefButF(block, NUMSLI, B_MATPRV, "DVar ",			10,10,135,19, &(mtex->def_var), 0.0, 1.0, 0, 0, "Value to use for Ref, Spec, Amb, Emit, Alpha, RayMir, TransLu and Hard");
+	if(psys_mapto && mtex->pmapto & MAP_PA_INIT)
+		uiButSetFunc(but, particle_recalc_material, ma, NULL);
 
+	/* MAP TO */
+	uiBlockBeginAlign(block);
+
 	if(psys_mapto && pattr) {
 		but=uiDefButBitS(block, TOG3, MAP_PA_TIME, B_MAT_PARTICLE, "Time",	10,180,60,19, &(mtex->pmapto), 0, 0, 0, 0, "Causes the texture to affect the emission time of particles");
 			//uiButSetFunc(but, particle_recalc_material, ma, NULL);		





More information about the Bf-blender-cvs mailing list