summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.github/ISSUE_TEMPLATE/bug_report.yml2
-rw-r--r--core/extension/gdnative_interface.cpp24
-rw-r--r--core/input/input.cpp5
-rw-r--r--core/math/geometry_2d.h3
-rw-r--r--core/os/memory.h14
-rw-r--r--core/string/ustring.cpp95
-rw-r--r--core/templates/cowdata.h8
-rw-r--r--core/templates/paged_allocator.h5
-rw-r--r--doc/classes/Control.xml12
-rw-r--r--doc/classes/DirectionalLight3D.xml1
-rw-r--r--doc/classes/PhysicsServer2D.xml16
-rw-r--r--doc/classes/SpotLight3D.xml3
-rw-r--r--doc/classes/Viewport.xml10
-rw-r--r--doc/classes/VisualShaderNodeTransformMult.xml32
-rw-r--r--doc/classes/VisualShaderNodeTransformOp.xml50
-rw-r--r--doc/classes/WorldMarginShape2D.xml (renamed from doc/classes/LineShape2D.xml)2
-rwxr-xr-xdoc/tools/makerst.py3
-rw-r--r--editor/code_editor.cpp39
-rw-r--r--editor/code_editor.h1
-rw-r--r--editor/editor_inspector.cpp4
-rw-r--r--editor/editor_log.cpp2
-rw-r--r--editor/editor_node.cpp10
-rw-r--r--editor/editor_themes.cpp31
-rw-r--r--editor/icons/WorldMarginShape2D.svg (renamed from editor/icons/LineShape2D.svg)0
-rw-r--r--editor/plugins/abstract_polygon_2d_editor.cpp4
-rw-r--r--editor/plugins/canvas_item_editor_plugin.cpp119
-rw-r--r--editor/plugins/canvas_item_editor_plugin.h9
-rw-r--r--editor/plugins/collision_shape_2d_editor_plugin.cpp22
-rw-r--r--editor/plugins/collision_shape_2d_editor_plugin.h2
-rw-r--r--editor/plugins/node_3d_editor_plugin.cpp92
-rw-r--r--editor/plugins/node_3d_editor_plugin.h12
-rw-r--r--editor/plugins/path_2d_editor_plugin.cpp2
-rw-r--r--editor/plugins/script_editor_plugin.cpp4
-rw-r--r--editor/plugins/script_text_editor.cpp15
-rw-r--r--editor/plugins/visual_shader_editor_plugin.cpp118
-rw-r--r--editor/plugins/visual_shader_editor_plugin.h8
-rw-r--r--modules/denoise/lightmap_denoiser.cpp2
-rw-r--r--modules/gdnative/gdnative/packed_arrays.cpp2
-rw-r--r--modules/gdnative/gdnative/variant.cpp116
-rw-r--r--modules/gdscript/gdscript_editor.cpp26
-rw-r--r--modules/gdscript/language_server/gdscript_text_document.cpp4
-rw-r--r--platform/osx/export/export_plugin.cpp16
-rw-r--r--scene/2d/animated_sprite_2d.cpp1
-rw-r--r--scene/2d/animated_sprite_2d.h1
-rw-r--r--scene/2d/area_2d.cpp1
-rw-r--r--scene/2d/audio_stream_player_2d.cpp1
-rw-r--r--scene/2d/audio_stream_player_2d.h1
-rw-r--r--scene/2d/camera_2d.cpp15
-rw-r--r--scene/2d/camera_2d.h1
-rw-r--r--scene/2d/collision_polygon_2d.cpp1
-rw-r--r--scene/2d/collision_polygon_2d.h1
-rw-r--r--scene/2d/collision_shape_2d.cpp6
-rw-r--r--scene/2d/cpu_particles_2d.cpp2
-rw-r--r--scene/2d/cpu_particles_2d.h2
-rw-r--r--scene/2d/gpu_particles_2d.cpp2
-rw-r--r--scene/2d/gpu_particles_2d.h2
-rw-r--r--scene/2d/joints_2d.cpp4
-rw-r--r--scene/2d/light_2d.cpp3
-rw-r--r--scene/2d/line_builder.h3
-rw-r--r--scene/2d/navigation_agent_2d.cpp9
-rw-r--r--scene/2d/navigation_agent_2d.h1
-rw-r--r--scene/2d/navigation_obstacle_2d.cpp7
-rw-r--r--scene/2d/navigation_region_2d.cpp1
-rw-r--r--scene/2d/node_2d.cpp5
-rw-r--r--scene/2d/parallax_background.h2
-rw-r--r--scene/2d/parallax_layer.cpp1
-rw-r--r--scene/2d/path_2d.cpp2
-rw-r--r--scene/2d/physics_body_2d.cpp5
-rw-r--r--scene/2d/position_2d.cpp3
-rw-r--r--scene/2d/ray_cast_2d.cpp3
-rw-r--r--scene/2d/remote_transform_2d.cpp1
-rw-r--r--scene/2d/skeleton_2d.cpp6
-rw-r--r--scene/2d/sprite_2d.cpp1
-rw-r--r--scene/2d/tile_map.cpp2
-rw-r--r--scene/2d/tile_map.h2
-rw-r--r--scene/2d/touch_screen_button.cpp5
-rw-r--r--scene/2d/visible_on_screen_notifier_2d.cpp6
-rw-r--r--scene/3d/SCsub5
-rw-r--r--scene/3d/area_3d.cpp1
-rw-r--r--scene/3d/audio_stream_player_3d.cpp5
-rw-r--r--scene/3d/audio_stream_player_3d.h2
-rw-r--r--scene/3d/camera_3d.cpp4
-rw-r--r--scene/3d/camera_3d.h3
-rw-r--r--scene/3d/collision_object_3d.cpp1
-rw-r--r--scene/3d/collision_object_3d.h2
-rw-r--r--scene/3d/collision_polygon_3d.cpp1
-rw-r--r--scene/3d/collision_shape_3d.cpp2
-rw-r--r--scene/3d/collision_shape_3d.h1
-rw-r--r--scene/3d/cpu_particles_3d.cpp2
-rw-r--r--scene/3d/cpu_particles_3d.h2
-rw-r--r--scene/3d/decal.h2
-rw-r--r--scene/3d/gpu_particles_3d.cpp4
-rw-r--r--scene/3d/gpu_particles_3d.h2
-rw-r--r--scene/3d/gpu_particles_collision_3d.cpp1
-rw-r--r--scene/3d/gpu_particles_collision_3d.h2
-rw-r--r--scene/3d/light_3d.cpp13
-rw-r--r--scene/3d/light_3d.h2
-rw-r--r--scene/3d/lightmap_gi.cpp7
-rw-r--r--scene/3d/lightmap_gi.h3
-rw-r--r--scene/3d/lightmapper.h5
-rw-r--r--scene/3d/listener_3d.cpp2
-rw-r--r--scene/3d/listener_3d.h1
-rw-r--r--scene/3d/mesh_instance_3d.cpp2
-rw-r--r--scene/3d/mesh_instance_3d.h6
-rw-r--r--scene/3d/navigation_agent_3d.cpp1
-rw-r--r--scene/3d/navigation_agent_3d.h1
-rw-r--r--scene/3d/navigation_obstacle_3d.h1
-rw-r--r--scene/3d/navigation_region_3d.cpp1
-rw-r--r--scene/3d/navigation_region_3d.h1
-rw-r--r--scene/3d/node_3d.cpp4
-rw-r--r--scene/3d/node_3d.h1
-rw-r--r--scene/3d/path_3d.cpp3
-rw-r--r--scene/3d/physics_body_3d.cpp6
-rw-r--r--scene/3d/physics_joint_3d.cpp4
-rw-r--r--scene/3d/position_3d.cpp1
-rw-r--r--scene/3d/ray_cast_3d.cpp2
-rw-r--r--scene/3d/reflection_probe.h3
-rw-r--r--scene/3d/skeleton_3d.cpp4
-rw-r--r--scene/3d/skeleton_3d.h1
-rw-r--r--scene/3d/skeleton_ik_3d.h5
-rw-r--r--scene/3d/soft_body_3d.cpp6
-rw-r--r--scene/3d/spring_arm_3d.cpp5
-rw-r--r--scene/3d/sprite_3d.h2
-rw-r--r--scene/3d/velocity_tracker_3d.cpp1
-rw-r--r--scene/3d/visible_on_screen_notifier_3d.cpp4
-rw-r--r--scene/3d/visual_instance_3d.cpp4
-rw-r--r--scene/3d/visual_instance_3d.h3
-rw-r--r--scene/3d/voxel_gi.cpp3
-rw-r--r--scene/3d/voxel_gi.h1
-rw-r--r--scene/3d/voxelizer.cpp5
-rw-r--r--scene/3d/voxelizer.h2
-rw-r--r--scene/3d/world_environment.cpp1
-rw-r--r--scene/3d/world_environment.h2
-rw-r--r--scene/3d/xr_nodes.cpp3
-rw-r--r--scene/3d/xr_nodes.h2
-rw-r--r--scene/SCsub3
-rw-r--r--scene/animation/animation_player.cpp6
-rw-r--r--scene/debugger/scene_debugger.cpp4
-rw-r--r--scene/gui/code_edit.cpp31
-rw-r--r--scene/gui/control.cpp50
-rw-r--r--scene/gui/control.h5
-rw-r--r--scene/gui/popup.h2
-rw-r--r--scene/gui/text_edit.cpp59
-rw-r--r--scene/gui/text_edit.h2
-rw-r--r--scene/main/canvas_item.cpp278
-rw-r--r--scene/main/canvas_item.h125
-rw-r--r--scene/main/canvas_layer.h1
-rw-r--r--scene/main/http_request.cpp2
-rw-r--r--scene/main/http_request.h6
-rw-r--r--scene/main/node.cpp4
-rw-r--r--scene/main/scene_tree.cpp15
-rw-r--r--scene/main/shader_globals_override.cpp3
-rw-r--r--scene/main/shader_globals_override.h2
-rw-r--r--scene/main/timer.cpp2
-rw-r--r--scene/main/viewport.cpp45
-rw-r--r--scene/main/viewport.h23
-rw-r--r--scene/main/window.cpp2
-rw-r--r--scene/main/window.h6
-rw-r--r--scene/register_scene_types.cpp8
-rw-r--r--scene/resources/canvas_item_material.cpp301
-rw-r--r--scene/resources/canvas_item_material.h151
-rw-r--r--scene/resources/material.cpp4
-rw-r--r--scene/resources/packed_scene.cpp8
-rw-r--r--scene/resources/skeleton_modification_2d.cpp8
-rw-r--r--scene/resources/skeleton_modification_2d_ccdik.cpp8
-rw-r--r--scene/resources/skeleton_modification_2d_fabrik.cpp10
-rw-r--r--scene/resources/skeleton_modification_2d_jiggle.cpp6
-rw-r--r--scene/resources/skeleton_modification_2d_lookat.cpp2
-rw-r--r--scene/resources/skeleton_modification_2d_twoboneik.cpp4
-rw-r--r--scene/resources/visual_shader_nodes.cpp84
-rw-r--r--scene/resources/visual_shader_nodes.h22
-rw-r--r--scene/resources/world_margin_shape_2d.cpp (renamed from scene/resources/line_shape_2d.cpp)36
-rw-r--r--scene/resources/world_margin_shape_2d.h (renamed from scene/resources/line_shape_2d.h)16
-rw-r--r--servers/physics_2d/collision_solver_2d_sat.cpp4
-rw-r--r--servers/physics_2d/collision_solver_2d_sw.cpp18
-rw-r--r--servers/physics_2d/collision_solver_2d_sw.h2
-rw-r--r--servers/physics_2d/physics_server_2d_sw.cpp8
-rw-r--r--servers/physics_2d/physics_server_2d_sw.h2
-rw-r--r--servers/physics_2d/physics_server_2d_wrap_mt.h2
-rw-r--r--servers/physics_2d/shape_2d_sw.cpp12
-rw-r--r--servers/physics_2d/shape_2d_sw.h6
-rw-r--r--servers/physics_server_2d.cpp4
-rw-r--r--servers/physics_server_2d.h4
-rw-r--r--servers/rendering/renderer_rd/effects_rd.cpp321
-rw-r--r--servers/rendering/renderer_rd/effects_rd.h87
-rw-r--r--servers/rendering/renderer_rd/renderer_scene_render_rd.cpp86
-rw-r--r--servers/rendering/renderer_rd/renderer_scene_render_rd.h9
-rw-r--r--servers/rendering/renderer_rd/shaders/blur_raster.glsl98
-rw-r--r--servers/rendering/renderer_rd/shaders/blur_raster_inc.glsl15
-rw-r--r--servers/rendering/renderer_rd/shaders/bokeh_dof.glsl38
-rw-r--r--servers/rendering/renderer_rd/shaders/bokeh_dof_inc.glsl37
-rw-r--r--servers/rendering/renderer_rd/shaders/bokeh_dof_raster.glsl253
-rw-r--r--servers/rendering/renderer_rd/shaders/scene_forward_lights_inc.glsl25
-rw-r--r--servers/rendering/renderer_scene_cull.cpp75
-rw-r--r--servers/rendering_server.cpp2
-rw-r--r--tests/test_physics_2d.cpp2
196 files changed, 2016 insertions, 1658 deletions
diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml
index 43ba5ef357..2c2a963a26 100644
--- a/.github/ISSUE_TEMPLATE/bug_report.yml
+++ b/.github/ISSUE_TEMPLATE/bug_report.yml
@@ -5,7 +5,7 @@ body:
- type: markdown
attributes:
value: |
- - Read our [CONTRIBUTING.md guide](CONTRIBUTING.md#reporting-bugs) on reporting bugs.
+ - Read our [CONTRIBUTING.md guide](https://github.com/godotengine/godot/blob/master/CONTRIBUTING.md#reporting-bugs) on reporting bugs.
- Write a descriptive issue title above.
- Search [open](https://github.com/godotengine/godot/issues) and [closed](https://github.com/godotengine/godot/issues?q=is%3Aissue+is%3Aclosed) issues to ensure it has not already been reported.
- Verify that you are using a [supported Godot version](https://docs.godotengine.org/en/stable/about/release_policy.html).
diff --git a/core/extension/gdnative_interface.cpp b/core/extension/gdnative_interface.cpp
index a444b2e18e..e0ebd19376 100644
--- a/core/extension/gdnative_interface.cpp
+++ b/core/extension/gdnative_interface.cpp
@@ -74,8 +74,6 @@ static void gdnative_variant_destroy(GDNativeVariantPtr p_self) {
// variant type
-#define memnew_placement_custom(m_placement, m_class, m_constr) _post_initialize(new (m_placement, sizeof(m_class), "") m_constr)
-
static void gdnative_variant_call(GDNativeVariantPtr p_self, const GDNativeStringNamePtr p_method, const GDNativeVariantPtr *p_args, const GDNativeInt p_argcount, GDNativeVariantPtr r_return, GDNativeCallError *r_error) {
Variant *self = (Variant *)p_self;
const StringName *method = (const StringName *)p_method;
@@ -83,7 +81,7 @@ static void gdnative_variant_call(GDNativeVariantPtr p_self, const GDNativeStrin
Variant ret;
Callable::CallError error;
self->call(*method, args, p_argcount, ret, error);
- memnew_placement_custom(r_return, Variant, Variant(ret));
+ memnew_placement(r_return, Variant(ret));
if (r_error) {
r_error->error = (GDNativeCallErrorType)(error.error);
@@ -99,7 +97,7 @@ static void gdnative_variant_call_static(GDNativeVariantType p_type, const GDNat
Variant ret;
Callable::CallError error;
Variant::call_static(type, *method, args, p_argcount, ret, error);
- memnew_placement_custom(r_return, Variant, Variant(ret));
+ memnew_placement(r_return, Variant(ret));
if (r_error) {
r_error->error = (GDNativeCallErrorType)error.error;
@@ -164,7 +162,7 @@ static void gdnative_variant_get(const GDNativeVariantPtr p_self, const GDNative
const Variant *key = (const Variant *)p_key;
bool valid;
- memnew_placement_custom(r_ret, Variant, Variant(self->get(*key, &valid)));
+ memnew_placement(r_ret, Variant(self->get(*key, &valid)));
*r_valid = valid;
}
@@ -173,7 +171,7 @@ static void gdnative_variant_get_named(const GDNativeVariantPtr p_self, const GD
const StringName *key = (const StringName *)p_key;
bool valid;
- memnew_placement_custom(r_ret, Variant, Variant(self->get_named(*key, valid)));
+ memnew_placement(r_ret, Variant(self->get_named(*key, valid)));
*r_valid = valid;
}
@@ -182,7 +180,7 @@ static void gdnative_variant_get_keyed(const GDNativeVariantPtr p_self, const GD
const Variant *key = (const Variant *)p_key;
bool valid;
- memnew_placement_custom(r_ret, Variant, Variant(self->get_keyed(*key, valid)));
+ memnew_placement(r_ret, Variant(self->get_keyed(*key, valid)));
*r_valid = valid;
}
@@ -191,7 +189,7 @@ static void gdnative_variant_get_indexed(const GDNativeVariantPtr p_self, GDNati
bool valid;
bool oob;
- memnew_placement_custom(r_ret, Variant, Variant(self->get_indexed(p_index, valid, oob)));
+ memnew_placement(r_ret, Variant(self->get_indexed(p_index, valid, oob)));
*r_valid = valid;
*r_oob = oob;
}
@@ -222,7 +220,7 @@ static void gdnative_variant_iter_get(const GDNativeVariantPtr p_self, GDNativeV
Variant *iter = (Variant *)r_iter;
bool valid;
- memnew_placement_custom(r_ret, Variant, Variant(self->iter_next(*iter, valid)));
+ memnew_placement(r_ret, Variant(self->iter_next(*iter, valid)));
*r_valid = valid;
}
@@ -254,12 +252,12 @@ static void gdnative_variant_interpolate(const GDNativeVariantPtr p_a, const GDN
static void gdnative_variant_duplicate(const GDNativeVariantPtr p_self, GDNativeVariantPtr r_ret, GDNativeBool p_deep) {
const Variant *self = (const Variant *)p_self;
- memnew_placement_custom(r_ret, Variant, Variant(self->duplicate(p_deep)));
+ memnew_placement(r_ret, Variant(self->duplicate(p_deep)));
}
static void gdnative_variant_stringify(const GDNativeVariantPtr p_self, GDNativeStringPtr r_ret) {
const Variant *self = (const Variant *)p_self;
- memnew_placement_custom(r_ret, String, String(*self));
+ memnew_placement(r_ret, String(*self));
}
static GDNativeVariantType gdnative_variant_get_type(const GDNativeVariantPtr p_self) {
@@ -288,7 +286,7 @@ static GDNativeBool gdnative_variant_has_key(const GDNativeVariantPtr p_self, co
static void gdnative_variant_get_type_name(GDNativeVariantType p_type, GDNativeStringPtr r_ret) {
String name = Variant::get_type_name((Variant::Type)p_type);
- memnew_placement_custom(r_ret, String, String(name));
+ memnew_placement(r_ret, String(name));
}
static GDNativeBool gdnative_variant_can_convert(GDNativeVariantType p_from, GDNativeVariantType p_to) {
@@ -508,7 +506,7 @@ static GDNativePtrKeyedChecker gdnative_variant_get_ptr_keyed_checker(GDNativeVa
return (GDNativePtrKeyedChecker)Variant::get_member_ptr_keyed_checker(Variant::Type(p_type));
}
static void gdnative_variant_get_constant_value(GDNativeVariantType p_type, const char *p_constant, GDNativeVariantPtr r_ret) {
- memnew_placement_custom(r_ret, Variant, Variant(Variant::get_constant_value(Variant::Type(p_type), p_constant)));
+ memnew_placement(r_ret, Variant(Variant::get_constant_value(Variant::Type(p_type), p_constant)));
}
static GDNativePtrUtilityFunction gdnative_variant_get_ptr_utility_function(const char *p_function, GDNativeInt p_hash) {
StringName function = p_function;
diff --git a/core/input/input.cpp b/core/input/input.cpp
index 8ba8b892ac..72563cc40a 100644
--- a/core/input/input.cpp
+++ b/core/input/input.cpp
@@ -163,8 +163,7 @@ void Input::_bind_methods() {
void Input::get_argument_options(const StringName &p_function, int p_idx, List<String> *r_options) const {
#ifdef TOOLS_ENABLED
-
- const String quote_style = EDITOR_DEF("text_editor/completion/use_single_quotes", 0) ? "'" : "\"";
+ const String quote_style = EDITOR_GET("text_editor/completion/use_single_quotes") ? "'" : "\"";
String pf = p_function;
if (p_idx == 0 && (pf == "is_action_pressed" || pf == "action_press" || pf == "action_release" ||
@@ -180,7 +179,7 @@ void Input::get_argument_options(const StringName &p_function, int p_idx, List<S
}
String name = pi.name.substr(pi.name.find("/") + 1, pi.name.length());
- r_options->push_back(quote_style + name + quote_style);
+ r_options->push_back(name.quote(quote_style));
}
}
#endif
diff --git a/core/math/geometry_2d.h b/core/math/geometry_2d.h
index a2894bc1d3..e1a5bfe6f2 100644
--- a/core/math/geometry_2d.h
+++ b/core/math/geometry_2d.h
@@ -32,9 +32,8 @@
#define GEOMETRY_2D_H
#include "core/math/delaunay_2d.h"
-#include "core/math/rect2.h"
#include "core/math/triangulate.h"
-#include "core/object/object.h"
+#include "core/math/vector3i.h"
#include "core/templates/vector.h"
class Geometry2D {
diff --git a/core/os/memory.h b/core/os/memory.h
index 9d09626b8c..f67384a17e 100644
--- a/core/os/memory.h
+++ b/core/os/memory.h
@@ -35,6 +35,7 @@
#include "core/templates/safe_refcount.h"
#include <stddef.h>
+#include <new>
#ifndef PAD_ALIGN
#define PAD_ALIGN 16 //must always be greater than this at much
@@ -92,15 +93,8 @@ _ALWAYS_INLINE_ T *_post_initialize(T *p_obj) {
#define memnew(m_class) _post_initialize(new ("") m_class)
-_ALWAYS_INLINE_ void *operator new(size_t p_size, void *p_pointer, size_t check, const char *p_description) {
- //void *failptr=0;
- //ERR_FAIL_COND_V( check < p_size , failptr); /** bug, or strange compiler, most likely */
-
- return p_pointer;
-}
-
#define memnew_allocator(m_class, m_allocator) _post_initialize(new (m_allocator::alloc) m_class)
-#define memnew_placement(m_placement, m_class) _post_initialize(new (m_placement, sizeof(m_class), "") m_class)
+#define memnew_placement(m_placement, m_class) _post_initialize(new (m_placement) m_class)
_ALWAYS_INLINE_ bool predelete_handler(void *) {
return true;
@@ -140,7 +134,7 @@ void memdelete_allocator(T *p_class) {
#define memnew_arr(m_class, m_count) memnew_arr_template<m_class>(m_count)
template <typename T>
-T *memnew_arr_template(size_t p_elements, const char *p_descr = "") {
+T *memnew_arr_template(size_t p_elements) {
if (p_elements == 0) {
return nullptr;
}
@@ -158,7 +152,7 @@ T *memnew_arr_template(size_t p_elements, const char *p_descr = "") {
/* call operator new */
for (size_t i = 0; i < p_elements; i++) {
- new (&elems[i], sizeof(T), p_descr) T;
+ new (&elems[i]) T;
}
}
diff --git a/core/string/ustring.cpp b/core/string/ustring.cpp
index 7beecdb6b5..2fdf6e84e5 100644
--- a/core/string/ustring.cpp
+++ b/core/string/ustring.cpp
@@ -54,11 +54,27 @@
#define snprintf _snprintf_s
#endif
-#define MAX_DECIMALS 32
-#define UPPERCASE(m_c) (((m_c) >= 'a' && (m_c) <= 'z') ? ((m_c) - ('a' - 'A')) : (m_c))
-#define LOWERCASE(m_c) (((m_c) >= 'A' && (m_c) <= 'Z') ? ((m_c) + ('a' - 'A')) : (m_c))
-#define IS_DIGIT(m_d) ((m_d) >= '0' && (m_d) <= '9')
-#define IS_HEX_DIGIT(m_d) (((m_d) >= '0' && (m_d) <= '9') || ((m_d) >= 'a' && (m_d) <= 'f') || ((m_d) >= 'A' && (m_d) <= 'F'))
+static const int MAX_DECIMALS = 32;
+
+static _FORCE_INLINE_ bool is_digit(char32_t c) {
+ return (c >= '0' && c <= '9');
+}
+
+static _FORCE_INLINE_ bool is_hex_digit(char32_t c) {
+ return (is_digit(c) || (c >= 'a' && c <= 'f') || (c >= 'A' && c <= 'F'));
+}
+
+static _FORCE_INLINE_ bool is_upper_case(char32_t c) {
+ return (c >= 'A' && c <= 'Z');
+}
+
+static _FORCE_INLINE_ bool is_lower_case(char32_t c) {
+ return (c >= 'a' && c <= 'z');
+}
+
+static _FORCE_INLINE_ char32_t lower_case(char32_t c) {
+ return (is_upper_case(c) ? (c + ('a' - 'A')) : c);
+}
const char CharString::_null = 0;
const char16_t Char16String::_null = 0;
@@ -738,6 +754,7 @@ bool String::operator<=(const String &p_str) const {
bool String::operator>(const String &p_str) const {
return p_str < *this;
}
+
bool String::operator>=(const String &p_str) const {
return !(*this < p_str);
}
@@ -871,8 +888,8 @@ signed char String::naturalnocasecmp_to(const String &p_str) const {
while (*this_str) {
if (!*that_str) {
return 1;
- } else if (IS_DIGIT(*this_str)) {
- if (!IS_DIGIT(*that_str)) {
+ } else if (is_digit(*this_str)) {
+ if (!is_digit(*that_str)) {
return -1;
}
@@ -881,10 +898,10 @@ signed char String::naturalnocasecmp_to(const String &p_str) const {
const char32_t *that_substr = that_str;
// Compare lengths of both numerical sequences, ignoring leading zeros
- while (IS_DIGIT(*this_str)) {
+ while (is_digit(*this_str)) {
this_str++;
}
- while (IS_DIGIT(*that_str)) {
+ while (is_digit(*that_str)) {
that_str++;
}
while (*this_substr == '0') {
@@ -912,7 +929,7 @@ signed char String::naturalnocasecmp_to(const String &p_str) const {
this_substr++;
that_substr++;
}
- } else if (IS_DIGIT(*that_str)) {
+ } else if (is_digit(*that_str)) {
return 1;
} else {
if (_find_upper(*this_str) < _find_upper(*that_str)) { //more than
@@ -962,26 +979,25 @@ String String::capitalize() const {
String String::camelcase_to_underscore(bool lowercase) const {
const char32_t *cstr = get_data();
String new_string;
- const char A = 'A', Z = 'Z';
- const char a = 'a', z = 'z';
int start_index = 0;
for (int i = 1; i < this->size(); i++) {
- bool is_upper = cstr[i] >= A && cstr[i] <= Z;
- bool is_number = cstr[i] >= '0' && cstr[i] <= '9';
+ bool is_upper = is_upper_case(cstr[i]);
+ bool is_number = is_digit(cstr[i]);
+
bool are_next_2_lower = false;
bool is_next_lower = false;
bool is_next_number = false;
- bool was_precedent_upper = cstr[i - 1] >= A && cstr[i - 1] <= Z;
- bool was_precedent_number = cstr[i - 1] >= '0' && cstr[i - 1] <= '9';
+ bool was_precedent_upper = is_upper_case(cstr[i - 1]);
+ bool was_precedent_number = is_digit(cstr[i - 1]);
if (i + 2 < this->size()) {
- are_next_2_lower = cstr[i + 1] >= a && cstr[i + 1] <= z && cstr[i + 2] >= a && cstr[i + 2] <= z;
+ are_next_2_lower = is_lower_case(cstr[i + 1]) && is_lower_case(cstr[i + 2]);
}
if (i + 1 < this->size()) {
- is_next_lower = cstr[i + 1] >= a && cstr[i + 1] <= z;
- is_next_number = cstr[i + 1] >= '0' && cstr[i + 1] <= '9';
+ is_next_lower = is_lower_case(cstr[i + 1]);
+ is_next_number = is_digit(cstr[i + 1]);
}
const bool cond_a = is_upper && !was_precedent_upper && !was_precedent_number;
@@ -2198,9 +2214,9 @@ int64_t String::hex_to_int() const {
int64_t hex = 0;
while (*s) {
- char32_t c = LOWERCASE(*s);
+ char32_t c = lower_case(*s);
int64_t n;
- if (c >= '0' && c <= '9') {
+ if (is_digit(c)) {
n = c - '0';
} else if (c >= 'a' && c <= 'f') {
n = (c - 'a') + 10;
@@ -2239,7 +2255,7 @@ int64_t String::bin_to_int() const {
int64_t binary = 0;
while (*s) {
- char32_t c = LOWERCASE(*s);
+ char32_t c = lower_case(*s);
int64_t n;
if (c == '0' || c == '1') {
n = c - '0';
@@ -2269,7 +2285,7 @@ int64_t String::to_int() const {
for (int i = 0; i < to; i++) {
char32_t c = operator[](i);
- if (c >= '0' && c <= '9') {
+ if (is_digit(c)) {
bool overflow = (integer > INT64_MAX / 10) || (integer == INT64_MAX / 10 && ((sign == 1 && c > '7') || (sign == -1 && c > '8')));
ERR_FAIL_COND_V_MSG(overflow, sign == 1 ? INT64_MAX : INT64_MIN, "Cannot represent " + *this + " as 64-bit integer, provided value is " + (sign == 1 ? "too big." : "too small."));
integer *= 10;
@@ -2298,7 +2314,7 @@ int64_t String::to_int(const char *p_str, int p_len) {
for (int i = 0; i < to; i++) {
char c = p_str[i];
- if (c >= '0' && c <= '9') {
+ if (is_digit(c)) {
bool overflow = (integer > INT64_MAX / 10) || (integer == INT64_MAX / 10 && ((sign == 1 && c > '7') || (sign == -1 && c > '8')));
ERR_FAIL_COND_V_MSG(overflow, sign == 1 ? INT64_MAX : INT64_MIN, "Cannot represent " + String(p_str).substr(0, to) + " as integer, provided value is " + (sign == 1 ? "too big." : "too small."));
integer *= 10;
@@ -2329,7 +2345,7 @@ int64_t String::to_int(const wchar_t *p_str, int p_len) {
for (int i = 0; i < to; i++) {
wchar_t c = p_str[i];
- if (c >= '0' && c <= '9') {
+ if (is_digit(c)) {
bool overflow = (integer > INT64_MAX / 10) || (integer == INT64_MAX / 10 && ((sign == 1 && c > '7') || (sign == -1 && c > '8')));
ERR_FAIL_COND_V_MSG(overflow, sign == 1 ? INT64_MAX : INT64_MIN, "Cannot represent " + String(p_str).substr(0, to) + " as integer, provided value is " + (sign == 1 ? "too big." : "too small."));
integer *= 10;
@@ -2449,7 +2465,7 @@ static double built_in_strtod(const C *string, /* A decimal ASCII floating-point
decPt = -1;
for (mantSize = 0;; mantSize += 1) {
c = *p;
- if (!IS_DIGIT(c)) {
+ if (!is_digit(c)) {
if ((c != '.') || (decPt >= 0)) {
break;
}
@@ -2524,11 +2540,11 @@ static double built_in_strtod(const C *string, /* A decimal ASCII floating-point
}
expSign = false;
}
- if (!IS_DIGIT(char32_t(*p))) {
+ if (!is_digit(char32_t(*p))) {
p = pExp;
goto done;
}
- while (IS_DIGIT(char32_t(*p))) {
+ while (is_digit(char32_t(*p))) {
exp = exp * 10 + (*p - '0');
p += 1;
}
@@ -2614,7 +2630,7 @@ int64_t String::to_int(const char32_t *p_str, int p_len, bool p_clamp) {
char32_t c = *(str++);
switch (reading) {
case READING_SIGN: {
- if (c >= '0' && c <= '9') {
+ if (is_digit(c)) {
reading = READING_INT;
// let it fallthrough
} else if (c == '-') {
@@ -2631,7 +2647,7 @@ int64_t String::to_int(const char32_t *p_str, int p_len, bool p_clamp) {
[[fallthrough]];
}
case READING_INT: {
- if (c >= '0' && c <= '9') {
+ if (is_digit(c)) {
if (integer > INT64_MAX / 10) {
String number("");
str = p_str;
@@ -3800,12 +3816,12 @@ bool String::is_valid_identifier() const {
for (int i = 0; i < len; i++) {
if (i == 0) {
- if (str[0] >= '0' && str[0] <= '9') {
+ if (is_digit(str[0])) {
return false; // no start with number plz
}
}
- bool valid_char = (str[i] >= '0' && str[i] <= '9') || (str[i] >= 'a' && str[i] <= 'z') || (str[i] >= 'A' && str[i] <= 'Z') || str[i] == '_';
+ bool valid_char = is_digit(str[i]) || is_lower_case(str[i]) || is_upper_case(str[i]) || str[i] == '_';
if (!valid_char) {
return false;
@@ -3830,10 +3846,7 @@ String String::uri_encode() const {
String res;
for (int i = 0; i < temp.length(); ++i) {
char ord = temp[i];
- if (ord == '.' || ord == '-' || ord == '_' || ord == '~' ||
- (ord >= 'a' && ord <= 'z') ||
- (ord >= 'A' && ord <= 'Z') ||
- (ord >= '0' && ord <= '9')) {
+ if (ord == '.' || ord == '-' || ord == '_' || ord == '~' || is_lower_case(ord) || is_upper_case(ord) || is_digit(ord)) {
res += ord;
} else {
char h_Val[3];
@@ -3855,9 +3868,9 @@ String String::uri_decode() const {
for (int i = 0; i < src.length(); ++i) {
if (src[i] == '%' && i + 2 < src.length()) {
char ord1 = src[i + 1];
- if ((ord1 >= '0' && ord1 <= '9') || (ord1 >= 'A' && ord1 <= 'Z')) {
+ if (is_digit(ord1) || is_upper_case(ord1)) {
char ord2 = src[i + 2];
- if ((ord2 >= '0' && ord2 <= '9') || (ord2 >= 'A' && ord2 <= 'Z')) {
+ if (is_digit(ord2) || is_upper_case(ord2)) {
char bytes[3] = { (char)ord1, (char)ord2, 0 };
res += (char)strtol(bytes, nullptr, 16);
i += 2;
@@ -3963,7 +3976,7 @@ static _FORCE_INLINE_ int _xml_unescape(const char32_t *p_src, int p_src_len, ch
char32_t ct = p_src[i];
if (ct == ';') {
break;
- } else if (ct >= '0' && ct <= '9') {
+ } else if (is_digit(ct)) {
ct = ct - '0';
} else if (ct >= 'a' && ct <= 'f') {
ct = (ct - 'a') + 10;
@@ -4191,7 +4204,7 @@ bool String::is_valid_hex_number(bool p_with_prefix) const {
for (int i = from; i < len; i++) {
char32_t c = operator[](i);
- if ((c >= '0' && c <= '9') || (c >= 'a' && c <= 'f') || (c >= 'A' && c <= 'F')) {
+ if (is_hex_digit(c)) {
continue;
}
return false;
@@ -4219,7 +4232,7 @@ bool String::is_valid_float() const {
bool numbers_found = false;
for (int i = from; i < len; i++) {
- if (operator[](i) >= '0' && operator[](i) <= '9') {
+ if (is_digit(operator[](i))) {
if (exponent_found) {
exponent_values_found = true;
} else {
diff --git a/core/templates/cowdata.h b/core/templates/cowdata.h
index c985593473..ba9babe0af 100644
--- a/core/templates/cowdata.h
+++ b/core/templates/cowdata.h
@@ -232,7 +232,7 @@ uint32_t CowData<T>::_copy_on_write() {
uint32_t *mem_new = (uint32_t *)Memory::alloc_static(_get_alloc_size(current_size), true);
- new (mem_new - 2, sizeof(uint32_t), "") SafeNumeric<uint32_t>(1); //refcount
+ new (mem_new - 2) SafeNumeric<uint32_t>(1); //refcount
*(mem_new - 1) = current_size; //size
T *_data = (T *)(mem_new);
@@ -286,14 +286,14 @@ Error CowData<T>::resize(int p_size) {
uint32_t *ptr = (uint32_t *)Memory::alloc_static(alloc_size, true);
ERR_FAIL_COND_V(!ptr, ERR_OUT_OF_MEMORY);
*(ptr - 1) = 0; //size, currently none
- new (ptr - 2, sizeof(uint32_t), "") SafeNumeric<uint32_t>(1); //refcount
+ new (ptr - 2) SafeNumeric<uint32_t>(1); //refcount
_ptr = (T *)ptr;
} else {
uint32_t *_ptrnew = (uint32_t *)Memory::realloc_static(_ptr, alloc_size, true);
ERR_FAIL_COND_V(!_ptrnew, ERR_OUT_OF_MEMORY);
- new (_ptrnew - 2, sizeof(uint32_t), "") SafeNumeric<uint32_t>(rc); //refcount
+ new (_ptrnew - 2) SafeNumeric<uint32_t>(rc); //refcount
_ptr = (T *)(_ptrnew);
}
@@ -323,7 +323,7 @@ Error CowData<T>::resize(int p_size) {
if (alloc_size != current_alloc_size) {
uint32_t *_ptrnew = (uint32_t *)Memory::realloc_static(_ptr, alloc_size, true);
ERR_FAIL_COND_V(!_ptrnew, ERR_OUT_OF_MEMORY);
- new (_ptrnew - 2, sizeof(uint32_t), "") SafeNumeric<uint32_t>(rc); //refcount
+ new (_ptrnew - 2) SafeNumeric<uint32_t>(rc); //refcount
_ptr = (T *)(_ptrnew);
}
diff --git a/core/templates/paged_allocator.h b/core/templates/paged_allocator.h
index 481289309f..dfc885c6eb 100644
--- a/core/templates/paged_allocator.h
+++ b/core/templates/paged_allocator.h
@@ -50,7 +50,8 @@ class PagedAllocator {
SpinLock spin_lock;
public:
- T *alloc() {
+ template <class... Args>
+ T *alloc(const Args &&...p_args) {
if (thread_safe) {
spin_lock.lock();
}
@@ -75,7 +76,7 @@ public:
if (thread_safe) {
spin_lock.unlock();
}
- memnew_placement(alloc, T);
+ memnew_placement(alloc, T(p_args...));
return alloc;
}
diff --git a/doc/classes/Control.xml b/doc/classes/Control.xml
index 43e3c97bff..0834521c91 100644
--- a/doc/classes/Control.xml
+++ b/doc/classes/Control.xml
@@ -306,6 +306,18 @@
[/codeblocks]
</description>
</method>
+ <method name="begin_bulk_theme_override">
+ <return type="void" />
+ <description>
+ Prevents [code]*_theme_*_override[/code] methods from emitting [constant NOTIFICATION_THEME_CHANGED] until [method end_bulk_theme_override] is called.
+ </description>
+ </method>
+ <method name="end_bulk_theme_override">
+ <return type="void" />
+ <description>
+ Ends a bulk theme override update. See [method begin_bulk_theme_override].
+ </description>
+ </method>
<method name="find_next_valid_focus" qualifiers="const">
<return type="Control" />
<description>
diff --git a/doc/classes/DirectionalLight3D.xml b/doc/classes/DirectionalLight3D.xml
index 4f51adb8fc..0060368207 100644
--- a/doc/classes/DirectionalLight3D.xml
+++ b/doc/classes/DirectionalLight3D.xml
@@ -36,7 +36,6 @@
<member name="directional_shadow_split_3" type="float" setter="set_param" getter="get_param" default="0.5">
The distance from shadow split 2 to split 3. Relative to [member directional_shadow_max_distance]. Only used when [member directional_shadow_mode] is [code]SHADOW_PARALLEL_4_SPLITS[/code].
</member>
- <member name="shadow_bias" type="float" setter="set_param" getter="get_param" override="true" default="0.05" />
<member name="shadow_normal_bias" type="float" setter="set_param" getter="get_param" override="true" default="1.0" />
<member name="use_in_sky_only" type="bool" setter="set_sky_only" getter="is_sky_only" default="false">
If [code]true[/code], this [DirectionalLight3D] will not be used for anything except sky shaders. Use this for lights that impact your sky shader that you may want to hide from affecting the rest of the scene. For example, you may want to enable this when the sun in your sky shader falls below the horizon.
diff --git a/doc/classes/PhysicsServer2D.xml b/doc/classes/PhysicsServer2D.xml
index 387d79d210..1df2fd0158 100644
--- a/doc/classes/PhysicsServer2D.xml
+++ b/doc/classes/PhysicsServer2D.xml
@@ -716,11 +716,6 @@
Sets a joint parameter. See [enum JointParam] for a list of available parameters.
</description>
</method>
- <method name="line_shape_create">
- <return type="RID" />
- <description>
- </description>
- </method>
<method name="rectangle_shape_create">
<return type="RID" />
<description>
@@ -812,6 +807,11 @@
Sets the value for a space parameter. See [enum SpaceParameter] for a list of available parameters.
</description>
</method>
+ <method name="world_margin_shape_create">
+ <return type="RID" />
+ <description>
+ </description>
+ </method>
</methods>
<constants>
<constant name="SPACE_PARAM_CONTACT_RECYCLE_RADIUS" value="0" enum="SpaceParameter">
@@ -837,11 +837,11 @@
</constant>
<constant name="SPACE_PARAM_TEST_MOTION_MIN_CONTACT_DEPTH" value="7" enum="SpaceParameter">
</constant>
- <constant name="SHAPE_LINE" value="0" enum="ShapeType">
- This is the constant for creating line shapes. A line shape is an infinite line with an origin point, and a normal. Thus, it can be used for front/behind checks.
+ <constant name="SHAPE_WORLD_MARGIN" value="0" enum="ShapeType">
+ This is the constant for creating world margin shapes. A world margin shape is an [i]infinite[/i] line with an origin point, and a normal. Thus, it can be used for front/behind checks.
</constant>
<constant name="SHAPE_SEGMENT" value="1" enum="ShapeType">
- This is the constant for creating segment shapes. A segment shape is a line from a point A to a point B. It can be checked for intersections.
+ This is the constant for creating segment shapes. A segment shape is a [i]finite[/i] line from a point A to a point B. It can be checked for intersections.
</constant>
<constant name="SHAPE_CIRCLE" value="2" enum="ShapeType">
This is the constant for creating circle shapes. A circle shape only has a radius. It can be used for intersections and inside/outside checks.
diff --git a/doc/classes/SpotLight3D.xml b/doc/classes/SpotLight3D.xml
index f868503bbd..fde40ba6de 100644
--- a/doc/classes/SpotLight3D.xml
+++ b/doc/classes/SpotLight3D.xml
@@ -13,8 +13,7 @@
<methods>
</methods>
<members>
- <member name="shadow_bias" type="float" setter="set_param" getter="get_param" override="true" default="0.02" />
- <member name="shadow_normal_bias" type="float" setter="set_param" getter="get_param" override="true" default="1.0" />
+ <member name="shadow_bias" type="float" setter="set_param" getter="get_param" override="true" default="0.03" />
<member name="spot_angle" type="float" setter="set_param" getter="get_param" default="45.0">
The spotlight's angle in degrees.
</member>
diff --git a/doc/classes/Viewport.xml b/doc/classes/Viewport.xml
index 7b5cb2c459..4a62d3ec7b 100644
--- a/doc/classes/Viewport.xml
+++ b/doc/classes/Viewport.xml
@@ -296,19 +296,19 @@
Represents the size of the [enum ShadowAtlasQuadrantSubdiv] enum.
</constant>
<constant name="MSAA_DISABLED" value="0" enum="MSAA">
- Multisample antialiasing mode disabled. This is the default value, and also the fastest setting.
+ Multisample antialiasing mode disabled. This is the default value, and is also the fastest setting.
</constant>
<constant name="MSAA_2X" value="1" enum="MSAA">
- Use 2x Multisample Antialiasing.
+ Use 2× Multisample Antialiasing. This has a moderate performance cost. It helps reduce aliasing noticeably, but 4× MSAA still looks substantially better.
</constant>
<constant name="MSAA_4X" value="2" enum="MSAA">
- Use 4x Multisample Antialiasing.
+ Use 4× Multisample Antialiasing. This has a significant performance cost, and is generally a good compromise between performance and quality.
</constant>
<constant name="MSAA_8X" value="3" enum="MSAA">
- Use 8x Multisample Antialiasing. Likely unsupported on low-end and older hardware.
+ Use 8× Multisample Antialiasing. This has a very high performance cost. The difference between 4× and 8× MSAA may not always be visible in real gameplay conditions. Likely unsupported on low-end and older hardware.
</constant>
<constant name="MSAA_16X" value="4" enum="MSAA">
- Use 16x Multisample Antialiasing. Likely unsupported on medium and low-end hardware.
+ Use 16× Multisample Antialiasing. This has a very high performance cost. The difference between 8× and 16× MSAA may not always be visible in real gameplay conditions. Likely unsupported on medium and low-end hardware.
</constant>
<constant name="MSAA_MAX" value="5" enum="MSAA">
Represents the size of the [enum MSAA] enum.
diff --git a/doc/classes/VisualShaderNodeTransformMult.xml b/doc/classes/VisualShaderNodeTransformMult.xml
deleted file mode 100644
index f26f60a1f3..0000000000
--- a/doc/classes/VisualShaderNodeTransformMult.xml
+++ /dev/null
@@ -1,32 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" ?>
-<class name="VisualShaderNodeTransformMult" inherits="VisualShaderNode" version="4.0">
- <brief_description>
- Multiplies [Transform3D] by [Transform3D] within the visual shader graph.
- </brief_description>
- <description>
- A multiplication operation on two transforms (4x4 matrices), with support for different multiplication operators.
- </description>
- <tutorials>
- </tutorials>
- <methods>
- </methods>
- <members>
- <member name="operator" type="int" setter="set_operator" getter="get_operator" enum="VisualShaderNodeTransformMult.Operator" default="0">
- The multiplication type to be performed on the transforms. See [enum Operator] for options.
- </member>
- </members>
- <constants>
- <constant name="OP_AxB" value="0" enum="Operator">
- Multiplies transform [code]a[/code] by the transform [code]b[/code].
- </constant>
- <constant name="OP_BxA" value="1" enum="Operator">
- Multiplies transform [code]b[/code] by the transform [code]a[/code].
- </constant>
- <constant name="OP_AxB_COMP" value="2" enum="Operator">
- Performs a component-wise multiplication of transform [code]a[/code] by the transform [code]b[/code].
- </constant>
- <constant name="OP_BxA_COMP" value="3" enum="Operator">
- Performs a component-wise multiplication of transform [code]b[/code] by the transform [code]a[/code].
- </constant>
- </constants>
-</class>
diff --git a/doc/classes/VisualShaderNodeTransformOp.xml b/doc/classes/VisualShaderNodeTransformOp.xml
new file mode 100644
index 0000000000..a628fa3e8d
--- /dev/null
+++ b/doc/classes/VisualShaderNodeTransformOp.xml
@@ -0,0 +1,50 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<class name="VisualShaderNodeTransformOp" inherits="VisualShaderNode" version="4.0">
+ <brief_description>
+ A [Transform3D] operator to be used within the visual shader graph.
+ </brief_description>
+ <description>
+ Applies [member operator] to two transform (4x4 matrices) inputs.
+ </description>
+ <tutorials>
+ </tutorials>
+ <methods>
+ </methods>
+ <members>
+ <member name="operator" type="int" setter="set_operator" getter="get_operator" enum="VisualShaderNodeTransformOp.Operator" default="0">
+ The type of the operation to be performed on the transforms. See [enum Operator] for options.
+ </member>
+ </members>
+ <constants>
+ <constant name="OP_AxB" value="0" enum="Operator">
+ Multiplies transform [code]a[/code] by the transform [code]b[/code].
+ </constant>
+ <constant name="OP_BxA" value="1" enum="Operator">
+ Multiplies transform [code]b[/code] by the transform [code]a[/code].
+ </constant>
+ <constant name="OP_AxB_COMP" value="2" enum="Operator">
+ Performs a component-wise multiplication of transform [code]a[/code] by the transform [code]b[/code].
+ </constant>
+ <constant name="OP_BxA_COMP" value="3" enum="Operator">
+ Performs a component-wise multiplication of transform [code]b[/code] by the transform [code]a[/code].
+ </constant>
+ <constant name="OP_ADD" value="4" enum="Operator">
+ Adds two transforms.
+ </constant>
+ <constant name="OP_A_MINUS_B" value="5" enum="Operator">
+ Subtracts the transform [code]a[/code] from the transform [code]b[/code].
+ </constant>
+ <constant name="OP_B_MINUS_A" value="6" enum="Operator">
+ Subtracts the transform [code]b[/code] from the transform [code]a[/code].
+ </constant>
+ <constant name="OP_A_DIV_B" value="7" enum="Operator">
+ Divides the transform [code]a[/code] by the transform [code]b[/code].
+ </constant>
+ <constant name="OP_B_DIV_A" value="8" enum="Operator">
+ Divides the transform [code]b[/code] by the transform [code]a[/code].
+ </constant>
+ <constant name="OP_LIMITER" value="9" enum="Operator">
+ Represents the size of the [enum Operator] enum.
+ </constant>
+ </constants>
+</class>
diff --git a/doc/classes/LineShape2D.xml b/doc/classes/WorldMarginShape2D.xml
index 434e6fba8e..1839ab16ad 100644
--- a/doc/classes/LineShape2D.xml
+++ b/doc/classes/WorldMarginShape2D.xml
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" ?>
-<class name="LineShape2D" inherits="Shape2D" version="4.0">
+<class name="WorldMarginShape2D" inherits="Shape2D" version="4.0">
<brief_description>
Line shape for 2D collisions.
</brief_description>
diff --git a/doc/tools/makerst.py b/doc/tools/makerst.py
index 770419a37c..6f9a07af1f 100755
--- a/doc/tools/makerst.py
+++ b/doc/tools/makerst.py
@@ -479,7 +479,7 @@ def make_rst_class(class_def, state, dry_run, output_dir): # type: (ClassDef, S
format_table(f, ml)
# Theme properties
- if class_def.theme_items is not None and len(class_def.theme_items) > 0:
+ if len(class_def.theme_items) > 0:
f.write(make_heading("Theme Properties", "-"))
pl = []
for theme_item_def in class_def.theme_items.values():
@@ -601,6 +601,7 @@ def make_rst_class(class_def, state, dry_run, output_dir): # type: (ClassDef, S
index += 1
+ # Theme property descriptions
if len(class_def.theme_items) > 0:
f.write(make_heading("Theme Property Descriptions", "-"))
index = 0
diff --git a/editor/code_editor.cpp b/editor/code_editor.cpp
index 4a3be1d29c..a5943c952b 100644
--- a/editor/code_editor.cpp
+++ b/editor/code_editor.cpp
@@ -1520,40 +1520,12 @@ void CodeTextEditor::goto_error() {
}
void CodeTextEditor::_update_text_editor_theme() {
- text_editor->add_theme_color_override("background_color", EDITOR_GET("text_editor/highlighting/background_color"));
- text_editor->add_theme_color_override("completion_background_color", EDITOR_GET("text_editor/highlighting/completion_background_color"));
- text_editor->add_theme_color_override("completion_selected_color", EDITOR_GET("text_editor/highlighting/completion_selected_color"));
- text_editor->add_theme_color_override("completion_existing_color", EDITOR_GET("text_editor/highlighting/completion_existing_color"));
- text_editor->add_theme_color_override("completion_scroll_color", EDITOR_GET("text_editor/highlighting/completion_scroll_color"));
- text_editor->add_theme_color_override("completion_font_color", EDITOR_GET("text_editor/highlighting/completion_font_color"));
- text_editor->add_theme_color_override("font_color", EDITOR_GET("text_editor/highlighting/text_color"));
- text_editor->add_theme_color_override("line_number_color", EDITOR_GET("text_editor/highlighting/line_number_color"));
- text_editor->add_theme_color_override("caret_color", EDITOR_GET("text_editor/highlighting/caret_color"));
- text_editor->add_theme_color_override("caret_background_color", EDITOR_GET("text_editor/highlighting/caret_background_color"));
- text_editor->add_theme_color_override("font_selected_color", EDITOR_GET("text_editor/highlighting/text_selected_color"));
- text_editor->add_theme_color_override("selection_color", EDITOR_GET("text_editor/highlighting/selection_color"));
- text_editor->add_theme_color_override("brace_mismatch_color", EDITOR_GET("text_editor/highlighting/brace_mismatch_color"));
- text_editor->add_theme_color_override("current_line_color", EDITOR_GET("text_editor/highlighting/current_line_color"));
- text_editor->add_theme_color_override("line_length_guideline_color", EDITOR_GET("text_editor/highlighting/line_length_guideline_color"));
- text_editor->add_theme_color_override("word_highlighted_color", EDITOR_GET("text_editor/highlighting/word_highlighted_color"));
- text_editor->add_theme_color_override("bookmark_color", EDITOR_GET("text_editor/highlighting/bookmark_color"));
- text_editor->add_theme_color_override("breakpoint_color", EDITOR_GET("text_editor/highlighting/breakpoint_color"));
- text_editor->add_theme_color_override("executing_line_color", EDITOR_GET("text_editor/highlighting/executing_line_color"));
- text_editor->add_theme_color_override("code_folding_color", EDITOR_GET("text_editor/highlighting/code_folding_color"));
- text_editor->add_theme_color_override("search_result_color", EDITOR_GET("text_editor/highlighting/search_result_color"));
- text_editor->add_theme_color_override("search_result_border_color", EDITOR_GET("text_editor/highlighting/search_result_border_color"));
- text_editor->add_theme_constant_override("line_spacing", EDITOR_DEF("text_editor/theme/line_spacing", 6));
emit_signal(SNAME("load_theme_settings"));
- _load_theme_settings();
-}
-
-void CodeTextEditor::_update_font() {
- text_editor->add_theme_font_override("font", get_theme_font(SNAME("source"), SNAME("EditorFonts")));
- text_editor->add_theme_font_size_override("font_size", get_theme_font_size(SNAME("source_size"), SNAME("EditorFonts")));
- error->add_theme_font_override("font", get_theme_font(SNAME("status_source"), SNAME("EditorFonts")));
- error->add_theme_font_size_override("font_size", get_theme_font_size(SNAME("status_source_size"), SNAME("EditorFonts")));
- error->add_theme_color_override("font_color", get_theme_color(SNAME("error_color"), SNAME("Editor")));
+ error->begin_bulk_theme_override();
+ error->add_theme_font_override(SNAME("font"), get_theme_font(SNAME("status_source"), SNAME("EditorFonts")));
+ error->add_theme_font_size_override(SNAME("font_size"), get_theme_font_size(SNAME("status_source_size"), SNAME("EditorFonts")));
+ error->add_theme_color_override(SNAME("font_color"), get_theme_color(SNAME("error_color"), SNAME("Editor")));
Ref<Font> status_bar_font = get_theme_font(SNAME("status_source"), SNAME("EditorFonts"));
int status_bar_font_size = get_theme_font_size(SNAME("status_source_size"), SNAME("EditorFonts"));
@@ -1567,6 +1539,7 @@ void CodeTextEditor::_update_font() {
n->add_theme_font_size_override("font_size", status_bar_font_size);
}
}
+ error->end_bulk_theme_override();
}
void CodeTextEditor::_on_settings_change() {
@@ -1582,7 +1555,6 @@ void CodeTextEditor::_apply_settings_change() {
settings_changed = false;
_update_text_editor_theme();
- _update_font();
font_size = EditorSettings::get_singleton()->get("interface/editor/code_font_size");
@@ -1668,7 +1640,6 @@ void CodeTextEditor::_notification(int p_what) {
update_toggle_scripts_button();
}
_update_text_editor_theme();
- _update_font();
} break;
case NOTIFICATION_ENTER_TREE: {
error_button->set_icon(get_theme_icon(SNAME("StatusError"), SNAME("EditorIcons")));
diff --git a/editor/code_editor.h b/editor/code_editor.h
index 4cd4880df0..ee8f4366dd 100644
--- a/editor/code_editor.h
+++ b/editor/code_editor.h
@@ -168,7 +168,6 @@ class CodeTextEditor : public VBoxContainer {
void _apply_settings_change();
void _update_text_editor_theme();
- void _update_font();
void _complete_request();
Ref<Texture2D> _get_completion_icon(const ScriptCodeCompletionOption &p_option);
void _font_resize_timeout();
diff --git a/editor/editor_inspector.cpp b/editor/editor_inspector.cpp
index 679f2e8ce4..9de8b0451a 100644
--- a/editor/editor_inspector.cpp
+++ b/editor/editor_inspector.cpp
@@ -887,7 +887,7 @@ Control *EditorProperty::make_custom_tooltip(const String &p_text) const {
text += "\n" + property_doc;
}
}
- help_bit->set_text(text);
+ help_bit->call_deferred(SNAME("set_text"), text); //hack so it uses proper theme once inside scene
}
return help_bit;
@@ -1102,7 +1102,7 @@ Control *EditorInspectorCategory::make_custom_tooltip(const String &p_text) cons
text += "\n" + property_doc;
}
}
- help_bit->set_text(text); //hack so it uses proper theme once inside scene
+ help_bit->call_deferred(SNAME("set_text"), text); //hack so it uses proper theme once inside scene
}
return help_bit;
diff --git a/editor/editor_log.cpp b/editor/editor_log.cpp
index 2cb73664f5..296a33d917 100644
--- a/editor/editor_log.cpp
+++ b/editor/editor_log.cpp
@@ -397,7 +397,7 @@ EditorLog::EditorLog() {
show_search_button->set_focus_mode(FOCUS_NONE);
show_search_button->set_toggle_mode(true);
show_search_button->set_pressed(true);
- show_search_button->set_shortcut(ED_SHORTCUT("editor/open_search", TTR("Open the search box."), KEY_MASK_CMD | KEY_F));
+ show_search_button->set_shortcut(ED_SHORTCUT("editor/open_search", TTR("Focus Search/Filter Bar"), KEY_MASK_CMD | KEY_F));
show_search_button->set_shortcut_context(this);
show_search_button->connect("toggled", callable_mp(this, &EditorLog::_set_search_visible));
hb_tools2->add_child(show_search_button);
diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp
index 74ee9099f2..19a6d027bc 100644
--- a/editor/editor_node.cpp
+++ b/editor/editor_node.cpp
@@ -6240,9 +6240,9 @@ EditorNode::EditorNode() {
gui_base->add_child(warning);
warning->connect("custom_action", callable_mp(this, &EditorNode::_copy_warning));
- ED_SHORTCUT("editor/next_tab", TTR("Next tab"), KEY_MASK_CMD + KEY_TAB);
- ED_SHORTCUT("editor/prev_tab", TTR("Previous tab"), KEY_MASK_CMD + KEY_MASK_SHIFT + KEY_TAB);
- ED_SHORTCUT("editor/filter_files", TTR("Filter Files..."), KEY_MASK_CMD + KEY_MASK_ALT + KEY_P);
+ ED_SHORTCUT("editor/next_tab", TTR("Next Scene Tab"), KEY_MASK_CMD + KEY_TAB);
+ ED_SHORTCUT("editor/prev_tab", TTR("Previous Scene Tab"), KEY_MASK_CMD + KEY_MASK_SHIFT + KEY_TAB);
+ ED_SHORTCUT("editor/filter_files", TTR("Focus FileSystem Filter"), KEY_MASK_CMD + KEY_MASK_ALT + KEY_P);
command_palette = EditorCommandPalette::get_singleton();
command_palette->set_title(TTR("Command Palette"));
@@ -7056,8 +7056,8 @@ EditorNode::EditorNode() {
ED_SHORTCUT_AND_COMMAND("editor/editor_assetlib", TTR("Open Asset Library"), KEY_MASK_CTRL | KEY_F4);
ED_SHORTCUT("editor/command_palette", TTR("Open Command Palette"), KEY_MASK_CTRL | KEY_MASK_SHIFT | KEY_P);
#endif
- ED_SHORTCUT_AND_COMMAND("editor/editor_next", TTR("Open the next Editor"));
- ED_SHORTCUT_AND_COMMAND("editor/editor_prev", TTR("Open the previous Editor"));
+ ED_SHORTCUT_AND_COMMAND("editor/editor_next", TTR("Next Editor Tab"));
+ ED_SHORTCUT_AND_COMMAND("editor/editor_prev", TTR("Next Editor Tab"));
screenshot_timer = memnew(Timer);
screenshot_timer->set_one_shot(true);
diff --git a/editor/editor_themes.cpp b/editor/editor_themes.cpp
index fe6c081922..e93c8a1a05 100644
--- a/editor/editor_themes.cpp
+++ b/editor/editor_themes.cpp
@@ -1051,19 +1051,17 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) {
theme->set_constant("line_spacing", "TextEdit", 4 * EDSCALE);
// CodeEdit
+ theme->set_font("font", "CodeEdit", theme->get_font("source", "EditorFonts"));
+ theme->set_font_size("font_size", "CodeEdit", theme->get_font_size("source_size", "EditorFonts"));
theme->set_stylebox("normal", "CodeEdit", style_widget);
theme->set_stylebox("focus", "CodeEdit", style_widget_hover);
theme->set_stylebox("read_only", "CodeEdit", style_widget_disabled);
- theme->set_constant("side_margin", "TabContainer", 0);
theme->set_icon("tab", "CodeEdit", theme->get_icon("GuiTab", "EditorIcons"));
theme->set_icon("space", "CodeEdit", theme->get_icon("GuiSpace", "EditorIcons"));
theme->set_icon("folded", "CodeEdit", theme->get_icon("GuiTreeArrowRight", "EditorIcons"));
theme->set_icon("can_fold", "CodeEdit", theme->get_icon("GuiTreeArrowDown", "EditorIcons"));
theme->set_icon("executing_line", "CodeEdit", theme->get_icon("MainPlay", "EditorIcons"));
- theme->set_color("font_color", "CodeEdit", font_color);
- theme->set_color("caret_color", "CodeEdit", font_color);
- theme->set_color("selection_color", "CodeEdit", selection_color);
- theme->set_constant("line_spacing", "CodeEdit", 4 * EDSCALE);
+ theme->set_constant("line_spacing", "CodeEdit", EDITOR_DEF("text_editor/theme/line_spacing", 6));
// H/VSplitContainer
theme->set_stylebox("bg", "VSplitContainer", make_stylebox(theme->get_icon("GuiVsplitBg", "EditorIcons"), 1, 1, 1, 1));
@@ -1474,6 +1472,29 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) {
setting->load_text_editor_theme();
}
+ // Now theme is loaded, apply it to CodeEdit.
+ theme->set_color("background_color", "CodeEdit", EDITOR_GET("text_editor/highlighting/background_color"));
+ theme->set_color("completion_background_color", "CodeEdit", EDITOR_GET("text_editor/highlighting/completion_background_color"));
+ theme->set_color("completion_selected_color", "CodeEdit", EDITOR_GET("text_editor/highlighting/completion_selected_color"));
+ theme->set_color("completion_existing_color", "CodeEdit", EDITOR_GET("text_editor/highlighting/completion_existing_color"));
+ theme->set_color("completion_scroll_color", "CodeEdit", EDITOR_GET("text_editor/highlighting/completion_scroll_color"));
+ theme->set_color("completion_font_color", "CodeEdit", EDITOR_GET("text_editor/highlighting/completion_font_color"));
+ theme->set_color("font_color", "CodeEdit", EDITOR_GET("text_editor/highlighting/text_color"));
+ theme->set_color("line_number_color", "CodeEdit", EDITOR_GET("text_editor/highlighting/line_number_color"));
+ theme->set_color("caret_color", "CodeEdit", EDITOR_GET("text_editor/highlighting/caret_color"));
+ theme->set_color("font_selected_color", "CodeEdit", EDITOR_GET("text_editor/highlighting/text_selected_color"));
+ theme->set_color("selection_color", "CodeEdit", EDITOR_GET("text_editor/highlighting/selection_color"));
+ theme->set_color("brace_mismatch_color", "CodeEdit", EDITOR_GET("text_editor/highlighting/brace_mismatch_color"));
+ theme->set_color("current_line_color", "CodeEdit", EDITOR_GET("text_editor/highlighting/current_line_color"));
+ theme->set_color("line_length_guideline_color", "CodeEdit", EDITOR_GET("text_editor/highlighting/line_length_guideline_color"));
+ theme->set_color("word_highlighted_color", "CodeEdit", EDITOR_GET("text_editor/highlighting/word_highlighted_color"));
+ theme->set_color("bookmark_color", "CodeEdit", EDITOR_GET("text_editor/highlighting/bookmark_color"));
+ theme->set_color("breakpoint_color", "CodeEdit", EDITOR_GET("text_editor/highlighting/breakpoint_color"));
+ theme->set_color("executing_line_color", "CodeEdit", EDITOR_GET("text_editor/highlighting/executing_line_color"));
+ theme->set_color("code_folding_color", "CodeEdit", EDITOR_GET("text_editor/highlighting/code_folding_color"));
+ theme->set_color("search_result_color", "CodeEdit", EDITOR_GET("text_editor/highlighting/search_result_color"));
+ theme->set_color("search_result_border_color", "CodeEdit", EDITOR_GET("text_editor/highlighting/search_result_border_color"));
+
return theme;
}
diff --git a/editor/icons/LineShape2D.svg b/editor/icons/WorldMarginShape2D.svg
index f1dbe97c6f..f1dbe97c6f 100644
--- a/editor/icons/LineShape2D.svg
+++ b/editor/icons/WorldMarginShape2D.svg
diff --git a/editor/plugins/abstract_polygon_2d_editor.cpp b/editor/plugins/abstract_polygon_2d_editor.cpp
index df01ecd1be..ef3b0588b8 100644
--- a/editor/plugins/abstract_polygon_2d_editor.cpp
+++ b/editor/plugins/abstract_polygon_2d_editor.cpp
@@ -261,7 +261,7 @@ bool AbstractPolygon2DEditor::forward_gui_input(const Ref<InputEvent> &p_event)
Transform2D xform = canvas_item_editor->get_canvas_transform() * _get_node()->get_global_transform();
Vector2 gpoint = mb->get_position();
- Vector2 cpoint = _get_node()->get_global_transform().affine_inverse().xform(canvas_item_editor->snap_point(canvas_item_editor->get_canvas_transform().affine_inverse().xform(mb->get_position())));
+ Vector2 cpoint = _get_node()->to_local(canvas_item_editor->snap_point(canvas_item_editor->get_canvas_transform().affine_inverse().xform(mb->get_position())));
if (mode == MODE_EDIT || (_is_line() && mode == MODE_CREATE)) {
if (mb->get_button_index() == MOUSE_BUTTON_LEFT) {
@@ -396,7 +396,7 @@ bool AbstractPolygon2DEditor::forward_gui_input(const Ref<InputEvent> &p_event)
Vector2 gpoint = mm->get_position();
if (edited_point.valid() && (wip_active || (mm->get_button_mask() & MOUSE_BUTTON_MASK_LEFT))) {
- Vector2 cpoint = _get_node()->get_global_transform().affine_inverse().xform(canvas_item_editor->snap_point(canvas_item_editor->get_canvas_transform().affine_inverse().xform(gpoint)));
+ Vector2 cpoint = _get_node()->to_local(canvas_item_editor->snap_point(canvas_item_editor->get_canvas_transform().affine_inverse().xform(gpoint)));
//Move the point in a single axis. Should only work when editing a polygon and while holding shift.
if (mode == MODE_EDIT && mm->is_shift_pressed()) {
diff --git a/editor/plugins/canvas_item_editor_plugin.cpp b/editor/plugins/canvas_item_editor_plugin.cpp
index 7fe12089c8..76c056ed33 100644
--- a/editor/plugins/canvas_item_editor_plugin.cpp
+++ b/editor/plugins/canvas_item_editor_plugin.cpp
@@ -41,6 +41,7 @@
#include "editor/editor_settings.h"
#include "editor/plugins/animation_player_editor_plugin.h"
#include "editor/plugins/script_editor_plugin.h"
+#include "scene/2d/cpu_particles_2d.h"
#include "scene/2d/gpu_particles_2d.h"
#include "scene/2d/light_2d.h"
#include "scene/2d/polygon_2d.h"
@@ -5740,7 +5741,7 @@ void CanvasItemEditorViewport::_on_change_type_confirmed() {
}
CheckBox *check = Object::cast_to<CheckBox>(button_group->get_pressed_button());
- default_type = check->get_text();
+ default_texture_node_type = check->get_text();
_perform_drop_data();
selector->hide();
}
@@ -5832,14 +5833,13 @@ void CanvasItemEditorViewport::_create_nodes(Node *parent, Node *child, String &
child->set_name(name);
Ref<Texture2D> texture = Ref<Texture2D>(Object::cast_to<Texture2D>(ResourceCache::get(path)));
- Size2 texture_size = texture->get_size();
if (parent) {
editor_data->get_undo_redo().add_do_method(parent, "add_child", child);
editor_data->get_undo_redo().add_do_method(child, "set_owner", editor->get_edited_scene());
editor_data->get_undo_redo().add_do_reference(child);
editor_data->get_undo_redo().add_undo_method(parent, "remove_child", child);
- } else { // if we haven't parent, lets try to make a child as a parent.
+ } else { // If no parent is selected, set as root node of the scene.
editor_data->get_undo_redo().add_do_method(editor, "set_edited_scene", child);
editor_data->get_undo_redo().add_do_method(child, "set_owner", editor->get_edited_scene());
editor_data->get_undo_redo().add_do_reference(child);
@@ -5853,28 +5853,23 @@ void CanvasItemEditorViewport::_create_nodes(Node *parent, Node *child, String &
editor_data->get_undo_redo().add_undo_method(ed, "live_debug_remove_node", NodePath(String(editor->get_edited_scene()->get_path_to(parent)) + "/" + new_name));
}
- // handle with different property for texture
- String property = "texture";
- List<PropertyInfo> props;
- child->get_property_list(&props);
- for (const PropertyInfo &E : props) {
- if (E.name == "config/texture") { // Particles2D
- property = "config/texture";
- break;
- } else if (E.name == "texture/texture") { // Polygon2D
- property = "texture/texture";
- break;
- } else if (E.name == "normal") { // TouchScreenButton
- property = "normal";
- break;
- }
+ String node_class = child->get_class();
+ if (node_class == "Polygon2D") {
+ editor_data->get_undo_redo().add_do_property(child, "texture/texture", texture);
+ } else if (node_class == "TouchScreenButton") {
+ editor_data->get_undo_redo().add_do_property(child, "normal", texture);
+ } else if (node_class == "TextureButton") {
+ editor_data->get_undo_redo().add_do_property(child, "texture_button", texture);
+ } else {
+ editor_data->get_undo_redo().add_do_property(child, "texture", texture);
}
- editor_data->get_undo_redo().add_do_property(child, property, texture);
// make visible for certain node type
- if (default_type == "NinePatchRect") {
- editor_data->get_undo_redo().add_do_property(child, "rect/size", texture_size);
- } else if (default_type == "Polygon2D") {
+ if (ClassDB::is_parent_class(node_class, "Control")) {
+ Size2 texture_size = texture->get_size();
+ editor_data->get_undo_redo().add_do_property(child, "rect_size", texture_size);
+ } else if (node_class == "Polygon2D") {
+ Size2 texture_size = texture->get_size();
Vector<Vector2> list;
list.push_back(Vector2(0, 0));
list.push_back(Vector2(texture_size.width, 0));
@@ -5975,23 +5970,7 @@ void CanvasItemEditorViewport::_perform_drop_data() {
} else {
Ref<Texture2D> texture = Ref<Texture2D>(Object::cast_to<Texture2D>(*res));
if (texture != nullptr && texture.is_valid()) {
- Node *child;
- if (default_type == "Light2D") {
- child = memnew(Light2D);
- } else if (default_type == "GPUParticles2D") {
- child = memnew(GPUParticles2D);
- } else if (default_type == "Polygon2D") {
- child = memnew(Polygon2D);
- } else if (default_type == "TouchScreenButton") {
- child = memnew(TouchScreenButton);
- } else if (default_type == "TextureRect") {
- child = memnew(TextureRect);
- } else if (default_type == "NinePatchRect") {
- child = memnew(NinePatchRect);
- } else {
- child = memnew(Sprite2D); // default
- }
-
+ Node *child = _make_texture_node_type(default_texture_node_type);
_create_nodes(target_node, child, path, drop_pos);
}
}
@@ -6029,13 +6008,7 @@ bool CanvasItemEditorViewport::can_drop_data(const Point2 &p_point, const Varian
continue;
}
memdelete(instantiated_scene);
- } else if (type == "Texture2D" ||
- type == "ImageTexture" ||
- type == "ViewportTexture" ||
- type == "CurveTexture" ||
- type == "GradientTexture" ||
- type == "StreamTexture2D" ||
- type == "AtlasTexture") {
+ } else if (ClassDB::is_parent_class(type, "Texture2D")) {
Ref<Texture2D> texture = Ref<Texture2D>(Object::cast_to<Texture2D>(*res));
if (!texture.is_valid()) {
continue;
@@ -6052,7 +6025,7 @@ bool CanvasItemEditorViewport::can_drop_data(const Point2 &p_point, const Varian
}
Transform2D trans = canvas_item_editor->get_canvas_transform();
preview_node->set_position((p_point - trans.get_origin()) / trans.get_scale().x);
- label->set_text(vformat(TTR("Adding %s..."), default_type));
+ label->set_text(vformat(TTR("Adding %s..."), default_texture_node_type));
}
return can_instantiate;
}
@@ -6068,9 +6041,9 @@ void CanvasItemEditorViewport::_show_resource_type_selector() {
for (int i = 0; i < btn_list.size(); i++) {
CheckBox *check = Object::cast_to<CheckBox>(btn_list[i]);
- check->set_pressed(check->get_text() == default_type);
+ check->set_pressed(check->get_text() == default_texture_node_type);
}
- selector->set_title(vformat(TTR("Add %s"), default_type));
+ selector->set_title(vformat(TTR("Add %s"), default_texture_node_type));
selector->popup_centered();
}
@@ -6126,6 +6099,30 @@ void CanvasItemEditorViewport::drop_data(const Point2 &p_point, const Variant &p
}
}
+Node *CanvasItemEditorViewport::_make_texture_node_type(String texture_node_type) {
+ Node *node = nullptr;
+ if (texture_node_type == "Sprite2D") {
+ node = memnew(Sprite2D);
+ } else if (texture_node_type == "PointLight2D") {
+ node = memnew(PointLight2D);
+ } else if (texture_node_type == "CPUParticles2D") {
+ node = memnew(CPUParticles2D);
+ } else if (texture_node_type == "GPUParticles2D") {
+ node = memnew(GPUParticles2D);
+ } else if (texture_node_type == "Polygon2D") {
+ node = memnew(Polygon2D);
+ } else if (texture_node_type == "TouchScreenButton") {
+ node = memnew(TouchScreenButton);
+ } else if (texture_node_type == "TextureRect") {
+ node = memnew(TextureRect);
+ } else if (texture_node_type == "TextureButton") {
+ node = memnew(TextureButton);
+ } else if (texture_node_type == "NinePatchRect") {
+ node = memnew(NinePatchRect);
+ }
+ return node;
+}
+
void CanvasItemEditorViewport::_notification(int p_what) {
switch (p_what) {
case NOTIFICATION_ENTER_TREE: {
@@ -6145,22 +6142,24 @@ void CanvasItemEditorViewport::_bind_methods() {
}
CanvasItemEditorViewport::CanvasItemEditorViewport(EditorNode *p_node, CanvasItemEditor *p_canvas_item_editor) {
- default_type = "Sprite2D";
+ default_texture_node_type = "Sprite2D";
// Node2D
- types.push_back("Sprite2D");
- types.push_back("Light2D");
- types.push_back("GPUParticles2D");
- types.push_back("Polygon2D");
- types.push_back("TouchScreenButton");
+ texture_node_types.push_back("Sprite2D");
+ texture_node_types.push_back("PointLight2D");
+ texture_node_types.push_back("CPUParticles2D");
+ texture_node_types.push_back("GPUParticles2D");
+ texture_node_types.push_back("Polygon2D");
+ texture_node_types.push_back("TouchScreenButton");
// Control
- types.push_back("TextureRect");
- types.push_back("NinePatchRect");
+ texture_node_types.push_back("TextureRect");
+ texture_node_types.push_back("TextureButton");
+ texture_node_types.push_back("NinePatchRect");
target_node = nullptr;
editor = p_node;
editor_data = editor->get_scene_tree_dock()->get_editor_data();
canvas_item_editor = p_canvas_item_editor;
- preview_node = memnew(Node2D);
+ preview_node = memnew(Control);
accept = memnew(AcceptDialog);
editor->get_gui_base()->add_child(accept);
@@ -6182,10 +6181,10 @@ CanvasItemEditorViewport::CanvasItemEditorViewport(EditorNode *p_node, CanvasIte
btn_group->set_h_size_flags(0);
button_group.instantiate();
- for (int i = 0; i < types.size(); i++) {
+ for (int i = 0; i < texture_node_types.size(); i++) {
CheckBox *check = memnew(CheckBox);
btn_group->add_child(check);
- check->set_text(types[i]);
+ check->set_text(texture_node_types[i]);
check->connect("button_down", callable_mp(this, &CanvasItemEditorViewport::_on_select_type), varray(check));
check->set_button_group(button_group);
}
diff --git a/editor/plugins/canvas_item_editor_plugin.h b/editor/plugins/canvas_item_editor_plugin.h
index 495cd5f515..bff580315e 100644
--- a/editor/plugins/canvas_item_editor_plugin.h
+++ b/editor/plugins/canvas_item_editor_plugin.h
@@ -639,8 +639,10 @@ public:
class CanvasItemEditorViewport : public Control {
GDCLASS(CanvasItemEditorViewport, Control);
- String default_type;
- Vector<String> types;
+ // The type of node that will be created when dropping texture into the viewport.
+ String default_texture_node_type;
+ // Node types that are available to select from when dropping texture into viewport.
+ Vector<String> texture_node_types;
Vector<String> selected_files;
Node *target_node;
@@ -649,7 +651,7 @@ class CanvasItemEditorViewport : public Control {
EditorNode *editor;
EditorData *editor_data;
CanvasItemEditor *canvas_item_editor;
- Node2D *preview_node;
+ Control *preview_node;
AcceptDialog *accept;
AcceptDialog *selector;
Label *selector_label;
@@ -662,6 +664,7 @@ class CanvasItemEditorViewport : public Control {
void _on_select_type(Object *selected);
void _on_change_type_confirmed();
void _on_change_type_closed();
+ Node *_make_texture_node_type(String texture_node_type);
void _create_preview(const Vector<String> &files) const;
void _remove_preview();
diff --git a/editor/plugins/collision_shape_2d_editor_plugin.cpp b/editor/plugins/collision_shape_2d_editor_plugin.cpp
index 4266e0f676..486f947e43 100644
--- a/editor/plugins/collision_shape_2d_editor_plugin.cpp
+++ b/editor/plugins/collision_shape_2d_editor_plugin.cpp
@@ -36,9 +36,9 @@
#include "scene/resources/circle_shape_2d.h"
#include "scene/resources/concave_polygon_shape_2d.h"
#include "scene/resources/convex_polygon_shape_2d.h"
-#include "scene/resources/line_shape_2d.h"
#include "scene/resources/rectangle_shape_2d.h"
#include "scene/resources/segment_shape_2d.h"
+#include "scene/resources/world_margin_shape_2d.h"
void CollisionShape2DEditor::_node_removed(Node *p_node) {
if (p_node == node) {
@@ -74,8 +74,8 @@ Variant CollisionShape2DEditor::get_handle_value(int idx) const {
case CONVEX_POLYGON_SHAPE: {
} break;
- case LINE_SHAPE: {
- Ref<LineShape2D> line = node->get_shape();
+ case WORLD_MARGIN_SHAPE: {
+ Ref<WorldMarginShape2D> line = node->get_shape();
if (idx == 0) {
return line->get_distance();
@@ -142,9 +142,9 @@ void CollisionShape2DEditor::set_handle(int idx, Point2 &p_point) {
case CONVEX_POLYGON_SHAPE: {
} break;
- case LINE_SHAPE: {
+ case WORLD_MARGIN_SHAPE: {
if (idx < 2) {
- Ref<LineShape2D> line = node->get_shape();
+ Ref<WorldMarginShape2D> line = node->get_shape();
if (idx == 0) {
line->set_distance(p_point.length());
@@ -241,8 +241,8 @@ void CollisionShape2DEditor::commit_handle(int idx, Variant &p_org) {
// Cannot be edited directly, use CollisionPolygon2D instead.
} break;
- case LINE_SHAPE: {
- Ref<LineShape2D> line = node->get_shape();
+ case WORLD_MARGIN_SHAPE: {
+ Ref<WorldMarginShape2D> line = node->get_shape();
if (idx == 0) {
undo_redo->add_do_method(line.ptr(), "set_distance", line->get_distance());
@@ -397,8 +397,8 @@ void CollisionShape2DEditor::_get_current_shape_type() {
shape_type = CONCAVE_POLYGON_SHAPE;
} else if (Object::cast_to<ConvexPolygonShape2D>(*s)) {
shape_type = CONVEX_POLYGON_SHAPE;
- } else if (Object::cast_to<LineShape2D>(*s)) {
- shape_type = LINE_SHAPE;
+ } else if (Object::cast_to<WorldMarginShape2D>(*s)) {
+ shape_type = WORLD_MARGIN_SHAPE;
} else if (Object::cast_to<RectangleShape2D>(*s)) {
shape_type = RECTANGLE_SHAPE;
} else if (Object::cast_to<SegmentShape2D>(*s)) {
@@ -464,8 +464,8 @@ void CollisionShape2DEditor::forward_canvas_draw_over_viewport(Control *p_overla
case CONVEX_POLYGON_SHAPE: {
} break;
- case LINE_SHAPE: {
- Ref<LineShape2D> shape = node->get_shape();
+ case WORLD_MARGIN_SHAPE: {
+ Ref<WorldMarginShape2D> shape = node->get_shape();
handles.resize(2);
handles.write[0] = shape->get_normal() * shape->get_distance();
diff --git a/editor/plugins/collision_shape_2d_editor_plugin.h b/editor/plugins/collision_shape_2d_editor_plugin.h
index 130ec708cf..056e1b5b7d 100644
--- a/editor/plugins/collision_shape_2d_editor_plugin.h
+++ b/editor/plugins/collision_shape_2d_editor_plugin.h
@@ -46,7 +46,7 @@ class CollisionShape2DEditor : public Control {
CIRCLE_SHAPE,
CONCAVE_POLYGON_SHAPE,
CONVEX_POLYGON_SHAPE,
- LINE_SHAPE,
+ WORLD_MARGIN_SHAPE,
RECTANGLE_SHAPE,
SEGMENT_SHAPE
};
diff --git a/editor/plugins/node_3d_editor_plugin.cpp b/editor/plugins/node_3d_editor_plugin.cpp
index 8f0359bd0f..a48b6a090b 100644
--- a/editor/plugins/node_3d_editor_plugin.cpp
+++ b/editor/plugins/node_3d_editor_plugin.cpp
@@ -809,18 +809,66 @@ void Node3DEditorViewport::_select_region() {
}
void Node3DEditorViewport::_update_name() {
- String view_mode = orthogonal ? TTR("Orthogonal") : TTR("Perspective");
+ String name;
- if (auto_orthogonal) {
- view_mode += " [auto]";
+ switch (view_type) {
+ case VIEW_TYPE_USER: {
+ if (orthogonal) {
+ name = TTR("Orthogonal");
+ } else {
+ name = TTR("Perspective");
+ }
+ } break;
+ case VIEW_TYPE_TOP: {
+ if (orthogonal) {
+ name = TTR("Top Orthogonal");
+ } else {
+ name = TTR("Top Perspective");
+ }
+ } break;
+ case VIEW_TYPE_BOTTOM: {
+ if (orthogonal) {
+ name = TTR("Bottom Orthogonal");
+ } else {
+ name = TTR("Bottom Perspective");
+ }
+ } break;
+ case VIEW_TYPE_LEFT: {
+ if (orthogonal) {
+ name = TTR("Left Orthogonal");
+ } else {
+ name = TTR("Right Perspective");
+ }
+ } break;
+ case VIEW_TYPE_RIGHT: {
+ if (orthogonal) {
+ name = TTR("Right Orthogonal");
+ } else {
+ name = TTR("Right Perspective");
+ }
+ } break;
+ case VIEW_TYPE_FRONT: {
+ if (orthogonal) {
+ name = TTR("Front Orthogonal");
+ } else {
+ name = TTR("Front Perspective");
+ }
+ } break;
+ case VIEW_TYPE_REAR: {
+ if (orthogonal) {
+ name = TTR("Rear Orthogonal");
+ } else {
+ name = TTR("Rear Perspective");
+ }
+ } break;
}
- if (name != "") {
- view_menu->set_text(name + " " + view_mode);
- } else {
- view_menu->set_text(view_mode);
+ if (auto_orthogonal) {
+ // TRANSLATORS: This will be appended to the view name when Auto Orthogonal is enabled.
+ name += TTR(" [auto]");
}
+ view_menu->set_text(name);
view_menu->set_size(Vector2(0, 0)); // resets the button size
}
@@ -1384,7 +1432,7 @@ void Node3DEditorViewport::_sinput(const Ref<InputEvent> &p_event) {
case TRANSFORM_VIEW: {
_edit.plane = TRANSFORM_X_AXIS;
set_message(TTR("X-Axis Transform."), 2);
- name = "";
+ view_type = VIEW_TYPE_USER;
_update_name();
} break;
case TRANSFORM_X_AXIS: {
@@ -2325,7 +2373,7 @@ void Node3DEditorViewport::_nav_orbit(Ref<InputEventWithModifiers> p_event, cons
} else {
cursor.y_rot += p_relative.x * radians_per_pixel;
}
- name = "";
+ view_type = VIEW_TYPE_USER;
_update_name();
}
@@ -2363,7 +2411,7 @@ void Node3DEditorViewport::_nav_look(Ref<InputEventWithModifiers> p_event, const
Vector3 diff = prev_pos - pos;
cursor.pos += diff;
- name = "";
+ view_type = VIEW_TYPE_USER;
_update_name();
}
@@ -3008,7 +3056,7 @@ void Node3DEditorViewport::_menu_option(int p_option) {
cursor.y_rot = 0;
cursor.x_rot = Math_PI / 2.0;
set_message(TTR("Top View."), 2);
- name = TTR("Top");
+ view_type = VIEW_TYPE_TOP;
_set_auto_orthogonal();
_update_name();
@@ -3017,7 +3065,7 @@ void Node3DEditorViewport::_menu_option(int p_option) {
cursor.y_rot = 0;
cursor.x_rot = -Math_PI / 2.0;
set_message(TTR("Bottom View."), 2);
- name = TTR("Bottom");
+ view_type = VIEW_TYPE_BOTTOM;
_set_auto_orthogonal();
_update_name();
@@ -3026,7 +3074,7 @@ void Node3DEditorViewport::_menu_option(int p_option) {
cursor.x_rot = 0;
cursor.y_rot = Math_PI / 2.0;
set_message(TTR("Left View."), 2);
- name = TTR("Left");
+ view_type = VIEW_TYPE_LEFT;
_set_auto_orthogonal();
_update_name();
@@ -3035,7 +3083,7 @@ void Node3DEditorViewport::_menu_option(int p_option) {
cursor.x_rot = 0;
cursor.y_rot = -Math_PI / 2.0;
set_message(TTR("Right View."), 2);
- name = TTR("Right");
+ view_type = VIEW_TYPE_RIGHT;
_set_auto_orthogonal();
_update_name();
@@ -3044,7 +3092,7 @@ void Node3DEditorViewport::_menu_option(int p_option) {
cursor.x_rot = 0;
cursor.y_rot = Math_PI;
set_message(TTR("Front View."), 2);
- name = TTR("Front");
+ view_type = VIEW_TYPE_FRONT;
_set_auto_orthogonal();
_update_name();
@@ -3053,7 +3101,7 @@ void Node3DEditorViewport::_menu_option(int p_option) {
cursor.x_rot = 0;
cursor.y_rot = 0;
set_message(TTR("Rear View."), 2);
- name = TTR("Rear");
+ view_type = VIEW_TYPE_REAR;
_set_auto_orthogonal();
_update_name();
@@ -3597,8 +3645,8 @@ void Node3DEditorViewport::set_state(const Dictionary &p_state) {
_menu_option(VIEW_PERSPECTIVE);
}
}
- if (p_state.has("view_name")) {
- name = p_state["view_name"];
+ if (p_state.has("view_type")) {
+ view_type = ViewType(p_state["view_type"].operator int());
_update_name();
}
if (p_state.has("auto_orthogonal")) {
@@ -3706,7 +3754,7 @@ Dictionary Node3DEditorViewport::get_state() const {
d["distance"] = cursor.distance;
d["use_environment"] = camera->get_environment().is_valid();
d["use_orthogonal"] = camera->get_projection() == Camera3D::PROJECTION_ORTHOGONAL;
- d["view_name"] = name;
+ d["view_type"] = view_type;
d["auto_orthogonal"] = auto_orthogonal;
d["auto_orthogonal_enabled"] = view_menu->get_popup()->is_item_checked(view_menu->get_popup()->get_item_index(VIEW_AUTO_ORTHOGONAL));
if (view_menu->get_popup()->is_item_checked(view_menu->get_popup()->get_item_index(VIEW_DISPLAY_NORMAL))) {
@@ -3751,7 +3799,7 @@ void Node3DEditorViewport::reset() {
message_time = 0;
message = "";
last_message = "";
- name = "";
+ view_type = VIEW_TYPE_USER;
cursor = Cursor();
_update_name();
@@ -4030,7 +4078,7 @@ bool Node3DEditorViewport::can_drop_data_fw(const Point2 &p_point, const Variant
continue;
}
memdelete(instantiated_scene);
- } else if (type == "Mesh" || type == "ArrayMesh" || type == "PrimitiveMesh") {
+ } else if (ClassDB::is_parent_class(type, "Mesh")) {
Ref<Mesh> mesh = ResourceLoader::load(files[i]);
if (!mesh.is_valid()) {
continue;
@@ -4366,7 +4414,7 @@ Node3DEditorViewport::Node3DEditorViewport(Node3DEditor *p_spatial_editor, Edito
viewport->set_as_audio_listener_3d(true);
}
- name = "";
+ view_type = VIEW_TYPE_USER;
_update_name();
EditorSettings::get_singleton()->connect("settings_changed", callable_mp(this, &Node3DEditorViewport::update_transform_gizmo_view));
diff --git a/editor/plugins/node_3d_editor_plugin.h b/editor/plugins/node_3d_editor_plugin.h
index 094aa5662f..d29c1efabb 100644
--- a/editor/plugins/node_3d_editor_plugin.h
+++ b/editor/plugins/node_3d_editor_plugin.h
@@ -143,6 +143,16 @@ class Node3DEditorViewport : public Control {
VIEW_MAX
};
+ enum ViewType {
+ VIEW_TYPE_USER,
+ VIEW_TYPE_TOP,
+ VIEW_TYPE_BOTTOM,
+ VIEW_TYPE_LEFT,
+ VIEW_TYPE_RIGHT,
+ VIEW_TYPE_FRONT,
+ VIEW_TYPE_REAR,
+ };
+
public:
enum {
GIZMO_BASE_LAYER = 27,
@@ -172,7 +182,7 @@ private:
int gpu_time_history_index;
int index;
- String name;
+ ViewType view_type;
void _menu_option(int p_option);
void _set_auto_orthogonal();
Node3D *preview_node;
diff --git a/editor/plugins/path_2d_editor_plugin.cpp b/editor/plugins/path_2d_editor_plugin.cpp
index 8866e8c53e..584eb84ecd 100644
--- a/editor/plugins/path_2d_editor_plugin.cpp
+++ b/editor/plugins/path_2d_editor_plugin.cpp
@@ -77,7 +77,7 @@ bool Path2DEditor::forward_gui_input(const Ref<InputEvent> &p_event) {
Transform2D xform = canvas_item_editor->get_canvas_transform() * node->get_global_transform();
Vector2 gpoint = mb->get_position();
- Vector2 cpoint = node->get_global_transform().affine_inverse().xform(canvas_item_editor->snap_point(canvas_item_editor->get_canvas_transform().affine_inverse().xform(mb->get_position())));
+ Vector2 cpoint = node->to_local(canvas_item_editor->snap_point(canvas_item_editor->get_canvas_transform().affine_inverse().xform(mb->get_position())));
if (mb->is_pressed() && action == ACTION_NONE) {
Ref<Curve2D> curve = node->get_curve();
diff --git a/editor/plugins/script_editor_plugin.cpp b/editor/plugins/script_editor_plugin.cpp
index 668a15da37..e6762826dd 100644
--- a/editor/plugins/script_editor_plugin.cpp
+++ b/editor/plugins/script_editor_plugin.cpp
@@ -3409,8 +3409,8 @@ ScriptEditor::ScriptEditor(EditorNode *p_editor) {
ED_SHORTCUT("script_editor/window_sort", TTR("Sort"));
ED_SHORTCUT("script_editor/window_move_up", TTR("Move Up"), KEY_MASK_SHIFT | KEY_MASK_ALT | KEY_UP);
ED_SHORTCUT("script_editor/window_move_down", TTR("Move Down"), KEY_MASK_SHIFT | KEY_MASK_ALT | KEY_DOWN);
- ED_SHORTCUT("script_editor/next_script", TTR("Next script"), KEY_MASK_CMD | KEY_MASK_SHIFT | KEY_PERIOD); // these should be KEY_GREATER and KEY_LESS but those don't work
- ED_SHORTCUT("script_editor/prev_script", TTR("Previous script"), KEY_MASK_CMD | KEY_MASK_SHIFT | KEY_COMMA);
+ ED_SHORTCUT("script_editor/next_script", TTR("Next Script"), KEY_MASK_CMD | KEY_MASK_SHIFT | KEY_PERIOD); // these should be KEY_GREATER and KEY_LESS but those don't work
+ ED_SHORTCUT("script_editor/prev_script", TTR("Previous Script"), KEY_MASK_CMD | KEY_MASK_SHIFT | KEY_COMMA);
set_process_unhandled_key_input(true);
file_menu = memnew(MenuButton);
diff --git a/editor/plugins/script_text_editor.cpp b/editor/plugins/script_text_editor.cpp
index 8cd746304c..1d7592d2c3 100644
--- a/editor/plugins/script_text_editor.cpp
+++ b/editor/plugins/script_text_editor.cpp
@@ -1390,6 +1390,7 @@ bool ScriptTextEditor::can_drop_data_fw(const Point2 &p_point, const Variant &p_
if (d.has("type") && (String(d["type"]) == "resource" ||
String(d["type"]) == "files" ||
String(d["type"]) == "nodes" ||
+ String(d["type"]) == "obj_property" ||
String(d["type"]) == "files_and_dirs")) {
return true;
}
@@ -1419,10 +1420,11 @@ static Node *_find_script_node(Node *p_edited_scene, Node *p_current_node, const
}
void ScriptTextEditor::drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) {
+ const String quote_style = EDITOR_GET("text_editor/completion/use_single_quotes") ? "'" : "\"";
+
Dictionary d = p_data;
CodeEdit *te = code_editor->get_text_editor();
-
Point2i pos = te->get_line_column_at_pos(p_point);
int row = pos.y;
int col = pos.x;
@@ -1444,7 +1446,6 @@ void ScriptTextEditor::drop_data_fw(const Point2 &p_point, const Variant &p_data
}
if (d.has("type") && (String(d["type"]) == "files" || String(d["type"]) == "files_and_dirs")) {
- const String quote_style = EDITOR_DEF("text_editor/completion/use_single_quotes", false) ? "'" : "\"";
Array files = d["files"];
String text_to_drop;
@@ -1488,13 +1489,21 @@ void ScriptTextEditor::drop_data_fw(const Point2 &p_point, const Variant &p_data
}
String path = sn->get_path_to(node);
- text_to_drop += "\"" + path.c_escape() + "\"";
+ text_to_drop += path.c_escape().quote(quote_style);
}
te->set_caret_line(row);
te->set_caret_column(col);
te->insert_text_at_caret(text_to_drop);
}
+
+ if (d.has("type") && String(d["type"]) == "obj_property") {
+ const String text_to_drop = String(d["property"]).c_escape().quote(quote_style);
+
+ te->set_caret_line(row);
+ te->set_caret_column(col);
+ te->insert_text_at_caret(text_to_drop);
+ }
}
void ScriptTextEditor::_text_edit_gui_input(const Ref<InputEvent> &ev) {
diff --git a/editor/plugins/visual_shader_editor_plugin.cpp b/editor/plugins/visual_shader_editor_plugin.cpp
index d6ac238414..1fbf5eb0e6 100644
--- a/editor/plugins/visual_shader_editor_plugin.cpp
+++ b/editor/plugins/visual_shader_editor_plugin.cpp
@@ -110,7 +110,6 @@ void VisualShaderGraphPlugin::_bind_methods() {
ClassDB::bind_method("set_expression", &VisualShaderGraphPlugin::set_expression);
ClassDB::bind_method("update_curve", &VisualShaderGraphPlugin::update_curve);
ClassDB::bind_method("update_curve_xyz", &VisualShaderGraphPlugin::update_curve_xyz);
- ClassDB::bind_method("update_constant", &VisualShaderGraphPlugin::update_constant);
}
void VisualShaderGraphPlugin::register_shader(VisualShader *p_shader) {
@@ -237,18 +236,6 @@ int VisualShaderGraphPlugin::get_constant_index(float p_constant) const {
return 0;
}
-void VisualShaderGraphPlugin::update_constant(VisualShader::Type p_type, int p_node_id) {
- if (p_type != visual_shader->get_shader_type() || !links.has(p_node_id) || !links[p_node_id].const_op) {
- return;
- }
- VisualShaderNodeFloatConstant *float_const = Object::cast_to<VisualShaderNodeFloatConstant>(links[p_node_id].visual_node);
- if (!float_const) {
- return;
- }
- links[p_node_id].const_op->select(get_constant_index(float_const->get_constant()));
- links[p_node_id].graph_node->set_size(Size2(-1, -1));
-}
-
void VisualShaderGraphPlugin::set_expression(VisualShader::Type p_type, int p_node_id, const String &p_expression) {
if (p_type != visual_shader->get_shader_type() || !links.has(p_node_id) || !links[p_node_id].expression_edit) {
return;
@@ -267,10 +254,6 @@ void VisualShaderGraphPlugin::register_default_input_button(int p_node_id, int p
links[p_node_id].input_ports.insert(p_port_id, { p_button });
}
-void VisualShaderGraphPlugin::register_constant_option_btn(int p_node_id, OptionButton *p_button) {
- links[p_node_id].const_op = p_button;
-}
-
void VisualShaderGraphPlugin::register_expression_edit(int p_node_id, CodeEdit *p_expression_edit) {
links[p_node_id].expression_edit = p_expression_edit;
}
@@ -322,7 +305,7 @@ void VisualShaderGraphPlugin::make_dirty(bool p_enabled) {
}
void VisualShaderGraphPlugin::register_link(VisualShader::Type p_type, int p_id, VisualShaderNode *p_visual_node, GraphNode *p_graph_node) {
- links.insert(p_id, { p_type, p_visual_node, p_graph_node, p_visual_node->get_output_port_for_preview() != -1, -1, Map<int, InputPort>(), Map<int, Port>(), nullptr, nullptr, nullptr, nullptr, { nullptr, nullptr, nullptr } });
+ links.insert(p_id, { p_type, p_visual_node, p_graph_node, p_visual_node->get_output_port_for_preview() != -1, -1, Map<int, InputPort>(), Map<int, Port>(), nullptr, nullptr, nullptr, { nullptr, nullptr, nullptr } });
}
void VisualShaderGraphPlugin::register_output_port(int p_node_id, int p_port, TextureButton *p_button) {
@@ -498,23 +481,6 @@ void VisualShaderGraphPlugin::add_node(VisualShader::Type p_type, int p_id) {
custom_editor = hbox;
}
- Ref<VisualShaderNodeFloatConstant> float_const = vsnode;
- if (float_const.is_valid()) {
- HBoxContainer *hbox = memnew(HBoxContainer);
-
- hbox->add_child(custom_editor);
- OptionButton *btn = memnew(OptionButton);
- hbox->add_child(btn);
- register_constant_option_btn(p_id, btn);
- btn->add_item("");
- for (int i = 0; i < MAX_FLOAT_CONST_DEFS; i++) {
- btn->add_item(float_constant_defs[i].name);
- }
- btn->select(get_constant_index(float_const->get_constant()));
- btn->connect("item_selected", callable_mp(VisualShaderEditor::get_singleton(), &VisualShaderEditor::_float_constant_selected), varray(p_id));
- custom_editor = hbox;
- }
-
if (custom_editor && !vsnode->is_use_prop_slots() && vsnode->get_output_port_count() > 0 && vsnode->get_output_port_name(0) == "" && (vsnode->get_input_port_count() == 0 || vsnode->get_input_port_name(0) == "")) {
//will be embedded in first port
} else if (custom_editor) {
@@ -2182,6 +2148,16 @@ void VisualShaderEditor::_setup_node(VisualShaderNode *p_node, int p_op_idx) {
}
}
+ // TRANSFORM_OP
+ {
+ VisualShaderNodeTransformOp *matOp = Object::cast_to<VisualShaderNodeTransformOp>(p_node);
+
+ if (matOp) {
+ matOp->set_operator((VisualShaderNodeTransformOp::Operator)p_op_idx);
+ return;
+ }
+ }
+
// TRANSFORM_FUNC
{
VisualShaderNodeTransformFunc *matFunc = Object::cast_to<VisualShaderNodeTransformFunc>(p_node);
@@ -2944,6 +2920,7 @@ void VisualShaderEditor::_graph_gui_input(const Ref<InputEvent> &p_event) {
selected_constants.clear();
selected_uniforms.clear();
selected_comment = -1;
+ selected_float_constant = -1;
List<int> to_change;
for (int i = 0; i < graph->get_child_count(); i++) {
@@ -2963,6 +2940,10 @@ void VisualShaderEditor::_graph_gui_input(const Ref<InputEvent> &p_event) {
if (constant_node != nullptr) {
selected_constants.insert(id);
}
+ VisualShaderNodeFloatConstant *float_constant_node = Object::cast_to<VisualShaderNodeFloatConstant>(node.ptr());
+ if (float_constant_node != nullptr) {
+ selected_float_constant = id;
+ }
VisualShaderNodeUniform *uniform_node = Object::cast_to<VisualShaderNodeUniform>(node.ptr());
if (uniform_node != nullptr && uniform_node->is_convertible_to_constant()) {
selected_uniforms.insert(id);
@@ -2973,6 +2954,7 @@ void VisualShaderEditor::_graph_gui_input(const Ref<InputEvent> &p_event) {
if (to_change.size() > 1) {
selected_comment = -1;
+ selected_float_constant = -1;
}
if (to_change.is_empty() && copy_nodes_buffer.is_empty()) {
@@ -2987,6 +2969,10 @@ void VisualShaderEditor::_graph_gui_input(const Ref<InputEvent> &p_event) {
if (temp != -1) {
popup_menu->remove_item(temp);
}
+ temp = popup_menu->get_item_index(NodeMenuOptions::FLOAT_CONSTANTS);
+ if (temp != -1) {
+ popup_menu->remove_item(temp);
+ }
temp = popup_menu->get_item_index(NodeMenuOptions::CONVERT_CONSTANTS_TO_UNIFORMS);
if (temp != -1) {
popup_menu->remove_item(temp);
@@ -3008,14 +2994,23 @@ void VisualShaderEditor::_graph_gui_input(const Ref<InputEvent> &p_event) {
popup_menu->remove_item(temp);
}
- if (selected_comment != -1) {
+ if (selected_constants.size() > 0 || selected_uniforms.size() > 0) {
popup_menu->add_separator("", NodeMenuOptions::SEPARATOR2);
- popup_menu->add_item(TTR("Set Comment Title"), NodeMenuOptions::SET_COMMENT_TITLE);
- popup_menu->add_item(TTR("Set Comment Description"), NodeMenuOptions::SET_COMMENT_DESCRIPTION);
- }
- if (selected_constants.size() > 0 || selected_uniforms.size() > 0) {
- popup_menu->add_separator("", NodeMenuOptions::SEPARATOR3);
+ if (selected_float_constant != -1) {
+ popup_menu->add_submenu_item(TTR("Float Constants"), "FloatConstants", int(NodeMenuOptions::FLOAT_CONSTANTS));
+
+ if (!constants_submenu) {
+ constants_submenu = memnew(PopupMenu);
+ constants_submenu->set_name("FloatConstants");
+
+ for (int i = 0; i < MAX_FLOAT_CONST_DEFS; i++) {
+ constants_submenu->add_item(float_constant_defs[i].name, i);
+ }
+ popup_menu->add_child(constants_submenu);
+ constants_submenu->connect("index_pressed", callable_mp(this, &VisualShaderEditor::_float_constant_selected));
+ }
+ }
if (selected_constants.size() > 0) {
popup_menu->add_item(TTR("Convert Constant(s) to Uniform(s)"), NodeMenuOptions::CONVERT_CONSTANTS_TO_UNIFORMS);
@@ -3026,6 +3021,12 @@ void VisualShaderEditor::_graph_gui_input(const Ref<InputEvent> &p_event) {
}
}
+ if (selected_comment != -1) {
+ popup_menu->add_separator("", NodeMenuOptions::SEPARATOR3);
+ popup_menu->add_item(TTR("Set Comment Title"), NodeMenuOptions::SET_COMMENT_TITLE);
+ popup_menu->add_item(TTR("Set Comment Description"), NodeMenuOptions::SET_COMMENT_DESCRIPTION);
+ }
+
menu_point = graph->get_local_mouse_position();
Point2 gpos = Input::get_singleton()->get_mouse_position();
popup_menu->set_position(gpos);
@@ -3495,27 +3496,20 @@ void VisualShaderEditor::_uniform_select_item(Ref<VisualShaderNodeUniformRef> p_
undo_redo->commit_action();
}
-void VisualShaderEditor::_float_constant_selected(int p_index, int p_node) {
- if (p_index == 0) {
- graph_plugin->update_node_size(p_node);
- return;
- }
-
- --p_index;
-
- ERR_FAIL_INDEX(p_index, MAX_FLOAT_CONST_DEFS);
+void VisualShaderEditor::_float_constant_selected(int p_which) {
+ ERR_FAIL_INDEX(p_which, MAX_FLOAT_CONST_DEFS);
VisualShader::Type type = get_current_shader_type();
- Ref<VisualShaderNodeFloatConstant> node = visual_shader->get_node(type, p_node);
- if (!node.is_valid()) {
- return;
+ Ref<VisualShaderNodeFloatConstant> node = visual_shader->get_node(type, selected_float_constant);
+ ERR_FAIL_COND(!node.is_valid());
+
+ if (Math::is_equal_approx(node->get_constant(), float_constant_defs[p_which].value)) {
+ return; // same
}
- undo_redo->create_action(TTR("Set constant"));
- undo_redo->add_do_method(node.ptr(), "set_constant", float_constant_defs[p_index].value);
+ undo_redo->create_action(vformat(TTR("Set Constant: %s"), float_constant_defs[p_which].name));
+ undo_redo->add_do_method(node.ptr(), "set_constant", float_constant_defs[p_which].value);
undo_redo->add_undo_method(node.ptr(), "set_constant", node->get_constant());
- undo_redo->add_do_method(graph_plugin.ptr(), "update_constant", type, p_node);
- undo_redo->add_undo_method(graph_plugin.ptr(), "update_constant", type, p_node);
undo_redo->commit_action();
}
@@ -4460,6 +4454,7 @@ VisualShaderEditor::VisualShaderEditor() {
// TRANSFORM
add_options.push_back(AddOption("TransformFunc", "Transform", "Common", "VisualShaderNodeTransformFunc", TTR("Transform function."), -1, VisualShaderNode::PORT_TYPE_TRANSFORM));
+ add_options.push_back(AddOption("TransformOp", "Transform", "Common", "VisualShaderNodeTransformOp", TTR("Transform operator."), -1, VisualShaderNode::PORT_TYPE_TRANSFORM));
add_options.push_back(AddOption("OuterProduct", "Transform", "Composition", "VisualShaderNodeOuterProduct", TTR("Calculate the outer product of a pair of vectors.\n\nOuterProduct treats the first parameter 'c' as a column vector (matrix with one column) and the second parameter 'r' as a row vector (matrix with one row) and does a linear algebraic matrix multiply 'c * r', yielding a matrix whose number of rows is the number of components in 'c' and whose number of columns is the number of components in 'r'."), -1, VisualShaderNode::PORT_TYPE_TRANSFORM));
add_options.push_back(AddOption("TransformCompose", "Transform", "Composition", "VisualShaderNodeTransformCompose", TTR("Composes transform from four vectors."), -1, VisualShaderNode::PORT_TYPE_TRANSFORM));
@@ -4470,7 +4465,11 @@ VisualShaderEditor::VisualShaderEditor() {
add_options.push_back(AddOption("Inverse", "Transform", "Functions", "VisualShaderNodeTransformFunc", TTR("Calculates the inverse of a transform."), VisualShaderNodeTransformFunc::FUNC_INVERSE, VisualShaderNode::PORT_TYPE_TRANSFORM));
add_options.push_back(AddOption("Transpose", "Transform", "Functions", "VisualShaderNodeTransformFunc", TTR("Calculates the transpose of a transform."), VisualShaderNodeTransformFunc::FUNC_TRANSPOSE, VisualShaderNode::PORT_TYPE_TRANSFORM));
- add_options.push_back(AddOption("TransformMult", "Transform", "Operators", "VisualShaderNodeTransformMult", TTR("Multiplies transform by transform."), -1, VisualShaderNode::PORT_TYPE_TRANSFORM));
+ add_options.push_back(AddOption("Add", "Transform", "Operators", "VisualShaderNodeTransformOp", TTR("Sums two transforms."), VisualShaderNodeTransformOp::OP_ADD, VisualShaderNode::PORT_TYPE_TRANSFORM));
+ add_options.push_back(AddOption("Divide", "Transform", "Operators", "VisualShaderNodeTransformOp", TTR("Divides two transforms."), VisualShaderNodeTransformOp::OP_A_DIV_B, VisualShaderNode::PORT_TYPE_TRANSFORM));
+ add_options.push_back(AddOption("Multiply", "Transform", "Operators", "VisualShaderNodeTransformOp", TTR("Multiplies two transforms."), VisualShaderNodeTransformOp::OP_AxB, VisualShaderNode::PORT_TYPE_TRANSFORM));
+ add_options.push_back(AddOption("MultiplyComp", "Transform", "Operators", "VisualShaderNodeTransformOp", TTR("Performs per-component multiplication of two transforms."), VisualShaderNodeTransformOp::OP_AxB_COMP, VisualShaderNode::PORT_TYPE_TRANSFORM));
+ add_options.push_back(AddOption("Subtract", "Transform", "Operators", "VisualShaderNodeTransformOp", TTR("Subtracts two transforms."), VisualShaderNodeTransformOp::OP_A_MINUS_B, VisualShaderNode::PORT_TYPE_TRANSFORM));
add_options.push_back(AddOption("TransformVectorMult", "Transform", "Operators", "VisualShaderNodeTransformVecMult", TTR("Multiplies vector by transform."), -1, VisualShaderNode::PORT_TYPE_VECTOR));
add_options.push_back(AddOption("TransformConstant", "Transform", "Variables", "VisualShaderNodeTransformConstant", TTR("Transform constant."), -1, VisualShaderNode::PORT_TYPE_TRANSFORM));
@@ -4753,9 +4752,6 @@ public:
if (p_property != "constant") {
undo_redo->add_do_method(VisualShaderEditor::get_singleton()->get_graph_plugin(), "update_node_deferred", shader_type, node_id);
undo_redo->add_undo_method(VisualShaderEditor::get_singleton()->get_graph_plugin(), "update_node_deferred", shader_type, node_id);
- } else {
- undo_redo->add_do_method(VisualShaderEditor::get_singleton()->get_graph_plugin(), "update_constant", shader_type, node_id);
- undo_redo->add_undo_method(VisualShaderEditor::get_singleton()->get_graph_plugin(), "update_constant", shader_type, node_id);
}
undo_redo->commit_action();
diff --git a/editor/plugins/visual_shader_editor_plugin.h b/editor/plugins/visual_shader_editor_plugin.h
index f53726edb9..87bab16a45 100644
--- a/editor/plugins/visual_shader_editor_plugin.h
+++ b/editor/plugins/visual_shader_editor_plugin.h
@@ -73,7 +73,6 @@ private:
Map<int, Port> output_ports;
VBoxContainer *preview_box = nullptr;
LineEdit *uniform_name = nullptr;
- OptionButton *const_op = nullptr;
CodeEdit *expression_edit = nullptr;
CurveEditor *curve_editors[3] = { nullptr, nullptr, nullptr };
};
@@ -95,7 +94,6 @@ public:
void register_output_port(int p_id, int p_port, TextureButton *p_button);
void register_uniform_name(int p_id, LineEdit *p_uniform_name);
void register_default_input_button(int p_node_id, int p_port_id, Button *p_button);
- void register_constant_option_btn(int p_node_id, OptionButton *p_button);
void register_expression_edit(int p_node_id, CodeEdit *p_expression_edit);
void register_curve_editor(int p_node_id, int p_index, CurveEditor *p_curve_editor);
void clear_links();
@@ -118,7 +116,6 @@ public:
void set_uniform_name(VisualShader::Type p_type, int p_node_id, const String &p_name);
void update_curve(int p_node_id);
void update_curve_xyz(int p_node_id);
- void update_constant(VisualShader::Type p_type, int p_node_id);
void set_expression(VisualShader::Type p_type, int p_node_id, const String &p_expression);
int get_constant_index(float p_constant) const;
void update_node_size(int p_node_id);
@@ -164,6 +161,7 @@ class VisualShaderEditor : public VBoxContainer {
ConfirmationDialog *members_dialog;
PopupMenu *popup_menu;
+ PopupMenu *constants_submenu = nullptr;
MenuButton *tools;
PopupPanel *comment_title_change_popup = nullptr;
@@ -214,6 +212,7 @@ class VisualShaderEditor : public VBoxContainer {
DELETE,
DUPLICATE,
SEPARATOR2, // ignore
+ FLOAT_CONSTANTS,
CONVERT_CONSTANTS_TO_UNIFORMS,
CONVERT_UNIFORMS_TO_CONSTANTS,
SEPARATOR3, // ignore
@@ -347,6 +346,7 @@ class VisualShaderEditor : public VBoxContainer {
Set<int> selected_constants;
Set<int> selected_uniforms;
int selected_comment = -1;
+ int selected_float_constant = -1;
void _convert_constants_to_uniforms(bool p_vice_versa);
void _replace_node(VisualShader::Type p_type_id, int p_node_id, const StringName &p_from, const StringName &p_to);
@@ -396,7 +396,7 @@ class VisualShaderEditor : public VBoxContainer {
void _input_select_item(Ref<VisualShaderNodeInput> input, String name);
void _uniform_select_item(Ref<VisualShaderNodeUniformRef> p_uniform, String p_name);
- void _float_constant_selected(int p_index, int p_node);
+ void _float_constant_selected(int p_which);
VisualShader::Type get_current_shader_type() const;
diff --git a/modules/denoise/lightmap_denoiser.cpp b/modules/denoise/lightmap_denoiser.cpp
index 003bc832b0..71dcc1d75f 100644
--- a/modules/denoise/lightmap_denoiser.cpp
+++ b/modules/denoise/lightmap_denoiser.cpp
@@ -31,6 +31,8 @@
#include "lightmap_denoiser.h"
#include "denoise_wrapper.h"
+#include "core/io/image.h"
+
LightmapDenoiser *LightmapDenoiserOIDN::create_oidn_denoiser() {
return memnew(LightmapDenoiserOIDN);
}
diff --git a/modules/gdnative/gdnative/packed_arrays.cpp b/modules/gdnative/gdnative/packed_arrays.cpp
index 396109e576..f03c94aeb8 100644
--- a/modules/gdnative/gdnative/packed_arrays.cpp
+++ b/modules/gdnative/gdnative/packed_arrays.cpp
@@ -51,8 +51,6 @@ static_assert(sizeof(godot_packed_color_array) == sizeof(PackedColorArray), "Pac
extern "C" {
#endif
-#define memnew_placement_custom(m_placement, m_class, m_constr) _post_initialize(new (m_placement, sizeof(m_class), "") m_constr)
-
// byte
void GDAPI godot_packed_byte_array_new(godot_packed_byte_array *p_self) {
diff --git a/modules/gdnative/gdnative/variant.cpp b/modules/gdnative/gdnative/variant.cpp
index 1d75ea206c..ec9aaa0a55 100644
--- a/modules/gdnative/gdnative/variant.cpp
+++ b/modules/gdnative/gdnative/variant.cpp
@@ -48,8 +48,6 @@ static_assert(sizeof(godot_variant) == sizeof(Variant), "Variant size mismatch")
#pragma GCC optimize("-O0")
#endif
-#define memnew_placement_custom(m_placement, m_class, m_constr) _post_initialize(new (m_placement, sizeof(m_class), "") m_constr)
-
#if defined(__arm__) && defined(__GNUC__) && !defined(__clang__) && \
(__GNUC__ == 6 || (__GNUC__ == 7 && __GNUC_MINOR__ < 4) || (__GNUC__ == 8 && __GNUC_MINOR__ < 1))
#pragma GCC pop_options
@@ -70,131 +68,131 @@ void GDAPI godot_variant_new_nil(godot_variant *r_dest) {
void GDAPI godot_variant_new_bool(godot_variant *r_dest, const godot_bool p_b) {
Variant *dest = (Variant *)r_dest;
- memnew_placement_custom(dest, Variant, Variant(p_b));
+ memnew_placement(dest, Variant(p_b));
}
void GDAPI godot_variant_new_int(godot_variant *r_dest, const godot_int p_i) {
Variant *dest = (Variant *)r_dest;
- memnew_placement_custom(dest, Variant, Variant(p_i));
+ memnew_placement(dest, Variant(p_i));
}
void GDAPI godot_variant_new_float(godot_variant *r_dest, const godot_float p_r) {
Variant *dest = (Variant *)r_dest;
- memnew_placement_custom(dest, Variant, Variant(p_r));
+ memnew_placement(dest, Variant(p_r));
}
void GDAPI godot_variant_new_string(godot_variant *r_dest, const godot_string *p_s) {
Variant *dest = (Variant *)r_dest;
const String *s = (const String *)p_s;
- memnew_placement_custom(dest, Variant, Variant(*s));
+ memnew_placement(dest, Variant(*s));
}
void GDAPI godot_variant_new_string_name(godot_variant *r_dest, const godot_string_name *p_s) {
Variant *dest = (Variant *)r_dest;
const StringName *s = (const StringName *)p_s;
- memnew_placement_custom(dest, Variant, Variant(*s));
+ memnew_placement(dest, Variant(*s));
}
void GDAPI godot_variant_new_vector2(godot_variant *r_dest, const godot_vector2 *p_v2) {
Variant *dest = (Variant *)r_dest;
const Vector2 *v2 = (const Vector2 *)p_v2;
- memnew_placement_custom(dest, Variant, Variant(*v2));
+ memnew_placement(dest, Variant(*v2));
}
void GDAPI godot_variant_new_vector2i(godot_variant *r_dest, const godot_vector2i *p_v2) {
Variant *dest = (Variant *)r_dest;
const Vector2i *v2 = (const Vector2i *)p_v2;
- memnew_placement_custom(dest, Variant, Variant(*v2));
+ memnew_placement(dest, Variant(*v2));
}
void GDAPI godot_variant_new_rect2(godot_variant *r_dest, const godot_rect2 *p_rect2) {
Variant *dest = (Variant *)r_dest;
const Rect2 *rect2 = (const Rect2 *)p_rect2;
- memnew_placement_custom(dest, Variant, Variant(*rect2));
+ memnew_placement(dest, Variant(*rect2));
}
void GDAPI godot_variant_new_rect2i(godot_variant *r_dest, const godot_rect2i *p_rect2) {
Variant *dest = (Variant *)r_dest;
const Rect2i *rect2 = (const Rect2i *)p_rect2;
- memnew_placement_custom(dest, Variant, Variant(*rect2));
+ memnew_placement(dest, Variant(*rect2));
}
void GDAPI godot_variant_new_vector3(godot_variant *r_dest, const godot_vector3 *p_v3) {
Variant *dest = (Variant *)r_dest;
const Vector3 *v3 = (const Vector3 *)p_v3;
- memnew_placement_custom(dest, Variant, Variant(*v3));
+ memnew_placement(dest, Variant(*v3));
}
void GDAPI godot_variant_new_vector3i(godot_variant *r_dest, const godot_vector3i *p_v3) {
Variant *dest = (Variant *)r_dest;
const Vector3i *v3 = (const Vector3i *)p_v3;
- memnew_placement_custom(dest, Variant, Variant(*v3));
+ memnew_placement(dest, Variant(*v3));
}
void GDAPI godot_variant_new_transform2d(godot_variant *r_dest, const godot_transform2d *p_t2d) {
Variant *dest = (Variant *)r_dest;
const Transform2D *t2d = (const Transform2D *)p_t2d;
- memnew_placement_custom(dest, Variant, Variant(*t2d));
+ memnew_placement(dest, Variant(*t2d));
}
void GDAPI godot_variant_new_plane(godot_variant *r_dest, const godot_plane *p_plane) {
Variant *dest = (Variant *)r_dest;
const Plane *plane = (const Plane *)p_plane;
- memnew_placement_custom(dest, Variant, Variant(*plane));
+ memnew_placement(dest, Variant(*plane));
}
void GDAPI godot_variant_new_quaternion(godot_variant *r_dest, const godot_quaternion *p_quaternion) {
Variant *dest = (Variant *)r_dest;
const Quaternion *quaternion = (const Quaternion *)p_quaternion;
- memnew_placement_custom(dest, Variant, Variant(*quaternion));
+ memnew_placement(dest, Variant(*quaternion));
}
void GDAPI godot_variant_new_aabb(godot_variant *r_dest, const godot_aabb *p_aabb) {
Variant *dest = (Variant *)r_dest;
const AABB *aabb = (const AABB *)p_aabb;
- memnew_placement_custom(dest, Variant, Variant(*aabb));
+ memnew_placement(dest, Variant(*aabb));
}
void GDAPI godot_variant_new_basis(godot_variant *r_dest, const godot_basis *p_basis) {
Variant *dest = (Variant *)r_dest;
const Basis *basis = (const Basis *)p_basis;
- memnew_placement_custom(dest, Variant, Variant(*basis));
+ memnew_placement(dest, Variant(*basis));
}
void GDAPI godot_variant_new_transform3d(godot_variant *r_dest, const godot_transform3d *p_trans) {
Variant *dest = (Variant *)r_dest;
const Transform3D *trans = (const Transform3D *)p_trans;
- memnew_placement_custom(dest, Variant, Variant(*trans));
+ memnew_placement(dest, Variant(*trans));
}
void GDAPI godot_variant_new_color(godot_variant *r_dest, const godot_color *p_color) {
Variant *dest = (Variant *)r_dest;
const Color *color = (const Color *)p_color;
- memnew_placement_custom(dest, Variant, Variant(*color));
+ memnew_placement(dest, Variant(*color));
}
void GDAPI godot_variant_new_node_path(godot_variant *r_dest, const godot_node_path *p_np) {
Variant *dest = (Variant *)r_dest;
const NodePath *np = (const NodePath *)p_np;
- memnew_placement_custom(dest, Variant, Variant(*np));
+ memnew_placement(dest, Variant(*np));
}
void GDAPI godot_variant_new_rid(godot_variant *r_dest, const godot_rid *p_rid) {
Variant *dest = (Variant *)r_dest;
const RID *rid = (const RID *)p_rid;
- memnew_placement_custom(dest, Variant, Variant(*rid));
+ memnew_placement(dest, Variant(*rid));
}
void GDAPI godot_variant_new_callable(godot_variant *r_dest, const godot_callable *p_cb) {
Variant *dest = (Variant *)r_dest;
const Callable *cb = (const Callable *)p_cb;
- memnew_placement_custom(dest, Variant, Variant(*cb));
+ memnew_placement(dest, Variant(*cb));
}
void GDAPI godot_variant_new_signal(godot_variant *r_dest, const godot_signal *p_signal) {
Variant *dest = (Variant *)r_dest;
const Signal *signal = (const Signal *)p_signal;
- memnew_placement_custom(dest, Variant, Variant(*signal));
+ memnew_placement(dest, Variant(*signal));
}
void GDAPI godot_variant_new_object(godot_variant *r_dest, const godot_object *p_obj) {
@@ -206,81 +204,81 @@ void GDAPI godot_variant_new_object(godot_variant *r_dest, const godot_object *p
ref = REF(ref_counted);
}
if (!ref.is_null()) {
- memnew_placement_custom(dest, Variant, Variant(ref));
+ memnew_placement(dest, Variant(ref));
} else {
#if defined(DEBUG_METHODS_ENABLED)
if (ref_counted) {
ERR_PRINT("RefCounted object has 0 refcount in godot_variant_new_object - you lost it somewhere.");
}
#endif
- memnew_placement_custom(dest, Variant, Variant(obj));
+ memnew_placement(dest, Variant(obj));
}
}
void GDAPI godot_variant_new_dictionary(godot_variant *r_dest, const godot_dictionary *p_dict) {
Variant *dest = (Variant *)r_dest;
const Dictionary *dict = (const Dictionary *)p_dict;
- memnew_placement_custom(dest, Variant, Variant(*dict));
+ memnew_placement(dest, Variant(*dict));
}
void GDAPI godot_variant_new_array(godot_variant *r_dest, const godot_array *p_arr) {
Variant *dest = (Variant *)r_dest;
const Array *arr = (const Array *)p_arr;
- memnew_placement_custom(dest, Variant, Variant(*arr));
+ memnew_placement(dest, Variant(*arr));
}
void GDAPI godot_variant_new_packed_byte_array(godot_variant *r_dest, const godot_packed_byte_array *p_pba) {
Variant *dest = (Variant *)r_dest;
const PackedByteArray *pba = (const PackedByteArray *)p_pba;
- memnew_placement_custom(dest, Variant, Variant(*pba));
+ memnew_placement(dest, Variant(*pba));
}
void GDAPI godot_variant_new_packed_int32_array(godot_variant *r_dest, const godot_packed_int32_array *p_pia) {
Variant *dest = (Variant *)r_dest;
const PackedInt32Array *pia = (const PackedInt32Array *)p_pia;
- memnew_placement_custom(dest, Variant, Variant(*pia));
+ memnew_placement(dest, Variant(*pia));
}
void GDAPI godot_variant_new_packed_int64_array(godot_variant *r_dest, const godot_packed_int64_array *p_pia) {
Variant *dest = (Variant *)r_dest;
const PackedInt64Array *pia = (const PackedInt64Array *)p_pia;
- memnew_placement_custom(dest, Variant, Variant(*pia));
+ memnew_placement(dest, Variant(*pia));
}
void GDAPI godot_variant_new_packed_float32_array(godot_variant *r_dest, const godot_packed_float32_array *p_pra) {
Variant *dest = (Variant *)r_dest;
const PackedFloat32Array *pra = (const PackedFloat32Array *)p_pra;
- memnew_placement_custom(dest, Variant, Variant(*pra));
+ memnew_placement(dest, Variant(*pra));
}
void GDAPI godot_variant_new_packed_float64_array(godot_variant *r_dest, const godot_packed_float64_array *p_pra) {
Variant *dest = (Variant *)r_dest;
const PackedFloat64Array *pra = (const PackedFloat64Array *)p_pra;
- memnew_placement_custom(dest, Variant, Variant(*pra));
+ memnew_placement(dest, Variant(*pra));
}
void GDAPI godot_variant_new_packed_string_array(godot_variant *r_dest, const godot_packed_string_array *p_psa) {
Variant *dest = (Variant *)r_dest;
const PackedStringArray *psa = (const PackedStringArray *)p_psa;
- memnew_placement_custom(dest, Variant, Variant(*psa));
+ memnew_placement(dest, Variant(*psa));
}
void GDAPI godot_variant_new_packed_vector2_array(godot_variant *r_dest, const godot_packed_vector2_array *p_pv2a) {
Variant *dest = (Variant *)r_dest;
const PackedVector2Array *pv2a = (const PackedVector2Array *)p_pv2a;
- memnew_placement_custom(dest, Variant, Variant(*pv2a));
+ memnew_placement(dest, Variant(*pv2a));
}
void GDAPI godot_variant_new_packed_vector3_array(godot_variant *r_dest, const godot_packed_vector3_array *p_pv3a) {
Variant *dest = (Variant *)r_dest;
const PackedVector3Array *pv3a = (const PackedVector3Array *)p_pv3a;
- memnew_placement_custom(dest, Variant, Variant(*pv3a));
+ memnew_placement(dest, Variant(*pv3a));
}
void GDAPI godot_variant_new_packed_color_array(godot_variant *r_dest, const godot_packed_color_array *p_pca) {
Variant *dest = (Variant *)r_dest;
const PackedColorArray *pca = (const PackedColorArray *)p_pca;
- memnew_placement_custom(dest, Variant, Variant(*pca));
+ memnew_placement(dest, Variant(*pca));
}
godot_bool GDAPI godot_variant_as_bool(const godot_variant *p_self) {
@@ -568,7 +566,7 @@ void GDAPI godot_variant_call(godot_variant *p_self, const godot_string_name *p_
Variant ret;
Callable::CallError error;
self->call(*method, args, p_argcount, ret, error);
- memnew_placement_custom(r_return, Variant, Variant(ret));
+ memnew_placement(r_return, Variant(ret));
if (r_error) {
r_error->error = (godot_variant_call_error_error)error.error;
@@ -584,7 +582,7 @@ void GDAPI godot_variant_call_with_cstring(godot_variant *p_self, const char *p_
Variant ret;
Callable::CallError error;
self->call(method, args, p_argcount, ret, error);
- memnew_placement_custom(r_return, Variant, Variant(ret));
+ memnew_placement(r_return, Variant(ret));
if (r_error) {
r_error->error = (godot_variant_call_error_error)error.error;
@@ -600,7 +598,7 @@ void GDAPI godot_variant_call_static(godot_variant_type p_type, const godot_stri
Variant ret;
Callable::CallError error;
Variant::call_static(type, *method, args, p_argcount, ret, error);
- memnew_placement_custom(r_return, Variant, Variant(ret));
+ memnew_placement(r_return, Variant(ret));
if (r_error) {
r_error->error = (godot_variant_call_error_error)error.error;
@@ -616,7 +614,7 @@ void GDAPI godot_variant_call_static_with_cstring(godot_variant_type p_type, con
Variant ret;
Callable::CallError error;
Variant::call_static(type, method, args, p_argcount, ret, error);
- memnew_placement_custom(r_return, Variant, Variant(ret));
+ memnew_placement(r_return, Variant(ret));
if (r_error) {
r_error->error = (godot_variant_call_error_error)error.error;
@@ -679,7 +677,7 @@ godot_variant GDAPI godot_variant_get(const godot_variant *p_self, const godot_v
ret = self->get(*key, r_valid);
godot_variant result;
- memnew_placement_custom(&result, Variant, Variant(ret));
+ memnew_placement(&result, Variant(ret));
return result;
}
@@ -690,7 +688,7 @@ godot_variant GDAPI godot_variant_get_named(const godot_variant *p_self, const g
ret = self->get_named(*key, *r_valid);
godot_variant result;
- memnew_placement_custom(&result, Variant, Variant(ret));
+ memnew_placement(&result, Variant(ret));
return result;
}
@@ -701,7 +699,7 @@ godot_variant GDAPI godot_variant_get_named_with_cstring(const godot_variant *p_
ret = self->get_named(*key, *r_valid);
godot_variant result;
- memnew_placement_custom(&result, Variant, Variant(ret));
+ memnew_placement(&result, Variant(ret));
return result;
}
@@ -712,7 +710,7 @@ godot_variant GDAPI godot_variant_get_keyed(const godot_variant *p_self, const g
ret = self->get_keyed(*key, *r_valid);
godot_variant result;
- memnew_placement_custom(&result, Variant, Variant(ret));
+ memnew_placement(&result, Variant(ret));
return result;
}
@@ -722,7 +720,7 @@ godot_variant GDAPI godot_variant_get_indexed(const godot_variant *p_self, godot
ret = self->get_indexed(p_index, *r_valid, *r_oob);
godot_variant result;
- memnew_placement_custom(&result, Variant, Variant(ret));
+ memnew_placement(&result, Variant(ret));
return result;
}
@@ -747,7 +745,7 @@ godot_variant GDAPI godot_variant_iter_get(const godot_variant *p_self, godot_va
Variant result = self->iter_next(*iter, *r_valid);
godot_variant ret;
- memnew_placement_custom(&ret, Variant, Variant(result));
+ memnew_placement(&ret, Variant(result));
return ret;
}
@@ -781,7 +779,7 @@ godot_variant GDAPI godot_variant_duplicate(const godot_variant *p_self, godot_b
const Variant *self = (const Variant *)p_self;
Variant result = self->duplicate(p_deep);
godot_variant ret;
- memnew_placement_custom(&ret, Variant, Variant(result));
+ memnew_placement(&ret, Variant(result));
return ret;
}
@@ -789,7 +787,7 @@ godot_string GDAPI godot_variant_stringify(const godot_variant *p_self) {
const Variant *self = (const Variant *)p_self;
String result = *self;
godot_string ret;
- memnew_placement_custom(&ret, String, String(result));
+ memnew_placement(&ret, String(result));
return ret;
}
@@ -811,7 +809,7 @@ godot_variant_type GDAPI godot_variant_get_operator_return_type(godot_variant_op
godot_string GDAPI godot_variant_get_operator_name(godot_variant_operator p_operator) {
String op_name = Variant::get_operator_name((Variant::Operator)p_operator);
godot_string ret;
- memnew_placement_custom(&ret, String, String(op_name));
+ memnew_placement(&ret, String(op_name));
return ret;
}
@@ -916,7 +914,7 @@ void GDAPI godot_variant_get_builtin_method_list(godot_variant_type p_type, godo
Variant::get_builtin_method_list((Variant::Type)p_type, &list);
int i = 0;
for (const StringName &E : list) {
- memnew_placement_custom(&r_list[i], StringName, StringName(E));
+ memnew_placement(&r_list[i], StringName(E));
}
}
@@ -971,7 +969,7 @@ void GDAPI godot_variant_get_member_list(godot_variant_type p_type, godot_string
Variant::get_member_list((Variant::Type)p_type, &members);
int i = 0;
for (const StringName &E : members) {
- memnew_placement_custom(&r_list[i++], StringName, StringName(E));
+ memnew_placement(&r_list[i++], StringName(E));
}
}
@@ -1076,7 +1074,7 @@ void GDAPI godot_variant_get_constants_list(godot_variant_type p_type, godot_str
int i = 0;
Variant::get_constants_for_type((Variant::Type)p_type, &constants);
for (const StringName &E : constants) {
- memnew_placement_custom(&r_list[i++], StringName, StringName(E));
+ memnew_placement(&r_list[i++], StringName(E));
}
}
@@ -1091,14 +1089,14 @@ bool GDAPI godot_variant_has_constant_with_cstring(godot_variant_type p_type, co
godot_variant GDAPI godot_variant_get_constant_value(godot_variant_type p_type, const godot_string_name *p_constant) {
Variant constant = Variant::get_constant_value((Variant::Type)p_type, *((const StringName *)p_constant));
godot_variant ret;
- memnew_placement_custom(&ret, Variant, Variant(constant));
+ memnew_placement(&ret, Variant(constant));
return ret;
}
godot_variant GDAPI godot_variant_get_constant_value_with_cstring(godot_variant_type p_type, const char *p_constant) {
Variant constant = Variant::get_constant_value((Variant::Type)p_type, StringName(p_constant));
godot_variant ret;
- memnew_placement_custom(&ret, Variant, Variant(constant));
+ memnew_placement(&ret, Variant(constant));
return ret;
}
@@ -1183,14 +1181,14 @@ godot_variant_type GDAPI godot_variant_get_utility_function_argument_type_with_c
godot_string GDAPI godot_variant_get_utility_function_argument_name(const godot_string_name *p_function, int p_argument) {
String argument_name = Variant::get_utility_function_argument_name(*((const StringName *)p_function), p_argument);
godot_string ret;
- memnew_placement_custom(&ret, String, String(argument_name));
+ memnew_placement(&ret, String(argument_name));
return ret;
}
godot_string GDAPI godot_variant_get_utility_function_argument_name_with_cstring(const char *p_function, int p_argument) {
String argument_name = Variant::get_utility_function_argument_name(StringName(p_function), p_argument);
godot_string ret;
- memnew_placement_custom(&ret, String, String(argument_name));
+ memnew_placement(&ret, String(argument_name));
return ret;
}
@@ -1228,7 +1226,7 @@ void GDAPI godot_variant_get_utility_function_list(godot_string_name *r_function
Variant::get_utility_function_list(&functions);
for (const StringName &E : functions) {
- memnew_placement_custom(func++, StringName, StringName(E));
+ memnew_placement(func++, StringName(E));
}
}
@@ -1258,7 +1256,7 @@ bool GDAPI godot_variant_has_key(const godot_variant *p_self, const godot_varian
godot_string GDAPI godot_variant_get_type_name(godot_variant_type p_type) {
String name = Variant::get_type_name((Variant::Type)p_type);
godot_string ret;
- memnew_placement_custom(&ret, String, String(name));
+ memnew_placement(&ret, String(name));
return ret;
}
diff --git a/modules/gdscript/gdscript_editor.cpp b/modules/gdscript/gdscript_editor.cpp
index 2e570d5a5b..1c6f23f454 100644
--- a/modules/gdscript/gdscript_editor.cpp
+++ b/modules/gdscript/gdscript_editor.cpp
@@ -623,11 +623,11 @@ static String _make_arguments_hint(const GDScriptParser::FunctionNode *p_functio
}
static void _get_directory_contents(EditorFileSystemDirectory *p_dir, Map<String, ScriptCodeCompletionOption> &r_list) {
- const String quote_style = EDITOR_DEF("text_editor/completion/use_single_quotes", false) ? "'" : "\"";
+ const String quote_style = EDITOR_GET("text_editor/completion/use_single_quotes") ? "'" : "\"";
for (int i = 0; i < p_dir->get_file_count(); i++) {
ScriptCodeCompletionOption option(p_dir->get_file_path(i), ScriptCodeCompletionOption::KIND_FILE_PATH);
- option.insert_text = quote_style + option.display + quote_style;
+ option.insert_text = option.display.quote(quote_style);
r_list.insert(option.display, option);
}
@@ -641,20 +641,20 @@ static void _find_annotation_arguments(const GDScriptParser::AnnotationNode *p_a
if (p_argument == 3 || p_argument == 4) {
// Slider hint.
ScriptCodeCompletionOption slider1("or_greater", ScriptCodeCompletionOption::KIND_PLAIN_TEXT);
- slider1.insert_text = p_quote_style + slider1.display + p_quote_style;
+ slider1.insert_text = slider1.display.quote(p_quote_style);
r_result.insert(slider1.display, slider1);
ScriptCodeCompletionOption slider2("or_lesser", ScriptCodeCompletionOption::KIND_PLAIN_TEXT);
- slider2.insert_text = p_quote_style + slider2.display + p_quote_style;
+ slider2.insert_text = slider2.display.quote(p_quote_style);
r_result.insert(slider2.display, slider2);
}
} else if (p_annotation->name == "@export_exp_easing") {
if (p_argument == 0 || p_argument == 1) {
// Easing hint.
ScriptCodeCompletionOption hint1("attenuation", ScriptCodeCompletionOption::KIND_PLAIN_TEXT);
- hint1.insert_text = p_quote_style + hint1.display + p_quote_style;
+ hint1.insert_text = hint1.display.quote(p_quote_style);
r_result.insert(hint1.display, hint1);
ScriptCodeCompletionOption hint2("inout", ScriptCodeCompletionOption::KIND_PLAIN_TEXT);
- hint2.insert_text = p_quote_style + hint2.display + p_quote_style;
+ hint2.insert_text = hint2.display.quote(p_quote_style);
r_result.insert(hint2.display, hint2);
}
} else if (p_annotation->name == "@export_node_path") {
@@ -2192,7 +2192,7 @@ static void _find_call_arguments(GDScriptParser::CompletionContext &p_context, c
Variant base = p_base.value;
GDScriptParser::DataType base_type = p_base.type;
- const String quote_style = EDITOR_DEF("text_editor/completion/use_single_quotes", false) ? "'" : "\"";
+ const String quote_style = EDITOR_GET("text_editor/completion/use_single_quotes") ? "'" : "\"";
while (base_type.is_set() && !base_type.is_variant()) {
switch (base_type.kind) {
@@ -2254,7 +2254,7 @@ static void _find_call_arguments(GDScriptParser::CompletionContext &p_context, c
}
String name = s.get_slice("/", 1);
ScriptCodeCompletionOption option("/root/" + name, ScriptCodeCompletionOption::KIND_NODE_PATH);
- option.insert_text = quote_style + option.display + quote_style;
+ option.insert_text = option.display.quote(quote_style);
r_result.insert(option.display, option);
}
}
@@ -2270,7 +2270,7 @@ static void _find_call_arguments(GDScriptParser::CompletionContext &p_context, c
}
String name = s.get_slice("/", 1);
ScriptCodeCompletionOption option(name, ScriptCodeCompletionOption::KIND_CONSTANT);
- option.insert_text = quote_style + option.display + quote_style;
+ option.insert_text = option.display.quote(quote_style);
r_result.insert(option.display, option);
}
}
@@ -2305,8 +2305,6 @@ static void _find_call_arguments(GDScriptParser::CompletionContext &p_context, c
}
static void _find_call_arguments(GDScriptParser::CompletionContext &p_context, const GDScriptParser::Node *p_call, int p_argidx, Map<String, ScriptCodeCompletionOption> &r_result, bool &r_forced, String &r_arghint) {
- const String quote_style = EDITOR_DEF("text_editor/completion/use_single_quotes", false) ? "'" : "\"";
-
if (p_call->type == GDScriptParser::Node::PRELOAD) {
if (p_argidx == 0 && bool(EditorSettings::get_singleton()->get("text_editor/completion/complete_file_paths"))) {
_get_directory_contents(EditorFileSystem::get_singleton()->get_filesystem(), r_result);
@@ -2382,7 +2380,7 @@ static void _find_call_arguments(GDScriptParser::CompletionContext &p_context, c
}
::Error GDScriptLanguage::complete_code(const String &p_code, const String &p_path, Object *p_owner, List<ScriptCodeCompletionOption> *r_options, bool &r_forced, String &r_call_hint) {
- const String quote_style = EDITOR_DEF("text_editor/completion/use_single_quotes", false) ? "'" : "\"";
+ const String quote_style = EDITOR_GET("text_editor/completion/use_single_quotes") ? "'" : "\"";
GDScriptParser parser;
GDScriptAnalyzer analyzer(&parser);
@@ -2671,8 +2669,8 @@ static void _find_call_arguments(GDScriptParser::CompletionContext &p_context, c
Map<StringName, ProjectSettings::AutoloadInfo> autoloads = ProjectSettings::get_singleton()->get_autoload_list();
for (Map<StringName, ProjectSettings::AutoloadInfo>::Element *E = autoloads.front(); E; E = E->next()) {
- String name = E->key();
- ScriptCodeCompletionOption option(quote_style + "/root/" + name + quote_style, ScriptCodeCompletionOption::KIND_NODE_PATH);
+ String path = "/root/" + E->key();
+ ScriptCodeCompletionOption option(path.quote(quote_style), ScriptCodeCompletionOption::KIND_NODE_PATH);
options.insert(option.display, option);
}
}
diff --git a/modules/gdscript/language_server/gdscript_text_document.cpp b/modules/gdscript/language_server/gdscript_text_document.cpp
index 9574c765bc..03b1e3fa44 100644
--- a/modules/gdscript/language_server/gdscript_text_document.cpp
+++ b/modules/gdscript/language_server/gdscript_text_document.cpp
@@ -291,8 +291,8 @@ Dictionary GDScriptTextDocument::resolve(const Dictionary &p_params) {
}
} else if (item.kind == lsp::CompletionItemKind::Event) {
if (params.context.triggerKind == lsp::CompletionTriggerKind::TriggerCharacter && (params.context.triggerCharacter == "(")) {
- const String quote_style = EDITOR_DEF("text_editor/completion/use_single_quotes", false) ? "'" : "\"";
- item.insertText = quote_style + item.label + quote_style;
+ const String quote_style = EDITOR_GET("text_editor/completion/use_single_quotes") ? "'" : "\"";
+ item.insertText = item.label.quote(quote_style);
}
}
diff --git a/platform/osx/export/export_plugin.cpp b/platform/osx/export/export_plugin.cpp
index 53ae1ea6fe..5b959d6da4 100644
--- a/platform/osx/export/export_plugin.cpp
+++ b/platform/osx/export/export_plugin.cpp
@@ -193,16 +193,16 @@ void EditorExportPlatformOSX::_make_icon(const Ref<Image> &p_icon, Vector<uint8_
};
static const MacOSIconInfo icon_infos[] = {
- { "ic10", "", true, 1024 }, //1024x1024 32-bit PNG and 512x512@2x 32-bit "retina" PNG
+ { "ic10", "", true, 1024 }, //1024×1024 32-bit PNG and 512×512@2x 32-bit "retina" PNG
{ "ic09", "", true, 512 }, //512×512 32-bit PNG
- { "ic14", "", true, 512 }, //256x256@2x 32-bit "retina" PNG
+ { "ic14", "", true, 512 }, //256×256@2x 32-bit "retina" PNG
{ "ic08", "", true, 256 }, //256×256 32-bit PNG
- { "ic13", "", true, 256 }, //128x128@2x 32-bit "retina" PNG
- { "ic07", "", true, 128 }, //128x128 32-bit PNG
- { "ic12", "", true, 64 }, //32x32@2x 32-bit "retina" PNG
- { "ic11", "", true, 32 }, //16x16@2x 32-bit "retina" PNG
- { "il32", "l8mk", false, 32 }, //32x32 24-bit RLE + 8-bit uncompressed mask
- { "is32", "s8mk", false, 16 } //16x16 24-bit RLE + 8-bit uncompressed mask
+ { "ic13", "", true, 256 }, //128×128@2x 32-bit "retina" PNG
+ { "ic07", "", true, 128 }, //128×128 32-bit PNG
+ { "ic12", "", true, 64 }, //32×32@2× 32-bit "retina" PNG
+ { "ic11", "", true, 32 }, //16×16@2× 32-bit "retina" PNG
+ { "il32", "l8mk", false, 32 }, //32×32 24-bit RLE + 8-bit uncompressed mask
+ { "is32", "s8mk", false, 16 } //16×16 24-bit RLE + 8-bit uncompressed mask
};
for (uint64_t i = 0; i < (sizeof(icon_infos) / sizeof(icon_infos[0])); ++i) {
diff --git a/scene/2d/animated_sprite_2d.cpp b/scene/2d/animated_sprite_2d.cpp
index 026f0a85a6..96a3134691 100644
--- a/scene/2d/animated_sprite_2d.cpp
+++ b/scene/2d/animated_sprite_2d.cpp
@@ -30,7 +30,6 @@
#include "animated_sprite_2d.h"
-#include "core/os/os.h"
#include "scene/main/viewport.h"
#include "scene/scene_string_names.h"
diff --git a/scene/2d/animated_sprite_2d.h b/scene/2d/animated_sprite_2d.h
index 0769b19b50..ac4b20a6d9 100644
--- a/scene/2d/animated_sprite_2d.h
+++ b/scene/2d/animated_sprite_2d.h
@@ -33,7 +33,6 @@
#include "scene/2d/node_2d.h"
#include "scene/resources/sprite_frames.h"
-#include "scene/resources/texture.h"
class AnimatedSprite2D : public Node2D {
GDCLASS(AnimatedSprite2D, Node2D);
diff --git a/scene/2d/area_2d.cpp b/scene/2d/area_2d.cpp
index cf84767151..d78b9847e6 100644
--- a/scene/2d/area_2d.cpp
+++ b/scene/2d/area_2d.cpp
@@ -32,7 +32,6 @@
#include "scene/scene_string_names.h"
#include "servers/audio_server.h"
-#include "servers/physics_server_2d.h"
void Area2D::set_space_override_mode(SpaceOverride p_mode) {
space_override = p_mode;
diff --git a/scene/2d/audio_stream_player_2d.cpp b/scene/2d/audio_stream_player_2d.cpp
index 4b96689613..e0b994f27d 100644
--- a/scene/2d/audio_stream_player_2d.cpp
+++ b/scene/2d/audio_stream_player_2d.cpp
@@ -30,7 +30,6 @@
#include "audio_stream_player_2d.h"
-#include "core/config/engine.h"
#include "scene/2d/area_2d.h"
#include "scene/main/window.h"
diff --git a/scene/2d/audio_stream_player_2d.h b/scene/2d/audio_stream_player_2d.h
index 21f524c703..cf05a49b00 100644
--- a/scene/2d/audio_stream_player_2d.h
+++ b/scene/2d/audio_stream_player_2d.h
@@ -31,7 +31,6 @@
#ifndef AUDIO_STREAM_PLAYER_2D_H
#define AUDIO_STREAM_PLAYER_2D_H
-#include "core/templates/safe_refcount.h"
#include "scene/2d/node_2d.h"
#include "servers/audio/audio_stream.h"
#include "servers/audio_server.h"
diff --git a/scene/2d/camera_2d.cpp b/scene/2d/camera_2d.cpp
index 2219437c14..13b37aa2b2 100644
--- a/scene/2d/camera_2d.cpp
+++ b/scene/2d/camera_2d.cpp
@@ -30,10 +30,7 @@
#include "camera_2d.h"
-#include "core/config/engine.h"
-#include "core/math/math_funcs.h"
-#include "scene/scene_string_names.h"
-#include "servers/rendering_server.h"
+#include "scene/main/window.h"
void Camera2D::_update_scroll() {
if (!is_inside_tree()) {
@@ -99,7 +96,7 @@ Transform2D Camera2D::get_camera_transform() {
Size2 screen_size = _get_camera_screen_size();
- Point2 new_camera_pos = get_global_transform().get_origin();
+ Point2 new_camera_pos = get_global_position();
Point2 ret_camera_pos;
if (!first) {
@@ -172,7 +169,7 @@ Transform2D Camera2D::get_camera_transform() {
Point2 screen_offset = (anchor_mode == ANCHOR_MODE_DRAG_CENTER ? (screen_size * 0.5 * zoom) : Point2());
- real_t angle = get_global_transform().get_rotation();
+ real_t angle = get_global_rotation();
if (rotating) {
screen_offset = screen_offset.rotated(angle);
}
@@ -308,8 +305,8 @@ void Camera2D::_notification(int p_what) {
limit_drawing_width = 3;
}
- Vector2 camera_origin = get_global_transform().get_origin();
- Vector2 camera_scale = get_global_transform().get_scale().abs();
+ Vector2 camera_origin = get_global_position();
+ Vector2 camera_scale = get_global_scale().abs();
Vector2 limit_points[4] = {
(Vector2(limit[SIDE_LEFT], limit[SIDE_TOP]) - camera_origin) / camera_scale,
(Vector2(limit[SIDE_RIGHT], limit[SIDE_TOP]) - camera_origin) / camera_scale,
@@ -492,7 +489,7 @@ void Camera2D::align() {
Size2 screen_size = _get_camera_screen_size();
- Point2 current_camera_pos = get_global_transform().get_origin();
+ Point2 current_camera_pos = get_global_position();
if (anchor_mode == ANCHOR_MODE_DRAG_CENTER) {
if (drag_horizontal_offset < 0) {
camera_pos.x = current_camera_pos.x + screen_size.x * 0.5 * drag_margin[SIDE_RIGHT] * drag_horizontal_offset;
diff --git a/scene/2d/camera_2d.h b/scene/2d/camera_2d.h
index 95b49cf076..d697515547 100644
--- a/scene/2d/camera_2d.h
+++ b/scene/2d/camera_2d.h
@@ -32,7 +32,6 @@
#define CAMERA_2D_H
#include "scene/2d/node_2d.h"
-#include "scene/main/window.h"
class Camera2D : public Node2D {
GDCLASS(Camera2D, Node2D);
diff --git a/scene/2d/collision_polygon_2d.cpp b/scene/2d/collision_polygon_2d.cpp
index 2a2fde80e2..8c8a292ad7 100644
--- a/scene/2d/collision_polygon_2d.cpp
+++ b/scene/2d/collision_polygon_2d.cpp
@@ -31,7 +31,6 @@
#include "collision_polygon_2d.h"
#include "collision_object_2d.h"
-#include "core/config/engine.h"
#include "core/math/geometry_2d.h"
#include "scene/resources/concave_polygon_shape_2d.h"
#include "scene/resources/convex_polygon_shape_2d.h"
diff --git a/scene/2d/collision_polygon_2d.h b/scene/2d/collision_polygon_2d.h
index 95dd8c9e21..6b32923010 100644
--- a/scene/2d/collision_polygon_2d.h
+++ b/scene/2d/collision_polygon_2d.h
@@ -32,7 +32,6 @@
#define COLLISION_POLYGON_2D_H
#include "scene/2d/node_2d.h"
-#include "scene/resources/shape_2d.h"
class CollisionObject2D;
diff --git a/scene/2d/collision_shape_2d.cpp b/scene/2d/collision_shape_2d.cpp
index 60780f1cc3..d52795f0d5 100644
--- a/scene/2d/collision_shape_2d.cpp
+++ b/scene/2d/collision_shape_2d.cpp
@@ -31,14 +31,8 @@
#include "collision_shape_2d.h"
#include "collision_object_2d.h"
-#include "core/config/engine.h"
-#include "scene/resources/capsule_shape_2d.h"
-#include "scene/resources/circle_shape_2d.h"
#include "scene/resources/concave_polygon_shape_2d.h"
#include "scene/resources/convex_polygon_shape_2d.h"
-#include "scene/resources/line_shape_2d.h"
-#include "scene/resources/rectangle_shape_2d.h"
-#include "scene/resources/segment_shape_2d.h"
void CollisionShape2D::_shape_changed() {
update();
diff --git a/scene/2d/cpu_particles_2d.cpp b/scene/2d/cpu_particles_2d.cpp
index ced1c5cb81..559bd2fd16 100644
--- a/scene/2d/cpu_particles_2d.cpp
+++ b/scene/2d/cpu_particles_2d.cpp
@@ -32,9 +32,7 @@
#include "core/core_string_names.h"
#include "scene/2d/gpu_particles_2d.h"
-#include "scene/main/canvas_item.h"
#include "scene/resources/particles_material.h"
-#include "servers/rendering_server.h"
void CPUParticles2D::set_emitting(bool p_emitting) {
if (emitting == p_emitting) {
diff --git a/scene/2d/cpu_particles_2d.h b/scene/2d/cpu_particles_2d.h
index 1a1f35fca5..0f8950375f 100644
--- a/scene/2d/cpu_particles_2d.h
+++ b/scene/2d/cpu_particles_2d.h
@@ -31,9 +31,7 @@
#ifndef CPU_PARTICLES_2D_H
#define CPU_PARTICLES_2D_H
-#include "core/templates/rid.h"
#include "scene/2d/node_2d.h"
-#include "scene/resources/texture.h"
class CPUParticles2D : public Node2D {
private:
diff --git a/scene/2d/gpu_particles_2d.cpp b/scene/2d/gpu_particles_2d.cpp
index 58525c6954..47bf1bc77c 100644
--- a/scene/2d/gpu_particles_2d.cpp
+++ b/scene/2d/gpu_particles_2d.cpp
@@ -30,9 +30,7 @@
#include "gpu_particles_2d.h"
-#include "core/os/os.h"
#include "scene/resources/particles_material.h"
-#include "scene/scene_string_names.h"
#ifdef TOOLS_ENABLED
#include "core/config/engine.h"
diff --git a/scene/2d/gpu_particles_2d.h b/scene/2d/gpu_particles_2d.h
index 67a87f2339..d7eee461b4 100644
--- a/scene/2d/gpu_particles_2d.h
+++ b/scene/2d/gpu_particles_2d.h
@@ -31,9 +31,7 @@
#ifndef PARTICLES_2D_H
#define PARTICLES_2D_H
-#include "core/templates/rid.h"
#include "scene/2d/node_2d.h"
-#include "scene/resources/texture.h"
class GPUParticles2D : public Node2D {
private:
diff --git a/scene/2d/joints_2d.cpp b/scene/2d/joints_2d.cpp
index dbba6917b5..4a6606256e 100644
--- a/scene/2d/joints_2d.cpp
+++ b/scene/2d/joints_2d.cpp
@@ -30,10 +30,8 @@
#include "joints_2d.h"
-#include "core/config/engine.h"
#include "physics_body_2d.h"
#include "scene/scene_string_names.h"
-#include "servers/physics_server_2d.h"
void Joint2D::_disconnect_signals() {
Node *node_a = get_node_or_null(a);
@@ -254,7 +252,7 @@ void PinJoint2D::_notification(int p_what) {
}
void PinJoint2D::_configure_joint(RID p_joint, PhysicsBody2D *body_a, PhysicsBody2D *body_b) {
- PhysicsServer2D::get_singleton()->joint_make_pin(p_joint, get_global_transform().get_origin(), body_a->get_rid(), body_b ? body_b->get_rid() : RID());
+ PhysicsServer2D::get_singleton()->joint_make_pin(p_joint, get_global_position(), body_a->get_rid(), body_b ? body_b->get_rid() : RID());
PhysicsServer2D::get_singleton()->pin_joint_set_param(p_joint, PhysicsServer2D::PIN_JOINT_SOFTNESS, softness);
}
diff --git a/scene/2d/light_2d.cpp b/scene/2d/light_2d.cpp
index ce57895341..1853b3428c 100644
--- a/scene/2d/light_2d.cpp
+++ b/scene/2d/light_2d.cpp
@@ -30,9 +30,6 @@
#include "light_2d.h"
-#include "core/config/engine.h"
-#include "servers/rendering_server.h"
-
void Light2D::_update_light_visibility() {
if (!is_inside_tree()) {
return;
diff --git a/scene/2d/line_builder.h b/scene/2d/line_builder.h
index 654e61422b..16c88d00e9 100644
--- a/scene/2d/line_builder.h
+++ b/scene/2d/line_builder.h
@@ -31,10 +31,7 @@
#ifndef LINE_BUILDER_H
#define LINE_BUILDER_H
-#include "core/math/color.h"
-#include "core/math/vector2.h"
#include "line_2d.h"
-#include "scene/resources/gradient.h"
class LineBuilder {
public:
diff --git a/scene/2d/navigation_agent_2d.cpp b/scene/2d/navigation_agent_2d.cpp
index e9a95b680c..2f00978123 100644
--- a/scene/2d/navigation_agent_2d.cpp
+++ b/scene/2d/navigation_agent_2d.cpp
@@ -30,7 +30,6 @@
#include "navigation_agent_2d.h"
-#include "core/config/engine.h"
#include "core/math/geometry_2d.h"
#include "servers/navigation_server_2d.h"
@@ -103,7 +102,7 @@ void NavigationAgent2D::_notification(int p_what) {
} break;
case NOTIFICATION_INTERNAL_PHYSICS_PROCESS: {
if (agent_parent) {
- NavigationServer2D::get_singleton()->agent_set_position(agent, agent_parent->get_global_transform().get_origin());
+ NavigationServer2D::get_singleton()->agent_set_position(agent, agent_parent->get_global_position());
_check_distance_to_target();
}
} break;
@@ -186,7 +185,7 @@ Vector2 NavigationAgent2D::get_next_location() {
update_navigation();
if (navigation_path.size() == 0) {
ERR_FAIL_COND_V(agent_parent == nullptr, Vector2());
- return agent_parent->get_global_transform().get_origin();
+ return agent_parent->get_global_position();
} else {
return navigation_path[nav_path_index];
}
@@ -194,7 +193,7 @@ Vector2 NavigationAgent2D::get_next_location() {
real_t NavigationAgent2D::distance_to_target() const {
ERR_FAIL_COND_V(agent_parent == nullptr, 0.0);
- return agent_parent->get_global_transform().get_origin().distance_to(target_location);
+ return agent_parent->get_global_position().distance_to(target_location);
}
bool NavigationAgent2D::is_target_reached() const {
@@ -261,7 +260,7 @@ void NavigationAgent2D::update_navigation() {
update_frame_id = Engine::get_singleton()->get_physics_frames();
- Vector2 o = agent_parent->get_global_transform().get_origin();
+ Vector2 o = agent_parent->get_global_position();
bool reload_path = false;
diff --git a/scene/2d/navigation_agent_2d.h b/scene/2d/navigation_agent_2d.h
index 234cad333f..052cd78a56 100644
--- a/scene/2d/navigation_agent_2d.h
+++ b/scene/2d/navigation_agent_2d.h
@@ -31,7 +31,6 @@
#ifndef NAVIGATION_AGENT_2D_H
#define NAVIGATION_AGENT_2D_H
-#include "core/templates/vector.h"
#include "scene/main/node.h"
class Node2D;
diff --git a/scene/2d/navigation_obstacle_2d.cpp b/scene/2d/navigation_obstacle_2d.cpp
index a06f7a9fd0..0a105826c0 100644
--- a/scene/2d/navigation_obstacle_2d.cpp
+++ b/scene/2d/navigation_obstacle_2d.cpp
@@ -31,7 +31,6 @@
#include "navigation_obstacle_2d.h"
#include "scene/2d/collision_shape_2d.h"
-#include "scene/2d/physics_body_2d.h"
#include "servers/navigation_server_2d.h"
void NavigationObstacle2D::_bind_methods() {
@@ -54,7 +53,7 @@ void NavigationObstacle2D::_notification(int p_what) {
} break;
case NOTIFICATION_INTERNAL_PHYSICS_PROCESS: {
if (parent_node2d) {
- NavigationServer2D::get_singleton()->agent_set_position(agent, parent_node2d->get_global_transform().get_origin());
+ NavigationServer2D::get_singleton()->agent_set_position(agent, parent_node2d->get_global_position());
}
} break;
}
@@ -93,13 +92,13 @@ void NavigationObstacle2D::update_agent_shape() {
// and add the enclosing shape radius
r += cs->get_shape()->get_enclosing_radius();
}
- Size2 s = cs->get_global_transform().get_scale();
+ Size2 s = cs->get_global_scale();
r *= MAX(s.x, s.y);
// Takes the biggest radius
radius = MAX(radius, r);
}
}
- Vector2 s = parent_node2d->get_global_transform().get_scale();
+ Vector2 s = parent_node2d->get_global_scale();
radius *= MAX(s.x, s.y);
if (radius == 0.0) {
diff --git a/scene/2d/navigation_region_2d.cpp b/scene/2d/navigation_region_2d.cpp
index 58b20ccad0..72ea6541e3 100644
--- a/scene/2d/navigation_region_2d.cpp
+++ b/scene/2d/navigation_region_2d.cpp
@@ -30,7 +30,6 @@
#include "navigation_region_2d.h"
-#include "core/config/engine.h"
#include "core/core_string_names.h"
#include "core/math/geometry_2d.h"
#include "core/os/mutex.h"
diff --git a/scene/2d/node_2d.cpp b/scene/2d/node_2d.cpp
index a744ef40f6..6a8788ee6e 100644
--- a/scene/2d/node_2d.cpp
+++ b/scene/2d/node_2d.cpp
@@ -30,11 +30,6 @@
#include "node_2d.h"
-#include "core/object/message_queue.h"
-#include "scene/gui/control.h"
-#include "scene/main/window.h"
-#include "servers/rendering_server.h"
-
#ifdef TOOLS_ENABLED
Dictionary Node2D::_edit_get_state() const {
Dictionary state;
diff --git a/scene/2d/parallax_background.h b/scene/2d/parallax_background.h
index 27134dab29..3745c5b587 100644
--- a/scene/2d/parallax_background.h
+++ b/scene/2d/parallax_background.h
@@ -31,8 +31,6 @@
#ifndef PARALLAX_BACKGROUND_H
#define PARALLAX_BACKGROUND_H
-#include "scene/2d/camera_2d.h"
-#include "scene/2d/node_2d.h"
#include "scene/main/canvas_layer.h"
class ParallaxBackground : public CanvasLayer {
diff --git a/scene/2d/parallax_layer.cpp b/scene/2d/parallax_layer.cpp
index 228020d383..1fe6a4a4b8 100644
--- a/scene/2d/parallax_layer.cpp
+++ b/scene/2d/parallax_layer.cpp
@@ -30,7 +30,6 @@
#include "parallax_layer.h"
-#include "core/config/engine.h"
#include "parallax_background.h"
void ParallaxLayer::set_motion_scale(const Size2 &p_scale) {
diff --git a/scene/2d/path_2d.cpp b/scene/2d/path_2d.cpp
index 9912612c4f..ed30e871d7 100644
--- a/scene/2d/path_2d.cpp
+++ b/scene/2d/path_2d.cpp
@@ -30,9 +30,7 @@
#include "path_2d.h"
-#include "core/config/engine.h"
#include "core/math/geometry_2d.h"
-#include "scene/scene_string_names.h"
#ifdef TOOLS_ENABLED
#include "editor/editor_scale.h"
diff --git a/scene/2d/physics_body_2d.cpp b/scene/2d/physics_body_2d.cpp
index fa19d5c2cf..d52c293763 100644
--- a/scene/2d/physics_body_2d.cpp
+++ b/scene/2d/physics_body_2d.cpp
@@ -30,12 +30,7 @@
#include "physics_body_2d.h"
-#include "core/config/engine.h"
#include "core/core_string_names.h"
-#include "core/math/math_funcs.h"
-#include "core/object/class_db.h"
-#include "core/templates/list.h"
-#include "core/templates/rid.h"
#include "scene/scene_string_names.h"
void PhysicsBody2D::_bind_methods() {
diff --git a/scene/2d/position_2d.cpp b/scene/2d/position_2d.cpp
index 1019f85c8a..4f053ff8b0 100644
--- a/scene/2d/position_2d.cpp
+++ b/scene/2d/position_2d.cpp
@@ -30,9 +30,6 @@
#include "position_2d.h"
-#include "core/config/engine.h"
-#include "scene/resources/texture.h"
-
const real_t DEFAULT_GIZMO_EXTENTS = 10.0;
void Position2D::_draw_cross() {
diff --git a/scene/2d/ray_cast_2d.cpp b/scene/2d/ray_cast_2d.cpp
index 546536f546..3ac2128c2e 100644
--- a/scene/2d/ray_cast_2d.cpp
+++ b/scene/2d/ray_cast_2d.cpp
@@ -31,9 +31,6 @@
#include "ray_cast_2d.h"
#include "collision_object_2d.h"
-#include "core/config/engine.h"
-#include "physics_body_2d.h"
-#include "servers/physics_server_2d.h"
void RayCast2D::set_target_position(const Vector2 &p_point) {
target_position = p_point;
diff --git a/scene/2d/remote_transform_2d.cpp b/scene/2d/remote_transform_2d.cpp
index e7cef965fe..fe3e867424 100644
--- a/scene/2d/remote_transform_2d.cpp
+++ b/scene/2d/remote_transform_2d.cpp
@@ -29,7 +29,6 @@
/*************************************************************************/
#include "remote_transform_2d.h"
-#include "scene/scene_string_names.h"
void RemoteTransform2D::_update_cache() {
cache = ObjectID();
diff --git a/scene/2d/skeleton_2d.cpp b/scene/2d/skeleton_2d.cpp
index 85d632af00..4bbbc3575d 100644
--- a/scene/2d/skeleton_2d.cpp
+++ b/scene/2d/skeleton_2d.cpp
@@ -30,8 +30,6 @@
#include "skeleton_2d.h"
-#include "scene/resources/skeleton_modification_2d.h"
-
#ifdef TOOLS_ENABLED
#include "editor/editor_settings.h"
#include "editor/plugins/canvas_item_editor_plugin.h"
@@ -327,7 +325,7 @@ bool Bone2D::_editor_get_bone_shape(Vector<Vector2> *p_shape, Vector<Vector2> *p
Vector2 rel;
if (p_other_bone) {
- rel = (p_other_bone->get_global_transform().get_origin() - get_global_transform().get_origin());
+ rel = (p_other_bone->get_global_position() - get_global_position());
rel = rel.rotated(-get_global_rotation()); // Undo Bone2D node's rotation so its drawn correctly regardless of the node's rotation
} else {
real_t angle_to_use = get_rotation() + bone_angle;
@@ -456,7 +454,7 @@ void Bone2D::calculate_length_and_rotation() {
for (int i = 0; i < child_count; i++) {
Bone2D *child = Object::cast_to<Bone2D>(get_child(i));
if (child) {
- Vector2 child_local_pos = to_local(child->get_global_transform().get_origin());
+ Vector2 child_local_pos = to_local(child->get_global_position());
length = child_local_pos.length();
bone_angle = Math::atan2(child_local_pos.normalized().y, child_local_pos.normalized().x);
calculated = true;
diff --git a/scene/2d/sprite_2d.cpp b/scene/2d/sprite_2d.cpp
index 40e0f4523f..5761f19a53 100644
--- a/scene/2d/sprite_2d.cpp
+++ b/scene/2d/sprite_2d.cpp
@@ -31,7 +31,6 @@
#include "sprite_2d.h"
#include "core/core_string_names.h"
-#include "core/os/os.h"
#include "scene/main/window.h"
#include "scene/scene_string_names.h"
diff --git a/scene/2d/tile_map.cpp b/scene/2d/tile_map.cpp
index e2a415e5aa..74eb3f2fc2 100644
--- a/scene/2d/tile_map.cpp
+++ b/scene/2d/tile_map.cpp
@@ -31,8 +31,6 @@
#include "tile_map.h"
#include "core/io/marshalls.h"
-#include "core/math/geometry_2d.h"
-#include "core/os/os.h"
#include "servers/navigation_server_2d.h"
diff --git a/scene/2d/tile_map.h b/scene/2d/tile_map.h
index dce18f7682..4e2d76a7b7 100644
--- a/scene/2d/tile_map.h
+++ b/scene/2d/tile_map.h
@@ -31,8 +31,6 @@
#ifndef TILE_MAP_H
#define TILE_MAP_H
-#include "core/templates/self_list.h"
-#include "core/templates/vset.h"
#include "scene/2d/node_2d.h"
#include "scene/gui/control.h"
#include "scene/resources/tile_set.h"
diff --git a/scene/2d/touch_screen_button.cpp b/scene/2d/touch_screen_button.cpp
index 7c345ad377..00e4e1dc62 100644
--- a/scene/2d/touch_screen_button.cpp
+++ b/scene/2d/touch_screen_button.cpp
@@ -30,11 +30,8 @@
#include "touch_screen_button.h"
-#include "core/input/input.h"
-#include "core/input/input_map.h"
-#include "core/os/os.h"
#include "scene/main/window.h"
-#
+
void TouchScreenButton::set_texture(const Ref<Texture2D> &p_texture) {
texture = p_texture;
update();
diff --git a/scene/2d/visible_on_screen_notifier_2d.cpp b/scene/2d/visible_on_screen_notifier_2d.cpp
index 25237edacf..eb4bedb6a3 100644
--- a/scene/2d/visible_on_screen_notifier_2d.cpp
+++ b/scene/2d/visible_on_screen_notifier_2d.cpp
@@ -30,12 +30,6 @@
#include "visible_on_screen_notifier_2d.h"
-#include "core/config/engine.h"
-#include "gpu_particles_2d.h"
-#include "scene/2d/animated_sprite_2d.h"
-#include "scene/2d/physics_body_2d.h"
-#include "scene/animation/animation_player.h"
-#include "scene/main/window.h"
#include "scene/scene_string_names.h"
#ifdef TOOLS_ENABLED
diff --git a/scene/3d/SCsub b/scene/3d/SCsub
index 40bdaee47d..fc61250247 100644
--- a/scene/3d/SCsub
+++ b/scene/3d/SCsub
@@ -2,7 +2,4 @@
Import("env")
-if env["disable_3d"]:
- env.add_source_files(env.scene_sources, "node_3d.cpp")
-else:
- env.add_source_files(env.scene_sources, "*.cpp")
+env.add_source_files(env.scene_sources, "*.cpp")
diff --git a/scene/3d/area_3d.cpp b/scene/3d/area_3d.cpp
index cd64a813dd..2e917c4a42 100644
--- a/scene/3d/area_3d.cpp
+++ b/scene/3d/area_3d.cpp
@@ -32,7 +32,6 @@
#include "scene/scene_string_names.h"
#include "servers/audio_server.h"
-#include "servers/physics_server_3d.h"
void Area3D::set_space_override_mode(SpaceOverride p_mode) {
space_override = p_mode;
diff --git a/scene/3d/audio_stream_player_3d.cpp b/scene/3d/audio_stream_player_3d.cpp
index 6318aad08e..d2424c9a3b 100644
--- a/scene/3d/audio_stream_player_3d.cpp
+++ b/scene/3d/audio_stream_player_3d.cpp
@@ -30,11 +30,10 @@
#include "audio_stream_player_3d.h"
-#include "core/config/engine.h"
#include "scene/3d/area_3d.h"
#include "scene/3d/camera_3d.h"
#include "scene/3d/listener_3d.h"
-#include "scene/main/window.h"
+#include "scene/main/viewport.h"
// Based on "A Novel Multichannel Panning Method for Standard and Arbitrary Loudspeaker Configurations" by Ramy Sadek and Chris Kyriakakis (2004)
// Speaker-Placement Correction Amplitude Panning (SPCAP)
@@ -429,7 +428,7 @@ void AudioStreamPlayer3D::_notification(int p_what) {
if (area && area->is_using_reverb_bus() && area->get_reverb_uniformity() > 0) {
area_sound_pos = space_state->get_closest_point_to_object_volume(area->get_rid(), listener_node->get_global_transform().origin);
- listener_area_pos = listener_node->get_global_transform().affine_inverse().xform(area_sound_pos);
+ listener_area_pos = listener_node->to_local(area_sound_pos);
}
if (max_distance > 0) {
diff --git a/scene/3d/audio_stream_player_3d.h b/scene/3d/audio_stream_player_3d.h
index 8aec493602..f86e19403c 100644
--- a/scene/3d/audio_stream_player_3d.h
+++ b/scene/3d/audio_stream_player_3d.h
@@ -31,12 +31,10 @@
#ifndef AUDIO_STREAM_PLAYER_3D_H
#define AUDIO_STREAM_PLAYER_3D_H
-#include "core/templates/safe_refcount.h"
#include "scene/3d/node_3d.h"
#include "scene/3d/velocity_tracker_3d.h"
#include "servers/audio/audio_filter_sw.h"
#include "servers/audio/audio_stream.h"
-#include "servers/audio_server.h"
class Camera3D;
class AudioStreamPlayer3D : public Node3D {
diff --git a/scene/3d/camera_3d.cpp b/scene/3d/camera_3d.cpp
index 9dc1df202c..3ada9072c2 100644
--- a/scene/3d/camera_3d.cpp
+++ b/scene/3d/camera_3d.cpp
@@ -31,10 +31,8 @@
#include "camera_3d.h"
#include "collision_object_3d.h"
-#include "core/config/engine.h"
#include "core/math/camera_matrix.h"
-#include "scene/resources/material.h"
-#include "scene/resources/surface_tool.h"
+#include "scene/main/viewport.h"
void Camera3D::_update_audio_listener_state() {
}
diff --git a/scene/3d/camera_3d.h b/scene/3d/camera_3d.h
index b7bf5566e7..3b704944b0 100644
--- a/scene/3d/camera_3d.h
+++ b/scene/3d/camera_3d.h
@@ -33,9 +33,6 @@
#include "scene/3d/node_3d.h"
#include "scene/3d/velocity_tracker_3d.h"
-#include "scene/main/window.h"
-#include "scene/resources/camera_effects.h"
-#include "scene/resources/environment.h"
class Camera3D : public Node3D {
GDCLASS(Camera3D, Node3D);
diff --git a/scene/3d/collision_object_3d.cpp b/scene/3d/collision_object_3d.cpp
index 75bb2995d3..36d9bfba82 100644
--- a/scene/3d/collision_object_3d.cpp
+++ b/scene/3d/collision_object_3d.cpp
@@ -30,7 +30,6 @@
#include "collision_object_3d.h"
-#include "core/config/engine.h"
#include "scene/scene_string_names.h"
void CollisionObject3D::_notification(int p_what) {
diff --git a/scene/3d/collision_object_3d.h b/scene/3d/collision_object_3d.h
index 2e74d84465..c066960eb4 100644
--- a/scene/3d/collision_object_3d.h
+++ b/scene/3d/collision_object_3d.h
@@ -32,8 +32,6 @@
#define COLLISION_OBJECT_3D_H
#include "scene/3d/node_3d.h"
-#include "scene/resources/shape_3d.h"
-#include "servers/physics_server_3d.h"
class CollisionObject3D : public Node3D {
GDCLASS(CollisionObject3D, Node3D);
diff --git a/scene/3d/collision_polygon_3d.cpp b/scene/3d/collision_polygon_3d.cpp
index 42645f47d4..d5835586f9 100644
--- a/scene/3d/collision_polygon_3d.cpp
+++ b/scene/3d/collision_polygon_3d.cpp
@@ -32,7 +32,6 @@
#include "collision_object_3d.h"
#include "core/math/geometry_2d.h"
-#include "scene/resources/concave_polygon_shape_3d.h"
#include "scene/resources/convex_polygon_shape_3d.h"
void CollisionPolygon3D::_build_polygon() {
diff --git a/scene/3d/collision_shape_3d.cpp b/scene/3d/collision_shape_3d.cpp
index 36d4c8f4f0..d4668a24f2 100644
--- a/scene/3d/collision_shape_3d.cpp
+++ b/scene/3d/collision_shape_3d.cpp
@@ -30,12 +30,10 @@
#include "collision_shape_3d.h"
-#include "core/math/quick_hull.h"
#include "mesh_instance_3d.h"
#include "physics_body_3d.h"
#include "scene/resources/concave_polygon_shape_3d.h"
#include "scene/resources/convex_polygon_shape_3d.h"
-#include "servers/rendering_server.h"
void CollisionShape3D::make_convex_from_siblings() {
Node *p = get_parent();
diff --git a/scene/3d/collision_shape_3d.h b/scene/3d/collision_shape_3d.h
index f69c1e38eb..cb7fe21eae 100644
--- a/scene/3d/collision_shape_3d.h
+++ b/scene/3d/collision_shape_3d.h
@@ -33,6 +33,7 @@
#include "scene/3d/node_3d.h"
#include "scene/resources/shape_3d.h"
+
class CollisionObject3D;
class CollisionShape3D : public Node3D {
GDCLASS(CollisionShape3D, Node3D);
diff --git a/scene/3d/cpu_particles_3d.cpp b/scene/3d/cpu_particles_3d.cpp
index 5a358e1917..e2095940ff 100644
--- a/scene/3d/cpu_particles_3d.cpp
+++ b/scene/3d/cpu_particles_3d.cpp
@@ -32,8 +32,8 @@
#include "scene/3d/camera_3d.h"
#include "scene/3d/gpu_particles_3d.h"
+#include "scene/main/viewport.h"
#include "scene/resources/particles_material.h"
-#include "servers/rendering_server.h"
AABB CPUParticles3D::get_aabb() const {
return AABB();
diff --git a/scene/3d/cpu_particles_3d.h b/scene/3d/cpu_particles_3d.h
index bb6699ddc7..5b60322f05 100644
--- a/scene/3d/cpu_particles_3d.h
+++ b/scene/3d/cpu_particles_3d.h
@@ -31,8 +31,6 @@
#ifndef CPU_PARTICLES_H
#define CPU_PARTICLES_H
-#include "core/templates/rid.h"
-#include "core/templates/safe_refcount.h"
#include "scene/3d/visual_instance_3d.h"
class CPUParticles3D : public GeometryInstance3D {
diff --git a/scene/3d/decal.h b/scene/3d/decal.h
index 041c8f97b2..e9bda3276d 100644
--- a/scene/3d/decal.h
+++ b/scene/3d/decal.h
@@ -32,8 +32,6 @@
#define DECAL_H
#include "scene/3d/visual_instance_3d.h"
-#include "scene/resources/texture.h"
-#include "servers/rendering_server.h"
class Decal : public VisualInstance3D {
GDCLASS(Decal, VisualInstance3D);
diff --git a/scene/3d/gpu_particles_3d.cpp b/scene/3d/gpu_particles_3d.cpp
index 7a6410ec51..d56228df66 100644
--- a/scene/3d/gpu_particles_3d.cpp
+++ b/scene/3d/gpu_particles_3d.cpp
@@ -30,11 +30,8 @@
#include "gpu_particles_3d.h"
-#include "core/os/os.h"
#include "scene/resources/particles_material.h"
-#include "servers/rendering_server.h"
-
AABB GPUParticles3D::get_aabb() const {
return AABB();
}
@@ -487,6 +484,7 @@ void GPUParticles3D::set_skin(const Ref<Skin> &p_skin) {
skin = p_skin;
_skinning_changed();
}
+
Ref<Skin> GPUParticles3D::get_skin() const {
return skin;
}
diff --git a/scene/3d/gpu_particles_3d.h b/scene/3d/gpu_particles_3d.h
index 31f33fde59..5e96f660da 100644
--- a/scene/3d/gpu_particles_3d.h
+++ b/scene/3d/gpu_particles_3d.h
@@ -31,9 +31,7 @@
#ifndef PARTICLES_H
#define PARTICLES_H
-#include "core/templates/rid.h"
#include "scene/3d/visual_instance_3d.h"
-#include "scene/resources/material.h"
#include "scene/resources/skin.h"
class GPUParticles3D : public GeometryInstance3D {
diff --git a/scene/3d/gpu_particles_collision_3d.cpp b/scene/3d/gpu_particles_collision_3d.cpp
index 8b214a9cfb..a34a30913e 100644
--- a/scene/3d/gpu_particles_collision_3d.cpp
+++ b/scene/3d/gpu_particles_collision_3d.cpp
@@ -30,7 +30,6 @@
#include "gpu_particles_collision_3d.h"
-#include "core/templates/thread_work_pool.h"
#include "mesh_instance_3d.h"
#include "scene/3d/camera_3d.h"
#include "scene/main/viewport.h"
diff --git a/scene/3d/gpu_particles_collision_3d.h b/scene/3d/gpu_particles_collision_3d.h
index f96edd4bfc..fbf68ed6df 100644
--- a/scene/3d/gpu_particles_collision_3d.h
+++ b/scene/3d/gpu_particles_collision_3d.h
@@ -32,9 +32,7 @@
#define GPU_PARTICLES_COLLISION_3D_H
#include "core/templates/local_vector.h"
-#include "core/templates/rid.h"
#include "scene/3d/visual_instance_3d.h"
-#include "scene/resources/material.h"
class GPUParticlesCollision3D : public VisualInstance3D {
GDCLASS(GPUParticlesCollision3D, VisualInstance3D);
diff --git a/scene/3d/light_3d.cpp b/scene/3d/light_3d.cpp
index 40f33dfa72..508f8a70df 100644
--- a/scene/3d/light_3d.cpp
+++ b/scene/3d/light_3d.cpp
@@ -30,10 +30,6 @@
#include "light_3d.h"
-#include "core/config/engine.h"
-#include "core/config/project_settings.h"
-#include "scene/resources/surface_tool.h"
-
bool Light3D::_can_gizmo_scale() const {
return false;
}
@@ -216,6 +212,10 @@ void Light3D::_validate_property(PropertyInfo &property) const {
property.usage = PROPERTY_USAGE_NONE;
}
+ if (get_light_type() == RS::LIGHT_SPOT && property.name == "shadow_normal_bias") {
+ property.usage = PROPERTY_USAGE_NONE;
+ }
+
if (get_light_type() == RS::LIGHT_DIRECTIONAL && property.name == "light_projector") {
property.usage = PROPERTY_USAGE_NONE;
}
@@ -344,7 +344,7 @@ Light3D::Light3D(RenderingServer::LightType p_type) {
set_param(PARAM_SHADOW_FADE_START, 0.8);
set_param(PARAM_SHADOW_PANCAKE_SIZE, 20.0);
set_param(PARAM_SHADOW_BLUR, 1.0);
- set_param(PARAM_SHADOW_BIAS, 0.02);
+ set_param(PARAM_SHADOW_BIAS, 0.03);
set_param(PARAM_SHADOW_NORMAL_BIAS, 1.0);
set_param(PARAM_TRANSMITTANCE_BIAS, 0.05);
set_param(PARAM_SHADOW_VOLUMETRIC_FOG_FADE, 0.1);
@@ -426,7 +426,8 @@ DirectionalLight3D::DirectionalLight3D() :
set_param(PARAM_SHADOW_FADE_START, 0.8);
// Increase the default shadow bias to better suit most scenes.
// Leave normal bias untouched as it doesn't benefit DirectionalLight3D as much as OmniLight3D.
- set_param(PARAM_SHADOW_BIAS, 0.05);
+ set_param(PARAM_SHADOW_BIAS, 0.1);
+ set_param(PARAM_SHADOW_NORMAL_BIAS, 1.0);
set_shadow_mode(SHADOW_PARALLEL_4_SPLITS);
blend_splits = false;
}
diff --git a/scene/3d/light_3d.h b/scene/3d/light_3d.h
index 51ed2fcf50..ecea60339f 100644
--- a/scene/3d/light_3d.h
+++ b/scene/3d/light_3d.h
@@ -32,8 +32,6 @@
#define LIGHT_3D_H
#include "scene/3d/visual_instance_3d.h"
-#include "scene/resources/texture.h"
-#include "servers/rendering_server.h"
class Light3D : public VisualInstance3D {
GDCLASS(Light3D, VisualInstance3D);
diff --git a/scene/3d/lightmap_gi.cpp b/scene/3d/lightmap_gi.cpp
index 0085c8933d..7dd083e314 100644
--- a/scene/3d/lightmap_gi.cpp
+++ b/scene/3d/lightmap_gi.cpp
@@ -31,14 +31,9 @@
#include "lightmap_gi.h"
#include "core/io/config_file.h"
-#include "core/io/dir_access.h"
-#include "core/io/file_access.h"
-#include "core/io/resource_saver.h"
-#include "core/math/camera_matrix.h"
#include "core/math/delaunay_3d.h"
-#include "core/os/os.h"
-#include "core/templates/sort_array.h"
#include "lightmap_probe.h"
+#include "scene/3d/mesh_instance_3d.h"
void LightmapGIData::add_user(const NodePath &p_path, const Rect2 &p_uv_scale, int p_slice_index, int32_t p_sub_instance) {
User user;
diff --git a/scene/3d/lightmap_gi.h b/scene/3d/lightmap_gi.h
index 8a54512383..e73350fd64 100644
--- a/scene/3d/lightmap_gi.h
+++ b/scene/3d/lightmap_gi.h
@@ -34,10 +34,7 @@
#include "core/templates/local_vector.h"
#include "scene/3d/light_3d.h"
#include "scene/3d/lightmapper.h"
-#include "scene/3d/mesh_instance_3d.h"
-#include "scene/3d/multimesh_instance_3d.h"
#include "scene/3d/visual_instance_3d.h"
-#include "scene/resources/sky.h"
class LightmapGIData : public Resource {
GDCLASS(LightmapGIData, Resource);
diff --git a/scene/3d/lightmapper.h b/scene/3d/lightmapper.h
index 3a6a88d435..d028628901 100644
--- a/scene/3d/lightmapper.h
+++ b/scene/3d/lightmapper.h
@@ -31,8 +31,9 @@
#ifndef LIGHTMAPPER_H
#define LIGHTMAPPER_H
-#include "scene/resources/mesh.h"
-#include "servers/rendering/rendering_device.h"
+#include "core/object/ref_counted.h"
+
+class Image;
#if !defined(__aligned)
diff --git a/scene/3d/listener_3d.cpp b/scene/3d/listener_3d.cpp
index 43d6f262d8..1c52933ee5 100644
--- a/scene/3d/listener_3d.cpp
+++ b/scene/3d/listener_3d.cpp
@@ -30,7 +30,7 @@
#include "listener_3d.h"
-#include "scene/resources/mesh.h"
+#include "scene/main/viewport.h"
void Listener3D::_update_audio_listener_state() {
}
diff --git a/scene/3d/listener_3d.h b/scene/3d/listener_3d.h
index bcc66f167c..25eacf5135 100644
--- a/scene/3d/listener_3d.h
+++ b/scene/3d/listener_3d.h
@@ -32,7 +32,6 @@
#define LISTENER_3D_H
#include "scene/3d/node_3d.h"
-#include "scene/main/window.h"
class Listener3D : public Node3D {
GDCLASS(Listener3D, Node3D);
diff --git a/scene/3d/mesh_instance_3d.cpp b/scene/3d/mesh_instance_3d.cpp
index 9ca1d55d0b..de6925244a 100644
--- a/scene/3d/mesh_instance_3d.cpp
+++ b/scene/3d/mesh_instance_3d.cpp
@@ -33,8 +33,6 @@
#include "collision_shape_3d.h"
#include "core/core_string_names.h"
#include "physics_body_3d.h"
-#include "scene/resources/material.h"
-#include "skeleton_3d.h"
bool MeshInstance3D::_set(const StringName &p_name, const Variant &p_value) {
//this is not _too_ bad performance wise, really. it only arrives here if the property was not set anywhere else.
diff --git a/scene/3d/mesh_instance_3d.h b/scene/3d/mesh_instance_3d.h
index e2d20d0a90..beb7f6cf95 100644
--- a/scene/3d/mesh_instance_3d.h
+++ b/scene/3d/mesh_instance_3d.h
@@ -31,10 +31,10 @@
#ifndef MESH_INSTANCE_H
#define MESH_INSTANCE_H
-#include "scene/3d/skeleton_3d.h"
#include "scene/3d/visual_instance_3d.h"
-#include "scene/resources/mesh.h"
-#include "scene/resources/skin.h"
+
+class Skin;
+class SkinReference;
class MeshInstance3D : public GeometryInstance3D {
GDCLASS(MeshInstance3D, GeometryInstance3D);
diff --git a/scene/3d/navigation_agent_3d.cpp b/scene/3d/navigation_agent_3d.cpp
index f890ceeb95..c2d5c757db 100644
--- a/scene/3d/navigation_agent_3d.cpp
+++ b/scene/3d/navigation_agent_3d.cpp
@@ -30,7 +30,6 @@
#include "navigation_agent_3d.h"
-#include "core/config/engine.h"
#include "servers/navigation_server_3d.h"
void NavigationAgent3D::_bind_methods() {
diff --git a/scene/3d/navigation_agent_3d.h b/scene/3d/navigation_agent_3d.h
index 56da2d1acf..bebfdc5f7e 100644
--- a/scene/3d/navigation_agent_3d.h
+++ b/scene/3d/navigation_agent_3d.h
@@ -31,7 +31,6 @@
#ifndef NAVIGATION_AGENT_H
#define NAVIGATION_AGENT_H
-#include "core/templates/vector.h"
#include "scene/main/node.h"
class Node3D;
diff --git a/scene/3d/navigation_obstacle_3d.h b/scene/3d/navigation_obstacle_3d.h
index 2f78f624a4..ab0b158303 100644
--- a/scene/3d/navigation_obstacle_3d.h
+++ b/scene/3d/navigation_obstacle_3d.h
@@ -32,7 +32,6 @@
#define NAVIGATION_OBSTACLE_H
#include "scene/3d/node_3d.h"
-#include "scene/main/node.h"
class NavigationObstacle3D : public Node {
GDCLASS(NavigationObstacle3D, Node);
diff --git a/scene/3d/navigation_region_3d.cpp b/scene/3d/navigation_region_3d.cpp
index 2976dad39d..8a51a259f7 100644
--- a/scene/3d/navigation_region_3d.cpp
+++ b/scene/3d/navigation_region_3d.cpp
@@ -30,7 +30,6 @@
#include "navigation_region_3d.h"
-#include "core/os/thread.h"
#include "mesh_instance_3d.h"
#include "servers/navigation_server_3d.h"
diff --git a/scene/3d/navigation_region_3d.h b/scene/3d/navigation_region_3d.h
index c2045215b1..ec7761ef93 100644
--- a/scene/3d/navigation_region_3d.h
+++ b/scene/3d/navigation_region_3d.h
@@ -32,7 +32,6 @@
#define NAVIGATION_REGION_H
#include "scene/3d/node_3d.h"
-#include "scene/resources/mesh.h"
#include "scene/resources/navigation_mesh.h"
class NavigationRegion3D : public Node3D {
diff --git a/scene/3d/node_3d.cpp b/scene/3d/node_3d.cpp
index 8f186199db..12470939f5 100644
--- a/scene/3d/node_3d.cpp
+++ b/scene/3d/node_3d.cpp
@@ -30,11 +30,9 @@
#include "node_3d.h"
-#include "core/config/engine.h"
#include "core/object/message_queue.h"
#include "scene/3d/visual_instance_3d.h"
-#include "scene/main/scene_tree.h"
-#include "scene/main/window.h"
+#include "scene/main/viewport.h"
#include "scene/scene_string_names.h"
/*
diff --git a/scene/3d/node_3d.h b/scene/3d/node_3d.h
index da54452abb..0fd0c4e205 100644
--- a/scene/3d/node_3d.h
+++ b/scene/3d/node_3d.h
@@ -32,7 +32,6 @@
#define NODE_3D_H
#include "scene/main/node.h"
-#include "scene/main/scene_tree.h"
class Node3DGizmo : public RefCounted {
GDCLASS(Node3DGizmo, RefCounted);
diff --git a/scene/3d/path_3d.cpp b/scene/3d/path_3d.cpp
index 6818acf69d..9ea37e4bfa 100644
--- a/scene/3d/path_3d.cpp
+++ b/scene/3d/path_3d.cpp
@@ -30,9 +30,6 @@
#include "path_3d.h"
-#include "core/config/engine.h"
-#include "scene/scene_string_names.h"
-
void Path3D::_notification(int p_what) {
}
diff --git a/scene/3d/physics_body_3d.cpp b/scene/3d/physics_body_3d.cpp
index e1e6153bfb..12c91271d4 100644
--- a/scene/3d/physics_body_3d.cpp
+++ b/scene/3d/physics_body_3d.cpp
@@ -30,14 +30,8 @@
#include "physics_body_3d.h"
-#include "core/config/engine.h"
#include "core/core_string_names.h"
-#include "core/object/class_db.h"
-#include "core/templates/list.h"
-#include "core/templates/rid.h"
-#include "scene/3d/collision_shape_3d.h"
#include "scene/scene_string_names.h"
-#include "servers/navigation_server_3d.h"
#ifdef TOOLS_ENABLED
#include "editor/plugins/node_3d_editor_plugin.h"
diff --git a/scene/3d/physics_joint_3d.cpp b/scene/3d/physics_joint_3d.cpp
index 59440bd1a8..12938946a0 100644
--- a/scene/3d/physics_joint_3d.cpp
+++ b/scene/3d/physics_joint_3d.cpp
@@ -259,11 +259,11 @@ real_t PinJoint3D::get_param(Param p_param) const {
void PinJoint3D::_configure_joint(RID p_joint, PhysicsBody3D *body_a, PhysicsBody3D *body_b) {
Vector3 pinpos = get_global_transform().origin;
- Vector3 local_a = body_a->get_global_transform().affine_inverse().xform(pinpos);
+ Vector3 local_a = body_a->to_local(pinpos);
Vector3 local_b;
if (body_b) {
- local_b = body_b->get_global_transform().affine_inverse().xform(pinpos);
+ local_b = body_b->to_local(pinpos);
} else {
local_b = pinpos;
}
diff --git a/scene/3d/position_3d.cpp b/scene/3d/position_3d.cpp
index b231ba0df7..9747465103 100644
--- a/scene/3d/position_3d.cpp
+++ b/scene/3d/position_3d.cpp
@@ -29,7 +29,6 @@
/*************************************************************************/
#include "position_3d.h"
-#include "scene/resources/mesh.h"
Position3D::Position3D() {
}
diff --git a/scene/3d/ray_cast_3d.cpp b/scene/3d/ray_cast_3d.cpp
index e757d6d3f4..fd4c6e7416 100644
--- a/scene/3d/ray_cast_3d.cpp
+++ b/scene/3d/ray_cast_3d.cpp
@@ -31,9 +31,7 @@
#include "ray_cast_3d.h"
#include "collision_object_3d.h"
-#include "core/config/engine.h"
#include "mesh_instance_3d.h"
-#include "servers/physics_server_3d.h"
void RayCast3D::set_target_position(const Vector3 &p_point) {
target_position = p_point;
diff --git a/scene/3d/reflection_probe.h b/scene/3d/reflection_probe.h
index 4bf20c89c5..d1b9b12f65 100644
--- a/scene/3d/reflection_probe.h
+++ b/scene/3d/reflection_probe.h
@@ -32,9 +32,6 @@
#define REFLECTIONPROBE_H
#include "scene/3d/visual_instance_3d.h"
-#include "scene/resources/sky.h"
-#include "scene/resources/texture.h"
-#include "servers/rendering_server.h"
class ReflectionProbe : public VisualInstance3D {
GDCLASS(ReflectionProbe, VisualInstance3D);
diff --git a/scene/3d/skeleton_3d.cpp b/scene/3d/skeleton_3d.cpp
index 86e2af7df5..c996735761 100644
--- a/scene/3d/skeleton_3d.cpp
+++ b/scene/3d/skeleton_3d.cpp
@@ -30,12 +30,8 @@
#include "skeleton_3d.h"
-#include "core/config/engine.h"
-#include "core/config/project_settings.h"
#include "core/object/message_queue.h"
-#include "core/variant/type_info.h"
#include "scene/3d/physics_body_3d.h"
-#include "scene/resources/surface_tool.h"
#include "scene/scene_string_names.h"
void SkinReference::_skin_changed() {
diff --git a/scene/3d/skeleton_3d.h b/scene/3d/skeleton_3d.h
index 3fdf5321a5..bccad97d5f 100644
--- a/scene/3d/skeleton_3d.h
+++ b/scene/3d/skeleton_3d.h
@@ -31,7 +31,6 @@
#ifndef SKELETON_3D_H
#define SKELETON_3D_H
-#include "core/templates/rid.h"
#include "scene/3d/node_3d.h"
#include "scene/resources/skin.h"
diff --git a/scene/3d/skeleton_ik_3d.h b/scene/3d/skeleton_ik_3d.h
index 81dfe675c3..4cf08e7c99 100644
--- a/scene/3d/skeleton_ik_3d.h
+++ b/scene/3d/skeleton_ik_3d.h
@@ -33,11 +33,6 @@
#ifndef _3D_DISABLED
-/**
- * @author AndreaCatania
- */
-
-#include "core/math/transform_3d.h"
#include "scene/3d/skeleton_3d.h"
class FabrikInverseKinematic {
diff --git a/scene/3d/soft_body_3d.cpp b/scene/3d/soft_body_3d.cpp
index 3dbeac5e97..28ff3e9412 100644
--- a/scene/3d/soft_body_3d.cpp
+++ b/scene/3d/soft_body_3d.cpp
@@ -30,13 +30,7 @@
#include "soft_body_3d.h"
-#include "core/object/class_db.h"
-#include "core/os/os.h"
-#include "core/templates/list.h"
-#include "core/templates/rid.h"
-#include "scene/3d/collision_object_3d.h"
#include "scene/3d/physics_body_3d.h"
-#include "scene/3d/skeleton_3d.h"
SoftBodyRenderingServerHandler::SoftBodyRenderingServerHandler() {}
diff --git a/scene/3d/spring_arm_3d.cpp b/scene/3d/spring_arm_3d.cpp
index 5e9265b4c3..4748a9d889 100644
--- a/scene/3d/spring_arm_3d.cpp
+++ b/scene/3d/spring_arm_3d.cpp
@@ -30,11 +30,6 @@
#include "spring_arm_3d.h"
-#include "core/config/engine.h"
-#include "scene/3d/collision_object_3d.h"
-#include "scene/resources/sphere_shape_3d.h"
-#include "servers/physics_server_3d.h"
-
void SpringArm3D::_notification(int p_what) {
switch (p_what) {
case NOTIFICATION_ENTER_TREE:
diff --git a/scene/3d/sprite_3d.h b/scene/3d/sprite_3d.h
index d35b9ffe1b..90c2a309e1 100644
--- a/scene/3d/sprite_3d.h
+++ b/scene/3d/sprite_3d.h
@@ -31,8 +31,8 @@
#ifndef SPRITE_3D_H
#define SPRITE_3D_H
-#include "scene/2d/animated_sprite_2d.h"
#include "scene/3d/visual_instance_3d.h"
+#include "scene/resources/sprite_frames.h"
class SpriteBase3D : public GeometryInstance3D {
GDCLASS(SpriteBase3D, GeometryInstance3D);
diff --git a/scene/3d/velocity_tracker_3d.cpp b/scene/3d/velocity_tracker_3d.cpp
index 8f4fecb348..200664a41b 100644
--- a/scene/3d/velocity_tracker_3d.cpp
+++ b/scene/3d/velocity_tracker_3d.cpp
@@ -29,7 +29,6 @@
/*************************************************************************/
#include "velocity_tracker_3d.h"
-#include "core/config/engine.h"
void VelocityTracker3D::set_track_physics_step(bool p_track_physics_step) {
physics_step = p_track_physics_step;
diff --git a/scene/3d/visible_on_screen_notifier_3d.cpp b/scene/3d/visible_on_screen_notifier_3d.cpp
index 6a80aa3f45..3d0bc3df9c 100644
--- a/scene/3d/visible_on_screen_notifier_3d.cpp
+++ b/scene/3d/visible_on_screen_notifier_3d.cpp
@@ -30,10 +30,6 @@
#include "visible_on_screen_notifier_3d.h"
-#include "core/config/engine.h"
-#include "scene/3d/camera_3d.h"
-#include "scene/3d/physics_body_3d.h"
-#include "scene/animation/animation_player.h"
#include "scene/scene_string_names.h"
void VisibleOnScreenNotifier3D::_visibility_enter() {
diff --git a/scene/3d/visual_instance_3d.cpp b/scene/3d/visual_instance_3d.cpp
index b437379b2a..73c2887983 100644
--- a/scene/3d/visual_instance_3d.cpp
+++ b/scene/3d/visual_instance_3d.cpp
@@ -31,8 +31,6 @@
#include "visual_instance_3d.h"
#include "scene/scene_string_names.h"
-#include "servers/rendering_server.h"
-#include "skeleton_3d.h"
AABB VisualInstance3D::get_transformed_aabb() const {
return get_global_transform().xform(get_aabb());
@@ -416,7 +414,7 @@ void GeometryInstance3D::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "ignore_occlusion_culling"), "set_ignore_occlusion_culling", "is_ignoring_occlusion_culling");
ADD_GROUP("Global Illumination", "gi_");
ADD_PROPERTY(PropertyInfo(Variant::INT, "gi_mode", PROPERTY_HINT_ENUM, "Disabled,Baked,Dynamic"), "set_gi_mode", "get_gi_mode");
- ADD_PROPERTY(PropertyInfo(Variant::INT, "gi_lightmap_scale", PROPERTY_HINT_ENUM, "1x,2x,4x,8x"), "set_lightmap_scale", "get_lightmap_scale");
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "gi_lightmap_scale", PROPERTY_HINT_ENUM, String::utf8("1×,2×,4×,8×")), "set_lightmap_scale", "get_lightmap_scale");
ADD_GROUP("Visibility Range", "visibility_range_");
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "visibility_range_begin", PROPERTY_HINT_RANGE, "0.0,4096.0,0.01"), "set_visibility_range_begin", "get_visibility_range_begin");
diff --git a/scene/3d/visual_instance_3d.h b/scene/3d/visual_instance_3d.h
index aa64195c2b..8d24e13d47 100644
--- a/scene/3d/visual_instance_3d.h
+++ b/scene/3d/visual_instance_3d.h
@@ -31,10 +31,7 @@
#ifndef VISUAL_INSTANCE_H
#define VISUAL_INSTANCE_H
-#include "core/math/face3.h"
-#include "core/templates/rid.h"
#include "scene/3d/node_3d.h"
-#include "scene/resources/material.h"
class VisualInstance3D : public Node3D {
GDCLASS(VisualInstance3D, Node3D);
diff --git a/scene/3d/voxel_gi.cpp b/scene/3d/voxel_gi.cpp
index 5cf7522667..d3d12d94e9 100644
--- a/scene/3d/voxel_gi.cpp
+++ b/scene/3d/voxel_gi.cpp
@@ -30,9 +30,8 @@
#include "voxel_gi.h"
-#include "core/os/os.h"
-
#include "mesh_instance_3d.h"
+#include "multimesh_instance_3d.h"
#include "voxelizer.h"
void VoxelGIData::_set_data(const Dictionary &p_data) {
diff --git a/scene/3d/voxel_gi.h b/scene/3d/voxel_gi.h
index 434d209421..5d0dda1ba3 100644
--- a/scene/3d/voxel_gi.h
+++ b/scene/3d/voxel_gi.h
@@ -31,7 +31,6 @@
#ifndef VOXEL_GI_H
#define VOXEL_GI_H
-#include "multimesh_instance_3d.h"
#include "scene/3d/visual_instance_3d.h"
class VoxelGIData : public Resource {
diff --git a/scene/3d/voxelizer.cpp b/scene/3d/voxelizer.cpp
index 6124326d2d..2d32379d69 100644
--- a/scene/3d/voxelizer.cpp
+++ b/scene/3d/voxelizer.cpp
@@ -29,11 +29,6 @@
/*************************************************************************/
#include "voxelizer.h"
-#include "core/math/geometry_3d.h"
-#include "core/os/os.h"
-#include "core/os/threaded_array_processor.h"
-
-#include <stdlib.h>
static _FORCE_INLINE_ void get_uv_and_normal(const Vector3 &p_pos, const Vector3 *p_vtx, const Vector2 *p_uv, const Vector3 *p_normal, Vector2 &r_uv, Vector3 &r_normal) {
if (p_pos.is_equal_approx(p_vtx[0])) {
diff --git a/scene/3d/voxelizer.h b/scene/3d/voxelizer.h
index e500d2d4c3..09c126bc4e 100644
--- a/scene/3d/voxelizer.h
+++ b/scene/3d/voxelizer.h
@@ -31,8 +31,6 @@
#ifndef VOXEL_LIGHT_BAKER_H
#define VOXEL_LIGHT_BAKER_H
-#include "core/math/vector3i.h"
-#include "scene/3d/mesh_instance_3d.h"
#include "scene/resources/multimesh.h"
class Voxelizer {
diff --git a/scene/3d/world_environment.cpp b/scene/3d/world_environment.cpp
index 352bef072f..26fa43b969 100644
--- a/scene/3d/world_environment.cpp
+++ b/scene/3d/world_environment.cpp
@@ -30,6 +30,7 @@
#include "world_environment.h"
+#include "scene/3d/node_3d.h"
#include "scene/main/window.h"
void WorldEnvironment::_notification(int p_what) {
diff --git a/scene/3d/world_environment.h b/scene/3d/world_environment.h
index 9e85982381..310d1e96a5 100644
--- a/scene/3d/world_environment.h
+++ b/scene/3d/world_environment.h
@@ -31,7 +31,7 @@
#ifndef SCENARIO_FX_H
#define SCENARIO_FX_H
-#include "scene/3d/node_3d.h"
+#include "scene/main/node.h"
#include "scene/resources/camera_effects.h"
#include "scene/resources/environment.h"
diff --git a/scene/3d/xr_nodes.cpp b/scene/3d/xr_nodes.cpp
index e620f33478..ebfb58e9fe 100644
--- a/scene/3d/xr_nodes.cpp
+++ b/scene/3d/xr_nodes.cpp
@@ -30,9 +30,8 @@
#include "xr_nodes.h"
-#include "core/input/input.h"
+#include "scene/main/viewport.h"
#include "servers/xr/xr_interface.h"
-#include "servers/xr_server.h"
////////////////////////////////////////////////////////////////////////////////////////////////////
diff --git a/scene/3d/xr_nodes.h b/scene/3d/xr_nodes.h
index 312287a93b..6e54ff83d7 100644
--- a/scene/3d/xr_nodes.h
+++ b/scene/3d/xr_nodes.h
@@ -32,8 +32,6 @@
#define XR_NODES_H
#include "scene/3d/camera_3d.h"
-#include "scene/3d/node_3d.h"
-#include "scene/resources/mesh.h"
#include "servers/xr/xr_positional_tracker.h"
/**
diff --git a/scene/SCsub b/scene/SCsub
index ccd2bab8ff..92288211bb 100644
--- a/scene/SCsub
+++ b/scene/SCsub
@@ -10,7 +10,8 @@ env.add_source_files(env.scene_sources, "*.cpp")
# Chain load SCsubs
SConscript("main/SCsub")
SConscript("gui/SCsub")
-SConscript("3d/SCsub")
+if not env["disable_3d"]:
+ SConscript("3d/SCsub")
SConscript("2d/SCsub")
SConscript("animation/SCsub")
SConscript("audio/SCsub")
diff --git a/scene/animation/animation_player.cpp b/scene/animation/animation_player.cpp
index 5d200ebf86..f6091f224c 100644
--- a/scene/animation/animation_player.cpp
+++ b/scene/animation/animation_player.cpp
@@ -1493,7 +1493,7 @@ NodePath AnimationPlayer::get_root() const {
void AnimationPlayer::get_argument_options(const StringName &p_function, int p_idx, List<String> *r_options) const {
#ifdef TOOLS_ENABLED
- const String quote_style = EDITOR_DEF("text_editor/completion/use_single_quotes", 0) ? "'" : "\"";
+ const String quote_style = EDITOR_GET("text_editor/completion/use_single_quotes") ? "'" : "\"";
#else
const String quote_style = "\"";
#endif
@@ -1502,8 +1502,8 @@ void AnimationPlayer::get_argument_options(const StringName &p_function, int p_i
if (p_idx == 0 && (p_function == "play" || p_function == "play_backwards" || p_function == "remove_animation" || p_function == "has_animation" || p_function == "queue")) {
List<StringName> al;
get_animation_list(&al);
- for (const StringName &E : al) {
- r_options->push_back(quote_style + String(E) + quote_style);
+ for (const StringName &name : al) {
+ r_options->push_back(String(name).quote(quote_style));
}
}
Node::get_argument_options(p_function, p_idx, r_options);
diff --git a/scene/debugger/scene_debugger.cpp b/scene/debugger/scene_debugger.cpp
index 869f2f68f7..df1aece80a 100644
--- a/scene/debugger/scene_debugger.cpp
+++ b/scene/debugger/scene_debugger.cpp
@@ -90,7 +90,7 @@ Error SceneDebugger::parse_message(void *p_user, const String &p_msg, const Arra
ERR_FAIL_COND_V(p_args.size() < 1, ERR_INVALID_DATA);
Transform2D transform = p_args[1];
scene_tree->get_root()->set_canvas_transform_override(transform);
-
+#ifndef _3D_DISABLED
} else if (p_msg == "override_camera_3D:set") {
ERR_FAIL_COND_V(p_args.size() < 1, ERR_INVALID_DATA);
bool enable = p_args[0];
@@ -109,7 +109,7 @@ Error SceneDebugger::parse_message(void *p_user, const String &p_msg, const Arra
scene_tree->get_root()->set_camera_3d_override_orthogonal(size_or_fov, near, far);
}
scene_tree->get_root()->set_camera_3d_override_transform(transform);
-
+#endif // _3D_DISABLED
} else if (p_msg == "set_object_property") {
ERR_FAIL_COND_V(p_args.size() < 3, ERR_INVALID_DATA);
_set_object_property(p_args[0], p_args[1], p_args[2]);
diff --git a/scene/gui/code_edit.cpp b/scene/gui/code_edit.cpp
index 503f9ffd4a..08dd7f28eb 100644
--- a/scene/gui/code_edit.cpp
+++ b/scene/gui/code_edit.cpp
@@ -72,7 +72,7 @@ void CodeEdit::_notification(int p_what) {
can_fold_icon = get_theme_icon(SNAME("can_fold"));
folded_icon = get_theme_icon(SNAME("folded"));
- code_completion_max_width = get_theme_constant(SNAME("completion_max_width")) * font->get_char_size('x').x;
+ code_completion_max_width = get_theme_constant(SNAME("completion_max_width"));
code_completion_max_lines = get_theme_constant(SNAME("completion_lines"));
code_completion_scroll_width = get_theme_constant(SNAME("completion_scroll_width"));
code_completion_scroll_color = get_theme_color(SNAME("completion_scroll_color"));
@@ -2652,6 +2652,8 @@ TypedArray<String> CodeEdit::_get_delimiters(DelimiterType p_type) const {
/* Code Completion */
void CodeEdit::_filter_code_completion_candidates() {
ScriptInstance *si = get_script_instance();
+ int line_height = get_line_height();
+
if (si && si->has_method("_filter_code_completion_candidates")) {
code_completion_options.clear();
code_completion_base = "";
@@ -2691,11 +2693,16 @@ void CodeEdit::_filter_code_completion_candidates() {
option.icon = completion_options[i].get("icon");
option.default_value = completion_options[i].get("default_value");
- max_width = MAX(max_width, font->get_string_size(option.display).width);
+ int offset = 0;
+ if (option.default_value.get_type() == Variant::COLOR) {
+ offset = line_height;
+ }
+
+ max_width = MAX(max_width, font->get_string_size(option.display, font_size).width + offset);
code_completion_options.push_back(option);
}
- code_completion_longest_line = MIN(max_width, code_completion_max_width);
+ code_completion_longest_line = MIN(max_width, code_completion_max_width * font_size);
code_completion_current_selected = 0;
code_completion_active = true;
update();
@@ -2783,6 +2790,11 @@ void CodeEdit::_filter_code_completion_candidates() {
option.display = option.display.unquote().quote("'");
}
+ int offset = 0;
+ if (option.default_value.get_type() == Variant::COLOR) {
+ offset = line_height;
+ }
+
if (in_string != -1) {
String quote = single_quote ? "'" : "\"";
option.display = option.display.unquote().quote(quote);
@@ -2795,7 +2807,7 @@ void CodeEdit::_filter_code_completion_candidates() {
if (string_to_complete.length() == 0) {
code_completion_options.push_back(option);
- max_width = MAX(max_width, font->get_string_size(option.display).width);
+ max_width = MAX(max_width, font->get_string_size(option.display, font_size).width + offset);
continue;
}
@@ -2844,7 +2856,7 @@ void CodeEdit::_filter_code_completion_candidates() {
} else {
completion_options_subseq.push_back(option);
}
- max_width = MAX(max_width, font->get_string_size(option.display).width);
+ max_width = MAX(max_width, font->get_string_size(option.display, font_size).width + offset);
/* Matched the whole subsequence in s_lower. */
} else if (!*ssq_lower) {
/* Finished matching in the first s.length() characters. */
@@ -2853,7 +2865,7 @@ void CodeEdit::_filter_code_completion_candidates() {
} else {
completion_options_subseq_casei.push_back(option);
}
- max_width = MAX(max_width, font->get_string_size(option.display).width);
+ max_width = MAX(max_width, font->get_string_size(option.display, font_size).width + offset);
}
}
@@ -2873,7 +2885,7 @@ void CodeEdit::_filter_code_completion_candidates() {
return;
}
- code_completion_longest_line = MIN(max_width, code_completion_max_width);
+ code_completion_longest_line = MIN(max_width, code_completion_max_width * font_size);
code_completion_current_selected = 0;
code_completion_active = true;
update();
@@ -2906,7 +2918,10 @@ void CodeEdit::_text_changed() {
while (lc /= 10) {
line_number_digits++;
}
- set_gutter_width(line_number_gutter, (line_number_digits + 1) * font->get_char_size('0', 0, font_size).width);
+
+ if (font.is_valid()) {
+ set_gutter_width(line_number_gutter, (line_number_digits + 1) * font->get_char_size('0', 0, font_size).width);
+ }
lc = get_line_count();
int line_change_size = (lines_edited_to - lines_edited_from);
diff --git a/scene/gui/control.cpp b/scene/gui/control.cpp
index a2e6872da6..f114e06c75 100644
--- a/scene/gui/control.cpp
+++ b/scene/gui/control.cpp
@@ -1686,6 +1686,17 @@ Rect2 Control::get_anchorable_rect() const {
return Rect2(Point2(), get_size());
}
+void Control::begin_bulk_theme_override() {
+ data.bulk_theme_override = true;
+}
+
+void Control::end_bulk_theme_override() {
+ ERR_FAIL_COND(!data.bulk_theme_override);
+
+ data.bulk_theme_override = false;
+ _notify_theme_changed();
+}
+
void Control::add_theme_icon_override(const StringName &p_name, const Ref<Texture2D> &p_icon) {
ERR_FAIL_COND(!p_icon.is_valid());
@@ -1695,7 +1706,7 @@ void Control::add_theme_icon_override(const StringName &p_name, const Ref<Textur
data.icon_override[p_name] = p_icon;
data.icon_override[p_name]->connect("changed", callable_mp(this, &Control::_override_changed), Vector<Variant>(), CONNECT_REFERENCE_COUNTED);
- notification(NOTIFICATION_THEME_CHANGED);
+ _notify_theme_changed();
}
void Control::add_theme_style_override(const StringName &p_name, const Ref<StyleBox> &p_style) {
@@ -1707,7 +1718,7 @@ void Control::add_theme_style_override(const StringName &p_name, const Ref<Style
data.style_override[p_name] = p_style;
data.style_override[p_name]->connect("changed", callable_mp(this, &Control::_override_changed), Vector<Variant>(), CONNECT_REFERENCE_COUNTED);
- notification(NOTIFICATION_THEME_CHANGED);
+ _notify_theme_changed();
}
void Control::add_theme_font_override(const StringName &p_name, const Ref<Font> &p_font) {
@@ -1719,22 +1730,22 @@ void Control::add_theme_font_override(const StringName &p_name, const Ref<Font>
data.font_override[p_name] = p_font;
data.font_override[p_name]->connect("changed", callable_mp(this, &Control::_override_changed), Vector<Variant>(), CONNECT_REFERENCE_COUNTED);
- notification(NOTIFICATION_THEME_CHANGED);
+ _notify_theme_changed();
}
void Control::add_theme_font_size_override(const StringName &p_name, int p_font_size) {
data.font_size_override[p_name] = p_font_size;
- notification(NOTIFICATION_THEME_CHANGED);
+ _notify_theme_changed();
}
void Control::add_theme_color_override(const StringName &p_name, const Color &p_color) {
data.color_override[p_name] = p_color;
- notification(NOTIFICATION_THEME_CHANGED);
+ _notify_theme_changed();
}
void Control::add_theme_constant_override(const StringName &p_name, int p_constant) {
data.constant_override[p_name] = p_constant;
- notification(NOTIFICATION_THEME_CHANGED);
+ _notify_theme_changed();
}
void Control::remove_theme_icon_override(const StringName &p_name) {
@@ -1743,7 +1754,7 @@ void Control::remove_theme_icon_override(const StringName &p_name) {
}
data.icon_override.erase(p_name);
- notification(NOTIFICATION_THEME_CHANGED);
+ _notify_theme_changed();
}
void Control::remove_theme_style_override(const StringName &p_name) {
@@ -1752,7 +1763,7 @@ void Control::remove_theme_style_override(const StringName &p_name) {
}
data.style_override.erase(p_name);
- notification(NOTIFICATION_THEME_CHANGED);
+ _notify_theme_changed();
}
void Control::remove_theme_font_override(const StringName &p_name) {
@@ -1761,22 +1772,22 @@ void Control::remove_theme_font_override(const StringName &p_name) {
}
data.font_override.erase(p_name);
- notification(NOTIFICATION_THEME_CHANGED);
+ _notify_theme_changed();
}
void Control::remove_theme_font_size_override(const StringName &p_name) {
data.font_size_override.erase(p_name);
- notification(NOTIFICATION_THEME_CHANGED);
+ _notify_theme_changed();
}
void Control::remove_theme_color_override(const StringName &p_name) {
data.color_override.erase(p_name);
- notification(NOTIFICATION_THEME_CHANGED);
+ _notify_theme_changed();
}
void Control::remove_theme_constant_override(const StringName &p_name) {
data.constant_override.erase(p_name);
- notification(NOTIFICATION_THEME_CHANGED);
+ _notify_theme_changed();
}
void Control::set_focus_mode(FocusMode p_focus_mode) {
@@ -2049,6 +2060,12 @@ void Control::_theme_changed() {
_propagate_theme_changed(this, this, nullptr, false);
}
+void Control::_notify_theme_changed() {
+ if (!data.bulk_theme_override) {
+ notification(NOTIFICATION_THEME_CHANGED);
+ }
+}
+
void Control::set_theme(const Ref<Theme> &p_theme) {
if (data.theme == p_theme) {
return;
@@ -2585,7 +2602,7 @@ bool Control::is_visibility_clip_disabled() const {
void Control::get_argument_options(const StringName &p_function, int p_idx, List<String> *r_options) const {
#ifdef TOOLS_ENABLED
- const String quote_style = EDITOR_DEF("text_editor/completion/use_single_quotes", 0) ? "'" : "\"";
+ const String quote_style = EDITOR_GET("text_editor/completion/use_single_quotes") ? "'" : "\"";
#else
const String quote_style = "\"";
#endif
@@ -2608,8 +2625,8 @@ void Control::get_argument_options(const StringName &p_function, int p_idx, List
}
sn.sort_custom<StringName::AlphCompare>();
- for (const StringName &E : sn) {
- r_options->push_back(quote_style + E + quote_style);
+ for (const StringName &name : sn) {
+ r_options->push_back(String(name).quote(quote_style));
}
}
}
@@ -2719,6 +2736,9 @@ void Control::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_theme_type_variation", "theme_type"), &Control::set_theme_type_variation);
ClassDB::bind_method(D_METHOD("get_theme_type_variation"), &Control::get_theme_type_variation);
+ ClassDB::bind_method(D_METHOD("begin_bulk_theme_override"), &Control::begin_bulk_theme_override);
+ ClassDB::bind_method(D_METHOD("end_bulk_theme_override"), &Control::end_bulk_theme_override);
+
ClassDB::bind_method(D_METHOD("add_theme_icon_override", "name", "texture"), &Control::add_theme_icon_override);
ClassDB::bind_method(D_METHOD("add_theme_stylebox_override", "name", "stylebox"), &Control::add_theme_style_override);
ClassDB::bind_method(D_METHOD("add_theme_font_override", "name", "font"), &Control::add_theme_font_override);
diff --git a/scene/gui/control.h b/scene/gui/control.h
index 8d669c7a6d..a871a8e9fb 100644
--- a/scene/gui/control.h
+++ b/scene/gui/control.h
@@ -220,6 +220,7 @@ private:
NodePath focus_next;
NodePath focus_prev;
+ bool bulk_theme_override = false;
HashMap<StringName, Ref<Texture2D>> icon_override;
HashMap<StringName, Ref<StyleBox>> style_override;
HashMap<StringName, Ref<Font>> font_override;
@@ -241,6 +242,7 @@ private:
void _set_size(const Size2 &p_size);
void _theme_changed();
+ void _notify_theme_changed();
void _update_minimum_size();
@@ -452,6 +454,9 @@ public:
/* SKINNING */
+ void begin_bulk_theme_override();
+ void end_bulk_theme_override();
+
void add_theme_icon_override(const StringName &p_name, const Ref<Texture2D> &p_icon);
void add_theme_style_override(const StringName &p_name, const Ref<StyleBox> &p_style);
void add_theme_font_override(const StringName &p_name, const Ref<Font> &p_font);
diff --git a/scene/gui/popup.h b/scene/gui/popup.h
index 0355405d7c..c7090e7231 100644
--- a/scene/gui/popup.h
+++ b/scene/gui/popup.h
@@ -35,6 +35,8 @@
#include "core/templates/local_vector.h"
+class Panel;
+
class Popup : public Window {
GDCLASS(Popup, Window);
diff --git a/scene/gui/text_edit.cpp b/scene/gui/text_edit.cpp
index 443eb68bc5..745920fcdd 100644
--- a/scene/gui/text_edit.cpp
+++ b/scene/gui/text_edit.cpp
@@ -62,11 +62,19 @@ static bool _is_char(char32_t c) {
///////////////////////////////////////////////////////////////////////////////
void TextEdit::Text::set_font(const Ref<Font> &p_font) {
+ if (font == p_font) {
+ return;
+ }
font = p_font;
+ is_dirty = true;
}
void TextEdit::Text::set_font_size(int p_font_size) {
+ if (font_size == p_font_size) {
+ return;
+ }
font_size = p_font_size;
+ is_dirty = true;
}
void TextEdit::Text::set_tab_size(int p_tab_size) {
@@ -78,16 +86,28 @@ int TextEdit::Text::get_tab_size() const {
}
void TextEdit::Text::set_font_features(const Dictionary &p_features) {
+ if (opentype_features.hash() == p_features.hash()) {
+ return;
+ }
opentype_features = p_features;
+ is_dirty = true;
}
void TextEdit::Text::set_direction_and_language(TextServer::Direction p_direction, const String &p_language) {
+ if (direction == p_direction && language == p_language) {
+ return;
+ }
direction = p_direction;
language = p_language;
+ is_dirty = true;
}
void TextEdit::Text::set_draw_control_chars(bool p_draw_control_chars) {
+ if (draw_control_chars == p_draw_control_chars) {
+ return;
+ }
draw_control_chars = p_draw_control_chars;
+ is_dirty = true;
}
int TextEdit::Text::get_line_width(int p_line, int p_wrap_index) const {
@@ -176,9 +196,14 @@ void TextEdit::Text::invalidate_all_lines() {
}
void TextEdit::Text::invalidate_all() {
+ if (!is_dirty) {
+ return;
+ }
+
for (int i = 0; i < text.size(); i++) {
invalidate_cache(i);
}
+ is_dirty = false;
}
void TextEdit::Text::clear() {
@@ -1110,20 +1135,37 @@ void TextEdit::_notification(int p_what) {
t_caret.size.y = h;
}
t_caret.position += Vector2(char_margin + ofs_x, ofs_y);
+ draw_rect(t_caret, caret_color, overtype_mode);
- draw_rect(t_caret, caret_color, false);
+ if (l_caret != Rect2() && l_dir != t_dir) {
+ l_caret.position += Vector2(char_margin + ofs_x, ofs_y);
+ l_caret.size.x = caret_width;
+ draw_rect(l_caret, caret_color * Color(1, 1, 1, 0.5));
+ }
} else { // End of the line.
- if (overtype_mode) {
- l_caret.position.y = TS->shaped_text_get_descent(rid);
+ if (gl_size > 0) {
+ // Adjust for actual line dimensions.
+ if (overtype_mode) {
+ l_caret.position.y = TS->shaped_text_get_descent(rid);
+ l_caret.size.y = caret_width;
+ } else {
+ l_caret.position.y = -TS->shaped_text_get_ascent(rid);
+ l_caret.size.y = h;
+ }
+ } else if (overtype_mode) {
+ l_caret.position.y += l_caret.size.y;
l_caret.size.y = caret_width;
+ }
+ if (l_caret.position.x >= TS->shaped_text_get_size(rid).x) {
+ l_caret.size.x = font->get_char_size('m', 0, font_size).x;
} else {
- l_caret.position.y = -TS->shaped_text_get_ascent(rid);
- l_caret.size.y = h;
+ l_caret.size.x = 3 * caret_width;
}
l_caret.position += Vector2(char_margin + ofs_x, ofs_y);
- l_caret.size.x = font->get_char_size('M', 0, font_size).x;
-
- draw_rect(l_caret, caret_color, false);
+ if (l_dir == TextServer::DIRECTION_RTL) {
+ l_caret.position.x -= l_caret.size.x;
+ }
+ draw_rect(l_caret, caret_color, overtype_mode);
}
} else {
// Normal caret.
@@ -4748,7 +4790,6 @@ bool TextEdit::_set(const StringName &p_name, const Variant &p_value) {
opentype_features[tag] = value;
text.set_font_features(opentype_features);
text.invalidate_all();
- ;
update();
}
}
diff --git a/scene/gui/text_edit.h b/scene/gui/text_edit.h
index 5d05e07b5d..da322a7bcd 100644
--- a/scene/gui/text_edit.h
+++ b/scene/gui/text_edit.h
@@ -151,6 +151,8 @@ private:
};
private:
+ bool is_dirty = false;
+
mutable Vector<Line> text;
Ref<Font> font;
int font_size = -1;
diff --git a/scene/main/canvas_item.cpp b/scene/main/canvas_item.cpp
index 0a76351885..f2415eaf71 100644
--- a/scene/main/canvas_item.cpp
+++ b/scene/main/canvas_item.cpp
@@ -30,289 +30,17 @@
#include "canvas_item.h"
-#include "core/input/input.h"
#include "core/object/message_queue.h"
#include "scene/2d/canvas_group.h"
#include "scene/main/canvas_layer.h"
-#include "scene/main/viewport.h"
#include "scene/main/window.h"
+#include "scene/resources/canvas_item_material.h"
#include "scene/resources/font.h"
+#include "scene/resources/multimesh.h"
#include "scene/resources/style_box.h"
-#include "scene/resources/texture.h"
+#include "scene/resources/world_2d.h"
#include "scene/scene_string_names.h"
-#include "servers/rendering_server.h"
-Mutex CanvasItemMaterial::material_mutex;
-SelfList<CanvasItemMaterial>::List *CanvasItemMaterial::dirty_materials = nullptr;
-Map<CanvasItemMaterial::MaterialKey, CanvasItemMaterial::ShaderData> CanvasItemMaterial::shader_map;
-CanvasItemMaterial::ShaderNames *CanvasItemMaterial::shader_names = nullptr;
-
-void CanvasItemMaterial::init_shaders() {
- dirty_materials = memnew(SelfList<CanvasItemMaterial>::List);
-
- shader_names = memnew(ShaderNames);
-
- shader_names->particles_anim_h_frames = "particles_anim_h_frames";
- shader_names->particles_anim_v_frames = "particles_anim_v_frames";
- shader_names->particles_anim_loop = "particles_anim_loop";
-}
-
-void CanvasItemMaterial::finish_shaders() {
- memdelete(dirty_materials);
- memdelete(shader_names);
- dirty_materials = nullptr;
-}
-
-void CanvasItemMaterial::_update_shader() {
- dirty_materials->remove(&element);
-
- MaterialKey mk = _compute_key();
- if (mk.key == current_key.key) {
- return; //no update required in the end
- }
-
- if (shader_map.has(current_key)) {
- shader_map[current_key].users--;
- if (shader_map[current_key].users == 0) {
- //deallocate shader, as it's no longer in use
- RS::get_singleton()->free(shader_map[current_key].shader);
- shader_map.erase(current_key);
- }
- }
-
- current_key = mk;
-
- if (shader_map.has(mk)) {
- RS::get_singleton()->material_set_shader(_get_material(), shader_map[mk].shader);
- shader_map[mk].users++;
- return;
- }
-
- //must create a shader!
-
- String code = "shader_type canvas_item;\nrender_mode ";
- switch (blend_mode) {
- case BLEND_MODE_MIX:
- code += "blend_mix";
- break;
- case BLEND_MODE_ADD:
- code += "blend_add";
- break;
- case BLEND_MODE_SUB:
- code += "blend_sub";
- break;
- case BLEND_MODE_MUL:
- code += "blend_mul";
- break;
- case BLEND_MODE_PREMULT_ALPHA:
- code += "blend_premul_alpha";
- break;
- case BLEND_MODE_DISABLED:
- code += "blend_disabled";
- break;
- }
-
- switch (light_mode) {
- case LIGHT_MODE_NORMAL:
- break;
- case LIGHT_MODE_UNSHADED:
- code += ",unshaded";
- break;
- case LIGHT_MODE_LIGHT_ONLY:
- code += ",light_only";
- break;
- }
-
- code += ";\n";
-
- if (particles_animation) {
- code += "uniform int particles_anim_h_frames;\n";
- code += "uniform int particles_anim_v_frames;\n";
- code += "uniform bool particles_anim_loop;\n\n";
-
- code += "void vertex() {\n";
- code += " float h_frames = float(particles_anim_h_frames);\n";
- code += " float v_frames = float(particles_anim_v_frames);\n";
- code += " VERTEX.xy /= vec2(h_frames, v_frames);\n";
- code += " float particle_total_frames = float(particles_anim_h_frames * particles_anim_v_frames);\n";
- code += " float particle_frame = floor(INSTANCE_CUSTOM.z * float(particle_total_frames));\n";
- code += " if (!particles_anim_loop) {\n";
- code += " particle_frame = clamp(particle_frame, 0.0, particle_total_frames - 1.0);\n";
- code += " } else {\n";
- code += " particle_frame = mod(particle_frame, particle_total_frames);\n";
- code += " }";
- code += " UV /= vec2(h_frames, v_frames);\n";
- code += " UV += vec2(mod(particle_frame, h_frames) / h_frames, floor(particle_frame / h_frames) / v_frames);\n";
- code += "}\n";
- }
-
- ShaderData shader_data;
- shader_data.shader = RS::get_singleton()->shader_create();
- shader_data.users = 1;
-
- RS::get_singleton()->shader_set_code(shader_data.shader, code);
-
- shader_map[mk] = shader_data;
-
- RS::get_singleton()->material_set_shader(_get_material(), shader_data.shader);
-}
-
-void CanvasItemMaterial::flush_changes() {
- MutexLock lock(material_mutex);
-
- while (dirty_materials->first()) {
- dirty_materials->first()->self()->_update_shader();
- }
-}
-
-void CanvasItemMaterial::_queue_shader_change() {
- MutexLock lock(material_mutex);
-
- if (!element.in_list()) {
- dirty_materials->add(&element);
- }
-}
-
-bool CanvasItemMaterial::_is_shader_dirty() const {
- MutexLock lock(material_mutex);
-
- return element.in_list();
-}
-
-void CanvasItemMaterial::set_blend_mode(BlendMode p_blend_mode) {
- blend_mode = p_blend_mode;
- _queue_shader_change();
-}
-
-CanvasItemMaterial::BlendMode CanvasItemMaterial::get_blend_mode() const {
- return blend_mode;
-}
-
-void CanvasItemMaterial::set_light_mode(LightMode p_light_mode) {
- light_mode = p_light_mode;
- _queue_shader_change();
-}
-
-CanvasItemMaterial::LightMode CanvasItemMaterial::get_light_mode() const {
- return light_mode;
-}
-
-void CanvasItemMaterial::set_particles_animation(bool p_particles_anim) {
- particles_animation = p_particles_anim;
- _queue_shader_change();
- notify_property_list_changed();
-}
-
-bool CanvasItemMaterial::get_particles_animation() const {
- return particles_animation;
-}
-
-void CanvasItemMaterial::set_particles_anim_h_frames(int p_frames) {
- particles_anim_h_frames = p_frames;
- RS::get_singleton()->material_set_param(_get_material(), shader_names->particles_anim_h_frames, p_frames);
-}
-
-int CanvasItemMaterial::get_particles_anim_h_frames() const {
- return particles_anim_h_frames;
-}
-
-void CanvasItemMaterial::set_particles_anim_v_frames(int p_frames) {
- particles_anim_v_frames = p_frames;
- RS::get_singleton()->material_set_param(_get_material(), shader_names->particles_anim_v_frames, p_frames);
-}
-
-int CanvasItemMaterial::get_particles_anim_v_frames() const {
- return particles_anim_v_frames;
-}
-
-void CanvasItemMaterial::set_particles_anim_loop(bool p_loop) {
- particles_anim_loop = p_loop;
- RS::get_singleton()->material_set_param(_get_material(), shader_names->particles_anim_loop, particles_anim_loop);
-}
-
-bool CanvasItemMaterial::get_particles_anim_loop() const {
- return particles_anim_loop;
-}
-
-void CanvasItemMaterial::_validate_property(PropertyInfo &property) const {
- if (property.name.begins_with("particles_anim_") && !particles_animation) {
- property.usage = PROPERTY_USAGE_NONE;
- }
-}
-
-RID CanvasItemMaterial::get_shader_rid() const {
- ERR_FAIL_COND_V(!shader_map.has(current_key), RID());
- return shader_map[current_key].shader;
-}
-
-Shader::Mode CanvasItemMaterial::get_shader_mode() const {
- return Shader::MODE_CANVAS_ITEM;
-}
-
-void CanvasItemMaterial::_bind_methods() {
- ClassDB::bind_method(D_METHOD("set_blend_mode", "blend_mode"), &CanvasItemMaterial::set_blend_mode);
- ClassDB::bind_method(D_METHOD("get_blend_mode"), &CanvasItemMaterial::get_blend_mode);
-
- ClassDB::bind_method(D_METHOD("set_light_mode", "light_mode"), &CanvasItemMaterial::set_light_mode);
- ClassDB::bind_method(D_METHOD("get_light_mode"), &CanvasItemMaterial::get_light_mode);
-
- ClassDB::bind_method(D_METHOD("set_particles_animation", "particles_anim"), &CanvasItemMaterial::set_particles_animation);
- ClassDB::bind_method(D_METHOD("get_particles_animation"), &CanvasItemMaterial::get_particles_animation);
-
- ClassDB::bind_method(D_METHOD("set_particles_anim_h_frames", "frames"), &CanvasItemMaterial::set_particles_anim_h_frames);
- ClassDB::bind_method(D_METHOD("get_particles_anim_h_frames"), &CanvasItemMaterial::get_particles_anim_h_frames);
-
- ClassDB::bind_method(D_METHOD("set_particles_anim_v_frames", "frames"), &CanvasItemMaterial::set_particles_anim_v_frames);
- ClassDB::bind_method(D_METHOD("get_particles_anim_v_frames"), &CanvasItemMaterial::get_particles_anim_v_frames);
-
- ClassDB::bind_method(D_METHOD("set_particles_anim_loop", "loop"), &CanvasItemMaterial::set_particles_anim_loop);
- ClassDB::bind_method(D_METHOD("get_particles_anim_loop"), &CanvasItemMaterial::get_particles_anim_loop);
-
- ADD_PROPERTY(PropertyInfo(Variant::INT, "blend_mode", PROPERTY_HINT_ENUM, "Mix,Add,Subtract,Multiply,Premultiplied Alpha"), "set_blend_mode", "get_blend_mode");
- ADD_PROPERTY(PropertyInfo(Variant::INT, "light_mode", PROPERTY_HINT_ENUM, "Normal,Unshaded,Light Only"), "set_light_mode", "get_light_mode");
- ADD_PROPERTY(PropertyInfo(Variant::BOOL, "particles_animation"), "set_particles_animation", "get_particles_animation");
-
- ADD_PROPERTY(PropertyInfo(Variant::INT, "particles_anim_h_frames", PROPERTY_HINT_RANGE, "1,128,1"), "set_particles_anim_h_frames", "get_particles_anim_h_frames");
- ADD_PROPERTY(PropertyInfo(Variant::INT, "particles_anim_v_frames", PROPERTY_HINT_RANGE, "1,128,1"), "set_particles_anim_v_frames", "get_particles_anim_v_frames");
- ADD_PROPERTY(PropertyInfo(Variant::BOOL, "particles_anim_loop"), "set_particles_anim_loop", "get_particles_anim_loop");
-
- BIND_ENUM_CONSTANT(BLEND_MODE_MIX);
- BIND_ENUM_CONSTANT(BLEND_MODE_ADD);
- BIND_ENUM_CONSTANT(BLEND_MODE_SUB);
- BIND_ENUM_CONSTANT(BLEND_MODE_MUL);
- BIND_ENUM_CONSTANT(BLEND_MODE_PREMULT_ALPHA);
-
- BIND_ENUM_CONSTANT(LIGHT_MODE_NORMAL);
- BIND_ENUM_CONSTANT(LIGHT_MODE_UNSHADED);
- BIND_ENUM_CONSTANT(LIGHT_MODE_LIGHT_ONLY);
-}
-
-CanvasItemMaterial::CanvasItemMaterial() :
- element(this) {
- set_particles_anim_h_frames(1);
- set_particles_anim_v_frames(1);
- set_particles_anim_loop(false);
-
- current_key.invalid_key = 1;
- _queue_shader_change();
-}
-
-CanvasItemMaterial::~CanvasItemMaterial() {
- MutexLock lock(material_mutex);
-
- if (shader_map.has(current_key)) {
- shader_map[current_key].users--;
- if (shader_map[current_key].users == 0) {
- //deallocate shader, as it's no longer in use
- RS::get_singleton()->free(shader_map[current_key].shader);
- shader_map.erase(current_key);
- }
-
- RS::get_singleton()->material_set_shader(_get_material(), RID());
- }
-}
-
-///////////////////////////////////////////////////////////////////
#ifdef TOOLS_ENABLED
bool CanvasItem::_edit_is_selected_on_click(const Point2 &p_point, double p_tolerance) const {
if (_edit_use_rect()) {
diff --git a/scene/main/canvas_item.h b/scene/main/canvas_item.h
index f264764870..dc7ad2bf5d 100644
--- a/scene/main/canvas_item.h
+++ b/scene/main/canvas_item.h
@@ -33,132 +33,15 @@
#include "scene/main/node.h"
#include "scene/main/scene_tree.h"
-#include "scene/resources/material.h"
-#include "scene/resources/multimesh.h"
-#include "scene/resources/shader.h"
-#include "scene/resources/texture.h"
+#include "scene/resources/canvas_item_material.h"
#include "servers/text_server.h"
class CanvasLayer;
-class Viewport;
class Font;
-
+class MultiMesh;
class StyleBox;
-
-class CanvasItemMaterial : public Material {
- GDCLASS(CanvasItemMaterial, Material);
-
-public:
- enum BlendMode {
- BLEND_MODE_MIX,
- BLEND_MODE_ADD,
- BLEND_MODE_SUB,
- BLEND_MODE_MUL,
- BLEND_MODE_PREMULT_ALPHA,
- BLEND_MODE_DISABLED
- };
-
- enum LightMode {
- LIGHT_MODE_NORMAL,
- LIGHT_MODE_UNSHADED,
- LIGHT_MODE_LIGHT_ONLY
- };
-
-private:
- union MaterialKey {
- struct {
- uint32_t blend_mode : 4;
- uint32_t light_mode : 4;
- uint32_t particles_animation : 1;
- uint32_t invalid_key : 1;
- };
-
- uint32_t key = 0;
-
- bool operator<(const MaterialKey &p_key) const {
- return key < p_key.key;
- }
- };
-
- struct ShaderNames {
- StringName particles_anim_h_frames;
- StringName particles_anim_v_frames;
- StringName particles_anim_loop;
- };
-
- static ShaderNames *shader_names;
-
- struct ShaderData {
- RID shader;
- int users = 0;
- };
-
- static Map<MaterialKey, ShaderData> shader_map;
-
- MaterialKey current_key;
-
- _FORCE_INLINE_ MaterialKey _compute_key() const {
- MaterialKey mk;
- mk.key = 0;
- mk.blend_mode = blend_mode;
- mk.light_mode = light_mode;
- mk.particles_animation = particles_animation;
- return mk;
- }
-
- static Mutex material_mutex;
- static SelfList<CanvasItemMaterial>::List *dirty_materials;
- SelfList<CanvasItemMaterial> element;
-
- void _update_shader();
- _FORCE_INLINE_ void _queue_shader_change();
- _FORCE_INLINE_ bool _is_shader_dirty() const;
-
- BlendMode blend_mode = BLEND_MODE_MIX;
- LightMode light_mode = LIGHT_MODE_NORMAL;
- bool particles_animation = false;
-
- // Initialized in the constructor.
- int particles_anim_h_frames;
- int particles_anim_v_frames;
- bool particles_anim_loop;
-
-protected:
- static void _bind_methods();
- void _validate_property(PropertyInfo &property) const override;
-
-public:
- void set_blend_mode(BlendMode p_blend_mode);
- BlendMode get_blend_mode() const;
-
- void set_light_mode(LightMode p_light_mode);
- LightMode get_light_mode() const;
-
- void set_particles_animation(bool p_particles_anim);
- bool get_particles_animation() const;
-
- void set_particles_anim_h_frames(int p_frames);
- int get_particles_anim_h_frames() const;
- void set_particles_anim_v_frames(int p_frames);
- int get_particles_anim_v_frames() const;
-
- void set_particles_anim_loop(bool p_loop);
- bool get_particles_anim_loop() const;
-
- static void init_shaders();
- static void finish_shaders();
- static void flush_changes();
-
- virtual RID get_shader_rid() const override;
-
- virtual Shader::Mode get_shader_mode() const override;
-
- CanvasItemMaterial();
- virtual ~CanvasItemMaterial();
-};
-
-VARIANT_ENUM_CAST(CanvasItemMaterial::BlendMode)
-VARIANT_ENUM_CAST(CanvasItemMaterial::LightMode)
+class Window;
+class World2D;
class CanvasItem : public Node {
GDCLASS(CanvasItem, Node);
diff --git a/scene/main/canvas_layer.h b/scene/main/canvas_layer.h
index 5de1ebf18d..9d8e0c203d 100644
--- a/scene/main/canvas_layer.h
+++ b/scene/main/canvas_layer.h
@@ -32,7 +32,6 @@
#define CANVAS_LAYER_H
#include "scene/main/node.h"
-#include "scene/resources/world_2d.h"
class Viewport;
class CanvasLayer : public Node {
diff --git a/scene/main/http_request.cpp b/scene/main/http_request.cpp
index 2c6cefa771..f24d880045 100644
--- a/scene/main/http_request.cpp
+++ b/scene/main/http_request.cpp
@@ -30,7 +30,7 @@
#include "http_request.h"
#include "core/io/compression.h"
-#include "core/string/ustring.h"
+#include "scene/main/timer.h"
void HTTPRequest::_redirect_request(const String &p_new_url) {
}
diff --git a/scene/main/http_request.h b/scene/main/http_request.h
index 22e822253f..673cf3a740 100644
--- a/scene/main/http_request.h
+++ b/scene/main/http_request.h
@@ -31,12 +31,12 @@
#ifndef HTTPREQUEST_H
#define HTTPREQUEST_H
-#include "core/io/file_access.h"
#include "core/io/http_client.h"
#include "core/os/thread.h"
#include "core/templates/safe_refcount.h"
-#include "node.h"
-#include "scene/main/timer.h"
+#include "scene/main/node.h"
+
+class Timer;
class HTTPRequest : public Node {
GDCLASS(HTTPRequest, Node);
diff --git a/scene/main/node.cpp b/scene/main/node.cpp
index cbd5fa7425..155af30a6d 100644
--- a/scene/main/node.cpp
+++ b/scene/main/node.cpp
@@ -2465,7 +2465,7 @@ NodePath Node::get_import_path() const {
static void _add_nodes_to_options(const Node *p_base, const Node *p_node, List<String> *r_options) {
#ifdef TOOLS_ENABLED
- const String quote_style = EDITOR_DEF("text_editor/completion/use_single_quotes", 0) ? "'" : "\"";
+ const String quote_style = EDITOR_GET("text_editor/completion/use_single_quotes") ? "'" : "\"";
#else
const String quote_style = "\"";
#endif
@@ -2474,7 +2474,7 @@ static void _add_nodes_to_options(const Node *p_base, const Node *p_node, List<S
return;
}
String n = p_base->get_path_to(p_node);
- r_options->push_back(quote_style + n + quote_style);
+ r_options->push_back(n.quote(quote_style));
for (int i = 0; i < p_node->get_child_count(); i++) {
_add_nodes_to_options(p_base, p_node->get_child(i), r_options);
}
diff --git a/scene/main/scene_tree.cpp b/scene/main/scene_tree.cpp
index 420516cbcd..5b707498a7 100644
--- a/scene/main/scene_tree.cpp
+++ b/scene/main/scene_tree.cpp
@@ -499,7 +499,7 @@ bool SceneTree::process(double p_time) {
_call_idle_callbacks();
#ifdef TOOLS_ENABLED
-
+#ifndef _3D_DISABLED
if (Engine::get_singleton()->is_editor_hint()) {
//simple hack to reload fallback environment if it changed from editor
String env_path = ProjectSettings::get_singleton()->get(SNAME("rendering/environment/defaults/default_environment"));
@@ -522,8 +522,8 @@ bool SceneTree::process(double p_time) {
get_root()->get_world_3d()->set_fallback_environment(fallback);
}
}
-
-#endif
+#endif // _3D_DISABLED
+#endif // TOOLS_ENABLED
return _quit;
}
@@ -1333,20 +1333,21 @@ SceneTree::SceneTree() {
root = memnew(Window);
root->set_name("root");
+#ifndef _3D_DISABLED
if (!root->get_world_3d().is_valid()) {
root->set_world_3d(Ref<World3D>(memnew(World3D)));
}
+ root->set_as_audio_listener_3d(true);
+#endif // _3D_DISABLED
// Initialize network state.
set_multiplayer(Ref<MultiplayerAPI>(memnew(MultiplayerAPI)));
- //root->set_world_2d( Ref<World2D>( memnew( World2D )));
- root->set_as_audio_listener_3d(true);
root->set_as_audio_listener_2d(true);
current_scene = nullptr;
const int msaa_mode = GLOBAL_DEF("rendering/anti_aliasing/quality/msaa", 0);
- ProjectSettings::get_singleton()->set_custom_property_info("rendering/anti_aliasing/quality/msaa", PropertyInfo(Variant::INT, "rendering/anti_aliasing/quality/msaa", PROPERTY_HINT_ENUM, "Disabled (Fastest),2x (Fast),4x (Average),8x (Slow),16x (Slower)"));
+ ProjectSettings::get_singleton()->set_custom_property_info("rendering/anti_aliasing/quality/msaa", PropertyInfo(Variant::INT, "rendering/anti_aliasing/quality/msaa", PROPERTY_HINT_ENUM, String::utf8("Disabled (Fastest),2× (Fast),4× (Average),8× (Slow),16× (Slower)")));
root->set_msaa(Viewport::MSAA(msaa_mode));
const int ssaa_mode = GLOBAL_DEF("rendering/anti_aliasing/quality/screen_space_aa", 0);
@@ -1397,6 +1398,7 @@ SceneTree::SceneTree() {
ProjectSettings::get_singleton()->set_custom_property_info("rendering/2d/sdf/oversize", PropertyInfo(Variant::INT, "rendering/2d/sdf/oversize", PROPERTY_HINT_ENUM, "100%,120%,150%,200%"));
ProjectSettings::get_singleton()->set_custom_property_info("rendering/2d/sdf/scale", PropertyInfo(Variant::INT, "rendering/2d/sdf/scale", PROPERTY_HINT_ENUM, "100%,50%,25%"));
+#ifndef _3D_DISABLED
{ // Load default fallback environment.
// Get possible extensions.
List<String> exts;
@@ -1428,6 +1430,7 @@ SceneTree::SceneTree() {
}
}
}
+#endif // _3D_DISABLED
root->set_physics_object_picking(GLOBAL_DEF("physics/common/enable_object_picking", true));
diff --git a/scene/main/shader_globals_override.cpp b/scene/main/shader_globals_override.cpp
index d22a6b2875..9477e300d1 100644
--- a/scene/main/shader_globals_override.cpp
+++ b/scene/main/shader_globals_override.cpp
@@ -30,8 +30,7 @@
#include "shader_globals_override.h"
-#include "core/core_string_names.h"
-#include "scene/main/window.h"
+#include "scene/3d/node_3d.h"
#include "scene/scene_string_names.h"
StringName *ShaderGlobalsOverride::_remap(const StringName &p_name) const {
diff --git a/scene/main/shader_globals_override.h b/scene/main/shader_globals_override.h
index 2d9c3c76bd..ab4b9de727 100644
--- a/scene/main/shader_globals_override.h
+++ b/scene/main/shader_globals_override.h
@@ -31,7 +31,7 @@
#ifndef SHADER_GLOBALS_OVERRIDE_H
#define SHADER_GLOBALS_OVERRIDE_H
-#include "scene/3d/node_3d.h"
+#include "scene/main/node.h"
class ShaderGlobalsOverride : public Node {
GDCLASS(ShaderGlobalsOverride, Node);
diff --git a/scene/main/timer.cpp b/scene/main/timer.cpp
index b5a2a30b3b..9e462eb1c8 100644
--- a/scene/main/timer.cpp
+++ b/scene/main/timer.cpp
@@ -30,8 +30,6 @@
#include "timer.h"
-#include "core/config/engine.h"
-
void Timer::_notification(int p_what) {
switch (p_what) {
case NOTIFICATION_READY: {
diff --git a/scene/main/viewport.cpp b/scene/main/viewport.cpp
index 908950a714..78fa0985a9 100644
--- a/scene/main/viewport.cpp
+++ b/scene/main/viewport.cpp
@@ -30,33 +30,27 @@
#include "viewport.h"
-#include "core/config/project_settings.h"
#include "core/core_string_names.h"
#include "core/debugger/engine_debugger.h"
-#include "core/input/input.h"
-#include "core/os/os.h"
#include "core/string/translation.h"
-
+#include "core/templates/pair.h"
#include "scene/2d/camera_2d.h"
#include "scene/2d/collision_object_2d.h"
+#ifndef _3D_DISABLED
#include "scene/3d/camera_3d.h"
#include "scene/3d/collision_object_3d.h"
#include "scene/3d/listener_3d.h"
-#include "scene/3d/node_3d.h"
#include "scene/3d/world_environment.h"
+#endif // _3D_DISABLED
#include "scene/gui/control.h"
#include "scene/gui/label.h"
-#include "scene/gui/menu_button.h"
-#include "scene/gui/panel.h"
-#include "scene/gui/panel_container.h"
-#include "scene/gui/popup_menu.h"
+#include "scene/gui/popup.h"
#include "scene/main/canvas_layer.h"
-#include "scene/main/timer.h"
#include "scene/main/window.h"
#include "scene/resources/mesh.h"
+#include "scene/resources/text_line.h"
+#include "scene/resources/world_2d.h"
#include "scene/scene_string_names.h"
-#include "servers/display_server.h"
-#include "servers/physics_server_2d.h"
void ViewportTexture::setup_local_to_scene() {
if (vp) {
@@ -385,14 +379,17 @@ void Viewport::_notification(int p_what) {
current_canvas = find_world_2d()->get_canvas();
RenderingServer::get_singleton()->viewport_attach_canvas(viewport, current_canvas);
_update_listener_2d();
+#ifndef _3D_DISABLED
RenderingServer::get_singleton()->viewport_set_scenario(viewport, find_world_3d()->get_scenario());
_update_listener_3d();
+#endif // _3D_DISABLED
add_to_group("_viewports");
if (get_tree()->is_debugging_collisions_hint()) {
PhysicsServer2D::get_singleton()->space_set_debug_contacts(find_world_2d()->get_space(), get_tree()->get_collision_debug_contact_count());
contact_2d_debug = RenderingServer::get_singleton()->canvas_item_create();
RenderingServer::get_singleton()->canvas_item_set_parent(contact_2d_debug, find_world_2d()->get_canvas());
+#ifndef _3D_DISABLED
PhysicsServer3D::get_singleton()->space_set_debug_contacts(find_world_3d()->get_space(), get_tree()->get_collision_debug_contact_count());
contact_3d_debug_multimesh = RenderingServer::get_singleton()->multimesh_create();
RenderingServer::get_singleton()->multimesh_allocate_data(contact_3d_debug_multimesh, get_tree()->get_collision_debug_contact_count(), RS::MULTIMESH_TRANSFORM_3D, true);
@@ -402,10 +399,12 @@ void Viewport::_notification(int p_what) {
RenderingServer::get_singleton()->instance_set_base(contact_3d_debug_instance, contact_3d_debug_multimesh);
RenderingServer::get_singleton()->instance_set_scenario(contact_3d_debug_instance, find_world_3d()->get_scenario());
//RenderingServer::get_singleton()->instance_geometry_set_flag(contact_3d_debug_instance, RS::INSTANCE_FLAG_VISIBLE_IN_ALL_ROOMS, true);
+#endif // _3D_DISABLED
}
} break;
case NOTIFICATION_READY: {
+#ifndef _3D_DISABLED
if (listener_3d_set.size() && !listener_3d) {
Listener3D *first = nullptr;
for (Set<Listener3D *>::Element *E = listener_3d_set.front(); E; E = E->next()) {
@@ -432,7 +431,7 @@ void Viewport::_notification(int p_what) {
first->make_current();
}
}
-
+#endif // _3D_DISABLED
} break;
case NOTIFICATION_EXIT_TREE: {
_gui_cancel_tooltip();
@@ -470,6 +469,7 @@ void Viewport::_notification(int p_what) {
RenderingServer::get_singleton()->canvas_item_add_rect(contact_2d_debug, Rect2(points[i] - Vector2(2, 2), Vector2(5, 5)), ccol);
}
}
+#ifndef _3D_DISABLED
if (get_tree()->is_debugging_collisions_hint() && contact_3d_debug_multimesh.is_valid()) {
Vector<Vector3> points = PhysicsServer3D::get_singleton()->space_get_contacts(find_world_3d()->get_space());
int point_count = PhysicsServer3D::get_singleton()->space_get_contact_count(find_world_3d()->get_space());
@@ -482,6 +482,7 @@ void Viewport::_notification(int p_what) {
RS::get_singleton()->multimesh_instance_set_transform(contact_3d_debug_multimesh, i, point_transform);
}
}
+#endif // _3D_DISABLED
} break;
case NOTIFICATION_WM_MOUSE_EXIT: {
_drop_physics_mouseover();
@@ -514,10 +515,6 @@ void Viewport::_process_picking() {
_drop_physics_mouseover(true);
- Vector2 last_pos(1e20, 1e20);
- CollisionObject3D *last_object = nullptr;
- ObjectID last_id;
- PhysicsDirectSpaceState3D::RayResult result;
PhysicsDirectSpaceState2D *ss2d = PhysicsServer2D::get_singleton()->space_get_direct_state(find_world_2d()->get_space());
if (physics_has_last_mousepos) {
@@ -677,6 +674,11 @@ void Viewport::_process_picking() {
}
}
+#ifndef _3D_DISABLED
+ Vector2 last_pos(1e20, 1e20);
+ CollisionObject3D *last_object = nullptr;
+ ObjectID last_id;
+ PhysicsDirectSpaceState3D::RayResult result;
bool captured = false;
if (physics_object_capture.is_valid()) {
@@ -749,6 +751,7 @@ void Viewport::_process_picking() {
last_pos = pos;
}
}
+#endif // _3D_DISABLED
}
}
@@ -2212,6 +2215,7 @@ void Viewport::_drop_physics_mouseover(bool p_paused_only) {
_cleanup_mouseover_colliders(true, p_paused_only);
+#ifndef _3D_DISABLED
if (physics_object_over.is_valid()) {
CollisionObject3D *co = Object::cast_to<CollisionObject3D>(ObjectDB::get_instance(physics_object_over));
if (co) {
@@ -2222,6 +2226,7 @@ void Viewport::_drop_physics_mouseover(bool p_paused_only) {
}
}
}
+#endif // _3D_DISABLED
}
void Viewport::_cleanup_mouseover_colliders(bool p_clean_all_frames, bool p_paused_only, uint64_t p_frame_reference) {
@@ -3071,6 +3076,7 @@ Viewport::SDFScale Viewport::get_sdf_scale() const {
return sdf_scale;
}
+#ifndef _3D_DISABLED
Listener3D *Viewport::get_listener_3d() const {
return listener_3d;
}
@@ -3468,6 +3474,7 @@ void Viewport::set_use_xr(bool p_use_xr) {
bool Viewport::is_using_xr() {
return use_xr;
}
+#endif // _3D_DISABLED
void Viewport::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_world_2d", "world_2d"), &Viewport::set_world_2d);
@@ -3573,6 +3580,7 @@ void Viewport::_bind_methods() {
ClassDB::bind_method(D_METHOD("_process_picking"), &Viewport::_process_picking);
+#ifndef _3D_DISABLED
ClassDB::bind_method(D_METHOD("set_world_3d", "world_3d"), &Viewport::set_world_3d);
ClassDB::bind_method(D_METHOD("get_world_3d"), &Viewport::get_world_3d);
ClassDB::bind_method(D_METHOD("find_world_3d"), &Viewport::find_world_3d);
@@ -3595,13 +3603,14 @@ void Viewport::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "audio_listener_enable_3d"), "set_as_audio_listener_3d", "is_audio_listener_3d");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "own_world_3d"), "set_use_own_world_3d", "is_using_own_world_3d");
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "world_3d", PROPERTY_HINT_RESOURCE_TYPE, "World3D"), "set_world_3d", "get_world_3d");
+#endif // _3D_DISABLED
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "world_2d", PROPERTY_HINT_RESOURCE_TYPE, "World2D", PROPERTY_USAGE_NONE), "set_world_2d", "get_world_2d");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "transparent_bg"), "set_transparent_background", "has_transparent_background");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "handle_input_locally"), "set_handle_input_locally", "is_handling_input_locally");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "snap_2d_transforms_to_pixel"), "set_snap_2d_transforms_to_pixel", "is_snap_2d_transforms_to_pixel_enabled");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "snap_2d_vertices_to_pixel"), "set_snap_2d_vertices_to_pixel", "is_snap_2d_vertices_to_pixel_enabled");
ADD_GROUP("Rendering", "");
- ADD_PROPERTY(PropertyInfo(Variant::INT, "msaa", PROPERTY_HINT_ENUM, "Disabled (Fastest),2x (Fast),4x (Average),8x (Slow),16x (Slower)"), "set_msaa", "get_msaa");
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "msaa", PROPERTY_HINT_ENUM, String::utf8("Disabled (Fastest),2× (Fast),4× (Average),8× (Slow),16× (Slower)")), "set_msaa", "get_msaa");
ADD_PROPERTY(PropertyInfo(Variant::INT, "screen_space_aa", PROPERTY_HINT_ENUM, "Disabled (Fastest),FXAA (Fast)"), "set_screen_space_aa", "get_screen_space_aa");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "use_debanding"), "set_use_debanding", "is_using_debanding");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "use_occlusion_culling"), "set_use_occlusion_culling", "is_using_occlusion_culling");
diff --git a/scene/main/viewport.h b/scene/main/viewport.h
index 7a25f5aa00..9c51f404d7 100644
--- a/scene/main/viewport.h
+++ b/scene/main/viewport.h
@@ -31,26 +31,25 @@
#ifndef VIEWPORT_H
#define VIEWPORT_H
-#include "core/math/transform_2d.h"
-#include "core/templates/pair.h"
#include "scene/main/node.h"
#include "scene/resources/texture.h"
-#include "scene/resources/world_2d.h"
-#include "servers/display_server.h"
-#include "servers/rendering_server.h"
+#ifndef _3D_DISABLED
class Camera3D;
-class Camera2D;
+class CollisionObject3D;
class Listener3D;
-class Control;
+class World3D;
+#endif // _3D_DISABLED
+
+class Camera2D;
class CanvasItem;
class CanvasLayer;
-class Panel;
+class Control;
class Label;
-class Timer;
-class Viewport;
-class CollisionObject3D;
class SceneTreeTimer;
+class Viewport;
+class Window;
+class World2D;
class ViewportTexture : public Texture2D {
GDCLASS(ViewportTexture, Texture2D);
@@ -576,6 +575,7 @@ public:
void pass_mouse_focus_to(Viewport *p_viewport, Control *p_control);
+#ifndef _3D_DISABLED
bool use_xr = false;
friend class Listener3D;
Listener3D *listener_3d = nullptr;
@@ -647,6 +647,7 @@ public:
void set_use_xr(bool p_use_xr);
bool is_using_xr();
+#endif // _3D_DISABLED
Viewport();
~Viewport();
diff --git a/scene/main/window.cpp b/scene/main/window.cpp
index 1f1da7cefb..6995c77b8e 100644
--- a/scene/main/window.cpp
+++ b/scene/main/window.cpp
@@ -31,10 +31,8 @@
#include "window.h"
#include "core/debugger/engine_debugger.h"
-#include "core/os/keyboard.h"
#include "core/string/translation.h"
#include "scene/gui/control.h"
-#include "scene/resources/font.h"
#include "scene/scene_string_names.h"
void Window::set_title(const String &p_title) {
diff --git a/scene/main/window.h b/scene/main/window.h
index 7013694a06..4f31d9cd1f 100644
--- a/scene/main/window.h
+++ b/scene/main/window.h
@@ -32,10 +32,12 @@
#define WINDOW_H
#include "scene/main/viewport.h"
-#include "scene/resources/theme.h"
-#include "servers/display_server.h"
class Control;
+class Font;
+class StyleBox;
+class Theme;
+
class Window : public Viewport {
GDCLASS(Window, Viewport)
public:
diff --git a/scene/register_scene_types.cpp b/scene/register_scene_types.cpp
index 04a533bedb..47c7e57e3f 100644
--- a/scene/register_scene_types.cpp
+++ b/scene/register_scene_types.cpp
@@ -148,7 +148,6 @@
#include "scene/resources/gradient.h"
#include "scene/resources/height_map_shape_3d.h"
#include "scene/resources/immediate_mesh.h"
-#include "scene/resources/line_shape_2d.h"
#include "scene/resources/material.h"
#include "scene/resources/mesh.h"
#include "scene/resources/mesh_data_tool.h"
@@ -187,6 +186,7 @@
#include "scene/resources/visual_shader_sdf_nodes.h"
#include "scene/resources/world_2d.h"
#include "scene/resources/world_3d.h"
+#include "scene/resources/world_margin_shape_2d.h"
#include "scene/resources/world_margin_shape_3d.h"
#include "scene/scene_string_names.h"
@@ -557,7 +557,7 @@ void register_scene_types() {
GDREGISTER_CLASS(VisualShaderNodeIntOp);
GDREGISTER_CLASS(VisualShaderNodeVectorOp);
GDREGISTER_CLASS(VisualShaderNodeColorOp);
- GDREGISTER_CLASS(VisualShaderNodeTransformMult);
+ GDREGISTER_CLASS(VisualShaderNodeTransformOp);
GDREGISTER_CLASS(VisualShaderNodeTransformVecMult);
GDREGISTER_CLASS(VisualShaderNodeFloatFunc);
GDREGISTER_CLASS(VisualShaderNodeIntFunc);
@@ -823,7 +823,7 @@ void register_scene_types() {
OS::get_singleton()->yield(); //may take time to init
GDREGISTER_VIRTUAL_CLASS(Shape2D);
- GDREGISTER_CLASS(LineShape2D);
+ GDREGISTER_CLASS(WorldMarginShape2D);
GDREGISTER_CLASS(SegmentShape2D);
GDREGISTER_CLASS(CircleShape2D);
GDREGISTER_CLASS(RectangleShape2D);
@@ -910,6 +910,7 @@ void register_scene_types() {
ClassDB::add_compatibility_class("KinematicBody2D", "CharacterBody2D");
ClassDB::add_compatibility_class("KinematicCollision", "KinematicCollision3D");
ClassDB::add_compatibility_class("Light", "Light3D");
+ ClassDB::add_compatibility_class("LineShape2D", "WorldMarginShape2D");
ClassDB::add_compatibility_class("Listener", "Listener3D");
ClassDB::add_compatibility_class("MeshInstance", "MeshInstance3D");
ClassDB::add_compatibility_class("MultiMeshInstance", "MultiMeshInstance3D");
@@ -983,6 +984,7 @@ void register_scene_types() {
ClassDB::add_compatibility_class("VisualShaderNodeVectorScalarSmoothStep", "VisualShaderNodeSmoothStep");
ClassDB::add_compatibility_class("VisualShaderNodeVectorScalarStep", "VisualShaderNodeStep");
ClassDB::add_compatibility_class("VisualShaderNodeScalarSwitch", "VisualShaderNodeSwitch");
+ ClassDB::add_compatibility_class("VisualShaderNodeScalarTransformMult", "VisualShaderNodeTransformOp");
ClassDB::add_compatibility_class("World", "World3D");
ClassDB::add_compatibility_class("StreamTexture", "StreamTexture2D");
ClassDB::add_compatibility_class("Light2D", "PointLight2D");
diff --git a/scene/resources/canvas_item_material.cpp b/scene/resources/canvas_item_material.cpp
new file mode 100644
index 0000000000..7ba57a6532
--- /dev/null
+++ b/scene/resources/canvas_item_material.cpp
@@ -0,0 +1,301 @@
+/*************************************************************************/
+/* canvas_item_material.cpp */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* https://godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
+/* */
+/* Permission is hereby granted, free of charge, to any person obtaining */
+/* a copy of this software and associated documentation files (the */
+/* "Software"), to deal in the Software without restriction, including */
+/* without limitation the rights to use, copy, modify, merge, publish, */
+/* distribute, sublicense, and/or sell copies of the Software, and to */
+/* permit persons to whom the Software is furnished to do so, subject to */
+/* the following conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
+/*************************************************************************/
+
+#include "canvas_item_material.h"
+
+Mutex CanvasItemMaterial::material_mutex;
+SelfList<CanvasItemMaterial>::List *CanvasItemMaterial::dirty_materials = nullptr;
+Map<CanvasItemMaterial::MaterialKey, CanvasItemMaterial::ShaderData> CanvasItemMaterial::shader_map;
+CanvasItemMaterial::ShaderNames *CanvasItemMaterial::shader_names = nullptr;
+
+void CanvasItemMaterial::init_shaders() {
+ dirty_materials = memnew(SelfList<CanvasItemMaterial>::List);
+
+ shader_names = memnew(ShaderNames);
+
+ shader_names->particles_anim_h_frames = "particles_anim_h_frames";
+ shader_names->particles_anim_v_frames = "particles_anim_v_frames";
+ shader_names->particles_anim_loop = "particles_anim_loop";
+}
+
+void CanvasItemMaterial::finish_shaders() {
+ memdelete(dirty_materials);
+ memdelete(shader_names);
+ dirty_materials = nullptr;
+}
+
+void CanvasItemMaterial::_update_shader() {
+ dirty_materials->remove(&element);
+
+ MaterialKey mk = _compute_key();
+ if (mk.key == current_key.key) {
+ return; //no update required in the end
+ }
+
+ if (shader_map.has(current_key)) {
+ shader_map[current_key].users--;
+ if (shader_map[current_key].users == 0) {
+ //deallocate shader, as it's no longer in use
+ RS::get_singleton()->free(shader_map[current_key].shader);
+ shader_map.erase(current_key);
+ }
+ }
+
+ current_key = mk;
+
+ if (shader_map.has(mk)) {
+ RS::get_singleton()->material_set_shader(_get_material(), shader_map[mk].shader);
+ shader_map[mk].users++;
+ return;
+ }
+
+ //must create a shader!
+
+ String code = "shader_type canvas_item;\nrender_mode ";
+ switch (blend_mode) {
+ case BLEND_MODE_MIX:
+ code += "blend_mix";
+ break;
+ case BLEND_MODE_ADD:
+ code += "blend_add";
+ break;
+ case BLEND_MODE_SUB:
+ code += "blend_sub";
+ break;
+ case BLEND_MODE_MUL:
+ code += "blend_mul";
+ break;
+ case BLEND_MODE_PREMULT_ALPHA:
+ code += "blend_premul_alpha";
+ break;
+ case BLEND_MODE_DISABLED:
+ code += "blend_disabled";
+ break;
+ }
+
+ switch (light_mode) {
+ case LIGHT_MODE_NORMAL:
+ break;
+ case LIGHT_MODE_UNSHADED:
+ code += ",unshaded";
+ break;
+ case LIGHT_MODE_LIGHT_ONLY:
+ code += ",light_only";
+ break;
+ }
+
+ code += ";\n";
+
+ if (particles_animation) {
+ code += "uniform int particles_anim_h_frames;\n";
+ code += "uniform int particles_anim_v_frames;\n";
+ code += "uniform bool particles_anim_loop;\n\n";
+
+ code += "void vertex() {\n";
+ code += " float h_frames = float(particles_anim_h_frames);\n";
+ code += " float v_frames = float(particles_anim_v_frames);\n";
+ code += " VERTEX.xy /= vec2(h_frames, v_frames);\n";
+ code += " float particle_total_frames = float(particles_anim_h_frames * particles_anim_v_frames);\n";
+ code += " float particle_frame = floor(INSTANCE_CUSTOM.z * float(particle_total_frames));\n";
+ code += " if (!particles_anim_loop) {\n";
+ code += " particle_frame = clamp(particle_frame, 0.0, particle_total_frames - 1.0);\n";
+ code += " } else {\n";
+ code += " particle_frame = mod(particle_frame, particle_total_frames);\n";
+ code += " }";
+ code += " UV /= vec2(h_frames, v_frames);\n";
+ code += " UV += vec2(mod(particle_frame, h_frames) / h_frames, floor(particle_frame / h_frames) / v_frames);\n";
+ code += "}\n";
+ }
+
+ ShaderData shader_data;
+ shader_data.shader = RS::get_singleton()->shader_create();
+ shader_data.users = 1;
+
+ RS::get_singleton()->shader_set_code(shader_data.shader, code);
+
+ shader_map[mk] = shader_data;
+
+ RS::get_singleton()->material_set_shader(_get_material(), shader_data.shader);
+}
+
+void CanvasItemMaterial::flush_changes() {
+ MutexLock lock(material_mutex);
+
+ while (dirty_materials->first()) {
+ dirty_materials->first()->self()->_update_shader();
+ }
+}
+
+void CanvasItemMaterial::_queue_shader_change() {
+ MutexLock lock(material_mutex);
+
+ if (!element.in_list()) {
+ dirty_materials->add(&element);
+ }
+}
+
+bool CanvasItemMaterial::_is_shader_dirty() const {
+ MutexLock lock(material_mutex);
+
+ return element.in_list();
+}
+
+void CanvasItemMaterial::set_blend_mode(BlendMode p_blend_mode) {
+ blend_mode = p_blend_mode;
+ _queue_shader_change();
+}
+
+CanvasItemMaterial::BlendMode CanvasItemMaterial::get_blend_mode() const {
+ return blend_mode;
+}
+
+void CanvasItemMaterial::set_light_mode(LightMode p_light_mode) {
+ light_mode = p_light_mode;
+ _queue_shader_change();
+}
+
+CanvasItemMaterial::LightMode CanvasItemMaterial::get_light_mode() const {
+ return light_mode;
+}
+
+void CanvasItemMaterial::set_particles_animation(bool p_particles_anim) {
+ particles_animation = p_particles_anim;
+ _queue_shader_change();
+ notify_property_list_changed();
+}
+
+bool CanvasItemMaterial::get_particles_animation() const {
+ return particles_animation;
+}
+
+void CanvasItemMaterial::set_particles_anim_h_frames(int p_frames) {
+ particles_anim_h_frames = p_frames;
+ RS::get_singleton()->material_set_param(_get_material(), shader_names->particles_anim_h_frames, p_frames);
+}
+
+int CanvasItemMaterial::get_particles_anim_h_frames() const {
+ return particles_anim_h_frames;
+}
+
+void CanvasItemMaterial::set_particles_anim_v_frames(int p_frames) {
+ particles_anim_v_frames = p_frames;
+ RS::get_singleton()->material_set_param(_get_material(), shader_names->particles_anim_v_frames, p_frames);
+}
+
+int CanvasItemMaterial::get_particles_anim_v_frames() const {
+ return particles_anim_v_frames;
+}
+
+void CanvasItemMaterial::set_particles_anim_loop(bool p_loop) {
+ particles_anim_loop = p_loop;
+ RS::get_singleton()->material_set_param(_get_material(), shader_names->particles_anim_loop, particles_anim_loop);
+}
+
+bool CanvasItemMaterial::get_particles_anim_loop() const {
+ return particles_anim_loop;
+}
+
+void CanvasItemMaterial::_validate_property(PropertyInfo &property) const {
+ if (property.name.begins_with("particles_anim_") && !particles_animation) {
+ property.usage = PROPERTY_USAGE_NONE;
+ }
+}
+
+RID CanvasItemMaterial::get_shader_rid() const {
+ ERR_FAIL_COND_V(!shader_map.has(current_key), RID());
+ return shader_map[current_key].shader;
+}
+
+Shader::Mode CanvasItemMaterial::get_shader_mode() const {
+ return Shader::MODE_CANVAS_ITEM;
+}
+
+void CanvasItemMaterial::_bind_methods() {
+ ClassDB::bind_method(D_METHOD("set_blend_mode", "blend_mode"), &CanvasItemMaterial::set_blend_mode);
+ ClassDB::bind_method(D_METHOD("get_blend_mode"), &CanvasItemMaterial::get_blend_mode);
+
+ ClassDB::bind_method(D_METHOD("set_light_mode", "light_mode"), &CanvasItemMaterial::set_light_mode);
+ ClassDB::bind_method(D_METHOD("get_light_mode"), &CanvasItemMaterial::get_light_mode);
+
+ ClassDB::bind_method(D_METHOD("set_particles_animation", "particles_anim"), &CanvasItemMaterial::set_particles_animation);
+ ClassDB::bind_method(D_METHOD("get_particles_animation"), &CanvasItemMaterial::get_particles_animation);
+
+ ClassDB::bind_method(D_METHOD("set_particles_anim_h_frames", "frames"), &CanvasItemMaterial::set_particles_anim_h_frames);
+ ClassDB::bind_method(D_METHOD("get_particles_anim_h_frames"), &CanvasItemMaterial::get_particles_anim_h_frames);
+
+ ClassDB::bind_method(D_METHOD("set_particles_anim_v_frames", "frames"), &CanvasItemMaterial::set_particles_anim_v_frames);
+ ClassDB::bind_method(D_METHOD("get_particles_anim_v_frames"), &CanvasItemMaterial::get_particles_anim_v_frames);
+
+ ClassDB::bind_method(D_METHOD("set_particles_anim_loop", "loop"), &CanvasItemMaterial::set_particles_anim_loop);
+ ClassDB::bind_method(D_METHOD("get_particles_anim_loop"), &CanvasItemMaterial::get_particles_anim_loop);
+
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "blend_mode", PROPERTY_HINT_ENUM, "Mix,Add,Subtract,Multiply,Premultiplied Alpha"), "set_blend_mode", "get_blend_mode");
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "light_mode", PROPERTY_HINT_ENUM, "Normal,Unshaded,Light Only"), "set_light_mode", "get_light_mode");
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "particles_animation"), "set_particles_animation", "get_particles_animation");
+
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "particles_anim_h_frames", PROPERTY_HINT_RANGE, "1,128,1"), "set_particles_anim_h_frames", "get_particles_anim_h_frames");
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "particles_anim_v_frames", PROPERTY_HINT_RANGE, "1,128,1"), "set_particles_anim_v_frames", "get_particles_anim_v_frames");
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "particles_anim_loop"), "set_particles_anim_loop", "get_particles_anim_loop");
+
+ BIND_ENUM_CONSTANT(BLEND_MODE_MIX);
+ BIND_ENUM_CONSTANT(BLEND_MODE_ADD);
+ BIND_ENUM_CONSTANT(BLEND_MODE_SUB);
+ BIND_ENUM_CONSTANT(BLEND_MODE_MUL);
+ BIND_ENUM_CONSTANT(BLEND_MODE_PREMULT_ALPHA);
+
+ BIND_ENUM_CONSTANT(LIGHT_MODE_NORMAL);
+ BIND_ENUM_CONSTANT(LIGHT_MODE_UNSHADED);
+ BIND_ENUM_CONSTANT(LIGHT_MODE_LIGHT_ONLY);
+}
+
+CanvasItemMaterial::CanvasItemMaterial() :
+ element(this) {
+ set_particles_anim_h_frames(1);
+ set_particles_anim_v_frames(1);
+ set_particles_anim_loop(false);
+
+ current_key.invalid_key = 1;
+ _queue_shader_change();
+}
+
+CanvasItemMaterial::~CanvasItemMaterial() {
+ MutexLock lock(material_mutex);
+
+ if (shader_map.has(current_key)) {
+ shader_map[current_key].users--;
+ if (shader_map[current_key].users == 0) {
+ //deallocate shader, as it's no longer in use
+ RS::get_singleton()->free(shader_map[current_key].shader);
+ shader_map.erase(current_key);
+ }
+
+ RS::get_singleton()->material_set_shader(_get_material(), RID());
+ }
+}
diff --git a/scene/resources/canvas_item_material.h b/scene/resources/canvas_item_material.h
new file mode 100644
index 0000000000..0a813e0ae5
--- /dev/null
+++ b/scene/resources/canvas_item_material.h
@@ -0,0 +1,151 @@
+/*************************************************************************/
+/* canvas_item_material.h */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* https://godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
+/* */
+/* Permission is hereby granted, free of charge, to any person obtaining */
+/* a copy of this software and associated documentation files (the */
+/* "Software"), to deal in the Software without restriction, including */
+/* without limitation the rights to use, copy, modify, merge, publish, */
+/* distribute, sublicense, and/or sell copies of the Software, and to */
+/* permit persons to whom the Software is furnished to do so, subject to */
+/* the following conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
+/*************************************************************************/
+
+#ifndef CANVAS_ITEM_MATERIAL_H
+#define CANVAS_ITEM_MATERIAL_H
+
+#include "scene/resources/material.h"
+
+class CanvasItemMaterial : public Material {
+ GDCLASS(CanvasItemMaterial, Material);
+
+public:
+ enum BlendMode {
+ BLEND_MODE_MIX,
+ BLEND_MODE_ADD,
+ BLEND_MODE_SUB,
+ BLEND_MODE_MUL,
+ BLEND_MODE_PREMULT_ALPHA,
+ BLEND_MODE_DISABLED
+ };
+
+ enum LightMode {
+ LIGHT_MODE_NORMAL,
+ LIGHT_MODE_UNSHADED,
+ LIGHT_MODE_LIGHT_ONLY
+ };
+
+private:
+ union MaterialKey {
+ struct {
+ uint32_t blend_mode : 4;
+ uint32_t light_mode : 4;
+ uint32_t particles_animation : 1;
+ uint32_t invalid_key : 1;
+ };
+
+ uint32_t key = 0;
+
+ bool operator<(const MaterialKey &p_key) const {
+ return key < p_key.key;
+ }
+ };
+
+ struct ShaderNames {
+ StringName particles_anim_h_frames;
+ StringName particles_anim_v_frames;
+ StringName particles_anim_loop;
+ };
+
+ static ShaderNames *shader_names;
+
+ struct ShaderData {
+ RID shader;
+ int users = 0;
+ };
+
+ static Map<MaterialKey, ShaderData> shader_map;
+
+ MaterialKey current_key;
+
+ _FORCE_INLINE_ MaterialKey _compute_key() const {
+ MaterialKey mk;
+ mk.key = 0;
+ mk.blend_mode = blend_mode;
+ mk.light_mode = light_mode;
+ mk.particles_animation = particles_animation;
+ return mk;
+ }
+
+ static Mutex material_mutex;
+ static SelfList<CanvasItemMaterial>::List *dirty_materials;
+ SelfList<CanvasItemMaterial> element;
+
+ void _update_shader();
+ _FORCE_INLINE_ void _queue_shader_change();
+ _FORCE_INLINE_ bool _is_shader_dirty() const;
+
+ BlendMode blend_mode = BLEND_MODE_MIX;
+ LightMode light_mode = LIGHT_MODE_NORMAL;
+ bool particles_animation = false;
+
+ // Initialized in the constructor.
+ int particles_anim_h_frames;
+ int particles_anim_v_frames;
+ bool particles_anim_loop;
+
+protected:
+ static void _bind_methods();
+ void _validate_property(PropertyInfo &property) const override;
+
+public:
+ void set_blend_mode(BlendMode p_blend_mode);
+ BlendMode get_blend_mode() const;
+
+ void set_light_mode(LightMode p_light_mode);
+ LightMode get_light_mode() const;
+
+ void set_particles_animation(bool p_particles_anim);
+ bool get_particles_animation() const;
+
+ void set_particles_anim_h_frames(int p_frames);
+ int get_particles_anim_h_frames() const;
+ void set_particles_anim_v_frames(int p_frames);
+ int get_particles_anim_v_frames() const;
+
+ void set_particles_anim_loop(bool p_loop);
+ bool get_particles_anim_loop() const;
+
+ static void init_shaders();
+ static void finish_shaders();
+ static void flush_changes();
+
+ virtual RID get_shader_rid() const override;
+
+ virtual Shader::Mode get_shader_mode() const override;
+
+ CanvasItemMaterial();
+ virtual ~CanvasItemMaterial();
+};
+
+VARIANT_ENUM_CAST(CanvasItemMaterial::BlendMode)
+VARIANT_ENUM_CAST(CanvasItemMaterial::LightMode)
+
+#endif // CANVAS_ITEM_MATERIAL_H
diff --git a/scene/resources/material.cpp b/scene/resources/material.cpp
index 08f7274ff6..896a33e02e 100644
--- a/scene/resources/material.cpp
+++ b/scene/resources/material.cpp
@@ -268,7 +268,7 @@ void ShaderMaterial::_bind_methods() {
void ShaderMaterial::get_argument_options(const StringName &p_function, int p_idx, List<String> *r_options) const {
#ifdef TOOLS_ENABLED
- const String quote_style = EDITOR_DEF("text_editor/completion/use_single_quotes", 0) ? "'" : "\"";
+ const String quote_style = EDITOR_GET("text_editor/completion/use_single_quotes") ? "'" : "\"";
#else
const String quote_style = "\"";
#endif
@@ -279,7 +279,7 @@ void ShaderMaterial::get_argument_options(const StringName &p_function, int p_id
List<PropertyInfo> pl;
shader->get_param_list(&pl);
for (const PropertyInfo &E : pl) {
- r_options->push_back(quote_style + E.name.replace_first("shader_param/", "") + quote_style);
+ r_options->push_back(E.name.replace_first("shader_param/", "").quote(quote_style));
}
}
}
diff --git a/scene/resources/packed_scene.cpp b/scene/resources/packed_scene.cpp
index eddbb9a842..54bfc427c4 100644
--- a/scene/resources/packed_scene.cpp
+++ b/scene/resources/packed_scene.cpp
@@ -162,12 +162,14 @@ Node *SceneState::instantiate(GenEditState p_edit_state) const {
}
WARN_PRINT(vformat("Node %s of type %s cannot be created. A placeholder will be created instead.", snames[n.name], snames[n.type]).ascii().get_data());
if (n.parent >= 0 && n.parent < nc && ret_nodes[n.parent]) {
- if (Object::cast_to<Node3D>(ret_nodes[n.parent])) {
- obj = memnew(Node3D);
- } else if (Object::cast_to<Control>(ret_nodes[n.parent])) {
+ if (Object::cast_to<Control>(ret_nodes[n.parent])) {
obj = memnew(Control);
} else if (Object::cast_to<Node2D>(ret_nodes[n.parent])) {
obj = memnew(Node2D);
+#ifndef _3D_DISABLED
+ } else if (Object::cast_to<Node3D>(ret_nodes[n.parent])) {
+ obj = memnew(Node3D);
+#endif // _3D_DISABLED
}
}
diff --git a/scene/resources/skeleton_modification_2d.cpp b/scene/resources/skeleton_modification_2d.cpp
index b52a60006a..2d5b42ddf4 100644
--- a/scene/resources/skeleton_modification_2d.cpp
+++ b/scene/resources/skeleton_modification_2d.cpp
@@ -166,13 +166,13 @@ void SkeletonModification2D::editor_draw_angle_constraints(Bone2D *p_operation_b
if (operation_bone_parent_bone) {
stack->skeleton->draw_set_transform(
- stack->skeleton->get_global_transform().affine_inverse().xform(p_operation_bone->get_global_position()),
+ stack->skeleton->to_local(p_operation_bone->get_global_position()),
operation_bone_parent_bone->get_global_rotation() - stack->skeleton->get_global_rotation());
} else {
- stack->skeleton->draw_set_transform(stack->skeleton->get_global_transform().affine_inverse().xform(p_operation_bone->get_global_position()));
+ stack->skeleton->draw_set_transform(stack->skeleton->to_local(p_operation_bone->get_global_position()));
}
} else {
- stack->skeleton->draw_set_transform(stack->skeleton->get_global_transform().affine_inverse().xform(p_operation_bone->get_global_position()));
+ stack->skeleton->draw_set_transform(stack->skeleton->to_local(p_operation_bone->get_global_position()));
}
if (p_constraint_inverted) {
@@ -186,7 +186,7 @@ void SkeletonModification2D::editor_draw_angle_constraints(Bone2D *p_operation_b
stack->skeleton->draw_line(Vector2(0, 0), Vector2(Math::cos(arc_angle_max), Math::sin(arc_angle_max)) * p_operation_bone->get_length(), bone_ik_color, 1.0);
} else {
- stack->skeleton->draw_set_transform(stack->skeleton->get_global_transform().affine_inverse().xform(p_operation_bone->get_global_position()));
+ stack->skeleton->draw_set_transform(stack->skeleton->to_local(p_operation_bone->get_global_position()));
stack->skeleton->draw_arc(Vector2(0, 0), p_operation_bone->get_length(), 0, Math_PI * 2, 32, bone_ik_color, 1.0);
stack->skeleton->draw_line(Vector2(0, 0), Vector2(1, 0) * p_operation_bone->get_length(), bone_ik_color, 1.0);
}
diff --git a/scene/resources/skeleton_modification_2d_ccdik.cpp b/scene/resources/skeleton_modification_2d_ccdik.cpp
index 7ea60e584e..6eab8d4afe 100644
--- a/scene/resources/skeleton_modification_2d_ccdik.cpp
+++ b/scene/resources/skeleton_modification_2d_ccdik.cpp
@@ -201,18 +201,18 @@ void SkeletonModification2DCCDIK::_execute_ccdik_joint(int p_joint_idx, Node2D *
if (ccdik_data.rotate_from_joint) {
// To rotate from the joint, simply look at the target!
operation_transform.set_rotation(
- operation_transform.looking_at(p_target->get_global_transform().get_origin()).get_rotation() - operation_bone->get_bone_angle());
+ operation_transform.looking_at(p_target->get_global_position()).get_rotation() - operation_bone->get_bone_angle());
} else {
// How to rotate from the tip: get the difference of rotation needed from the tip to the target, from the perspective of the joint.
// Because we are only using the offset, we do not need to account for the bone angle of the Bone2D node.
- float joint_to_tip = operation_transform.get_origin().angle_to_point(p_tip->get_global_transform().get_origin());
- float joint_to_target = operation_transform.get_origin().angle_to_point(p_target->get_global_transform().get_origin());
+ float joint_to_tip = operation_transform.get_origin().angle_to_point(p_tip->get_global_position());
+ float joint_to_target = operation_transform.get_origin().angle_to_point(p_target->get_global_position());
operation_transform.set_rotation(
operation_transform.get_rotation() + (joint_to_target - joint_to_tip));
}
// Reset scale
- operation_transform.set_scale(operation_bone->get_global_transform().get_scale());
+ operation_transform.set_scale(operation_bone->get_global_scale());
// Apply constraints in globalspace:
if (ccdik_data.enable_constraint && !ccdik_data.constraint_in_localspace) {
diff --git a/scene/resources/skeleton_modification_2d_fabrik.cpp b/scene/resources/skeleton_modification_2d_fabrik.cpp
index aef852f7e4..c03a92b503 100644
--- a/scene/resources/skeleton_modification_2d_fabrik.cpp
+++ b/scene/resources/skeleton_modification_2d_fabrik.cpp
@@ -161,25 +161,25 @@ void SkeletonModification2DFABRIK::_execute(float p_delta) {
}
Bone2D *final_bone2d_node = Object::cast_to<Bone2D>(ObjectDB::get_instance(fabrik_data_chain[fabrik_data_chain.size() - 1].bone2d_node_cache));
- float final_bone2d_angle = final_bone2d_node->get_global_transform().get_rotation();
+ float final_bone2d_angle = final_bone2d_node->get_global_rotation();
if (fabrik_data_chain[fabrik_data_chain.size() - 1].use_target_rotation) {
final_bone2d_angle = target_global_pose.get_rotation();
}
Vector2 final_bone2d_direction = Vector2(Math::cos(final_bone2d_angle), Math::sin(final_bone2d_angle));
float final_bone2d_length = final_bone2d_node->get_length() * MIN(final_bone2d_node->get_global_scale().x, final_bone2d_node->get_global_scale().y);
- float target_distance = (final_bone2d_node->get_global_transform().get_origin() + (final_bone2d_direction * final_bone2d_length)).distance_to(target->get_global_transform().get_origin());
+ float target_distance = (final_bone2d_node->get_global_position() + (final_bone2d_direction * final_bone2d_length)).distance_to(target->get_global_position());
chain_iterations = 0;
while (target_distance > chain_tolarance) {
chain_backwards();
chain_forwards();
- final_bone2d_angle = final_bone2d_node->get_global_transform().get_rotation();
+ final_bone2d_angle = final_bone2d_node->get_global_rotation();
if (fabrik_data_chain[fabrik_data_chain.size() - 1].use_target_rotation) {
final_bone2d_angle = target_global_pose.get_rotation();
}
final_bone2d_direction = Vector2(Math::cos(final_bone2d_angle), Math::sin(final_bone2d_angle));
- target_distance = (final_bone2d_node->get_global_transform().get_origin() + (final_bone2d_direction * final_bone2d_length)).distance_to(target->get_global_transform().get_origin());
+ target_distance = (final_bone2d_node->get_global_position() + (final_bone2d_direction * final_bone2d_length)).distance_to(target->get_global_position());
chain_iterations += 1;
if (chain_iterations >= chain_max_iterations) {
@@ -210,7 +210,7 @@ void SkeletonModification2DFABRIK::_execute(float p_delta) {
chain_trans.set_rotation(chain_trans.get_rotation() - joint_bone2d_node->get_bone_angle());
// Reset scale
- chain_trans.set_scale(joint_bone2d_node->get_global_transform().get_scale());
+ chain_trans.set_scale(joint_bone2d_node->get_global_scale());
// Apply to the bone, and to the override
joint_bone2d_node->set_global_transform(chain_trans);
diff --git a/scene/resources/skeleton_modification_2d_jiggle.cpp b/scene/resources/skeleton_modification_2d_jiggle.cpp
index 2547083336..84abc9d020 100644
--- a/scene/resources/skeleton_modification_2d_jiggle.cpp
+++ b/scene/resources/skeleton_modification_2d_jiggle.cpp
@@ -171,7 +171,7 @@ void SkeletonModification2DJiggle::_execute_jiggle_joint(int p_joint_idx, Node2D
}
Transform2D operation_bone_trans = operation_bone->get_global_transform();
- Vector2 target_position = p_target->get_global_transform().get_origin();
+ Vector2 target_position = p_target->get_global_position();
jiggle_data_chain.write[p_joint_idx].force = (target_position - jiggle_data_chain[p_joint_idx].dynamic_position) * jiggle_data_chain[p_joint_idx].stiffness * p_delta;
@@ -215,7 +215,7 @@ void SkeletonModification2DJiggle::_execute_jiggle_joint(int p_joint_idx, Node2D
operation_bone_trans.set_rotation(operation_bone_trans.get_rotation() - operation_bone->get_bone_angle());
// Reset scale
- operation_bone_trans.set_scale(operation_bone->get_global_transform().get_scale());
+ operation_bone_trans.set_scale(operation_bone->get_global_scale());
operation_bone->set_global_transform(operation_bone_trans);
stack->skeleton->set_bone_local_pose_override(jiggle_data_chain[p_joint_idx].bone_idx, operation_bone->get_transform(), stack->strength, true);
@@ -244,7 +244,7 @@ void SkeletonModification2DJiggle::_setup_modification(SkeletonModificationStack
int bone_idx = jiggle_data_chain[i].bone_idx;
if (bone_idx > 0 && bone_idx < stack->skeleton->get_bone_count()) {
Bone2D *bone2d_node = stack->skeleton->get_bone(bone_idx);
- jiggle_data_chain.write[i].dynamic_position = bone2d_node->get_global_transform().get_origin();
+ jiggle_data_chain.write[i].dynamic_position = bone2d_node->get_global_position();
}
}
}
diff --git a/scene/resources/skeleton_modification_2d_lookat.cpp b/scene/resources/skeleton_modification_2d_lookat.cpp
index fd5c8c7cc2..2da770f012 100644
--- a/scene/resources/skeleton_modification_2d_lookat.cpp
+++ b/scene/resources/skeleton_modification_2d_lookat.cpp
@@ -147,7 +147,7 @@ void SkeletonModification2DLookAt::_execute(float p_delta) {
// Look at the target!
operation_transform = operation_transform.looking_at(target_trans.get_origin());
// Apply whatever scale it had prior to looking_at
- operation_transform.set_scale(operation_bone->get_global_transform().get_scale());
+ operation_transform.set_scale(operation_bone->get_global_scale());
// Account for the direction the bone faces in:
operation_transform.set_rotation(operation_transform.get_rotation() - operation_bone->get_bone_angle());
diff --git a/scene/resources/skeleton_modification_2d_twoboneik.cpp b/scene/resources/skeleton_modification_2d_twoboneik.cpp
index 0a91290015..88d80a501f 100644
--- a/scene/resources/skeleton_modification_2d_twoboneik.cpp
+++ b/scene/resources/skeleton_modification_2d_twoboneik.cpp
@@ -142,7 +142,7 @@ void SkeletonModification2DTwoBoneIK::_execute(float p_delta) {
// http://theorangeduck.com/page/simple-two-joint
// https://www.alanzucconi.com/2018/05/02/ik-2d-2/
// With modifications by TwistedTwigleg
- Vector2 target_difference = target->get_global_transform().get_origin() - joint_one_bone->get_global_transform().get_origin();
+ Vector2 target_difference = target->get_global_position() - joint_one_bone->get_global_position();
float joint_one_to_target = target_difference.length();
float angle_atan = Math::atan2(target_difference.y, target_difference.x);
@@ -206,7 +206,7 @@ void SkeletonModification2DTwoBoneIK::_draw_editor_gizmo() {
return;
}
stack->skeleton->draw_set_transform(
- stack->skeleton->get_global_transform().affine_inverse().xform(operation_bone_one->get_global_position()),
+ stack->skeleton->to_local(operation_bone_one->get_global_position()),
operation_bone_one->get_global_rotation() - stack->skeleton->get_global_rotation());
Color bone_ik_color = Color(1.0, 0.65, 0.0, 0.4);
diff --git a/scene/resources/visual_shader_nodes.cpp b/scene/resources/visual_shader_nodes.cpp
index afe0bdfd5c..a8ec78f63e 100644
--- a/scene/resources/visual_shader_nodes.cpp
+++ b/scene/resources/visual_shader_nodes.cpp
@@ -38,7 +38,7 @@ VisualShaderNodeConstant::VisualShaderNodeConstant() {
////////////// Scalar(Float)
String VisualShaderNodeFloatConstant::get_caption() const {
- return "ScalarFloat";
+ return "FloatConstant";
}
int VisualShaderNodeFloatConstant::get_input_port_count() const {
@@ -97,7 +97,7 @@ VisualShaderNodeFloatConstant::VisualShaderNodeFloatConstant() {
////////////// Scalar(Int)
String VisualShaderNodeIntConstant::get_caption() const {
- return "ScalarInt";
+ return "IntConstant";
}
int VisualShaderNodeIntConstant::get_input_port_count() const {
@@ -156,7 +156,7 @@ VisualShaderNodeIntConstant::VisualShaderNodeIntConstant() {
////////////// Boolean
String VisualShaderNodeBooleanConstant::get_caption() const {
- return "Boolean";
+ return "BooleanConstant";
}
int VisualShaderNodeBooleanConstant::get_input_port_count() const {
@@ -215,7 +215,7 @@ VisualShaderNodeBooleanConstant::VisualShaderNodeBooleanConstant() {
////////////// Color
String VisualShaderNodeColorConstant::get_caption() const {
- return "Color";
+ return "ColorConstant";
}
int VisualShaderNodeColorConstant::get_input_port_count() const {
@@ -285,7 +285,7 @@ VisualShaderNodeColorConstant::VisualShaderNodeColorConstant() {
////////////// Vector
String VisualShaderNodeVec3Constant::get_caption() const {
- return "Vector";
+ return "VectorConstant";
}
int VisualShaderNodeVec3Constant::get_input_port_count() const {
@@ -344,7 +344,7 @@ VisualShaderNodeVec3Constant::VisualShaderNodeVec3Constant() {
////////////// Transform3D
String VisualShaderNodeTransformConstant::get_caption() const {
- return "Transform3D";
+ return "TransformConstant";
}
int VisualShaderNodeTransformConstant::get_input_port_count() const {
@@ -1915,76 +1915,96 @@ VisualShaderNodeColorOp::VisualShaderNodeColorOp() {
set_input_port_default_value(1, Vector3());
}
-////////////// Transform Mult
+////////////// Transform Op
-String VisualShaderNodeTransformMult::get_caption() const {
- return "TransformMult";
+String VisualShaderNodeTransformOp::get_caption() const {
+ return "TransformOp";
}
-int VisualShaderNodeTransformMult::get_input_port_count() const {
+int VisualShaderNodeTransformOp::get_input_port_count() const {
return 2;
}
-VisualShaderNodeTransformMult::PortType VisualShaderNodeTransformMult::get_input_port_type(int p_port) const {
+VisualShaderNodeTransformOp::PortType VisualShaderNodeTransformOp::get_input_port_type(int p_port) const {
return PORT_TYPE_TRANSFORM;
}
-String VisualShaderNodeTransformMult::get_input_port_name(int p_port) const {
+String VisualShaderNodeTransformOp::get_input_port_name(int p_port) const {
return p_port == 0 ? "a" : "b";
}
-int VisualShaderNodeTransformMult::get_output_port_count() const {
+int VisualShaderNodeTransformOp::get_output_port_count() const {
return 1;
}
-VisualShaderNodeTransformMult::PortType VisualShaderNodeTransformMult::get_output_port_type(int p_port) const {
+VisualShaderNodeTransformOp::PortType VisualShaderNodeTransformOp::get_output_port_type(int p_port) const {
return PORT_TYPE_TRANSFORM;
}
-String VisualShaderNodeTransformMult::get_output_port_name(int p_port) const {
+String VisualShaderNodeTransformOp::get_output_port_name(int p_port) const {
return "mult"; //no output port means the editor will be used as port
}
-String VisualShaderNodeTransformMult::generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview) const {
- if (op == OP_AxB) {
- return " " + p_output_vars[0] + " = " + p_input_vars[0] + " * " + p_input_vars[1] + ";\n";
- } else if (op == OP_BxA) {
- return " " + p_output_vars[0] + " = " + p_input_vars[1] + " * " + p_input_vars[0] + ";\n";
- } else if (op == OP_AxB_COMP) {
- return " " + p_output_vars[0] + " = matrixCompMult(" + p_input_vars[0] + ", " + p_input_vars[1] + ");\n";
- } else {
- return " " + p_output_vars[0] + " = matrixCompMult(" + p_input_vars[1] + ", " + p_input_vars[0] + ");\n";
+String VisualShaderNodeTransformOp::generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview) const {
+ switch (op) {
+ case OP_AxB:
+ return " " + p_output_vars[0] + " = " + p_input_vars[0] + " * " + p_input_vars[1] + ";\n";
+ case OP_BxA:
+ return " " + p_output_vars[0] + " = " + p_input_vars[1] + " * " + p_input_vars[0] + ";\n";
+ case OP_AxB_COMP:
+ return " " + p_output_vars[0] + " = matrixCompMult(" + p_input_vars[0] + ", " + p_input_vars[1] + ");\n";
+ case OP_BxA_COMP:
+ return " " + p_output_vars[0] + " = matrixCompMult(" + p_input_vars[1] + ", " + p_input_vars[0] + ");\n";
+ case OP_ADD:
+ return " " + p_output_vars[0] + " = " + p_input_vars[0] + " + " + p_input_vars[1] + ";\n";
+ case OP_A_MINUS_B:
+ return " " + p_output_vars[0] + " = " + p_input_vars[0] + " - " + p_input_vars[1] + ";\n";
+ case OP_B_MINUS_A:
+ return " " + p_output_vars[0] + " = " + p_input_vars[1] + " - " + p_input_vars[0] + ";\n";
+ case OP_A_DIV_B:
+ return " " + p_output_vars[0] + " = " + p_input_vars[0] + " / " + p_input_vars[1] + ";\n";
+ case OP_B_DIV_A:
+ return " " + p_output_vars[0] + " = " + p_input_vars[1] + " / " + p_input_vars[0] + ";\n";
+ default:
+ return "";
}
}
-void VisualShaderNodeTransformMult::set_operator(Operator p_op) {
+void VisualShaderNodeTransformOp::set_operator(Operator p_op) {
+ ERR_FAIL_INDEX(int(p_op), int(OP_LIMITER));
op = p_op;
emit_changed();
}
-VisualShaderNodeTransformMult::Operator VisualShaderNodeTransformMult::get_operator() const {
+VisualShaderNodeTransformOp::Operator VisualShaderNodeTransformOp::get_operator() const {
return op;
}
-Vector<StringName> VisualShaderNodeTransformMult::get_editable_properties() const {
+Vector<StringName> VisualShaderNodeTransformOp::get_editable_properties() const {
Vector<StringName> props;
props.push_back("operator");
return props;
}
-void VisualShaderNodeTransformMult::_bind_methods() {
- ClassDB::bind_method(D_METHOD("set_operator", "op"), &VisualShaderNodeTransformMult::set_operator);
- ClassDB::bind_method(D_METHOD("get_operator"), &VisualShaderNodeTransformMult::get_operator);
+void VisualShaderNodeTransformOp::_bind_methods() {
+ ClassDB::bind_method(D_METHOD("set_operator", "op"), &VisualShaderNodeTransformOp::set_operator);
+ ClassDB::bind_method(D_METHOD("get_operator"), &VisualShaderNodeTransformOp::get_operator);
- ADD_PROPERTY(PropertyInfo(Variant::INT, "operator", PROPERTY_HINT_ENUM, "A x B,B x A,A x B(per component),B x A(per component)"), "set_operator", "get_operator");
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "operator", PROPERTY_HINT_ENUM, "A x B,B x A,A x B(per component),B x A(per component),A + B,A - B,B - A,A / B,B / A"), "set_operator", "get_operator");
BIND_ENUM_CONSTANT(OP_AxB);
BIND_ENUM_CONSTANT(OP_BxA);
BIND_ENUM_CONSTANT(OP_AxB_COMP);
BIND_ENUM_CONSTANT(OP_BxA_COMP);
+ BIND_ENUM_CONSTANT(OP_ADD);
+ BIND_ENUM_CONSTANT(OP_A_MINUS_B);
+ BIND_ENUM_CONSTANT(OP_B_MINUS_A);
+ BIND_ENUM_CONSTANT(OP_A_DIV_B);
+ BIND_ENUM_CONSTANT(OP_B_DIV_A);
+ BIND_ENUM_CONSTANT(OP_LIMITER);
}
-VisualShaderNodeTransformMult::VisualShaderNodeTransformMult() {
+VisualShaderNodeTransformOp::VisualShaderNodeTransformOp() {
set_input_port_default_value(0, Transform3D());
set_input_port_default_value(1, Transform3D());
}
diff --git a/scene/resources/visual_shader_nodes.h b/scene/resources/visual_shader_nodes.h
index 33a45a4384..99617b46a3 100644
--- a/scene/resources/visual_shader_nodes.h
+++ b/scene/resources/visual_shader_nodes.h
@@ -696,19 +696,25 @@ public:
VARIANT_ENUM_CAST(VisualShaderNodeColorOp::Operator)
-///////////////////////////////////////
-/// TRANSFORM-TRANSFORM MULTIPLICATION
-///////////////////////////////////////
+////////////////////////////////
+/// TRANSFORM-TRANSFORM OPERATOR
+////////////////////////////////
-class VisualShaderNodeTransformMult : public VisualShaderNode {
- GDCLASS(VisualShaderNodeTransformMult, VisualShaderNode);
+class VisualShaderNodeTransformOp : public VisualShaderNode {
+ GDCLASS(VisualShaderNodeTransformOp, VisualShaderNode);
public:
enum Operator {
OP_AxB,
OP_BxA,
OP_AxB_COMP,
- OP_BxA_COMP
+ OP_BxA_COMP,
+ OP_ADD,
+ OP_A_MINUS_B,
+ OP_B_MINUS_A,
+ OP_A_DIV_B,
+ OP_B_DIV_A,
+ OP_LIMITER,
};
protected:
@@ -734,10 +740,10 @@ public:
virtual Vector<StringName> get_editable_properties() const override;
- VisualShaderNodeTransformMult();
+ VisualShaderNodeTransformOp();
};
-VARIANT_ENUM_CAST(VisualShaderNodeTransformMult::Operator)
+VARIANT_ENUM_CAST(VisualShaderNodeTransformOp::Operator)
///////////////////////////////////////
/// TRANSFORM-VECTOR MULTIPLICATION
diff --git a/scene/resources/line_shape_2d.cpp b/scene/resources/world_margin_shape_2d.cpp
index d206f12287..3b43681528 100644
--- a/scene/resources/line_shape_2d.cpp
+++ b/scene/resources/world_margin_shape_2d.cpp
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* line_shape_2d.cpp */
+/* world_margin_shape_2d.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -28,13 +28,13 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#include "line_shape_2d.h"
+#include "world_margin_shape_2d.h"
#include "core/math/geometry_2d.h"
#include "servers/physics_server_2d.h"
#include "servers/rendering_server.h"
-bool LineShape2D::_edit_is_selected_on_click(const Point2 &p_point, double p_tolerance) const {
+bool WorldMarginShape2D::_edit_is_selected_on_click(const Point2 &p_point, double p_tolerance) const {
Vector2 point = get_distance() * get_normal();
Vector2 l[2][2] = { { point - get_normal().orthogonal() * 100, point + get_normal().orthogonal() * 100 }, { point, point + get_normal() * 30 } };
@@ -48,7 +48,7 @@ bool LineShape2D::_edit_is_selected_on_click(const Point2 &p_point, double p_tol
return false;
}
-void LineShape2D::_update_shape() {
+void WorldMarginShape2D::_update_shape() {
Array arr;
arr.push_back(normal);
arr.push_back(distance);
@@ -56,25 +56,25 @@ void LineShape2D::_update_shape() {
emit_changed();
}
-void LineShape2D::set_normal(const Vector2 &p_normal) {
+void WorldMarginShape2D::set_normal(const Vector2 &p_normal) {
normal = p_normal;
_update_shape();
}
-void LineShape2D::set_distance(real_t p_distance) {
+void WorldMarginShape2D::set_distance(real_t p_distance) {
distance = p_distance;
_update_shape();
}
-Vector2 LineShape2D::get_normal() const {
+Vector2 WorldMarginShape2D::get_normal() const {
return normal;
}
-real_t LineShape2D::get_distance() const {
+real_t WorldMarginShape2D::get_distance() const {
return distance;
}
-void LineShape2D::draw(const RID &p_to_rid, const Color &p_color) {
+void WorldMarginShape2D::draw(const RID &p_to_rid, const Color &p_color) {
Vector2 point = get_distance() * get_normal();
Vector2 l1[2] = { point - get_normal().orthogonal() * 100, point + get_normal().orthogonal() * 100 };
@@ -83,7 +83,7 @@ void LineShape2D::draw(const RID &p_to_rid, const Color &p_color) {
RS::get_singleton()->canvas_item_add_line(p_to_rid, l2[0], l2[1], p_color, 3);
}
-Rect2 LineShape2D::get_rect() const {
+Rect2 WorldMarginShape2D::get_rect() const {
Vector2 point = get_distance() * get_normal();
Vector2 l1[2] = { point - get_normal().orthogonal() * 100, point + get_normal().orthogonal() * 100 };
@@ -96,22 +96,22 @@ Rect2 LineShape2D::get_rect() const {
return rect;
}
-real_t LineShape2D::get_enclosing_radius() const {
+real_t WorldMarginShape2D::get_enclosing_radius() const {
return distance;
}
-void LineShape2D::_bind_methods() {
- ClassDB::bind_method(D_METHOD("set_normal", "normal"), &LineShape2D::set_normal);
- ClassDB::bind_method(D_METHOD("get_normal"), &LineShape2D::get_normal);
+void WorldMarginShape2D::_bind_methods() {
+ ClassDB::bind_method(D_METHOD("set_normal", "normal"), &WorldMarginShape2D::set_normal);
+ ClassDB::bind_method(D_METHOD("get_normal"), &WorldMarginShape2D::get_normal);
- ClassDB::bind_method(D_METHOD("set_distance", "distance"), &LineShape2D::set_distance);
- ClassDB::bind_method(D_METHOD("get_distance"), &LineShape2D::get_distance);
+ ClassDB::bind_method(D_METHOD("set_distance", "distance"), &WorldMarginShape2D::set_distance);
+ ClassDB::bind_method(D_METHOD("get_distance"), &WorldMarginShape2D::get_distance);
ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "normal"), "set_normal", "get_normal");
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "distance"), "set_distance", "get_distance");
}
-LineShape2D::LineShape2D() :
- Shape2D(PhysicsServer2D::get_singleton()->line_shape_create()) {
+WorldMarginShape2D::WorldMarginShape2D() :
+ Shape2D(PhysicsServer2D::get_singleton()->world_margin_shape_create()) {
_update_shape();
}
diff --git a/scene/resources/line_shape_2d.h b/scene/resources/world_margin_shape_2d.h
index 210a1aa9e6..3c1d593ffe 100644
--- a/scene/resources/line_shape_2d.h
+++ b/scene/resources/world_margin_shape_2d.h
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* line_shape_2d.h */
+/* world_margin_shape_2d.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -28,15 +28,15 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#ifndef LINE_SHAPE_2D_H
-#define LINE_SHAPE_2D_H
+#ifndef WORLD_MARGIN_SHAPE_2D_H
+#define WORLD_MARGIN_SHAPE_2D_H
#include "scene/resources/shape_2d.h"
-class LineShape2D : public Shape2D {
- GDCLASS(LineShape2D, Shape2D);
+class WorldMarginShape2D : public Shape2D {
+ GDCLASS(WorldMarginShape2D, Shape2D);
- // LineShape2D is often used for one-way platforms, where the normal pointing up makes sense.
+ // WorldMarginShape2D is often used for one-way platforms, where the normal pointing up makes sense.
Vector2 normal = Vector2(0, -1);
real_t distance = 0.0;
@@ -58,7 +58,7 @@ public:
virtual Rect2 get_rect() const override;
virtual real_t get_enclosing_radius() const override;
- LineShape2D();
+ WorldMarginShape2D();
};
-#endif // LINE_SHAPE_2D_H
+#endif // WORLD_MARGIN_SHAPE_2D_H
diff --git a/servers/physics_2d/collision_solver_2d_sat.cpp b/servers/physics_2d/collision_solver_2d_sat.cpp
index 45b9e6414d..30a99d3d74 100644
--- a/servers/physics_2d/collision_solver_2d_sat.cpp
+++ b/servers/physics_2d/collision_solver_2d_sat.cpp
@@ -1114,12 +1114,12 @@ static void _collision_convex_polygon_convex_polygon(const Shape2DSW *p_a, const
bool sat_2d_calculate_penetration(const Shape2DSW *p_shape_A, const Transform2D &p_transform_A, const Vector2 &p_motion_A, const Shape2DSW *p_shape_B, const Transform2D &p_transform_B, const Vector2 &p_motion_B, CollisionSolver2DSW::CallbackResult p_result_callback, void *p_userdata, bool p_swap, Vector2 *sep_axis, real_t p_margin_A, real_t p_margin_B) {
PhysicsServer2D::ShapeType type_A = p_shape_A->get_type();
- ERR_FAIL_COND_V(type_A == PhysicsServer2D::SHAPE_LINE, false);
+ ERR_FAIL_COND_V(type_A == PhysicsServer2D::SHAPE_WORLD_MARGIN, false);
ERR_FAIL_COND_V(p_shape_A->is_concave(), false);
PhysicsServer2D::ShapeType type_B = p_shape_B->get_type();
- ERR_FAIL_COND_V(type_B == PhysicsServer2D::SHAPE_LINE, false);
+ ERR_FAIL_COND_V(type_B == PhysicsServer2D::SHAPE_WORLD_MARGIN, false);
ERR_FAIL_COND_V(p_shape_B->is_concave(), false);
static const CollisionFunc collision_table[5][5] = {
diff --git a/servers/physics_2d/collision_solver_2d_sw.cpp b/servers/physics_2d/collision_solver_2d_sw.cpp
index ed398a24e5..8f8a4a862c 100644
--- a/servers/physics_2d/collision_solver_2d_sw.cpp
+++ b/servers/physics_2d/collision_solver_2d_sw.cpp
@@ -34,14 +34,14 @@
#define collision_solver sat_2d_calculate_penetration
//#define collision_solver gjk_epa_calculate_penetration
-bool CollisionSolver2DSW::solve_static_line(const Shape2DSW *p_shape_A, const Transform2D &p_transform_A, const Shape2DSW *p_shape_B, const Transform2D &p_transform_B, CallbackResult p_result_callback, void *p_userdata, bool p_swap_result) {
- const LineShape2DSW *line = static_cast<const LineShape2DSW *>(p_shape_A);
- if (p_shape_B->get_type() == PhysicsServer2D::SHAPE_LINE) {
+bool CollisionSolver2DSW::solve_static_world_margin(const Shape2DSW *p_shape_A, const Transform2D &p_transform_A, const Shape2DSW *p_shape_B, const Transform2D &p_transform_B, CallbackResult p_result_callback, void *p_userdata, bool p_swap_result) {
+ const WorldMarginShape2DSW *world_margin = static_cast<const WorldMarginShape2DSW *>(p_shape_A);
+ if (p_shape_B->get_type() == PhysicsServer2D::SHAPE_WORLD_MARGIN) {
return false;
}
- Vector2 n = p_transform_A.basis_xform(line->get_normal()).normalized();
- Vector2 p = p_transform_A.xform(line->get_normal() * line->get_d());
+ Vector2 n = p_transform_A.basis_xform(world_margin->get_normal()).normalized();
+ Vector2 p = p_transform_A.xform(world_margin->get_normal() * world_margin->get_d());
real_t d = n.dot(p);
Vector2 supports[2];
@@ -166,15 +166,15 @@ bool CollisionSolver2DSW::solve(const Shape2DSW *p_shape_A, const Transform2D &p
swap = true;
}
- if (type_A == PhysicsServer2D::SHAPE_LINE) {
- if (type_B == PhysicsServer2D::SHAPE_LINE) {
+ if (type_A == PhysicsServer2D::SHAPE_WORLD_MARGIN) {
+ if (type_B == PhysicsServer2D::SHAPE_WORLD_MARGIN) {
return false;
}
if (swap) {
- return solve_static_line(p_shape_B, p_transform_B, p_shape_A, p_transform_A, p_result_callback, p_userdata, true);
+ return solve_static_world_margin(p_shape_B, p_transform_B, p_shape_A, p_transform_A, p_result_callback, p_userdata, true);
} else {
- return solve_static_line(p_shape_A, p_transform_A, p_shape_B, p_transform_B, p_result_callback, p_userdata, false);
+ return solve_static_world_margin(p_shape_A, p_transform_A, p_shape_B, p_transform_B, p_result_callback, p_userdata, false);
}
} else if (concave_B) {
diff --git a/servers/physics_2d/collision_solver_2d_sw.h b/servers/physics_2d/collision_solver_2d_sw.h
index 4f12ca9e88..17c0c2fe70 100644
--- a/servers/physics_2d/collision_solver_2d_sw.h
+++ b/servers/physics_2d/collision_solver_2d_sw.h
@@ -38,7 +38,7 @@ public:
typedef void (*CallbackResult)(const Vector2 &p_point_A, const Vector2 &p_point_B, void *p_userdata);
private:
- static bool solve_static_line(const Shape2DSW *p_shape_A, const Transform2D &p_transform_A, const Shape2DSW *p_shape_B, const Transform2D &p_transform_B, CallbackResult p_result_callback, void *p_userdata, bool p_swap_result);
+ static bool solve_static_world_margin(const Shape2DSW *p_shape_A, const Transform2D &p_transform_A, const Shape2DSW *p_shape_B, const Transform2D &p_transform_B, CallbackResult p_result_callback, void *p_userdata, bool p_swap_result);
static void concave_callback(void *p_userdata, Shape2DSW *p_convex);
static bool solve_concave(const Shape2DSW *p_shape_A, const Transform2D &p_transform_A, const Vector2 &p_motion_A, const Shape2DSW *p_shape_B, const Transform2D &p_transform_B, const Vector2 &p_motion_B, CallbackResult p_result_callback, void *p_userdata, bool p_swap_result, Vector2 *sep_axis = nullptr, real_t p_margin_A = 0, real_t p_margin_B = 0);
static bool solve_raycast(const Shape2DSW *p_shape_A, const Vector2 &p_motion_A, const Transform2D &p_transform_A, const Shape2DSW *p_shape_B, const Transform2D &p_transform_B, CallbackResult p_result_callback, void *p_userdata, bool p_swap_result, Vector2 *sep_axis = nullptr);
diff --git a/servers/physics_2d/physics_server_2d_sw.cpp b/servers/physics_2d/physics_server_2d_sw.cpp
index 4dcc4a9cfd..88c097453e 100644
--- a/servers/physics_2d/physics_server_2d_sw.cpp
+++ b/servers/physics_2d/physics_server_2d_sw.cpp
@@ -42,8 +42,8 @@
RID PhysicsServer2DSW::_shape_create(ShapeType p_shape) {
Shape2DSW *shape = nullptr;
switch (p_shape) {
- case SHAPE_LINE: {
- shape = memnew(LineShape2DSW);
+ case SHAPE_WORLD_MARGIN: {
+ shape = memnew(WorldMarginShape2DSW);
} break;
case SHAPE_SEGMENT: {
shape = memnew(SegmentShape2DSW);
@@ -75,8 +75,8 @@ RID PhysicsServer2DSW::_shape_create(ShapeType p_shape) {
return id;
}
-RID PhysicsServer2DSW::line_shape_create() {
- return _shape_create(SHAPE_LINE);
+RID PhysicsServer2DSW::world_margin_shape_create() {
+ return _shape_create(SHAPE_WORLD_MARGIN);
}
RID PhysicsServer2DSW::segment_shape_create() {
diff --git a/servers/physics_2d/physics_server_2d_sw.h b/servers/physics_2d/physics_server_2d_sw.h
index e1ad6a56ee..3610f43f93 100644
--- a/servers/physics_2d/physics_server_2d_sw.h
+++ b/servers/physics_2d/physics_server_2d_sw.h
@@ -87,7 +87,7 @@ public:
Vector2 *ptr;
};
- virtual RID line_shape_create() override;
+ virtual RID world_margin_shape_create() override;
virtual RID segment_shape_create() override;
virtual RID circle_shape_create() override;
virtual RID rectangle_shape_create() override;
diff --git a/servers/physics_2d/physics_server_2d_wrap_mt.h b/servers/physics_2d/physics_server_2d_wrap_mt.h
index 7bc1096f93..b93178919d 100644
--- a/servers/physics_2d/physics_server_2d_wrap_mt.h
+++ b/servers/physics_2d/physics_server_2d_wrap_mt.h
@@ -79,7 +79,7 @@ public:
#include "servers/server_wrap_mt_common.h"
//FUNC1RID(shape,ShapeType); todo fix
- FUNCRID(line_shape)
+ FUNCRID(world_margin_shape)
FUNCRID(segment_shape)
FUNCRID(circle_shape)
FUNCRID(rectangle_shape)
diff --git a/servers/physics_2d/shape_2d_sw.cpp b/servers/physics_2d/shape_2d_sw.cpp
index b16efbfe64..b3e4ca84c3 100644
--- a/servers/physics_2d/shape_2d_sw.cpp
+++ b/servers/physics_2d/shape_2d_sw.cpp
@@ -88,15 +88,15 @@ Shape2DSW::~Shape2DSW() {
/*********************************************************/
/*********************************************************/
-void LineShape2DSW::get_supports(const Vector2 &p_normal, Vector2 *r_supports, int &r_amount) const {
+void WorldMarginShape2DSW::get_supports(const Vector2 &p_normal, Vector2 *r_supports, int &r_amount) const {
r_amount = 0;
}
-bool LineShape2DSW::contains_point(const Vector2 &p_point) const {
+bool WorldMarginShape2DSW::contains_point(const Vector2 &p_point) const {
return normal.dot(p_point) < d;
}
-bool LineShape2DSW::intersect_segment(const Vector2 &p_begin, const Vector2 &p_end, Vector2 &r_point, Vector2 &r_normal) const {
+bool WorldMarginShape2DSW::intersect_segment(const Vector2 &p_begin, const Vector2 &p_end, Vector2 &r_point, Vector2 &r_normal) const {
Vector2 segment = p_begin - p_end;
real_t den = normal.dot(segment);
@@ -118,11 +118,11 @@ bool LineShape2DSW::intersect_segment(const Vector2 &p_begin, const Vector2 &p_e
return true;
}
-real_t LineShape2DSW::get_moment_of_inertia(real_t p_mass, const Size2 &p_scale) const {
+real_t WorldMarginShape2DSW::get_moment_of_inertia(real_t p_mass, const Size2 &p_scale) const {
return 0;
}
-void LineShape2DSW::set_data(const Variant &p_data) {
+void WorldMarginShape2DSW::set_data(const Variant &p_data) {
ERR_FAIL_COND(p_data.get_type() != Variant::ARRAY);
Array arr = p_data;
ERR_FAIL_COND(arr.size() != 2);
@@ -131,7 +131,7 @@ void LineShape2DSW::set_data(const Variant &p_data) {
configure(Rect2(Vector2(-1e4, -1e4), Vector2(1e4 * 2, 1e4 * 2)));
}
-Variant LineShape2DSW::get_data() const {
+Variant WorldMarginShape2DSW::get_data() const {
Array arr;
arr.resize(2);
arr[0] = normal;
diff --git a/servers/physics_2d/shape_2d_sw.h b/servers/physics_2d/shape_2d_sw.h
index 3e4271b156..2de0f3cb9f 100644
--- a/servers/physics_2d/shape_2d_sw.h
+++ b/servers/physics_2d/shape_2d_sw.h
@@ -36,7 +36,7 @@
/*
-SHAPE_LINE, ///< plane:"plane"
+SHAPE_WORLD_MARGIN, ///< plane:"plane"
SHAPE_SEGMENT, ///< real_t:"length"
SHAPE_CIRCLE, ///< real_t:"radius"
SHAPE_RECTANGLE, ///< vec3:"extents"
@@ -152,7 +152,7 @@ public:
r_max = MAX(maxa, maxb); \
}
-class LineShape2DSW : public Shape2DSW {
+class WorldMarginShape2DSW : public Shape2DSW {
Vector2 normal;
real_t d;
@@ -160,7 +160,7 @@ public:
_FORCE_INLINE_ Vector2 get_normal() const { return normal; }
_FORCE_INLINE_ real_t get_d() const { return d; }
- virtual PhysicsServer2D::ShapeType get_type() const { return PhysicsServer2D::SHAPE_LINE; }
+ virtual PhysicsServer2D::ShapeType get_type() const { return PhysicsServer2D::SHAPE_WORLD_MARGIN; }
virtual void project_rangev(const Vector2 &p_normal, const Transform2D &p_transform, real_t &r_min, real_t &r_max) const { project_range(p_normal, p_transform, r_min, r_max); }
virtual void get_supports(const Vector2 &p_normal, Vector2 *r_supports, int &r_amount) const;
diff --git a/servers/physics_server_2d.cpp b/servers/physics_server_2d.cpp
index c2dedde0be..092c3ae7a9 100644
--- a/servers/physics_server_2d.cpp
+++ b/servers/physics_server_2d.cpp
@@ -513,7 +513,7 @@ bool PhysicsServer2D::_body_test_motion(RID p_body, const Transform2D &p_from, c
}
void PhysicsServer2D::_bind_methods() {
- ClassDB::bind_method(D_METHOD("line_shape_create"), &PhysicsServer2D::line_shape_create);
+ ClassDB::bind_method(D_METHOD("world_margin_shape_create"), &PhysicsServer2D::world_margin_shape_create);
ClassDB::bind_method(D_METHOD("segment_shape_create"), &PhysicsServer2D::segment_shape_create);
ClassDB::bind_method(D_METHOD("circle_shape_create"), &PhysicsServer2D::circle_shape_create);
ClassDB::bind_method(D_METHOD("rectangle_shape_create"), &PhysicsServer2D::rectangle_shape_create);
@@ -674,7 +674,7 @@ void PhysicsServer2D::_bind_methods() {
BIND_ENUM_CONSTANT(SPACE_PARAM_CONSTRAINT_DEFAULT_BIAS);
BIND_ENUM_CONSTANT(SPACE_PARAM_TEST_MOTION_MIN_CONTACT_DEPTH);
- BIND_ENUM_CONSTANT(SHAPE_LINE);
+ BIND_ENUM_CONSTANT(SHAPE_WORLD_MARGIN);
BIND_ENUM_CONSTANT(SHAPE_SEGMENT);
BIND_ENUM_CONSTANT(SHAPE_CIRCLE);
BIND_ENUM_CONSTANT(SHAPE_RECTANGLE);
diff --git a/servers/physics_server_2d.h b/servers/physics_server_2d.h
index dbbc128793..27bc654594 100644
--- a/servers/physics_server_2d.h
+++ b/servers/physics_server_2d.h
@@ -219,7 +219,7 @@ public:
static PhysicsServer2D *get_singleton();
enum ShapeType {
- SHAPE_LINE, ///< plane:"plane"
+ SHAPE_WORLD_MARGIN, ///< plane:"plane"
SHAPE_SEGMENT, ///< float:"length"
SHAPE_CIRCLE, ///< float:"radius"
SHAPE_RECTANGLE, ///< vec3:"extents"
@@ -229,7 +229,7 @@ public:
SHAPE_CUSTOM, ///< Server-Implementation based custom shape, calling shape_create() with this value will result in an error
};
- virtual RID line_shape_create() = 0;
+ virtual RID world_margin_shape_create() = 0;
virtual RID segment_shape_create() = 0;
virtual RID circle_shape_create() = 0;
virtual RID rectangle_shape_create() = 0;
diff --git a/servers/rendering/renderer_rd/effects_rd.cpp b/servers/rendering/renderer_rd/effects_rd.cpp
index c609f25e31..0af8f8bacf 100644
--- a/servers/rendering/renderer_rd/effects_rd.cpp
+++ b/servers/rendering/renderer_rd/effects_rd.cpp
@@ -928,7 +928,7 @@ void EffectsRD::luminance_reduction_raster(RID p_source_texture, const Size2i p_
}
}
-void EffectsRD::bokeh_dof(RID p_base_texture, RID p_depth_texture, const Size2i &p_base_texture_size, RID p_secondary_texture, RID p_halfsize_texture1, RID p_halfsize_texture2, bool p_dof_far, float p_dof_far_begin, float p_dof_far_size, bool p_dof_near, float p_dof_near_begin, float p_dof_near_size, float p_bokeh_size, RenderingServer::DOFBokehShape p_bokeh_shape, RS::DOFBlurQuality p_quality, bool p_use_jitter, float p_cam_znear, float p_cam_zfar, bool p_cam_orthogonal) {
+void EffectsRD::bokeh_dof(const BokehBuffers &p_buffers, bool p_dof_far, float p_dof_far_begin, float p_dof_far_size, bool p_dof_near, float p_dof_near_begin, float p_dof_near_size, float p_bokeh_size, RenderingServer::DOFBokehShape p_bokeh_shape, RS::DOFBlurQuality p_quality, bool p_use_jitter, float p_cam_znear, float p_cam_zfar, bool p_cam_orthogonal) {
ERR_FAIL_COND_MSG(prefer_raster_effects, "Can't use compute version of BOKEH DOF with the mobile renderer.");
bokeh.push_constant.blur_far_active = p_dof_far;
@@ -957,22 +957,22 @@ void EffectsRD::bokeh_dof(RID p_base_texture, RID p_depth_texture, const Size2i
// The alpha channel of the source color texture is filled with the expected circle size
// If used for DOF far, the size is positive, if used for near, its negative.
- RD::get_singleton()->compute_list_bind_compute_pipeline(compute_list, bokeh.pipelines[BOKEH_GEN_BLUR_SIZE]);
+ RD::get_singleton()->compute_list_bind_compute_pipeline(compute_list, bokeh.compute_pipelines[BOKEH_GEN_BLUR_SIZE]);
- RD::get_singleton()->compute_list_bind_uniform_set(compute_list, _get_uniform_set_from_image(p_base_texture), 0);
- RD::get_singleton()->compute_list_bind_uniform_set(compute_list, _get_compute_uniform_set_from_texture(p_depth_texture), 1);
+ RD::get_singleton()->compute_list_bind_uniform_set(compute_list, _get_uniform_set_from_image(p_buffers.base_texture), 0);
+ RD::get_singleton()->compute_list_bind_uniform_set(compute_list, _get_compute_uniform_set_from_texture(p_buffers.depth_texture), 1);
- bokeh.push_constant.size[0] = p_base_texture_size.x;
- bokeh.push_constant.size[1] = p_base_texture_size.y;
+ bokeh.push_constant.size[0] = p_buffers.base_texture_size.x;
+ bokeh.push_constant.size[1] = p_buffers.base_texture_size.y;
RD::get_singleton()->compute_list_set_push_constant(compute_list, &bokeh.push_constant, sizeof(BokehPushConstant));
- RD::get_singleton()->compute_list_dispatch_threads(compute_list, p_base_texture_size.x, p_base_texture_size.y, 1);
+ RD::get_singleton()->compute_list_dispatch_threads(compute_list, p_buffers.base_texture_size.x, p_buffers.base_texture_size.y, 1);
RD::get_singleton()->compute_list_add_barrier(compute_list);
if (p_bokeh_shape == RS::DOF_BOKEH_BOX || p_bokeh_shape == RS::DOF_BOKEH_HEXAGON) {
//second pass
- RD::get_singleton()->compute_list_bind_compute_pipeline(compute_list, bokeh.pipelines[p_bokeh_shape == RS::DOF_BOKEH_BOX ? BOKEH_GEN_BOKEH_BOX : BOKEH_GEN_BOKEH_HEXAGONAL]);
+ RD::get_singleton()->compute_list_bind_compute_pipeline(compute_list, bokeh.compute_pipelines[p_bokeh_shape == RS::DOF_BOKEH_BOX ? BOKEH_GEN_BOKEH_BOX : BOKEH_GEN_BOKEH_HEXAGONAL]);
static const int quality_samples[4] = { 6, 12, 12, 24 };
@@ -981,18 +981,18 @@ void EffectsRD::bokeh_dof(RID p_base_texture, RID p_depth_texture, const Size2i
if (p_quality == RS::DOF_BLUR_QUALITY_VERY_LOW || p_quality == RS::DOF_BLUR_QUALITY_LOW) {
//box and hexagon are more or less the same, and they can work in either half (very low and low quality) or full (medium and high quality_ sizes)
- RD::get_singleton()->compute_list_bind_uniform_set(compute_list, _get_uniform_set_from_image(p_halfsize_texture1), 0);
- RD::get_singleton()->compute_list_bind_uniform_set(compute_list, _get_compute_uniform_set_from_texture(p_base_texture), 1);
+ RD::get_singleton()->compute_list_bind_uniform_set(compute_list, _get_uniform_set_from_image(p_buffers.half_texture[0]), 0);
+ RD::get_singleton()->compute_list_bind_uniform_set(compute_list, _get_compute_uniform_set_from_texture(p_buffers.base_texture), 1);
- bokeh.push_constant.size[0] = p_base_texture_size.x >> 1;
- bokeh.push_constant.size[1] = p_base_texture_size.y >> 1;
+ bokeh.push_constant.size[0] = p_buffers.base_texture_size.x >> 1;
+ bokeh.push_constant.size[1] = p_buffers.base_texture_size.y >> 1;
bokeh.push_constant.half_size = true;
bokeh.push_constant.blur_size *= 0.5;
} else {
//medium and high quality use full size
- RD::get_singleton()->compute_list_bind_uniform_set(compute_list, _get_uniform_set_from_image(p_secondary_texture), 0);
- RD::get_singleton()->compute_list_bind_uniform_set(compute_list, _get_compute_uniform_set_from_texture(p_base_texture), 1);
+ RD::get_singleton()->compute_list_bind_uniform_set(compute_list, _get_uniform_set_from_image(p_buffers.secondary_texture), 0);
+ RD::get_singleton()->compute_list_bind_uniform_set(compute_list, _get_compute_uniform_set_from_texture(p_buffers.base_texture), 1);
}
RD::get_singleton()->compute_list_set_push_constant(compute_list, &bokeh.push_constant, sizeof(BokehPushConstant));
@@ -1004,11 +1004,11 @@ void EffectsRD::bokeh_dof(RID p_base_texture, RID p_depth_texture, const Size2i
bokeh.push_constant.second_pass = true;
if (p_quality == RS::DOF_BLUR_QUALITY_VERY_LOW || p_quality == RS::DOF_BLUR_QUALITY_LOW) {
- RD::get_singleton()->compute_list_bind_uniform_set(compute_list, _get_uniform_set_from_image(p_halfsize_texture2), 0);
- RD::get_singleton()->compute_list_bind_uniform_set(compute_list, _get_compute_uniform_set_from_texture(p_halfsize_texture1), 1);
+ RD::get_singleton()->compute_list_bind_uniform_set(compute_list, _get_uniform_set_from_image(p_buffers.half_texture[1]), 0);
+ RD::get_singleton()->compute_list_bind_uniform_set(compute_list, _get_compute_uniform_set_from_texture(p_buffers.half_texture[0]), 1);
} else {
- RD::get_singleton()->compute_list_bind_uniform_set(compute_list, _get_uniform_set_from_image(p_base_texture), 0);
- RD::get_singleton()->compute_list_bind_uniform_set(compute_list, _get_compute_uniform_set_from_texture(p_secondary_texture), 1);
+ RD::get_singleton()->compute_list_bind_uniform_set(compute_list, _get_uniform_set_from_image(p_buffers.base_texture), 0);
+ RD::get_singleton()->compute_list_bind_uniform_set(compute_list, _get_compute_uniform_set_from_texture(p_buffers.secondary_texture), 1);
}
RD::get_singleton()->compute_list_set_push_constant(compute_list, &bokeh.push_constant, sizeof(BokehPushConstant));
@@ -1019,25 +1019,25 @@ void EffectsRD::bokeh_dof(RID p_base_texture, RID p_depth_texture, const Size2i
if (p_quality == RS::DOF_BLUR_QUALITY_VERY_LOW || p_quality == RS::DOF_BLUR_QUALITY_LOW) {
//forth pass, upscale for low quality
- RD::get_singleton()->compute_list_bind_compute_pipeline(compute_list, bokeh.pipelines[BOKEH_COMPOSITE]);
+ RD::get_singleton()->compute_list_bind_compute_pipeline(compute_list, bokeh.compute_pipelines[BOKEH_COMPOSITE]);
- RD::get_singleton()->compute_list_bind_uniform_set(compute_list, _get_uniform_set_from_image(p_base_texture), 0);
- RD::get_singleton()->compute_list_bind_uniform_set(compute_list, _get_compute_uniform_set_from_texture(p_halfsize_texture2), 1);
+ RD::get_singleton()->compute_list_bind_uniform_set(compute_list, _get_uniform_set_from_image(p_buffers.base_texture), 0);
+ RD::get_singleton()->compute_list_bind_uniform_set(compute_list, _get_compute_uniform_set_from_texture(p_buffers.half_texture[1]), 1);
- bokeh.push_constant.size[0] = p_base_texture_size.x;
- bokeh.push_constant.size[1] = p_base_texture_size.y;
+ bokeh.push_constant.size[0] = p_buffers.base_texture_size.x;
+ bokeh.push_constant.size[1] = p_buffers.base_texture_size.y;
bokeh.push_constant.half_size = false;
bokeh.push_constant.second_pass = false;
RD::get_singleton()->compute_list_set_push_constant(compute_list, &bokeh.push_constant, sizeof(BokehPushConstant));
- RD::get_singleton()->compute_list_dispatch_threads(compute_list, p_base_texture_size.x, p_base_texture_size.y, 1);
+ RD::get_singleton()->compute_list_dispatch_threads(compute_list, p_buffers.base_texture_size.x, p_buffers.base_texture_size.y, 1);
}
} else {
//circle
//second pass
- RD::get_singleton()->compute_list_bind_compute_pipeline(compute_list, bokeh.pipelines[BOKEH_GEN_BOKEH_CIRCULAR]);
+ RD::get_singleton()->compute_list_bind_compute_pipeline(compute_list, bokeh.compute_pipelines[BOKEH_GEN_BOKEH_CIRCULAR]);
static const float quality_scale[4] = { 8.0, 4.0, 1.0, 0.5 };
@@ -1046,11 +1046,11 @@ void EffectsRD::bokeh_dof(RID p_base_texture, RID p_depth_texture, const Size2i
//circle always runs in half size, otherwise too expensive
- RD::get_singleton()->compute_list_bind_uniform_set(compute_list, _get_uniform_set_from_image(p_halfsize_texture1), 0);
- RD::get_singleton()->compute_list_bind_uniform_set(compute_list, _get_compute_uniform_set_from_texture(p_base_texture), 1);
+ RD::get_singleton()->compute_list_bind_uniform_set(compute_list, _get_uniform_set_from_image(p_buffers.half_texture[0]), 0);
+ RD::get_singleton()->compute_list_bind_uniform_set(compute_list, _get_compute_uniform_set_from_texture(p_buffers.base_texture), 1);
- bokeh.push_constant.size[0] = p_base_texture_size.x >> 1;
- bokeh.push_constant.size[1] = p_base_texture_size.y >> 1;
+ bokeh.push_constant.size[0] = p_buffers.base_texture_size.x >> 1;
+ bokeh.push_constant.size[1] = p_buffers.base_texture_size.y >> 1;
bokeh.push_constant.half_size = true;
RD::get_singleton()->compute_list_set_push_constant(compute_list, &bokeh.push_constant, sizeof(BokehPushConstant));
@@ -1062,93 +1062,195 @@ void EffectsRD::bokeh_dof(RID p_base_texture, RID p_depth_texture, const Size2i
// upscale
- RD::get_singleton()->compute_list_bind_compute_pipeline(compute_list, bokeh.pipelines[BOKEH_COMPOSITE]);
+ RD::get_singleton()->compute_list_bind_compute_pipeline(compute_list, bokeh.compute_pipelines[BOKEH_COMPOSITE]);
- RD::get_singleton()->compute_list_bind_uniform_set(compute_list, _get_uniform_set_from_image(p_base_texture), 0);
- RD::get_singleton()->compute_list_bind_uniform_set(compute_list, _get_compute_uniform_set_from_texture(p_halfsize_texture1), 1);
+ RD::get_singleton()->compute_list_bind_uniform_set(compute_list, _get_uniform_set_from_image(p_buffers.base_texture), 0);
+ RD::get_singleton()->compute_list_bind_uniform_set(compute_list, _get_compute_uniform_set_from_texture(p_buffers.half_texture[0]), 1);
- bokeh.push_constant.size[0] = p_base_texture_size.x;
- bokeh.push_constant.size[1] = p_base_texture_size.y;
+ bokeh.push_constant.size[0] = p_buffers.base_texture_size.x;
+ bokeh.push_constant.size[1] = p_buffers.base_texture_size.y;
bokeh.push_constant.half_size = false;
bokeh.push_constant.second_pass = false;
RD::get_singleton()->compute_list_set_push_constant(compute_list, &bokeh.push_constant, sizeof(BokehPushConstant));
- RD::get_singleton()->compute_list_dispatch_threads(compute_list, p_base_texture_size.x, p_base_texture_size.y, 1);
+ RD::get_singleton()->compute_list_dispatch_threads(compute_list, p_buffers.base_texture_size.x, p_buffers.base_texture_size.y, 1);
}
RD::get_singleton()->compute_list_end();
}
-void EffectsRD::blur_dof_raster(RID p_base_texture, RID p_depth_texture, const Size2i &p_base_texture_size, RID p_base_fb, RID p_secondary_texture, RID p_secondary_fb, bool p_dof_far, float p_dof_far_begin, float p_dof_far_size, bool p_dof_near, float p_dof_near_begin, float p_dof_near_size, float p_dof_blur_amount, RS::DOFBlurQuality p_quality, float p_cam_znear, float p_cam_zfar, bool p_cam_orthogonal) {
+void EffectsRD::bokeh_dof_raster(const BokehBuffers &p_buffers, bool p_dof_far, float p_dof_far_begin, float p_dof_far_size, bool p_dof_near, float p_dof_near_begin, float p_dof_near_size, float p_dof_blur_amount, RenderingServer::DOFBokehShape p_bokeh_shape, RS::DOFBlurQuality p_quality, float p_cam_znear, float p_cam_zfar, bool p_cam_orthogonal) {
ERR_FAIL_COND_MSG(!prefer_raster_effects, "Can't use blur DOF with the clustered renderer.");
- memset(&blur_raster.push_constant, 0, sizeof(BlurRasterPushConstant));
-
- BlurRasterMode blur_mode;
- int qsteps[4] = { 4, 4, 10, 20 };
- uint32_t base_flags = p_cam_orthogonal ? BLUR_FLAG_USE_ORTHOGONAL_PROJECTION : 0;
+ memset(&bokeh.push_constant, 0, sizeof(BokehPushConstant));
- Vector2 pixel_size = Vector2(1.0 / p_base_texture_size.width, 1.0 / p_base_texture_size.height);
+ bokeh.push_constant.orthogonal = p_cam_orthogonal;
+ bokeh.push_constant.size[0] = p_buffers.base_texture_size.width;
+ bokeh.push_constant.size[1] = p_buffers.base_texture_size.height;
+ bokeh.push_constant.z_far = p_cam_zfar;
+ bokeh.push_constant.z_near = p_cam_znear;
- blur_raster.push_constant.dof_radius = (p_dof_blur_amount * p_dof_blur_amount) / qsteps[p_quality];
- blur_raster.push_constant.pixel_size[0] = pixel_size.x;
- blur_raster.push_constant.pixel_size[1] = pixel_size.y;
- blur_raster.push_constant.camera_z_far = p_cam_zfar;
- blur_raster.push_constant.camera_z_near = p_cam_znear;
+ bokeh.push_constant.second_pass = false;
+ bokeh.push_constant.half_size = false;
+ bokeh.push_constant.blur_size = p_dof_blur_amount;
if (p_dof_far || p_dof_near) {
- if (p_quality == RS::DOF_BLUR_QUALITY_HIGH) {
- blur_mode = BLUR_MODE_DOF_HIGH;
- } else if (p_quality == RS::DOF_BLUR_QUALITY_MEDIUM) {
- blur_mode = BLUR_MODE_DOF_MEDIUM;
- } else { // for LOW or VERYLOW we use LOW
- blur_mode = BLUR_MODE_DOF_LOW;
- }
-
if (p_dof_far) {
- base_flags |= BLUR_FLAG_DOF_FAR;
- blur_raster.push_constant.dof_far_begin = p_dof_far_begin;
- blur_raster.push_constant.dof_far_end = p_dof_far_begin + p_dof_far_size;
+ bokeh.push_constant.blur_far_active = true;
+ bokeh.push_constant.blur_far_begin = p_dof_far_begin;
+ bokeh.push_constant.blur_far_end = p_dof_far_begin + p_dof_far_size;
}
if (p_dof_near) {
- base_flags |= BLUR_FLAG_DOF_NEAR;
- blur_raster.push_constant.dof_near_begin = p_dof_near_begin;
- blur_raster.push_constant.dof_near_end = p_dof_near_begin - p_dof_near_size;
+ bokeh.push_constant.blur_near_active = true;
+ bokeh.push_constant.blur_near_begin = p_dof_near_begin;
+ bokeh.push_constant.blur_near_end = p_dof_near_begin - p_dof_near_size;
}
- //HORIZONTAL
- RD::DrawListID draw_list = RD::get_singleton()->draw_list_begin(p_secondary_fb, RD::INITIAL_ACTION_KEEP, RD::FINAL_ACTION_READ, RD::INITIAL_ACTION_KEEP, RD::FINAL_ACTION_DISCARD);
- RD::get_singleton()->draw_list_bind_render_pipeline(draw_list, blur_raster.pipelines[blur_mode].get_render_pipeline(RD::INVALID_ID, RD::get_singleton()->framebuffer_get_format(p_secondary_fb)));
- RD::get_singleton()->draw_list_bind_uniform_set(draw_list, _get_uniform_set_from_texture(p_base_texture), 0);
- RD::get_singleton()->draw_list_bind_uniform_set(draw_list, _get_uniform_set_from_texture(p_depth_texture), 1);
- RD::get_singleton()->draw_list_bind_index_array(draw_list, index_array);
+ {
+ // generate our depth data
+ RID framebuffer = p_buffers.base_weight_fb;
+ RD::DrawListID draw_list = RD::get_singleton()->draw_list_begin(framebuffer, RD::INITIAL_ACTION_KEEP, RD::FINAL_ACTION_READ, RD::INITIAL_ACTION_KEEP, RD::FINAL_ACTION_DISCARD);
+ RD::get_singleton()->draw_list_bind_render_pipeline(draw_list, bokeh.raster_pipelines[BOKEH_GEN_BLUR_SIZE].get_render_pipeline(RD::INVALID_ID, RD::get_singleton()->framebuffer_get_format(framebuffer)));
+ RD::get_singleton()->draw_list_bind_uniform_set(draw_list, _get_uniform_set_from_texture(p_buffers.depth_texture), 0);
+ RD::get_singleton()->draw_list_bind_index_array(draw_list, index_array);
- blur_raster.push_constant.flags = base_flags | BLUR_FLAG_HORIZONTAL;
- blur_raster.push_constant.dof_dir[0] = 1.0;
- blur_raster.push_constant.dof_dir[1] = 0.0;
+ RD::get_singleton()->draw_list_set_push_constant(draw_list, &bokeh.push_constant, sizeof(BokehPushConstant));
- RD::get_singleton()->draw_list_set_push_constant(draw_list, &blur_raster.push_constant, sizeof(BlurRasterPushConstant));
+ RD::get_singleton()->draw_list_draw(draw_list, true);
+ RD::get_singleton()->draw_list_end();
+ }
- RD::get_singleton()->draw_list_draw(draw_list, true);
- RD::get_singleton()->draw_list_end();
+ if (p_bokeh_shape == RS::DOF_BOKEH_BOX || p_bokeh_shape == RS::DOF_BOKEH_HEXAGON) {
+ // double pass approach
+ BokehMode mode = p_bokeh_shape == RS::DOF_BOKEH_BOX ? BOKEH_GEN_BOKEH_BOX : BOKEH_GEN_BOKEH_HEXAGONAL;
- //VERTICAL
- draw_list = RD::get_singleton()->draw_list_begin(p_base_fb, RD::INITIAL_ACTION_KEEP, RD::FINAL_ACTION_READ, RD::INITIAL_ACTION_KEEP, RD::FINAL_ACTION_DISCARD);
- RD::get_singleton()->draw_list_bind_render_pipeline(draw_list, blur_raster.pipelines[blur_mode].get_render_pipeline(RD::INVALID_ID, RD::get_singleton()->framebuffer_get_format(p_base_fb)));
- RD::get_singleton()->draw_list_bind_uniform_set(draw_list, _get_uniform_set_from_texture(p_secondary_texture), 0);
- RD::get_singleton()->draw_list_bind_uniform_set(draw_list, _get_uniform_set_from_texture(p_depth_texture), 1);
- RD::get_singleton()->draw_list_bind_index_array(draw_list, index_array);
+ if (p_quality == RS::DOF_BLUR_QUALITY_VERY_LOW || p_quality == RS::DOF_BLUR_QUALITY_LOW) {
+ //box and hexagon are more or less the same, and they can work in either half (very low and low quality) or full (medium and high quality_ sizes)
+ bokeh.push_constant.size[0] = p_buffers.base_texture_size.x >> 1;
+ bokeh.push_constant.size[1] = p_buffers.base_texture_size.y >> 1;
+ bokeh.push_constant.half_size = true;
+ bokeh.push_constant.blur_size *= 0.5;
+ }
- blur_raster.push_constant.flags = base_flags;
- blur_raster.push_constant.dof_dir[0] = 0.0;
- blur_raster.push_constant.dof_dir[1] = 1.0;
+ static const int quality_samples[4] = { 6, 12, 12, 24 };
+ bokeh.push_constant.blur_scale = 0.5;
+ bokeh.push_constant.steps = quality_samples[p_quality];
- RD::get_singleton()->draw_list_set_push_constant(draw_list, &blur_raster.push_constant, sizeof(BlurRasterPushConstant));
+ RID framebuffer = bokeh.push_constant.half_size ? p_buffers.half_fb[0] : p_buffers.secondary_fb;
- RD::get_singleton()->draw_list_draw(draw_list, true);
- RD::get_singleton()->draw_list_end();
+ // Pass 1
+ RD::DrawListID draw_list = RD::get_singleton()->draw_list_begin(framebuffer, RD::INITIAL_ACTION_KEEP, RD::FINAL_ACTION_READ, RD::INITIAL_ACTION_KEEP, RD::FINAL_ACTION_DISCARD);
+ RD::get_singleton()->draw_list_bind_render_pipeline(draw_list, bokeh.raster_pipelines[mode].get_render_pipeline(RD::INVALID_ID, RD::get_singleton()->framebuffer_get_format(framebuffer)));
+ RD::get_singleton()->draw_list_bind_uniform_set(draw_list, _get_uniform_set_from_texture(p_buffers.base_texture), 0);
+ RD::get_singleton()->draw_list_bind_uniform_set(draw_list, _get_uniform_set_from_texture(p_buffers.weight_texture[0]), 1);
+ RD::get_singleton()->draw_list_bind_index_array(draw_list, index_array);
+
+ RD::get_singleton()->draw_list_set_push_constant(draw_list, &bokeh.push_constant, sizeof(BokehPushConstant));
+
+ RD::get_singleton()->draw_list_draw(draw_list, true);
+ RD::get_singleton()->draw_list_end();
+
+ // Pass 2
+ if (!bokeh.push_constant.half_size) {
+ // do not output weight, we're writing back into our base buffer
+ mode = p_bokeh_shape == RS::DOF_BOKEH_BOX ? BOKEH_GEN_BOKEH_BOX_NOWEIGHT : BOKEH_GEN_BOKEH_HEXAGONAL_NOWEIGHT;
+ }
+ bokeh.push_constant.second_pass = true;
+
+ framebuffer = bokeh.push_constant.half_size ? p_buffers.half_fb[1] : p_buffers.base_fb;
+ RID texture = bokeh.push_constant.half_size ? p_buffers.half_texture[0] : p_buffers.secondary_texture;
+ RID weight = bokeh.push_constant.half_size ? p_buffers.weight_texture[2] : p_buffers.weight_texture[1];
+
+ draw_list = RD::get_singleton()->draw_list_begin(framebuffer, RD::INITIAL_ACTION_KEEP, RD::FINAL_ACTION_READ, RD::INITIAL_ACTION_KEEP, RD::FINAL_ACTION_DISCARD);
+ RD::get_singleton()->draw_list_bind_render_pipeline(draw_list, bokeh.raster_pipelines[mode].get_render_pipeline(RD::INVALID_ID, RD::get_singleton()->framebuffer_get_format(framebuffer)));
+ RD::get_singleton()->draw_list_bind_uniform_set(draw_list, _get_uniform_set_from_texture(texture), 0);
+ RD::get_singleton()->draw_list_bind_uniform_set(draw_list, _get_uniform_set_from_texture(weight), 1);
+ RD::get_singleton()->draw_list_bind_index_array(draw_list, index_array);
+
+ RD::get_singleton()->draw_list_set_push_constant(draw_list, &bokeh.push_constant, sizeof(BokehPushConstant));
+
+ RD::get_singleton()->draw_list_draw(draw_list, true);
+ RD::get_singleton()->draw_list_end();
+
+ if (bokeh.push_constant.half_size) {
+ // Compose pass
+ mode = BOKEH_COMPOSITE;
+ framebuffer = p_buffers.base_fb;
+
+ draw_list = RD::get_singleton()->draw_list_begin(framebuffer, RD::INITIAL_ACTION_KEEP, RD::FINAL_ACTION_READ, RD::INITIAL_ACTION_KEEP, RD::FINAL_ACTION_DISCARD);
+ RD::get_singleton()->draw_list_bind_render_pipeline(draw_list, bokeh.raster_pipelines[mode].get_render_pipeline(RD::INVALID_ID, RD::get_singleton()->framebuffer_get_format(framebuffer)));
+ RD::get_singleton()->draw_list_bind_uniform_set(draw_list, _get_uniform_set_from_texture(p_buffers.half_texture[1]), 0);
+ RD::get_singleton()->draw_list_bind_uniform_set(draw_list, _get_uniform_set_from_texture(p_buffers.weight_texture[3]), 1);
+ RD::get_singleton()->draw_list_bind_uniform_set(draw_list, _get_uniform_set_from_texture(p_buffers.weight_texture[0]), 2);
+ RD::get_singleton()->draw_list_bind_index_array(draw_list, index_array);
+
+ RD::get_singleton()->draw_list_set_push_constant(draw_list, &bokeh.push_constant, sizeof(BokehPushConstant));
+
+ RD::get_singleton()->draw_list_draw(draw_list, true);
+ RD::get_singleton()->draw_list_end();
+ }
+
+ } else {
+ // circular is a single pass approach
+ BokehMode mode = BOKEH_GEN_BOKEH_CIRCULAR;
+
+ {
+ // circle always runs in half size, otherwise too expensive (though the code below does support making this optional)
+ bokeh.push_constant.size[0] = p_buffers.base_texture_size.x >> 1;
+ bokeh.push_constant.size[1] = p_buffers.base_texture_size.y >> 1;
+ bokeh.push_constant.half_size = true;
+ // bokeh.push_constant.blur_size *= 0.5;
+ }
+
+ static const float quality_scale[4] = { 8.0, 4.0, 1.0, 0.5 };
+ bokeh.push_constant.blur_scale = quality_scale[p_quality];
+ bokeh.push_constant.steps = 0.0;
+
+ RID framebuffer = bokeh.push_constant.half_size ? p_buffers.half_fb[0] : p_buffers.secondary_fb;
+
+ RD::DrawListID draw_list = RD::get_singleton()->draw_list_begin(framebuffer, RD::INITIAL_ACTION_KEEP, RD::FINAL_ACTION_READ, RD::INITIAL_ACTION_KEEP, RD::FINAL_ACTION_DISCARD);
+ RD::get_singleton()->draw_list_bind_render_pipeline(draw_list, bokeh.raster_pipelines[mode].get_render_pipeline(RD::INVALID_ID, RD::get_singleton()->framebuffer_get_format(framebuffer)));
+ RD::get_singleton()->draw_list_bind_uniform_set(draw_list, _get_uniform_set_from_texture(p_buffers.base_texture), 0);
+ RD::get_singleton()->draw_list_bind_uniform_set(draw_list, _get_uniform_set_from_texture(p_buffers.weight_texture[0]), 1);
+ RD::get_singleton()->draw_list_bind_index_array(draw_list, index_array);
+
+ RD::get_singleton()->draw_list_set_push_constant(draw_list, &bokeh.push_constant, sizeof(BokehPushConstant));
+
+ RD::get_singleton()->draw_list_draw(draw_list, true);
+ RD::get_singleton()->draw_list_end();
+
+ if (bokeh.push_constant.half_size) {
+ // Compose
+ mode = BOKEH_COMPOSITE;
+ framebuffer = p_buffers.base_fb;
+
+ draw_list = RD::get_singleton()->draw_list_begin(framebuffer, RD::INITIAL_ACTION_KEEP, RD::FINAL_ACTION_READ, RD::INITIAL_ACTION_KEEP, RD::FINAL_ACTION_DISCARD);
+ RD::get_singleton()->draw_list_bind_render_pipeline(draw_list, bokeh.raster_pipelines[mode].get_render_pipeline(RD::INVALID_ID, RD::get_singleton()->framebuffer_get_format(framebuffer)));
+ RD::get_singleton()->draw_list_bind_uniform_set(draw_list, _get_uniform_set_from_texture(p_buffers.half_texture[0]), 0);
+ RD::get_singleton()->draw_list_bind_uniform_set(draw_list, _get_uniform_set_from_texture(p_buffers.weight_texture[2]), 1);
+ RD::get_singleton()->draw_list_bind_uniform_set(draw_list, _get_uniform_set_from_texture(p_buffers.weight_texture[0]), 2);
+ RD::get_singleton()->draw_list_bind_index_array(draw_list, index_array);
+
+ RD::get_singleton()->draw_list_set_push_constant(draw_list, &bokeh.push_constant, sizeof(BokehPushConstant));
+
+ RD::get_singleton()->draw_list_draw(draw_list, true);
+ RD::get_singleton()->draw_list_end();
+ } else {
+ // Just copy it back (we use our blur raster shader here)..
+ draw_list = RD::get_singleton()->draw_list_begin(p_buffers.base_fb, RD::INITIAL_ACTION_KEEP, RD::FINAL_ACTION_READ, RD::INITIAL_ACTION_KEEP, RD::FINAL_ACTION_DISCARD);
+ RD::get_singleton()->draw_list_bind_render_pipeline(draw_list, blur_raster.pipelines[BLUR_MODE_COPY].get_render_pipeline(RD::INVALID_ID, RD::get_singleton()->framebuffer_get_format(p_buffers.base_fb)));
+ RD::get_singleton()->draw_list_bind_uniform_set(draw_list, _get_uniform_set_from_texture(p_buffers.secondary_texture), 0);
+ RD::get_singleton()->draw_list_bind_index_array(draw_list, index_array);
+
+ memset(&blur_raster.push_constant, 0, sizeof(BlurRasterPushConstant));
+ RD::get_singleton()->draw_list_set_push_constant(draw_list, &blur_raster.push_constant, sizeof(BlurRasterPushConstant));
+
+ RD::get_singleton()->draw_list_draw(draw_list, true);
+ RD::get_singleton()->draw_list_end();
+ }
+ }
}
}
@@ -1774,9 +1876,7 @@ EffectsRD::EffectsRD(bool p_prefer_raster_effects) {
blur_modes.push_back("\n#define MODE_GAUSSIAN_BLUR\n"); // BLUR_MODE_GAUSSIAN_BLUR
blur_modes.push_back("\n#define MODE_GAUSSIAN_GLOW\n"); // BLUR_MODE_GAUSSIAN_GLOW
blur_modes.push_back("\n#define MODE_GAUSSIAN_GLOW\n#define GLOW_USE_AUTO_EXPOSURE\n"); // BLUR_MODE_GAUSSIAN_GLOW_AUTO_EXPOSURE
- blur_modes.push_back("\n#define MODE_DOF_BLUR\n#define DOF_QUALITY_LOW\n"); // BLUR_MODE_DOF_LOW
- blur_modes.push_back("\n#define MODE_DOF_BLUR\n#define DOF_QUALITY_MEDIUM\n"); // BLUR_MODE_DOF_MEDIUM
- blur_modes.push_back("\n#define MODE_DOF_BLUR\n#define DOF_QUALITY_HIGH\n"); // BLUR_MODE_DOF_HIGH
+ blur_modes.push_back("\n#define MODE_COPY\n"); // BLUR_MODE_COPY
blur_raster.shader.initialize(blur_modes);
memset(&blur_raster.push_constant, 0, sizeof(BlurRasterPushConstant));
@@ -1956,23 +2056,40 @@ EffectsRD::EffectsRD(bool p_prefer_raster_effects) {
cube_to_dp.pipeline.setup(shader, RD::RENDER_PRIMITIVE_TRIANGLES, RD::PipelineRasterizationState(), RD::PipelineMultisampleState(), dss, RD::PipelineColorBlendState(), 0);
}
+ // Initialize bokeh
+ Vector<String> bokeh_modes;
+ bokeh_modes.push_back("\n#define MODE_GEN_BLUR_SIZE\n");
+ bokeh_modes.push_back("\n#define MODE_BOKEH_BOX\n#define OUTPUT_WEIGHT\n");
+ bokeh_modes.push_back("\n#define MODE_BOKEH_BOX\n");
+ bokeh_modes.push_back("\n#define MODE_BOKEH_HEXAGONAL\n#define OUTPUT_WEIGHT\n");
+ bokeh_modes.push_back("\n#define MODE_BOKEH_HEXAGONAL\n");
+ bokeh_modes.push_back("\n#define MODE_BOKEH_CIRCULAR\n#define OUTPUT_WEIGHT\n");
+ bokeh_modes.push_back("\n#define MODE_COMPOSITE_BOKEH\n");
if (prefer_raster_effects) {
- // not supported
+ bokeh.raster_shader.initialize(bokeh_modes);
+
+ bokeh.shader_version = bokeh.raster_shader.version_create();
+
+ const int att_count[BOKEH_MAX] = { 1, 2, 1, 2, 1, 2, 1 };
+ for (int i = 0; i < BOKEH_MAX; i++) {
+ RD::PipelineColorBlendState blend_state = (i == BOKEH_COMPOSITE) ? RD::PipelineColorBlendState::create_blend(att_count[i]) : RD::PipelineColorBlendState::create_disabled(att_count[i]);
+ bokeh.raster_pipelines[i].setup(bokeh.raster_shader.version_get_shader(bokeh.shader_version, i), RD::RENDER_PRIMITIVE_TRIANGLES, RD::PipelineRasterizationState(), RD::PipelineMultisampleState(), RD::PipelineDepthStencilState(), blend_state, 0);
+ }
} else {
- // Initialize bokeh
- Vector<String> bokeh_modes;
- bokeh_modes.push_back("\n#define MODE_GEN_BLUR_SIZE\n");
- bokeh_modes.push_back("\n#define MODE_BOKEH_BOX\n");
- bokeh_modes.push_back("\n#define MODE_BOKEH_HEXAGONAL\n");
- bokeh_modes.push_back("\n#define MODE_BOKEH_CIRCULAR\n");
- bokeh_modes.push_back("\n#define MODE_COMPOSITE_BOKEH\n");
+ bokeh.compute_shader.initialize(bokeh_modes);
- bokeh.shader.initialize(bokeh_modes);
+ bokeh.shader_version = bokeh.compute_shader.version_create();
+ bokeh.compute_shader.set_variant_enabled(BOKEH_GEN_BOKEH_BOX_NOWEIGHT, false);
+ bokeh.compute_shader.set_variant_enabled(BOKEH_GEN_BOKEH_HEXAGONAL_NOWEIGHT, false);
- bokeh.shader_version = bokeh.shader.version_create();
+ for (int i = 0; i < BOKEH_MAX; i++) {
+ if (bokeh.compute_shader.is_variant_enabled(i)) {
+ bokeh.compute_pipelines[i] = RD::get_singleton()->compute_pipeline_create(bokeh.compute_shader.version_get_shader(bokeh.shader_version, i));
+ }
+ }
for (int i = 0; i < BOKEH_MAX; i++) {
- bokeh.pipelines[i] = RD::get_singleton()->compute_pipeline_create(bokeh.shader.version_get_shader(bokeh.shader_version, i));
+ bokeh.raster_pipelines[i].clear();
}
}
@@ -2173,12 +2290,13 @@ EffectsRD::EffectsRD(bool p_prefer_raster_effects) {
if (prefer_raster_effects) {
filter.raster_shader.initialize(cubemap_filter_modes);
- filter.shader_version = filter.raster_shader.version_create();
// array variants are not supported in raster
filter.raster_shader.set_variant_enabled(FILTER_MODE_HIGH_QUALITY_ARRAY, false);
filter.raster_shader.set_variant_enabled(FILTER_MODE_LOW_QUALITY_ARRAY, false);
+ filter.shader_version = filter.raster_shader.version_create();
+
for (int i = 0; i < FILTER_MODE_MAX; i++) {
if (filter.raster_shader.is_variant_enabled(i)) {
filter.raster_pipelines[i].setup(filter.raster_shader.version_get_shader(filter.shader_version, i), RD::RENDER_PRIMITIVE_TRIANGLES, RD::PipelineRasterizationState(), RD::PipelineMultisampleState(), RD::PipelineDepthStencilState(), RD::PipelineColorBlendState::create_disabled(), 0);
@@ -2390,12 +2508,13 @@ EffectsRD::~EffectsRD() {
if (prefer_raster_effects) {
blur_raster.shader.version_free(blur_raster.shader_version);
+ bokeh.raster_shader.version_free(blur_raster.shader_version);
luminance_reduce_raster.shader.version_free(luminance_reduce_raster.shader_version);
roughness.raster_shader.version_free(roughness.shader_version);
cubemap_downsampler.raster_shader.version_free(cubemap_downsampler.shader_version);
filter.raster_shader.version_free(filter.shader_version);
} else {
- bokeh.shader.version_free(bokeh.shader_version);
+ bokeh.compute_shader.version_free(bokeh.shader_version);
luminance_reduce.shader.version_free(luminance_reduce.shader_version);
roughness.compute_shader.version_free(roughness.shader_version);
cubemap_downsampler.compute_shader.version_free(cubemap_downsampler.shader_version);
diff --git a/servers/rendering/renderer_rd/effects_rd.h b/servers/rendering/renderer_rd/effects_rd.h
index 79d9a8b738..fc14050ccb 100644
--- a/servers/rendering/renderer_rd/effects_rd.h
+++ b/servers/rendering/renderer_rd/effects_rd.h
@@ -35,6 +35,7 @@
#include "servers/rendering/renderer_rd/pipeline_cache_rd.h"
#include "servers/rendering/renderer_rd/shaders/blur_raster.glsl.gen.h"
#include "servers/rendering/renderer_rd/shaders/bokeh_dof.glsl.gen.h"
+#include "servers/rendering/renderer_rd/shaders/bokeh_dof_raster.glsl.gen.h"
#include "servers/rendering/renderer_rd/shaders/copy.glsl.gen.h"
#include "servers/rendering/renderer_rd/shaders/copy_to_fb.glsl.gen.h"
#include "servers/rendering/renderer_rd/shaders/cube_to_dp.glsl.gen.h"
@@ -72,10 +73,7 @@ private:
BLUR_MODE_GAUSSIAN_BLUR,
BLUR_MODE_GAUSSIAN_GLOW,
BLUR_MODE_GAUSSIAN_GLOW_AUTO_EXPOSURE,
-
- BLUR_MODE_DOF_LOW,
- BLUR_MODE_DOF_MEDIUM,
- BLUR_MODE_DOF_HIGH,
+ BLUR_MODE_COPY,
BLUR_MODE_MAX
};
@@ -84,8 +82,6 @@ private:
BLUR_FLAG_HORIZONTAL = (1 << 0),
BLUR_FLAG_USE_ORTHOGONAL_PROJECTION = (1 << 1),
BLUR_FLAG_GLOW_FIRST_PASS = (1 << 2),
- BLUR_FLAG_DOF_FAR = (1 << 3),
- BLUR_FLAG_DOF_NEAR = (1 << 4),
};
struct BlurRasterPushConstant {
@@ -103,19 +99,6 @@ private:
float glow_white;
float glow_luminance_cap;
float glow_auto_exposure_grey;
-
- //dof
- float dof_far_begin;
- float dof_far_end;
- float dof_near_begin;
- float dof_near_end;
-
- float dof_radius;
- float dof_pad[3];
-
- float dof_dir[2];
- float camera_z_far;
- float camera_z_near;
};
struct BlurRaster {
@@ -252,29 +235,29 @@ private:
};
struct TonemapPushConstant {
- float bcs[3];
- uint32_t use_bcs;
+ float bcs[3]; // 12 - 12
+ uint32_t use_bcs; // 4 - 16
- uint32_t use_glow;
- uint32_t use_auto_exposure;
- uint32_t use_color_correction;
- uint32_t tonemapper;
+ uint32_t use_glow; // 4 - 20
+ uint32_t use_auto_exposure; // 4 - 24
+ uint32_t use_color_correction; // 4 - 28
+ uint32_t tonemapper; // 4 - 32
- uint32_t glow_texture_size[2];
- float glow_intensity;
- uint32_t pad3;
+ uint32_t glow_texture_size[2]; // 8 - 40
+ float glow_intensity; // 4 - 44
+ uint32_t pad3; // 4 - 48
- uint32_t glow_mode;
- float glow_levels[7];
+ uint32_t glow_mode; // 4 - 52
+ float glow_levels[7]; // 28 - 80
- float exposure;
- float white;
- float auto_exposure_grey;
- uint32_t pad2;
+ float exposure; // 4 - 84
+ float white; // 4 - 88
+ float auto_exposure_grey; // 4 - 92
+ uint32_t pad2; // 4 - 96
- float pixel_size[2];
- uint32_t use_fxaa;
- uint32_t use_debanding;
+ float pixel_size[2]; // 8 - 104
+ uint32_t use_fxaa; // 4 - 108
+ uint32_t use_debanding; // 4 - 112
};
/* tonemap actually writes to a framebuffer, which is
@@ -375,7 +358,9 @@ private:
enum BokehMode {
BOKEH_GEN_BLUR_SIZE,
BOKEH_GEN_BOKEH_BOX,
+ BOKEH_GEN_BOKEH_BOX_NOWEIGHT,
BOKEH_GEN_BOKEH_HEXAGONAL,
+ BOKEH_GEN_BOKEH_HEXAGONAL_NOWEIGHT,
BOKEH_GEN_BOKEH_CIRCULAR,
BOKEH_COMPOSITE,
BOKEH_MAX
@@ -383,9 +368,11 @@ private:
struct Bokeh {
BokehPushConstant push_constant;
- BokehDofShaderRD shader;
+ BokehDofShaderRD compute_shader;
+ BokehDofRasterShaderRD raster_shader;
RID shader_version;
- RID pipelines[BOKEH_MAX];
+ RID compute_pipelines[BOKEH_MAX];
+ PipelineCacheRD raster_pipelines[BOKEH_MAX];
} bokeh;
enum SSAOMode {
@@ -784,8 +771,26 @@ public:
void luminance_reduction(RID p_source_texture, const Size2i p_source_size, const Vector<RID> p_reduce, RID p_prev_luminance, float p_min_luminance, float p_max_luminance, float p_adjust, bool p_set = false);
void luminance_reduction_raster(RID p_source_texture, const Size2i p_source_size, const Vector<RID> p_reduce, Vector<RID> p_fb, RID p_prev_luminance, float p_min_luminance, float p_max_luminance, float p_adjust, bool p_set = false);
- void bokeh_dof(RID p_base_texture, RID p_depth_texture, const Size2i &p_base_texture_size, RID p_secondary_texture, RID p_bokeh_texture1, RID p_bokeh_texture2, bool p_dof_far, float p_dof_far_begin, float p_dof_far_size, bool p_dof_near, float p_dof_near_begin, float p_dof_near_size, float p_bokeh_size, RS::DOFBokehShape p_bokeh_shape, RS::DOFBlurQuality p_quality, bool p_use_jitter, float p_cam_znear, float p_cam_zfar, bool p_cam_orthogonal);
- void blur_dof_raster(RID p_base_texture, RID p_depth_texture, const Size2i &p_base_texture_size, RID p_base_fb, RID p_secondary_texture, RID p_secondary_fb, bool p_dof_far, float p_dof_far_begin, float p_dof_far_size, bool p_dof_near, float p_dof_near_begin, float p_dof_near_size, float p_dof_blur_amount, RS::DOFBlurQuality p_quality, float p_cam_znear, float p_cam_zfar, bool p_cam_orthogonal);
+ struct BokehBuffers {
+ // bokeh buffers
+
+ // textures
+ Size2i base_texture_size;
+ RID base_texture;
+ RID depth_texture;
+ RID secondary_texture;
+ RID half_texture[2];
+
+ // raster only
+ RID base_fb;
+ RID secondary_fb; // with weights
+ RID half_fb[2]; // with weights
+ RID base_weight_fb;
+ RID weight_texture[4];
+ };
+
+ void bokeh_dof(const BokehBuffers &p_buffers, bool p_dof_far, float p_dof_far_begin, float p_dof_far_size, bool p_dof_near, float p_dof_near_begin, float p_dof_near_size, float p_bokeh_size, RS::DOFBokehShape p_bokeh_shape, RS::DOFBlurQuality p_quality, bool p_use_jitter, float p_cam_znear, float p_cam_zfar, bool p_cam_orthogonal);
+ void bokeh_dof_raster(const BokehBuffers &p_buffers, bool p_dof_far, float p_dof_far_begin, float p_dof_far_size, bool p_dof_near, float p_dof_near_begin, float p_dof_near_size, float p_dof_blur_amount, RenderingServer::DOFBokehShape p_bokeh_shape, RS::DOFBlurQuality p_quality, float p_cam_znear, float p_cam_zfar, bool p_cam_orthogonal);
struct TonemapSettings {
bool use_glow = false;
diff --git a/servers/rendering/renderer_rd/renderer_scene_render_rd.cpp b/servers/rendering/renderer_rd/renderer_scene_render_rd.cpp
index fd797b1cab..06e5ff4a0b 100644
--- a/servers/rendering/renderer_rd/renderer_scene_render_rd.cpp
+++ b/servers/rendering/renderer_rd/renderer_scene_render_rd.cpp
@@ -1464,6 +1464,53 @@ void RendererSceneRenderRD::_allocate_blur_textures(RenderBuffers *rb) {
base_width = MAX(1, base_width >> 1);
base_height = MAX(1, base_height >> 1);
}
+
+ if (!_render_buffers_can_be_storage()) {
+ // create 4 weight textures, 2 full size, 2 half size
+
+ tf.format = RD::DATA_FORMAT_R16_SFLOAT; // We could probably use DATA_FORMAT_R8_SNORM if we don't pre-multiply by blur_size but that depends on whether we can remove DEPTH_GAP
+ tf.width = rb->width;
+ tf.height = rb->height;
+ tf.texture_type = rb->view_count > 1 ? RD::TEXTURE_TYPE_2D_ARRAY : RD::TEXTURE_TYPE_2D;
+ tf.array_layers = rb->view_count;
+ tf.usage_bits = RD::TEXTURE_USAGE_SAMPLING_BIT | RD::TEXTURE_USAGE_CAN_COPY_TO_BIT | RD::TEXTURE_USAGE_COLOR_ATTACHMENT_BIT;
+ tf.mipmaps = 1;
+ for (uint32_t i = 0; i < 4; i++) {
+ // associated blur texture
+ RID texture;
+ if (i == 0) {
+ texture = rb->texture;
+ } else if (i == 1) {
+ texture = rb->blur[0].mipmaps[0].texture;
+ } else if (i == 2) {
+ texture = rb->blur[1].mipmaps[0].texture;
+ } else if (i == 3) {
+ texture = rb->blur[0].mipmaps[1].texture;
+ }
+
+ // create weight texture
+ rb->weight_buffers[i].weight = RD::get_singleton()->texture_create(tf, RD::TextureView());
+
+ // create frame buffer
+ Vector<RID> fb;
+ fb.push_back(texture);
+ fb.push_back(rb->weight_buffers[i].weight);
+ rb->weight_buffers[i].fb = RD::get_singleton()->framebuffer_create(fb);
+
+ if (i == 1) {
+ // next 2 are half size
+ tf.width = MAX(1, tf.width >> 1);
+ tf.height = MAX(1, tf.height >> 1);
+ }
+ }
+
+ {
+ // and finally an FB for just our base weights
+ Vector<RID> fb;
+ fb.push_back(rb->weight_buffers[0].weight);
+ rb->base_weight_fb = RD::get_singleton()->framebuffer_create(fb);
+ }
+ }
}
void RendererSceneRenderRD::_allocate_luminance_textures(RenderBuffers *rb) {
@@ -1851,11 +1898,34 @@ void RendererSceneRenderRD::_render_buffers_post_process_and_tonemap(const Rende
_allocate_blur_textures(rb);
}
+ EffectsRD::BokehBuffers buffers;
+
+ // textures we use
+ buffers.base_texture_size = Size2i(rb->width, rb->height);
+ buffers.base_texture = rb->texture;
+ buffers.depth_texture = rb->depth_texture;
+ buffers.secondary_texture = rb->blur[0].mipmaps[0].texture;
+ buffers.half_texture[0] = rb->blur[1].mipmaps[0].texture;
+ buffers.half_texture[1] = rb->blur[0].mipmaps[1].texture;
+
+ float bokeh_size = camfx->dof_blur_amount * 64.0;
if (can_use_storage) {
- float bokeh_size = camfx->dof_blur_amount * 64.0;
- storage->get_effects()->bokeh_dof(rb->texture, rb->depth_texture, Size2i(rb->width, rb->height), rb->blur[0].mipmaps[0].texture, rb->blur[1].mipmaps[0].texture, rb->blur[0].mipmaps[1].texture, camfx->dof_blur_far_enabled, camfx->dof_blur_far_distance, camfx->dof_blur_far_transition, camfx->dof_blur_near_enabled, camfx->dof_blur_near_distance, camfx->dof_blur_near_transition, bokeh_size, dof_blur_bokeh_shape, dof_blur_quality, dof_blur_use_jitter, p_render_data->z_near, p_render_data->z_far, p_render_data->cam_ortogonal);
+ storage->get_effects()->bokeh_dof(buffers, camfx->dof_blur_far_enabled, camfx->dof_blur_far_distance, camfx->dof_blur_far_transition, camfx->dof_blur_near_enabled, camfx->dof_blur_near_distance, camfx->dof_blur_near_transition, bokeh_size, dof_blur_bokeh_shape, dof_blur_quality, dof_blur_use_jitter, p_render_data->z_near, p_render_data->z_far, p_render_data->cam_ortogonal);
} else {
- storage->get_effects()->blur_dof_raster(rb->texture, rb->depth_texture, Size2i(rb->width, rb->height), rb->texture_fb, rb->blur[0].mipmaps[0].texture, rb->blur[0].mipmaps[0].fb, camfx->dof_blur_far_enabled, camfx->dof_blur_far_distance, camfx->dof_blur_far_transition, camfx->dof_blur_near_enabled, camfx->dof_blur_near_distance, camfx->dof_blur_near_transition, camfx->dof_blur_amount, dof_blur_quality, p_render_data->z_near, p_render_data->z_far, p_render_data->cam_ortogonal);
+ // set framebuffers
+ buffers.base_fb = rb->texture_fb;
+ buffers.secondary_fb = rb->weight_buffers[1].fb;
+ buffers.half_fb[0] = rb->weight_buffers[2].fb;
+ buffers.half_fb[1] = rb->weight_buffers[3].fb;
+ buffers.weight_texture[0] = rb->weight_buffers[0].weight;
+ buffers.weight_texture[1] = rb->weight_buffers[1].weight;
+ buffers.weight_texture[2] = rb->weight_buffers[2].weight;
+ buffers.weight_texture[3] = rb->weight_buffers[3].weight;
+
+ // set weight buffers
+ buffers.base_weight_fb = rb->base_weight_fb;
+
+ storage->get_effects()->bokeh_dof_raster(buffers, camfx->dof_blur_far_enabled, camfx->dof_blur_far_distance, camfx->dof_blur_far_transition, camfx->dof_blur_near_enabled, camfx->dof_blur_near_distance, camfx->dof_blur_near_transition, bokeh_size, dof_blur_bokeh_shape, dof_blur_quality, p_render_data->z_near, p_render_data->z_far, p_render_data->cam_ortogonal);
}
RD::get_singleton()->draw_command_end_label();
}
@@ -2777,7 +2847,7 @@ void RendererSceneRenderRD::_setup_lights(const PagedArray<RID> &p_lights, const
CameraMatrix shadow_mtx = rectm * bias * matrix * modelview;
light_data.shadow_split_offsets[j] = split;
float bias_scale = li->shadow_transform[j].bias_scale;
- light_data.shadow_bias[j] = storage->light_get_param(base, RS::LIGHT_PARAM_SHADOW_BIAS) * bias_scale;
+ light_data.shadow_bias[j] = storage->light_get_param(base, RS::LIGHT_PARAM_SHADOW_BIAS) / 100.0 * bias_scale;
light_data.shadow_normal_bias[j] = storage->light_get_param(base, RS::LIGHT_PARAM_SHADOW_NORMAL_BIAS) * li->shadow_transform[j].shadow_texel_size;
light_data.shadow_transmittance_bias[j] = storage->light_get_transmittance_bias(base) * bias_scale;
light_data.shadow_z_range[j] = li->shadow_transform[j].farplane;
@@ -2948,14 +3018,10 @@ void RendererSceneRenderRD::_setup_lights(const PagedArray<RID> &p_lights, const
light_data.shadow_enabled = true;
if (type == RS::LIGHT_SPOT) {
- light_data.shadow_bias = (storage->light_get_param(base, RS::LIGHT_PARAM_SHADOW_BIAS) * radius / 10.0);
- float shadow_texel_size = Math::tan(Math::deg2rad(spot_angle)) * radius * 2.0;
- shadow_texel_size *= light_instance_get_shadow_texel_size(li->self, p_shadow_atlas);
-
- light_data.shadow_normal_bias = storage->light_get_param(base, RS::LIGHT_PARAM_SHADOW_NORMAL_BIAS) * shadow_texel_size;
+ light_data.shadow_bias = (storage->light_get_param(base, RS::LIGHT_PARAM_SHADOW_BIAS) / 100.0);
} else { //omni
- light_data.shadow_bias = storage->light_get_param(base, RS::LIGHT_PARAM_SHADOW_BIAS) * radius / 10.0;
+ light_data.shadow_bias = storage->light_get_param(base, RS::LIGHT_PARAM_SHADOW_BIAS) / 100.0;
float shadow_texel_size = light_instance_get_shadow_texel_size(li->self, p_shadow_atlas);
light_data.shadow_normal_bias = storage->light_get_param(base, RS::LIGHT_PARAM_SHADOW_NORMAL_BIAS) * shadow_texel_size * 2.0; // applied in -1 .. 1 space
}
diff --git a/servers/rendering/renderer_rd/renderer_scene_render_rd.h b/servers/rendering/renderer_rd/renderer_scene_render_rd.h
index 336dd6e1a7..236e4b4320 100644
--- a/servers/rendering/renderer_rd/renderer_scene_render_rd.h
+++ b/servers/rendering/renderer_rd/renderer_scene_render_rd.h
@@ -483,6 +483,15 @@ private:
Blur blur[2]; //the second one starts from the first mipmap
+ struct WeightBuffers {
+ RID weight;
+ RID fb; // FB with both texture and weight
+ };
+
+ // 2 full size, 2 half size
+ WeightBuffers weight_buffers[4]; // Only used in raster
+ RID base_weight_fb; // base buffer for weight
+
struct Luminance {
Vector<RID> reduce;
RID current;
diff --git a/servers/rendering/renderer_rd/shaders/blur_raster.glsl b/servers/rendering/renderer_rd/shaders/blur_raster.glsl
index b1d1c2365e..0789a4b396 100644
--- a/servers/rendering/renderer_rd/shaders/blur_raster.glsl
+++ b/servers/rendering/renderer_rd/shaders/blur_raster.glsl
@@ -37,32 +37,6 @@ layout(set = 1, binding = 0) uniform sampler2D source_auto_exposure;
layout(location = 0) out vec4 frag_color;
-//DOF
-#ifdef MODE_DOF_BLUR
-
-layout(set = 1, binding = 0) uniform sampler2D dof_source_depth;
-
-#ifdef DOF_QUALITY_LOW
-const int dof_kernel_size = 5;
-const int dof_kernel_from = 2;
-const float dof_kernel[5] = float[](0.153388, 0.221461, 0.250301, 0.221461, 0.153388);
-#endif
-
-#ifdef DOF_QUALITY_MEDIUM
-const int dof_kernel_size = 11;
-const int dof_kernel_from = 5;
-const float dof_kernel[11] = float[](0.055037, 0.072806, 0.090506, 0.105726, 0.116061, 0.119726, 0.116061, 0.105726, 0.090506, 0.072806, 0.055037);
-
-#endif
-
-#ifdef DOF_QUALITY_HIGH
-const int dof_kernel_size = 21;
-const int dof_kernel_from = 10;
-const float dof_kernel[21] = float[](0.028174, 0.032676, 0.037311, 0.041944, 0.046421, 0.050582, 0.054261, 0.057307, 0.059587, 0.060998, 0.061476, 0.060998, 0.059587, 0.057307, 0.054261, 0.050582, 0.046421, 0.041944, 0.037311, 0.032676, 0.028174);
-#endif
-
-#endif
-
void main() {
#ifdef MODE_MIPMAP
@@ -155,74 +129,8 @@ void main() {
#endif
-#ifdef MODE_DOF_BLUR
-
- vec4 color_accum = vec4(0.0);
-
- float depth = texture(dof_source_depth, uv_interp, 0.0).r;
- depth = depth * 2.0 - 1.0;
-
- if (bool(blur.flags & FLAG_USE_ORTHOGONAL_PROJECTION)) {
- depth = ((depth + (blur.camera_z_far + blur.camera_z_near) / (blur.camera_z_far - blur.camera_z_near)) * (blur.camera_z_far - blur.camera_z_near)) / 2.0;
- } else {
- depth = 2.0 * blur.camera_z_near * blur.camera_z_far / (blur.camera_z_far + blur.camera_z_near - depth * (blur.camera_z_far - blur.camera_z_near));
- }
-
- // mix near and far blur amount
- float amount = 1.0;
- if (bool(blur.flags & FLAG_DOF_FAR)) {
- amount *= 1.0 - smoothstep(blur.dof_far_begin, blur.dof_far_end, depth);
- }
- if (bool(blur.flags & FLAG_DOF_NEAR)) {
- amount *= smoothstep(blur.dof_near_end, blur.dof_near_begin, depth);
- }
- amount = 1.0 - amount;
-
- if (amount > 0.0) {
- float k_accum = 0.0;
-
- for (int i = 0; i < dof_kernel_size; i++) {
- int int_ofs = i - dof_kernel_from;
- vec2 tap_uv = uv_interp + blur.dof_dir * float(int_ofs) * amount * blur.dof_radius;
-
- float tap_k = dof_kernel[i];
-
- float tap_depth = texture(dof_source_depth, tap_uv, 0.0).r;
- tap_depth = tap_depth * 2.0 - 1.0;
-
- if (bool(blur.flags & FLAG_USE_ORTHOGONAL_PROJECTION)) {
- tap_depth = ((tap_depth + (blur.camera_z_far + blur.camera_z_near) / (blur.camera_z_far - blur.camera_z_near)) * (blur.camera_z_far - blur.camera_z_near)) / 2.0;
- } else {
- tap_depth = 2.0 * blur.camera_z_near * blur.camera_z_far / (blur.camera_z_far + blur.camera_z_near - tap_depth * (blur.camera_z_far - blur.camera_z_near));
- }
-
- // mix near and far blur amount
- float tap_amount = 1.0;
- if (bool(blur.flags & FLAG_DOF_FAR)) {
- tap_amount *= mix(1.0 - smoothstep(blur.dof_far_begin, blur.dof_far_end, tap_depth), 0.0, int_ofs == 0);
- }
- if (bool(blur.flags & FLAG_DOF_NEAR)) {
- tap_amount *= mix(smoothstep(blur.dof_near_end, blur.dof_near_begin, tap_depth), 0.0, int_ofs == 0);
- }
- tap_amount = 1.0 - tap_amount;
-
- tap_amount *= tap_amount * tap_amount; //prevent undesired glow effect
-
- vec4 tap_color = texture(source_color, tap_uv, 0.0) * tap_k;
-
- k_accum += tap_k * tap_amount;
- color_accum += tap_color * tap_amount;
- }
-
- if (k_accum > 0.0) {
- color_accum /= k_accum;
- }
-
- frag_color = color_accum; ///k_accum;
- } else {
- // we are in focus, don't waste time
- frag_color = texture(source_color, uv_interp, 0.0);
- }
-
+#ifdef MODE_COPY
+ vec4 color = textureLod(source_color, uv_interp, 0.0);
+ frag_color = color;
#endif
}
diff --git a/servers/rendering/renderer_rd/shaders/blur_raster_inc.glsl b/servers/rendering/renderer_rd/shaders/blur_raster_inc.glsl
index 6ea968e595..52bf2886b5 100644
--- a/servers/rendering/renderer_rd/shaders/blur_raster_inc.glsl
+++ b/servers/rendering/renderer_rd/shaders/blur_raster_inc.glsl
@@ -1,8 +1,6 @@
#define FLAG_HORIZONTAL (1 << 0)
#define FLAG_USE_ORTHOGONAL_PROJECTION (1 << 1)
#define FLAG_GLOW_FIRST_PASS (1 << 2)
-#define FLAG_DOF_FAR (1 << 3)
-#define FLAG_DOF_NEAR (1 << 4)
layout(push_constant, binding = 1, std430) uniform Blur {
vec2 pixel_size;
@@ -19,18 +17,5 @@ layout(push_constant, binding = 1, std430) uniform Blur {
float glow_white;
float glow_luminance_cap;
float glow_auto_exposure_grey;
-
- // DOF.
- float dof_far_begin;
- float dof_far_end;
- float dof_near_begin;
- float dof_near_end;
-
- float dof_radius;
- float dof_pad[3];
-
- vec2 dof_dir;
- float camera_z_far;
- float camera_z_near;
}
blur;
diff --git a/servers/rendering/renderer_rd/shaders/bokeh_dof.glsl b/servers/rendering/renderer_rd/shaders/bokeh_dof.glsl
index b70e0b6bd5..0438671dd2 100644
--- a/servers/rendering/renderer_rd/shaders/bokeh_dof.glsl
+++ b/servers/rendering/renderer_rd/shaders/bokeh_dof.glsl
@@ -25,34 +25,7 @@ layout(set = 1, binding = 0) uniform sampler2D source_bokeh;
// based on https://www.shadertoy.com/view/Xd3GDl
-layout(push_constant, binding = 1, std430) uniform Params {
- ivec2 size;
- float z_far;
- float z_near;
-
- bool orthogonal;
- float blur_size;
- float blur_scale;
- int blur_steps;
-
- bool blur_near_active;
- float blur_near_begin;
- float blur_near_end;
- bool blur_far_active;
-
- float blur_far_begin;
- float blur_far_end;
- bool second_pass;
- bool half_size;
-
- bool use_jitter;
- float jitter_seed;
- uint pad[2];
-}
-params;
-
-//used to work around downsampling filter
-#define DEPTH_GAP 0.0
+#include "bokeh_dof_inc.glsl"
#ifdef MODE_GEN_BLUR_SIZE
@@ -80,15 +53,6 @@ float get_blur_size(float depth) {
#endif
-const float GOLDEN_ANGLE = 2.39996323;
-
-//note: uniform pdf rand [0;1[
-float hash12n(vec2 p) {
- p = fract(p * vec2(5.3987, 5.4421));
- p += dot(p.yx, p.xy + vec2(21.5351, 14.3137));
- return fract(p.x * p.y * 95.4307);
-}
-
#if defined(MODE_BOKEH_BOX) || defined(MODE_BOKEH_HEXAGONAL)
vec4 weighted_filter_dir(vec2 dir, vec2 uv, vec2 pixel_size) {
diff --git a/servers/rendering/renderer_rd/shaders/bokeh_dof_inc.glsl b/servers/rendering/renderer_rd/shaders/bokeh_dof_inc.glsl
new file mode 100644
index 0000000000..fadea1631c
--- /dev/null
+++ b/servers/rendering/renderer_rd/shaders/bokeh_dof_inc.glsl
@@ -0,0 +1,37 @@
+layout(push_constant, binding = 1, std430) uniform Params {
+ ivec2 size;
+ float z_far;
+ float z_near;
+
+ bool orthogonal;
+ float blur_size;
+ float blur_scale;
+ int blur_steps;
+
+ bool blur_near_active;
+ float blur_near_begin;
+ float blur_near_end;
+ bool blur_far_active;
+
+ float blur_far_begin;
+ float blur_far_end;
+ bool second_pass;
+ bool half_size;
+
+ bool use_jitter;
+ float jitter_seed;
+ uint pad[2];
+}
+params;
+
+//used to work around downsampling filter
+#define DEPTH_GAP 0.0
+
+const float GOLDEN_ANGLE = 2.39996323;
+
+//note: uniform pdf rand [0;1[
+float hash12n(vec2 p) {
+ p = fract(p * vec2(5.3987, 5.4421));
+ p += dot(p.yx, p.xy + vec2(21.5351, 14.3137));
+ return fract(p.x * p.y * 95.4307);
+}
diff --git a/servers/rendering/renderer_rd/shaders/bokeh_dof_raster.glsl b/servers/rendering/renderer_rd/shaders/bokeh_dof_raster.glsl
new file mode 100644
index 0000000000..43a2a29616
--- /dev/null
+++ b/servers/rendering/renderer_rd/shaders/bokeh_dof_raster.glsl
@@ -0,0 +1,253 @@
+/* clang-format off */
+#[vertex]
+
+#version 450
+
+#VERSION_DEFINES
+
+#include "bokeh_dof_inc.glsl"
+
+layout(location = 0) out vec2 uv_interp;
+/* clang-format on */
+
+void main() {
+ vec2 base_arr[4] = vec2[](vec2(0.0, 0.0), vec2(0.0, 1.0), vec2(1.0, 1.0), vec2(1.0, 0.0));
+ uv_interp = base_arr[gl_VertexIndex];
+
+ gl_Position = vec4(uv_interp * 2.0 - 1.0, 0.0, 1.0);
+}
+
+/* clang-format off */
+#[fragment]
+
+#version 450
+
+#VERSION_DEFINES
+
+#include "bokeh_dof_inc.glsl"
+
+layout(location = 0) in vec2 uv_interp;
+/* clang-format on */
+
+#ifdef MODE_GEN_BLUR_SIZE
+layout(location = 0) out float weight;
+
+layout(set = 0, binding = 0) uniform sampler2D source_depth;
+#else
+layout(location = 0) out vec4 frag_color;
+#ifdef OUTPUT_WEIGHT
+layout(location = 1) out float weight;
+#endif
+
+layout(set = 0, binding = 0) uniform sampler2D source_color;
+layout(set = 1, binding = 0) uniform sampler2D source_weight;
+#ifdef MODE_COMPOSITE_BOKEH
+layout(set = 2, binding = 0) uniform sampler2D original_weight;
+#endif
+#endif
+
+//DOF
+// Bokeh single pass implementation based on http://tuxedolabs.blogspot.com/2018/05/bokeh-depth-of-field-in-single-pass.html
+
+#ifdef MODE_GEN_BLUR_SIZE
+
+float get_depth_at_pos(vec2 uv) {
+ float depth = textureLod(source_depth, uv, 0.0).x;
+ if (params.orthogonal) {
+ depth = ((depth + (params.z_far + params.z_near) / (params.z_far - params.z_near)) * (params.z_far - params.z_near)) / 2.0;
+ } else {
+ depth = 2.0 * params.z_near * params.z_far / (params.z_far + params.z_near - depth * (params.z_far - params.z_near));
+ }
+ return depth;
+}
+
+float get_blur_size(float depth) {
+ if (params.blur_near_active && depth < params.blur_near_begin) {
+ return -(1.0 - smoothstep(params.blur_near_end, params.blur_near_begin, depth)) * params.blur_size - DEPTH_GAP; //near blur is negative
+ }
+
+ if (params.blur_far_active && depth > params.blur_far_begin) {
+ return smoothstep(params.blur_far_begin, params.blur_far_end, depth) * params.blur_size + DEPTH_GAP;
+ }
+
+ return 0.0;
+}
+
+#endif
+
+#if defined(MODE_BOKEH_BOX) || defined(MODE_BOKEH_HEXAGONAL)
+
+vec4 weighted_filter_dir(vec2 dir, vec2 uv, vec2 pixel_size) {
+ dir *= pixel_size;
+ vec4 color = texture(source_color, uv);
+ color.a = texture(source_weight, uv).r;
+
+ vec4 accum = color;
+ float total = 1.0;
+
+ float blur_scale = params.blur_size / float(params.blur_steps);
+
+ if (params.use_jitter) {
+ uv += dir * (hash12n(uv + params.jitter_seed) - 0.5);
+ }
+
+ for (int i = -params.blur_steps; i <= params.blur_steps; i++) {
+ if (i == 0) {
+ continue;
+ }
+ float radius = float(i) * blur_scale;
+ vec2 suv = uv + dir * radius;
+ radius = abs(radius);
+
+ vec4 sample_color = texture(source_color, suv);
+ sample_color.a = texture(source_weight, suv).r;
+ float limit;
+
+ if (sample_color.a < color.a) {
+ limit = abs(sample_color.a);
+ } else {
+ limit = abs(color.a);
+ }
+
+ limit -= DEPTH_GAP;
+
+ float m = smoothstep(radius - 0.5, radius + 0.5, limit);
+
+ accum += mix(color, sample_color, m);
+
+ total += 1.0;
+ }
+
+ return accum / total;
+}
+
+#endif
+
+void main() {
+ vec2 pixel_size = 1.0 / vec2(params.size);
+ vec2 uv = uv_interp;
+
+#ifdef MODE_GEN_BLUR_SIZE
+ uv += pixel_size * 0.5;
+ float center_depth = get_depth_at_pos(uv);
+ weight = get_blur_size(center_depth);
+#endif
+
+#ifdef MODE_BOKEH_BOX
+ //pixel_size*=0.5; //resolution is doubled
+ if (params.second_pass || !params.half_size) {
+ uv += pixel_size * 0.5; //half pixel to read centers
+ } else {
+ uv += pixel_size * 0.25; //half pixel to read centers from full res
+ }
+
+ float alpha = texture(source_color, uv).a; // retain this
+ vec2 dir = (params.second_pass ? vec2(0.0, 1.0) : vec2(1.0, 0.0));
+
+ vec4 color = weighted_filter_dir(dir, uv, pixel_size);
+
+ frag_color = color;
+ frag_color.a = alpha; // attempt to retain this in case we have a transparent background, ignored if half_size
+#ifdef OUTPUT_WEIGHT
+ weight = color.a;
+#endif
+
+#endif
+
+#ifdef MODE_BOKEH_HEXAGONAL
+
+ //pixel_size*=0.5; //resolution is doubled
+ if (params.second_pass || !params.half_size) {
+ uv += pixel_size * 0.5; //half pixel to read centers
+ } else {
+ uv += pixel_size * 0.25; //half pixel to read centers from full res
+ }
+
+ float alpha = texture(source_color, uv).a; // retain this
+
+ vec2 dir = (params.second_pass ? normalize(vec2(1.0, 0.577350269189626)) : vec2(0.0, 1.0));
+
+ vec4 color = weighted_filter_dir(dir, uv, pixel_size);
+
+ if (params.second_pass) {
+ dir = normalize(vec2(-1.0, 0.577350269189626));
+
+ vec4 color2 = weighted_filter_dir(dir, uv, pixel_size);
+
+ color.rgb = min(color.rgb, color2.rgb);
+ color.a = (color.a + color2.a) * 0.5;
+ }
+
+ frag_color = color;
+ frag_color.a = alpha; // attempt to retain this in case we have a transparent background, ignored if half_size
+#ifdef OUTPUT_WEIGHT
+ weight = color.a;
+#endif
+
+#endif
+
+#ifdef MODE_BOKEH_CIRCULAR
+ if (params.half_size) {
+ pixel_size *= 0.5; //resolution is doubled
+ }
+
+ uv += pixel_size * 0.5; //half pixel to read centers
+
+ vec4 color = texture(source_color, uv);
+ float alpha = color.a; // retain this
+ color.a = texture(source_weight, uv).r;
+
+ vec4 color_accum = color;
+ float accum = 1.0;
+
+ float radius = params.blur_scale;
+ for (float ang = 0.0; radius < params.blur_size; ang += GOLDEN_ANGLE) {
+ vec2 uv_adj = uv + vec2(cos(ang), sin(ang)) * pixel_size * radius;
+
+ vec4 sample_color = texture(source_color, uv_adj);
+ sample_color.a = texture(source_weight, uv_adj).r;
+
+ float limit;
+
+ if (sample_color.a < color.a) {
+ limit = abs(sample_color.a);
+ } else {
+ limit = abs(color.a);
+ }
+
+ limit -= DEPTH_GAP;
+
+ float m = smoothstep(radius - 0.5, radius + 0.5, limit);
+ color_accum += mix(color_accum / accum, sample_color, m);
+ accum += 1.0;
+
+ radius += params.blur_scale / radius;
+ }
+
+ color_accum = color_accum / accum;
+
+ frag_color.rgb = color_accum.rgb;
+ frag_color.a = alpha; // attempt to retain this in case we have a transparent background, ignored if half_size
+#ifdef OUTPUT_WEIGHT
+ weight = color_accum.a;
+#endif
+
+#endif
+
+#ifdef MODE_COMPOSITE_BOKEH
+ frag_color.rgb = texture(source_color, uv).rgb;
+
+ float center_weigth = texture(source_weight, uv).r;
+ float sample_weight = texture(original_weight, uv).r;
+
+ float mix_amount;
+ if (sample_weight < center_weigth) {
+ mix_amount = min(1.0, max(0.0, max(abs(center_weigth), abs(sample_weight)) - DEPTH_GAP));
+ } else {
+ mix_amount = min(1.0, max(0.0, abs(center_weigth) - DEPTH_GAP));
+ }
+
+ // let alpha blending take care of mixing
+ frag_color.a = mix_amount;
+#endif
+}
diff --git a/servers/rendering/renderer_rd/shaders/scene_forward_lights_inc.glsl b/servers/rendering/renderer_rd/shaders/scene_forward_lights_inc.glsl
index 5920444f7a..4a41c66ef3 100644
--- a/servers/rendering/renderer_rd/shaders/scene_forward_lights_inc.glsl
+++ b/servers/rendering/renderer_rd/shaders/scene_forward_lights_inc.glsl
@@ -410,14 +410,8 @@ float light_process_omni_shadow(uint idx, vec3 vertex, vec3 normal) {
vec4 v = vec4(vertex, 1.0);
vec4 splane = (omni_lights.data[idx].shadow_matrix * v);
- float shadow_len = length(splane.xyz); //need to remember shadow len from here
- {
- vec3 nofs = normal_interp * omni_lights.data[idx].shadow_normal_bias / omni_lights.data[idx].inv_radius;
- nofs *= (1.0 - max(0.0, dot(normalize(light_rel_vec), normalize(normal_interp))));
- v.xyz += nofs;
- splane = (omni_lights.data[idx].shadow_matrix * v);
- }
+ float shadow_len = length(splane.xyz); //need to remember shadow len from here
float shadow;
@@ -526,7 +520,8 @@ float light_process_omni_shadow(uint idx, vec3 vertex, vec3 normal) {
splane.xy /= splane.z;
splane.xy = splane.xy * 0.5 + 0.5;
- splane.z = (shadow_len - omni_lights.data[idx].shadow_bias) * omni_lights.data[idx].inv_radius;
+ splane.z = shadow_len * omni_lights.data[idx].inv_radius;
+ splane.z -= omni_lights.data[idx].shadow_bias;
splane.xy = clamp_rect.xy + splane.xy * clamp_rect.zw;
splane.w = 1.0; //needed? i think it should be 1 already
shadow = sample_pcf_shadow(shadow_atlas, omni_lights.data[idx].soft_shadow_scale * scene_data.shadow_atlas_pixel_size, splane);
@@ -702,27 +697,17 @@ float light_process_spot_shadow(uint idx, vec3 vertex, vec3 normal) {
//there is a shadowmap
vec4 v = vec4(vertex, 1.0);
- v.xyz -= spot_dir * spot_lights.data[idx].shadow_bias;
-
- float z_norm = dot(spot_dir, -light_rel_vec) * spot_lights.data[idx].inv_radius;
-
- float depth_bias_scale = 1.0 / (max(0.0001, z_norm)); //the closer to the light origin, the more you have to offset to reach 1px in the map
- vec3 normal_bias = normalize(normal_interp) * (1.0 - max(0.0, dot(spot_dir, -normalize(normal_interp)))) * spot_lights.data[idx].shadow_normal_bias * depth_bias_scale;
- normal_bias -= spot_dir * dot(spot_dir, normal_bias); //only XY, no Z
- v.xyz += normal_bias;
-
- //adjust with bias
- z_norm = dot(spot_dir, v.xyz - spot_lights.data[idx].position) * spot_lights.data[idx].inv_radius;
-
float shadow;
vec4 splane = (spot_lights.data[idx].shadow_matrix * v);
splane /= splane.w;
+ splane.z -= spot_lights.data[idx].shadow_bias;
if (sc_use_light_soft_shadows && spot_lights.data[idx].soft_shadow_size > 0.0) {
//soft shadow
//find blocker
+ float z_norm = dot(spot_dir, -light_rel_vec) * spot_lights.data[idx].inv_radius;
vec2 shadow_uv = splane.xy * spot_lights.data[idx].atlas_rect.zw + spot_lights.data[idx].atlas_rect.xy;
diff --git a/servers/rendering/renderer_scene_cull.cpp b/servers/rendering/renderer_scene_cull.cpp
index 6357a6f4c2..4a4976718c 100644
--- a/servers/rendering/renderer_scene_cull.cpp
+++ b/servers/rendering/renderer_scene_cull.cpp
@@ -1955,10 +1955,6 @@ void RendererSceneCull::_light_instance_setup_directional_shadow(int p_shadow_in
bool overlap = RSG::storage->light_directional_get_blend_splits(p_instance->base);
- real_t first_radius = 0.0;
-
- real_t min_distance_bias_scale = distances[1];
-
cull.shadow_count = p_shadow_index + 1;
cull.shadows[p_shadow_index].cascade_count = splits;
cull.shadows[p_shadow_index].light_instance = light->instance;
@@ -2006,8 +2002,8 @@ void RendererSceneCull::_light_instance_setup_directional_shadow(int p_shadow_in
real_t z_min_cam = 0.f;
//real_t z_max_cam = 0.f;
- real_t bias_scale = 1.0;
- real_t aspect_bias_scale = 1.0;
+ //real_t bias_scale = 1.0;
+ //real_t aspect_bias_scale = 1.0;
//used for culling
@@ -2061,12 +2057,6 @@ void RendererSceneCull::_light_instance_setup_directional_shadow(int p_shadow_in
radius *= texture_size / (texture_size - 2.0); //add a texel by each side
- if (i == 0) {
- first_radius = radius;
- } else {
- bias_scale = radius / first_radius;
- }
-
z_min_cam = z_vec.dot(center) - radius;
{
@@ -2110,64 +2100,7 @@ void RendererSceneCull::_light_instance_setup_directional_shadow(int p_shadow_in
// a pre pass will need to be needed to determine the actual z-near to be used
- if (pancake_size > 0) {
- z_max = z_vec.dot(center) + radius + pancake_size;
- }
-
- if (aspect != 1.0) {
- // if the aspect is different, then the radius will become larger.
- // if this happens, then bias needs to be adjusted too, as depth will increase
- // to do this, compare the depth of one that would have resulted from a square frustum
-
- CameraMatrix camera_matrix_square;
- if (p_cam_orthogonal) {
- Vector2 vp_he = camera_matrix.get_viewport_half_extents();
- if (p_cam_vaspect) {
- camera_matrix_square.set_orthogonal(vp_he.x * 2.0, 1.0, distances[(i == 0 || !overlap) ? i : i - 1], distances[i + 1], true);
- } else {
- camera_matrix_square.set_orthogonal(vp_he.y * 2.0, 1.0, distances[(i == 0 || !overlap) ? i : i - 1], distances[i + 1], false);
- }
- } else {
- Vector2 vp_he = camera_matrix.get_viewport_half_extents();
- if (p_cam_vaspect) {
- camera_matrix_square.set_frustum(vp_he.x * 2.0, 1.0, Vector2(), distances[(i == 0 || !overlap) ? i : i - 1], distances[i + 1], true);
- } else {
- camera_matrix_square.set_frustum(vp_he.y * 2.0, 1.0, Vector2(), distances[(i == 0 || !overlap) ? i : i - 1], distances[i + 1], false);
- }
- }
-
- Vector3 endpoints_square[8]; // frustum plane endpoints
- res = camera_matrix_square.get_endpoints(p_cam_transform, endpoints_square);
- ERR_CONTINUE(!res);
- Vector3 center_square;
-
- for (int j = 0; j < 8; j++) {
- center_square += endpoints_square[j];
- }
-
- center_square /= 8.0;
-
- real_t radius_square = 0;
-
- for (int j = 0; j < 8; j++) {
- real_t d = center_square.distance_to(endpoints_square[j]);
- if (d > radius_square) {
- radius_square = d;
- }
- }
-
- radius_square *= texture_size / (texture_size - 2.0); //add a texel by each side
-
- float z_max_square = z_vec.dot(center_square) + radius_square + pancake_size;
-
- real_t z_min_cam_square = z_vec.dot(center_square) - radius_square;
-
- aspect_bias_scale = (z_max - z_min_cam) / (z_max_square - z_min_cam_square);
-
- // this is not entirely perfect, because the cull-adjusted z-max may be different
- // but at least it's warranted that it results in a greater bias, so no acne should be present either way.
- // pancaking also helps with this.
- }
+ z_max = z_vec.dot(center) + radius + pancake_size;
{
CameraMatrix ortho_camera;
@@ -2188,7 +2121,7 @@ void RendererSceneCull::_light_instance_setup_directional_shadow(int p_shadow_in
cull.shadows[p_shadow_index].cascades[i].zfar = z_max - z_min_cam;
cull.shadows[p_shadow_index].cascades[i].split = distances[i + 1];
cull.shadows[p_shadow_index].cascades[i].shadow_texel_size = radius * 2.0 / texture_size;
- cull.shadows[p_shadow_index].cascades[i].bias_scale = bias_scale * aspect_bias_scale * min_distance_bias_scale;
+ cull.shadows[p_shadow_index].cascades[i].bias_scale = (z_max - z_min_cam);
cull.shadows[p_shadow_index].cascades[i].range_begin = z_max;
cull.shadows[p_shadow_index].cascades[i].uv_scale = uv_scale;
}
diff --git a/servers/rendering_server.cpp b/servers/rendering_server.cpp
index 6c4fb31efd..222ea9e622 100644
--- a/servers/rendering_server.cpp
+++ b/servers/rendering_server.cpp
@@ -2828,7 +2828,7 @@ RenderingServer::RenderingServer() {
GLOBAL_DEF_RST("rendering/textures/default_filters/use_nearest_mipmap_filter", false);
GLOBAL_DEF_RST("rendering/textures/default_filters/anisotropic_filtering_level", 2);
- ProjectSettings::get_singleton()->set_custom_property_info("rendering/textures/default_filters/anisotropic_filtering_level", PropertyInfo(Variant::INT, "rendering/textures/default_filters/anisotropic_filtering_level", PROPERTY_HINT_ENUM, "Disabled (Fastest),2x (Faster),4x (Fast),8x (Average),16x (Slow)"));
+ ProjectSettings::get_singleton()->set_custom_property_info("rendering/textures/default_filters/anisotropic_filtering_level", PropertyInfo(Variant::INT, "rendering/textures/default_filters/anisotropic_filtering_level", PROPERTY_HINT_ENUM, String::utf8("Disabled (Fastest),2× (Faster),4× (Fast),8× (Average),16× (Slow)")));
GLOBAL_DEF("rendering/camera/depth_of_field/depth_of_field_bokeh_shape", 1);
ProjectSettings::get_singleton()->set_custom_property_info("rendering/camera/depth_of_field/depth_of_field_bokeh_shape", PropertyInfo(Variant::INT, "rendering/camera/depth_of_field/depth_of_field_bokeh_shape", PROPERTY_HINT_ENUM, "Box (Fast),Hexagon (Average),Circle (Slowest)"));
diff --git a/tests/test_physics_2d.cpp b/tests/test_physics_2d.cpp
index 40dc74e89c..61b8951afa 100644
--- a/tests/test_physics_2d.cpp
+++ b/tests/test_physics_2d.cpp
@@ -255,7 +255,7 @@ protected:
arr.push_back(p_normal);
arr.push_back(p_d);
- RID plane = ps->line_shape_create();
+ RID plane = ps->world_margin_shape_create();
ps->shape_set_data(plane, arr);
RID plane_body = ps->body_create();