diff options
author | Janne Karhu <jhkarh@gmail.com> | 2008-05-28 21:16:43 +0400 |
---|---|---|
committer | Janne Karhu <jhkarh@gmail.com> | 2008-05-28 21:16:43 +0400 |
commit | 9a3b25d8a098577a1889900353af536151683f91 (patch) | |
tree | bfdeaebc02e2e723b1b67f2e75a0e63bf84f3c7a /source/blender/src | |
parent | c6668755ff865f79d9526301ca6edac48d982b06 (diff) |
Fix for bug: [#11680] "Col" option for particle systems does not work correctly with Mat IPOs
-the feature simply was not coded
Diffstat (limited to 'source/blender/src')
-rw-r--r-- | source/blender/src/drawobject.c | 83 |
1 files changed, 68 insertions, 15 deletions
diff --git a/source/blender/src/drawobject.c b/source/blender/src/drawobject.c index 3ef14574bc8..d2555f355bb 100644 --- a/source/blender/src/drawobject.c +++ b/source/blender/src/drawobject.c @@ -2902,7 +2902,7 @@ static void draw_new_particle_system(Base *base, ParticleSystem *psys, int dt) float *vdata=0, *vedata=0, *cdata=0, *ndata=0, *vd=0, *ved=0, *cd=0, *nd=0, xvec[3], yvec[3], zvec[3]; int a, k, k_max=0, totpart, totpoint=0, draw_as, path_nbr=0; int path_possible=0, keys_possible=0, draw_keys=0, totchild=0; - int select=ob->flag&SELECT; + int select=ob->flag&SELECT, create_cdata=0; GLint polygonmode[2]; char val[32]; @@ -2956,8 +2956,10 @@ static void draw_new_particle_system(Base *base, ParticleSystem *psys, int dt) if(select) cpack(0xFFFFFF); - else if((ma) && (part->draw&PART_DRAW_MAT_COL)) + else if((ma) && (part->draw&PART_DRAW_MAT_COL)) { glColor3f(ma->r,ma->g,ma->b); + create_cdata = 1; + } else cpack(0); @@ -3065,19 +3067,25 @@ static void draw_new_particle_system(Base *base, ParticleSystem *psys, int dt) if(draw_as!=PART_DRAW_CIRC){ switch(draw_as){ case PART_DRAW_AXIS: - cdata=MEM_callocN((totpart+totchild)*(path_nbr+1)*6*3*sizeof(float), "particle_cdata"); - /* no break! */ case PART_DRAW_CROSS: + if(draw_as!=PART_DRAW_CROSS || create_cdata) + cdata=MEM_callocN((totpart+totchild)*(path_nbr+1)*6*3*sizeof(float), "particle_cdata"); vdata=MEM_callocN((totpart+totchild)*(path_nbr+1)*6*3*sizeof(float), "particle_vdata"); break; case PART_DRAW_LINE: + if(create_cdata) + cdata=MEM_callocN((totpart+totchild)*(path_nbr+1)*2*3*sizeof(float), "particle_cdata"); vdata=MEM_callocN((totpart+totchild)*(path_nbr+1)*2*3*sizeof(float), "particle_vdata"); break; case PART_DRAW_BB: + if(create_cdata) + cdata=MEM_callocN((totpart+totchild)*(path_nbr+1)*4*3*sizeof(float), "particle_cdata"); vdata=MEM_callocN((totpart+totchild)*(path_nbr+1)*4*3*sizeof(float), "particle_vdata"); ndata=MEM_callocN((totpart+totchild)*(path_nbr+1)*4*3*sizeof(float), "particle_vdata"); break; default: + if(create_cdata) + cdata=MEM_callocN((totpart+totchild)*(path_nbr+1)*3*sizeof(float), "particle_cdata"); vdata=MEM_callocN((totpart+totchild)*(path_nbr+1)*3*sizeof(float), "particle_vdata"); } } @@ -3102,9 +3110,17 @@ static void draw_new_particle_system(Base *base, ParticleSystem *psys, int dt) pa_time=(cfra-pa->time)/pa->lifetime; - if((part->flag&PART_ABS_TIME)==0 && part->ipo){ - calc_ipo(part->ipo, 100*pa_time); - execute_ipo((ID *)part, part->ipo); + if((part->flag&PART_ABS_TIME)==0){ + if(ma->ipo){ + /* correction for lifetime */ + calc_ipo(ma->ipo, 100.0f*pa_time); + execute_ipo((ID *)ma, ma->ipo); + } + if(part->ipo) { + /* correction for lifetime */ + calc_ipo(part->ipo, 100*pa_time); + execute_ipo((ID *)part, part->ipo); + } } pa_size=pa->size; @@ -3121,9 +3137,17 @@ static void draw_new_particle_system(Base *base, ParticleSystem *psys, int dt) pa_time=psys_get_child_time(psys,cpa,cfra); - if((part->flag&PART_ABS_TIME)==0 && part->ipo){ - calc_ipo(part->ipo, 100*pa_time); - execute_ipo((ID *)part, part->ipo); + if((part->flag&PART_ABS_TIME)==0) { + if(ma->ipo){ + /* correction for lifetime */ + calc_ipo(ma->ipo, 100.0f*pa_time); + execute_ipo((ID *)ma, ma->ipo); + } + if(part->ipo) { + /* correction for lifetime */ + calc_ipo(part->ipo, 100*pa_time); + execute_ipo((ID *)part, part->ipo); + } } pa_size=psys_get_child_size(psys,cpa,cfra,0); @@ -3161,6 +3185,12 @@ static void draw_new_particle_system(Base *base, ParticleSystem *psys, int dt) switch(draw_as){ case PART_DRAW_DOT: + if(cd) { + cd[0]=ma->r; + cd[1]=ma->g; + cd[2]=ma->b; + cd+=3; + } if(vd){ VECCOPY(vd,state.co) vd+=3; } @@ -3181,7 +3211,15 @@ static void draw_new_particle_system(Base *base, ParticleSystem *psys, int dt) VECCOPY(vec2,state.co); } - else VECSUB(vec2,state.co,vec); + else { + if(cd) { + cd[0]=cd[3]=cd[6]=cd[9]=cd[12]=cd[15]=ma->r; + cd[1]=cd[4]=cd[7]=cd[10]=cd[13]=cd[16]=ma->g; + cd[2]=cd[5]=cd[8]=cd[11]=cd[14]=cd[17]=ma->b; + cd+=18; + } + VECSUB(vec2,state.co,vec); + } VECADD(vec,state.co,vec); VECCOPY(vd,vec); vd+=3; @@ -3219,11 +3257,25 @@ static void draw_new_particle_system(Base *base, ParticleSystem *psys, int dt) VecMulf(vec,VecLength(state.vel)); VECADDFAC(vd,state.co,vec,-part->draw_line[0]); vd+=3; VECADDFAC(vd,state.co,vec,part->draw_line[1]); vd+=3; + if(cd) { + cd[0]=cd[3]=ma->r; + cd[1]=cd[4]=ma->g; + cd[2]=cd[5]=ma->b; + cd+=3; + } break; case PART_DRAW_CIRC: + if(create_cdata) + glColor3f(ma->r,ma->g,ma->b); drawcircball(GL_LINE_LOOP, state.co, pixsize, imat); break; case PART_DRAW_BB: + if(cd) { + cd[0]=cd[3]=cd[6]=cd[9]=ma->r; + cd[1]=cd[4]=cd[7]=cd[10]=ma->g; + cd[2]=cd[5]=cd[8]=cd[11]=ma->b; + cd+=12; + } if(part->draw&PART_DRAW_BB_LOCK && part->bb_align==PART_BB_VIEW){ VECCOPY(xvec,bb_ob->obmat[0]); Normalize(xvec); @@ -3419,13 +3471,14 @@ static void draw_new_particle_system(Base *base, ParticleSystem *psys, int dt) glDisable(GL_LIGHTING); } + if(cdata){ + glEnableClientState(GL_COLOR_ARRAY); + glColorPointer(3, GL_FLOAT, 0, cdata); + } + switch(draw_as){ case PART_DRAW_AXIS: case PART_DRAW_CROSS: - if(cdata){ - glEnableClientState(GL_COLOR_ARRAY); - glColorPointer(3, GL_FLOAT, 0, cdata); - } glDrawArrays(GL_LINES, 0, 6*totpoint); break; case PART_DRAW_LINE: |