Browse Source

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.
PouleyKetchoupp 4 years ago
parent
commit
3878948300

+ 26 - 2
2d/physics_tests/main.tscn

@@ -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,16 +36,18 @@ __meta__ = {
 }
 
 [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
-text = "R - RESTART / D - TOGGLE COLLISION / F - TOGGLE FULL SCREEN / ESC - QUIT"
+text = "P - TOGGLE PAUSE / R - RESTART / D - 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
@@ -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 = -20.0
+margin_top = -40.9695
+margin_right = 31.0
+margin_bottom = -26.9695
+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

+ 5 - 0
2d/physics_tests/project.godot

@@ -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]
 

+ 1 - 0
2d/physics_tests/tests/functional/test_collision_pairs.tscn

@@ -85,6 +85,7 @@ 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

+ 1 - 0
2d/physics_tests/tests/functional/test_one_way_collision.tscn

@@ -31,6 +31,7 @@ __meta__ = {
 [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

+ 4 - 4
2d/physics_tests/tests/functional/test_raycasting.tscn

@@ -6,10 +6,10 @@
 [sub_resource type="RectangleShape2D" id=1]
 extents = Vector2( 40, 60 )
 
-[sub_resource type="CircleShape2D" id=3]
+[sub_resource type="CircleShape2D" id=2]
 radius = 60.0
 
-[sub_resource type="CapsuleShape2D" id=2]
+[sub_resource type="CapsuleShape2D" id=3]
 radius = 30.0
 height = 50.0
 
@@ -37,7 +37,7 @@ position = Vector2( 314.894, 257.658 )
 mode = 1
 
 [node name="CollisionShape2D" type="CollisionShape2D" parent="Shapes/RigidBodySphere"]
-shape = SubResource( 3 )
+shape = SubResource( 2 )
 
 [node name="RigidBodyCapsule" type="RigidBody2D" parent="Shapes"]
 position = Vector2( 465.629, 261.204 )
@@ -46,7 +46,7 @@ mode = 1
 [node name="CollisionShape2D" type="CollisionShape2D" parent="Shapes/RigidBodyCapsule"]
 rotation = -0.202458
 scale = Vector2( 1.2, 1.2 )
-shape = SubResource( 2 )
+shape = SubResource( 3 )
 
 [node name="RigidBodyConvexPolygon" type="RigidBody2D" parent="Shapes"]
 position = Vector2( 613.385, 252.771 )

+ 1 - 0
2d/physics_tests/tests/test_options.tscn

@@ -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

+ 5 - 0
2d/physics_tests/utils/label_pause.gd

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

+ 5 - 0
2d/physics_tests/utils/system.gd

@@ -10,6 +10,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/2d/physics_engine")
@@ -34,6 +36,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()
 

+ 25 - 1
3d/physics_tests/main.tscn

@@ -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

+ 5 - 0
3d/physics_tests/project.godot

@@ -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]
 

+ 9 - 8
3d/physics_tests/tests/functional/test_collision_pairs.tscn

@@ -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 )

+ 8 - 8
3d/physics_tests/tests/functional/test_raycasting.tscn

@@ -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 )

+ 1 - 0
3d/physics_tests/tests/test_options.tscn

@@ -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

+ 5 - 0
3d/physics_tests/utils/label_pause.gd

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

+ 5 - 0
3d/physics_tests/utils/system.gd

@@ -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()