Support for pause in 2D/3D physics tests

New controls for all tests:
P to toggle pause on/off

Affects the running tests but not menus.
This commit is contained in:
PouleyKetchoupp
2021-01-06 21:25:34 -07:00
parent ca4cde1c26
commit 3878948300
15 changed files with 106 additions and 23 deletions

View File

@@ -1,10 +1,11 @@
[gd_scene load_steps=10 format=2]
[gd_scene load_steps=11 format=2]
[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]
@@ -22,6 +23,7 @@ __meta__ = {
}
[node name="TestsMenu" type="MenuButton" parent="."]
pause_mode = 2
margin_left = 10.0
margin_top = 10.0
margin_right = 125.0
@@ -34,6 +36,7 @@ __meta__ = {
}
[node name="LabelControls" type="Label" parent="."]
pause_mode = 2
margin_left = 157.0
margin_top = 13.0
margin_right = 375.0
@@ -44,6 +47,7 @@ __meta__ = {
}
[node name="LabelFPS" type="Label" parent="."]
pause_mode = 2
anchor_top = 1.0
anchor_bottom = 1.0
margin_left = 10.0
@@ -57,6 +61,7 @@ __meta__ = {
}
[node name="LabelEngine" type="Label" parent="."]
pause_mode = 2
anchor_top = 1.0
anchor_bottom = 1.0
margin_left = 10.0
@@ -70,6 +75,7 @@ __meta__ = {
}
[node name="LabelVersion" type="Label" parent="."]
pause_mode = 2
anchor_top = 1.0
anchor_bottom = 1.0
margin_left = 10.0
@@ -83,6 +89,7 @@ __meta__ = {
}
[node name="LabelTest" type="Label" parent="."]
pause_mode = 2
anchor_top = 1.0
anchor_bottom = 1.0
margin_left = 10.0
@@ -95,7 +102,24 @@ __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
text = "PAUSED"
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

View File

@@ -67,6 +67,11 @@ restart_test={
"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,"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,"unicode":0,"echo":false,"script":null)
]
}
[rendering]

View File

@@ -8,13 +8,13 @@
[sub_resource type="BoxShape" id=1]
[sub_resource type="SphereShape" id=5]
[sub_resource type="SphereShape" id=2]
[sub_resource type="CapsuleShape" id=2]
[sub_resource type="CapsuleShape" id=3]
[sub_resource type="CylinderShape" id=3]
[sub_resource type="CylinderShape" id=4]
[sub_resource type="ConvexPolygonShape" 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 )
[node name="Test" type="Spatial"]
@@ -23,6 +23,7 @@ script = ExtResource( 2 )
[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
@@ -128,14 +129,14 @@ mode = 3
[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( 5 )
shape = SubResource( 2 )
[node name="RigidBodyCapsule" type="RigidBody" parent="Shapes"]
mode = 3
[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( 2 )
shape = SubResource( 3 )
[node name="RigidBodyCylinder" type="RigidBody" parent="Shapes"]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 3, 0, 0 )
@@ -144,7 +145,7 @@ script = ExtResource( 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( 3 )
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 )
@@ -152,7 +153,7 @@ mode = 3
[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( 4 )
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 )

View File

@@ -7,13 +7,13 @@
[sub_resource type="BoxShape" id=1]
[sub_resource type="SphereShape" id=5]
[sub_resource type="SphereShape" id=2]
[sub_resource type="CapsuleShape" id=2]
[sub_resource type="CapsuleShape" id=3]
[sub_resource type="CylinderShape" id=3]
[sub_resource type="CylinderShape" id=4]
[sub_resource type="ConvexPolygonShape" 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 )
[node name="Test" type="Spatial"]
@@ -36,14 +36,14 @@ mode = 3
[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( 5 )
shape = SubResource( 2 )
[node name="RigidBodyCapsule" type="RigidBody" parent="Shapes"]
mode = 3
[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( 2 )
shape = SubResource( 3 )
[node name="RigidBodyCylinder" type="RigidBody" parent="Shapes"]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 3, 0, 0 )
@@ -52,7 +52,7 @@ script = ExtResource( 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( 3 )
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 )
@@ -60,7 +60,7 @@ mode = 3
[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( 4 )
shape = SubResource( 5 )
[node name="StaticBodyHead" type="StaticBody" parent="Shapes"]
transform = Transform( 2, 0, 0, 0, 2, 0, 0, 0, 2, 0, -6, 3.93357 )

View File

@@ -3,6 +3,7 @@
[ext_resource path="res://utils/option_menu.gd" type="Script" id=1]
[node name="Options" type="MenuButton"]
pause_mode = 2
margin_left = 10.0
margin_top = 106.719
margin_right = 125.0

View File

@@ -0,0 +1,5 @@
extends Label
func _process(_delta):
visible = get_tree().paused

View File

@@ -11,6 +11,8 @@ var _engine = PhysicsEngine.OTHER
func _enter_tree():
pause_mode = Node.PAUSE_MODE_PROCESS
get_tree().debug_collisions_hint = true
var engine_string = ProjectSettings.get_setting("physics/3d/physics_engine")
@@ -37,6 +39,9 @@ func _process(_delta):
else:
Log.print_log("Debug Collision OFF")
if Input.is_action_just_pressed("toggle_pause"):
get_tree().paused = not get_tree().paused
if Input.is_action_just_pressed("exit"):
get_tree().quit()