[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [12417] branches/particles/source/blender: -particle mode selection coloring
Janne Karhu
jhkarh at utu.fi
Sun Oct 28 13:43:28 CET 2007
Revision: 12417
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=12417
Author: jhk
Date: 2007-10-28 13:43:24 +0100 (Sun, 28 Oct 2007)
Log Message:
-----------
-particle mode selection coloring
-rotations & guides for path cache work again
-few bugs that assumed particle edit was available
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_system.c
branches/particles/source/blender/render/intern/source/convertblender.c
branches/particles/source/blender/src/drawobject.c
branches/particles/source/blender/src/editparticle.c
Modified: branches/particles/source/blender/blenkernel/BKE_particle.h
===================================================================
--- branches/particles/source/blender/blenkernel/BKE_particle.h 2007-10-28 01:40:25 UTC (rev 12416)
+++ branches/particles/source/blender/blenkernel/BKE_particle.h 2007-10-28 12:43:24 UTC (rev 12417)
@@ -119,7 +119,8 @@
float co[3];
float vel[3];
float rot[4];
- float col[4];
+ float col[3];
+ int steps;
} ParticleCacheKey;
typedef struct ParticleEditKey{
Modified: branches/particles/source/blender/blenkernel/intern/particle.c
===================================================================
--- branches/particles/source/blender/blenkernel/intern/particle.c 2007-10-28 01:40:25 UTC (rev 12416)
+++ branches/particles/source/blender/blenkernel/intern/particle.c 2007-10-28 12:43:24 UTC (rev 12417)
@@ -569,7 +569,7 @@
}
static void interpolate_particle(short type, ParticleKey keys[4], float dt, ParticleKey *result)
{
- float t[4], temp[3];
+ float t[4];
if(type<0) {
VecfCubicInterpol(keys[1].co, keys[1].vel, keys[2].co, keys[2].vel, dt, result->co, result->vel);
@@ -979,7 +979,8 @@
break;
case PART_KINK_WAVE:
vec[axis]=1.0;
- Mat4MulVecfl(obmat,vec);
+ if(obmat)
+ Mat4MulVecfl(obmat,vec);
if(par_rot)
QuatMulVecf(par_rot,vec);
@@ -1504,7 +1505,7 @@
branch_prob=0.0f;
}
- cache[i]->col[3]=(float)steps;
+ cache[i]->steps = steps;
if(between){
int w = 0;
@@ -1749,25 +1750,26 @@
/* -Cached path data is also used to determine cut position for the editmode tool. */
void psys_cache_paths(Object *ob, ParticleSystem *psys, float cfra)
{
- ParticleCacheKey *ca, *tcache, **cache=psys->pathcache;
+ ParticleCacheKey *ca, **cache=psys->pathcache;
ParticleSystemModifierData *psmd = psys_get_modifier(ob, psys);
- HairKey *hkey[2];
- ParticleKey *kkey[2];
- ParticleKey keys[4], result;
+
ParticleData *pa;
- ParticleEditKey *ekey=0;
+ ParticleKey keys[4], result, *kkey[2];
+ HairKey *hkey[2];
+
ParticleEdit *edit = 0;
- BodyPoint *bp[2];
+ ParticleEditKey *ekey = 0;
+
SoftBody *soft = 0;
- float birthtime=0.0, dietime=0.0;
- float t, time, keytime, dfra=1.0, frs_sec=G.scene->r.frs_sec;
- float col[3]={0.5f,0.5f,0.5f};
- float vel_1st[3], rot_1st[4];
- float co[3], ve[3];
+ BodyPoint *bp[2];
+
+ float birthtime = 0.0, dietime = 0.0;
+ float t, time, keytime, dfra = 1.0, frs_sec = G.scene->r.frs_sec;
+ float col[3] = {0.5f, 0.5f, 0.5f};
+ float prev_tangent[3];
int k,i;
int steps = (int)pow(2.0, (double)psys->part->draw_step);
int totpart = psys->totpart;
- int timed = 0;
char nosel[4], sel[4];
float sel_col[3];
float nosel_col[3];
@@ -1777,7 +1779,7 @@
else if(ob==OBACT && psys->edit && G.f & G_PARTICLEEDIT && psys->flag&PSYS_CURRENT){
edit=psys->edit;
- timed = edit->draw_timed;
+ //timed = edit->draw_timed;
PE_get_colors(sel,nosel);
if(psys->edit->brush == PE_BRUSH_WEIGHT){
@@ -1799,21 +1801,15 @@
/* allocate cache array for fast access and set pointers to contiguous mem block */
cache = psys->pathcache = MEM_callocN(totpart * sizeof(void *), "Path cache array");
- tcache = MEM_callocN(totpart * (steps + 1) * sizeof(ParticleCacheKey), "Path cache");
- for(i=0; i<totpart; i++)
- cache[i] = tcache + i * (steps + 1);
+ cache[0] = MEM_callocN(totpart * (steps + 1) * sizeof(ParticleCacheKey), "Path cache");
+ for(i=1; i<totpart; i++)
+ cache[i] = cache[0] + i * (steps + 1);
if(edit==NULL && psys->soft && psys->softflag & OB_SB_ENABLE)
soft = psys->soft;
psys->lattice = psys_get_lattice(ob, psys);
- /* set correct ipo timing */
- //if(part->flag&PART_ABS_TIME && part->ipo){
- // calc_ipo(part->ipo, cfra);
- // execute_ipo((ID *)part, part->ipo);
- //}
-
/*---first main loop: create all actual particles' paths---*/
for(i=0,pa=psys->particles; i<totpart; i++, pa++){
if(psys && edit==NULL && (pa->flag & PARS_NO_DISP || pa->flag & PARS_UNEXIST)) {
@@ -1822,14 +1818,8 @@
continue;
}
- //if((part->flag&PART_ABS_TIME)==0 && part->ipo){
- // calc_ipo(part->ipo, 100.0f*(cfra-pa->time)/pa->lifetime);
- // execute_ipo((ID *)part, part->ipo);
- //}
+ cache[i]->steps = steps;
- /* col[3] here is abused for counting how many steps are actually used */
- cache[i]->col[3] = (float)steps;
-
if(edit)
ekey = edit->keys[i];
@@ -1944,109 +1934,88 @@
Mat4MulVecfl(ob->obmat, result.co);
}
+
/* apply guide curves to path data */
- //if(bsys->type==BAKEABLE_PARTICLE){
- // ParticleSystem *psys = bsys->system;
- // ParticleSettings *part = psys->part;
- // BakeKeyParticle *bkp0 = (BakeKeyParticle*)bel->custom;
- // BakeKeyParticle *bkp1;
+ if(edit==0 && psys->effectors.first && (psys->part->flag & PART_CHILD_GUIDE)==0)
+ do_guide(&result, i, time, &psys->effectors);
- // if(soft)
- // bkp0+=(key[0]-sbel.keys);
- // else
- // bkp0+=(key[0]-bel->keys);
+ /* figure out rotation */
+
+ if(k) {
+ float angle, tangent[3], normal[3], q[4];
- // bkp1=bkp0+1;
+ if(k == 1) {
+ float *q2;
- // /* figure out rotation */
- // if(part->rotfrom==PART_ROT_KEYS)
- // QuatInterpol(cstate->rot,bkp0->rot,bkp1->rot,keytime);
- // else{
- // if(k==0){
- // float nvel[3];
- // float *q2;
- // if(part->rotfrom==PART_ROT_ZINCR){
- // VECCOPY(nvel,state.vel);
- // VecMulf(nvel,-1.0f);
- // q2=vectoquat(nvel, OB_POSX, OB_POSZ);
- // QUATCOPY(cstate->rot,q2);
- // }
- // else{
- // QUATCOPY(cstate->rot,bkp0->rot);
- // }
+ VECSUB(tangent, result.co, (ca - 1)->co);
- // VECCOPY(vel_1st,state.vel);
- // Normalize(vel_1st);
- // QUATCOPY(rot_1st,cstate->rot);
- // }
- // else{
- // float angle,vel[3],c[3],q[4];
+ q2 = vectoquat(tangent, OB_POSX, OB_POSZ);
- // VECCOPY(vel,state.vel);
- // Normalize(vel);
- // angle=saacos(Inpf(vel,vel_1st));
+ QUATCOPY((ca - 1)->rot, q2);
- // if((angle > -0.000001) && (angle < 0.000001)){
- // QUATCOPY(cstate->rot,rot_1st);
- // }
- // else{
- // Crossf(c,vel_1st,vel);
- // VecRotToQuat(c,angle,q);
- // QuatMul(cstate->rot,q,rot_1st);
- // }
+ VECCOPY(prev_tangent, tangent);
+ Normalize(prev_tangent);
+ }
+ else {
+ VECSUB(tangent, result.co, (ca - 1)->co);
+ Normalize(tangent);
+ angle = saacos(Inpf(tangent, prev_tangent));
- // VECCOPY(vel_1st,state.vel);
- // Normalize(vel_1st);
- // QUATCOPY(rot_1st,cstate->rot);
- // }
- // }
- // if(edit==0 && psys->effectors.first && (part->flag & PART_CHILD_GUIDE)==0 &&
- // (bsys->flag&BSYS_KEYED || part->flag&PART_BAKED_GUIDES))
- // do_guide(&state,i,time,&psys->effectors);
- //}
+ if((angle > -0.000001) && (angle < 0.000001)){
+ QUATCOPY((ca - 1)->rot, (ca - 2)->rot);
+ }
+ else{
+ Crossf(normal, prev_tangent, tangent);
+ VecRotToQuat(normal, angle, q);
+ QuatMul((ca - 1)->rot, q, (ca - 2)->rot);
+ }
+ VECCOPY(prev_tangent, tangent);
+ }
+
+ if(k == steps) {
+ QUATCOPY(ca->rot, (ca - 1)->rot);
+ }
+ }
+
VECCOPY(ca->co, result.co);
VECCOPY(ca->vel, result.vel);
- //if(edit){
- // if(edit->brush==EB_BRUSH_WEIGHT){
- // if(k==steps)
- // VecLerpf(cstate->col,nosel_col,sel_col,key[1]->weight);
- // else
- // VecLerpf(cstate->col,nosel_col,sel_col,
- // (1.0f - keytime) * key[1]->weight + keytime * key[2]->weight);
- // }
- // else{
- // BakeKey *belkeys = soft?sbel.keys:bel->keys;
- // if((bek+(key[0]-belkeys))->flag&PEK_SELECT){
- // if((bek+(key[1]-belkeys))->flag&PEK_SELECT){
- // VECCOPY(cstate->col,sel_col);
- // }
- // else{
- // VecLerpf(cstate->col,sel_col,nosel_col,keytime);
- // }
- // }
- // else{
- // if((bek+(key[1]-belkeys))->flag&PEK_SELECT){
- // VecLerpf(cstate->col,nosel_col,sel_col,keytime);
- // }
- // else{
- // VECCOPY(cstate->col,nosel_col);
- // }
- // }
- // }
- // if(timed){
- // cstate->col[3]=1.0f-(float)fabs(cfra-t)/(float)timed;
- // CLAMP(cstate->col[3],0.0f,1.0f);
- // }
- // else
- // cstate->col[3]=1.0f;
- //}
- //else{
- VECCOPY(ca->col,col);
- //}
+
+ /* selection coloring in edit mode */
+ if(edit){
+ if(edit->brush==PE_BRUSH_WEIGHT){
+ if(k==steps)
+ VecLerpf(ca->col, nosel_col, sel_col, hkey[0]->weight);
+ else
+ VecLerpf(ca->col,nosel_col,sel_col,
+ (1.0f - keytime) * hkey[0]->weight + keytime * hkey[1]->weight);
+ }
+ else{
+ if((ekey + (hkey[0] - pa->hair))->flag & PEK_SELECT){
+ if((ekey + (hkey[1] - pa->hair))->flag & PEK_SELECT){
+ VECCOPY(ca->col, sel_col);
+ }
+ else{
+ VecLerpf(ca->col, sel_col, nosel_col, keytime);
+ }
+ }
+ else{
+ if((ekey + (hkey[1] - pa->hair))->flag & PEK_SELECT){
+ VecLerpf(ca->col, nosel_col, sel_col, keytime);
+ }
+ else{
+ VECCOPY(ca->col, nosel_col);
+ }
+ }
+ }
+ }
+ else{
+ VECCOPY(ca->col, col);
+ }
+
if(psys->lattice && edit==0)
- calc_latt_deform(ca->co,1.0f);
+ calc_latt_deform(ca->co, 1.0f);
}
}
Modified: branches/particles/source/blender/blenkernel/intern/particle_system.c
===================================================================
--- branches/particles/source/blender/blenkernel/intern/particle_system.c 2007-10-28 01:40:25 UTC (rev 12416)
+++ branches/particles/source/blender/blenkernel/intern/particle_system.c 2007-10-28 12:43:24 UTC (rev 12417)
@@ -3818,8 +3818,6 @@
pa->alive=PARS_ALIVE;
pa_dfra= cfra - birthtime;
pa_dtime= pa_dfra*timestep;
- //if(psys->flag & PSYS_BAKING)
- // DB_psys_set_key(bsys,p,&pa->state,pa->time);
}
else if(dietime <= cfra && psys->cfra < dietime){
/* particle dies some time between this and last step */
@@ -3861,9 +3859,6 @@
if(pa_die){
push_reaction(ob,psys,p,PART_EVENT_DEATH,key);
- //if(psys->flag & PSYS_BAKING)
- // DB_psys_set_key(bsys,p,key,pa->dietime);
-
if(part->flag & PART_LOOP){
pa->loop++;
@@ -4005,9 +4000,6 @@
}
}
- //if(part->type==PART_HAIR && ob->recalc&OB_RECALC_TIME && bsys->flag&BSYS_AUTOBAKE_TIME)
- // bsys->flag |= BSYS_TO_AUTOBAKE;
-
if(psys->effectors.first)
psys_end_effectors(psys);
Modified: branches/particles/source/blender/render/intern/source/convertblender.c
===================================================================
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list