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:
authorTon Roosendaal <ton@blender.org>2006-11-21 00:25:02 +0300
committerTon Roosendaal <ton@blender.org>2006-11-21 00:25:02 +0300
commitc57d5bca73ce274f41febace72388e9e198d4d35 (patch)
treec1372d1a1e49beebbd98af27332824dadc3544bf /source/blender/blenkernel
parent208e69abab9d4a2581e3295f46728ff184fe77b2 (diff)
Step one in migrating to use glArray calls in Blender
- Curve/Nurbs/Font/MBall now all draw arrays. - had to flip abgr to rgba in shaded drawing - Mesh drawing can't be easily done; the indices for faces are not in in one chunk. Also need a way to gether trias/quads, per material. Speedup results are mixed. Something between 2-4 times. Especially for text it seems to help.
Diffstat (limited to 'source/blender/blenkernel')
-rw-r--r--source/blender/blenkernel/BKE_displist.h18
-rw-r--r--source/blender/blenkernel/intern/cdderivedmesh.c16
-rw-r--r--source/blender/blenkernel/intern/displist.c62
-rw-r--r--source/blender/blenkernel/intern/mball.c22
4 files changed, 71 insertions, 47 deletions
diff --git a/source/blender/blenkernel/BKE_displist.h b/source/blender/blenkernel/BKE_displist.h
index 4bcd5d8955c..04f3aadbe3c 100644
--- a/source/blender/blenkernel/BKE_displist.h
+++ b/source/blender/blenkernel/BKE_displist.h
@@ -85,28 +85,18 @@ struct Material;
struct Bone;
struct Mesh;
-/*
- * All the different DispList.type's use the
- * data in the displist structure in fairly
- * different ways which can be rather confusing,
- * the best thing to do would be to make a structure
- * for each displaylist type that has the fields
- * needed w/ proper names, and then make the actual
- * DispList structure a typed union.
- * - zr
- */
-
-/* needs splitting! */
+
+/* used for curves, nurbs, mball, importing */
typedef struct DispList {
struct DispList *next, *prev;
short type, flag;
int parts, nr;
- short col, rt; /* rt wordt gebruikt door initrenderNurbs */
+ short col, rt; /* rt used by initrenderNurbs */
float *verts, *nors;
int *index;
unsigned int *col1, *col2;
int charidx;
- int pad;
+ int totindex; /* indexed array drawing surfaces */
unsigned int *bevelSplitFlag;
} DispList;
diff --git a/source/blender/blenkernel/intern/cdderivedmesh.c b/source/blender/blenkernel/intern/cdderivedmesh.c
index 78ee6bb40e2..19898ebb03c 100644
--- a/source/blender/blenkernel/intern/cdderivedmesh.c
+++ b/source/blender/blenkernel/intern/cdderivedmesh.c
@@ -343,26 +343,26 @@ static void cdDM_drawFacesColored(DerivedMesh *dm, int useTwoSided, unsigned cha
glBegin(glmode = new_glmode);
}
- glColor3ub(cp1[3], cp1[2], cp1[1]);
+ glColor3ub(cp1[0], cp1[1], cp1[2]);
glVertex3fv(mvert[mface->v1].co);
- glColor3ub(cp1[7], cp1[6], cp1[5]);
+ glColor3ub(cp1[4], cp1[5], cp1[6]);
glVertex3fv(mvert[mface->v2].co);
- glColor3ub(cp1[11], cp1[10], cp1[9]);
+ glColor3ub(cp1[8], cp1[9], cp1[10]);
glVertex3fv(mvert[mface->v3].co);
if(mface->v4) {
- glColor3ub(cp1[15], cp1[14], cp1[13]);
+ glColor3ub(cp1[12], cp1[13], cp1[14]);
glVertex3fv(mvert[mface->v4].co);
}
if(useTwoSided) {
- glColor3ub(cp2[11], cp2[10], cp2[9]);
+ glColor3ub(cp2[8], cp2[9], cp2[10]);
glVertex3fv(mvert[mface->v3].co );
- glColor3ub(cp2[7], cp2[6], cp2[5]);
+ glColor3ub(cp2[4], cp2[5], cp2[6]);
glVertex3fv(mvert[mface->v2].co );
- glColor3ub(cp2[3], cp2[2], cp2[1]);
+ glColor3ub(cp2[0], cp2[1], cp2[2]);
glVertex3fv(mvert[mface->v1].co );
if(mface->v4) {
- glColor3ub(cp2[15], cp2[14], cp2[13]);
+ glColor3ub(cp2[12], cp2[13], cp2[14]);
glVertex3fv(mvert[mface->v4].co );
}
}
diff --git a/source/blender/blenkernel/intern/displist.c b/source/blender/blenkernel/intern/displist.c
index e8ac82fc596..763a4cdc0a0 100644
--- a/source/blender/blenkernel/intern/displist.c
+++ b/source/blender/blenkernel/intern/displist.c
@@ -196,14 +196,14 @@ void addnormalsDispList(Object *ob, ListBase *lb)
while(dl) {
if(dl->type==DL_INDEX3) {
- if(dl->nors==0) {
+ if(dl->nors==NULL) {
dl->nors= MEM_callocN(sizeof(float)*3, "dlnors");
if(dl->verts[2]<0.0) dl->nors[2]= -1.0;
else dl->nors[2]= 1.0;
}
}
else if(dl->type==DL_SURF) {
- if(dl->nors==0) {
+ if(dl->nors==NULL) {
dl->nors= MEM_callocN(sizeof(float)*3*dl->nr*dl->parts, "dlnors");
vdata= dl->verts;
@@ -276,7 +276,7 @@ void count_displist(ListBase *lb, int *totvert, int *totface)
}
-/* ***************************** shade displist ******************** */
+/* ***************************** shade displist. note colors now are in rgb(a) order ******************** */
/* create default shade input... save cpu cycles with ugly global */
static ShadeInput shi;
@@ -369,11 +369,11 @@ static void fastshade(float *co, float *nor, float *orco, float *uv, Material *m
VECADD(shr.combined, shr.diff, shr.spec);
a= 256.0f*(shr.combined[0]);
- col1[3]= CLAMPIS(a, 0, 255);
+ col1[0]= CLAMPIS(a, 0, 255);
a= 256.0f*(shr.combined[1]);
- col1[2]= CLAMPIS(a, 0, 255);
- a= 256.0f*(shr.combined[2]);
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];
@@ -386,11 +386,11 @@ static void fastshade(float *co, float *nor, float *orco, float *uv, Material *m
VECADD(shr.combined, shr.diff, shr.spec);
a= 256.0f*(shr.combined[0]);
- col2[3]= CLAMPIS(a, 0, 255);
+ col2[0]= CLAMPIS(a, 0, 255);
a= 256.0f*(shr.combined[1]);
- col2[2]= CLAMPIS(a, 0, 255);
- a= 256.0f*(shr.combined[2]);
col2[1]= CLAMPIS(a, 0, 255);
+ a= 256.0f*(shr.combined[2]);
+ col2[2]= CLAMPIS(a, 0, 255);
}
}
@@ -558,8 +558,17 @@ static void mesh_create_shadedColors(Render *re, Object *ob, int onlyForMesh, un
void shadeMeshMCol(Object *ob, Mesh *me)
{
+ int a;
+ char *cp;
+
Render *re= fastshade_get_render();
mesh_create_shadedColors(re, ob, 1, (unsigned int **)&me->mcol, NULL);
+
+ /* 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 */
@@ -1226,6 +1235,35 @@ void curve_calc_modifiers_post(Object *ob, ListBase *nurb, ListBase *dispbase, i
}
}
+static void displist_surf_indices(DispList *dl)
+{
+ int a, b, p1, p2, p3, p4;
+ int *index;
+
+ dl->totindex= 0;
+
+ index=dl->index= MEM_mallocN( 4*sizeof(int)*(dl->parts+1)*(dl->nr+1), "index array nurbs");
+
+ for(a=0; a<dl->parts; a++) {
+
+ DL_SURFINDEX(dl->flag & DL_CYCL_U, dl->flag & DL_CYCL_V, dl->nr, dl->parts);
+
+ for(; b<dl->nr; b++, index+=4) {
+ index[0]= p1;
+ index[1]= p2;
+ index[2]= p4;
+ index[3]= p3;
+
+ dl->totindex++;
+
+ p2= p1; p1++;
+ p4= p3; p3++;
+
+ }
+ }
+
+}
+
void makeDispListSurf(Object *ob, ListBase *dispbase, int forRender)
{
ListBase *nubase;
@@ -1288,6 +1326,9 @@ void makeDispListSurf(Object *ob, ListBase *dispbase, int forRender)
if(nu->flagu & CU_CYCLIC) dl->flag|= DL_CYCL_V;
makeNurbfaces(nu, data, 0);
+
+ /* gl array drawing: using indices */
+ displist_surf_indices(dl);
}
}
}
@@ -1440,6 +1481,9 @@ void makeDispListCurveTypes(Object *ob, int forOrco)
}
}
}
+
+ /* gl array drawing: using indices */
+ displist_surf_indices(dl);
}
}
diff --git a/source/blender/blenkernel/intern/mball.c b/source/blender/blenkernel/intern/mball.c
index 65a7a3f4f20..3c4b1526c8b 100644
--- a/source/blender/blenkernel/intern/mball.c
+++ b/source/blender/blenkernel/intern/mball.c
@@ -571,7 +571,7 @@ float metaball(float x, float y, float z)
/* ******************************************** */
-int *indices=0;
+int *indices=NULL;
int totindex, curindex;
@@ -593,25 +593,15 @@ void accum_mballfaces(int i1, int i2, int i3, int i4)
cur= indices+4*curindex;
- /* prevent zero codes for faces indices */
- if(i3==0) {
- if(i4) {
- i3= i4;
- i4= i1;
- i1= i2;
- i2= 0;
- }
- else {
- i3= i2;
- i2= i1;
- i1= 0;
- }
- }
+ /* diplists now support array drawing, we treat trias as fake quad */
cur[0]= i1;
cur[1]= i2;
cur[2]= i3;
- cur[3]= i4;
+ if(i4==0)
+ cur[3]= i3;
+ else
+ cur[3]= i4;
curindex++;