ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/hd/rhpict2.c
(Generate patch)

Comparing ray/src/hd/rhpict2.c (file contents):
Revision 3.10 by greg, Sat Feb 22 02:07:25 2003 UTC vs.
Revision 3.17 by greg, Fri Oct 5 19:19:16 2018 UTC

# Line 5 | Line 5 | static const char      RCSid[] = "$Id$";
5   * Rendering routines for rhpict.
6   */
7  
8 + #include <string.h>
9 +
10   #include "holo.h"
11   #include "view.h"
12   #include "random.h"
# Line 35 | Line 37 | static const char      RCSid[] = "$Id$";
37   #define CLR4(f,i)       FL4OP(f,i,&=~)
38   #define TGL4(f,i)       FL4OP(f,i,^=)
39   #define FL4NELS(n)      (((n)+0x1f)>>5)
40 < #define CLR4ALL(f,n)    bzero((char *)(f),FL4NELS(n)*sizeof(int4))
40 > #define CLR4ALL(f,n)    memset((char *)(f),'\0',FL4NELS(n)*sizeof(int32))
41   #endif
42  
43 < static int4     *pixFlags;      /* pixel occupancy flags */
43 > static int32    *pixFlags;      /* pixel occupancy flags */
44   static float    pixWeight[MAXRAD2];     /* pixel weighting function */
45   static short    isqrttab[MAXRAD2];      /* integer square root table */
46  
# Line 50 | Line 52 | extern float   *myweight;      /* weights (used to compute fi
52   extern float    *mydepth;       /* depth values (visibility culling) */
53   extern int      hres, vres;     /* current horizontal and vertical res. */
54  
55 + extern void pixFinish(double ransamp);
56 + extern void pixBeam(BEAM *bp, HDBEAMI *hb);
57  
58 < pixBeam(bp, hb)                 /* render a particular beam */
59 < BEAM    *bp;
60 < register HDBEAMI        *hb;
58 > typedef int (sampfunc)(int h, int v, short nl[NNEIGH][2], int nd[NNEIGH],
59 >                int n, double *rf);
60 > static sampfunc kill_occl;
61 > static sampfunc smooth_samp;
62 > static sampfunc random_samp;
63 > static void meet_neighbors(int occ, sampfunc *nf, double *dp);
64 > static void reset_flags(void);
65 > static void init_wfunc(void);
66 > static int findneigh(short nl[NNEIGH][2], int nd[NNEIGH], int h, int v,
67 >                short (*rnl)[NNEIGH]);
68 >
69 >
70 > void
71 > pixBeam(                        /* render a particular beam */
72 >        BEAM    *bp,
73 >        HDBEAMI *hb
74 > )
75   {
76          GCOORD  gc[2];
77 <        register RAYVAL *rv;
77 >        RAYVAL  *rv;
78          FVECT   rorg, rdir, wp, ip;
79          double  d, prox;
80          COLOR   col;
81          int     n;
82 <        register int4   p;
82 >        int32   p;
83  
84          if (!hdbcoord(gc, hb->h, hb->b))
85                  error(CONSISTENCY, "bad beam in render_beam");
# Line 81 | Line 99 | register HDBEAMI       *hb;
99                          VSUM(wp, myview.vp, rdir, FHUGE);
100                          prox = 1.;
101                  }
102 <                viewloc(ip, &myview, wp);       /* frustum clipping */
103 <                if (ip[2] < 0.)
86 <                        continue;
87 <                if (ip[0] < 0. || ip[0] >= 1.)
88 <                        continue;
89 <                if (ip[1] < 0. || ip[1] >= 1.)
90 <                        continue;
102 >                if (viewloc(ip, &myview, wp) != 1)
103 >                        continue;               /* frustum clipping */
104                  if (myview.vaft > FTINY && ip[2] > myview.vaft - myview.vfore)
105                          continue;               /* not exact for VT_PER */
106                  p = (int)(ip[1]*vres)*hres + (int)(ip[0]*hres);
# Line 108 | Line 121 | register HDBEAMI       *hb;
121   }
122  
123  
124 < int
125 < kill_occl(h, v, nl, nd, n)              /* check for occlusion errors */
126 < int     h, v;
127 < register short  nl[NNEIGH][2];
128 < int     nd[NNEIGH];
129 < int     n;
124 > static int
125 > kill_occl(              /* check for occlusion errors */
126 >        int     h,
127 >        int     v,
128 >        short   nl[NNEIGH][2],
129 >        int     nd[NNEIGH],
130 >        int     n,
131 >        double *rf
132 > )
133   {
134          short   forequad[2][2];
135          int     d;
136 <        register int    i;
137 <        register int4   p;
136 >        int     i;
137 >        int32   p;
138  
139          if (n <= 0) {
140   #ifdef DEBUG
# Line 141 | Line 157 | int    n;
157   }
158  
159  
160 < int
161 < smooth_samp(h, v, nl, nd, n)    /* grow sample point smoothly */
162 < int     h, v;
163 < register short  nl[NNEIGH][2];
164 < int     nd[NNEIGH];
165 < int     n;
160 > static int
161 > smooth_samp(    /* grow sample point smoothly */
162 >        int     h,
163 >        int     v,
164 >        short   nl[NNEIGH][2],
165 >        int     nd[NNEIGH],
166 >        int     n,
167 >        double *rf
168 > )
169   {
170          int     dis[NNEIGH], ndis;
171          COLOR   mykern[MAXRAD2];
172          int     maxr2;
173          double  d;
174 <        register int4   p;
175 <        register int    r2;
174 >        int32   p;
175 >        int     r2;
176          int     i, r, maxr, h2, v2;
177  
178          if (n <= 0)
# Line 203 | Line 222 | int    n;
222   }
223  
224  
225 < int
226 < random_samp(h, v, nl, nd, n, rf)        /* gather samples randomly */
227 < int     h, v;
228 < register short  nl[NNEIGH][2];
229 < int     nd[NNEIGH];
230 < int     n;
231 < double  *rf;
225 > static int
226 > random_samp(    /* gather samples randomly */
227 >        int     h,
228 >        int     v,
229 >        short   nl[NNEIGH][2],
230 >        int     nd[NNEIGH],
231 >        int     n,
232 >        double  *rf
233 > )
234   {
235          float   rnt[NNEIGH];
236          double  rvar;
237 <        register int4   p, pn;
238 <        register int    ni;
237 >        int32   p, pn;
238 >        int     ni;
239  
240          if (n <= 0)
241                  return(1);
# Line 237 | Line 258 | double *rf;
258   }
259  
260  
261 < pixFinish(ransamp)              /* done with beams -- compute pixel values */
262 < double  ransamp;
261 > void
262 > pixFinish(              /* done with beams -- compute pixel values */
263 >        double  ransamp
264 > )
265   {
266          if (pixWeight[0] <= FTINY)
267                  init_wfunc();           /* initialize weighting function */
# Line 254 | Line 277 | double ransamp;
277   }
278  
279  
280 < reset_flags()                   /* allocate/set/reset occupancy flags */
280 > static void
281 > reset_flags(void)                       /* allocate/set/reset occupancy flags */
282   {
283 <        register int4   p;
283 >        int32   p;
284  
285          if (pixFlags == NULL) {
286 <                pixFlags = (int4 *)calloc(FL4NELS(hres*vres), sizeof(int4));
286 >                pixFlags = (int32 *)calloc(FL4NELS(hres*vres), sizeof(int32));
287                  CHECK(pixFlags==NULL, SYSTEM, "out of memory in reset_flags");
288          } else
289                  CLR4ALL(pixFlags, hres*vres);
# Line 269 | Line 293 | reset_flags()                  /* allocate/set/reset occupancy flags
293   }
294  
295  
296 < init_wfunc()                    /* initialize weighting function */
296 > static void
297 > init_wfunc(void)                        /* initialize weighting function */
298   {
299 <        register int    r2;
300 <        register double d;
299 >        int     r2;
300 >        double  d;
301  
302          for (r2 = MAXRAD2; --r2; ) {
303                  d = sqrt((double)r2);
# Line 284 | Line 309 | init_wfunc()                   /* initialize weighting function */
309   }
310  
311  
312 < int
313 < findneigh(nl, nd, h, v, rnl)    /* find NNEIGH neighbors for pixel */
314 < short   nl[NNEIGH][2];
315 < int     nd[NNEIGH];
316 < int     h, v;
317 < register short  (*rnl)[NNEIGH];
312 > static int
313 > findneigh(      /* find NNEIGH neighbors for pixel */
314 >        short   nl[NNEIGH][2],
315 >        int     nd[NNEIGH],
316 >        int     h,
317 >        int     v,
318 >        short   (*rnl)[NNEIGH]
319 > )
320   {
321          int     nn = 0;
322          int     d, n, hoff;
323 <        register int    h2, n2;
323 >        int     h2, n2;
324  
325          nd[NNEIGH-1] = MAXRAD2;
326          for (hoff = 0; hoff < hres; hoff = (hoff<=0) - hoff) {
327                  h2 = h + hoff;
328 <                if (h2 < 0 | h2 >= hres)
328 >                if ((h2 < 0) | (h2 >= hres))
329                          continue;
330                  if ((h2-h)*(h2-h) >= nd[NNEIGH-1])
331                          break;
332                  for (n = 0; n < NNEIGH && rnl[h2][n] < NINF; n++) {
333                          d = (h2-h)*(h2-h) + (v-rnl[h2][n])*(v-rnl[h2][n]);
334 <                        if (d == 0 | d >= nd[NNEIGH-1])
334 >                        if ((d == 0) | (d >= nd[NNEIGH-1]))
335                                  continue;
336                          if (nn < NNEIGH)        /* insert neighbor */
337                                  nn++;
# Line 325 | Line 352 | register short (*rnl)[NNEIGH];
352   }
353  
354  
355 < meet_neighbors(occ, nf, dp)     /* run through samples and their neighbors */
356 < int     occ;
357 < int     (*nf)();
358 < char    *dp;
355 > static void
356 > meet_neighbors( /* run through samples and their neighbors */
357 >        int     occ,
358 >        sampfunc *nf,
359 >        double  *dp
360 > )
361   {
362          short   ln[NNEIGH][2];
363          int     nd[NNEIGH];
364          int     h, v, n, v2;
365 <        register short  (*rnl)[NNEIGH];
365 >        short   (*rnl)[NNEIGH];
366                                          /* initialize bottom row list */
367          rnl = (short (*)[NNEIGH])malloc(NNEIGH*sizeof(short)*hres);
368          CHECK(rnl==NULL, SYSTEM, "out of memory in meet_neighbors");

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines