[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [11053] branches/particles/source/blender: *bugs fixed
Janne Karhu
janne.karhu at utu.fi
Mon Jun 25 22:10:06 CEST 2007
Revision: 11053
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=11053
Author: jhk
Date: 2007-06-25 22:10:06 +0200 (Mon, 25 Jun 2007)
Log Message:
-----------
*bugs fixed
-vortex effector didn't work correctly with particle velocity
*new things
-option to draw particles with their material's diffuse color in certain draw types
-a LOT of new billboard options
-particle tabs were getting cluttered so created an own tab-window for particles (need a new icon for fields, softbody & fluid)
-reorganized the ui a bit
-confirmation for freeing a bake that has been edited in particle mode
-changed the way particle mass is handled
-particle size updates better on all size effecting changes
-deflections
*speedup by using bounding boxes
*independence of surface normal direction
*option for swept sphere intersection (size deflect) i.e. particle size is taken into account on deflections
Modified Paths:
--------------
branches/particles/source/blender/blenkernel/BKE_particle.h
branches/particles/source/blender/blenkernel/intern/particle.c
branches/particles/source/blender/blenkernel/intern/particle_edit.c
branches/particles/source/blender/blenkernel/intern/particle_system.c
branches/particles/source/blender/blenlib/BLI_arithb.h
branches/particles/source/blender/blenlib/intern/arithb.c
branches/particles/source/blender/include/BIF_butspace.h
branches/particles/source/blender/include/butspace.h
branches/particles/source/blender/makesdna/DNA_particle_types.h
branches/particles/source/blender/render/intern/source/convertblender.c
branches/particles/source/blender/src/butspace.c
branches/particles/source/blender/src/buttons_object.c
branches/particles/source/blender/src/drawobject.c
branches/particles/source/blender/src/header_buttonswin.c
branches/particles/source/blender/src/space.c
Modified: branches/particles/source/blender/blenkernel/BKE_particle.h
===================================================================
--- branches/particles/source/blender/blenkernel/BKE_particle.h 2007-06-25 19:50:25 UTC (rev 11052)
+++ branches/particles/source/blender/blenkernel/BKE_particle.h 2007-06-25 20:10:06 UTC (rev 11053)
@@ -16,10 +16,14 @@
struct pNewEffectorCache *next, *prev;
Object *ob;
- /* precalculated variables (only for guides)*/
+ /* precalculated variables for guides */
float firstloc[4], firstdir[3];
float *distances;
float *locations;
+ /* precalculated variables for deflection */
+ float ob_minmax[6];
+ float *face_minmax;
+ float *vert_cos;
short type, psys_nbr;
@@ -128,7 +132,7 @@
void cache_particle_paths(struct Object *ob, struct ParticleSystemModifierData *psmd, struct ParticleSystem *psys, float cfra);
void particle_guide(struct ParticleKey *state, int pa_num, float time, struct ListBase *lb);
-float get_particle_size(struct ParticleSettings *part, struct ParticleData *pa);
+float get_particle_size(struct Material *ma, struct ParticleSystemModifierData *psmd, struct IpoCurve *icu_size, struct ParticleSystem *psys, struct ParticleSettings *part, struct ParticleData *pa, float *vg_size);
float get_particle_timestep(struct ParticleSettings *part);
float get_child_particle_time(struct ParticleSystem *psys, int child_nbr, float cfra);
float get_child_particle_size(struct ParticleSystem *psys, int child_nbr, float cfra, float *pa_time);
@@ -192,11 +196,11 @@
float interpolate_particle_value_from_verts(struct DerivedMesh *dm, short from, int index, float *fuv, float *values);
void get_from_particle_key(struct ParticleKey *key, float *loc, float *vel, float *rot, float *time);
-int particle_intersect_dm(int final, struct Object *ob, struct DerivedMesh *dm, float *co1, float* co2, float *min_d, int *min_face, float *min_uv);
+int particle_intersect_dm(struct Object *ob, struct DerivedMesh *dm, float *vert_cos, float *co1, float* co2, float *min_d, int *min_face, float *min_uv, float *face_minmax, float *pa_minmax, float radius, float *ipoint);
void particle_on_dm(struct DerivedMesh *dm, int from, int index, float *fuv, float *vec, float *nor, float *utan, float *vtan);
/* particle_system.c */
-void initialize_particle(struct ParticleData *pa, int p, Object *ob, struct ParticleSystem *psys, struct ParticleSystemModifierData *psmd, float *vg_size);
+void initialize_particle(struct ParticleData *pa, int p, Object *ob, struct ParticleSystem *psys, struct ParticleSystemModifierData *psmd);
void reset_particle(struct ParticleData *pa, struct ParticleSystem *psys, struct ParticleSystemModifierData *psmd, struct Object *ob, float dtime, float cfra, float *vg_vel);
/* particle_edit.c */
Modified: branches/particles/source/blender/blenkernel/intern/particle.c
===================================================================
--- branches/particles/source/blender/blenkernel/intern/particle.c 2007-06-25 19:50:25 UTC (rev 11052)
+++ branches/particles/source/blender/blenkernel/intern/particle.c 2007-06-25 20:10:06 UTC (rev 11053)
@@ -2556,9 +2556,29 @@
return 0.04f*part->timetweak;
}
/* part->size should be updated with possible ipo effection before this is called */
-float get_particle_size(ParticleSettings *part, ParticleData *pa)
+float get_particle_size(Material *ma, ParticleSystemModifierData *psmd, IpoCurve *icu_size, ParticleSystem *psys, ParticleSettings *part, ParticleData *pa, float *vg_size)
{
- return part->size*pa->sizemul;
+ ParticleTexture ptex;
+ float size=part->size;
+
+ if(part->randsize!=0.0)
+ size*= 1.0f - part->randsize*pa->sizemul;
+
+ if(vg_size)
+ size*=interpolate_particle_value_from_verts(psmd->dm,part->from,pa->num,pa->fuv,vg_size);
+
+ if(ma && part->from!=PART_FROM_PARTICLE){
+ ptex.size=size;
+ get_particle_texture(ma,psmd,psys,pa,&ptex,MAP_PA_SIZE);
+ size=ptex.size;
+ }
+
+ if(icu_size){
+ calc_icu(icu_size,pa->time);
+ size*=icu_size->curval;
+ }
+
+ return size;
}
float get_child_particle_time(ParticleSystem *psys, int child_nbr, float cfra)
{
Modified: branches/particles/source/blender/blenkernel/intern/particle_edit.c
===================================================================
--- branches/particles/source/blender/blenkernel/intern/particle_edit.c 2007-06-25 19:50:25 UTC (rev 11052)
+++ branches/particles/source/blender/blenkernel/intern/particle_edit.c 2007-06-25 20:10:06 UTC (rev 11053)
@@ -1696,7 +1696,7 @@
Mat4MulVecfl(imat,co2);
min_d=2.0;
- if(particle_intersect_dm(0,ob,psmd->dm,co1,co2,&min_d,&add_pars[n].num,add_pars[n].fuv)){
+ if(particle_intersect_dm(ob,psmd->dm,0,co1,co2,&min_d,&add_pars[n].num,add_pars[n].fuv,0,0,0,0)){
mface=psmd->dm->getFaceData(psmd->dm,add_pars[n].num,CD_MFACE);
add_pars[n].fuv[2]=0.0;
@@ -1767,7 +1767,7 @@
for(i=psys->totpart-n, pa=psys->particles+i; i<psys->totpart; i++,pa++){
mface=psmd->dm->getFaceData(psmd->dm,pa->num,CD_MFACE);
- initialize_particle(pa,i,ob,psys,psmd,0);
+ initialize_particle(pa,i,ob,psys,psmd);
reset_particle(pa,psys,psmd,ob,0.0,1.0,0);
framestep = pa->lifetime/(float)(ep->totaddkey-1);
Modified: branches/particles/source/blender/blenkernel/intern/particle_system.c
===================================================================
--- branches/particles/source/blender/blenkernel/intern/particle_system.c 2007-06-25 19:50:25 UTC (rev 11052)
+++ branches/particles/source/blender/blenkernel/intern/particle_system.c 2007-06-25 20:10:06 UTC (rev 11053)
@@ -908,7 +908,7 @@
}
}
/* set particle parameters that don't change during particle's life */
-void initialize_particle(ParticleData *pa, int p, Object *ob, ParticleSystem *psys, ParticleSystemModifierData *psmd, float *vg_size)
+void initialize_particle(ParticleData *pa, int p, Object *ob, ParticleSystem *psys, ParticleSystemModifierData *psmd)
{
ParticleSettings *part;
ParticleTexture ptex;
@@ -935,25 +935,8 @@
pa->lifetime= part->lifetime*ptex.life;
- if(part->type==PART_REACTOR && (part->flag&PART_REACT_STA_END)==0){
- //if(part->reactevent==PART_EVENT_NEAR && part->from==PART_FROM_PARTICLE){
- // Object *tob;
- // ParticleSystem *tpsys=0;
- // ParticleData *tpa=0;
-
- // get_reactor_particle_target(ob,psys,tob,tpsys);
-
- // if(tpsys){
- // tpa=tpsys->particles + pa->num;
- // /* pa->fuv[2] was abused in distribute for even time distribution for each target particle */
- // pa->time= tpa->time + pa->fuv[2]*tpa->lifetime;
- // }
- // else
- // pa->time=MAXFRAMEF;
- //}
- //else
+ if(part->type==PART_REACTOR && (part->flag&PART_REACT_STA_END)==0)
pa->time=MAXFRAMEF;
- }
else{
icu=find_ipocurve(psys->part->ipo,PART_EMIT_TIME);
if(icu){
@@ -978,27 +961,10 @@
pa->dietime= pa->time+pa->lifetime;
- pa->mass = part->mass;
- rand= BLI_frand();
- if(part->randmass!=0.0)
- pa->mass*= 1.0f - part->randmass*rand;
-
- icu=find_ipocurve(psys->part->ipo,PART_EMIT_SIZE);
- if(icu){
- calc_icu(icu,100*ptex.time);
- ptex.size*=icu->curval;
- }
+ pa->sizemul= BLI_frand();
- pa->sizemul = ptex.size;
rand= BLI_frand();
- if(part->randsize!=0.0)
- pa->sizemul*= 1.0f - part->randsize*rand;
- if(vg_size)
- pa->sizemul*= interpolate_particle_value_from_verts(psmd->dm,part->from,pa->num,pa->fuv,vg_size);
-
- rand= BLI_frand();
-
/* while loops are to have a spherical distribution (avoid cubic distribution) */
length=2.0f;
while(length>1.0){
@@ -1034,13 +1000,9 @@
static void initialize_all_particles(Object *ob, ParticleSystem *psys, ParticleSystemModifierData *psmd){
ParticleData *pa;
int p, totpart=psys->totpart;
- float *vg_size=cache_particle_vgroup(psmd->dm,psys,PSYS_VG_SIZE);
for(p=0, pa=psys->particles; p<totpart; p++, pa++)
- initialize_particle(pa,p,ob,psys,psmd,vg_size);
-
- if(vg_size)
- MEM_freeN(vg_size);
+ initialize_particle(pa,p,ob,psys,psmd);
}
/* sets particle to the emitter surface with initial velocity & rotation */
void reset_particle(ParticleData *pa, ParticleSystem *psys, ParticleSystemModifierData *psmd, Object *ob, float dtime, float cfra, float *vg_vel){
@@ -1476,7 +1438,7 @@
float *eff_velocity, float *vec_to_part, float *velocity, float *force, float *acc, int planar)
{
float strength, mag_vec[3]={0,0,0};
- float temp[3], temp2[3], rad;
+ float temp[3], temp2[3], rad, fac;
switch(type){
case PFIELD_WIND:
@@ -1503,10 +1465,14 @@
VECADDFAC(force,force,mag_vec,strength);
+ fac=-Inpf(velocity,eff_velocity);
+ VECADDFAC(temp,velocity,eff_velocity,fac);
+
/* normal acceleration */
- strength=VecLength(velocity);
+ strength=VecLength(temp);
- VECADDFAC(mag_vec,vec_to_part,eff_velocity,-Inpf(vec_to_part,eff_velocity));
+ fac=-Inpf(vec_to_part,eff_velocity);
+ VECADDFAC(mag_vec,vec_to_part,eff_velocity,fac);
strength/=VecLength(mag_vec);
VECADDFAC(force,force,mag_vec,-strength*strength);
@@ -1632,7 +1598,7 @@
PartDeflect *pd= ob->pd;
short type=0,i;
- if(ob != obsrc){
+ if(pd && ob != obsrc){
if(pd->forcefield == PFIELD_GUIDE && ((psys->flag&PSYS_BAKED)==0 || psys->part->flag&PART_BAKED_GUIDES)) {
if(ob->type==OB_CURVE && obsrc->type==OB_MESH) { /* guides only do mesh particles */
Curve *cu= ob->data;
@@ -1650,7 +1616,7 @@
}
}
- if(pd->deflect && ((psys->flag&PSYS_BAKED)==0 || psys->flag&PSYS_AUTOBAKE)){
+ if(pd && pd->deflect && ((psys->flag&PSYS_BAKED)==0 || psys->flag&PSYS_AUTOBAKE)){
type |= PSYS_EC_DEFLECT;
}
@@ -1741,6 +1707,12 @@
if(ec->locations)
MEM_freeN(ec->locations);
+
+ if(ec->face_minmax)
+ MEM_freeN(ec->face_minmax);
+
+ if(ec->vert_cos)
+ MEM_freeN(ec->vert_cos);
}
BLI_freelistN(lb);
@@ -1753,8 +1725,8 @@
pNewEffectorCache *ec;
ParticleSettings *part=psys->part;
ParticleData *pa;
- float vec2[3],loc[3];
- int p,totpart;
+ float vec2[3],loc[3],*co=0;
+ int p,totpart,totvert;
for(ec= lb->first; ec; ec= ec->next) {
PartDeflect *pd= ec->ob->pd;
@@ -1787,6 +1759,88 @@
}
}
}
+ else if(ec->type==PSYS_EC_DEFLECT){
+ DerivedMesh *dm;
+ MFace *mface=0;
+ MVert *mvert=0;
+ int i, totface;
+ float v1[3],v2[3],v3[3],v4[4], *min, *max;
+
+ if(ec->ob->particleSystem){
+ /* temporarily disable object's particle systems */
+ for(i=0; i<ob->totpart; i++){
+ ob->particleSystem[i]->flag |= PSYS_NO_STEP;
+ }
+ }
+ dm=mesh_get_derived_final(ec->ob,0);
+
+ if(ec->ob->particleSystem){
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list