ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/rt/pmaprand.h
Revision: 2.2
Committed: Tue Apr 21 19:16:51 2015 UTC (9 years, 1 month ago) by greg
Content type: text/plain
Branch: MAIN
Changes since 2.1: +14 -5 lines
Log Message:
Fixes for Windows and photon map

File Contents

# Content
1 #ifndef PMAPRAND_H
2 #define PMAPRAND_H
3
4 /*
5 ==================================================================
6 Random number generators for photon distribution
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
11 ==================================================================
12
13 $Id: pmaprand.h,v 2.1 2015/02/24 19:39:27 greg Exp $
14 */
15
16
17
18 /* According to the analytical validation, skipping numbers in the sequence
19 introduces bias in scenes with high reflectance. We therefore use
20 erand48() with separate states for photon emission, scattering, and
21 russian roulette. The pmapSeed() and pmapRandom() macros can be adapted
22 to other (better?) RNGs. */
23
24 #if defined(_WIN32) || defined(BSD)
25 /* Assume no erand48(), so use standard RNG without explicit multistate
26 control; the resulting sequences will be suboptimal */
27 #include "random.h"
28
29 #define pmapSeed(seed, state) (srandom(seed))
30 #define pmapRandom(state) (frandom())
31 #else
32 #define pmapSeed(seed, state) (state [0] += seed, state [1] += seed, \
33 state [2] += seed)
34 #define pmapRandom(state) erand48(state)
35 #endif
36
37
38 extern unsigned short partState [3], emitState [3], cntState [3],
39 mediumState [3], scatterState [3], rouletteState [3],
40 randSeed;
41
42 #endif
43