Skip to content

Commit

Permalink
Add extended physics tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
fire committed Jul 3, 2020
1 parent d3317cc commit 297a40b
Show file tree
Hide file tree
Showing 4 changed files with 165 additions and 21 deletions.
4 changes: 4 additions & 0 deletions 3d/physics_tests/tests.gd
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ var _tests = [
"id" : "Performance Tests/Contacts",
"path" : "res://tests/performance/test_perf_contacts.tscn",
},
{
"id" : "Performance Tests/Contacts Extended",
"path" : "res://tests/performance/test_perf_contacts_extended.tscn",
},
]


Expand Down
45 changes: 25 additions & 20 deletions 3d/physics_tests/tests/performance/test_perf_contacts.gd
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@ const OPTION_TYPE_CAPSULE = "Shape type/Capsule"
const OPTION_TYPE_CYLINDER = "Shape type/Cylinder"
const OPTION_TYPE_CONVEX = "Shape type/Convex"
const OPTION_TYPE_SPHERE = "Shape type/Sphere"
export(Array) var spawns = Array()

export(int) var spawn_count = 1
export(int) var spawn_count = 100
export(int, 1, 10) var spawn_multipiler = 5

var _object_templates = []

Expand Down Expand Up @@ -116,14 +118,16 @@ func _start_all_types():

func _spawn_objects(type_index):
var template_node = _object_templates[type_index]
var spawn_parent = $SpawnTarget

Log.print_log("* Spawning: " + template_node.name)

for node_index in spawn_count:
var node = template_node.duplicate() as Spatial
node.transform = Transform.IDENTITY
spawn_parent.add_child(node)
for spawn in spawns:
var spawn_parent = get_node(spawn)

Log.print_log("* Spawning: " + template_node.name)

for _index in range(spawn_multipiler):
for _node_index in spawn_count / spawn_multipiler:
var node = template_node.duplicate() as Spatial
var transform = Transform.IDENTITY
spawn_parent.add_child(node)


func _activate_objects():
Expand All @@ -137,15 +141,16 @@ func _activate_objects():


func _despawn_objects():
var spawn_parent = $SpawnTarget
for spawn in spawns:
var spawn_parent = get_node(spawn)

if spawn_parent.get_child_count() == 0:
return

Log.print_log("* Despawning")

while spawn_parent.get_child_count():
var node_index = spawn_parent.get_child_count() - 1
var node = spawn_parent.get_child(node_index)
spawn_parent.remove_child(node)
node.queue_free()
if spawn_parent.get_child_count() == 0:
return
Log.print_log("* Despawning")
while spawn_parent.get_child_count():
var node_index = spawn_parent.get_child_count() - 1
var node = spawn_parent.get_child(node_index)
spawn_parent.remove_child(node)
node.queue_free()
2 changes: 1 addition & 1 deletion 3d/physics_tests/tests/performance/test_perf_contacts.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ data = PoolVector3Array( -1, 0, 1, 1, 0, -1, 1, 0, 1, -1, 0, 1, -1, 0, -1, 1, 0,

[node name="Test" type="Spatial"]
script = ExtResource( 2 )
spawn_count = 100
spawns = [ "SpawnTarget" ]

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

Expand Down
135 changes: 135 additions & 0 deletions 3d/physics_tests/tests/performance/test_perf_contacts_extended.tscn
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
[gd_scene load_steps=12 format=2]

[ext_resource path="res://tests/performance/test_perf_contacts.gd" type="Script" id=1]
[ext_resource path="res://utils/exception_cylinder.gd" type="Script" id=2]
[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]

[sub_resource type="BoxShape" id=1]

[sub_resource type="CapsuleShape" id=2]

[sub_resource type="CylinderShape" 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="SphereShape" id=5]

[sub_resource type="ConcavePolygonShape" id=6]
data = PoolVector3Array( -1, 0, 1, 1, 0, -1, 1, 0, 1, -1, 0, 1, -1, 0, -1, 1, 0, -1 )

[node name="Test" type="Spatial"]
script = ExtResource( 1 )
spawns = [ "SpawnTarget", "SpawnTarget2", "SpawnTarget3", "SpawnTarget4", "SpawnTarget5", "SpawnTarget6", "SpawnTarget7", "SpawnTarget8", "SpawnTarget9", "SpawnTarget10", "SpawnTarget11", "SpawnTarget12", "SpawnTarget13", "SpawnTarget14", "SpawnTarget15", "SpawnTarget16" ]

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

[node name="SpawnTarget" type="Spatial" parent="."]
transform = Transform( 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="SpawnTarget3" type="Spatial" parent="."]
transform = Transform( 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="SpawnTarget5" type="Spatial" parent="."]
transform = Transform( 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="SpawnTarget7" type="Spatial" parent="."]
transform = Transform( 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="SpawnTarget9" type="Spatial" parent="."]
transform = Transform( 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="SpawnTarget11" type="Spatial" parent="."]
transform = Transform( 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="SpawnTarget13" type="Spatial" parent="."]
transform = Transform( 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="SpawnTarget15" type="Spatial" parent="."]
transform = Transform( 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="DynamicShapes" type="Spatial" parent="."]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, -26.3192, 1.2359, 38.0117 )

[node name="RigidBodyBox" type="RigidBody" parent="DynamicShapes"]

[node name="CollisionShape" type="CollisionShape" 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="CollisionShape" type="CollisionShape" 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 )
script = ExtResource( 2 )

[node name="CollisionShape" type="CollisionShape" 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="CollisionShape" type="CollisionShape" 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="CollisionShape" type="CollisionShape" parent="DynamicShapes/RigidBodySphere"]
shape = SubResource( 5 )

[node name="StaticBodyWalls" type="StaticBody" parent="."]

[node name="CollisionShape1" type="CollisionShape" parent="StaticBodyWalls"]
transform = Transform( -1.62921e-05, 1, 0, -100, -1.62921e-07, 0, 0, 0, 100, -5, 0, 0 )
shape = SubResource( 6 )

[node name="CollisionShape2" type="CollisionShape" parent="StaticBodyWalls"]
transform = Transform( -1.62921e-05, -1, 0, 100, -1.62921e-07, 0, 0, 0, 100, 5, 0, 0 )
shape = SubResource( 6 )

[node name="CollisionShape3" type="CollisionShape" parent="StaticBodyWalls"]
transform = Transform( 2.65431e-12, 1.62921e-07, 100, 100, -1.62921e-07, 0, 1.62921e-05, 1, -1.62921e-05, 0, 0, -5 )
shape = SubResource( 6 )

[node name="CollisionShape4" type="CollisionShape" parent="StaticBodyWalls"]
transform = Transform( 2.65431e-12, 1.62921e-07, -100, 100, -1.62921e-07, 0, -1.62921e-05, -1, -1.62921e-05, 0, 0, 5 )
shape = SubResource( 6 )

[node name="StaticScene" parent="." instance=ExtResource( 5 )]

[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="OmniLight" type="OmniLight" parent="Camera"]
omni_range = 80.0

0 comments on commit 297a40b

Please sign in to comment.