Code cleanup: remove unused shaded draw mode code.
This commit is contained in:
@@ -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 */
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -235,7 +235,7 @@ int ED_mesh_uv_texture_remove(bContext *C, Object *ob, Mesh *me)
|
||||
return 1;
|
||||
}
|
||||
|
||||
int ED_mesh_color_add(bContext *C, Scene *scene, Object *ob, Mesh *me, const char *name, int active_set)
|
||||
int ED_mesh_color_add(bContext *C, Scene *UNUSED(scene), Object *UNUSED(ob), Mesh *me, const char *name, int active_set)
|
||||
{
|
||||
EditMesh *em;
|
||||
MCol *mcol;
|
||||
@@ -272,9 +272,6 @@ int ED_mesh_color_add(bContext *C, Scene *scene, Object *ob, Mesh *me, const cha
|
||||
CustomData_set_layer_active(&me->fdata, CD_MCOL, layernum);
|
||||
|
||||
mesh_update_customdata_pointers(me);
|
||||
|
||||
if(!mcol)
|
||||
shadeMeshMCol(scene, ob, me);
|
||||
}
|
||||
|
||||
DAG_id_tag_update(&me->id, 0);
|
||||
|
||||
@@ -823,8 +823,6 @@ static int object_delete_exec(bContext *C, wmOperator *UNUSED(op))
|
||||
}
|
||||
CTX_DATA_END;
|
||||
|
||||
if(islamp) reshadeall_displist(scene); /* only frees displist */
|
||||
|
||||
DAG_scene_sort(bmain, scene);
|
||||
DAG_ids_flush_update(bmain, 0);
|
||||
|
||||
|
||||
@@ -1127,8 +1127,6 @@ static int move_to_layer_exec(bContext *C, wmOperator *op)
|
||||
}
|
||||
CTX_DATA_END;
|
||||
}
|
||||
|
||||
if(islamp) reshadeall_displist(scene); /* only frees */
|
||||
|
||||
/* warning, active object may be hidden now */
|
||||
|
||||
|
||||
@@ -215,7 +215,7 @@ int draw_glsl_material(Scene *scene, Object *ob, View3D *v3d, int dt)
|
||||
if(ob==OBACT && (ob && ob->mode & OB_MODE_WEIGHT_PAINT))
|
||||
return 0;
|
||||
|
||||
return (scene->gm.matmode == GAME_MAT_GLSL) && (dt >= OB_SHADED);
|
||||
return (scene->gm.matmode == GAME_MAT_GLSL) && (dt > OB_SOLID);
|
||||
}
|
||||
|
||||
static int check_material_alpha(Base *base, Mesh *me, int glsl)
|
||||
@@ -2584,7 +2584,6 @@ static void draw_mesh_fancy(Scene *scene, ARegion *ar, View3D *v3d, RegionView3D
|
||||
const short is_paint_sel= (ob==OBACT && paint_facesel_test(ob));
|
||||
int draw_wire = 0;
|
||||
int /* totvert,*/ totedge, totface;
|
||||
DispList *dl;
|
||||
DerivedMesh *dm= mesh_get_derived_final(scene, ob, scene->customdata_mask);
|
||||
|
||||
if(!dm)
|
||||
@@ -2718,10 +2717,7 @@ static void draw_mesh_fancy(Scene *scene, ARegion *ar, View3D *v3d, RegionView3D
|
||||
}
|
||||
}
|
||||
else if(dt==OB_SHADED) {
|
||||
int do_draw= 1; /* to resolve all G.f settings below... */
|
||||
|
||||
if(ob==OBACT) {
|
||||
do_draw= 0;
|
||||
if(ob && ob->mode & OB_MODE_WEIGHT_PAINT) {
|
||||
/* enforce default material settings */
|
||||
GPU_enable_material(0, NULL);
|
||||
@@ -2750,38 +2746,6 @@ static void draw_mesh_fancy(Scene *scene, ARegion *ar, View3D *v3d, RegionView3D
|
||||
dm->drawMappedFaces(dm, wpaint__setSolidDrawOptions, NULL, 0, GPU_enable_material);
|
||||
}
|
||||
}
|
||||
else do_draw= 1;
|
||||
}
|
||||
if(do_draw) {
|
||||
dl = ob->disp.first;
|
||||
if (!dl || !dl->col1) {
|
||||
/* release and reload derivedmesh because it might be freed in
|
||||
shadeDispList due to a different datamask */
|
||||
dm->release(dm);
|
||||
shadeDispList(scene, base);
|
||||
dl = find_displist(&ob->disp, DL_VERTCOL);
|
||||
dm= mesh_get_derived_final(scene, ob, scene->customdata_mask);
|
||||
}
|
||||
|
||||
if ((v3d->flag&V3D_SELECT_OUTLINE) && ((v3d->flag2 & V3D_RENDER_OVERRIDE)==0) && (base->flag&SELECT) && !draw_wire) {
|
||||
draw_mesh_object_outline(v3d, ob, dm);
|
||||
}
|
||||
|
||||
/* False for dupliframe objects */
|
||||
if (dl) {
|
||||
unsigned int *obCol1 = dl->col1;
|
||||
unsigned int *obCol2 = dl->col2;
|
||||
|
||||
dm->drawFacesColored(dm, me->flag&ME_TWOSIDED, (unsigned char*) obCol1, (unsigned char*) obCol2);
|
||||
}
|
||||
|
||||
if(base->flag & SELECT) {
|
||||
UI_ThemeColor((ob==OBACT)?TH_ACTIVE:TH_SELECT);
|
||||
} else {
|
||||
UI_ThemeColor(TH_WIRE);
|
||||
}
|
||||
if((v3d->flag2 & V3D_RENDER_OVERRIDE)==0)
|
||||
dm->drawLooseEdges(dm);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3139,57 +3103,6 @@ static void drawDispListsolid(ListBase *lb, Object *ob, int glsl)
|
||||
glFrontFace(GL_CCW);
|
||||
}
|
||||
|
||||
static void drawDispListshaded(ListBase *lb, Object *ob)
|
||||
{
|
||||
DispList *dl, *dlob;
|
||||
unsigned int *cdata;
|
||||
|
||||
if(lb==NULL) return;
|
||||
|
||||
glShadeModel(GL_SMOOTH);
|
||||
glEnableClientState(GL_VERTEX_ARRAY);
|
||||
glEnableClientState(GL_COLOR_ARRAY);
|
||||
|
||||
dl= lb->first;
|
||||
dlob= ob->disp.first;
|
||||
while(dl && dlob) {
|
||||
|
||||
cdata= dlob->col1;
|
||||
if(cdata==NULL) break;
|
||||
|
||||
switch(dl->type) {
|
||||
case DL_SURF:
|
||||
if(dl->index) {
|
||||
glVertexPointer(3, GL_FLOAT, 0, dl->verts);
|
||||
glColorPointer(4, GL_UNSIGNED_BYTE, 0, cdata);
|
||||
glDrawElements(GL_QUADS, 4*dl->totindex, GL_UNSIGNED_INT, dl->index);
|
||||
}
|
||||
break;
|
||||
|
||||
case DL_INDEX3:
|
||||
|
||||
glVertexPointer(3, GL_FLOAT, 0, dl->verts);
|
||||
glColorPointer(4, GL_UNSIGNED_BYTE, 0, cdata);
|
||||
glDrawElements(GL_TRIANGLES, 3*dl->parts, GL_UNSIGNED_INT, dl->index);
|
||||
break;
|
||||
|
||||
case DL_INDEX4:
|
||||
|
||||
glVertexPointer(3, GL_FLOAT, 0, dl->verts);
|
||||
glColorPointer(4, GL_UNSIGNED_BYTE, 0, cdata);
|
||||
glDrawElements(GL_QUADS, 4*dl->parts, GL_UNSIGNED_INT, dl->index);
|
||||
break;
|
||||
}
|
||||
|
||||
dl= dl->next;
|
||||
dlob= dlob->next;
|
||||
}
|
||||
|
||||
glShadeModel(GL_FLAT);
|
||||
glDisableClientState(GL_VERTEX_ARRAY);
|
||||
glDisableClientState(GL_COLOR_ARRAY);
|
||||
}
|
||||
|
||||
static void drawCurveDMWired(Object *ob)
|
||||
{
|
||||
DerivedMesh *dm = ob->derivedFinal;
|
||||
@@ -3270,10 +3183,6 @@ static int drawDispList(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *bas
|
||||
drawDispListsolid(lb, ob, 1);
|
||||
GPU_end_object_materials();
|
||||
}
|
||||
else if(dt == OB_SHADED) {
|
||||
if(ob->disp.first==NULL) shadeDispList(scene, base);
|
||||
drawDispListshaded(lb, ob);
|
||||
}
|
||||
else {
|
||||
GPU_begin_object_materials(v3d, rv3d, scene, ob, 0, NULL);
|
||||
glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, 0);
|
||||
@@ -3312,10 +3221,6 @@ static int drawDispList(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *bas
|
||||
drawDispListsolid(lb, ob, 1);
|
||||
GPU_end_object_materials();
|
||||
}
|
||||
else if(dt==OB_SHADED) {
|
||||
if(ob->disp.first==NULL) shadeDispList(scene, base);
|
||||
drawDispListshaded(lb, ob);
|
||||
}
|
||||
else {
|
||||
GPU_begin_object_materials(v3d, rv3d, scene, ob, 0, NULL);
|
||||
glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, 0);
|
||||
@@ -3341,11 +3246,6 @@ static int drawDispList(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *bas
|
||||
drawDispListsolid(lb, ob, 1);
|
||||
GPU_end_object_materials();
|
||||
}
|
||||
else if(dt == OB_SHADED) {
|
||||
dl= lb->first;
|
||||
if(dl && dl->col1==NULL) shadeDispList(scene, base);
|
||||
drawDispListshaded(lb, ob);
|
||||
}
|
||||
else {
|
||||
GPU_begin_object_materials(v3d, rv3d, scene, ob, 0, NULL);
|
||||
glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, 0);
|
||||
@@ -6311,7 +6211,7 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, int flag)
|
||||
}
|
||||
}
|
||||
|
||||
if(dt<OB_SHADED && (v3d->flag2 & V3D_RENDER_OVERRIDE)==0) {
|
||||
if(dt<=OB_SOLID && (v3d->flag2 & V3D_RENDER_OVERRIDE)==0) {
|
||||
if((ob->gameflag & OB_DYNAMIC) ||
|
||||
((ob->gameflag & OB_BOUNDS) && (ob->boundtype == OB_BOUND_SPHERE))) {
|
||||
float imat[4][4], vec[3]= {0.0f, 0.0f, 0.0f};
|
||||
|
||||
@@ -2074,10 +2074,6 @@ static void gpu_update_lamps_shadows(Scene *scene, View3D *v3d)
|
||||
CustomDataMask ED_view3d_datamask(Scene *scene, View3D *v3d)
|
||||
{
|
||||
CustomDataMask mask= 0;
|
||||
if(v3d->drawtype == OB_SHADED) {
|
||||
/* this includes normals for mesh_create_shadedColors */
|
||||
mask |= CD_MASK_MTFACE | CD_MASK_MCOL | CD_MASK_NORMAL | CD_MASK_ORCO;
|
||||
}
|
||||
if((v3d->drawtype == OB_TEXTURE) || ((v3d->drawtype == OB_SOLID) && (v3d->flag2 & V3D_SOLID_TEX))) {
|
||||
mask |= CD_MASK_MTFACE | CD_MASK_MCOL;
|
||||
|
||||
|
||||
@@ -5077,10 +5077,6 @@ void special_aftertrans_update(bContext *C, TransInfo *t)
|
||||
#if 0 // TRANSFORM_FIX_ME
|
||||
if(resetslowpar)
|
||||
reset_slowparents();
|
||||
|
||||
/* note; should actually only be done for all objects when a lamp is moved... (ton) */
|
||||
if(t->spacetype==SPACE_VIEW3D && G.vd->drawtype == OB_SHADED)
|
||||
reshadeall_displist();
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@@ -840,9 +840,6 @@ void recalcData(TransInfo *t)
|
||||
DAG_id_tag_update(&ob->id, OB_RECALC_OB);
|
||||
}
|
||||
}
|
||||
|
||||
if(((View3D*)t->view)->drawtype == OB_SHADED)
|
||||
reshadeall_displist(t->scene);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -208,7 +208,6 @@ struct Render;
|
||||
struct Image;
|
||||
struct Object;
|
||||
|
||||
void RE_shade_external(struct Render *re, struct ShadeInput *shi, struct ShadeResult *shr);
|
||||
int RE_bake_shade_all_selected(struct Render *re, int type, struct Object *actob, short *do_update, float *progress);
|
||||
struct Image *RE_bake_shade_get_image(void);
|
||||
void RE_bake_ibuf_filter(struct ImBuf *ibuf, unsigned char *mask, const int filter);
|
||||
|
||||
@@ -1956,40 +1956,6 @@ void add_halo_flare(Render *re)
|
||||
R.r.mode= mode;
|
||||
}
|
||||
|
||||
/* ************************* used for shaded view ************************ */
|
||||
|
||||
/* if *re, then initialize, otherwise execute */
|
||||
void RE_shade_external(Render *re, ShadeInput *shi, ShadeResult *shr)
|
||||
{
|
||||
static VlakRen vlr;
|
||||
static ObjectRen obr;
|
||||
static ObjectInstanceRen obi;
|
||||
|
||||
/* init */
|
||||
if(re) {
|
||||
R= *re;
|
||||
|
||||
/* fake render face */
|
||||
memset(&vlr, 0, sizeof(VlakRen));
|
||||
memset(&obr, 0, sizeof(ObjectRen));
|
||||
memset(&obi, 0, sizeof(ObjectInstanceRen));
|
||||
obr.lay= -1;
|
||||
obi.obr= &obr;
|
||||
|
||||
return;
|
||||
}
|
||||
shi->vlr= &vlr;
|
||||
shi->obr= &obr;
|
||||
shi->obi= &obi;
|
||||
|
||||
if(shi->mat->nodetree && shi->mat->use_nodes)
|
||||
ntreeShaderExecTree(shi->mat->nodetree, shi, shr);
|
||||
else {
|
||||
shade_input_init_material(shi);
|
||||
shade_material_loop(shi, shr);
|
||||
}
|
||||
}
|
||||
|
||||
/* ************************* bake ************************ */
|
||||
|
||||
|
||||
|
||||
@@ -379,7 +379,6 @@ void WM_exit(bContext *C)
|
||||
|
||||
BKE_freecubetable();
|
||||
|
||||
fastshade_free_render(); /* shaded view */
|
||||
ED_preview_free_dbase(); /* frees a Main dbase, before free_blender! */
|
||||
|
||||
if(C && CTX_wm_manager(C))
|
||||
|
||||
Reference in New Issue
Block a user