bullet3 0.1.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 (54) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE.txt +21 -0
  3. data/README.md +194 -0
  4. data/data/cube.urdf +22 -0
  5. data/data/plane.urdf +19 -0
  6. data/ext/bullet3/CMakeLists.txt +224 -0
  7. data/ext/bullet3/bullet3.cpp +34 -0
  8. data/ext/bullet3/collision/rb_collision.cpp +428 -0
  9. data/ext/bullet3/collision/rb_collision.hpp +87 -0
  10. data/ext/bullet3/collision/shapes/rb_collision_shape.cpp +485 -0
  11. data/ext/bullet3/collision/shapes/rb_collision_shape.hpp +5 -0
  12. data/ext/bullet3/constraints/rb_constraints.cpp +1310 -0
  13. data/ext/bullet3/constraints/rb_constraints.hpp +226 -0
  14. data/ext/bullet3/dynamics/rb_dynamics.cpp +862 -0
  15. data/ext/bullet3/dynamics/rb_dynamics.hpp +180 -0
  16. data/ext/bullet3/extconf.rb +57 -0
  17. data/ext/bullet3/io/rb_io.cpp +108 -0
  18. data/ext/bullet3/io/rb_io.hpp +40 -0
  19. data/ext/bullet3/linear_math/rb_matrix3x3.cpp +93 -0
  20. data/ext/bullet3/linear_math/rb_matrix3x3.hpp +5 -0
  21. data/ext/bullet3/linear_math/rb_quaternion.cpp +134 -0
  22. data/ext/bullet3/linear_math/rb_quaternion.hpp +5 -0
  23. data/ext/bullet3/linear_math/rb_transform.cpp +157 -0
  24. data/ext/bullet3/linear_math/rb_transform.hpp +34 -0
  25. data/ext/bullet3/linear_math/rb_vector3.cpp +123 -0
  26. data/ext/bullet3/linear_math/rb_vector3.hpp +5 -0
  27. data/ext/bullet3/multi_body/rb_multi_body.cpp +1000 -0
  28. data/ext/bullet3/multi_body/rb_multi_body.hpp +190 -0
  29. data/ext/bullet3/soft_body/rb_soft_body.cpp +720 -0
  30. data/ext/bullet3/soft_body/rb_soft_body.hpp +122 -0
  31. data/ext/bullet3/util/rb_debug_draw.cpp +250 -0
  32. data/ext/bullet3/util/rb_debug_draw.hpp +47 -0
  33. data/ext/bullet3/util/ruby_cpp_compat.hpp +29 -0
  34. data/ext/bullet3/util/type_conversions.hpp +107 -0
  35. data/ext/bullet3/vehicle/rb_vehicle.cpp +467 -0
  36. data/ext/bullet3/vehicle/rb_vehicle.hpp +115 -0
  37. data/lib/bullet3/collision.rb +6 -0
  38. data/lib/bullet3/constraints.rb +6 -0
  39. data/lib/bullet3/data.rb +39 -0
  40. data/lib/bullet3/debug_draw.rb +73 -0
  41. data/lib/bullet3/dynamics.rb +4 -0
  42. data/lib/bullet3/io.rb +110 -0
  43. data/lib/bullet3/linear_math/matrix3x3.rb +69 -0
  44. data/lib/bullet3/linear_math/quaternion.rb +187 -0
  45. data/lib/bullet3/linear_math/transform.rb +48 -0
  46. data/lib/bullet3/linear_math/vector3.rb +199 -0
  47. data/lib/bullet3/linear_math.rb +6 -0
  48. data/lib/bullet3/multi_body.rb +6 -0
  49. data/lib/bullet3/simulation.rb +1170 -0
  50. data/lib/bullet3/soft_body.rb +6 -0
  51. data/lib/bullet3/vehicle.rb +4 -0
  52. data/lib/bullet3/version.rb +5 -0
  53. data/lib/bullet3.rb +49 -0
  54. metadata +124 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: af2691fadab6e9aa49453e54a0bc963c73df2b7c82293e67e0182a7e1a05f340
4
+ data.tar.gz: 45dc19eac3c36b5158899a11c660a55a530032105bd0068571316440d9989991
5
+ SHA512:
6
+ metadata.gz: 2ad7ad00f698746f663feeb81406b3527de59d4ed7fe1d4207323f7fd73ea76891e6feabab6e19c92abeef156dfc76e8ccbdb72196de6f5d3d07d33fa381937e
7
+ data.tar.gz: 6c4aabaf3d0be52b88780ba5e926bdd8fd126dde2703be573247d9bb2a1379fcd9870fc9dd244c6d6249b1ec1a66957634e0899da69c043ab8637b67e1b7abe1
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2026 Yudai Takada
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
13
+ all 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
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,194 @@
1
+ # bullet3
2
+
3
+ Ruby bindings for the Bullet Physics SDK.
4
+
5
+ This project exposes a two-layer API:
6
+
7
+ - low-level Bullet3 C++ bindings exposed under `Bullet3`
8
+ - Ruby-friendly helpers and simulation APIs built on top of those bindings
9
+
10
+ The current native extension covers LinearMath, collision shapes,
11
+ `CollisionObject`/`CollisionWorld`, rigid bodies, dynamics worlds, constraints,
12
+ ray/contact/closest-point queries, raycast vehicles, soft bodies, multibodies,
13
+ primitive URDF loading, bundled data paths, and the high-level
14
+ `Bullet3::Simulation` facade.
15
+
16
+ ## Installation
17
+
18
+ Add the gem from this repository:
19
+
20
+ ```bash
21
+ gem "bullet3", path: "path/to/bullet3"
22
+ ```
23
+
24
+ Then install dependencies:
25
+
26
+ ```bash
27
+ brew install bullet
28
+ bundle install
29
+ ```
30
+
31
+ On Linux, install the Bullet development package for your distribution before
32
+ running `bundle install`:
33
+
34
+ ```bash
35
+ sudo apt install libbullet-dev
36
+ sudo dnf install bullet-devel
37
+ ```
38
+
39
+ Compile the native extension before using the Bullet3-backed classes:
40
+
41
+ ```bash
42
+ bundle exec rake compile
43
+ ```
44
+
45
+ ## Usage
46
+
47
+ ```ruby
48
+ require "bullet3"
49
+
50
+ v = Bullet3::Vector3.new(1, 2, 3)
51
+ axis = Bullet3::Vector3.new(0, 0, 1)
52
+ rotation = Bullet3::Quaternion.from_axis_angle(axis, Math::PI / 2)
53
+ transform = Bullet3::Transform.new(rotation, Bullet3::Vector3.new(1, 0, 0))
54
+
55
+ p transform * v
56
+ ```
57
+
58
+ High-level direct simulation:
59
+
60
+ ```ruby
61
+ sim = Bullet3::Simulation.new
62
+ sim.set_gravity(0, -10, 0)
63
+
64
+ plane = sim.create_collision_shape(:static_plane, normal: [0, 1, 0], offset: 0)
65
+ sphere = sim.create_collision_shape(:sphere, radius: 1.0)
66
+
67
+ sim.create_rigid_body(mass: 0.0, collision_shape: plane)
68
+ body = sim.create_rigid_body(mass: 1.0, collision_shape: sphere, position: [0, 10, 0])
69
+
70
+ 120.times { sim.step_simulation(time_step: 1.0 / 60.0, fixed_time_step: 1.0 / 60.0) }
71
+ p sim.get_base_position_and_orientation(body)
72
+ puts sim.get_contact_points(body_a: body).inspect
73
+ ```
74
+
75
+ By default `require "bullet3"` loads the native extension when it has been
76
+ compiled. Set `BULLET3_SKIP_NATIVE=1` to force the pure Ruby fallback for
77
+ non-native classes.
78
+
79
+ Primitive URDF loading and data paths:
80
+
81
+ ```ruby
82
+ sim = Bullet3::Simulation.new
83
+ sim.set_gravity(0, 0, -10)
84
+
85
+ plane = sim.load_urdf("plane.urdf", use_fixed_base: true)
86
+ cube = sim.load_urdf("cube.urdf", base_position: [0, 0, 3])
87
+
88
+ 120.times { sim.step_simulation(time_step: 1.0 / 60.0) }
89
+ p sim.get_aabb(cube)
90
+ p sim.get_contact_points(body_a: plane, body_b: cube)
91
+ ```
92
+
93
+ Lower-level APIs are available for direct Bullet3 usage:
94
+
95
+ ```ruby
96
+ world = Bullet3::CollisionWorld.create
97
+ shape = Bullet3::Shapes::SphereShape.new(1.0)
98
+ object = Bullet3::CollisionObject.new(shape)
99
+ world.add_collision_object(object)
100
+
101
+ p world.ray_test([0, 5, 0], [0, -5, 0])
102
+ ```
103
+
104
+ Native `.bullet` serialization and import:
105
+
106
+ ```ruby
107
+ sim = Bullet3::Simulation.new
108
+ shape = sim.create_collision_shape(:sphere, radius: 1.0)
109
+ sim.create_rigid_body(mass: 0.0, collision_shape: shape)
110
+
111
+ sim.save_bullet("world.bullet")
112
+
113
+ loaded = Bullet3::Simulation.new
114
+ importer = loaded.load_bullet("world.bullet")
115
+ p importer.num_rigid_bodies
116
+ ```
117
+
118
+ `.bullet` import support is enabled when Bullet's WorldImporter extras are
119
+ available at build time. Set `BULLET3_EXTRAS_SOURCE_DIR` to Bullet's
120
+ `Extras/Serialize` source directory before compiling if your system Bullet
121
+ package does not ship those libraries.
122
+
123
+ Debug drawing via Bullet3's `btIDebugDraw` interface:
124
+
125
+ ```ruby
126
+ drawer = Bullet3::DebugDraw.new
127
+ drawer.debug_mode = Bullet3::DebugDraw::DRAW_WIREFRAME | Bullet3::DebugDraw::DRAW_AABB
128
+ sim.debug_draw_world(drawer)
129
+
130
+ p drawer.lines.first
131
+ ```
132
+
133
+ ## Implemented Scope
134
+
135
+ - LinearMath: `Vector3`, `Quaternion`, `Matrix3x3`, `Transform`
136
+ - Collision shapes: primitive, compound, convex hull, triangle mesh,
137
+ convex triangle mesh, multi-sphere, heightfield
138
+ - Collision world: standalone collision objects, broadphases, ray tests,
139
+ contact tests, pair tests, closest points
140
+ - Dynamics: rigid bodies, motion states, default/explicit worlds,
141
+ constraints, contact manifolds, GVL-free stepping
142
+ - Extras: raycast vehicles, soft bodies, multibodies
143
+ - High-level API: direct/gui/shared-memory compatible local simulation modes,
144
+ primitive body creation, single- and multi-link URDF, SDF and MJCF primitive
145
+ import, ray/contact/AABB helpers, base pose, joint state/control helpers,
146
+ camera ray rendering, JSON world snapshots, native `.bullet` serialization
147
+ and import, debug drawing, dynamics updates, reset/disconnect
148
+
149
+ Remaining limitations: GUI and shared-memory modes run through the same local
150
+ simulation backend, and camera images use the built-in ray renderer rather than
151
+ TinyRenderer/OpenGL.
152
+
153
+ ## Development
154
+
155
+ After checking out the repo, install Bullet and Ruby dependencies:
156
+
157
+ ```bash
158
+ brew install bullet
159
+ bundle install
160
+ ```
161
+
162
+ Use `BULLET_ROOT=/path/to/bullet` when Bullet is installed outside the standard
163
+ system prefixes. `.bullet` import support also needs Bullet's WorldImporter
164
+ extras; set `BULLET3_EXTRAS_SOURCE_DIR=/path/to/bullet3/Extras/Serialize` before
165
+ compiling to enable it from a Bullet source checkout.
166
+
167
+ Run the Ruby fallback test suite:
168
+
169
+ ```bash
170
+ BULLET3_SKIP_NATIVE=1 bundle exec rake spec
171
+ ```
172
+
173
+ Compile and test the native extension:
174
+
175
+ ```bash
176
+ bundle exec rake compile
177
+ bundle exec rake spec
178
+ ```
179
+
180
+ Run examples:
181
+
182
+ ```bash
183
+ bundle exec ruby examples/hello_world.rb
184
+ bundle exec ruby examples/ray_casting.rb
185
+ bundle exec ruby examples/urdf.rb
186
+ ```
187
+
188
+ ## Contributing
189
+
190
+ Bug reports and pull requests are welcome on GitHub.
191
+
192
+ ## License
193
+
194
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
data/data/cube.urdf ADDED
@@ -0,0 +1,22 @@
1
+ <?xml version="1.0"?>
2
+ <robot name="cube">
3
+ <link name="baseLink">
4
+ <contact>
5
+ <lateral_friction value="1.0"/>
6
+ <rolling_friction value="0.0"/>
7
+ <contact_cfm value="0.0"/>
8
+ <contact_erp value="1.0"/>
9
+ </contact>
10
+ <inertial>
11
+ <origin rpy="0 0 0" xyz="0 0 0"/>
12
+ <mass value="1.0"/>
13
+ <inertia ixx="1" ixy="0" ixz="0" iyy="1" iyz="0" izz="1"/>
14
+ </inertial>
15
+ <collision>
16
+ <origin rpy="0 0 0" xyz="0 0 0"/>
17
+ <geometry>
18
+ <box size="1 1 1"/>
19
+ </geometry>
20
+ </collision>
21
+ </link>
22
+ </robot>
data/data/plane.urdf ADDED
@@ -0,0 +1,19 @@
1
+ <?xml version="1.0"?>
2
+ <robot name="plane">
3
+ <link name="planeLink">
4
+ <contact>
5
+ <lateral_friction value="1"/>
6
+ </contact>
7
+ <inertial>
8
+ <origin rpy="0 0 0" xyz="0 0 0"/>
9
+ <mass value="0"/>
10
+ <inertia ixx="0" ixy="0" ixz="0" iyy="0" iyz="0" izz="0"/>
11
+ </inertial>
12
+ <collision>
13
+ <origin rpy="0 0 0" xyz="0 0 -5"/>
14
+ <geometry>
15
+ <box size="200 200 10"/>
16
+ </geometry>
17
+ </collision>
18
+ </link>
19
+ </robot>
@@ -0,0 +1,224 @@
1
+ cmake_minimum_required(VERSION 3.16)
2
+
3
+ project(bullet3_native LANGUAGES CXX)
4
+
5
+ set(CMAKE_CXX_STANDARD 17)
6
+ set(CMAKE_CXX_STANDARD_REQUIRED ON)
7
+ set(CMAKE_POSITION_INDEPENDENT_CODE ON)
8
+
9
+ find_package(Ruby REQUIRED COMPONENTS Development)
10
+ find_package(PkgConfig QUIET)
11
+
12
+ execute_process(
13
+ COMMAND ${RUBY_EXECUTABLE} -rrubygems -e "print Gem::Specification.find_by_name('rice').full_gem_path"
14
+ OUTPUT_VARIABLE RICE_GEM_PATH
15
+ OUTPUT_STRIP_TRAILING_WHITESPACE
16
+ RESULT_VARIABLE RICE_LOOKUP_RESULT
17
+ )
18
+
19
+ if(NOT RICE_LOOKUP_RESULT EQUAL 0)
20
+ message(FATAL_ERROR "Rice gem is required to build bullet3")
21
+ endif()
22
+
23
+ set(BULLET_ROOT "" CACHE PATH "Path to a Bullet Physics SDK installation")
24
+ if(NOT BULLET_ROOT AND DEFINED ENV{BULLET_ROOT})
25
+ set(BULLET_ROOT "$ENV{BULLET_ROOT}")
26
+ endif()
27
+
28
+ set(BULLET3_SEARCH_PREFIXES
29
+ "${BULLET_ROOT}"
30
+ "$ENV{BULLET_ROOT}"
31
+ /opt/homebrew/opt/bullet
32
+ /usr/local
33
+ /usr
34
+ )
35
+ list(REMOVE_ITEM BULLET3_SEARCH_PREFIXES "")
36
+
37
+ set(BULLET3_INCLUDE_DIRS "")
38
+ set(BULLET3_LIBRARIES "")
39
+ set(BULLET3_LINK_TARGETS "")
40
+ set(BULLET3_LIBRARY_DIRS "")
41
+
42
+ find_package(Bullet QUIET)
43
+ if(Bullet_FOUND OR BULLET_FOUND)
44
+ if(DEFINED BULLET_INCLUDE_DIRS)
45
+ set(BULLET3_INCLUDE_DIRS ${BULLET_INCLUDE_DIRS})
46
+ elseif(DEFINED BULLET_INCLUDE_DIR)
47
+ set(BULLET3_INCLUDE_DIRS ${BULLET_INCLUDE_DIR})
48
+ endif()
49
+ set(BULLET3_LIBRARIES ${BULLET_LIBRARIES})
50
+ elseif(PkgConfig_FOUND)
51
+ pkg_check_modules(BULLET_PC QUIET IMPORTED_TARGET bullet)
52
+ if(BULLET_PC_FOUND)
53
+ if(TARGET PkgConfig::BULLET_PC)
54
+ list(APPEND BULLET3_LINK_TARGETS PkgConfig::BULLET_PC)
55
+ else()
56
+ set(BULLET3_INCLUDE_DIRS ${BULLET_PC_INCLUDE_DIRS})
57
+ set(BULLET3_LIBRARIES ${BULLET_PC_LIBRARIES})
58
+ set(BULLET3_LIBRARY_DIRS ${BULLET_PC_LIBRARY_DIRS})
59
+ endif()
60
+ endif()
61
+ endif()
62
+
63
+ if(NOT BULLET3_LINK_TARGETS AND NOT BULLET3_LIBRARIES)
64
+ find_path(BULLET3_INCLUDE_DIR
65
+ NAMES btBulletDynamicsCommon.h
66
+ HINTS ${BULLET3_SEARCH_PREFIXES}
67
+ PATH_SUFFIXES include/bullet include
68
+ )
69
+
70
+ set(BULLET3_REQUIRED_BULLET_LIBRARIES
71
+ BulletSoftBody
72
+ BulletDynamics
73
+ BulletCollision
74
+ LinearMath
75
+ )
76
+ set(BULLET3_MISSING_BULLET_LIBRARIES "")
77
+ foreach(BULLET3_LIBRARY_NAME IN LISTS BULLET3_REQUIRED_BULLET_LIBRARIES)
78
+ string(TOUPPER "${BULLET3_LIBRARY_NAME}" BULLET3_LIBRARY_VARIABLE)
79
+ find_library(BULLET3_${BULLET3_LIBRARY_VARIABLE}_LIBRARY
80
+ NAMES ${BULLET3_LIBRARY_NAME}
81
+ HINTS ${BULLET3_SEARCH_PREFIXES}
82
+ PATH_SUFFIXES lib lib64
83
+ )
84
+ if(BULLET3_${BULLET3_LIBRARY_VARIABLE}_LIBRARY)
85
+ list(APPEND BULLET3_LIBRARIES ${BULLET3_${BULLET3_LIBRARY_VARIABLE}_LIBRARY})
86
+ else()
87
+ list(APPEND BULLET3_MISSING_BULLET_LIBRARIES ${BULLET3_LIBRARY_NAME})
88
+ endif()
89
+ endforeach()
90
+
91
+ if(BULLET3_INCLUDE_DIR AND NOT BULLET3_MISSING_BULLET_LIBRARIES)
92
+ set(BULLET3_INCLUDE_DIRS ${BULLET3_INCLUDE_DIR})
93
+ endif()
94
+ endif()
95
+
96
+ if(NOT BULLET3_LINK_TARGETS AND (NOT BULLET3_INCLUDE_DIRS OR NOT BULLET3_LIBRARIES))
97
+ message(FATAL_ERROR "Bullet development files are required to build bullet3. Install Bullet or set BULLET_ROOT to the installation prefix.")
98
+ endif()
99
+
100
+ set(BULLET3_OPTIONAL_SOURCES "")
101
+ set(BULLET3_OPTIONAL_INCLUDE_DIRS "")
102
+ set(BULLET3_OPTIONAL_LIBRARIES "")
103
+
104
+ set(BULLET3_EXTRAS_SOURCE_DIR "" CACHE PATH "Optional path to Bullet Extras/Serialize sources for .bullet import support")
105
+ if(NOT BULLET3_EXTRAS_SOURCE_DIR AND DEFINED ENV{BULLET3_EXTRAS_SOURCE_DIR})
106
+ set(BULLET3_EXTRAS_SOURCE_DIR "$ENV{BULLET3_EXTRAS_SOURCE_DIR}")
107
+ endif()
108
+
109
+ if(BULLET3_EXTRAS_SOURCE_DIR)
110
+ set(BULLET3_FILE_LOADER_DIR "${BULLET3_EXTRAS_SOURCE_DIR}/BulletFileLoader")
111
+ set(BULLET3_WORLD_IMPORTER_DIR "${BULLET3_EXTRAS_SOURCE_DIR}/BulletWorldImporter")
112
+
113
+ if(NOT EXISTS "${BULLET3_FILE_LOADER_DIR}/btBulletFile.cpp" OR NOT EXISTS "${BULLET3_WORLD_IMPORTER_DIR}/btBulletWorldImporter.cpp")
114
+ message(FATAL_ERROR "BULLET3_EXTRAS_SOURCE_DIR must point to Bullet's Extras/Serialize directory")
115
+ endif()
116
+
117
+ list(APPEND BULLET3_OPTIONAL_SOURCES
118
+ "${BULLET3_FILE_LOADER_DIR}/bChunk.cpp"
119
+ "${BULLET3_FILE_LOADER_DIR}/bDNA.cpp"
120
+ "${BULLET3_FILE_LOADER_DIR}/bFile.cpp"
121
+ "${BULLET3_FILE_LOADER_DIR}/btBulletFile.cpp"
122
+ "${BULLET3_WORLD_IMPORTER_DIR}/btBulletWorldImporter.cpp"
123
+ "${BULLET3_WORLD_IMPORTER_DIR}/btWorldImporter.cpp"
124
+ )
125
+ list(APPEND BULLET3_OPTIONAL_INCLUDE_DIRS
126
+ "${BULLET3_FILE_LOADER_DIR}"
127
+ "${BULLET3_WORLD_IMPORTER_DIR}"
128
+ )
129
+ set(BULLET3_WITH_WORLD_IMPORTER TRUE)
130
+ else()
131
+ find_path(BULLET3_WORLD_IMPORTER_INCLUDE_DIR
132
+ NAMES btBulletWorldImporter.h
133
+ HINTS ${BULLET3_SEARCH_PREFIXES}
134
+ PATH_SUFFIXES
135
+ include/bullet/Extras/Serialize/BulletWorldImporter
136
+ include/Extras/Serialize/BulletWorldImporter
137
+ )
138
+ find_library(BULLET3_WORLD_IMPORTER_LIBRARY
139
+ NAMES BulletWorldImporter
140
+ HINTS ${BULLET3_SEARCH_PREFIXES}
141
+ PATH_SUFFIXES lib lib64
142
+ )
143
+ find_library(BULLET3_FILE_LOADER_LIBRARY
144
+ NAMES BulletFileLoader Bullet2FileLoader
145
+ HINTS ${BULLET3_SEARCH_PREFIXES}
146
+ PATH_SUFFIXES lib lib64
147
+ )
148
+
149
+ if(BULLET3_WORLD_IMPORTER_INCLUDE_DIR AND BULLET3_WORLD_IMPORTER_LIBRARY AND BULLET3_FILE_LOADER_LIBRARY)
150
+ list(APPEND BULLET3_OPTIONAL_INCLUDE_DIRS ${BULLET3_WORLD_IMPORTER_INCLUDE_DIR})
151
+ list(APPEND BULLET3_OPTIONAL_LIBRARIES ${BULLET3_WORLD_IMPORTER_LIBRARY} ${BULLET3_FILE_LOADER_LIBRARY})
152
+ set(BULLET3_WITH_WORLD_IMPORTER TRUE)
153
+ endif()
154
+ endif()
155
+
156
+ add_library(bullet3 MODULE
157
+ bullet3.cpp
158
+ collision/rb_collision.cpp
159
+ collision/shapes/rb_collision_shape.cpp
160
+ constraints/rb_constraints.cpp
161
+ dynamics/rb_dynamics.cpp
162
+ io/rb_io.cpp
163
+ linear_math/rb_matrix3x3.cpp
164
+ linear_math/rb_quaternion.cpp
165
+ linear_math/rb_transform.cpp
166
+ linear_math/rb_vector3.cpp
167
+ multi_body/rb_multi_body.cpp
168
+ soft_body/rb_soft_body.cpp
169
+ util/rb_debug_draw.cpp
170
+ vehicle/rb_vehicle.cpp
171
+ ${BULLET3_OPTIONAL_SOURCES}
172
+ )
173
+
174
+ target_include_directories(bullet3 PRIVATE
175
+ ${BULLET3_INCLUDE_DIRS}
176
+ ${BULLET3_OPTIONAL_INCLUDE_DIRS}
177
+ )
178
+
179
+ target_include_directories(bullet3 SYSTEM PRIVATE
180
+ ${Ruby_INCLUDE_DIRS}
181
+ "${RICE_GEM_PATH}/include"
182
+ )
183
+
184
+ set(BULLET3_RUBY_LIBRARIES "")
185
+ foreach(RUBY_LIBRARY IN LISTS Ruby_LIBRARIES)
186
+ if(RUBY_LIBRARY AND NOT RUBY_LIBRARY MATCHES "-NOTFOUND$")
187
+ list(APPEND BULLET3_RUBY_LIBRARIES ${RUBY_LIBRARY})
188
+ endif()
189
+ endforeach()
190
+
191
+ if(BULLET3_LIBRARY_DIRS)
192
+ target_link_directories(bullet3 PRIVATE ${BULLET3_LIBRARY_DIRS})
193
+ endif()
194
+
195
+ target_link_libraries(bullet3 PRIVATE
196
+ ${BULLET3_RUBY_LIBRARIES}
197
+ ${BULLET3_LINK_TARGETS}
198
+ ${BULLET3_LIBRARIES}
199
+ ${BULLET3_OPTIONAL_LIBRARIES}
200
+ )
201
+
202
+ if(APPLE)
203
+ target_link_options(bullet3 PRIVATE -undefined dynamic_lookup)
204
+ endif()
205
+
206
+ if(BULLET3_WITH_WORLD_IMPORTER)
207
+ target_compile_definitions(bullet3 PRIVATE BULLET3_WITH_WORLD_IMPORTER)
208
+ endif()
209
+
210
+ if(MSVC)
211
+ target_compile_options(bullet3 PRIVATE /W4)
212
+ else()
213
+ target_compile_options(bullet3 PRIVATE
214
+ -Wall
215
+ -Wextra
216
+ $<$<COMPILE_LANG_AND_ID:CXX,AppleClang,Clang,GNU>:-include${CMAKE_CURRENT_SOURCE_DIR}/util/ruby_cpp_compat.hpp>
217
+ )
218
+ endif()
219
+
220
+ set_target_properties(bullet3 PROPERTIES
221
+ PREFIX ""
222
+ SUFFIX "${RUBY_EXTENSION_SUFFIX}"
223
+ LIBRARY_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}"
224
+ )
@@ -0,0 +1,34 @@
1
+ #include <rice/rice.hpp>
2
+
3
+ void Init_Shapes(Rice::Module rb_mBullet);
4
+ void Init_Collision(Rice::Module rb_mBullet);
5
+ void Init_SoftBody(Rice::Module rb_mBullet);
6
+ void Init_Constraints(Rice::Module rb_mBullet);
7
+ void Init_Dynamics(Rice::Module rb_mBullet);
8
+ void Init_DebugDraw(Rice::Module rb_mBullet);
9
+ void Init_IO(Rice::Module rb_mBullet);
10
+ void Init_Matrix3x3(Rice::Module rb_mBullet);
11
+ void Init_MultiBody(Rice::Module rb_mBullet);
12
+ void Init_Quaternion(Rice::Module rb_mBullet);
13
+ void Init_Transform(Rice::Module rb_mBullet);
14
+ void Init_Vector3(Rice::Module rb_mBullet);
15
+ void Init_Vehicle(Rice::Module rb_mBullet);
16
+
17
+ extern "C"
18
+ void Init_bullet3()
19
+ {
20
+ Rice::Module rb_mBullet = Rice::define_module("Bullet3");
21
+ Init_Vector3(rb_mBullet);
22
+ Init_Quaternion(rb_mBullet);
23
+ Init_Matrix3x3(rb_mBullet);
24
+ Init_Transform(rb_mBullet);
25
+ Init_Shapes(rb_mBullet);
26
+ Init_Dynamics(rb_mBullet);
27
+ Init_Collision(rb_mBullet);
28
+ Init_Constraints(rb_mBullet);
29
+ Init_DebugDraw(rb_mBullet);
30
+ Init_IO(rb_mBullet);
31
+ Init_Vehicle(rb_mBullet);
32
+ Init_SoftBody(rb_mBullet);
33
+ Init_MultiBody(rb_mBullet);
34
+ }