Skip to content

Commit

Permalink
Merge pull request #39421 from RandomShaper/pause_aware_picking_3.2
Browse files Browse the repository at this point in the history
Implement pause-aware picking (3.2)
  • Loading branch information
akien-mga authored Feb 9, 2021
2 parents daa0fe1 + 745c711 commit 398a625
Show file tree
Hide file tree
Showing 6 changed files with 272 additions and 230 deletions.
6 changes: 6 additions & 0 deletions doc/classes/ProjectSettings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1006,6 +1006,12 @@
<member name="physics/common/enable_object_picking" type="bool" setter="" getter="" default="true">
Enables [member Viewport.physics_object_picking] on the root viewport.
</member>
<member name="physics/common/enable_pause_aware_picking" type="bool" setter="" getter="" default="false">
If enabled, 2D and 3D physics picking behaves this way in relation to pause:
- When pause is started, every collision object that is hovered or captured (3D only) is released from that condition, getting the relevant mouse-exit callback, unless its pause mode makes it immune to pause.
- During pause, picking only considers collision objects immune to pause, sending input events and enter/exit callbacks to them as expected.
If disabled, the legacy behavior is used, which consists in queuing the picking input events during pause (so nodes won't get them) and flushing that queue on resume, against the state of the 2D/3D world at that point.
</member>
<member name="physics/common/physics_fps" type="int" setter="" getter="" default="60">
The number of fixed iterations per second. This controls how often physics simulation and [method Node._physics_process] methods are run.
[b]Note:[/b] This property is only read when the project starts. To change the physics FPS at runtime, set [member Engine.iterations_per_second] instead.
Expand Down
1 change: 1 addition & 0 deletions editor/project_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -499,6 +499,7 @@ class ProjectDialog : public ConfirmationDialog {
initial_settings["application/config/name"] = project_name->get_text();
initial_settings["application/config/icon"] = "res://icon.png";
initial_settings["rendering/environment/default_environment"] = "res://default_env.tres";
initial_settings["physics/common/enable_pause_aware_picking"] = true;

if (ProjectSettings::get_singleton()->save_custom(dir.plus_file("project.godot"), initial_settings, Vector<String>(), false) != OK) {
set_message(TTR("Couldn't create project.godot in project path."), MESSAGE_ERROR);
Expand Down
1 change: 1 addition & 0 deletions main/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1194,6 +1194,7 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph
Engine::get_singleton()->set_physics_jitter_fix(GLOBAL_DEF("physics/common/physics_jitter_fix", 0.5));
Engine::get_singleton()->set_target_fps(GLOBAL_DEF("debug/settings/fps/force_fps", 0));
ProjectSettings::get_singleton()->set_custom_property_info("debug/settings/fps/force_fps", PropertyInfo(Variant::INT, "debug/settings/fps/force_fps", PROPERTY_HINT_RANGE, "0,120,1,or_greater"));
GLOBAL_DEF("physics/common/enable_pause_aware_picking", false);

GLOBAL_DEF("debug/settings/stdout/print_fps", false);
GLOBAL_DEF("debug/settings/stdout/verbose_stdout", false);
Expand Down
3 changes: 3 additions & 0 deletions scene/main/scene_tree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -478,6 +478,9 @@ bool SceneTree::iteration(float p_time) {
emit_signal("physics_frame");

_notify_group_pause("physics_process_internal", Node::NOTIFICATION_INTERNAL_PHYSICS_PROCESS);
if (GLOBAL_GET("physics/common/enable_pause_aware_picking")) {
call_group_flags(GROUP_CALL_REALTIME, "_viewports", "_process_picking", true);
}
_notify_group_pause("physics_process", Node::NOTIFICATION_PHYSICS_PROCESS);
_flush_ugc();
MessageQueue::get_singleton()->flush(); //small little hack
Expand Down
Loading

0 comments on commit 398a625

Please sign in to comment.