defs.h 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346
  1. /*
  2. ---------------------------------------------------------------------------
  3. Open Asset Import Library (assimp)
  4. ---------------------------------------------------------------------------
  5. Copyright (c) 2006-2022, 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. #ifdef __GNUC__
  42. #pragma GCC system_header
  43. #endif
  44. #include <assimp/config.h>
  45. //////////////////////////////////////////////////////////////////////////
  46. /* Define ASSIMP_BUILD_NO_XX_IMPORTER to disable a specific
  47. * file format loader. The loader is be excluded from the
  48. * build in this case. 'XX' stands for the most common file
  49. * extension of the file format. E.g.:
  50. * ASSIMP_BUILD_NO_X_IMPORTER disables the X loader.
  51. *
  52. * If you're unsure about that, take a look at the implementation of the
  53. * import plugin you wish to disable. You'll find the right define in the
  54. * first lines of the corresponding unit.
  55. *
  56. * Other (mixed) configuration switches are listed here:
  57. * ASSIMP_BUILD_NO_COMPRESSED_X
  58. * - Disable support for compressed X files (zip)
  59. * ASSIMP_BUILD_NO_COMPRESSED_BLEND
  60. * - Disable support for compressed Blender files (zip)
  61. * ASSIMP_BUILD_NO_COMPRESSED_IFC
  62. * - Disable support for IFCZIP files (unzip)
  63. */
  64. //////////////////////////////////////////////////////////////////////////
  65. #ifndef ASSIMP_BUILD_NO_COMPRESSED_X
  66. #define ASSIMP_BUILD_NEED_Z_INFLATE
  67. #endif
  68. #ifndef ASSIMP_BUILD_NO_COMPRESSED_BLEND
  69. #define ASSIMP_BUILD_NEED_Z_INFLATE
  70. #endif
  71. #ifndef ASSIMP_BUILD_NO_COMPRESSED_IFC
  72. #define ASSIMP_BUILD_NEED_Z_INFLATE
  73. #define ASSIMP_BUILD_NEED_UNZIP
  74. #endif
  75. #ifndef ASSIMP_BUILD_NO_Q3BSP_IMPORTER
  76. #define ASSIMP_BUILD_NEED_Z_INFLATE
  77. #define ASSIMP_BUILD_NEED_UNZIP
  78. #endif
  79. // We need those constants, workaround for any platforms where nobody defined them yet
  80. #if (!defined SIZE_MAX)
  81. #define SIZE_MAX (~((size_t)0))
  82. #endif
  83. /*#if (!defined UINT_MAX)
  84. #define UINT_MAX (~((unsigned int)0))
  85. #endif*/
  86. //////////////////////////////////////////////////////////////////////////
  87. /* Define ASSIMP_BUILD_NO_XX_PROCESS to disable a specific
  88. * post processing step. This is the current list of process names ('XX'):
  89. * CALCTANGENTS
  90. * JOINVERTICES
  91. * TRIANGULATE
  92. * DROPFACENORMALS
  93. * GENFACENORMALS
  94. * GENVERTEXNORMALS
  95. * REMOVEVC
  96. * SPLITLARGEMESHES
  97. * PRETRANSFORMVERTICES
  98. * LIMITBONEWEIGHTS
  99. * VALIDATEDS
  100. * IMPROVECACHELOCALITY
  101. * FIXINFACINGNORMALS
  102. * REMOVE_REDUNDANTMATERIALS
  103. * OPTIMIZEGRAPH
  104. * SORTBYPTYPE
  105. * FINDINVALIDDATA
  106. * TRANSFORMTEXCOORDS
  107. * GENUVCOORDS
  108. * ENTITYMESHBUILDER
  109. * EMBEDTEXTURES
  110. * MAKELEFTHANDED
  111. * FLIPUVS
  112. * FLIPWINDINGORDER
  113. * OPTIMIZEMESHES
  114. * OPTIMIZEANIMS
  115. * OPTIMIZEGRAPH
  116. * GENENTITYMESHES
  117. * FIXTEXTUREPATHS
  118. * GENBOUNDINGBOXES */
  119. //////////////////////////////////////////////////////////////////////////
  120. #ifdef _WIN32
  121. #undef ASSIMP_API
  122. //////////////////////////////////////////////////////////////////////////
  123. /* Define 'ASSIMP_BUILD_DLL_EXPORT' to build a DLL of the library */
  124. //////////////////////////////////////////////////////////////////////////
  125. #ifdef ASSIMP_BUILD_DLL_EXPORT
  126. #define ASSIMP_API __declspec(dllexport)
  127. #define ASSIMP_API_WINONLY __declspec(dllexport)
  128. //////////////////////////////////////////////////////////////////////////
  129. /* Define 'ASSIMP_DLL' before including Assimp to link to ASSIMP in
  130. * an external DLL under Windows. Default is static linkage. */
  131. //////////////////////////////////////////////////////////////////////////
  132. #elif (defined ASSIMP_DLL)
  133. #define ASSIMP_API __declspec(dllimport)
  134. #define ASSIMP_API_WINONLY __declspec(dllimport)
  135. #else
  136. #define ASSIMP_API
  137. #define ASSIMP_API_WINONLY
  138. #endif
  139. #elif defined(SWIG)
  140. /* Do nothing, the relevant defines are all in AssimpSwigPort.i */
  141. #else
  142. #define ASSIMP_API __attribute__((visibility("default")))
  143. #define ASSIMP_API_WINONLY
  144. #endif // _WIN32
  145. #ifdef _MSC_VER
  146. #pragma warning(disable : 4521 4512 4714 4127 4351 4510)
  147. #ifdef ASSIMP_BUILD_DLL_EXPORT
  148. #pragma warning(disable : 4251)
  149. #endif
  150. /* Force the compiler to inline a function, if possible */
  151. #define AI_FORCE_INLINE inline
  152. /* Tells the compiler that a function never returns. Used in code analysis
  153. * to skip dead paths (e.g. after an assertion evaluated to false). */
  154. #define AI_WONT_RETURN __declspec(noreturn)
  155. #elif defined(SWIG)
  156. /* Do nothing, the relevant defines are all in AssimpSwigPort.i */
  157. #else
  158. #define AI_WONT_RETURN
  159. #define AI_FORCE_INLINE inline
  160. #endif // (defined _MSC_VER)
  161. #ifdef __GNUC__
  162. # define AI_WONT_RETURN_SUFFIX __attribute__((noreturn))
  163. #elif _MSC_VER
  164. #if defined(__clang__)
  165. # define AI_WONT_RETURN_SUFFIX __attribute__((noreturn))
  166. #else
  167. # define AI_WONT_RETURN_SUFFIX
  168. #endif
  169. #else
  170. # define AI_WONT_RETURN_SUFFIX
  171. #endif // (defined __clang__)
  172. #ifdef __cplusplus
  173. /* No explicit 'struct' and 'enum' tags for C++, this keeps showing up
  174. * in doxydocs.
  175. */
  176. #define C_STRUCT
  177. #define C_ENUM
  178. #else
  179. //////////////////////////////////////////////////////////////////////////
  180. /* To build the documentation, make sure ASSIMP_DOXYGEN_BUILD
  181. * is defined by Doxygen's preprocessor. The corresponding
  182. * entries in the DOXYFILE are: */
  183. //////////////////////////////////////////////////////////////////////////
  184. #if 0
  185. ENABLE_PREPROCESSING = YES
  186. MACRO_EXPANSION = YES
  187. EXPAND_ONLY_PREDEF = YES
  188. SEARCH_INCLUDES = YES
  189. INCLUDE_PATH =
  190. INCLUDE_FILE_PATTERNS =
  191. PREDEFINED = ASSIMP_DOXYGEN_BUILD=1
  192. EXPAND_AS_DEFINED = C_STRUCT C_ENUM
  193. SKIP_FUNCTION_MACROS = YES
  194. #endif
  195. //////////////////////////////////////////////////////////////////////////
  196. /* Doxygen gets confused if we use c-struct typedefs to avoid
  197. * the explicit 'struct' notation. This trick here has the same
  198. * effect as the TYPEDEF_HIDES_STRUCT option, but we don't need
  199. * to typedef all structs/enums. */
  200. //////////////////////////////////////////////////////////////////////////
  201. #if (defined ASSIMP_DOXYGEN_BUILD)
  202. #define C_STRUCT
  203. #define C_ENUM
  204. #else
  205. #define C_STRUCT struct
  206. #define C_ENUM enum
  207. #endif
  208. #endif
  209. #if (defined(__BORLANDC__) || defined(__BCPLUSPLUS__))
  210. #error Currently, Borland is unsupported. Feel free to port Assimp.
  211. #endif
  212. //////////////////////////////////////////////////////////////////////////
  213. /* Define ASSIMP_BUILD_SINGLETHREADED to compile assimp
  214. * without threading support. The library doesn't utilize
  215. * threads then and is itself not threadsafe. */
  216. //////////////////////////////////////////////////////////////////////////
  217. #ifndef ASSIMP_BUILD_SINGLETHREADED
  218. #define ASSIMP_BUILD_SINGLETHREADED
  219. #endif
  220. #if defined(_DEBUG) || !defined(NDEBUG)
  221. #define ASSIMP_BUILD_DEBUG
  222. #endif
  223. //////////////////////////////////////////////////////////////////////////
  224. /* Define ASSIMP_DOUBLE_PRECISION to compile assimp
  225. * with double precision support (64-bit). */
  226. //////////////////////////////////////////////////////////////////////////
  227. #ifdef ASSIMP_DOUBLE_PRECISION
  228. typedef double ai_real;
  229. typedef signed long long int ai_int;
  230. typedef unsigned long long int ai_uint;
  231. #ifndef ASSIMP_AI_REAL_TEXT_PRECISION
  232. #define ASSIMP_AI_REAL_TEXT_PRECISION 17
  233. #endif // ASSIMP_AI_REAL_TEXT_PRECISION
  234. #else // ASSIMP_DOUBLE_PRECISION
  235. typedef float ai_real;
  236. typedef signed int ai_int;
  237. typedef unsigned int ai_uint;
  238. #ifndef ASSIMP_AI_REAL_TEXT_PRECISION
  239. #define ASSIMP_AI_REAL_TEXT_PRECISION 9
  240. #endif // ASSIMP_AI_REAL_TEXT_PRECISION
  241. #endif // ASSIMP_DOUBLE_PRECISION
  242. //////////////////////////////////////////////////////////////////////////
  243. /* Useful constants */
  244. //////////////////////////////////////////////////////////////////////////
  245. /* This is PI. Hi PI. */
  246. #define AI_MATH_PI (3.141592653589793238462643383279)
  247. #define AI_MATH_TWO_PI (AI_MATH_PI * 2.0)
  248. #define AI_MATH_HALF_PI (AI_MATH_PI * 0.5)
  249. /* And this is to avoid endless casts to float */
  250. #define AI_MATH_PI_F (3.1415926538f)
  251. #define AI_MATH_TWO_PI_F (AI_MATH_PI_F * 2.0f)
  252. #define AI_MATH_HALF_PI_F (AI_MATH_PI_F * 0.5f)
  253. /* Tiny macro to convert from radians to degrees and back */
  254. #define AI_DEG_TO_RAD(x) ((x) * (ai_real) 0.0174532925)
  255. #define AI_RAD_TO_DEG(x) ((x) * (ai_real) 57.2957795)
  256. /* Numerical limits */
  257. #ifdef __cplusplus
  258. constexpr ai_real ai_epsilon = (ai_real) 1e-6;
  259. #else
  260. #define ai_epsilon ((ai_real)1e-6)
  261. #endif
  262. /* Support for big-endian builds */
  263. #if defined(__BYTE_ORDER__)
  264. #if (__BYTE_ORDER__ == __ORDER_BIG_ENDIAN__)
  265. #if !defined(__BIG_ENDIAN__)
  266. #define __BIG_ENDIAN__
  267. #endif
  268. #else /* little endian */
  269. #if defined(__BIG_ENDIAN__)
  270. #undef __BIG_ENDIAN__
  271. #endif
  272. #endif
  273. #endif
  274. #if defined(__BIG_ENDIAN__)
  275. #define AI_BUILD_BIG_ENDIAN
  276. #endif
  277. /**
  278. * To avoid running out of memory
  279. * This can be adjusted for specific use cases
  280. * It's NOT a total limit, just a limit for individual allocations
  281. */
  282. #define AI_MAX_ALLOC(type) ((256U * 1024 * 1024) / sizeof(type))
  283. #ifndef _MSC_VER
  284. #if __cplusplus >= 201103L // C++11
  285. #define AI_NO_EXCEPT noexcept
  286. #else
  287. #define AI_NO_EXCEPT
  288. #endif
  289. #else
  290. #if (_MSC_VER >= 1915)
  291. #define AI_NO_EXCEPT noexcept
  292. #else
  293. #define AI_NO_EXCEPT
  294. #endif
  295. #endif // _MSC_VER
  296. /**
  297. * Helper macro to set a pointer to NULL in debug builds
  298. */
  299. #if (defined ASSIMP_BUILD_DEBUG)
  300. #define AI_DEBUG_INVALIDATE_PTR(x) x = NULL;
  301. #else
  302. #define AI_DEBUG_INVALIDATE_PTR(x)
  303. #endif
  304. #define AI_COUNT_OF(X) (sizeof(X) / sizeof((X)[0]))
  305. #endif // !! AI_DEFINES_H_INC