mirror of
https://github.com/godotengine/godot-demo-projects.git
synced 2026-01-04 23:10:08 +01:00
Use Jolt Physics in all 3D demos that use physics, improve physics tests demos (#1195)
- Add options for physics ticks per second, time scale, max physics steps per frame
and physics interpolation to the 2D and 3D physics tests demos.
- Physics ticks per second are always multiplied by time scale so that
time scale does not affect the physics simulation quality.
- Enable 4× MSAA for better debug shape display. Remove meshes/lights as
the debug collision fill make these unnecessary.
- Switch to the Mobile rendering method in the 2D physics tests demo
to allow for 2D MSAA, as it's not implemented in Compatibility yet.
- Improve collision shapes color in the 2D and 3D physics tests demos
for better visibility. Each PhysicsBody type now has its own collision
shape color.
This commit is contained in:
@@ -5,6 +5,8 @@ func _ready() -> void:
|
||||
match System.get_physics_engine():
|
||||
System.PhysicsEngine.GODOT_PHYSICS:
|
||||
engine_name = "GodotPhysics 3D"
|
||||
System.PhysicsEngine.JOLT_PHYSICS:
|
||||
engine_name = "Jolt Physics"
|
||||
System.PhysicsEngine.OTHER:
|
||||
var engine_setting := str(ProjectSettings.get_setting("physics/3d/physics_engine"))
|
||||
engine_name = "Other (%s)" % engine_setting
|
||||
|
||||
6
3d/physics_tests/utils/max_steps_per_frame.gd
Normal file
6
3d/physics_tests/utils/max_steps_per_frame.gd
Normal file
@@ -0,0 +1,6 @@
|
||||
extends HBoxContainer
|
||||
|
||||
|
||||
func _on_h_slider_value_changed(value: float) -> void:
|
||||
$Value.text = str(roundi(value))
|
||||
Engine.max_physics_steps_per_frame = roundi(value)
|
||||
1
3d/physics_tests/utils/max_steps_per_frame.gd.uid
Normal file
1
3d/physics_tests/utils/max_steps_per_frame.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://cvoeuonqmsye1
|
||||
5
3d/physics_tests/utils/physics_interpolation.gd
Normal file
5
3d/physics_tests/utils/physics_interpolation.gd
Normal file
@@ -0,0 +1,5 @@
|
||||
extends CheckButton
|
||||
|
||||
|
||||
func _on_check_button_toggled(toggled_on: bool) -> void:
|
||||
get_tree().physics_interpolation = toggled_on
|
||||
1
3d/physics_tests/utils/physics_interpolation.gd.uid
Normal file
1
3d/physics_tests/utils/physics_interpolation.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://ijebwwx4t8et
|
||||
@@ -2,6 +2,7 @@ extends Node
|
||||
|
||||
enum PhysicsEngine {
|
||||
GODOT_PHYSICS,
|
||||
JOLT_PHYSICS,
|
||||
OTHER,
|
||||
}
|
||||
|
||||
@@ -20,6 +21,8 @@ func _enter_tree() -> void:
|
||||
_engine = PhysicsEngine.GODOT_PHYSICS
|
||||
"GodotPhysics3D":
|
||||
_engine = PhysicsEngine.GODOT_PHYSICS
|
||||
"Jolt Physics":
|
||||
_engine = PhysicsEngine.JOLT_PHYSICS
|
||||
_:
|
||||
_engine = PhysicsEngine.OTHER
|
||||
|
||||
|
||||
6
3d/physics_tests/utils/ticks_per_second.gd
Normal file
6
3d/physics_tests/utils/ticks_per_second.gd
Normal file
@@ -0,0 +1,6 @@
|
||||
extends HBoxContainer
|
||||
|
||||
|
||||
func _on_h_slider_value_changed(value: float) -> void:
|
||||
$Value.text = str(roundi(value))
|
||||
Engine.physics_ticks_per_second = roundi(value * Engine.time_scale)
|
||||
1
3d/physics_tests/utils/ticks_per_second.gd.uid
Normal file
1
3d/physics_tests/utils/ticks_per_second.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://7kql0xtuc7ny
|
||||
8
3d/physics_tests/utils/time_scale.gd
Normal file
8
3d/physics_tests/utils/time_scale.gd
Normal file
@@ -0,0 +1,8 @@
|
||||
extends HBoxContainer
|
||||
|
||||
|
||||
func _on_h_slider_value_changed(value: float) -> void:
|
||||
value = maxf(0.1, value)
|
||||
$Value.text = "%.1f×" % value
|
||||
Engine.time_scale = value
|
||||
Engine.physics_ticks_per_second = $"../TicksPerSecond/HSlider".value * value
|
||||
1
3d/physics_tests/utils/time_scale.gd.uid
Normal file
1
3d/physics_tests/utils/time_scale.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://beqnv31yip0bl
|
||||
Reference in New Issue
Block a user