diff options
author | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2011-06-15 14:17:06 +0400 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2011-06-15 14:17:06 +0400 |
commit | aaf7dae5f18d918cce34e6c54eb971778cdd1bb9 (patch) | |
tree | 29524ad30652490664c4b10cce5c6d9d2568eb96 /source/blender/blenkernel | |
parent | 5e418071352977f0e55e0f84ffbb02ff8c5a6763 (diff) |
Code cleanup: remove unused shaded draw mode code.
Diffstat (limited to 'source/blender/blenkernel')
-rw-r--r-- | source/blender/blenkernel/BKE_displist.h | 5 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/blender.c | 1 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/displist.c | 496 |
3 files changed, 0 insertions, 502 deletions
diff --git a/source/blender/blenkernel/BKE_displist.h b/source/blender/blenkernel/BKE_displist.h index 68745975dae..b00db53a199 100644 --- a/source/blender/blenkernel/BKE_displist.h +++ b/source/blender/blenkernel/BKE_displist.h @@ -97,15 +97,10 @@ extern void makeDispListCurveTypes_forRender(struct Scene *scene, struct Object extern void makeDispListCurveTypes_forOrco(struct Scene *scene, struct Object *ob, struct ListBase *dispbase); extern void makeDispListMBall(struct Scene *scene, struct Object *ob); extern void makeDispListMBall_forRender(struct Scene *scene, struct Object *ob, struct ListBase *dispbase); -extern void shadeDispList(struct Scene *scene, struct Base *base); -extern void shadeMeshMCol(struct Scene *scene, struct Object *ob, struct Mesh *me); int surfindex_displist(DispList *dl, int a, int *b, int *p1, int *p2, int *p3, int *p4); -void reshadeall_displist(struct Scene *scene); void filldisplist(struct ListBase *dispbase, struct ListBase *to, int flipnormal); -void fastshade_free_render(void); - float calc_taper(struct Scene *scene, struct Object *taperobj, int cur, int tot); /* add Orco layer to the displist object which has got derived mesh and return orco */ diff --git a/source/blender/blenkernel/intern/blender.c b/source/blender/blenkernel/intern/blender.c index 5a9432552d2..0f545ad3ff9 100644 --- a/source/blender/blenkernel/intern/blender.c +++ b/source/blender/blenkernel/intern/blender.c @@ -154,7 +154,6 @@ static void clear_global(void) { // extern short winqueue_break; /* screen.c */ - fastshade_free_render(); /* lamps hang otherwise */ free_main(G.main); /* free all lib data */ // free_vertexpaint(); diff --git a/source/blender/blenkernel/intern/displist.c b/source/blender/blenkernel/intern/displist.c index 9aa794aa97e..8f57490d057 100644 --- a/source/blender/blenkernel/intern/displist.c +++ b/source/blender/blenkernel/intern/displist.c @@ -65,9 +65,6 @@ #include "BKE_lattice.h" #include "BKE_modifier.h" -#include "RE_pipeline.h" -#include "RE_shader_ext.h" - #include "BLO_sys_types.h" // for intptr_t support #include "ED_curve.h" /* for BKE_curve_nurbs */ @@ -286,499 +283,6 @@ int surfindex_displist(DispList *dl, int a, int *b, int *p1, int *p2, int *p3, i return 1; } -/* ***************************** shade displist. note colors now are in rgb(a) order ******************** */ - -/* create default shade input... save cpu cycles with ugly global */ -/* XXXX bad code warning: local ShadeInput initialize... */ -static ShadeInput shi; -static void init_fastshade_shadeinput(Render *re) -{ - memset(&shi, 0, sizeof(ShadeInput)); - shi.lay= RE_GetScene(re)->lay; - shi.view[2]= -1.0f; - shi.passflag= SCE_PASS_COMBINED; - shi.combinedflag= -1; -} - -static Render *fastshade_get_render(Scene *UNUSED(scene)) -{ - // XXX 2.5: this crashes combined with previewrender - // due to global R so disabled for now -#if 0 - /* XXX ugly global still, but we can't do preview while rendering */ - if(G.rendering==0) { - - Render *re= RE_GetRender("_Shade View_"); - if(re==NULL) { - re= RE_NewRender("_Shade View_"); - - RE_Database_Baking(re, scene, 0, 0); /* 0= no faces */ - } - return re; - } -#endif - - return NULL; -} - -/* called on file reading */ -void fastshade_free_render(void) -{ - Render *re= RE_GetRender("_Shade View_"); - - if(re) { - RE_Database_Free(re); - RE_FreeRender(re); - } -} - - -static void fastshade_customdata(CustomData *fdata, int a, int j, Material *ma) -{ - CustomDataLayer *layer; - MTFace *mtface; - int index, needuv= ma->texco & TEXCO_UV; - char *vertcol; - - shi.totuv= 0; - shi.totcol= 0; - - for(index=0; index<fdata->totlayer; index++) { - layer= &fdata->layers[index]; - - if(needuv && layer->type == CD_MTFACE && shi.totuv < MAX_MTFACE) { - mtface= &((MTFace*)layer->data)[a]; - - shi.uv[shi.totuv].uv[0]= 2.0f*mtface->uv[j][0]-1.0f; - shi.uv[shi.totuv].uv[1]= 2.0f*mtface->uv[j][1]-1.0f; - shi.uv[shi.totuv].uv[2]= 1.0f; - - shi.uv[shi.totuv].name= layer->name; - shi.totuv++; - } - else if(layer->type == CD_MCOL && shi.totcol < MAX_MCOL) { - vertcol= (char*)&((MCol*)layer->data)[a*4 + j]; - - shi.col[shi.totcol].col[0]= ((float)vertcol[3])/255.0f; - shi.col[shi.totcol].col[1]= ((float)vertcol[2])/255.0f; - shi.col[shi.totcol].col[2]= ((float)vertcol[1])/255.0f; - - shi.col[shi.totcol].name= layer->name; - shi.totcol++; - } - } - - if(needuv && shi.totuv == 0) - VECCOPY(shi.uv[0].uv, shi.lo); - - if(shi.totcol) - VECCOPY(shi.vcol, shi.col[0].col); -} - -static void fastshade(float *co, float *nor, float *orco, Material *ma, char *col1, char *col2) -{ - ShadeResult shr; - int a; - - VECCOPY(shi.co, co); - shi.vn[0]= -nor[0]; - shi.vn[1]= -nor[1]; - shi.vn[2]= -nor[2]; - VECCOPY(shi.vno, shi.vn); - VECCOPY(shi.facenor, shi.vn); - - if(ma->texco) { - VECCOPY(shi.lo, orco); - - if(ma->texco & TEXCO_GLOB) { - VECCOPY(shi.gl, shi.lo); - } - if(ma->texco & TEXCO_WINDOW) { - VECCOPY(shi.winco, shi.lo); - } - if(ma->texco & TEXCO_STICKY) { - VECCOPY(shi.sticky, shi.lo); - } - if(ma->texco & TEXCO_OBJECT) { - VECCOPY(shi.co, shi.lo); - } - if(ma->texco & TEXCO_NORM) { - VECCOPY(shi.orn, shi.vn); - } - if(ma->texco & TEXCO_REFL) { - float inp= 2.0f * (shi.vn[2]); - shi.ref[0]= (inp*shi.vn[0]); - shi.ref[1]= (inp*shi.vn[1]); - shi.ref[2]= (-1.0f + inp*shi.vn[2]); - } - } - - shi.mat= ma; /* set each time... node shaders change it */ - RE_shade_external(NULL, &shi, &shr); - - a= 256.0f*(shr.combined[0]); - col1[0]= CLAMPIS(a, 0, 255); - a= 256.0f*(shr.combined[1]); - col1[1]= CLAMPIS(a, 0, 255); - a= 256.0f*(shr.combined[2]); - col1[2]= CLAMPIS(a, 0, 255); - - if(col2) { - shi.vn[0]= -shi.vn[0]; - shi.vn[1]= -shi.vn[1]; - shi.vn[2]= -shi.vn[2]; - - shi.mat= ma; /* set each time... node shaders change it */ - RE_shade_external(NULL, &shi, &shr); - - a= 256.0f*(shr.combined[0]); - col2[0]= CLAMPIS(a, 0, 255); - a= 256.0f*(shr.combined[1]); - col2[1]= CLAMPIS(a, 0, 255); - a= 256.0f*(shr.combined[2]); - col2[2]= CLAMPIS(a, 0, 255); - } -} - -static void init_fastshade_for_ob(Render *re, Object *ob, int *need_orco_r, float mat[4][4], float imat[3][3]) -{ - float tmat[4][4]; - float amb[3]= {0.0f, 0.0f, 0.0f}; - int a; - - /* initialize globals in render */ - RE_shade_external(re, NULL, NULL); - - /* initialize global here */ - init_fastshade_shadeinput(re); - - RE_DataBase_GetView(re, tmat); - mul_m4_m4m4(mat, ob->obmat, tmat); - - invert_m4_m4(tmat, mat); - copy_m3_m4(imat, tmat); - if(ob->transflag & OB_NEG_SCALE) mul_m3_fl(imat, -1.0); - - if (need_orco_r) *need_orco_r= 0; - for(a=0; a<ob->totcol; a++) { - Material *ma= give_current_material(ob, a+1); - if(ma) { - init_render_material(ma, 0, amb); - - if(ma->texco & TEXCO_ORCO) { - if (need_orco_r) *need_orco_r= 1; - } - } - } -} - -static void end_fastshade_for_ob(Object *ob) -{ - int a; - - for(a=0; a<ob->totcol; a++) { - Material *ma= give_current_material(ob, a+1); - if(ma) - end_render_material(ma); - } -} - - -static void mesh_create_shadedColors(Render *re, Object *ob, int onlyForMesh, unsigned int **col1_r, unsigned int **col2_r) -{ - Mesh *me= ob->data; - DerivedMesh *dm; - MVert *mvert; - MFace *mface; - unsigned int *col1, *col2; - float *orco, *vnors, *nors, imat[3][3], mat[4][4], vec[3]; - int a, i, need_orco, totface, totvert; - CustomDataMask dataMask = CD_MASK_BAREMESH | CD_MASK_MCOL - | CD_MASK_MTFACE | CD_MASK_NORMAL; - - - init_fastshade_for_ob(re, ob, &need_orco, mat, imat); - - if(need_orco) - dataMask |= CD_MASK_ORCO; - - if (onlyForMesh) - dm = mesh_get_derived_deform(RE_GetScene(re), ob, dataMask); - else - dm = mesh_get_derived_final(RE_GetScene(re), ob, dataMask); - - mvert = dm->getVertArray(dm); - mface = dm->getFaceArray(dm); - nors = dm->getFaceDataArray(dm, CD_NORMAL); - totvert = dm->getNumVerts(dm); - totface = dm->getNumFaces(dm); - orco= dm->getVertDataArray(dm, CD_ORCO); - - if (onlyForMesh) { - col1 = *col1_r; - col2 = NULL; - } else { - *col1_r = col1 = MEM_mallocN(sizeof(*col1)*totface*4, "col1"); - - if (col2_r && (me->flag & ME_TWOSIDED)) - col2 = MEM_mallocN(sizeof(*col2)*totface*4, "col2"); - else - col2 = NULL; - - if (col2_r) *col2_r = col2; - } - - /* vertexnormals */ - vnors= MEM_mallocN(totvert*3*sizeof(float), "vnors disp"); - for (a=0; a<totvert; a++) { - MVert *mv = &mvert[a]; - float *vn= &vnors[a*3]; - float xn= mv->no[0]; - float yn= mv->no[1]; - float zn= mv->no[2]; - - /* transpose ! */ - vn[0]= imat[0][0]*xn+imat[0][1]*yn+imat[0][2]*zn; - vn[1]= imat[1][0]*xn+imat[1][1]*yn+imat[1][2]*zn; - vn[2]= imat[2][0]*xn+imat[2][1]*yn+imat[2][2]*zn; - normalize_v3(vn); - } - - for (i=0; i<totface; i++) { - MFace *mf= &mface[i]; - Material *ma= give_current_material(ob, mf->mat_nr+1); - int j, vidx[4], nverts= mf->v4?4:3; - unsigned char *col1base= (unsigned char*) &col1[i*4]; - unsigned char *col2base= (unsigned char*) (col2?&col2[i*4]:NULL); - float nor[3], n1[3]; - - if(ma==NULL) ma= &defmaterial; - - vidx[0]= mf->v1; - vidx[1]= mf->v2; - vidx[2]= mf->v3; - vidx[3]= mf->v4; - - if (nors) { - VECCOPY(nor, &nors[i*3]); - } else { - if (mf->v4) - normal_quad_v3( nor,mvert[mf->v1].co, mvert[mf->v2].co, mvert[mf->v3].co, mvert[mf->v4].co); - else - normal_tri_v3( nor,mvert[mf->v1].co, mvert[mf->v2].co, mvert[mf->v3].co); - } - - n1[0]= imat[0][0]*nor[0]+imat[0][1]*nor[1]+imat[0][2]*nor[2]; - n1[1]= imat[1][0]*nor[0]+imat[1][1]*nor[1]+imat[1][2]*nor[2]; - n1[2]= imat[2][0]*nor[0]+imat[2][1]*nor[1]+imat[2][2]*nor[2]; - normalize_v3(n1); - - for (j=0; j<nverts; j++) { - MVert *mv= &mvert[vidx[j]]; - char *col1= (char*)&col1base[j*4]; - char *col2= (char*)(col2base?&col2base[j*4]:NULL); - float *vn = (mf->flag & ME_SMOOTH)?&vnors[3*vidx[j]]:n1; - - mul_v3_m4v3(vec, mat, mv->co); - - mul_v3_v3fl(vec, vn, 0.001f); - - fastshade_customdata(&dm->faceData, i, j, ma); - fastshade(vec, vn, orco?&orco[vidx[j]*3]:mv->co, ma, col1, col2); - } - } - MEM_freeN(vnors); - - dm->release(dm); - - end_fastshade_for_ob(ob); -} - -void shadeMeshMCol(Scene *scene, Object *ob, Mesh *me) -{ - Render *re= fastshade_get_render(scene); - int a; - char *cp; - unsigned int *mcol= (unsigned int*)me->mcol; - - if(re) { - mesh_create_shadedColors(re, ob, 1, &mcol, NULL); - me->mcol= (MCol*)mcol; - - /* swap bytes */ - for(cp= (char *)me->mcol, a= 4*me->totface; a>0; a--, cp+=4) { - SWAP(char, cp[0], cp[3]); - SWAP(char, cp[1], cp[2]); - } - } -} - -/* has base pointer, to check for layer */ -/* called from drawobject.c */ -void shadeDispList(Scene *scene, Base *base) -{ - Object *ob= base->object; - DispList *dl, *dlob; - Material *ma = NULL; - Render *re; - float imat[3][3], mat[4][4], vec[3]; - float *fp, *nor, n1[3]; - unsigned int *col1; - int a, need_orco; - - re= fastshade_get_render(scene); - if(re==NULL) - return; - - dl = find_displist(&ob->disp, DL_VERTCOL); - if (dl) { - BLI_remlink(&ob->disp, dl); - free_disp_elem(dl); - } - - if(ob->type==OB_MESH) { - dl= MEM_callocN(sizeof(DispList), "displistshade"); - dl->type= DL_VERTCOL; - - mesh_create_shadedColors(re, ob, 0, &dl->col1, &dl->col2); - - /* add dl to ob->disp after mesh_create_shadedColors, because it - might indirectly free ob->disp */ - BLI_addtail(&ob->disp, dl); - } - else { - - init_fastshade_for_ob(re, ob, &need_orco, mat, imat); - - if (ELEM3(ob->type, OB_CURVE, OB_SURF, OB_FONT)) { - - /* now we need the normals */ - dl= ob->disp.first; - - while(dl) { - dlob= MEM_callocN(sizeof(DispList), "displistshade"); - BLI_addtail(&ob->disp, dlob); - dlob->type= DL_VERTCOL; - dlob->parts= dl->parts; - dlob->nr= dl->nr; - - if(dl->type==DL_INDEX3) { - col1= dlob->col1= MEM_mallocN(sizeof(int)*dl->nr, "col1"); - } - else { - col1= dlob->col1= MEM_mallocN(sizeof(int)*dl->parts*dl->nr, "col1"); - } - - - ma= give_current_material(ob, dl->col+1); - if(ma==NULL) ma= &defmaterial; - - if(dl->type==DL_INDEX3) { - if(dl->nors) { - /* there's just one normal */ - n1[0]= imat[0][0]*dl->nors[0]+imat[0][1]*dl->nors[1]+imat[0][2]*dl->nors[2]; - n1[1]= imat[1][0]*dl->nors[0]+imat[1][1]*dl->nors[1]+imat[1][2]*dl->nors[2]; - n1[2]= imat[2][0]*dl->nors[0]+imat[2][1]*dl->nors[1]+imat[2][2]*dl->nors[2]; - normalize_v3(n1); - - fp= dl->verts; - - a= dl->nr; - while(a--) { - mul_v3_m4v3(vec, mat, fp); - - fastshade(vec, n1, fp, ma, (char *)col1, NULL); - - fp+= 3; col1++; - } - } - } - else if(dl->type==DL_SURF) { - if(dl->nors) { - a= dl->nr*dl->parts; - fp= dl->verts; - nor= dl->nors; - - while(a--) { - mul_v3_m4v3(vec, mat, fp); - - n1[0]= imat[0][0]*nor[0]+imat[0][1]*nor[1]+imat[0][2]*nor[2]; - n1[1]= imat[1][0]*nor[0]+imat[1][1]*nor[1]+imat[1][2]*nor[2]; - n1[2]= imat[2][0]*nor[0]+imat[2][1]*nor[1]+imat[2][2]*nor[2]; - normalize_v3(n1); - - fastshade(vec, n1, fp, ma, (char *)col1, NULL); - - fp+= 3; nor+= 3; col1++; - } - } - } - dl= dl->next; - } - } - else if(ob->type==OB_MBALL) { - /* there are normals already */ - dl= ob->disp.first; - - while(dl) { - - if(dl->type==DL_INDEX4) { - if(dl->nors) { - if(dl->col1) MEM_freeN(dl->col1); - col1= dl->col1= MEM_mallocN(sizeof(int)*dl->nr, "col1"); - - ma= give_current_material(ob, dl->col+1); - if(ma==NULL) ma= &defmaterial; - - fp= dl->verts; - nor= dl->nors; - - a= dl->nr; - while(a--) { - mul_v3_m4v3(vec, mat, fp); - - /* transpose ! */ - n1[0]= imat[0][0]*nor[0]+imat[0][1]*nor[1]+imat[0][2]*nor[2]; - n1[1]= imat[1][0]*nor[0]+imat[1][1]*nor[1]+imat[1][2]*nor[2]; - n1[2]= imat[2][0]*nor[0]+imat[2][1]*nor[1]+imat[2][2]*nor[2]; - normalize_v3(n1); - - fastshade(vec, n1, fp, ma, (char *)col1, NULL); - - fp+= 3; col1++; nor+= 3; - } - } - } - dl= dl->next; - } - } - - end_fastshade_for_ob(ob); - } -} - -/* frees render and shade part of displists */ -/* note: dont do a shade again, until a redraw happens */ -void reshadeall_displist(Scene *scene) -{ - Base *base; - Object *ob; - - fastshade_free_render(); - - for(base= scene->base.first; base; base= base->next) { - ob= base->object; - - if(ELEM5(ob->type, OB_MESH, OB_CURVE, OB_SURF, OB_FONT, OB_MBALL)) - freedisplist(&ob->disp); - - if(base->lay & scene->lay) { - /* Metaballs have standard displist at the Object */ - if(ob->type==OB_MBALL) shadeDispList(scene, base); - } - } -} - /* ****************** make displists ********************* */ static void curve_to_displist(Curve *cu, ListBase *nubase, ListBase *dispbase, int forRender) |