diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..2ebd842 --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +bin/ +target/ +lib/ +logs/ diff --git a/addons/3d_batcher/batched_mesh_instance.gdns b/addons/3d_batcher/batched_mesh_instance.gdns new file mode 100644 index 0000000..b67260a --- /dev/null +++ b/addons/3d_batcher/batched_mesh_instance.gdns @@ -0,0 +1,8 @@ +[gd_resource type="NativeScript" load_steps=2 format=2] + +[ext_resource path="res://addons/3d_batcher/gd_3d_batcher.gdnlib" type="GDNativeLibrary" id=1] + +[resource] +class_name = "BatchedMeshInstance" +library = ExtResource( 1 ) +script_class_name = "BatchedMeshInstance" diff --git a/addons/3d_batcher/batched_mesh_manager.gdns b/addons/3d_batcher/batched_mesh_manager.gdns new file mode 100644 index 0000000..e152769 --- /dev/null +++ b/addons/3d_batcher/batched_mesh_manager.gdns @@ -0,0 +1,9 @@ +[gd_resource type="NativeScript" load_steps=2 format=2] + +[ext_resource path="res://addons/3d_batcher/gd_3d_batcher.gdnlib" type="GDNativeLibrary" id=1] + +[resource] +resource_name = "BatchedMeshManager" +class_name = "BatchedMeshManager" +library = ExtResource( 1 ) +script_class_name = "BatchedMeshManager" diff --git a/addons/3d_batcher/gd_3d_batcher.gdnlib b/addons/3d_batcher/gd_3d_batcher.gdnlib new file mode 100644 index 0000000..41740ab --- /dev/null +++ b/addons/3d_batcher/gd_3d_batcher.gdnlib @@ -0,0 +1,23 @@ +[resource] + +entry/X11.64="res://addons/3d_batcher/lib/libgd_3d_batcher.so" +dependency/X11.64=[ ] + +[general] + +singleton=false +load_once=true +symbol_prefix="godot_" +reloadable=true + +[entry] + +OSX.64="res://addons/3d_batcher/lib/libgd_3d_batcher.dylib" +Windows.64="res://addons/3d_batcher/lib/gd_3d_batcher.dll" +X11.64="res://addons/3d_batcher/lib/libgd_3d_batcher.so" + +[dependencies] + +OSX.64=[ ] +Windows.64=[ ] +X11.64=[ ] diff --git a/addons/3d_batcher/lib/gd_3d_batcher.dll b/addons/3d_batcher/lib/gd_3d_batcher.dll new file mode 100755 index 0000000..18e31a0 Binary files /dev/null and b/addons/3d_batcher/lib/gd_3d_batcher.dll differ diff --git a/addons/3d_batcher/lib/libgd_3d_batcher.dylib b/addons/3d_batcher/lib/libgd_3d_batcher.dylib new file mode 100755 index 0000000..d6f58bb Binary files /dev/null and b/addons/3d_batcher/lib/libgd_3d_batcher.dylib differ diff --git a/addons/3d_batcher/lib/libgd_3d_batcher.so b/addons/3d_batcher/lib/libgd_3d_batcher.so new file mode 100755 index 0000000..afce937 Binary files /dev/null and b/addons/3d_batcher/lib/libgd_3d_batcher.so differ diff --git a/addons/3d_batcher/plugin.cfg b/addons/3d_batcher/plugin.cfg new file mode 100644 index 0000000..5848edf --- /dev/null +++ b/addons/3d_batcher/plugin.cfg @@ -0,0 +1,7 @@ +[plugin] + +name="3D Batcher" +description="Automatically batch nodes with the same mesh and material." +author="David Hoppenbrouwers" +version="0.1" +script="plugin.gd" diff --git a/addons/3d_batcher/plugin.gd b/addons/3d_batcher/plugin.gd new file mode 100644 index 0000000..e71e85b --- /dev/null +++ b/addons/3d_batcher/plugin.gd @@ -0,0 +1,17 @@ +tool +extends EditorPlugin + + +const AUTOLOAD_SCRIPT := "batched_mesh_manager.gdns" + +var autoload = null + + +func _enter_tree() -> void: + autoload = preload(AUTOLOAD_SCRIPT).new() + add_child(autoload) + + +func _exit_tree() -> void: + autoload.queue_free() + autoload = null diff --git a/addons/rapier3d/box.gdns b/addons/rapier3d/box.gdns new file mode 100644 index 0000000..246e9c3 --- /dev/null +++ b/addons/rapier3d/box.gdns @@ -0,0 +1,8 @@ +[gd_resource type="NativeScript" load_steps=2 format=2] + +[ext_resource path="res://addons/rapier3d/rapier3d.gdnlib" type="GDNativeLibrary" id=1] + +[resource] +class_name = "Box" +library = ExtResource( 1 ) +script_class_name = "Rapier3D_Box" diff --git a/addons/rapier3d/rapier3d.gdnlib b/addons/rapier3d/rapier3d.gdnlib new file mode 100644 index 0000000..a3bcdb5 --- /dev/null +++ b/addons/rapier3d/rapier3d.gdnlib @@ -0,0 +1,14 @@ +[general] + +singleton=false +load_once=true +symbol_prefix="gd_rapier3d_" +reloadable=true + +[entry] + +X11.64="res://addons/rapier3d/lib/libgodot_rapier3d.so" + +[dependencies] + +X11.64=[ ] diff --git a/addons/rapier3d/rapier3d.gdns b/addons/rapier3d/rapier3d.gdns new file mode 100644 index 0000000..32f743c --- /dev/null +++ b/addons/rapier3d/rapier3d.gdns @@ -0,0 +1,8 @@ +[gd_resource type="NativeScript" load_steps=2 format=2] + +[ext_resource path="res://addons/rapier3d/rapier3d.gdnlib" type="GDNativeLibrary" id=1] + +[resource] +class_name = "Rapier3D" +library = ExtResource( 1 ) +script_class_name = "Rapier3D" diff --git a/addons/rapier3d/rigid_body.gdns b/addons/rapier3d/rigid_body.gdns new file mode 100644 index 0000000..df9b1e0 --- /dev/null +++ b/addons/rapier3d/rigid_body.gdns @@ -0,0 +1,8 @@ +[gd_resource type="NativeScript" load_steps=2 format=2] + +[ext_resource path="res://addons/rapier3d/rapier3d.gdnlib" type="GDNativeLibrary" id=1] + +[resource] +class_name = "RigidBody" +library = ExtResource( 1 ) +script_class_name = "Rapier3D_RigidBody" diff --git a/addons/rapier3d/rustfmt.toml b/addons/rapier3d/rustfmt.toml new file mode 100644 index 0000000..218e203 --- /dev/null +++ b/addons/rapier3d/rustfmt.toml @@ -0,0 +1 @@ +hard_tabs = true diff --git a/addons/rapier3d/static_body.gdns b/addons/rapier3d/static_body.gdns new file mode 100644 index 0000000..1dfdd5b --- /dev/null +++ b/addons/rapier3d/static_body.gdns @@ -0,0 +1,9 @@ +[gd_resource type="NativeScript" load_steps=2 format=2] + +[ext_resource path="res://addons/rapier3d/rapier3d.gdnlib" type="GDNativeLibrary" id=1] + +[resource] +resource_name = "StaticBody" +class_name = "StaticBody" +library = ExtResource( 1 ) +script_class_name = "Rapier3D_StaticBody" diff --git a/box_godot.tscn b/box_godot.tscn new file mode 100644 index 0000000..e2c2be0 --- /dev/null +++ b/box_godot.tscn @@ -0,0 +1,25 @@ +[gd_scene load_steps=5 format=2] + +[ext_resource path="res://addons/3d_batcher/batched_mesh_instance.gdns" type="Script" id=3] + +[sub_resource type="BoxShape" id=1] +extents = Vector3( 0.5, 0.5, 0.5 ) + +[sub_resource type="SpatialMaterial" id=2] +vertex_color_use_as_albedo = true + +[sub_resource type="CubeMesh" id=3] +material = SubResource( 2 ) +size = Vector3( 1, 1, 1 ) + +[node name="Box" type="RigidBody"] +input_ray_pickable = false + +[node name="Shape" type="CollisionShape" parent="."] +shape = SubResource( 1 ) + +[node name="Mesh" type="Spatial" parent="."] +script = ExtResource( 3 ) +mesh = SubResource( 3 ) +use_color = true +color = Color( 1, 1, 1, 1 ) diff --git a/box_rapier3d.tscn b/box_rapier3d.tscn new file mode 100644 index 0000000..2c30658 --- /dev/null +++ b/box_rapier3d.tscn @@ -0,0 +1,28 @@ +[gd_scene load_steps=6 format=2] + +[ext_resource path="res://addons/rapier3d/box.gdns" type="Script" id=1] +[ext_resource path="res://addons/rapier3d/rigid_body.gdns" type="Script" id=2] +[ext_resource path="res://addons/3d_batcher/batched_mesh_instance.gdns" type="Script" id=3] + +[sub_resource type="SpatialMaterial" id=2] +vertex_color_use_as_albedo = true + +[sub_resource type="CubeMesh" id=1] +material = SubResource( 2 ) +size = Vector3( 1, 1, 1 ) + +[node name="Box" type="Spatial"] +script = ExtResource( 2 ) +__meta__ = { +"_edit_group_": true +} + +[node name="Shape" type="Spatial" parent="."] +script = ExtResource( 1 ) +extents = Vector3( 0.5, 0.5, 0.5 ) + +[node name="Mesh" type="Spatial" parent="."] +script = ExtResource( 3 ) +mesh = SubResource( 1 ) +use_color = true +color = Color( 1, 1, 1, 1 ) diff --git a/boxes.gd b/boxes.gd new file mode 100644 index 0000000..ab65442 --- /dev/null +++ b/boxes.gd @@ -0,0 +1,24 @@ +extends Node + + +export var x := 10 +export var y := 10 +export var z := 10 +export var origin := Vector3.ONE +export var offset := Vector3.ONE +export var box_rapier3d: PackedScene +export var box_godot: PackedScene +export var use_rapier3d := true +export var colors := PoolColorArray([Color.white, Color.red, Color.green, Color.blue, Color.yellow, Color.magenta]) + + +func _ready(): + var i := 0 + for a in x: + for b in y: + for c in z: + var n: Spatial = (box_rapier3d if use_rapier3d else box_godot).instance() + n.get_node("Mesh").color = colors[i % len(colors)] + i += 1 + n.translation = Vector3(a, b, c) * offset + origin + add_child(n) diff --git a/boxes.tscn b/boxes.tscn new file mode 100644 index 0000000..8ff0dd7 --- /dev/null +++ b/boxes.tscn @@ -0,0 +1,68 @@ +[gd_scene load_steps=10 format=2] + +[ext_resource path="res://addons/rapier3d/rapier3d.gdns" type="Script" id=1] +[ext_resource path="res://addons/rapier3d/static_body.gdns" type="Script" id=2] +[ext_resource path="res://addons/rapier3d/box.gdns" type="Script" id=3] +[ext_resource path="res://box_rapier3d.tscn" type="PackedScene" id=4] +[ext_resource path="res://boxes.gd" type="Script" id=5] +[ext_resource path="res://box_godot.tscn" type="PackedScene" id=6] +[ext_resource path="res://stats.gd" type="Script" id=7] + +[sub_resource type="CubeMesh" id=1] +size = Vector3( 100, 1, 100 ) + +[sub_resource type="BoxShape" id=2] +extents = Vector3( 50, 0.5, 50 ) + +[node name="Node" type="Node"] +script = ExtResource( 5 ) +x = 16 +y = 16 +z = 16 +box_rapier3d = ExtResource( 4 ) +box_godot = ExtResource( 6 ) + +[node name="Floor Rapier3D" type="Spatial" parent="."] +script = ExtResource( 2 ) +__meta__ = { +"_edit_group_": true +} + +[node name="Shape" type="Spatial" parent="Floor Rapier3D"] +script = ExtResource( 3 ) +extents = Vector3( 50, 0.5, 50 ) + +[node name="MeshInstance" type="MeshInstance" parent="Floor Rapier3D"] +mesh = SubResource( 1 ) +material/0 = null + +[node name="Floor Godot" type="StaticBody" parent="."] + +[node name="Shape" type="CollisionShape" parent="Floor Godot"] +shape = SubResource( 2 ) + +[node name="Rapier" type="Node" parent="."] +script = ExtResource( 1 ) + +[node name="Camera" type="Camera" parent="."] +transform = Transform( 0, -0.5, 0.866025, 0, 0.866025, 0.5, -1, 0, 0, 41, 25, 3 ) + +[node name="DirectionalLight" type="DirectionalLight" parent="."] +transform = Transform( -0.965926, -0.12941, 0.224144, 0, 0.866025, 0.5, -0.258819, 0.482963, -0.836516, 0, 7, -13 ) +shadow_enabled = true + +[node name="Stats" type="Panel" parent="."] +margin_right = 186.0 +margin_bottom = 94.0 +__meta__ = { +"_edit_use_anchors_": false +} + +[node name="Stats" type="Label" parent="Stats"] +process_priority = 10 +margin_right = 120.0 +margin_bottom = 35.0 +script = ExtResource( 7 ) +__meta__ = { +"_edit_use_anchors_": false +} diff --git a/default_env.tres b/default_env.tres new file mode 100644 index 0000000..54a466d --- /dev/null +++ b/default_env.tres @@ -0,0 +1,8 @@ +[gd_resource type="Environment" load_steps=2 format=2] + +[sub_resource type="ProceduralSky" id=1] + +[resource] +background_mode = 2 +background_sky = SubResource( 1 ) +ambient_light_energy = 0.3 diff --git a/export_presets.cfg b/export_presets.cfg new file mode 100644 index 0000000..4bb9a7a --- /dev/null +++ b/export_presets.cfg @@ -0,0 +1,25 @@ +[preset.0] + +name="Linux/X11" +platform="Linux/X11" +runnable=true +custom_features="" +export_filter="all_resources" +include_filter="" +exclude_filter="" +export_path="bin/rapier_test.x86_64" +patch_list=PoolStringArray( ) +script_export_mode=1 +script_encryption_key="" + +[preset.0.options] + +texture_format/bptc=false +texture_format/s3tc=true +texture_format/etc=false +texture_format/etc2=false +texture_format/no_bptc_fallbacks=true +binary_format/64_bits=true +binary_format/embed_pck=false +custom_template/release="" +custom_template/debug="" diff --git a/native/.gdignore b/native/.gdignore new file mode 100644 index 0000000..e69de29 diff --git a/native/Cargo.lock b/native/Cargo.lock new file mode 100644 index 0000000..74887a2 --- /dev/null +++ b/native/Cargo.lock @@ -0,0 +1,1058 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +[[package]] +name = "ahash" +version = "0.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f200cbb1e856866d9eade941cf3aa0c5d7dd36f74311c4273b494f4ef036957" +dependencies = [ + "getrandom", + "once_cell", + "version_check", +] + +[[package]] +name = "approx" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f2a05fd1bd10b2527e20a2cd32d8873d115b8b39fe219ee25f42a8aca6ba278" +dependencies = [ + "num-traits", +] + +[[package]] +name = "arrayvec" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "23b62fc65de8e4e7f52534fb52b0f3ed04746ae267519eef2a83941e8085068b" + +[[package]] +name = "autocfg" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cdb031dd78e28731d87d56cc8ffef4a8f36ca26c38fe2de700543e627f8a464a" + +[[package]] +name = "base-x" +version = "0.2.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a4521f3e3d031370679b3b140beb36dfe4801b09ac77e30c61941f97df3ef28b" + +[[package]] +name = "bindgen" +version = "0.56.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2da379dbebc0b76ef63ca68d8fc6e71c0f13e59432e0987e508c1820e6ab5239" +dependencies = [ + "bitflags", + "cexpr", + "clang-sys", + "lazy_static", + "lazycell", + "peeking_take_while", + "proc-macro2", + "quote", + "regex", + "rustc-hash", + "shlex", +] + +[[package]] +name = "bit-vec" +version = "0.6.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "349f9b6a179ed607305526ca489b34ad0a41aed5f7980fa90eb03160b69598fb" + +[[package]] +name = "bitflags" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693" + +[[package]] +name = "bumpalo" +version = "3.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "63396b8a4b9de3f4fdfb320ab6080762242f66a8ef174c49d8e19b674db4cdbe" + +[[package]] +name = "cexpr" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f4aedb84272dbe89af497cf81375129abda4fc0a9e7c5d317498c15cc30c0d27" +dependencies = [ + "nom", +] + +[[package]] +name = "cfg-if" +version = "0.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822" + +[[package]] +name = "cfg-if" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" + +[[package]] +name = "clang-sys" +version = "1.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f54d78e30b388d4815220c8dd03fea5656b6c6d32adb59e89061552a102f8da1" +dependencies = [ + "glob", + "libc", + "libloading", +] + +[[package]] +name = "const_fn" +version = "0.4.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "28b9d6de7f49e22cf97ad17fc4036ece69300032f45f78f30b4a4482cdc3f4a6" + +[[package]] +name = "crossbeam" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fd01a6eb3daaafa260f6fc94c3a6c36390abc2080e38e3e34ced87393fb77d80" +dependencies = [ + "cfg-if 1.0.0", + "crossbeam-channel", + "crossbeam-deque", + "crossbeam-epoch", + "crossbeam-queue", + "crossbeam-utils", +] + +[[package]] +name = "crossbeam-channel" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dca26ee1f8d361640700bde38b2c37d8c22b3ce2d360e1fc1c74ea4b0aa7d775" +dependencies = [ + "cfg-if 1.0.0", + "crossbeam-utils", +] + +[[package]] +name = "crossbeam-deque" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "94af6efb46fef72616855b036a624cf27ba656ffc9be1b9a3c931cfc7749a9a9" +dependencies = [ + "cfg-if 1.0.0", + "crossbeam-epoch", + "crossbeam-utils", +] + +[[package]] +name = "crossbeam-epoch" +version = "0.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2584f639eb95fea8c798496315b297cf81b9b58b6d30ab066a75455333cf4b12" +dependencies = [ + "cfg-if 1.0.0", + "crossbeam-utils", + "lazy_static", + "memoffset", + "scopeguard", +] + +[[package]] +name = "crossbeam-queue" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0f6cb3c7f5b8e51bc3ebb73a2327ad4abdbd119dc13223f14f961d2f38486756" +dependencies = [ + "cfg-if 1.0.0", + "crossbeam-utils", +] + +[[package]] +name = "crossbeam-utils" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e7e9d99fa91428effe99c5c6d4634cdeba32b8cf784fc428a2a687f61a952c49" +dependencies = [ + "autocfg", + "cfg-if 1.0.0", + "lazy_static", +] + +[[package]] +name = "discard" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "212d0f5754cb6769937f4501cc0e67f4f4483c8d2c3e1e922ee9edbe4ab4c7c0" + +[[package]] +name = "downcast-rs" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ea835d29036a4087793836fa931b08837ad5e957da9e23886b29586fb9b6650" + +[[package]] +name = "either" +version = "1.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e78d4f1cc4ae33bbfc157ed5d5a5ef3bc29227303d595861deb238fcec4e9457" + +[[package]] +name = "euclid" +version = "0.22.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "51e5bac4ec41ece6346fd867815a57a221abdf48f4eb931b033789b5b4b6fc70" +dependencies = [ + "num-traits", +] + +[[package]] +name = "gdnative" +version = "0.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7ff5b6474bfe306c35ecb0cae47291e9af8af2f72e98d65cba7b76b2a52bf82b" +dependencies = [ + "gdnative-bindings", + "gdnative-core", + "gdnative-derive", +] + +[[package]] +name = "gdnative-bindings" +version = "0.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "56b520f9b48e89d45852907b1acf0f25bc4bc8e8ee31148d351070096d00c761" +dependencies = [ + "bitflags", + "gdnative-core", + "gdnative-sys", + "gdnative_bindings_generator", + "heck", + "libc", +] + +[[package]] +name = "gdnative-core" +version = "0.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "51d26a9076a40e568e6a29180985a111290e060f33581f37cb7695b1187d3bb7" +dependencies = [ + "ahash", + "approx", + "bitflags", + "euclid", + "gdnative-impl-proc-macros", + "gdnative-sys", + "indexmap", + "libc", + "parking_lot", +] + +[[package]] +name = "gdnative-derive" +version = "0.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "82a0fc3c7dcadb3d2c2df567f80b12d872363bf3298a97f1b7a668150cd2f1cd" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "gdnative-impl-proc-macros" +version = "0.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d2483f2b4038c2efb4fb22742a779201eb0bb1d4fb1d5dca3666e124281af86" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "gdnative-sys" +version = "0.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "97911fe633877345ce7788cf19febb322dc7a7ffd585098fea7e5cef11edf7f2" +dependencies = [ + "bindgen", + "libc", + "miniserde", + "proc-macro2", + "quote", +] + +[[package]] +name = "gdnative_bindings_generator" +version = "0.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ef6014ab49e58445894633f8a01b321ed86337150b6f1024ffea923e4499b91" +dependencies = [ + "heck", + "miniserde", + "proc-macro2", + "quote", + "roxmltree", + "syn", + "unindent", +] + +[[package]] +name = "generational-arena" +version = "0.2.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e1d3b771574f62d0548cee0ad9057857e9fc25d7a3335f140c84f6acd0bf601" +dependencies = [ + "cfg-if 0.1.10", +] + +[[package]] +name = "generic-array" +version = "0.14.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "501466ecc8a30d1d3b7fc9229b122b2ce8ed6e9d9223f1138d4babb253e51817" +dependencies = [ + "typenum", + "version_check", +] + +[[package]] +name = "getrandom" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c9495705279e7140bf035dde1f6e750c162df8b625267cd52cc44e0b156732c8" +dependencies = [ + "cfg-if 1.0.0", + "libc", + "wasi", +] + +[[package]] +name = "glob" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b919933a397b79c37e33b77bb2aa3dc8eb6e165ad809e58ff75bc7db2e34574" + +[[package]] +name = "hashbrown" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d7afe4a420e3fe79967a00898cc1f4db7c8a49a9333a29f8a4bd76a253d5cd04" + +[[package]] +name = "heck" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87cbf45460356b7deeb5e3415b5563308c0a9b057c85e12b06ad551f98d0a6ac" +dependencies = [ + "unicode-segmentation", +] + +[[package]] +name = "indexmap" +version = "1.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "824845a0bf897a9042383849b02c1bc219c2383772efcd5c6f9766fa4b81aef3" +dependencies = [ + "autocfg", + "hashbrown", +] + +[[package]] +name = "instant" +version = "0.1.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "61124eeebbd69b8190558df225adf7e4caafce0d743919e5d6b19652314ec5ec" +dependencies = [ + "cfg-if 1.0.0", + "time", +] + +[[package]] +name = "itoa" +version = "0.4.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dd25036021b0de88a0aff6b850051563c6516d0bf53f8638938edbb9de732736" + +[[package]] +name = "lazy_static" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" + +[[package]] +name = "lazycell" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55" + +[[package]] +name = "libc" +version = "0.2.91" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8916b1f6ca17130ec6568feccee27c156ad12037880833a3b842a823236502e7" + +[[package]] +name = "libloading" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6f84d96438c15fcd6c3f244c8fce01d1e2b9c6b5623e9c711dc9286d8fc92d6a" +dependencies = [ + "cfg-if 1.0.0", + "winapi", +] + +[[package]] +name = "libm" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7fc7aa29613bd6a620df431842069224d8bc9011086b1db4c0e0cd47fa03ec9a" + +[[package]] +name = "lock_api" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dd96ffd135b2fd7b973ac026d28085defbe8983df057ced3eb4f2130b0831312" +dependencies = [ + "scopeguard", +] + +[[package]] +name = "log" +version = "0.4.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "51b9bbe6c47d51fc3e1a9b945965946b4c44142ab8792c50835a980d362c2710" +dependencies = [ + "cfg-if 1.0.0", +] + +[[package]] +name = "matrixmultiply" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1300bdbea33ec2836b01ff1f5a6eed8bad66d0c31f94d9b7993407a8b054c3a1" +dependencies = [ + "rawpointer", +] + +[[package]] +name = "memchr" +version = "2.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ee1c47aaa256ecabcaea351eae4a9b01ef39ed810004e298d2511ed284b1525" + +[[package]] +name = "memoffset" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "157b4208e3059a8f9e78d559edc658e13df41410cb3ae03979c83130067fdd87" +dependencies = [ + "autocfg", +] + +[[package]] +name = "mini-internal" +version = "0.1.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7b3fb39c72c84ffbed14f8ee8b1a0e52ecd323df2ee69499fd3400a95d7269aa" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "miniserde" +version = "0.1.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e021d8031f6e224438f402d4c59d26c997e6e13498bd34da1aa1f858bd3b2f43" +dependencies = [ + "itoa", + "mini-internal", + "ryu", +] + +[[package]] +name = "nalgebra" +version = "0.25.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5cb5960baf61e6cc763d6a7ab1443381ae0091073861e26cd9d792d06d478a79" +dependencies = [ + "approx", + "generic-array", + "matrixmultiply", + "num-complex", + "num-rational", + "num-traits", + "simba", + "typenum", +] + +[[package]] +name = "native" +version = "0.1.0" +dependencies = [ + "gdnative", + "lazy_static", + "rapier3d", +] + +[[package]] +name = "nom" +version = "5.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ffb4262d26ed83a1c0a33a38fe2bb15797329c85770da05e6b828ddb782627af" +dependencies = [ + "memchr", + "version_check", +] + +[[package]] +name = "num-complex" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "747d632c0c558b87dbabbe6a82f3b4ae03720d0646ac5b7b4dae89394be5f2c5" +dependencies = [ + "num-traits", +] + +[[package]] +name = "num-derive" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "876a53fff98e03a936a674b29568b0e605f06b29372c2489ff4de23f1949743d" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "num-integer" +version = "0.1.44" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d2cc698a63b549a70bc047073d2949cce27cd1c7b0a4a862d08a8031bc2801db" +dependencies = [ + "autocfg", + "num-traits", +] + +[[package]] +name = "num-rational" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "12ac428b1cb17fce6f731001d307d351ec70a6d202fc2e60f7d4c5e42d8f4f07" +dependencies = [ + "autocfg", + "num-integer", + "num-traits", +] + +[[package]] +name = "num-traits" +version = "0.2.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a64b1ec5cda2586e284722486d802acf1f7dbdc623e2bfc57e65ca1cd099290" +dependencies = [ + "autocfg", +] + +[[package]] +name = "once_cell" +version = "1.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "af8b08b04175473088b46763e51ee54da5f9a164bc162f615b91bc179dbf15a3" + +[[package]] +name = "packed_simd_2" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3278e0492f961fd4ae70909f56b2723a7e8d01a228427294e19cdfdebda89a17" +dependencies = [ + "cfg-if 0.1.10", + "libm", +] + +[[package]] +name = "parking_lot" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6d7744ac029df22dca6284efe4e898991d28e3085c706c972bcd7da4a27a15eb" +dependencies = [ + "instant", + "lock_api", + "parking_lot_core", +] + +[[package]] +name = "parking_lot_core" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fa7a782938e745763fe6907fc6ba86946d72f49fe7e21de074e08128a99fb018" +dependencies = [ + "cfg-if 1.0.0", + "instant", + "libc", + "redox_syscall", + "smallvec", + "winapi", +] + +[[package]] +name = "parry3d" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3d44a46651f3458959c2f403ea40ff15501584f97e4aba759a7fd745a2ec4dd9" +dependencies = [ + "approx", + "bitflags", + "downcast-rs", + "either", + "nalgebra", + "num-derive", + "num-traits", + "rustc-hash", + "simba", + "slab", + "smallvec", +] + +[[package]] +name = "paste" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "acbf547ad0c65e31259204bd90935776d1c693cec2f4ff7abb7a1bbbd40dfe58" + +[[package]] +name = "peeking_take_while" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "19b17cddbe7ec3f8bc800887bab5e717348c95ea2ca0b1bf0837fb964dc67099" + +[[package]] +name = "proc-macro-hack" +version = "0.5.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dbf0c48bc1d91375ae5c3cd81e3722dff1abcf81a30960240640d223f59fe0e5" + +[[package]] +name = "proc-macro2" +version = "1.0.24" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e0704ee1a7e00d7bb417d0770ea303c1bccbabf0ef1667dae92b5967f5f8a71" +dependencies = [ + "unicode-xid", +] + +[[package]] +name = "quote" +version = "1.0.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c3d0b9745dc2debf507c8422de05d7226cc1f0644216dfdfead988f9b1ab32a7" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "rapier3d" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4a7d770ea5c3b6a1d1c8e144952a303f0a80f6873b5c12149abf02c39167599a" +dependencies = [ + "approx", + "arrayvec", + "bit-vec", + "bitflags", + "crossbeam", + "downcast-rs", + "generational-arena", + "instant", + "nalgebra", + "num-derive", + "num-traits", + "parry3d", + "rustc-hash", + "simba", + "vec_map", +] + +[[package]] +name = "rawpointer" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "60a357793950651c4ed0f3f52338f53b2f809f32d83a07f72909fa13e4c6c1e3" + +[[package]] +name = "redox_syscall" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "94341e4e44e24f6b591b59e47a8a027df12e008d73fd5672dbea9cc22f4507d9" +dependencies = [ + "bitflags", +] + +[[package]] +name = "regex" +version = "1.4.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "957056ecddbeba1b26965114e191d2e8589ce74db242b6ea25fc4062427a5c19" +dependencies = [ + "regex-syntax", +] + +[[package]] +name = "regex-syntax" +version = "0.6.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "24d5f089152e60f62d28b835fbff2cd2e8dc0baf1ac13343bef92ab7eed84548" + +[[package]] +name = "roxmltree" +version = "0.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bf58a7d05b28e14b1e8902fa04c4d5d6109f5450ef71a5e6597f66e53f541504" +dependencies = [ + "xmlparser", +] + +[[package]] +name = "rustc-hash" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" + +[[package]] +name = "rustc_version" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a" +dependencies = [ + "semver", +] + +[[package]] +name = "ryu" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "71d301d4193d031abdd79ff7e3dd721168a9572ef3fe51a1517aba235bd8f86e" + +[[package]] +name = "scopeguard" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" + +[[package]] +name = "semver" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" +dependencies = [ + "semver-parser", +] + +[[package]] +name = "semver-parser" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" + +[[package]] +name = "serde" +version = "1.0.125" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "558dc50e1a5a5fa7112ca2ce4effcb321b0300c0d4ccf0776a9f60cd89031171" + +[[package]] +name = "serde_derive" +version = "1.0.125" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b093b7a2bb58203b5da3056c05b4ec1fed827dcfdb37347a8841695263b3d06d" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "serde_json" +version = "1.0.64" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "799e97dc9fdae36a5c8b8f2cae9ce2ee9fdce2058c57a93e6099d919fd982f79" +dependencies = [ + "itoa", + "ryu", + "serde", +] + +[[package]] +name = "sha1" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2579985fda508104f7587689507983eadd6a6e84dd35d6d115361f530916fa0d" + +[[package]] +name = "shlex" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7fdf1b9db47230893d76faad238fd6097fd6d6a9245cd7a4d90dbd639536bbd2" + +[[package]] +name = "simba" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5132a955559188f3d13c9ba831e77c802ddc8782783f050ed0c52f5988b95f4c" +dependencies = [ + "approx", + "num-complex", + "num-traits", + "packed_simd_2", + "paste", +] + +[[package]] +name = "slab" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c111b5bd5695e56cffe5129854aa230b39c93a305372fdbb2668ca2394eea9f8" + +[[package]] +name = "smallvec" +version = "1.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fe0f37c9e8f3c5a4a66ad655a93c74daac4ad00c441533bf5c6e7990bb42604e" + +[[package]] +name = "standback" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e113fb6f3de07a243d434a56ec6f186dfd51cb08448239fe7bcae73f87ff28ff" +dependencies = [ + "version_check", +] + +[[package]] +name = "stdweb" +version = "0.4.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d022496b16281348b52d0e30ae99e01a73d737b2f45d38fed4edf79f9325a1d5" +dependencies = [ + "discard", + "rustc_version", + "stdweb-derive", + "stdweb-internal-macros", + "stdweb-internal-runtime", + "wasm-bindgen", +] + +[[package]] +name = "stdweb-derive" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c87a60a40fccc84bef0652345bbbbbe20a605bf5d0ce81719fc476f5c03b50ef" +dependencies = [ + "proc-macro2", + "quote", + "serde", + "serde_derive", + "syn", +] + +[[package]] +name = "stdweb-internal-macros" +version = "0.2.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "58fa5ff6ad0d98d1ffa8cb115892b6e69d67799f6763e162a1c9db421dc22e11" +dependencies = [ + "base-x", + "proc-macro2", + "quote", + "serde", + "serde_derive", + "serde_json", + "sha1", + "syn", +] + +[[package]] +name = "stdweb-internal-runtime" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "213701ba3370744dcd1a12960caa4843b3d68b4d1c0a5d575e0d65b2ee9d16c0" + +[[package]] +name = "syn" +version = "1.0.64" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3fd9d1e9976102a03c542daa2eff1b43f9d72306342f3f8b3ed5fb8908195d6f" +dependencies = [ + "proc-macro2", + "quote", + "unicode-xid", +] + +[[package]] +name = "time" +version = "0.2.26" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08a8cbfbf47955132d0202d1662f49b2423ae35862aee471f3ba4b133358f372" +dependencies = [ + "const_fn", + "libc", + "standback", + "stdweb", + "time-macros", + "version_check", + "winapi", +] + +[[package]] +name = "time-macros" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "957e9c6e26f12cb6d0dd7fc776bb67a706312e7299aed74c8dd5b17ebb27e2f1" +dependencies = [ + "proc-macro-hack", + "time-macros-impl", +] + +[[package]] +name = "time-macros-impl" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e5c3be1edfad6027c69f5491cf4cb310d1a71ecd6af742788c6ff8bced86b8fa" +dependencies = [ + "proc-macro-hack", + "proc-macro2", + "quote", + "standback", + "syn", +] + +[[package]] +name = "typenum" +version = "1.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "879f6906492a7cd215bfa4cf595b600146ccfac0c79bcbd1f3000162af5e8b06" + +[[package]] +name = "unicode-segmentation" +version = "1.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bb0d2e7be6ae3a5fa87eed5fb451aff96f2573d2694942e40543ae0bbe19c796" + +[[package]] +name = "unicode-xid" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f7fe0bb3479651439c9112f72b6c505038574c9fbb575ed1bf3b797fa39dd564" + +[[package]] +name = "unindent" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f14ee04d9415b52b3aeab06258a3f07093182b88ba0f9b8d203f211a7a7d41c7" + +[[package]] +name = "vec_map" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f1bddf1187be692e79c5ffeab891132dfb0f236ed36a43c7ed39f1165ee20191" + +[[package]] +name = "version_check" +version = "0.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5fecdca9a5291cc2b8dcf7dc02453fee791a280f3743cb0905f8822ae463b3fe" + +[[package]] +name = "wasi" +version = "0.10.2+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fd6fbd9a79829dd1ad0cc20627bf1ed606756a7f77edff7b66b7064f9cb327c6" + +[[package]] +name = "wasm-bindgen" +version = "0.2.72" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8fe8f61dba8e5d645a4d8132dc7a0a66861ed5e1045d2c0ed940fab33bac0fbe" +dependencies = [ + "cfg-if 1.0.0", + "wasm-bindgen-macro", +] + +[[package]] +name = "wasm-bindgen-backend" +version = "0.2.72" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "046ceba58ff062da072c7cb4ba5b22a37f00a302483f7e2a6cdc18fedbdc1fd3" +dependencies = [ + "bumpalo", + "lazy_static", + "log", + "proc-macro2", + "quote", + "syn", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-macro" +version = "0.2.72" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ef9aa01d36cda046f797c57959ff5f3c615c9cc63997a8d545831ec7976819b" +dependencies = [ + "quote", + "wasm-bindgen-macro-support", +] + +[[package]] +name = "wasm-bindgen-macro-support" +version = "0.2.72" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "96eb45c1b2ee33545a813a92dbb53856418bf7eb54ab34f7f7ff1448a5b3735d" +dependencies = [ + "proc-macro2", + "quote", + "syn", + "wasm-bindgen-backend", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-shared" +version = "0.2.72" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b7148f4696fb4960a346eaa60bbfb42a1ac4ebba21f750f75fc1375b098d5ffa" + +[[package]] +name = "winapi" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" +dependencies = [ + "winapi-i686-pc-windows-gnu", + "winapi-x86_64-pc-windows-gnu", +] + +[[package]] +name = "winapi-i686-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" + +[[package]] +name = "winapi-x86_64-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" + +[[package]] +name = "xmlparser" +version = "0.13.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "114ba2b24d2167ef6d67d7d04c8cc86522b87f490025f39f0303b7db5bf5e3d8" diff --git a/native/Cargo.toml b/native/Cargo.toml new file mode 100644 index 0000000..2eac5fb --- /dev/null +++ b/native/Cargo.toml @@ -0,0 +1,15 @@ +[package] +name = "native" +version = "0.1.0" +authors = ["David Hoppenbrouwers "] +edition = "2018" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html +[lib] +name = "godot_rapier3d" +crate-type = ["cdylib"] + +[dependencies] +rapier3d = { version = "*", features = ["simd-nightly"] } +gdnative = "*" +lazy_static = "*" diff --git a/native/Makefile b/native/Makefile new file mode 100644 index 0000000..e334217 --- /dev/null +++ b/native/Makefile @@ -0,0 +1,20 @@ +TARGET_LINUX?=x86_64-unknown-linux-gnu +TARGET_OSX?=x86_64-apple-darwin +TARGET_WINDOWS?=x86_64-pc-windows-gnu +OUTPUT_DIR?=../addons/rapier3d/lib + + +default: release + +release: linux + +linux: + cargo build --quiet --target $(TARGET_LINUX) --release + cp target/$(TARGET_LINUX)/release/libgodot_rapier3d.so $(OUTPUT_DIR)/libgodot_rapier3d.so + +debug: + cargo build + cp target/debug/libgodot_rapier3d.so $(OUTPUT_DIR)/libgodot_rapier3d.so + +clean: + cargo clean diff --git a/native/src/body/kinematic.rs b/native/src/body/kinematic.rs new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/native/src/body/kinematic.rs @@ -0,0 +1 @@ + diff --git a/native/src/body/mod.rs b/native/src/body/mod.rs new file mode 100644 index 0000000..5e90e73 --- /dev/null +++ b/native/src/body/mod.rs @@ -0,0 +1,13 @@ +mod kinematic; +mod rigid; +mod r#static; + +pub use kinematic::*; +pub use r#static::*; +pub use rigid::*; + +use rapier3d::dynamics::RigidBodyHandle; + +pub trait Body { + fn handle(&self) -> Option; +} diff --git a/native/src/body/rigid.rs b/native/src/body/rigid.rs new file mode 100644 index 0000000..d35ddb3 --- /dev/null +++ b/native/src/body/rigid.rs @@ -0,0 +1,50 @@ +use crate::util::*; +use gdnative::api::World; +use gdnative::prelude::*; +use rapier3d::dynamics::{self, RigidBodyBuilder, RigidBodyHandle}; +use rapier3d::na::Isometry3; +use rapier3d::na::Quaternion; +use rapier3d::na::UnitQuaternion; + +#[derive(NativeClass)] +#[inherit(Spatial)] +pub struct RigidBody { + body: Option, +} + +#[methods] +impl RigidBody { + fn new(_owner: TRef) -> Self { + Self { body: None } + } + + #[export] + fn _enter_tree(&mut self, owner: TRef) { + assert!(self.body.is_none(), "Body handle is not None"); + let world = owner.get_world().expect("Failed to get World"); + let transform = owner.global_transform(); + let quat = transform.basis.to_quat(); + let quat = Quaternion::new(quat.r, quat.i, quat.j, quat.k); + let quat = UnitQuaternion::from_quaternion(quat); + let origin = vec_gd_to_na(transform.origin); + let isometry = Isometry3::from_parts(origin.into(), quat); + let body = RigidBodyBuilder::new_dynamic() + .position(isometry) + .build(); + self.body = Some(crate::add_rigid_body(world, body)); + } + + #[export] + fn _physics_process(&self, owner: TRef, _delta: f32) { + let body = self.body.expect("Body handle is None"); + let world = owner.get_world().expect("Failed to get World"); + let transform = crate::get_transform(&world, body).expect("Failed to get transform"); + owner.set_global_transform(transform); + } +} + +impl super::Body for RigidBody { + fn handle(&self) -> Option { + self.body + } +} diff --git a/native/src/body/static.rs b/native/src/body/static.rs new file mode 100644 index 0000000..0559326 --- /dev/null +++ b/native/src/body/static.rs @@ -0,0 +1,29 @@ +use gdnative::prelude::*; +use rapier3d::dynamics::{RigidBodyBuilder, RigidBodyHandle}; + +#[derive(NativeClass)] +#[inherit(Spatial)] +pub struct StaticBody { + body: Option, +} + +#[methods] +impl StaticBody { + fn new(owner: TRef) -> Self { + Self { body: None } + } + + #[export] + fn _enter_tree(&mut self, owner: TRef) { + assert!(self.body.is_none(), "Body handle is not None"); + let world = owner.get_world().expect("Failed to get World"); + let body = RigidBodyBuilder::new_static().build(); + self.body = Some(crate::add_rigid_body(world, body)); + } +} + +impl super::Body for StaticBody { + fn handle(&self) -> Option { + self.body + } +} diff --git a/native/src/collider/box.rs b/native/src/collider/box.rs new file mode 100644 index 0000000..256a274 --- /dev/null +++ b/native/src/collider/box.rs @@ -0,0 +1,49 @@ +use crate::body::*; +use crate::util::*; +use gdnative::api::Spatial; +use gdnative::prelude::*; +use rapier3d::geometry::{ColliderHandle, ColliderBuilder}; + +#[derive(NativeClass)] +#[inherit(Spatial)] +pub struct Box { + #[property] + extents: Vector3, + collider: Option, +} + +#[methods] +impl Box { + fn new(_owner: TRef) -> Self { + Self { + extents: Vector3::new(1.0, 1.0, 1.0), + collider: None, + } + } + + #[export] + fn _enter_tree(&mut self, owner: TRef) { + assert!(self.collider.is_none(), "Body handle is not None"); + if let Some(parent) = owner.get_parent() { + unsafe { + if let Some(parent) = parent.assume_safe().cast::() { + let handle = if let Some(parent) = parent.cast_instance::() { + parent.map(|s, _| s.handle()) + } else if let Some(parent) = parent.cast_instance::() { + parent.map(|s, _| s.handle()) + } else { + godot_warn!("Parent is not a Body"); + return; + }.unwrap().expect("Parent has no handle"); + let world = parent.get_world().expect("World is None"); + let collider = ColliderBuilder::cuboid(self.extents.x, self.extents.y, self.extents.z).build(); + self.collider = Some(crate::add_collider(&world, handle, collider).expect("Failed to add collider")); + } else { + godot_warn!("Parent is not a Spatial"); + } + } + } else { + godot_warn!("Colliders need to be attached to a Body") + } + } +} diff --git a/native/src/collider/mod.rs b/native/src/collider/mod.rs new file mode 100644 index 0000000..6b4a755 --- /dev/null +++ b/native/src/collider/mod.rs @@ -0,0 +1,3 @@ +mod r#box; + +pub use r#box::*; diff --git a/native/src/lib.rs b/native/src/lib.rs new file mode 100644 index 0000000..c94f9be --- /dev/null +++ b/native/src/lib.rs @@ -0,0 +1,145 @@ +#![allow(dead_code)] +#![allow(unused_imports)] + +mod body; +mod collider; +mod util; + +use gdnative::api::World; +use gdnative::prelude::*; +use lazy_static::lazy_static; +use rapier3d::dynamics::{IntegrationParameters, JointSet, RigidBodySet, RigidBody, RigidBodyHandle}; +use rapier3d::geometry::{BroadPhase, Collider, ColliderHandle, ColliderSet, NarrowPhase}; +use rapier3d::pipeline::PhysicsPipeline; +use std::collections::HashMap; +use std::sync::RwLock; + +use util::*; + +lazy_static! { + static ref WORLDS: RwLock, World3D>> = RwLock::new(HashMap::new()); +} + +struct World3D { + pipeline: PhysicsPipeline, + gravity: Vector3, + integration_parameters: IntegrationParameters, + broad_phase: BroadPhase, + narrow_phase: NarrowPhase, + bodies: RigidBodySet, + colliders: ColliderSet, + joints: JointSet, + physics_hooks: (), + event_handler: (), +} + +#[derive(NativeClass)] +#[inherit(Node)] +struct Rapier3D; + +#[methods] +impl Rapier3D { + fn new(_owner: TRef) -> Self { + Self + } + + #[export] + fn _physics_process(&mut self, owner: TRef, delta: f32) { + self.step(owner, delta); + } + + #[export] + fn step(&mut self, _owner: TRef, delta: f32) { + let mut worlds = WORLDS.write().expect("Failed to write to WORLDS"); + for world in worlds.values_mut() { + world.pipeline.step( + &vec_gd_to_na(world.gravity), + &world.integration_parameters, + &mut world.broad_phase, + &mut world.narrow_phase, + &mut world.bodies, + &mut world.colliders, + &mut world.joints, + &world.physics_hooks, + &world.event_handler, + ); + } + } +} + +macro_rules! get_worlds_mut { + () => { + WORLDS.write().expect("Failed to write WORLDS") + }; +} + +macro_rules! get_worlds { + () => { + WORLDS.read().expect("Failed to read WORLDS") + }; +} + +fn add_rigid_body(world: Ref, body: RigidBody) -> RigidBodyHandle { + get_worlds_mut!() + .entry(world) + .or_insert_with(create_world) + .bodies + .insert(body) +} + +fn add_collider( + world: &Ref, + body: RigidBodyHandle, + collider: Collider, +) -> Result { + let mut worlds = get_worlds_mut!(); + let world = worlds.get_mut(world).ok_or(())?; + Ok(world.colliders.insert(collider, body, &mut world.bodies)) +} + +fn create_world() -> World3D { + World3D { + pipeline: PhysicsPipeline::new(), + gravity: Vector3::new(0.0, -9.81, 0.0), + integration_parameters: IntegrationParameters::default(), + broad_phase: BroadPhase::new(), + narrow_phase: NarrowPhase::new(), + bodies: RigidBodySet::new(), + colliders: ColliderSet::new(), + joints: JointSet::new(), + // We ignore physics hooks and contact events for now. + physics_hooks: (), + event_handler: (), + } +} + +fn get_transform(world: &Ref, handle: RigidBodyHandle) -> Result { + let worlds = get_worlds!(); + let world = worlds.get(world).ok_or(())?; + let isometry = world.bodies.get(handle).map(|b| b.position()).ok_or(())?; + let rotation: rapier3d::na::Rotation3<_> = isometry.rotation.into(); + let mat = rotation.matrix(); + let basis = Basis { + elements: [ + Vector3::new(mat.m11, mat.m12, mat.m13), + Vector3::new(mat.m21, mat.m22, mat.m23), + Vector3::new(mat.m31, mat.m32, mat.m33), + ] + }; + let transform = Transform { + basis, + origin: vec_na_to_gd(isometry.translation.vector), + }; + Ok(transform) +} + +fn init(handle: InitHandle) { + handle.add_class::(); + handle.add_class::(); + handle.add_class::(); + handle.add_class::(); +} + +godot_gdnative_init!(_ as gd_rapier3d_gdnative_init); +godot_nativescript_init!(init as gd_rapier3d_nativescript_init); +godot_gdnative_terminate!(_ as gd_rapier3d_gdnative_terminate); diff --git a/native/src/util.rs b/native/src/util.rs new file mode 100644 index 0000000..63e3dd9 --- /dev/null +++ b/native/src/util.rs @@ -0,0 +1,10 @@ +use gdnative::prelude::Vector3; +use rapier3d::na; + +pub fn vec_gd_to_na(from: Vector3) -> na::Vector3 { + na::Vector3::new(from.x, from.y, from.z) +} + +pub fn vec_na_to_gd(from: na::Vector3) -> Vector3 { + Vector3::new(from.x, from.y, from.z) +} diff --git a/project.godot b/project.godot new file mode 100644 index 0000000..6256769 --- /dev/null +++ b/project.godot @@ -0,0 +1,67 @@ +; Engine configuration file. +; It's best edited using the editor UI and not directly, +; since the parameters that go here are not all obvious. +; +; Format: +; [section] ; section goes between [] +; param=value ; assign values to parameters + +config_version=4 + +_global_script_classes=[ { +"base": "Spatial", +"class": "BatchedMeshInstance", +"language": "NativeScript", +"path": "res://addons/3d_batcher/batched_mesh_instance.gdns" +}, { +"base": "Node", +"class": "BatchedMeshManager", +"language": "NativeScript", +"path": "res://addons/3d_batcher/batched_mesh_manager.gdns" +}, { +"base": "Node", +"class": "Rapier3D", +"language": "NativeScript", +"path": "res://addons/rapier3d/rapier3d.gdns" +}, { +"base": "Spatial", +"class": "Rapier3D_Box", +"language": "NativeScript", +"path": "res://addons/rapier3d/box.gdns" +}, { +"base": "Spatial", +"class": "Rapier3D_RigidBody", +"language": "NativeScript", +"path": "res://addons/rapier3d/rigid_body.gdns" +}, { +"base": "Spatial", +"class": "Rapier3D_StaticBody", +"language": "NativeScript", +"path": "res://addons/rapier3d/static_body.gdns" +} ] +_global_script_class_icons={ +"BatchedMeshInstance": "", +"BatchedMeshManager": "", +"Rapier3D": "", +"Rapier3D_Box": "", +"Rapier3D_RigidBody": "", +"Rapier3D_StaticBody": "" +} + +[application] + +config/name="Rapier3D" +config/description="Rapier3D physics for Godot" +run/main_scene="res://boxes.tscn" + +[autoload] + +BatchedMeshManager="*res://addons/3d_batcher/batched_mesh_manager.gdns" + +[editor_plugins] + +enabled=PoolStringArray( "3d_batcher" ) + +[rendering] + +environment/default_environment="res://default_env.tres" diff --git a/stats.gd b/stats.gd new file mode 100644 index 0000000..87e5713 --- /dev/null +++ b/stats.gd @@ -0,0 +1,32 @@ +extends Label + + +var file := File.new() +var sample_time := OS.get_ticks_msec() + + +func _enter_tree(): + var date := OS.get_datetime() + var eng := "rapier3d" if $"../../".use_rapier3d else "godot3d" + var name := "%s_%d-%d-%d_%d-%d-%d" % [eng, date.year, date.month, date.day, date.hour, date.minute, date.second] + var e := file.open("user://%s.txt" % name, File.WRITE) + assert(e == OK, "Failed to open stats file: %d" % e) + + +func _exit_tree(): + file.close() + + +func _physics_process(_delta: float) -> void: + var draw_calls = get_tree() \ + .root \ + .get_render_info(Viewport.RENDER_INFO_DRAW_CALLS_IN_FRAME) + var time := OS.get_ticks_msec() + var delta := time - sample_time + sample_time = time + text = "" + text += "\nFPS: %f" % (delta / 1000.0) + text += "\nTime per frame: %f" % (1000.0 / delta) + text += "\nFrame: %d" % Engine.get_physics_frames() + text += "\nDraw calls: %d" % draw_calls + file.store_line(str(delta))