Path Tracer
defs.h
Go to the documentation of this file.
1 /*
2 ---------------------------------------------------------------------------
3 Open Asset Import Library (assimp)
4 ---------------------------------------------------------------------------
5 
6 Copyright (c) 2006-2020, assimp team
7 
8 All rights reserved.
9 
10 Redistribution and use of this software in source and binary forms,
11 with or without modification, are permitted provided that the following
12 conditions are met:
13 
14 * Redistributions of source code must retain the above
15  copyright notice, this list of conditions and the
16  following disclaimer.
17 
18 * Redistributions in binary form must reproduce the above
19  copyright notice, this list of conditions and the
20  following disclaimer in the documentation and/or other
21  materials provided with the distribution.
22 
23 * Neither the name of the assimp team, nor the names of its
24  contributors may be used to endorse or promote products
25  derived from this software without specific prior
26  written permission of the assimp team.
27 
28 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
29 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
30 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
31 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
32 OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
33 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
34 LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
35 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
36 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
37 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
38 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
39 ---------------------------------------------------------------------------
40 */
41 
47 #pragma once
48 #ifndef AI_DEFINES_H_INC
49 #define AI_DEFINES_H_INC
50 
51 #ifdef __GNUC__
52 #pragma GCC system_header
53 #endif
54 
55 #include <assimp/config.h>
56 
58 /* Define ASSIMP_BUILD_NO_XX_IMPORTER to disable a specific
59  * file format loader. The loader is be excluded from the
60  * build in this case. 'XX' stands for the most common file
61  * extension of the file format. E.g.:
62  * ASSIMP_BUILD_NO_X_IMPORTER disables the X loader.
63  *
64  * If you're unsure about that, take a look at the implementation of the
65  * import plugin you wish to disable. You'll find the right define in the
66  * first lines of the corresponding unit.
67  *
68  * Other (mixed) configuration switches are listed here:
69  * ASSIMP_BUILD_NO_COMPRESSED_X
70  * - Disable support for compressed X files (zip)
71  * ASSIMP_BUILD_NO_COMPRESSED_BLEND
72  * - Disable support for compressed Blender files (zip)
73  * ASSIMP_BUILD_NO_COMPRESSED_IFC
74  * - Disable support for IFCZIP files (unzip)
75  */
77 
78 #ifndef ASSIMP_BUILD_NO_COMPRESSED_X
79 #define ASSIMP_BUILD_NEED_Z_INFLATE
80 #endif
81 
82 #ifndef ASSIMP_BUILD_NO_COMPRESSED_BLEND
83 #define ASSIMP_BUILD_NEED_Z_INFLATE
84 #endif
85 
86 #ifndef ASSIMP_BUILD_NO_COMPRESSED_IFC
87 #define ASSIMP_BUILD_NEED_Z_INFLATE
88 #define ASSIMP_BUILD_NEED_UNZIP
89 #endif
90 
91 #ifndef ASSIMP_BUILD_NO_Q3BSP_IMPORTER
92 #define ASSIMP_BUILD_NEED_Z_INFLATE
93 #define ASSIMP_BUILD_NEED_UNZIP
94 #endif
95 
97 /* Define ASSIMP_BUILD_NO_XX_PROCESS to disable a specific
98  * post processing step. This is the current list of process names ('XX'):
99  * CALCTANGENTS
100  * JOINVERTICES
101  * TRIANGULATE
102  * DROPFACENORMALS
103  * GENFACENORMALS
104  * GENVERTEXNORMALS
105  * REMOVEVC
106  * SPLITLARGEMESHES
107  * PRETRANSFORMVERTICES
108  * LIMITBONEWEIGHTS
109  * VALIDATEDS
110  * IMPROVECACHELOCALITY
111  * FIXINFACINGNORMALS
112  * REMOVE_REDUNDANTMATERIALS
113  * OPTIMIZEGRAPH
114  * SORTBYPTYPE
115  * FINDINVALIDDATA
116  * TRANSFORMTEXCOORDS
117  * GENUVCOORDS
118  * ENTITYMESHBUILDER
119  * EMBEDTEXTURES
120  * MAKELEFTHANDED
121  * FLIPUVS
122  * FLIPWINDINGORDER
123  * OPTIMIZEMESHES
124  * OPTIMIZEANIMS
125  * OPTIMIZEGRAPH
126  * GENENTITYMESHES
127  * FIXTEXTUREPATHS
128  * GENBOUNDINGBOXES */
130 
131 #ifdef _WIN32
132 #undef ASSIMP_API
133 /* Define 'ASSIMP_BUILD_DLL_EXPORT' to build a DLL of the library */
136 #ifdef ASSIMP_BUILD_DLL_EXPORT
137 #define ASSIMP_API __declspec(dllexport)
138 #define ASSIMP_API_WINONLY __declspec(dllexport)
139 
141 /* Define 'ASSIMP_DLL' before including Assimp to link to ASSIMP in
142  * an external DLL under Windows. Default is static linkage. */
144 #elif (defined ASSIMP_DLL)
145 #define ASSIMP_API __declspec(dllimport)
146 #define ASSIMP_API_WINONLY __declspec(dllimport)
147 #else
148 #define ASSIMP_API
149 #define ASSIMP_API_WINONLY
150 #endif
151 #elif defined(SWIG)
152 /* Do nothing, the relevant defines are all in AssimpSwigPort.i */
153 #else
154 #define ASSIMP_API __attribute__((visibility("default")))
155 #define ASSIMP_API_WINONLY
156 #endif // _WIN32
157 
158 #ifdef _MSC_VER
159 #pragma warning(disable : 4521 4512 4714 4127 4351 4510)
160 #ifdef ASSIMP_BUILD_DLL_EXPORT
161 #pragma warning(disable : 4251)
162 #endif
163 /* Force the compiler to inline a function, if possible
164  */
165 #define AI_FORCE_INLINE __forceinline
166 
167 /* Tells the compiler that a function never returns. Used in code analysis
168  * to skip dead paths (e.g. after an assertion evaluated to false). */
169 #define AI_WONT_RETURN __declspec(noreturn)
170 #elif defined(SWIG)
171 
172 /* Do nothing, the relevant defines are all in AssimpSwigPort.i */
173 
174 #else
175 #define AI_WONT_RETURN
176 #define AI_FORCE_INLINE inline
177 #endif // (defined _MSC_VER)
178 
179 #ifdef __GNUC__
180 #define AI_WONT_RETURN_SUFFIX __attribute__((noreturn))
181 #else
182 #define AI_WONT_RETURN_SUFFIX
183 #endif // (defined __clang__)
184 
185 #ifdef __cplusplus
186 /* No explicit 'struct' and 'enum' tags for C++, this keeps showing up
187  * in doxydocs.
188  */
189 #define C_STRUCT
190 #define C_ENUM
191 #else
192 /* To build the documentation, make sure ASSIMP_DOXYGEN_BUILD
194  * is defined by Doxygen's preprocessor. The corresponding
195  * entries in the DOXYFILE are: */
197 #if 0
198  ENABLE_PREPROCESSING = YES
199  MACRO_EXPANSION = YES
200  EXPAND_ONLY_PREDEF = YES
201  SEARCH_INCLUDES = YES
202  INCLUDE_PATH =
203  INCLUDE_FILE_PATTERNS =
204  PREDEFINED = ASSIMP_DOXYGEN_BUILD=1
205  EXPAND_AS_DEFINED = C_STRUCT C_ENUM
206  SKIP_FUNCTION_MACROS = YES
207 #endif
208 /* Doxygen gets confused if we use c-struct typedefs to avoid
210  * the explicit 'struct' notation. This trick here has the same
211  * effect as the TYPEDEF_HIDES_STRUCT option, but we don't need
212  * to typedef all structs/enums. */
214 #if (defined ASSIMP_DOXYGEN_BUILD)
215 #define C_STRUCT
216 #define C_ENUM
217 #else
218 #define C_STRUCT struct
219 #define C_ENUM enum
220 #endif
221 #endif
222 
223 #if (defined(__BORLANDC__) || defined(__BCPLUSPLUS__))
224 #error Currently, Borland is unsupported. Feel free to port Assimp.
225 #endif
226 
228 /* Define ASSIMP_BUILD_SINGLETHREADED to compile assimp
229  * without threading support. The library doesn't utilize
230  * threads then and is itself not threadsafe. */
232 #ifndef ASSIMP_BUILD_SINGLETHREADED
233 #define ASSIMP_BUILD_SINGLETHREADED
234 #endif
235 
236 #if defined(_DEBUG) || !defined(NDEBUG)
237 #define ASSIMP_BUILD_DEBUG
238 #endif
239 
241 /* Define ASSIMP_DOUBLE_PRECISION to compile assimp
242  * with double precision support (64-bit). */
244 
245 #ifdef ASSIMP_DOUBLE_PRECISION
246 typedef double ai_real;
247 typedef signed long long int ai_int;
248 typedef unsigned long long int ai_uint;
249 #ifndef ASSIMP_AI_REAL_TEXT_PRECISION
250 #define ASSIMP_AI_REAL_TEXT_PRECISION 16
251 #endif // ASSIMP_AI_REAL_TEXT_PRECISION
252 #else // ASSIMP_DOUBLE_PRECISION
253 typedef float ai_real;
254 typedef signed int ai_int;
255 typedef unsigned int ai_uint;
256 #ifndef ASSIMP_AI_REAL_TEXT_PRECISION
257 #define ASSIMP_AI_REAL_TEXT_PRECISION 8
258 #endif // ASSIMP_AI_REAL_TEXT_PRECISION
259 #endif // ASSIMP_DOUBLE_PRECISION
260 
262 /* Useful constants */
264 
265 /* This is PI. Hi PI. */
266 #define AI_MATH_PI (3.141592653589793238462643383279)
267 #define AI_MATH_TWO_PI (AI_MATH_PI * 2.0)
268 #define AI_MATH_HALF_PI (AI_MATH_PI * 0.5)
269 
270 /* And this is to avoid endless casts to float */
271 #define AI_MATH_PI_F (3.1415926538f)
272 #define AI_MATH_TWO_PI_F (AI_MATH_PI_F * 2.0f)
273 #define AI_MATH_HALF_PI_F (AI_MATH_PI_F * 0.5f)
274 
275 /* Tiny macro to convert from radians to degrees and back */
276 #define AI_DEG_TO_RAD(x) ((x) * (ai_real)0.0174532925)
277 #define AI_RAD_TO_DEG(x) ((x) * (ai_real)57.2957795)
278 
279 /* Numerical limits */
280 static const ai_real ai_epsilon = (ai_real)0.00001;
281 
282 /* Support for big-endian builds */
283 #if defined(__BYTE_ORDER__)
284 #if (__BYTE_ORDER__ == __ORDER_BIG_ENDIAN__)
285 #if !defined(__BIG_ENDIAN__)
286 #define __BIG_ENDIAN__
287 #endif
288 #else /* little endian */
289 #if defined(__BIG_ENDIAN__)
290 #undef __BIG_ENDIAN__
291 #endif
292 #endif
293 #endif
294 #if defined(__BIG_ENDIAN__)
295 #define AI_BUILD_BIG_ENDIAN
296 #endif
297 
303 #define AI_MAX_ALLOC(type) ((256U * 1024 * 1024) / sizeof(type))
304 
305 #ifndef _MSC_VER
306 #if __cplusplus >= 201103L // C++11
307 #define AI_NO_EXCEPT noexcept
308 #else
309 #define AI_NO_EXCEPT
310 #endif
311 #else
312 #if (_MSC_VER >= 1915)
313 #define AI_NO_EXCEPT noexcept
314 #else
315 #define AI_NO_EXCEPT
316 #endif
317 #endif // _MSC_VER
318 
322 #if (defined ASSIMP_BUILD_DEBUG)
323 #define AI_DEBUG_INVALIDATE_PTR(x) x = NULL;
324 #else
325 #define AI_DEBUG_INVALIDATE_PTR(x)
326 #endif
327 
328 #endif // !! AI_DEFINES_H_INC