--- ray/src/gen/gensurf.c 2011/08/15 19:48:06 2.20 +++ ray/src/gen/gensurf.c 2013/12/09 22:08:13 2.22 @@ -1,5 +1,5 @@ #ifndef lint -static const char RCSid[] = "$Id: gensurf.c,v 2.20 2011/08/15 19:48:06 greg Exp $"; +static const char RCSid[] = "$Id: gensurf.c,v 2.22 2013/12/09 22:08:13 greg Exp $"; #endif /* * gensurf.c - program to generate functional surfaces @@ -58,6 +58,7 @@ double l_hermite(), l_bezier(), l_bspline(), l_datava typedef struct { int valid; /* point is valid (vertex number) */ + int nvalid; /* normal is valid */ FVECT p; /* vertex position */ FVECT n; /* average normal */ RREAL uv[2]; /* (u,v) position */ @@ -197,8 +198,8 @@ loaddata( /* load point data from file */ { FILE *fp; char word[64]; - register int size; - register RREAL *dp; + int size; + RREAL *dp; datarec.flags = HASBORDER; /* assume border values */ datarec.m = m+1; @@ -254,8 +255,8 @@ l_dataval( /* return recorded data value */ ) { double u, v; - register int i, j; - register RREAL *dp; + int i, j; + RREAL *dp; double d00, d01, d10, d11; /* compute coordinates */ u = argument(1); v = argument(2); @@ -293,20 +294,24 @@ l_dataval( /* return recorded data value */ void putobjrow( /* output vertex row to .OBJ */ - register POINT *rp, + POINT *rp, int n ) { static int nverts = 0; + static int nnorms = 0; for ( ; n-- >= 0; rp++) { if (!rp->valid) continue; fputs("v ", stdout); pvect(rp->p); - if (smooth && !ZEROVECT(rp->n)) + if (smooth && !ZEROVECT(rp->n)) { printf("\tvn %.9g %.9g %.9g\n", rp->n[0], rp->n[1], rp->n[2]); + rp->nvalid = ++nnorms; + } else + rp->nvalid = 0; printf("\tvt %.9g %.9g\n", rp->uv[0], rp->uv[1]); rp->valid = ++nverts; } @@ -344,35 +349,24 @@ putsquare( /* put out a square */ if (!(ok1 | ok2)) return; if (objout) { /* output .OBJ faces */ - int p0n=0, p1n=0, p2n=0, p3n=0; - if (smooth) { - if (!ZEROVECT(p0->n)) - p0n = p0->valid; - if (!ZEROVECT(p1->n)) - p1n = p1->valid; - if (!ZEROVECT(p2->n)) - p2n = p2->valid; - if (!ZEROVECT(p3->n)) - p3n = p3->valid; - } if (ok1 & ok2 && fdot(vc1,vc2) >= 1.0-FTINY*FTINY) { printf("f %d/%d/%d %d/%d/%d %d/%d/%d %d/%d/%d\n", - p0->valid, p0->valid, p0n, - p1->valid, p1->valid, p1n, - p3->valid, p3->valid, p3n, - p2->valid, p2->valid, p2n); + p0->valid, p0->valid, p0->nvalid, + p1->valid, p1->valid, p1->nvalid, + p3->valid, p3->valid, p3->nvalid, + p2->valid, p2->valid, p2->nvalid); return; } if (ok1) printf("f %d/%d/%d %d/%d/%d %d/%d/%d\n", - p0->valid, p0->valid, p0n, - p1->valid, p1->valid, p1n, - p2->valid, p2->valid, p2n); + p0->valid, p0->valid, p0->nvalid, + p1->valid, p1->valid, p1->nvalid, + p2->valid, p2->valid, p2->nvalid); if (ok2) printf("f %d/%d/%d %d/%d/%d %d/%d/%d\n", - p2->valid, p2->valid, p2n, - p1->valid, p1->valid, p1n, - p3->valid, p3->valid, p3n); + p2->valid, p2->valid, p2->nvalid, + p1->valid, p1->valid, p1->nvalid, + p3->valid, p3->valid, p3->nvalid); return; } /* compute normal interpolation */ @@ -443,14 +437,14 @@ putsquare( /* put out a square */ void comprow( /* compute row of values */ double s, - register POINT *row, + POINT *row, int siz ) { double st[2]; int end; int checkvalid; - register int i; + int i; if (smooth) { i = -1; /* compute one past each end */ @@ -484,9 +478,9 @@ comprow( /* compute row of values */ void compnorms( /* compute row of averaged normals */ - register POINT *r0, - register POINT *r1, - register POINT *r2, + POINT *r0, + POINT *r1, + POINT *r2, int siz ) { @@ -527,7 +521,7 @@ compnorms( /* compute row of averaged normals */ int norminterp( /* compute normal interpolation */ - register FVECT resmat[4], + FVECT resmat[4], POINT *p0, POINT *p1, POINT *p2, @@ -537,10 +531,10 @@ norminterp( /* compute normal interpolation */ #define u ((ax+1)%3) #define v ((ax+2)%3) - register int ax; + int ax; MAT4 eqnmat; FVECT v1; - register int i, j; + int i, j; if (!smooth) /* no interpolation if no smoothing */ return(-1);