forked from bartvdbraak/blender
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
This commit is contained in:
parent
1ccf92aecd
commit
5e3ff914cb
@ -3092,6 +3092,7 @@ static void get_cpa_texture(DerivedMesh *dm, Material *ma, int face_index, float
|
|||||||
if(ma) for(m=0; m<MAX_MTEX; m++){
|
if(ma) for(m=0; m<MAX_MTEX; m++){
|
||||||
mtex=ma->mtex[m];
|
mtex=ma->mtex[m];
|
||||||
if(mtex && (ma->septex & (1<<m))==0){
|
if(mtex && (ma->septex & (1<<m))==0){
|
||||||
|
float def=mtex->def_var;
|
||||||
float var=mtex->varfac;
|
float var=mtex->varfac;
|
||||||
short blend=mtex->blendtype;
|
short blend=mtex->blendtype;
|
||||||
short neg=mtex->pmaptoneg;
|
short neg=mtex->pmaptoneg;
|
||||||
@ -3126,13 +3127,13 @@ static void get_cpa_texture(DerivedMesh *dm, Material *ma, int face_index, float
|
|||||||
ptex->time= texture_value_blend(mtex->def_var,ptex->time,value,var,blend,neg & MAP_PA_TIME);
|
ptex->time= texture_value_blend(mtex->def_var,ptex->time,value,var,blend,neg & MAP_PA_TIME);
|
||||||
}
|
}
|
||||||
if((event & mtex->pmapto) & MAP_PA_LENGTH)
|
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)
|
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)
|
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)
|
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); }
|
if(event & MAP_PA_TIME) { CLAMP(ptex->time,0.0,1.0); }
|
||||||
@ -3152,6 +3153,7 @@ void psys_get_texture(Object *ob, Material *ma, ParticleSystemModifierData *psmd
|
|||||||
mtex=ma->mtex[m];
|
mtex=ma->mtex[m];
|
||||||
if(mtex && (ma->septex & (1<<m))==0){
|
if(mtex && (ma->septex & (1<<m))==0){
|
||||||
float var=mtex->varfac;
|
float var=mtex->varfac;
|
||||||
|
float def=mtex->def_var;
|
||||||
short blend=mtex->blendtype;
|
short blend=mtex->blendtype;
|
||||||
short neg=mtex->pmaptoneg;
|
short neg=mtex->pmaptoneg;
|
||||||
|
|
||||||
@ -3192,24 +3194,24 @@ void psys_get_texture(Object *ob, Material *ma, ParticleSystemModifierData *psmd
|
|||||||
setvars |= MAP_PA_TIME;
|
setvars |= MAP_PA_TIME;
|
||||||
}
|
}
|
||||||
else
|
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)
|
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)
|
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)
|
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)
|
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)
|
if((event & mtex->pmapto) & MAP_PA_PVEL)
|
||||||
texture_rgb_blend(ptex->pvel,rgba,ptex->pvel,value,var,blend);
|
texture_rgb_blend(ptex->pvel,rgba,ptex->pvel,value,var,blend);
|
||||||
if((event & mtex->pmapto) & MAP_PA_LENGTH)
|
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)
|
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)
|
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); }
|
if(event & MAP_PA_TIME) { CLAMP(ptex->time,0.0,1.0); }
|
||||||
|
@ -3167,7 +3167,7 @@ void do_matbuts(unsigned short event)
|
|||||||
ob=base->object;
|
ob=base->object;
|
||||||
for(psys=ob->particlesystem.first; psys; psys=psys->next) {
|
for(psys=ob->particlesystem.first; psys; psys=psys->next) {
|
||||||
if(psys && ma==give_current_material(ob,psys->part->omat)) {
|
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);
|
DAG_object_flush_update(G.scene, ob, OB_RECALC_DATA);
|
||||||
}
|
}
|
||||||
@ -3193,7 +3193,7 @@ static void particle_recalc_material(void *ma_v, void *arg2)
|
|||||||
ob=base->object;
|
ob=base->object;
|
||||||
for(psys=ob->particlesystem.first; psys; psys=psys->next){
|
for(psys=ob->particlesystem.first; psys; psys=psys->next){
|
||||||
if(psys && ma==give_current_material(ob,psys->part->omat)){
|
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);
|
DAG_object_flush_update(G.scene, ob, OB_RECALC_DATA);
|
||||||
}
|
}
|
||||||
@ -3250,16 +3250,18 @@ static void material_panel_map_to(Object *ob, Material *ma, int from_nodes)
|
|||||||
}
|
}
|
||||||
uiBlockEndAlign(block);
|
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*/
|
/*check if material is being used by particles*/
|
||||||
for(psys=ob->particlesystem.first; psys; psys=psys->next)
|
for(psys=ob->particlesystem.first; psys; psys=psys->next)
|
||||||
if(psys->part->omat==ob->actcol)
|
if(psys->part->omat==ob->actcol)
|
||||||
psys_mapto=1;
|
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) {
|
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");
|
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);
|
//uiButSetFunc(but, particle_recalc_material, ma, NULL);
|
||||||
|
Loading…
Reference in New Issue
Block a user