| 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 |
|
* Source sampling routines |
| 6 |
+ |
* |
| 7 |
+ |
* External symbols declared in source.h |
| 8 |
|
*/ |
| 9 |
|
|
| 10 |
+ |
#include "copyright.h" |
| 11 |
+ |
|
| 12 |
|
#include "ray.h" |
| 13 |
|
|
| 14 |
|
#include "source.h" |
| 16 |
|
#include "random.h" |
| 17 |
|
|
| 18 |
|
|
| 19 |
+ |
static int cyl_partit(), flt_partit(); |
| 20 |
+ |
|
| 21 |
+ |
|
| 22 |
|
double |
| 23 |
|
nextssamp(r, si) /* compute sample for source, rtn. distance */ |
| 24 |
|
register RAY *r; /* origin is read, direction is set */ |
| 28 |
|
FVECT vpos; |
| 29 |
|
double d; |
| 30 |
|
register int i; |
| 31 |
< |
|
| 31 |
> |
nextsample: |
| 32 |
|
while (++si->sp >= si->np) { /* get next sample */ |
| 33 |
|
if (++si->sn >= nsources) |
| 34 |
|
return(0.0); /* no more */ |
| 80 |
|
r->rdir[i] -= r->rorg[i]; |
| 81 |
|
/* compute distance */ |
| 82 |
|
if ((d = normalize(r->rdir)) == 0.0) |
| 83 |
< |
return(nextssamp(r, si)); /* at source! */ |
| 83 |
> |
goto nextsample; /* at source! */ |
| 84 |
|
|
| 85 |
|
/* compute sample size */ |
| 82 |
– |
si->dom = source[si->sn].ss2; |
| 86 |
|
if (source[si->sn].sflags & SFLAT) { |
| 87 |
< |
si->dom *= sflatform(si->sn, r->rdir); |
| 88 |
< |
si->dom *= (double)(size[SU]*size[SV])/(MAXSPART*MAXSPART); |
| 87 |
> |
si->dom = sflatform(si->sn, r->rdir); |
| 88 |
> |
si->dom *= size[SU]*size[SV]/(MAXSPART*(double)MAXSPART); |
| 89 |
|
} else if (source[si->sn].sflags & SCYL) { |
| 90 |
< |
si->dom *= scylform(si->sn, r->rdir); |
| 91 |
< |
si->dom *= (double)size[SU]/MAXSPART; |
| 90 |
> |
si->dom = scylform(si->sn, r->rdir); |
| 91 |
> |
si->dom *= size[SU]/(double)MAXSPART; |
| 92 |
|
} else { |
| 93 |
< |
si->dom *= (double)(size[SU]*size[SV]*size[SW]) / |
| 94 |
< |
(MAXSPART*MAXSPART*MAXSPART) ; |
| 93 |
> |
si->dom = size[SU]*size[SV]*(double)size[SW] / |
| 94 |
> |
(MAXSPART*MAXSPART*(double)MAXSPART) ; |
| 95 |
|
} |
| 96 |
< |
if (source[si->sn].sflags & SDISTANT) |
| 96 |
> |
if (source[si->sn].sflags & SDISTANT) { |
| 97 |
> |
si->dom *= source[si->sn].ss2; |
| 98 |
|
return(FHUGE); |
| 99 |
< |
si->dom /= d*d; |
| 99 |
> |
} |
| 100 |
> |
if (si->dom <= 1e-4) |
| 101 |
> |
goto nextsample; /* behind source? */ |
| 102 |
> |
si->dom *= source[si->sn].ss2/(d*d); |
| 103 |
|
return(d); /* sample OK, return distance */ |
| 104 |
|
} |
| 105 |
|
|
| 106 |
|
|
| 107 |
+ |
int |
| 108 |
|
skipparts(ct, sz, pp, pt) /* skip to requested partition */ |
| 109 |
|
int ct[3], sz[3]; /* center and size of partition (returned) */ |
| 110 |
|
register int pp[2]; /* current index, number to skip (modified) */ |
| 136 |
|
} |
| 137 |
|
|
| 138 |
|
|
| 139 |
+ |
void |
| 140 |
|
nopart(si, r) /* single source partition */ |
| 141 |
|
register SRCINDEX *si; |
| 142 |
|
RAY *r; |
| 147 |
|
} |
| 148 |
|
|
| 149 |
|
|
| 150 |
+ |
void |
| 151 |
|
cylpart(si, r) /* partition a cylinder */ |
| 152 |
|
SRCINDEX *si; |
| 153 |
|
register RAY *r; |
| 224 |
|
} |
| 225 |
|
|
| 226 |
|
|
| 227 |
+ |
void |
| 228 |
|
flatpart(si, r) /* partition a flat source */ |
| 229 |
|
register SRCINDEX *si; |
| 230 |
|
register RAY *r; |