Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrecht Van Lommel <brechtvanlommel@pandora.be>2007-12-05 18:48:49 +0300
committerBrecht Van Lommel <brechtvanlommel@pandora.be>2007-12-05 18:48:49 +0300
commitb3c1e458b43d4014bc720c7eb20af5e02f6f5ab5 (patch)
treeeea106767a5f83798af9cd4054f682799a4b6dd7
parent29d87d64caac51fc900825063421a35ac9a7c7ae (diff)
Particles
========= - Added texture control for child particle roughness. - Fix some use of uninitialized variables in particle texture code.
-rw-r--r--source/blender/blenkernel/BKE_particle.h8
-rw-r--r--source/blender/blenkernel/intern/particle.c44
-rw-r--r--source/blender/makesdna/DNA_material_types.h3
-rw-r--r--source/blender/src/buttons_shading.c2
4 files changed, 32 insertions, 25 deletions
diff --git a/source/blender/blenkernel/BKE_particle.h b/source/blender/blenkernel/BKE_particle.h
index c41a54b0ea7..649a711a2e2 100644
--- a/source/blender/blenkernel/BKE_particle.h
+++ b/source/blender/blenkernel/BKE_particle.h
@@ -87,10 +87,10 @@ typedef struct ParticleReactEvent {
}ParticleReactEvent;
typedef struct ParticleTexture{
- float ivel; /* used in reset */
- float time, life, exist, size; /* used in init */
- float pvel[3]; /* used in physics */
- float length, clump, kink; /* used in path caching */
+ float ivel; /* used in reset */
+ float time, life, exist, size; /* used in init */
+ float pvel[3]; /* used in physics */
+ float length, clump, kink, rough; /* used in path caching */
} ParticleTexture;
typedef struct BoidVecFunc{
diff --git a/source/blender/blenkernel/intern/particle.c b/source/blender/blenkernel/intern/particle.c
index 32383302485..034d61e2bc6 100644
--- a/source/blender/blenkernel/intern/particle.c
+++ b/source/blender/blenkernel/intern/particle.c
@@ -1480,7 +1480,8 @@ void psys_thread_create_path(ParticleThread *thread, struct ChildParticle *cpa,
float *cpa_fuv=0;
float co[3], orco[3], ornor[3], t, rough_t, cpa_1st[3], dvec[3];
float branch_begin, branch_end, branch_prob, branchfac, rough_rand;
- float pa_rough1, pa_rough2, pa_roughe, length, pa_length, pa_clump, pa_kink;
+ float pa_rough1, pa_rough2, pa_roughe;
+ float length, pa_length, pa_clump, pa_kink;
float max_length = 1.0f, cur_length = 0.0f;
int k, cpa_num, guided=0;
short cpa_from;
@@ -1583,15 +1584,17 @@ void psys_thread_create_path(ParticleThread *thread, struct ChildParticle *cpa,
ptex.length=part->length*(1.0f - part->randlength*cpa->rand[0]);
ptex.clump=1.0;
ptex.kink=1.0;
+ ptex.rough= 1.0;
- get_cpa_texture(ctx->dm,ctx->ma,cpa_num,cpa_fuv,orco,&ptex,MAP_PA_CACHE);
+ get_cpa_texture(ctx->dm,ctx->ma,cpa_num,cpa_fuv,orco,&ptex,
+ MAP_PA_LENGTH|MAP_PA_CLUMP|MAP_PA_KINK|MAP_PA_ROUGH);
pa_length=ptex.length;
pa_clump=ptex.clump;
pa_kink=ptex.kink;
- pa_rough1=1.0;
- pa_rough2=1.0;
- pa_roughe=1.0;
+ pa_rough1=ptex.rough;
+ pa_rough2=ptex.rough;
+ pa_roughe=ptex.rough;
if(ctx->vg_length)
pa_length*=psys_interpolate_value_from_verts(ctx->dm,cpa_from,cpa_num,cpa_fuv,ctx->vg_length);
@@ -2606,13 +2609,16 @@ static void get_cpa_texture(DerivedMesh *dm, Material *ma, int face_index, float
if((event & mtex->pmapto) & MAP_PA_CLUMP)
ptex->clump= texture_value_blend(value,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_CLUMP);
+ ptex->kink= texture_value_blend(value,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);
}
}
- CLAMP(ptex->time,0.0,1.0);
- CLAMP(ptex->length,0.0,1.0);
- CLAMP(ptex->clump,0.0,1.0);
- CLAMP(ptex->kink,0.0,1.0);
+ if(event & MAP_PA_TIME) { CLAMP(ptex->time,0.0,1.0); }
+ if(event & MAP_PA_LENGTH) { CLAMP(ptex->length,0.0,1.0); }
+ if(event & MAP_PA_CLUMP) { CLAMP(ptex->clump,0.0,1.0); }
+ if(event & MAP_PA_KINK) { CLAMP(ptex->kink,0.0,1.0); }
+ if(event & MAP_PA_ROUGH) { CLAMP(ptex->rough,0.0,1.0); }
}
void psys_get_texture(Object *ob, Material *ma, ParticleSystemModifierData *psmd, ParticleSystem *psys, ParticleData *pa, ParticleTexture *ptex, int event)
{
@@ -2682,14 +2688,14 @@ void psys_get_texture(Object *ob, Material *ma, ParticleSystemModifierData *psmd
ptex->kink= texture_value_blend(mtex->def_var,ptex->kink,value,var,blend,neg & MAP_PA_CLUMP);
}
}
- CLAMP(ptex->time,0.0,1.0);
- CLAMP(ptex->life,0.0,1.0);
- CLAMP(ptex->exist,0.0,1.0);
- CLAMP(ptex->size,0.0,1.0);
- CLAMP(ptex->ivel,0.0,1.0);
- CLAMP(ptex->length,0.0,1.0);
- CLAMP(ptex->clump,0.0,1.0);
- CLAMP(ptex->kink,0.0,1.0);
+ if(event & MAP_PA_TIME) { CLAMP(ptex->time,0.0,1.0); }
+ if(event & MAP_PA_LIFE) { CLAMP(ptex->life,0.0,1.0); }
+ if(event & MAP_PA_DENS) { CLAMP(ptex->exist,0.0,1.0); }
+ if(event & MAP_PA_SIZE) { CLAMP(ptex->size,0.0,1.0); }
+ if(event & MAP_PA_IVEL) { CLAMP(ptex->ivel,0.0,1.0); }
+ if(event & MAP_PA_LENGTH) { CLAMP(ptex->length,0.0,1.0); }
+ if(event & MAP_PA_CLUMP) { CLAMP(ptex->clump,0.0,1.0); }
+ if(event & MAP_PA_KINK) { CLAMP(ptex->kink,0.0,1.0); }
}
/************************************************/
/* Particle State */
@@ -2966,7 +2972,7 @@ void psys_get_particle_on_path(Object *ob, ParticleSystem *psys, int p, Particle
ptex.clump=1.0;
ptex.kink=1.0;
- get_cpa_texture(psmd->dm,ma,cpa_num,cpa_fuv,orco,&ptex,MAP_PA_CACHE-MAP_PA_LENGTH);
+ get_cpa_texture(psmd->dm,ma,cpa_num,cpa_fuv,orco,&ptex,MAP_PA_CLUMP|MAP_PA_KINK);
pa_clump=ptex.clump;
pa_kink=ptex.kink;
diff --git a/source/blender/makesdna/DNA_material_types.h b/source/blender/makesdna/DNA_material_types.h
index 489ba71d639..22585e59c7b 100644
--- a/source/blender/makesdna/DNA_material_types.h
+++ b/source/blender/makesdna/DNA_material_types.h
@@ -298,9 +298,10 @@ typedef struct Material {
/* physics */
#define MAP_PA_PVEL 64
/* path cache */
-#define MAP_PA_CACHE 384
+#define MAP_PA_CACHE 912
#define MAP_PA_CLUMP 128
#define MAP_PA_KINK 256
+#define MAP_PA_ROUGH 512
/* pr_type */
#define MA_FLAT 0
diff --git a/source/blender/src/buttons_shading.c b/source/blender/src/buttons_shading.c
index 8bc165702fc..ff491b43370 100644
--- a/source/blender/src/buttons_shading.c
+++ b/source/blender/src/buttons_shading.c
@@ -3164,7 +3164,7 @@ static void material_panel_map_to(Object *ob, Material *ma, int from_nodes)
but=uiDefButBitS(block, TOG3, MAP_PA_DENS, B_MAT_PARTICLE, "Dens", 130,180,60,19, &(mtex->pmapto), 0, 0, 0, 0, "Causes the texture to affect the density of particles");
//uiButSetFunc(but, particle_recalc_material, ma, NULL);
uiDefButBitS(block, TOG3, MAP_PA_IVEL, B_MAT_PARTICLE, "IVel", 190,180,60,19, &(mtex->pmapto), 0, 0, 0, 0, "Causes the texture to affect the initial velocity of particles");
- uiDefButBitS(block, TOG3, MAP_PA_PVEL, B_MAT_PARTICLE, "PVel", 250,180,60,19, &(mtex->pmapto), 0, 0, 0, 0, "Causes the texture to affect the velocity of particles");
+ uiDefButBitS(block, TOG3, MAP_PA_ROUGH, B_MAT_PARTICLE, "Rough", 250,180,60,19, &(mtex->pmapto), 0, 0, 0, 0, "Causes the texture to affect the roughness of child particles");
but=uiDefButBitS(block, TOG3, MAP_PA_SIZE, B_MAT_PARTICLE, "Size", 10,160,60,19, &(mtex->pmapto), 0, 0, 0, 0, "Causes the texture to affect the size of particles");
//uiButSetFunc(but, particle_recalc_material, ma, NULL);