defs.h 10 KB

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