mirror of
https://github.com/godotengine/godot.git
synced 2024-10-22 21:21:53 +00:00
Merge 05232ca04f
into 533c616cb8
This commit is contained in:
commit
26ae5caae1
|
@ -1504,8 +1504,8 @@ ProjectSettings::ProjectSettings() {
|
|||
// Keep the enum values in sync with the `DisplayServer::VSyncMode` enum.
|
||||
custom_prop_info["display/window/vsync/vsync_mode"] = PropertyInfo(Variant::INT, "display/window/vsync/vsync_mode", PROPERTY_HINT_ENUM, "Disabled,Enabled,Adaptive,Mailbox");
|
||||
custom_prop_info["rendering/driver/threads/thread_model"] = PropertyInfo(Variant::INT, "rendering/driver/threads/thread_model", PROPERTY_HINT_ENUM, "Single-Unsafe,Single-Safe,Multi-Threaded");
|
||||
GLOBAL_DEF("physics/2d/run_on_separate_thread", false);
|
||||
GLOBAL_DEF("physics/3d/run_on_separate_thread", false);
|
||||
GLOBAL_DEF_RST(PropertyInfo(Variant::INT, "physics/2d/run_on_separate_thread", PROPERTY_HINT_ENUM, "Disabled,Game,Game and Editor"), 0);
|
||||
GLOBAL_DEF_RST(PropertyInfo(Variant::INT, "physics/3d/run_on_separate_thread", PROPERTY_HINT_ENUM, "Disabled,Game,Game and Editor"), 0);
|
||||
|
||||
GLOBAL_DEF_BASIC(PropertyInfo(Variant::STRING, "display/window/stretch/mode", PROPERTY_HINT_ENUM, "disabled,canvas_items,viewport"), "disabled");
|
||||
GLOBAL_DEF_BASIC(PropertyInfo(Variant::STRING, "display/window/stretch/aspect", PROPERTY_HINT_ENUM, "ignore,keep,keep_width,keep_height,expand"), "keep");
|
||||
|
|
|
@ -917,6 +917,38 @@ void Node3DEditorViewport::_find_items_at_pos(const Point2 &p_pos, Vector<_RayRe
|
|||
r_results.sort();
|
||||
}
|
||||
|
||||
void Node3DEditorViewport::_reposition_selected_nodes() {
|
||||
if (collision_reposition) {
|
||||
List<Node *> &selection = editor_selection->get_selected_node_list();
|
||||
|
||||
if (selection.size() == 1) {
|
||||
Node3D *first_selected_node = Object::cast_to<Node3D>(selection.front()->get());
|
||||
double snap = EDITOR_GET("interface/inspector/default_float_step");
|
||||
int snap_step_decimals = Math::range_step_decimals(snap);
|
||||
set_message(TTR("Translating:") + " (" + String::num(first_selected_node->get_global_position().x, snap_step_decimals) + ", " +
|
||||
String::num(first_selected_node->get_global_position().y, snap_step_decimals) + ", " + String::num(first_selected_node->get_global_position().z, snap_step_decimals) + ")");
|
||||
first_selected_node->set_global_position(spatial_editor->snap_point(_get_instance_position(_edit.mouse_pos, first_selected_node)));
|
||||
}
|
||||
}
|
||||
|
||||
if (!update_preview_node) {
|
||||
return;
|
||||
}
|
||||
if (preview_node->is_inside_tree()) {
|
||||
preview_node_pos = spatial_editor->snap_point(_get_instance_position(preview_node_viewport_pos, preview_node));
|
||||
double snap = EDITOR_GET("interface/inspector/default_float_step");
|
||||
int snap_step_decimals = Math::range_step_decimals(snap);
|
||||
set_message(TTR("Instantiating:") + " (" + String::num(preview_node_pos.x, snap_step_decimals) + ", " +
|
||||
String::num(preview_node_pos.y, snap_step_decimals) + ", " + String::num(preview_node_pos.z, snap_step_decimals) + ")");
|
||||
Transform3D preview_gl_transform = Transform3D(Basis(), preview_node_pos);
|
||||
preview_node->set_global_transform(preview_gl_transform);
|
||||
if (!preview_node->is_visible()) {
|
||||
preview_node->show();
|
||||
}
|
||||
}
|
||||
update_preview_node = false;
|
||||
}
|
||||
|
||||
Vector3 Node3DEditorViewport::_get_screen_to_space(const Vector3 &p_vector3) {
|
||||
Projection cm;
|
||||
if (orthogonal) {
|
||||
|
@ -2850,6 +2882,8 @@ void Node3DEditorViewport::_project_settings_changed() {
|
|||
|
||||
const float texture_mipmap_bias = GLOBAL_GET("rendering/textures/default_filters/texture_mipmap_bias");
|
||||
viewport->set_texture_mipmap_bias(texture_mipmap_bias);
|
||||
|
||||
is_3d_editor_using_separate_physics_thread = GLOBAL_GET("physics/3d/run_on_separate_thread").operator int() != 0 && GLOBAL_GET("physics/3d/run_on_separate_thread").operator int() != 1;
|
||||
}
|
||||
|
||||
void Node3DEditorViewport::_notification(int p_what) {
|
||||
|
@ -3082,38 +3116,16 @@ void Node3DEditorViewport::_notification(int p_what) {
|
|||
float locked_half_width = locked_label->get_size().width / 2.0f;
|
||||
locked_label->set_anchor_and_offset(SIDE_LEFT, 0.5f, -locked_half_width);
|
||||
}
|
||||
|
||||
if (!is_3d_editor_using_separate_physics_thread) {
|
||||
_reposition_selected_nodes();
|
||||
}
|
||||
} break;
|
||||
|
||||
case NOTIFICATION_PHYSICS_PROCESS: {
|
||||
if (collision_reposition) {
|
||||
List<Node *> &selection = editor_selection->get_selected_node_list();
|
||||
|
||||
if (selection.size() == 1) {
|
||||
Node3D *first_selected_node = Object::cast_to<Node3D>(selection.front()->get());
|
||||
double snap = EDITOR_GET("interface/inspector/default_float_step");
|
||||
int snap_step_decimals = Math::range_step_decimals(snap);
|
||||
set_message(TTR("Translating:") + " (" + String::num(first_selected_node->get_global_position().x, snap_step_decimals) + ", " +
|
||||
String::num(first_selected_node->get_global_position().y, snap_step_decimals) + ", " + String::num(first_selected_node->get_global_position().z, snap_step_decimals) + ")");
|
||||
first_selected_node->set_global_position(spatial_editor->snap_point(_get_instance_position(_edit.mouse_pos, first_selected_node)));
|
||||
}
|
||||
if (is_3d_editor_using_separate_physics_thread) {
|
||||
_reposition_selected_nodes();
|
||||
}
|
||||
|
||||
if (!update_preview_node) {
|
||||
return;
|
||||
}
|
||||
if (preview_node->is_inside_tree()) {
|
||||
preview_node_pos = spatial_editor->snap_point(_get_instance_position(preview_node_viewport_pos, preview_node));
|
||||
double snap = EDITOR_GET("interface/inspector/default_float_step");
|
||||
int snap_step_decimals = Math::range_step_decimals(snap);
|
||||
set_message(TTR("Instantiating:") + " (" + String::num(preview_node_pos.x, snap_step_decimals) + ", " +
|
||||
String::num(preview_node_pos.y, snap_step_decimals) + ", " + String::num(preview_node_pos.z, snap_step_decimals) + ")");
|
||||
Transform3D preview_gl_transform = Transform3D(Basis(), preview_node_pos);
|
||||
preview_node->set_global_transform(preview_gl_transform);
|
||||
if (!preview_node->is_visible()) {
|
||||
preview_node->show();
|
||||
}
|
||||
}
|
||||
update_preview_node = false;
|
||||
} break;
|
||||
|
||||
case NOTIFICATION_APPLICATION_FOCUS_OUT:
|
||||
|
@ -5707,6 +5719,8 @@ Node3DEditorViewport::Node3DEditorViewport(Node3DEditor *p_spatial_editor, int p
|
|||
freelook_active = false;
|
||||
freelook_speed = EDITOR_GET("editors/3d/freelook/freelook_base_speed");
|
||||
|
||||
is_3d_editor_using_separate_physics_thread = GLOBAL_GET("physics/3d/run_on_separate_thread").operator int() != 0 && GLOBAL_GET("physics/3d/run_on_separate_thread").operator int() != 1;
|
||||
|
||||
selection_menu = memnew(PopupMenu);
|
||||
add_child(selection_menu);
|
||||
selection_menu->set_min_size(Size2(100, 0) * EDSCALE);
|
||||
|
|
|
@ -246,6 +246,7 @@ private:
|
|||
bool lock_rotation;
|
||||
bool transform_gizmo_visible = true;
|
||||
bool collision_reposition = false;
|
||||
bool is_3d_editor_using_separate_physics_thread = false;
|
||||
real_t gizmo_scale;
|
||||
|
||||
bool freelook_active;
|
||||
|
@ -285,6 +286,7 @@ private:
|
|||
void _select_clicked(bool p_allow_locked);
|
||||
ObjectID _select_ray(const Point2 &p_pos) const;
|
||||
void _find_items_at_pos(const Point2 &p_pos, Vector<_RayResult> &r_results, bool p_include_locked);
|
||||
void _reposition_selected_nodes();
|
||||
|
||||
Transform3D _get_camera_transform() const;
|
||||
int get_selected_count() const;
|
||||
|
|
|
@ -36,7 +36,16 @@
|
|||
|
||||
static PhysicsServer2D *_createGodotPhysics2DCallback() {
|
||||
#ifdef THREADS_ENABLED
|
||||
bool using_threads = GLOBAL_GET("physics/2d/run_on_separate_thread");
|
||||
bool using_threads = false;
|
||||
const int thread_type = GLOBAL_GET("physics/2d/run_on_separate_thread").operator int();
|
||||
|
||||
if (thread_type == 0) { // Threads disabled
|
||||
using_threads = false;
|
||||
} else if (thread_type == 1) { // Just runtime game threads
|
||||
using_threads = !Engine::get_singleton()->is_editor_hint();
|
||||
} else if (thread_type == 2) { // Both runtime game and editor threads
|
||||
using_threads = true;
|
||||
}
|
||||
#else
|
||||
bool using_threads = false;
|
||||
#endif
|
||||
|
|
|
@ -36,7 +36,16 @@
|
|||
|
||||
static PhysicsServer3D *_createGodotPhysics3DCallback() {
|
||||
#ifdef THREADS_ENABLED
|
||||
bool using_threads = GLOBAL_GET("physics/3d/run_on_separate_thread");
|
||||
bool using_threads = false;
|
||||
const int thread_type = GLOBAL_GET("physics/3d/run_on_separate_thread").operator int();
|
||||
|
||||
if (thread_type == 0) { // Threads disabled
|
||||
using_threads = false;
|
||||
} else if (thread_type == 1) { // Just runtime game threads
|
||||
using_threads = !Engine::get_singleton()->is_editor_hint();
|
||||
} else if (thread_type == 2) { // Both runtime game and editor threads
|
||||
using_threads = true;
|
||||
}
|
||||
#else
|
||||
bool using_threads = false;
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue
Block a user