Skip to content

Commit

Permalink
Merge pull request #473 from nekomatata/physics-tests
Browse files Browse the repository at this point in the history
Add Physics Tests project
  • Loading branch information
aaronfranke authored Jun 19, 2020
2 parents 3ea2246 + afd99e5 commit d3317cc
Show file tree
Hide file tree
Showing 33 changed files with 1,384 additions and 0 deletions.
18 changes: 18 additions & 0 deletions 3d/physics_tests/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# 3D Physics Tests

This demo contains a series of tests for the 3D
physics engine.

They can be used for different purpose:
- Functional tests to check for regressions and
compare the behavior between physics engines
- Performance tests to evaluate and compare
performance between physics engines

Language: GDScript

Renderer: GLES 2

## Screenshots

![Screenshot](screenshots/screenshot.png)
Binary file not shown.

Large diffs are not rendered by default.

11 changes: 11 additions & 0 deletions 3d/physics_tests/assets/robot_head/readme.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
- Robot Head model created by James Redmond (fracteed) 2018

- http://www.fracteed.com/godot.html

- created with Godot 3.0.5

- models created using Blender 2.79 and Sunstance Painter/Designer

- Creative Commons License CC-BY:
"This license lets others distribute, remix, tweak, and build upon your work, even commercially, as long as they credit you for the original creation.
This is the most accommodating of licenses offered. Recommended for maximum dissemination and use of licensed materials."
3 changes: 3 additions & 0 deletions 3d/physics_tests/default_env.tres
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[gd_resource type="Environment" format=2]

[resource]
Binary file added 3d/physics_tests/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
34 changes: 34 additions & 0 deletions 3d/physics_tests/icon.png.import
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
[remap]

importer="texture"
type="StreamTexture"
path="res://.import/icon.png-487276ed1e3a0c39cad0279d744ee560.stex"
metadata={
"vram_texture": false
}

[deps]

source_file="res://icon.png"
dest_files=[ "res://.import/icon.png-487276ed1e3a0c39cad0279d744ee560.stex" ]

[params]

compress/mode=0
compress/lossy_quality=0.7
compress/hdr_mode=0
compress/bptc_ldr=0
compress/normal_map=0
flags/repeat=0
flags/filter=true
flags/mipmaps=false
flags/anisotropic=false
flags/srgb=2
process/fix_alpha_border=true
process/premult_alpha=false
process/HDR_as_SRGB=false
process/invert_color=false
stream=false
size_limit=0
detect_3d=true
svg/scale=1.0
174 changes: 174 additions & 0 deletions 3d/physics_tests/main.tscn
Original file line number Diff line number Diff line change
@@ -0,0 +1,174 @@
[gd_scene load_steps=10 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/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]

[sub_resource type="StyleBoxFlat" id=1]
bg_color = Color( 0, 0, 0, 0.176471 )

[node name="Main" type="Control"]
anchor_right = 1.0
anchor_bottom = 1.0
mouse_filter = 2
script = ExtResource( 12 )
__meta__ = {
"_edit_use_anchors_": false
}

[node name="TestsMenu" type="MenuButton" parent="."]
margin_left = 10.0
margin_top = 10.0
margin_right = 125.0
margin_bottom = 30.0
text = "TESTS"
flat = false
script = ExtResource( 4 )
__meta__ = {
"_edit_use_anchors_": false
}

[node name="LabelControls" type="Label" parent="."]
margin_left = 157.0
margin_top = 13.0
margin_right = 375.0
margin_bottom = 27.0
text = "R - RESTART / D - TOGGLE COLLISION / F - TOGGLE FULL SCREEN / ESC - QUIT"
__meta__ = {
"_edit_use_anchors_": false
}

[node name="LabelFPS" type="Label" parent="."]
anchor_top = 1.0
anchor_bottom = 1.0
margin_left = 10.0
margin_top = -19.0
margin_right = 50.0
margin_bottom = -5.0
text = "FPS: 0"
script = ExtResource( 1 )
__meta__ = {
"_edit_use_anchors_": false
}

[node name="LabelEngine" type="Label" parent="."]
anchor_top = 1.0
anchor_bottom = 1.0
margin_left = 10.0
margin_top = -39.0
margin_right = 50.0
margin_bottom = -25.0
text = "Physics engine:"
script = ExtResource( 3 )
__meta__ = {
"_edit_use_anchors_": false
}

[node name="LabelVersion" type="Label" parent="."]
anchor_top = 1.0
anchor_bottom = 1.0
margin_left = 10.0
margin_top = -59.0
margin_right = 50.0
margin_bottom = -45.0
text = "Godot Version:"
script = ExtResource( 2 )
__meta__ = {
"_edit_use_anchors_": false
}

[node name="LabelTest" type="Label" parent="."]
anchor_top = 1.0
anchor_bottom = 1.0
margin_left = 10.0
margin_top = -79.0
margin_right = 50.0
margin_bottom = -65.0
text = "Test:"
script = ExtResource( 5 )
__meta__ = {
"_edit_use_anchors_": false
}

[node name="PanelLog" type="Panel" parent="."]
anchor_left = 1.0
anchor_top = 1.0
anchor_right = 1.0
anchor_bottom = 1.0
margin_left = -428.0
margin_top = -125.0
custom_styles/panel = SubResource( 1 )
__meta__ = {
"_edit_use_anchors_": false
}

[node name="ButtonClear" type="Button" parent="PanelLog"]
anchor_left = 1.0
anchor_top = 1.0
anchor_right = 1.0
anchor_bottom = 1.0
margin_left = -48.0
margin_top = -25.0
margin_right = -5.0
margin_bottom = -5.0
focus_mode = 0
enabled_focus_mode = 0
text = "clear"
__meta__ = {
"_edit_use_anchors_": false
}

[node name="CheckBoxScroll" type="CheckBox" parent="PanelLog"]
anchor_left = 1.0
anchor_top = 1.0
anchor_right = 1.0
anchor_bottom = 1.0
margin_left = -150.0
margin_top = -27.0
margin_right = -54.0
margin_bottom = -3.0
focus_mode = 0
pressed = true
enabled_focus_mode = 0
text = "auto-scroll"
__meta__ = {
"_edit_use_anchors_": false
}

[node name="ScrollLog" type="ScrollContainer" parent="PanelLog"]
margin_left = 10.0
margin_top = 5.0
margin_right = 418.0
margin_bottom = 94.0
scroll_horizontal_enabled = false
script = ExtResource( 11 )
__meta__ = {
"_edit_use_anchors_": false
}
auto_scroll = true

[node name="VBoxLog" type="VBoxContainer" parent="PanelLog/ScrollLog"]
margin_right = 408.0
margin_bottom = 89.0
size_flags_horizontal = 3
size_flags_vertical = 3
alignment = 2
script = ExtResource( 10 )

[node name="LabelLog" type="Label" parent="PanelLog/ScrollLog/VBoxLog"]
margin_top = 75.0
margin_right = 408.0
margin_bottom = 89.0
text = "Log start"
valign = 2
max_lines_visible = 5
__meta__ = {
"_edit_use_anchors_": false
}
[connection signal="pressed" from="PanelLog/ButtonClear" to="PanelLog/ScrollLog/VBoxLog" method="clear"]
[connection signal="toggled" from="PanelLog/CheckBoxScroll" to="PanelLog/ScrollLog" method="set_auto_scroll"]
68 changes: 68 additions & 0 deletions 3d/physics_tests/project.godot
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
; Engine configuration file.
; It's best edited using the editor UI and not directly,
; since the parameters that go here are not all obvious.
;
; Format:
; [section] ; section goes between []
; param=value ; assign values to parameters

config_version=4

_global_script_classes=[ {
"base": "MenuButton",
"class": "OptionMenu",
"language": "GDScript",
"path": "res://utils/option_menu.gd"
}, {
"base": "Node",
"class": "Test",
"language": "GDScript",
"path": "res://test.gd"
} ]
_global_script_class_icons={
"OptionMenu": "",
"Test": ""
}

[application]

config/name="Physics Tests"
run/main_scene="res://main.tscn"
config/icon="res://icon.png"

[autoload]

Log="*res://utils/system_log.gd"
System="*res://utils/system.gd"

[debug]

gdscript/warnings/return_value_discarded=false

[input]

toggle_full_screen={
"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":70,"unicode":0,"echo":false,"script":null)
]
}
exit={
"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":16777217,"unicode":0,"echo":false,"script":null)
]
}
toggle_debug_collision={
"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":68,"unicode":0,"echo":false,"script":null)
]
}
restart_test={
"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":82,"unicode":0,"echo":false,"script":null)
]
}

[rendering]

quality/driver/driver_name="GLES2"
environment/default_environment="res://default_env.tres"
Empty file.
Binary file added 3d/physics_tests/screenshots/screenshot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
36 changes: 36 additions & 0 deletions 3d/physics_tests/test.gd
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
class_name Test
extends Node


var _timer
var _timer_started = false


func start_timer(timeout):
if _timer == null:
_timer = Timer.new()
_timer.one_shot = true
add_child(_timer)
_timer.connect("timeout", self, "_on_timer_done")
else:
cancel_timer()

_timer.start(timeout)
_timer_started = true

return _timer


func cancel_timer():
if _timer_started:
_timer.paused = true
_timer.emit_signal("timeout")
_timer.paused = false


func is_timer_canceled():
return _timer.paused


func _on_timer_done():
_timer_started = false
27 changes: 27 additions & 0 deletions 3d/physics_tests/tests.gd
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
extends Node


var _tests = [
{
"id" : "Functional Tests/Shapes",
"path" : "res://tests/functional/test_shapes.tscn",
},
{
"id" : "Functional Tests/Compound Shapes",
"path" : "res://tests/functional/test_compound_shapes.tscn",
},
{
"id" : "Functional Tests/Friction",
"path" : "res://tests/functional/test_friction.tscn",
},
{
"id" : "Performance Tests/Contacts",
"path" : "res://tests/performance/test_perf_contacts.tscn",
},
]


func _ready():
var test_menu = $TestsMenu
for test in _tests:
test_menu.add_test(test.id, test.path)
Loading

0 comments on commit d3317cc

Please sign in to comment.