defs.h 11 KB

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