Skip to content

Commit 5132941

Browse files
authored
Merge pull request #612 from nekomatata/physics-tests-3.3
Physics Tests 3.3 update
2 parents 31bb092 + ef265cc commit 5132941

File tree

8 files changed

+32
-28
lines changed

8 files changed

+32
-28
lines changed

2d/physics_tests/tests/functional/test_shapes.tscn

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
[gd_scene load_steps=7 format=2]
1+
[gd_scene load_steps=8 format=2]
22

33
[ext_resource path="res://assets/texture/godot-head.png" type="Texture" id=1]
44
[ext_resource path="res://test.gd" type="Script" id=2]
5+
[ext_resource path="res://utils/rigidbody_pick.gd" type="Script" id=3]
56
[ext_resource path="res://tests/static_scene.tscn" type="PackedScene" id=6]
67

78
[sub_resource type="RectangleShape2D" id=1]
@@ -21,20 +22,23 @@ script = ExtResource( 2 )
2122

2223
[node name="RigidBodyRectangle" type="RigidBody2D" parent="DynamicShapes"]
2324
position = Vector2( 96, 127 )
25+
script = ExtResource( 3 )
2426

2527
[node name="CollisionShape2D" type="CollisionShape2D" parent="DynamicShapes/RigidBodyRectangle"]
2628
rotation = 0.675442
2729
shape = SubResource( 1 )
2830

2931
[node name="RigidBodyCapsule" type="RigidBody2D" parent="DynamicShapes"]
3032
position = Vector2( 270.165, 139.444 )
33+
script = ExtResource( 3 )
3134

3235
[node name="CollisionShape2D" type="CollisionShape2D" parent="DynamicShapes/RigidBodyCapsule"]
3336
rotation = -0.202458
3437
shape = SubResource( 2 )
3538

3639
[node name="RigidBodyConcavePolygon" type="RigidBody2D" parent="DynamicShapes"]
3740
position = Vector2( 683.614, 132.749 )
41+
script = ExtResource( 3 )
3842

3943
[node name="CollisionPolygon2D" type="CollisionPolygon2D" parent="DynamicShapes/RigidBodyConcavePolygon"]
4044
scale = Vector2( 0.5, 0.5 )
@@ -47,6 +51,7 @@ texture = ExtResource( 1 )
4751

4852
[node name="RigidBodyConvexPolygon" type="RigidBody2D" parent="DynamicShapes"]
4953
position = Vector2( 473.536, 134.336 )
54+
script = ExtResource( 3 )
5055

5156
[node name="CollisionPolygon2D" type="CollisionPolygon2D" parent="DynamicShapes/RigidBodyConvexPolygon"]
5257
scale = Vector2( 0.5, 0.5 )
@@ -59,6 +64,7 @@ texture = ExtResource( 1 )
5964

6065
[node name="RigidBodySphere" type="RigidBody2D" parent="DynamicShapes"]
6166
position = Vector2( 919.968, 115.129 )
67+
script = ExtResource( 3 )
6268

6369
[node name="CollisionShape2D" type="CollisionShape2D" parent="DynamicShapes/RigidBodySphere"]
6470
shape = SubResource( 3 )

3d/physics_tests/test.gd

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,23 +46,33 @@ func add_sphere(pos, radius, color):
4646

4747

4848
func add_shape(shape, transform, color):
49+
var body = StaticBody.new()
50+
body.collision_layer = 0
51+
body.collision_mask = 0
52+
4953
var collision = CollisionShape.new()
54+
collision.transform = transform
5055
collision.shape = shape
5156

52-
_drawn_nodes.push_back(collision)
53-
add_child(collision)
57+
body.add_child(collision)
58+
59+
add_child(body)
60+
_drawn_nodes.push_back(body)
5461

55-
var mesh_instance = collision.get_child(0)
62+
call_deferred("initialize_shape_material", body, color)
63+
64+
65+
func initialize_shape_material(body, color):
66+
var mesh_instance = body.get_child(1)
5667
var material = SpatialMaterial.new()
5768
material.flags_unshaded = true
5869
material.albedo_color = color
5970
mesh_instance.material_override = material
6071

61-
collision.global_transform = transform
62-
6372

6473
func clear_drawn_nodes():
6574
for node in _drawn_nodes:
75+
remove_child(node)
6676
node.queue_free()
6777
_drawn_nodes.clear()
6878

3d/physics_tests/tests/functional/test_collision_pairs.tscn

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
[gd_scene load_steps=11 format=2]
1+
[gd_scene load_steps=10 format=2]
22

33
[ext_resource path="res://assets/robot_head/godot3_robot_head_collision.tres" type="Shape" id=1]
44
[ext_resource path="res://tests/functional/test_collision_pairs.gd" type="Script" id=2]
5-
[ext_resource path="res://utils/exception_cylinder.gd" type="Script" id=3]
65
[ext_resource path="res://utils/camera_orbit.gd" type="Script" id=4]
76
[ext_resource path="res://tests/test_options.tscn" type="PackedScene" id=5]
87

@@ -141,7 +140,6 @@ shape = SubResource( 3 )
141140
[node name="RigidBodyCylinder" type="RigidBody" parent="Shapes"]
142141
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 3, 0, 0 )
143142
mode = 3
144-
script = ExtResource( 3 )
145143

146144
[node name="CollisionShape" type="CollisionShape" parent="Shapes/RigidBodyCylinder"]
147145
transform = Transform( 0.772741, -0.258819, 2.59821e-08, 0.2, 0.933013, -0.207055, 0.0535898, 0.25, 0.772741, 0, 0, 0 )

3d/physics_tests/tests/functional/test_raycasting.tscn

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
[gd_scene load_steps=10 format=2]
1+
[gd_scene load_steps=9 format=2]
22

33
[ext_resource path="res://assets/robot_head/godot3_robot_head_collision.tres" type="Shape" id=1]
44
[ext_resource path="res://tests/functional/test_raycasting.gd" type="Script" id=2]
5-
[ext_resource path="res://utils/exception_cylinder.gd" type="Script" id=3]
65
[ext_resource path="res://utils/camera_orbit.gd" type="Script" id=4]
76

87
[sub_resource type="BoxShape" id=1]
@@ -48,7 +47,6 @@ shape = SubResource( 3 )
4847
[node name="RigidBodyCylinder" type="RigidBody" parent="Shapes"]
4948
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 3, 0, 0 )
5049
mode = 3
51-
script = ExtResource( 3 )
5250

5351
[node name="CollisionShape" type="CollisionShape" parent="Shapes/RigidBodyCylinder"]
5452
transform = Transform( 0.772741, -0.258819, 2.59821e-08, 0.2, 0.933013, -0.207055, 0.0535898, 0.25, 0.772741, 0, 0, 0 )

3d/physics_tests/tests/functional/test_shapes.tscn

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[gd_scene load_steps=10 format=2]
22

3+
[ext_resource path="res://utils/rigidbody_pick.gd" type="Script" id=1]
34
[ext_resource path="res://test.gd" type="Script" id=2]
4-
[ext_resource path="res://utils/exception_cylinder.gd" type="Script" id=3]
55
[ext_resource path="res://utils/camera_orbit.gd" type="Script" id=4]
66
[ext_resource path="res://tests/static_scene.tscn" type="PackedScene" id=6]
77

@@ -24,34 +24,38 @@ transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 9.35591, 0 )
2424

2525
[node name="RigidBodyBox" type="RigidBody" parent="DynamicShapes"]
2626
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, -6, 0, 0 )
27+
script = ExtResource( 1 )
2728

2829
[node name="CollisionShape" type="CollisionShape" parent="DynamicShapes/RigidBodyBox"]
2930
transform = Transform( 0.579556, 0.0885213, 0.145926, 0, 0.939693, -0.205212, -0.155291, 0.330366, 0.544604, 0, 0, 0 )
3031
shape = SubResource( 1 )
3132

3233
[node name="RigidBodyCapsule" type="RigidBody" parent="DynamicShapes"]
3334
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, -3, 0, 0 )
35+
script = ExtResource( 1 )
3436

3537
[node name="CollisionShape" type="CollisionShape" parent="DynamicShapes/RigidBodyCapsule"]
3638
transform = Transform( 0.8, 0, 0, 0, -1.30337e-07, -0.8, 0, 0.8, -1.30337e-07, 0, 0, 0 )
3739
shape = SubResource( 2 )
3840

3941
[node name="RigidBodyCylinder" type="RigidBody" parent="DynamicShapes"]
40-
script = ExtResource( 3 )
42+
script = ExtResource( 1 )
4143

4244
[node name="CollisionShape" type="CollisionShape" parent="DynamicShapes/RigidBodyCylinder"]
4345
transform = Transform( 0.772741, -0.258819, 2.59821e-08, 0.2, 0.933013, -0.207055, 0.0535898, 0.25, 0.772741, 0, 0, 0 )
4446
shape = SubResource( 3 )
4547

4648
[node name="RigidBodyConvex" type="RigidBody" parent="DynamicShapes"]
4749
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 3, 0, 0 )
50+
script = ExtResource( 1 )
4851

4952
[node name="CollisionShape" type="CollisionShape" parent="DynamicShapes/RigidBodyConvex"]
5053
transform = Transform( 1.5, 0, 0, 0, 1.93185, -0.388229, 0, 0.517638, 1.44889, 0, 0, 0 )
5154
shape = SubResource( 4 )
5255

5356
[node name="RigidBodySphere" type="RigidBody" parent="DynamicShapes"]
5457
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 6, 0, 0 )
58+
script = ExtResource( 1 )
5559

5660
[node name="CollisionShape" type="CollisionShape" parent="DynamicShapes/RigidBodySphere"]
5761
transform = Transform( 0.8, 0, 0, 0, 0.8, 0, 0, 0, 0.8, 0, 0, 0 )

3d/physics_tests/tests/performance/test_perf_contacts.tscn

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
[gd_scene load_steps=12 format=2]
1+
[gd_scene load_steps=11 format=2]
22

33
[ext_resource path="res://tests/static_scene.tscn" type="PackedScene" id=1]
44
[ext_resource path="res://tests/performance/test_perf_contacts.gd" type="Script" id=2]
5-
[ext_resource path="res://utils/exception_cylinder.gd" type="Script" id=3]
65
[ext_resource path="res://tests/test_options.tscn" type="PackedScene" id=4]
76
[ext_resource path="res://utils/camera_orbit.gd" type="Script" id=5]
87

@@ -46,7 +45,6 @@ shape = SubResource( 2 )
4645

4746
[node name="RigidBodyCylinder" type="RigidBody" parent="DynamicShapes"]
4847
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 4, 0, 0 )
49-
script = ExtResource( 3 )
5048

5149
[node name="CollisionShape" type="CollisionShape" parent="DynamicShapes/RigidBodyCylinder"]
5250
shape = SubResource( 3 )

3d/physics_tests/tests/performance/test_perf_contacts_extended.tscn

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
[gd_scene load_steps=12 format=2]
1+
[gd_scene load_steps=11 format=2]
22

33
[ext_resource path="res://tests/performance/test_perf_contacts.gd" type="Script" id=1]
4-
[ext_resource path="res://utils/exception_cylinder.gd" type="Script" id=2]
54
[ext_resource path="res://utils/camera_orbit.gd" type="Script" id=3]
65
[ext_resource path="res://tests/test_options.tscn" type="PackedScene" id=4]
76
[ext_resource path="res://tests/static_scene.tscn" type="PackedScene" id=5]
@@ -91,7 +90,6 @@ shape = SubResource( 2 )
9190

9291
[node name="RigidBodyCylinder" type="RigidBody" parent="DynamicShapes"]
9392
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 4, 0, 0 )
94-
script = ExtResource( 2 )
9593

9694
[node name="CollisionShape" type="CollisionShape" parent="DynamicShapes/RigidBodyCylinder"]
9795
shape = SubResource( 3 )

3d/physics_tests/utils/exception_cylinder.gd

Lines changed: 0 additions & 8 deletions
This file was deleted.

0 commit comments

Comments
 (0)