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

Comparing ray/src/rt/source.c (file contents):
Revision 2.83 by greg, Sat Nov 9 15:21:32 2024 UTC vs.
Revision 2.88 by greg, Tue Oct 21 16:12:05 2025 UTC

# Line 52 | Line 52 | marksources(void)                      /* find and mark source objects */
52          int  ns;
53                                          /* call us only once! */
54          if (nsources)
55 <                error(CONSISTENCY, "Multiple calls to marksources!");
55 >                error(CONSISTENCY, "multiple calls to marksources!");
56                                          /* initialize dispatch table */
57          initstypes();
58                                          /* find direct sources */
# Line 150 | Line 150 | distantsources(void)                   /* only mark distant sources */
150          int  ns;
151                                          /* call us only once! */
152          if (nsources)
153 <                error(CONSISTENCY, "Multiple calls to distantsources!");
153 >                error(CONSISTENCY, "multiple calls to distantsources!");
154                                          /* initialize dispatch table */
155          initstypes();
156                                          /* sources needed for sourcehit() */
# Line 216 | Line 216 | freesources(void)                      /* free all source structures */
216  
217  
218   int
219 < srcray(                         /* send a ray to a source, return domega */
220 <        RAY  *sr,               /* returned source ray */
221 <        RAY  *r,                        /* ray which hit object */
219 > srcray(                         /* aim a ray at a source, return domega */
220 >        RAY  *sr,               /* prepared source ray */
221 >        RAY  *r,                        /* originating ray (or NULL) */
222          SRCINDEX  *si                   /* source sample index */
223   )
224   {
# Line 231 | Line 231 | srcray(                                /* send a ray to a source, return domega */
231                  sr->rmax = 0.0;
232  
233          while ((d = nextssamp(sr, si)) != 0.0) {
234 <                sr->rsrc = si->sn;                      /* remember source */
234 >                sr->rsrc = si->sn;              /* remember source */
235                  srcp = source + si->sn;
236                  if (srcp->sflags & SDISTANT) {
237                          if (srcp->sflags & SSPOT && spotout(sr, srcp->sl.s))
# Line 561 | Line 561 | srcscatter(                    /* compute source scattering into ray */
561          RAY  *r
562   )
563   {
564 <        int  oldsampndx;
564 >        unsigned long  oldsampndx;
565          int  nsamps;
566          RAY  sr;
567          SRCINDEX  si;
# Line 583 | Line 583 | srcscatter(                    /* compute source scattering into ray */
583                  nsamps = MAXSSAMP;
584   #endif
585          oldsampndx = samplendx;
586 <        samplendx = random()&0x7fff;            /* randomize */
586 >        samplendx = random()&0x7ffff;           /* randomize */
587          for (i = volumePhotonMapping ? 1 : r->slights[0]; i > 0; i--) {
588                  /* for each source OR once if volume photon map enabled */
589                  for (j = 0; j < nsamps; j++) {  /* for each sample position */
# Line 603 | Line 603 | srcscatter(                    /* compute source scattering into ray */
603                          sr.rorg[2] = r->rorg[2] + r->rdir[2]*t;
604                          
605                          if (!volumePhotonMapping) {
606 <                                if (srcskip(r->slights[i], r))
606 >                                sr.parent = r;          /* hack for preemptive test */
607 >                                if (srcskip(r->slights[i], &sr))
608                                          continue;
609                                  initsrcindex(&si);      /* sample ray to this source */
610                                  si.sn = r->slights[i];

Diff Legend

Removed lines
+ Added lines
< Changed lines (old)
> Changed lines (new)