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:
authorBrecht Van Lommel <brechtvanlommel@pandora.be>2006-11-10 02:47:28 +0300
committerBrecht Van Lommel <brechtvanlommel@pandora.be>2006-11-10 02:47:28 +0300
commit740e3233e0ddd76ec3caa2dd78760e88351a41b5 (patch)
tree28594bdc8d8262d313b7e2e7fc2a00be2758b48d /source/blender/radiosity
parent57a2f7a5b569d1d0564c45e33eae1ebad3cd560b (diff)
Modified the way face data is preserved in the radiosity module. There
is one user level change: the result is now no longer split up in meshes of maximum 64k faces, was a workaround for an old limitation.
Diffstat (limited to 'source/blender/radiosity')
-rw-r--r--source/blender/radiosity/extern/include/radio.h3
-rw-r--r--source/blender/radiosity/extern/include/radio_types.h22
-rw-r--r--source/blender/radiosity/intern/source/radio.c9
-rw-r--r--source/blender/radiosity/intern/source/radnode.c21
-rw-r--r--source/blender/radiosity/intern/source/radpostprocess.c627
-rw-r--r--source/blender/radiosity/intern/source/radpreprocess.c198
6 files changed, 348 insertions, 532 deletions
diff --git a/source/blender/radiosity/extern/include/radio.h b/source/blender/radiosity/extern/include/radio.h
index 23aa30e3bda..ba1917e9191 100644
--- a/source/blender/radiosity/extern/include/radio.h
+++ b/source/blender/radiosity/extern/include/radio.h
@@ -133,8 +133,7 @@ void addaccuweight(register char *z, register char *t, int w);
void triaweight(Face *face, int *w1, int *w2, int *w3);
void init_face_tab(void);
Face *addface(void);
-Face *makeface(float *v1, float *v2, float *v3, float *v4, RNode *rn, short hasUV);
-void dofaceuv(Face *face, float uvs[8][2], short flag1, short flag2, short flag3, short flag4);
+Face *makeface(float *v1, float *v2, float *v3, float *v4, RNode *rn);
void anchorQuadface(RNode *rn, float *v1, float *v2, float *v3, float *v4, int flag);
void anchorTriface(RNode *rn, float *v1, float *v2, float *v3, int flag);
float *findmiddlevertex(RNode *node, RNode *nb, float *v1, float *v2);
diff --git a/source/blender/radiosity/extern/include/radio_types.h b/source/blender/radiosity/extern/include/radio_types.h
index ae1f1e4f7ee..23ce17d9611 100644
--- a/source/blender/radiosity/extern/include/radio_types.h
+++ b/source/blender/radiosity/extern/include/radio_types.h
@@ -42,6 +42,7 @@
#include "DNA_material_types.h"
struct Render;
+struct TFace;
#define DTWIRE 0
#define DTGOUR 2
@@ -87,28 +88,14 @@ typedef struct RNode { /* length: 104 */
float totrad[3], area;
unsigned int col;
- float uv[4][2]; /* when you change this: also do function set_correct_uv in editmesh.c, and there are more locations that use the size of this part */
- struct TFace *tface;
+ unsigned int orig; /* index in face elem data */
} RNode;
-typedef struct Elem { /* length: 44 */
- struct RPatch *par;
-
- short type; /* type: 4==QUAD, 3==TRIA */
- short f; /* bit 0: patch, bit 1: shootelement */
- float *v1, *v2, *v3, *v4;
- float totrad[3], area;
-
- unsigned int col;
-} Elem;
-
-
typedef struct Face { /* length: 52 */
float *v1, *v2, *v3, *v4;
unsigned int col, matindex;
- float uv[4][2]; /* when you change this: also do function set_correct_uv in editmesh.c, and there are more locations that use the size of this part */
- struct TFace *tface;
+ unsigned int orig; /* index in face elem data */
} Face;
/* rp->f1 */
@@ -168,6 +155,9 @@ typedef struct {
/* to preserve materials as used before, max 16 */
Material *matar[MAXMAT];
int totmat;
+
+ struct RNode **mfdatanodes; /* nodes associated with the mfdata */
+ struct TFace *tface;
/* this part is a copy of struct Radio */
short hemires, maxiter;
diff --git a/source/blender/radiosity/intern/source/radio.c b/source/blender/radiosity/intern/source/radio.c
index 21292e14df3..6426592244a 100644
--- a/source/blender/radiosity/intern/source/radio.c
+++ b/source/blender/radiosity/intern/source/radio.c
@@ -143,6 +143,15 @@ void freeAllRad()
MEM_freeN(RG.facebase);
RG.facebase= 0;
}
+
+ if(RG.mfdatanodes) {
+ MEM_freeN(RG.mfdatanodes);
+ RG.mfdatanodes= NULL;
+ if(RG.tface) {
+ MEM_freeN(RG.tface);
+ RG.tface= NULL;
+ }
+ }
RG.totelem= RG.totpatch= RG.totvert= RG.totface= RG.totlamp= RG.totmat= 0;
}
diff --git a/source/blender/radiosity/intern/source/radnode.c b/source/blender/radiosity/intern/source/radnode.c
index d96649af30e..15901a66f1e 100644
--- a/source/blender/radiosity/intern/source/radnode.c
+++ b/source/blender/radiosity/intern/source/radnode.c
@@ -632,9 +632,6 @@ void subdivideTriNode(RNode *node, RNode *edge)
n1->v1[2]= 0.5*(node->v1[2]+ node->v2[2]);
n1->v1[3]= node->v1[3]; /* color */
}
- /* UVs */
- n1->uv[0][0] = n2->uv[1][0] = 0.5*(node->uv[0][0]+ node->uv[1][0]);
- n1->uv[0][1] = n2->uv[1][1] = 0.5*(node->uv[0][1]+ node->uv[1][1]);
}
else if(uvl==2) {
@@ -670,9 +667,6 @@ void subdivideTriNode(RNode *node, RNode *edge)
n1->v3[2]= 0.5*(node->v2[2]+ node->v3[2]);
n1->v3[3]= node->v1[3]; /* color */
}
- /* UVs */
- n1->uv[2][0] = n2->uv[1][0] = 0.5*(node->uv[1][0]+ node->uv[2][0]);
- n1->uv[2][1] = n2->uv[1][1] = 0.5*(node->uv[1][1]+ node->uv[2][1]);
}
else if(uvl==3) {
@@ -708,9 +702,6 @@ void subdivideTriNode(RNode *node, RNode *edge)
n1->v3[2]= 0.5*(node->v1[2]+ node->v3[2]);
n1->v3[3]= node->v3[3]; /* color */
}
- /* UVs */
- n1->uv[2][0] = n2->uv[0][0] = 0.5*(node->uv[0][0]+ node->uv[2][0]);
- n1->uv[2][1] = n2->uv[0][1] = 0.5*(node->uv[0][1]+ node->uv[2][1]);
}
n1->area= AreaT3Dfl(n1->v1, n1->v2, n1->v3);
n2->area= AreaT3Dfl(n2->v1, n2->v2, n2->v3);
@@ -837,9 +828,6 @@ void subdivideNode(RNode *node, RNode *edge)
n1->v1[2]= 0.5*(node->v1[2]+ node->v2[2]);
n1->v1[3]= node->v1[3]; /* color */
}
- /* UVs */
- n1->uv[0][0] = n2->uv[1][0] = 0.5*(node->uv[0][0]+ node->uv[1][0]);
- n1->uv[0][1] = n2->uv[1][1] = 0.5*(node->uv[0][1]+ node->uv[1][1]);
/* NEW VERTEX from edge 3 */
if( setvertexpointersNode(n1->ed3, n1, n1->lev3, &v1, &v2) ) { /* nodes have equal levels */
@@ -859,9 +847,6 @@ void subdivideNode(RNode *node, RNode *edge)
n1->v4[2]= 0.5*(node->v3[2]+ node->v4[2]);
n1->v4[3]= node->v4[3]; /* color */
}
- /* UVs */
- n1->uv[3][0] = n2->uv[2][0] = 0.5*(node->uv[2][0]+ node->uv[3][0]);
- n1->uv[3][1] = n2->uv[2][1] = 0.5*(node->uv[2][1]+ node->uv[3][1]);
}
/* subdivide edge 2 and 4 */
else if(uvl==2) {
@@ -902,9 +887,6 @@ void subdivideNode(RNode *node, RNode *edge)
n1->v3[2]= 0.5*(node->v2[2]+ node->v3[2]);
n1->v3[3]= node->v3[3]; /* color */
}
- /* UVs */
- n1->uv[2][0] = n2->uv[1][0] = 0.5*(node->uv[1][0]+ node->uv[2][0]);
- n1->uv[2][1] = n2->uv[1][1] = 0.5*(node->uv[1][1]+ node->uv[2][1]);
/* NEW VERTEX from edge 4 */
if( setvertexpointersNode(n1->ed4, n1, n1->lev4, &v1, &v2) ) { /* nodes have equal levels */
@@ -924,9 +906,6 @@ void subdivideNode(RNode *node, RNode *edge)
n1->v4[2]= 0.5*(node->v1[2]+ node->v4[2]);
n1->v4[3]= node->v4[3]; /* color */
}
- /* UVs */
- n1->uv[3][0] = n2->uv[0][0] = 0.5*(node->uv[0][0]+ node->uv[3][0]);
- n1->uv[3][1] = n2->uv[0][1] = 0.5*(node->uv[0][1]+ node->uv[3][1]);
}
n1->area= AreaQ3Dfl(n1->v1, n1->v2, n1->v3, n1->v4);
diff --git a/source/blender/radiosity/intern/source/radpostprocess.c b/source/blender/radiosity/intern/source/radpostprocess.c
index ff1f57b6021..16de4918742 100644
--- a/source/blender/radiosity/intern/source/radpostprocess.c
+++ b/source/blender/radiosity/intern/source/radpostprocess.c
@@ -60,17 +60,18 @@
#include "DNA_object_types.h"
#include "DNA_radio_types.h"
-#include "BKE_utildefines.h"
#include "BKE_global.h"
#include "BKE_main.h"
+#include "BKE_material.h"
#include "BKE_mesh.h"
#include "BKE_object.h"
-#include "BKE_material.h"
+#include "BKE_utildefines.h"
#include "BIF_screen.h" /* waitcursor */
#include "BIF_editview.h" /* deselectall */
#include "BDR_editobject.h" /* delete_obj */
+#include "BDR_editface.h" /* default_tface */
#include "radio.h"
@@ -172,18 +173,7 @@ Face *addface()
}
-#define HALFUV(uv, uv1, uv2) {uv[0] = 0.5 * (uv1[0] + uv2[0]); uv[1] = 0.5 * (uv1[1] + uv2[1]);}
-#define COPYUV(dst, src) {dst[0] = src[0]; dst[1] = src[1];}
-
-void dofaceuv(Face *face, float uvs[8][2], short flag1, short flag2, short flag3, short flag4)
-{
- COPYUV(face->uv[0], uvs[flag1]);
- COPYUV(face->uv[1], uvs[flag2]);
- COPYUV(face->uv[2], uvs[flag3]);
- COPYUV(face->uv[3], uvs[flag4]);
-}
-
-Face * makeface(float *v1, float *v2, float *v3, float *v4, RNode *rn, short hasUV)
+Face * makeface(float *v1, float *v2, float *v3, float *v4, RNode *rn)
{
Face *face;
@@ -194,10 +184,7 @@ Face * makeface(float *v1, float *v2, float *v3, float *v4, RNode *rn, short has
face->v4= v4;
face->col= rn->col;
face->matindex= rn->par->matindex;
- face->tface = rn->tface;
-
- if (hasUV)
- memcpy(face->uv, rn->uv, sizeof(float) * 4 * 2);
+ face->orig= rn->orig;
return face;
}
@@ -205,207 +192,90 @@ Face * makeface(float *v1, float *v2, float *v3, float *v4, RNode *rn, short has
void anchorQuadface(RNode *rn, float *v1, float *v2, float *v3, float *v4, int flag)
{
Face *face;
- float uvs[8][2];
-
- memcpy(uvs, rn->uv, sizeof(float) * 4 * 2);
- HALFUV(uvs[4], rn->uv[0], rn->uv[1]);
- HALFUV(uvs[5], rn->uv[1], rn->uv[2]);
- HALFUV(uvs[6], rn->uv[2], rn->uv[3]);
- HALFUV(uvs[7], rn->uv[3], rn->uv[0]);
switch(flag) {
case 1:
- face = makeface(rn->v1, v1, rn->v4, NULL, rn, 0);
- dofaceuv(face, uvs, 0, 4, 3, 0);
-
- face = makeface(v1, rn->v3, rn->v4, NULL, rn, 0);
- dofaceuv(face, uvs, 4, 2, 3, 0);
-
- face = makeface(v1, rn->v2, rn->v3, NULL, rn, 0);
- dofaceuv(face, uvs, 4, 1, 2, 0);
-
+ face = makeface(rn->v1, v1, rn->v4, NULL, rn);
+ face = makeface(v1, rn->v3, rn->v4, NULL, rn);
+ face = makeface(v1, rn->v2, rn->v3, NULL, rn);
break;
case 2:
- face = makeface(rn->v2, v2, rn->v1, NULL, rn, 0);
- dofaceuv(face, uvs, 1, 5, 0, 0);
-
- face = makeface(v2, rn->v4, rn->v1, NULL, rn, 0);
- dofaceuv(face, uvs, 5, 3, 0, 0);
-
- face = makeface(v2, rn->v3, rn->v4, NULL, rn, 0);
- dofaceuv(face, uvs, 5, 2, 3, 0);
-
+ face = makeface(rn->v2, v2, rn->v1, NULL, rn);
+ face = makeface(v2, rn->v4, rn->v1, NULL, rn);
+ face = makeface(v2, rn->v3, rn->v4, NULL, rn);
break;
case 4:
- face = makeface(rn->v3, v3, rn->v2, NULL, rn, 0);
- dofaceuv(face, uvs, 2, 6, 1, 0);
-
- face = makeface(v3, rn->v1, rn->v2, NULL, rn, 0);
- dofaceuv(face, uvs, 6, 0, 1, 0);
-
- face = makeface(v3, rn->v4, rn->v1, NULL, rn, 0);
- dofaceuv(face, uvs, 6, 3, 0, 0);
-
+ face = makeface(rn->v3, v3, rn->v2, NULL, rn);
+ face = makeface(v3, rn->v1, rn->v2, NULL, rn);
+ face = makeface(v3, rn->v4, rn->v1, NULL, rn);
break;
case 8:
- face = makeface(rn->v4, v4, rn->v3, NULL, rn, 0);
- dofaceuv(face, uvs, 3, 7, 2, 0);
-
- face = makeface(v4, rn->v2, rn->v3, NULL, rn, 0);
- dofaceuv(face, uvs, 7, 1, 2, 0);
-
- face = makeface(v4, rn->v1, rn->v2, NULL, rn, 0);
- dofaceuv(face, uvs, 7, 0, 1, 0);
-
+ face = makeface(rn->v4, v4, rn->v3, NULL, rn);
+ face = makeface(v4, rn->v2, rn->v3, NULL, rn);
+ face = makeface(v4, rn->v1, rn->v2, NULL, rn);
break;
-
case 3:
- face = makeface(rn->v1, v1, rn->v4, NULL, rn, 0);
- dofaceuv(face, uvs, 0, 4, 3, 0);
-
- face = makeface(v1, v2, rn->v4, NULL, rn, 0);
- dofaceuv(face, uvs, 4, 5, 3, 0);
-
- face = makeface(v1, rn->v2, v2, NULL, rn, 0);
- dofaceuv(face, uvs, 4, 1, 5, 0);
-
- face = makeface(v2, rn->v3, rn->v4, NULL, rn, 0);
- dofaceuv(face, uvs, 5, 2, 3, 0);
-
+ face = makeface(rn->v1, v1, rn->v4, NULL, rn);
+ face = makeface(v1, v2, rn->v4, NULL, rn);
+ face = makeface(v1, rn->v2, v2, NULL, rn);
+ face = makeface(v2, rn->v3, rn->v4, NULL, rn);
break;
case 6:
- face = makeface(rn->v2, v2, rn->v1, NULL, rn, 0);
- dofaceuv(face, uvs, 1, 5, 0, 0);
-
- face = makeface(v2, v3, rn->v1, NULL, rn, 0);
- dofaceuv(face, uvs, 5, 6, 0, 0);
-
- face = makeface(v2, rn->v3, v3, NULL, rn, 0);
- dofaceuv(face, uvs, 5, 2, 6, 0);
-
- face = makeface(v3, rn->v4, rn->v1, NULL, rn, 0);
- dofaceuv(face, uvs, 6, 3, 0, 0);
-
+ face = makeface(rn->v2, v2, rn->v1, NULL, rn);
+ face = makeface(v2, v3, rn->v1, NULL, rn);
+ face = makeface(v2, rn->v3, v3, NULL, rn);
+ face = makeface(v3, rn->v4, rn->v1, NULL, rn);
break;
case 12:
- face = makeface(rn->v3, v3, rn->v2, NULL, rn, 0);
- dofaceuv(face, uvs, 2, 6, 1, 0);
-
- face = makeface(v3, v4, rn->v2, NULL, rn, 0);
- dofaceuv(face, uvs, 6, 7, 1, 0);
-
- face = makeface(v3, rn->v4, v4, NULL, rn, 0);
- dofaceuv(face, uvs, 6, 3, 7, 0);
-
- face = makeface(v4, rn->v1, rn->v2, NULL, rn, 0);
- dofaceuv(face, uvs, 7, 0, 1, 0);
-
+ face = makeface(rn->v3, v3, rn->v2, NULL, rn);
+ face = makeface(v3, v4, rn->v2, NULL, rn);
+ face = makeface(v3, rn->v4, v4, NULL, rn);
+ face = makeface(v4, rn->v1, rn->v2, NULL, rn);
break;
case 9:
- face = makeface(rn->v4, v4, rn->v3, NULL, rn, 0);
- dofaceuv(face, uvs, 3, 7, 2, 0);
-
- face = makeface(v4, v1, rn->v3, NULL, rn, 0);
- dofaceuv(face, uvs, 7, 4, 2, 0);
-
- face = makeface(v4, rn->v1, v1, NULL, rn, 0);
- dofaceuv(face, uvs, 7, 0, 4, 0);
-
- face = makeface(v1, rn->v2, rn->v3, NULL, rn, 0);
- dofaceuv(face, uvs, 4, 1, 2, 0);
-
+ face = makeface(rn->v4, v4, rn->v3, NULL, rn);
+ face = makeface(v4, v1, rn->v3, NULL, rn);
+ face = makeface(v4, rn->v1, v1, NULL, rn);
+ face = makeface(v1, rn->v2, rn->v3, NULL, rn);
break;
-
case 5:
- face = makeface(rn->v1, v1, v3, rn->v4, rn, 0);
- dofaceuv(face, uvs, 0, 4, 6, 3);
-
- face = makeface(v1, rn->v2, rn->v3, v3, rn, 0);
- dofaceuv(face, uvs, 4, 1, 2, 6);
-
+ face = makeface(rn->v1, v1, v3, rn->v4, rn);
+ face = makeface(v1, rn->v2, rn->v3, v3, rn);
break;
case 10:
- face = makeface(rn->v1, rn->v2, v2, v4, rn, 0);
- dofaceuv(face, uvs, 0, 1, 5, 7);
-
- face = makeface(v4, v2, rn->v3, rn->v4, rn, 0);
- dofaceuv(face, uvs, 7, 5, 2, 3);
-
+ face = makeface(rn->v1, rn->v2, v2, v4, rn);
+ face = makeface(v4, v2, rn->v3, rn->v4, rn);
break;
-
case 7:
- face = makeface(rn->v1, v1, v3, rn->v4, rn, 0);
- dofaceuv(face, uvs, 0, 4, 6, 3);
-
- face = makeface(v1, v2, v3, NULL, rn, 0);
- dofaceuv(face, uvs, 4, 5, 6, 0);
-
- face = makeface(v1, rn->v2, v2, NULL, rn, 0);
- dofaceuv(face, uvs, 4, 1, 5, 0);
-
- face = makeface(v2, rn->v3, v3, NULL, rn, 0);
- dofaceuv(face, uvs, 5, 2, 6, 0);
-
+ face = makeface(rn->v1, v1, v3, rn->v4, rn);
+ face = makeface(v1, v2, v3, NULL, rn);
+ face = makeface(v1, rn->v2, v2, NULL, rn);
+ face = makeface(v2, rn->v3, v3, NULL, rn);
break;
case 14:
- face = makeface(rn->v2, v2, v4, rn->v1, rn, 0);
- dofaceuv(face, uvs, 1, 5, 7, 0);
-
- face = makeface(v2, v3, v4, NULL, rn, 0);
- dofaceuv(face, uvs, 5, 6, 7, 0);
-
- face = makeface(v2, rn->v3, v3, NULL, rn, 0);
- dofaceuv(face, uvs, 5, 2, 6, 0);
-
- face = makeface(v3, rn->v4, v4, NULL, rn, 0);
- dofaceuv(face, uvs, 6, 3, 7, 0);
-
+ face = makeface(rn->v2, v2, v4, rn->v1, rn);
+ face = makeface(v2, v3, v4, NULL, rn);
+ face = makeface(v2, rn->v3, v3, NULL, rn);
+ face = makeface(v3, rn->v4, v4, NULL, rn);
break;
case 13:
- face = makeface(rn->v3, v3, v1, rn->v2, rn, 0);
- dofaceuv(face, uvs, 2, 6, 4, 1);
-
- face = makeface(v3, v4, v1, NULL, rn, 0);
- dofaceuv(face, uvs, 6, 7, 4, 0);
-
- face = makeface(v3, rn->v4, v4, NULL, rn, 0);
- dofaceuv(face, uvs, 6, 3, 7, 0);
-
- face = makeface(v4, rn->v1, v1, NULL, rn, 0);
- dofaceuv(face, uvs, 7, 0, 4, 0);
-
+ face = makeface(rn->v3, v3, v1, rn->v2, rn);
+ face = makeface(v3, v4, v1, NULL, rn);
+ face = makeface(v3, rn->v4, v4, NULL, rn);
+ face = makeface(v4, rn->v1, v1, NULL, rn);
break;
case 11:
- face = makeface(rn->v4, v4, v2, rn->v3, rn, 0);
- dofaceuv(face, uvs, 3, 7, 5, 2);
-
- face = makeface(v4, v1, v2, NULL, rn, 0);
- dofaceuv(face, uvs, 7, 4, 5, 0);
-
- face = makeface(v4, rn->v1, v1, NULL, rn, 0);
- dofaceuv(face, uvs, 7, 0, 4, 0);
-
- face = makeface(v1, rn->v2, v2, NULL, rn, 0);
- dofaceuv(face, uvs, 4, 1, 5, 0);
-
+ face = makeface(rn->v4, v4, v2, rn->v3, rn);
+ face = makeface(v4, v1, v2, NULL, rn);
+ face = makeface(v4, rn->v1, v1, NULL, rn);
+ face = makeface(v1, rn->v2, v2, NULL, rn);
break;
-
case 15:
- face = makeface(v1, v2, v3, v4, rn, 0);
- dofaceuv(face, uvs, 4, 5, 6, 7);
-
- face = makeface(v1, rn->v2, v2, NULL, rn, 0);
- dofaceuv(face, uvs, 4, 1, 5, 0);
-
- face = makeface(v2, rn->v3, v3, NULL, rn, 0);
- dofaceuv(face, uvs, 5, 2, 6, 0);
-
- face = makeface(v3, rn->v4, v4, NULL, rn, 0);
- dofaceuv(face, uvs, 6, 3, 7, 0);
-
- face = makeface(v4, rn->v1, v1, NULL, rn, 0);
- dofaceuv(face, uvs, 7, 0, 4, 0);
-
+ face = makeface(v1, v2, v3, v4, rn);
+ face = makeface(v1, rn->v2, v2, NULL, rn);
+ face = makeface(v2, rn->v3, v3, NULL, rn);
+ face = makeface(v3, rn->v4, v4, NULL, rn);
+ face = makeface(v4, rn->v1, v1, NULL, rn);
break;
}
}
@@ -413,86 +283,41 @@ void anchorQuadface(RNode *rn, float *v1, float *v2, float *v3, float *v4, int f
void anchorTriface(RNode *rn, float *v1, float *v2, float *v3, int flag)
{
Face *face;
- float uvs[8][2];
-
- memcpy(uvs, rn->uv, sizeof(float) * 4 * 2);
- HALFUV(uvs[4], rn->uv[0], rn->uv[1]);
- HALFUV(uvs[5], rn->uv[1], rn->uv[2]);
- HALFUV(uvs[6], rn->uv[2], rn->uv[0]);
switch(flag) {
case 1:
- face = makeface(rn->v1, v1, rn->v3, NULL, rn, 0);
- dofaceuv(face, uvs, 0, 4, 2, 0);
-
- face = makeface(v1, rn->v2, rn->v3, NULL, rn, 0);
- dofaceuv(face, uvs, 4, 1, 2, 0);
-
+ face = makeface(rn->v1, v1, rn->v3, NULL, rn);
+ face = makeface(v1, rn->v2, rn->v3, NULL, rn);
break;
case 2:
- face = makeface(rn->v2, v2, rn->v1, NULL, rn, 0);
- dofaceuv(face, uvs, 1, 5, 0, 0);
-
- face = makeface(v2, rn->v3, rn->v1, NULL, rn, 0);
- dofaceuv(face, uvs, 5, 2, 0, 0);
-
+ face = makeface(rn->v2, v2, rn->v1, NULL, rn);
+ face = makeface(v2, rn->v3, rn->v1, NULL, rn);
break;
case 4:
- face = makeface(rn->v3, v3, rn->v2, NULL, rn, 0);
- dofaceuv(face, uvs, 2, 6, 1, 0);
-
- face = makeface(v3, rn->v1, rn->v2, NULL, rn, 0);
- dofaceuv(face, uvs, 6, 0, 1, 0);
-
+ face = makeface(rn->v3, v3, rn->v2, NULL, rn);
+ face = makeface(v3, rn->v1, rn->v2, NULL, rn);
break;
-
case 3:
- face = makeface(rn->v1, v2, rn->v3, NULL, rn, 0);
- dofaceuv(face, uvs, 0, 5, 2, 0);
-
- face = makeface(rn->v1, v1, v2, NULL, rn, 0);
- dofaceuv(face, uvs, 0, 4, 5, 0);
-
- face = makeface(v1, rn->v2, v2, NULL, rn, 0);
- dofaceuv(face, uvs, 4, 1, 5, 0);
-
+ face = makeface(rn->v1, v2, rn->v3, NULL, rn);
+ face = makeface(rn->v1, v1, v2, NULL, rn);
+ face = makeface(v1, rn->v2, v2, NULL, rn);
break;
case 6:
- face = makeface(rn->v2, v3, rn->v1, NULL, rn, 0);
- dofaceuv(face, uvs, 1, 6, 0, 0);
-
- face = makeface(rn->v2, v2, v3, NULL, rn, 0);
- dofaceuv(face, uvs, 1, 5, 6, 0);
-
- face = makeface(v2, rn->v3, v3, NULL, rn, 0);
- dofaceuv(face, uvs, 5, 2, 6, 0);
-
+ face = makeface(rn->v2, v3, rn->v1, NULL, rn);
+ face = makeface(rn->v2, v2, v3, NULL, rn);
+ face = makeface(v2, rn->v3, v3, NULL, rn);
break;
case 5:
- face = makeface(rn->v3, v1, rn->v2, NULL, rn, 0);
- dofaceuv(face, uvs, 2, 4, 1, 0);
-
- face = makeface(rn->v3, v3, v1, NULL, rn, 0);
- dofaceuv(face, uvs, 2, 6, 4, 0);
-
- face = makeface(v3, rn->v1, v1, NULL, rn, 0);
- dofaceuv(face, uvs, 6, 0, 4, 0);
-
+ face = makeface(rn->v3, v1, rn->v2, NULL, rn);
+ face = makeface(rn->v3, v3, v1, NULL, rn);
+ face = makeface(v3, rn->v1, v1, NULL, rn);
break;
case 7:
- face = makeface(v1, v2, v3, NULL, rn, 0);
- dofaceuv(face, uvs, 4, 5, 6, 0);
-
- face = makeface(rn->v1, v1, v3, NULL, rn, 0);
- dofaceuv(face, uvs, 0, 4, 6, 0);
-
- face = makeface(rn->v2, v2, v1, NULL, rn, 0);
- dofaceuv(face, uvs, 1, 5, 4, 0);
-
- face = makeface(rn->v3, v3, v2, NULL, rn, 0);
- dofaceuv(face, uvs, 2, 6, 5, 0);
-
+ face = makeface(v1, v2, v3, NULL, rn);
+ face = makeface(rn->v1, v1, v3, NULL, rn);
+ face = makeface(rn->v2, v2, v1, NULL, rn);
+ face = makeface(rn->v3, v3, v2, NULL, rn);
break;
}
}
@@ -602,7 +427,7 @@ void make_face_tab() /* takes care of anchoring */
/* using flag and vertexpointers now Faces can be made */
if(flag==0) {
- makeface(rn->v1, rn->v2, rn->v3, rn->v4, rn, 1);
+ makeface(rn->v1, rn->v2, rn->v3, rn->v4, rn);
}
else if(rn->type==4) anchorQuadface(rn, v1, v2, v3, v4, flag);
else anchorTriface(rn, v1, v2, v3, flag);
@@ -859,7 +684,22 @@ void removeEqualNodes(short limit)
waitcursor(0);
}
-#define BLSIZE 32000
+static void rad_interp_uv(float *v1, float *v2, float *v3, float *v4, float *co, TFace *tf, TFace *outtf, int j)
+{
+ float *uv, w[4];
+
+ uv = (float*)outtf->uv[j];
+
+ InterpWeightsQ3Dfl(v1, v2, v3, v4, co, w);
+
+ uv[0]= w[0]*tf->uv[0][0] + w[1]*tf->uv[1][0] + w[2]*tf->uv[2][0];
+ uv[1]= w[0]*tf->uv[0][1] + w[1]*tf->uv[1][1] + w[2]*tf->uv[2][1];
+
+ if (v4) {
+ uv[0] += w[3]*tf->uv[3][0];
+ uv[1] += w[3]*tf->uv[3][1];
+ }
+}
void rad_addmesh(void)
{
@@ -867,174 +707,161 @@ void rad_addmesh(void)
Object *ob;
Mesh *me;
MVert *mvert;
- MFace *mface;
- TFace *tface;
+ MFace *mf;
+ TFace *tf;
Material *ma=0;
- unsigned int *md, *coldata, *cd;
- float **fpp, **poindata;
+ float **vco, **vertexco;
float cent[3], min[3], max[3];
- int a, vcount, vlnr, startf, endf;
+ int a, nvert, i;
- if(RG.totface==0) return;
+ if(RG.totface==0)
+ return;
- if(RG.totmat==MAXMAT) notice("warning: cannot assign more than 16 materials to 1 mesh");
+ if(RG.totmat==MAXMAT)
+ notice("warning: cannot assign more than 16 materials to 1 mesh");
- /* make sure there's alpha in the color, to distinguish */
- for(a=0; a<RG.totface; a++) {
+ /* create the mesh */
+ ob= add_object(OB_MESH);
+
+ me= ob->data;
+ me->totvert= 0;
+ me->totface= RG.totface;
+ me->flag= 0;
+ me->mface= MEM_callocN(me->totface*sizeof(MFace), "mface");
+ me->tface= MEM_callocN(me->totface*sizeof(TFace), "tface");
+
+ /* create materials and set vertex color flag */
+ for(a=0; a<RG.totmat; a++) {
+ assign_material(ob, RG.matar[a], a+1);
+ ma= RG.matar[a];
+ if(ma) ma->mode |= MA_VERTEXCOL;
+ }
+
+ /* load Face vertex colors into TFace, with alpha added */
+ tf= me->tface;
+ for(a=0; a<me->totface; a++, tf++) {
RAD_NEXTFACE(a);
- *((unsigned int *)face->v1+3) |= 0x1000000;
- *((unsigned int *)face->v2+3) |= 0x1000000;
- *((unsigned int *)face->v3+3) |= 0x1000000;
- if(face->v4) {
- *((unsigned int *)face->v4+3) |= 0x1000000;
- }
+
+ if (RG.tface)
+ *tf= RG.tface[face->orig];
+ else
+ default_tface(tf);
+
+ tf->col[0]= *((unsigned int*)face->v1+3) | 0x1000000;
+ tf->col[1]= *((unsigned int*)face->v2+3) | 0x1000000;
+ tf->col[2]= *((unsigned int*)face->v3+3) | 0x1000000;
+ if(face->v4)
+ tf->col[3]= *((unsigned int*)face->v4+3) | 0x1000000;
}
-
- /* we write in blocks of BLSIZE vertices max */
- coldata= MEM_mallocN(4*BLSIZE, "writefaces");
- poindata= MEM_mallocN(sizeof(void *)*BLSIZE, "writefaces1");
-
- vlnr= 0;
- endf= 0;
- while(endf<RG.totface) {
-
- cd= coldata;
- fpp= poindata;
- startf= endf;
- vcount= 0;
-
- face= RG.facebase[(startf-1)>>10]+((startf-1) & 1023);
- for(vlnr=startf; vlnr<RG.totface; vlnr++) {
- RAD_NEXTFACE(vlnr);
-
- if( *((unsigned int *)face->v1+3) & 0x1000000 ) { /* is a color */
- *cd= *((unsigned int *)face->v1+3);
- *((unsigned int *)face->v1+3) = vcount;
- *fpp= face->v1;
- fpp++; vcount++; cd++;
- }
- if( *((unsigned int *)face->v2+3) & 0x1000000 ) {
- *cd= *((unsigned int *)face->v2+3);
- *((unsigned int *)face->v2+3) = vcount;
- *fpp= face->v2;
- fpp++; vcount++; cd++;
- }
- if( *((unsigned int *)face->v3+3) & 0x1000000 ) {
- *cd= *((unsigned int *)face->v3+3);
- *((unsigned int *)face->v3+3) = vcount;
- *fpp= face->v3;
- fpp++; vcount++; cd++;
- }
- if(face->v4 && ( *((unsigned int *)face->v4+3) & 0x1000000 ) ) {
- *cd= *((unsigned int *)face->v4+3);
- *((unsigned int *)face->v4+3) = vcount;
- *fpp= face->v4;
- fpp++; vcount++; cd++;
- }
- if(vcount>=BLSIZE-4) {
- vlnr++;
- break;
- }
- }
+ /* clear Face vertex color memory for vertex index assignment */
+ for(a=0; a<me->totface; a++) {
+ RAD_NEXTFACE(a);
- /* we now make the Mesh */
- endf= vlnr;
+ *((unsigned int*)face->v1+3)= ~0;
+ *((unsigned int*)face->v2+3)= ~0;
+ *((unsigned int*)face->v3+3)= ~0;
+ if(face->v4)
+ *((unsigned int*)face->v4+3)= ~0;
+ }
- ob= add_object(OB_MESH);
-
- me= ob->data;
- me->totvert= vcount;
- me->totface= endf-startf;
- me->flag= 0;
- me->mvert= MEM_callocN(me->totvert*sizeof(MVert), "mverts");
- //me->mcol= MEM_callocN(4*me->totface*sizeof(MCol), "mverts");
- me->mface= MEM_callocN(me->totface*sizeof(MFace), "mface");
- me->tface= MEM_callocN(me->totface*sizeof(TFace), "tface");
-
- /* materials, and set VCOL flag */
- for(a=0; a<RG.totmat; a++) {
- assign_material(ob, RG.matar[a], a+1);
- ma= RG.matar[a];
- if(ma) ma->mode |= MA_VERTEXCOL;
- }
+ /* create faces and create array with pointers to vertex coords */
+ vco= vertexco= MEM_mallocN(sizeof(float *)*4*RG.totface, "radiovertexco");
+ mf= me->mface;
- /* verts */
- mvert= me->mvert;
- fpp= poindata;
- for(a=0; a<me->totvert; a++, mvert++, fpp++) {
- VECCOPY(mvert->co, *fpp);
- }
+ for(a=0; a<me->totface; a++, mf++) {
+ RAD_NEXTFACE(a);
+ nvert= (face->v4)? 4: 3;
+
+ for(i=0; i<nvert; i++) {
+ unsigned int *col= ((unsigned int**)&face->v1)[i] + 3;
- /* faces, mcol and uv */
- mface= me->mface;
- tface = me->tface;
- md= (unsigned int *)me->mcol;
-
- face= RG.facebase[(startf-1)>>10]+((startf-1) & 1023);
- for(a=startf; a<endf; a++, md+=4, mface++, tface++) {
- RAD_NEXTFACE(a);
- mface->v1= *((unsigned int *)face->v1+3);
- mface->v2= *((unsigned int *)face->v2+3);
- mface->v3= *((unsigned int *)face->v3+3);
- if(face->v4) mface->v4= *((unsigned int *)face->v4+3);
- test_index_face(mface, NULL, NULL, face->v4 ? 4 : 3);
- mface->mat_nr= face->matindex;
-
- if (face->tface) {
- memcpy(tface, face->tface, sizeof(TFace));
+ if (*col == ~0) {
+ /* vertex has no index yet, so assign one */
+ *col= me->totvert;
+ *vco= ((float**)&face->v1)[i];
+ me->totvert++;
+ vco++;
}
- memcpy(tface->uv, face->uv, sizeof(float) * 4 * 2);
- tface->col[0]= coldata[mface->v1];
- tface->col[1]= coldata[mface->v2];
- tface->col[2]= coldata[mface->v3];
- tface->col[3]= coldata[mface->v4];
+ ((unsigned int*)&mf->v1)[i] = *col;
}
-
- /* boundbox and centrenew */
-
- INIT_MINMAX(min, max);
+ }
- mvert= me->mvert;
- for(a=0; a<me->totvert; a++, mvert++) {
- DO_MINMAX(mvert->co, min, max);
- }
+ /* create vertices */
+ mvert= me->mvert= MEM_callocN(me->totvert*sizeof(MVert), "mverts");
+ for(vco=vertexco, a=0; a<me->totvert; a++, mvert++, vco++) {
+ VECCOPY(mvert->co, *vco);
+ }
- cent[0]= (min[0]+max[0])/2.0f;
- cent[1]= (min[1]+max[1])/2.0f;
- cent[2]= (min[2]+max[2])/2.0f;
+ MEM_freeN(vertexco);
+
+ /* assign face data */
+ mf= me->mface;
+ tf= me->tface;
- mvert= me->mvert;
- for(a=0; a<me->totvert; a++, mvert++) {
- VecSubf(mvert->co, mvert->co, cent);
- }
-
- VECCOPY(ob->loc, cent);
-
- /* restore colors */
- face= RG.facebase[(startf-1)>>10]+((startf-1) & 1023);
- for(a=startf; a<endf; a++) {
- RAD_NEXTFACE(a);
-
- cd= ((unsigned int *)face->v1+3);
- if( *cd < 0x1000000 ) *cd= coldata[*cd];
- cd= ((unsigned int *)face->v2+3);
- if( *cd < 0x1000000 ) *cd= coldata[*cd];
- cd= ((unsigned int *)face->v3+3);
- if( *cd < 0x1000000 ) *cd= coldata[*cd];
- if(face->v4) {
- cd= ((unsigned int *)face->v4+3);
- if( *cd < 0x1000000 ) *cd= coldata[*cd];
+ for(a=0; a<me->totface; a++, mf++, tf++) {
+ TFace *origtf;
+ RNode *orignode;
+ float *subco;
+
+ RAD_NEXTFACE(a);
+ nvert= (face->v4)? 4: 3;
+
+ /* copy */
+ mf->mat_nr= face->matindex;
+
+ /* UV interpolation */
+ if (RG.tface) {
+ origtf= &RG.tface[face->orig];
+
+ orignode= RG.mfdatanodes[face->orig];
+
+ for(i=0; i<nvert; i++) {
+ subco= (me->mvert + ((unsigned int*)&mf->v1)[i])->co;
+
+ rad_interp_uv(orignode->v1, orignode->v2, orignode->v3,
+ orignode->v4, subco, origtf, tf, i);
}
}
- /* by default, meshes need edge list */
- make_edges(me, 0);
}
-
- MEM_freeN(coldata);
- MEM_freeN(poindata);
+
+ /* restore vertex colors, and test_index */
+ mf= me->mface;
+ tf= me->tface;
+ for(a=0; a<me->totface; a++, mf++, tf++) {
+ RAD_NEXTFACE(a);
+
+ *((unsigned int*)face->v1+3)= tf->col[0];
+ *((unsigned int*)face->v2+3)= tf->col[1];
+ *((unsigned int*)face->v3+3)= tf->col[2];
+ if(face->v4)
+ *((unsigned int*)face->v4+3)= tf->col[3];
+
+ test_index_face(mf, NULL, tf, face->v4? 4: 3);
+ }
+
+ /* boundbox and centre new */
+ INIT_MINMAX(min, max);
+
+ mvert= me->mvert;
+ for(a=0; a<me->totvert; a++, mvert++) {
+ DO_MINMAX(mvert->co, min, max);
+ }
+
+ cent[0]= (min[0]+max[0])/2.0f;
+ cent[1]= (min[1]+max[1])/2.0f;
+ cent[2]= (min[2]+max[2])/2.0f;
+
+ mvert= me->mvert;
+ for(a=0; a<me->totvert; a++, mvert++) {
+ VecSubf(mvert->co, mvert->co, cent);
+ }
+ VECCOPY(ob->loc, cent);
+
+ /* create edges */
+ make_edges(me, 0);
}
void rad_replacemesh(void)
diff --git a/source/blender/radiosity/intern/source/radpreprocess.c b/source/blender/radiosity/intern/source/radpreprocess.c
index 38a28db2a04..1a1cc6e76b3 100644
--- a/source/blender/radiosity/intern/source/radpreprocess.c
+++ b/source/blender/radiosity/intern/source/radpreprocess.c
@@ -57,14 +57,17 @@
#include "DNA_scene_types.h"
#include "DNA_view3d_types.h"
-#include "BKE_utildefines.h"
#include "BKE_global.h"
#include "BKE_main.h"
#include "BKE_material.h"
+#include "BKE_mesh.h"
#include "BKE_object.h" /* during_script() */
+#include "BKE_utildefines.h"
#include "BIF_toolbox.h"
+#include "BDR_editface.h"
+
#include "radio.h"
#ifdef HAVE_CONFIG_H
@@ -306,12 +309,13 @@ void rad_collect_meshes()
Mesh *me;
MVert *mvert;
MFace *mface;
+ TFace *tf, *tface;
Material *ma = NULL, *noma= NULL;
RPatch *rp;
RNode *rn;
VeNoCo *vnc, **nodevert;
float *vd, *v1, *v2, *v3, *v4 = NULL;
- int a, b, offs, index;
+ int a, b, offs, index, mfdatatot, hastface = 0;
if (G.vd==NULL) {
printf("Error, trying to collect radiosity meshes with no 3d view\n");
@@ -351,6 +355,8 @@ void rad_collect_meshes()
RG.min[0]= RG.min[1]= RG.min[2]= 1.0e20f;
RG.max[0]= RG.max[1]= RG.max[2]= -1.0e20f;
+
+ mfdatatot= 0;
/* min-max and material array */
base= (G.scene->base.first);
@@ -394,6 +400,10 @@ void rad_collect_meshes()
RG.totmat++;
}
}
+
+ mfdatatot += me->totface;
+ if (me->tface)
+ hastface= 1;
}
}
base= base->next;
@@ -407,6 +417,10 @@ void rad_collect_meshes()
RG.size[2]= (RG.max[2]- RG.min[2]);
RG.maxsize= MAX3(RG.size[0],RG.size[1],RG.size[2]);
+ RG.mfdatanodes= MEM_mallocN(sizeof(RNode*)*mfdatatot, "radiomfdatanodes");
+ if (hastface)
+ RG.tface= MEM_mallocN(sizeof(TFace)*mfdatatot, "radiotface");
+
/* make patches */
RG.totelem= 0;
@@ -421,107 +435,105 @@ void rad_collect_meshes()
ob= base->object;
me= ob->data;
mface= me->mface;
+ tface= me->tface;
index= -1;
for(a=0; a<me->totface; a++, mface++) {
- TFace *tface = me->tface ? &((TFace*)me->tface)[a] : NULL;
+ tf= tface? tface+a: NULL;
+
+ if (tf && (tf->mode & TF_INVISIBLE))
+ continue;
+
+ rp= callocPatch();
+ BLI_addtail(&(RG.patchbase), rp);
+ rp->from= ob;
+
+ if(mface->v4) rp->type= 4;
+ else rp->type= 3;
+
+ rp->first= rn= callocNode();
+
+ if(mface->flag & ME_SMOOTH) rp->f1= RAD_NO_SPLIT;
- if (tface == NULL || (tface->mode & TF_INVISIBLE)==0) {
-
- rp= callocPatch();
- BLI_addtail(&(RG.patchbase), rp);
- rp->from= ob;
-
- if(mface->v4) rp->type= 4;
- else rp->type= 3;
-
- rp->first= rn= callocNode();
-
- if(mface->flag & ME_SMOOTH) rp->f1= RAD_NO_SPLIT;
-
- /* temporal: we store the venoco in the node */
- rn->v1= (float *)(RG.verts+mface->v1+offs);
- v1= (RG.verts+mface->v1+offs)->v;
- rn->v2= (float *)(RG.verts+mface->v2+offs);
- v2= (RG.verts+mface->v2+offs)->v;
- rn->v3= (float *)(RG.verts+mface->v3+offs);
- v3= (RG.verts+mface->v3+offs)->v;
-
- if(mface->v4) {
- rn->v4= (float *)(RG.verts+mface->v4+offs);
- v4= (RG.verts+mface->v4+offs)->v;
- }
- rn->par= rp;
- rn->f= RAD_PATCH; /* this node is a Patch */
- rn->type= rp->type;
-
- if(rn->type==4) {
- rp->area= AreaQ3Dfl(v1, v2, v3, v4);
- CalcNormFloat4(v1, v2, v3, v4, rp->norm);
- }
- else {
- rp->area= AreaT3Dfl(v1, v2, v3);
- CalcNormFloat(v1, v2, v3, rp->norm);
- }
-
- if (tface) {
- memcpy(rn->uv, tface->uv, sizeof(float) * 4 * 2);
- rn->tface = tface;
- }
- else {
- rn->uv[0][0] = 0.0f;
- rn->uv[0][1] = 0.0f;
- rn->uv[1][0] = 1.0f;
- rn->uv[1][1] = 0.0f;
- rn->uv[2][0] = 1.0f;
- rn->uv[2][1] = 1.0f;
- rn->uv[3][0] = 0.0f;
- rn->uv[3][1] = 1.0f;
- rn->tface = NULL;
- }
-
- rn->area= rp->area;
-
- /* color and emit */
- if(mface->mat_nr != index) {
- index= mface->mat_nr;
- ma= give_current_material(ob, index+1);
- if(ma==0) ma= &defmaterial;
- }
- rp->ref[0]= ma->r;
- rp->ref[1]= ma->g;
- rp->ref[2]= ma->b;
-
- if(ma->emit) RG.totlamp++;
-
- rp->emit[0]= rp->emit[1]= rp->emit[2]= ma->emit;
- rp->emit[0]*= rp->ref[0];
- rp->emit[1]*= rp->ref[1];
- rp->emit[2]*= rp->ref[2];
+ /* temporal: we store the venoco in the node */
+ rn->v1= (float *)(RG.verts+mface->v1+offs);
+ v1= (RG.verts+mface->v1+offs)->v;
+ rn->v2= (float *)(RG.verts+mface->v2+offs);
+ v2= (RG.verts+mface->v2+offs)->v;
+ rn->v3= (float *)(RG.verts+mface->v3+offs);
+ v3= (RG.verts+mface->v3+offs)->v;
+
+ if(mface->v4) {
+ rn->v4= (float *)(RG.verts+mface->v4+offs);
+ v4= (RG.verts+mface->v4+offs)->v;
+ }
+ rn->par= rp;
+ rn->f= RAD_PATCH; /* this node is a Patch */
+ rn->type= rp->type;
+
+ if(rn->type==4) {
+ rp->area= AreaQ3Dfl(v1, v2, v3, v4);
+ CalcNormFloat4(v1, v2, v3, v4, rp->norm);
+ }
+ else {
+ rp->area= AreaT3Dfl(v1, v2, v3);
+ CalcNormFloat(v1, v2, v3, rp->norm);
+ }
+
+ rn->area= rp->area;
+
+ /* color and emit */
+ if(mface->mat_nr != index) {
+ index= mface->mat_nr;
+ ma= give_current_material(ob, index+1);
+ if(ma==0) ma= &defmaterial;
+ }
+ rp->ref[0]= ma->r;
+ rp->ref[1]= ma->g;
+ rp->ref[2]= ma->b;
+
+ if(ma->emit) RG.totlamp++;
+
+ rp->emit[0]= rp->emit[1]= rp->emit[2]= ma->emit;
+ rp->emit[0]*= rp->ref[0];
+ rp->emit[1]*= rp->ref[1];
+ rp->emit[2]*= rp->ref[2];
// uncommented, this is not satisfying, but i leave it in code for now (ton)
// if(ma->translucency!=0.0) rn->f |= RAD_TWOSIDED;
- nodevert= (VeNoCo **)&(rn->v1);
- for(b=0; b<rp->type; b++) {
- rp->cent[0]+= (*nodevert)->v[0];
- rp->cent[1]+= (*nodevert)->v[1];
- rp->cent[2]+= (*nodevert)->v[2];
- nodevert++;
- }
- rp->cent[0]/= (float)rp->type;
- rp->cent[1]/= (float)rp->type;
- rp->cent[2]/= (float)rp->type;
-
- /* for reconstruction materials */
- rp->matindex= materialIndex(ma);
- if(rp->matindex==-1) rp->matindex= 1;
-
- RG.totelem++;
- RG.totpatch++;
- }
+ nodevert= (VeNoCo **)&(rn->v1);
+ for(b=0; b<rp->type; b++) {
+ rp->cent[0]+= (*nodevert)->v[0];
+ rp->cent[1]+= (*nodevert)->v[1];
+ rp->cent[2]+= (*nodevert)->v[2];
+ nodevert++;
+ }
+ rp->cent[0]/= (float)rp->type;
+ rp->cent[1]/= (float)rp->type;
+ rp->cent[2]/= (float)rp->type;
+
+ /* for reconstruction materials */
+ rp->matindex= materialIndex(ma);
+ if(rp->matindex==-1) rp->matindex= 1;
+
+ /* these RNode's are stored now for later use in rad_addmesh
+ they should not get deleted before that */
+ rn->orig= RG.totelem;
+ RG.mfdatanodes[RG.totelem]= rn;
+
+ if (RG.tface) {
+ if (tf)
+ RG.tface[RG.totelem]= *tf;
+ else
+ default_tface(&RG.tface[RG.totelem]);
+ }
+
+ RG.totelem++;
+ RG.totpatch++;
}
+
offs+= me->totvert;
}
}