mirror of
https://github.com/godotengine/godot-demo-projects.git
synced 2026-01-04 15:00:09 +01:00
- 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.
62 lines
1.7 KiB
GDScript
62 lines
1.7 KiB
GDScript
extends Node
|
|
|
|
enum PhysicsEngine {
|
|
GODOT_PHYSICS,
|
|
JOLT_PHYSICS,
|
|
OTHER,
|
|
}
|
|
|
|
var _engine := PhysicsEngine.OTHER
|
|
|
|
func _enter_tree() -> void:
|
|
process_mode = Node.PROCESS_MODE_ALWAYS
|
|
|
|
# Always enable visible collision shapes on startup
|
|
# (same as the Debug > Visible Collision Shapes option).
|
|
get_tree().debug_collisions_hint = true
|
|
|
|
var engine_string: String = ProjectSettings.get_setting("physics/3d/physics_engine")
|
|
match engine_string:
|
|
"DEFAULT":
|
|
_engine = PhysicsEngine.GODOT_PHYSICS
|
|
"GodotPhysics3D":
|
|
_engine = PhysicsEngine.GODOT_PHYSICS
|
|
"Jolt Physics":
|
|
_engine = PhysicsEngine.JOLT_PHYSICS
|
|
_:
|
|
_engine = PhysicsEngine.OTHER
|
|
|
|
|
|
func _process(_delta: float) -> void:
|
|
if Input.is_action_just_pressed(&"toggle_full_screen"):
|
|
if DisplayServer.window_get_mode() == DisplayServer.WINDOW_MODE_FULLSCREEN:
|
|
DisplayServer.window_set_mode(DisplayServer.WINDOW_MODE_WINDOWED)
|
|
else:
|
|
DisplayServer.window_set_mode(DisplayServer.WINDOW_MODE_FULLSCREEN)
|
|
|
|
if Input.is_action_just_pressed(&"toggle_debug_collision"):
|
|
var debug_collision_enabled := not _is_debug_collision_enabled()
|
|
_set_debug_collision_enabled(debug_collision_enabled)
|
|
if debug_collision_enabled:
|
|
Log.print_log("Debug Collision ON")
|
|
else:
|
|
Log.print_log("Debug Collision OFF")
|
|
|
|
if Input.is_action_just_pressed(&"toggle_pause"):
|
|
get_tree().paused = not get_tree().paused
|
|
|
|
if Input.is_action_just_pressed(&"exit"):
|
|
get_tree().quit()
|
|
|
|
|
|
func get_physics_engine() -> PhysicsEngine:
|
|
return _engine
|
|
|
|
|
|
func _set_debug_collision_enabled(enabled: bool) -> void:
|
|
get_tree().debug_collisions_hint = enabled
|
|
|
|
|
|
func _is_debug_collision_enabled() -> bool:
|
|
return get_tree().debug_collisions_hint
|