Skip to content

Commit c33ce26

Browse files
authored
Merge pull request #483 from fire/extended-physics-tests
Add extended physics tests.
2 parents f74217c + 3fd13c1 commit c33ce26

File tree

4 files changed

+166
-23
lines changed

4 files changed

+166
-23
lines changed

3d/physics_tests/tests.gd

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ var _tests = [
1818
"id": "Performance Tests/Contacts",
1919
"path": "res://tests/performance/test_perf_contacts.tscn",
2020
},
21+
{
22+
"id" : "Performance Tests/Contacts Extended",
23+
"path" : "res://tests/performance/test_perf_contacts_extended.tscn",
24+
},
2125
]
2226

2327

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

Lines changed: 25 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,10 @@ const OPTION_TYPE_CAPSULE = "Shape type/Capsule"
77
const OPTION_TYPE_CYLINDER = "Shape type/Cylinder"
88
const OPTION_TYPE_CONVEX = "Shape type/Convex"
99
const OPTION_TYPE_SPHERE = "Shape type/Sphere"
10+
export(Array) var spawns = Array()
1011

11-
export(int) var spawn_count = 1
12+
export(int) var spawn_count = 100
13+
export(int, 1, 10) var spawn_multipiler = 5
1214

1315
var _object_templates = []
1416

@@ -116,18 +118,19 @@ func _start_all_types():
116118

117119
func _spawn_objects(type_index):
118120
var template_node = _object_templates[type_index]
119-
var spawn_parent = $SpawnTarget
120-
121-
Log.print_log("* Spawning: " + template_node.name)
122-
123-
for node_index in spawn_count:
124-
var node = template_node.duplicate() as Spatial
125-
node.transform = Transform.IDENTITY
126-
spawn_parent.add_child(node)
121+
for spawn in spawns:
122+
var spawn_parent = get_node(spawn)
123+
124+
Log.print_log("* Spawning: " + template_node.name)
125+
126+
for _index in range(spawn_multipiler):
127+
for _node_index in spawn_count / spawn_multipiler:
128+
var node = template_node.duplicate() as Spatial
129+
spawn_parent.add_child(node)
127130

128131

129132
func _activate_objects():
130-
var spawn_parent = $SpawnTarget
133+
var spawn_parent = $SpawnTarget1
131134

132135
Log.print_log("* Activating")
133136

@@ -137,15 +140,16 @@ func _activate_objects():
137140

138141

139142
func _despawn_objects():
140-
var spawn_parent = $SpawnTarget
141-
142-
if spawn_parent.get_child_count() == 0:
143-
return
144-
145-
Log.print_log("* Despawning")
143+
for spawn in spawns:
144+
var spawn_parent = get_node(spawn)
146145

147-
while spawn_parent.get_child_count():
148-
var node_index = spawn_parent.get_child_count() - 1
149-
var node = spawn_parent.get_child(node_index)
150-
spawn_parent.remove_child(node)
151-
node.queue_free()
146+
if spawn_parent.get_child_count() == 0:
147+
return
148+
149+
Log.print_log("* Despawning")
150+
151+
while spawn_parent.get_child_count():
152+
var node_index = spawn_parent.get_child_count() - 1
153+
var node = spawn_parent.get_child(node_index)
154+
spawn_parent.remove_child(node)
155+
node.queue_free()

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,11 @@ data = PoolVector3Array( -1, 0, 1, 1, 0, -1, 1, 0, 1, -1, 0, 1, -1, 0, -1, 1, 0,
2222

2323
[node name="Test" type="Spatial"]
2424
script = ExtResource( 2 )
25-
spawn_count = 100
25+
spawns = [ "SpawnTarget1" ]
2626

2727
[node name="Options" parent="." instance=ExtResource( 4 )]
2828

29-
[node name="SpawnTarget" type="Spatial" parent="."]
29+
[node name="SpawnTarget1" type="Spatial" parent="."]
3030
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 7.06418, -1.24693 )
3131

3232
[node name="DynamicShapes" type="Spatial" parent="."]
Lines changed: 135 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,135 @@
1+
[gd_scene load_steps=12 format=2]
2+
3+
[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]
5+
[ext_resource path="res://utils/camera_orbit.gd" type="Script" id=3]
6+
[ext_resource path="res://tests/test_options.tscn" type="PackedScene" id=4]
7+
[ext_resource path="res://tests/static_scene.tscn" type="PackedScene" id=5]
8+
9+
[sub_resource type="BoxShape" id=1]
10+
11+
[sub_resource type="CapsuleShape" id=2]
12+
13+
[sub_resource type="CylinderShape" id=3]
14+
15+
[sub_resource type="ConvexPolygonShape" id=4]
16+
points = PoolVector3Array( -0.7, 0, -0.7, -0.3, 0, 0.8, 0.8, 0, -0.3, 0, -1, 0 )
17+
18+
[sub_resource type="SphereShape" id=5]
19+
20+
[sub_resource type="ConcavePolygonShape" id=6]
21+
data = PoolVector3Array( -1, 0, 1, 1, 0, -1, 1, 0, 1, -1, 0, 1, -1, 0, -1, 1, 0, -1 )
22+
23+
[node name="Test" type="Spatial"]
24+
script = ExtResource( 1 )
25+
spawns = [ "SpawnTarget1", "SpawnTarget2", "SpawnTarget3", "SpawnTarget4", "SpawnTarget5", "SpawnTarget6", "SpawnTarget7", "SpawnTarget8", "SpawnTarget9", "SpawnTarget10", "SpawnTarget11", "SpawnTarget12", "SpawnTarget13", "SpawnTarget14", "SpawnTarget15", "SpawnTarget16" ]
26+
27+
[node name="Options" parent="." instance=ExtResource( 4 )]
28+
29+
[node name="SpawnTarget1" type="Spatial" parent="."]
30+
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 40, 7, -37.715 )
31+
32+
[node name="SpawnTarget2" type="Spatial" parent="."]
33+
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 40, 7, -19.7248 )
34+
35+
[node name="SpawnTarget3" type="Spatial" parent="."]
36+
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 21.4903, 7, -37.715 )
37+
38+
[node name="SpawnTarget4" type="Spatial" parent="."]
39+
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 21.4903, 7, -19.7248 )
40+
41+
[node name="SpawnTarget5" type="Spatial" parent="."]
42+
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 40, 7, 10.7172 )
43+
44+
[node name="SpawnTarget6" type="Spatial" parent="."]
45+
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 40, 7, 28.7073 )
46+
47+
[node name="SpawnTarget7" type="Spatial" parent="."]
48+
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 21.4903, 7, 10.7172 )
49+
50+
[node name="SpawnTarget8" type="Spatial" parent="."]
51+
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 21.4903, 7, 28.7073 )
52+
53+
[node name="SpawnTarget9" type="Spatial" parent="."]
54+
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, -19.8583, 7, 10.7172 )
55+
56+
[node name="SpawnTarget10" type="Spatial" parent="."]
57+
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, -19.8583, 7, 28.7073 )
58+
59+
[node name="SpawnTarget11" type="Spatial" parent="."]
60+
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, -38.368, 7, 10.7172 )
61+
62+
[node name="SpawnTarget12" type="Spatial" parent="."]
63+
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, -38.368, 7, 28.7073 )
64+
65+
[node name="SpawnTarget13" type="Spatial" parent="."]
66+
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, -19.8583, 7, -38.798 )
67+
68+
[node name="SpawnTarget14" type="Spatial" parent="."]
69+
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, -19.8583, 7, -20.8078 )
70+
71+
[node name="SpawnTarget15" type="Spatial" parent="."]
72+
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, -38.368, 7, -38.798 )
73+
74+
[node name="SpawnTarget16" type="Spatial" parent="."]
75+
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, -38.368, 7, -20.8078 )
76+
77+
[node name="DynamicShapes" type="Spatial" parent="."]
78+
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, -26.3192, 1.2359, 38.0117 )
79+
80+
[node name="RigidBodyBox" type="RigidBody" parent="DynamicShapes"]
81+
82+
[node name="CollisionShape" type="CollisionShape" parent="DynamicShapes/RigidBodyBox"]
83+
shape = SubResource( 1 )
84+
85+
[node name="RigidBodyCapsule" type="RigidBody" parent="DynamicShapes"]
86+
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 2, 0, 0 )
87+
88+
[node name="CollisionShape" type="CollisionShape" parent="DynamicShapes/RigidBodyCapsule"]
89+
shape = SubResource( 2 )
90+
91+
[node name="RigidBodyCylinder" type="RigidBody" parent="DynamicShapes"]
92+
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 4, 0, 0 )
93+
script = ExtResource( 2 )
94+
95+
[node name="CollisionShape" type="CollisionShape" parent="DynamicShapes/RigidBodyCylinder"]
96+
shape = SubResource( 3 )
97+
98+
[node name="RigidBodyConvex" type="RigidBody" parent="DynamicShapes"]
99+
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 6, 0, 0 )
100+
101+
[node name="CollisionShape" type="CollisionShape" parent="DynamicShapes/RigidBodyConvex"]
102+
shape = SubResource( 4 )
103+
104+
[node name="RigidBodySphere" type="RigidBody" parent="DynamicShapes"]
105+
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 8, 0, 0 )
106+
107+
[node name="CollisionShape" type="CollisionShape" parent="DynamicShapes/RigidBodySphere"]
108+
shape = SubResource( 5 )
109+
110+
[node name="StaticBodyWalls" type="StaticBody" parent="."]
111+
112+
[node name="CollisionShape1" type="CollisionShape" parent="StaticBodyWalls"]
113+
transform = Transform( -1.62921e-05, 1, 0, -100, -1.62921e-07, 0, 0, 0, 100, -5, 0, 0 )
114+
shape = SubResource( 6 )
115+
116+
[node name="CollisionShape2" type="CollisionShape" parent="StaticBodyWalls"]
117+
transform = Transform( -1.62921e-05, -1, 0, 100, -1.62921e-07, 0, 0, 0, 100, 5, 0, 0 )
118+
shape = SubResource( 6 )
119+
120+
[node name="CollisionShape3" type="CollisionShape" parent="StaticBodyWalls"]
121+
transform = Transform( 2.65431e-12, 1.62921e-07, 100, 100, -1.62921e-07, 0, 1.62921e-05, 1, -1.62921e-05, 0, 0, -5 )
122+
shape = SubResource( 6 )
123+
124+
[node name="CollisionShape4" type="CollisionShape" parent="StaticBodyWalls"]
125+
transform = Transform( 2.65431e-12, 1.62921e-07, -100, 100, -1.62921e-07, 0, -1.62921e-05, -1, -1.62921e-05, 0, 0, 5 )
126+
shape = SubResource( 6 )
127+
128+
[node name="StaticScene" parent="." instance=ExtResource( 5 )]
129+
130+
[node name="Camera" type="Camera" parent="."]
131+
transform = Transform( 1, 0, 0, 0, 0.881757, 0.471705, 0, -0.471705, 0.881757, 0, 20.4125, 41.0426 )
132+
script = ExtResource( 3 )
133+
134+
[node name="OmniLight" type="OmniLight" parent="Camera"]
135+
omni_range = 80.0

0 commit comments

Comments
 (0)