Compare commits

..

36 Commits

Author SHA1 Message Date
Agnis "NeZvērs" Aldiņš
2d4d23302a 3D physics tests - Moving platform (#623) 2021-06-09 20:57:49 -04:00
Aaron Franke
4456027f91 Merge pull request #625 from aaronfranke/3d2d-robot
Simplify 3D robot in the 3D in 2D demo
2021-06-07 09:40:49 -04:00
Aaron Franke
19312b2899 Simplify 3D robot in the 3D in 2D demo 2021-06-06 23:28:53 -04:00
Aaron Franke
ca17967de1 Merge pull request #622 from aaronfranke/waypoint-camera-current
Have waypoints check if the camera is current
2021-05-29 03:19:57 -04:00
Aaron Franke
491fb265b1 Have waypoints check if the camera is current
If not, get the current camera.
2021-05-29 03:16:07 -04:00
Agnis "NeZvērs" Aldiņš
08be1b7f03 Additional 3D physics tests - RigidBody impact and ground check (#619)
Co-authored-by: Camille Mohr-Daurat <pouleyKetchoup@gmail.com>
2021-05-29 02:58:01 -04:00
Aaron Franke
4ef90a836a Merge pull request #621 from nellodotca/master
Fixed project settings to match tutorial
2021-05-24 21:09:43 -04:00
nello
bfd903a933 Fixed project settings to match tutorial 2021-05-24 19:14:12 -03:00
Aaron Franke
e0db0b8f6d Merge pull request #615 from nekomatata/physics-tests-draw-shape-clean
Fix hack to draw shapes in 3D physics tests
2021-05-19 15:45:22 -04:00
PouleyKetchoupp
4d21951b71 Fix hack to draw shapes in 3D physics tests
Using Shape::get_debug_mesh instead of the previous hack to draw a mesh
instance based on a collision shape.
2021-05-05 13:41:51 -07:00
Aaron Franke
7656c08454 Merge pull request #614 from aaronfranke/gridmap-perf
Improve performance in GridMap demos by adjusting octant size
2021-05-04 15:22:10 -04:00
Aaron Franke
e894e4655a Improve performance in GridMap demos 2021-05-04 02:48:32 -04:00
Aaron Franke
2ce76ff4e5 Update web deploy CI to use Godot 3.3 2021-04-24 04:20:39 -04:00
Aaron Franke
e5d829eb8f Merge pull request #613 from nekomatata/physics-tests-contacts-update
Update contact tests in physics tests for 2D & 3D
2021-04-24 02:32:19 -05:00
PouleyKetchoupp
7f025e000e Update contact tests in physics tests for 2D & 3D
- Create bodies by duplicating the ones from the scene to allow custom
settings on them for testing purpose
- Rename 3D test with multiple groups of bodies "Contact Islands"
instead of "Contacts Extended" for clarity
- Added "Contact Islands" test for 2D
- Fixed log spamming with "Contact Islands" tests due to printing log
messages for each group of bodies
- Added parameter to randomize spawn positions in order to make
contact separation more balanced (avoids artifacts like a huge column
for circles in 2D test)
- Using smaller shapes and larger amount of objects by default to test
more extreme case
2021-04-21 18:25:35 -07:00
Aaron Franke
5132941a84 Merge pull request #612 from nekomatata/physics-tests-3.3
Physics Tests 3.3 update
2021-04-21 19:51:44 -05:00
PouleyKetchoupp
ef265cca0a Physics Tests 3.3 update
Fix custom collision shape drawing in physics tests:
CollisionShape debug draw has changed in 3.3 and now requires a body
to be rendered, so the trick to display custom physics shapes in the
physics tests had to be updated.

Cylinder support:
Now cylinders are supported in Godot Physics, so the exception to avoid
spamming errors when cylinders are used can be removed.

Rigid body picking:
Added mouse-picking to Test Shapes in both 2D and 3D.
2021-04-21 16:50:33 -07:00
Aaron Franke
31bb09233b Update the OS test demo for Godot 3.3 2021-04-21 19:30:53 -04:00
Aaron Franke
57f5e0835d Merge pull request #558 from aaronfranke/update-3.2.4
Update projects to Godot 3.3
2021-04-21 18:20:01 -05:00
Aaron Franke
814909538f Update projects to Godot 3.3 2021-04-21 19:17:12 -04:00
Rémi Verschelde
94ec2ea5d9 Merge pull request #607 from aaronfranke/3.2-readme
Update README for the new 3.2 branch
2021-04-21 09:57:08 +02:00
Aaron Franke
40aec7c068 Update README for the new 3.2 branch 2021-04-14 13:46:19 -04:00
Aaron Franke
ead2777f48 Merge pull request #606 from nekomatata/physics-tests-contacts-update
Updated 2d/3d physics contact performance tests
2021-04-14 12:34:24 -05:00
PouleyKetchoupp
0a0d44d4f1 Updated 2d/3d physics contact performance tests 2021-04-14 08:19:10 -07:00
Aaron Franke
4911866f3d Merge pull request #604 from waimus/os_midi_scan_fix
Fix MIDI devices scanning
2021-04-05 16:51:00 -04:00
waimus
d7e1052205 Fix MIDI devices scanning 2021-04-06 03:10:33 +07:00
Aaron Franke
8e2dbf3f55 Merge pull request #602 from aaronfranke/etc
Use ETC instead of ETC2 for all GLES2 demos
2021-03-30 02:31:43 -04:00
Aaron Franke
2ee9b47f6c Use ETC instead of ETC2 for all GLES2 demos 2021-03-29 18:30:14 -04:00
Aaron Franke
d8dc94c1ff Merge pull request #601 from aaronfranke/ternary-volume
Use fewer ternary operators and decrease volume of Platformer 2D
2021-03-29 18:29:28 -04:00
Aaron Franke
d989bf6209 Use fewer ternary operators and decrease volume of Platformer 2D 2021-03-28 22:03:03 -04:00
Aaron Franke
021070215c Merge pull request #595 from dalexeev/bullet-shower-improve
Small improvement for Bullet Shower Demo
2021-03-26 20:20:31 -07:00
Aaron Franke
ac61cba05b Merge pull request #597 from aaronfranke/joy-24
Handle up to 24 joypad buttons in the Joypads demo
2021-03-15 04:34:12 -04:00
Aaron Franke
21e829416f Handle up to 24 joypad buttons in the Joypads demo 2021-03-13 23:28:22 -04:00
Danil Alexeev
cf7e4b31f4 Small improvement for Bullet Shower Demo 2021-03-13 21:04:13 +03:00
Aaron Franke
dc5c1016ce Merge pull request #594 from aaronfranke/assetlib-5c154da
Add links to the Asset Library after release 3.2-5c154da
2021-03-11 21:56:54 -08:00
Aaron Franke
8a0824a948 Add links to the Asset Library after release 3.2-5c154da
Also expand the CODEOWNERS file
2021-03-12 00:32:11 -05:00
261 changed files with 1603 additions and 905 deletions

View File

@@ -2,10 +2,15 @@
root = true
# Unix-style newlines with a newline ending every file.
[*.cs]
[*]
charset = utf-8
end_of_line = lf
insert_final_newline = true
[*.cs]
csharp_space_after_cast = false
indent_size = 4
[*.csproj]
insert_final_newline = false
indent_size = 2

13
.github/CODEOWNERS vendored
View File

@@ -2,7 +2,12 @@
# Each line is a file pattern followed by one or more owners.
# Owners can be @users, @org/teams or emails
/misc/2.5d @aaronfranke
/mono/2.5d @aaronfranke
/2d/physics_tests @pouleyKetchoupp
/3d/physics_tests @pouleyKetchoupp
/.github/dist/ @Calinou
/3d/voxel/ @aaronfranke
/misc/matrix_transform/ @aaronfranke
/misc/2.5d/ @aaronfranke
/mono/2.5d/ @aaronfranke
/2d/physics_tests/ @pouleyKetchoupp
/3d/physics_tests/ @pouleyKetchoupp

View File

@@ -1,9 +1,9 @@
---
name: Bug Report
about: Report a bug with one of the demo projects.
title: ''
title: ""
labels: bug
assignees: ''
assignees: ""
---

View File

@@ -1,9 +1,9 @@
---
name: Feature / Enhancement Request
about: Adding new features or improving existing ones.
title: ''
title: ""
labels: enhancement
assignees: ''
assignees: ""
---

View File

@@ -5,14 +5,14 @@ on:
- master
env:
GODOT_VERSION: 3.2.3
GODOT_VERSION: 3.3
jobs:
export-html5:
name: Export projects to HTML5 and deploy to GitHub Pages
runs-on: ubuntu-20.04
container:
image: barichello/godot-ci:3.2.3
image: barichello/godot-ci:3.3
steps:
- name: Checkout
uses: actions/checkout@v2.3.4

View File

@@ -11,6 +11,8 @@ Language: GDScript
Renderer: GLES 2
Check out this demo on the asset library: https://godotengine.org/asset-library/asset/887
## Screenshots
![No collision](screenshots/no_collision.png)

View File

@@ -52,22 +52,25 @@ func _ready():
bullets.push_back(bullet)
func _process(delta):
func _process(_delta):
# Order the CanvasItem to update every frame.
update()
func _physics_process(delta):
var transform2d = Transform2D()
var offset = get_viewport_rect().size.x + 16
for bullet in bullets:
bullet.position.x -= bullet.speed * delta
if bullet.position.x < -16:
# The bullet has left the screen; move it back to the right.
bullet.position.x = get_viewport_rect().size.x + 16
bullet.position.x = offset
transform2d.origin = bullet.position
Physics2DServer.body_set_state(bullet.body, Physics2DServer.BODY_STATE_TRANSFORM, transform2d)
# Order the CanvasItem to update since bullets are moving every frame.
update()
# Instead of drawing each bullet individually in a script attached to each bullet,
# we are drawing *all* the bullets at once here.

View File

@@ -29,5 +29,6 @@ frames = SubResource( 1 )
[node name="CollisionShape2D" type="CollisionShape2D" parent="Player"]
shape = SubResource( 2 )
[connection signal="body_shape_entered" from="Player" to="Player" method="_on_body_shape_entered"]
[connection signal="body_shape_exited" from="Player" to="Player" method="_on_body_shape_exited"]

View File

@@ -53,5 +53,6 @@ text = "Start"
[node name="MessageTimer" type="Timer" parent="."]
one_shot = true
[connection signal="pressed" from="StartButton" to="." method="_on_StartButton_pressed"]
[connection signal="timeout" from="MessageTimer" to="." method="_on_MessageTimer_timeout"]

View File

@@ -47,6 +47,7 @@ stream = ExtResource( 5 )
[node name="DeathSound" type="AudioStreamPlayer" parent="."]
stream = ExtResource( 6 )
[connection signal="hit" from="Player" to="." method="game_over"]
[connection signal="timeout" from="MobTimer" to="." method="_on_MobTimer_timeout"]
[connection signal="timeout" from="ScoreTimer" to="." method="_on_ScoreTimer_timeout"]

View File

@@ -50,4 +50,5 @@ rotation = 1.5708
shape = SubResource( 2 )
[node name="VisibilityNotifier2D" type="VisibilityNotifier2D" parent="."]
[connection signal="screen_exited" from="VisibilityNotifier2D" to="." method="_on_VisibilityNotifier2D_screen_exited"]

View File

@@ -67,4 +67,5 @@ speed_scale = 2.0
local_coords = false
process_material = SubResource( 7 )
texture = ExtResource( 2 )
[connection signal="body_entered" from="." to="." method="_on_Player_body_entered"]

View File

@@ -8,11 +8,6 @@
config_version=4
_global_script_classes=[ ]
_global_script_class_icons={
}
[application]
config/name="Dodge the Creeps"
@@ -29,6 +24,8 @@ config/icon="res://icon.png"
window/size/width=480
window/size/height=720
window/stretch/mode="2d"
window/stretch/aspect="keep"
[input]

View File

@@ -115,6 +115,7 @@ align = 1
valign = 1
uppercase = true
script = ExtResource( 15 )
[connection signal="state_changed" from="StateMachine" to="BodyPivot/WeaponPivot/Offset/Sword" method="_on_StateMachine_state_changed"]
[connection signal="state_changed" from="StateMachine" to="StateNameDisplayer" method="_on_StateMachine_state_changed"]
[connection signal="animation_finished" from="AnimationPlayer" to="StateMachine" method="_on_animation_finished"]

View File

@@ -19,7 +19,10 @@ var height = 0.0
func initialize(speed, velocity):
horizontal_speed = speed
max_horizontal_speed = speed if speed > 0.0 else base_max_horizontal_speed
if speed > 0.0:
max_horizontal_speed = speed
else:
max_horizontal_speed = base_max_horizontal_speed
enter_velocity = velocity
@@ -27,7 +30,10 @@ func enter():
var input_direction = get_input_direction()
update_look_direction(input_direction)
horizontal_velocity = enter_velocity if input_direction else Vector2()
if input_direction:
horizontal_velocity = enter_velocity
else:
horizontal_velocity = Vector2()
vertical_speed = 600.0
owner.get_node("AnimationPlayer").play("idle")

View File

@@ -22,7 +22,11 @@ func update(_delta):
emit_signal("finished", "idle")
update_look_direction(input_direction)
speed = max_run_speed if Input.is_action_pressed("run") else max_walk_speed
if Input.is_action_pressed("run"):
speed = max_run_speed
else:
speed = max_walk_speed
var collision_info = move(speed, input_direction)
if not collision_info:
return

View File

@@ -8,11 +8,6 @@
config_version=4
_global_script_classes=[ ]
_global_script_class_icons={
}
[application]
config/name="Hierarchical Finite State Machine"
@@ -102,3 +97,5 @@ attack={
[rendering]
quality/driver/driver_name="GLES2"
vram_compression/import_etc=true
vram_compression/import_etc2=false

View File

@@ -8,11 +8,6 @@
config_version=4
_global_script_classes=[ ]
_global_script_class_icons={
}
[application]
config/name="GD Paint"
@@ -37,3 +32,5 @@ singletons=[ ]
[rendering]
quality/driver/driver_name="GLES2"
vram_compression/import_etc=true
vram_compression/import_etc2=false

View File

@@ -8,11 +8,6 @@
config_version=4
_global_script_classes=[ ]
_global_script_class_icons={
}
[application]
config/name="HDR for 2D"

View File

@@ -8,11 +8,6 @@
config_version=4
_global_script_classes=[ ]
_global_script_class_icons={
}
[application]
config/name="Hexagonal Game"
@@ -68,4 +63,6 @@ move_up={
[rendering]
quality/driver/driver_name="GLES2"
vram_compression/import_etc=true
vram_compression/import_etc2=false
environment/default_clear_color=Color( 0.172549, 0.219608, 0.129412, 1 )

View File

@@ -8,11 +8,6 @@
config_version=4
_global_script_classes=[ ]
_global_script_class_icons={
}
[application]
config/name="Scene Instancing Demo"
@@ -39,4 +34,6 @@ singletons=[ ]
[rendering]
quality/driver/driver_name="GLES2"
vram_compression/import_etc=true
vram_compression/import_etc2=false
environment/default_clear_color=Color( 0.301961, 0.301961, 0.301961, 1 )

View File

@@ -8,11 +8,6 @@
config_version=4
_global_script_classes=[ ]
_global_script_class_icons={
}
[application]
config/name="Isometric Game"
@@ -80,4 +75,6 @@ use_pixel_snap=true
[rendering]
quality/driver/driver_name="GLES2"
vram_compression/import_etc=true
vram_compression/import_etc2=false
environment/default_clear_color=Color( 0.0784314, 0.105882, 0.145098, 1 )

View File

@@ -8,11 +8,6 @@
config_version=4
_global_script_classes=[ ]
_global_script_class_icons={
}
[application]
config/name="Kinematic Character 2D"
@@ -76,4 +71,6 @@ multithread/thread_rid_pool_prealloc=60
[rendering]
quality/driver/driver_name="GLES2"
vram_compression/import_etc=true
vram_compression/import_etc2=false
environment/default_clear_color=Color( 0.156, 0.1325, 0.25, 1 )

View File

@@ -266,4 +266,5 @@ shape = SubResource( 12 )
[node name="Camera2D" type="Camera2D" parent="."]
offset = Vector2( 265, 247 )
current = true
[connection signal="body_entered" from="Princess" to="Princess" method="_on_body_entered"]

View File

@@ -8,11 +8,6 @@
config_version=4
_global_script_classes=[ ]
_global_script_class_icons={
}
[application]
config/name="2D Lights as Mask"
@@ -37,3 +32,5 @@ shadow_filter=3
[rendering]
quality/driver/driver_name="GLES2"
vram_compression/import_etc=true
vram_compression/import_etc2=false

View File

@@ -8,11 +8,6 @@
config_version=4
_global_script_classes=[ ]
_global_script_class_icons={
}
[application]
config/name="2D Lights and Shadows"
@@ -41,3 +36,5 @@ shadow_filter=2
[rendering]
quality/driver/driver_name="GLES2"
vram_compression/import_etc=true
vram_compression/import_etc2=false

View File

@@ -8,11 +8,6 @@
config_version=4
_global_script_classes=[ ]
_global_script_class_icons={
}
[application]
config/name="Navigation Polygon 2D"
@@ -46,4 +41,6 @@ click={
[rendering]
quality/driver/driver_name="GLES2"
vram_compression/import_etc=true
vram_compression/import_etc2=false
environment/default_clear_color=Color( 0.160784, 0.172549, 0.278431, 1 )

View File

@@ -8,11 +8,6 @@
config_version=4
_global_script_classes=[ ]
_global_script_class_icons={
}
[application]
config/name="Grid-based Pathfinding with Astar"
@@ -38,3 +33,5 @@ click={
[rendering]
quality/driver/driver_name="GLES2"
vram_compression/import_etc=true
vram_compression/import_etc2=false

View File

@@ -8,11 +8,6 @@
config_version=4
_global_script_classes=[ ]
_global_script_class_icons={
}
[application]
config/name="2D Particles"

View File

@@ -142,4 +142,5 @@ texture = ExtResource( 4 )
[node name="Enabler" type="VisibilityEnabler2D" parent="."]
rect = Rect2( -5, -5, 10, 10 )
pause_particles = false
[connection signal="body_entered" from="." to="." method="_on_body_enter"]

View File

@@ -83,4 +83,5 @@ one_shot = true
[node name="AnimationPlayer" type="AnimationPlayer" parent="."]
anims/shutdown = SubResource( 4 )
[connection signal="timeout" from="Timer" to="." method="disable"]

View File

@@ -215,8 +215,8 @@ script = ExtResource( 1 )
[node name="Sprite" type="Sprite" parent="."]
texture = ExtResource( 2 )
vframes = 2
hframes = 16
vframes = 2
[node name="Smoke" type="Particles2D" parent="Sprite"]
self_modulate = Color( 1, 1, 1, 0.26702 )

View File

@@ -156,10 +156,11 @@ mipmap_policy=1
quality/intended_usage/framebuffer_allocation=0
quality/intended_usage/framebuffer_allocation.mobile=1
quality/2d/use_pixel_snap=true
2d/snapping/use_gpu_pixel_snap=true
quality/filters/anisotropic_filter_level=2
quality/filters/use_nearest_mipmap_filter=true
quality/depth/hdr=false
quality/2d/use_pixel_snap=true
[texture_import]

View File

@@ -4,6 +4,7 @@ This demo contains a series of tests for the 2D
physics engine.
They can be used for different purpose:
- Functional tests to check for regressions and
behavior of the 2D physics engine
- Performance tests to evaluate performance
@@ -13,6 +14,8 @@ Language: GDScript
Renderer: GLES 2
Check out this demo on the asset library: https://godotengine.org/asset-library/asset/888
## Screenshots
![Screenshot](screenshots/screenshot.png)

View File

@@ -193,5 +193,6 @@ 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"]

View File

@@ -120,5 +120,7 @@ limits/message_queue/max_size_kb=10240
[rendering]
quality/driver/driver_name="GLES2"
vram_compression/import_etc=true
vram_compression/import_etc2=false
environment/default_clear_color=Color( 0.184314, 0.184314, 0.184314, 1 )
quality/filters/msaa=2

View File

@@ -68,12 +68,10 @@ func clear_drawn_nodes():
_drawn_nodes.clear()
func create_rigidbody_box(size, pickable = false, use_icon = false):
var shape = RectangleShape2D.new()
shape.extents = 0.5 * size
func create_rigidbody(shape, pickable = false, transform = Transform.IDENTITY):
var collision = CollisionShape2D.new()
collision.shape = shape
collision.transform = transform
var body = RigidBody2D.new()
body.add_child(collision)
@@ -82,6 +80,15 @@ func create_rigidbody_box(size, pickable = false, use_icon = false):
var script = load("res://utils/rigidbody_pick.gd")
body.set_script(script)
return body
func create_rigidbody_box(size, pickable = false, use_icon = false, transform = Transform.IDENTITY):
var shape = RectangleShape2D.new()
shape.extents = 0.5 * size
var body = create_rigidbody(shape, pickable, transform)
if use_icon:
var texture = load("res://icon.png")
var icon = Sprite.new()

View File

@@ -50,6 +50,10 @@ var _tests = [
"id": "Performance Tests/Contacts",
"path": "res://tests/performance/test_perf_contacts.tscn",
},
{
"id" : "Performance Tests/Contact Islands",
"path" : "res://tests/performance/test_perf_contact_islands.tscn",
},
]

View File

@@ -167,7 +167,7 @@ func _on_option_selected(option):
func _find_type_index(type_name):
for type_index in _collision_shapes.size():
for type_index in range(_collision_shapes.size()):
var type_shape = _collision_shapes[type_index]
if type_shape.resource_name.find(type_name) > -1:
return type_index

View File

@@ -146,5 +146,6 @@ rect_min_size = Vector2( 120, 0 )
min_value = -1.0
max_value = 1.0
step = 0.01
[connection signal="value_changed" from="Controls/OffsetH/HSlider" to="." method="set_h_offset"]
[connection signal="value_changed" from="Controls/OffsetV/HSlider" to="." method="set_v_offset"]

View File

@@ -11,8 +11,6 @@ const OPTION_TEST_CASE_CHANGE_POSITIONS = "Test case/Set body positions after ad
const BOX_SIZE = Vector2(64, 64)
onready var options = $Options
var _update_joint = false
var _selected_joint = null
@@ -27,8 +25,10 @@ var _joint_types = {}
func _ready():
var options = $Options
var joints = $Joints
for joint_index in joints.get_child_count():
for joint_index in range(joints.get_child_count()):
var joint_node = joints.get_child(joint_index)
joint_node.visible = false
var joint_name = joint_node.name

View File

@@ -17,13 +17,6 @@ extents = Vector2( 32, 32 )
[node name="Test" type="Node2D"]
script = ExtResource( 1 )
_enable_debug_collision = true
_platform_size = 64.0
_platform_angle = 0.0
_platform_speed = 0.0
_body_angle = 0.0
_body_velocity = Vector2( 400, 0 )
_use_kinematic_body = false
[node name="LabelTestType" type="Label" parent="."]
margin_left = 14.0
@@ -245,6 +238,7 @@ texture = ExtResource( 2 )
[node name="CollisionShape2D" type="CollisionShape2D" parent="KinematicBody2D"]
shape = SubResource( 3 )
[connection signal="value_changed" from="Controls/PlatformSize/HSlider" to="." method="_set_platform_size"]
[connection signal="value_changed" from="Controls/PlatformAngle/HSlider" to="." method="_set_platform_angle"]
[connection signal="value_changed" from="Controls/BodyAngle/HSlider" to="." method="_set_rigidbody_angle"]

View File

@@ -28,7 +28,7 @@ func _create_pyramid():
var pos_x = -0.5 * (num_boxes - 1) * (box_size.x + box_spacing.x)
for box_index in num_boxes:
for box_index in range(num_boxes):
var box = template_body.duplicate()
box.position = Vector2(pos_x, 0.0)
box.name = "Box%02d" % (box_index + 1)

View File

@@ -1,7 +1,8 @@
[gd_scene load_steps=7 format=2]
[gd_scene load_steps=8 format=2]
[ext_resource path="res://assets/texture/godot-head.png" type="Texture" id=1]
[ext_resource path="res://test.gd" type="Script" id=2]
[ext_resource path="res://utils/rigidbody_pick.gd" type="Script" id=3]
[ext_resource path="res://tests/static_scene.tscn" type="PackedScene" id=6]
[sub_resource type="RectangleShape2D" id=1]
@@ -21,6 +22,7 @@ script = ExtResource( 2 )
[node name="RigidBodyRectangle" type="RigidBody2D" parent="DynamicShapes"]
position = Vector2( 96, 127 )
script = ExtResource( 3 )
[node name="CollisionShape2D" type="CollisionShape2D" parent="DynamicShapes/RigidBodyRectangle"]
rotation = 0.675442
@@ -28,6 +30,7 @@ shape = SubResource( 1 )
[node name="RigidBodyCapsule" type="RigidBody2D" parent="DynamicShapes"]
position = Vector2( 270.165, 139.444 )
script = ExtResource( 3 )
[node name="CollisionShape2D" type="CollisionShape2D" parent="DynamicShapes/RigidBodyCapsule"]
rotation = -0.202458
@@ -35,6 +38,7 @@ shape = SubResource( 2 )
[node name="RigidBodyConcavePolygon" type="RigidBody2D" parent="DynamicShapes"]
position = Vector2( 683.614, 132.749 )
script = ExtResource( 3 )
[node name="CollisionPolygon2D" type="CollisionPolygon2D" parent="DynamicShapes/RigidBodyConcavePolygon"]
scale = Vector2( 0.5, 0.5 )
@@ -47,6 +51,7 @@ texture = ExtResource( 1 )
[node name="RigidBodyConvexPolygon" type="RigidBody2D" parent="DynamicShapes"]
position = Vector2( 473.536, 134.336 )
script = ExtResource( 3 )
[node name="CollisionPolygon2D" type="CollisionPolygon2D" parent="DynamicShapes/RigidBodyConvexPolygon"]
scale = Vector2( 0.5, 0.5 )
@@ -59,6 +64,7 @@ texture = ExtResource( 1 )
[node name="RigidBodySphere" type="RigidBody2D" parent="DynamicShapes"]
position = Vector2( 919.968, 115.129 )
script = ExtResource( 3 )
[node name="CollisionShape2D" type="CollisionShape2D" parent="DynamicShapes/RigidBodySphere"]
shape = SubResource( 3 )

View File

@@ -26,7 +26,7 @@ func _create_stack():
var pos_x = -0.5 * (width - 1) * (box_size.x + box_spacing.x)
for box_index in width:
for box_index in range(width):
var box = template_body.duplicate()
box.position = Vector2(pos_x, 0.0)
box.name = "Box%02d" % (box_index + 1)

View File

@@ -148,7 +148,7 @@ func _remove_objects():
# Remove objects in reversed order to avoid the overhead of changing children index in parent.
var object_count = _objects.size()
for object_index in object_count:
for object_index in range(object_count):
root_node.remove_child(_objects[object_count - object_index - 1])
timer = OS.get_ticks_usec() - timer

View File

@@ -0,0 +1,105 @@
[gd_scene load_steps=8 format=2]
[ext_resource path="res://tests/static_scene.tscn" type="PackedScene" id=1]
[ext_resource path="res://tests/performance/test_perf_contacts.gd" type="Script" id=2]
[ext_resource path="res://assets/texture/godot-head.png" type="Texture" id=3]
[ext_resource path="res://tests/test_options.tscn" type="PackedScene" id=4]
[sub_resource type="RectangleShape2D" id=1]
extents = Vector2( 5, 7 )
[sub_resource type="CircleShape2D" id=2]
radius = 5.0
[sub_resource type="CapsuleShape2D" id=3]
radius = 5.0
height = 7.0
[node name="Test" type="Node2D"]
script = ExtResource( 2 )
_enable_debug_collision = false
spawns = [ NodePath("SpawnTarget1"), NodePath("SpawnTarget2"), NodePath("SpawnTarget3"), NodePath("SpawnTarget4"), NodePath("SpawnTarget5"), NodePath("SpawnTarget6"), NodePath("SpawnTarget7"), NodePath("SpawnTarget8"), NodePath("SpawnTarget9") ]
spawn_count = 300
spawn_randomize = Vector2( 10, 10 )
[node name="Options" parent="." instance=ExtResource( 4 )]
[node name="SpawnTarget1" type="Node2D" parent="."]
position = Vector2( 145.646, 109.462 )
[node name="SpawnTarget2" type="Node2D" parent="."]
position = Vector2( 508.14, 109.113 )
[node name="SpawnTarget3" type="Node2D" parent="."]
position = Vector2( 873.995, 110.042 )
[node name="SpawnTarget4" type="Node2D" parent="."]
position = Vector2( 149.646, 301.462 )
[node name="SpawnTarget5" type="Node2D" parent="."]
position = Vector2( 512.14, 301.113 )
[node name="SpawnTarget6" type="Node2D" parent="."]
position = Vector2( 877.995, 302.042 )
[node name="SpawnTarget7" type="Node2D" parent="."]
position = Vector2( 165.646, 507.462 )
[node name="SpawnTarget8" type="Node2D" parent="."]
position = Vector2( 528.14, 507.113 )
[node name="SpawnTarget9" type="Node2D" parent="."]
position = Vector2( 893.995, 508.042 )
[node name="StaticScene" parent="." instance=ExtResource( 1 )]
visible = false
position = Vector2( 0, 125.017 )
[node name="DynamicShapes" type="Node2D" parent="."]
[node name="RigidBodyRectangle" type="RigidBody2D" parent="DynamicShapes"]
position = Vector2( 0, 1024 )
gravity_scale = 0.0
[node name="CollisionShape2D" type="CollisionShape2D" parent="DynamicShapes/RigidBodyRectangle"]
shape = SubResource( 1 )
[node name="RigidBodySphere" type="RigidBody2D" parent="DynamicShapes"]
position = Vector2( 100, 1024 )
gravity_scale = 0.0
[node name="CollisionShape2D" type="CollisionShape2D" parent="DynamicShapes/RigidBodySphere"]
shape = SubResource( 2 )
[node name="RigidBodyCapsule" type="RigidBody2D" parent="DynamicShapes"]
position = Vector2( 200, 1024 )
gravity_scale = 0.0
[node name="CollisionShape2D" type="CollisionShape2D" parent="DynamicShapes/RigidBodyCapsule"]
shape = SubResource( 3 )
[node name="RigidBodyConvexPolygon" type="RigidBody2D" parent="DynamicShapes"]
position = Vector2( 300, 1024 )
gravity_scale = 0.0
[node name="CollisionPolygon2D" type="CollisionPolygon2D" parent="DynamicShapes/RigidBodyConvexPolygon"]
scale = Vector2( 0.1, 0.1 )
polygon = PoolVector2Array( 10.7, -54.5, 28.3596, -49.4067, 47.6282, -34.3806, 57.9717, -20.9447, 50.9869, 35.2694, 38.8, 47.5, 15.9852, 54.3613, -14.9507, 54.1845, -36.5, 48.1, -50.4828, 36.33, -58.0115, -20.515, -46.9473, -34.7342, -26.0876, -50.1138, -11.4152, -54.5332 )
[node name="GodotIcon" type="Sprite" parent="DynamicShapes/RigidBodyConvexPolygon"]
self_modulate = Color( 1, 1, 1, 0.392157 )
scale = Vector2( 0.1, 0.1 )
texture = ExtResource( 3 )
[node name="RigidBodyConcavePolygon" type="RigidBody2D" parent="DynamicShapes"]
position = Vector2( 400, 1024 )
gravity_scale = 0.0
[node name="CollisionPolygon2D" type="CollisionPolygon2D" parent="DynamicShapes/RigidBodyConcavePolygon"]
scale = Vector2( 0.1, 0.1 )
polygon = PoolVector2Array( -5.93512, -43.2195, 6.44476, -42.9695, 11.127, -54.3941, 26.9528, -49.4309, 26.2037, -36.508, 37.5346, -28.1737, 47.6282, -34.3806, 58.0427, -20.9631, 51.113, -10.2876, 50.9869, 35.2694, 38.8, 47.5, 15.9852, 54.3613, -14.9507, 54.1845, -36.5, 48.1, -50.4828, 36.33, -51.3668, -9.98545, -57.8889, -20.5885, -46.9473, -34.7342, -37.4014, -28.547, -26.0876, -37.0323, -26.9862, -49.15, -11.4152, -54.5332 )
[node name="GodotIcon" type="Sprite" parent="DynamicShapes/RigidBodyConcavePolygon"]
self_modulate = Color( 1, 1, 1, 0.392157 )
scale = Vector2( 0.1, 0.1 )
texture = ExtResource( 3 )

View File

@@ -8,14 +8,18 @@ const OPTION_TYPE_CAPSULE = "Shape type/Capsule"
const OPTION_TYPE_CONVEX_POLYGON = "Shape type/Convex Polygon"
const OPTION_TYPE_CONCAVE_POLYGON = "Shape type/Concave Polygon"
export(Array) var spawns = Array()
export(Array, NodePath) var spawns = Array()
export(int) var spawn_count = 100
export(int, 1, 10) var spawn_multiplier = 5
export(Vector2) var spawn_randomize
onready var options = $Options
var _object_templates = []
var _log_physics = false
var _log_physics_time = 0
var _log_physics_time_start = 0
func _ready():
yield(start_timer(0.5), "timeout")
@@ -40,6 +44,25 @@ func _ready():
_start_all_types()
func _physics_process(_delta):
if _log_physics:
var time = OS.get_ticks_usec()
var time_delta = time - _log_physics_time
var time_total = time - _log_physics_time_start
_log_physics_time = time
Log.print_log(" Physics Tick: %.3f ms (total = %.3f ms)" % [0.001 * time_delta, 0.001 * time_total])
func _log_physics_start():
_log_physics = true
_log_physics_time_start = OS.get_ticks_usec()
_log_physics_time = _log_physics_time_start
func _log_physics_stop():
_log_physics = false
func _exit_tree():
for object_template in _object_templates:
object_template.free()
@@ -66,7 +89,7 @@ func _on_option_selected(option):
func _find_type_index(type_name):
for type_index in _object_templates.size():
for type_index in range(_object_templates.size()):
var type_node = _object_templates[type_index]
if type_node.name.find(type_name) > -1:
return type_index
@@ -85,80 +108,98 @@ func _start_type(type_index):
if is_timer_canceled():
return
_log_physics_start()
_spawn_objects(type_index)
yield(wait_for_physics_ticks(5), "wait_done")
_log_physics_stop()
yield(start_timer(1.0), "timeout")
if is_timer_canceled():
return
_log_physics_start()
_activate_objects()
yield(wait_for_physics_ticks(5), "wait_done")
_log_physics_stop()
yield(start_timer(5.0), "timeout")
if is_timer_canceled():
return
_log_physics_start()
_despawn_objects()
Log.print_log("* Done.")
yield(wait_for_physics_ticks(5), "wait_done")
_log_physics_stop()
yield(start_timer(1.0), "timeout")
func _start_all_types():
for type_index in _object_templates.size():
yield(start_timer(1.0), "timeout")
Log.print_log("* Start all types.")
for type_index in range(_object_templates.size()):
yield(_start_type(type_index), "completed")
if is_timer_canceled():
return
_spawn_objects(type_index)
yield(start_timer(1.0), "timeout")
if is_timer_canceled():
return
_activate_objects()
yield(start_timer(5.0), "timeout")
if is_timer_canceled():
return
_despawn_objects()
Log.print_log("* Done.")
Log.print_log("* Done all types.")
func _spawn_objects(type_index):
var template_node = _object_templates[type_index]
Log.print_log("* Spawning: " + template_node.name)
for spawn in spawns:
var spawn_parent = get_node(spawn)
Log.print_log("* Spawning: " + template_node.name)
for _index in range(spawn_multiplier):
for _node_index in spawn_count / spawn_multiplier:
var node = template_node.duplicate() as Node2D
spawn_parent.add_child(node)
for _node_index in range(spawn_count):
# Create a new object and shape every time to avoid the overhead of connecting many bodies to the same shape.
var collision = template_node.get_child(0).duplicate()
if collision is CollisionShape2D:
collision.shape = collision.shape.duplicate()
var body = template_node.duplicate()
body.transform = Transform.IDENTITY
if spawn_randomize != Vector2.ZERO:
body.position.x = randf() * spawn_randomize.x
body.position.y = randf() * spawn_randomize.y
var prev_collision = body.get_child(0)
body.remove_child(prev_collision)
prev_collision.queue_free()
body.add_child(collision)
body.set_sleeping(true)
spawn_parent.add_child(body)
func _activate_objects():
var spawn_parent = $SpawnTarget1
Log.print_log("* Activating")
for node_index in spawn_parent.get_child_count():
var node = spawn_parent.get_child(node_index) as RigidBody2D
node.set_sleeping(false)
func _despawn_objects():
for spawn in spawns:
var spawn_parent = get_node(spawn)
if spawn_parent.get_child_count() == 0:
return
for node_index in range(spawn_parent.get_child_count()):
var node = spawn_parent.get_child(node_index) as RigidBody2D
node.set_sleeping(false)
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)
func _despawn_objects():
Log.print_log("* Despawning")
for spawn in spawns:
var spawn_parent = get_node(spawn)
var object_count = spawn_parent.get_child_count()
if object_count == 0:
continue
# Remove objects in reversed order to avoid the overhead of changing children index in parent.
for object_index in range(object_count):
var node = spawn_parent.get_child(object_count - object_index - 1)
spawn_parent.remove_child(node)
node.queue_free()

View File

@@ -6,18 +6,20 @@
[ext_resource path="res://tests/test_options.tscn" type="PackedScene" id=4]
[sub_resource type="RectangleShape2D" id=1]
extents = Vector2( 20, 30 )
extents = Vector2( 10, 15 )
[sub_resource type="CircleShape2D" id=2]
radius = 30.0
radius = 15.0
[sub_resource type="CapsuleShape2D" id=3]
radius = 20.0
height = 30.0
height = 15.0
[node name="Test" type="Node2D"]
script = ExtResource( 2 )
_enable_debug_collision = false
spawns = [ NodePath("SpawnTarget1") ]
spawn_count = 500
spawn_randomize = Vector2( 10, 10 )
[node name="Options" parent="." instance=ExtResource( 4 )]
@@ -51,22 +53,22 @@ shape = SubResource( 3 )
position = Vector2( 300, 1024 )
[node name="CollisionPolygon2D" type="CollisionPolygon2D" parent="DynamicShapes/RigidBodyConvexPolygon"]
scale = Vector2( 0.5, 0.5 )
scale = Vector2( 0.25, 0.25 )
polygon = PoolVector2Array( 10.7, -54.5, 28.3596, -49.4067, 47.6282, -34.3806, 57.9717, -20.9447, 50.9869, 35.2694, 38.8, 47.5, 15.9852, 54.3613, -14.9507, 54.1845, -36.5, 48.1, -50.4828, 36.33, -58.0115, -20.515, -46.9473, -34.7342, -26.0876, -50.1138, -11.4152, -54.5332 )
[node name="GodotIcon" type="Sprite" parent="DynamicShapes/RigidBodyConvexPolygon"]
self_modulate = Color( 1, 1, 1, 0.392157 )
scale = Vector2( 0.5, 0.5 )
scale = Vector2( 0.25, 0.25 )
texture = ExtResource( 3 )
[node name="RigidBodyConcavePolygon" type="RigidBody2D" parent="DynamicShapes"]
position = Vector2( 400, 1024 )
[node name="CollisionPolygon2D" type="CollisionPolygon2D" parent="DynamicShapes/RigidBodyConcavePolygon"]
scale = Vector2( 0.5, 0.5 )
scale = Vector2( 0.25, 0.25 )
polygon = PoolVector2Array( -5.93512, -43.2195, 6.44476, -42.9695, 11.127, -54.3941, 26.9528, -49.4309, 26.2037, -36.508, 37.5346, -28.1737, 47.6282, -34.3806, 58.0427, -20.9631, 51.113, -10.2876, 50.9869, 35.2694, 38.8, 47.5, 15.9852, 54.3613, -14.9507, 54.1845, -36.5, 48.1, -50.4828, 36.33, -51.3668, -9.98545, -57.8889, -20.5885, -46.9473, -34.7342, -37.4014, -28.547, -26.0876, -37.0323, -26.9862, -49.15, -11.4152, -54.5332 )
[node name="GodotIcon" type="Sprite" parent="DynamicShapes/RigidBodyConcavePolygon"]
self_modulate = Color( 1, 1, 1, 0.392157 )
scale = Vector2( 0.5, 0.5 )
scale = Vector2( 0.25, 0.25 )
texture = ExtResource( 3 )

View File

@@ -13,7 +13,7 @@ func add_menu_item(item_path, checkbox = false, checked = false, radio = false):
var path = ""
var popup = get_popup()
for element_index in path_element_count - 1:
for element_index in range(path_element_count - 1):
var popup_label = path_elements[element_index]
path += popup_label + "/"
popup = _add_popup(popup, path, popup_label)
@@ -59,7 +59,7 @@ func _on_item_pressed(item_index, popup_menu, path):
var checked = popup_menu.is_item_checked(item_index)
if not checked:
popup_menu.set_item_checked(item_index, true)
for other_index in popup_menu.get_item_count():
for other_index in range(popup_menu.get_item_count()):
if other_index != item_index:
popup_menu.set_item_checked(other_index, false)
emit_signal("option_selected", item_path)

View File

@@ -242,10 +242,11 @@ mipmap_policy=1
quality/intended_usage/framebuffer_allocation=0
quality/intended_usage/framebuffer_allocation.mobile=1
quality/2d/use_pixel_snap=true
2d/snapping/use_gpu_pixel_snap=true
quality/filters/anisotropic_filter_level=2
quality/filters/use_nearest_mipmap_filter=true
quality/depth/hdr=false
quality/2d/use_pixel_snap=true
[texture_import]

View File

@@ -49,7 +49,10 @@ func _physics_process(_delta):
_velocity.y = move_and_slide(_velocity, FLOOR_NORMAL).y
# We flip the Sprite depending on which way the enemy is moving.
sprite.scale.x = 1 if _velocity.x > 0 else -1
if _velocity.x > 0:
sprite.scale.x = 1
else:
sprite.scale.x = -1
var animation = get_new_animation()
if animation != animation_player.current_animation:
@@ -64,7 +67,10 @@ func destroy():
func get_new_animation():
var animation_new = ""
if _state == State.WALKING:
animation_new = "walk" if abs(_velocity.x) > 0 else "idle"
if _velocity.x == 0:
animation_new = "idle"
else:
animation_new = "walk"
else:
animation_new = "destroy"
return animation_new

View File

@@ -51,7 +51,9 @@ func _physics_process(_delta):
var is_jump_interrupted = Input.is_action_just_released("jump" + action_suffix) and _velocity.y < 0.0
_velocity = calculate_move_velocity(_velocity, direction, speed, is_jump_interrupted)
var snap_vector = Vector2.DOWN * FLOOR_DETECT_DISTANCE if direction.y == 0.0 else Vector2.ZERO
var snap_vector = Vector2.ZERO
if direction.y == 0.0:
snap_vector = Vector2.DOWN * FLOOR_DETECT_DISTANCE
var is_on_platform = platform_detector.is_colliding()
_velocity = move_and_slide_with_snap(
_velocity, snap_vector, FLOOR_NORMAL, not is_on_platform, 4, 0.9, false
@@ -60,7 +62,10 @@ func _physics_process(_delta):
# When the characters direction changes, we want to to scale the Sprite accordingly to flip it.
# This will make Robi face left or right depending on the direction you move.
if direction.x != 0:
sprite.scale.x = 1 if direction.x > 0 else -1
if direction.x > 0:
sprite.scale.x = 1
else:
sprite.scale.x = -1
# We use the sprite's scale to store Robis look direction which allows us to shoot
# bullets forward.
@@ -106,9 +111,15 @@ func calculate_move_velocity(
func get_new_animation(is_shooting = false):
var animation_new = ""
if is_on_floor():
animation_new = "run" if abs(_velocity.x) > 0.1 else "idle"
if abs(_velocity.x) > 0.1:
animation_new = "run"
else:
animation_new = "idle"
else:
animation_new = "falling" if _velocity.y > 0 else "jumping"
if _velocity.y > 0:
animation_new = "falling"
else:
animation_new = "jumping"
if is_shooting:
animation_new += "_weapon"
return animation_new

View File

@@ -203,8 +203,8 @@ collision_mask = 8
[node name="Sprite" type="Sprite" parent="."]
position = Vector2( 0, -14 )
texture = ExtResource( 2 )
vframes = 2
hframes = 16
vframes = 2
frame = 16
[node name="Gun" type="Position2D" parent="Sprite"]

View File

@@ -2,7 +2,7 @@ extends AudioStreamPlayer
const DOUBLE_VOLUME_DB = 6 # Do not change. Represents doubling of sound pressure.
export(int) var base_volume_db = -4
export(int) var base_volume_db = -14
func _ready():
# To avoid AudioStreamPlayer2D sounds playing on top of each other and

View File

@@ -94,5 +94,6 @@ autostart = true
[node name="AnimationPlayer" type="AnimationPlayer" parent="."]
anims/destroy = SubResource( 6 )
[connection signal="body_entered" from="." to="." method="_on_body_entered"]
[connection signal="timeout" from="Timer" to="." method="destroy"]

View File

@@ -160,4 +160,5 @@ shape = SubResource( 3 )
[node name="Pickup" type="AudioStreamPlayer2D" parent="."]
stream = ExtResource( 3 )
[connection signal="body_entered" from="." to="." method="_on_body_entered"]

View File

@@ -84,6 +84,7 @@ margin_right = 105.0
margin_bottom = 50.0
[node name="Tween" type="Tween" parent="."]
[connection signal="pressed" from="ColorRect/CenterContainer/VBoxContainer/ResumeButton" to="." method="_on_ResumeButton_pressed"]
[connection signal="pressed" from="ColorRect/CenterContainer/VBoxContainer/QuitButton" to="." method="_on_QuitButton_pressed"]
[connection signal="tween_all_completed" from="Tween" to="." method="_on_Tween_all_completed"]

View File

@@ -12,7 +12,10 @@ func _ready():
var n = name.to_lower()
_up = n + "_move_up"
_down = n + "_move_down"
_ball_dir = 1 if n == "left" else -1
if n == "left":
_ball_dir = 1
else:
_ball_dir = -1
func _process(delta):

View File

@@ -98,6 +98,7 @@ shape = SubResource( 4 )
[node name="Camera2D" type="Camera2D" parent="."]
offset = Vector2( 320, 200 )
current = true
[connection signal="area_entered" from="Left" to="Left" method="_on_area_entered"]
[connection signal="area_entered" from="Right" to="Right" method="_on_area_entered"]
[connection signal="area_entered" from="LeftWall" to="LeftWall" method="_on_wall_area_entered"]

View File

@@ -8,11 +8,6 @@
config_version=4
_global_script_classes=[ ]
_global_script_class_icons={
}
[application]
config/name="Pong with GDScript"
@@ -71,4 +66,6 @@ right_move_up={
quality/driver/driver_name="GLES2"
quality/2d/use_pixel_snap=true
vram_compression/import_etc=true
vram_compression/import_etc2=false
viewport/default_clear_color=Color( 0, 0, 0, 1 )

View File

@@ -34,4 +34,5 @@ margin_top = 32.0
margin_right = 1264.0
margin_bottom = 151.0
text = "Next"
[connection signal="button_up" from="Button" to="." method="_on_Button_button_up"]

View File

@@ -8,11 +8,6 @@
config_version=4
_global_script_classes=[ ]
_global_script_class_icons={
}
[application]
config/name="JRPG Demo"
@@ -68,3 +63,5 @@ ui_down={
[rendering]
quality/driver/driver_name="GLES2"
vram_compression/import_etc=true
vram_compression/import_etc2=false

View File

@@ -78,6 +78,7 @@ margin_bottom = 242.0
size_flags_horizontal = 3
size_flags_vertical = 3
text = "Flee"
[connection signal="button_up" from="UI/Buttons/GridContainer/Attack" to="UI" method="_on_Attack_button_up"]
[connection signal="button_up" from="UI/Buttons/GridContainer/Defend" to="UI" method="_on_Defend_button_up"]
[connection signal="button_up" from="UI/Buttons/GridContainer/Flee" to="UI" method="_on_Flee_button_up"]

View File

@@ -99,5 +99,6 @@ size_flags_horizontal = 2
size_flags_vertical = 4
size_flags_stretch_ratio = 0.0
text = "Add"
[connection signal="button_down" from="Panel/Button" to="Panel/VBoxContainer" method="_on_Button_button_down"]
[connection signal="button_up" from="Panel/Button" to="Panel/VBoxContainer" method="_on_Button_button_up"]

View File

@@ -8,11 +8,6 @@
config_version=4
_global_script_classes=[ ]
_global_script_class_icons={
}
[application]
config/name="Screen Space Shaders"

View File

@@ -262,5 +262,6 @@ margin_right = 260.0
margin_bottom = 28.0
size_flags_horizontal = 2
size_flags_vertical = 2
[connection signal="item_selected" from="Picture" to="." method="_on_picture_item_selected"]
[connection signal="item_selected" from="Effect" to="." method="_on_effect_item_selected"]

View File

@@ -8,11 +8,6 @@
config_version=4
_global_script_classes=[ ]
_global_script_class_icons={
}
[application]
config/name="2D Shaders for Sprites"
@@ -30,3 +25,5 @@ window/stretch/aspect="expand"
[rendering]
quality/driver/driver_name="GLES2"
vram_compression/import_etc=true
vram_compression/import_etc2=false

View File

@@ -381,6 +381,7 @@ size_flags_vertical = 2
__meta__ = {
"_edit_use_anchors_": false
}
[connection signal="tween_step" from="Tween" to="." method="_on_Tween_tween_step"]
[connection signal="value_changed" from="Top/Timeline" to="." method="_on_Timeline_value_changed"]
[connection signal="color_changed" from="Controls/ColorFrom/ColorPicker" to="." method="_on_ColorPicker_color_changed"]

View File

@@ -8,11 +8,6 @@
config_version=4
_global_script_classes=[ ]
_global_script_class_icons={
}
[application]
config/name="Tween Demo"
@@ -45,4 +40,6 @@ multithread/thread_rid_pool_prealloc=60
[rendering]
quality/driver/driver_name="GLES2"
vram_compression/import_etc=true
vram_compression/import_etc2=false
environment/default_clear_color=Color( 0.2349, 0.2349, 0.27, 1 )

View File

@@ -596,5 +596,4 @@ material/0 = ExtResource( 12 )
material/1 = ExtResource( 13 )
[editable path="KinematicBody/CameraHolder/Weapon/Pistol"]
[editable path="KinematicBody/GodotBattleBot"]

View File

@@ -16,6 +16,7 @@ nodes/root_name="WeaponPistol"
nodes/root_scale=1.0
nodes/custom_script=""
nodes/storage=0
nodes/use_legacy_names=false
materials/location=0
materials/storage=0
materials/keep_on_reimport=true

View File

@@ -16,6 +16,7 @@ nodes/root_name="GodotBattleBot"
nodes/root_scale=1.0
nodes/custom_script=""
nodes/storage=0
nodes/use_legacy_names=false
materials/location=0
materials/storage=0
materials/keep_on_reimport=true

View File

@@ -8,11 +8,6 @@
config_version=4
_global_script_classes=[ ]
_global_script_class_icons={
}
[application]
config/name="3D Inverse Kinematics"

View File

@@ -52,7 +52,6 @@ __meta__ = {
[node name="GridMap" type="GridMap" parent="."]
mesh_library = ExtResource( 1 )
cell_size = Vector3( 1, 1, 1 )
cell_octant_size = 4
data = {
"cells": PoolIntArray( 0, 0, 0, 1, 0, 0, 2, 0, 0, 3, 0, 0, 4, 0, 0, 65530, 0, 0, 65531, 0, 0, 65532, 0, 0, 65533, 0, 0, 65534, 0, 0, 65535, 0, 0, 196603, 0, 0, 196604, 0, 0, 524292, 0, 0, 589820, 0, 0, 786432, 0, 0, 851967, 0, 0, 0, 1, 0, 1, 1, 0, 2, 1, 0, 3, 1, 0, 4, 1, 0, 65530, 1, 0, 65531, 1, 0, 65532, 1, 0, 65533, 1, 0, 65534, 1, 0, 65535, 1, 0, 131075, 1, 0, 196603, 1, 0, 196604, 1, 0, 524292, 1, 0, 589820, 1, 0, 786432, 1, 0, 851967, 1, 0, 0, 2, 0, 1, 2, 0, 2, 2, 0, 3, 2, 0, 4, 2, 0, 65530, 2, 0, 65531, 2, 0, 65532, 2, 0, 65533, 2, 0, 65534, 2, 0, 65535, 2, 0, 131075, 2, 0, 196603, 2, 0, 196604, 2, 0, 524292, 2, 0, 589820, 2, 0, 786432, 2, 0, 786433, 2, 0, 851966, 2, 0, 851967, 2, 0, 0, 3, 0, 1, 3, 0, 2, 3, 0, 3, 3, 0, 4, 3, 0, 65530, 3, 0, 65531, 3, 0, 65532, 3, 0, 65533, 3, 0, 65534, 3, 0, 65535, 3, 0, 196603, 3, 0, 524291, 3, 0, 524292, 3, 0, 589820, 3, 0, 786432, 3, 0, 786433, 3, 0, 851966, 3, 0, 851967, 3, 0, 0, 4, 0, 1, 4, 0, 2, 4, 0, 3, 4, 0, 4, 4, 0, 65530, 4, 0, 65531, 4, 0, 65532, 4, 0, 65533, 4, 0, 65534, 4, 0, 65535, 4, 0, 196603, 4, 0, 786432, 4, 0, 851967, 4, 0, 0, 5, 0, 1, 5, 0, 2, 5, 0, 3, 5, 0, 4, 5, 0, 65530, 5, 0, 65531, 5, 0, 65532, 5, 0, 65533, 5, 0, 65534, 5, 0, 65535, 5, 0, 131075, 5, 0, 0, 6, 0, 1, 6, 0, 2, 6, 0, 3, 6, 0, 4, 6, 0, 65530, 6, 0, 65531, 6, 0, 65532, 6, 0, 65533, 6, 0, 65534, 6, 0, 65535, 6, 0, 131075, 6, 0, 196603, 6, 0, 0, 7, 0, 1, 7, 0, 2, 7, 0, 3, 7, 0, 4, 7, 0, 65530, 7, 0, 65531, 7, 0, 65532, 7, 0, 65533, 7, 0, 65534, 7, 0, 65535, 7, 0, 131075, 7, 0, 196603, 7, 0, 0, 8, 0, 1, 8, 0, 2, 8, 0, 3, 8, 0, 4, 8, 0, 65530, 8, 0, 65531, 8, 0, 65532, 8, 0, 65533, 8, 0, 65534, 8, 0, 65535, 8, 0, 131075, 8, 0, 196603, 8, 0, 196604, 8, 0, 0, 9, 0, 1, 9, 0, 2, 9, 0, 3, 9, 0, 4, 9, 0, 65530, 9, 0, 65531, 9, 0, 65532, 9, 0, 65533, 9, 0, 65534, 9, 0, 65535, 9, 0, 131073, 9, 0, 131074, 9, 0, 131075, 9, 0, 196603, 9, 0, 196604, 9, 0, 196605, 9, 0, 196608, 9, 0, 262142, 9, 0, 0, 10, 0, 1, 10, 0, 2, 10, 0, 3, 10, 0, 4, 10, 0, 65530, 10, 0, 65531, 10, 0, 65532, 10, 0, 65533, 10, 0, 65534, 10, 0, 65535, 10, 0, 0, 11, 0, 1, 11, 0, 2, 11, 0, 3, 11, 0, 4, 11, 0, 65530, 11, 0, 65531, 11, 0, 65532, 11, 0, 65533, 11, 0, 65534, 11, 0, 65535, 11, 0, 0, 65532, 0, 1, 65532, 0, 2, 65532, 0, 3, 65532, 0, 4, 65532, 0, 65530, 65532, 0, 65531, 65532, 0, 65532, 65532, 0, 65533, 65532, 0, 65534, 65532, 0, 65535, 65532, 0, 0, 65533, 0, 1, 65533, 0, 2, 65533, 0, 3, 65533, 0, 4, 65533, 0, 65530, 65533, 0, 65531, 65533, 0, 65532, 65533, 0, 65533, 65533, 0, 65534, 65533, 0, 65535, 65533, 0, 262145, 65533, 0, 262146, 65533, 0, 262147, 65533, 0, 589822, 65533, 0, 589823, 65533, 0, 655363, 65533, 0, 655364, 65533, 0, 720897, 65533, 0, 720898, 65533, 0, 786432, 65533, 0, 851967, 65533, 0, 0, 65534, 0, 1, 65534, 0, 2, 65534, 0, 3, 65534, 0, 4, 65534, 0, 65530, 65534, 0, 65531, 65534, 0, 65532, 65534, 0, 65533, 65534, 0, 65534, 65534, 0, 65535, 65534, 0, 65536, 65534, 0, 131071, 65534, 0, 196603, 65534, 0, 196604, 65534, 0, 196605, 65534, 0, 196606, 65534, 0, 196607, 65534, 0, 589822, 65534, 0, 589828, 65534, 0, 786432, 65534, 0, 851967, 65534, 0, 0, 65535, 0, 1, 65535, 0, 2, 65535, 0, 3, 65535, 0, 4, 65535, 0, 65530, 65535, 0, 65531, 65535, 0, 65532, 65535, 0, 65533, 65535, 0, 65534, 65535, 0, 65535, 65535, 0, 196603, 65535, 0, 196604, 65535, 0, 196611, 65535, 0, 589820, 65535, 0, 589821, 65535, 0, 589822, 65535, 0, 589828, 65535, 0, 786432, 65535, 0, 851967, 65535, 0 )
}
@@ -117,4 +116,5 @@ transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 13.25, 3 )
[node name="CollisionShape" type="CollisionShape" parent="Princess"]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0 )
shape = SubResource( 4 )
[connection signal="body_entered" from="Princess" to="Cubio" method="_on_tcube_body_entered"]

View File

@@ -16,6 +16,7 @@ nodes/root_name="Cube"
nodes/root_scale=1.0
nodes/custom_script=""
nodes/storage=0
nodes/use_legacy_names=true
materials/location=1
materials/storage=2
materials/keep_on_reimport=true

View File

@@ -16,6 +16,7 @@ nodes/root_name="Mushroom"
nodes/root_scale=1.0
nodes/custom_script=""
nodes/storage=0
nodes/use_legacy_names=true
materials/location=1
materials/storage=0
materials/keep_on_reimport=true

View File

@@ -8,11 +8,6 @@
config_version=4
_global_script_classes=[ ]
_global_script_class_icons={
}
[application]
config/name="Kinematic Character 3D"

View File

@@ -415,6 +415,7 @@ margin_top = -44.0
margin_bottom = -30.0
size_flags_vertical = 0
align = 1
[connection signal="item_selected" from="UI/Background" to="." method="_on_bg_item_selected"]
[connection signal="pressed" from="UI/Previous" to="." method="_on_Previous_pressed"]
[connection signal="pressed" from="UI/Next" to="." method="_on_Next_pressed"]

View File

@@ -16,6 +16,7 @@ nodes/root_name="Scene Root"
nodes/root_scale=1.0
nodes/custom_script=""
nodes/storage=0
nodes/use_legacy_names=false
materials/location=1
materials/storage=2
materials/keep_on_reimport=true

View File

@@ -8,11 +8,6 @@
config_version=4
_global_script_classes=[ ]
_global_script_class_icons={
}
[application]
config/name="Material Testers"

View File

@@ -3,16 +3,16 @@
importer="texture"
type="StreamTexture"
path.s3tc="res://.import/particle.png-c2ba3d91e96c62035d672392a1197218.s3tc.stex"
path.etc2="res://.import/particle.png-c2ba3d91e96c62035d672392a1197218.etc2.stex"
path.etc="res://.import/particle.png-c2ba3d91e96c62035d672392a1197218.etc.stex"
metadata={
"imported_formats": [ "s3tc", "etc2" ],
"imported_formats": [ "s3tc", "etc" ],
"vram_texture": true
}
[deps]
source_file="res://particle.png"
dest_files=[ "res://.import/particle.png-c2ba3d91e96c62035d672392a1197218.s3tc.stex", "res://.import/particle.png-c2ba3d91e96c62035d672392a1197218.etc2.stex" ]
dest_files=[ "res://.import/particle.png-c2ba3d91e96c62035d672392a1197218.s3tc.stex", "res://.import/particle.png-c2ba3d91e96c62035d672392a1197218.etc.stex" ]
[params]

View File

@@ -8,11 +8,6 @@
config_version=4
_global_script_classes=[ ]
_global_script_class_icons={
}
[application]
config/name="3D Navigation Mesh"
@@ -31,5 +26,7 @@ singletons=[ ]
quality/driver/driver_name="GLES2"
quality/intended_usage/framebuffer_allocation=3
vram_compression/import_etc=true
vram_compression/import_etc2=false
quality/shadows/filter_mode=2
quality/filters/msaa=2

View File

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

View File

@@ -192,5 +192,6 @@ 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"]

View File

@@ -88,9 +88,29 @@ toggle_pause={
"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)
]
}
character_right={
"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)
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":16777233,"unicode":0,"echo":false,"script":null)
]
}
character_left={
"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":65,"unicode":0,"echo":false,"script":null)
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":16777231,"unicode":0,"echo":false,"script":null)
]
}
character_jump={
"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":87,"unicode":0,"echo":false,"script":null)
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":32,"unicode":0,"echo":false,"script":null)
]
}
[rendering]
quality/driver/driver_name="GLES2"
vram_compression/import_etc=true
vram_compression/import_etc2=false
environment/default_clear_color=Color( 0.184314, 0.184314, 0.184314, 1 )
quality/filters/msaa=2

View File

@@ -46,33 +46,32 @@ func add_sphere(pos, radius, color):
func add_shape(shape, transform, color):
var collision = CollisionShape.new()
collision.shape = shape
var debug_mesh = shape.get_debug_mesh()
_drawn_nodes.push_back(collision)
add_child(collision)
var mesh_instance = MeshInstance.new()
mesh_instance.transform = transform
mesh_instance.mesh = debug_mesh
var mesh_instance = collision.get_child(0)
var material = SpatialMaterial.new()
material.flags_unshaded = true
material.albedo_color = color
mesh_instance.material_override = material
collision.global_transform = transform
add_child(mesh_instance)
_drawn_nodes.push_back(mesh_instance)
func clear_drawn_nodes():
for node in _drawn_nodes:
remove_child(node)
node.queue_free()
_drawn_nodes.clear()
func create_rigidbody_box(size, pickable = false):
var shape = BoxShape.new()
shape.extents = 0.5 * size
func create_rigidbody(shape, pickable = false, transform = Transform.IDENTITY):
var collision = CollisionShape.new()
collision.shape = shape
collision.transform = transform
var body = RigidBody.new()
body.add_child(collision)
@@ -84,6 +83,13 @@ func create_rigidbody_box(size, pickable = false):
return body
func create_rigidbody_box(size, pickable = false, transform = Transform.IDENTITY):
var shape = BoxShape.new()
shape.extents = 0.5 * size
return create_rigidbody(shape, pickable, transform)
func start_timer(timeout):
if _timer == null:
_timer = Timer.new()

View File

@@ -34,6 +34,18 @@ var _tests = [
"id": "Functional Tests/Raycasting",
"path": "res://tests/functional/test_raycasting.tscn",
},
{
"id": "Functional Tests/RigidBody Impact",
"path": "res://tests/functional/test_rigidbody_impact.tscn",
},
{
"id": "Functional Tests/RigidBody Ground Check",
"path": "res://tests/functional/test_rigidbody_ground_check.tscn",
},
{
"id": "Functional Tests/Moving Platform",
"path": "res://tests/functional/test_moving_platform.tscn",
},
{
"id": "Performance Tests/Broadphase",
"path": "res://tests/performance/test_perf_broadphase.tscn",
@@ -43,8 +55,8 @@ var _tests = [
"path": "res://tests/performance/test_perf_contacts.tscn",
},
{
"id" : "Performance Tests/Contacts Extended",
"path" : "res://tests/performance/test_perf_contacts_extended.tscn",
"id" : "Performance Tests/Contact Islands",
"path" : "res://tests/performance/test_perf_contact_islands.tscn",
},
]

View File

@@ -170,7 +170,7 @@ func _on_option_selected(option):
func _find_type_index(type_name):
for type_index in _collision_shapes.size():
for type_index in range(_collision_shapes.size()):
var type_shape = _collision_shapes[type_index]
if type_shape.resource_name.find(type_name) > -1:
return type_index

View File

@@ -1,8 +1,7 @@
[gd_scene load_steps=11 format=2]
[gd_scene load_steps=10 format=2]
[ext_resource path="res://assets/robot_head/godot3_robot_head_collision.tres" type="Shape" id=1]
[ext_resource path="res://tests/functional/test_collision_pairs.gd" type="Script" id=2]
[ext_resource path="res://utils/exception_cylinder.gd" type="Script" id=3]
[ext_resource path="res://utils/camera_orbit.gd" type="Script" id=4]
[ext_resource path="res://tests/test_options.tscn" type="PackedScene" id=5]
@@ -141,7 +140,6 @@ shape = SubResource( 3 )
[node name="RigidBodyCylinder" type="RigidBody" parent="Shapes"]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 3, 0, 0 )
mode = 3
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 )
@@ -165,6 +163,7 @@ shape = ExtResource( 1 )
[node name="Camera" type="Camera" parent="."]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 5.8667, 11.8164 )
script = ExtResource( 4 )
[connection signal="value_changed" from="Controls/OffsetX/HSlider" to="." method="set_x_offset"]
[connection signal="value_changed" from="Controls/OffsetY/HSlider" to="." method="set_y_offset"]
[connection signal="value_changed" from="Controls/OffsetZ/HSlider" to="." method="set_z_offset"]

View File

@@ -24,23 +24,26 @@ var _joint_types = {}
func _ready():
for joint_index in $Joints.get_child_count():
var joint_node = $Joints.get_child(joint_index)
var options = $Options
var joints = $Joints
for joint_index in joints.get_child_count():
var joint_node = joints.get_child(joint_index)
joint_node.visible = false
var joint_name = joint_node.name
var joint_short = joint_name.substr(0, joint_name.length() - 5)
var option_name = OPTION_JOINT_TYPE % [joint_short, joint_index + 1]
$Options.add_menu_item(option_name)
options.add_menu_item(option_name)
_joint_types[option_name] = joint_node
$Options.add_menu_item(OPTION_TEST_CASE_BODIES_COLLIDE, true, false)
$Options.add_menu_item(OPTION_TEST_CASE_WORLD_ATTACHMENT, true, false)
$Options.add_menu_item(OPTION_TEST_CASE_DYNAMIC_ATTACHMENT, true, false)
$Options.add_menu_item(OPTION_TEST_CASE_DESTROY_BODY, true, false)
$Options.add_menu_item(OPTION_TEST_CASE_CHANGE_POSITIONS, true, false)
options.add_menu_item(OPTION_TEST_CASE_BODIES_COLLIDE, true, false)
options.add_menu_item(OPTION_TEST_CASE_WORLD_ATTACHMENT, true, false)
options.add_menu_item(OPTION_TEST_CASE_DYNAMIC_ATTACHMENT, true, false)
options.add_menu_item(OPTION_TEST_CASE_DESTROY_BODY, true, false)
options.add_menu_item(OPTION_TEST_CASE_CHANGE_POSITIONS, true, false)
$Options.connect("option_selected", self, "_on_option_selected")
$Options.connect("option_changed", self, "_on_option_changed")
options.connect("option_selected", self, "_on_option_selected")
options.connect("option_changed", self, "_on_option_changed")
_selected_joint = _joint_types.values()[0]
_update_joint = true

View File

@@ -0,0 +1,137 @@
extends Test
const OPTION_BODY_TYPE = "Body Type/%s (%d)"
const OPTION_GRAVITY = "Physics options/Gravity on floor (Kinematic only)"
const OPTION_SLOPE = "Physics options/Stop on slope (Kinematic only)"
const OPTION_SNAP = "Physics options/Use snap (Kinematic only)"
const OPTION_FRICTION = "Physics options/Friction (Rigid only)"
const OPTION_ROUGH = "Physics options/Rough (Rigid only)"
const OPTION_PROCESS_PHYSICS = "Physics options/AnimationPlayer physics process mode"
var _gravity = false
var _slope = false
var _snap = false
var _friction = false
var _rough = false
var _animation_physics = false
var _body_scene = {}
var _key_list = []
var _current_body_index = 0
var _current_body_key = ""
var _current_body = null
var _body_type = ["KinematicBody", "RigidBody"]
func _ready():
var options = $Options
var bodies = $Bodies.get_children()
for i in bodies.size():
var body = bodies[i]
var option_name = OPTION_BODY_TYPE % [body.name, i + 1]
options.add_menu_item(option_name)
_key_list.append(option_name)
_body_scene[option_name] = get_packed_scene(body)
body.queue_free()
options.add_menu_item(OPTION_GRAVITY, true, false)
options.add_menu_item(OPTION_SLOPE, true, false)
options.add_menu_item(OPTION_SNAP, true, false)
options.add_menu_item(OPTION_FRICTION, true, false)
options.add_menu_item(OPTION_ROUGH, true, false)
options.add_menu_item(OPTION_PROCESS_PHYSICS, true, false)
options.connect("option_selected", self, "_on_option_selected")
options.connect("option_changed", self, "_on_option_changed")
spawn_body_index(_current_body_index)
func _input(event):
var key_event = event as InputEventKey
if key_event and not key_event.pressed:
var _index = key_event.scancode - KEY_1
if _index >= 0 and _index < _key_list.size():
spawn_body_index(_index)
func _on_option_selected(option):
if _body_scene.has(option):
spawn_body_key(option)
func _on_option_changed(option, checked):
match option:
OPTION_GRAVITY:
_gravity = checked
spawn_body_index(_current_body_index)
OPTION_SLOPE:
_slope = checked
spawn_body_index(_current_body_index)
OPTION_SNAP:
_snap = checked
spawn_body_index(_current_body_index)
OPTION_FRICTION:
_friction = checked
spawn_body_index(_current_body_index)
OPTION_ROUGH:
_rough = checked
spawn_body_index(_current_body_index)
OPTION_PROCESS_PHYSICS:
_animation_physics = checked
spawn_body_index(_current_body_index)
func spawn_body_index(body_index):
if _current_body:
_current_body.queue_free()
_current_body_index = body_index
_current_body_key = _key_list[body_index]
var body_parent = $Bodies
var body = _body_scene[_key_list[body_index]].instance()
body_parent.add_child(body)
_current_body = body
init_body()
func spawn_body_key(body_key):
if _current_body:
_current_body.queue_free()
_current_body_key = body_key
_current_body_index = _key_list.find(body_key)
var body_parent = $Bodies
var body = _body_scene[body_key].instance()
body_parent.add_child(body)
_current_body = body
init_body()
func init_body():
if _current_body is KinematicBody:
_current_body._gravity_on_floor = _gravity
_current_body._stop_on_slopes = _slope
_current_body._use_snap = _snap
elif _current_body is RigidBody:
_current_body.physics_material_override.rough = _rough
_current_body.physics_material_override.friction = 1.0 if _friction else 0.0
var animation_player = $Platforms/KinematicPlatform/AnimationPlayer
animation_player.stop()
if _animation_physics:
animation_player.playback_process_mode = AnimationPlayer.ANIMATION_PROCESS_PHYSICS
else:
animation_player.playback_process_mode = AnimationPlayer.ANIMATION_PROCESS_IDLE
animation_player.play("Move")
$LabelBodyType.text = "Body Type: " + _body_type[_current_body_index]
func get_packed_scene(node):
node.owner = self
for child in node.get_children():
child.owner = node
var packed_scene = PackedScene.new()
packed_scene.pack(node)
return packed_scene

View File

@@ -0,0 +1,86 @@
[gd_scene load_steps=9 format=2]
[ext_resource path="res://utils/camera_orbit.gd" type="Script" id=1]
[ext_resource path="res://tests/functional/test_moving_platform.gd" type="Script" id=2]
[ext_resource path="res://tests/test_options.tscn" type="PackedScene" id=3]
[ext_resource path="res://utils/kinematicbody_physics.gd" type="Script" id=4]
[sub_resource type="CapsuleShape" id=1]
radius = 0.3
[sub_resource type="PhysicsMaterial" id=2]
[sub_resource type="BoxShape" id=3]
extents = Vector3( 2, 0.2, 1 )
[sub_resource type="Animation" id=4]
length = 4.0
tracks/0/type = "bezier"
tracks/0/path = NodePath(".:translation:x")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/keys = {
"points": PoolRealArray( -7, -0.25, 0, 0.25, 0, -7, -0.25, 0, 0.245766, 0.531658, 6, -0.132614, -0.374802, 0.25, 0 ),
"times": PoolRealArray( 0, 0.5, 4 )
}
[node name="Test" type="Spatial"]
script = ExtResource( 2 )
[node name="LabelBodyType" type="Label" parent="."]
margin_left = 14.0
margin_top = 78.0
margin_right = 171.0
margin_bottom = 92.0
text = "Body Type: "
__meta__ = {
"_edit_use_anchors_": false
}
[node name="Options" parent="." instance=ExtResource( 3 )]
[node name="Bodies" type="Spatial" parent="."]
[node name="KinematicBody" type="KinematicBody" parent="Bodies"]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, -7, -1.95, 0 )
collision_layer = 2
script = ExtResource( 4 )
_stop_on_slopes = true
_use_snap = true
[node name="CollisionShape" type="CollisionShape" parent="Bodies/KinematicBody"]
transform = Transform( 1, 0, 0, 0, -4.37114e-08, -1, 0, 1, -4.37114e-08, 0, 0.8, 0 )
shape = SubResource( 1 )
[node name="RigidBody" type="RigidBody" parent="Bodies"]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, -7, -1.95, 0 )
collision_layer = 4
physics_material_override = SubResource( 2 )
axis_lock_angular_x = true
axis_lock_angular_y = true
axis_lock_angular_z = true
[node name="CollisionShape" type="CollisionShape" parent="Bodies/RigidBody"]
transform = Transform( 1, 0, 0, 0, -4.37114e-08, -1, 0, 1, -4.37114e-08, 0, 0.8, 0 )
shape = SubResource( 1 )
[node name="Platforms" type="Spatial" parent="."]
[node name="KinematicPlatform" type="KinematicBody" parent="Platforms"]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, -7, -2, 0 )
[node name="CollisionShape" type="CollisionShape" parent="Platforms/KinematicPlatform"]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -0.2, 0 )
shape = SubResource( 3 )
[node name="AnimationPlayer" type="AnimationPlayer" parent="Platforms/KinematicPlatform"]
anims/Move = SubResource( 4 )
[node name="Camera" type="Camera" parent="."]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 10 )
script = ExtResource( 1 )
[node name="OmniLight" type="OmniLight" parent="Camera"]
omni_range = 50.0

View File

@@ -1,8 +1,7 @@
[gd_scene load_steps=10 format=2]
[gd_scene load_steps=9 format=2]
[ext_resource path="res://assets/robot_head/godot3_robot_head_collision.tres" type="Shape" id=1]
[ext_resource path="res://tests/functional/test_raycasting.gd" type="Script" id=2]
[ext_resource path="res://utils/exception_cylinder.gd" type="Script" id=3]
[ext_resource path="res://utils/camera_orbit.gd" type="Script" id=4]
[sub_resource type="BoxShape" id=1]
@@ -48,7 +47,6 @@ shape = SubResource( 3 )
[node name="RigidBodyCylinder" type="RigidBody" parent="Shapes"]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 3, 0, 0 )
mode = 3
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 )

View File

@@ -0,0 +1,159 @@
[gd_scene load_steps=25 format=2]
[ext_resource path="res://utils/rigidbody_ground_check.gd" type="Script" id=1]
[ext_resource path="res://test.gd" type="Script" id=2]
[ext_resource path="res://tests/static_scene_plane.tscn" type="PackedScene" id=3]
[ext_resource path="res://utils/camera_orbit.gd" type="Script" id=4]
[sub_resource type="PhysicsMaterial" id=1]
friction = 0.0
[sub_resource type="BoxShape" id=2]
[sub_resource type="CubeMesh" id=3]
[sub_resource type="SpatialMaterial" id=4]
[sub_resource type="PhysicsMaterial" id=5]
friction = 0.0
[sub_resource type="CapsuleShape" id=6]
[sub_resource type="CapsuleMesh" id=7]
[sub_resource type="SpatialMaterial" id=8]
[sub_resource type="PhysicsMaterial" id=9]
friction = 0.0
[sub_resource type="CylinderShape" id=10]
[sub_resource type="CylinderMesh" id=11]
[sub_resource type="SpatialMaterial" id=12]
[sub_resource type="PhysicsMaterial" id=13]
friction = 0.0
[sub_resource type="ConvexPolygonShape" id=14]
points = PoolVector3Array( -0.7, 0, -0.7, -0.3, 0, 0.8, 0.8, 0, -0.3, 0, -1, 0 )
[sub_resource type="ArrayMesh" id=15]
surfaces/0 = {
"aabb": AABB( -0.7, -1, -0.7, 1.5, 1.00001, 1.5 ),
"array_data": PoolByteArray( 51, 51, 51, 191, 0, 0, 0, 0, 51, 51, 51, 191, 167, 0, 167, 0, 154, 153, 153, 190, 0, 0, 0, 0, 205, 204, 76, 63, 212, 0, 118, 0, 205, 204, 76, 63, 0, 0, 0, 0, 154, 153, 153, 190, 118, 0, 212, 0, 0, 0, 0, 0, 0, 0, 128, 191, 0, 0, 0, 0, 0, 129, 0, 0 ),
"array_index_data": PoolByteArray( 0, 0, 1, 0, 3, 0, 1, 0, 2, 0, 3, 0, 2, 0, 0, 0, 3, 0, 2, 0, 1, 0, 0, 0 ),
"blend_shape_data": [ ],
"format": 97539,
"index_count": 12,
"primitive": 4,
"skeleton_aabb": [ ],
"vertex_count": 4
}
[sub_resource type="SpatialMaterial" id=16]
[sub_resource type="PhysicsMaterial" id=17]
friction = 0.0
[sub_resource type="SphereShape" id=18]
[sub_resource type="SphereMesh" id=19]
[sub_resource type="SpatialMaterial" id=20]
[node name="Test" type="Spatial"]
script = ExtResource( 2 )
[node name="DynamicShapes" type="Spatial" parent="."]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 9.35591, 0 )
[node name="RigidBodyBox" type="RigidBody" parent="DynamicShapes"]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, -6, 0, 0 )
physics_material_override = SubResource( 1 )
axis_lock_angular_x = true
axis_lock_angular_y = true
axis_lock_angular_z = true
script = ExtResource( 1 )
[node name="CollisionShape" type="CollisionShape" parent="DynamicShapes/RigidBodyBox"]
transform = Transform( 0.6, 0, 0, 0, 1, 0, 0, 0, 0.6, 0, 0, 0 )
shape = SubResource( 2 )
[node name="MeshInstance" type="MeshInstance" parent="DynamicShapes/RigidBodyBox/CollisionShape"]
mesh = SubResource( 3 )
material/0 = SubResource( 4 )
[node name="RigidBodyCapsule" type="RigidBody" parent="DynamicShapes"]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, -3, 0, 0 )
physics_material_override = SubResource( 5 )
axis_lock_angular_x = true
axis_lock_angular_y = true
axis_lock_angular_z = true
script = ExtResource( 1 )
[node name="CollisionShape" type="CollisionShape" parent="DynamicShapes/RigidBodyCapsule"]
transform = Transform( 0.8, 0, 0, 0, -3.49691e-08, -0.8, 0, 0.8, -3.49691e-08, 0, 0, 0 )
shape = SubResource( 6 )
[node name="MeshInstance" type="MeshInstance" parent="DynamicShapes/RigidBodyCapsule/CollisionShape"]
mesh = SubResource( 7 )
material/0 = SubResource( 8 )
[node name="RigidBodyCylinder" type="RigidBody" parent="DynamicShapes"]
physics_material_override = SubResource( 9 )
axis_lock_angular_x = true
axis_lock_angular_y = true
axis_lock_angular_z = true
script = ExtResource( 1 )
[node name="CollisionShape" type="CollisionShape" parent="DynamicShapes/RigidBodyCylinder"]
transform = Transform( 0.8, 0, 0, 0, 1, 0, 0, 0, 0.8, 0, 0, 0 )
shape = SubResource( 10 )
[node name="MeshInstance" type="MeshInstance" parent="DynamicShapes/RigidBodyCylinder/CollisionShape"]
mesh = SubResource( 11 )
material/0 = SubResource( 12 )
[node name="RigidBodyConvex" type="RigidBody" parent="DynamicShapes"]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 3, 0.974548, 0 )
physics_material_override = SubResource( 13 )
axis_lock_angular_x = true
axis_lock_angular_y = true
axis_lock_angular_z = true
script = ExtResource( 1 )
[node name="CollisionShape" type="CollisionShape" parent="DynamicShapes/RigidBodyConvex"]
transform = Transform( 1.5, 0, 0, 0, 2, 0, 0, 0, 1.5, 0, 0, 0 )
shape = SubResource( 14 )
[node name="MeshInstance" type="MeshInstance" parent="DynamicShapes/RigidBodyConvex/CollisionShape"]
mesh = SubResource( 15 )
material/0 = SubResource( 16 )
[node name="RigidBodySphere" type="RigidBody" parent="DynamicShapes"]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 6, 0, 0 )
physics_material_override = SubResource( 17 )
axis_lock_angular_x = true
axis_lock_angular_y = true
axis_lock_angular_z = true
script = ExtResource( 1 )
[node name="CollisionShape" type="CollisionShape" parent="DynamicShapes/RigidBodySphere"]
transform = Transform( 0.8, 0, 0, 0, 0.8, 0, 0, 0, 0.8, 0, 0, 0 )
shape = SubResource( 18 )
[node name="MeshInstance" type="MeshInstance" parent="DynamicShapes/RigidBodySphere/CollisionShape"]
mesh = SubResource( 19 )
material/0 = SubResource( 20 )
[node name="StaticBodyPlane" parent="." instance=ExtResource( 3 )]
collision_layer = 2
collision_mask = 3
[node name="Camera" type="Camera" parent="."]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 3.604, 22.124 )
script = ExtResource( 4 )
[node name="OmniLight" type="OmniLight" parent="Camera"]
omni_range = 50.0

View File

@@ -0,0 +1,87 @@
[gd_scene load_steps=10 format=2]
[ext_resource path="res://utils/rigidbody_pick.gd" type="Script" id=1]
[ext_resource path="res://test.gd" type="Script" id=2]
[ext_resource path="res://tests/static_scene_plane.tscn" type="PackedScene" id=3]
[ext_resource path="res://utils/camera_orbit.gd" type="Script" id=4]
[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]
[node name="Test" type="Spatial"]
script = ExtResource( 2 )
[node name="DynamicShapes" type="Spatial" parent="."]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 9.35591, 0 )
[node name="RigidBodyBox" type="RigidBody" parent="DynamicShapes"]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, -6, 0, 0 )
axis_lock_angular_x = true
axis_lock_angular_y = true
axis_lock_angular_z = true
script = ExtResource( 1 )
[node name="CollisionShape" type="CollisionShape" parent="DynamicShapes/RigidBodyBox"]
transform = Transform( 0.6, 0, 0, 0, 1, 0, 0, 0, 0.6, 0, 0, 0 )
shape = SubResource( 1 )
[node name="RigidBodyCapsule" type="RigidBody" parent="DynamicShapes"]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, -3, 0, 0 )
axis_lock_angular_x = true
axis_lock_angular_y = true
axis_lock_angular_z = true
script = ExtResource( 1 )
[node name="CollisionShape" type="CollisionShape" parent="DynamicShapes/RigidBodyCapsule"]
transform = Transform( 0.8, 0, 0, 0, -3.49691e-08, -0.8, 0, 0.8, -3.49691e-08, 0, 0, 0 )
shape = SubResource( 2 )
[node name="RigidBodyCylinder" type="RigidBody" parent="DynamicShapes"]
axis_lock_angular_x = true
axis_lock_angular_y = true
axis_lock_angular_z = true
script = ExtResource( 1 )
[node name="CollisionShape" type="CollisionShape" parent="DynamicShapes/RigidBodyCylinder"]
transform = Transform( 0.8, 0, 0, 0, 1, 0, 0, 0, 0.8, 0, 0, 0 )
shape = SubResource( 3 )
[node name="RigidBodyConvex" type="RigidBody" parent="DynamicShapes"]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 3, 0.974548, 0 )
axis_lock_angular_x = true
axis_lock_angular_y = true
axis_lock_angular_z = true
script = ExtResource( 1 )
[node name="CollisionShape" type="CollisionShape" parent="DynamicShapes/RigidBodyConvex"]
transform = Transform( 1.5, 0, 0, 0, 2, 0, 0, 0, 1.5, 0, 0, 0 )
shape = SubResource( 4 )
[node name="RigidBodySphere" type="RigidBody" parent="DynamicShapes"]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 6, 0, 0 )
axis_lock_angular_x = true
axis_lock_angular_y = true
axis_lock_angular_z = true
script = ExtResource( 1 )
[node name="CollisionShape" type="CollisionShape" parent="DynamicShapes/RigidBodySphere"]
transform = Transform( 0.8, 0, 0, 0, 0.8, 0, 0, 0, 0.8, 0, 0, 0 )
shape = SubResource( 5 )
[node name="StaticBodyPlane" parent="." instance=ExtResource( 3 )]
[node name="Camera" type="Camera" parent="."]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 3.604, 22.124 )
fov = 35.0
script = ExtResource( 4 )
[node name="OmniLight" type="OmniLight" parent="Camera"]
omni_range = 50.0

View File

@@ -1,7 +1,7 @@
[gd_scene load_steps=10 format=2]
[ext_resource path="res://utils/rigidbody_pick.gd" type="Script" id=1]
[ext_resource path="res://test.gd" type="Script" id=2]
[ext_resource path="res://utils/exception_cylinder.gd" type="Script" id=3]
[ext_resource path="res://utils/camera_orbit.gd" type="Script" id=4]
[ext_resource path="res://tests/static_scene.tscn" type="PackedScene" id=6]
@@ -24,6 +24,7 @@ transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 9.35591, 0 )
[node name="RigidBodyBox" type="RigidBody" parent="DynamicShapes"]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, -6, 0, 0 )
script = ExtResource( 1 )
[node name="CollisionShape" type="CollisionShape" parent="DynamicShapes/RigidBodyBox"]
transform = Transform( 0.579556, 0.0885213, 0.145926, 0, 0.939693, -0.205212, -0.155291, 0.330366, 0.544604, 0, 0, 0 )
@@ -31,13 +32,14 @@ shape = SubResource( 1 )
[node name="RigidBodyCapsule" type="RigidBody" parent="DynamicShapes"]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, -3, 0, 0 )
script = ExtResource( 1 )
[node name="CollisionShape" type="CollisionShape" parent="DynamicShapes/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 )
[node name="RigidBodyCylinder" type="RigidBody" parent="DynamicShapes"]
script = ExtResource( 3 )
script = ExtResource( 1 )
[node name="CollisionShape" type="CollisionShape" parent="DynamicShapes/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 )
@@ -45,6 +47,7 @@ shape = SubResource( 3 )
[node name="RigidBodyConvex" type="RigidBody" parent="DynamicShapes"]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 3, 0, 0 )
script = ExtResource( 1 )
[node name="CollisionShape" type="CollisionShape" parent="DynamicShapes/RigidBodyConvex"]
transform = Transform( 1.5, 0, 0, 0, 1.93185, -0.388229, 0, 0.517638, 1.44889, 0, 0, 0 )
@@ -52,6 +55,7 @@ shape = SubResource( 4 )
[node name="RigidBodySphere" type="RigidBody" parent="DynamicShapes"]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 6, 0, 0 )
script = ExtResource( 1 )
[node name="CollisionShape" type="CollisionShape" parent="DynamicShapes/RigidBodySphere"]
transform = Transform( 0.8, 0, 0, 0, 0.8, 0, 0, 0, 0.8, 0, 0, 0 )

View File

@@ -154,7 +154,7 @@ func _remove_objects():
# Remove objects in reversed order to avoid the overhead of changing children index in parent.
var object_count = _objects.size()
for object_index in object_count:
for object_index in range(object_count):
root_node.remove_child(_objects[object_count - object_index - 1])
timer = OS.get_ticks_usec() - timer

View File

@@ -1,28 +1,35 @@
[gd_scene load_steps=12 format=2]
[gd_scene load_steps=11 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]
extents = Vector3( 0.5, 0.5, 0.5 )
[sub_resource type="CapsuleShape" id=2]
radius = 0.5
height = 0.5
[sub_resource type="CylinderShape" id=3]
radius = 0.5
height = 1.0
[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]
radius = 0.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 )
[sub_resource type="PlaneShape" id=6]
[node name="Test" type="Spatial"]
script = ExtResource( 1 )
_enable_debug_collision = false
spawns = [ "SpawnTarget1", "SpawnTarget2", "SpawnTarget3", "SpawnTarget4", "SpawnTarget5", "SpawnTarget6", "SpawnTarget7", "SpawnTarget8", "SpawnTarget9", "SpawnTarget10", "SpawnTarget11", "SpawnTarget12", "SpawnTarget13", "SpawnTarget14", "SpawnTarget15", "SpawnTarget16" ]
spawn_count = 200
spawn_randomize = Vector3( 0.2, 0.2, 0.2 )
[node name="Options" parent="." instance=ExtResource( 4 )]
@@ -90,7 +97,6 @@ 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 )
@@ -99,6 +105,7 @@ shape = SubResource( 3 )
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 6, 0, 0 )
[node name="CollisionShape" type="CollisionShape" parent="DynamicShapes/RigidBodyConvex"]
transform = Transform( 0.5, 0, 0, 0, 0.5, 0, 0, 0, 0.5, 0, 0, 0 )
shape = SubResource( 4 )
[node name="RigidBodySphere" type="RigidBody" parent="DynamicShapes"]
@@ -107,26 +114,26 @@ 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="StaticScene" parent="." instance=ExtResource( 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 )
transform = Transform( -1.62921e-07, 1, 0, -1, -1.62921e-07, 0, 0, 0, 1, -50, 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 )
transform = Transform( -1.62921e-07, -1, 0, 1, -1.62921e-07, 0, 0, 0, 1, 50, 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 )
transform = Transform( 2.6543e-14, 1.62921e-07, 1, 1, -1.62921e-07, 1.56125e-19, 1.62921e-07, 1, -1.62921e-07, 0, 0, -50 )
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 )
transform = Transform( 2.6543e-14, 1.62921e-07, -1, 1, -1.62921e-07, -1.56125e-19, -1.62921e-07, -1, -1.62921e-07, 0, 0, 50 )
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 )

View File

@@ -8,12 +8,16 @@ const OPTION_TYPE_CAPSULE = "Shape type/Capsule"
const OPTION_TYPE_CYLINDER = "Shape type/Cylinder"
const OPTION_TYPE_CONVEX = "Shape type/Convex"
export(Array) var spawns = Array()
export(Array, NodePath) var spawns = Array()
export(int) var spawn_count = 100
export(int, 1, 10) var spawn_multiplier = 5
export(Vector3) var spawn_randomize
var _object_templates = []
var _log_physics = false
var _log_physics_time = 0
var _log_physics_time_start = 0
func _ready():
yield(start_timer(0.5), "timeout")
@@ -41,6 +45,25 @@ func _exit_tree():
object_template.free()
func _physics_process(_delta):
if _log_physics:
var time = OS.get_ticks_usec()
var time_delta = time - _log_physics_time
var time_total = time - _log_physics_time_start
_log_physics_time = time
Log.print_log(" Physics Tick: %.3f ms (total = %.3f ms)" % [0.001 * time_delta, 0.001 * time_total])
func _log_physics_start():
_log_physics = true
_log_physics_time_start = OS.get_ticks_usec()
_log_physics_time = _log_physics_time_start
func _log_physics_stop():
_log_physics = false
func _on_option_selected(option):
cancel_timer()
@@ -62,7 +85,7 @@ func _on_option_selected(option):
func _find_type_index(type_name):
for type_index in _object_templates.size():
for type_index in range(_object_templates.size()):
var type_node = _object_templates[type_index]
if type_node.name.find(type_name) > -1:
return type_index
@@ -81,81 +104,95 @@ func _start_type(type_index):
if is_timer_canceled():
return
_log_physics_start()
_spawn_objects(type_index)
yield(wait_for_physics_ticks(5), "wait_done")
_log_physics_stop()
yield(start_timer(1.0), "timeout")
if is_timer_canceled():
return
_log_physics_start()
_activate_objects()
yield(wait_for_physics_ticks(5), "wait_done")
_log_physics_stop()
yield(start_timer(5.0), "timeout")
if is_timer_canceled():
return
_log_physics_start()
_despawn_objects()
Log.print_log("* Done.")
yield(wait_for_physics_ticks(5), "wait_done")
_log_physics_stop()
yield(start_timer(1.0), "timeout")
func _start_all_types():
for type_index in _object_templates.size():
yield(start_timer(1.0), "timeout")
Log.print_log("* Start all types.")
for type_index in range(_object_templates.size()):
yield(_start_type(type_index), "completed")
if is_timer_canceled():
return
_spawn_objects(type_index)
yield(start_timer(1.0), "timeout")
if is_timer_canceled():
return
_activate_objects()
yield(start_timer(5.0), "timeout")
if is_timer_canceled():
return
_despawn_objects()
Log.print_log("* Done.")
Log.print_log("* Done all types.")
func _spawn_objects(type_index):
var template_node = _object_templates[type_index]
Log.print_log("* Spawning: " + template_node.name)
for spawn in spawns:
var spawn_parent = get_node(spawn)
Log.print_log("* Spawning: " + template_node.name)
for _index in range(spawn_multiplier):
for _node_index in spawn_count / spawn_multiplier:
var node = template_node.duplicate() as Spatial
node.transform.origin = Vector3.ZERO
spawn_parent.add_child(node)
for _node_index in range(spawn_count):
# Create a new object and shape every time to avoid the overhead of connecting many bodies to the same shape.
var collision = template_node.get_child(0).duplicate()
collision.shape = collision.shape.duplicate()
var body = template_node.duplicate()
body.transform = Transform.IDENTITY
if spawn_randomize != Vector3.ZERO:
body.transform.origin.x = randf() * spawn_randomize.x
body.transform.origin.y = randf() * spawn_randomize.y
body.transform.origin.z = randf() * spawn_randomize.z
var prev_collision = body.get_child(0)
body.remove_child(prev_collision)
prev_collision.queue_free()
body.add_child(collision)
body.set_sleeping(true)
spawn_parent.add_child(body)
func _activate_objects():
var spawn_parent = $SpawnTarget1
Log.print_log("* Activating")
for node_index in spawn_parent.get_child_count():
var node = spawn_parent.get_child(node_index) as RigidBody
node.set_sleeping(false)
func _despawn_objects():
for spawn in spawns:
var spawn_parent = get_node(spawn)
if spawn_parent.get_child_count() == 0:
return
for node_index in range(spawn_parent.get_child_count()):
var node = spawn_parent.get_child(node_index) as RigidBody
node.set_sleeping(false)
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)
func _despawn_objects():
Log.print_log("* Despawning")
for spawn in spawns:
var spawn_parent = get_node(spawn)
# Remove objects in reversed order to avoid the overhead of changing children index in parent.
var object_count = spawn_parent.get_child_count()
for object_index in range(object_count):
var node = spawn_parent.get_child(object_count - object_index - 1)
spawn_parent.remove_child(node)
node.queue_free()

Some files were not shown because too many files have changed in this diff Show More