--- ray/src/hd/rhpict2.c 1999/03/10 16:15:19 3.9 +++ ray/src/hd/rhpict2.c 2004/01/01 11:21:55 3.15 @@ -1,13 +1,12 @@ -/* Copyright (c) 1999 Silicon Graphics, Inc. */ - #ifndef lint -static char SCCSid[] = "$SunId$ SGI"; +static const char RCSid[] = "$Id: rhpict2.c,v 3.15 2004/01/01 11:21:55 schorsch Exp $"; #endif - /* * Rendering routines for rhpict. */ +#include + #include "holo.h" #include "view.h" #include "random.h" @@ -38,10 +37,10 @@ static char SCCSid[] = "$SunId$ SGI"; #define CLR4(f,i) FL4OP(f,i,&=~) #define TGL4(f,i) FL4OP(f,i,^=) #define FL4NELS(n) (((n)+0x1f)>>5) -#define CLR4ALL(f,n) bzero((char *)(f),FL4NELS(n)*sizeof(int4)) +#define CLR4ALL(f,n) memset((char *)(f),'\0',FL4NELS(n)*sizeof(int32)) #endif -static int4 *pixFlags; /* pixel occupancy flags */ +static int32 *pixFlags; /* pixel occupancy flags */ static float pixWeight[MAXRAD2]; /* pixel weighting function */ static short isqrttab[MAXRAD2]; /* integer square root table */ @@ -53,10 +52,26 @@ extern float *myweight; /* weights (used to compute fi extern float *mydepth; /* depth values (visibility culling) */ extern int hres, vres; /* current horizontal and vertical res. */ +extern void pixFinish(double ransamp); +extern void pixBeam(BEAM *bp, HDBEAMI *hb); -pixBeam(bp, hb) /* render a particular beam */ -BEAM *bp; -register HDBEAMI *hb; +typedef int (sampfunc)(int h, int v, short nl[NNEIGH][2], int nd[NNEIGH], + int n, double *rf); +static sampfunc kill_occl; +static sampfunc smooth_samp; +static sampfunc random_samp; +static void meet_neighbors(int occ, sampfunc *nf, double *dp); +static void reset_flags(void); +static void init_wfunc(void); +static int findneigh(short nl[NNEIGH][2], int nd[NNEIGH], int h, int v, + register short (*rnl)[NNEIGH]); + + +extern void +pixBeam( /* render a particular beam */ + BEAM *bp, + register HDBEAMI *hb +) { GCOORD gc[2]; register RAYVAL *rv; @@ -64,7 +79,7 @@ register HDBEAMI *hb; double d, prox; COLOR col; int n; - register int4 p; + register int32 p; if (!hdbcoord(gc, hb->h, hb->b)) error(CONSISTENCY, "bad beam in render_beam"); @@ -111,17 +126,20 @@ register HDBEAMI *hb; } -int -kill_occl(h, v, nl, nd, n) /* check for occlusion errors */ -int h, v; -register short nl[NNEIGH][2]; -int nd[NNEIGH]; -int n; +static int +kill_occl( /* check for occlusion errors */ + int h, + int v, + register short nl[NNEIGH][2], + int nd[NNEIGH], + int n, + double *rf +) { short forequad[2][2]; int d; register int i; - register int4 p; + register int32 p; if (n <= 0) { #ifdef DEBUG @@ -144,18 +162,21 @@ int n; } -int -smooth_samp(h, v, nl, nd, n) /* grow sample point smoothly */ -int h, v; -register short nl[NNEIGH][2]; -int nd[NNEIGH]; -int n; +static int +smooth_samp( /* grow sample point smoothly */ + int h, + int v, + register short nl[NNEIGH][2], + int nd[NNEIGH], + int n, + double *rf +) { int dis[NNEIGH], ndis; COLOR mykern[MAXRAD2]; int maxr2; double d; - register int4 p; + register int32 p; register int r2; int i, r, maxr, h2, v2; @@ -206,17 +227,19 @@ int n; } -int -random_samp(h, v, nl, nd, n, rf) /* gather samples randomly */ -int h, v; -register short nl[NNEIGH][2]; -int nd[NNEIGH]; -int n; -double *rf; +static int +random_samp( /* gather samples randomly */ + int h, + int v, + register short nl[NNEIGH][2], + int nd[NNEIGH], + int n, + double *rf +) { float rnt[NNEIGH]; double rvar; - register int4 p, pn; + register int32 p, pn; register int ni; if (n <= 0) @@ -240,8 +263,10 @@ double *rf; } -pixFinish(ransamp) /* done with beams -- compute pixel values */ -double ransamp; +extern void +pixFinish( /* done with beams -- compute pixel values */ + double ransamp +) { if (pixWeight[0] <= FTINY) init_wfunc(); /* initialize weighting function */ @@ -252,17 +277,18 @@ double ransamp; meet_neighbors(0,random_samp,&ransamp); else meet_neighbors(1,smooth_samp,NULL); - free((char *)pixFlags); /* free pixel flags */ + free((void *)pixFlags); /* free pixel flags */ pixFlags = NULL; } -reset_flags() /* allocate/set/reset occupancy flags */ +static void +reset_flags(void) /* allocate/set/reset occupancy flags */ { - register int4 p; + register int32 p; if (pixFlags == NULL) { - pixFlags = (int4 *)calloc(FL4NELS(hres*vres), sizeof(int4)); + pixFlags = (int32 *)calloc(FL4NELS(hres*vres), sizeof(int32)); CHECK(pixFlags==NULL, SYSTEM, "out of memory in reset_flags"); } else CLR4ALL(pixFlags, hres*vres); @@ -272,7 +298,8 @@ reset_flags() /* allocate/set/reset occupancy flags } -init_wfunc() /* initialize weighting function */ +static void +init_wfunc(void) /* initialize weighting function */ { register int r2; register double d; @@ -287,12 +314,14 @@ init_wfunc() /* initialize weighting function */ } -int -findneigh(nl, nd, h, v, rnl) /* find NNEIGH neighbors for pixel */ -short nl[NNEIGH][2]; -int nd[NNEIGH]; -int h, v; -register short (*rnl)[NNEIGH]; +static int +findneigh( /* find NNEIGH neighbors for pixel */ + short nl[NNEIGH][2], + int nd[NNEIGH], + int h, + int v, + register short (*rnl)[NNEIGH] +) { int nn = 0; int d, n, hoff; @@ -301,13 +330,13 @@ register short (*rnl)[NNEIGH]; nd[NNEIGH-1] = MAXRAD2; for (hoff = 0; hoff < hres; hoff = (hoff<=0) - hoff) { h2 = h + hoff; - if (h2 < 0 | h2 >= hres) + if ((h2 < 0) | (h2 >= hres)) continue; if ((h2-h)*(h2-h) >= nd[NNEIGH-1]) break; for (n = 0; n < NNEIGH && rnl[h2][n] < NINF; n++) { d = (h2-h)*(h2-h) + (v-rnl[h2][n])*(v-rnl[h2][n]); - if (d == 0 | d >= nd[NNEIGH-1]) + if ((d == 0) | (d >= nd[NNEIGH-1])) continue; if (nn < NNEIGH) /* insert neighbor */ nn++; @@ -328,10 +357,12 @@ register short (*rnl)[NNEIGH]; } -meet_neighbors(occ, nf, dp) /* run through samples and their neighbors */ -int occ; -int (*nf)(); -char *dp; +static void +meet_neighbors( /* run through samples and their neighbors */ + int occ, + sampfunc *nf, + double *dp +) { short ln[NNEIGH][2]; int nd[NNEIGH]; @@ -373,5 +404,5 @@ char *dp; } } } - free((char *)rnl); /* free row list */ + free((void *)rnl); /* free row list */ }