Merge pull request #638 from nekomatata/physics-tests-4.0-conversion

Convert physics test projects to 4.0
This commit is contained in:
Camille Mohr-Daurat
2021-12-07 09:21:00 -07:00
committed by GitHub
89 changed files with 2687 additions and 2885 deletions

View File

@@ -1,8 +1,9 @@
[remap]
importer="texture"
type="StreamTexture"
path="res://.import/godot-head.png-6a90da7ab6a8c80b4170f240c8e33e70.stex"
type="StreamTexture2D"
uid="uid://c5duuyhbmd0m4"
path="res://.godot/imported/godot-head.png-6a90da7ab6a8c80b4170f240c8e33e70.stex"
metadata={
"vram_texture": false
}
@@ -10,26 +11,25 @@ metadata={
[deps]
source_file="res://assets/texture/godot-head.png"
dest_files=[ "res://.import/godot-head.png-6a90da7ab6a8c80b4170f240c8e33e70.stex" ]
dest_files=["res://.godot/imported/godot-head.png-6a90da7ab6a8c80b4170f240c8e33e70.stex"]
[params]
compress/mode=0
compress/lossy_quality=0.7
compress/hdr_mode=0
compress/hdr_compression=1
compress/bptc_ldr=0
compress/normal_map=0
flags/repeat=0
flags/filter=true
flags/mipmaps=false
flags/anisotropic=false
flags/srgb=2
compress/channel_pack=0
compress/streamed=false
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/HDR_as_SRGB=false
process/invert_color=false
process/normal_map_invert_y=false
stream=false
size_limit=0
detect_3d=true
process/HDR_as_SRGB=false
process/size_limit=0
detect_3d/compress_to=1
svg/scale=1.0

View File

@@ -1,8 +1,9 @@
[remap]
importer="texture"
type="StreamTexture"
path="res://.import/tiles_demo.png-4d398d5cc02bc85a2809dc13fbc9a3c2.stex"
type="StreamTexture2D"
uid="uid://1nmxl2dgdqro"
path="res://.godot/imported/tiles_demo.png-4d398d5cc02bc85a2809dc13fbc9a3c2.stex"
metadata={
"vram_texture": false
}
@@ -10,26 +11,25 @@ metadata={
[deps]
source_file="res://assets/tileset/tiles_demo.png"
dest_files=[ "res://.import/tiles_demo.png-4d398d5cc02bc85a2809dc13fbc9a3c2.stex" ]
dest_files=["res://.godot/imported/tiles_demo.png-4d398d5cc02bc85a2809dc13fbc9a3c2.stex"]
[params]
compress/mode=0
compress/lossy_quality=0.7
compress/hdr_mode=0
compress/hdr_compression=1
compress/bptc_ldr=0
compress/normal_map=0
flags/repeat=0
flags/filter=true
flags/mipmaps=false
flags/anisotropic=false
flags/srgb=2
compress/channel_pack=0
compress/streamed=false
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/HDR_as_SRGB=false
process/invert_color=false
process/normal_map_invert_y=false
stream=false
size_limit=0
detect_3d=true
process/HDR_as_SRGB=false
process/size_limit=0
detect_3d/compress_to=1
svg/scale=1.0

View File

@@ -1,335 +1,21 @@
[gd_resource type="TileSet" load_steps=14 format=2]
[gd_resource type="TileSet" load_steps=3 format=3 uid="uid://rgfdpxlejxl3"]
[ext_resource path="res://assets/tileset/tiles_demo.png" type="Texture" id=1]
[ext_resource type="Texture2D" uid="uid://1nmxl2dgdqro" path="res://assets/tileset/tiles_demo.png" id="1"]
[sub_resource type="ConvexPolygonShape2D" id=1]
points = PoolVector2Array( 0, 6, 32, 6, 32, 32, 0, 32 )
[sub_resource type="ConvexPolygonShape2D" id=2]
points = PoolVector2Array( 0, 6, 28, 6, 28, 32, 0, 32 )
[sub_resource type="ConvexPolygonShape2D" id=3]
points = PoolVector2Array( 0, 0, 32, 0, 32, 32, 0, 32 )
[sub_resource type="ConvexPolygonShape2D" id=4]
points = PoolVector2Array( 0, 6, 32, 6, 32, 32, 0, 32 )
[sub_resource type="ConvexPolygonShape2D" id=5]
points = PoolVector2Array( 32, 38, 32, 64, 0, 64, 0, 6 )
[sub_resource type="ConvexPolygonShape2D" id=6]
points = PoolVector2Array( 0, 0, 28, 0, 28, 32, 0, 32 )
[sub_resource type="ConvexPolygonShape2D" id=7]
points = PoolVector2Array( 28, 6, 32, 6, 32, 32, 0, 32, 0, 0, 28, 0 )
[sub_resource type="ConvexPolygonShape2D" id=8]
points = PoolVector2Array( 0, 6, 32, 6, 32, 32, 0, 32 )
[sub_resource type="ConvexPolygonShape2D" id=9]
points = PoolVector2Array( 0, 6, 28, 6, 28, 32, 0, 32 )
[sub_resource type="ConvexPolygonShape2D" id=10]
points = PoolVector2Array( 0, 0, 32, 0, 32, 32, 0, 32 )
[sub_resource type="ConvexPolygonShape2D" id=11]
points = PoolVector2Array( 0, 0, 32, 0, 32, 24, 0, 24 )
[sub_resource type="ConvexPolygonShape2D" id=12]
points = PoolVector2Array( 0, 0, 28, 0, 28, 24, 0, 24 )
[sub_resource type="TileSetAtlasSource" id="TileSetAtlasSource_4jjf0"]
texture = ExtResource( "1" )
0:0/next_alternative_id = 8
0:0/0 = 0
0:0/0/modulate = Color(0, 0, 1, 1)
0:0/0/physics_layer_0/linear_velocity = Vector2(0, 0)
0:0/0/physics_layer_0/angular_velocity = 0.0
0:0/0/physics_layer_0/polygon_0/points = PackedVector2Array(-8, -8, 8, -8, 8, 8, -8, 8)
1:0/0 = 0
1:0/0/physics_layer_0/linear_velocity = Vector2(0, 0)
1:0/0/physics_layer_0/angular_velocity = 0.0
1:0/0/physics_layer_0/polygon_0/points = PackedVector2Array(-8, -8, 8, -8, 8, 8, -8, 8)
1:0/0/physics_layer_0/polygon_0/one_way = true
[resource]
0/name = "ground"
0/texture = ExtResource( 1 )
0/tex_offset = Vector2( 0, 0 )
0/modulate = Color( 0, 0, 1, 1 )
0/region = Rect2( 0, 0, 32, 32 )
0/tile_mode = 0
0/occluder_offset = Vector2( 0, 0 )
0/navigation_offset = Vector2( 0, 0 )
0/shape_offset = Vector2( 0, 0 )
0/shape_transform = Transform2D( 1, 0, 0, 1, 0, 0 )
0/shape = SubResource( 1 )
0/shape_one_way = false
0/shape_one_way_margin = 1.0
0/shapes = [ {
"autotile_coord": Vector2( 0, 0 ),
"one_way": false,
"one_way_margin": 1.0,
"shape": SubResource( 1 ),
"shape_transform": Transform2D( 1, 0, 0, 1, 0, 0 )
} ]
0/z_index = 0
1/name = "ground_end"
1/texture = ExtResource( 1 )
1/tex_offset = Vector2( 0, 0 )
1/modulate = Color( 1, 1, 1, 1 )
1/region = Rect2( 32, 0, 32, 32 )
1/tile_mode = 0
1/occluder_offset = Vector2( 0, 0 )
1/navigation_offset = Vector2( 0, 0 )
1/shape_offset = Vector2( 0, 0 )
1/shape_transform = Transform2D( 1, 0, 0, 1, 0, 0 )
1/shape = SubResource( 2 )
1/shape_one_way = false
1/shape_one_way_margin = 1.0
1/shapes = [ {
"autotile_coord": Vector2( 0, 0 ),
"one_way": false,
"one_way_margin": 1.0,
"shape": SubResource( 2 ),
"shape_transform": Transform2D( 1, 0, 0, 1, 0, 0 )
} ]
1/z_index = 0
2/name = "slope"
2/texture = ExtResource( 1 )
2/tex_offset = Vector2( 0, 0 )
2/modulate = Color( 1, 1, 1, 1 )
2/region = Rect2( 64, 64, 32, 64 )
2/tile_mode = 0
2/occluder_offset = Vector2( 0, 0 )
2/navigation_offset = Vector2( 0, 0 )
2/shape_offset = Vector2( 0, 0 )
2/shape_transform = Transform2D( 1, 0, 0, 1, 0, 0 )
2/shape = SubResource( 5 )
2/shape_one_way = false
2/shape_one_way_margin = 1.0
2/shapes = [ {
"autotile_coord": Vector2( 0, 0 ),
"one_way": false,
"one_way_margin": 1.0,
"shape": SubResource( 5 ),
"shape_transform": Transform2D( 1, 0, 0, 1, 0, 0 )
} ]
2/z_index = 0
3/name = "wall"
3/texture = ExtResource( 1 )
3/tex_offset = Vector2( 0, 0 )
3/modulate = Color( 1, 1, 1, 1 )
3/region = Rect2( 32, 32, 32, 32 )
3/tile_mode = 0
3/occluder_offset = Vector2( 0, 0 )
3/navigation_offset = Vector2( 0, 0 )
3/shape_offset = Vector2( 0, 0 )
3/shape_transform = Transform2D( 1, 0, 0, 1, 0, 0 )
3/shape = SubResource( 6 )
3/shape_one_way = false
3/shape_one_way_margin = 1.0
3/shapes = [ {
"autotile_coord": Vector2( 0, 0 ),
"one_way": false,
"one_way_margin": 1.0,
"shape": SubResource( 6 ),
"shape_transform": Transform2D( 1, 0, 0, 1, 0, 0 )
} ]
3/z_index = 0
4/name = "slope_top"
4/texture = ExtResource( 1 )
4/tex_offset = Vector2( 0, 0 )
4/modulate = Color( 1, 1, 1, 1 )
4/region = Rect2( 32, 64, 32, 32 )
4/tile_mode = 0
4/occluder_offset = Vector2( 0, 0 )
4/navigation_offset = Vector2( 0, 0 )
4/shape_offset = Vector2( 0, 0 )
4/shape_transform = Transform2D( 1, 0, 0, 1, 0, 0 )
4/shape = SubResource( 7 )
4/shape_one_way = false
4/shape_one_way_margin = 1.0
4/shapes = [ {
"autotile_coord": Vector2( 0, 0 ),
"one_way": false,
"one_way_margin": 1.0,
"shape": SubResource( 7 ),
"shape_transform": Transform2D( 1, 0, 0, 1, 0, 0 )
} ]
4/z_index = 0
5/name = "one_way"
5/texture = ExtResource( 1 )
5/tex_offset = Vector2( 0, 0 )
5/modulate = Color( 1, 1, 1, 1 )
5/region = Rect2( 64, 0, 32, 32 )
5/tile_mode = 0
5/occluder_offset = Vector2( 0, 0 )
5/navigation_offset = Vector2( 0, 0 )
5/shape_offset = Vector2( 0, 0 )
5/shape_transform = Transform2D( 1, 0, 0, 1, 0, 0 )
5/shape = SubResource( 8 )
5/shape_one_way = true
5/shape_one_way_margin = 1.0
5/shapes = [ {
"autotile_coord": Vector2( 0, 0 ),
"one_way": true,
"one_way_margin": 1.0,
"shape": SubResource( 8 ),
"shape_transform": Transform2D( 1, 0, 0, 1, 0, 0 )
} ]
5/z_index = 0
6/name = "one_way_end"
6/texture = ExtResource( 1 )
6/tex_offset = Vector2( 0, 0 )
6/modulate = Color( 1, 1, 1, 1 )
6/region = Rect2( 96, 0, 32, 32 )
6/tile_mode = 0
6/occluder_offset = Vector2( 0, 0 )
6/navigation_offset = Vector2( 0, 0 )
6/shape_offset = Vector2( 0, 0 )
6/shape_transform = Transform2D( 1, 0, 0, 1, 0, 0 )
6/shape = SubResource( 9 )
6/shape_one_way = true
6/shape_one_way_margin = 1.0
6/shapes = [ {
"autotile_coord": Vector2( 0, 0 ),
"one_way": true,
"one_way_margin": 1.0,
"shape": SubResource( 9 ),
"shape_transform": Transform2D( 1, 0, 0, 1, 0, 0 )
} ]
6/z_index = 0
7/name = "rock"
7/texture = ExtResource( 1 )
7/tex_offset = Vector2( 0, 0 )
7/modulate = Color( 1, 1, 1, 1 )
7/region = Rect2( 0, 32, 32, 32 )
7/tile_mode = 0
7/occluder_offset = Vector2( 0, 0 )
7/navigation_offset = Vector2( 0, 0 )
7/shape_offset = Vector2( 0, 0 )
7/shape_transform = Transform2D( 1, 0, 0, 1, 0, 0 )
7/shape = SubResource( 10 )
7/shape_one_way = false
7/shape_one_way_margin = 1.0
7/shapes = [ {
"autotile_coord": Vector2( 0, 0 ),
"one_way": false,
"one_way_margin": 1.0,
"shape": SubResource( 10 ),
"shape_transform": Transform2D( 1, 0, 0, 1, 0, 0 )
} ]
7/z_index = 0
8/name = "bottom"
8/texture = ExtResource( 1 )
8/tex_offset = Vector2( 0, 0 )
8/modulate = Color( 1, 1, 1, 1 )
8/region = Rect2( 192, 32, 32, 32 )
8/tile_mode = 0
8/occluder_offset = Vector2( 0, 0 )
8/navigation_offset = Vector2( 0, 0 )
8/shape_offset = Vector2( 0, 0 )
8/shape_transform = Transform2D( 1, 0, 0, 1, 0, 0 )
8/shape = SubResource( 11 )
8/shape_one_way = false
8/shape_one_way_margin = 1.0
8/shapes = [ {
"autotile_coord": Vector2( 0, 0 ),
"one_way": false,
"one_way_margin": 1.0,
"shape": SubResource( 11 ),
"shape_transform": Transform2D( 1, 0, 0, 1, 0, 0 )
} ]
8/z_index = 0
9/name = "bottom_end"
9/texture = ExtResource( 1 )
9/tex_offset = Vector2( 0, 0 )
9/modulate = Color( 1, 1, 1, 1 )
9/region = Rect2( 224, 32, 32, 32 )
9/tile_mode = 0
9/occluder_offset = Vector2( 0, 0 )
9/navigation_offset = Vector2( 0, 0 )
9/shape_offset = Vector2( 0, 0 )
9/shape_transform = Transform2D( 1, 0, 0, 1, 0, 0 )
9/shape = SubResource( 12 )
9/shape_one_way = false
9/shape_one_way_margin = 1.0
9/shapes = [ {
"autotile_coord": Vector2( 0, 0 ),
"one_way": false,
"one_way_margin": 1.0,
"shape": SubResource( 12 ),
"shape_transform": Transform2D( 1, 0, 0, 1, 0, 0 )
} ]
9/z_index = 0
10/name = "bottom_corner"
10/texture = ExtResource( 1 )
10/tex_offset = Vector2( 0, 0 )
10/modulate = Color( 1, 1, 1, 1 )
10/region = Rect2( 160, 32, 32, 32 )
10/tile_mode = 0
10/occluder_offset = Vector2( 0, 0 )
10/navigation_offset = Vector2( 0, 0 )
10/shape_offset = Vector2( 0, 0 )
10/shape_transform = Transform2D( 1, 0, 0, 1, 0, 0 )
10/shape = SubResource( 3 )
10/shape_one_way = false
10/shape_one_way_margin = 1.0
10/shapes = [ {
"autotile_coord": Vector2( 0, 0 ),
"one_way": false,
"one_way_margin": 1.0,
"shape": SubResource( 3 ),
"shape_transform": Transform2D( 1, 0, 0, 1, 0, 0 )
} ]
10/z_index = 0
11/name = "tree_trunk_0"
11/texture = ExtResource( 1 )
11/tex_offset = Vector2( 0, 0 )
11/modulate = Color( 1, 1, 1, 1 )
11/region = Rect2( 128, 64, 32, 32 )
11/tile_mode = 0
11/occluder_offset = Vector2( 0, 0 )
11/navigation_offset = Vector2( 0, 0 )
11/shape_offset = Vector2( 0, 0 )
11/shape_transform = Transform2D( 1, 0, 0, 1, 0, 0 )
11/shape_one_way = false
11/shape_one_way_margin = 0.0
11/shapes = [ ]
11/z_index = 0
12/name = "tree_trunk_1"
12/texture = ExtResource( 1 )
12/tex_offset = Vector2( 0, 0 )
12/modulate = Color( 1, 1, 1, 1 )
12/region = Rect2( 128, 32, 32, 32 )
12/tile_mode = 0
12/occluder_offset = Vector2( 0, 0 )
12/navigation_offset = Vector2( 0, 0 )
12/shape_offset = Vector2( 0, 0 )
12/shape_transform = Transform2D( 1, 0, 0, 1, 0, 0 )
12/shape_one_way = false
12/shape_one_way_margin = 0.0
12/shapes = [ ]
12/z_index = 0
13/name = "tree_base"
13/texture = ExtResource( 1 )
13/tex_offset = Vector2( 0, 0 )
13/modulate = Color( 1, 1, 1, 1 )
13/region = Rect2( 128, 96, 32, 32 )
13/tile_mode = 0
13/occluder_offset = Vector2( 0, 0 )
13/navigation_offset = Vector2( 0, 0 )
13/shape_offset = Vector2( 0, 0 )
13/shape_transform = Transform2D( 1, 0, 0, 1, 0, 0 )
13/shape = SubResource( 4 )
13/shape_one_way = false
13/shape_one_way_margin = 1.0
13/shapes = [ {
"autotile_coord": Vector2( 0, 0 ),
"one_way": false,
"one_way_margin": 1.0,
"shape": SubResource( 4 ),
"shape_transform": Transform2D( 1, 0, 0, 1, 0, 0 )
} ]
13/z_index = 0
14/name = "tree_top"
14/texture = ExtResource( 1 )
14/tex_offset = Vector2( 0, 0 )
14/modulate = Color( 1, 1, 1, 1 )
14/region = Rect2( 128, 0, 32, 32 )
14/tile_mode = 0
14/occluder_offset = Vector2( 0, 0 )
14/navigation_offset = Vector2( 0, 0 )
14/shape_offset = Vector2( 0, 0 )
14/shape_transform = Transform2D( 1, 0, 0, 1, 0, 0 )
14/shape_one_way = false
14/shape_one_way_margin = 0.0
14/shapes = [ ]
14/z_index = 0
physics_layer_0/collision_layer = 1
sources/0 = SubResource( "TileSetAtlasSource_4jjf0" )

View File

@@ -1,8 +1,9 @@
[remap]
importer="texture"
type="StreamTexture"
path="res://.import/icon.png-487276ed1e3a0c39cad0279d744ee560.stex"
type="StreamTexture2D"
uid="uid://cpps5r8o4dfwo"
path="res://.godot/imported/icon.png-487276ed1e3a0c39cad0279d744ee560.stex"
metadata={
"vram_texture": false
}
@@ -10,26 +11,25 @@ metadata={
[deps]
source_file="res://icon.png"
dest_files=[ "res://.import/icon.png-487276ed1e3a0c39cad0279d744ee560.stex" ]
dest_files=["res://.godot/imported/icon.png-487276ed1e3a0c39cad0279d744ee560.stex"]
[params]
compress/mode=0
compress/lossy_quality=0.7
compress/hdr_mode=0
compress/hdr_compression=1
compress/bptc_ldr=0
compress/normal_map=0
flags/repeat=0
flags/filter=true
flags/mipmaps=false
flags/anisotropic=false
flags/srgb=2
compress/channel_pack=0
compress/streamed=false
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/HDR_as_SRGB=false
process/invert_color=false
process/normal_map_invert_y=false
stream=false
size_limit=0
detect_3d=true
process/HDR_as_SRGB=false
process/size_limit=0
detect_3d/compress_to=1
svg/scale=1.0

View File

@@ -1,132 +1,124 @@
[gd_scene load_steps=11 format=2]
[gd_scene load_steps=11 format=3 uid="uid://6a0nxwkgf5dq"]
[ext_resource path="res://utils/label_fps.gd" type="Script" id=1]
[ext_resource path="res://utils/label_version.gd" type="Script" id=2]
[ext_resource path="res://utils/label_engine.gd" type="Script" id=3]
[ext_resource path="res://tests_menu.gd" type="Script" id=4]
[ext_resource path="res://utils/label_test.gd" type="Script" id=5]
[ext_resource path="res://utils/label_pause.gd" type="Script" id=6]
[ext_resource path="res://utils/container_log.gd" type="Script" id=10]
[ext_resource path="res://utils/scroll_log.gd" type="Script" id=11]
[ext_resource path="res://tests.gd" type="Script" id=12]
[ext_resource type="Script" path="res://utils/label_fps.gd" id="1"]
[ext_resource type="Script" path="res://utils/label_version.gd" id="2"]
[ext_resource type="Script" path="res://utils/label_engine.gd" id="3"]
[ext_resource type="Script" path="res://tests_menu.gd" id="4"]
[ext_resource type="Script" path="res://utils/label_test.gd" id="5"]
[ext_resource type="Script" path="res://utils/label_pause.gd" id="6"]
[ext_resource type="Script" path="res://utils/container_log.gd" id="10"]
[ext_resource type="Script" path="res://utils/scroll_log.gd" id="11"]
[ext_resource type="Script" path="res://tests.gd" id="12"]
[sub_resource type="StyleBoxFlat" id=1]
bg_color = Color( 0, 0, 0, 0.176471 )
[sub_resource type="StyleBoxFlat" id="1"]
bg_color = Color(0, 0, 0, 0.176471)
[node name="Main" type="Control"]
anchor_right = 1.0
anchor_bottom = 1.0
mouse_filter = 2
script = ExtResource( 12 )
script = ExtResource( "12" )
__meta__ = {
"_edit_use_anchors_": false
}
[node name="TestsMenu" type="MenuButton" parent="."]
pause_mode = 2
margin_left = 10.0
margin_top = 10.0
margin_right = 125.0
margin_bottom = 30.0
offset_left = 10.0
offset_top = 10.0
offset_right = 125.0
offset_bottom = 30.0
text = "TESTS"
flat = false
script = ExtResource( 4 )
script = ExtResource( "4" )
__meta__ = {
"_edit_use_anchors_": false
}
[node name="LabelControls" type="Label" parent="."]
pause_mode = 2
margin_left = 157.0
margin_top = 13.0
margin_right = 646.0
margin_bottom = 27.0
offset_left = 157.0
offset_top = 13.0
offset_right = 646.0
offset_bottom = 27.0
text = "P - TOGGLE PAUSE / R - RESTART / C - TOGGLE COLLISION / F - TOGGLE FULL SCREEN / ESC - QUIT"
__meta__ = {
"_edit_use_anchors_": false
}
[node name="LabelFPS" type="Label" parent="."]
pause_mode = 2
anchor_top = 1.0
anchor_bottom = 1.0
margin_left = 10.0
margin_top = -19.0
margin_right = 50.0
margin_bottom = -5.0
offset_left = 10.0
offset_top = -19.0
offset_right = 50.0
offset_bottom = -5.0
text = "FPS: 0"
script = ExtResource( 1 )
script = ExtResource( "1" )
__meta__ = {
"_edit_use_anchors_": false
}
[node name="LabelEngine" type="Label" parent="."]
pause_mode = 2
anchor_top = 1.0
anchor_bottom = 1.0
margin_left = 10.0
margin_top = -39.0
margin_right = 50.0
margin_bottom = -25.0
offset_left = 10.0
offset_top = -39.0
offset_right = 50.0
offset_bottom = -25.0
text = "Physics engine:"
script = ExtResource( 3 )
script = ExtResource( "3" )
__meta__ = {
"_edit_use_anchors_": false
}
[node name="LabelVersion" type="Label" parent="."]
pause_mode = 2
anchor_top = 1.0
anchor_bottom = 1.0
margin_left = 10.0
margin_top = -59.0
margin_right = 50.0
margin_bottom = -45.0
offset_left = 10.0
offset_top = -59.0
offset_right = 50.0
offset_bottom = -45.0
text = "Godot Version:"
script = ExtResource( 2 )
script = ExtResource( "2" )
__meta__ = {
"_edit_use_anchors_": false
}
[node name="LabelTest" type="Label" parent="."]
pause_mode = 2
anchor_top = 1.0
anchor_bottom = 1.0
margin_left = 10.0
margin_top = -79.0
margin_right = 50.0
margin_bottom = -65.0
offset_left = 10.0
offset_top = -79.0
offset_right = 50.0
offset_bottom = -65.0
text = "Test:"
script = ExtResource( 5 )
script = ExtResource( "5" )
__meta__ = {
"_edit_use_anchors_": false
}
[node name="LabelPause" type="Label" parent="."]
pause_mode = 2
anchor_left = 0.5
anchor_top = 1.0
anchor_right = 0.5
anchor_bottom = 1.0
margin_left = -20.0
margin_top = -40.9695
margin_right = 31.0
margin_bottom = -26.9695
offset_left = -20.0
offset_top = -40.9695
offset_right = 31.0
offset_bottom = -26.9695
text = "PAUSED"
script = ExtResource( 6 )
script = ExtResource( "6" )
__meta__ = {
"_edit_use_anchors_": false
}
[node name="PanelLog" type="Panel" parent="."]
pause_mode = 2
anchor_left = 1.0
anchor_top = 1.0
anchor_right = 1.0
anchor_bottom = 1.0
margin_left = -428.0
margin_top = -125.0
custom_styles/panel = SubResource( 1 )
offset_left = -428.0
offset_top = -125.0
theme_override_styles/panel = SubResource( "1" )
__meta__ = {
"_edit_use_anchors_": false
}
@@ -136,10 +128,10 @@ anchor_left = 1.0
anchor_top = 1.0
anchor_right = 1.0
anchor_bottom = 1.0
margin_left = -48.0
margin_top = -25.0
margin_right = -5.0
margin_bottom = -5.0
offset_left = -48.0
offset_top = -25.0
offset_right = -5.0
offset_bottom = -5.0
focus_mode = 0
text = "clear"
__meta__ = {
@@ -151,10 +143,10 @@ anchor_left = 1.0
anchor_top = 1.0
anchor_right = 1.0
anchor_bottom = 1.0
margin_left = -150.0
margin_top = -27.0
margin_right = -54.0
margin_bottom = -3.0
offset_left = -150.0
offset_top = -27.0
offset_right = -54.0
offset_bottom = -3.0
focus_mode = 0
pressed = true
text = "auto-scroll"
@@ -163,32 +155,31 @@ __meta__ = {
}
[node name="ScrollLog" type="ScrollContainer" parent="PanelLog"]
margin_left = 10.0
margin_top = 5.0
margin_right = 418.0
margin_bottom = 94.0
offset_left = 10.0
offset_top = 5.0
offset_right = 418.0
offset_bottom = 94.0
scroll_horizontal_enabled = false
script = ExtResource( 11 )
script = ExtResource( "11" )
__meta__ = {
"_edit_use_anchors_": false
}
auto_scroll = true
[node name="VBoxLog" type="VBoxContainer" parent="PanelLog/ScrollLog"]
margin_right = 408.0
margin_bottom = 89.0
offset_right = 408.0
offset_bottom = 89.0
size_flags_horizontal = 3
size_flags_vertical = 3
alignment = 2
script = ExtResource( 10 )
script = ExtResource( "10" )
[node name="LabelLog" type="Label" parent="PanelLog/ScrollLog/VBoxLog"]
margin_top = 75.0
margin_right = 408.0
margin_bottom = 89.0
offset_top = 63.0
offset_right = 408.0
offset_bottom = 89.0
text = "Log start"
valign = 2
autowrap = true
max_lines_visible = 5
__meta__ = {
"_edit_use_anchors_": false

View File

@@ -6,24 +6,24 @@
; [section] ; section goes between []
; param=value ; assign values to parameters
config_version=4
config_version=5
_global_script_classes=[ {
_global_script_classes=[{
"base": "MenuButton",
"class": "OptionMenu",
"language": "GDScript",
"class": &"OptionMenu",
"language": &"GDScript",
"path": "res://utils/option_menu.gd"
}, {
"base": "Node2D",
"class": "Test",
"language": "GDScript",
"class": &"Test",
"language": &"GDScript",
"path": "res://test.gd"
}, {
"base": "Test",
"class": "TestCharacter",
"language": "GDScript",
"class": &"TestCharacter",
"language": &"GDScript",
"path": "res://tests/functional/test_character.gd"
} ]
}]
_global_script_class_icons={
"OptionMenu": "",
"Test": "",
@@ -33,14 +33,9 @@ _global_script_class_icons={
[application]
config/name="2D Physics Tests"
config/description="This demo contains a series of tests for the 2D physics engine.
They can be used for different purpose:
- Functional tests to check for regressions and behavior of the 2D physics engine
- Performance tests to evaluate performance of the 2D physics engine"
run/main_scene="res://main.tscn"
config/icon="res://icon.png"
config/features=PackedStringArray("4.0")
[autoload]
@@ -54,69 +49,69 @@ gdscript/warnings/return_value_discarded=false
[display]
window/dpi/allow_hidpi=true
window/stretch/mode="2d"
window/stretch/mode="canvas_items"
window/stretch/aspect="expand"
[input]
ui_left={
"deadzone": 0.5,
"events": [ ]
"events": []
}
ui_right={
"deadzone": 0.5,
"events": [ ]
"events": []
}
ui_up={
"deadzone": 0.5,
"events": [ ]
"events": []
}
ui_down={
"deadzone": 0.5,
"events": [ ]
"events": []
}
toggle_full_screen={
"deadzone": 0.5,
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":70,"physical_scancode":0,"unicode":0,"echo":false,"script":null)
]
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"store_command":true,"alt_pressed":false,"shift_pressed":false,"meta_pressed":false,"command_pressed":false,"pressed":false,"keycode":70,"physical_keycode":0,"unicode":0,"echo":false,"script":null)
]
}
exit={
"deadzone": 0.5,
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":16777217,"physical_scancode":0,"unicode":0,"echo":false,"script":null)
]
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"store_command":true,"alt_pressed":false,"shift_pressed":false,"meta_pressed":false,"command_pressed":false,"pressed":false,"keycode":16777217,"physical_keycode":0,"unicode":0,"echo":false,"script":null)
]
}
toggle_debug_collision={
"deadzone": 0.5,
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":67,"physical_scancode":0,"unicode":0,"echo":false,"script":null)
]
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"store_command":true,"alt_pressed":false,"shift_pressed":false,"meta_pressed":false,"command_pressed":false,"pressed":false,"keycode":67,"physical_keycode":0,"unicode":0,"echo":false,"script":null)
]
}
restart_test={
"deadzone": 0.5,
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":82,"physical_scancode":0,"unicode":0,"echo":false,"script":null)
]
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"store_command":true,"alt_pressed":false,"shift_pressed":false,"meta_pressed":false,"command_pressed":false,"pressed":false,"keycode":82,"physical_keycode":0,"unicode":0,"echo":false,"script":null)
]
}
toggle_pause={
"deadzone": 0.5,
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":80,"physical_scancode":0,"unicode":0,"echo":false,"script":null)
]
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"store_command":true,"alt_pressed":false,"shift_pressed":false,"meta_pressed":false,"command_pressed":false,"pressed":false,"keycode":80,"physical_keycode":0,"unicode":0,"echo":false,"script":null)
]
}
character_left={
"deadzone": 0.5,
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":16777231,"physical_scancode":0,"unicode":0,"echo":false,"script":null)
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":65,"physical_scancode":0,"unicode":0,"echo":false,"script":null)
]
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"store_command":true,"alt_pressed":false,"shift_pressed":false,"meta_pressed":false,"command_pressed":false,"pressed":false,"keycode":16777231,"physical_keycode":0,"unicode":0,"echo":false,"script":null)
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"store_command":true,"alt_pressed":false,"shift_pressed":false,"meta_pressed":false,"command_pressed":false,"pressed":false,"keycode":65,"physical_keycode":0,"unicode":0,"echo":false,"script":null)
]
}
character_right={
"deadzone": 0.5,
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":16777233,"physical_scancode":0,"unicode":0,"echo":false,"script":null)
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":68,"physical_scancode":0,"unicode":0,"echo":false,"script":null)
]
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"store_command":true,"alt_pressed":false,"shift_pressed":false,"meta_pressed":false,"command_pressed":false,"pressed":false,"keycode":16777233,"physical_keycode":0,"unicode":0,"echo":false,"script":null)
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"store_command":true,"alt_pressed":false,"shift_pressed":false,"meta_pressed":false,"command_pressed":false,"pressed":false,"keycode":68,"physical_keycode":0,"unicode":0,"echo":false,"script":null)
]
}
character_jump={
"deadzone": 0.5,
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":16777232,"physical_scancode":0,"unicode":0,"echo":false,"script":null)
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":87,"physical_scancode":0,"unicode":0,"echo":false,"script":null)
]
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"store_command":true,"alt_pressed":false,"shift_pressed":false,"meta_pressed":false,"command_pressed":false,"pressed":false,"keycode":16777232,"physical_keycode":0,"unicode":0,"echo":false,"script":null)
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"store_command":true,"alt_pressed":false,"shift_pressed":false,"meta_pressed":false,"command_pressed":false,"pressed":false,"keycode":87,"physical_keycode":0,"unicode":0,"echo":false,"script":null)
]
}
[memory]
@@ -128,5 +123,5 @@ limits/message_queue/max_size_kb=10240
quality/driver/driver_name="GLES2"
vram_compression/import_etc=true
vram_compression/import_etc2=false
environment/default_clear_color=Color( 0.184314, 0.184314, 0.184314, 1 )
environment/default_clear_color=Color(0.184314, 0.184314, 0.184314, 1)
quality/filters/msaa=2

View File

@@ -4,7 +4,7 @@ extends Node2D
signal wait_done()
export var _enable_debug_collision = true
@export var _enable_debug_collision = true
var _timer
var _timer_started = false
@@ -53,10 +53,10 @@ func add_circle(pos, radius, color):
add_child(circle)
func add_shape(shape, transform, color):
func add_shape(shape, shape_transform, color):
var collision = CollisionShape2D.new()
collision.shape = shape
collision.transform = transform
collision.transform = shape_transform
collision.modulate = color
_drawn_nodes.push_back(collision)
add_child(collision)
@@ -68,12 +68,12 @@ func clear_drawn_nodes():
_drawn_nodes.clear()
func create_rigidbody(shape, pickable = false, transform = Transform.IDENTITY):
func create_rigidbody(shape, pickable = false, shape_transform = Transform2D.IDENTITY):
var collision = CollisionShape2D.new()
collision.shape = shape
collision.transform = transform
collision.transform = shape_transform
var body = RigidBody2D.new()
var body = RigidDynamicBody2D.new()
body.add_child(collision)
if pickable:
@@ -83,15 +83,15 @@ func create_rigidbody(shape, pickable = false, transform = Transform.IDENTITY):
return body
func create_rigidbody_box(size, pickable = false, use_icon = false, transform = Transform.IDENTITY):
func create_rigidbody_box(size, pickable = false, use_icon = false, shape_transform = Transform2D.IDENTITY):
var shape = RectangleShape2D.new()
shape.extents = 0.5 * size
shape.size = size
var body = create_rigidbody(shape, pickable, transform)
var body = create_rigidbody(shape, pickable, shape_transform)
if use_icon:
var texture = load("res://icon.png")
var icon = Sprite.new()
var icon = Sprite2D.new()
icon.texture = texture
icon.scale = size / texture.get_size()
body.add_child(icon)
@@ -104,7 +104,7 @@ func start_timer(timeout):
_timer = Timer.new()
_timer.one_shot = true
add_child(_timer)
_timer.connect("timeout", self, "_on_timer_done")
_timer.connect("timeout", Callable(self, "_on_timer_done"))
else:
cancel_timer()

View File

@@ -1,10 +1,10 @@
[gd_scene load_steps=2 format=2]
[gd_scene load_steps=2 format=3 uid="uid://gk0nqu0jrwm"]
[sub_resource type="RectangleShape2D" id=1]
extents = Vector2( 20, 20 )
[sub_resource type="RectangleShape2D" id="1"]
size = Vector2(40, 40)
[node name="StackBox" type="RigidBody2D"]
position = Vector2( -180, -20 )
[node name="StackBox" type="RigidDynamicBody2D"]
position = Vector2(-180, -20)
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
shape = SubResource( 1 )
shape = SubResource( "1" )

View File

@@ -3,66 +3,86 @@ class_name TestCharacter
enum E_BodyType {
CHARACTER_BODY,
CHARACTER_BODY_RAY,
RIGID_BODY,
KINEMATIC_BODY,
KINEMATIC_BODY_RAY_SHAPE,
RIGID_BODY_RAY,
}
const OPTION_OBJECT_TYPE_RIGIDBODY = "Object type/Rigid body (1)"
const OPTION_OBJECT_TYPE_KINEMATIC = "Object type/Kinematic body (2)"
const OPTION_OBJECT_TYPE_KINEMATIC_RAYSHAPE = "Object type/Kinematic body with ray shape (3)"
const OPTION_OBJECT_TYPE_CHARACTER = "Object type/Character body (1)"
const OPTION_OBJECT_TYPE_CHARACTER_RAY = "Object type/Character body with ray (2)"
const OPTION_OBJECT_TYPE_RIGID_BODY = "Object type/Rigid body (3)"
const OPTION_OBJECT_TYPE_RIGID_BODY_RAY = "Object type/Rigid body with ray (4)"
const OPTION_MOVE_KINEMATIC_SNAP = "Move Options/Use snap (Kinematic only)"
const OPTION_MOVE_KINEMATIC_STOP_ON_SLOPE = "Move Options/Use stop on slope (Kinematic only)"
const OPTION_MOVE_CHARACTER_SNAP = "Move Options/Use snap (Character only)"
const OPTION_MOVE_CHARACTER_STOP_ON_SLOPE = "Move Options/Use stop on slope (Character only)"
const OPTION_MOVE_CHARACTER_FLOOR_ONLY = "Move Options/Move on floor only (Character only)"
const OPTION_MOVE_CHARACTER_CONSTANT_SPEED = "Move Options/Use constant speed (Character only)"
export(Vector2) var _initial_velocity = Vector2.ZERO
export(Vector2) var _constant_velocity = Vector2.ZERO
export(float) var _motion_speed = 400.0
export(float) var _gravity_force = 50.0
export(float) var _jump_force = 1000.0
export(float) var _snap_distance = 0.0
export(float) var _floor_max_angle = 45.0
export(E_BodyType) var _body_type = 0
@export var _initial_velocity = Vector2.ZERO
@export var _constant_velocity = Vector2.ZERO
@export var _motion_speed = 400.0
@export var _gravity_force = 50.0
@export var _jump_force = 1000.0
@export var _snap_distance = 0.0
@export var _floor_max_angle = 45.0
@export var _body_type : E_BodyType = 0
onready var options = $Options
@onready var options = $Options
var _use_snap = true
var _use_stop_on_slope = true
var _use_floor_only = true
var _use_constant_speed = false
var _body_parent = null
var _body_parent : Node = null
var _character_body_template = null
var _character_body_ray_template = null
var _rigid_body_template = null
var _kinematic_body_template = null
var _kinematic_body_ray_template = null
var _moving_body = null
var _rigid_body_ray_template = null
var _moving_body : PhysicsBody2D = null
func _ready():
options.connect("option_selected", self, "_on_option_selected")
options.connect("option_changed", self, "_on_option_changed")
options.connect("option_selected", Callable(self, "_on_option_selected"))
options.connect("option_changed", Callable(self, "_on_option_changed"))
_character_body_template = find_node("CharacterBody2D")
if _character_body_template:
_body_parent = _character_body_template.get_parent()
_body_parent.remove_child(_character_body_template)
var enabled = _body_type == E_BodyType.CHARACTER_BODY
options.add_menu_item(OPTION_OBJECT_TYPE_CHARACTER, true, enabled, true)
_character_body_ray_template = find_node("CharacterBodyRay2D")
if _character_body_ray_template:
_body_parent = _character_body_ray_template.get_parent()
_body_parent.remove_child(_character_body_ray_template)
var enabled = _body_type == E_BodyType.CHARACTER_BODY_RAY
options.add_menu_item(OPTION_OBJECT_TYPE_CHARACTER_RAY, true, enabled, true)
_rigid_body_template = find_node("RigidBody2D")
if _rigid_body_template:
_body_parent = _rigid_body_template.get_parent()
_body_parent.remove_child(_rigid_body_template)
var enabled = _body_type == E_BodyType.RIGID_BODY
options.add_menu_item(OPTION_OBJECT_TYPE_RIGIDBODY, true, enabled, true)
options.add_menu_item(OPTION_OBJECT_TYPE_RIGID_BODY, true, enabled, true)
_kinematic_body_template = find_node("KinematicBody2D")
if _kinematic_body_template:
_body_parent = _kinematic_body_template.get_parent()
_body_parent.remove_child(_kinematic_body_template)
var enabled = _body_type == E_BodyType.KINEMATIC_BODY
options.add_menu_item(OPTION_OBJECT_TYPE_KINEMATIC, true, enabled, true)
_rigid_body_ray_template = find_node("RigidBodyRay2D")
if _rigid_body_ray_template:
_body_parent = _rigid_body_ray_template.get_parent()
_body_parent.remove_child(_rigid_body_ray_template)
var enabled = _body_type == E_BodyType.RIGID_BODY_RAY
options.add_menu_item(OPTION_OBJECT_TYPE_RIGID_BODY_RAY, true, enabled, true)
_kinematic_body_ray_template = find_node("KinematicBodyRay2D")
if _kinematic_body_ray_template:
_body_parent = _kinematic_body_ray_template.get_parent()
_body_parent.remove_child(_kinematic_body_ray_template)
var enabled = _body_type == E_BodyType.KINEMATIC_BODY_RAY_SHAPE
options.add_menu_item(OPTION_OBJECT_TYPE_KINEMATIC_RAYSHAPE, true, enabled, true)
options.add_menu_item(OPTION_MOVE_CHARACTER_SNAP, true, _use_snap)
options.add_menu_item(OPTION_MOVE_CHARACTER_STOP_ON_SLOPE, true, _use_stop_on_slope)
options.add_menu_item(OPTION_MOVE_CHARACTER_FLOOR_ONLY, true, _use_floor_only)
options.add_menu_item(OPTION_MOVE_CHARACTER_CONSTANT_SPEED, true, _use_constant_speed)
options.add_menu_item(OPTION_MOVE_KINEMATIC_SNAP, true, _use_snap)
options.add_menu_item(OPTION_MOVE_KINEMATIC_STOP_ON_SLOPE, true, _use_stop_on_slope)
var floor_slider = find_node("FloorMaxAngle")
if floor_slider:
floor_slider.get_node("HSlider").value = _floor_max_angle
_start_test()
@@ -72,10 +92,10 @@ func _process(_delta):
if _moving_body:
if _moving_body.is_on_floor():
label_floor.text = "ON FLOOR"
label_floor.self_modulate = Color.green
label_floor.self_modulate = Color.GREEN
else:
label_floor.text = "OFF FLOOR"
label_floor.self_modulate = Color.red
label_floor.self_modulate = Color.RED
else:
label_floor.visible = false
@@ -83,47 +103,74 @@ func _process(_delta):
func _input(event):
var key_event = event as InputEventKey
if key_event and not key_event.pressed:
if key_event.scancode == KEY_1:
if key_event.keycode == KEY_1:
if _character_body_template:
_on_option_selected(OPTION_OBJECT_TYPE_CHARACTER)
elif key_event.keycode == KEY_2:
if _character_body_ray_template:
_on_option_selected(OPTION_OBJECT_TYPE_CHARACTER_RAY)
elif key_event.keycode == KEY_3:
if _rigid_body_template:
_on_option_selected(OPTION_OBJECT_TYPE_RIGIDBODY)
elif key_event.scancode == KEY_2:
if _kinematic_body_template:
_on_option_selected(OPTION_OBJECT_TYPE_KINEMATIC)
elif key_event.scancode == KEY_3:
if _kinematic_body_ray_template:
_on_option_selected(OPTION_OBJECT_TYPE_KINEMATIC_RAYSHAPE)
_on_option_selected(OPTION_OBJECT_TYPE_RIGID_BODY)
elif key_event.keycode == KEY_4:
if _rigid_body_ray_template:
_on_option_selected(OPTION_OBJECT_TYPE_RIGID_BODY_RAY)
func _exit_tree():
if _character_body_template:
_character_body_template.free()
if _character_body_ray_template:
_character_body_ray_template.free()
if _rigid_body_template:
_rigid_body_template.free()
if _kinematic_body_template:
_kinematic_body_template.free()
if _kinematic_body_ray_template:
_kinematic_body_ray_template.free()
if _rigid_body_ray_template:
_rigid_body_ray_template.free()
func _on_option_selected(option):
match option:
OPTION_OBJECT_TYPE_RIGIDBODY:
OPTION_OBJECT_TYPE_CHARACTER:
_body_type = E_BodyType.CHARACTER_BODY
_start_test()
OPTION_OBJECT_TYPE_CHARACTER_RAY:
_body_type = E_BodyType.CHARACTER_BODY_RAY
_start_test()
OPTION_OBJECT_TYPE_RIGID_BODY:
_body_type = E_BodyType.RIGID_BODY
_start_test()
OPTION_OBJECT_TYPE_KINEMATIC:
_body_type = E_BodyType.KINEMATIC_BODY
_start_test()
OPTION_OBJECT_TYPE_KINEMATIC_RAYSHAPE:
_body_type = E_BodyType.KINEMATIC_BODY_RAY_SHAPE
OPTION_OBJECT_TYPE_RIGID_BODY_RAY:
_body_type = E_BodyType.RIGID_BODY_RAY
_start_test()
func _on_option_changed(option, checked):
match option:
OPTION_MOVE_KINEMATIC_SNAP:
OPTION_MOVE_CHARACTER_SNAP:
_use_snap = checked
_start_test()
OPTION_MOVE_KINEMATIC_STOP_ON_SLOPE:
if _moving_body and _moving_body is CharacterBody2D:
_moving_body._snap = _snap_distance if _use_snap else 0.0
OPTION_MOVE_CHARACTER_STOP_ON_SLOPE:
_use_stop_on_slope = checked
_start_test()
if _moving_body and _moving_body is CharacterBody2D:
_moving_body._stop_on_slope = _use_stop_on_slope
OPTION_MOVE_CHARACTER_FLOOR_ONLY:
_use_floor_only = checked
if _moving_body and _moving_body is CharacterBody2D:
_moving_body._move_on_floor_only = _use_floor_only
OPTION_MOVE_CHARACTER_CONSTANT_SPEED:
_use_constant_speed = checked
if _moving_body and _moving_body is CharacterBody2D:
_moving_body._constant_speed = _use_constant_speed
func _update_floor_max_angle(value):
if (value == _floor_max_angle):
return
_floor_max_angle = value
if _moving_body and _moving_body is CharacterBody2D:
_moving_body._floor_max_angle = _floor_max_angle
func _start_test():
@@ -138,14 +185,16 @@ func _start_test():
var template = null
match _body_type:
E_BodyType.CHARACTER_BODY:
template = _character_body_template
E_BodyType.CHARACTER_BODY_RAY:
template = _character_body_ray_template
E_BodyType.RIGID_BODY:
template = _rigid_body_template
E_BodyType.KINEMATIC_BODY:
template = _kinematic_body_template
E_BodyType.KINEMATIC_BODY_RAY_SHAPE:
template = _kinematic_body_ray_template
E_BodyType.RIGID_BODY_RAY:
template = _rigid_body_ray_template
test_label += template.name
test_label += String(template.name)
_moving_body = template.duplicate()
_body_parent.add_child(_moving_body)
@@ -155,11 +204,12 @@ func _start_test():
_moving_body._motion_speed = _motion_speed
_moving_body._gravity_force = _gravity_force
_moving_body._jump_force = _jump_force
_moving_body._floor_max_angle = _floor_max_angle
if _moving_body is KinematicBody2D:
if _use_snap:
_moving_body._snap = Vector2(0, _snap_distance)
if _moving_body is CharacterBody2D:
_moving_body._snap = _snap_distance if _use_snap else 0.0
_moving_body._stop_on_slope = _use_stop_on_slope
_moving_body._floor_max_angle = _floor_max_angle
_moving_body._move_on_floor_only = _use_floor_only
_moving_body._constant_speed = _use_constant_speed
$LabelTestType.text = test_label

View File

@@ -2,8 +2,8 @@ extends TestCharacter
const OPTION_TEST_CASE_ALL = "Test Cases/TEST ALL (0)"
const OPTION_TEST_CASE_DETECT_FLOOR_NO_SNAP = "Test Cases/Floor detection (Kinematic Body)"
const OPTION_TEST_CASE_DETECT_FLOOR_MOTION_CHANGES = "Test Cases/Floor detection with motion changes (Kinematic Body)"
const OPTION_TEST_CASE_DETECT_FLOOR_NO_SNAP = "Test Cases/Floor detection (Character Body)"
const OPTION_TEST_CASE_DETECT_FLOOR_MOTION_CHANGES = "Test Cases/Floor detection with motion changes (Character Body)"
const MOTION_CHANGES_DIR = Vector2(1.0, 1.0)
const MOTION_CHANGES_SPEEDS = [0.5, 1.0, 2.0, 5.0, 10.0, 20.0, 50.0]
@@ -17,11 +17,15 @@ var _failed_reason = ""
func _ready():
super._ready()
options.add_menu_item(OPTION_TEST_CASE_ALL)
options.add_menu_item(OPTION_TEST_CASE_DETECT_FLOOR_NO_SNAP)
options.add_menu_item(OPTION_TEST_CASE_DETECT_FLOOR_MOTION_CHANGES)
func _physics_process(_delta):
func _physics_process(delta):
super._physics_process(delta)
if _moving_body:
if _moving_body.is_on_floor():
_floor_detected = true
@@ -40,24 +44,26 @@ func _physics_process(_delta):
func _input(event):
super._input(event)
var key_event = event as InputEventKey
if key_event and not key_event.pressed:
if key_event.scancode == KEY_0:
_on_option_selected(OPTION_TEST_CASE_ALL)
if key_event.keycode == KEY_0:
await _on_option_selected(OPTION_TEST_CASE_ALL)
func _on_option_selected(option):
match option:
OPTION_TEST_CASE_ALL:
_test_all()
await _test_all()
OPTION_TEST_CASE_DETECT_FLOOR_NO_SNAP:
_start_test_case(option)
await _start_test_case(option)
return
OPTION_TEST_CASE_DETECT_FLOOR_MOTION_CHANGES:
_start_test_case(option)
await _start_test_case(option)
return
._on_option_selected(option)
super._on_option_selected(option)
func _start_test_case(option):
@@ -68,10 +74,10 @@ func _start_test_case(option):
_test_floor_detection = true
_test_motion_changes = false
_use_snap = false
_body_type = E_BodyType.KINEMATIC_BODY
_body_type = E_BodyType.CHARACTER_BODY
_start_test()
yield(start_timer(1.0), "timeout")
await start_timer(1.0).timeout
if is_timer_canceled():
return
@@ -80,10 +86,10 @@ func _start_test_case(option):
_test_floor_detection = true
_test_motion_changes = true
_use_snap = false
_body_type = E_BodyType.KINEMATIC_BODY
_body_type = E_BodyType.CHARACTER_BODY
_start_test()
yield(start_timer(4.0), "timeout")
await start_timer(4.0).timeout
if is_timer_canceled():
_test_motion_changes = false
return
@@ -100,13 +106,13 @@ func _test_all():
Log.print_log("* TESTING ALL...")
# Test floor detection with no snapping.
yield(_start_test_case(OPTION_TEST_CASE_DETECT_FLOOR_NO_SNAP), "completed")
await _start_test_case(OPTION_TEST_CASE_DETECT_FLOOR_NO_SNAP)
if is_timer_canceled():
return
# Test floor detection with no snapping.
# In this test case, motion alternates different speeds.
yield(_start_test_case(OPTION_TEST_CASE_DETECT_FLOOR_MOTION_CHANGES), "completed")
await _start_test_case(OPTION_TEST_CASE_DETECT_FLOOR_MOTION_CHANGES)
if is_timer_canceled():
return
@@ -120,7 +126,7 @@ func _set_result(test_passed):
else:
result = "FAILED"
if not test_passed and not _failed_reason.empty():
if not test_passed and not _failed_reason.is_empty():
result += _failed_reason
else:
result += "."
@@ -129,7 +135,7 @@ func _set_result(test_passed):
func _start_test():
._start_test()
super._start_test()
_failed_reason = ""
@@ -140,7 +146,7 @@ func _start_test():
_failed_reason = ": floor was not detected consistently."
if _test_motion_changes:
# Always use the same seed for reproducible results.
rand_seed(123456789)
seed(123456789)
_moving_body._gravity_force = 0.0
_moving_body._motion_speed = 0.0
_moving_body._jump_force = 0.0

View File

@@ -1,41 +1,41 @@
[gd_scene load_steps=12 format=2]
[gd_scene load_steps=12 format=3 uid="uid://bxx2ftwccdlft"]
[ext_resource path="res://tests/functional/test_character_pixels.gd" type="Script" id=1]
[ext_resource path="res://utils/rigidbody_controller.gd" type="Script" id=2]
[ext_resource path="res://tests/test_options.tscn" type="PackedScene" id=3]
[ext_resource path="res://tests/static_scene_flat.tscn" type="PackedScene" id=4]
[ext_resource path="res://utils/kinematicbody_controller.gd" type="Script" id=7]
[ext_resource type="Script" path="res://tests/functional/test_character_pixels.gd" id="1"]
[ext_resource type="Script" path="res://utils/rigidbody_controller.gd" id="2"]
[ext_resource type="PackedScene" uid="uid://blh3twy74kbkv" path="res://tests/test_options.tscn" id="3"]
[ext_resource type="PackedScene" uid="uid://cx2q80okt25o1" path="res://tests/static_scene_flat.tscn" id="4"]
[ext_resource type="Script" path="res://utils/characterbody_controller.gd" id="7"]
[sub_resource type="PhysicsMaterial" id=1]
[sub_resource type="RectangleShape2D" id="3"]
size = Vector2(6, 9.8)
[sub_resource type="RectangleShape2D" id="RectangleShape2D_scs3g"]
size = Vector2(6, 4.8)
[sub_resource type="SeparationRayShape2D" id="SeparationRayShape2D_vby12"]
length = 7.0
[sub_resource type="PhysicsMaterial" id="1"]
friction = 0.0
[sub_resource type="RectangleShape2D" id=2]
extents = Vector2( 3, 5 )
[sub_resource type="RectangleShape2D" id="2"]
size = Vector2(6, 10)
[sub_resource type="RectangleShape2D" id=3]
extents = Vector2( 3, 4.9 )
[sub_resource type="RectangleShape2D" id=4]
extents = Vector2( 3, 3 )
[sub_resource type="RayShape2D" id=5]
length = 3.0
[sub_resource type="RectangleShape2D" id=6]
extents = Vector2( 10, 2 )
[sub_resource type="RectangleShape2D" id="6"]
size = Vector2(20, 4)
[node name="Test" type="Node2D"]
script = ExtResource( 1 )
script = ExtResource( "1" )
_motion_speed = 30.0
_gravity_force = 2.0
_jump_force = 50.0
_snap_distance = 1.0
[node name="ViewportContainer" type="ViewportContainer" parent="."]
[node name="ViewportContainer" type="SubViewportContainer" parent="."]
anchor_right = 1.0
anchor_bottom = 1.0
margin_right = 1024.0
margin_bottom = 600.0
offset_right = 1024.0
offset_bottom = 600.0
size_flags_horizontal = 3
size_flags_vertical = 3
stretch = true
@@ -43,107 +43,126 @@ __meta__ = {
"_edit_use_anchors_": false
}
[node name="Viewport" type="Viewport" parent="ViewportContainer"]
size = Vector2( 128, 75 )
[node name="Viewport" type="SubViewport" parent="ViewportContainer"]
handle_input_locally = false
render_target_update_mode = 3
size = Vector2i(1024, 600)
size_2d_override = Vector2i(128, 75)
size_2d_override_stretch = true
render_target_update_mode = 4
[node name="StaticSceneFlat" parent="ViewportContainer/Viewport" instance=ExtResource( 4 )]
position = Vector2( 0, -450 )
[node name="StaticSceneFlat" parent="ViewportContainer/Viewport" instance=ExtResource( "4" )]
position = Vector2(0, -450)
[node name="RigidBody2D" type="RigidBody2D" parent="ViewportContainer/Viewport"]
position = Vector2( 30, 40 )
[node name="CharacterBody2D" type="CharacterBody2D" parent="ViewportContainer/Viewport"]
position = Vector2(30, 40)
collision_mask = 2147483649
mode = 2
physics_material_override = SubResource( 1 )
script = ExtResource( "7" )
[node name="CollisionShape2D" type="CollisionShape2D" parent="ViewportContainer/Viewport/CharacterBody2D"]
shape = SubResource( "3" )
[node name="CharacterBodyRay2D" type="CharacterBody2D" parent="ViewportContainer/Viewport"]
position = Vector2(30, 40)
collision_mask = 2147483649
script = ExtResource( "7" )
[node name="CollisionShape2D" type="CollisionShape2D" parent="ViewportContainer/Viewport/CharacterBodyRay2D"]
position = Vector2(0, -2.5)
shape = SubResource( "RectangleShape2D_scs3g" )
[node name="CollisionShapeRay2D" type="CollisionShape2D" parent="ViewportContainer/Viewport/CharacterBodyRay2D"]
position = Vector2(0, -2)
shape = SubResource( "SeparationRayShape2D_vby12" )
[node name="RigidBody2D" type="RigidDynamicBody2D" parent="ViewportContainer/Viewport"]
position = Vector2(30, 40)
collision_mask = 2147483649
physics_material_override = SubResource( "1" )
contacts_reported = 4
contact_monitor = true
script = ExtResource( 2 )
lock_rotation = true
script = ExtResource( "2" )
[node name="CollisionShape2D" type="CollisionShape2D" parent="ViewportContainer/Viewport/RigidBody2D"]
shape = SubResource( 2 )
shape = SubResource( "2" )
[node name="KinematicBody2D" type="KinematicBody2D" parent="ViewportContainer/Viewport"]
position = Vector2( 30, 40 )
[node name="RigidBodyRay2D" type="RigidDynamicBody2D" parent="ViewportContainer/Viewport"]
position = Vector2(30, 40)
collision_mask = 2147483649
script = ExtResource( 7 )
physics_material_override = SubResource( "1" )
contacts_reported = 4
contact_monitor = true
lock_rotation = true
script = ExtResource( "2" )
[node name="CollisionShape2D" type="CollisionShape2D" parent="ViewportContainer/Viewport/KinematicBody2D"]
shape = SubResource( 3 )
[node name="CollisionShape2D" type="CollisionShape2D" parent="ViewportContainer/Viewport/RigidBodyRay2D"]
position = Vector2(0, -2.5)
shape = SubResource( "RectangleShape2D_scs3g" )
[node name="KinematicBodyRay2D" type="KinematicBody2D" parent="ViewportContainer/Viewport"]
position = Vector2( 30, 40 )
collision_mask = 2147483649
script = ExtResource( 7 )
[node name="CollisionShape2D" type="CollisionShape2D" parent="ViewportContainer/Viewport/KinematicBodyRay2D"]
position = Vector2( 0, -2 )
shape = SubResource( 4 )
[node name="CollisionShapeRay2D" type="CollisionShape2D" parent="ViewportContainer/Viewport/KinematicBodyRay2D"]
position = Vector2( 0, -1 )
shape = SubResource( 5 )
[node name="CollisionShapeRay2D" type="CollisionShape2D" parent="ViewportContainer/Viewport/RigidBodyRay2D"]
position = Vector2(0, -2)
shape = SubResource( "SeparationRayShape2D_vby12" )
[node name="Wall1" type="StaticBody2D" parent="ViewportContainer/Viewport"]
position = Vector2( 20, 40 )
position = Vector2(20, 40)
[node name="CollisionShape2D" type="CollisionShape2D" parent="ViewportContainer/Viewport/Wall1"]
rotation = 1.5708
shape = SubResource( 6 )
shape = SubResource( "6" )
[node name="Wall2" type="StaticBody2D" parent="ViewportContainer/Viewport"]
position = Vector2( 122, 40 )
position = Vector2(122, 40)
[node name="CollisionShape2D" type="CollisionShape2D" parent="ViewportContainer/Viewport/Wall2"]
rotation = 1.5708
shape = SubResource( 6 )
shape = SubResource( "6" )
[node name="Platform1" type="StaticBody2D" parent="ViewportContainer/Viewport"]
position = Vector2( 50, 44 )
position = Vector2(50, 44)
[node name="CollisionShape2D" type="CollisionShape2D" parent="ViewportContainer/Viewport/Platform1"]
shape = SubResource( 6 )
shape = SubResource( "6" )
one_way_collision = true
[node name="Platform2" type="StaticBody2D" parent="ViewportContainer/Viewport"]
position = Vector2( 80, 38 )
position = Vector2(80, 38)
[node name="CollisionShape2D" type="CollisionShape2D" parent="ViewportContainer/Viewport/Platform2"]
shape = SubResource( 6 )
shape = SubResource( "6" )
[node name="Slope" type="StaticBody2D" parent="ViewportContainer/Viewport"]
position = Vector2( 84, 36 )
position = Vector2(85, 36)
[node name="CollisionShape2D" type="CollisionPolygon2D" parent="ViewportContainer/Viewport/Slope"]
polygon = PoolVector2Array( 0, 0, 6, 0, 22, 16, 16, 16 )
polygon = PackedVector2Array(0, 0, 6, 0, 22, 16, 16, 16)
[node name="LabelTestType" type="Label" parent="."]
margin_left = 14.0
margin_top = 79.0
margin_right = 145.0
margin_bottom = 93.0
offset_left = 14.0
offset_top = 79.0
offset_right = 145.0
offset_bottom = 93.0
text = "Testing: "
__meta__ = {
"_edit_use_anchors_": false
}
[node name="Options" parent="." instance=ExtResource( 3 )]
[node name="Options" parent="." instance=ExtResource( "3" )]
[node name="LabelFloor" type="Label" parent="."]
margin_left = 14.0
margin_top = 237.929
margin_right = 145.0
margin_bottom = 251.929
offset_left = 14.0
offset_top = 237.929
offset_right = 145.0
offset_bottom = 251.929
text = "ON FLOOR"
__meta__ = {
"_edit_use_anchors_": false
}
[node name="LabelControls" type="Label" parent="."]
margin_left = 14.0
margin_top = 263.291
margin_right = 145.0
margin_bottom = 294.291
offset_left = 14.0
offset_top = 263.291
offset_right = 145.0
offset_bottom = 294.291
text = "LEFT/RIGHT - MOVE
UP - JUMP"
__meta__ = {

View File

@@ -1,102 +1,163 @@
[gd_scene load_steps=11 format=2]
[gd_scene load_steps=15 format=3 uid="uid://bqmku5ewlo6j5"]
[ext_resource path="res://tests/functional/test_character.gd" type="Script" id=1]
[ext_resource path="res://tests/test_options.tscn" type="PackedScene" id=3]
[ext_resource path="res://tests/static_scene_flat.tscn" type="PackedScene" id=4]
[ext_resource path="res://utils/rigidbody_controller.gd" type="Script" id=6]
[ext_resource path="res://utils/kinematicbody_controller.gd" type="Script" id=7]
[ext_resource type="Script" path="res://tests/functional/test_character.gd" id="1"]
[ext_resource type="PackedScene" uid="uid://blh3twy74kbkv" path="res://tests/test_options.tscn" id="3"]
[ext_resource type="Script" path="res://utils/slider.gd" id="3_cd5g0"]
[ext_resource type="PackedScene" uid="uid://cx2q80okt25o1" path="res://tests/static_scene_flat.tscn" id="4"]
[ext_resource type="Script" path="res://utils/label_slider_value.gd" id="4_eoplu"]
[ext_resource type="Script" path="res://utils/rigidbody_controller.gd" id="6"]
[ext_resource type="Script" path="res://utils/characterbody_controller.gd" id="7"]
[sub_resource type="PhysicsMaterial" id=1]
[sub_resource type="CapsuleShape2D" id="3"]
radius = 15.0
height = 96.0
[sub_resource type="CircleShape2D" id="CircleShape2D_llvur"]
radius = 32.0
[sub_resource type="SeparationRayShape2D" id="RayShape2D_3lv1w"]
length = 64.0
[sub_resource type="PhysicsMaterial" id="1"]
friction = 0.0
[sub_resource type="CapsuleShape2D" id=2]
radius = 32.0
height = 32.0
[sub_resource type="CapsuleShape2D" id="2"]
radius = 15.0
height = 96.0
[sub_resource type="CapsuleShape2D" id=3]
radius = 32.0
height = 32.0
[sub_resource type="CircleShape2D" id=4]
[sub_resource type="CircleShape2D" id="CircleShape2D_dr08f"]
radius = 32.0
[sub_resource type="RayShape2D" id=5]
[sub_resource type="SeparationRayShape2D" id="RayShape2D_w83f0"]
length = 64.0
[node name="Test" type="Node2D"]
script = ExtResource( 1 )
script = ExtResource( "1" )
_snap_distance = 32.0
_floor_max_angle = 60.0
[node name="LabelTestType" type="Label" parent="."]
margin_left = 14.0
margin_top = 79.0
margin_right = 145.0
margin_bottom = 93.0
offset_left = 14.0
offset_top = 79.0
offset_right = 145.0
offset_bottom = 93.0
text = "Testing: "
__meta__ = {
"_edit_use_anchors_": false
}
[node name="Options" parent="." instance=ExtResource( 3 )]
[node name="Options" parent="." instance=ExtResource( "3" )]
[node name="LabelFloor" type="Label" parent="."]
margin_left = 14.0
margin_top = 237.929
margin_right = 145.0
margin_bottom = 251.929
offset_left = 14.0
offset_top = 237.929
offset_right = 145.0
offset_bottom = 251.929
text = "ON FLOOR"
__meta__ = {
"_edit_use_anchors_": false
}
[node name="LabelControls" type="Label" parent="."]
margin_left = 14.0
margin_top = 263.291
margin_right = 145.0
margin_bottom = 294.291
offset_left = 14.0
offset_top = 263.291
offset_right = 145.0
offset_bottom = 294.291
text = "LEFT/RIGHT - MOVE
UP - JUMP"
__meta__ = {
"_edit_use_anchors_": false
}
[node name="RigidBody2D" type="RigidBody2D" parent="."]
position = Vector2( 100, 450 )
[node name="FloorMaxAngle" type="HBoxContainer" parent="."]
offset_left = 14.0
offset_top = 160.0
offset_right = 476.0
offset_bottom = 186.0
theme_override_constants/separation = 20
alignment = 2
__meta__ = {
"_edit_use_anchors_": false
}
[node name="Label" type="Label" parent="FloorMaxAngle"]
offset_right = 122.0
offset_bottom = 26.0
text = "Floor Max angle"
[node name="HSlider" type="HSlider" parent="FloorMaxAngle"]
offset_left = 142.0
offset_right = 342.0
offset_bottom = 16.0
rect_min_size = Vector2(200, 0)
max_value = 180.0
script = ExtResource( "3_cd5g0" )
snap_step = 5.0
[node name="LabelValue" type="Label" parent="FloorMaxAngle"]
offset_left = 362.0
offset_right = 462.0
offset_bottom = 26.0
rect_min_size = Vector2(100, 0)
text = "0.0"
script = ExtResource( "4_eoplu" )
[node name="CharacterBody2D" type="CharacterBody2D" parent="."]
position = Vector2(100, 450)
collision_mask = 2147483649
mode = 2
physics_material_override = SubResource( 1 )
script = ExtResource( "7" )
[node name="CollisionShape2D" type="CollisionShape2D" parent="CharacterBody2D"]
shape = SubResource( "3" )
[node name="CharacterBodyRay2D" type="CharacterBody2D" parent="."]
position = Vector2(100, 450)
collision_mask = 2147483649
script = ExtResource( "7" )
[node name="CollisionShape2D" type="CollisionShape2D" parent="CharacterBodyRay2D"]
position = Vector2(0, -16)
shape = SubResource( "CircleShape2D_llvur" )
[node name="CollisionShapeRay2D" type="CollisionShape2D" parent="CharacterBodyRay2D"]
position = Vector2(0, -16)
shape = SubResource( "RayShape2D_3lv1w" )
[node name="RigidBody2D" type="RigidDynamicBody2D" parent="."]
position = Vector2(100, 450)
collision_mask = 2147483649
physics_material_override = SubResource( "1" )
contacts_reported = 4
contact_monitor = true
script = ExtResource( 6 )
lock_rotation = true
script = ExtResource( "6" )
[node name="CollisionShape2D" type="CollisionShape2D" parent="RigidBody2D"]
shape = SubResource( 2 )
shape = SubResource( "2" )
[node name="KinematicBody2D" type="KinematicBody2D" parent="."]
position = Vector2( 100, 450 )
[node name="RigidBodyRay2D" type="RigidDynamicBody2D" parent="."]
position = Vector2(100, 450)
collision_mask = 2147483649
script = ExtResource( 7 )
physics_material_override = SubResource( "1" )
contacts_reported = 4
contact_monitor = true
lock_rotation = true
script = ExtResource( "6" )
[node name="CollisionShape2D" type="CollisionShape2D" parent="KinematicBody2D"]
shape = SubResource( 3 )
[node name="CollisionShape2D" type="CollisionShape2D" parent="RigidBodyRay2D"]
position = Vector2(-7.62939e-06, -16)
shape = SubResource( "CircleShape2D_dr08f" )
[node name="KinematicBodyRay2D" type="KinematicBody2D" parent="."]
position = Vector2( 100, 450 )
collision_mask = 2147483649
script = ExtResource( 7 )
[node name="CollisionShapeRay2D" type="CollisionShape2D" parent="RigidBodyRay2D"]
position = Vector2(-7.62939e-06, -16)
shape = SubResource( "RayShape2D_w83f0" )
[node name="CollisionShape2D" type="CollisionShape2D" parent="KinematicBodyRay2D"]
position = Vector2( 0, -16 )
shape = SubResource( 4 )
[node name="CollisionShapeRay2D" type="CollisionShape2D" parent="KinematicBodyRay2D"]
position = Vector2( 0, -16 )
shape = SubResource( 5 )
[node name="StaticSceneFlat" parent="." instance=ExtResource( 4 )]
position = Vector2( 0, 12 )
[node name="StaticSceneFlat" parent="." instance=ExtResource( "4" )]
position = Vector2(0, 12)
[node name="StaticBody2D" type="StaticBody2D" parent="."]
[node name="CollisionPolygon2D" type="CollisionPolygon2D" parent="StaticBody2D"]
polygon = PoolVector2Array( 171.04, 529.248, 379.275, 294.316, 506.084, 429.135, 648.26, 322.058, 868.746, 322.058, 985.282, 36.6919, 1242.91, 531.917 )
polygon = PackedVector2Array(171.04, 529.248, 379.275, 294.316, 506.084, 429.135, 648.26, 322.058, 868.746, 322.058, 985.282, 36.6919, 1242.91, 531.917)
[connection signal="value_changed" from="FloorMaxAngle/HSlider" to="." method="_update_floor_max_angle"]

View File

@@ -3,57 +3,61 @@ extends TestCharacter
const OPTION_TEST_CASE_ALL = "Test Cases/TEST ALL (0)"
const OPTION_TEST_CASE_JUMP_ONE_WAY_RIGID = "Test Cases/Jump through one-way tiles (Rigid Body)"
const OPTION_TEST_CASE_JUMP_ONE_WAY_KINEMATIC = "Test Cases/Jump through one-way tiles (Kinematic Body)"
const OPTION_TEST_CASE_JUMP_ONE_WAY_CHARACTER = "Test Cases/Jump through one-way tiles (Character Body)"
const OPTION_TEST_CASE_JUMP_ONE_WAY_CORNER_RIGID = "Test Cases/Jump through one-way corner (Rigid Body)"
const OPTION_TEST_CASE_JUMP_ONE_WAY_CORNER_KINEMATIC = "Test Cases/Jump through one-way corner (Kinematic Body)"
const OPTION_TEST_CASE_FALL_ONE_WAY_KINEMATIC = "Test Cases/Fall and pushed on one-way tiles (Kinematic Body)"
const OPTION_TEST_CASE_JUMP_ONE_WAY_CORNER_CHARACTER = "Test Cases/Jump through one-way corner (Character Body)"
const OPTION_TEST_CASE_FALL_ONE_WAY_CHARACTER = "Test Cases/Fall and pushed on one-way tiles (Character Body)"
var _test_jump_one_way = false
var _test_jump_one_way_corner = false
var _test_fall_one_way = false
var _extra_body = null
var _extra_body : PhysicsBody2D = null
var _failed_reason = ""
func _ready():
super._ready()
options.add_menu_item(OPTION_TEST_CASE_ALL)
options.add_menu_item(OPTION_TEST_CASE_JUMP_ONE_WAY_RIGID)
options.add_menu_item(OPTION_TEST_CASE_JUMP_ONE_WAY_KINEMATIC)
options.add_menu_item(OPTION_TEST_CASE_JUMP_ONE_WAY_CHARACTER)
options.add_menu_item(OPTION_TEST_CASE_JUMP_ONE_WAY_CORNER_RIGID)
options.add_menu_item(OPTION_TEST_CASE_JUMP_ONE_WAY_CORNER_KINEMATIC)
options.add_menu_item(OPTION_TEST_CASE_FALL_ONE_WAY_KINEMATIC)
options.add_menu_item(OPTION_TEST_CASE_JUMP_ONE_WAY_CORNER_CHARACTER)
options.add_menu_item(OPTION_TEST_CASE_FALL_ONE_WAY_CHARACTER)
func _input(event):
super._input(event)
var key_event = event as InputEventKey
if key_event and not key_event.pressed:
if key_event.scancode == KEY_0:
_on_option_selected(OPTION_TEST_CASE_ALL)
if key_event.keycode == KEY_0:
await _on_option_selected(OPTION_TEST_CASE_ALL)
func _on_option_selected(option):
match option:
OPTION_TEST_CASE_ALL:
_test_all()
await _test_all()
OPTION_TEST_CASE_JUMP_ONE_WAY_RIGID:
_start_test_case(option)
await _start_test_case(option)
return
OPTION_TEST_CASE_JUMP_ONE_WAY_KINEMATIC:
_start_test_case(option)
OPTION_TEST_CASE_JUMP_ONE_WAY_CHARACTER:
await _start_test_case(option)
return
OPTION_TEST_CASE_JUMP_ONE_WAY_CORNER_RIGID:
_start_test_case(option)
await _start_test_case(option)
return
OPTION_TEST_CASE_JUMP_ONE_WAY_CORNER_KINEMATIC:
_start_test_case(option)
OPTION_TEST_CASE_JUMP_ONE_WAY_CORNER_CHARACTER:
await _start_test_case(option)
return
OPTION_TEST_CASE_FALL_ONE_WAY_KINEMATIC:
_start_test_case(option)
OPTION_TEST_CASE_FALL_ONE_WAY_CHARACTER:
await _start_test_case(option)
return
._on_option_selected(option)
super._on_option_selected(option)
func _start_test_case(option):
@@ -63,22 +67,22 @@ func _start_test_case(option):
OPTION_TEST_CASE_JUMP_ONE_WAY_RIGID:
_body_type = E_BodyType.RIGID_BODY
_test_jump_one_way_corner = false
yield(_start_jump_one_way(), "completed")
OPTION_TEST_CASE_JUMP_ONE_WAY_KINEMATIC:
_body_type = E_BodyType.KINEMATIC_BODY
await _start_jump_one_way()
OPTION_TEST_CASE_JUMP_ONE_WAY_CHARACTER:
_body_type = E_BodyType.CHARACTER_BODY
_test_jump_one_way_corner = false
yield(_start_jump_one_way(), "completed")
await _start_jump_one_way()
OPTION_TEST_CASE_JUMP_ONE_WAY_CORNER_RIGID:
_body_type = E_BodyType.RIGID_BODY
_test_jump_one_way_corner = true
yield(_start_jump_one_way(), "completed")
OPTION_TEST_CASE_JUMP_ONE_WAY_CORNER_KINEMATIC:
_body_type = E_BodyType.KINEMATIC_BODY
await _start_jump_one_way()
OPTION_TEST_CASE_JUMP_ONE_WAY_CORNER_CHARACTER:
_body_type = E_BodyType.CHARACTER_BODY
_test_jump_one_way_corner = true
yield(_start_jump_one_way(), "completed")
OPTION_TEST_CASE_FALL_ONE_WAY_KINEMATIC:
_body_type = E_BodyType.KINEMATIC_BODY
yield(_start_fall_one_way(), "completed")
await _start_jump_one_way()
OPTION_TEST_CASE_FALL_ONE_WAY_CHARACTER:
_body_type = E_BodyType.CHARACTER_BODY
await _start_fall_one_way()
_:
Log.print_error("Invalid test case.")
@@ -87,24 +91,24 @@ func _test_all():
Log.print_log("* TESTING ALL...")
# RigidBody tests.
yield(_start_test_case(OPTION_TEST_CASE_JUMP_ONE_WAY_RIGID), "completed")
await _start_test_case(OPTION_TEST_CASE_JUMP_ONE_WAY_RIGID)
if is_timer_canceled():
return
yield(_start_test_case(OPTION_TEST_CASE_JUMP_ONE_WAY_CORNER_RIGID), "completed")
await _start_test_case(OPTION_TEST_CASE_JUMP_ONE_WAY_CORNER_RIGID)
if is_timer_canceled():
return
# KinematicBody tests.
yield(_start_test_case(OPTION_TEST_CASE_JUMP_ONE_WAY_KINEMATIC), "completed")
# CharacterBody tests.
await _start_test_case(OPTION_TEST_CASE_JUMP_ONE_WAY_CHARACTER)
if is_timer_canceled():
return
yield(_start_test_case(OPTION_TEST_CASE_JUMP_ONE_WAY_CORNER_KINEMATIC), "completed")
await _start_test_case(OPTION_TEST_CASE_JUMP_ONE_WAY_CORNER_CHARACTER)
if is_timer_canceled():
return
yield(_start_test_case(OPTION_TEST_CASE_FALL_ONE_WAY_KINEMATIC), "completed")
await _start_test_case(OPTION_TEST_CASE_FALL_ONE_WAY_CHARACTER)
if is_timer_canceled():
return
@@ -118,7 +122,7 @@ func _set_result(test_passed):
else:
result = "FAILED"
if not test_passed and not _failed_reason.empty():
if not test_passed and not _failed_reason.is_empty():
result += _failed_reason
else:
result += "."
@@ -132,7 +136,7 @@ func _start_test():
_extra_body.queue_free()
_extra_body = null
._start_test()
super._start_test()
if _test_jump_one_way:
_test_jump_one_way = false
@@ -167,7 +171,7 @@ func _start_jump_one_way():
_test_jump_one_way = true
_start_test()
yield(start_timer(1.5), "timeout")
await start_timer(1.5).timeout
if is_timer_canceled():
return
@@ -178,7 +182,7 @@ func _start_fall_one_way():
_test_fall_one_way = true
_start_test()
yield(start_timer(1.0), "timeout")
await start_timer(1.0).timeout
if is_timer_canceled():
return

View File

@@ -1,125 +1,151 @@
[gd_scene load_steps=12 format=2]
[gd_scene load_steps=12 format=3 uid="uid://b7fcmfv5sqxfo"]
[ext_resource path="res://tests/functional/test_character_tilemap.gd" type="Script" id=1]
[ext_resource path="res://tests/test_options.tscn" type="PackedScene" id=3]
[ext_resource path="res://tests/static_scene_flat.tscn" type="PackedScene" id=4]
[ext_resource path="res://assets/tileset/tileset.tres" type="TileSet" id=5]
[ext_resource path="res://utils/rigidbody_controller.gd" type="Script" id=6]
[ext_resource path="res://utils/kinematicbody_controller.gd" type="Script" id=7]
[ext_resource type="Script" path="res://tests/functional/test_character_tilemap.gd" id="1"]
[ext_resource type="PackedScene" uid="uid://blh3twy74kbkv" path="res://tests/test_options.tscn" id="3"]
[ext_resource type="PackedScene" uid="uid://cx2q80okt25o1" path="res://tests/static_scene_flat.tscn" id="4"]
[ext_resource type="TileSet" uid="uid://rgfdpxlejxl3" path="res://assets/tileset/tileset.tres" id="5"]
[ext_resource type="Script" path="res://utils/rigidbody_controller.gd" id="6"]
[ext_resource type="Script" path="res://utils/characterbody_controller.gd" id="7"]
[sub_resource type="PhysicsMaterial" id=1]
friction = 0.0
[sub_resource type="RectangleShape2D" id="2"]
size = Vector2(32, 63.9)
[sub_resource type="RectangleShape2D" id=2]
extents = Vector2( 16, 31.9 )
[sub_resource type="RectangleShape2D" id="RectangleShape2D_jx2e1"]
size = Vector2(32, 47.8)
[sub_resource type="RectangleShape2D" id=3]
extents = Vector2( 16, 24 )
[sub_resource type="RayShape2D" id=4]
[sub_resource type="SeparationRayShape2D" id="RayShape2D_206f5"]
length = 24.0
[sub_resource type="CircleShape2D" id=5]
[sub_resource type="PhysicsMaterial" id="1"]
friction = 0.0
[sub_resource type="CircleShape2D" id="5"]
radius = 16.0
[node name="Test" type="Node2D"]
script = ExtResource( 1 )
script = ExtResource( "1" )
[node name="LabelTestType" type="Label" parent="."]
margin_left = 14.0
margin_top = 79.0
margin_right = 145.0
margin_bottom = 93.0
offset_left = 14.0
offset_top = 79.0
offset_right = 145.0
offset_bottom = 93.0
text = "Testing: "
__meta__ = {
"_edit_use_anchors_": false
}
[node name="Options" parent="." instance=ExtResource( 3 )]
[node name="Options" parent="." instance=ExtResource( "3" )]
[node name="LabelFloor" type="Label" parent="."]
margin_left = 14.0
margin_top = 237.929
margin_right = 145.0
margin_bottom = 251.929
offset_left = 14.0
offset_top = 237.929
offset_right = 145.0
offset_bottom = 251.929
text = "ON FLOOR"
__meta__ = {
"_edit_use_anchors_": false
}
[node name="LabelControls" type="Label" parent="."]
margin_left = 14.0
margin_top = 263.291
margin_right = 145.0
margin_bottom = 277.291
offset_left = 14.0
offset_top = 263.291
offset_right = 145.0
offset_bottom = 277.291
text = "LEFT/RIGHT - MOVE
UP - JUMP"
__meta__ = {
"_edit_use_anchors_": false
}
[node name="RigidBody2D" type="RigidBody2D" parent="."]
position = Vector2( 250, 460 )
[node name="CharacterBody2D" type="CharacterBody2D" parent="."]
position = Vector2(250, 460)
collision_mask = 2147483649
mode = 2
physics_material_override = SubResource( 1 )
script = ExtResource( "7" )
[node name="CollisionShape2D" type="CollisionShape2D" parent="CharacterBody2D"]
shape = SubResource( "2" )
[node name="CharacterBodyRay2D" type="CharacterBody2D" parent="."]
position = Vector2(250, 460)
collision_mask = 2147483649
script = ExtResource( "7" )
[node name="CollisionShape2D" type="CollisionShape2D" parent="CharacterBodyRay2D"]
position = Vector2(0, -8)
shape = SubResource( "RectangleShape2D_jx2e1" )
[node name="CollisionShapeRay2D" type="CollisionShape2D" parent="CharacterBodyRay2D"]
position = Vector2(0, 8)
shape = SubResource( "RayShape2D_206f5" )
[node name="CollisionShapeRay2DLeft" type="CollisionShape2D" parent="CharacterBodyRay2D"]
position = Vector2(-12, 8)
shape = SubResource( "RayShape2D_206f5" )
[node name="CollisionShapeRay2DRight" type="CollisionShape2D" parent="CharacterBodyRay2D"]
position = Vector2(12, 8)
shape = SubResource( "RayShape2D_206f5" )
[node name="RigidBody2D" type="RigidDynamicBody2D" parent="."]
position = Vector2(250, 460)
collision_mask = 2147483649
physics_material_override = SubResource( "1" )
contacts_reported = 4
contact_monitor = true
script = ExtResource( 6 )
lock_rotation = true
script = ExtResource( "6" )
[node name="CollisionShape2D" type="CollisionShape2D" parent="RigidBody2D"]
shape = SubResource( 2 )
shape = SubResource( "2" )
[node name="KinematicBody2D" type="KinematicBody2D" parent="."]
position = Vector2( 250, 460 )
[node name="RigidBodyRay2D" type="RigidDynamicBody2D" parent="."]
position = Vector2(250, 460)
collision_mask = 2147483649
script = ExtResource( 7 )
physics_material_override = SubResource( "1" )
contacts_reported = 4
contact_monitor = true
lock_rotation = true
script = ExtResource( "6" )
[node name="CollisionShape2D" type="CollisionShape2D" parent="KinematicBody2D"]
shape = SubResource( 2 )
[node name="CollisionShape2D" type="CollisionShape2D" parent="RigidBodyRay2D"]
position = Vector2(0, -8)
shape = SubResource( "RectangleShape2D_jx2e1" )
[node name="KinematicBodyRay2D" type="KinematicBody2D" parent="."]
position = Vector2( 250, 460 )
collision_mask = 2147483649
script = ExtResource( 7 )
[node name="CollisionShapeRay2D" type="CollisionShape2D" parent="RigidBodyRay2D"]
position = Vector2(0, 8)
shape = SubResource( "RayShape2D_206f5" )
[node name="CollisionShape2D" type="CollisionShape2D" parent="KinematicBodyRay2D"]
position = Vector2( 0, -8 )
shape = SubResource( 3 )
[node name="CollisionShapeRay2DLeft" type="CollisionShape2D" parent="RigidBodyRay2D"]
position = Vector2(-12, 8)
shape = SubResource( "RayShape2D_206f5" )
[node name="CollisionShapeRay2D" type="CollisionShape2D" parent="KinematicBodyRay2D"]
position = Vector2( 0, 8 )
shape = SubResource( 4 )
[node name="CollisionShapeRay2DLeft" type="CollisionShape2D" parent="KinematicBodyRay2D"]
position = Vector2( -16, 8 )
shape = SubResource( 4 )
[node name="CollisionShapeRay2DRight" type="CollisionShape2D" parent="KinematicBodyRay2D"]
position = Vector2( 16, 8 )
shape = SubResource( 4 )
[node name="CollisionShapeRay2DRight" type="CollisionShape2D" parent="RigidBodyRay2D"]
position = Vector2(12, 8)
shape = SubResource( "RayShape2D_206f5" )
[node name="JumpTargetArea2D" type="Area2D" parent="."]
visible = false
position = Vector2( 810, 390 )
position = Vector2(810, 390)
[node name="CollisionShape2D" type="CollisionShape2D" parent="JumpTargetArea2D"]
shape = SubResource( 5 )
shape = SubResource( "5" )
disabled = true
[node name="FallTargetArea2D" type="Area2D" parent="."]
visible = false
position = Vector2( 250, 480 )
position = Vector2(250, 480)
[node name="CollisionShape2D" type="CollisionShape2D" parent="FallTargetArea2D"]
shape = SubResource( 5 )
shape = SubResource( "5" )
disabled = true
[node name="StaticSceneFlat" parent="." instance=ExtResource( 4 )]
position = Vector2( 0, 12 )
[node name="StaticSceneFlat" parent="." instance=ExtResource( "4" )]
position = Vector2(0, 12)
[node name="TileMap" type="TileMap" parent="."]
tile_set = ExtResource( 5 )
cell_size = Vector2( 32, 32 )
format = 1
tile_data = PoolIntArray( 458764, 5, 0, 458765, 5, 0, 458766, 5, 0, 458767, 5, 0, 458768, 5, 0, 458769, 5, 0, 458770, 5, 0, 458771, 5, 0, 524300, 5, 0, 524301, 5, 0, 524302, 5, 0, 524303, 5, 0, 524304, 5, 0, 524305, 5, 0, 524306, 5, 0, 524307, 5, 0, 589836, 5, 0, 589837, 5, 0, 589838, 5, 0, 589839, 5, 0, 589840, 5, 0, 589841, 5, 0, 589842, 5, 0, 589843, 5, 0, 655372, 5, 0, 655373, 5, 0, 655374, 5, 0, 655375, 5, 0, 655376, 5, 0, 655377, 5, 0, 655378, 5, 0, 655379, 5, 0, 720908, 5, 0, 720909, 5, 0, 720910, 5, 0, 720911, 5, 0, 720912, 5, 0, 720913, 5, 0, 720914, 5, 0, 720915, 5, 0, 720922, 0, 0, 720923, 0, 0, 720924, 0, 0, 720925, 0, 0, 786438, 5, 0, 786439, 5, 0, 786440, 5, 0, 786441, 5, 0, 786444, 5, 0, 786445, 5, 0, 786446, 5, 0, 786447, 5, 0, 786448, 5, 0, 786449, 5, 0, 786450, 5, 0, 786451, 5, 0, 851980, 5, 0, 851981, 5, 0, 851982, 5, 0, 851983, 5, 0, 851984, 5, 0, 851985, 5, 0, 851986, 5, 0, 851987, 5, 0, 851992, 0, 0, 851993, 0, 0, 851994, 0, 0, 851995, 0, 0, 917516, 5, 0, 917517, 5, 0, 917518, 5, 0, 917519, 5, 0, 917520, 5, 0, 917521, 5, 0, 917522, 5, 0, 917523, 5, 0, 983052, 5, 0, 983053, 5, 0, 983054, 5, 0, 983055, 5, 0, 983056, 5, 0, 983057, 5, 0, 983058, 5, 0, 983059, 5, 0 )
scale = Vector2(2, 2)
tile_set = ExtResource( "5" )
collision_visibility_mode = 1
format = 2
layer_0/tile_data = PackedInt32Array(786438, 65536, 0, 786439, 65536, 0, 786440, 65536, 0, 786441, 65536, 0, 458764, 65536, 0, 524300, 65536, 0, 589836, 65536, 0, 655372, 65536, 0, 720908, 65536, 0, 786444, 65536, 0, 851980, 65536, 0, 917516, 65536, 0, 983052, 65536, 0, 458765, 65536, 0, 524301, 65536, 0, 589837, 65536, 0, 655373, 65536, 0, 720909, 65536, 0, 786445, 65536, 0, 851981, 65536, 0, 917517, 65536, 0, 983053, 65536, 0, 458766, 65536, 0, 524302, 65536, 0, 589838, 65536, 0, 655374, 65536, 0, 720910, 65536, 0, 786446, 65536, 0, 851982, 65536, 0, 917518, 65536, 0, 983054, 65536, 0, 458767, 65536, 0, 524303, 65536, 0, 589839, 65536, 0, 655375, 65536, 0, 720911, 65536, 0, 786447, 65536, 0, 851983, 65536, 0, 917519, 65536, 0, 983055, 65536, 0, 458768, 65536, 0, 524304, 65536, 0, 589840, 65536, 0, 655376, 65536, 0, 720912, 65536, 0, 786448, 65536, 0, 851984, 65536, 0, 917520, 65536, 0, 983056, 65536, 0, 458769, 65536, 0, 524305, 65536, 0, 589841, 65536, 0, 655377, 65536, 0, 720913, 65536, 0, 786449, 65536, 0, 851985, 65536, 0, 917521, 65536, 0, 983057, 65536, 0, 458770, 65536, 0, 524306, 65536, 0, 589842, 65536, 0, 655378, 65536, 0, 720914, 65536, 0, 786450, 65536, 0, 851986, 65536, 0, 917522, 65536, 0, 983058, 65536, 0, 458771, 65536, 0, 524307, 65536, 0, 589843, 65536, 0, 655379, 65536, 0, 720915, 65536, 0, 786451, 65536, 0, 851987, 65536, 0, 917523, 65536, 0, 983059, 65536, 0, 851992, 0, 0, 851993, 0, 0, 720922, 0, 0, 851994, 0, 0, 720923, 0, 0, 851995, 0, 0, 720924, 0, 0, 720925, 0, 0)

View File

@@ -16,9 +16,9 @@ const OPTION_SHAPE_CONCAVE_SEGMENTS = "Shape type/Concave Segments"
const OFFSET_RANGE = 120.0
export(Vector2) var offset = Vector2.ZERO
@export var offset = Vector2.ZERO
onready var options = $Options
@onready var options = $Options
var _update_collision = false
var _collision_test_index = 0
@@ -42,10 +42,10 @@ func _ready():
options.add_menu_item(OPTION_SHAPE_CONCAVE_POLYGON, true, true)
options.add_menu_item(OPTION_SHAPE_CONCAVE_SEGMENTS, true, true)
options.connect("option_selected", self, "_on_option_selected")
options.connect("option_changed", self, "_on_option_changed")
options.connect("option_selected", Callable(self, "_on_option_selected"))
options.connect("option_changed", Callable(self, "_on_option_changed"))
yield(start_timer(0.5), "timeout")
await start_timer(0.5).timeout
if is_timer_canceled():
return
@@ -55,19 +55,21 @@ func _ready():
func _input(event):
var key_event = event as InputEventKey
if key_event and not key_event.pressed:
if key_event.scancode == KEY_1:
if key_event.keycode == KEY_1:
_on_option_selected(OPTION_TYPE_RECTANGLE)
elif key_event.scancode == KEY_2:
elif key_event.keycode == KEY_2:
_on_option_selected(OPTION_TYPE_SPHERE)
elif key_event.scancode == KEY_3:
elif key_event.keycode == KEY_3:
_on_option_selected(OPTION_TYPE_CAPSULE)
elif key_event.scancode == KEY_4:
elif key_event.keycode == KEY_4:
_on_option_selected(OPTION_TYPE_CONVEX_POLYGON)
elif key_event.scancode == KEY_5:
elif key_event.keycode == KEY_5:
_on_option_selected(OPTION_TYPE_CONCAVE_SEGMENTS)
func _physics_process(_delta):
func _physics_process(delta):
super._physics_process(delta)
if not _update_collision:
return
@@ -104,7 +106,7 @@ func _do_collision_test():
Log.print_log("* Start %s collision tests..." % shape.resource_name)
var shape_query = Physics2DShapeQueryParameters.new()
var shape_query = PhysicsShapeQueryParameters2D.new()
shape_query.set_shape(shape)
var shape_scale = Vector2(0.5, 0.5)
shape_query.transform = Transform2D.IDENTITY.scaled(shape_scale)
@@ -116,13 +118,13 @@ func _do_collision_test():
var body = node as PhysicsBody2D
var space_state = body.get_world_2d().direct_space_state
Log.print_log("* Testing: %s" % body.name)
Log.print_log("* Testing: %s" % String(body.name))
var center = body.position
# Collision at the center inside.
var res = _add_collision(space_state, center, shape, shape_query)
Log.print_log("Collision center inside: %s" % ("NO HIT" if res.empty() else "HIT"))
Log.print_log("Collision center inside: %s" % ("NO HIT" if res.is_empty() else "HIT"))
Log.print_log("* Done.")
@@ -132,17 +134,17 @@ func _add_collision(space_state, pos, shape, shape_query):
var results = space_state.collide_shape(shape_query)
var color
if results.empty():
color = Color.white.darkened(0.5)
if results.is_empty():
color = Color.WHITE.darkened(0.5)
else:
color = Color.green
color = Color.GREEN
# Draw collision query shape.
add_shape(shape, shape_query.transform, color)
# Draw contact positions.
for contact_pos in results:
add_circle(contact_pos, 1.0, Color.red)
add_circle(contact_pos, 1.0, Color.RED)
return results

View File

@@ -1,148 +1,145 @@
[gd_scene load_steps=8 format=2]
[gd_scene load_steps=8 format=3 uid="uid://pm3t5nl2v6gj"]
[ext_resource path="res://tests/functional/test_collision_pairs.gd" type="Script" id=1]
[ext_resource path="res://assets/texture/godot-head.png" type="Texture" id=2]
[ext_resource path="res://tests/test_options.tscn" type="PackedScene" id=3]
[ext_resource type="Script" path="res://tests/functional/test_collision_pairs.gd" id="1"]
[ext_resource type="Texture2D" uid="uid://c5duuyhbmd0m4" path="res://assets/texture/godot-head.png" id="2"]
[ext_resource type="PackedScene" uid="uid://blh3twy74kbkv" path="res://tests/test_options.tscn" id="3"]
[sub_resource type="RectangleShape2D" id=1]
extents = Vector2( 40, 60 )
[sub_resource type="RectangleShape2D" id="1"]
size = Vector2(80, 120)
[sub_resource type="CircleShape2D" id=2]
[sub_resource type="CircleShape2D" id="2"]
radius = 60.0
[sub_resource type="CapsuleShape2D" id=3]
[sub_resource type="CapsuleShape2D" id="3"]
radius = 30.0
height = 50.0
height = 110.0
[sub_resource type="ConcavePolygonShape2D" id=4]
segments = PoolVector2Array( -5.93512, -43.2195, 6.44476, -42.9695, 6.44476, -42.9695, 11.127, -54.3941, 11.127, -54.3941, 26.9528, -49.4309, 26.9528, -49.4309, 26.2037, -36.508, 26.2037, -36.508, 37.5346, -28.1737, 37.5346, -28.1737, 47.6282, -34.3806, 47.6282, -34.3806, 58.0427, -20.9631, 58.0427, -20.9631, 51.113, -10.2876, 51.113, -10.2876, 50.9869, 35.2694, 50.9869, 35.2694, 38.8, 47.5, 38.8, 47.5, 15.9852, 54.3613, 15.9852, 54.3613, -14.9507, 54.1845, -14.9507, 54.1845, -36.5, 48.1, -36.5, 48.1, -50.4828, 36.33, -50.4828, 36.33, -51.3668, -9.98545, -51.3668, -9.98545, -57.8889, -20.5885, -57.8889, -20.5885, -46.9473, -34.7342, -46.9473, -34.7342, -37.4014, -28.547, -37.4014, -28.547, -26.0876, -37.0323, -26.0876, -37.0323, -26.9862, -49.15, -26.9862, -49.15, -11.4152, -54.5332, -11.4152, -54.5332, -5.93512, -43.2195 )
[sub_resource type="ConcavePolygonShape2D" id="4"]
segments = PackedVector2Array(-5.93512, -43.2195, 6.44476, -42.9695, 6.44476, -42.9695, 11.127, -54.3941, 11.127, -54.3941, 26.9528, -49.4309, 26.9528, -49.4309, 26.2037, -36.508, 26.2037, -36.508, 37.5346, -28.1737, 37.5346, -28.1737, 47.6282, -34.3806, 47.6282, -34.3806, 58.0427, -20.9631, 58.0427, -20.9631, 51.113, -10.2876, 51.113, -10.2876, 50.9869, 35.2694, 50.9869, 35.2694, 38.8, 47.5, 38.8, 47.5, 15.9852, 54.3613, 15.9852, 54.3613, -14.9507, 54.1845, -14.9507, 54.1845, -36.5, 48.1, -36.5, 48.1, -50.4828, 36.33, -50.4828, 36.33, -51.3668, -9.98545, -51.3668, -9.98545, -57.8889, -20.5885, -57.8889, -20.5885, -46.9473, -34.7342, -46.9473, -34.7342, -37.4014, -28.547, -37.4014, -28.547, -26.0876, -37.0323, -26.0876, -37.0323, -26.9862, -49.15, -26.9862, -49.15, -11.4152, -54.5332, -11.4152, -54.5332, -5.93512, -43.2195)
[node name="Test" type="Node2D"]
script = ExtResource( 1 )
script = ExtResource( "1" )
[node name="Options" parent="." instance=ExtResource( 3 )]
[node name="Options" parent="." instance=ExtResource( "3" )]
[node name="Shapes" type="Node2D" parent="."]
z_index = -1
z_as_relative = false
[node name="RigidBodyRectangle" type="RigidBody2D" parent="Shapes"]
position = Vector2( 114.877, 248.76 )
mode = 1
[node name="RigidBodyRectangle" type="RigidDynamicBody2D" parent="Shapes"]
position = Vector2(114.877, 248.76)
freeze = true
[node name="CollisionShape2D" type="CollisionShape2D" parent="Shapes/RigidBodyRectangle"]
rotation = -1.19206
scale = Vector2( 1.2, 1.2 )
shape = SubResource( 1 )
scale = Vector2(1.2, 1.2)
shape = SubResource( "1" )
[node name="RigidBodySphere" type="RigidBody2D" parent="Shapes"]
position = Vector2( 314.894, 257.658 )
mode = 1
[node name="RigidBodySphere" type="RigidDynamicBody2D" parent="Shapes"]
position = Vector2(314.894, 257.658)
freeze = true
[node name="CollisionShape2D" type="CollisionShape2D" parent="Shapes/RigidBodySphere"]
shape = SubResource( 2 )
shape = SubResource( "2" )
[node name="RigidBodyCapsule" type="RigidBody2D" parent="Shapes"]
position = Vector2( 465.629, 261.204 )
mode = 1
[node name="RigidBodyCapsule" type="RigidDynamicBody2D" parent="Shapes"]
position = Vector2(465.629, 261.204)
freeze = true
[node name="CollisionShape2D" type="CollisionShape2D" parent="Shapes/RigidBodyCapsule"]
rotation = -0.202458
scale = Vector2( 1.2, 1.2 )
shape = SubResource( 3 )
scale = Vector2(1.2, 1.2)
shape = SubResource( "3" )
[node name="RigidBodyConvexPolygon" type="RigidBody2D" parent="Shapes"]
position = Vector2( 613.385, 252.771 )
mode = 1
[node name="RigidBodyConvexPolygon" type="RigidDynamicBody2D" parent="Shapes"]
position = Vector2(613.385, 252.771)
freeze = true
[node name="CollisionPolygon2D" type="CollisionPolygon2D" parent="Shapes/RigidBodyConvexPolygon"]
polygon = PoolVector2Array( 10.7, -54.5, 28.3596, -49.4067, 47.6282, -34.3806, 57.9717, -20.9447, 50.9869, 35.2694, 38.8, 47.5, 15.9852, 54.3613, -14.9507, 54.1845, -36.5, 48.1, -50.4828, 36.33, -58.0115, -20.515, -46.9473, -34.7342, -26.0876, -50.1138, -11.4152, -54.5332 )
polygon = PackedVector2Array(10.7, -54.5, 28.3596, -49.4067, 47.6282, -34.3806, 57.9717, -20.9447, 50.9869, 35.2694, 38.8, 47.5, 15.9852, 54.3613, -14.9507, 54.1845, -36.5, 48.1, -50.4828, 36.33, -58.0115, -20.515, -46.9473, -34.7342, -26.0876, -50.1138, -11.4152, -54.5332)
[node name="GodotIcon" type="Sprite" parent="Shapes/RigidBodyConvexPolygon"]
modulate = Color( 1, 1, 1, 0.392157 )
texture = ExtResource( 2 )
[node name="GodotIcon" type="Sprite2D" parent="Shapes/RigidBodyConvexPolygon"]
modulate = Color(1, 1, 1, 0.392157)
texture = ExtResource( "2" )
[node name="RigidBodyConcavePolygon" type="RigidBody2D" parent="Shapes"]
position = Vector2( 771.159, 252.771 )
mode = 1
[node name="RigidBodyConcavePolygon" type="RigidDynamicBody2D" parent="Shapes"]
position = Vector2(771.159, 252.771)
freeze = true
[node name="CollisionPolygon2D" type="CollisionPolygon2D" parent="Shapes/RigidBodyConcavePolygon"]
polygon = PoolVector2Array( -5.93512, -43.2195, 6.44476, -42.9695, 11.127, -54.3941, 26.9528, -49.4309, 26.2037, -36.508, 37.5346, -28.1737, 47.6282, -34.3806, 58.0427, -20.9631, 51.113, -10.2876, 50.9869, 35.2694, 38.8, 47.5, 15.9852, 54.3613, -14.9507, 54.1845, -36.5, 48.1, -50.4828, 36.33, -51.3668, -9.98545, -57.8889, -20.5885, -46.9473, -34.7342, -37.4014, -28.547, -26.0876, -37.0323, -26.9862, -49.15, -11.4152, -54.5332 )
polygon = PackedVector2Array(-5.93512, -43.2195, 6.44476, -42.9695, 11.127, -54.3941, 26.9528, -49.4309, 26.2037, -36.508, 37.5346, -28.1737, 47.6282, -34.3806, 58.0427, -20.9631, 51.113, -10.2876, 50.9869, 35.2694, 38.8, 47.5, 15.9852, 54.3613, -14.9507, 54.1845, -36.5, 48.1, -50.4828, 36.33, -51.3668, -9.98545, -57.8889, -20.5885, -46.9473, -34.7342, -37.4014, -28.547, -26.0876, -37.0323, -26.9862, -49.15, -11.4152, -54.5332)
[node name="GodotIcon" type="Sprite" parent="Shapes/RigidBodyConcavePolygon"]
modulate = Color( 1, 1, 1, 0.392157 )
texture = ExtResource( 2 )
[node name="GodotIcon" type="Sprite2D" parent="Shapes/RigidBodyConcavePolygon"]
modulate = Color(1, 1, 1, 0.392157)
texture = ExtResource( "2" )
[node name="RigidBodyConcaveSegments" type="RigidBody2D" parent="Shapes"]
position = Vector2( 930.097, 252.771 )
mode = 1
[node name="RigidBodyConcaveSegments" type="RigidDynamicBody2D" parent="Shapes"]
position = Vector2(930.097, 252.771)
freeze = true
[node name="CollisionShape2D" type="CollisionShape2D" parent="Shapes/RigidBodyConcaveSegments"]
shape = SubResource( 4 )
shape = SubResource( "4" )
[node name="GodotIcon" type="Sprite" parent="Shapes/RigidBodyConcaveSegments"]
modulate = Color( 1, 1, 1, 0.392157 )
texture = ExtResource( 2 )
[node name="GodotIcon" type="Sprite2D" parent="Shapes/RigidBodyConcaveSegments"]
modulate = Color(1, 1, 1, 0.392157)
texture = ExtResource( "2" )
[node name="Controls" type="VBoxContainer" parent="."]
pause_mode = 2
anchor_right = 1.0
anchor_bottom = 1.0
margin_left = 25.3619
margin_top = 416.765
margin_right = 218.362
margin_bottom = 458.765
custom_constants/separation = 10
offset_left = 25.3619
offset_top = 416.765
offset_right = 218.362
offset_bottom = 458.765
theme_override_constants/separation = 10
__meta__ = {
"_edit_use_anchors_": false
}
[node name="OffsetH" type="HBoxContainer" parent="Controls"]
margin_right = 193.0
margin_bottom = 16.0
custom_constants/separation = 20
offset_right = 204.0
offset_bottom = 26.0
theme_override_constants/separation = 20
alignment = 2
__meta__ = {
"_edit_use_anchors_": false
}
[node name="Label" type="Label" parent="Controls/OffsetH"]
margin_top = 1.0
margin_right = 53.0
margin_bottom = 15.0
offset_right = 64.0
offset_bottom = 26.0
text = "Offset H"
[node name="HSlider" type="HSlider" parent="Controls/OffsetH"]
margin_left = 73.0
margin_right = 193.0
margin_bottom = 16.0
rect_min_size = Vector2( 120, 0 )
offset_left = 84.0
offset_right = 204.0
offset_bottom = 16.0
rect_min_size = Vector2(120, 0)
min_value = -1.0
max_value = 1.0
step = 0.01
[node name="OffsetV" type="HBoxContainer" parent="Controls"]
margin_top = 26.0
margin_right = 193.0
margin_bottom = 42.0
custom_constants/separation = 20
offset_top = 36.0
offset_right = 204.0
offset_bottom = 62.0
theme_override_constants/separation = 20
alignment = 2
__meta__ = {
"_edit_use_anchors_": false
}
[node name="Label" type="Label" parent="Controls/OffsetV"]
margin_left = 2.0
margin_top = 1.0
margin_right = 53.0
margin_bottom = 15.0
offset_left = 2.0
offset_right = 64.0
offset_bottom = 26.0
text = "Offset V"
[node name="HSlider" type="HSlider" parent="Controls/OffsetV"]
margin_left = 73.0
margin_right = 193.0
margin_bottom = 16.0
rect_min_size = Vector2( 120, 0 )
offset_left = 84.0
offset_right = 204.0
offset_bottom = 16.0
rect_min_size = Vector2(120, 0)
min_value = -1.0
max_value = 1.0
step = 0.01

View File

@@ -31,7 +31,7 @@ func _ready():
for joint_index in range(joints.get_child_count()):
var joint_node = joints.get_child(joint_index)
joint_node.visible = false
var joint_name = joint_node.name
var joint_name = String(joint_node.name)
var joint_short = joint_name.substr(0, joint_name.length() - 7)
var option_name = OPTION_JOINT_TYPE % [joint_short, joint_index + 1]
options.add_menu_item(option_name)
@@ -43,8 +43,8 @@ func _ready():
options.add_menu_item(OPTION_TEST_CASE_DESTROY_BODY, true, false)
options.add_menu_item(OPTION_TEST_CASE_CHANGE_POSITIONS, true, false)
options.connect("option_selected", self, "_on_option_selected")
options.connect("option_changed", self, "_on_option_changed")
options.connect("option_selected", Callable(self, "_on_option_selected"))
options.connect("option_changed", Callable(self, "_on_option_changed"))
_selected_joint = _joint_types.values()[0]
_update_joint = true
@@ -53,14 +53,14 @@ func _ready():
func _process(_delta):
if _update_joint:
_update_joint = false
_create_joint()
$LabelJointType.text = "Joint Type: " + _selected_joint.name
await _create_joint()
$LabelJointType.text = "Joint Type: " + String(_selected_joint.name)
func _input(event):
var key_event = event as InputEventKey
if key_event and not key_event.pressed:
var joint_index = key_event.scancode - KEY_1
var joint_index = key_event.keycode - KEY_1
if joint_index >= 0 and joint_index < _joint_types.size():
_selected_joint = _joint_types.values()[joint_index]
_update_joint = true
@@ -103,7 +103,6 @@ func _create_joint():
last_child.queue_free()
var child_body = create_rigidbody_box(BOX_SIZE, true, true)
child_body.mode = RigidBody2D.MODE_RIGID
if _change_positions:
root.add_child(child_body)
child_body.position = Vector2(0.0, 40)
@@ -115,11 +114,10 @@ func _create_joint():
if not _world_attachement:
parent_body = create_rigidbody_box(BOX_SIZE, true, true)
if _dynamic_attachement:
parent_body.mode = RigidBody2D.MODE_RIGID
parent_body.gravity_scale = 0.0
child_body.gravity_scale = 0.0
else:
parent_body.mode = RigidBody2D.MODE_STATIC
parent_body.freeze = true
if _change_positions:
root.add_child(parent_body)
parent_body.position = Vector2(0.0, -40)
@@ -130,13 +128,13 @@ func _create_joint():
var joint = _selected_joint.duplicate()
joint.visible = true
joint.disable_collision = not _bodies_collide
if parent_body:
joint.node_a = parent_body.get_path()
joint.node_b = child_body.get_path()
root.add_child(joint)
if parent_body:
joint.set_node_a(joint.get_path_to(parent_body))
joint.set_node_b(joint.get_path_to(child_body))
if _destroy_body:
yield(start_timer(0.5), "timeout")
await start_timer(0.5).timeout
if is_timer_canceled():
return

View File

@@ -1,25 +1,25 @@
[gd_scene load_steps=3 format=2]
[gd_scene load_steps=3 format=3 uid="uid://bckpvilds8sif"]
[ext_resource path="res://tests/functional/test_joints.gd" type="Script" id=2]
[ext_resource path="res://tests/test_options.tscn" type="PackedScene" id=4]
[ext_resource type="Script" path="res://tests/functional/test_joints.gd" id="2"]
[ext_resource type="PackedScene" uid="uid://blh3twy74kbkv" path="res://tests/test_options.tscn" id="4"]
[node name="JointTest2D" type="Node2D"]
script = ExtResource( 2 )
script = ExtResource( "2" )
[node name="LabelJointType" type="Label" parent="."]
margin_left = 14.0
margin_top = 79.0
margin_right = 145.0
margin_bottom = 93.0
offset_left = 14.0
offset_top = 79.0
offset_right = 145.0
offset_bottom = 93.0
text = "Joint Type: "
__meta__ = {
"_edit_use_anchors_": false
}
[node name="Options" parent="." instance=ExtResource( 4 )]
[node name="Options" parent="." instance=ExtResource( "4" )]
[node name="Joints" type="Node2D" parent="."]
position = Vector2( 512, 200 )
position = Vector2(512, 200)
[node name="PinJoint2D" type="PinJoint2D" parent="Joints"]
@@ -28,4 +28,4 @@ position = Vector2( 512, 200 )
[node name="GrooveJoint2D" type="GrooveJoint2D" parent="Joints"]
[node name="Objects" type="Node2D" parent="."]
position = Vector2( 512, 200 )
position = Vector2(512, 200)

View File

@@ -1,41 +1,62 @@
@tool
extends Test
tool
signal all_tests_done()
signal test_done()
const OPTION_OBJECT_TYPE_RIGIDBODY = "Object type/Rigid body (1)"
const OPTION_OBJECT_TYPE_KINEMATIC = "Object type/Kinematic body (2)"
const OPTION_OBJECT_TYPE_CHARACTER = "Object type/Character body (2)"
const OPTION_TEST_CASE_ALL = "Test Cases/TEST ALL (0)"
const OPTION_TEST_CASE_ALL_RIGID = "Test Cases/All Rigid Body tests"
const OPTION_TEST_CASE_ALL_KINEMATIC = "Test Cases/All Kinematic Body tests"
const OPTION_TEST_CASE_ALL_CHARACTER = "Test Cases/All Character Body tests"
const OPTION_TEST_CASE_ALL_ANGLES_RIGID = "Test Cases/Around the clock (Rigid Body)"
const OPTION_TEST_CASE_ALL_ANGLES_KINEMATIC = "Test Cases/Around the clock (Kinematic Body)"
const OPTION_TEST_CASE_ALL_ANGLES_CHARACTER = "Test Cases/Around the clock (Character Body)"
const OPTION_TEST_CASE_MOVING_PLATFORM_RIGID = "Test Cases/Moving Platform (Rigid Body)"
const OPTION_TEST_CASE_MOVING_PLATFORM_KINEMATIC = "Test Cases/Moving Platform (Kinematic Body)"
const OPTION_TEST_CASE_MOVING_PLATFORM_CHARACTER = "Test Cases/Moving Platform (Character Body)"
const TEST_ALL_ANGLES_STEP = 15.0
const TEST_ALL_ANGLES_MAX = 344.0
export(float, 32, 128, 0.1) var _platform_size = 64.0 setget _set_platform_size
export(float, 0, 360, 0.1) var _platform_angle = 0.0 setget _set_platform_angle
export(float) var _platform_speed = 0.0
export(float, 0, 360, 0.1) var _body_angle = 0.0 setget _set_rigidbody_angle
export(Vector2) var _body_velocity = Vector2(400.0, 0.0)
export(bool) var _use_kinematic_body = false
@export_range(64, 256, 0.1) var _platform_size = 128.0:
set(value):
if value == _platform_size:
return
_platform_size = value
_update_platform_size(value)
onready var options = $Options
@export_range(0, 360, 0.1) var _platform_angle = 0.0:
set(value):
if value == _platform_angle:
return
_platform_angle = value
_update_platform_angle(value)
@export var _platform_speed = 0.0
@export_range(0, 360, 0.1) var _body_angle = 0.0:
set(value):
if value == _body_angle:
return
_body_angle = value
_update_rigidbody_angle(value)
@export var _body_velocity = Vector2(400.0, 0.0)
@export var _use_character_body = false
@onready var options = $Options
var _rigid_body_template = null
var _kinematic_body_template = null
var _moving_body = null
var _character_body_template = null
var _moving_body : PhysicsBody2D = null
var _platform_template = null
var _platform_body = null
var _platform_body : PhysicsBody2D = null
var _platform_velocity = Vector2.ZERO
@onready var _target_area = $TargetArea2D
var _contact_detected = false
var _target_entered = false
var _test_passed = false
@@ -48,53 +69,56 @@ var _test_canceled = false
func _ready():
if not Engine.editor_hint:
options.add_menu_item(OPTION_OBJECT_TYPE_RIGIDBODY, true, not _use_kinematic_body, true)
options.add_menu_item(OPTION_OBJECT_TYPE_KINEMATIC, true, _use_kinematic_body, true)
if not Engine.is_editor_hint():
options.add_menu_item(OPTION_OBJECT_TYPE_RIGIDBODY, true, not _use_character_body, true)
options.add_menu_item(OPTION_OBJECT_TYPE_CHARACTER, true, _use_character_body, true)
options.add_menu_item(OPTION_TEST_CASE_ALL)
options.add_menu_item(OPTION_TEST_CASE_ALL_RIGID)
options.add_menu_item(OPTION_TEST_CASE_ALL_KINEMATIC)
options.add_menu_item(OPTION_TEST_CASE_ALL_CHARACTER)
options.add_menu_item(OPTION_TEST_CASE_ALL_ANGLES_RIGID)
options.add_menu_item(OPTION_TEST_CASE_ALL_ANGLES_KINEMATIC)
options.add_menu_item(OPTION_TEST_CASE_ALL_ANGLES_CHARACTER)
options.add_menu_item(OPTION_TEST_CASE_MOVING_PLATFORM_RIGID)
options.add_menu_item(OPTION_TEST_CASE_MOVING_PLATFORM_KINEMATIC)
options.add_menu_item(OPTION_TEST_CASE_MOVING_PLATFORM_CHARACTER)
options.connect("option_selected", self, "_on_option_selected")
options.connect("option_selected", Callable(self, "_on_option_selected"))
$Controls/PlatformSize/HSlider.value = _platform_size
$Controls/PlatformAngle/HSlider.value = _platform_angle
$Controls/BodyAngle/HSlider.value = _body_angle
$TargetArea2D.connect("body_entered", self, "_on_target_entered")
$Timer.connect("timeout", self, "_on_timeout")
remove_child(_target_area)
_target_area.connect("body_entered", Callable(self, "_on_target_entered"))
$Timer.connect("timeout", Callable(self, "_on_timeout"))
_rigid_body_template = $RigidBody2D
remove_child(_rigid_body_template)
_kinematic_body_template = $KinematicBody2D
remove_child(_kinematic_body_template)
_character_body_template = $CharacterBody2D
remove_child(_character_body_template)
_platform_template = $OneWayKinematicBody2D
_platform_template = $OneWayStaticBody2D
remove_child(_platform_template)
_start_test()
func _process(_delta):
if not Engine.editor_hint:
if not Engine.is_editor_hint():
if Input.is_action_just_pressed("ui_accept"):
_reset_test(false)
await _reset_test(false)
func _physics_process(delta):
if not Engine.editor_hint:
super._physics_process(delta)
if not Engine.is_editor_hint():
if _moving_body and not _contact_detected:
if _use_kinematic_body:
var collision = _moving_body.move_and_collide(_body_velocity * delta, false)
if _use_character_body:
var collision = _moving_body.move_and_collide(_body_velocity, false)
if collision:
var colliding_body = collision.collider
_on_contact_detected(colliding_body)
var colliding_body = collision.get_collider()
await _on_contact_detected(colliding_body)
if _platform_body and _platform_velocity != Vector2.ZERO:
var motion = _platform_velocity * delta
@@ -104,33 +128,33 @@ func _physics_process(delta):
func _input(event):
var key_event = event as InputEventKey
if key_event and not key_event.pressed:
if key_event.scancode == KEY_0:
_on_option_selected(OPTION_TEST_CASE_ALL)
if key_event.scancode == KEY_1:
_on_option_selected(OPTION_OBJECT_TYPE_RIGIDBODY)
elif key_event.scancode == KEY_2:
_on_option_selected(OPTION_OBJECT_TYPE_KINEMATIC)
if key_event.keycode == KEY_0:
await _on_option_selected(OPTION_TEST_CASE_ALL)
if key_event.keycode == KEY_1:
await _on_option_selected(OPTION_OBJECT_TYPE_RIGIDBODY)
elif key_event.keycode == KEY_2:
await _on_option_selected(OPTION_OBJECT_TYPE_CHARACTER)
func _exit_tree():
if not Engine.editor_hint:
if not Engine.is_editor_hint():
_rigid_body_template.free()
_kinematic_body_template.free()
_character_body_template.free()
_platform_template.free()
func _set_platform_size(value, reset = true):
func _update_platform_size(value, reset = true):
if _lock_controls:
return
if value == _platform_size:
return
_platform_size = value
if is_inside_tree():
if Engine.editor_hint:
$OneWayKinematicBody2D/CollisionShape2D.shape.extents.x = value
if Engine.is_editor_hint():
$OneWayStaticBody2D/CollisionShape2D.shape.size.x = value
else:
var platform_collision = _platform_template.get_child(0)
platform_collision.shape.extents.x = value
platform_collision.shape.size.x = value
if _platform_body:
# Bug: need to re-add when changing shape.
var child_index = _platform_body.get_index()
@@ -138,137 +162,137 @@ func _set_platform_size(value, reset = true):
add_child(_platform_body)
move_child(_platform_body, child_index)
if reset:
_reset_test()
await _reset_test()
func _set_platform_angle(value, reset = true):
func _update_platform_angle(value, reset = true):
if _lock_controls:
return
if value == _platform_angle:
return
_platform_angle = value
if is_inside_tree():
if Engine.editor_hint:
$OneWayKinematicBody2D.rotation = deg2rad(value)
if Engine.is_editor_hint():
$OneWayStaticBody2D.rotation = deg2rad(value)
else:
if _platform_body:
_platform_body.rotation = deg2rad(value)
_platform_template.rotation = deg2rad(value)
if reset:
_reset_test()
await _reset_test()
func _set_rigidbody_angle(value, reset = true):
func _update_rigidbody_angle(value, reset = true):
if _lock_controls:
return
if value == _body_angle:
return
_body_angle = value
if is_inside_tree():
if Engine.editor_hint:
if Engine.is_editor_hint():
$RigidBody2D.rotation = deg2rad(value)
$KinematicBody2D.rotation = deg2rad(value)
$CharacterBody2D.rotation = deg2rad(value)
else:
if _moving_body:
_moving_body.rotation = deg2rad(value)
_rigid_body_template.rotation = deg2rad(value)
_kinematic_body_template.rotation = deg2rad(value)
_character_body_template.rotation = deg2rad(value)
if reset:
_reset_test()
await _reset_test()
func _on_option_selected(option):
match option:
OPTION_OBJECT_TYPE_KINEMATIC:
_use_kinematic_body = true
_reset_test()
OPTION_OBJECT_TYPE_CHARACTER:
_use_character_body = true
await _reset_test()
OPTION_OBJECT_TYPE_RIGIDBODY:
_use_kinematic_body = false
_reset_test()
_use_character_body = false
await _reset_test()
OPTION_TEST_CASE_ALL:
_test_all()
await _test_all()
OPTION_TEST_CASE_ALL_RIGID:
_test_all_rigid_body()
OPTION_TEST_CASE_ALL_KINEMATIC:
_test_all_kinematic_body()
await _test_all_rigid_body()
OPTION_TEST_CASE_ALL_CHARACTER:
await _test_all_character_body()
OPTION_TEST_CASE_ALL_ANGLES_RIGID:
_use_kinematic_body = false
_use_character_body = false
_test_all_angles = true
_reset_test(false)
OPTION_TEST_CASE_ALL_ANGLES_KINEMATIC:
_use_kinematic_body = true
await _reset_test(false)
OPTION_TEST_CASE_ALL_ANGLES_CHARACTER:
_use_character_body = true
_test_all_angles = true
_reset_test(false)
await _reset_test(false)
OPTION_TEST_CASE_MOVING_PLATFORM_RIGID:
_use_kinematic_body = false
_test_moving_platform()
OPTION_TEST_CASE_MOVING_PLATFORM_KINEMATIC:
_use_kinematic_body = true
_test_moving_platform()
_use_character_body = false
await _test_moving_platform()
OPTION_TEST_CASE_MOVING_PLATFORM_CHARACTER:
_use_character_body = true
await _test_moving_platform()
func _start_test_case(option):
Log.print_log("* Starting " + option)
_on_option_selected(option)
await _on_option_selected(option)
yield(self, "all_tests_done")
await self.all_tests_done
func _wait_for_test():
_reset_test()
await _reset_test()
yield(self, "test_done")
await self.test_done
func _test_all_rigid_body():
Log.print_log("* All RigidBody test cases...")
_set_platform_size(64.0, false)
_set_rigidbody_angle(0.0, false)
yield(_start_test_case(OPTION_TEST_CASE_ALL_ANGLES_RIGID), "completed")
await _update_platform_size(128.0, false)
await _update_rigidbody_angle(0.0, false)
await _start_test_case(OPTION_TEST_CASE_ALL_ANGLES_RIGID)
if _test_canceled:
return
_set_platform_size(64.0, false)
_set_rigidbody_angle(45.0, false)
yield(_start_test_case(OPTION_TEST_CASE_ALL_ANGLES_RIGID), "completed")
await _update_platform_size(128.0, false)
await _update_rigidbody_angle(45.0, false)
await _start_test_case(OPTION_TEST_CASE_ALL_ANGLES_RIGID)
if _test_canceled:
return
_set_platform_size(32.0, false)
_set_rigidbody_angle(45.0, false)
yield(_start_test_case(OPTION_TEST_CASE_ALL_ANGLES_RIGID), "completed")
await _update_platform_size(64.0, false)
await _update_rigidbody_angle(45.0, false)
await _start_test_case(OPTION_TEST_CASE_ALL_ANGLES_RIGID)
if _test_canceled:
return
yield(_start_test_case(OPTION_TEST_CASE_MOVING_PLATFORM_RIGID), "completed")
await _start_test_case(OPTION_TEST_CASE_MOVING_PLATFORM_RIGID)
if _test_canceled:
return
func _test_all_kinematic_body():
Log.print_log("* All KinematicBody test cases...")
func _test_all_character_body():
Log.print_log("* All CharacterBody test cases...")
_set_platform_size(64.0, false)
_set_rigidbody_angle(0.0, false)
yield(_start_test_case(OPTION_TEST_CASE_ALL_ANGLES_KINEMATIC), "completed")
await _update_platform_size(128.0, false)
await _update_rigidbody_angle(0.0, false)
await _start_test_case(OPTION_TEST_CASE_ALL_ANGLES_CHARACTER)
if _test_canceled:
return
_set_platform_size(64.0, false)
_set_rigidbody_angle(45.0, false)
yield(_start_test_case(OPTION_TEST_CASE_ALL_ANGLES_KINEMATIC), "completed")
await _update_platform_size(128.0, false)
await _update_rigidbody_angle(45.0, false)
await _start_test_case(OPTION_TEST_CASE_ALL_ANGLES_CHARACTER)
if _test_canceled:
return
_set_platform_size(32.0, false)
_set_rigidbody_angle(45.0, false)
yield(_start_test_case(OPTION_TEST_CASE_ALL_ANGLES_KINEMATIC), "completed")
await _update_platform_size(64.0, false)
await _update_rigidbody_angle(45.0, false)
await _start_test_case(OPTION_TEST_CASE_ALL_ANGLES_CHARACTER)
if _test_canceled:
return
yield(_start_test_case(OPTION_TEST_CASE_MOVING_PLATFORM_KINEMATIC), "completed")
await _start_test_case(OPTION_TEST_CASE_MOVING_PLATFORM_CHARACTER)
if _test_canceled:
return
@@ -277,32 +301,32 @@ func _test_moving_platform():
Log.print_log("* Start moving platform tests")
Log.print_log("* Platform moving away from body...")
_set_platform_size(64.0, false)
_set_rigidbody_angle(0.0, false)
await _update_platform_size(128.0, false)
await _update_rigidbody_angle(0.0, false)
_platform_speed = 50.0
_set_platform_angle(90.0, false)
yield(_wait_for_test(), "completed")
await _update_platform_angle(90.0, false)
await _wait_for_test()
if _test_canceled:
return
_set_platform_angle(-90.0, false)
yield(_wait_for_test(), "completed")
await _update_platform_angle(-90.0, false)
await _wait_for_test()
if _test_canceled:
return
Log.print_log("* Platform moving towards body...")
_set_platform_size(64.0, false)
_set_rigidbody_angle(0.0, false)
await _update_platform_size(128.0, false)
await _update_rigidbody_angle(0.0, false)
_platform_speed = -50.0
_set_platform_angle(90.0, false)
yield(_wait_for_test(), "completed")
await _update_platform_angle(90.0, false)
await _wait_for_test()
if _test_canceled:
return
_set_platform_angle(-90.0, false)
yield(_wait_for_test(), "completed")
await _update_platform_angle(-90.0, false)
await _wait_for_test()
if _test_canceled:
return
@@ -313,11 +337,11 @@ func _test_moving_platform():
func _test_all():
Log.print_log("* TESTING ALL...")
yield(_test_all_rigid_body(), "completed")
await _test_all_rigid_body()
if _test_canceled:
return
yield(_test_all_kinematic_body(), "completed")
await _test_all_character_body()
if _test_canceled:
return
@@ -330,6 +354,7 @@ func _start_test():
var platform_angle = _platform_template.rotation
if _platform_body:
platform_angle = _platform_body.rotation
_platform_body.remove_child(_target_area)
remove_child(_platform_body)
_platform_body.queue_free()
_platform_body = null
@@ -338,14 +363,17 @@ func _start_test():
_platform_body.rotation = platform_angle
add_child(_platform_body)
if _use_kinematic_body:
test_label += _kinematic_body_template.name
_moving_body = _kinematic_body_template.duplicate()
_platform_body.add_child(_target_area)
_target_area.position = Vector2()
if _use_character_body:
test_label += String(_character_body_template.name)
_moving_body = _character_body_template.duplicate()
else:
test_label += _rigid_body_template.name
test_label += String(_rigid_body_template.name)
_moving_body = _rigid_body_template.duplicate()
_moving_body.linear_velocity = _body_velocity
_moving_body.connect("body_entered", self, "_on_contact_detected")
_moving_body.connect("body_entered", Callable(self, "_on_contact_detected"))
add_child(_moving_body)
if _platform_speed != 0.0:
@@ -369,12 +397,12 @@ func _start_test():
$Timer.start()
$LabelResult.text = "..."
$LabelResult.self_modulate = Color.white
$LabelResult.self_modulate = Color.WHITE
func _reset_test(cancel_test = true):
_test_canceled = true
_on_timeout()
await _on_timeout()
_test_canceled = false
_test_step = 0
@@ -427,17 +455,20 @@ func _on_contact_detected(_body):
_contact_detected = true
_test_passed = _should_collide()
_set_result()
_on_timeout()
await _on_timeout()
func _on_target_entered(_body):
if _body != _moving_body:
return
if _contact_detected or _target_entered:
return
_target_entered = true
_test_passed = not _should_collide()
_set_result()
_on_timeout()
await _on_timeout()
func _should_collide():
@@ -464,7 +495,7 @@ func _on_timeout():
Log.print_log("Test TIMEOUT")
_set_result()
yield(start_timer(0.5), "timeout")
await start_timer(0.5).timeout
if _test_canceled:
emit_signal("test_done")
emit_signal("all_tests_done")
@@ -484,10 +515,10 @@ func _set_result():
var result = ""
if _test_passed:
result = "PASSED"
$LabelResult.self_modulate = Color.green
$LabelResult.self_modulate = Color.GREEN
else:
result = "FAILED"
$LabelResult.self_modulate = Color.red
$LabelResult.self_modulate = Color.RED
$LabelResult.text = result

View File

@@ -1,161 +1,154 @@
[gd_scene load_steps=9 format=2]
[gd_scene load_steps=9 format=3 uid="uid://c85275leeliuq"]
[ext_resource path="res://tests/functional/test_one_way_collision.gd" type="Script" id=1]
[ext_resource path="res://icon.png" type="Texture" id=2]
[ext_resource path="res://tests/test_options.tscn" type="PackedScene" id=3]
[ext_resource path="res://utils/label_slider_value.gd" type="Script" id=4]
[ext_resource path="res://utils/slider.gd" type="Script" id=5]
[ext_resource type="Script" path="res://tests/functional/test_one_way_collision.gd" id="1"]
[ext_resource type="Texture2D" uid="uid://cpps5r8o4dfwo" path="res://icon.png" id="2"]
[ext_resource type="PackedScene" uid="uid://blh3twy74kbkv" path="res://tests/test_options.tscn" id="3"]
[ext_resource type="Script" path="res://utils/label_slider_value.gd" id="4"]
[ext_resource type="Script" path="res://utils/slider.gd" id="5"]
[sub_resource type="RectangleShape2D" id=1]
extents = Vector2( 32, 32 )
[sub_resource type="CircleShape2D" id="CircleShape2D_e5nt1"]
radius = 16.0
[sub_resource type="RectangleShape2D" id=2]
extents = Vector2( 64, 32 )
[sub_resource type="RectangleShape2D" id="2"]
size = Vector2(128, 64)
[sub_resource type="RectangleShape2D" id=3]
extents = Vector2( 32, 32 )
[sub_resource type="RectangleShape2D" id="3"]
size = Vector2(64, 64)
[node name="Test" type="Node2D"]
script = ExtResource( 1 )
script = ExtResource( "1" )
[node name="LabelTestType" type="Label" parent="."]
margin_left = 14.0
margin_top = 79.0
margin_right = 145.0
margin_bottom = 93.0
offset_left = 14.0
offset_top = 79.0
offset_right = 145.0
offset_bottom = 93.0
text = "Testing: "
__meta__ = {
"_edit_use_anchors_": false
}
[node name="Options" parent="." instance=ExtResource( 3 )]
[node name="Options" parent="." instance=ExtResource( "3" )]
[node name="Controls" type="VBoxContainer" parent="."]
pause_mode = 2
anchor_right = 1.0
anchor_bottom = 1.0
margin_left = 25.3619
margin_top = 416.765
margin_right = 265.362
margin_bottom = 484.765
custom_constants/separation = 10
offset_left = 25.3619
offset_top = 416.765
offset_right = 265.362
offset_bottom = 484.765
theme_override_constants/separation = 10
__meta__ = {
"_edit_use_anchors_": false
}
[node name="PlatformSize" type="HBoxContainer" parent="Controls"]
margin_right = 432.0
margin_bottom = 16.0
custom_constants/separation = 20
offset_right = 452.0
offset_bottom = 26.0
theme_override_constants/separation = 20
alignment = 2
__meta__ = {
"_edit_use_anchors_": false
}
[node name="Label" type="Label" parent="Controls/PlatformSize"]
margin_left = 8.0
margin_top = 1.0
margin_right = 92.0
margin_bottom = 15.0
offset_left = 12.0
offset_right = 112.0
offset_bottom = 26.0
text = "Platform size"
[node name="HSlider" type="HSlider" parent="Controls/PlatformSize"]
margin_left = 112.0
margin_right = 312.0
margin_bottom = 16.0
rect_min_size = Vector2( 200, 0 )
min_value = 32.0
max_value = 128.0
offset_left = 132.0
offset_right = 332.0
offset_bottom = 16.0
rect_min_size = Vector2(200, 0)
min_value = 64.0
max_value = 256.0
value = 64.0
script = ExtResource( 5 )
script = ExtResource( "5" )
[node name="LabelValue" type="Label" parent="Controls/PlatformSize"]
margin_left = 332.0
margin_top = 1.0
margin_right = 432.0
margin_bottom = 15.0
rect_min_size = Vector2( 100, 0 )
offset_left = 352.0
offset_right = 452.0
offset_bottom = 26.0
rect_min_size = Vector2(100, 0)
text = "64.0"
script = ExtResource( 4 )
script = ExtResource( "4" )
[node name="PlatformAngle" type="HBoxContainer" parent="Controls"]
margin_top = 26.0
margin_right = 432.0
margin_bottom = 42.0
custom_constants/separation = 20
offset_top = 36.0
offset_right = 452.0
offset_bottom = 62.0
theme_override_constants/separation = 20
alignment = 2
__meta__ = {
"_edit_use_anchors_": false
}
[node name="Label" type="Label" parent="Controls/PlatformAngle"]
margin_top = 1.0
margin_right = 92.0
margin_bottom = 15.0
offset_right = 112.0
offset_bottom = 26.0
text = "Platform angle"
[node name="HSlider" type="HSlider" parent="Controls/PlatformAngle"]
margin_left = 112.0
margin_right = 312.0
margin_bottom = 16.0
rect_min_size = Vector2( 200, 0 )
offset_left = 132.0
offset_right = 332.0
offset_bottom = 16.0
rect_min_size = Vector2(200, 0)
max_value = 360.0
script = ExtResource( 5 )
script = ExtResource( "5" )
snap_step = 5.0
[node name="LabelValue" type="Label" parent="Controls/PlatformAngle"]
margin_left = 332.0
margin_top = 1.0
margin_right = 432.0
margin_bottom = 15.0
rect_min_size = Vector2( 100, 0 )
offset_left = 352.0
offset_right = 452.0
offset_bottom = 26.0
rect_min_size = Vector2(100, 0)
text = "0.0"
script = ExtResource( 4 )
script = ExtResource( "4" )
[node name="BodyAngle" type="HBoxContainer" parent="Controls"]
margin_top = 52.0
margin_right = 432.0
margin_bottom = 68.0
custom_constants/separation = 20
offset_top = 72.0
offset_right = 452.0
offset_bottom = 98.0
theme_override_constants/separation = 20
alignment = 2
__meta__ = {
"_edit_use_anchors_": false
}
[node name="Label" type="Label" parent="Controls/BodyAngle"]
margin_left = 22.0
margin_top = 1.0
margin_right = 92.0
margin_bottom = 15.0
offset_left = 27.0
offset_right = 112.0
offset_bottom = 26.0
text = "Body angle"
[node name="HSlider" type="HSlider" parent="Controls/BodyAngle"]
margin_left = 112.0
margin_right = 312.0
margin_bottom = 16.0
rect_min_size = Vector2( 200, 0 )
offset_left = 132.0
offset_right = 332.0
offset_bottom = 16.0
rect_min_size = Vector2(200, 0)
max_value = 360.0
script = ExtResource( 5 )
script = ExtResource( "5" )
snap_step = 5.0
[node name="LabelValue" type="Label" parent="Controls/BodyAngle"]
margin_left = 332.0
margin_top = 1.0
margin_right = 432.0
margin_bottom = 15.0
rect_min_size = Vector2( 100, 0 )
offset_left = 352.0
offset_right = 452.0
offset_bottom = 26.0
rect_min_size = Vector2(100, 0)
text = "0.0"
script = ExtResource( 4 )
script = ExtResource( "4" )
[node name="LabelResultTitle" type="Label" parent="."]
anchor_left = 0.5
anchor_top = 0.5
anchor_right = 0.5
anchor_bottom = 0.5
margin_left = 34.1273
margin_top = 251.131
margin_right = 88.1273
margin_bottom = 265.131
offset_left = 34.1273
offset_top = 251.131
offset_right = 88.1273
offset_bottom = 265.131
text = "RESULT: "
align = 1
valign = 1
@@ -168,10 +161,10 @@ anchor_left = 0.5
anchor_top = 0.5
anchor_right = 0.5
anchor_bottom = 0.5
margin_left = 34.1273
margin_top = 266.131
margin_right = 88.1273
margin_bottom = 280.131
offset_left = 34.1273
offset_top = 266.131
offset_right = 88.1273
offset_bottom = 280.131
text = "..."
align = 1
valign = 1
@@ -184,10 +177,10 @@ anchor_left = 0.5
anchor_top = 0.5
anchor_right = 0.5
anchor_bottom = 0.5
margin_left = 34.1273
margin_top = 304.841
margin_right = 139.127
margin_bottom = 318.841
offset_left = 34.1273
offset_top = 304.841
offset_right = 139.127
offset_bottom = 318.841
text = "SPACE - RESTART"
align = 1
valign = 1
@@ -200,45 +193,45 @@ wait_time = 5.0
one_shot = true
[node name="TargetArea2D" type="Area2D" parent="."]
position = Vector2( 724, 300 )
position = Vector2(512, 300)
[node name="CollisionShape2D" type="CollisionShape2D" parent="TargetArea2D"]
shape = SubResource( 1 )
shape = SubResource( "CircleShape2D_e5nt1" )
[node name="OneWayKinematicBody2D" type="KinematicBody2D" parent="."]
position = Vector2( 512, 300 )
[node name="OneWayStaticBody2D" type="StaticBody2D" parent="."]
position = Vector2(512, 300)
[node name="CollisionShape2D" type="CollisionShape2D" parent="OneWayKinematicBody2D"]
shape = SubResource( 2 )
[node name="CollisionShape2D" type="CollisionShape2D" parent="OneWayStaticBody2D"]
shape = SubResource( "2" )
one_way_collision = true
[node name="RigidBody2D" type="RigidBody2D" parent="."]
position = Vector2( 300, 300 )
[node name="RigidBody2D" type="RigidDynamicBody2D" parent="."]
position = Vector2(300, 300)
collision_mask = 2147483649
gravity_scale = 0.0
contacts_reported = 1
contact_monitor = true
[node name="Sprite" type="Sprite" parent="RigidBody2D"]
self_modulate = Color( 1, 1, 1, 0.501961 )
scale = Vector2( 0.5, 0.5 )
texture = ExtResource( 2 )
[node name="Sprite" type="Sprite2D" parent="RigidBody2D"]
self_modulate = Color(1, 1, 1, 0.501961)
scale = Vector2(0.5, 0.5)
texture = ExtResource( "2" )
[node name="CollisionShape2D" type="CollisionShape2D" parent="RigidBody2D"]
shape = SubResource( 3 )
shape = SubResource( "3" )
[node name="KinematicBody2D" type="KinematicBody2D" parent="."]
position = Vector2( 300, 300 )
[node name="CharacterBody2D" type="CharacterBody2D" parent="."]
position = Vector2(300, 300)
collision_mask = 2147483649
[node name="Sprite" type="Sprite" parent="KinematicBody2D"]
self_modulate = Color( 1, 1, 1, 0.501961 )
scale = Vector2( 0.5, 0.5 )
texture = ExtResource( 2 )
[node name="Sprite" type="Sprite2D" parent="CharacterBody2D"]
self_modulate = Color(1, 1, 1, 0.501961)
scale = Vector2(0.5, 0.5)
texture = ExtResource( "2" )
[node name="CollisionShape2D" type="CollisionShape2D" parent="KinematicBody2D"]
shape = SubResource( 3 )
[node name="CollisionShape2D" type="CollisionShape2D" parent="CharacterBody2D"]
shape = SubResource( "3" )
[connection signal="value_changed" from="Controls/PlatformSize/HSlider" to="." method="_set_platform_size"]
[connection signal="value_changed" from="Controls/PlatformAngle/HSlider" to="." method="_set_platform_angle"]
[connection signal="value_changed" from="Controls/BodyAngle/HSlider" to="." method="_set_rigidbody_angle"]
[connection signal="value_changed" from="Controls/PlatformSize/HSlider" to="." method="_update_platform_size"]
[connection signal="value_changed" from="Controls/PlatformAngle/HSlider" to="." method="_update_platform_angle"]
[connection signal="value_changed" from="Controls/BodyAngle/HSlider" to="." method="_update_rigidbody_angle"]

View File

@@ -1,9 +1,9 @@
extends Test
export(int, 1, 100) var height = 10
export(Vector2) var box_size = Vector2(40.0, 40.0)
export(Vector2) var box_spacing = Vector2(0.0, 0.0)
@export_range(1, 100) var height = 10
@export var box_size = Vector2(40.0, 40.0)
@export var box_spacing = Vector2(0.0, 0.0)
func _ready():

View File

@@ -1,12 +1,12 @@
[gd_scene load_steps=3 format=2]
[gd_scene load_steps=3 format=3 uid="uid://b4s4ohq0j4oi8"]
[ext_resource path="res://tests/functional/test_pyramid.gd" type="Script" id=1]
[ext_resource path="res://tests/static_scene_flat.tscn" type="PackedScene" id=2]
[ext_resource type="Script" path="res://tests/functional/test_pyramid.gd" id="1"]
[ext_resource type="PackedScene" uid="uid://cx2q80okt25o1" path="res://tests/static_scene_flat.tscn" id="2"]
[node name="Test" type="Node2D"]
script = ExtResource( 1 )
script = ExtResource( "1" )
[node name="Pyramid" type="Node2D" parent="."]
position = Vector2( 512, 500 )
position = Vector2(512, 500)
[node name="StaticSceneFlat" parent="." instance=ExtResource( 2 )]
[node name="StaticSceneFlat" parent="." instance=ExtResource( "2" )]

View File

@@ -1,18 +1,29 @@
extends Test
const OPTION_TEST_CASE_HIT_FROM_INSIDE = "Test case/Hit from inside"
var _hit_from_inside = false
var _do_raycasts = false
func _ready():
yield(start_timer(0.5), "timeout")
var options = $Options
options.add_menu_item(OPTION_TEST_CASE_HIT_FROM_INSIDE, true, false)
options.connect("option_changed", Callable(self, "_on_option_changed"))
await start_timer(0.5).timeout
if is_timer_canceled():
return
_do_raycasts = true
func _physics_process(_delta):
func _physics_process(delta):
super._physics_process(delta)
if not _do_raycasts:
return
@@ -45,20 +56,32 @@ func _physics_process(_delta):
res = _add_raycast(space_state, center, center + Vector2(0, 40))
Log.print_log("Raycast inside: %s" % ("HIT" if res else "NO HIT"))
if String(body.name).ends_with("ConcavePolygon"):
if body_name.begins_with("Concave"):
# Raycast inside an internal face.
center.x += 20
res = _add_raycast(space_state, center, center + Vector2(0, 40))
Log.print_log("Raycast inside face: %s" % ("HIT" if res else "NO HIT"))
func _on_option_changed(option, checked):
match option:
OPTION_TEST_CASE_HIT_FROM_INSIDE:
_hit_from_inside = checked
_do_raycasts = true
func _add_raycast(space_state, pos_start, pos_end):
var result = space_state.intersect_ray(pos_start, pos_end)
var params = PhysicsRayQueryParameters2D.new()
params.from = pos_start
params.to = pos_end
params.hit_from_inside = _hit_from_inside
var result = space_state.intersect_ray(params)
var color
if result:
color = Color.green
color = Color.GREEN.darkened(0.2)
else:
color = Color.red.darkened(0.5)
color = Color.RED.darkened(0.5)
# Draw raycast line.
add_line(pos_start, pos_end, color)
@@ -67,4 +90,12 @@ func _add_raycast(space_state, pos_start, pos_end):
add_line(pos_end, pos_end + Vector2(-5, -10), color)
add_line(pos_end, pos_end + Vector2(5, -10), color)
if result:
# Draw raycast hit pos.
var hit_pos = result.position
add_circle(hit_pos, 4.0, Color.YELLOW)
# Draw raycast hit normal.
add_line(hit_pos, hit_pos + result.normal * 16.0, Color.YELLOW)
return result

View File

@@ -1,82 +1,86 @@
[gd_scene load_steps=7 format=2]
[gd_scene load_steps=7 format=3 uid="uid://dwka2imbe5gcs"]
[ext_resource path="res://assets/texture/godot-head.png" type="Texture" id=1]
[ext_resource path="res://tests/functional/test_raycasting.gd" type="Script" id=2]
[ext_resource type="Texture2D" uid="uid://c5duuyhbmd0m4" path="res://assets/texture/godot-head.png" id="1"]
[ext_resource type="Script" path="res://tests/functional/test_raycasting.gd" id="2"]
[ext_resource type="PackedScene" uid="uid://blh3twy74kbkv" path="res://tests/test_options.tscn" id="2_q8u1v"]
[sub_resource type="RectangleShape2D" id=1]
extents = Vector2( 40, 60 )
[sub_resource type="RectangleShape2D" id="1"]
size = Vector2(80, 120)
[sub_resource type="CircleShape2D" id=2]
[sub_resource type="CircleShape2D" id="2"]
radius = 60.0
[sub_resource type="CapsuleShape2D" id=3]
[sub_resource type="CapsuleShape2D" id="3"]
radius = 30.0
height = 50.0
[sub_resource type="ConcavePolygonShape2D" id=4]
segments = PoolVector2Array( -5.93512, -43.2195, 6.44476, -42.9695, 6.44476, -42.9695, 11.127, -54.3941, 11.127, -54.3941, 26.9528, -49.4309, 26.9528, -49.4309, 26.2037, -36.508, 26.2037, -36.508, 37.5346, -28.1737, 37.5346, -28.1737, 47.6282, -34.3806, 47.6282, -34.3806, 58.0427, -20.9631, 58.0427, -20.9631, 51.113, -10.2876, 51.113, -10.2876, 50.9869, 35.2694, 50.9869, 35.2694, 38.8, 47.5, 38.8, 47.5, 15.9852, 54.3613, 15.9852, 54.3613, -14.9507, 54.1845, -14.9507, 54.1845, -36.5, 48.1, -36.5, 48.1, -50.4828, 36.33, -50.4828, 36.33, -51.3668, -9.98545, -51.3668, -9.98545, -57.8889, -20.5885, -57.8889, -20.5885, -46.9473, -34.7342, -46.9473, -34.7342, -37.4014, -28.547, -37.4014, -28.547, -26.0876, -37.0323, -26.0876, -37.0323, -26.9862, -49.15, -26.9862, -49.15, -11.4152, -54.5332, -11.4152, -54.5332, -5.93512, -43.2195 )
height = 110.0
[node name="Test" type="Node2D"]
script = ExtResource( 2 )
script = ExtResource( "2" )
[node name="Options" parent="." instance=ExtResource( "2_q8u1v" )]
offset_right = 134.0
offset_bottom = 135.719
theme_override_font_sizes/font_size = 16
[node name="Shapes" type="Node2D" parent="."]
z_index = -1
z_as_relative = false
[node name="RigidBodyRectangle" type="RigidBody2D" parent="Shapes"]
position = Vector2( 114.877, 248.76 )
mode = 1
[node name="RigidBodyRectangle" type="RigidDynamicBody2D" parent="Shapes"]
position = Vector2(114.877, 248.76)
freeze = true
[node name="CollisionShape2D" type="CollisionShape2D" parent="Shapes/RigidBodyRectangle"]
rotation = -1.19206
scale = Vector2( 1.2, 1.2 )
shape = SubResource( 1 )
scale = Vector2(1.2, 1.2)
shape = SubResource( "1" )
[node name="RigidBodySphere" type="RigidBody2D" parent="Shapes"]
position = Vector2( 314.894, 257.658 )
mode = 1
[node name="RigidBodySphere" type="RigidDynamicBody2D" parent="Shapes"]
position = Vector2(314.894, 257.658)
freeze = true
[node name="CollisionShape2D" type="CollisionShape2D" parent="Shapes/RigidBodySphere"]
shape = SubResource( 2 )
shape = SubResource( "2" )
[node name="RigidBodyCapsule" type="RigidBody2D" parent="Shapes"]
position = Vector2( 465.629, 261.204 )
mode = 1
[node name="RigidBodyCapsule" type="RigidDynamicBody2D" parent="Shapes"]
position = Vector2(465.629, 261.204)
freeze = true
[node name="CollisionShape2D" type="CollisionShape2D" parent="Shapes/RigidBodyCapsule"]
rotation = -0.202458
scale = Vector2( 1.2, 1.2 )
shape = SubResource( 3 )
scale = Vector2(1.2, 1.2)
shape = SubResource( "3" )
[node name="RigidBodyConvexPolygon" type="RigidBody2D" parent="Shapes"]
position = Vector2( 613.385, 252.771 )
mode = 1
[node name="RigidBodyConvexPolygon" type="RigidDynamicBody2D" parent="Shapes"]
position = Vector2(613.385, 252.771)
freeze = true
[node name="CollisionPolygon2D" type="CollisionPolygon2D" parent="Shapes/RigidBodyConvexPolygon"]
polygon = PoolVector2Array( 10.7, -54.5, 28.3596, -49.4067, 47.6282, -34.3806, 57.9717, -20.9447, 50.9869, 35.2694, 38.8, 47.5, 15.9852, 54.3613, -14.9507, 54.1845, -36.5, 48.1, -50.4828, 36.33, -58.0115, -20.515, -46.9473, -34.7342, -26.0876, -50.1138, -11.4152, -54.5332 )
polygon = PackedVector2Array(10.7, -54.5, 28.3596, -49.4067, 47.6282, -34.3806, 57.9717, -20.9447, 50.9869, 35.2694, 38.8, 47.5, 15.9852, 54.3613, -14.9507, 54.1845, -36.5, 48.1, -50.4828, 36.33, -58.0115, -20.515, -46.9473, -34.7342, -26.0876, -50.1138, -11.4152, -54.5332)
[node name="GodotIcon" type="Sprite" parent="Shapes/RigidBodyConvexPolygon"]
modulate = Color( 1, 1, 1, 0.392157 )
texture = ExtResource( 1 )
[node name="GodotIcon" type="Sprite2D" parent="Shapes/RigidBodyConvexPolygon"]
modulate = Color(1, 1, 1, 0.392157)
texture = ExtResource( "1" )
[node name="RigidBodyConcavePolygon" type="RigidBody2D" parent="Shapes"]
position = Vector2( 771.159, 252.771 )
mode = 1
[node name="RigidBodyConcavePolygon" type="RigidDynamicBody2D" parent="Shapes"]
position = Vector2(771.159, 252.771)
freeze = true
[node name="CollisionPolygon2D" type="CollisionPolygon2D" parent="Shapes/RigidBodyConcavePolygon"]
polygon = PoolVector2Array( -5.93512, -43.2195, 6.44476, -42.9695, 11.127, -54.3941, 26.9528, -49.4309, 26.2037, -36.508, 37.5346, -28.1737, 47.6282, -34.3806, 58.0427, -20.9631, 51.113, -10.2876, 50.9869, 35.2694, 38.8, 47.5, 15.9852, 54.3613, -14.9507, 54.1845, -36.5, 48.1, -50.4828, 36.33, -51.3668, -9.98545, -57.8889, -20.5885, -46.9473, -34.7342, -37.4014, -28.547, -26.0876, -37.0323, -26.9862, -49.15, -11.4152, -54.5332 )
polygon = PackedVector2Array(-5.93512, -43.2195, 6.44476, -42.9695, 11.127, -54.3941, 26.9528, -49.4309, 26.2037, -36.508, 37.5346, -28.1737, 47.6282, -34.3806, 58.0427, -20.9631, 51.113, -10.2876, 50.9869, 35.2694, 38.8, 47.5, 15.9852, 54.3613, -14.9507, 54.1845, -36.5, 48.1, -50.4828, 36.33, -51.3668, -9.98545, -57.8889, -20.5885, -46.9473, -34.7342, -37.4014, -28.547, -26.0876, -37.0323, -26.9862, -49.15, -11.4152, -54.5332)
[node name="GodotIcon" type="Sprite" parent="Shapes/RigidBodyConcavePolygon"]
modulate = Color( 1, 1, 1, 0.392157 )
texture = ExtResource( 1 )
[node name="GodotIcon" type="Sprite2D" parent="Shapes/RigidBodyConcavePolygon"]
modulate = Color(1, 1, 1, 0.392157)
texture = ExtResource( "1" )
[node name="RigidBodyConcaveSegments" type="RigidBody2D" parent="Shapes"]
position = Vector2( 930.097, 252.771 )
mode = 1
[node name="RigidBodyConcaveSegments" type="RigidDynamicBody2D" parent="Shapes"]
position = Vector2(930.097, 252.771)
freeze = true
[node name="CollisionShape2D" type="CollisionShape2D" parent="Shapes/RigidBodyConcaveSegments"]
shape = SubResource( 4 )
[node name="CollisionPolygon2D" type="CollisionPolygon2D" parent="Shapes/RigidBodyConcaveSegments"]
build_mode = 1
polygon = PackedVector2Array(-5.93512, -43.2195, 6.44476, -42.9695, 11.127, -54.3941, 26.9528, -49.4309, 26.2037, -36.508, 37.5346, -28.1737, 47.6282, -34.3806, 58.0427, -20.9631, 51.113, -10.2876, 50.9869, 35.2694, 38.8, 47.5, 15.9852, 54.3613, -14.9507, 54.1845, -36.5, 48.1, -50.4828, 36.33, -51.3668, -9.98545, -57.8889, -20.5885, -46.9473, -34.7342, -37.4014, -28.547, -26.0876, -37.0323, -26.9862, -49.15, -11.4152, -54.5332)
[node name="GodotIcon" type="Sprite" parent="Shapes/RigidBodyConcaveSegments"]
modulate = Color( 1, 1, 1, 0.392157 )
texture = ExtResource( 1 )
[node name="GodotIcon" type="Sprite2D" parent="Shapes/RigidBodyConcaveSegments"]
modulate = Color(1, 1, 1, 0.392157)
texture = ExtResource( "1" )

View File

@@ -1,72 +1,72 @@
[gd_scene load_steps=8 format=2]
[gd_scene load_steps=8 format=3 uid="uid://v3saw5bafa6a"]
[ext_resource path="res://assets/texture/godot-head.png" type="Texture" id=1]
[ext_resource path="res://test.gd" type="Script" id=2]
[ext_resource path="res://utils/rigidbody_pick.gd" type="Script" id=3]
[ext_resource path="res://tests/static_scene.tscn" type="PackedScene" id=6]
[ext_resource type="Texture2D" uid="uid://c5duuyhbmd0m4" path="res://assets/texture/godot-head.png" id="1"]
[ext_resource type="Script" path="res://test.gd" id="2"]
[ext_resource type="Script" path="res://utils/rigidbody_pick.gd" id="3"]
[ext_resource type="PackedScene" uid="uid://dv7rxhg55y3t6" path="res://tests/static_scene.tscn" id="6"]
[sub_resource type="RectangleShape2D" id=1]
extents = Vector2( 20, 30 )
[sub_resource type="RectangleShape2D" id="1"]
size = Vector2(40, 60)
[sub_resource type="CapsuleShape2D" id=2]
[sub_resource type="CapsuleShape2D" id="2"]
radius = 20.0
height = 30.0
height = 70.0
[sub_resource type="CircleShape2D" id=3]
[sub_resource type="CircleShape2D" id="3"]
radius = 30.0
[node name="Test" type="Node2D"]
script = ExtResource( 2 )
script = ExtResource( "2" )
[node name="DynamicShapes" type="Node2D" parent="."]
[node name="RigidBodyRectangle" type="RigidBody2D" parent="DynamicShapes"]
position = Vector2( 96, 127 )
script = ExtResource( 3 )
[node name="RigidBodyRectangle" type="RigidDynamicBody2D" parent="DynamicShapes"]
position = Vector2(96, 127)
script = ExtResource( "3" )
[node name="CollisionShape2D" type="CollisionShape2D" parent="DynamicShapes/RigidBodyRectangle"]
rotation = 0.675442
shape = SubResource( 1 )
shape = SubResource( "1" )
[node name="RigidBodyCapsule" type="RigidBody2D" parent="DynamicShapes"]
position = Vector2( 270.165, 139.444 )
script = ExtResource( 3 )
[node name="RigidBodyCapsule" type="RigidDynamicBody2D" parent="DynamicShapes"]
position = Vector2(270.165, 139.444)
script = ExtResource( "3" )
[node name="CollisionShape2D" type="CollisionShape2D" parent="DynamicShapes/RigidBodyCapsule"]
rotation = -0.202458
shape = SubResource( 2 )
shape = SubResource( "2" )
[node name="RigidBodyConcavePolygon" type="RigidBody2D" parent="DynamicShapes"]
position = Vector2( 683.614, 132.749 )
script = ExtResource( 3 )
[node name="RigidBodyConcavePolygon" type="RigidDynamicBody2D" parent="DynamicShapes"]
position = Vector2(683.614, 132.749)
script = ExtResource( "3" )
[node name="CollisionPolygon2D" type="CollisionPolygon2D" parent="DynamicShapes/RigidBodyConcavePolygon"]
scale = Vector2( 0.5, 0.5 )
polygon = PoolVector2Array( -5.93512, -43.2195, 6.44476, -42.9695, 11.127, -54.3941, 26.9528, -49.4309, 26.2037, -36.508, 37.5346, -28.1737, 47.6282, -34.3806, 58.0427, -20.9631, 51.113, -10.2876, 50.9869, 35.2694, 38.8, 47.5, 15.9852, 54.3613, -14.9507, 54.1845, -36.5, 48.1, -50.4828, 36.33, -51.3668, -9.98545, -57.8889, -20.5885, -46.9473, -34.7342, -37.4014, -28.547, -26.0876, -37.0323, -26.9862, -49.15, -11.4152, -54.5332 )
scale = Vector2(0.5, 0.5)
polygon = PackedVector2Array(-5.93512, -43.2195, 6.44476, -42.9695, 11.127, -54.3941, 26.9528, -49.4309, 26.2037, -36.508, 37.5346, -28.1737, 47.6282, -34.3806, 58.0427, -20.9631, 51.113, -10.2876, 50.9869, 35.2694, 38.8, 47.5, 15.9852, 54.3613, -14.9507, 54.1845, -36.5, 48.1, -50.4828, 36.33, -51.3668, -9.98545, -57.8889, -20.5885, -46.9473, -34.7342, -37.4014, -28.547, -26.0876, -37.0323, -26.9862, -49.15, -11.4152, -54.5332)
[node name="GodotIcon" type="Sprite" parent="DynamicShapes/RigidBodyConcavePolygon"]
self_modulate = Color( 1, 1, 1, 0.392157 )
scale = Vector2( 0.5, 0.5 )
texture = ExtResource( 1 )
[node name="GodotIcon" type="Sprite2D" parent="DynamicShapes/RigidBodyConcavePolygon"]
self_modulate = Color(1, 1, 1, 0.392157)
scale = Vector2(0.5, 0.5)
texture = ExtResource( "1" )
[node name="RigidBodyConvexPolygon" type="RigidBody2D" parent="DynamicShapes"]
position = Vector2( 473.536, 134.336 )
script = ExtResource( 3 )
[node name="RigidBodyConvexPolygon" type="RigidDynamicBody2D" parent="DynamicShapes"]
position = Vector2(473.536, 134.336)
script = ExtResource( "3" )
[node name="CollisionPolygon2D" type="CollisionPolygon2D" parent="DynamicShapes/RigidBodyConvexPolygon"]
scale = Vector2( 0.5, 0.5 )
polygon = PoolVector2Array( 10.7, -54.5, 28.3596, -49.4067, 47.6282, -34.3806, 57.9717, -20.9447, 50.9869, 35.2694, 38.8, 47.5, 15.9852, 54.3613, -14.9507, 54.1845, -36.5, 48.1, -50.4828, 36.33, -58.0115, -20.515, -46.9473, -34.7342, -26.0876, -50.1138, -11.4152, -54.5332 )
scale = Vector2(0.5, 0.5)
polygon = PackedVector2Array(10.7, -54.5, 28.3596, -49.4067, 47.6282, -34.3806, 57.9717, -20.9447, 50.9869, 35.2694, 38.8, 47.5, 15.9852, 54.3613, -14.9507, 54.1845, -36.5, 48.1, -50.4828, 36.33, -58.0115, -20.515, -46.9473, -34.7342, -26.0876, -50.1138, -11.4152, -54.5332)
[node name="GodotIcon" type="Sprite" parent="DynamicShapes/RigidBodyConvexPolygon"]
self_modulate = Color( 1, 1, 1, 0.392157 )
scale = Vector2( 0.5, 0.5 )
texture = ExtResource( 1 )
[node name="GodotIcon" type="Sprite2D" parent="DynamicShapes/RigidBodyConvexPolygon"]
self_modulate = Color(1, 1, 1, 0.392157)
scale = Vector2(0.5, 0.5)
texture = ExtResource( "1" )
[node name="RigidBodySphere" type="RigidBody2D" parent="DynamicShapes"]
position = Vector2( 919.968, 115.129 )
script = ExtResource( 3 )
[node name="RigidBodySphere" type="RigidDynamicBody2D" parent="DynamicShapes"]
position = Vector2(919.968, 115.129)
script = ExtResource( "3" )
[node name="CollisionShape2D" type="CollisionShape2D" parent="DynamicShapes/RigidBodySphere"]
shape = SubResource( 3 )
shape = SubResource( "3" )
[node name="StaticScene" parent="." instance=ExtResource( 6 )]
[node name="StaticScene" parent="." instance=ExtResource( "6" )]

View File

@@ -1,10 +1,10 @@
extends Test
export(int) var height = 10
export(int) var width = 1
export(Vector2) var box_size = Vector2(40.0, 40.0)
export(Vector2) var box_spacing = Vector2(0.0, 0.0)
@export var height = 10
@export var width = 1
@export var box_size = Vector2(40.0, 40.0)
@export var box_spacing = Vector2(0.0, 0.0)
func _ready():

View File

@@ -1,12 +1,12 @@
[gd_scene load_steps=3 format=2]
[gd_scene load_steps=3 format=3 uid="uid://m8crffoaqg7b"]
[ext_resource path="res://tests/functional/test_stack.gd" type="Script" id=1]
[ext_resource path="res://tests/static_scene_flat.tscn" type="PackedScene" id=2]
[ext_resource type="Script" path="res://tests/functional/test_stack.gd" id="1"]
[ext_resource type="PackedScene" uid="uid://cx2q80okt25o1" path="res://tests/static_scene_flat.tscn" id="2"]
[node name="Test" type="Node2D"]
script = ExtResource( 1 )
script = ExtResource( "1" )
[node name="Stack" type="Node2D" parent="."]
position = Vector2( 512, 500 )
position = Vector2(512, 500)
[node name="StaticSceneFlat" parent="." instance=ExtResource( 2 )]
[node name="StaticSceneFlat" parent="." instance=ExtResource( "2" )]

View File

@@ -4,8 +4,8 @@ extends Test
const BOX_SIZE = Vector2(40, 40)
const BOX_SPACE = Vector2(50, 50)
export(int, 1, 1000) var row_size = 100
export(int, 1, 1000) var column_size = 100
@export_range(1, 1000) var row_size = 100
@export_range(1, 1000) var column_size = 100
var _objects = []
@@ -15,7 +15,7 @@ var _log_physics_time_start = 0
func _ready():
yield(start_timer(1.0), "timeout")
await start_timer(1.0).timeout
if is_timer_canceled():
return
@@ -23,10 +23,10 @@ func _ready():
_create_objects()
yield(wait_for_physics_ticks(5), "wait_done")
await wait_for_physics_ticks(5).wait_done
_log_physics_stop()
yield(start_timer(1.0), "timeout")
await start_timer(1.0).timeout
if is_timer_canceled():
return
@@ -34,10 +34,10 @@ func _ready():
_add_objects()
yield(wait_for_physics_ticks(5), "wait_done")
await wait_for_physics_ticks(5).wait_done
_log_physics_stop()
yield(start_timer(1.0), "timeout")
await start_timer(1.0).timeout
if is_timer_canceled():
return
@@ -45,10 +45,10 @@ func _ready():
_move_objects()
yield(wait_for_physics_ticks(5), "wait_done")
await wait_for_physics_ticks(5).wait_done
_log_physics_stop()
yield(start_timer(1.0), "timeout")
await start_timer(1.0).timeout
if is_timer_canceled():
return
@@ -56,10 +56,10 @@ func _ready():
_remove_objects()
yield(wait_for_physics_ticks(5), "wait_done")
await wait_for_physics_ticks(5).wait_done
_log_physics_stop()
yield(start_timer(1.0), "timeout")
await start_timer(1.0).timeout
if is_timer_canceled():
return
@@ -71,9 +71,11 @@ func _exit_tree():
object.free()
func _physics_process(_delta):
func _physics_process(delta):
super._physics_process(delta)
if _log_physics:
var time = OS.get_ticks_usec()
var time = Time.get_ticks_usec()
var time_delta = time - _log_physics_time
var time_total = time - _log_physics_time_start
_log_physics_time = time
@@ -82,7 +84,7 @@ func _physics_process(_delta):
func _log_physics_start():
_log_physics = true
_log_physics_time_start = OS.get_ticks_usec()
_log_physics_time_start = Time.get_ticks_usec()
_log_physics_time = _log_physics_time_start
@@ -94,7 +96,7 @@ func _create_objects():
_objects.clear()
Log.print_log("* Creating objects...")
var timer = OS.get_ticks_usec()
var timer = Time.get_ticks_usec()
var pos_x = -0.5 * (row_size - 1) * BOX_SPACE.x
@@ -112,7 +114,7 @@ func _create_objects():
pos_x += BOX_SPACE.x
timer = OS.get_ticks_usec() - timer
timer = Time.get_ticks_usec() - timer
Log.print_log(" Create Time: %.3f ms" % (0.001 * timer))
@@ -120,23 +122,23 @@ func _add_objects():
var root_node = $Objects
Log.print_log("* Adding objects...")
var timer = OS.get_ticks_usec()
var timer = Time.get_ticks_usec()
for object in _objects:
root_node.add_child(object)
timer = OS.get_ticks_usec() - timer
timer = Time.get_ticks_usec() - timer
Log.print_log(" Add Time: %.3f ms" % (0.001 * timer))
func _move_objects():
Log.print_log("* Moving objects...")
var timer = OS.get_ticks_usec()
var timer = Time.get_ticks_usec()
for object in _objects:
object.position += BOX_SPACE
timer = OS.get_ticks_usec() - timer
timer = Time.get_ticks_usec() - timer
Log.print_log(" Move Time: %.3f ms" % (0.001 * timer))
@@ -144,12 +146,12 @@ func _remove_objects():
var root_node = $Objects
Log.print_log("* Removing objects...")
var timer = OS.get_ticks_usec()
var timer = Time.get_ticks_usec()
# Remove objects in reversed order to avoid the overhead of changing children index in parent.
var object_count = _objects.size()
for object_index in range(object_count):
root_node.remove_child(_objects[object_count - object_index - 1])
timer = OS.get_ticks_usec() - timer
timer = Time.get_ticks_usec() - timer
Log.print_log(" Remove Time: %.3f ms" % (0.001 * timer))

View File

@@ -1,12 +1,12 @@
[gd_scene load_steps=2 format=2]
[gd_scene load_steps=2 format=3 uid="uid://yk1857jynutc"]
[ext_resource path="res://tests/performance/test_perf_broadphase.gd" type="Script" id=1]
[ext_resource type="Script" path="res://tests/performance/test_perf_broadphase.gd" id="1"]
[node name="Test" type="Node2D"]
script = ExtResource( 1 )
script = ExtResource( "1" )
_enable_debug_collision = false
row_size = 300
column_size = 300
[node name="Objects" type="Node2D" parent="."]
position = Vector2( 512, 300 )
position = Vector2(512, 300)

View File

@@ -1,105 +1,105 @@
[gd_scene load_steps=8 format=2]
[gd_scene load_steps=8 format=3 uid="uid://vb6u0374prwg"]
[ext_resource path="res://tests/static_scene.tscn" type="PackedScene" id=1]
[ext_resource path="res://tests/performance/test_perf_contacts.gd" type="Script" id=2]
[ext_resource path="res://assets/texture/godot-head.png" type="Texture" id=3]
[ext_resource path="res://tests/test_options.tscn" type="PackedScene" id=4]
[ext_resource type="PackedScene" uid="uid://dv7rxhg55y3t6" path="res://tests/static_scene.tscn" id="1"]
[ext_resource type="Script" path="res://tests/performance/test_perf_contacts.gd" id="2"]
[ext_resource type="Texture2D" uid="uid://c5duuyhbmd0m4" path="res://assets/texture/godot-head.png" id="3"]
[ext_resource type="PackedScene" uid="uid://blh3twy74kbkv" path="res://tests/test_options.tscn" id="4"]
[sub_resource type="RectangleShape2D" id=1]
extents = Vector2( 5, 7 )
[sub_resource type="RectangleShape2D" id="1"]
size = Vector2(10, 14)
[sub_resource type="CircleShape2D" id=2]
[sub_resource type="CircleShape2D" id="2"]
radius = 5.0
[sub_resource type="CapsuleShape2D" id=3]
[sub_resource type="CapsuleShape2D" id="3"]
radius = 5.0
height = 7.0
height = 17.0
[node name="Test" type="Node2D"]
script = ExtResource( 2 )
script = ExtResource( "2" )
_enable_debug_collision = false
spawns = [ NodePath("SpawnTarget1"), NodePath("SpawnTarget2"), NodePath("SpawnTarget3"), NodePath("SpawnTarget4"), NodePath("SpawnTarget5"), NodePath("SpawnTarget6"), NodePath("SpawnTarget7"), NodePath("SpawnTarget8"), NodePath("SpawnTarget9") ]
spawns = [NodePath("SpawnTarget1"), NodePath("SpawnTarget2"), NodePath("SpawnTarget3"), NodePath("SpawnTarget4"), NodePath("SpawnTarget5"), NodePath("SpawnTarget6"), NodePath("SpawnTarget7"), NodePath("SpawnTarget8"), NodePath("SpawnTarget9")]
spawn_count = 300
spawn_randomize = Vector2( 10, 10 )
spawn_randomize = Vector2(10, 10)
[node name="Options" parent="." instance=ExtResource( 4 )]
[node name="Options" parent="." instance=ExtResource( "4" )]
[node name="SpawnTarget1" type="Node2D" parent="."]
position = Vector2( 145.646, 109.462 )
position = Vector2(145.646, 109.462)
[node name="SpawnTarget2" type="Node2D" parent="."]
position = Vector2( 508.14, 109.113 )
position = Vector2(508.14, 109.113)
[node name="SpawnTarget3" type="Node2D" parent="."]
position = Vector2( 873.995, 110.042 )
position = Vector2(873.995, 110.042)
[node name="SpawnTarget4" type="Node2D" parent="."]
position = Vector2( 149.646, 301.462 )
position = Vector2(149.646, 301.462)
[node name="SpawnTarget5" type="Node2D" parent="."]
position = Vector2( 512.14, 301.113 )
position = Vector2(512.14, 301.113)
[node name="SpawnTarget6" type="Node2D" parent="."]
position = Vector2( 877.995, 302.042 )
position = Vector2(877.995, 302.042)
[node name="SpawnTarget7" type="Node2D" parent="."]
position = Vector2( 165.646, 507.462 )
position = Vector2(165.646, 507.462)
[node name="SpawnTarget8" type="Node2D" parent="."]
position = Vector2( 528.14, 507.113 )
position = Vector2(528.14, 507.113)
[node name="SpawnTarget9" type="Node2D" parent="."]
position = Vector2( 893.995, 508.042 )
position = Vector2(893.995, 508.042)
[node name="StaticScene" parent="." instance=ExtResource( 1 )]
[node name="StaticScene" parent="." instance=ExtResource( "1" )]
visible = false
position = Vector2( 0, 125.017 )
position = Vector2(0, 125.017)
[node name="DynamicShapes" type="Node2D" parent="."]
[node name="RigidBodyRectangle" type="RigidBody2D" parent="DynamicShapes"]
position = Vector2( 0, 1024 )
[node name="RigidBodyRectangle" type="RigidDynamicBody2D" parent="DynamicShapes"]
position = Vector2(0, 1024)
gravity_scale = 0.0
[node name="CollisionShape2D" type="CollisionShape2D" parent="DynamicShapes/RigidBodyRectangle"]
shape = SubResource( 1 )
shape = SubResource( "1" )
[node name="RigidBodySphere" type="RigidBody2D" parent="DynamicShapes"]
position = Vector2( 100, 1024 )
[node name="RigidBodySphere" type="RigidDynamicBody2D" parent="DynamicShapes"]
position = Vector2(100, 1024)
gravity_scale = 0.0
[node name="CollisionShape2D" type="CollisionShape2D" parent="DynamicShapes/RigidBodySphere"]
shape = SubResource( 2 )
shape = SubResource( "2" )
[node name="RigidBodyCapsule" type="RigidBody2D" parent="DynamicShapes"]
position = Vector2( 200, 1024 )
[node name="RigidBodyCapsule" type="RigidDynamicBody2D" parent="DynamicShapes"]
position = Vector2(200, 1024)
gravity_scale = 0.0
[node name="CollisionShape2D" type="CollisionShape2D" parent="DynamicShapes/RigidBodyCapsule"]
shape = SubResource( 3 )
shape = SubResource( "3" )
[node name="RigidBodyConvexPolygon" type="RigidBody2D" parent="DynamicShapes"]
position = Vector2( 300, 1024 )
[node name="RigidBodyConvexPolygon" type="RigidDynamicBody2D" parent="DynamicShapes"]
position = Vector2(300, 1024)
gravity_scale = 0.0
[node name="CollisionPolygon2D" type="CollisionPolygon2D" parent="DynamicShapes/RigidBodyConvexPolygon"]
scale = Vector2( 0.1, 0.1 )
polygon = PoolVector2Array( 10.7, -54.5, 28.3596, -49.4067, 47.6282, -34.3806, 57.9717, -20.9447, 50.9869, 35.2694, 38.8, 47.5, 15.9852, 54.3613, -14.9507, 54.1845, -36.5, 48.1, -50.4828, 36.33, -58.0115, -20.515, -46.9473, -34.7342, -26.0876, -50.1138, -11.4152, -54.5332 )
scale = Vector2(0.1, 0.1)
polygon = PackedVector2Array(10.7, -54.5, 28.3596, -49.4067, 47.6282, -34.3806, 57.9717, -20.9447, 50.9869, 35.2694, 38.8, 47.5, 15.9852, 54.3613, -14.9507, 54.1845, -36.5, 48.1, -50.4828, 36.33, -58.0115, -20.515, -46.9473, -34.7342, -26.0876, -50.1138, -11.4152, -54.5332)
[node name="GodotIcon" type="Sprite" parent="DynamicShapes/RigidBodyConvexPolygon"]
self_modulate = Color( 1, 1, 1, 0.392157 )
scale = Vector2( 0.1, 0.1 )
texture = ExtResource( 3 )
[node name="GodotIcon" type="Sprite2D" parent="DynamicShapes/RigidBodyConvexPolygon"]
self_modulate = Color(1, 1, 1, 0.392157)
scale = Vector2(0.1, 0.1)
texture = ExtResource( "3" )
[node name="RigidBodyConcavePolygon" type="RigidBody2D" parent="DynamicShapes"]
position = Vector2( 400, 1024 )
[node name="RigidBodyConcavePolygon" type="RigidDynamicBody2D" parent="DynamicShapes"]
position = Vector2(400, 1024)
gravity_scale = 0.0
[node name="CollisionPolygon2D" type="CollisionPolygon2D" parent="DynamicShapes/RigidBodyConcavePolygon"]
scale = Vector2( 0.1, 0.1 )
polygon = PoolVector2Array( -5.93512, -43.2195, 6.44476, -42.9695, 11.127, -54.3941, 26.9528, -49.4309, 26.2037, -36.508, 37.5346, -28.1737, 47.6282, -34.3806, 58.0427, -20.9631, 51.113, -10.2876, 50.9869, 35.2694, 38.8, 47.5, 15.9852, 54.3613, -14.9507, 54.1845, -36.5, 48.1, -50.4828, 36.33, -51.3668, -9.98545, -57.8889, -20.5885, -46.9473, -34.7342, -37.4014, -28.547, -26.0876, -37.0323, -26.9862, -49.15, -11.4152, -54.5332 )
scale = Vector2(0.1, 0.1)
polygon = PackedVector2Array(-5.93512, -43.2195, 6.44476, -42.9695, 11.127, -54.3941, 26.9528, -49.4309, 26.2037, -36.508, 37.5346, -28.1737, 47.6282, -34.3806, 58.0427, -20.9631, 51.113, -10.2876, 50.9869, 35.2694, 38.8, 47.5, 15.9852, 54.3613, -14.9507, 54.1845, -36.5, 48.1, -50.4828, 36.33, -51.3668, -9.98545, -57.8889, -20.5885, -46.9473, -34.7342, -37.4014, -28.547, -26.0876, -37.0323, -26.9862, -49.15, -11.4152, -54.5332)
[node name="GodotIcon" type="Sprite" parent="DynamicShapes/RigidBodyConcavePolygon"]
self_modulate = Color( 1, 1, 1, 0.392157 )
scale = Vector2( 0.1, 0.1 )
texture = ExtResource( 3 )
[node name="GodotIcon" type="Sprite2D" parent="DynamicShapes/RigidBodyConcavePolygon"]
self_modulate = Color(1, 1, 1, 0.392157)
scale = Vector2(0.1, 0.1)
texture = ExtResource( "3" )

View File

@@ -8,11 +8,11 @@ const OPTION_TYPE_CAPSULE = "Shape type/Capsule"
const OPTION_TYPE_CONVEX_POLYGON = "Shape type/Convex Polygon"
const OPTION_TYPE_CONCAVE_POLYGON = "Shape type/Concave Polygon"
export(Array, NodePath) var spawns = Array()
export(int) var spawn_count = 100
export(Vector2) var spawn_randomize
@export var spawns = []
@export var spawn_count = 100
@export var spawn_randomize = Vector2.ZERO
onready var options = $Options
@onready var options = $Options
var _object_templates = []
@@ -22,7 +22,7 @@ var _log_physics_time_start = 0
func _ready():
yield(start_timer(0.5), "timeout")
await start_timer(0.5).timeout
if is_timer_canceled():
return
@@ -39,14 +39,16 @@ func _ready():
options.add_menu_item(OPTION_TYPE_CAPSULE)
options.add_menu_item(OPTION_TYPE_CONVEX_POLYGON)
options.add_menu_item(OPTION_TYPE_CONCAVE_POLYGON)
options.connect("option_selected", self, "_on_option_selected")
options.connect("option_selected", Callable(self, "_on_option_selected"))
_start_all_types()
await _start_all_types()
func _physics_process(_delta):
func _physics_process(delta):
super._physics_process(delta)
if _log_physics:
var time = OS.get_ticks_usec()
var time = Time.get_ticks_usec()
var time_delta = time - _log_physics_time
var time_total = time - _log_physics_time_start
_log_physics_time = time
@@ -55,7 +57,7 @@ func _physics_process(_delta):
func _log_physics_start():
_log_physics = true
_log_physics_time_start = OS.get_ticks_usec()
_log_physics_time_start = Time.get_ticks_usec()
_log_physics_time = _log_physics_time_start
@@ -75,17 +77,17 @@ func _on_option_selected(option):
match option:
OPTION_TYPE_ALL:
_start_all_types()
await _start_all_types()
OPTION_TYPE_RECTANGLE:
_start_type(_find_type_index("Rectangle"))
await _start_type(_find_type_index("Rectangle"))
OPTION_TYPE_SPHERE:
_start_type(_find_type_index("Sphere"))
await _start_type(_find_type_index("Sphere"))
OPTION_TYPE_CAPSULE:
_start_type(_find_type_index("Capsule"))
await _start_type(_find_type_index("Capsule"))
OPTION_TYPE_CONVEX_POLYGON:
_start_type(_find_type_index("ConvexPolygon"))
await _start_type(_find_type_index("ConvexPolygon"))
OPTION_TYPE_CONCAVE_POLYGON:
_start_type(_find_type_index("ConcavePolygon"))
await _start_type(_find_type_index("ConcavePolygon"))
func _find_type_index(type_name):
@@ -104,7 +106,7 @@ func _start_type(type_index):
if type_index >= _object_templates.size():
return
yield(start_timer(1.0), "timeout")
await start_timer(1.0).timeout
if is_timer_canceled():
return
@@ -112,10 +114,10 @@ func _start_type(type_index):
_spawn_objects(type_index)
yield(wait_for_physics_ticks(5), "wait_done")
await wait_for_physics_ticks(5).wait_done
_log_physics_stop()
yield(start_timer(1.0), "timeout")
await start_timer(1.0).timeout
if is_timer_canceled():
return
@@ -123,10 +125,10 @@ func _start_type(type_index):
_activate_objects()
yield(wait_for_physics_ticks(5), "wait_done")
await wait_for_physics_ticks(5).wait_done
_log_physics_stop()
yield(start_timer(5.0), "timeout")
await start_timer(5.0).timeout
if is_timer_canceled():
return
@@ -134,17 +136,17 @@ func _start_type(type_index):
_despawn_objects()
yield(wait_for_physics_ticks(5), "wait_done")
await wait_for_physics_ticks(5).wait_done
_log_physics_stop()
yield(start_timer(1.0), "timeout")
await start_timer(1.0).timeout
func _start_all_types():
Log.print_log("* Start all types.")
for type_index in range(_object_templates.size()):
yield(_start_type(type_index), "completed")
await _start_type(type_index)
if is_timer_canceled():
return
@@ -154,7 +156,7 @@ func _start_all_types():
func _spawn_objects(type_index):
var template_node = _object_templates[type_index]
Log.print_log("* Spawning: " + template_node.name)
Log.print_log("* Spawning: " + String(template_node.name))
for spawn in spawns:
var spawn_parent = get_node(spawn)
@@ -165,7 +167,7 @@ func _spawn_objects(type_index):
if collision is CollisionShape2D:
collision.shape = collision.shape.duplicate()
var body = template_node.duplicate()
body.transform = Transform.IDENTITY
body.transform = Transform2D.IDENTITY
if spawn_randomize != Vector2.ZERO:
body.position.x = randf() * spawn_randomize.x
body.position.y = randf() * spawn_randomize.y
@@ -184,7 +186,7 @@ func _activate_objects():
var spawn_parent = get_node(spawn)
for node_index in range(spawn_parent.get_child_count()):
var node = spawn_parent.get_child(node_index) as RigidBody2D
var node = spawn_parent.get_child(node_index) as RigidDynamicBody2D
node.set_sleeping(false)

View File

@@ -1,74 +1,74 @@
[gd_scene load_steps=8 format=2]
[gd_scene load_steps=8 format=3 uid="uid://bsieda0p35qu3"]
[ext_resource path="res://tests/static_scene.tscn" type="PackedScene" id=1]
[ext_resource path="res://tests/performance/test_perf_contacts.gd" type="Script" id=2]
[ext_resource path="res://assets/texture/godot-head.png" type="Texture" id=3]
[ext_resource path="res://tests/test_options.tscn" type="PackedScene" id=4]
[ext_resource type="PackedScene" uid="uid://dv7rxhg55y3t6" path="res://tests/static_scene.tscn" id="1"]
[ext_resource type="Script" path="res://tests/performance/test_perf_contacts.gd" id="2"]
[ext_resource type="Texture2D" uid="uid://c5duuyhbmd0m4" path="res://assets/texture/godot-head.png" id="3"]
[ext_resource type="PackedScene" uid="uid://blh3twy74kbkv" path="res://tests/test_options.tscn" id="4"]
[sub_resource type="RectangleShape2D" id=1]
extents = Vector2( 10, 15 )
[sub_resource type="RectangleShape2D" id="1"]
size = Vector2(20, 30)
[sub_resource type="CircleShape2D" id=2]
[sub_resource type="CircleShape2D" id="2"]
radius = 15.0
[sub_resource type="CapsuleShape2D" id=3]
height = 15.0
[sub_resource type="CapsuleShape2D" id="3"]
height = 35.0
[node name="Test" type="Node2D"]
script = ExtResource( 2 )
script = ExtResource( "2" )
_enable_debug_collision = false
spawns = [ NodePath("SpawnTarget1") ]
spawns = [NodePath("SpawnTarget1")]
spawn_count = 500
spawn_randomize = Vector2( 10, 10 )
spawn_randomize = Vector2(10, 10)
[node name="Options" parent="." instance=ExtResource( 4 )]
[node name="Options" parent="." instance=ExtResource( "4" )]
[node name="SpawnTarget1" type="Node2D" parent="."]
position = Vector2( 512, 400 )
position = Vector2(512, 400)
[node name="StaticScene" parent="." instance=ExtResource( 1 )]
position = Vector2( 0, 125.017 )
[node name="StaticScene" parent="." instance=ExtResource( "1" )]
position = Vector2(0, 125.017)
[node name="DynamicShapes" type="Node2D" parent="."]
[node name="RigidBodyRectangle" type="RigidBody2D" parent="DynamicShapes"]
position = Vector2( 0, 1024 )
[node name="RigidBodyRectangle" type="RigidDynamicBody2D" parent="DynamicShapes"]
position = Vector2(0, 1024)
[node name="CollisionShape2D" type="CollisionShape2D" parent="DynamicShapes/RigidBodyRectangle"]
shape = SubResource( 1 )
shape = SubResource( "1" )
[node name="RigidBodySphere" type="RigidBody2D" parent="DynamicShapes"]
position = Vector2( 100, 1024 )
[node name="RigidBodySphere" type="RigidDynamicBody2D" parent="DynamicShapes"]
position = Vector2(100, 1024)
[node name="CollisionShape2D" type="CollisionShape2D" parent="DynamicShapes/RigidBodySphere"]
shape = SubResource( 2 )
shape = SubResource( "2" )
[node name="RigidBodyCapsule" type="RigidBody2D" parent="DynamicShapes"]
position = Vector2( 200, 1024 )
[node name="RigidBodyCapsule" type="RigidDynamicBody2D" parent="DynamicShapes"]
position = Vector2(200, 1024)
[node name="CollisionShape2D" type="CollisionShape2D" parent="DynamicShapes/RigidBodyCapsule"]
shape = SubResource( 3 )
shape = SubResource( "3" )
[node name="RigidBodyConvexPolygon" type="RigidBody2D" parent="DynamicShapes"]
position = Vector2( 300, 1024 )
[node name="RigidBodyConvexPolygon" type="RigidDynamicBody2D" parent="DynamicShapes"]
position = Vector2(300, 1024)
[node name="CollisionPolygon2D" type="CollisionPolygon2D" parent="DynamicShapes/RigidBodyConvexPolygon"]
scale = Vector2( 0.25, 0.25 )
polygon = PoolVector2Array( 10.7, -54.5, 28.3596, -49.4067, 47.6282, -34.3806, 57.9717, -20.9447, 50.9869, 35.2694, 38.8, 47.5, 15.9852, 54.3613, -14.9507, 54.1845, -36.5, 48.1, -50.4828, 36.33, -58.0115, -20.515, -46.9473, -34.7342, -26.0876, -50.1138, -11.4152, -54.5332 )
scale = Vector2(0.25, 0.25)
polygon = PackedVector2Array(10.7, -54.5, 28.3596, -49.4067, 47.6282, -34.3806, 57.9717, -20.9447, 50.9869, 35.2694, 38.8, 47.5, 15.9852, 54.3613, -14.9507, 54.1845, -36.5, 48.1, -50.4828, 36.33, -58.0115, -20.515, -46.9473, -34.7342, -26.0876, -50.1138, -11.4152, -54.5332)
[node name="GodotIcon" type="Sprite" parent="DynamicShapes/RigidBodyConvexPolygon"]
self_modulate = Color( 1, 1, 1, 0.392157 )
scale = Vector2( 0.25, 0.25 )
texture = ExtResource( 3 )
[node name="GodotIcon" type="Sprite2D" parent="DynamicShapes/RigidBodyConvexPolygon"]
self_modulate = Color(1, 1, 1, 0.392157)
scale = Vector2(0.25, 0.25)
texture = ExtResource( "3" )
[node name="RigidBodyConcavePolygon" type="RigidBody2D" parent="DynamicShapes"]
position = Vector2( 400, 1024 )
[node name="RigidBodyConcavePolygon" type="RigidDynamicBody2D" parent="DynamicShapes"]
position = Vector2(400, 1024)
[node name="CollisionPolygon2D" type="CollisionPolygon2D" parent="DynamicShapes/RigidBodyConcavePolygon"]
scale = Vector2( 0.25, 0.25 )
polygon = PoolVector2Array( -5.93512, -43.2195, 6.44476, -42.9695, 11.127, -54.3941, 26.9528, -49.4309, 26.2037, -36.508, 37.5346, -28.1737, 47.6282, -34.3806, 58.0427, -20.9631, 51.113, -10.2876, 50.9869, 35.2694, 38.8, 47.5, 15.9852, 54.3613, -14.9507, 54.1845, -36.5, 48.1, -50.4828, 36.33, -51.3668, -9.98545, -57.8889, -20.5885, -46.9473, -34.7342, -37.4014, -28.547, -26.0876, -37.0323, -26.9862, -49.15, -11.4152, -54.5332 )
scale = Vector2(0.25, 0.25)
polygon = PackedVector2Array(-5.93512, -43.2195, 6.44476, -42.9695, 11.127, -54.3941, 26.9528, -49.4309, 26.2037, -36.508, 37.5346, -28.1737, 47.6282, -34.3806, 58.0427, -20.9631, 51.113, -10.2876, 50.9869, 35.2694, 38.8, 47.5, 15.9852, 54.3613, -14.9507, 54.1845, -36.5, 48.1, -50.4828, 36.33, -51.3668, -9.98545, -57.8889, -20.5885, -46.9473, -34.7342, -37.4014, -28.547, -26.0876, -37.0323, -26.9862, -49.15, -11.4152, -54.5332)
[node name="GodotIcon" type="Sprite" parent="DynamicShapes/RigidBodyConcavePolygon"]
self_modulate = Color( 1, 1, 1, 0.392157 )
scale = Vector2( 0.25, 0.25 )
texture = ExtResource( 3 )
[node name="GodotIcon" type="Sprite2D" parent="DynamicShapes/RigidBodyConcavePolygon"]
self_modulate = Color(1, 1, 1, 0.392157)
scale = Vector2(0.25, 0.25)
texture = ExtResource( "3" )

View File

@@ -1,10 +1,10 @@
[gd_scene format=2]
[gd_scene format=3 uid="uid://dv7rxhg55y3t6"]
[node name="StaticScene" type="Node2D"]
[node name="StaticBodyPolygon" type="StaticBody2D" parent="."]
position = Vector2( -7.85718, 399.596 )
position = Vector2(-7.85718, 399.596)
[node name="CollisionPolygon2D" type="CollisionPolygon2D" parent="StaticBodyPolygon"]
build_mode = 1
polygon = PoolVector2Array( 16.3331, -129.432, 154.006, -20.0078, 292.354, 30.3943, 447.054, 33.9161, 584.899, -14.7955, 751.156, -15.5179, 894.098, -65.4518, 1000.73, -209.127, 1037.77, -398.823, 1029.92, 253.327, 6.2309, 261.185, 7.35339, -398.823 )
polygon = PackedVector2Array(16.3331, -129.432, 154.006, -20.0078, 292.354, 30.3943, 447.054, 33.9161, 584.899, -14.7955, 751.156, -15.5179, 894.098, -65.4518, 1000.73, -209.127, 1037.77, -398.823, 1029.92, 253.327, 6.2309, 261.185, 7.35339, -398.823)

View File

@@ -1,12 +1,12 @@
[gd_scene load_steps=2 format=2]
[gd_scene load_steps=2 format=3 uid="uid://cx2q80okt25o1"]
[sub_resource type="RectangleShape2D" id=1]
extents = Vector2( 800, 50 )
[sub_resource type="RectangleShape2D" id="1"]
size = Vector2(1600, 100)
[node name="StaticSceneFlat" type="Node2D"]
[node name="StaticBodyPolygon" type="StaticBody2D" parent="."]
position = Vector2( 512, 550 )
position = Vector2(512, 550)
[node name="CollisionShape2D" type="CollisionShape2D" parent="StaticBodyPolygon"]
shape = SubResource( 1 )
shape = SubResource( "1" )

View File

@@ -1,17 +1,16 @@
[gd_scene load_steps=2 format=2]
[gd_scene load_steps=2 format=3 uid="uid://blh3twy74kbkv"]
[ext_resource path="res://utils/option_menu.gd" type="Script" id=1]
[ext_resource type="Script" path="res://utils/option_menu.gd" id="1"]
[node name="Options" type="MenuButton"]
pause_mode = 2
margin_left = 10.0
margin_top = 106.719
margin_right = 125.0
margin_bottom = 126.719
offset_left = 10.0
offset_top = 106.719
offset_right = 125.0
offset_bottom = 126.719
text = "TEST OPTIONS"
flat = false
align = 0
script = ExtResource( 1 )
script = ExtResource( "1" )
__meta__ = {
"_edit_use_anchors_": false
}

View File

@@ -9,11 +9,11 @@ class TestData:
var _test_list = []
var _current_test = null
var _current_test_scene = null
var _current_test_scene : Node = null
func _ready():
connect("option_selected", self, "_on_option_selected")
connect("option_selected", Callable(self, "_on_option_selected"))
func _process(_delta):
@@ -46,7 +46,7 @@ func _start_test(test):
Log.print_log("*** STARTING TEST: " + test.id)
var scene = load(test.scene_path)
_current_test_scene = scene.instance()
_current_test_scene = scene.instantiate()
get_tree().root.add_child(_current_test_scene)
get_tree().root.move_child(_current_test_scene, 0)

View File

@@ -1,4 +1,4 @@
extends KinematicBody2D
extends CharacterBody2D
var _initial_velocity = Vector2.ZERO
@@ -7,9 +7,11 @@ var _motion_speed = 400.0
var _gravity_force = 50.0
var _jump_force = 1000.0
var _velocity = Vector2.ZERO
var _snap = Vector2.ZERO
var _snap = 0.0
var _floor_max_angle = 45.0
var _stop_on_slope = false
var _move_on_floor_only = false
var _constant_speed = false
var _jumping = false
var _keep_velocity = false
@@ -42,13 +44,17 @@ func _physics_process(_delta):
# Start jumping.
_jumping = true
_velocity.y = -_jump_force
else:
_velocity.y += _gravity_force
# Always apply gravity for floor detection.
_velocity.y += _gravity_force
var snap = _snap if not _jumping else Vector2.ZERO
var max_angle = deg2rad(_floor_max_angle)
_velocity = move_and_slide_with_snap(_velocity, snap, Vector2.UP, _stop_on_slope, 4, max_angle)
floor_snap_length = _snap
floor_stop_on_slope = _stop_on_slope
floor_block_on_wall = _move_on_floor_only
floor_constant_speed = _constant_speed
floor_max_angle = deg2rad(_floor_max_angle)
motion_velocity = _velocity
move_and_slide()
_velocity = motion_velocity
# Get next jump ready.
if _jumping:

View File

@@ -7,7 +7,7 @@ var _entry_template
func _enter_tree():
Log.connect("entry_logged", self, "_on_log_entry")
Log.connect("entry_logged", Callable(self, "_on_log_entry"))
_entry_template = get_child(0) as Label
remove_child(_entry_template)
@@ -29,9 +29,9 @@ func _on_log_entry(message, type):
new_entry.set_text(message)
if type == Log.LogType.ERROR:
new_entry.modulate = Color.red
new_entry.modulate = Color.RED
else:
new_entry.modulate = Color.white
new_entry.modulate = Color.WHITE
if get_child_count() >= MAX_ENTRIES:
var first_entry = get_child(0) as Label

View File

@@ -1,5 +1,5 @@
@tool
extends Label
tool
func _process(_delta):

View File

@@ -1,13 +1,13 @@
extends Label
var test_name setget _set_test_name
var test_name = "":
set(value):
if (test_name != value):
return
test_name = value
set_text("Test: %s" % test_name)
func _ready():
set_text("Select a test from the menu to start it")
func _set_test_name(value):
test_name = value
set_text("Test: %s" % test_name)

View File

@@ -47,7 +47,7 @@ func _add_popup(parent_popup, path, label):
parent_popup.add_child(popup_menu)
parent_popup.add_submenu_item(label, label)
popup_menu.connect("index_pressed", self, "_on_item_pressed", [popup_menu, path])
popup_menu.connect("index_pressed", Callable(self, "_on_item_pressed"), [popup_menu, path])
return popup_menu

View File

@@ -1,4 +1,4 @@
extends RigidBody2D
extends RigidDynamicBody2D
var _initial_velocity = Vector2.ZERO
@@ -7,11 +7,15 @@ var _motion_speed = 400.0
var _gravity_force = 50.0
var _jump_force = 1000.0
var _velocity = Vector2.ZERO
var _floor_max_angle = 45.0
var _on_floor = false
var _jumping = false
var _keep_velocity = false
func _ready():
gravity_scale = 0.0
func _physics_process(_delta):
if _initial_velocity != Vector2.ZERO:
_velocity = _initial_velocity
@@ -44,7 +48,6 @@ func _physics_process(_delta):
# Reset gravity.
_velocity.y = 0.0
else:
# Apply gravity and get jump ready.
_velocity.y += _gravity_force
_jumping = false
@@ -56,10 +59,16 @@ func _integrate_forces(state):
var contacts = state.get_contact_count()
for i in contacts:
var pos = state.get_contact_collider_position(i)
if pos.y > position.y:
var normal = state.get_contact_local_normal(i)
# Detect floor.
if acos(normal.dot(Vector2.UP)) <= deg2rad(_floor_max_angle) + 0.01:
_on_floor = true
# Detect ceiling.
if acos(normal.dot(-Vector2.UP)) <= deg2rad(_floor_max_angle) + 0.01:
_jumping = false
_velocity.y = 0.0
func is_on_floor():
return _on_floor

View File

@@ -1,4 +1,4 @@
extends RigidBody2D
extends RigidDynamicBody2D
var _picked = false
@@ -25,7 +25,7 @@ func _input_event(_viewport, event, _shape_idx):
func _physics_process(delta):
if _picked:
var mouse_pos = get_global_mouse_position()
if mode == MODE_STATIC:
if freeze:
global_position = mouse_pos
else:
linear_velocity = (mouse_pos - _last_mouse_pos) / delta

View File

@@ -1,12 +1,12 @@
extends ScrollContainer
export(bool) var auto_scroll = false setget set_auto_scroll
@export var auto_scroll = false
func _ready():
var scrollbar = get_v_scrollbar()
scrollbar.connect("scrolling", self, "_on_scrolling")
scrollbar.connect("scrolling", Callable(self, "_on_scrolling"))
func _process(_delta):
@@ -15,10 +15,6 @@ func _process(_delta):
scrollbar.value = scrollbar.max_value
func set_auto_scroll(value):
auto_scroll = value
func _on_scrolling():
auto_scroll = false
$"../CheckBoxScroll".pressed = false

View File

@@ -1,7 +1,7 @@
extends Slider
extends HSlider
export(float) var snap_step = 1.0
@export var snap_step = 1.0
func _process(_delta):

View File

@@ -10,7 +10,7 @@ var _engine = PhysicsEngine.OTHER
func _enter_tree():
pause_mode = Node.PAUSE_MODE_PROCESS
process_mode = Node.PROCESS_MODE_ALWAYS
get_tree().debug_collisions_hint = true
@@ -18,7 +18,7 @@ func _enter_tree():
match engine_string:
"DEFAULT":
_engine = PhysicsEngine.GODOT_PHYSICS
"GodotPhysics":
"GodotPhysics2D":
_engine = PhysicsEngine.GODOT_PHYSICS
_:
_engine = PhysicsEngine.OTHER
@@ -26,7 +26,10 @@ func _enter_tree():
func _process(_delta):
if Input.is_action_just_pressed("toggle_full_screen"):
OS.window_fullscreen = not OS.window_fullscreen
if DisplayServer.window_get_mode() == DisplayServer.WINDOW_MODE_FULLSCREEN:
DisplayServer.window_set_mode(DisplayServer.WINDOW_MODE_WINDOWED)
else:
DisplayServer.window_set_mode(DisplayServer.WINDOW_MODE_FULLSCREEN)
if Input.is_action_just_pressed("toggle_debug_collision"):
var debug_collision_enabled = not _is_debug_collision_enabled()

File diff suppressed because one or more lines are too long

View File

@@ -1,8 +1,9 @@
[remap]
importer="texture"
type="StreamTexture"
path="res://.import/icon.png-487276ed1e3a0c39cad0279d744ee560.stex"
type="StreamTexture2D"
uid="uid://dyn1ihdui7i3h"
path="res://.godot/imported/icon.png-487276ed1e3a0c39cad0279d744ee560.stex"
metadata={
"vram_texture": false
}
@@ -10,26 +11,25 @@ metadata={
[deps]
source_file="res://icon.png"
dest_files=[ "res://.import/icon.png-487276ed1e3a0c39cad0279d744ee560.stex" ]
dest_files=["res://.godot/imported/icon.png-487276ed1e3a0c39cad0279d744ee560.stex"]
[params]
compress/mode=0
compress/lossy_quality=0.7
compress/hdr_mode=0
compress/hdr_compression=1
compress/bptc_ldr=0
compress/normal_map=0
flags/repeat=0
flags/filter=true
flags/mipmaps=false
flags/anisotropic=false
flags/srgb=2
compress/channel_pack=0
compress/streamed=false
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/HDR_as_SRGB=false
process/invert_color=false
process/normal_map_invert_y=false
stream=false
size_limit=0
detect_3d=true
process/HDR_as_SRGB=false
process/size_limit=0
detect_3d/compress_to=1
svg/scale=1.0

View File

@@ -1,132 +1,124 @@
[gd_scene load_steps=11 format=2]
[gd_scene load_steps=11 format=3 uid="uid://pfb5u7r1hl8t"]
[ext_resource path="res://utils/label_fps.gd" type="Script" id=1]
[ext_resource path="res://utils/label_version.gd" type="Script" id=2]
[ext_resource path="res://utils/label_engine.gd" type="Script" id=3]
[ext_resource path="res://tests_menu.gd" type="Script" id=4]
[ext_resource path="res://utils/label_test.gd" type="Script" id=5]
[ext_resource path="res://utils/label_pause.gd" type="Script" id=6]
[ext_resource path="res://utils/container_log.gd" type="Script" id=10]
[ext_resource path="res://utils/scroll_log.gd" type="Script" id=11]
[ext_resource path="res://tests.gd" type="Script" id=12]
[ext_resource type="Script" path="res://utils/label_fps.gd" id="1"]
[ext_resource type="Script" path="res://utils/label_version.gd" id="2"]
[ext_resource type="Script" path="res://utils/label_engine.gd" id="3"]
[ext_resource type="Script" path="res://tests_menu.gd" id="4"]
[ext_resource type="Script" path="res://utils/label_test.gd" id="5"]
[ext_resource type="Script" path="res://utils/label_pause.gd" id="6"]
[ext_resource type="Script" path="res://utils/container_log.gd" id="10"]
[ext_resource type="Script" path="res://utils/scroll_log.gd" id="11"]
[ext_resource type="Script" path="res://tests.gd" id="12"]
[sub_resource type="StyleBoxFlat" id=1]
bg_color = Color( 0, 0, 0, 0.176471 )
[sub_resource type="StyleBoxFlat" id="1"]
bg_color = Color(0, 0, 0, 0.176471)
[node name="Main" type="Control"]
anchor_right = 1.0
anchor_bottom = 1.0
mouse_filter = 2
script = ExtResource( 12 )
script = ExtResource( "12" )
__meta__ = {
"_edit_use_anchors_": false
}
[node name="TestsMenu" type="MenuButton" parent="."]
pause_mode = 2
margin_left = 10.0
margin_top = 10.0
margin_right = 125.0
margin_bottom = 30.0
offset_left = 10.0
offset_top = 10.0
offset_right = 125.0
offset_bottom = 30.0
text = "TESTS"
flat = false
script = ExtResource( 4 )
script = ExtResource( "4" )
__meta__ = {
"_edit_use_anchors_": false
}
[node name="LabelControls" type="Label" parent="."]
pause_mode = 2
margin_left = 157.0
margin_top = 13.0
margin_right = 375.0
margin_bottom = 27.0
offset_left = 157.0
offset_top = 13.0
offset_right = 375.0
offset_bottom = 27.0
text = "P - TOGGLE PAUSE / R - RESTART / C - TOGGLE COLLISION / F - TOGGLE FULL SCREEN / ESC - QUIT"
__meta__ = {
"_edit_use_anchors_": false
}
[node name="LabelFPS" type="Label" parent="."]
pause_mode = 2
anchor_top = 1.0
anchor_bottom = 1.0
margin_left = 10.0
margin_top = -19.0
margin_right = 50.0
margin_bottom = -5.0
offset_left = 10.0
offset_top = -19.0
offset_right = 50.0
offset_bottom = -5.0
text = "FPS: 0"
script = ExtResource( 1 )
script = ExtResource( "1" )
__meta__ = {
"_edit_use_anchors_": false
}
[node name="LabelEngine" type="Label" parent="."]
pause_mode = 2
anchor_top = 1.0
anchor_bottom = 1.0
margin_left = 10.0
margin_top = -39.0
margin_right = 50.0
margin_bottom = -25.0
offset_left = 10.0
offset_top = -39.0
offset_right = 50.0
offset_bottom = -25.0
text = "Physics engine:"
script = ExtResource( 3 )
script = ExtResource( "3" )
__meta__ = {
"_edit_use_anchors_": false
}
[node name="LabelVersion" type="Label" parent="."]
pause_mode = 2
anchor_top = 1.0
anchor_bottom = 1.0
margin_left = 10.0
margin_top = -59.0
margin_right = 50.0
margin_bottom = -45.0
offset_left = 10.0
offset_top = -59.0
offset_right = 50.0
offset_bottom = -45.0
text = "Godot Version:"
script = ExtResource( 2 )
script = ExtResource( "2" )
__meta__ = {
"_edit_use_anchors_": false
}
[node name="LabelTest" type="Label" parent="."]
pause_mode = 2
anchor_top = 1.0
anchor_bottom = 1.0
margin_left = 10.0
margin_top = -79.0
margin_right = 50.0
margin_bottom = -65.0
offset_left = 10.0
offset_top = -79.0
offset_right = 50.0
offset_bottom = -65.0
text = "Test:"
script = ExtResource( 5 )
script = ExtResource( "5" )
__meta__ = {
"_edit_use_anchors_": false
}
[node name="LabelPause" type="Label" parent="."]
pause_mode = 2
anchor_left = 0.5
anchor_top = 1.0
anchor_right = 0.5
anchor_bottom = 1.0
margin_left = -25.5
margin_top = -25.0
margin_right = 25.5
margin_bottom = -11.0
offset_left = -25.5
offset_top = -25.0
offset_right = 25.5
offset_bottom = -11.0
text = "PAUSED"
script = ExtResource( 6 )
script = ExtResource( "6" )
__meta__ = {
"_edit_use_anchors_": false
}
[node name="PanelLog" type="Panel" parent="."]
pause_mode = 2
anchor_left = 1.0
anchor_top = 1.0
anchor_right = 1.0
anchor_bottom = 1.0
margin_left = -428.0
margin_top = -125.0
custom_styles/panel = SubResource( 1 )
offset_left = -428.0
offset_top = -125.0
theme_override_styles/panel = SubResource( "1" )
__meta__ = {
"_edit_use_anchors_": false
}
@@ -136,10 +128,10 @@ anchor_left = 1.0
anchor_top = 1.0
anchor_right = 1.0
anchor_bottom = 1.0
margin_left = -48.0
margin_top = -25.0
margin_right = -5.0
margin_bottom = -5.0
offset_left = -48.0
offset_top = -25.0
offset_right = -5.0
offset_bottom = -5.0
focus_mode = 0
text = "clear"
__meta__ = {
@@ -151,10 +143,10 @@ anchor_left = 1.0
anchor_top = 1.0
anchor_right = 1.0
anchor_bottom = 1.0
margin_left = -150.0
margin_top = -27.0
margin_right = -54.0
margin_bottom = -3.0
offset_left = -150.0
offset_top = -27.0
offset_right = -54.0
offset_bottom = -3.0
focus_mode = 0
pressed = true
text = "auto-scroll"
@@ -163,29 +155,29 @@ __meta__ = {
}
[node name="ScrollLog" type="ScrollContainer" parent="PanelLog"]
margin_left = 10.0
margin_top = 5.0
margin_right = 418.0
margin_bottom = 94.0
offset_left = 10.0
offset_top = 5.0
offset_right = 418.0
offset_bottom = 94.0
scroll_horizontal_enabled = false
script = ExtResource( 11 )
script = ExtResource( "11" )
__meta__ = {
"_edit_use_anchors_": false
}
auto_scroll = true
[node name="VBoxLog" type="VBoxContainer" parent="PanelLog/ScrollLog"]
margin_right = 408.0
margin_bottom = 89.0
offset_right = 408.0
offset_bottom = 89.0
size_flags_horizontal = 3
size_flags_vertical = 3
alignment = 2
script = ExtResource( 10 )
script = ExtResource( "10" )
[node name="LabelLog" type="Label" parent="PanelLog/ScrollLog/VBoxLog"]
margin_top = 75.0
margin_right = 408.0
margin_bottom = 89.0
offset_top = 63.0
offset_right = 408.0
offset_bottom = 89.0
text = "Log start"
valign = 2
max_lines_visible = 5

View File

@@ -6,19 +6,19 @@
; [section] ; section goes between []
; param=value ; assign values to parameters
config_version=4
config_version=5
_global_script_classes=[ {
_global_script_classes=[{
"base": "MenuButton",
"class": "OptionMenu",
"language": "GDScript",
"class": &"OptionMenu",
"language": &"GDScript",
"path": "res://utils/option_menu.gd"
}, {
"base": "Node",
"class": "Test",
"language": "GDScript",
"class": &"Test",
"language": &"GDScript",
"path": "res://test.gd"
} ]
}]
_global_script_class_icons={
"OptionMenu": "",
"Test": ""
@@ -27,14 +27,9 @@ _global_script_class_icons={
[application]
config/name="3D Physics Tests"
config/description="This demo contains a series of tests for the 3D physics engine.
They can be used for different purposes:
- Functional tests to check for regressions and compare the behavior between physics engines
- Performance tests to evaluate and compare performance between physics engines"
run/main_scene="res://main.tscn"
config/icon="res://icon.png"
config/features=PackedStringArray("4.0")
[autoload]
@@ -55,62 +50,62 @@ window/stretch/aspect="expand"
ui_left={
"deadzone": 0.5,
"events": [ ]
"events": []
}
ui_right={
"deadzone": 0.5,
"events": [ ]
"events": []
}
ui_up={
"deadzone": 0.5,
"events": [ ]
"events": []
}
ui_down={
"deadzone": 0.5,
"events": [ ]
"events": []
}
toggle_full_screen={
"deadzone": 0.5,
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":70,"physical_scancode":0,"unicode":0,"echo":false,"script":null)
]
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"store_command":true,"alt_pressed":false,"shift_pressed":false,"meta_pressed":false,"command_pressed":false,"pressed":false,"keycode":70,"physical_keycode":0,"unicode":0,"echo":false,"script":null)
]
}
exit={
"deadzone": 0.5,
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":16777217,"physical_scancode":0,"unicode":0,"echo":false,"script":null)
]
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"store_command":true,"alt_pressed":false,"shift_pressed":false,"meta_pressed":false,"command_pressed":false,"pressed":false,"keycode":16777217,"physical_keycode":0,"unicode":0,"echo":false,"script":null)
]
}
toggle_debug_collision={
"deadzone": 0.5,
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":67,"physical_scancode":0,"unicode":0,"echo":false,"script":null)
]
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"store_command":true,"alt_pressed":false,"shift_pressed":false,"meta_pressed":false,"command_pressed":false,"pressed":false,"keycode":67,"physical_keycode":0,"unicode":0,"echo":false,"script":null)
]
}
restart_test={
"deadzone": 0.5,
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":82,"physical_scancode":0,"unicode":0,"echo":false,"script":null)
]
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"store_command":true,"alt_pressed":false,"shift_pressed":false,"meta_pressed":false,"command_pressed":false,"pressed":false,"keycode":82,"physical_keycode":0,"unicode":0,"echo":false,"script":null)
]
}
toggle_pause={
"deadzone": 0.5,
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":80,"physical_scancode":0,"unicode":0,"echo":false,"script":null)
]
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"store_command":true,"alt_pressed":false,"shift_pressed":false,"meta_pressed":false,"command_pressed":false,"pressed":false,"keycode":80,"physical_keycode":0,"unicode":0,"echo":false,"script":null)
]
}
character_right={
"deadzone": 0.5,
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":68,"physical_scancode":0,"unicode":0,"echo":false,"script":null)
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":16777233,"physical_scancode":0,"unicode":0,"echo":false,"script":null)
]
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"store_command":true,"alt_pressed":false,"shift_pressed":false,"meta_pressed":false,"command_pressed":false,"pressed":false,"keycode":16777233,"physical_keycode":0,"unicode":0,"echo":false,"script":null)
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"store_command":true,"alt_pressed":false,"shift_pressed":false,"meta_pressed":false,"command_pressed":false,"pressed":false,"keycode":68,"physical_keycode":0,"unicode":0,"echo":false,"script":null)
]
}
character_left={
"deadzone": 0.5,
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":65,"physical_scancode":0,"unicode":0,"echo":false,"script":null)
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":16777231,"physical_scancode":0,"unicode":0,"echo":false,"script":null)
]
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"store_command":true,"alt_pressed":false,"shift_pressed":false,"meta_pressed":false,"command_pressed":false,"pressed":false,"keycode":16777231,"physical_keycode":0,"unicode":0,"echo":false,"script":null)
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"store_command":true,"alt_pressed":false,"shift_pressed":false,"meta_pressed":false,"command_pressed":false,"pressed":false,"keycode":65,"physical_keycode":0,"unicode":0,"echo":false,"script":null)
]
}
character_jump={
"deadzone": 0.5,
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":87,"physical_scancode":0,"unicode":0,"echo":false,"script":null)
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":32,"physical_scancode":0,"unicode":0,"echo":false,"script":null)
]
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"store_command":true,"alt_pressed":false,"shift_pressed":false,"meta_pressed":false,"command_pressed":false,"pressed":false,"keycode":16777232,"physical_keycode":0,"unicode":0,"echo":false,"script":null)
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"store_command":true,"alt_pressed":false,"shift_pressed":false,"meta_pressed":false,"command_pressed":false,"pressed":false,"keycode":87,"physical_keycode":0,"unicode":0,"echo":false,"script":null)
]
}
[rendering]
@@ -118,5 +113,5 @@ character_jump={
quality/driver/driver_name="GLES2"
vram_compression/import_etc=true
vram_compression/import_etc2=false
environment/default_clear_color=Color( 0.184314, 0.184314, 0.184314, 1 )
environment/default_clear_color=Color(0.184314, 0.184314, 0.184314, 1)
quality/filters/msaa=2

View File

@@ -4,7 +4,7 @@ extends Node
signal wait_done()
export var _enable_debug_collision = true
@export var _enable_debug_collision = true
var _timer
var _timer_started = false
@@ -27,17 +27,17 @@ func _physics_process(_delta):
func add_sphere(pos, radius, color):
var sphere = MeshInstance.new()
var sphere = MeshInstance3D.new()
var sphere_mesh = SphereMesh.new()
sphere_mesh.radius = radius
sphere_mesh.height = radius * 2.0
sphere.mesh = sphere_mesh
var material = SpatialMaterial.new()
var material = StandardMaterial3D.new()
material.flags_unshaded = true
material.albedo_color = color
sphere.material_override = material
sphere.set_surface_override_material(0, material)
_drawn_nodes.push_back(sphere)
add_child(sphere)
@@ -48,14 +48,14 @@ func add_sphere(pos, radius, color):
func add_shape(shape, transform, color):
var debug_mesh = shape.get_debug_mesh()
var mesh_instance = MeshInstance.new()
var mesh_instance = MeshInstance3D.new()
mesh_instance.transform = transform
mesh_instance.mesh = debug_mesh
var material = SpatialMaterial.new()
var material = StandardMaterial3D.new()
material.flags_unshaded = true
material.albedo_color = color
mesh_instance.material_override = material
mesh_instance.set_surface_override_material(0, material)
add_child(mesh_instance)
_drawn_nodes.push_back(mesh_instance)
@@ -68,12 +68,12 @@ func clear_drawn_nodes():
_drawn_nodes.clear()
func create_rigidbody(shape, pickable = false, transform = Transform.IDENTITY):
var collision = CollisionShape.new()
func create_rigidbody(shape, pickable = false, transform = Transform3D.IDENTITY):
var collision = CollisionShape3D.new()
collision.shape = shape
collision.transform = transform
var body = RigidBody.new()
var body = RigidDynamicBody3D.new()
body.add_child(collision)
if pickable:
@@ -83,9 +83,9 @@ func create_rigidbody(shape, pickable = false, transform = Transform.IDENTITY):
return body
func create_rigidbody_box(size, pickable = false, transform = Transform.IDENTITY):
var shape = BoxShape.new()
shape.extents = 0.5 * size
func create_rigidbody_box(size, pickable = false, transform = Transform3D.IDENTITY):
var shape = BoxShape3D.new()
shape.size = size
return create_rigidbody(shape, pickable, transform)
@@ -95,7 +95,7 @@ func start_timer(timeout):
_timer = Timer.new()
_timer.one_shot = true
add_child(_timer)
_timer.connect("timeout", self, "_on_timer_done")
_timer.connect("timeout", Callable(self, "_on_timer_done"))
else:
cancel_timer()

View File

@@ -16,7 +16,7 @@ const OPTION_SHAPE_CONCAVE_POLYGON = "Shape type/Concave Polygon"
const OFFSET_RANGE = 3.0
export(Vector3) var offset = Vector3.ZERO
@export var offset = Vector3.ZERO
var _update_collision = false
var _collision_test_index = 0
@@ -40,10 +40,10 @@ func _ready():
$Options.add_menu_item(OPTION_SHAPE_CONVEX_POLYGON, true, true)
$Options.add_menu_item(OPTION_SHAPE_CONCAVE_POLYGON, true, true)
$Options.connect("option_selected", self, "_on_option_selected")
$Options.connect("option_changed", self, "_on_option_changed")
$Options.connect("option_selected", Callable(self, "_on_option_selected"))
$Options.connect("option_changed", Callable(self, "_on_option_changed"))
yield(start_timer(0.5), "timeout")
await start_timer(0.5).timeout
if is_timer_canceled():
return
@@ -53,19 +53,21 @@ func _ready():
func _input(event):
var key_event = event as InputEventKey
if key_event and not key_event.pressed:
if key_event.scancode == KEY_1:
if key_event.keycode == KEY_1:
_on_option_selected(OPTION_TYPE_BOX)
elif key_event.scancode == KEY_2:
elif key_event.keycode == KEY_2:
_on_option_selected(OPTION_TYPE_SPHERE)
elif key_event.scancode == KEY_3:
elif key_event.keycode == KEY_3:
_on_option_selected(OPTION_TYPE_CAPSULE)
elif key_event.scancode == KEY_4:
elif key_event.keycode == KEY_4:
_on_option_selected(OPTION_TYPE_CYLINDER)
elif key_event.scancode == KEY_5:
elif key_event.keycode == KEY_5:
_on_option_selected(OPTION_TYPE_CONVEX_POLYGON)
func _physics_process(_delta):
func _physics_process(delta):
super._physics_process(delta)
if not _update_collision:
return
@@ -93,7 +95,7 @@ func _initialize_collision_shapes():
_collision_shapes.clear()
for node in $Shapes.get_children():
var body = node as PhysicsBody
var body = node as PhysicsBody3D
var shape = body.shape_owner_get_shape(0, 0)
shape.resource_name = String(node.name).substr("RigidBody".length())
@@ -107,17 +109,17 @@ func _do_collision_test():
Log.print_log("* Start %s collision tests..." % shape.resource_name)
var shape_query = PhysicsShapeQueryParameters.new()
var shape_query = PhysicsShapeQueryParameters3D.new()
shape_query.set_shape(shape)
var shape_scale = Vector3(0.5, 0.5, 0.5)
shape_query.transform = Transform.IDENTITY.scaled(shape_scale)
shape_query.transform = Transform3D.IDENTITY.scaled(shape_scale)
for node in $Shapes.get_children():
if not node.visible:
continue
var body = node as PhysicsBody
var space_state = body.get_world().direct_space_state
var body = node as PhysicsBody3D
var space_state = body.get_world_3d().direct_space_state
Log.print_log("* Testing: %s" % body.name)
@@ -125,7 +127,7 @@ func _do_collision_test():
# Collision at the center inside.
var res = _add_collision(space_state, center, shape, shape_query)
Log.print_log("Collision center inside: %s" % ("NO HIT" if res.empty() else "HIT"))
Log.print_log("Collision center inside: %s" % ("NO HIT" if res.is_empty() else "HIT"))
Log.print_log("* Done.")
@@ -135,17 +137,17 @@ func _add_collision(space_state, pos, shape, shape_query):
var results = space_state.collide_shape(shape_query)
var color
if results.empty():
color = Color.white.darkened(0.5)
if results.is_empty():
color = Color.WHITE.darkened(0.5)
else:
color = Color.green
color = Color.GREEN
# Draw collision query shape.
add_shape(shape, shape_query.transform, color)
# Draw contact positions.
for contact_pos in results:
add_sphere(contact_pos, 0.05, Color.red)
add_sphere(contact_pos, 0.05, Color.RED)
return results

View File

@@ -1,168 +1,163 @@
[gd_scene load_steps=10 format=2]
[gd_scene load_steps=10 format=3 uid="uid://wy4qr8euxk27"]
[ext_resource path="res://assets/robot_head/godot3_robot_head_collision.tres" type="Shape" id=1]
[ext_resource path="res://tests/functional/test_collision_pairs.gd" type="Script" id=2]
[ext_resource path="res://utils/camera_orbit.gd" type="Script" id=4]
[ext_resource path="res://tests/test_options.tscn" type="PackedScene" id=5]
[ext_resource type="Shape3D" path="res://assets/robot_head/godot3_robot_head_collision.tres" id="1"]
[ext_resource type="Script" path="res://tests/functional/test_collision_pairs.gd" id="2"]
[ext_resource type="Script" path="res://utils/camera_orbit.gd" id="4"]
[ext_resource type="PackedScene" uid="uid://b1ihqm3x8jru" path="res://tests/test_options.tscn" id="5"]
[sub_resource type="BoxShape" id=1]
[sub_resource type="BoxShape3D" id="1"]
[sub_resource type="SphereShape" id=2]
[sub_resource type="SphereShape3D" id="2"]
[sub_resource type="CapsuleShape" id=3]
[sub_resource type="CapsuleShape3D" id="3"]
[sub_resource type="CylinderShape" id=4]
[sub_resource type="CylinderShape3D" id="4"]
[sub_resource type="ConvexPolygonShape" id=5]
points = PoolVector3Array( -0.7, 0, -0.7, -0.3, 0, 0.8, 0.8, 0, -0.3, 0, -1, 0 )
[sub_resource type="ConvexPolygonShape3D" id="5"]
points = PackedVector3Array(-0.7, 0, -0.7, -0.3, 0, 0.8, 0.8, 0, -0.3, 0, -1, 0)
[node name="Test" type="Spatial"]
script = ExtResource( 2 )
[node name="Test" type="Node3D"]
script = ExtResource( "2" )
[node name="Options" parent="." instance=ExtResource( 5 )]
[node name="Options" parent="." instance=ExtResource( "5" )]
[node name="Controls" type="VBoxContainer" parent="."]
pause_mode = 2
anchor_right = 1.0
anchor_bottom = 1.0
margin_left = 25.0
margin_top = 417.0
margin_right = -806.0
margin_bottom = -141.0
custom_constants/separation = 10
offset_left = 25.0
offset_top = 417.0
offset_right = -806.0
offset_bottom = -141.0
theme_override_constants/separation = 10
__meta__ = {
"_edit_use_anchors_": false
}
[node name="OffsetX" type="HBoxContainer" parent="Controls"]
margin_right = 193.0
margin_bottom = 16.0
custom_constants/separation = 20
offset_right = 202.0
offset_bottom = 26.0
theme_override_constants/separation = 20
alignment = 2
__meta__ = {
"_edit_use_anchors_": false
}
[node name="Label" type="Label" parent="Controls/OffsetX"]
margin_left = 2.0
margin_top = 1.0
margin_right = 53.0
margin_bottom = 15.0
offset_right = 62.0
offset_bottom = 26.0
text = "Offset X"
[node name="HSlider" type="HSlider" parent="Controls/OffsetX"]
margin_left = 73.0
margin_right = 193.0
margin_bottom = 16.0
rect_min_size = Vector2( 120, 0 )
offset_left = 82.0
offset_right = 202.0
offset_bottom = 16.0
rect_min_size = Vector2(120, 0)
min_value = -1.0
max_value = 1.0
step = 0.01
[node name="OffsetY" type="HBoxContainer" parent="Controls"]
margin_top = 26.0
margin_right = 193.0
margin_bottom = 42.0
custom_constants/separation = 20
offset_top = 36.0
offset_right = 202.0
offset_bottom = 62.0
theme_override_constants/separation = 20
alignment = 2
__meta__ = {
"_edit_use_anchors_": false
}
[node name="Label" type="Label" parent="Controls/OffsetY"]
margin_left = 3.0
margin_top = 1.0
margin_right = 53.0
margin_bottom = 15.0
offset_left = 1.0
offset_right = 62.0
offset_bottom = 26.0
text = "Offset Y"
[node name="HSlider" type="HSlider" parent="Controls/OffsetY"]
margin_left = 73.0
margin_right = 193.0
margin_bottom = 16.0
rect_min_size = Vector2( 120, 0 )
offset_left = 82.0
offset_right = 202.0
offset_bottom = 16.0
rect_min_size = Vector2(120, 0)
min_value = -1.0
max_value = 1.0
step = 0.01
[node name="OffsetZ" type="HBoxContainer" parent="Controls"]
margin_top = 52.0
margin_right = 193.0
margin_bottom = 68.0
custom_constants/separation = 20
offset_top = 72.0
offset_right = 202.0
offset_bottom = 98.0
theme_override_constants/separation = 20
alignment = 2
__meta__ = {
"_edit_use_anchors_": false
}
[node name="Label" type="Label" parent="Controls/OffsetZ"]
margin_left = 2.0
margin_top = 1.0
margin_right = 53.0
margin_bottom = 15.0
offset_left = 1.0
offset_right = 62.0
offset_bottom = 26.0
text = "Offset Z"
[node name="HSlider" type="HSlider" parent="Controls/OffsetZ"]
margin_left = 73.0
margin_right = 193.0
margin_bottom = 16.0
rect_min_size = Vector2( 120, 0 )
offset_left = 82.0
offset_right = 202.0
offset_bottom = 16.0
rect_min_size = Vector2(120, 0)
min_value = -1.0
max_value = 1.0
step = 0.01
[node name="Shapes" type="Spatial" parent="."]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 9.35591, 0 )
[node name="Shapes" type="Node3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 9.35591, 0)
[node name="RigidBodyBox" type="RigidBody" parent="Shapes"]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, -6, 0, 0 )
mode = 3
[node name="RigidBodyBox" type="RigidDynamicBody3D" parent="Shapes"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -6, 0, 0)
freeze = true
[node name="CollisionShape" type="CollisionShape" parent="Shapes/RigidBodyBox"]
transform = Transform( 0.579556, 0.0885213, 0.145926, 0, 0.939693, -0.205212, -0.155291, 0.330366, 0.544604, 0, 0, 0 )
shape = SubResource( 1 )
[node name="CollisionShape" type="CollisionShape3D" parent="Shapes/RigidBodyBox"]
transform = Transform3D(0.579556, 0.0885213, 0.145926, 0, 0.939693, -0.205212, -0.155291, 0.330366, 0.544604, 0, 0, 0)
shape = SubResource( "1" )
[node name="RigidBodySphere" type="RigidBody" parent="Shapes"]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, -3, 0, 0 )
mode = 3
[node name="RigidBodySphere" type="RigidDynamicBody3D" parent="Shapes"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -3, 0, 0)
freeze = true
[node name="CollisionShape" type="CollisionShape" parent="Shapes/RigidBodySphere"]
transform = Transform( 1.2, 0, 0, 0, 1.2, 0, 0, 0, 1.2, 0, 0, 0 )
shape = SubResource( 2 )
[node name="CollisionShape" type="CollisionShape3D" parent="Shapes/RigidBodySphere"]
transform = Transform3D(1.2, 0, 0, 0, 1.2, 0, 0, 0, 1.2, 0, 0, 0)
shape = SubResource( "2" )
[node name="RigidBodyCapsule" type="RigidBody" parent="Shapes"]
mode = 3
[node name="RigidBodyCapsule" type="RigidDynamicBody3D" parent="Shapes"]
freeze = true
[node name="CollisionShape" type="CollisionShape" parent="Shapes/RigidBodyCapsule"]
transform = Transform( 0.8, 0, 0, 0, -1.30337e-07, -0.8, 0, 0.8, -1.30337e-07, 0, 0, 0 )
shape = SubResource( 3 )
[node name="CollisionShape" type="CollisionShape3D" parent="Shapes/RigidBodyCapsule"]
transform = Transform3D(0.8, 0, 0, 0, 0.8, 0, 0, 0, 0.8, 0, 0, 0)
shape = SubResource( "3" )
[node name="RigidBodyCylinder" type="RigidBody" parent="Shapes"]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 3, 0, 0 )
mode = 3
[node name="RigidBodyCylinder" type="RigidDynamicBody3D" parent="Shapes"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 3, 0, 0)
freeze = true
[node name="CollisionShape" type="CollisionShape" parent="Shapes/RigidBodyCylinder"]
transform = Transform( 0.772741, -0.258819, 2.59821e-08, 0.2, 0.933013, -0.207055, 0.0535898, 0.25, 0.772741, 0, 0, 0 )
shape = SubResource( 4 )
[node name="CollisionShape" type="CollisionShape3D" parent="Shapes/RigidBodyCylinder"]
transform = Transform3D(0.772741, -0.258819, 2.59821e-08, 0.2, 0.933013, -0.207055, 0.0535898, 0.25, 0.772741, 0, 0, 0)
shape = SubResource( "4" )
[node name="RigidBodyConvexPolygon" type="RigidBody" parent="Shapes"]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 6, -0.211, 0 )
mode = 3
[node name="RigidBodyConvexPolygon" type="RigidDynamicBody3D" parent="Shapes"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 6, -0.211, 0)
freeze = true
[node name="CollisionShape" type="CollisionShape" parent="Shapes/RigidBodyConvexPolygon"]
transform = Transform( 2, 0, 0, 0, 2.89766, -0.517939, 0, 0.776908, 1.93177, 0, 0.3533, 0 )
shape = SubResource( 5 )
[node name="CollisionShape" type="CollisionShape3D" parent="Shapes/RigidBodyConvexPolygon"]
transform = Transform3D(2, 0, 0, 0, 2.95442, 0.347296, 0, -0.520945, 1.96962, 0, 0.35, 0)
shape = SubResource( "5" )
[node name="RigidBodyConcavePolygon" type="StaticBody" parent="Shapes"]
transform = Transform( 2, 0, 0, 0, 2, 0, 0, 0, 2, 0, -6, 3.93357 )
[node name="RigidBodyConcavePolygon" type="StaticBody3D" parent="Shapes"]
transform = Transform3D(2, 0, 0, 0, 2, 0, 0, 0, 2, 0, -6, 3.934)
[node name="CollisionShape" type="CollisionShape" parent="Shapes/RigidBodyConcavePolygon"]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -1, 0 )
shape = ExtResource( 1 )
[node name="CollisionShape" type="CollisionShape3D" parent="Shapes/RigidBodyConcavePolygon"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -1, 0)
shape = ExtResource( "1" )
[node name="Camera" type="Camera" parent="."]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 5.8667, 11.8164 )
script = ExtResource( 4 )
[node name="Camera3D" type="Camera3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 8.38087, 11.8164)
script = ExtResource( "4" )
[connection signal="value_changed" from="Controls/OffsetX/HSlider" to="." method="set_x_offset"]
[connection signal="value_changed" from="Controls/OffsetY/HSlider" to="." method="set_y_offset"]

View File

@@ -1,134 +1,134 @@
[gd_scene load_steps=6 format=2]
[gd_scene load_steps=6 format=3 uid="uid://b15gg5je5qdu4"]
[ext_resource path="res://tests/static_scene.tscn" type="PackedScene" id=1]
[ext_resource path="res://test.gd" type="Script" id=2]
[ext_resource path="res://utils/camera_orbit.gd" type="Script" id=3]
[ext_resource type="PackedScene" uid="uid://cl2vpuxqgnylc" path="res://tests/static_scene.tscn" id="1"]
[ext_resource type="Script" path="res://test.gd" id="2"]
[ext_resource type="Script" path="res://utils/camera_orbit.gd" id="3"]
[sub_resource type="BoxShape" id=1]
[sub_resource type="BoxShape3D" id="1"]
[sub_resource type="CapsuleShape" id=2]
[sub_resource type="CapsuleShape3D" id="2"]
radius = 0.2
[node name="Test" type="Spatial"]
script = ExtResource( 2 )
[node name="Test" type="Node3D"]
script = ExtResource( "2" )
[node name="DynamicShapes" type="Spatial" parent="."]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 9.35591, 0 )
[node name="DynamicShapes" type="Node3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 9.35591, 0)
[node name="RigidBodyG" type="RigidBody" parent="DynamicShapes"]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, -5.51361, 0, 0 )
[node name="RigidBodyG" type="RigidDynamicBody3D" parent="DynamicShapes"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -5.51361, 0, 0)
[node name="CollisionShape1" type="CollisionShape" parent="DynamicShapes/RigidBodyG"]
transform = Transform( -2.44381e-07, -0.3, 0, 1.5, -4.88762e-08, 0, 0, 0, 0.3, -0.8, 0, 0 )
shape = SubResource( 1 )
[node name="CollisionShape1" type="CollisionShape3D" parent="DynamicShapes/RigidBodyG"]
transform = Transform3D(-2.44381e-07, -0.3, 0, 1.5, -4.88762e-08, 0, 0, 0, 0.3, -0.8, 0, 0)
shape = SubResource( "1" )
[node name="CollisionShape2" type="CollisionShape" parent="DynamicShapes/RigidBodyG"]
transform = Transform( 0.8, 0, 4.26326e-15, 0, 0.3, 0, -1.13687e-14, 0, 0.3, 0.3, -1.2, 0 )
shape = SubResource( 1 )
[node name="CollisionShape2" type="CollisionShape3D" parent="DynamicShapes/RigidBodyG"]
transform = Transform3D(0.8, 0, 4.26326e-15, 0, 0.3, 0, -1.13687e-14, 0, 0.3, 0.3, -1.2, 0)
shape = SubResource( "1" )
[node name="CollisionShape3" type="CollisionShape" parent="DynamicShapes/RigidBodyG"]
transform = Transform( -8.14603e-08, -0.3, 0, 0.5, -4.88762e-08, 0, 0, 0, 0.3, 0.8, -0.5, 0 )
shape = SubResource( 1 )
[node name="CollisionShape3" type="CollisionShape3D" parent="DynamicShapes/RigidBodyG"]
transform = Transform3D(-8.14603e-08, -0.3, 0, 0.5, -4.88762e-08, 0, 0, 0, 0.3, 0.8, -0.5, 0)
shape = SubResource( "1" )
[node name="CollisionShape4" type="CollisionShape" parent="DynamicShapes/RigidBodyG"]
transform = Transform( 0.8, 0, 4.26326e-15, 0, 0.3, 0, -1.13687e-14, 0, 0.3, 0.3, 1.2, 0 )
shape = SubResource( 1 )
[node name="CollisionShape4" type="CollisionShape3D" parent="DynamicShapes/RigidBodyG"]
transform = Transform3D(0.8, 0, 4.26326e-15, 0, 0.3, 0, -1.13687e-14, 0, 0.3, 0.3, 1.2, 0)
shape = SubResource( "1" )
[node name="RigidBodyO" type="RigidBody" parent="DynamicShapes"]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, -2.65654, 0, 0 )
[node name="RigidBodyO" type="RigidDynamicBody3D" parent="DynamicShapes"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -2.65654, 0, 0)
[node name="CollisionShape1" type="CollisionShape" parent="DynamicShapes/RigidBodyO"]
transform = Transform( -2.44381e-07, -0.3, 0, 1.5, -4.88762e-08, 0, 0, 0, 0.3, -0.8, 0, 0 )
shape = SubResource( 1 )
[node name="CollisionShape1" type="CollisionShape3D" parent="DynamicShapes/RigidBodyO"]
transform = Transform3D(-2.44381e-07, -0.3, 0, 1.5, -4.88762e-08, 0, 0, 0, 0.3, -0.8, 0, 0)
shape = SubResource( "1" )
[node name="CollisionShape2" type="CollisionShape" parent="DynamicShapes/RigidBodyO"]
transform = Transform( 0.5, 0, 4.26326e-15, 0, 0.3, 0, -7.10543e-15, 0, 0.3, 0, 1.2, 0 )
shape = SubResource( 1 )
[node name="CollisionShape2" type="CollisionShape3D" parent="DynamicShapes/RigidBodyO"]
transform = Transform3D(0.5, 0, 4.26326e-15, 0, 0.3, 0, -7.10543e-15, 0, 0.3, 0, 1.2, 0)
shape = SubResource( "1" )
[node name="CollisionShape3" type="CollisionShape" parent="DynamicShapes/RigidBodyO"]
transform = Transform( 0.5, 0, 4.26326e-15, 0, 0.3, 0, -7.10543e-15, 0, 0.3, 0, -1.2, 0 )
shape = SubResource( 1 )
[node name="CollisionShape3" type="CollisionShape3D" parent="DynamicShapes/RigidBodyO"]
transform = Transform3D(0.5, 0, 4.26326e-15, 0, 0.3, 0, -7.10543e-15, 0, 0.3, 0, -1.2, 0)
shape = SubResource( "1" )
[node name="CollisionShape4" type="CollisionShape" parent="DynamicShapes/RigidBodyO"]
transform = Transform( -2.44381e-07, -0.3, 0, 1.5, -4.88762e-08, 0, 0, 0, 0.3, 0.8, 0, 0 )
shape = SubResource( 1 )
[node name="CollisionShape4" type="CollisionShape3D" parent="DynamicShapes/RigidBodyO"]
transform = Transform3D(-2.44381e-07, -0.3, 0, 1.5, -4.88762e-08, 0, 0, 0, 0.3, 0.8, 0, 0)
shape = SubResource( "1" )
[node name="RigidBodyD" type="RigidBody" parent="DynamicShapes"]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0.248918, 0, 0 )
[node name="RigidBodyD" type="RigidDynamicBody3D" parent="DynamicShapes"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.248918, 0, 0)
[node name="CollisionShape1" type="CollisionShape" parent="DynamicShapes/RigidBodyD"]
transform = Transform( -2.44381e-07, -0.3, 0, 1.5, -4.88762e-08, 0, 0, 0, 0.3, -0.8, 0, 0 )
shape = SubResource( 1 )
[node name="CollisionShape1" type="CollisionShape3D" parent="DynamicShapes/RigidBodyD"]
transform = Transform3D(-2.44381e-07, -0.3, 0, 1.5, -4.88762e-08, 0, 0, 0, 0.3, -0.8, 0, 0)
shape = SubResource( "1" )
[node name="CollisionShape2" type="CollisionShape" parent="DynamicShapes/RigidBodyD"]
transform = Transform( 0.5, 0, 4.26326e-15, 0, 0.3, 0, -7.10543e-15, 0, 0.3, 0, 1.2, 0 )
shape = SubResource( 1 )
[node name="CollisionShape2" type="CollisionShape3D" parent="DynamicShapes/RigidBodyD"]
transform = Transform3D(0.5, 0, 4.26326e-15, 0, 0.3, 0, -7.10543e-15, 0, 0.3, 0, 1.2, 0)
shape = SubResource( "1" )
[node name="CollisionShape3" type="CollisionShape" parent="DynamicShapes/RigidBodyD"]
transform = Transform( 0.5, 0, 4.26326e-15, 0, 0.3, 0, -7.10543e-15, 0, 0.3, 0, -1.2, 0 )
shape = SubResource( 1 )
[node name="CollisionShape3" type="CollisionShape3D" parent="DynamicShapes/RigidBodyD"]
transform = Transform3D(0.5, 0, 4.26326e-15, 0, 0.3, 0, -7.10543e-15, 0, 0.3, 0, -1.2, 0)
shape = SubResource( "1" )
[node name="CollisionShape4" type="CollisionShape" parent="DynamicShapes/RigidBodyD"]
transform = Transform( -1.46629e-07, -0.3, 0, 0.9, -4.88762e-08, 0, 0, 0, 0.3, 0.8, 0, 0 )
shape = SubResource( 1 )
[node name="CollisionShape4" type="CollisionShape3D" parent="DynamicShapes/RigidBodyD"]
transform = Transform3D(-1.46629e-07, -0.3, 0, 0.9, -4.88762e-08, 0, 0, 0, 0.3, 0.8, 0, 0)
shape = SubResource( "1" )
[node name="RigidBodyO2" type="RigidBody" parent="DynamicShapes"]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 2.97932, 0, 0 )
[node name="RigidBodyO2" type="RigidDynamicBody3D" parent="DynamicShapes"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 2.97932, 0, 0)
[node name="CollisionShape1" type="CollisionShape" parent="DynamicShapes/RigidBodyO2"]
transform = Transform( -2.44381e-07, -0.3, 0, 1.5, -4.88762e-08, 0, 0, 0, 0.3, -0.8, 0, 0 )
shape = SubResource( 1 )
[node name="CollisionShape1" type="CollisionShape3D" parent="DynamicShapes/RigidBodyO2"]
transform = Transform3D(-2.44381e-07, -0.3, 0, 1.5, -4.88762e-08, 0, 0, 0, 0.3, -0.8, 0, 0)
shape = SubResource( "1" )
[node name="CollisionShape2" type="CollisionShape" parent="DynamicShapes/RigidBodyO2"]
transform = Transform( 0.5, 0, 4.26326e-15, 0, 0.3, 0, -7.10543e-15, 0, 0.3, 0, 1.2, 0 )
shape = SubResource( 1 )
[node name="CollisionShape2" type="CollisionShape3D" parent="DynamicShapes/RigidBodyO2"]
transform = Transform3D(0.5, 0, 4.26326e-15, 0, 0.3, 0, -7.10543e-15, 0, 0.3, 0, 1.2, 0)
shape = SubResource( "1" )
[node name="CollisionShape3" type="CollisionShape" parent="DynamicShapes/RigidBodyO2"]
transform = Transform( 0.5, 0, 4.26326e-15, 0, 0.3, 0, -7.10543e-15, 0, 0.3, 0, -1.2, 0 )
shape = SubResource( 1 )
[node name="CollisionShape3" type="CollisionShape3D" parent="DynamicShapes/RigidBodyO2"]
transform = Transform3D(0.5, 0, 4.26326e-15, 0, 0.3, 0, -7.10543e-15, 0, 0.3, 0, -1.2, 0)
shape = SubResource( "1" )
[node name="CollisionShape4" type="CollisionShape" parent="DynamicShapes/RigidBodyO2"]
transform = Transform( -2.44381e-07, -0.3, 0, 1.5, -4.88762e-08, 0, 0, 0, 0.3, 0.8, 0, 0 )
shape = SubResource( 1 )
[node name="CollisionShape4" type="CollisionShape3D" parent="DynamicShapes/RigidBodyO2"]
transform = Transform3D(-2.44381e-07, -0.3, 0, 1.5, -4.88762e-08, 0, 0, 0, 0.3, 0.8, 0, 0)
shape = SubResource( "1" )
[node name="RigidBodyT" type="RigidBody" parent="DynamicShapes"]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 5.46836, 0, 0 )
[node name="RigidBodyT" type="RigidDynamicBody3D" parent="DynamicShapes"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 5.46836, 0, 0)
[node name="CollisionShape1" type="CollisionShape" parent="DynamicShapes/RigidBodyT"]
transform = Transform( -1.95505e-07, -0.3, 0, 1.2, -4.88762e-08, 0, 0, 0, 0.3, 0, -0.3, 0 )
shape = SubResource( 1 )
[node name="CollisionShape1" type="CollisionShape3D" parent="DynamicShapes/RigidBodyT"]
transform = Transform3D(-1.95505e-07, -0.3, 0, 1.2, -4.88762e-08, 0, 0, 0, 0.3, 0, -0.3, 0)
shape = SubResource( "1" )
[node name="CollisionShape2" type="CollisionShape" parent="DynamicShapes/RigidBodyT"]
transform = Transform( 1, 0, 4.26326e-15, 0, 0.3, 0, -1.42109e-14, 0, 0.3, 0, 1.2, 0 )
shape = SubResource( 1 )
[node name="CollisionShape2" type="CollisionShape3D" parent="DynamicShapes/RigidBodyT"]
transform = Transform3D(1, 0, 4.26326e-15, 0, 0.3, 0, -1.42109e-14, 0, 0.3, 0, 1.2, 0)
shape = SubResource( "1" )
[node name="StaticBodyPins" type="StaticBody" parent="."]
[node name="StaticBodyPins" type="StaticBody3D" parent="."]
[node name="CollisionShape" type="CollisionShape" parent="StaticBodyPins"]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 9.13207, 0 )
shape = SubResource( 2 )
[node name="CollisionShape" type="CollisionShape3D" parent="StaticBodyPins"]
transform = Transform3D(1, 0, 0, 0, -4.37114e-08, -1, 0, 1, -4.37114e-08, 0, 9.13207, 0)
shape = SubResource( "2" )
[node name="CollisionShape2" type="CollisionShape" parent="StaticBodyPins"]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, -2.71742, 9.13207, 0 )
shape = SubResource( 2 )
[node name="CollisionShape2" type="CollisionShape3D" parent="StaticBodyPins"]
transform = Transform3D(1, 0, 0, 0, -4.37114e-08, -1, 0, 1, -4.37114e-08, -2.71742, 9.13207, 0)
shape = SubResource( "2" )
[node name="CollisionShape3" type="CollisionShape" parent="StaticBodyPins"]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, -5.64188, 9.13207, 0 )
shape = SubResource( 2 )
[node name="CollisionShape3" type="CollisionShape3D" parent="StaticBodyPins"]
transform = Transform3D(1, 0, 0, 0, -4.37114e-08, -1, 0, 1, -4.37114e-08, -5.64188, 9.13207, 0)
shape = SubResource( "2" )
[node name="CollisionShape4" type="CollisionShape" parent="StaticBodyPins"]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 2.87444, 9.13207, 0 )
shape = SubResource( 2 )
[node name="CollisionShape4" type="CollisionShape3D" parent="StaticBodyPins"]
transform = Transform3D(1, 0, 0, 0, -4.37114e-08, -1, 0, 1, -4.37114e-08, 2.87444, 9.13207, 0)
shape = SubResource( "2" )
[node name="CollisionShape5" type="CollisionShape" parent="StaticBodyPins"]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 4.81639, 9.13207, 0 )
shape = SubResource( 2 )
[node name="CollisionShape5" type="CollisionShape3D" parent="StaticBodyPins"]
transform = Transform3D(1, 0, 0, 0, -4.37114e-08, -1, 0, 1, -4.37114e-08, 4.81639, 9.13207, 0)
shape = SubResource( "2" )
[node name="StaticScene" parent="." instance=ExtResource( 1 )]
[node name="StaticScene" parent="." instance=ExtResource( "1" )]
[node name="Camera" type="Camera" parent="."]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 4.53602, 22.1236 )
script = ExtResource( 3 )
[node name="Camera3D" type="Camera3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 4.53602, 22.1236)
script = ExtResource( "3" )
[node name="OmniLight" type="OmniLight" parent="Camera"]
[node name="OmniLight" type="OmniLight3D" parent="Camera3D"]
omni_range = 50.0

View File

@@ -1,172 +1,172 @@
[gd_scene load_steps=10 format=2]
[gd_scene load_steps=10 format=3 uid="uid://d1j6kxs3plvry"]
[ext_resource path="res://test.gd" type="Script" id=1]
[ext_resource path="res://utils/control3d.gd" type="Script" id=2]
[ext_resource type="Script" path="res://test.gd" id="1"]
[ext_resource type="Script" path="res://utils/control3d.gd" id="2"]
[sub_resource type="PhysicsMaterial" id=1]
[sub_resource type="PhysicsMaterial" id="1"]
friction = 0.0
[sub_resource type="ConcavePolygonShape" id=2]
data = PoolVector3Array( -1, 0, 1, 1, 0, -1, 1, 0, 1, -1, 0, 1, -1, 0, -1, 1, 0, -1 )
[sub_resource type="ConcavePolygonShape3D" id="2"]
data = PackedVector3Array(-1, 0, 1, 1, 0, -1, 1, 0, 1, -1, 0, 1, -1, 0, -1, 1, 0, -1)
[sub_resource type="PhysicsMaterial" id=3]
[sub_resource type="PhysicsMaterial" id="3"]
friction = 0.0
[sub_resource type="BoxShape" id=4]
[sub_resource type="BoxShape3D" id="4"]
[sub_resource type="PhysicsMaterial" id=5]
[sub_resource type="PhysicsMaterial" id="5"]
friction = 0.5
[sub_resource type="PhysicsMaterial" id=6]
[sub_resource type="PhysicsMaterial" id="6"]
[sub_resource type="PhysicsMaterial" id=7]
[sub_resource type="PhysicsMaterial" id="7"]
[node name="Test" type="Spatial"]
script = ExtResource( 1 )
[node name="Test" type="Node3D"]
script = ExtResource( "1" )
[node name="StaticBodyFriction0" type="StaticBody" parent="."]
transform = Transform( 1, 0, 0, 0, 0.866025, -0.5, 0, 0.5, 0.866025, -6, 8.581, 0 )
physics_material_override = SubResource( 1 )
[node name="StaticBodyFriction0" type="StaticBody3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 0.866025, -0.5, 0, 0.5, 0.866025, -6, 8.581, 0)
physics_material_override = SubResource( "1" )
[node name="CollisionShape" type="CollisionShape" parent="StaticBodyFriction0"]
transform = Transform( 5, 0, 0, 0, 1, 0, 0, 0, 50, 0, 0, 0 )
shape = SubResource( 2 )
[node name="CollisionShape" type="CollisionShape3D" parent="StaticBodyFriction0"]
transform = Transform3D(5, 0, 0, 0, 1, 0, 0, 0, 50, 0, 0, 0)
shape = SubResource( "2" )
[node name="RigidBodies" type="Spatial" parent="StaticBodyFriction0"]
transform = Transform( 1, 0, 0, 0, 0.866026, 0.5, 0, -0.5, 0.866026, -3, -7.431, 4.291 )
[node name="RigidBodies" type="Node3D" parent="StaticBodyFriction0"]
transform = Transform3D(1, 0, 0, 0, 0.866026, 0.5, 0, -0.5, 0.866026, -3, -7.431, 4.291)
[node name="RigidBodyFriction0" type="RigidBody" parent="StaticBodyFriction0/RigidBodies"]
transform = Transform( 1, 0, 0, 0, 0.866025, -0.5, 0, 0.5, 0.866025, 0, 10, 0 )
physics_material_override = SubResource( 3 )
[node name="RigidBodyFriction0" type="RigidDynamicBody3D" parent="StaticBodyFriction0/RigidBodies"]
transform = Transform3D(1, 0, 0, 0, 0.866025, -0.5, 0, 0.5, 0.866025, 0, 10, 0)
physics_material_override = SubResource( "3" )
[node name="CollisionShape" type="CollisionShape" parent="StaticBodyFriction0/RigidBodies/RigidBodyFriction0"]
shape = SubResource( 4 )
[node name="CollisionShape" type="CollisionShape3D" parent="StaticBodyFriction0/RigidBodies/RigidBodyFriction0"]
shape = SubResource( "4" )
[node name="LabelFriction" type="Label" parent="StaticBodyFriction0/RigidBodies/RigidBodyFriction0"]
margin_right = 40.0
margin_bottom = 14.0
offset_right = 40.0
offset_bottom = 14.0
text = "0"
align = 1
script = ExtResource( 2 )
script = ExtResource( "2" )
__meta__ = {
"_edit_use_anchors_": false
}
world_offset = Vector3( 0, 1.5, 0 )
world_offset = Vector3(0, 1.5, 0)
[node name="RigidBodyFriction05" type="RigidBody" parent="StaticBodyFriction0/RigidBodies"]
transform = Transform( 1, 0, 0, 0, 0.866025, -0.5, 0, 0.5, 0.866025, 3, 10, 0 )
physics_material_override = SubResource( 5 )
[node name="RigidBodyFriction05" type="RigidDynamicBody3D" parent="StaticBodyFriction0/RigidBodies"]
transform = Transform3D(1, 0, 0, 0, 0.866025, -0.5, 0, 0.5, 0.866025, 3, 10, 0)
physics_material_override = SubResource( "5" )
[node name="CollisionShape" type="CollisionShape" parent="StaticBodyFriction0/RigidBodies/RigidBodyFriction05"]
shape = SubResource( 4 )
[node name="CollisionShape" type="CollisionShape3D" parent="StaticBodyFriction0/RigidBodies/RigidBodyFriction05"]
shape = SubResource( "4" )
[node name="LabelFriction" type="Label" parent="StaticBodyFriction0/RigidBodies/RigidBodyFriction05"]
margin_right = 40.0
margin_bottom = 14.0
offset_right = 40.0
offset_bottom = 14.0
text = "0.5"
align = 1
script = ExtResource( 2 )
script = ExtResource( "2" )
__meta__ = {
"_edit_use_anchors_": false
}
world_offset = Vector3( 0, 1.5, 0 )
world_offset = Vector3(0, 1.5, 0)
[node name="RigidBodyFriction1" type="RigidBody" parent="StaticBodyFriction0/RigidBodies"]
transform = Transform( 1, 0, 0, 0, 0.866025, -0.5, 0, 0.5, 0.866025, 6, 10, 0 )
physics_material_override = SubResource( 6 )
[node name="RigidBodyFriction1" type="RigidDynamicBody3D" parent="StaticBodyFriction0/RigidBodies"]
transform = Transform3D(1, 0, 0, 0, 0.866025, -0.5, 0, 0.5, 0.866025, 6, 10, 0)
physics_material_override = SubResource( "6" )
[node name="CollisionShape" type="CollisionShape" parent="StaticBodyFriction0/RigidBodies/RigidBodyFriction1"]
shape = SubResource( 4 )
[node name="CollisionShape" type="CollisionShape3D" parent="StaticBodyFriction0/RigidBodies/RigidBodyFriction1"]
shape = SubResource( "4" )
[node name="LabelFriction" type="Label" parent="StaticBodyFriction0/RigidBodies/RigidBodyFriction1"]
margin_right = 40.0
margin_bottom = 14.0
offset_right = 40.0
offset_bottom = 14.0
text = "1"
align = 1
script = ExtResource( 2 )
script = ExtResource( "2" )
__meta__ = {
"_edit_use_anchors_": false
}
world_offset = Vector3( 0, 1.5, 0 )
world_offset = Vector3(0, 1.5, 0)
[node name="StaticBodyFriction1" type="StaticBody" parent="."]
transform = Transform( 1, 0, 0, 0, 0.866025, -0.5, 0, 0.5, 0.866025, 6, 8.581, 0 )
physics_material_override = SubResource( 7 )
[node name="StaticBodyFriction1" type="StaticBody3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 0.866025, -0.5, 0, 0.5, 0.866025, 6, 8.581, 0)
physics_material_override = SubResource( "7" )
[node name="CollisionShape" type="CollisionShape" parent="StaticBodyFriction1"]
transform = Transform( 5, 0, 0, 0, 1, 0, 0, 0, 50, 0, 0, 0 )
shape = SubResource( 2 )
[node name="CollisionShape" type="CollisionShape3D" parent="StaticBodyFriction1"]
transform = Transform3D(5, 0, 0, 0, 1, 0, 0, 0, 50, 0, 0, 0)
shape = SubResource( "2" )
[node name="RigidBodies" type="Spatial" parent="StaticBodyFriction1"]
transform = Transform( 1, 0, 0, 0, 0.866026, 0.5, 0, -0.5, 0.866026, -3, -7.431, 4.291 )
[node name="RigidBodies" type="Node3D" parent="StaticBodyFriction1"]
transform = Transform3D(1, 0, 0, 0, 0.866026, 0.5, 0, -0.5, 0.866026, -3, -7.431, 4.291)
[node name="RigidBodyFriction0" type="RigidBody" parent="StaticBodyFriction1/RigidBodies"]
transform = Transform( 1, 0, 0, 0, 0.866025, -0.5, 0, 0.5, 0.866025, 0, 10, 0 )
physics_material_override = SubResource( 3 )
[node name="RigidBodyFriction0" type="RigidDynamicBody3D" parent="StaticBodyFriction1/RigidBodies"]
transform = Transform3D(1, 0, 0, 0, 0.866025, -0.5, 0, 0.5, 0.866025, 0, 10, 0)
physics_material_override = SubResource( "3" )
[node name="CollisionShape" type="CollisionShape" parent="StaticBodyFriction1/RigidBodies/RigidBodyFriction0"]
shape = SubResource( 4 )
[node name="CollisionShape" type="CollisionShape3D" parent="StaticBodyFriction1/RigidBodies/RigidBodyFriction0"]
shape = SubResource( "4" )
[node name="LabelFriction" type="Label" parent="StaticBodyFriction1/RigidBodies/RigidBodyFriction0"]
margin_right = 40.0
margin_bottom = 14.0
offset_right = 40.0
offset_bottom = 14.0
text = "0"
align = 1
script = ExtResource( 2 )
script = ExtResource( "2" )
__meta__ = {
"_edit_use_anchors_": false
}
world_offset = Vector3( 0, 1.5, 0 )
world_offset = Vector3(0, 1.5, 0)
[node name="RigidBodyFriction05" type="RigidBody" parent="StaticBodyFriction1/RigidBodies"]
transform = Transform( 1, 0, 0, 0, 0.866025, -0.5, 0, 0.5, 0.866025, 3, 10, 0 )
physics_material_override = SubResource( 5 )
[node name="RigidBodyFriction05" type="RigidDynamicBody3D" parent="StaticBodyFriction1/RigidBodies"]
transform = Transform3D(1, 0, 0, 0, 0.866025, -0.5, 0, 0.5, 0.866025, 3, 10, 0)
physics_material_override = SubResource( "5" )
[node name="CollisionShape" type="CollisionShape" parent="StaticBodyFriction1/RigidBodies/RigidBodyFriction05"]
shape = SubResource( 4 )
[node name="CollisionShape" type="CollisionShape3D" parent="StaticBodyFriction1/RigidBodies/RigidBodyFriction05"]
shape = SubResource( "4" )
[node name="LabelFriction" type="Label" parent="StaticBodyFriction1/RigidBodies/RigidBodyFriction05"]
margin_right = 40.0
margin_bottom = 14.0
offset_right = 40.0
offset_bottom = 14.0
text = "0.5"
align = 1
script = ExtResource( 2 )
script = ExtResource( "2" )
__meta__ = {
"_edit_use_anchors_": false
}
world_offset = Vector3( 0, 1.5, 0 )
world_offset = Vector3(0, 1.5, 0)
[node name="RigidBodyFriction1" type="RigidBody" parent="StaticBodyFriction1/RigidBodies"]
transform = Transform( 1, 0, 0, 0, 0.866025, -0.5, 0, 0.5, 0.866025, 6, 10, 0 )
physics_material_override = SubResource( 6 )
[node name="RigidBodyFriction1" type="RigidDynamicBody3D" parent="StaticBodyFriction1/RigidBodies"]
transform = Transform3D(1, 0, 0, 0, 0.866025, -0.5, 0, 0.5, 0.866025, 6, 10, 0)
physics_material_override = SubResource( "6" )
[node name="CollisionShape" type="CollisionShape" parent="StaticBodyFriction1/RigidBodies/RigidBodyFriction1"]
shape = SubResource( 4 )
[node name="CollisionShape" type="CollisionShape3D" parent="StaticBodyFriction1/RigidBodies/RigidBodyFriction1"]
shape = SubResource( "4" )
[node name="LabelFriction" type="Label" parent="StaticBodyFriction1/RigidBodies/RigidBodyFriction1"]
margin_right = 40.0
margin_bottom = 14.0
offset_right = 40.0
offset_bottom = 14.0
text = "1"
align = 1
script = ExtResource( 2 )
script = ExtResource( "2" )
__meta__ = {
"_edit_use_anchors_": false
}
world_offset = Vector3( 0, 1.5, 0 )
world_offset = Vector3(0, 1.5, 0)
[node name="Camera" type="Camera" parent="."]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 4.53602, 22.1236 )
[node name="Camera3D" type="Camera3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 4.53602, 22.1236)
[node name="OmniLight" type="OmniLight" parent="Camera"]
[node name="OmniLight" type="OmniLight3D" parent="Camera3D"]
omni_range = 50.0
[node name="LabelGround0" type="Label" parent="."]
anchor_left = 0.5
anchor_right = 0.5
margin_left = -164.0
margin_top = 80.0
margin_right = -28.0
margin_bottom = 94.0
offset_left = -164.0
offset_top = 80.0
offset_right = -28.0
offset_bottom = 94.0
text = "GROUND FRICTION 0"
__meta__ = {
"_edit_use_anchors_": false
@@ -175,10 +175,10 @@ __meta__ = {
[node name="LabelGround1" type="Label" parent="."]
anchor_left = 0.5
anchor_right = 0.5
margin_left = 31.0
margin_top = 80.0
margin_right = 167.0
margin_bottom = 94.0
offset_left = 31.0
offset_top = 80.0
offset_right = 167.0
offset_bottom = 94.0
text = "GROUND FRICTION 1"
__meta__ = {
"_edit_use_anchors_": false

View File

@@ -30,7 +30,7 @@ func _ready():
for joint_index in joints.get_child_count():
var joint_node = joints.get_child(joint_index)
joint_node.visible = false
var joint_name = joint_node.name
var joint_name = String(joint_node.name)
var joint_short = joint_name.substr(0, joint_name.length() - 5)
var option_name = OPTION_JOINT_TYPE % [joint_short, joint_index + 1]
options.add_menu_item(option_name)
@@ -42,8 +42,8 @@ func _ready():
options.add_menu_item(OPTION_TEST_CASE_DESTROY_BODY, true, false)
options.add_menu_item(OPTION_TEST_CASE_CHANGE_POSITIONS, true, false)
options.connect("option_selected", self, "_on_option_selected")
options.connect("option_changed", self, "_on_option_changed")
options.connect("option_selected", Callable(self, "_on_option_selected"))
options.connect("option_changed", Callable(self, "_on_option_changed"))
_selected_joint = _joint_types.values()[0]
_update_joint = true
@@ -52,14 +52,14 @@ func _ready():
func _process(_delta):
if _update_joint:
_update_joint = false
_create_joint()
$LabelJointType.text = "Joint Type: " + _selected_joint.name
await _create_joint()
$LabelJointType.text = "Joint Type: " + String(_selected_joint.name)
func _input(event):
var key_event = event as InputEventKey
if key_event and not key_event.pressed:
var joint_index = key_event.scancode - KEY_1
var joint_index = key_event.keycode - KEY_1
if joint_index >= 0 and joint_index < _joint_types.size():
_selected_joint = _joint_types.values()[joint_index]
_update_joint = true
@@ -102,7 +102,6 @@ func _create_joint():
last_child.queue_free()
var child_body = create_rigidbody_box(BOX_SIZE, true)
child_body.mode = RigidBody.MODE_RIGID
if _change_positions:
root.add_child(child_body)
child_body.transform.origin = Vector3(0.0, -1.5, 0.0)
@@ -114,11 +113,10 @@ func _create_joint():
if not _world_attachement:
parent_body = create_rigidbody_box(BOX_SIZE, true)
if _dynamic_attachement:
parent_body.mode = RigidBody.MODE_RIGID
parent_body.gravity_scale = 0.0
child_body.gravity_scale = 0.0
else:
parent_body.mode = RigidBody.MODE_STATIC
parent_body.freeze = true
if _change_positions:
root.add_child(parent_body)
parent_body.transform.origin = Vector3(0.0, 1.5, 0.0)
@@ -129,13 +127,13 @@ func _create_joint():
var joint = _selected_joint.duplicate()
joint.visible = true
joint.set_exclude_nodes_from_collision(not _bodies_collide)
if parent_body:
joint.set_node_a(parent_body.get_path())
joint.set_node_b(child_body.get_path())
root.add_child(joint)
if parent_body:
joint.set_node_a(joint.get_path_to(parent_body))
joint.set_node_b(joint.get_path_to(child_body))
if _destroy_body:
yield(start_timer(0.5), "timeout")
await start_timer(0.5).timeout
if is_timer_canceled():
return

View File

@@ -1,41 +1,41 @@
[gd_scene load_steps=4 format=2]
[gd_scene load_steps=4 format=3 uid="uid://ff88axeu4fvf"]
[ext_resource path="res://utils/camera_orbit.gd" type="Script" id=1]
[ext_resource path="res://tests/functional/test_joints.gd" type="Script" id=2]
[ext_resource path="res://tests/test_options.tscn" type="PackedScene" id=3]
[ext_resource type="Script" path="res://utils/camera_orbit.gd" id="1"]
[ext_resource type="Script" path="res://tests/functional/test_joints.gd" id="2"]
[ext_resource type="PackedScene" uid="uid://b1ihqm3x8jru" path="res://tests/test_options.tscn" id="3"]
[node name="Test" type="Spatial"]
script = ExtResource( 2 )
[node name="Test" type="Node3D"]
script = ExtResource( "2" )
[node name="LabelJointType" type="Label" parent="."]
margin_left = 14.0
margin_top = 78.0
margin_right = 171.0
margin_bottom = 92.0
offset_left = 14.0
offset_top = 78.0
offset_right = 171.0
offset_bottom = 92.0
text = "Joint Type: "
__meta__ = {
"_edit_use_anchors_": false
}
[node name="Options" parent="." instance=ExtResource( 3 )]
[node name="Options" parent="." instance=ExtResource( "3" )]
[node name="Joints" type="Spatial" parent="."]
[node name="Joints" type="Node3D" parent="."]
[node name="PinJoint" type="PinJoint" parent="Joints"]
[node name="PinJoint" type="PinJoint3D" parent="Joints"]
[node name="HingeJoint" type="HingeJoint" parent="Joints"]
[node name="HingeJoint" type="HingeJoint3D" parent="Joints"]
[node name="SliderJoint" type="SliderJoint" parent="Joints"]
[node name="SliderJoint" type="SliderJoint3D" parent="Joints"]
[node name="ConeTwistJoint" type="ConeTwistJoint" parent="Joints"]
[node name="ConeTwistJoint" type="ConeTwistJoint3D" parent="Joints"]
[node name="Generic6DOFJoint" type="Generic6DOFJoint" parent="Joints"]
[node name="Generic6DOFJoint" type="Generic6DOFJoint3D" parent="Joints"]
[node name="Objects" type="Spatial" parent="."]
[node name="Objects" type="Node3D" parent="."]
[node name="Camera" type="Camera" parent="."]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 6.19796 )
script = ExtResource( 1 )
[node name="Camera3D" type="Camera3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 6.19796)
script = ExtResource( "1" )
[node name="OmniLight" type="OmniLight" parent="Camera"]
[node name="OmniLight" type="OmniLight3D" parent="Camera3D"]
omni_range = 50.0

View File

@@ -3,9 +3,8 @@ extends Test
const OPTION_BODY_TYPE = "Body Type/%s (%d)"
const OPTION_GRAVITY = "Physics options/Gravity on floor (Kinematic only)"
const OPTION_SLOPE = "Physics options/Stop on slope (Kinematic only)"
const OPTION_SNAP = "Physics options/Use snap (Kinematic only)"
const OPTION_SLOPE = "Physics options/Stop on slope (Character only)"
const OPTION_SNAP = "Physics options/Use snap (Character only)"
const OPTION_FRICTION = "Physics options/Friction (Rigid only)"
const OPTION_ROUGH = "Physics options/Rough (Rigid only)"
const OPTION_PROCESS_PHYSICS = "Physics options/AnimationPlayer physics process mode"
@@ -15,9 +14,7 @@ const SHAPE_BOX = "Collision shapes/Box"
const SHAPE_CYLINDER = "Collision shapes/Cylinder"
const SHAPE_SPHERE = "Collision shapes/Sphere"
const SHAPE_CONVEX = "Collision shapes/Convex"
const SHAPE_RAY = "Collision shapes/Ray"
var _gravity = false
var _slope = false
var _snap = false
var _friction = false
@@ -28,8 +25,8 @@ var _body_scene = {}
var _key_list = []
var _current_body_index = 0
var _current_body_key = ""
var _current_body = null
var _body_type = ["KinematicBody", "RigidBody"]
var _current_body : PhysicsBody3D = null
var _body_type = ["CharacterBody3D", "RigidBody"]
var _shapes = {}
var _current_shape = ""
@@ -51,24 +48,21 @@ func _ready():
options.add_menu_item(SHAPE_CYLINDER)
options.add_menu_item(SHAPE_SPHERE)
options.add_menu_item(SHAPE_CONVEX)
options.add_menu_item(SHAPE_RAY)
options.add_menu_item(OPTION_GRAVITY, true, false)
options.add_menu_item(OPTION_SLOPE, true, false)
options.add_menu_item(OPTION_SNAP, true, false)
options.add_menu_item(OPTION_FRICTION, true, false)
options.add_menu_item(OPTION_ROUGH, true, false)
options.add_menu_item(OPTION_PROCESS_PHYSICS, true, false)
options.connect("option_selected", self, "_on_option_selected")
options.connect("option_changed", self, "_on_option_changed")
options.connect("option_selected", Callable(self, "_on_option_selected"))
options.connect("option_changed", Callable(self, "_on_option_changed"))
_shapes[SHAPE_CAPSULE] = "Capsule"
_shapes[SHAPE_BOX] = "Box"
_shapes[SHAPE_CYLINDER] = "Cylinder"
_shapes[SHAPE_SPHERE] = "Sphere"
_shapes[SHAPE_CONVEX] = "Convex"
_shapes[SHAPE_RAY] = "Ray"
_current_shape = _shapes[SHAPE_CAPSULE]
spawn_body_index(_current_body_index)
@@ -77,7 +71,7 @@ func _ready():
func _input(event):
var key_event = event as InputEventKey
if key_event and not key_event.pressed:
var _index = key_event.scancode - KEY_1
var _index = key_event.keycode - KEY_1
if _index >= 0 and _index < _key_list.size():
spawn_body_index(_index)
@@ -102,16 +96,10 @@ func _on_option_selected(option):
SHAPE_CONVEX:
_current_shape = _shapes[SHAPE_CONVEX]
spawn_body_index(_current_body_index)
SHAPE_RAY:
_current_shape = _shapes[SHAPE_RAY]
spawn_body_index(_current_body_index)
func _on_option_changed(option, checked):
match option:
OPTION_GRAVITY:
_gravity = checked
spawn_body_index(_current_body_index)
OPTION_SLOPE:
_slope = checked
spawn_body_index(_current_body_index)
@@ -135,7 +123,7 @@ func spawn_body_index(body_index):
_current_body_index = body_index
_current_body_key = _key_list[body_index]
var body_parent = $Bodies
var body = _body_scene[_key_list[body_index]].instance()
var body = _body_scene[_key_list[body_index]].instantiate()
_current_body = body
init_body()
body_parent.add_child(body)
@@ -148,7 +136,7 @@ func spawn_body_key(body_key):
_current_body_key = body_key
_current_body_index = _key_list.find(body_key)
var body_parent = $Bodies
var body = _body_scene[body_key].instance()
var body = _body_scene[body_key].instantiate()
_current_body = body
init_body()
body_parent.add_child(body)
@@ -156,21 +144,20 @@ func spawn_body_key(body_key):
func init_body():
if _current_body is KinematicBody:
_current_body._gravity_on_floor = _gravity
if _current_body is CharacterBody3D:
_current_body._stop_on_slopes = _slope
_current_body._use_snap = _snap
elif _current_body is RigidBody:
elif _current_body is RigidDynamicBody3D:
_current_body.physics_material_override.rough = _rough
_current_body.physics_material_override.friction = 1.0 if _friction else 0.0
for shape in _current_body.get_children():
if shape is CollisionShape:
if shape is CollisionShape3D:
if shape.name != _current_shape:
shape.queue_free()
func start_test():
var animation_player = $Platforms/KinematicPlatform/AnimationPlayer
var animation_player = $Platforms/MovingPlatform/AnimationPlayer
animation_player.stop()
if _animation_physics:
animation_player.playback_process_mode = AnimationPlayer.ANIMATION_PROCESS_PHYSICS

View File

@@ -1,154 +1,124 @@
[gd_scene load_steps=14 format=2]
[gd_scene load_steps=13 format=3 uid="uid://dgh5drb4q81kh"]
[ext_resource path="res://utils/camera_orbit.gd" type="Script" id=1]
[ext_resource path="res://tests/functional/test_moving_platform.gd" type="Script" id=2]
[ext_resource path="res://tests/test_options.tscn" type="PackedScene" id=3]
[ext_resource path="res://utils/kinematicbody_physics.gd" type="Script" id=4]
[ext_resource type="Script" path="res://utils/camera_orbit.gd" id="1"]
[ext_resource type="Script" path="res://tests/functional/test_moving_platform.gd" id="2"]
[ext_resource type="PackedScene" uid="uid://b1ihqm3x8jru" path="res://tests/test_options.tscn" id="3"]
[ext_resource type="Script" path="res://utils/characterbody_physics.gd" id="4"]
[sub_resource type="CapsuleShape" id=1]
[sub_resource type="CapsuleShape3D" id="1"]
radius = 0.3
[sub_resource type="BoxShape" id=2]
extents = Vector3( 0.3, 0.8, 0.3 )
[sub_resource type="BoxShape3D" id="2"]
size = Vector3(0.6, 1.6, 0.6)
[sub_resource type="CylinderShape" id=3]
[sub_resource type="CylinderShape3D" id="3"]
radius = 0.3
height = 1.60005
[sub_resource type="SphereShape" id=4]
[sub_resource type="SphereShape3D" id="4"]
radius = 0.79945
[sub_resource type="ConvexPolygonShape" id=5]
points = PoolVector3Array( -0.7, 0, -0.7, -0.3, 0, 0.8, 0.8, 0, -0.3, 0, -0.8, 0 )
[sub_resource type="ConvexPolygonShape3D" id="5"]
points = PackedVector3Array(-0.7, 0, -0.7, -0.3, 0, 0.8, 0.8, 0, -0.3, 0, -0.8, 0)
[sub_resource type="RayShape" id=6]
length = 0.8
[sub_resource type="PhysicsMaterial" id="7"]
[sub_resource type="PhysicsMaterial" id=7]
[sub_resource type="BoxShape3D" id="8"]
size = Vector3(4, 0.4, 2)
[sub_resource type="BoxShape" id=8]
extents = Vector3( 2, 0.2, 1 )
[sub_resource type="Animation" id=9]
[sub_resource type="Animation" id="9"]
length = 9.0
tracks/0/type = "bezier"
tracks/0/path = NodePath(".:translation:x")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/keys = {
"points": PoolRealArray( -7, -0.25, 0, 0.25, 0, -7, -0.25, 0, 0.25, 0, 6, -0.25, 0, 0.25, 0 ),
"times": PoolRealArray( 0, 3, 6.5 )
}
tracks/1/type = "bezier"
tracks/1/path = NodePath(".:translation:y")
tracks/1/interp = 1
tracks/1/loop_wrap = true
tracks/1/imported = false
tracks/1/enabled = true
tracks/1/keys = {
"points": PoolRealArray( -4.23538, -0.25, 0, 0.25, 0, -4.23538, -0.25, 0, 0.25, 0, 3, -0.25, 0, 0.25, 0, 3, -0.25, 0, 0.25, 0, -4.23538, -0.25, 0, 0.25, 0 ),
"times": PoolRealArray( 0, 0.5, 3, 6.5, 9 )
}
[node name="Test" type="Spatial"]
script = ExtResource( 2 )
[node name="Test" type="Node3D"]
script = ExtResource( "2" )
[node name="LabelBodyType" type="Label" parent="."]
margin_left = 14.0
margin_top = 78.0
margin_right = 171.0
margin_bottom = 92.0
offset_left = 14.0
offset_top = 78.0
offset_right = 171.0
offset_bottom = 92.0
text = "Body Type: "
__meta__ = {
"_edit_use_anchors_": false
}
[node name="Options" parent="." instance=ExtResource( 3 )]
margin_top = 120.0
margin_bottom = 140.0
[node name="Options" parent="." instance=ExtResource( "3" )]
offset_top = 153.0
offset_right = 134.0
offset_bottom = 182.0
[node name="Bodies" type="Spatial" parent="."]
[node name="Bodies" type="Node3D" parent="."]
[node name="KinematicBody" type="KinematicBody" parent="Bodies"]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, -7, -4.18538, 0 )
[node name="CharacterBody3D" type="CharacterBody3D" parent="Bodies"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -7, -4.18538, 0)
collision_layer = 2
script = ExtResource( 4 )
script = ExtResource( "4" )
_stop_on_slopes = true
_use_snap = true
[node name="Capsule" type="CollisionShape" parent="Bodies/KinematicBody"]
transform = Transform( 1, 0, 0, 0, -4.37114e-08, -1, 0, 1, -4.37114e-08, 0, 0.8, 0 )
shape = SubResource( 1 )
[node name="Capsule" type="CollisionShape3D" parent="Bodies/CharacterBody3D"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.8, 0)
shape = SubResource( "1" )
[node name="Box" type="CollisionShape" parent="Bodies/KinematicBody"]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.8, 0 )
shape = SubResource( 2 )
[node name="Box" type="CollisionShape3D" parent="Bodies/CharacterBody3D"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.8, 0)
shape = SubResource( "2" )
[node name="Cylinder" type="CollisionShape" parent="Bodies/KinematicBody"]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.8, 0 )
shape = SubResource( 3 )
[node name="Cylinder" type="CollisionShape3D" parent="Bodies/CharacterBody3D"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.8, 0)
shape = SubResource( "3" )
[node name="Sphere" type="CollisionShape" parent="Bodies/KinematicBody"]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.8, 0 )
shape = SubResource( 4 )
[node name="Sphere" type="CollisionShape3D" parent="Bodies/CharacterBody3D"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.8, 0)
shape = SubResource( "4" )
[node name="Convex" type="CollisionShape" parent="Bodies/KinematicBody"]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.8, 0 )
shape = SubResource( 5 )
[node name="Convex" type="CollisionShape3D" parent="Bodies/CharacterBody3D"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.8, 0)
shape = SubResource( "5" )
[node name="Ray" type="CollisionShape" parent="Bodies/KinematicBody"]
transform = Transform( 1, 0, 0, 0, 0, -1, 0, 1, 0, 0, 0.8, 0 )
shape = SubResource( 6 )
[node name="RigidBody" type="RigidBody" parent="Bodies"]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, -7, -4.18538, 0 )
[node name="RigidBody" type="RigidDynamicBody3D" parent="Bodies"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -7, -4.18538, 0)
collision_layer = 4
physics_material_override = SubResource( 7 )
axis_lock_angular_x = true
axis_lock_angular_y = true
axis_lock_angular_z = true
physics_material_override = SubResource( "7" )
[node name="Capsule" type="CollisionShape" parent="Bodies/RigidBody"]
transform = Transform( 1, 0, 0, 0, -4.37114e-08, -1, 0, 1, -4.37114e-08, 0, 0.8, 0 )
shape = SubResource( 1 )
[node name="Capsule" type="CollisionShape3D" parent="Bodies/RigidBody"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.8, 0)
shape = SubResource( "1" )
[node name="Box" type="CollisionShape" parent="Bodies/RigidBody"]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.8, 0 )
shape = SubResource( 2 )
[node name="Box" type="CollisionShape3D" parent="Bodies/RigidBody"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.8, 0)
shape = SubResource( "2" )
[node name="Cylinder" type="CollisionShape" parent="Bodies/RigidBody"]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.8, 0 )
shape = SubResource( 3 )
[node name="Cylinder" type="CollisionShape3D" parent="Bodies/RigidBody"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.8, 0)
shape = SubResource( "3" )
[node name="Sphere" type="CollisionShape" parent="Bodies/RigidBody"]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.8, 0 )
shape = SubResource( 4 )
[node name="Sphere" type="CollisionShape3D" parent="Bodies/RigidBody"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.8, 0)
shape = SubResource( "4" )
[node name="Convex" type="CollisionShape" parent="Bodies/RigidBody"]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.8, 0 )
shape = SubResource( 5 )
[node name="Convex" type="CollisionShape3D" parent="Bodies/RigidBody"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.8, 0)
shape = SubResource( "5" )
[node name="Ray" type="CollisionShape" parent="Bodies/RigidBody"]
transform = Transform( 1, 0, 0, 0, 0, -1, 0, 1, 0, 0, 0.8, 0 )
shape = SubResource( 6 )
[node name="Platforms" type="Node3D" parent="."]
[node name="Platforms" type="Spatial" parent="."]
[node name="MovingPlatform" type="AnimatableBody3D" parent="Platforms"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -7, -4.235, 0)
[node name="KinematicPlatform" type="KinematicBody" parent="Platforms"]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, -7, -4.25, 0 )
[node name="CollisionShape" type="CollisionShape3D" parent="Platforms/MovingPlatform"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -0.2, 0)
shape = SubResource( "8" )
[node name="CollisionShape" type="CollisionShape" parent="Platforms/KinematicPlatform"]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -0.2, 0 )
shape = SubResource( 8 )
[node name="AnimationPlayer" type="AnimationPlayer" parent="Platforms/MovingPlatform"]
anims/Move = SubResource( "9" )
[node name="AnimationPlayer" type="AnimationPlayer" parent="Platforms/KinematicPlatform"]
anims/Move = SubResource( 9 )
[node name="Camera3D" type="Camera3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 10)
script = ExtResource( "1" )
[node name="Camera" type="Camera" parent="."]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 10 )
script = ExtResource( 1 )
[node name="OmniLight" type="OmniLight" parent="Camera"]
[node name="OmniLight" type="OmniLight3D" parent="Camera3D"]
omni_range = 50.0

View File

@@ -1,11 +1,11 @@
extends Test
export(int, 1, 100) var height = 10
export(int, 1, 100) var width_max = 100
export(int, 1, 100) var depth_max = 1
export(Vector3) var box_size = Vector3(1.0, 1.0, 1.0)
export(Vector3) var box_spacing = Vector3(0.0, 0.0, 0.0)
@export_range(1, 100) var height = 10
@export_range(1, 100) var width_max = 100
@export_range(1, 100) var depth_max = 1
@export var box_size = Vector3(1.0, 1.0, 1.0)
@export var box_spacing = Vector3(0.0, 0.0, 0.0)
func _ready():
@@ -25,7 +25,7 @@ func _create_pyramid():
var num_boxes_width = min(num_boxes, width_max)
var num_boxes_depth = min(num_boxes, depth_max)
var row_node = Spatial.new()
var row_node = Node3D.new()
row_node.transform.origin = Vector3(0.0, pos_y, 0.0)
row_node.name = "Row%02d" % (level + 1)
root_node.add_child(row_node)

View File

@@ -1,16 +1,16 @@
[gd_scene load_steps=4 format=2]
[gd_scene load_steps=4 format=3 uid="uid://coci5d8ma8tpi"]
[ext_resource path="res://tests/functional/test_pyramid.gd" type="Script" id=1]
[ext_resource path="res://tests/static_scene_plane.tscn" type="PackedScene" id=2]
[ext_resource path="res://utils/camera_orbit.gd" type="Script" id=4]
[ext_resource type="Script" path="res://tests/functional/test_pyramid.gd" id="1"]
[ext_resource type="PackedScene" uid="uid://3gkujifjokqw" path="res://tests/static_scene_plane.tscn" id="2"]
[ext_resource type="Script" path="res://utils/camera_orbit.gd" id="4"]
[node name="Test" type="Spatial"]
script = ExtResource( 1 )
[node name="Test" type="Node3D"]
script = ExtResource( "1" )
[node name="Pyramid" type="Spatial" parent="."]
[node name="Pyramid" type="Node3D" parent="."]
[node name="StaticBodyPlane" parent="." instance=ExtResource( 2 )]
[node name="StaticBodyPlane" parent="." instance=ExtResource( "2" )]
[node name="Camera" type="Camera" parent="."]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 6.62348, 22.9474 )
script = ExtResource( 4 )
[node name="Camera3D" type="Camera3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 6.62348, 22.9474)
script = ExtResource( "4" )

View File

@@ -1,28 +1,40 @@
extends Test
const OPTION_TEST_CASE_HIT_FROM_INSIDE = "Test case/Hit from inside"
var _hit_from_inside = false
var _do_raycasts = false
onready var _raycast_visuals = ImmediateGeometry.new()
@onready var _raycast_visuals = ImmediateMesh.new()
@onready var _material = StandardMaterial3D.new()
func _ready():
var material = SpatialMaterial.new()
material.flags_unshaded = true
material.vertex_color_use_as_albedo = true
_raycast_visuals.material_override = material
var options = $Options
add_child(_raycast_visuals)
move_child(_raycast_visuals, get_child_count())
options.add_menu_item(OPTION_TEST_CASE_HIT_FROM_INSIDE, true, false)
yield(start_timer(0.5), "timeout")
options.connect("option_changed", Callable(self, "_on_option_changed"))
_material.flags_unshaded = true
_material.vertex_color_use_as_albedo = true
var raycast_mesh_instance = MeshInstance3D.new()
raycast_mesh_instance.mesh = _raycast_visuals
add_child(raycast_mesh_instance)
move_child(raycast_mesh_instance, get_child_count())
await start_timer(0.5).timeout
if is_timer_canceled():
return
_do_raycasts = true
func _physics_process(_delta):
func _physics_process(delta):
super._physics_process(delta)
if not _do_raycasts:
return
@@ -30,12 +42,12 @@ func _physics_process(_delta):
Log.print_log("* Start Raycasting...")
_raycast_visuals.clear()
_raycast_visuals.begin(Mesh.PRIMITIVE_LINES)
_raycast_visuals.clear_surfaces()
_raycast_visuals.surface_begin(Mesh.PRIMITIVE_LINES)
for shape in $Shapes.get_children():
var body = shape as PhysicsBody
var space_state = body.get_world().direct_space_state
var body = shape as PhysicsBody3D
var space_state = body.get_world_3d().direct_space_state
Log.print_log("* Testing: %s" % body.name)
@@ -55,24 +67,38 @@ func _physics_process(_delta):
res = _add_raycast(space_state, center, center - Vector3(0.0, 0.8, 0.0))
Log.print_log("Raycast inside: %s" % ("HIT" if res else "NO HIT"))
_raycast_visuals.end()
_raycast_visuals.surface_end()
_raycast_visuals.surface_set_material(0, _material)
func _on_option_changed(option, checked):
match option:
OPTION_TEST_CASE_HIT_FROM_INSIDE:
_hit_from_inside = checked
_do_raycasts = true
func _add_raycast(space_state, pos_start, pos_end):
var result = space_state.intersect_ray(pos_start, pos_end)
var params = PhysicsRayQueryParameters3D.new()
params.from = pos_start
params.to = pos_end
params.hit_from_inside = _hit_from_inside
var result = space_state.intersect_ray(params)
if result:
_raycast_visuals.set_color(Color.green)
_raycast_visuals.surface_set_color(Color.GREEN)
else:
_raycast_visuals.set_color(Color.red.darkened(0.5))
_raycast_visuals.surface_set_color(Color.RED.darkened(0.5))
# Draw raycast line.
_raycast_visuals.add_vertex(pos_start)
_raycast_visuals.add_vertex(pos_end)
_raycast_visuals.surface_add_vertex(pos_start)
_raycast_visuals.surface_add_vertex(pos_end)
# Draw raycast arrow.
_raycast_visuals.add_vertex(pos_end)
_raycast_visuals.add_vertex(pos_end + Vector3(-0.05, 0.1, 0.0))
_raycast_visuals.add_vertex(pos_end)
_raycast_visuals.add_vertex(pos_end + Vector3(0.05, 0.1, 0.0))
_raycast_visuals.surface_add_vertex(pos_end)
_raycast_visuals.surface_add_vertex(pos_end + Vector3(-0.05, 0.1, 0.0))
_raycast_visuals.surface_add_vertex(pos_end)
_raycast_visuals.surface_add_vertex(pos_end + Vector3(0.05, 0.1, 0.0))
return result

View File

@@ -1,72 +1,78 @@
[gd_scene load_steps=9 format=2]
[gd_scene load_steps=10 format=3 uid="uid://dnpps474nfbu4"]
[ext_resource path="res://assets/robot_head/godot3_robot_head_collision.tres" type="Shape" id=1]
[ext_resource path="res://tests/functional/test_raycasting.gd" type="Script" id=2]
[ext_resource path="res://utils/camera_orbit.gd" type="Script" id=4]
[ext_resource type="Shape3D" path="res://assets/robot_head/godot3_robot_head_collision.tres" id="1"]
[ext_resource type="Script" path="res://tests/functional/test_raycasting.gd" id="2"]
[ext_resource type="PackedScene" uid="uid://b1ihqm3x8jru" path="res://tests/test_options.tscn" id="2_qprqi"]
[ext_resource type="Script" path="res://utils/camera_orbit.gd" id="4"]
[sub_resource type="BoxShape" id=1]
[sub_resource type="BoxShape3D" id="1"]
[sub_resource type="SphereShape" id=2]
[sub_resource type="SphereShape3D" id="2"]
[sub_resource type="CapsuleShape" id=3]
[sub_resource type="CapsuleShape3D" id="3"]
[sub_resource type="CylinderShape" id=4]
[sub_resource type="CylinderShape3D" id="4"]
[sub_resource type="ConvexPolygonShape" id=5]
points = PoolVector3Array( -0.7, 0, -0.7, -0.3, 0, 0.8, 0.8, 0, -0.3, 0, -1, 0 )
[sub_resource type="ConvexPolygonShape3D" id="5"]
points = PackedVector3Array(-0.7, 0, -0.7, -0.3, 0, 0.8, 0.8, 0, -0.3, 0, -1, 0)
[node name="Test" type="Spatial"]
script = ExtResource( 2 )
[node name="Test" type="Node3D"]
script = ExtResource( "2" )
[node name="Shapes" type="Spatial" parent="."]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 9.35591, 0 )
[node name="Options" parent="." instance=ExtResource( "2_qprqi" )]
offset_right = 134.0
offset_bottom = 135.719
theme_override_font_sizes/font_size = 16
[node name="RigidBodyBox" type="RigidBody" parent="Shapes"]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, -6, 0, 0 )
mode = 3
[node name="Shapes" type="Node3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 9.35591, 0)
[node name="CollisionShape" type="CollisionShape" parent="Shapes/RigidBodyBox"]
transform = Transform( 0.579556, 0.0885213, 0.145926, 0, 0.939693, -0.205212, -0.155291, 0.330366, 0.544604, 0, 0, 0 )
shape = SubResource( 1 )
[node name="RigidBodyBox" type="RigidDynamicBody3D" parent="Shapes"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -6, 0, 0)
freeze = true
[node name="RigidBodySphere" type="RigidBody" parent="Shapes"]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, -3, 0, 0 )
mode = 3
[node name="CollisionShape" type="CollisionShape3D" parent="Shapes/RigidBodyBox"]
transform = Transform3D(0.579556, 0.0885213, 0.145926, 0, 0.939693, -0.205212, -0.155291, 0.330366, 0.544604, 0, 0, 0)
shape = SubResource( "1" )
[node name="CollisionShape" type="CollisionShape" parent="Shapes/RigidBodySphere"]
transform = Transform( 1.2, 0, 0, 0, 1.2, 0, 0, 0, 1.2, 0, 0, 0 )
shape = SubResource( 2 )
[node name="RigidBodySphere" type="RigidDynamicBody3D" parent="Shapes"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -3, 0, 0)
freeze = true
[node name="RigidBodyCapsule" type="RigidBody" parent="Shapes"]
mode = 3
[node name="CollisionShape" type="CollisionShape3D" parent="Shapes/RigidBodySphere"]
transform = Transform3D(1.2, 0, 0, 0, 1.2, 0, 0, 0, 1.2, 0, 0, 0)
shape = SubResource( "2" )
[node name="CollisionShape" type="CollisionShape" parent="Shapes/RigidBodyCapsule"]
transform = Transform( 0.8, 0, 0, 0, -1.30337e-07, -0.8, 0, 0.8, -1.30337e-07, 0, 0, 0 )
shape = SubResource( 3 )
[node name="RigidBodyCapsule" type="RigidDynamicBody3D" parent="Shapes"]
freeze = true
[node name="RigidBodyCylinder" type="RigidBody" parent="Shapes"]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 3, 0, 0 )
mode = 3
[node name="CollisionShape" type="CollisionShape3D" parent="Shapes/RigidBodyCapsule"]
transform = Transform3D(0.8, 0, 0, 0, 0.8, 0, 0, 0, 0.8, 0, 0, 0)
shape = SubResource( "3" )
[node name="CollisionShape" type="CollisionShape" parent="Shapes/RigidBodyCylinder"]
transform = Transform( 0.772741, -0.258819, 2.59821e-08, 0.2, 0.933013, -0.207055, 0.0535898, 0.25, 0.772741, 0, 0, 0 )
shape = SubResource( 4 )
[node name="RigidBodyCylinder" type="RigidDynamicBody3D" parent="Shapes"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 3, 0, 0)
freeze = true
[node name="RigidBodyConvexPolygon" type="RigidBody" parent="Shapes"]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 6, -0.211, 0 )
mode = 3
[node name="CollisionShape" type="CollisionShape3D" parent="Shapes/RigidBodyCylinder"]
transform = Transform3D(0.772741, -0.258819, 2.59821e-08, 0.2, 0.933013, -0.207055, 0.0535898, 0.25, 0.772741, 0, 0, 0)
shape = SubResource( "4" )
[node name="CollisionShape" type="CollisionShape" parent="Shapes/RigidBodyConvexPolygon"]
transform = Transform( 2, 0, 0, 0, 2.89766, -0.517939, 0, 0.776908, 1.93177, 0, 0.3533, 0 )
shape = SubResource( 5 )
[node name="RigidBodyConvexPolygon" type="RigidDynamicBody3D" parent="Shapes"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 6, -0.211, 0)
freeze = true
[node name="StaticBodyHead" type="StaticBody" parent="Shapes"]
transform = Transform( 2, 0, 0, 0, 2, 0, 0, 0, 2, 0, -6, 3.93357 )
[node name="CollisionShape" type="CollisionShape3D" parent="Shapes/RigidBodyConvexPolygon"]
transform = Transform3D(2, 0, 0, 0, 2.89766, -0.517939, 0, 0.776908, 1.93177, 0, 0.3533, 0)
shape = SubResource( "5" )
[node name="CollisionShape" type="CollisionShape" parent="Shapes/StaticBodyHead"]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -1, 0 )
shape = ExtResource( 1 )
[node name="StaticBodyHead" type="StaticBody3D" parent="Shapes"]
transform = Transform3D(2, 0, 0, 0, 2, 0, 0, 0, 2, 0, -6, 3.93357)
[node name="Camera" type="Camera" parent="."]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 5.8667, 11.8164 )
script = ExtResource( 4 )
[node name="CollisionShape" type="CollisionShape3D" parent="Shapes/StaticBodyHead"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -1, 0)
shape = ExtResource( "1" )
[node name="Camera3D" type="Camera3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 5.8667, 11.8164)
script = ExtResource( "4" )

View File

@@ -36,7 +36,7 @@ func _ready():
options.add_menu_item(SHAPE_CONVEX)
options.add_menu_item(SHAPE_BOX)
options.connect("option_selected", self, "_on_option_selected")
options.connect("option_selected", Callable(self, "_on_option_selected"))
restart_scene()
@@ -57,11 +57,11 @@ func restart_scene():
if _current_floor:
_current_floor.queue_free()
var dynamic_bodies = _dynamic_shapes_scene.instance()
var dynamic_bodies = _dynamic_shapes_scene.instantiate()
_current_bodies = dynamic_bodies
add_child(dynamic_bodies)
var floor_inst = _floor_shapes[_current_floor_name + _floor_size].instance()
var floor_inst = _floor_shapes[_current_floor_name + _floor_size].instantiate()
_current_floor = floor_inst
$Floors.add_child(floor_inst)

View File

@@ -1,354 +1,287 @@
[gd_scene load_steps=35 format=2]
[gd_scene load_steps=28 format=3 uid="uid://se7gyhmygqul"]
[ext_resource path="res://utils/rigidbody_ground_check.gd" type="Script" id=1]
[ext_resource path="res://tests/test_options.tscn" type="PackedScene" id=2]
[ext_resource path="res://tests/functional/test_rigidbody_ground_check.gd" type="Script" id=3]
[ext_resource path="res://utils/camera_orbit.gd" type="Script" id=4]
[ext_resource type="Script" path="res://utils/rigidbody_ground_check.gd" id="1"]
[ext_resource type="PackedScene" uid="uid://b1ihqm3x8jru" path="res://tests/test_options.tscn" id="2"]
[ext_resource type="Script" path="res://tests/functional/test_rigidbody_ground_check.gd" id="3"]
[ext_resource type="Script" path="res://utils/camera_orbit.gd" id="4"]
[sub_resource type="PhysicsMaterial" id=1]
[sub_resource type="PhysicsMaterial" id="1"]
friction = 0.0
[sub_resource type="BoxShape" id=2]
[sub_resource type="BoxShape3D" id="2"]
[sub_resource type="CubeMesh" id=3]
[sub_resource type="BoxMesh" id="3"]
[sub_resource type="SpatialMaterial" id=4]
[sub_resource type="PhysicsMaterial" id=5]
[sub_resource type="PhysicsMaterial" id="5"]
friction = 0.0
[sub_resource type="CapsuleShape" id=6]
[sub_resource type="CapsuleShape3D" id="6"]
[sub_resource type="CapsuleMesh" id=7]
[sub_resource type="CapsuleMesh" id="7"]
[sub_resource type="SpatialMaterial" id=8]
[sub_resource type="PhysicsMaterial" id=9]
[sub_resource type="PhysicsMaterial" id="9"]
friction = 0.0
[sub_resource type="CylinderShape" id=10]
[sub_resource type="CylinderShape3D" id="10"]
[sub_resource type="CylinderMesh" id=11]
[sub_resource type="CylinderMesh" id="11"]
[sub_resource type="SpatialMaterial" id=12]
[sub_resource type="PhysicsMaterial" id=13]
[sub_resource type="PhysicsMaterial" id="13"]
friction = 0.0
[sub_resource type="ConvexPolygonShape" id=14]
points = PoolVector3Array( -0.7, 0, -0.7, -0.3, 0, 0.8, 0.8, 0, -0.3, 0, -1, 0 )
[sub_resource type="ConvexPolygonShape3D" id="14"]
points = PackedVector3Array(-0.7, 0, -0.7, -0.3, 0, 0.8, 0.8, 0, -0.3, 0, -1, 0)
[sub_resource type="ArrayMesh" id=15]
surfaces/0 = {
"aabb": AABB( -0.7, -1, -0.7, 1.5, 1.00001, 1.5 ),
"array_data": PoolByteArray( 51, 51, 51, 191, 0, 0, 0, 0, 51, 51, 51, 191, 167, 0, 167, 0, 154, 153, 153, 190, 0, 0, 0, 0, 205, 204, 76, 63, 212, 0, 118, 0, 205, 204, 76, 63, 0, 0, 0, 0, 154, 153, 153, 190, 118, 0, 212, 0, 0, 0, 0, 0, 0, 0, 128, 191, 0, 0, 0, 0, 0, 129, 0, 0 ),
"array_index_data": PoolByteArray( 0, 0, 1, 0, 3, 0, 1, 0, 2, 0, 3, 0, 2, 0, 0, 0, 3, 0, 2, 0, 1, 0, 0, 0 ),
"blend_shape_data": [ ],
"format": 97539,
[sub_resource type="ArrayMesh" id="15"]
_surfaces = [{
"aabb": AABB(-0.7, -1, -0.7, 1.5, 1.00001, 1.5),
"format": 4099,
"index_count": 12,
"primitive": 4,
"skeleton_aabb": [ ],
"vertex_count": 4
}
"index_data": PackedByteArray(0, 0, 1, 0, 3, 0, 1, 0, 2, 0, 3, 0, 2, 0, 0, 0, 3, 0, 2, 0, 1, 0, 0, 0),
"primitive": 3,
"vertex_count": 4,
"vertex_data": PackedByteArray(51, 51, 51, 191, 0, 0, 0, 0, 51, 51, 51, 191, 0, 0, 0, 0, 154, 153, 153, 190, 0, 0, 0, 0, 205, 204, 76, 63, 0, 0, 96, 59, 205, 204, 76, 63, 0, 0, 0, 0, 154, 153, 153, 190, 182, 3, 0, 0, 0, 0, 0, 0, 0, 0, 128, 191, 0, 0, 0, 0, 0, 0, 0, 0)
}]
[sub_resource type="SpatialMaterial" id=16]
[sub_resource type="PhysicsMaterial" id=17]
[sub_resource type="PhysicsMaterial" id="17"]
friction = 0.0
[sub_resource type="SphereShape" id=18]
[sub_resource type="SphereShape3D" id="18"]
[sub_resource type="SphereMesh" id=19]
[sub_resource type="SphereMesh" id="19"]
[sub_resource type="SpatialMaterial" id=20]
[sub_resource type="PlaneMesh" id="23"]
size = Vector2(50, 20)
[sub_resource type="RayShape" id=21]
length = 1.5
[sub_resource type="ConvexPolygonShape3D" id="24"]
points = PackedVector3Array(25, 0, 10, -25, 0, 10, 25, 0, -10, -25, 0, -10)
[sub_resource type="SphereMesh" id=22]
radius = 0.5
height = 1.0
[sub_resource type="ConvexPolygonShape3D" id="25"]
points = PackedVector3Array(25, 0, 10, -25, 0, 10, 25, 0, -10, -25, 0, -10)
[sub_resource type="PlaneMesh" id=23]
size = Vector2( 50, 20 )
[sub_resource type="ConvexPolygonShape3D" id="26"]
points = PackedVector3Array(50, 0, 50, -50, 0, 50, 50, 0, -50, -50, 0, -50)
[sub_resource type="ConvexPolygonShape" id=24]
points = PoolVector3Array( 25, 0, 10, -25, 0, 10, 25, 0, -10, -25, 0, -10 )
[sub_resource type="ConcavePolygonShape3D" id="27"]
data = PackedVector3Array(-1, 0, 1, 1, 0, -1, 1, 0, 1, -1, 0, 1, -1, 0, -1, 1, 0, -1)
[sub_resource type="ConvexPolygonShape" id=25]
points = PoolVector3Array( 25, 0, 10, -25, 0, 10, 25, 0, -10, -25, 0, -10 )
[sub_resource type="ConcavePolygonShape3D" id="28"]
data = PackedVector3Array(50, 0, 50, -50, 0, 50, 50, 0, -50, -50, 0, 50, -50, 0, -50, 50, 0, -50)
[sub_resource type="ConvexPolygonShape" id=26]
points = PoolVector3Array( 50, 0, 50, -50, 0, 50, 50, 0, -50, -50, 0, -50 )
[sub_resource type="BoxShape3D" id="29"]
size = Vector3(100, 2, 40)
[sub_resource type="ConcavePolygonShape" id=27]
data = PoolVector3Array( -1, 0, 1, 1, 0, -1, 1, 0, 1, -1, 0, 1, -1, 0, -1, 1, 0, -1 )
[sub_resource type="BoxShape3D" id="30"]
size = Vector3(200, 2, 200)
[sub_resource type="ConcavePolygonShape" id=28]
data = PoolVector3Array( 50, 0, 50, -50, 0, 50, 50, 0, -50, -50, 0, 50, -50, 0, -50, 50, 0, -50 )
[sub_resource type="BoxShape" id=29]
extents = Vector3( 50, 1, 20 )
[sub_resource type="BoxShape" id=30]
extents = Vector3( 100, 1, 100 )
[node name="Test" type="Spatial"]
script = ExtResource( 3 )
[node name="Test" type="Node3D"]
script = ExtResource( "3" )
[node name="LabelBodyType" type="Label" parent="."]
margin_left = 14.0
margin_top = 78.0
margin_right = 171.0
margin_bottom = 92.0
offset_left = 14.0
offset_top = 78.0
offset_right = 171.0
offset_bottom = 92.0
text = "Floor Type: "
__meta__ = {
"_edit_use_anchors_": false
}
[node name="Options" parent="." instance=ExtResource( 2 )]
margin_top = 120.0
margin_bottom = 140.0
[node name="Options" parent="." instance=ExtResource( "2" )]
offset_top = 120.0
offset_bottom = 140.0
focus_mode = 2
[node name="DynamicShapes" type="Spatial" parent="."]
[node name="DynamicShapes" type="Node3D" parent="."]
[node name="Bodies" type="Spatial" parent="DynamicShapes"]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 5.2912, 0 )
[node name="Bodies" type="Node3D" parent="DynamicShapes"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 5.2912, 0)
[node name="RigidBodyBox" type="RigidBody" parent="DynamicShapes/Bodies"]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, -6, 0, 0 )
physics_material_override = SubResource( 1 )
[node name="RigidBodyBox" type="RigidDynamicBody3D" parent="DynamicShapes/Bodies"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -6, 0, 0)
axis_lock_angular_x = true
axis_lock_angular_y = true
axis_lock_angular_z = true
script = ExtResource( 1 )
physics_material_override = SubResource( "1" )
script = ExtResource( "1" )
[node name="CollisionShape" type="CollisionShape" parent="DynamicShapes/Bodies/RigidBodyBox"]
transform = Transform( 0.6, 0, 0, 0, 1, 0, 0, 0, 0.6, 0, 0, 0 )
shape = SubResource( 2 )
[node name="CollisionShape" type="CollisionShape3D" parent="DynamicShapes/Bodies/RigidBodyBox"]
transform = Transform3D(0.6, 0, 0, 0, 1, 0, 0, 0, 0.6, 0, 0, 0)
shape = SubResource( "2" )
[node name="MeshInstance" type="MeshInstance" parent="DynamicShapes/Bodies/RigidBodyBox/CollisionShape"]
mesh = SubResource( 3 )
material/0 = SubResource( 4 )
[node name="MeshInstance3D" type="MeshInstance3D" parent="DynamicShapes/Bodies/RigidBodyBox/CollisionShape"]
mesh = SubResource( "3" )
[node name="RigidBodyCapsule" type="RigidBody" parent="DynamicShapes/Bodies"]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, -3, 0, 0 )
physics_material_override = SubResource( 5 )
[node name="RigidBodyCapsule" type="RigidDynamicBody3D" parent="DynamicShapes/Bodies"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -3, 0, 0)
axis_lock_angular_x = true
axis_lock_angular_y = true
axis_lock_angular_z = true
script = ExtResource( 1 )
physics_material_override = SubResource( "5" )
script = ExtResource( "1" )
[node name="CollisionShape" type="CollisionShape" parent="DynamicShapes/Bodies/RigidBodyCapsule"]
transform = Transform( 0.8, 0, 0, 0, -3.49691e-08, -0.8, 0, 0.8, -3.49691e-08, 0, 0, 0 )
shape = SubResource( 6 )
[node name="CollisionShape" type="CollisionShape3D" parent="DynamicShapes/Bodies/RigidBodyCapsule"]
transform = Transform3D(0.8, 0, 0, 0, 0.8, 0, 0, 0, 0.8, 0, 0, 0)
shape = SubResource( "6" )
[node name="MeshInstance" type="MeshInstance" parent="DynamicShapes/Bodies/RigidBodyCapsule/CollisionShape"]
mesh = SubResource( 7 )
material/0 = SubResource( 8 )
[node name="MeshInstance3D" type="MeshInstance3D" parent="DynamicShapes/Bodies/RigidBodyCapsule/CollisionShape"]
mesh = SubResource( "7" )
[node name="RigidBodyCylinder" type="RigidBody" parent="DynamicShapes/Bodies"]
physics_material_override = SubResource( 9 )
[node name="RigidBodyCylinder" type="RigidDynamicBody3D" parent="DynamicShapes/Bodies"]
axis_lock_angular_x = true
axis_lock_angular_y = true
axis_lock_angular_z = true
script = ExtResource( 1 )
physics_material_override = SubResource( "9" )
script = ExtResource( "1" )
[node name="CollisionShape" type="CollisionShape" parent="DynamicShapes/Bodies/RigidBodyCylinder"]
transform = Transform( 0.8, 0, 0, 0, 1, 0, 0, 0, 0.8, 0, 0, 0 )
shape = SubResource( 10 )
[node name="CollisionShape" type="CollisionShape3D" parent="DynamicShapes/Bodies/RigidBodyCylinder"]
transform = Transform3D(0.8, 0, 0, 0, 1, 0, 0, 0, 0.8, 0, 0, 0)
shape = SubResource( "10" )
[node name="MeshInstance" type="MeshInstance" parent="DynamicShapes/Bodies/RigidBodyCylinder/CollisionShape"]
mesh = SubResource( 11 )
material/0 = SubResource( 12 )
[node name="MeshInstance3D" type="MeshInstance3D" parent="DynamicShapes/Bodies/RigidBodyCylinder/CollisionShape"]
mesh = SubResource( "11" )
[node name="RigidBodyConvex" type="RigidBody" parent="DynamicShapes/Bodies"]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 3, 0.974548, 0 )
physics_material_override = SubResource( 13 )
[node name="RigidBodyConvex" type="RigidDynamicBody3D" parent="DynamicShapes/Bodies"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 3, 0.974548, 0)
axis_lock_angular_x = true
axis_lock_angular_y = true
axis_lock_angular_z = true
script = ExtResource( 1 )
physics_material_override = SubResource( "13" )
script = ExtResource( "1" )
[node name="CollisionShape" type="CollisionShape" parent="DynamicShapes/Bodies/RigidBodyConvex"]
transform = Transform( 1.5, 0, 0, 0, 2, 0, 0, 0, 1.5, 0, 0, 0 )
shape = SubResource( 14 )
[node name="CollisionShape" type="CollisionShape3D" parent="DynamicShapes/Bodies/RigidBodyConvex"]
transform = Transform3D(1.5, 0, 0, 0, 2, 0, 0, 0, 1.5, 0, 0, 0)
shape = SubResource( "14" )
[node name="MeshInstance" type="MeshInstance" parent="DynamicShapes/Bodies/RigidBodyConvex/CollisionShape"]
mesh = SubResource( 15 )
material/0 = SubResource( 16 )
[node name="MeshInstance3D" type="MeshInstance3D" parent="DynamicShapes/Bodies/RigidBodyConvex/CollisionShape"]
mesh = SubResource( "15" )
[node name="RigidBodySphere" type="RigidBody" parent="DynamicShapes/Bodies"]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 6, 0, 0 )
physics_material_override = SubResource( 17 )
[node name="RigidBodySphere" type="RigidDynamicBody3D" parent="DynamicShapes/Bodies"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 6, 0, 0)
axis_lock_angular_x = true
axis_lock_angular_y = true
axis_lock_angular_z = true
script = ExtResource( 1 )
physics_material_override = SubResource( "17" )
script = ExtResource( "1" )
[node name="CollisionShape" type="CollisionShape" parent="DynamicShapes/Bodies/RigidBodySphere"]
transform = Transform( 0.8, 0, 0, 0, 0.8, 0, 0, 0, 0.8, 0, 0, 0 )
shape = SubResource( 18 )
[node name="CollisionShape" type="CollisionShape3D" parent="DynamicShapes/Bodies/RigidBodySphere"]
transform = Transform3D(0.8, 0, 0, 0, 0.8, 0, 0, 0, 0.8, 0, 0, 0)
shape = SubResource( "18" )
[node name="MeshInstance" type="MeshInstance" parent="DynamicShapes/Bodies/RigidBodySphere/CollisionShape"]
mesh = SubResource( 19 )
material/0 = SubResource( 20 )
[node name="MeshInstance3D" type="MeshInstance3D" parent="DynamicShapes/Bodies/RigidBodySphere/CollisionShape"]
mesh = SubResource( "19" )
[node name="RigidBodyRay" type="RigidBody" parent="DynamicShapes/Bodies"]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 8.42391, 0, 0 )
physics_material_override = SubResource( 17 )
axis_lock_angular_x = true
axis_lock_angular_y = true
axis_lock_angular_z = true
script = ExtResource( 1 )
[node name="Floors" type="Node3D" parent="."]
[node name="CollisionShape" type="CollisionShape" parent="DynamicShapes/Bodies/RigidBodyRay"]
transform = Transform( 0.8, 0, 0, 0, 0, -0.8, 0, 0.8, 0, 0, 0, 0 )
shape = SubResource( 21 )
[node name="ConvexSmall" type="Node3D" parent="Floors"]
[node name="MeshInstance" type="MeshInstance" parent="DynamicShapes/Bodies/RigidBodyRay/CollisionShape"]
mesh = SubResource( 22 )
material/0 = SubResource( 20 )
[node name="ConvexFloor" type="StaticBody3D" parent="Floors/ConvexSmall"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, -10)
[node name="Floors" type="Spatial" parent="."]
[node name="ConvexSmall" type="Spatial" parent="Floors"]
[node name="ConvexFloor" type="StaticBody" parent="Floors/ConvexSmall"]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, -10 )
collision_layer = 2
collision_mask = 3
[node name="MeshInstance" type="MeshInstance" parent="Floors/ConvexSmall/ConvexFloor"]
[node name="MeshInstance3D" type="MeshInstance3D" parent="Floors/ConvexSmall/ConvexFloor"]
visible = false
mesh = SubResource( 23 )
material/0 = null
mesh = SubResource( "23" )
[node name="CollisionShape" type="CollisionShape" parent="Floors/ConvexSmall/ConvexFloor"]
shape = SubResource( 24 )
[node name="CollisionShape" type="CollisionShape3D" parent="Floors/ConvexSmall/ConvexFloor"]
shape = SubResource( "24" )
[node name="ConvexFloor2" type="StaticBody" parent="Floors/ConvexSmall"]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 10 )
collision_layer = 2
collision_mask = 3
[node name="ConvexFloor2" type="StaticBody3D" parent="Floors/ConvexSmall"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 10)
[node name="MeshInstance" type="MeshInstance" parent="Floors/ConvexSmall/ConvexFloor2"]
[node name="MeshInstance3D" type="MeshInstance3D" parent="Floors/ConvexSmall/ConvexFloor2"]
visible = false
mesh = SubResource( 23 )
material/0 = null
mesh = SubResource( "23" )
[node name="CollisionShape" type="CollisionShape" parent="Floors/ConvexSmall/ConvexFloor2"]
shape = SubResource( 25 )
[node name="CollisionShape" type="CollisionShape3D" parent="Floors/ConvexSmall/ConvexFloor2"]
shape = SubResource( "25" )
[node name="ConvexBig" type="Spatial" parent="Floors"]
[node name="ConvexBig" type="Node3D" parent="Floors"]
[node name="ConvexFloor" type="StaticBody" parent="Floors/ConvexBig"]
collision_layer = 2
collision_mask = 3
[node name="ConvexFloor" type="StaticBody3D" parent="Floors/ConvexBig"]
[node name="MeshInstance" type="MeshInstance" parent="Floors/ConvexBig/ConvexFloor"]
[node name="MeshInstance3D" type="MeshInstance3D" parent="Floors/ConvexBig/ConvexFloor"]
visible = false
mesh = SubResource( 23 )
material/0 = null
mesh = SubResource( "23" )
[node name="CollisionShape" type="CollisionShape" parent="Floors/ConvexBig/ConvexFloor"]
shape = SubResource( 26 )
[node name="CollisionShape" type="CollisionShape3D" parent="Floors/ConvexBig/ConvexFloor"]
shape = SubResource( "26" )
[node name="ConcaveSmall" type="Spatial" parent="Floors"]
[node name="ConcaveSmall" type="Node3D" parent="Floors"]
[node name="ConcaveFloor" type="StaticBody" parent="Floors/ConcaveSmall"]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, -10 )
collision_layer = 2
collision_mask = 3
[node name="ConcaveFloor" type="StaticBody3D" parent="Floors/ConcaveSmall"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, -10)
[node name="MeshInstance" type="MeshInstance" parent="Floors/ConcaveSmall/ConcaveFloor"]
[node name="MeshInstance3D" type="MeshInstance3D" parent="Floors/ConcaveSmall/ConcaveFloor"]
visible = false
mesh = SubResource( 23 )
material/0 = null
mesh = SubResource( "23" )
[node name="CollisionShape" type="CollisionShape" parent="Floors/ConcaveSmall/ConcaveFloor"]
transform = Transform( 25, 0, 0, 0, 1, 0, 0, 0, 10, 0, 0, 0 )
shape = SubResource( 27 )
[node name="CollisionShape" type="CollisionShape3D" parent="Floors/ConcaveSmall/ConcaveFloor"]
transform = Transform3D(25, 0, 0, 0, 1, 0, 0, 0, 10, 0, 0, 0)
shape = SubResource( "27" )
[node name="ConcaveFloor2" type="StaticBody" parent="Floors/ConcaveSmall"]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 10 )
collision_layer = 2
collision_mask = 3
[node name="ConcaveFloor2" type="StaticBody3D" parent="Floors/ConcaveSmall"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 10)
[node name="MeshInstance" type="MeshInstance" parent="Floors/ConcaveSmall/ConcaveFloor2"]
[node name="MeshInstance3D" type="MeshInstance3D" parent="Floors/ConcaveSmall/ConcaveFloor2"]
visible = false
mesh = SubResource( 23 )
material/0 = null
mesh = SubResource( "23" )
[node name="CollisionShape" type="CollisionShape" parent="Floors/ConcaveSmall/ConcaveFloor2"]
transform = Transform( 25, 0, 0, 0, 1, 0, 0, 0, 10, 0, 0, 0 )
shape = SubResource( 27 )
[node name="CollisionShape" type="CollisionShape3D" parent="Floors/ConcaveSmall/ConcaveFloor2"]
transform = Transform3D(25, 0, 0, 0, 1, 0, 0, 0, 10, 0, 0, 0)
shape = SubResource( "27" )
[node name="ConcaveBig" type="Spatial" parent="Floors"]
[node name="ConcaveBig" type="Node3D" parent="Floors"]
[node name="ConcaveFloor" type="StaticBody" parent="Floors/ConcaveBig"]
collision_layer = 2
collision_mask = 3
[node name="ConcaveFloor" type="StaticBody3D" parent="Floors/ConcaveBig"]
[node name="MeshInstance" type="MeshInstance" parent="Floors/ConcaveBig/ConcaveFloor"]
[node name="MeshInstance3D" type="MeshInstance3D" parent="Floors/ConcaveBig/ConcaveFloor"]
visible = false
mesh = SubResource( 23 )
material/0 = null
mesh = SubResource( "23" )
[node name="CollisionShape" type="CollisionShape" parent="Floors/ConcaveBig/ConcaveFloor"]
shape = SubResource( 28 )
[node name="CollisionShape" type="CollisionShape3D" parent="Floors/ConcaveBig/ConcaveFloor"]
shape = SubResource( "28" )
[node name="BoxSmall" type="Spatial" parent="Floors"]
[node name="BoxSmall" type="Node3D" parent="Floors"]
[node name="BoxFloor" type="StaticBody" parent="Floors/BoxSmall"]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, -10 )
collision_layer = 2
collision_mask = 3
[node name="BoxFloor" type="StaticBody3D" parent="Floors/BoxSmall"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, -10)
[node name="MeshInstance" type="MeshInstance" parent="Floors/BoxSmall/BoxFloor"]
[node name="MeshInstance3D" type="MeshInstance3D" parent="Floors/BoxSmall/BoxFloor"]
visible = false
mesh = SubResource( 23 )
material/0 = null
mesh = SubResource( "23" )
[node name="CollisionShape" type="CollisionShape" parent="Floors/BoxSmall/BoxFloor"]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -1, 0 )
shape = SubResource( 29 )
[node name="CollisionShape" type="CollisionShape3D" parent="Floors/BoxSmall/BoxFloor"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -1, 0)
shape = SubResource( "29" )
[node name="BoxFloor2" type="StaticBody" parent="Floors/BoxSmall"]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 10 )
collision_layer = 2
collision_mask = 3
[node name="BoxFloor2" type="StaticBody3D" parent="Floors/BoxSmall"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 10)
[node name="MeshInstance" type="MeshInstance" parent="Floors/BoxSmall/BoxFloor2"]
[node name="MeshInstance3D" type="MeshInstance3D" parent="Floors/BoxSmall/BoxFloor2"]
visible = false
mesh = SubResource( 23 )
material/0 = null
mesh = SubResource( "23" )
[node name="CollisionShape" type="CollisionShape" parent="Floors/BoxSmall/BoxFloor2"]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -1, 0 )
shape = SubResource( 29 )
[node name="CollisionShape" type="CollisionShape3D" parent="Floors/BoxSmall/BoxFloor2"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -1, 0)
shape = SubResource( "29" )
[node name="BoxBig" type="Spatial" parent="Floors"]
[node name="BoxBig" type="Node3D" parent="Floors"]
[node name="BoxFloor" type="StaticBody" parent="Floors/BoxBig"]
collision_layer = 2
collision_mask = 3
[node name="BoxFloor" type="StaticBody3D" parent="Floors/BoxBig"]
[node name="MeshInstance" type="MeshInstance" parent="Floors/BoxBig/BoxFloor"]
[node name="MeshInstance3D" type="MeshInstance3D" parent="Floors/BoxBig/BoxFloor"]
visible = false
mesh = SubResource( 23 )
material/0 = null
mesh = SubResource( "23" )
[node name="CollisionShape" type="CollisionShape" parent="Floors/BoxBig/BoxFloor"]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -1, 0 )
shape = SubResource( 30 )
[node name="CollisionShape" type="CollisionShape3D" parent="Floors/BoxBig/BoxFloor"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -1, 0)
shape = SubResource( "30" )
[node name="Camera" type="Camera" parent="."]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 3.604, 22.124 )
[node name="Camera3D" type="Camera3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 3.604, 22.124)
far = 1000.0
script = ExtResource( 4 )
script = ExtResource( "4" )
[node name="OmniLight" type="OmniLight" parent="Camera"]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 14.6965, -5.95932 )
[node name="OmniLight" type="OmniLight3D" parent="Camera3D"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 14.6965, -5.95932)
omni_range = 50.0

View File

@@ -1,101 +1,88 @@
[gd_scene load_steps=11 format=2]
[gd_scene load_steps=10 format=3 uid="uid://cw38dssdgqkti"]
[ext_resource path="res://utils/rigidbody_pick.gd" type="Script" id=1]
[ext_resource path="res://test.gd" type="Script" id=2]
[ext_resource path="res://tests/static_scene_plane.tscn" type="PackedScene" id=3]
[ext_resource path="res://utils/camera_orbit.gd" type="Script" id=4]
[ext_resource type="Script" path="res://utils/rigidbody_pick.gd" id="1"]
[ext_resource type="Script" path="res://test.gd" id="2"]
[ext_resource type="PackedScene" uid="uid://3gkujifjokqw" path="res://tests/static_scene_plane.tscn" id="3"]
[ext_resource type="Script" path="res://utils/camera_orbit.gd" id="4"]
[sub_resource type="BoxShape" id=1]
[sub_resource type="BoxShape3D" id="1"]
[sub_resource type="CapsuleShape" id=2]
[sub_resource type="CapsuleShape3D" id="2"]
[sub_resource type="CylinderShape" id=3]
[sub_resource type="CylinderShape3D" id="3"]
[sub_resource type="ConvexPolygonShape" id=4]
points = PoolVector3Array( -0.7, 0, -0.7, -0.3, 0, 0.8, 0.8, 0, -0.3, 0, -1, 0 )
[sub_resource type="ConvexPolygonShape3D" id="4"]
points = PackedVector3Array(-0.7, 0, -0.7, -0.3, 0, 0.8, 0.8, 0, -0.3, 0, -1, 0)
[sub_resource type="SphereShape" id=5]
[sub_resource type="SphereShape3D" id="5"]
[sub_resource type="RayShape" id=6]
[node name="Test" type="Node3D"]
script = ExtResource( "2" )
[node name="Test" type="Spatial"]
script = ExtResource( 2 )
[node name="DynamicShapes" type="Node3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 9.35591, 0)
[node name="DynamicShapes" type="Spatial" parent="."]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 9.35591, 0 )
[node name="RigidBodyBox" type="RigidBody" parent="DynamicShapes"]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, -6, 1, 0 )
[node name="RigidBodyBox" type="RigidDynamicBody3D" parent="DynamicShapes"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -6, 1, 0)
axis_lock_angular_x = true
axis_lock_angular_y = true
axis_lock_angular_z = true
script = ExtResource( 1 )
script = ExtResource( "1" )
[node name="CollisionShape" type="CollisionShape" parent="DynamicShapes/RigidBodyBox"]
transform = Transform( 0.6, 0, 0, 0, 1, 0, 0, 0, 0.6, 0, 0, 0 )
shape = SubResource( 1 )
[node name="CollisionShape" type="CollisionShape3D" parent="DynamicShapes/RigidBodyBox"]
transform = Transform3D(0.6, 0, 0, 0, 1, 0, 0, 0, 0.6, 0, 0, 0)
shape = SubResource( "1" )
[node name="RigidBodyCapsule" type="RigidBody" parent="DynamicShapes"]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, -3, 1.0034, 0 )
[node name="RigidBodyCapsule" type="RigidDynamicBody3D" parent="DynamicShapes"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -3, 1.0034, 0)
axis_lock_angular_x = true
axis_lock_angular_y = true
axis_lock_angular_z = true
script = ExtResource( 1 )
script = ExtResource( "1" )
[node name="CollisionShape" type="CollisionShape" parent="DynamicShapes/RigidBodyCapsule"]
transform = Transform( 0.8, 0, 0, 0, -3.49691e-08, -0.8, 0, 0.8, -3.49691e-08, 0, 0, 0 )
shape = SubResource( 2 )
[node name="CollisionShape" type="CollisionShape3D" parent="DynamicShapes/RigidBodyCapsule"]
transform = Transform3D(0.8, 0, 0, 0, 0.8, 0, 0, 0, 0.8, 0, 0, 0)
shape = SubResource( "2" )
[node name="RigidBodyCylinder" type="RigidBody" parent="DynamicShapes"]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.0034, 0 )
[node name="RigidBodyCylinder" type="RigidDynamicBody3D" parent="DynamicShapes"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.0034, 0)
axis_lock_angular_x = true
axis_lock_angular_y = true
axis_lock_angular_z = true
script = ExtResource( 1 )
script = ExtResource( "1" )
[node name="CollisionShape" type="CollisionShape" parent="DynamicShapes/RigidBodyCylinder"]
transform = Transform( 0.8, 0, 0, 0, 1, 0, 0, 0, 0.8, 0, 0, 0 )
shape = SubResource( 3 )
[node name="CollisionShape" type="CollisionShape3D" parent="DynamicShapes/RigidBodyCylinder"]
transform = Transform3D(0.8, 0, 0, 0, 1, 0, 0, 0, 0.8, 0, 0, 0)
shape = SubResource( "3" )
[node name="RigidBodyConvex" type="RigidBody" parent="DynamicShapes"]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 3, 1.97795, 0 )
[node name="RigidBodyConvex" type="RigidDynamicBody3D" parent="DynamicShapes"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 3, 1.97795, 0)
axis_lock_angular_x = true
axis_lock_angular_y = true
axis_lock_angular_z = true
script = ExtResource( 1 )
script = ExtResource( "1" )
[node name="CollisionShape" type="CollisionShape" parent="DynamicShapes/RigidBodyConvex"]
transform = Transform( 1.5, 0, 0, 0, 2, 0, 0, 0, 1.5, 0, 0, 0 )
shape = SubResource( 4 )
[node name="CollisionShape" type="CollisionShape3D" parent="DynamicShapes/RigidBodyConvex"]
transform = Transform3D(1.5, 0, 0, 0, 2, 0, 0, 0, 1.5, 0, 0, 0)
shape = SubResource( "4" )
[node name="RigidBodySphere" type="RigidBody" parent="DynamicShapes"]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 6, 1, 0 )
[node name="RigidBodySphere" type="RigidDynamicBody3D" parent="DynamicShapes"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 6, 1, 0)
axis_lock_angular_x = true
axis_lock_angular_y = true
axis_lock_angular_z = true
script = ExtResource( 1 )
script = ExtResource( "1" )
[node name="CollisionShape" type="CollisionShape" parent="DynamicShapes/RigidBodySphere"]
transform = Transform( 0.8, 0, 0, 0, 0.8, 0, 0, 0, 0.8, 0, 0, 0 )
shape = SubResource( 5 )
[node name="CollisionShape" type="CollisionShape3D" parent="DynamicShapes/RigidBodySphere"]
transform = Transform3D(0.8, 0, 0, 0, 0.8, 0, 0, 0, 0.8, 0, 0, 0)
shape = SubResource( "5" )
[node name="RigidBodyRay" type="RigidBody" parent="DynamicShapes"]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 8, 1, 0 )
axis_lock_angular_x = true
axis_lock_angular_y = true
axis_lock_angular_z = true
script = ExtResource( 1 )
[node name="StaticBodyPlane" parent="." instance=ExtResource( "3" )]
[node name="CollisionShape" type="CollisionShape" parent="DynamicShapes/RigidBodyRay"]
transform = Transform( 0.8, 0, 0, 0, 0, -0.8, 0, 0.8, 0, 0, 0, 0 )
shape = SubResource( 6 )
[node name="StaticBodyPlane" parent="." instance=ExtResource( 3 )]
[node name="Camera" type="Camera" parent="."]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 3.604, 22.124 )
[node name="Camera3D" type="Camera3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 3.604, 22.124)
fov = 35.0
script = ExtResource( 4 )
script = ExtResource( "4" )
[node name="OmniLight" type="OmniLight" parent="Camera"]
[node name="OmniLight" type="OmniLight3D" parent="Camera3D"]
omni_range = 50.0

View File

@@ -1,71 +1,71 @@
[gd_scene load_steps=10 format=2]
[gd_scene load_steps=10 format=3 uid="uid://dmvgjuovguvg7"]
[ext_resource path="res://utils/rigidbody_pick.gd" type="Script" id=1]
[ext_resource path="res://test.gd" type="Script" id=2]
[ext_resource path="res://utils/camera_orbit.gd" type="Script" id=4]
[ext_resource path="res://tests/static_scene.tscn" type="PackedScene" id=6]
[ext_resource type="Script" path="res://utils/rigidbody_pick.gd" id="1"]
[ext_resource type="Script" path="res://test.gd" id="2"]
[ext_resource type="Script" path="res://utils/camera_orbit.gd" id="4"]
[ext_resource type="PackedScene" uid="uid://cl2vpuxqgnylc" path="res://tests/static_scene.tscn" id="6"]
[sub_resource type="BoxShape" id=1]
[sub_resource type="BoxShape3D" id="1"]
[sub_resource type="CapsuleShape" id=2]
[sub_resource type="CapsuleShape3D" id="2"]
[sub_resource type="CylinderShape" id=3]
[sub_resource type="CylinderShape3D" id="3"]
[sub_resource type="ConvexPolygonShape" id=4]
points = PoolVector3Array( -0.7, 0, -0.7, -0.3, 0, 0.8, 0.8, 0, -0.3, 0, -1, 0 )
[sub_resource type="ConvexPolygonShape3D" id="4"]
points = PackedVector3Array(-0.7, 0, -0.7, -0.3, 0, 0.8, 0.8, 0, -0.3, 0, -1, 0)
[sub_resource type="SphereShape" id=5]
[sub_resource type="SphereShape3D" id="5"]
[node name="Test" type="Spatial"]
script = ExtResource( 2 )
[node name="Test" type="Node3D"]
script = ExtResource( "2" )
[node name="DynamicShapes" type="Spatial" parent="."]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 9.35591, 0 )
[node name="DynamicShapes" type="Node3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 9.35591, 0)
[node name="RigidBodyBox" type="RigidBody" parent="DynamicShapes"]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, -6, 0, 0 )
script = ExtResource( 1 )
[node name="RigidBodyBox" type="RigidDynamicBody3D" parent="DynamicShapes"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -6, 0, 0)
script = ExtResource( "1" )
[node name="CollisionShape" type="CollisionShape" parent="DynamicShapes/RigidBodyBox"]
transform = Transform( 0.579556, 0.0885213, 0.145926, 0, 0.939693, -0.205212, -0.155291, 0.330366, 0.544604, 0, 0, 0 )
shape = SubResource( 1 )
[node name="CollisionShape" type="CollisionShape3D" parent="DynamicShapes/RigidBodyBox"]
transform = Transform3D(0.579556, 0.0885213, 0.145926, 0, 0.939693, -0.205212, -0.155291, 0.330366, 0.544604, 0, 0, 0)
shape = SubResource( "1" )
[node name="RigidBodyCapsule" type="RigidBody" parent="DynamicShapes"]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, -3, 0, 0 )
script = ExtResource( 1 )
[node name="RigidBodyCapsule" type="RigidDynamicBody3D" parent="DynamicShapes"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -3, 0, 0)
script = ExtResource( "1" )
[node name="CollisionShape" type="CollisionShape" parent="DynamicShapes/RigidBodyCapsule"]
transform = Transform( 0.8, 0, 0, 0, -1.30337e-07, -0.8, 0, 0.8, -1.30337e-07, 0, 0, 0 )
shape = SubResource( 2 )
[node name="CollisionShape" type="CollisionShape3D" parent="DynamicShapes/RigidBodyCapsule"]
transform = Transform3D(0.8, 0, 0, 0, 0.8, 0, 0, 0, 0.8, 0, 0, 0)
shape = SubResource( "2" )
[node name="RigidBodyCylinder" type="RigidBody" parent="DynamicShapes"]
script = ExtResource( 1 )
[node name="RigidBodyCylinder" type="RigidDynamicBody3D" parent="DynamicShapes"]
script = ExtResource( "1" )
[node name="CollisionShape" type="CollisionShape" parent="DynamicShapes/RigidBodyCylinder"]
transform = Transform( 0.772741, -0.258819, 2.59821e-08, 0.2, 0.933013, -0.207055, 0.0535898, 0.25, 0.772741, 0, 0, 0 )
shape = SubResource( 3 )
[node name="CollisionShape" type="CollisionShape3D" parent="DynamicShapes/RigidBodyCylinder"]
transform = Transform3D(0.772741, -0.258819, 2.59821e-08, 0.2, 0.933013, -0.207055, 0.0535898, 0.25, 0.772741, 0, 0, 0)
shape = SubResource( "3" )
[node name="RigidBodyConvex" type="RigidBody" parent="DynamicShapes"]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 3, 0, 0 )
script = ExtResource( 1 )
[node name="RigidBodyConvex" type="RigidDynamicBody3D" parent="DynamicShapes"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 3, 0, 0)
script = ExtResource( "1" )
[node name="CollisionShape" type="CollisionShape" parent="DynamicShapes/RigidBodyConvex"]
transform = Transform( 1.5, 0, 0, 0, 1.93185, -0.388229, 0, 0.517638, 1.44889, 0, 0, 0 )
shape = SubResource( 4 )
[node name="CollisionShape" type="CollisionShape3D" parent="DynamicShapes/RigidBodyConvex"]
transform = Transform3D(1.5, 0, 0, 0, 1.93185, -0.388229, 0, 0.517638, 1.44889, 0, 0, 0)
shape = SubResource( "4" )
[node name="RigidBodySphere" type="RigidBody" parent="DynamicShapes"]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 6, 0, 0 )
script = ExtResource( 1 )
[node name="RigidBodySphere" type="RigidDynamicBody3D" parent="DynamicShapes"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 6, 0, 0)
script = ExtResource( "1" )
[node name="CollisionShape" type="CollisionShape" parent="DynamicShapes/RigidBodySphere"]
transform = Transform( 0.8, 0, 0, 0, 0.8, 0, 0, 0, 0.8, 0, 0, 0 )
shape = SubResource( 5 )
[node name="CollisionShape" type="CollisionShape3D" parent="DynamicShapes/RigidBodySphere"]
transform = Transform3D(0.8, 0, 0, 0, 0.8, 0, 0, 0, 0.8, 0, 0, 0)
shape = SubResource( "5" )
[node name="StaticScene" parent="." instance=ExtResource( 6 )]
[node name="StaticScene" parent="." instance=ExtResource( "6" )]
[node name="Camera" type="Camera" parent="."]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 4.53602, 22.1236 )
script = ExtResource( 4 )
[node name="Camera3D" type="Camera3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 4.53602, 22.1236)
script = ExtResource( "4" )
[node name="OmniLight" type="OmniLight" parent="Camera"]
[node name="OmniLight" type="OmniLight3D" parent="Camera3D"]
omni_range = 50.0

View File

@@ -1,11 +1,11 @@
extends Test
export(int, 1, 100) var height = 10
export(int, 1, 100) var width = 1
export(int, 1, 100) var depth = 1
export(Vector3) var box_size = Vector3(1.0, 1.0, 1.0)
export(Vector3) var box_spacing = Vector3(0.0, 0.0, 0.0)
@export_range(1, 100) var height = 10
@export_range(1, 100) var width = 1
@export_range(1, 100) var depth = 1
@export var box_size = Vector3(1.0, 1.0, 1.0)
@export var box_spacing = Vector3(0.0, 0.0, 0.0)
func _ready():
@@ -20,7 +20,7 @@ func _create_stack():
var pos_y = 0.5 * box_size.y + box_spacing.y
for level in height:
var row_node = Spatial.new()
var row_node = Node3D.new()
row_node.transform.origin = Vector3(0.0, pos_y, 0.0)
row_node.name = "Row%02d" % (level + 1)
root_node.add_child(row_node)

View File

@@ -1,16 +1,16 @@
[gd_scene load_steps=4 format=2]
[gd_scene load_steps=4 format=3 uid="uid://dwn10myg4lqtw"]
[ext_resource path="res://tests/functional/test_stack.gd" type="Script" id=1]
[ext_resource path="res://tests/static_scene_plane.tscn" type="PackedScene" id=2]
[ext_resource path="res://utils/camera_orbit.gd" type="Script" id=4]
[ext_resource type="Script" path="res://tests/functional/test_stack.gd" id="1"]
[ext_resource type="PackedScene" uid="uid://3gkujifjokqw" path="res://tests/static_scene_plane.tscn" id="2"]
[ext_resource type="Script" path="res://utils/camera_orbit.gd" id="4"]
[node name="Test" type="Spatial"]
script = ExtResource( 1 )
[node name="Test" type="Node3D"]
script = ExtResource( "1" )
[node name="Stack" type="Spatial" parent="."]
[node name="Stack" type="Node3D" parent="."]
[node name="StaticBodyPlane" parent="." instance=ExtResource( 2 )]
[node name="StaticBodyPlane" parent="." instance=ExtResource( "2" )]
[node name="Camera" type="Camera" parent="."]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 4.53602, 12.2684 )
script = ExtResource( 4 )
[node name="Camera3D" type="Camera3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 4.53602, 12.2684)
script = ExtResource( "4" )

View File

@@ -4,9 +4,9 @@ extends Test
const BOX_SIZE = Vector3(0.8, 0.8, 0.8)
const BOX_SPACE = Vector3(1.0, 1.0, 1.0)
export(int, 1, 1000) var row_size = 20
export(int, 1, 1000) var column_size = 20
export(int, 1, 1000) var depth_size = 20
@export_range(1, 1000) var row_size = 20
@export_range(1, 1000) var column_size = 20
@export_range(1, 1000) var depth_size = 20
var _objects = []
@@ -16,7 +16,7 @@ var _log_physics_time_start = 0
func _ready():
yield(start_timer(1.0), "timeout")
await start_timer(1.0).timeout
if is_timer_canceled():
return
@@ -24,10 +24,10 @@ func _ready():
_create_objects()
yield(wait_for_physics_ticks(5), "wait_done")
await wait_for_physics_ticks(5).wait_done
_log_physics_stop()
yield(start_timer(1.0), "timeout")
await start_timer(1.0).timeout
if is_timer_canceled():
return
@@ -35,10 +35,10 @@ func _ready():
_add_objects()
yield(wait_for_physics_ticks(5), "wait_done")
await wait_for_physics_ticks(5).wait_done
_log_physics_stop()
yield(start_timer(1.0), "timeout")
await start_timer(1.0).timeout
if is_timer_canceled():
return
@@ -46,10 +46,10 @@ func _ready():
_move_objects()
yield(wait_for_physics_ticks(5), "wait_done")
await wait_for_physics_ticks(5).wait_done
_log_physics_stop()
yield(start_timer(1.0), "timeout")
await start_timer(1.0).timeout
if is_timer_canceled():
return
@@ -57,10 +57,10 @@ func _ready():
_remove_objects()
yield(wait_for_physics_ticks(5), "wait_done")
await wait_for_physics_ticks(5).wait_done
_log_physics_stop()
yield(start_timer(1.0), "timeout")
await start_timer(1.0).timeout
if is_timer_canceled():
return
@@ -72,9 +72,11 @@ func _exit_tree():
object.free()
func _physics_process(_delta):
func _physics_process(delta):
super._physics_process(delta)
if _log_physics:
var time = OS.get_ticks_usec()
var time = Time.get_ticks_usec()
var time_delta = time - _log_physics_time
var time_total = time - _log_physics_time_start
_log_physics_time = time
@@ -83,7 +85,7 @@ func _physics_process(_delta):
func _log_physics_start():
_log_physics = true
_log_physics_time_start = OS.get_ticks_usec()
_log_physics_time_start = Time.get_ticks_usec()
_log_physics_time = _log_physics_time_start
@@ -95,7 +97,7 @@ func _create_objects():
_objects.clear()
Log.print_log("* Creating objects...")
var timer = OS.get_ticks_usec()
var timer = Time.get_ticks_usec()
var pos_x = -0.5 * (row_size - 1) * BOX_SPACE.x
@@ -118,7 +120,7 @@ func _create_objects():
pos_x += BOX_SPACE.x
timer = OS.get_ticks_usec() - timer
timer = Time.get_ticks_usec() - timer
Log.print_log(" Create Time: %.3f ms" % (0.001 * timer))
@@ -126,23 +128,23 @@ func _add_objects():
var root_node = $Objects
Log.print_log("* Adding objects...")
var timer = OS.get_ticks_usec()
var timer = Time.get_ticks_usec()
for object in _objects:
root_node.add_child(object)
timer = OS.get_ticks_usec() - timer
timer = Time.get_ticks_usec() - timer
Log.print_log(" Add Time: %.3f ms" % (0.001 * timer))
func _move_objects():
Log.print_log("* Moving objects...")
var timer = OS.get_ticks_usec()
var timer = Time.get_ticks_usec()
for object in _objects:
object.transform.origin += BOX_SPACE
timer = OS.get_ticks_usec() - timer
timer = Time.get_ticks_usec() - timer
Log.print_log(" Move Time: %.3f ms" % (0.001 * timer))
@@ -150,12 +152,12 @@ func _remove_objects():
var root_node = $Objects
Log.print_log("* Removing objects...")
var timer = OS.get_ticks_usec()
var timer = Time.get_ticks_usec()
# Remove objects in reversed order to avoid the overhead of changing children index in parent.
var object_count = _objects.size()
for object_index in range(object_count):
root_node.remove_child(_objects[object_count - object_index - 1])
timer = OS.get_ticks_usec() - timer
timer = Time.get_ticks_usec() - timer
Log.print_log(" Remove Time: %.3f ms" % (0.001 * timer))

View File

@@ -1,12 +1,12 @@
[gd_scene load_steps=2 format=2]
[gd_scene load_steps=2 format=3 uid="uid://d3h64row8tfqc"]
[ext_resource path="res://tests/performance/test_perf_broadphase.gd" type="Script" id=1]
[ext_resource type="Script" path="res://tests/performance/test_perf_broadphase.gd" id="1"]
[node name="Test" type="Spatial"]
script = ExtResource( 1 )
[node name="Test" type="Node3D"]
script = ExtResource( "1" )
_enable_debug_collision = false
row_size = 50
column_size = 50
depth_size = 50
[node name="Objects" type="Spatial" parent="."]
[node name="Objects" type="Node3D" parent="."]

View File

@@ -1,142 +1,142 @@
[gd_scene load_steps=11 format=2]
[gd_scene load_steps=11 format=3 uid="uid://ctni5eafiy2bu"]
[ext_resource path="res://tests/performance/test_perf_contacts.gd" type="Script" id=1]
[ext_resource path="res://utils/camera_orbit.gd" type="Script" id=3]
[ext_resource path="res://tests/test_options.tscn" type="PackedScene" id=4]
[ext_resource path="res://tests/static_scene.tscn" type="PackedScene" id=5]
[ext_resource type="Script" path="res://tests/performance/test_perf_contacts.gd" id="1"]
[ext_resource type="Script" path="res://utils/camera_orbit.gd" id="3"]
[ext_resource type="PackedScene" uid="uid://b1ihqm3x8jru" path="res://tests/test_options.tscn" id="4"]
[ext_resource type="PackedScene" uid="uid://cl2vpuxqgnylc" path="res://tests/static_scene.tscn" id="5"]
[sub_resource type="BoxShape" id=1]
extents = Vector3( 0.5, 0.5, 0.5 )
[sub_resource type="BoxShape3D" id="1"]
size = Vector3(1, 1, 1)
[sub_resource type="CapsuleShape" id=2]
[sub_resource type="CapsuleShape3D" id="2"]
radius = 0.5
height = 0.5
height = 1.5
[sub_resource type="CylinderShape" id=3]
[sub_resource type="CylinderShape3D" id="3"]
radius = 0.5
height = 1.0
[sub_resource type="ConvexPolygonShape" id=4]
points = PoolVector3Array( -0.7, 0, -0.7, -0.3, 0, 0.8, 0.8, 0, -0.3, 0, -1, 0 )
[sub_resource type="ConvexPolygonShape3D" id="4"]
points = PackedVector3Array(-0.7, 0, -0.7, -0.3, 0, 0.8, 0.8, 0, -0.3, 0, -1, 0)
[sub_resource type="SphereShape" id=5]
[sub_resource type="SphereShape3D" id="5"]
radius = 0.5
[sub_resource type="PlaneShape" id=6]
[sub_resource type="WorldBoundaryShape3D" id="6"]
[node name="Test" type="Spatial"]
script = ExtResource( 1 )
[node name="Test" type="Node3D"]
script = ExtResource( "1" )
_enable_debug_collision = false
spawns = [ "SpawnTarget1", "SpawnTarget2", "SpawnTarget3", "SpawnTarget4", "SpawnTarget5", "SpawnTarget6", "SpawnTarget7", "SpawnTarget8", "SpawnTarget9", "SpawnTarget10", "SpawnTarget11", "SpawnTarget12", "SpawnTarget13", "SpawnTarget14", "SpawnTarget15", "SpawnTarget16" ]
spawns = ["SpawnTarget1", "SpawnTarget2", "SpawnTarget3", "SpawnTarget4", "SpawnTarget5", "SpawnTarget6", "SpawnTarget7", "SpawnTarget8", "SpawnTarget9", "SpawnTarget10", "SpawnTarget11", "SpawnTarget12", "SpawnTarget13", "SpawnTarget14", "SpawnTarget15", "SpawnTarget16"]
spawn_count = 200
spawn_randomize = Vector3( 0.2, 0.2, 0.2 )
spawn_randomize = Vector3(0.2, 0.2, 0.2)
[node name="Options" parent="." instance=ExtResource( 4 )]
[node name="Options" parent="." instance=ExtResource( "4" )]
[node name="SpawnTarget1" type="Spatial" parent="."]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 40, 7, -37.715 )
[node name="SpawnTarget1" type="Node3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 40, 7, -37.715)
[node name="SpawnTarget2" type="Spatial" parent="."]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 40, 7, -19.7248 )
[node name="SpawnTarget2" type="Node3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 40, 7, -19.7248)
[node name="SpawnTarget3" type="Spatial" parent="."]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 21.4903, 7, -37.715 )
[node name="SpawnTarget3" type="Node3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 21.4903, 7, -37.715)
[node name="SpawnTarget4" type="Spatial" parent="."]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 21.4903, 7, -19.7248 )
[node name="SpawnTarget4" type="Node3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 21.4903, 7, -19.7248)
[node name="SpawnTarget5" type="Spatial" parent="."]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 40, 7, 10.7172 )
[node name="SpawnTarget5" type="Node3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 40, 7, 10.7172)
[node name="SpawnTarget6" type="Spatial" parent="."]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 40, 7, 28.7073 )
[node name="SpawnTarget6" type="Node3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 40, 7, 28.7073)
[node name="SpawnTarget7" type="Spatial" parent="."]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 21.4903, 7, 10.7172 )
[node name="SpawnTarget7" type="Node3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 21.4903, 7, 10.7172)
[node name="SpawnTarget8" type="Spatial" parent="."]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 21.4903, 7, 28.7073 )
[node name="SpawnTarget8" type="Node3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 21.4903, 7, 28.7073)
[node name="SpawnTarget9" type="Spatial" parent="."]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, -19.8583, 7, 10.7172 )
[node name="SpawnTarget9" type="Node3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -19.8583, 7, 10.7172)
[node name="SpawnTarget10" type="Spatial" parent="."]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, -19.8583, 7, 28.7073 )
[node name="SpawnTarget10" type="Node3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -19.8583, 7, 28.7073)
[node name="SpawnTarget11" type="Spatial" parent="."]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, -38.368, 7, 10.7172 )
[node name="SpawnTarget11" type="Node3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -38.368, 7, 10.7172)
[node name="SpawnTarget12" type="Spatial" parent="."]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, -38.368, 7, 28.7073 )
[node name="SpawnTarget12" type="Node3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -38.368, 7, 28.7073)
[node name="SpawnTarget13" type="Spatial" parent="."]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, -19.8583, 7, -38.798 )
[node name="SpawnTarget13" type="Node3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -19.8583, 7, -38.798)
[node name="SpawnTarget14" type="Spatial" parent="."]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, -19.8583, 7, -20.8078 )
[node name="SpawnTarget14" type="Node3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -19.8583, 7, -20.8078)
[node name="SpawnTarget15" type="Spatial" parent="."]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, -38.368, 7, -38.798 )
[node name="SpawnTarget15" type="Node3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -38.368, 7, -38.798)
[node name="SpawnTarget16" type="Spatial" parent="."]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, -38.368, 7, -20.8078 )
[node name="SpawnTarget16" type="Node3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -38.368, 7, -20.8078)
[node name="DynamicShapes" type="Spatial" parent="."]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, -26.3192, 1.2359, 38.0117 )
[node name="DynamicShapes" type="Node3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -26.3192, 1.2359, 38.0117)
[node name="RigidBodyBox" type="RigidBody" parent="DynamicShapes"]
[node name="RigidBodyBox" type="RigidDynamicBody3D" parent="DynamicShapes"]
[node name="CollisionShape" type="CollisionShape" parent="DynamicShapes/RigidBodyBox"]
shape = SubResource( 1 )
[node name="CollisionShape" type="CollisionShape3D" parent="DynamicShapes/RigidBodyBox"]
shape = SubResource( "1" )
[node name="RigidBodyCapsule" type="RigidBody" parent="DynamicShapes"]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 2, 0, 0 )
[node name="RigidBodyCapsule" type="RigidDynamicBody3D" parent="DynamicShapes"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 2, 0, 0)
[node name="CollisionShape" type="CollisionShape" parent="DynamicShapes/RigidBodyCapsule"]
shape = SubResource( 2 )
[node name="CollisionShape" type="CollisionShape3D" parent="DynamicShapes/RigidBodyCapsule"]
shape = SubResource( "2" )
[node name="RigidBodyCylinder" type="RigidBody" parent="DynamicShapes"]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 4, 0, 0 )
[node name="RigidBodyCylinder" type="RigidDynamicBody3D" parent="DynamicShapes"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 4, 0, 0)
[node name="CollisionShape" type="CollisionShape" parent="DynamicShapes/RigidBodyCylinder"]
shape = SubResource( 3 )
[node name="CollisionShape" type="CollisionShape3D" parent="DynamicShapes/RigidBodyCylinder"]
shape = SubResource( "3" )
[node name="RigidBodyConvex" type="RigidBody" parent="DynamicShapes"]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 6, 0, 0 )
[node name="RigidBodyConvex" type="RigidDynamicBody3D" parent="DynamicShapes"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 6, 0, 0)
[node name="CollisionShape" type="CollisionShape" parent="DynamicShapes/RigidBodyConvex"]
transform = Transform( 0.5, 0, 0, 0, 0.5, 0, 0, 0, 0.5, 0, 0, 0 )
shape = SubResource( 4 )
[node name="CollisionShape" type="CollisionShape3D" parent="DynamicShapes/RigidBodyConvex"]
transform = Transform3D(0.5, 0, 0, 0, 0.5, 0, 0, 0, 0.5, 0, 0, 0)
shape = SubResource( "4" )
[node name="RigidBodySphere" type="RigidBody" parent="DynamicShapes"]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 8, 0, 0 )
[node name="RigidBodySphere" type="RigidDynamicBody3D" parent="DynamicShapes"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 8, 0, 0)
[node name="CollisionShape" type="CollisionShape" parent="DynamicShapes/RigidBodySphere"]
shape = SubResource( 5 )
[node name="CollisionShape" type="CollisionShape3D" parent="DynamicShapes/RigidBodySphere"]
shape = SubResource( "5" )
[node name="StaticScene" parent="." instance=ExtResource( 5 )]
[node name="StaticScene" parent="." instance=ExtResource( "5" )]
[node name="StaticBodyWalls" type="StaticBody" parent="."]
[node name="StaticBodyWalls" type="StaticBody3D" parent="."]
[node name="CollisionShape1" type="CollisionShape" parent="StaticBodyWalls"]
transform = Transform( -1.62921e-07, 1, 0, -1, -1.62921e-07, 0, 0, 0, 1, -50, 0, 0 )
shape = SubResource( 6 )
[node name="CollisionShape1" type="CollisionShape3D" parent="StaticBodyWalls"]
transform = Transform3D(-1.62921e-07, 1, 0, -1, -1.62921e-07, 0, 0, 0, 1, -50, 0, 0)
shape = SubResource( "6" )
[node name="CollisionShape2" type="CollisionShape" parent="StaticBodyWalls"]
transform = Transform( -1.62921e-07, -1, 0, 1, -1.62921e-07, 0, 0, 0, 1, 50, 0, 0 )
shape = SubResource( 6 )
[node name="CollisionShape2" type="CollisionShape3D" parent="StaticBodyWalls"]
transform = Transform3D(-1.62921e-07, -1, 0, 1, -1.62921e-07, 0, 0, 0, 1, 50, 0, 0)
shape = SubResource( "6" )
[node name="CollisionShape3" type="CollisionShape" parent="StaticBodyWalls"]
transform = Transform( 2.6543e-14, 1.62921e-07, 1, 1, -1.62921e-07, 1.56125e-19, 1.62921e-07, 1, -1.62921e-07, 0, 0, -50 )
shape = SubResource( 6 )
[node name="CollisionShape3" type="CollisionShape3D" parent="StaticBodyWalls"]
transform = Transform3D(2.6543e-14, 1.62921e-07, 1, 1, -1.62921e-07, 1.56125e-19, 1.62921e-07, 1, -1.62921e-07, 0, 0, -50)
shape = SubResource( "6" )
[node name="CollisionShape4" type="CollisionShape" parent="StaticBodyWalls"]
transform = Transform( 2.6543e-14, 1.62921e-07, -1, 1, -1.62921e-07, -1.56125e-19, -1.62921e-07, -1, -1.62921e-07, 0, 0, 50 )
shape = SubResource( 6 )
[node name="CollisionShape4" type="CollisionShape3D" parent="StaticBodyWalls"]
transform = Transform3D(2.6543e-14, 1.62921e-07, -1, 1, -1.62921e-07, -1.56125e-19, -1.62921e-07, -1, -1.62921e-07, 0, 0, 50)
shape = SubResource( "6" )
[node name="Camera" type="Camera" parent="."]
transform = Transform( 1, 0, 0, 0, 0.881757, 0.471705, 0, -0.471705, 0.881757, 0, 20.4125, 41.0426 )
script = ExtResource( 3 )
[node name="Camera3D" type="Camera3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 0.881757, 0.471705, 0, -0.471705, 0.881757, 0, 20.4125, 41.0426)
script = ExtResource( "3" )
[node name="OmniLight" type="OmniLight" parent="Camera"]
[node name="OmniLight" type="OmniLight3D" parent="Camera3D"]
omni_range = 80.0

View File

@@ -8,9 +8,9 @@ const OPTION_TYPE_CAPSULE = "Shape type/Capsule"
const OPTION_TYPE_CYLINDER = "Shape type/Cylinder"
const OPTION_TYPE_CONVEX = "Shape type/Convex"
export(Array, NodePath) var spawns = Array()
export(int) var spawn_count = 100
export(Vector3) var spawn_randomize
@export var spawns = []
@export var spawn_count = 100
@export var spawn_randomize = Vector3.ZERO
var _object_templates = []
@@ -20,7 +20,7 @@ var _log_physics_time_start = 0
func _ready():
yield(start_timer(0.5), "timeout")
await start_timer(0.5).timeout
if is_timer_canceled():
return
@@ -35,9 +35,9 @@ func _ready():
$Options.add_menu_item(OPTION_TYPE_CAPSULE)
$Options.add_menu_item(OPTION_TYPE_CYLINDER)
$Options.add_menu_item(OPTION_TYPE_CONVEX)
$Options.connect("option_selected", self, "_on_option_selected")
$Options.connect("option_selected", Callable(self, "_on_option_selected"))
_start_all_types()
await _start_all_types()
func _exit_tree():
@@ -45,9 +45,11 @@ func _exit_tree():
object_template.free()
func _physics_process(_delta):
func _physics_process(delta):
super._physics_process(delta)
if _log_physics:
var time = OS.get_ticks_usec()
var time = Time.get_ticks_usec()
var time_delta = time - _log_physics_time
var time_total = time - _log_physics_time_start
_log_physics_time = time
@@ -56,7 +58,7 @@ func _physics_process(_delta):
func _log_physics_start():
_log_physics = true
_log_physics_time_start = OS.get_ticks_usec()
_log_physics_time_start = Time.get_ticks_usec()
_log_physics_time = _log_physics_time_start
@@ -71,17 +73,17 @@ func _on_option_selected(option):
match option:
OPTION_TYPE_ALL:
_start_all_types()
await _start_all_types()
OPTION_TYPE_BOX:
_start_type(_find_type_index("Box"))
await _start_type(_find_type_index("Box"))
OPTION_TYPE_SPHERE:
_start_type(_find_type_index("Sphere"))
await _start_type(_find_type_index("Sphere"))
OPTION_TYPE_CAPSULE:
_start_type(_find_type_index("Capsule"))
await _start_type(_find_type_index("Capsule"))
OPTION_TYPE_CYLINDER:
_start_type(_find_type_index("Cylinder"))
await _start_type(_find_type_index("Cylinder"))
OPTION_TYPE_CONVEX:
_start_type(_find_type_index("Convex"))
await _start_type(_find_type_index("Convex"))
func _find_type_index(type_name):
@@ -100,7 +102,7 @@ func _start_type(type_index):
if type_index >= _object_templates.size():
return
yield(start_timer(1.0), "timeout")
await start_timer(1.0).timeout
if is_timer_canceled():
return
@@ -108,10 +110,10 @@ func _start_type(type_index):
_spawn_objects(type_index)
yield(wait_for_physics_ticks(5), "wait_done")
await wait_for_physics_ticks(5).wait_done
_log_physics_stop()
yield(start_timer(1.0), "timeout")
await start_timer(1.0).timeout
if is_timer_canceled():
return
@@ -119,10 +121,10 @@ func _start_type(type_index):
_activate_objects()
yield(wait_for_physics_ticks(5), "wait_done")
await wait_for_physics_ticks(5).wait_done
_log_physics_stop()
yield(start_timer(5.0), "timeout")
await start_timer(5.0).timeout
if is_timer_canceled():
return
@@ -130,17 +132,17 @@ func _start_type(type_index):
_despawn_objects()
yield(wait_for_physics_ticks(5), "wait_done")
await wait_for_physics_ticks(5).wait_done
_log_physics_stop()
yield(start_timer(1.0), "timeout")
await start_timer(1.0).timeout
func _start_all_types():
Log.print_log("* Start all types.")
for type_index in range(_object_templates.size()):
yield(_start_type(type_index), "completed")
await _start_type(type_index)
if is_timer_canceled():
return
@@ -150,7 +152,7 @@ func _start_all_types():
func _spawn_objects(type_index):
var template_node = _object_templates[type_index]
Log.print_log("* Spawning: " + template_node.name)
Log.print_log("* Spawning: " + String(template_node.name))
for spawn in spawns:
var spawn_parent = get_node(spawn)
@@ -160,7 +162,7 @@ func _spawn_objects(type_index):
var collision = template_node.get_child(0).duplicate()
collision.shape = collision.shape.duplicate()
var body = template_node.duplicate()
body.transform = Transform.IDENTITY
body.transform = Transform3D.IDENTITY
if spawn_randomize != Vector3.ZERO:
body.transform.origin.x = randf() * spawn_randomize.x
body.transform.origin.y = randf() * spawn_randomize.y
@@ -180,7 +182,7 @@ func _activate_objects():
var spawn_parent = get_node(spawn)
for node_index in range(spawn_parent.get_child_count()):
var node = spawn_parent.get_child(node_index) as RigidBody
var node = spawn_parent.get_child(node_index) as RigidDynamicBody3D
node.set_sleeping(false)

View File

@@ -1,90 +1,90 @@
[gd_scene load_steps=11 format=2]
[gd_scene load_steps=11 format=3 uid="uid://4wsisagg0r7r"]
[ext_resource path="res://tests/static_scene.tscn" type="PackedScene" id=1]
[ext_resource path="res://tests/performance/test_perf_contacts.gd" type="Script" id=2]
[ext_resource path="res://tests/test_options.tscn" type="PackedScene" id=4]
[ext_resource path="res://utils/camera_orbit.gd" type="Script" id=5]
[ext_resource type="PackedScene" uid="uid://cl2vpuxqgnylc" path="res://tests/static_scene.tscn" id="1"]
[ext_resource type="Script" path="res://tests/performance/test_perf_contacts.gd" id="2"]
[ext_resource type="PackedScene" uid="uid://b1ihqm3x8jru" path="res://tests/test_options.tscn" id="4"]
[ext_resource type="Script" path="res://utils/camera_orbit.gd" id="5"]
[sub_resource type="BoxShape" id=1]
[sub_resource type="BoxShape3D" id="1"]
[sub_resource type="CapsuleShape" id=2]
[sub_resource type="CapsuleShape3D" id="2"]
[sub_resource type="CylinderShape" id=3]
[sub_resource type="CylinderShape3D" id="3"]
[sub_resource type="ConvexPolygonShape" id=4]
points = PoolVector3Array( -0.7, 0, -0.7, -0.3, 0, 0.8, 0.8, 0, -0.3, 0, -1, 0 )
[sub_resource type="ConvexPolygonShape3D" id="4"]
points = PackedVector3Array(-0.7, 0, -0.7, -0.3, 0, 0.8, 0.8, 0, -0.3, 0, -1, 0)
[sub_resource type="SphereShape" id=5]
[sub_resource type="SphereShape3D" id="5"]
[sub_resource type="PlaneShape" id=6]
[sub_resource type="WorldBoundaryShape3D" id="6"]
[node name="Test" type="Spatial"]
script = ExtResource( 2 )
[node name="Test" type="Node3D"]
script = ExtResource( "2" )
_enable_debug_collision = false
spawns = [ "SpawnTarget1" ]
spawns = ["SpawnTarget1"]
spawn_count = 500
spawn_randomize = Vector3( 0.2, 0.2, 0.2 )
spawn_randomize = Vector3(0.2, 0.2, 0.2)
[node name="Options" parent="." instance=ExtResource( 4 )]
[node name="Options" parent="." instance=ExtResource( "4" )]
[node name="SpawnTarget1" type="Spatial" parent="."]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 7.06418, -1.24693 )
[node name="SpawnTarget1" type="Node3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 7.06418, -1.24693)
[node name="DynamicShapes" type="Spatial" parent="."]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, -26.3192, 1.2359, 38.0117 )
[node name="DynamicShapes" type="Node3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -26.3192, 1.2359, 38.0117)
[node name="RigidBodyBox" type="RigidBody" parent="DynamicShapes"]
[node name="RigidBodyBox" type="RigidDynamicBody3D" parent="DynamicShapes"]
[node name="CollisionShape" type="CollisionShape" parent="DynamicShapes/RigidBodyBox"]
shape = SubResource( 1 )
[node name="CollisionShape" type="CollisionShape3D" parent="DynamicShapes/RigidBodyBox"]
shape = SubResource( "1" )
[node name="RigidBodyCapsule" type="RigidBody" parent="DynamicShapes"]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 2, 0, 0 )
[node name="RigidBodyCapsule" type="RigidDynamicBody3D" parent="DynamicShapes"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 2, 0, 0)
[node name="CollisionShape" type="CollisionShape" parent="DynamicShapes/RigidBodyCapsule"]
shape = SubResource( 2 )
[node name="CollisionShape" type="CollisionShape3D" parent="DynamicShapes/RigidBodyCapsule"]
shape = SubResource( "2" )
[node name="RigidBodyCylinder" type="RigidBody" parent="DynamicShapes"]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 4, 0, 0 )
[node name="RigidBodyCylinder" type="RigidDynamicBody3D" parent="DynamicShapes"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 4, 0, 0)
[node name="CollisionShape" type="CollisionShape" parent="DynamicShapes/RigidBodyCylinder"]
shape = SubResource( 3 )
[node name="CollisionShape" type="CollisionShape3D" parent="DynamicShapes/RigidBodyCylinder"]
shape = SubResource( "3" )
[node name="RigidBodyConvex" type="RigidBody" parent="DynamicShapes"]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 6, 0, 0 )
[node name="RigidBodyConvex" type="RigidDynamicBody3D" parent="DynamicShapes"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 6, 0, 0)
[node name="CollisionShape" type="CollisionShape" parent="DynamicShapes/RigidBodyConvex"]
shape = SubResource( 4 )
[node name="CollisionShape" type="CollisionShape3D" parent="DynamicShapes/RigidBodyConvex"]
shape = SubResource( "4" )
[node name="RigidBodySphere" type="RigidBody" parent="DynamicShapes"]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 8, 0, 0 )
[node name="RigidBodySphere" type="RigidDynamicBody3D" parent="DynamicShapes"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 8, 0, 0)
[node name="CollisionShape" type="CollisionShape" parent="DynamicShapes/RigidBodySphere"]
shape = SubResource( 5 )
[node name="CollisionShape" type="CollisionShape3D" parent="DynamicShapes/RigidBodySphere"]
shape = SubResource( "5" )
[node name="StaticBodyWalls" type="StaticBody" parent="."]
[node name="StaticBodyWalls" type="StaticBody3D" parent="."]
[node name="CollisionShape1" type="CollisionShape" parent="StaticBodyWalls"]
transform = Transform( -1.62921e-07, 1, 0, -1, -1.62921e-07, 0, 0, 0, 1, -5, 0, 0 )
shape = SubResource( 6 )
[node name="CollisionShape1" type="CollisionShape3D" parent="StaticBodyWalls"]
transform = Transform3D(-1.62921e-07, 1, 0, -1, -1.62921e-07, 0, 0, 0, 1, -5, 0, 0)
shape = SubResource( "6" )
[node name="CollisionShape2" type="CollisionShape" parent="StaticBodyWalls"]
transform = Transform( -1.62921e-07, -1, 0, 1, -1.62921e-07, 0, 0, 0, 1, 5, 0, 0 )
shape = SubResource( 6 )
[node name="CollisionShape2" type="CollisionShape3D" parent="StaticBodyWalls"]
transform = Transform3D(-1.62921e-07, -1, 0, 1, -1.62921e-07, 0, 0, 0, 1, 5, 0, 0)
shape = SubResource( "6" )
[node name="CollisionShape3" type="CollisionShape" parent="StaticBodyWalls"]
transform = Transform( 2.6543e-14, 1.62921e-07, 1, 1, -1.62921e-07, 1.56125e-19, 1.62921e-07, 1, -1.62921e-07, 0, 0, -5 )
shape = SubResource( 6 )
[node name="CollisionShape3" type="CollisionShape3D" parent="StaticBodyWalls"]
transform = Transform3D(2.6543e-14, 1.62921e-07, 1, 1, -1.62921e-07, 1.56125e-19, 1.62921e-07, 1, -1.62921e-07, 0, 0, -5)
shape = SubResource( "6" )
[node name="CollisionShape4" type="CollisionShape" parent="StaticBodyWalls"]
transform = Transform( 2.6543e-14, 1.62921e-07, -1, 1, -1.62921e-07, -1.56125e-19, -1.62921e-07, -1, -1.62921e-07, 0, 0, 5 )
shape = SubResource( 6 )
[node name="CollisionShape4" type="CollisionShape3D" parent="StaticBodyWalls"]
transform = Transform3D(2.6543e-14, 1.62921e-07, -1, 1, -1.62921e-07, -1.56125e-19, -1.62921e-07, -1, -1.62921e-07, 0, 0, 5)
shape = SubResource( "6" )
[node name="StaticScene" parent="." instance=ExtResource( 1 )]
[node name="StaticScene" parent="." instance=ExtResource( "1" )]
[node name="Camera" type="Camera" parent="."]
transform = Transform( 1, 0, 0, 0, 0.881757, 0.471705, 0, -0.471705, 0.881757, 0, 20.4125, 41.0426 )
script = ExtResource( 5 )
[node name="Camera3D" type="Camera3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 0.881757, 0.471705, 0, -0.471705, 0.881757, 0, 20.4125, 41.0426)
script = ExtResource( "5" )
[node name="OmniLight" type="OmniLight" parent="Camera"]
[node name="OmniLight" type="OmniLight3D" parent="Camera3D"]
omni_range = 80.0

View File

@@ -1,19 +1,18 @@
[gd_scene load_steps=4 format=2]
[gd_scene load_steps=4 format=3 uid="uid://cl2vpuxqgnylc"]
[ext_resource path="res://assets/robot_head/godot3_robot_head_collision.tres" type="Shape" id=1]
[ext_resource path="res://assets/robot_head/godot3_robot_head.mesh" type="ArrayMesh" id=2]
[ext_resource path="res://tests/static_scene_plane.tscn" type="PackedScene" id=3]
[ext_resource type="Shape3D" path="res://assets/robot_head/godot3_robot_head_collision.tres" id="1"]
[ext_resource type="ArrayMesh" path="res://assets/robot_head/godot3_robot_head.mesh" id="2"]
[ext_resource type="PackedScene" uid="uid://3gkujifjokqw" path="res://tests/static_scene_plane.tscn" id="3"]
[node name="StaticScene" type="Spatial"]
[node name="StaticScene" type="Node3D"]
[node name="StaticBodyPlane" parent="." instance=ExtResource( 3 )]
[node name="StaticBodyPlane" parent="." instance=ExtResource( "3" )]
[node name="StaticBodyHead" type="StaticBody" parent="."]
transform = Transform( 10, 0, 0, 0, 8.66025, 5, 0, -5, 8.66025, 0, -11.1389, 2.29332 )
[node name="StaticBodyHead" type="StaticBody3D" parent="."]
transform = Transform3D(10, 0, 0, 0, 8.66025, 5, 0, -5, 8.66025, 0, -11.1389, 2.29332)
[node name="RobotHead" type="MeshInstance" parent="StaticBodyHead"]
mesh = ExtResource( 2 )
material/0 = null
[node name="RobotHead" type="MeshInstance3D" parent="StaticBodyHead"]
mesh = ExtResource( "2" )
[node name="CollisionShape" type="CollisionShape" parent="StaticBodyHead"]
shape = ExtResource( 1 )
[node name="CollisionShape" type="CollisionShape3D" parent="StaticBodyHead"]
shape = ExtResource( "1" )

View File

@@ -1,17 +1,16 @@
[gd_scene load_steps=3 format=2]
[gd_scene load_steps=3 format=3 uid="uid://3gkujifjokqw"]
[sub_resource type="PlaneMesh" id=1]
[sub_resource type="PlaneMesh" id="1"]
[sub_resource type="ConcavePolygonShape" id=2]
data = PoolVector3Array( -1, 0, 1, 1, 0, -1, 1, 0, 1, -1, 0, 1, -1, 0, -1, 1, 0, -1 )
[sub_resource type="ConcavePolygonShape3D" id="2"]
data = PackedVector3Array(-1, 0, 1, 1, 0, -1, 1, 0, 1, -1, 0, 1, -1, 0, -1, 1, 0, -1)
[node name="StaticBodyPlane" type="StaticBody"]
[node name="StaticBodyPlane" type="StaticBody3D"]
[node name="MeshInstance" type="MeshInstance" parent="."]
transform = Transform( 50, 0, 0, 0, 1, 0, 0, 0, 50, 0, 0, 0 )
mesh = SubResource( 1 )
material/0 = null
[node name="MeshInstance3D" type="MeshInstance3D" parent="."]
transform = Transform3D(50, 0, 0, 0, 1, 0, 0, 0, 50, 0, 0, 0)
mesh = SubResource( "1" )
[node name="CollisionShape" type="CollisionShape" parent="."]
transform = Transform( 50, 0, 0, 0, 1, 0, 0, 0, 50, 0, 0, 0 )
shape = SubResource( 2 )
[node name="CollisionShape" type="CollisionShape3D" parent="."]
transform = Transform3D(50, 0, 0, 0, 1, 0, 0, 0, 50, 0, 0, 0)
shape = SubResource( "2" )

View File

@@ -1,17 +1,16 @@
[gd_scene load_steps=2 format=2]
[gd_scene load_steps=2 format=3 uid="uid://b1ihqm3x8jru"]
[ext_resource path="res://utils/option_menu.gd" type="Script" id=1]
[ext_resource type="Script" path="res://utils/option_menu.gd" id="1"]
[node name="Options" type="MenuButton"]
pause_mode = 2
margin_left = 10.0
margin_top = 106.719
margin_right = 125.0
margin_bottom = 126.719
offset_left = 10.0
offset_top = 106.719
offset_right = 125.0
offset_bottom = 126.719
text = "TEST OPTIONS"
flat = false
align = 0
script = ExtResource( 1 )
script = ExtResource( "1" )
__meta__ = {
"_edit_use_anchors_": false
}

View File

@@ -9,11 +9,11 @@ class TestData:
var _test_list = []
var _current_test = null
var _current_test_scene = null
var _current_test_scene : Node = null
func _ready():
connect("option_selected", self, "_on_option_selected")
connect("option_selected", Callable(self, "_on_option_selected"))
func _process(_delta):
@@ -46,7 +46,7 @@ func _start_test(test):
Log.print_log("*** STARTING TEST: " + test.id)
var scene = load(test.scene_path)
_current_test_scene = scene.instance()
_current_test_scene = scene.instantiate()
get_tree().root.add_child(_current_test_scene)
var label_test = get_node("../LabelTest")

View File

@@ -1,4 +1,4 @@
extends Camera
extends Camera3D
const ROTATION_COEFF = 0.02
@@ -14,7 +14,7 @@ func _ready():
func _unhandled_input(event):
var mouse_button_event = event as InputEventMouseButton
if mouse_button_event:
if mouse_button_event.button_index == BUTTON_RIGHT:
if mouse_button_event.button_index == MOUSE_BUTTON_RIGHT:
_rotation_enabled = mouse_button_event.pressed
return
@@ -28,7 +28,7 @@ func _unhandled_input(event):
func _initialize_pivot():
_rotation_pivot = Spatial.new()
_rotation_pivot = Node3D.new()
var camera_parent = get_parent()
camera_parent.add_child(_rotation_pivot)
camera_parent.remove_child(self)

View File

@@ -0,0 +1,17 @@
extends CharacterBody3D
@export var _stop_on_slopes = false
@export var _use_snap = false
var _gravity = 20.0
func _physics_process(delta):
if is_on_floor():
floor_snap_length = 0.2
else:
motion_velocity += Vector3.DOWN * _gravity * delta
floor_snap_length = 0.0
floor_stop_on_slope = _stop_on_slopes
move_and_slide()

View File

@@ -7,7 +7,7 @@ var _entry_template
func _enter_tree():
Log.connect("entry_logged", self, "_on_log_entry")
Log.connect("entry_logged", Callable(self, "_on_log_entry"))
_entry_template = get_child(0) as Label
remove_child(_entry_template)
@@ -29,9 +29,9 @@ func _on_log_entry(message, type):
new_entry.set_text(message)
if type == Log.LogType.ERROR:
new_entry.modulate = Color.red
new_entry.modulate = Color.RED
else:
new_entry.modulate = Color.white
new_entry.modulate = Color.WHITE
if get_child_count() >= MAX_ENTRIES:
var first_entry = get_child(0) as Label

View File

@@ -1,7 +1,7 @@
extends Control
export(Vector3) var world_offset
@export var world_offset = Vector3.ZERO
var _pos_offset
var _attachment
@@ -9,7 +9,7 @@ var _attachment
func _ready():
_pos_offset = rect_position
_attachment = get_parent() as Spatial
_attachment = get_parent() as Node3D
func _process(_delta):
@@ -20,7 +20,7 @@ func _process(_delta):
if viewport == null:
return
var camera = viewport.get_camera()
var camera = viewport.get_camera_3d()
if camera == null:
return

View File

@@ -1,23 +0,0 @@
extends KinematicBody
export(bool) var _gravity_on_floor = true
export(bool) var _stop_on_slopes = false
export(bool) var _use_snap = false
var _gravity = 20.0
var _velocity = Vector3.ZERO
func _physics_process(delta):
var snap = Vector3.DOWN * 0.2
if is_on_floor() and _gravity_on_floor:
_velocity += Vector3.DOWN * _gravity * delta
else:
_velocity += Vector3.DOWN * _gravity * delta
snap = Vector3.ZERO
if _use_snap:
_velocity = move_and_slide_with_snap(_velocity, snap, Vector3.UP, _stop_on_slopes)
else:
_velocity = move_and_slide(_velocity, Vector3.UP, _stop_on_slopes)

View File

@@ -1,13 +1,13 @@
extends Label
var test_name setget _set_test_name
var test_name = "":
set(value):
if (test_name != value):
return
test_name = value
set_text("Test: %s" % test_name)
func _ready():
set_text("Select a test from the menu to start it")
func _set_test_name(value):
test_name = value
set_text("Test: %s" % test_name)

View File

@@ -44,7 +44,7 @@ func _add_popup(parent_popup, path, label):
parent_popup.add_child(popup_menu)
parent_popup.add_submenu_item(label, label)
popup_menu.connect("index_pressed", self, "_on_item_pressed", [popup_menu, path])
popup_menu.connect("index_pressed", Callable(self, "_on_item_pressed"), [popup_menu, path])
return popup_menu

View File

@@ -1,9 +1,9 @@
extends RigidBody
extends RigidDynamicBody3D
onready var _forward = - transform.basis.z
onready var _collision_shape = $CollisionShape
onready var _material = $CollisionShape/MeshInstance.get_surface_material(0)
@onready var _forward = -transform.basis.z
@onready var _collision_shape = $CollisionShape
@onready var _material = $CollisionShape/MeshInstance3D.get_active_material(0)
var _dir = 1.0
var _distance = 10.0
@@ -13,11 +13,17 @@ var _gravity_impulse = 30.0
var _is_on_floor = false
func _ready():
if not _material:
_material = StandardMaterial3D.new()
$CollisionShape/MeshInstance3D.set_surface_override_material(0, _material)
func _process(_delta):
if _is_on_floor:
_material.albedo_color = Color.white
_material.albedo_color = Color.WHITE
else:
_material.albedo_color = Color.red
_material.albedo_color = Color.RED
func _integrate_forces(state):
@@ -34,8 +40,8 @@ func _integrate_forces(state):
func ground_check():
var space_state = get_world().direct_space_state
var shape = PhysicsShapeQueryParameters.new()
var space_state = get_world_3d().direct_space_state
var shape = PhysicsShapeQueryParameters3D.new()
shape.transform = _collision_shape.global_transform
shape.shape_rid = _collision_shape.shape.get_rid()
shape.collision_mask = 2

View File

@@ -1,4 +1,4 @@
extends RigidBody
extends RigidDynamicBody3D
const MOUSE_DELTA_COEFFICIENT = 0.01
@@ -16,7 +16,7 @@ func _ready():
func _input(event):
var mouse_event = event as InputEventMouseButton
if mouse_event and not mouse_event.pressed:
if mouse_event.button_index == BUTTON_LEFT:
if mouse_event.button_index == MOUSE_BUTTON_LEFT:
_picked = false
var mouse_motion = event as InputEventMouseMotion
@@ -27,7 +27,7 @@ func _input(event):
func _input_event(_viewport, event, _click_pos, _click_normal, _shape_idx):
var mouse_event = event as InputEventMouseButton
if mouse_event and mouse_event.pressed:
if mouse_event.button_index == BUTTON_LEFT:
if mouse_event.button_index == MOUSE_BUTTON_LEFT:
_picked = true
_mouse_pos = mouse_event.position
_last_mouse_pos = _mouse_pos
@@ -37,11 +37,11 @@ func _physics_process(delta):
if _picked:
var mouse_delta = _mouse_pos - _last_mouse_pos
var world_delta = Vector3.ZERO
var world_delta := Vector3.ZERO
world_delta.x = mouse_delta.x * MOUSE_DELTA_COEFFICIENT
world_delta.y = -mouse_delta.y * MOUSE_DELTA_COEFFICIENT
var camera = get_viewport().get_camera()
var camera = get_viewport().get_camera_3d()
if camera:
var camera_basis = camera.global_transform.basis
world_delta = camera_basis * world_delta
@@ -50,7 +50,7 @@ func _physics_process(delta):
var fov_coefficient = camera.fov / 70.0
world_delta *= CAMERA_DISTANCE_COEFFICIENT * camera_dist * fov_coefficient
if mode == MODE_STATIC:
if freeze:
global_transform.origin += world_delta
else:
linear_velocity = world_delta / delta

View File

@@ -1,14 +1,10 @@
extends ScrollContainer
export(bool) var auto_scroll = false setget set_auto_scroll
@export var auto_scroll = false
func _process(_delta):
if auto_scroll:
var scrollbar = get_v_scrollbar()
scrollbar.value = scrollbar.max_value
func set_auto_scroll(value):
auto_scroll = value

View File

@@ -11,7 +11,7 @@ var _engine = PhysicsEngine.OTHER
func _enter_tree():
pause_mode = Node.PAUSE_MODE_PROCESS
process_mode = Node.PROCESS_MODE_ALWAYS
get_tree().debug_collisions_hint = true
@@ -21,7 +21,7 @@ func _enter_tree():
_engine = PhysicsEngine.BULLET
"Bullet":
_engine = PhysicsEngine.BULLET
"GodotPhysics":
"GodotPhysics3D":
_engine = PhysicsEngine.GODOT_PHYSICS
_:
_engine = PhysicsEngine.OTHER
@@ -29,7 +29,10 @@ func _enter_tree():
func _process(_delta):
if Input.is_action_just_pressed("toggle_full_screen"):
OS.window_fullscreen = not OS.window_fullscreen
if DisplayServer.window_get_mode() == DisplayServer.WINDOW_MODE_FULLSCREEN:
DisplayServer.window_set_mode(DisplayServer.WINDOW_MODE_WINDOWED)
else:
DisplayServer.window_set_mode(DisplayServer.WINDOW_MODE_FULLSCREEN)
if Input.is_action_just_pressed("toggle_debug_collision"):
var debug_collision_enabled = not _is_debug_collision_enabled()