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:
authorCampbell Barton <ideasman42@gmail.com>2008-05-30 13:20:34 +0400
committerCampbell Barton <ideasman42@gmail.com>2008-05-30 13:20:34 +0400
commit555dff358f5236c5e9153a2726cad3c9e903d67c (patch)
treef14b02d613d12433639de9ff77831ac847ce489c /source/blender/src/drawobject.c
parent39da0b76191bc0648e01f23cbe800c5f43f17374 (diff)
parent2eb897e6db6099ef8a62969511eb72f0f75ff624 (diff)
svn merge -r14995:HEAD https://svn.blender.org/svnroot/bf-blender/trunk/blender/
Diffstat (limited to 'source/blender/src/drawobject.c')
-rw-r--r--source/blender/src/drawobject.c207
1 files changed, 152 insertions, 55 deletions
diff --git a/source/blender/src/drawobject.c b/source/blender/src/drawobject.c
index cec808836f5..45e7053e4dd 100644
--- a/source/blender/src/drawobject.c
+++ b/source/blender/src/drawobject.c
@@ -3008,7 +3008,7 @@ static int drawDispList(Base *base, int dt)
/* 5. start filling the arrays */
/* 6. draw the arrays */
/* 7. clean up */
-static void draw_new_particle_system(Base *base, ParticleSystem *psys)
+static void draw_new_particle_system(Base *base, ParticleSystem *psys, int dt)
{
View3D *v3d= G.vd;
Object *ob=base->object;
@@ -3025,7 +3025,7 @@ static void draw_new_particle_system(Base *base, ParticleSystem *psys)
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];
@@ -3079,8 +3079,10 @@ static void draw_new_particle_system(Base *base, ParticleSystem *psys)
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);
@@ -3188,19 +3190,25 @@ static void draw_new_particle_system(Base *base, ParticleSystem *psys)
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");
}
}
@@ -3225,9 +3233,17 @@ static void draw_new_particle_system(Base *base, ParticleSystem *psys)
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 && 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;
@@ -3244,9 +3260,17 @@ static void draw_new_particle_system(Base *base, ParticleSystem *psys)
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 && 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);
@@ -3284,6 +3308,12 @@ static void draw_new_particle_system(Base *base, ParticleSystem *psys)
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;
}
@@ -3304,7 +3334,15 @@ static void draw_new_particle_system(Base *base, ParticleSystem *psys)
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;
@@ -3342,11 +3380,25 @@ static void draw_new_particle_system(Base *base, ParticleSystem *psys)
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);
@@ -3457,14 +3509,24 @@ static void draw_new_particle_system(Base *base, ParticleSystem *psys)
float *cd2=0,*cdata2=0;
glEnableClientState(GL_VERTEX_ARRAY);
- glEnableClientState(GL_NORMAL_ARRAY);
- glEnable(GL_LIGHTING);
- glColorMaterial(GL_FRONT_AND_BACK, GL_DIFFUSE);
- glEnable(GL_COLOR_MATERIAL);
+ if(dt > OB_WIRE) {
+ glEnableClientState(GL_NORMAL_ARRAY);
- if(part->draw&PART_DRAW_MAT_COL)
- glEnableClientState(GL_COLOR_ARRAY);
+ if(part->draw&PART_DRAW_MAT_COL)
+ glEnableClientState(GL_COLOR_ARRAY);
+
+ glEnable(GL_LIGHTING);
+ glColorMaterial(GL_FRONT_AND_BACK, GL_DIFFUSE);
+ glEnable(GL_COLOR_MATERIAL);
+ }
+ else {
+ glDisableClientState(GL_NORMAL_ARRAY);
+
+ glDisable(GL_COLOR_MATERIAL);
+ glDisable(GL_LIGHTING);
+ BIF_ThemeColor(TH_WIRE);
+ }
if(totchild && (part->draw&PART_DRAW_PARENT)==0)
totpart=0;
@@ -3473,9 +3535,13 @@ static void draw_new_particle_system(Base *base, ParticleSystem *psys)
for(a=0, pa=psys->particles; a<totpart; a++, pa++){
path=cache[a];
glVertexPointer(3, GL_FLOAT, sizeof(ParticleCacheKey), path->co);
- glNormalPointer(GL_FLOAT, sizeof(ParticleCacheKey), path->vel);
- if(part->draw&PART_DRAW_MAT_COL)
- glColorPointer(3, GL_FLOAT, sizeof(ParticleCacheKey), path->col);
+
+ if(dt > OB_WIRE) {
+ glNormalPointer(GL_FLOAT, sizeof(ParticleCacheKey), path->vel);
+ if(part->draw&PART_DRAW_MAT_COL)
+ glColorPointer(3, GL_FLOAT, sizeof(ParticleCacheKey), path->col);
+ }
+
glDrawArrays(GL_LINE_STRIP, 0, path->steps + 1);
}
@@ -3483,15 +3549,21 @@ static void draw_new_particle_system(Base *base, ParticleSystem *psys)
for(a=0; a<totchild; a++){
path=cache[a];
glVertexPointer(3, GL_FLOAT, sizeof(ParticleCacheKey), path->co);
- glNormalPointer(GL_FLOAT, sizeof(ParticleCacheKey), path->vel);
- if(part->draw&PART_DRAW_MAT_COL)
- glColorPointer(3, GL_FLOAT, sizeof(ParticleCacheKey), path->col);
+
+ if(dt > OB_WIRE) {
+ glNormalPointer(GL_FLOAT, sizeof(ParticleCacheKey), path->vel);
+ if(part->draw&PART_DRAW_MAT_COL)
+ glColorPointer(3, GL_FLOAT, sizeof(ParticleCacheKey), path->col);
+ }
+
glDrawArrays(GL_LINE_STRIP, 0, path->steps + 1);
}
- if(part->draw&PART_DRAW_MAT_COL)
- glDisable(GL_COLOR_ARRAY);
- glDisable(GL_COLOR_MATERIAL);
+ if(dt > OB_WIRE) {
+ if(part->draw&PART_DRAW_MAT_COL)
+ glDisable(GL_COLOR_ARRAY);
+ glDisable(GL_COLOR_MATERIAL);
+ }
if(cdata2)
MEM_freeN(cdata2);
@@ -3512,7 +3584,7 @@ static void draw_new_particle_system(Base *base, ParticleSystem *psys)
else
glDisableClientState(GL_VERTEX_ARRAY);
- if(ndata && MIN2(G.vd->drawtype, ob->dt)>OB_WIRE){
+ if(ndata && dt>OB_WIRE){
glEnableClientState(GL_NORMAL_ARRAY);
glNormalPointer(GL_FLOAT, 0, ndata);
glEnable(GL_LIGHTING);
@@ -3522,20 +3594,21 @@ static void draw_new_particle_system(Base *base, ParticleSystem *psys)
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:
glDrawArrays(GL_LINES, 0, 2*totpoint);
break;
case PART_DRAW_BB:
- if(MIN2(G.vd->drawtype, ob->dt)<=OB_WIRE)
+ if(dt<=OB_WIRE)
glPolygonMode(GL_FRONT_AND_BACK,GL_LINE);
glDrawArrays(GL_QUADS, 0, 4*totpoint);
@@ -3589,7 +3662,7 @@ static void draw_new_particle_system(Base *base, ParticleSystem *psys)
mymultmatrix(ob->obmat); // bring back local matrix for dtx
}
-static void draw_particle_edit(Object *ob, ParticleSystem *psys)
+static void draw_particle_edit(Object *ob, ParticleSystem *psys, int dt)
{
ParticleEdit *edit = psys->edit;
ParticleData *pa;
@@ -3602,6 +3675,7 @@ static void draw_particle_edit(Object *ob, ParticleSystem *psys)
float nosel_col[3];
char val[32];
+ /* create path and child path cache if it doesn't exist already */
if(psys->pathcache==0){
PE_hide_keys_time(psys,CFRA);
psys_cache_paths(ob,psys,CFRA,0);
@@ -3616,11 +3690,13 @@ static void draw_particle_edit(Object *ob, ParticleSystem *psys)
else if(!(pset->flag & PE_SHOW_CHILD) && psys->childcache)
free_child_path_cache(psys);
+ /* opengl setup */
if((G.vd->flag & V3D_ZBUF_SELECT)==0)
glDisable(GL_DEPTH_TEST);
myloadmatrix(G.vd->viewmat);
+ /* get selection theme colors */
BIF_GetThemeColor3ubv(TH_VERTEX_SELECT, sel);
BIF_GetThemeColor3ubv(TH_VERTEX, nosel);
sel_col[0]=(float)sel[0]/255.0f;
@@ -3634,41 +3710,61 @@ static void draw_particle_edit(Object *ob, ParticleSystem *psys)
totchild = psys->totchildcache;
/* draw paths */
- glEnableClientState(GL_VERTEX_ARRAY);
- glEnableClientState(GL_NORMAL_ARRAY);
- glEnableClientState(GL_COLOR_ARRAY);
if(timed)
glEnable(GL_BLEND);
- if(pset->brushtype == PE_BRUSH_WEIGHT){
- glLineWidth(2.0f);
+ glEnableClientState(GL_VERTEX_ARRAY);
+
+ if(dt > OB_WIRE) {
+ /* solid shaded with lighting */
+ glEnableClientState(GL_NORMAL_ARRAY);
glEnableClientState(GL_COLOR_ARRAY);
+
+ glEnable(GL_COLOR_MATERIAL);
+ glColorMaterial(GL_FRONT_AND_BACK, GL_DIFFUSE);
+ }
+ else {
+ /* flat wire color */
+ glDisableClientState(GL_NORMAL_ARRAY);
glDisable(GL_LIGHTING);
+ BIF_ThemeColor(TH_WIRE);
}
- glColorMaterial(GL_FRONT_AND_BACK, GL_DIFFUSE);
- glEnable(GL_COLOR_MATERIAL);
-
- for(i=0, pa=psys->particles, path = psys->pathcache; i<totpart; i++, pa++, path++){
- glVertexPointer(3, GL_FLOAT, sizeof(ParticleCacheKey), (*path)->co);
- glNormalPointer(GL_FLOAT, sizeof(ParticleCacheKey), (*path)->vel);
- glColorPointer(3, GL_FLOAT, sizeof(ParticleCacheKey), (*path)->col);
-
- glDrawArrays(GL_LINE_STRIP, 0, (int)(*path)->steps + 1);
- }
+ /* only draw child paths with lighting */
+ if(dt > OB_WIRE)
+ glEnable(GL_LIGHTING);
- glEnable(GL_LIGHTING);
if(psys->part->draw_as == PART_DRAW_PATH) {
for(i=0, path=psys->childcache; i<totchild; i++,path++){
glVertexPointer(3, GL_FLOAT, sizeof(ParticleCacheKey), (*path)->co);
- glNormalPointer(GL_FLOAT, sizeof(ParticleCacheKey), (*path)->vel);
- glColorPointer(3, GL_FLOAT, sizeof(ParticleCacheKey), (*path)->col);
+ if(dt > OB_WIRE) {
+ glNormalPointer(GL_FLOAT, sizeof(ParticleCacheKey), (*path)->vel);
+ glColorPointer(3, GL_FLOAT, sizeof(ParticleCacheKey), (*path)->col);
+ }
glDrawArrays(GL_LINE_STRIP, 0, (int)(*path)->steps + 1);
}
}
- glDisable(GL_COLOR_MATERIAL);
+ if(dt > OB_WIRE)
+ glDisable(GL_LIGHTING);
+
+ if(pset->brushtype == PE_BRUSH_WEIGHT) {
+ glLineWidth(2.0f);
+ glEnableClientState(GL_COLOR_ARRAY);
+ glDisable(GL_LIGHTING);
+ }
+
+ /* draw parents last without lighting */
+ for(i=0, pa=psys->particles, path = psys->pathcache; i<totpart; i++, pa++, path++){
+ glVertexPointer(3, GL_FLOAT, sizeof(ParticleCacheKey), (*path)->co);
+ if(dt > OB_WIRE)
+ glNormalPointer(GL_FLOAT, sizeof(ParticleCacheKey), (*path)->vel);
+ if(dt > OB_WIRE || pset->brushtype == PE_BRUSH_WEIGHT)
+ glColorPointer(3, GL_FLOAT, sizeof(ParticleCacheKey), (*path)->col);
+
+ glDrawArrays(GL_LINE_STRIP, 0, (int)(*path)->steps + 1);
+ }
/* draw edit vertices */
if(G.scene->selectmode!=SCE_SELECT_PATH){
@@ -3742,6 +3838,7 @@ static void draw_particle_edit(Object *ob, ParticleSystem *psys)
glDisable(GL_BLEND);
glDisable(GL_LIGHTING);
+ glDisable(GL_COLOR_MATERIAL);
glDisableClientState(GL_COLOR_ARRAY);
glEnableClientState(GL_NORMAL_ARRAY);
glEnable(GL_DEPTH_TEST);
@@ -5137,12 +5234,12 @@ void draw_object(Base *base, int flag)
glDepthMask(GL_FALSE);
for(psys=ob->particlesystem.first; psys; psys=psys->next)
- draw_new_particle_system(base, psys);
+ draw_new_particle_system(base, psys, dt);
if(G.f & G_PARTICLEEDIT && ob==OBACT) {
psys= PE_get_current(ob);
if(psys && !G.obedit && psys_in_edit_mode(psys))
- draw_particle_edit(ob, psys);
+ draw_particle_edit(ob, psys, dt);
}
glDepthMask(GL_TRUE);
if(col) cpack(col);