b2_settings.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. // MIT License
  2. // Copyright (c) 2019 Erin Catto
  3. // Permission is hereby granted, free of charge, to any person obtaining a copy
  4. // of this software and associated documentation files (the "Software"), to deal
  5. // in the Software without restriction, including without limitation the rights
  6. // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  7. // copies of the Software, and to permit persons to whom the Software is
  8. // furnished to do so, subject to the following conditions:
  9. // The above copyright notice and this permission notice shall be included in all
  10. // copies or substantial portions of the Software.
  11. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  12. // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  13. // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  14. // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  15. // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  16. // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  17. // SOFTWARE.
  18. #ifndef B2_SETTINGS_H
  19. #define B2_SETTINGS_H
  20. #include "b2_types.h"
  21. #include "b2_api.h"
  22. /// @file
  23. /// Settings that can be overriden for your application
  24. ///
  25. /// Define this macro in your build if you want to override settings
  26. #ifdef B2_USER_SETTINGS
  27. /// This is a user file that includes custom definitions of the macros, structs, and functions
  28. /// defined below.
  29. #include "b2_user_settings.h"
  30. #else
  31. #include <stdarg.h>
  32. #include <stdint.h>
  33. // Tunable Constants
  34. /// You can use this to change the length scale used by your game.
  35. /// For example for inches you could use 39.4.
  36. #define b2_lengthUnitsPerMeter 1.0f
  37. /// The maximum number of vertices on a convex polygon. You cannot increase
  38. /// this too much because b2BlockAllocator has a maximum object size.
  39. #define b2_maxPolygonVertices 8
  40. // User data
  41. /// You can define this to inject whatever data you want in b2Body
  42. struct B2_API b2BodyUserData
  43. {
  44. b2BodyUserData()
  45. {
  46. pointer = 0;
  47. }
  48. /// For legacy compatibility
  49. uintptr_t pointer;
  50. };
  51. /// You can define this to inject whatever data you want in b2Fixture
  52. struct B2_API b2FixtureUserData
  53. {
  54. b2FixtureUserData()
  55. {
  56. pointer = 0;
  57. }
  58. /// For legacy compatibility
  59. uintptr_t pointer;
  60. };
  61. /// You can define this to inject whatever data you want in b2Joint
  62. struct B2_API b2JointUserData
  63. {
  64. b2JointUserData()
  65. {
  66. pointer = 0;
  67. }
  68. /// For legacy compatibility
  69. uintptr_t pointer;
  70. };
  71. // Memory Allocation
  72. /// Default allocation functions
  73. B2_API void* b2Alloc_Default(int32 size);
  74. B2_API void b2Free_Default(void* mem);
  75. /// Implement this function to use your own memory allocator.
  76. inline void* b2Alloc(int32 size)
  77. {
  78. return b2Alloc_Default(size);
  79. }
  80. /// If you implement b2Alloc, you should also implement this function.
  81. inline void b2Free(void* mem)
  82. {
  83. b2Free_Default(mem);
  84. }
  85. /// Default logging function
  86. B2_API void b2Log_Default(const char* string, va_list args);
  87. /// Implement this to use your own logging.
  88. inline void b2Log(const char* string, ...)
  89. {
  90. va_list args;
  91. va_start(args, string);
  92. b2Log_Default(string, args);
  93. va_end(args);
  94. }
  95. #endif // B2_USER_SETTINGS
  96. #include "b2_common.h"
  97. #endif