jolt-ruby 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (76) hide show
  1. checksums.yaml +7 -0
  2. data/.gitmodules +3 -0
  3. data/LICENSE.txt +21 -0
  4. data/README.md +228 -0
  5. data/Rakefile +180 -0
  6. data/examples/character_virtual.rb +35 -0
  7. data/examples/falling_sphere.rb +25 -0
  8. data/examples/stagecraft_binding.rb +29 -0
  9. data/ext/jolt_ruby/CMakeLists.txt +42 -0
  10. data/ext/jolt_ruby/character_helper.cpp +44 -0
  11. data/ext/jolt_ruby/constraint_helper.cpp +154 -0
  12. data/ext/jolt_ruby/extconf.rb +56 -0
  13. data/ext/jolt_ruby/helper.cpp +225 -0
  14. data/ext/jolt_ruby/helper.h +103 -0
  15. data/ext/joltc/.github/FUNDING.yml +1 -0
  16. data/ext/joltc/.github/workflows/build.yml +298 -0
  17. data/ext/joltc/.gitignore +272 -0
  18. data/ext/joltc/CMakeLists.txt +431 -0
  19. data/ext/joltc/LICENSE +21 -0
  20. data/ext/joltc/README.md +10 -0
  21. data/ext/joltc/build/cmake_vs2026_arm64.bat +3 -0
  22. data/ext/joltc/build/cmake_vs2026_clang.bat +10 -0
  23. data/ext/joltc/build/cmake_vs2026_x64.bat +3 -0
  24. data/ext/joltc/build/cmake_vs2026_x64_double.bat +3 -0
  25. data/ext/joltc/include/joltc.h +3166 -0
  26. data/ext/joltc/samples/01_HelloWorld/main.cpp +170 -0
  27. data/ext/joltc/samples/CMakeLists.txt +35 -0
  28. data/ext/joltc/src/joltc.c +4 -0
  29. data/ext/joltc/src/joltc.cpp +11812 -0
  30. data/ext/joltc/src/joltc_assert.cpp +271 -0
  31. data/ext/joltc/tests/CMakeLists.txt +77 -0
  32. data/ext/joltc/tests/test_character.cpp +149 -0
  33. data/ext/joltc/tests/test_collision.cpp +146 -0
  34. data/ext/joltc/tests/test_constraints.cpp +353 -0
  35. data/ext/joltc/tests/test_core.cpp +94 -0
  36. data/ext/joltc/tests/test_math.cpp +585 -0
  37. data/ext/joltc/tests/test_physics_system.cpp +465 -0
  38. data/ext/joltc/tests/test_shapes.cpp +789 -0
  39. data/ext/joltc/tests/test_skeleton.cpp +370 -0
  40. data/ext/joltc/tests/test_vehicle.cpp +319 -0
  41. data/generator/generate.rb +237 -0
  42. data/generator/layout_probe.cpp +489 -0
  43. data/generator/verify_layout.rb +32 -0
  44. data/lib/jolt/body.rb +147 -0
  45. data/lib/jolt/body_collection.rb +115 -0
  46. data/lib/jolt/body_dynamics.rb +93 -0
  47. data/lib/jolt/character_virtual.rb +162 -0
  48. data/lib/jolt/constraint.rb +136 -0
  49. data/lib/jolt/constraint_collection.rb +123 -0
  50. data/lib/jolt/contact_events.rb +19 -0
  51. data/lib/jolt/conversions.rb +76 -0
  52. data/lib/jolt/errors.rb +12 -0
  53. data/lib/jolt/fixed_stepper.rb +37 -0
  54. data/lib/jolt/hit.rb +5 -0
  55. data/lib/jolt/layers.rb +182 -0
  56. data/lib/jolt/native/character_functions.rb +16 -0
  57. data/lib/jolt/native/constraint_functions.rb +27 -0
  58. data/lib/jolt/native/core_functions.rb +17 -0
  59. data/lib/jolt/native/generated.rb +1995 -0
  60. data/lib/jolt/native/platform.rb +51 -0
  61. data/lib/jolt/native/query_functions.rb +43 -0
  62. data/lib/jolt/native/types.rb +28 -0
  63. data/lib/jolt/native.rb +94 -0
  64. data/lib/jolt/shape.rb +90 -0
  65. data/lib/jolt/shape_builders.rb +155 -0
  66. data/lib/jolt/system.rb +238 -0
  67. data/lib/jolt/system_characters.rb +25 -0
  68. data/lib/jolt/system_constraints.rb +36 -0
  69. data/lib/jolt/system_contacts.rb +57 -0
  70. data/lib/jolt/system_queries.rb +111 -0
  71. data/lib/jolt/transform.rb +5 -0
  72. data/lib/jolt/version.rb +5 -0
  73. data/lib/jolt.rb +83 -0
  74. data/script/smoke_gem.rb +29 -0
  75. data/script/verify_release.rb +36 -0
  76. metadata +147 -0
@@ -0,0 +1,431 @@
1
+ cmake_minimum_required(VERSION 3.16 FATAL_ERROR)
2
+
3
+ project(joltc CXX C)
4
+
5
+ # Use solution folders to organize projects
6
+ set_property(GLOBAL PROPERTY USE_FOLDERS ON)
7
+
8
+ # Requires C++ 17
9
+ set(CMAKE_CXX_STANDARD 17)
10
+ set(CMAKE_CXX_STANDARD_REQUIRED ON)
11
+ set(CMAKE_CXX_EXTENSIONS OFF)
12
+ set(CMAKE_INSTALL_MESSAGE LAZY)
13
+ set(CMAKE_POSITION_INDEPENDENT_CODE ON)
14
+ set(CMAKE_DEBUG_POSTFIX "d")
15
+
16
+ set(CMAKE_OSX_DEPLOYMENT_TARGET "11" CACHE STRING "Minimum OS X deployment version")
17
+ set(CMAKE_OSX_ARCHITECTURES "x86_64;arm64" CACHE STRING "Build architectures for OS X")
18
+
19
+ # Set default symbol visibility to hidden. This prevents all Jolt's symbols to be exported on macOS. This can cause crashes if a program loads multiple shared libraries with different versions of Jolt.
20
+ set(CMAKE_CXX_VISIBILITY_PRESET hidden)
21
+
22
+ # Determine if engine is built as a subproject (using add_subdirectory)
23
+ # or if it is the master project.
24
+ if (NOT DEFINED JPH_MASTER_PROJECT)
25
+ set(JPH_MASTER_PROJECT OFF)
26
+ if (CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR)
27
+ set(JPH_MASTER_PROJECT ON)
28
+ message(STATUS "CMake version: ${CMAKE_VERSION}")
29
+ endif ()
30
+ endif ()
31
+
32
+ if (JPH_MASTER_PROJECT)
33
+ # Configure CMake global variables
34
+ set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
35
+ set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
36
+ set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
37
+ endif()
38
+
39
+ if (MSVC AND JPH_MASTER_PROJECT)
40
+ if (NOT DEFINED CMAKE_MSVC_RUNTIME_LIBRARY)
41
+ set (CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
42
+ endif ()
43
+ endif ()
44
+
45
+ include(GNUInstallDirs)
46
+ include(FetchContent)
47
+
48
+ # When turning this option on, the library will be compiled using assertions. By default asserts are enabled in Debug build.
49
+ option(USE_ASSERTS "Enable asserts" OFF)
50
+
51
+ # When turning this option on, the library will be compiled using doubles for positions. This allows for much bigger worlds.
52
+ option(DOUBLE_PRECISION "Use double precision math" OFF)
53
+
54
+ # When turning this option on, the library will be compiled with debug symbols
55
+ option(GENERATE_DEBUG_SYMBOLS "Generate debug symbols" OFF)
56
+
57
+ # When turning this option on, the library will override the default CMAKE_CXX_FLAGS_DEBUG/RELEASE values, otherwise they will use the platform defaults
58
+ option(OVERRIDE_CXX_FLAGS "Override CMAKE_CXX_FLAGS_DEBUG/RELEASE" ON)
59
+
60
+ # When turning this option on, the library will be compiled in such a way to attempt to keep the simulation deterministic across platforms
61
+ option(CROSS_PLATFORM_DETERMINISTIC "Cross platform deterministic" OFF)
62
+
63
+ # When turning this option on, the library will be compiled for ARM (aarch64-linux-gnu), requires compiling with clang
64
+ option(CROSS_COMPILE_ARM "Cross compile to aarch64-linux-gnu" OFF)
65
+
66
+ # When turning this on, in Debug and Release mode, the library will emit extra code to ensure that the 4th component of a 3-vector is kept the same as the 3rd component
67
+ # and will enable floating point exceptions during simulation to detect divisions by zero.
68
+ # Note that this currently only works using MSVC. Clang turns Float2 into a SIMD vector sometimes causing floating point exceptions (the option is ignored).
69
+ option(FLOATING_POINT_EXCEPTIONS_ENABLED "Enable floating point exceptions" ON)
70
+
71
+ # When turning this on, the library will be compiled with C++ exceptions enabled.
72
+ # This adds some overhead and Jolt doesn't use exceptions so by default it is off.
73
+ option(CPP_EXCEPTIONS_ENABLED "Enable C++ exceptions" OFF)
74
+
75
+ # When turning this on, the library will be compiled with C++ RTTI enabled.
76
+ # This adds some overhead and Jolt doesn't use RTTI so by default it is off.
77
+ option(CPP_RTTI_ENABLED "Enable C++ RTTI" OFF)
78
+
79
+ # Use 32-bit object layers to support more bits in ObjectLayerPairFilterMask
80
+ set(OBJECT_LAYER_BITS 32)
81
+
82
+ # Select X86 processor features to use (if everything is off it will be SSE2 compatible)
83
+ option(USE_SSE4_1 "Enable SSE4.1" ON)
84
+ option(USE_SSE4_2 "Enable SSE4.2" ON)
85
+ option(USE_AVX "Enable AVX" ON)
86
+ option(USE_AVX2 "Enable AVX2" ON)
87
+ option(USE_AVX512 "Enable AVX512" OFF)
88
+ option(USE_LZCNT "Enable LZCNT" ON)
89
+ option(USE_TZCNT "Enable TZCNT" ON)
90
+ option(USE_F16C "Enable F16C" ON)
91
+ option(USE_FMADD "Enable FMADD" ON)
92
+
93
+ # Enable SIMD for the WASM build. Note that this is currently off by default since not all browsers support this.
94
+ # See: https://caniuse.com/?search=WebAssembly%20SIMD (Safari got support in March 2023 and was the last major browser to get support).
95
+ option(USE_WASM_SIMD "Enable SIMD for WASM" OFF)
96
+
97
+ # Enable all warnings
98
+ option(ENABLE_ALL_WARNINGS "Enable all warnings and warnings as errors" OFF)
99
+
100
+ # Setting to periodically trace broadphase stats to help determine if the broadphase layer configuration is optimal
101
+ option(TRACK_BROADPHASE_STATS "Track Broadphase Stats" OFF)
102
+
103
+ # Setting to periodically trace narrowphase stats to help determine which collision queries could be optimized
104
+ option(TRACK_NARROWPHASE_STATS "Track Narrowphase Stats" OFF)
105
+
106
+ # Enable the debug renderer in the Debug and Release builds. Note that DEBUG_RENDERER_IN_DISTRIBUTION will override this setting.
107
+ option(DEBUG_RENDERER_IN_DEBUG_AND_RELEASE "Enable debug renderer in Debug and Release builds" ON)
108
+
109
+ # Setting to enable the debug renderer in all builds.
110
+ # Note that enabling this reduces the performance of the library even if you're not drawing anything.
111
+ option(DEBUG_RENDERER_IN_DISTRIBUTION "Enable debug renderer in all builds" ON)
112
+
113
+ # Enable the profiler in Debug and Release builds. Note that PROFILER_IN_DISTRIBUTION will override this setting.
114
+ option(PROFILER_IN_DEBUG_AND_RELEASE "Enable the profiler in Debug and Release builds" ON)
115
+
116
+ # Enable the profiler in all builds.
117
+ # Note that enabling this reduces the performance of the library.
118
+ option(PROFILER_IN_DISTRIBUTION "Enable the profiler in all builds" OFF)
119
+
120
+ # Setting this option will force the library to use malloc/free instead of allowing the user to override the memory allocator
121
+ option(DISABLE_CUSTOM_ALLOCATOR "Disable support for a custom memory allocator" OFF)
122
+
123
+ # Setting this option will force the library to use the STL vector instead of the custom Array class
124
+ option(USE_STD_VECTOR "Use std::vector instead of own Array class" OFF)
125
+
126
+ # Setting this option will compile the ObjectStream class and RTTI attribute information
127
+ option(ENABLE_OBJECT_STREAM "Compile the ObjectStream class and RTTI attribute information" ON)
128
+
129
+ # Option to compile with DirectX 12 compute
130
+ option(JPH_USE_DX12 "Use DirectX" ON)
131
+
132
+ # Option to compile with Vulkan compute
133
+ option(JPH_USE_VK "Use Vulkan" ON)
134
+
135
+ # Option to compile with Metal compute
136
+ option(JPH_USE_MTL "Use Metal" ON)
137
+
138
+ # Option to compile with CPU fallback compute
139
+ option(JPH_USE_CPU_COMPUTE "Use CPU Compute" ON)
140
+
141
+ # Option to enable shader debug symbols
142
+ option(JPH_SHADER_DEBUG_SYMBOLS "Shader Debug Symbols" OFF)
143
+
144
+ # Option to enable shader optimizations. When this is on, the shaders will be optimized for performance, otherwise they're suitable for debugging.
145
+ option(JPH_SHADER_OPTIMIZATION "Shader Optimization" ON)
146
+
147
+ option(JPH_INSTALL "Install target" ${JPH_MASTER_PROJECT})
148
+ option(JPH_SAMPLES "Build samples" ${JPH_MASTER_PROJECT})
149
+
150
+ # Define standard configurations (Debug, Release, Distribution)
151
+ set(CMAKE_CONFIGURATION_TYPES "Debug;Release;Distribution")
152
+
153
+ # Set the default CMAKE_BUILD_TYPE to Release.
154
+ # This should be done before the project command since the latter can set
155
+ # CMAKE_BUILD_TYPE itself (it does so for nmake).
156
+ if (JPH_MASTER_PROJECT AND NOT CMAKE_BUILD_TYPE)
157
+ set(CMAKE_BUILD_TYPE "Distribution" CACHE STRING "The default build type" FORCE)
158
+ set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS ${CMAKE_CONFIGURATION_TYPES})
159
+ endif ()
160
+
161
+ # Search for local JoltPhysics first
162
+ if (DEFINED JOLT_PHYSICS_ROOT AND EXISTS "${JOLT_PHYSICS_ROOT}/Build/CMakeLists.txt")
163
+ message(STATUS "[JoltC] Using provided JOLT_PHYSICS_ROOT: ${JOLT_PHYSICS_ROOT}")
164
+ FetchContent_Declare(
165
+ JoltPhysics
166
+ SOURCE_DIR "${JOLT_PHYSICS_ROOT}"
167
+ SOURCE_SUBDIR "Build"
168
+ )
169
+ # 2. Check for JoltPhysics nested inside JoltC
170
+ elseif(EXISTS "${CMAKE_CURRENT_LIST_DIR}/JoltPhysics/Build/CMakeLists.txt")
171
+ message(STATUS "[JoltC] Using local JoltPhysics from nested directory")
172
+ FetchContent_Declare(
173
+ JoltPhysics
174
+ SOURCE_DIR "${CMAKE_CURRENT_LIST_DIR}/JoltPhysics"
175
+ SOURCE_SUBDIR "Build"
176
+ )
177
+ # 3. Check for JoltPhysics side-by-side with JoltC
178
+ elseif(EXISTS "${CMAKE_CURRENT_LIST_DIR}/../JoltPhysics/Build/CMakeLists.txt")
179
+ message(STATUS "[JoltC] Using local JoltPhysics from side-by-side directory")
180
+ FetchContent_Declare(
181
+ JoltPhysics
182
+ SOURCE_DIR "${CMAKE_CURRENT_LIST_DIR}/../JoltPhysics"
183
+ SOURCE_SUBDIR "Build"
184
+ )
185
+ # 4. Fallback to GitHub
186
+ else()
187
+ message(STATUS "[JoltC] Local Jolt not found, downloading from GitHub v5.6.0")
188
+ FetchContent_Declare(
189
+ JoltPhysics
190
+ GIT_REPOSITORY "https://github.com/jrouwe/JoltPhysics"
191
+ GIT_TAG v5.6.0
192
+ SOURCE_SUBDIR "Build"
193
+ )
194
+ endif()
195
+
196
+ FetchContent_MakeAvailable(JoltPhysics)
197
+
198
+ if (XCODE)
199
+ # Ensure that we enable SSE4.2 for the x86_64 build, XCode builds multiple architectures
200
+ set_property(TARGET Jolt PROPERTY XCODE_ATTRIBUTE_OTHER_CPLUSPLUSFLAGS[arch=x86_64] "$(inherited) -msse4.2 -mpopcnt")
201
+ endif()
202
+
203
+ if (MSVC)
204
+ # Fill in the path to the asan libraries
205
+ set(CLANG_LIB_PATH "\"$(VSInstallDir)\\VC\\Tools\\Llvm\\x64\\lib\\clang\\${CMAKE_CXX_COMPILER_VERSION}\\lib\\windows\"")
206
+
207
+ # 64 bit architecture
208
+ set(CMAKE_VS_PLATFORM_TOOLSET_HOST_ARCHITECTURE "x64")
209
+
210
+ # Set general compiler flags
211
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /Zc:__cplusplus /Gm- /MP /nologo /diagnostics:classic /FC /fp:except- /Zc:inline")
212
+
213
+ # Enable warnings
214
+ if (ENABLE_ALL_WARNINGS)
215
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /Wall /WX")
216
+ endif()
217
+
218
+ # Set compiler flag for disabling RTTI
219
+ if (NOT CPP_RTTI_ENABLED)
220
+ # Set compiler flag for disabling RTTI
221
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /GR-")
222
+ else()
223
+ # Set compiler flag for enabling RTTI
224
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /GR")
225
+ endif()
226
+
227
+ if (NOT CPP_EXCEPTIONS_ENABLED)
228
+ # Remove any existing compiler flag that enables exceptions
229
+ string(REPLACE "/EHsc" "" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS})
230
+
231
+ # Disable warning about STL and compiler-generated types using noexcept when exceptions are disabled
232
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4577")
233
+ else()
234
+ # Enable exceptions
235
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /EHsc")
236
+ endif()
237
+
238
+ set(CMAKE_CXX_FLAGS_DISTRIBUTION "${CMAKE_CXX_FLAGS_RELEASE}")
239
+
240
+ # Set linker flags
241
+ set(CMAKE_EXE_LINKER_FLAGS "/SUBSYSTEM:WINDOWS /ignore:4221")
242
+ if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
243
+ if (CROSS_PLATFORM_DETERMINISTIC)
244
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /fp:precise")
245
+ else()
246
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /fp:fast") # Clang doesn't use fast math because it cannot be turned off inside a single compilation unit
247
+ endif()
248
+ elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
249
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /showFilenames")
250
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Qunused-arguments") # Clang emits warnings about unused arguments such as /MP and /GL
251
+ endif()
252
+ else()
253
+ # Enable warnings
254
+ if (ENABLE_ALL_WARNINGS)
255
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Werror")
256
+ endif()
257
+
258
+ # Set compiler flag for disabling RTTI
259
+ if (NOT CPP_RTTI_ENABLED)
260
+ # Set compiler flag for disabling RTTI
261
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-rtti")
262
+ else()
263
+ # Set compiler flag for enabling RTTI
264
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -frtti")
265
+ endif()
266
+
267
+ # Disable exception-handling
268
+ if (NOT CPP_EXCEPTIONS_ENABLED)
269
+ # Set compiler flag for disabling exception-handling
270
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-exceptions")
271
+ else()
272
+ # Set compiler flag for enabling exception-handling
273
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fexceptions")
274
+ endif()
275
+
276
+ if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
277
+ # Also disable -Wstringop-overflow or it will generate false positives that can't be disabled from code when link-time optimizations are enabled
278
+ # Also turn off automatic fused multiply add contractions, there doesn't seem to be a way to do this selectively through the macro JPH_PRECISE_MATH_OFF
279
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-stringop-overflow -ffp-contract=off")
280
+ else()
281
+ # Do not use -ffast-math since it cannot be turned off in a single compilation unit under clang, see Core.h
282
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -ffp-model=precise")
283
+
284
+ # On clang 14 and later we can turn off float contraction through a pragma, older versions and deterministic versions need it off always, see Core.h
285
+ if (CMAKE_CXX_COMPILER_VERSION LESS 14 OR CROSS_PLATFORM_DETERMINISTIC)
286
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -ffp-contract=off")
287
+ endif()
288
+
289
+ # Cross compiler flags
290
+ if (CROSS_COMPILE_ARM)
291
+ set(CMAKE_CXX_FLAGS "--target=aarch64-linux-gnu ${CMAKE_CXX_FLAGS}")
292
+ endif()
293
+ endif()
294
+
295
+ # See https://github.com/jrouwe/JoltPhysics/issues/922. When compiling with DOUBLE_PRECISION=YES and CMAKE_OSX_DEPLOYMENT_TARGET=10.12 clang triggers a warning that we silence here.
296
+ if ("${CMAKE_SYSTEM_NAME}" MATCHES "Darwin" AND "${CMAKE_CXX_COMPILER_ID}" STREQUAL "AppleClang")
297
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -faligned-allocation")
298
+ endif()
299
+
300
+ # Set compiler flags for various configurations
301
+ if (OVERRIDE_CXX_FLAGS)
302
+ set(CMAKE_CXX_FLAGS_DEBUG "")
303
+ set(CMAKE_CXX_FLAGS_RELEASE "-O3")
304
+ endif()
305
+ set(CMAKE_CXX_FLAGS_DISTRIBUTION "${CMAKE_CXX_FLAGS_RELEASE}")
306
+
307
+ # Set linker flags
308
+ if (NOT ("${CMAKE_SYSTEM_NAME}" STREQUAL "Windows"))
309
+ set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -pthread")
310
+ endif()
311
+ endif()
312
+
313
+ # Set linker flags
314
+ set(CMAKE_EXE_LINKER_FLAGS_DISTRIBUTION "${CMAKE_EXE_LINKER_FLAGS_RELEASE}")
315
+ set(CMAKE_SHARED_LINKER_FLAGS_DISTRIBUTION "${CMAKE_SHARED_LINKER_FLAGS_RELEASE}")
316
+
317
+ SET_INTERPROCEDURAL_OPTIMIZATION()
318
+
319
+ set(PHYSICS_REPO_ROOT ${CMAKE_CURRENT_SOURCE_DIR}/src/joltc)
320
+ set(BUILD_SHARED_LIBS OFF CACHE BOOL "Disable shared library when building Jolt" FORCE)
321
+
322
+ # Options
323
+ if (IOS OR EMSCRIPTEN)
324
+ set(JPH_BUILD_SHARED OFF CACHE BOOL "Always Disable shared library on (IOS, WEB)" FORCE)
325
+ else()
326
+ option(JPH_BUILD_SHARED "Build a shared library" ${JPH_MASTER_PROJECT})
327
+ endif()
328
+
329
+ # Setup joltc library
330
+ # Define target name
331
+ if (DOUBLE_PRECISION)
332
+ set (TARGET_NAME joltc_double)
333
+ else()
334
+ set (TARGET_NAME joltc)
335
+ endif ()
336
+
337
+ set(SOURCE_FILES
338
+ ${CMAKE_CURRENT_SOURCE_DIR}/include/joltc.h
339
+ ${CMAKE_CURRENT_SOURCE_DIR}/src/joltc.cpp
340
+ ${CMAKE_CURRENT_SOURCE_DIR}/src/joltc_assert.cpp
341
+ ${CMAKE_CURRENT_SOURCE_DIR}/src/joltc.c
342
+ )
343
+
344
+ if (JPH_BUILD_SHARED)
345
+ add_library(${TARGET_NAME} SHARED ${SOURCE_FILES})
346
+ else()
347
+ add_library(${TARGET_NAME} ${SOURCE_FILES})
348
+ endif()
349
+
350
+ if(JPH_BUILD_SHARED)
351
+ target_compile_definitions(${TARGET_NAME} PRIVATE JPH_SHARED_LIBRARY_BUILD=1)
352
+ endif ()
353
+
354
+ target_include_directories(${TARGET_NAME} PUBLIC
355
+ $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
356
+ ${JoltPhysics_SOURCE_DIR}/..
357
+ )
358
+ target_link_libraries(${TARGET_NAME} PRIVATE Jolt)
359
+
360
+ if (MSVC)
361
+ # Debug information
362
+ target_compile_options(${TARGET_NAME} PRIVATE $<$<CONFIG:Debug>:/Zi>)
363
+
364
+ # Enable full optimization in dev/release
365
+ target_compile_options(${TARGET_NAME} PRIVATE $<$<CONFIG:Debug>:/Od> $<$<NOT:$<CONFIG:Debug>>:/Ox>)
366
+
367
+ # Inline function expansion
368
+ target_compile_options(${TARGET_NAME} PRIVATE /Ob2)
369
+
370
+ # Enable intrinsic functions in dev/release
371
+ target_compile_options(${TARGET_NAME} PRIVATE $<$<NOT:$<CONFIG:Debug>>:/Oi>)
372
+
373
+ # Favor fast code
374
+ target_compile_options(${TARGET_NAME} PRIVATE /Ot)
375
+
376
+ # Enable fiber-safe optimizations in dev/release
377
+ target_compile_options(${TARGET_NAME} PRIVATE $<$<NOT:$<CONFIG:Debug>>:/GT>)
378
+
379
+ # Enable string pooling
380
+ target_compile_options(${TARGET_NAME} PRIVATE /GF)
381
+
382
+ # Use security checks only in debug
383
+ target_compile_options(${TARGET_NAME} PRIVATE $<$<CONFIG:DEBUG>:/sdl> $<$<NOT:$<CONFIG:DEBUG>>:/sdl->)
384
+ else()
385
+
386
+ endif ()
387
+
388
+ if (JPH_INSTALL)
389
+ install(
390
+ FILES ${CMAKE_CURRENT_SOURCE_DIR}/include/joltc.h
391
+ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/Jolt
392
+ )
393
+
394
+ install(TARGETS ${TARGET_NAME}
395
+ EXPORT ${TARGET_NAME}
396
+ ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
397
+ LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
398
+ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
399
+ )
400
+
401
+ if (MSVC)
402
+ install(FILES $<TARGET_PDB_FILE:${TARGET_NAME}> DESTINATION bin OPTIONAL)
403
+ endif ()
404
+ endif()
405
+
406
+ if (JPH_SAMPLES)
407
+ add_subdirectory(samples)
408
+ endif ()
409
+
410
+ # Tests
411
+ option(JPH_TESTS "Build tests" ${JPH_MASTER_PROJECT})
412
+ if (JPH_TESTS)
413
+ add_subdirectory(tests)
414
+ endif ()
415
+
416
+ if (JPH_BUILD_SHARED)
417
+ message(STATUS " Library SHARED")
418
+ else ()
419
+ message(STATUS " Library STATIC")
420
+ endif ()
421
+
422
+ message(STATUS " Samples ${JPH_SAMPLES}")
423
+
424
+ if (CMAKE_GENERATOR_PLATFORM)
425
+ message(STATUS "CMAKE_GENERATOR_PLATFORM: ${CMAKE_GENERATOR_PLATFORM}")
426
+ endif()
427
+
428
+ message(STATUS "CMAKE_SYSTEM_PROCESSOR: ${CMAKE_SYSTEM_PROCESSOR}")
429
+ if (CMAKE_OSX_ARCHITECTURES)
430
+ message(STATUS "CMAKE_OSX_ARCHITECTURES: ${CMAKE_OSX_ARCHITECTURES}")
431
+ endif ()
data/ext/joltc/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) Amer Koleci and Contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,10 @@
1
+ # joltc
2
+
3
+ [![License: MIT](https://img.shields.io/badge/License-MIT-green.svg)](https://github.com/amerkoleci/joltc/blob/main/LICENSE)
4
+ [![Build status](https://github.com/amerkoleci/joltc/workflows/Build/badge.svg)](https://github.com/amerkoleci/joltc/actions)
5
+
6
+ [JoltPhysics](https://github.com/jrouwe/JoltPhysics) C interface.
7
+
8
+ ## Sponsors
9
+ Please consider [SPONSOR](https://github.com/sponsors/amerkoleci) me to further help development and to allow faster issue triaging and new features to be implemented.
10
+ **_NOTE:_** **any feature request** would require a [sponsor](https://github.com/sponsors/amerkoleci) in order to allow faster implementation and allow this project to continue.
@@ -0,0 +1,3 @@
1
+ @echo off
2
+ cmake -B "vs2026_arm64" -S "./../" -G "Visual Studio 18 2026" -A ARM64 -DCMAKE_INSTALL_PREFIX:String="Sdk" %*
3
+ echo Open vs2026_arm64\JoltC.sln to build the project.
@@ -0,0 +1,10 @@
1
+ @echo off
2
+ cmake -B "vs2026_clang" -S "./../" -G "Visual Studio 18 2026" -A x64 -T ClangCL -DCMAKE_INSTALL_PREFIX:String="SDK" %*
3
+ echo:
4
+ echo !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
5
+ echo Make sure to install:
6
+ echo - C++ Clang Compiler for Windows 12.0.0+
7
+ echo - C++ Clang-cl for v143+ build tools (x64/x86)
8
+ echo Using the Visual Studio Installer
9
+ echo !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
10
+ echo Open vs2026_clang\Alimer.sln to build the project.
@@ -0,0 +1,3 @@
1
+ @echo off
2
+ cmake -S "./../" -B "vs2026_x64" -G "Visual Studio 18 2026" -A x64 -DCMAKE_INSTALL_PREFIX:String="SDK" -DCMAKE_BUILD_TYPE:String=Distribution %*
3
+ echo Open vs2026_x64\JoltC.sln to build the project.
@@ -0,0 +1,3 @@
1
+ @echo off
2
+ cmake -S "./../" -B "vs2026_x64_double" -G "Visual Studio 18 2026" -A x64 -DCMAKE_INSTALL_PREFIX:String="SDK" -DDOUBLE_PRECISION=ON %*
3
+ echo Open vs2026_x64_double\JoltC.sln to build the project.