1 |
+ |
#ifndef lint |
2 |
+ |
static const char RCSid[] = "$Id$"; |
3 |
+ |
#endif |
4 |
|
/* |
5 |
|
================================================================== |
6 |
|
Photon map support routines for emission from light sources |
7 |
|
|
8 |
|
Roland Schregle (roland.schregle@{hslu.ch, gmail.com}) |
9 |
|
(c) Fraunhofer Institute for Solar Energy Systems, |
10 |
< |
Lucerne University of Applied Sciences & Arts |
10 |
> |
(c) Lucerne University of Applied Sciences and Arts, |
11 |
> |
supported by the Swiss National Science Foundation (SNSF, #147053) |
12 |
|
================================================================== |
13 |
|
|
14 |
|
$Id$ |
50 |
|
if (!emap -> partitions) |
51 |
|
error(USER, "can't allocate source partitions"); |
52 |
|
|
53 |
< |
bzero(emap -> partitions + (emap -> maxPartitions >> 2), |
54 |
< |
emap -> maxPartitions >> 2); |
53 |
> |
memset(emap -> partitions + (emap -> maxPartitions >> 2), 0, |
54 |
> |
emap -> maxPartitions >> 2); |
55 |
|
} |
56 |
|
|
57 |
|
if (du2 * dv2 <= 1) { /* hit limit? */ |
104 |
|
RREAL *vp; |
105 |
|
double du2, dv2; |
106 |
|
|
107 |
< |
bzero(emap -> partitions, emap -> maxPartitions >> 1); |
107 |
> |
memset(emap -> partitions, 0, emap -> maxPartitions >> 1); |
108 |
|
emap -> partArea = srcsizerat * thescene.cusize; |
109 |
|
emap -> partArea *= emap -> partArea; |
110 |
|
vp = emap -> src -> ss [SU]; |
136 |
|
|
137 |
|
else { |
138 |
|
/* No photon ports defined, so partition scene cube faces */ |
139 |
< |
bzero(emap -> partitions, emap -> maxPartitions >> 1); |
139 |
> |
memset(emap -> partitions, 0, emap -> maxPartitions >> 1); |
140 |
|
setpart(emap -> partitions, 0, S0); |
141 |
|
emap -> partitionCnt = 0; |
142 |
|
emap -> numPartitions = 1 / srcsizerat; |
154 |
|
{ |
155 |
|
unsigned numTheta, numPhi; |
156 |
|
|
157 |
< |
bzero(emap -> partitions, emap -> maxPartitions >> 1); |
157 |
> |
memset(emap -> partitions, 0, emap -> maxPartitions >> 1); |
158 |
|
setpart(emap -> partitions, 0, S0); |
159 |
|
emap -> partArea = 4 * PI * sqr(emap -> src -> srad); |
160 |
|
emap -> numPartitions = emap -> partArea / |
184 |
|
emap -> maxPartitions >> 1); |
185 |
|
if (!emap -> partitions) |
186 |
|
error(USER, "can't allocate source partitions"); |
187 |
< |
bzero(emap -> partitions + (emap -> maxPartitions >> 2), |
187 |
> |
|
188 |
> |
memset(emap -> partitions + (emap -> maxPartitions >> 2), 0, |
189 |
|
emap -> maxPartitions >> 2); |
190 |
|
} |
191 |
|
|
227 |
|
{ |
228 |
|
double d2; |
229 |
|
|
230 |
< |
bzero(emap -> partitions, emap -> maxPartitions >> 1); |
230 |
> |
memset(emap -> partitions, 0, emap -> maxPartitions >> 1); |
231 |
|
d2 = srcsizerat * thescene.cusize; |
232 |
|
d2 = PI * emap -> src -> ss2 / (2 * emap -> src -> srad * sqr(d2)); |
233 |
|
d2 *= d2 * DOT(emap -> src -> ss [SU], emap -> src -> ss [SU]); |
595 |
|
unsigned i, t, p; |
596 |
|
double phi, cosTheta, sinTheta, du, dv, dOmega, thetaScale; |
597 |
|
EmissionSample* sample; |
598 |
< |
const OBJREC* mod = objptr(emap -> src -> so -> omod); |
598 |
> |
const OBJREC* mod = findmaterial(emap -> src -> so); |
599 |
|
static RAY r; |
600 |
|
#if 0 |
601 |
|
static double lastCosNorm = FHUGE; |
602 |
|
static SRCREC *lastSrc = NULL, *lastPort = NULL; |
603 |
|
#endif |
604 |
|
|
605 |
+ |
setcolor(emap -> partFlux, 0, 0, 0); |
606 |
+ |
|
607 |
|
photonOrigin [emap -> src -> so -> otype] (emap); |
608 |
|
cosTheta = DOT(emap -> ws, emap -> wh); |
609 |
|
|
626 |
|
#endif |
627 |
|
|
628 |
|
/* Need to recompute flux & PDF */ |
622 |
– |
setcolor(emap -> partFlux, 0, 0, 0); |
629 |
|
emap -> cdf = 0; |
630 |
|
emap -> numSamples = 0; |
631 |
|
|
674 |
|
|
675 |
|
VCOPY(r.rorg, emap -> photonOrg); |
676 |
|
VCOPY(r.rop, emap -> photonOrg); |
677 |
< |
r.rmax = FHUGE; |
677 |
> |
r.rmax = 0; |
678 |
|
|
679 |
|
for (t = 0; t < emap -> numTheta; t++) { |
680 |
|
for (p = 0; p < emap -> numPhi; p++) { |
744 |
|
unsigned long i, lo, hi; |
745 |
|
const EmissionSample* sample = emap -> samples; |
746 |
|
RREAL du, dv, cosTheta, cosThetaSqr, sinTheta, phi; |
747 |
< |
const OBJREC* mod = objptr(emap -> src -> so -> omod); |
747 |
> |
const OBJREC* mod = findmaterial(emap -> src -> so); |
748 |
|
|
749 |
|
/* Choose a new origin within current partition for every |
750 |
|
emitted photon to break up clustering artifacts */ |
751 |
|
photonOrigin [emap -> src -> so -> otype] ((EmissionMap*)emap); |
752 |
+ |
/* If we have a local glow source with a maximum radius, then |
753 |
+ |
restrict our photon to the specified distance (otherwise no limit) */ |
754 |
+ |
if (mod -> otype == MAT_GLOW && !(emap -> src -> sflags & SDISTANT) |
755 |
+ |
&& mod -> oargs.farg[3] > FTINY) |
756 |
+ |
ray -> rmax = mod -> oargs.farg[3]; |
757 |
+ |
else |
758 |
+ |
ray -> rmax = 0; |
759 |
|
rayorigin(ray, PRIMARY, NULL, NULL); |
747 |
– |
ray -> rmax = FHUGE; |
760 |
|
|
761 |
|
if (!emap -> numSamples) { |
762 |
|
/* Source is unmodified and has no port, and either local with |