Mitsuba Renderer  0.5.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
constants.h
Go to the documentation of this file.
1 /*
2  This file is part of Mitsuba, a physically based rendering system.
3 
4  Copyright (c) 2007-2014 by Wenzel Jakob and others.
5 
6  Mitsuba is free software; you can redistribute it and/or modify
7  it under the terms of the GNU General Public License Version 3
8  as published by the Free Software Foundation.
9 
10  Mitsuba is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU General Public License for more details.
14 
15  You should have received a copy of the GNU General Public License
16  along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18 
19 #pragma once
20 #if !defined(__MITSUBA_CORE_CONSTANTS_H)
21 #define __MITSUBA_CORE_CONSTANTS_H
22 
23 /* Choice of precision */
24 #ifdef DOUBLE_PRECISION
25 #define Epsilon 1e-7
26 #define ShadowEpsilon 1e-5
27 #else
28 #define Epsilon 1e-4f
29 #define ShadowEpsilon 1e-3f
30 #endif
31 #define DeltaEpsilon 1e-3f
32 
33 /* Assumed L1 cache line size for alignment purposes */
34 #if !defined(L1_CACHE_LINE_SIZE)
35 #define L1_CACHE_LINE_SIZE 64
36 #endif
37 
38 #ifdef M_E
39 #undef M_E
40 #endif
41 
42 #ifdef M_PI
43 #undef M_PI
44 #endif
45 
46 #ifdef INFINITY
47 #undef INFINITY
48 #endif
49 
50 #if defined(__WINDOWS__)
51 #define ONE_MINUS_EPS_FLT 0.999999940395355225f
52 #define ONE_MINUS_EPS_DBL 0.999999999999999888
53 #define RCPOVERFLOW_FLT 2.93873587705571876e-39f
54 #define RCPOVERFLOW_DBL 5.56268464626800345e-309
55 #else
56 #define ONE_MINUS_EPS_FLT 0x1.fffffep-1f
57 #define ONE_MINUS_EPS_DBL 0x1.fffffffffffff7p-1
58 #define RCPOVERFLOW_FLT 0x1p-128f
59 #define RCPOVERFLOW_DBL 0x1p-1024
60 #endif
61 
62 #define M_E_FLT 2.71828182845904523536f
63 #define M_PI_FLT 3.14159265358979323846f
64 #define INV_PI_FLT 0.31830988618379067154f
65 #define INV_TWOPI_FLT 0.15915494309189533577f
66 #define INV_FOURPI_FLT 0.07957747154594766788f
67 #define SQRT_TWO_FLT 1.41421356237309504880f
68 #define INV_SQRT_TWO_FLT 0.70710678118654752440f
69 
70 #define M_E_DBL 2.71828182845904523536
71 #define M_PI_DBL 3.14159265358979323846
72 #define INV_PI_DBL 0.31830988618379067154
73 #define INV_TWOPI_DBL 0.15915494309189533577
74 #define INV_FOURPI_DBL 0.07957747154594766788
75 #define SQRT_TWO_DBL 1.41421356237309504880
76 #define INV_SQRT_TWO_DBL 0.70710678118654752440
77 
78 #ifdef SINGLE_PRECISION
79 #define M_E M_E_FLT
80 #define M_PI M_PI_FLT
81 #define INV_PI INV_PI_FLT
82 #define INV_TWOPI INV_TWOPI_FLT
83 #define INV_FOURPI INV_FOURPI_FLT
84 #define SQRT_TWO SQRT_TWO_FLT
85 #define INV_SQRT_TWO INV_SQRT_TWO_FLT
86 #define ONE_MINUS_EPS ONE_MINUS_EPS_FLT
87 #define RCPOVERFLOW RCPOVERFLOW_FLT
88 #else
89 #define M_E M_E_DBL
90 #define M_PI M_PI_DBL
91 #define INV_PI INV_PI_DBL
92 #define INV_TWOPI INV_TWOPI_DBL
93 #define INV_FOURPI INV_FOURPI_DBL
94 #define SQRT_TWO SQRT_TWO_DBL
95 #define INV_SQRT_TWO INV_SQRT_TWO_DBL
96 #define ONE_MINUS_EPS ONE_MINUS_EPS_DBL
97 #define RCPOVERFLOW RCPOVERFLOW_DBL
98 #endif
99 #endif /* __MITSUBA_CORE_CONSTANTS_H */