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.49 by greg, Tue Apr 19 01:15:06 2005 UTC vs.
Revision 2.92 by greg, Thu Dec 5 19:23:43 2024 UTC

# Line 13 | Line 13 | static const char RCSid[] = "$Id$";
13   #include  "source.h"
14   #include  "otypes.h"
15   #include  "otspecial.h"
16 + #include  "random.h"
17 + #include  "pmap.h"
18  
19   #define  MAXCSET        ((MAXSET+1)*2-1)        /* maximum check set size */
20  
21 < unsigned long  raynum = 0;              /* next unique ray number */
22 < unsigned long  nrays = 0;               /* number of calls to localhit */
21 > RNUMBER  raynum = 0;            /* next unique ray number */
22 > RNUMBER  nrays = 0;             /* number of calls to localhit */
23  
24   static RREAL  Lambfa[5] = {PI, PI, PI, 0.0, 0.0};
25   OBJREC  Lamb = {
26          OVOID, MAT_PLASTIC, "Lambertian",
27 <        {0, 5, NULL, Lambfa}, NULL,
27 >        {NULL, Lambfa, 0, 5}, NULL
28   };                                      /* a Lambertian surface */
29  
30   OBJREC  Aftplane;                       /* aft clipping plane object */
# Line 34 | Line 36 | static int checkhit(RAY  *r, CUBE  *cu, OBJECT  *cxs);
36   static void checkset(OBJECT  *os, OBJECT  *cs);
37  
38  
39 < extern int
39 > int
40   rayorigin(              /* start new ray from old one */
41          RAY  *r,
42          int  rt,
43          const RAY  *ro,
44 <        const COLOR rc
44 >        const SCOLOR rc
45   )
46   {
47          double  rw, re;
48                                                  /* assign coefficient/weight */
49          if (rc == NULL) {
50                  rw = 1.0;
51 <                setcolor(r->rcoef, 1., 1., 1.);
51 >                setscolor(r->rcoef, 1., 1., 1.);
52          } else {
53 <                rw = intens(rc);
53 >                rw = sintens((COLORV *)rc);
54 >                if (rw > 1.0)
55 >                        rw = 1.0;               /* avoid calculation growth */
56                  if (rc != r->rcoef)
57 <                        copycolor(r->rcoef, rc);
57 >                        copyscolor(r->rcoef, rc);
58          }
59          if ((r->parent = ro) == NULL) {         /* primary ray */
60                  r->rlvl = 0;
61                  r->rweight = rw;
62                  r->crtype = r->rtype = rt;
63                  r->rsrc = -1;
64 + #ifdef SSKIPOPT
65 +                r->scorr = 1.f;
66 + #endif
67                  r->clipset = NULL;
68 +                r->revf = raytrace;
69                  copycolor(r->cext, cextinction);
70                  copycolor(r->albedo, salbedo);
71                  r->gecc = seccg;
72                  r->slights = NULL;
73          } else {                                /* spawned ray */
74 <                if (ro->rot >= FHUGE) {
74 >                if (ro->rot >= FHUGE*.99) {
75                          memset(r, 0, sizeof(RAY));
76                          return(-1);             /* illegal continuation */
77                  }
78                  r->rlvl = ro->rlvl;
79 +                r->rsrc = ro->rsrc;
80 + #ifdef SSKIPOPT
81 +                r->scorr = ro->scorr;
82 + #endif
83                  if (rt & RAYREFL) {
84                          r->rlvl++;
85 <                        r->rsrc = -1;
85 >                        if (r->rsrc >= 0)       /* malfunctioning material? */
86 >                                r->rsrc = -1;
87                          r->clipset = ro->clipset;
88                          r->rmax = 0.0;
89                  } else {
77                        r->rsrc = ro->rsrc;
90                          r->clipset = ro->newcset;
91 <                        r->rmax = ro->rmax <= FTINY ? 0.0 : ro->rmax - ro->rot;
91 >                        r->rmax = (ro->rmax > FTINY)*(ro->rmax - ro->rot);
92                  }
93 +                r->revf = ro->revf;
94                  copycolor(r->cext, ro->cext);
95                  copycolor(r->albedo, ro->albedo);
96                  r->gecc = ro->gecc;
# Line 90 | Line 103 | rayorigin(             /* start new ray from old one */
103                                  colval(ro->cext,RED) : colval(ro->cext,GRN);
104                  if (colval(ro->cext,BLU) < re) re = colval(ro->cext,BLU);
105                  re *= ro->rot;
106 <                if (re > .1)
107 <                        r->rweight *= exp(-re);
106 >                if (re > 0.1) {
107 >                        if (re > 92.) {
108 >                                r->rweight = 0.0;
109 >                        } else {
110 >                                r->rweight *= exp(-re);
111 >                        }
112 >                }
113          }
114          rayclear(r);
115 <        return(r->rlvl <= maxdepth && r->rweight >= minweight ? 0 : -1);
115 >        if (r->rweight <= 0.0)                  /* check for expiration */
116 >                return(-1);
117 >        if (r->crtype & SHADOW)                 /* shadow commitment */
118 >                return(0);
119 >                                                /* ambient in photon map? */
120 >        if (ro != NULL && ro->crtype & AMBIENT) {
121 >                if (causticPhotonMapping)
122 >                        return(-1);
123 >                if (photonMapping && rt != TRANS)
124 >                        return(-1);
125 >        }
126 >        if ((maxdepth <= 0) & (rc != NULL)) {   /* Russian roulette */
127 >                if (minweight <= 0.0)
128 >                        error(USER, "zero ray weight in Russian roulette");
129 >                if ((maxdepth < 0) & (r->rlvl > -maxdepth))
130 >                        return(-1);             /* upper reflection limit */
131 >                if (r->rweight >= minweight)
132 >                        return(0);
133 >                if (frandom() > r->rweight/minweight)
134 >                        return(-1);
135 >                rw = minweight/r->rweight;      /* promote survivor */
136 >                scalescolor(r->rcoef, rw);
137 >                r->rweight = minweight;
138 >                return(0);
139 >        }
140 >        return((r->rweight >= minweight) & (r->rlvl <= abs(maxdepth)) ? 0 : -1);
141   }
142  
143  
144 < extern void
144 > void
145   rayclear(                       /* clear a ray for (re)evaluation */
146 <        register RAY  *r
146 >        RAY  *r
147   )
148   {
149          r->rno = raynum++;
# Line 109 | Line 152 | rayclear(                      /* clear a ray for (re)evaluation */
152          r->robj = OVOID;
153          r->ro = NULL;
154          r->rox = NULL;
155 <        r->rt = r->rot = FHUGE;
155 >        r->rxt = r->rmt = r->rot = FHUGE;
156 >        VCOPY(r->rop, r->rorg);
157 >        r->ron[0] = -r->rdir[0]; r->ron[1] = -r->rdir[1]; r->ron[2] = -r->rdir[2];
158 >        r->rod = 1.0;
159          r->pert[0] = r->pert[1] = r->pert[2] = 0.0;
160 +        r->rflips = 0;
161          r->uv[0] = r->uv[1] = 0.0;
162 <        setcolor(r->pcol, 1.0, 1.0, 1.0);
163 <        setcolor(r->rcol, 0.0, 0.0, 0.0);
162 >        setscolor(r->pcol, 1.0, 1.0, 1.0);
163 >        scolorblack(r->mcol);
164 >        scolorblack(r->rcol);
165   }
166  
167  
168 < extern void
169 < rayvalue(                       /* trace a ray and compute its value */
168 > void
169 > raytrace(                       /* trace a ray and compute its value */
170          RAY  *r
171   )
172   {
# Line 137 | Line 185 | rayvalue(                      /* trace a ray and compute its value */
185   }
186  
187  
188 < extern void
188 > void
189   raycont(                        /* check for clipped object and continue */
190 <        register RAY  *r
190 >        RAY  *r
191   )
192   {
193          if ((r->clipset != NULL && inset(r->clipset, r->ro->omod)) ||
# Line 148 | Line 196 | raycont(                       /* check for clipped object and continue */
196   }
197  
198  
199 < extern void
199 > void
200   raytrans(                       /* transmit ray as is */
201 <        register RAY  *r
201 >        RAY  *r
202   )
203   {
204          RAY  tr;
205  
206 <        if (rayorigin(&tr, TRANS, r, NULL) == 0) {
207 <                VCOPY(tr.rdir, r->rdir);
208 <                rayvalue(&tr);
209 <                copycolor(r->rcol, tr.rcol);
210 <                r->rt = r->rot + tr.rt;
206 >        rayorigin(&tr, TRANS, r, NULL);         /* always continue */
207 >        VCOPY(tr.rdir, r->rdir);
208 >        rayvalue(&tr);
209 >        copyscolor(r->mcol, tr.mcol);
210 >        copyscolor(r->rcol, tr.rcol);
211 >        r->rmt = r->rot + tr.rmt;
212 >        r->rxt = r->rot + tr.rxt;
213 > }
214 >
215 >
216 > int
217 > raytirrad(                      /* irradiance hack */
218 >        OBJREC  *m,
219 >        RAY     *r
220 > )
221 > {
222 >        if (m->otype != MAT_CLIP && ismaterial(m->otype)) {
223 >                if (istransp(m->otype) || isBSDFproxy(m)) {
224 >                        raytrans(r);
225 >                        return(1);
226 >                }
227 >                if (!islight(m->otype)) {
228 >                        setscolor(r->pcol, 1.0, 1.0, 1.0);
229 >                        return((*ofun[Lamb.otype].funp)(&Lamb, r));
230 >                }
231          }
232 +        return(0);              /* not a qualifying surface */
233   }
234  
235  
236 < extern int
236 > int
237   rayshade(               /* shade ray r with material mod */
238 <        register RAY  *r,
238 >        RAY  *r,
239          int  mod
240   )
241   {
242 <        register OBJREC  *m;
242 >        int     tst_irrad = do_irrad && !(r->crtype & ~(PRIMARY|TRANS));
243 >        OBJREC  *m;
244  
245 <        r->rt = r->rot;                 /* set effective ray length */
245 >        r->rxt = r->rot;                /* preset effective ray length */
246          for ( ; mod != OVOID; mod = m->omod) {
247                  m = objptr(mod);
248                  /****** unnecessary test since modifier() is always called
# Line 182 | Line 252 | rayshade(              /* shade ray r with material mod */
252                  }
253                  ******/
254                                          /* hack for irradiance calculation */
255 <                if (do_irrad && !(r->crtype & ~(PRIMARY|TRANS)) &&
256 <                                m->otype != MAT_CLIP &&
257 <                                (ofun[m->otype].flags & (T_M|T_X))) {
188 <                        if (irr_ignore(m->otype)) {
189 <                                raytrans(r);
190 <                                return(1);
191 <                        }
192 <                        if (!islight(m->otype))
193 <                                m = &Lamb;
194 <                }
255 >                if (tst_irrad && raytirrad(m, r))
256 >                        return(1);
257 >
258                  if ((*ofun[m->otype].funp)(m, r))
259                          return(1);      /* materials call raytexture() */
260          }
# Line 199 | Line 262 | rayshade(              /* shade ray r with material mod */
262   }
263  
264  
265 < extern void
265 > void
266   rayparticipate(                 /* compute ray medium participation */
267 <        register RAY  *r
267 >        RAY  *r
268   )
269   {
270 <        COLOR   ce, ca;
270 >        SCOLOR  ce, ca;
271          double  re, ge, be;
272  
273          if (intens(r->cext) <= 1./FHUGE)
# Line 217 | Line 280 | rayparticipate(                        /* compute ray medium participation
280                  ge *= 1. - colval(r->albedo,GRN);
281                  be *= 1. - colval(r->albedo,BLU);
282          }
283 <        setcolor(ce,    re<=FTINY ? 1. : re>92. ? 0. : exp(-re),
283 >        setscolor(ce,   re<=FTINY ? 1. : re>92. ? 0. : exp(-re),
284                          ge<=FTINY ? 1. : ge>92. ? 0. : exp(-ge),
285                          be<=FTINY ? 1. : be>92. ? 0. : exp(-be));
286 <        multcolor(r->rcol, ce);                 /* path extinction */
286 >        smultscolor(r->rcol, ce);               /* path extinction */
287          if (r->crtype & SHADOW || intens(r->albedo) <= FTINY)
288                  return;                         /* no scattering */
289 <        setcolor(ca,
290 <                colval(r->albedo,RED)*colval(ambval,RED)*(1.-colval(ce,RED)),
291 <                colval(r->albedo,GRN)*colval(ambval,GRN)*(1.-colval(ce,GRN)),
292 <                colval(r->albedo,BLU)*colval(ambval,BLU)*(1.-colval(ce,BLU)));
293 <        addcolor(r->rcol, ca);                  /* ambient in scattering */
289 >        
290 >        /* PMAP: indirect inscattering accounted for by volume photons? */
291 >        if (!volumePhotonMapping) {
292 >                setscolor(ca,
293 >                        colval(r->albedo,RED)*colval(ambval,RED)*(1.-colval(ce,RED)),
294 >                        colval(r->albedo,GRN)*colval(ambval,GRN)*(1.-colval(ce,GRN)),
295 >                        colval(r->albedo,BLU)*colval(ambval,BLU)*(1.-colval(ce,BLU)));
296 >                saddscolor(r->rcol, ca);                /* ambient in scattering */
297 >        }
298 >        
299          srcscatter(r);                          /* source in scattering */
300   }
301  
302  
303 < extern void
303 > void
304   raytexture(                     /* get material modifiers */
305          RAY  *r,
306          OBJECT  mod
307   )
308   {
309 <        register OBJREC  *m;
309 >        OBJREC  *m;
310                                          /* execute textures and patterns */
311          for ( ; mod != OVOID; mod = m->omod) {
312                  m = objptr(mod);
# Line 257 | Line 325 | raytexture(                    /* get material modifiers */
325   }
326  
327  
328 < extern int
328 > int
329   raymixture(             /* mix modifiers */
330 <        register RAY  *r,
330 >        RAY  *r,
331          OBJECT  fore,
332          OBJECT  back,
333          double  coef
334   )
335   {
336          RAY  fr, br;
337 +        double  mfore, mback;
338          int  foremat, backmat;
339 <        register int  i;
339 >        int  i;
340                                          /* bound coefficient */
341          if (coef > 1.0)
342                  coef = 1.0;
# Line 277 | Line 346 | raymixture(            /* mix modifiers */
346          foremat = backmat = 0;
347                                          /* foreground */
348          fr = *r;
349 <        if (coef > FTINY)
349 >        if (coef > FTINY) {
350 >                fr.rweight *= coef;
351 >                scalescolor(fr.rcoef, coef);
352                  foremat = rayshade(&fr, fore);
353 +        }
354                                          /* background */
355          br = *r;
356 <        if (coef < 1.0-FTINY)
356 >        if (coef < 1.0-FTINY) {
357 >                br.rweight *= 1.0-coef;
358 >                scalescolor(br.rcoef, 1.0-coef);
359                  backmat = rayshade(&br, back);
360 +        }
361                                          /* check for transparency */
362          if (backmat ^ foremat) {
363                  if (backmat && coef > FTINY)
# Line 294 | Line 369 | raymixture(            /* mix modifiers */
369          for (i = 0; i < 3; i++)
370                  r->pert[i] = coef*fr.pert[i] + (1.0-coef)*br.pert[i];
371                                          /* mix pattern colors */
372 <        scalecolor(fr.pcol, coef);
373 <        scalecolor(br.pcol, 1.0-coef);
374 <        copycolor(r->pcol, fr.pcol);
375 <        addcolor(r->pcol, br.pcol);
372 >        scalescolor(fr.pcol, coef);
373 >        scalescolor(br.pcol, 1.0-coef);
374 >        copyscolor(r->pcol, fr.pcol);
375 >        saddscolor(r->pcol, br.pcol);
376                                          /* return value tells if material */
377          if (!foremat & !backmat)
378                  return(0);
379                                          /* mix returned ray values */
380 <        scalecolor(fr.rcol, coef);
381 <        scalecolor(br.rcol, 1.0-coef);
382 <        copycolor(r->rcol, fr.rcol);
383 <        addcolor(r->rcol, br.rcol);
384 <        r->rt = bright(fr.rcol) > bright(br.rcol) ? fr.rt : br.rt;
380 >        scalescolor(fr.rcol, coef);
381 >        scalescolor(br.rcol, 1.0-coef);
382 >        copyscolor(r->rcol, fr.rcol);
383 >        saddscolor(r->rcol, br.rcol);
384 >        scalescolor(fr.mcol, coef);
385 >        scalescolor(br.mcol, 1.0-coef);
386 >        copyscolor(r->mcol, fr.mcol);
387 >        saddscolor(r->mcol, br.mcol);
388 >        mfore = pbright(fr.mcol); mback = pbright(br.mcol);
389 >        r->rmt = mfore > mback ? fr.rmt : br.rmt;
390 >        r->rxt = pbright(fr.rcol)-mfore > pbright(br.rcol)-mback ?
391 >                        fr.rxt : br.rxt;
392          return(1);
393   }
394  
395  
396 < extern double
396 > double
397   raydist(                /* compute (cumulative) ray distance */
398 <        register const RAY  *r,
399 <        register int  flags
398 >        const RAY  *r,
399 >        int  flags
400   )
401   {
402          double  sum = 0.0;
# Line 327 | Line 409 | raydist(               /* compute (cumulative) ray distance */
409   }
410  
411  
412 < extern void
412 > void
413   raycontrib(             /* compute (cumulative) ray contribution */
414 <        COLOR  rc,
414 >        SCOLOR  rc,
415          const RAY  *r,
416          int  flags
417   )
418   {
419 <        COLOR   eext, ext1;
338 <        
339 <        setcolor(eext, 0., 0., 0.);
340 <        setcolor(rc, 1., 1., 1.);
419 >        static int      warnedPM = 0;
420  
421 +        setscolor(rc, 1., 1., 1.);
422 +
423          while (r != NULL && r->crtype&flags) {
424 <                multcolor(rc, r->rcoef);
425 <                copycolor(ext1, r->cext);
426 <                scalecolor(ext1, r->rot);
427 <                addcolor(eext, ext1);
424 >                smultscolor(rc, r->rcoef);
425 >                                        /* check for participating medium */
426 >                if (!warnedPM && (bright(r->cext) > FTINY) |
427 >                                (bright(r->albedo) > FTINY)) {
428 >                        error(WARNING,
429 >        "ray contribution calculation does not support participating media");
430 >                        warnedPM++;
431 >                }
432                  r = r->parent;
433          }
349        if (intens(eext) > FTINY) {
350                setcolor(ext1,  exp(-colval(eext,RED)),
351                                exp(-colval(eext,GRN)),
352                                exp(-colval(eext,BLU)));
353                multcolor(rc, ext1);
354        }
434   }
435  
436  
437 < extern double
437 > double
438   raynormal(              /* compute perturbed normal for ray */
439          FVECT  norm,
440 <        register RAY  *r
440 >        RAY  *r
441   )
442   {
443          double  newdot;
444 <        register int  i;
444 >        int  i;
445  
446          /*      The perturbation is added to the surface normal to obtain
447           *  the new normal.  If the new normal would affect the surface
# Line 382 | Line 461 | raynormal(             /* compute perturbed normal for ray */
461                  return(r->rod);
462          }
463          newdot = -DOT(norm, r->rdir);
464 <        if ((newdot > 0.0) != (r->rod > 0.0)) {         /* fix orientation */
464 >        if ((newdot > 0.0) ^ (r->rod > 0.0)) {          /* fix orientation */
465                  for (i = 0; i < 3; i++)
466                          norm[i] += 2.0*newdot*r->rdir[i];
467                  newdot = -newdot;
# Line 391 | Line 470 | raynormal(             /* compute perturbed normal for ray */
470   }
471  
472  
473 < extern void
473 > void
474   newrayxf(                       /* get new tranformation matrix for ray */
475          RAY  *r
476   )
# Line 400 | Line 479 | newrayxf(                      /* get new tranformation matrix for ray */
479                  struct xfn  *next;
480                  FULLXF  xf;
481          }  xfseed = { &xfseed }, *xflast = &xfseed;
482 <        register struct xfn  *xp;
483 <        register const RAY  *rp;
482 >        struct xfn  *xp;
483 >        const RAY  *rp;
484  
485          /*
486           * Search for transform in circular list that
# Line 412 | Line 491 | newrayxf(                      /* get new tranformation matrix for ray */
491                  if (rp->rox == &xp->xf) {               /* xp in use */
492                          xp = xp->next;                  /* move to next */
493                          if (xp == xflast) {             /* need new one */
494 <                                xp = (struct xfn *)malloc(sizeof(struct xfn));
494 >                                xp = (struct xfn *)bmalloc(sizeof(struct xfn));
495                                  if (xp == NULL)
496                                          error(SYSTEM,
497                                                  "out of memory in newrayxf");
# Line 429 | Line 508 | newrayxf(                      /* get new tranformation matrix for ray */
508   }
509  
510  
511 < extern void
511 > void
512   flipsurface(                    /* reverse surface orientation */
513 <        register RAY  *r
513 >        RAY  *r
514   )
515   {
516          r->rod = -r->rod;
# Line 441 | Line 520 | flipsurface(                   /* reverse surface orientation */
520          r->pert[0] = -r->pert[0];
521          r->pert[1] = -r->pert[1];
522          r->pert[2] = -r->pert[2];
523 +        r->rflips++;
524   }
525  
526  
527 < extern void
527 > int
528 > rayreject(              /* check if candidate hit is worse than current */
529 >        OBJREC *o,
530 >        RAY *r,
531 >        double t,
532 >        double rod
533 > )
534 > {
535 >        OBJREC  *mnew, *mray;
536 >
537 >        if ((t <= FTINY) | (t > r->rot + FTINY))
538 >                return(1);
539 >        if (t < r->rot - FTINY)         /* is new hit significantly closer? */
540 >                return(0);
541 >                                        /* coincident point, so decide... */
542 >        if (o == r->ro)
543 >                return(1);              /* shouldn't happen */
544 >        if (r->ro == NULL)
545 >                return(0);              /* ditto */
546 >        mnew = findmaterial(o);
547 >        mray = findmaterial(r->ro);     /* check material transparencies */
548 >        if (mnew == NULL) {
549 >                if (mray != NULL)
550 >                        return(1);      /* old has material, new does not */
551 >        } else if (mray == NULL) {
552 >                return(0);              /* new has material, old does not */
553 >        } else if (istransp(mnew->otype)) {
554 >                if (!istransp(mray->otype))
555 >                        return(1);      /* new is transparent, old is not */
556 >        } else if (istransp(mray->otype)) {
557 >                return(0);              /* old is transparent, new is not */
558 >        }
559 >        if (rod <= 0) {                 /* check which side we hit */
560 >                if (r->rod > 0)
561 >                        return(1);      /* old hit front, new did not */
562 >        } else if (r->rod <= 0) {
563 >                return(0);              /* new hit front, old did not */
564 >        }
565 >                        /* earlier modifier definition wins tie */
566 >        return (r->ro->omod >= o->omod);
567 > }
568 >
569 > void
570   rayhit(                 /* standard ray hit test */
571          OBJECT  *oset,
572          RAY  *r
# Line 461 | Line 583 | rayhit(                        /* standard ray hit test */
583   }
584  
585  
586 < extern int
586 > int
587   localhit(               /* check for hit in the octree */
588 <        register RAY  *r,
589 <        register CUBE  *scene
588 >        RAY  *r,
589 >        CUBE  *scene
590   )
591   {
592          OBJECT  cxset[MAXCSET+1];       /* set of checked objects */
593          FVECT  curpos;                  /* current cube position */
594          int  sflags;                    /* sign flags */
595          double  t, dt;
596 <        register int  i;
596 >        int  i;
597  
598          nrays++;                        /* increment trace counter */
599          sflags = 0;
# Line 482 | Line 604 | localhit(              /* check for hit in the octree */
604                  else if (r->rdir[i] < -1e-7)
605                          sflags |= 0x10 << i;
606          }
607 <        if (sflags == 0)
608 <                error(CONSISTENCY, "zero ray direction in localhit");
607 >        if (!sflags) {
608 >                error(WARNING, "zero ray direction in localhit");
609 >                return(0);
610 >        }
611                                          /* start off assuming nothing hit */
612          if (r->rmax > FTINY) {          /* except aft plane if one */
613                  r->ro = &Aftplane;
614                  r->rot = r->rmax;
615 <                for (i = 0; i < 3; i++)
492 <                        r->rop[i] = r->rorg[i] + r->rot*r->rdir[i];
615 >                VSUM(r->rop, r->rorg, r->rdir, r->rot);
616          }
617                                          /* find global cube entrance point */
618          t = 0.0;
# Line 512 | Line 635 | localhit(              /* check for hit in the octree */
635                  if (t >= r->rot)        /* clipped already */
636                          return(0);
637                                          /* advance position */
638 <                for (i = 0; i < 3; i++)
516 <                        curpos[i] += r->rdir[i]*t;
638 >                VSUM(curpos, curpos, r->rdir, t);
639  
640                  if (!incube(scene, curpos))     /* non-intersecting ray */
641                          return(0);
# Line 529 | Line 651 | raymove(               /* check for hit as we move */
651          FVECT  pos,                     /* current position, modified herein */
652          OBJECT  *cxs,                   /* checked objects, modified by checkhit */
653          int  dirf,                      /* direction indicators to speed tests */
654 <        register RAY  *r,
655 <        register CUBE  *cu
654 >        RAY  *r,
655 >        CUBE  *cu
656   )
657   {
658          int  ax;
# Line 538 | Line 660 | raymove(               /* check for hit as we move */
660  
661          if (istree(cu->cutree)) {               /* recurse on subcubes */
662                  CUBE  cukid;
663 <                register int  br, sgn;
663 >                int  br, sgn;
664  
665                  cukid.cusize = cu->cusize * 0.5;        /* find subcube */
666                  VCOPY(cukid.cuorg, cu->cuorg);
# Line 604 | Line 726 | raymove(               /* check for hit as we move */
726                          ax = 2;
727                  }
728          }
729 <        pos[0] += r->rdir[0]*t;
608 <        pos[1] += r->rdir[1]*t;
609 <        pos[2] += r->rdir[2]*t;
729 >        VSUM(pos, pos, r->rdir, t);
730          return(ax);
731   }
732  
733  
734   static int
735   checkhit(               /* check for hit in full cube */
736 <        register RAY  *r,
736 >        RAY  *r,
737          CUBE  *cu,
738          OBJECT  *cxs
739   )
# Line 634 | Line 754 | checkhit(              /* check for hit in full cube */
754  
755   static void
756   checkset(               /* modify checked set and set to check */
757 <        register OBJECT  *os,                   /* os' = os - cs */
758 <        register OBJECT  *cs                    /* cs' = cs + os */
757 >        OBJECT  *os,                    /* os' = os - cs */
758 >        OBJECT  *cs                     /* cs' = cs + os */
759   )
760   {
761          OBJECT  cset[MAXCSET+MAXSET+1];
762 <        register int  i, j;
762 >        int  i, j;
763          int  k;
764                                          /* copy os in place, cset <- cs */
765          cset[0] = 0;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines