Skip to content

Commit

Permalink
Initial test
Browse files Browse the repository at this point in the history
Rapier wins! At least with boxes...
  • Loading branch information
Demindiro committed Mar 23, 2021
0 parents commit e6fcb71
Show file tree
Hide file tree
Showing 35 changed files with 1,786 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
bin/
target/
lib/
logs/
8 changes: 8 additions & 0 deletions addons/3d_batcher/batched_mesh_instance.gdns
Original file line number Diff line number Diff line change
@@ -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"
9 changes: 9 additions & 0 deletions addons/3d_batcher/batched_mesh_manager.gdns
Original file line number Diff line number Diff line change
@@ -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"
23 changes: 23 additions & 0 deletions addons/3d_batcher/gd_3d_batcher.gdnlib
Original file line number Diff line number Diff line change
@@ -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=[ ]
Binary file added addons/3d_batcher/lib/gd_3d_batcher.dll
Binary file not shown.
Binary file added addons/3d_batcher/lib/libgd_3d_batcher.dylib
Binary file not shown.
Binary file added addons/3d_batcher/lib/libgd_3d_batcher.so
Binary file not shown.
7 changes: 7 additions & 0 deletions addons/3d_batcher/plugin.cfg
Original file line number Diff line number Diff line change
@@ -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"
17 changes: 17 additions & 0 deletions addons/3d_batcher/plugin.gd
Original file line number Diff line number Diff line change
@@ -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
8 changes: 8 additions & 0 deletions addons/rapier3d/box.gdns
Original file line number Diff line number Diff line change
@@ -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"
14 changes: 14 additions & 0 deletions addons/rapier3d/rapier3d.gdnlib
Original file line number Diff line number Diff line change
@@ -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=[ ]
8 changes: 8 additions & 0 deletions addons/rapier3d/rapier3d.gdns
Original file line number Diff line number Diff line change
@@ -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"
8 changes: 8 additions & 0 deletions addons/rapier3d/rigid_body.gdns
Original file line number Diff line number Diff line change
@@ -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"
1 change: 1 addition & 0 deletions addons/rapier3d/rustfmt.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
hard_tabs = true
9 changes: 9 additions & 0 deletions addons/rapier3d/static_body.gdns
Original file line number Diff line number Diff line change
@@ -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"
25 changes: 25 additions & 0 deletions box_godot.tscn
Original file line number Diff line number Diff line change
@@ -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 )
28 changes: 28 additions & 0 deletions box_rapier3d.tscn
Original file line number Diff line number Diff line change
@@ -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 )
24 changes: 24 additions & 0 deletions boxes.gd
Original file line number Diff line number Diff line change
@@ -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)
68 changes: 68 additions & 0 deletions boxes.tscn
Original file line number Diff line number Diff line change
@@ -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
}
8 changes: 8 additions & 0 deletions default_env.tres
Original file line number Diff line number Diff line change
@@ -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
25 changes: 25 additions & 0 deletions export_presets.cfg
Original file line number Diff line number Diff line change
@@ -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=""
Empty file added native/.gdignore
Empty file.
Loading

0 comments on commit e6fcb71

Please sign in to comment.