Creating texture coordinates for Curve bevels didn't allocate a correct
sized memory block when both U and V directions of a bevel are circular.

This will also fix "UV orco" for such curves (like donut shapes).
This commit is contained in:
Ton Roosendaal
2006-06-21 10:02:47 +00:00
parent f28a1b438a
commit 985db6c4ef
2 changed files with 21 additions and 11 deletions

View File

@@ -1003,21 +1003,26 @@ float *make_orco_curve(Object *ob)
remakeDisp = 1;
}
/* Assumes displist has been built */
/* Assumes displist has been built */
numVerts = 0;
for (dl=cu->disp.first; dl; dl=dl->next) {
if (dl->type==DL_INDEX3) {
numVerts += dl->nr;
} else if (dl->type==DL_SURF) {
numVerts += dl->parts*dl->nr;
if (dl->flag & DL_CYCL_U)
numVerts+= dl->parts;
/* convertblender.c uses the Surface code for creating renderfaces when cyclic U only (closed circle beveling) */
if (dl->flag & DL_CYCL_U) {
if (dl->flag & DL_CYCL_V)
numVerts += (dl->parts+1)*(dl->nr+1);
else
numVerts += dl->parts*(dl->nr+1);
}
else
numVerts += dl->parts*dl->nr;
}
}
fp= orco= MEM_mallocN(3*sizeof(float)*numVerts, "cu_orco");
for (dl=cu->disp.first; dl; dl=dl->next) {
if (dl->type==DL_INDEX3) {
for (u=0; u<dl->nr; u++, fp+=3) {
@@ -1034,12 +1039,16 @@ float *make_orco_curve(Object *ob)
}
}
} else if (dl->type==DL_SURF) {
int sizeu= dl->nr;
int sizeu= dl->nr, sizev= dl->parts;
if (dl->flag & DL_CYCL_U)
/* exception as handled in convertblender.c too */
if (dl->flag & DL_CYCL_U) {
sizeu++;
for (u=0; u<dl->parts; u++) {
if (dl->flag & DL_CYCL_V)
sizev++;
}
for (u=0; u<sizev; u++) {
for (v=0; v<sizeu; v++,fp+=3) {
if (cu->flag & CU_UV_ORCO) {
fp[0]= 2.0f*u/(dl->parts-1) - 1.0f;

View File

@@ -2568,7 +2568,7 @@ static void init_render_curve(Render *re, Object *ob, int only_verts)
DispList *dl;
ListBase olddl={NULL, NULL};
Material *matar[32];
float len, *data, *fp, *orco=NULL;
float len, *data, *fp, *orco=NULL, *orcobase= NULL;
float n[3], mat[4][4];
int nr, startvert, startvlak, a, b;
int frontside, need_orco=0;
@@ -2600,7 +2600,7 @@ static void init_render_curve(Render *re, Object *ob, int only_verts)
}
}
if(need_orco) orco= get_object_orco(re, ob);
if(need_orco) orcobase=orco= get_object_orco(re, ob);
dl= cu->disp.first;
while(dl) {
@@ -2668,6 +2668,7 @@ static void init_render_curve(Render *re, Object *ob, int only_verts)
}
else if (dl->type==DL_SURF) {
/* cyclic U means an extruded full circular curve, we skip bevel splitting then */
if (dl->flag & DL_CYCL_U) {
orco+= 3*dl_surf_to_renderdata(re, ob, dl, matar, orco, mat);
}