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

Comparing ray/src/rt/raytrace.c (file contents):
Revision 2.5 by greg, Mon Mar 8 12:37:30 1993 UTC vs.
Revision 2.50 by greg, Thu May 26 06:55:22 2005 UTC

# Line 1 | Line 1
1 /* Copyright (c) 1991 Regents of the University of California */
2
1   #ifndef lint
2 < static char SCCSid[] = "$SunId$ LBL";
2 > static const char RCSid[] = "$Id$";
3   #endif
6
4   /*
5   *  raytrace.c - routines for tracing and shading rays.
6   *
7 < *     8/7/85
7 > *  External symbols declared in ray.h
8   */
9  
10 < #include  "ray.h"
10 > #include "copyright.h"
11  
12 < #include  "octree.h"
13 <
12 > #include  "ray.h"
13 > #include  "source.h"
14   #include  "otypes.h"
18
15   #include  "otspecial.h"
16  
17   #define  MAXCSET        ((MAXSET+1)*2-1)        /* maximum check set size */
18  
19 < extern CUBE  thescene;                  /* our scene */
20 < extern int  maxdepth;                   /* maximum recursion depth */
25 < extern double  minweight;               /* minimum ray weight */
26 < extern int  do_irrad;                   /* compute irradiance? */
19 > unsigned long  raynum = 0;              /* next unique ray number */
20 > unsigned long  nrays = 0;               /* number of calls to localhit */
21  
22 < long  raynum = 0L;                      /* next unique ray number */
29 < long  nrays = 0L;                       /* number of calls to localhit */
30 <
31 < static FLOAT  Lambfa[5] = {PI, PI, PI, 0.0, 0.0};
22 > static RREAL  Lambfa[5] = {PI, PI, PI, 0.0, 0.0};
23   OBJREC  Lamb = {
24          OVOID, MAT_PLASTIC, "Lambertian",
25          {0, 5, NULL, Lambfa}, NULL,
26   };                                      /* a Lambertian surface */
27  
28 < static int  raymove(), checkset(), checkhit();
28 > OBJREC  Aftplane;                       /* aft clipping plane object */
29  
39 #define  MAXLOOP        128             /* modifier loop detection */
40
30   #define  RAYHIT         (-1)            /* return value for intercepted ray */
31  
32 + static int raymove(FVECT  pos, OBJECT  *cxs, int  dirf, RAY  *r, CUBE  *cu);
33 + static int checkhit(RAY  *r, CUBE  *cu, OBJECT  *cxs);
34 + static void checkset(OBJECT  *os, OBJECT  *cs);
35  
36 < rayorigin(r, ro, rt, rw)                /* start new ray from old one */
37 < register RAY  *r, *ro;
38 < int  rt;
39 < double  rw;
36 >
37 > extern int
38 > rayorigin(              /* start new ray from old one */
39 >        RAY  *r,
40 >        int  rt,
41 >        const RAY  *ro,
42 >        const COLOR rc
43 > )
44   {
45 +        double  rw, re;
46 +                                                /* assign coefficient/weight */
47 +        if (rc == NULL) {
48 +                rw = 1.0;
49 +                setcolor(r->rcoef, 1., 1., 1.);
50 +        } else {
51 +                rw = intens(rc);
52 +                if (rc != r->rcoef)
53 +                        copycolor(r->rcoef, rc);
54 +        }
55          if ((r->parent = ro) == NULL) {         /* primary ray */
56                  r->rlvl = 0;
57                  r->rweight = rw;
# Line 53 | Line 59 | double  rw;
59                  r->rsrc = -1;
60                  r->clipset = NULL;
61                  r->revf = raytrace;
62 +                copycolor(r->cext, cextinction);
63 +                copycolor(r->albedo, salbedo);
64 +                r->gecc = seccg;
65 +                r->slights = NULL;
66          } else {                                /* spawned ray */
67 +                if (ro->rot >= FHUGE) {
68 +                        memset(r, 0, sizeof(RAY));
69 +                        return(-1);             /* illegal continuation */
70 +                }
71                  r->rlvl = ro->rlvl;
72                  if (rt & RAYREFL) {
73                          r->rlvl++;
74                          r->rsrc = -1;
75                          r->clipset = ro->clipset;
76 +                        r->rmax = 0.0;
77                  } else {
78                          r->rsrc = ro->rsrc;
79                          r->clipset = ro->newcset;
80 +                        r->rmax = ro->rmax <= FTINY ? 0.0 : ro->rmax - ro->rot;
81                  }
82                  r->revf = ro->revf;
83 <                r->rweight = ro->rweight * rw;
83 >                copycolor(r->cext, ro->cext);
84 >                copycolor(r->albedo, ro->albedo);
85 >                r->gecc = ro->gecc;
86 >                r->slights = ro->slights;
87                  r->crtype = ro->crtype | (r->rtype = rt);
88                  VCOPY(r->rorg, ro->rop);
89 +                r->rweight = ro->rweight * rw;
90 +                                                /* estimate extinction */
91 +                re = colval(ro->cext,RED) < colval(ro->cext,GRN) ?
92 +                                colval(ro->cext,RED) : colval(ro->cext,GRN);
93 +                if (colval(ro->cext,BLU) < re) re = colval(ro->cext,BLU);
94 +                re *= ro->rot;
95 +                if (re > .1)
96 +                        r->rweight *= exp(-re);
97          }
98          rayclear(r);
99          return(r->rlvl <= maxdepth && r->rweight >= minweight ? 0 : -1);
100   }
101  
102  
103 < rayclear(r)                     /* clear a ray for (re)evaluation */
104 < register RAY  *r;
103 > extern void
104 > rayclear(                       /* clear a ray for (re)evaluation */
105 >        register RAY  *r
106 > )
107   {
108          r->rno = raynum++;
109          r->newcset = r->clipset;
110 +        r->hitf = rayhit;
111 +        r->robj = OVOID;
112          r->ro = NULL;
113 <        r->rot = FHUGE;
113 >        r->rox = NULL;
114 >        r->rt = r->rot = FHUGE;
115          r->pert[0] = r->pert[1] = r->pert[2] = 0.0;
116 +        r->uv[0] = r->uv[1] = 0.0;
117          setcolor(r->pcol, 1.0, 1.0, 1.0);
118          setcolor(r->rcol, 0.0, 0.0, 0.0);
86        r->rt = 0.0;
119   }
120  
121  
122 < raytrace(r)                     /* trace a ray and compute its value */
123 < RAY  *r;
122 > extern void
123 > raytrace(                       /* trace a ray and compute its value */
124 >        RAY  *r
125 > )
126   {
93        extern int  (*trace)();
94
127          if (localhit(r, &thescene))
128 <                raycont(r);
129 <        else if (sourcehit(r))
130 <                rayshade(r, r->ro->omod);
128 >                raycont(r);             /* hit local surface, evaluate */
129 >        else if (r->ro == &Aftplane) {
130 >                r->ro = NULL;           /* hit aft clipping plane */
131 >                r->rot = FHUGE;
132 >        } else if (sourcehit(r))
133 >                rayshade(r, r->ro->omod);       /* distant source */
134  
135          if (trace != NULL)
136                  (*trace)(r);            /* trace execution */
137 +
138 +        rayparticipate(r);              /* for participating medium */
139   }
140  
141  
142 < raycont(r)                      /* check for clipped object and continue */
143 < register RAY  *r;
142 > extern void
143 > raycont(                        /* check for clipped object and continue */
144 >        register RAY  *r
145 > )
146   {
147 <        if (r->clipset != NULL && inset(r->clipset, r->ro->omod))
147 >        if ((r->clipset != NULL && inset(r->clipset, r->ro->omod)) ||
148 >                        !rayshade(r, r->ro->omod))
149                  raytrans(r);
110        else
111                rayshade(r, r->ro->omod);
150   }
151  
152  
153 < raytrans(r)                     /* transmit ray as is */
154 < register RAY  *r;
153 > extern void
154 > raytrans(                       /* transmit ray as is */
155 >        register RAY  *r
156 > )
157   {
158          RAY  tr;
159  
160 <        if (rayorigin(&tr, r, TRANS, 1.0) == 0) {
160 >        if (rayorigin(&tr, TRANS, r, NULL) == 0) {
161                  VCOPY(tr.rdir, r->rdir);
162                  rayvalue(&tr);
163                  copycolor(r->rcol, tr.rcol);
# Line 126 | Line 166 | register RAY  *r;
166   }
167  
168  
169 < rayshade(r, mod)                /* shade ray r with material mod */
170 < register RAY  *r;
171 < int  mod;
169 > extern int
170 > rayshade(               /* shade ray r with material mod */
171 >        register RAY  *r,
172 >        int  mod
173 > )
174   {
133        static int  depth = 0;
175          register OBJREC  *m;
176 <                                        /* check for infinite loop */
136 <        if (depth++ >= MAXLOOP)
137 <                objerror(r->ro, USER, "possible modifier loop");
176 >
177          r->rt = r->rot;                 /* set effective ray length */
178          for ( ; mod != OVOID; mod = m->omod) {
179                  m = objptr(mod);
# Line 145 | Line 184 | int  mod;
184                  }
185                  ******/
186                                          /* hack for irradiance calculation */
187 <                if (do_irrad && !(r->crtype & ~(PRIMARY|TRANS))) {
187 >                if (do_irrad && !(r->crtype & ~(PRIMARY|TRANS)) &&
188 >                                m->otype != MAT_CLIP &&
189 >                                (ofun[m->otype].flags & (T_M|T_X))) {
190                          if (irr_ignore(m->otype)) {
150                                depth--;
191                                  raytrans(r);
192 <                                return;
192 >                                return(1);
193                          }
194                          if (!islight(m->otype))
195                                  m = &Lamb;
196                  }
197 <                (*ofun[m->otype].funp)(m, r);   /* execute function */
198 <                if (ismaterial(m->otype)) {     /* materials call raytexture */
159 <                        depth--;
160 <                        return;         /* we're done */
161 <                }
197 >                if ((*ofun[m->otype].funp)(m, r))
198 >                        return(1);      /* materials call raytexture() */
199          }
200 <        objerror(r->ro, USER, "material not found");
200 >        return(0);                      /* no material! */
201   }
202  
203  
204 < raytexture(r, mod)                      /* get material modifiers */
205 < RAY  *r;
206 < int  mod;
204 > extern void
205 > rayparticipate(                 /* compute ray medium participation */
206 >        register RAY  *r
207 > )
208   {
209 <        static int  depth = 0;
209 >        COLOR   ce, ca;
210 >        double  re, ge, be;
211 >
212 >        if (intens(r->cext) <= 1./FHUGE)
213 >                return;                         /* no medium */
214 >        re = r->rot*colval(r->cext,RED);
215 >        ge = r->rot*colval(r->cext,GRN);
216 >        be = r->rot*colval(r->cext,BLU);
217 >        if (r->crtype & SHADOW) {               /* no scattering for sources */
218 >                re *= 1. - colval(r->albedo,RED);
219 >                ge *= 1. - colval(r->albedo,GRN);
220 >                be *= 1. - colval(r->albedo,BLU);
221 >        }
222 >        setcolor(ce,    re<=FTINY ? 1. : re>92. ? 0. : exp(-re),
223 >                        ge<=FTINY ? 1. : ge>92. ? 0. : exp(-ge),
224 >                        be<=FTINY ? 1. : be>92. ? 0. : exp(-be));
225 >        multcolor(r->rcol, ce);                 /* path extinction */
226 >        if (r->crtype & SHADOW || intens(r->albedo) <= FTINY)
227 >                return;                         /* no scattering */
228 >        setcolor(ca,
229 >                colval(r->albedo,RED)*colval(ambval,RED)*(1.-colval(ce,RED)),
230 >                colval(r->albedo,GRN)*colval(ambval,GRN)*(1.-colval(ce,GRN)),
231 >                colval(r->albedo,BLU)*colval(ambval,BLU)*(1.-colval(ce,BLU)));
232 >        addcolor(r->rcol, ca);                  /* ambient in scattering */
233 >        srcscatter(r);                          /* source in scattering */
234 > }
235 >
236 >
237 > extern void
238 > raytexture(                     /* get material modifiers */
239 >        RAY  *r,
240 >        OBJECT  mod
241 > )
242 > {
243          register OBJREC  *m;
173                                        /* check for infinite loop */
174        if (depth++ >= MAXLOOP)
175                objerror(r->ro, USER, "modifier loop");
244                                          /* execute textures and patterns */
245          for ( ; mod != OVOID; mod = m->omod) {
246                  m = objptr(mod);
247 <                if (!istexture(m->otype)) {
247 >                /****** unnecessary test since modifier() is always called
248 >                if (!ismodifier(m->otype)) {
249                          sprintf(errmsg, "illegal modifier \"%s\"", m->oname);
250                          error(USER, errmsg);
251                  }
252 <                (*ofun[m->otype].funp)(m, r);
252 >                ******/
253 >                if ((*ofun[m->otype].funp)(m, r)) {
254 >                        sprintf(errmsg, "conflicting material \"%s\"",
255 >                                        m->oname);
256 >                        objerror(r->ro, USER, errmsg);
257 >                }
258          }
185        depth--;                        /* end here */
259   }
260  
261  
262 < raymixture(r, fore, back, coef)         /* mix modifiers */
263 < register RAY  *r;
264 < OBJECT  fore, back;
265 < double  coef;
262 > extern int
263 > raymixture(             /* mix modifiers */
264 >        register RAY  *r,
265 >        OBJECT  fore,
266 >        OBJECT  back,
267 >        double  coef
268 > )
269   {
270 <        FVECT  curpert, forepert, backpert;
271 <        COLOR  curpcol, forepcol, backpcol;
270 >        RAY  fr, br;
271 >        int  foremat, backmat;
272          register int  i;
273 <                                        /* clip coefficient */
273 >                                        /* bound coefficient */
274          if (coef > 1.0)
275                  coef = 1.0;
276          else if (coef < 0.0)
277                  coef = 0.0;
278 <                                        /* save current mods */
279 <        VCOPY(curpert, r->pert);
280 <        copycolor(curpcol, r->pcol);
281 <                                        /* compute new mods */
282 <                                                /* foreground */
283 <        r->pert[0] = r->pert[1] = r->pert[2] = 0.0;
284 <        setcolor(r->pcol, 1.0, 1.0, 1.0);
285 <        if (fore != OVOID && coef > FTINY)
286 <                raytexture(r, fore);
287 <        VCOPY(forepert, r->pert);
288 <        copycolor(forepcol, r->pcol);
289 <                                                /* background */
290 <        r->pert[0] = r->pert[1] = r->pert[2] = 0.0;
291 <        setcolor(r->pcol, 1.0, 1.0, 1.0);
292 <        if (back != OVOID && coef < 1.0-FTINY)
293 <                raytexture(r, back);
294 <        VCOPY(backpert, r->pert);
295 <        copycolor(backpcol, r->pcol);
220 <                                        /* sum perturbations */
278 >                                        /* compute foreground and background */
279 >        foremat = backmat = 0;
280 >                                        /* foreground */
281 >        fr = *r;
282 >        if (coef > FTINY)
283 >                foremat = rayshade(&fr, fore);
284 >                                        /* background */
285 >        br = *r;
286 >        if (coef < 1.0-FTINY)
287 >                backmat = rayshade(&br, back);
288 >                                        /* check for transparency */
289 >        if (backmat ^ foremat) {
290 >                if (backmat && coef > FTINY)
291 >                        raytrans(&fr);
292 >                else if (foremat && coef < 1.0-FTINY)
293 >                        raytrans(&br);
294 >        }
295 >                                        /* mix perturbations */
296          for (i = 0; i < 3; i++)
297 <                r->pert[i] = curpert[i] + coef*forepert[i] +
298 <                                (1.0-coef)*backpert[i];
299 <                                        /* multiply colors */
300 <        setcolor(r->pcol, coef*colval(forepcol,RED) +
301 <                                (1.0-coef)*colval(backpcol,RED),
302 <                        coef*colval(forepcol,GRN) +
303 <                                (1.0-coef)*colval(backpcol,GRN),
304 <                        coef*colval(forepcol,BLU) +
305 <                                (1.0-coef)*colval(backpcol,BLU));
306 <        multcolor(r->pcol, curpcol);
297 >                r->pert[i] = coef*fr.pert[i] + (1.0-coef)*br.pert[i];
298 >                                        /* mix pattern colors */
299 >        scalecolor(fr.pcol, coef);
300 >        scalecolor(br.pcol, 1.0-coef);
301 >        copycolor(r->pcol, fr.pcol);
302 >        addcolor(r->pcol, br.pcol);
303 >                                        /* return value tells if material */
304 >        if (!foremat & !backmat)
305 >                return(0);
306 >                                        /* mix returned ray values */
307 >        scalecolor(fr.rcol, coef);
308 >        scalecolor(br.rcol, 1.0-coef);
309 >        copycolor(r->rcol, fr.rcol);
310 >        addcolor(r->rcol, br.rcol);
311 >        r->rt = bright(fr.rcol) > bright(br.rcol) ? fr.rt : br.rt;
312 >        return(1);
313   }
314  
315  
316 < double
317 < raynormal(norm, r)              /* compute perturbed normal for ray */
318 < FVECT  norm;
319 < register RAY  *r;
316 > extern double
317 > raydist(                /* compute (cumulative) ray distance */
318 >        register const RAY  *r,
319 >        register int  flags
320 > )
321   {
322 +        double  sum = 0.0;
323 +
324 +        while (r != NULL && r->crtype&flags) {
325 +                sum += r->rot;
326 +                r = r->parent;
327 +        }
328 +        return(sum);
329 + }
330 +
331 +
332 + extern void
333 + raycontrib(             /* compute (cumulative) ray contribution */
334 +        COLOR  rc,
335 +        const RAY  *r,
336 +        int  flags
337 + )
338 + {
339 +        COLOR   eext, ext1;
340 +        
341 +        setcolor(eext, 0., 0., 0.);
342 +        setcolor(rc, 1., 1., 1.);
343 +
344 +        while (r != NULL && r->crtype&flags) {
345 +                multcolor(rc, r->rcoef);
346 +                copycolor(ext1, r->cext);
347 +                scalecolor(ext1, r->rot);
348 +                addcolor(eext, ext1);
349 +                r = r->parent;
350 +        }
351 +        if (intens(eext) > FTINY) {
352 +                setcolor(ext1,  exp(-colval(eext,RED)),
353 +                                exp(-colval(eext,GRN)),
354 +                                exp(-colval(eext,BLU)));
355 +                multcolor(rc, ext1);
356 +        }
357 + }
358 +
359 +
360 + extern double
361 + raynormal(              /* compute perturbed normal for ray */
362 +        FVECT  norm,
363 +        register RAY  *r
364 + )
365 + {
366          double  newdot;
367          register int  i;
368  
# Line 267 | Line 393 | register RAY  *r;
393   }
394  
395  
396 < newrayxf(r)                     /* get new tranformation matrix for ray */
397 < RAY  *r;
396 > extern void
397 > newrayxf(                       /* get new tranformation matrix for ray */
398 >        RAY  *r
399 > )
400   {
401          static struct xfn {
402                  struct xfn  *next;
403                  FULLXF  xf;
404          }  xfseed = { &xfseed }, *xflast = &xfseed;
405          register struct xfn  *xp;
406 <        register RAY  *rp;
406 >        register const RAY  *rp;
407  
408          /*
409           * Search for transform in circular list that
# Line 286 | Line 414 | RAY  *r;
414                  if (rp->rox == &xp->xf) {               /* xp in use */
415                          xp = xp->next;                  /* move to next */
416                          if (xp == xflast) {             /* need new one */
417 <                                xp = (struct xfn *)bmalloc(sizeof(struct xfn));
417 >                                xp = (struct xfn *)malloc(sizeof(struct xfn));
418                                  if (xp == NULL)
419                                          error(SYSTEM,
420                                                  "out of memory in newrayxf");
# Line 303 | Line 431 | RAY  *r;
431   }
432  
433  
434 < flipsurface(r)                  /* reverse surface orientation */
435 < register RAY  *r;
434 > extern void
435 > flipsurface(                    /* reverse surface orientation */
436 >        register RAY  *r
437 > )
438   {
439          r->rod = -r->rod;
440          r->ron[0] = -r->ron[0];
# Line 316 | Line 446 | register RAY  *r;
446   }
447  
448  
449 < localhit(r, scene)              /* check for hit in the octree */
450 < register RAY  *r;
451 < register CUBE  *scene;
449 > extern void
450 > rayhit(                 /* standard ray hit test */
451 >        OBJECT  *oset,
452 >        RAY  *r
453 > )
454   {
455 +        OBJREC  *o;
456 +        int     i;
457 +
458 +        for (i = oset[0]; i > 0; i--) {
459 +                o = objptr(oset[i]);
460 +                if ((*ofun[o->otype].funp)(o, r))
461 +                        r->robj = oset[i];
462 +        }
463 + }
464 +
465 +
466 + extern int
467 + localhit(               /* check for hit in the octree */
468 +        register RAY  *r,
469 +        register CUBE  *scene
470 + )
471 + {
472          OBJECT  cxset[MAXCSET+1];       /* set of checked objects */
473          FVECT  curpos;                  /* current cube position */
474          int  sflags;                    /* sign flags */
# Line 330 | Line 479 | register CUBE  *scene;
479          sflags = 0;
480          for (i = 0; i < 3; i++) {
481                  curpos[i] = r->rorg[i];
482 <                if (r->rdir[i] > FTINY)
482 >                if (r->rdir[i] > 1e-7)
483                          sflags |= 1 << i;
484 <                else if (r->rdir[i] < -FTINY)
484 >                else if (r->rdir[i] < -1e-7)
485                          sflags |= 0x10 << i;
486          }
487          if (sflags == 0)
488                  error(CONSISTENCY, "zero ray direction in localhit");
489 +                                        /* start off assuming nothing hit */
490 +        if (r->rmax > FTINY) {          /* except aft plane if one */
491 +                r->ro = &Aftplane;
492 +                r->rot = r->rmax;
493 +                for (i = 0; i < 3; i++)
494 +                        r->rop[i] = r->rorg[i] + r->rot*r->rdir[i];
495 +        }
496 +                                        /* find global cube entrance point */
497          t = 0.0;
498          if (!incube(scene, curpos)) {
499                                          /* find distance to entry */
# Line 354 | Line 511 | register CUBE  *scene;
511                                  t = dt; /* farthest face is the one */
512                  }
513                  t += FTINY;             /* fudge to get inside cube */
514 +                if (t >= r->rot)        /* clipped already */
515 +                        return(0);
516                                          /* advance position */
517                  for (i = 0; i < 3; i++)
518                          curpos[i] += r->rdir[i]*t;
# Line 362 | Line 521 | register CUBE  *scene;
521                          return(0);
522          }
523          cxset[0] = 0;
524 <        return(raymove(curpos, cxset, sflags, r, scene) == RAYHIT);
524 >        raymove(curpos, cxset, sflags, r, scene);
525 >        return((r->ro != NULL) & (r->ro != &Aftplane));
526   }
527  
528  
529   static int
530 < raymove(pos, cxs, dirf, r, cu)          /* check for hit as we move */
531 < FVECT  pos;                     /* current position, modified herein */
532 < OBJECT  *cxs;                   /* checked objects, modified by checkhit */
533 < int  dirf;                      /* direction indicators to speed tests */
534 < register RAY  *r;
535 < register CUBE  *cu;
530 > raymove(                /* check for hit as we move */
531 >        FVECT  pos,                     /* current position, modified herein */
532 >        OBJECT  *cxs,                   /* checked objects, modified by checkhit */
533 >        int  dirf,                      /* direction indicators to speed tests */
534 >        register RAY  *r,
535 >        register CUBE  *cu
536 > )
537   {
538          int  ax;
539          double  dt, t;
# Line 417 | Line 578 | register CUBE  *cu;
578                  }
579                  /*NOTREACHED*/
580          }
581 <        if (isfull(cu->cutree) && checkhit(r, cu, cxs))
581 >        if (isfull(cu->cutree)) {
582 >                if (checkhit(r, cu, cxs))
583 >                        return(RAYHIT);
584 >        } else if (r->ro == &Aftplane && incube(cu, r->rop))
585                  return(RAYHIT);
586                                          /* advance to next cube */
587          if (dirf&0x11) {
# Line 449 | Line 613 | register CUBE  *cu;
613   }
614  
615  
616 < static
617 < checkhit(r, cu, cxs)            /* check for hit in full cube */
618 < register RAY  *r;
619 < CUBE  *cu;
620 < OBJECT  *cxs;
616 > static int
617 > checkhit(               /* check for hit in full cube */
618 >        register RAY  *r,
619 >        CUBE  *cu,
620 >        OBJECT  *cxs
621 > )
622   {
623          OBJECT  oset[MAXSET+1];
459        register OBJREC  *o;
460        register int  i;
624  
625          objset(oset, cu->cutree);
626 <        checkset(oset, cxs);                    /* eliminate double-checking */
627 <        for (i = oset[0]; i > 0; i--) {
628 <                o = objptr(oset[i]);
629 <                if (o->omod == OVOID && issurface(o->otype))
630 <                        continue;               /* ignore void surfaces */
468 <                (*ofun[o->otype].funp)(o, r);
469 <        }
470 <        if (r->ro == NULL)
626 >        checkset(oset, cxs);                    /* avoid double-checking */
627 >
628 >        (*r->hitf)(oset, r);                    /* test for hit in set */
629 >
630 >        if (r->robj == OVOID)
631                  return(0);                      /* no scores yet */
632  
633          return(incube(cu, r->rop));             /* hit OK if in current cube */
634   }
635  
636  
637 < static
638 < checkset(os, cs)                /* modify checked set and set to check */
639 < register OBJECT  *os;                   /* os' = os - cs */
640 < register OBJECT  *cs;                   /* cs' = cs + os */
637 > static void
638 > checkset(               /* modify checked set and set to check */
639 >        register OBJECT  *os,                   /* os' = os - cs */
640 >        register OBJECT  *cs                    /* cs' = cs + os */
641 > )
642   {
643          OBJECT  cset[MAXCSET+MAXSET+1];
644          register int  i, j;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines