summaryrefslogtreecommitdiff
path: root/servers
diff options
context:
space:
mode:
Diffstat (limited to 'servers')
-rw-r--r--servers/SCsub1
-rw-r--r--servers/display_server.cpp5
-rw-r--r--servers/display_server.h1
-rw-r--r--servers/physics_2d/body_direct_state_2d_sw.cpp16
-rw-r--r--servers/physics_2d/body_direct_state_2d_sw.h1
-rw-r--r--servers/physics_2d/collision_object_2d_sw.cpp5
-rw-r--r--servers/physics_2d/collision_object_2d_sw.h6
-rw-r--r--servers/physics_2d/physics_server_2d_sw.cpp280
-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.cpp10
-rw-r--r--servers/physics_2d/space_2d_sw.cpp13
-rw-r--r--servers/physics_3d/body_3d_sw.cpp6
-rw-r--r--servers/physics_3d/physics_server_3d_sw.cpp376
-rw-r--r--servers/physics_3d/physics_server_3d_sw.h2
-rw-r--r--servers/physics_3d/physics_server_3d_wrap_mt.h2
-rw-r--r--servers/physics_3d/shape_3d_sw.cpp4
-rw-r--r--servers/physics_3d/soft_body_3d_sw.cpp20
-rw-r--r--servers/physics_3d/soft_body_3d_sw.h5
-rw-r--r--servers/physics_3d/space_3d_sw.cpp13
-rw-r--r--servers/physics_3d/step_3d_sw.cpp6
-rw-r--r--servers/physics_server_2d.cpp7
-rw-r--r--servers/physics_server_2d.h8
-rw-r--r--servers/physics_server_3d.h3
-rw-r--r--servers/register_server_types.cpp18
-rw-r--r--servers/rendering/rasterizer_dummy.h6
-rw-r--r--servers/rendering/renderer_canvas_cull.cpp200
-rw-r--r--servers/rendering/renderer_rd/forward_clustered/render_forward_clustered.cpp2
-rw-r--r--servers/rendering/renderer_rd/forward_clustered/scene_shader_forward_clustered.cpp28
-rw-r--r--servers/rendering/renderer_rd/forward_mobile/render_forward_mobile.cpp2
-rw-r--r--servers/rendering/renderer_rd/forward_mobile/scene_shader_forward_mobile.cpp28
-rw-r--r--servers/rendering/renderer_rd/renderer_canvas_render_rd.cpp52
-rw-r--r--servers/rendering/renderer_rd/renderer_scene_gi_rd.cpp18
-rw-r--r--servers/rendering/renderer_rd/renderer_scene_gi_rd.h2
-rw-r--r--servers/rendering/renderer_rd/renderer_scene_render_rd.cpp312
-rw-r--r--servers/rendering/renderer_rd/renderer_scene_render_rd.h74
-rw-r--r--servers/rendering/renderer_rd/renderer_scene_sky_rd.cpp30
-rw-r--r--servers/rendering/renderer_rd/renderer_storage_rd.cpp730
-rw-r--r--servers/rendering/renderer_rd/renderer_storage_rd.h100
-rw-r--r--servers/rendering/renderer_rd/shader_compiler_rd.cpp14
-rw-r--r--servers/rendering/renderer_rd/shader_rd.cpp26
-rw-r--r--servers/rendering/renderer_rd/shader_rd.h2
-rw-r--r--servers/rendering/renderer_rd/shaders/scene_forward_clustered.glsl2
-rw-r--r--servers/rendering/renderer_rd/shaders/scene_forward_mobile.glsl2
-rw-r--r--servers/rendering/renderer_scene_cull.cpp116
-rw-r--r--servers/rendering/renderer_storage.cpp20
-rw-r--r--servers/rendering/renderer_viewport.cpp132
-rw-r--r--servers/rendering/rendering_device_binds.cpp6
-rw-r--r--servers/rendering/rendering_device_binds.h10
-rw-r--r--servers/rendering/rendering_server_default.cpp3
-rw-r--r--servers/rendering/shader_language.cpp92
-rw-r--r--servers/rendering/shader_warnings.cpp8
-rw-r--r--servers/rendering_server.cpp1
-rw-r--r--servers/rendering_server.h2
-rw-r--r--servers/text/SCsub5
-rw-r--r--servers/text/text_server_extension.cpp1281
-rw-r--r--servers/text/text_server_extension.h426
-rw-r--r--servers/text_server.cpp561
-rw-r--r--servers/text_server.h294
59 files changed, 3519 insertions, 1880 deletions
diff --git a/servers/SCsub b/servers/SCsub
index 121990f2e1..76c11724d3 100644
--- a/servers/SCsub
+++ b/servers/SCsub
@@ -11,6 +11,7 @@ SConscript("physics_3d/SCsub")
SConscript("physics_2d/SCsub")
SConscript("rendering/SCsub")
SConscript("audio/SCsub")
+SConscript("text/SCsub")
lib = env.add_library("servers", env.servers_sources)
diff --git a/servers/display_server.cpp b/servers/display_server.cpp
index cdf892094d..3897e5e7c2 100644
--- a/servers/display_server.cpp
+++ b/servers/display_server.cpp
@@ -285,6 +285,10 @@ String DisplayServer::keyboard_get_layout_name(int p_index) const {
return "Not supported";
}
+Key DisplayServer::keyboard_get_keycode_from_physical(Key p_keycode) const {
+ ERR_FAIL_V_MSG(p_keycode, "Not supported by this display server.");
+}
+
void DisplayServer::force_process_and_drop_events() {
}
@@ -452,6 +456,7 @@ void DisplayServer::_bind_methods() {
ClassDB::bind_method(D_METHOD("keyboard_set_current_layout", "index"), &DisplayServer::keyboard_set_current_layout);
ClassDB::bind_method(D_METHOD("keyboard_get_layout_language", "index"), &DisplayServer::keyboard_get_layout_language);
ClassDB::bind_method(D_METHOD("keyboard_get_layout_name", "index"), &DisplayServer::keyboard_get_layout_name);
+ ClassDB::bind_method(D_METHOD("keyboard_get_keycode_from_physical", "keycode"), &DisplayServer::keyboard_get_keycode_from_physical);
ClassDB::bind_method(D_METHOD("process_events"), &DisplayServer::process_events);
ClassDB::bind_method(D_METHOD("force_process_and_drop_events"), &DisplayServer::force_process_and_drop_events);
diff --git a/servers/display_server.h b/servers/display_server.h
index 788206768c..f411a72aa3 100644
--- a/servers/display_server.h
+++ b/servers/display_server.h
@@ -343,6 +343,7 @@ public:
virtual void keyboard_set_current_layout(int p_index);
virtual String keyboard_get_layout_language(int p_index) const;
virtual String keyboard_get_layout_name(int p_index) const;
+ virtual Key keyboard_get_keycode_from_physical(Key p_keycode) const;
virtual int tablet_get_driver_count() const { return 1; };
virtual String tablet_get_driver_name(int p_driver) const { return "default"; };
diff --git a/servers/physics_2d/body_direct_state_2d_sw.cpp b/servers/physics_2d/body_direct_state_2d_sw.cpp
index 1e924a831e..1c6adfe27c 100644
--- a/servers/physics_2d/body_direct_state_2d_sw.cpp
+++ b/servers/physics_2d/body_direct_state_2d_sw.cpp
@@ -169,22 +169,6 @@ Vector2 PhysicsDirectBodyState2DSW::get_contact_collider_velocity_at_position(in
return body->contacts[p_contact_idx].collider_velocity_at_pos;
}
-Variant PhysicsDirectBodyState2DSW::get_contact_collider_shape_metadata(int p_contact_idx) const {
- ERR_FAIL_INDEX_V(p_contact_idx, body->contact_count, Variant());
-
- if (!PhysicsServer2DSW::singletonsw->body_owner.owns(body->contacts[p_contact_idx].collider)) {
- return Variant();
- }
- Body2DSW *other = PhysicsServer2DSW::singletonsw->body_owner.getornull(body->contacts[p_contact_idx].collider);
-
- int sidx = body->contacts[p_contact_idx].collider_shape;
- if (sidx < 0 || sidx >= other->get_shape_count()) {
- return Variant();
- }
-
- return other->get_shape_metadata(sidx);
-}
-
PhysicsDirectSpaceState2D *PhysicsDirectBodyState2DSW::get_space_state() {
return body->get_space()->get_direct_state();
}
diff --git a/servers/physics_2d/body_direct_state_2d_sw.h b/servers/physics_2d/body_direct_state_2d_sw.h
index 34faa174d8..4266b24842 100644
--- a/servers/physics_2d/body_direct_state_2d_sw.h
+++ b/servers/physics_2d/body_direct_state_2d_sw.h
@@ -80,7 +80,6 @@ public:
virtual Vector2 get_contact_collider_position(int p_contact_idx) const override;
virtual ObjectID get_contact_collider_id(int p_contact_idx) const override;
virtual int get_contact_collider_shape(int p_contact_idx) const override;
- virtual Variant get_contact_collider_shape_metadata(int p_contact_idx) const override;
virtual Vector2 get_contact_collider_velocity_at_position(int p_contact_idx) const override;
diff --git a/servers/physics_2d/collision_object_2d_sw.cpp b/servers/physics_2d/collision_object_2d_sw.cpp
index c92f01d120..bc7d277152 100644
--- a/servers/physics_2d/collision_object_2d_sw.cpp
+++ b/servers/physics_2d/collision_object_2d_sw.cpp
@@ -61,11 +61,6 @@ void CollisionObject2DSW::set_shape(int p_index, Shape2DSW *p_shape) {
}
}
-void CollisionObject2DSW::set_shape_metadata(int p_index, const Variant &p_metadata) {
- ERR_FAIL_INDEX(p_index, shapes.size());
- shapes.write[p_index].metadata = p_metadata;
-}
-
void CollisionObject2DSW::set_shape_transform(int p_index, const Transform2D &p_transform) {
ERR_FAIL_INDEX(p_index, shapes.size());
diff --git a/servers/physics_2d/collision_object_2d_sw.h b/servers/physics_2d/collision_object_2d_sw.h
index 69487631a6..ca258a906a 100644
--- a/servers/physics_2d/collision_object_2d_sw.h
+++ b/servers/physics_2d/collision_object_2d_sw.h
@@ -58,7 +58,6 @@ private:
BroadPhase2DSW::ID bpid = 0;
Rect2 aabb_cache; //for rayqueries
Shape2DSW *shape = nullptr;
- Variant metadata;
bool disabled = false;
bool one_way_collision = false;
real_t one_way_collision_margin = 0.0;
@@ -110,7 +109,6 @@ public:
void add_shape(Shape2DSW *p_shape, const Transform2D &p_transform = Transform2D(), bool p_disabled = false);
void set_shape(int p_index, Shape2DSW *p_shape);
void set_shape_transform(int p_index, const Transform2D &p_transform);
- void set_shape_metadata(int p_index, const Variant &p_metadata);
_FORCE_INLINE_ int get_shape_count() const { return shapes.size(); }
_FORCE_INLINE_ Shape2DSW *get_shape(int p_index) const {
@@ -129,10 +127,6 @@ public:
CRASH_BAD_INDEX(p_index, shapes.size());
return shapes[p_index].aabb_cache;
}
- _FORCE_INLINE_ const Variant &get_shape_metadata(int p_index) const {
- CRASH_BAD_INDEX(p_index, shapes.size());
- return shapes[p_index].metadata;
- }
_FORCE_INLINE_ const Transform2D &get_transform() const { return transform; }
_FORCE_INLINE_ const Transform2D &get_inv_transform() const { return inv_transform; }
diff --git a/servers/physics_2d/physics_server_2d_sw.cpp b/servers/physics_2d/physics_server_2d_sw.cpp
index e052258a92..4315b55df4 100644
--- a/servers/physics_2d/physics_server_2d_sw.cpp
+++ b/servers/physics_2d/physics_server_2d_sw.cpp
@@ -112,32 +112,32 @@ RID PhysicsServer2DSW::concave_polygon_shape_create() {
}
void PhysicsServer2DSW::shape_set_data(RID p_shape, const Variant &p_data) {
- Shape2DSW *shape = shape_owner.getornull(p_shape);
+ Shape2DSW *shape = shape_owner.get_or_null(p_shape);
ERR_FAIL_COND(!shape);
shape->set_data(p_data);
};
void PhysicsServer2DSW::shape_set_custom_solver_bias(RID p_shape, real_t p_bias) {
- Shape2DSW *shape = shape_owner.getornull(p_shape);
+ Shape2DSW *shape = shape_owner.get_or_null(p_shape);
ERR_FAIL_COND(!shape);
shape->set_custom_bias(p_bias);
}
PhysicsServer2D::ShapeType PhysicsServer2DSW::shape_get_type(RID p_shape) const {
- const Shape2DSW *shape = shape_owner.getornull(p_shape);
+ const Shape2DSW *shape = shape_owner.get_or_null(p_shape);
ERR_FAIL_COND_V(!shape, SHAPE_CUSTOM);
return shape->get_type();
};
Variant PhysicsServer2DSW::shape_get_data(RID p_shape) const {
- const Shape2DSW *shape = shape_owner.getornull(p_shape);
+ const Shape2DSW *shape = shape_owner.get_or_null(p_shape);
ERR_FAIL_COND_V(!shape, Variant());
ERR_FAIL_COND_V(!shape->is_configured(), Variant());
return shape->get_data();
};
real_t PhysicsServer2DSW::shape_get_custom_solver_bias(RID p_shape) const {
- const Shape2DSW *shape = shape_owner.getornull(p_shape);
+ const Shape2DSW *shape = shape_owner.get_or_null(p_shape);
ERR_FAIL_COND_V(!shape, 0);
return shape->get_custom_bias();
}
@@ -193,9 +193,9 @@ void PhysicsServer2DSW::_shape_col_cbk(const Vector2 &p_point_A, const Vector2 &
}
bool PhysicsServer2DSW::shape_collide(RID p_shape_A, const Transform2D &p_xform_A, const Vector2 &p_motion_A, RID p_shape_B, const Transform2D &p_xform_B, const Vector2 &p_motion_B, Vector2 *r_results, int p_result_max, int &r_result_count) {
- Shape2DSW *shape_A = shape_owner.getornull(p_shape_A);
+ Shape2DSW *shape_A = shape_owner.get_or_null(p_shape_A);
ERR_FAIL_COND_V(!shape_A, false);
- Shape2DSW *shape_B = shape_owner.getornull(p_shape_B);
+ Shape2DSW *shape_B = shape_owner.get_or_null(p_shape_B);
ERR_FAIL_COND_V(!shape_B, false);
if (p_result_max == 0) {
@@ -218,7 +218,7 @@ RID PhysicsServer2DSW::space_create() {
RID id = space_owner.make_rid(space);
space->set_self(id);
RID area_id = area_create();
- Area2DSW *area = area_owner.getornull(area_id);
+ Area2DSW *area = area_owner.get_or_null(area_id);
ERR_FAIL_COND_V(!area, RID());
space->set_default_area(area);
area->set_space(space);
@@ -228,7 +228,7 @@ RID PhysicsServer2DSW::space_create() {
};
void PhysicsServer2DSW::space_set_active(RID p_space, bool p_active) {
- Space2DSW *space = space_owner.getornull(p_space);
+ Space2DSW *space = space_owner.get_or_null(p_space);
ERR_FAIL_COND(!space);
if (p_active) {
active_spaces.insert(space);
@@ -238,45 +238,45 @@ void PhysicsServer2DSW::space_set_active(RID p_space, bool p_active) {
}
bool PhysicsServer2DSW::space_is_active(RID p_space) const {
- const Space2DSW *space = space_owner.getornull(p_space);
+ const Space2DSW *space = space_owner.get_or_null(p_space);
ERR_FAIL_COND_V(!space, false);
return active_spaces.has(space);
}
void PhysicsServer2DSW::space_set_param(RID p_space, SpaceParameter p_param, real_t p_value) {
- Space2DSW *space = space_owner.getornull(p_space);
+ Space2DSW *space = space_owner.get_or_null(p_space);
ERR_FAIL_COND(!space);
space->set_param(p_param, p_value);
}
real_t PhysicsServer2DSW::space_get_param(RID p_space, SpaceParameter p_param) const {
- const Space2DSW *space = space_owner.getornull(p_space);
+ const Space2DSW *space = space_owner.get_or_null(p_space);
ERR_FAIL_COND_V(!space, 0);
return space->get_param(p_param);
}
void PhysicsServer2DSW::space_set_debug_contacts(RID p_space, int p_max_contacts) {
- Space2DSW *space = space_owner.getornull(p_space);
+ Space2DSW *space = space_owner.get_or_null(p_space);
ERR_FAIL_COND(!space);
space->set_debug_contacts(p_max_contacts);
}
Vector<Vector2> PhysicsServer2DSW::space_get_contacts(RID p_space) const {
- Space2DSW *space = space_owner.getornull(p_space);
+ Space2DSW *space = space_owner.get_or_null(p_space);
ERR_FAIL_COND_V(!space, Vector<Vector2>());
return space->get_debug_contacts();
}
int PhysicsServer2DSW::space_get_contact_count(RID p_space) const {
- Space2DSW *space = space_owner.getornull(p_space);
+ Space2DSW *space = space_owner.get_or_null(p_space);
ERR_FAIL_COND_V(!space, 0);
return space->get_debug_contact_count();
}
PhysicsDirectSpaceState2D *PhysicsServer2DSW::space_get_direct_state(RID p_space) {
- Space2DSW *space = space_owner.getornull(p_space);
+ Space2DSW *space = space_owner.get_or_null(p_space);
ERR_FAIL_COND_V(!space, nullptr);
ERR_FAIL_COND_V_MSG((using_threads && !doing_sync) || space->is_locked(), nullptr, "Space state is inaccessible right now, wait for iteration or physics process notification.");
@@ -291,12 +291,12 @@ RID PhysicsServer2DSW::area_create() {
};
void PhysicsServer2DSW::area_set_space(RID p_area, RID p_space) {
- Area2DSW *area = area_owner.getornull(p_area);
+ Area2DSW *area = area_owner.get_or_null(p_area);
ERR_FAIL_COND(!area);
Space2DSW *space = nullptr;
if (p_space.is_valid()) {
- space = space_owner.getornull(p_space);
+ space = space_owner.get_or_null(p_space);
ERR_FAIL_COND(!space);
}
@@ -309,7 +309,7 @@ void PhysicsServer2DSW::area_set_space(RID p_area, RID p_space) {
};
RID PhysicsServer2DSW::area_get_space(RID p_area) const {
- Area2DSW *area = area_owner.getornull(p_area);
+ Area2DSW *area = area_owner.get_or_null(p_area);
ERR_FAIL_COND_V(!area, RID());
Space2DSW *space = area->get_space();
@@ -320,34 +320,34 @@ RID PhysicsServer2DSW::area_get_space(RID p_area) const {
};
void PhysicsServer2DSW::area_set_space_override_mode(RID p_area, AreaSpaceOverrideMode p_mode) {
- Area2DSW *area = area_owner.getornull(p_area);
+ Area2DSW *area = area_owner.get_or_null(p_area);
ERR_FAIL_COND(!area);
area->set_space_override_mode(p_mode);
}
PhysicsServer2D::AreaSpaceOverrideMode PhysicsServer2DSW::area_get_space_override_mode(RID p_area) const {
- const Area2DSW *area = area_owner.getornull(p_area);
+ const Area2DSW *area = area_owner.get_or_null(p_area);
ERR_FAIL_COND_V(!area, AREA_SPACE_OVERRIDE_DISABLED);
return area->get_space_override_mode();
}
void PhysicsServer2DSW::area_add_shape(RID p_area, RID p_shape, const Transform2D &p_transform, bool p_disabled) {
- Area2DSW *area = area_owner.getornull(p_area);
+ Area2DSW *area = area_owner.get_or_null(p_area);
ERR_FAIL_COND(!area);
- Shape2DSW *shape = shape_owner.getornull(p_shape);
+ Shape2DSW *shape = shape_owner.get_or_null(p_shape);
ERR_FAIL_COND(!shape);
area->add_shape(shape, p_transform, p_disabled);
}
void PhysicsServer2DSW::area_set_shape(RID p_area, int p_shape_idx, RID p_shape) {
- Area2DSW *area = area_owner.getornull(p_area);
+ Area2DSW *area = area_owner.get_or_null(p_area);
ERR_FAIL_COND(!area);
- Shape2DSW *shape = shape_owner.getornull(p_shape);
+ Shape2DSW *shape = shape_owner.get_or_null(p_shape);
ERR_FAIL_COND(!shape);
ERR_FAIL_COND(!shape->is_configured());
@@ -355,14 +355,14 @@ void PhysicsServer2DSW::area_set_shape(RID p_area, int p_shape_idx, RID p_shape)
}
void PhysicsServer2DSW::area_set_shape_transform(RID p_area, int p_shape_idx, const Transform2D &p_transform) {
- Area2DSW *area = area_owner.getornull(p_area);
+ Area2DSW *area = area_owner.get_or_null(p_area);
ERR_FAIL_COND(!area);
area->set_shape_transform(p_shape_idx, p_transform);
}
void PhysicsServer2DSW::area_set_shape_disabled(RID p_area, int p_shape, bool p_disabled) {
- Area2DSW *area = area_owner.getornull(p_area);
+ Area2DSW *area = area_owner.get_or_null(p_area);
ERR_FAIL_COND(!area);
ERR_FAIL_INDEX(p_shape, area->get_shape_count());
FLUSH_QUERY_CHECK(area);
@@ -371,14 +371,14 @@ void PhysicsServer2DSW::area_set_shape_disabled(RID p_area, int p_shape, bool p_
}
int PhysicsServer2DSW::area_get_shape_count(RID p_area) const {
- Area2DSW *area = area_owner.getornull(p_area);
+ Area2DSW *area = area_owner.get_or_null(p_area);
ERR_FAIL_COND_V(!area, -1);
return area->get_shape_count();
}
RID PhysicsServer2DSW::area_get_shape(RID p_area, int p_shape_idx) const {
- Area2DSW *area = area_owner.getornull(p_area);
+ Area2DSW *area = area_owner.get_or_null(p_area);
ERR_FAIL_COND_V(!area, RID());
Shape2DSW *shape = area->get_shape(p_shape_idx);
@@ -388,21 +388,21 @@ RID PhysicsServer2DSW::area_get_shape(RID p_area, int p_shape_idx) const {
}
Transform2D PhysicsServer2DSW::area_get_shape_transform(RID p_area, int p_shape_idx) const {
- Area2DSW *area = area_owner.getornull(p_area);
+ Area2DSW *area = area_owner.get_or_null(p_area);
ERR_FAIL_COND_V(!area, Transform2D());
return area->get_shape_transform(p_shape_idx);
}
void PhysicsServer2DSW::area_remove_shape(RID p_area, int p_shape_idx) {
- Area2DSW *area = area_owner.getornull(p_area);
+ Area2DSW *area = area_owner.get_or_null(p_area);
ERR_FAIL_COND(!area);
area->remove_shape(p_shape_idx);
}
void PhysicsServer2DSW::area_clear_shapes(RID p_area) {
- Area2DSW *area = area_owner.getornull(p_area);
+ Area2DSW *area = area_owner.get_or_null(p_area);
ERR_FAIL_COND(!area);
while (area->get_shape_count()) {
@@ -412,86 +412,86 @@ void PhysicsServer2DSW::area_clear_shapes(RID p_area) {
void PhysicsServer2DSW::area_attach_object_instance_id(RID p_area, ObjectID p_id) {
if (space_owner.owns(p_area)) {
- Space2DSW *space = space_owner.getornull(p_area);
+ Space2DSW *space = space_owner.get_or_null(p_area);
p_area = space->get_default_area()->get_self();
}
- Area2DSW *area = area_owner.getornull(p_area);
+ Area2DSW *area = area_owner.get_or_null(p_area);
ERR_FAIL_COND(!area);
area->set_instance_id(p_id);
}
ObjectID PhysicsServer2DSW::area_get_object_instance_id(RID p_area) const {
if (space_owner.owns(p_area)) {
- Space2DSW *space = space_owner.getornull(p_area);
+ Space2DSW *space = space_owner.get_or_null(p_area);
p_area = space->get_default_area()->get_self();
}
- Area2DSW *area = area_owner.getornull(p_area);
+ Area2DSW *area = area_owner.get_or_null(p_area);
ERR_FAIL_COND_V(!area, ObjectID());
return area->get_instance_id();
}
void PhysicsServer2DSW::area_attach_canvas_instance_id(RID p_area, ObjectID p_id) {
if (space_owner.owns(p_area)) {
- Space2DSW *space = space_owner.getornull(p_area);
+ Space2DSW *space = space_owner.get_or_null(p_area);
p_area = space->get_default_area()->get_self();
}
- Area2DSW *area = area_owner.getornull(p_area);
+ Area2DSW *area = area_owner.get_or_null(p_area);
ERR_FAIL_COND(!area);
area->set_canvas_instance_id(p_id);
}
ObjectID PhysicsServer2DSW::area_get_canvas_instance_id(RID p_area) const {
if (space_owner.owns(p_area)) {
- Space2DSW *space = space_owner.getornull(p_area);
+ Space2DSW *space = space_owner.get_or_null(p_area);
p_area = space->get_default_area()->get_self();
}
- Area2DSW *area = area_owner.getornull(p_area);
+ Area2DSW *area = area_owner.get_or_null(p_area);
ERR_FAIL_COND_V(!area, ObjectID());
return area->get_canvas_instance_id();
}
void PhysicsServer2DSW::area_set_param(RID p_area, AreaParameter p_param, const Variant &p_value) {
if (space_owner.owns(p_area)) {
- Space2DSW *space = space_owner.getornull(p_area);
+ Space2DSW *space = space_owner.get_or_null(p_area);
p_area = space->get_default_area()->get_self();
}
- Area2DSW *area = area_owner.getornull(p_area);
+ Area2DSW *area = area_owner.get_or_null(p_area);
ERR_FAIL_COND(!area);
area->set_param(p_param, p_value);
};
void PhysicsServer2DSW::area_set_transform(RID p_area, const Transform2D &p_transform) {
- Area2DSW *area = area_owner.getornull(p_area);
+ Area2DSW *area = area_owner.get_or_null(p_area);
ERR_FAIL_COND(!area);
area->set_transform(p_transform);
};
Variant PhysicsServer2DSW::area_get_param(RID p_area, AreaParameter p_param) const {
if (space_owner.owns(p_area)) {
- Space2DSW *space = space_owner.getornull(p_area);
+ Space2DSW *space = space_owner.get_or_null(p_area);
p_area = space->get_default_area()->get_self();
}
- Area2DSW *area = area_owner.getornull(p_area);
+ Area2DSW *area = area_owner.get_or_null(p_area);
ERR_FAIL_COND_V(!area, Variant());
return area->get_param(p_param);
};
Transform2D PhysicsServer2DSW::area_get_transform(RID p_area) const {
- Area2DSW *area = area_owner.getornull(p_area);
+ Area2DSW *area = area_owner.get_or_null(p_area);
ERR_FAIL_COND_V(!area, Transform2D());
return area->get_transform();
};
void PhysicsServer2DSW::area_set_pickable(RID p_area, bool p_pickable) {
- Area2DSW *area = area_owner.getornull(p_area);
+ Area2DSW *area = area_owner.get_or_null(p_area);
ERR_FAIL_COND(!area);
area->set_pickable(p_pickable);
}
void PhysicsServer2DSW::area_set_monitorable(RID p_area, bool p_monitorable) {
- Area2DSW *area = area_owner.getornull(p_area);
+ Area2DSW *area = area_owner.get_or_null(p_area);
ERR_FAIL_COND(!area);
FLUSH_QUERY_CHECK(area);
@@ -499,28 +499,28 @@ void PhysicsServer2DSW::area_set_monitorable(RID p_area, bool p_monitorable) {
}
void PhysicsServer2DSW::area_set_collision_mask(RID p_area, uint32_t p_mask) {
- Area2DSW *area = area_owner.getornull(p_area);
+ Area2DSW *area = area_owner.get_or_null(p_area);
ERR_FAIL_COND(!area);
area->set_collision_mask(p_mask);
}
void PhysicsServer2DSW::area_set_collision_layer(RID p_area, uint32_t p_layer) {
- Area2DSW *area = area_owner.getornull(p_area);
+ Area2DSW *area = area_owner.get_or_null(p_area);
ERR_FAIL_COND(!area);
area->set_collision_layer(p_layer);
}
void PhysicsServer2DSW::area_set_monitor_callback(RID p_area, Object *p_receiver, const StringName &p_method) {
- Area2DSW *area = area_owner.getornull(p_area);
+ Area2DSW *area = area_owner.get_or_null(p_area);
ERR_FAIL_COND(!area);
area->set_monitor_callback(p_receiver ? p_receiver->get_instance_id() : ObjectID(), p_method);
}
void PhysicsServer2DSW::area_set_area_monitor_callback(RID p_area, Object *p_receiver, const StringName &p_method) {
- Area2DSW *area = area_owner.getornull(p_area);
+ Area2DSW *area = area_owner.get_or_null(p_area);
ERR_FAIL_COND(!area);
area->set_area_monitor_callback(p_receiver ? p_receiver->get_instance_id() : ObjectID(), p_method);
@@ -536,11 +536,11 @@ RID PhysicsServer2DSW::body_create() {
}
void PhysicsServer2DSW::body_set_space(RID p_body, RID p_space) {
- Body2DSW *body = body_owner.getornull(p_body);
+ Body2DSW *body = body_owner.get_or_null(p_body);
ERR_FAIL_COND(!body);
Space2DSW *space = nullptr;
if (p_space.is_valid()) {
- space = space_owner.getornull(p_space);
+ space = space_owner.get_or_null(p_space);
ERR_FAIL_COND(!space);
}
@@ -553,7 +553,7 @@ void PhysicsServer2DSW::body_set_space(RID p_body, RID p_space) {
};
RID PhysicsServer2DSW::body_get_space(RID p_body) const {
- Body2DSW *body = body_owner.getornull(p_body);
+ Body2DSW *body = body_owner.get_or_null(p_body);
ERR_FAIL_COND_V(!body, RID());
Space2DSW *space = body->get_space();
@@ -564,7 +564,7 @@ RID PhysicsServer2DSW::body_get_space(RID p_body) const {
};
void PhysicsServer2DSW::body_set_mode(RID p_body, BodyMode p_mode) {
- Body2DSW *body = body_owner.getornull(p_body);
+ Body2DSW *body = body_owner.get_or_null(p_body);
ERR_FAIL_COND(!body);
FLUSH_QUERY_CHECK(body);
@@ -572,27 +572,27 @@ void PhysicsServer2DSW::body_set_mode(RID p_body, BodyMode p_mode) {
};
PhysicsServer2D::BodyMode PhysicsServer2DSW::body_get_mode(RID p_body) const {
- Body2DSW *body = body_owner.getornull(p_body);
+ Body2DSW *body = body_owner.get_or_null(p_body);
ERR_FAIL_COND_V(!body, BODY_MODE_STATIC);
return body->get_mode();
};
void PhysicsServer2DSW::body_add_shape(RID p_body, RID p_shape, const Transform2D &p_transform, bool p_disabled) {
- Body2DSW *body = body_owner.getornull(p_body);
+ Body2DSW *body = body_owner.get_or_null(p_body);
ERR_FAIL_COND(!body);
- Shape2DSW *shape = shape_owner.getornull(p_shape);
+ Shape2DSW *shape = shape_owner.get_or_null(p_shape);
ERR_FAIL_COND(!shape);
body->add_shape(shape, p_transform, p_disabled);
}
void PhysicsServer2DSW::body_set_shape(RID p_body, int p_shape_idx, RID p_shape) {
- Body2DSW *body = body_owner.getornull(p_body);
+ Body2DSW *body = body_owner.get_or_null(p_body);
ERR_FAIL_COND(!body);
- Shape2DSW *shape = shape_owner.getornull(p_shape);
+ Shape2DSW *shape = shape_owner.get_or_null(p_shape);
ERR_FAIL_COND(!shape);
ERR_FAIL_COND(!shape->is_configured());
@@ -600,33 +600,21 @@ void PhysicsServer2DSW::body_set_shape(RID p_body, int p_shape_idx, RID p_shape)
}
void PhysicsServer2DSW::body_set_shape_transform(RID p_body, int p_shape_idx, const Transform2D &p_transform) {
- Body2DSW *body = body_owner.getornull(p_body);
+ Body2DSW *body = body_owner.get_or_null(p_body);
ERR_FAIL_COND(!body);
body->set_shape_transform(p_shape_idx, p_transform);
}
-void PhysicsServer2DSW::body_set_shape_metadata(RID p_body, int p_shape_idx, const Variant &p_metadata) {
- Body2DSW *body = body_owner.getornull(p_body);
- ERR_FAIL_COND(!body);
- body->set_shape_metadata(p_shape_idx, p_metadata);
-}
-
-Variant PhysicsServer2DSW::body_get_shape_metadata(RID p_body, int p_shape_idx) const {
- Body2DSW *body = body_owner.getornull(p_body);
- ERR_FAIL_COND_V(!body, Variant());
- return body->get_shape_metadata(p_shape_idx);
-}
-
int PhysicsServer2DSW::body_get_shape_count(RID p_body) const {
- Body2DSW *body = body_owner.getornull(p_body);
+ Body2DSW *body = body_owner.get_or_null(p_body);
ERR_FAIL_COND_V(!body, -1);
return body->get_shape_count();
}
RID PhysicsServer2DSW::body_get_shape(RID p_body, int p_shape_idx) const {
- Body2DSW *body = body_owner.getornull(p_body);
+ Body2DSW *body = body_owner.get_or_null(p_body);
ERR_FAIL_COND_V(!body, RID());
Shape2DSW *shape = body->get_shape(p_shape_idx);
@@ -636,21 +624,21 @@ RID PhysicsServer2DSW::body_get_shape(RID p_body, int p_shape_idx) const {
}
Transform2D PhysicsServer2DSW::body_get_shape_transform(RID p_body, int p_shape_idx) const {
- Body2DSW *body = body_owner.getornull(p_body);
+ Body2DSW *body = body_owner.get_or_null(p_body);
ERR_FAIL_COND_V(!body, Transform2D());
return body->get_shape_transform(p_shape_idx);
}
void PhysicsServer2DSW::body_remove_shape(RID p_body, int p_shape_idx) {
- Body2DSW *body = body_owner.getornull(p_body);
+ Body2DSW *body = body_owner.get_or_null(p_body);
ERR_FAIL_COND(!body);
body->remove_shape(p_shape_idx);
}
void PhysicsServer2DSW::body_clear_shapes(RID p_body) {
- Body2DSW *body = body_owner.getornull(p_body);
+ Body2DSW *body = body_owner.get_or_null(p_body);
ERR_FAIL_COND(!body);
while (body->get_shape_count()) {
@@ -659,7 +647,7 @@ void PhysicsServer2DSW::body_clear_shapes(RID p_body) {
}
void PhysicsServer2DSW::body_set_shape_disabled(RID p_body, int p_shape_idx, bool p_disabled) {
- Body2DSW *body = body_owner.getornull(p_body);
+ Body2DSW *body = body_owner.get_or_null(p_body);
ERR_FAIL_COND(!body);
ERR_FAIL_INDEX(p_shape_idx, body->get_shape_count());
FLUSH_QUERY_CHECK(body);
@@ -668,7 +656,7 @@ void PhysicsServer2DSW::body_set_shape_disabled(RID p_body, int p_shape_idx, boo
}
void PhysicsServer2DSW::body_set_shape_as_one_way_collision(RID p_body, int p_shape_idx, bool p_enable, real_t p_margin) {
- Body2DSW *body = body_owner.getornull(p_body);
+ Body2DSW *body = body_owner.get_or_null(p_body);
ERR_FAIL_COND(!body);
ERR_FAIL_INDEX(p_shape_idx, body->get_shape_count());
FLUSH_QUERY_CHECK(body);
@@ -677,109 +665,109 @@ void PhysicsServer2DSW::body_set_shape_as_one_way_collision(RID p_body, int p_sh
}
void PhysicsServer2DSW::body_set_continuous_collision_detection_mode(RID p_body, CCDMode p_mode) {
- Body2DSW *body = body_owner.getornull(p_body);
+ Body2DSW *body = body_owner.get_or_null(p_body);
ERR_FAIL_COND(!body);
body->set_continuous_collision_detection_mode(p_mode);
}
PhysicsServer2DSW::CCDMode PhysicsServer2DSW::body_get_continuous_collision_detection_mode(RID p_body) const {
- const Body2DSW *body = body_owner.getornull(p_body);
+ const Body2DSW *body = body_owner.get_or_null(p_body);
ERR_FAIL_COND_V(!body, CCD_MODE_DISABLED);
return body->get_continuous_collision_detection_mode();
}
void PhysicsServer2DSW::body_attach_object_instance_id(RID p_body, ObjectID p_id) {
- Body2DSW *body = body_owner.getornull(p_body);
+ Body2DSW *body = body_owner.get_or_null(p_body);
ERR_FAIL_COND(!body);
body->set_instance_id(p_id);
};
ObjectID PhysicsServer2DSW::body_get_object_instance_id(RID p_body) const {
- Body2DSW *body = body_owner.getornull(p_body);
+ Body2DSW *body = body_owner.get_or_null(p_body);
ERR_FAIL_COND_V(!body, ObjectID());
return body->get_instance_id();
};
void PhysicsServer2DSW::body_attach_canvas_instance_id(RID p_body, ObjectID p_id) {
- Body2DSW *body = body_owner.getornull(p_body);
+ Body2DSW *body = body_owner.get_or_null(p_body);
ERR_FAIL_COND(!body);
body->set_canvas_instance_id(p_id);
};
ObjectID PhysicsServer2DSW::body_get_canvas_instance_id(RID p_body) const {
- Body2DSW *body = body_owner.getornull(p_body);
+ Body2DSW *body = body_owner.get_or_null(p_body);
ERR_FAIL_COND_V(!body, ObjectID());
return body->get_canvas_instance_id();
};
void PhysicsServer2DSW::body_set_collision_layer(RID p_body, uint32_t p_layer) {
- Body2DSW *body = body_owner.getornull(p_body);
+ Body2DSW *body = body_owner.get_or_null(p_body);
ERR_FAIL_COND(!body);
body->set_collision_layer(p_layer);
};
uint32_t PhysicsServer2DSW::body_get_collision_layer(RID p_body) const {
- Body2DSW *body = body_owner.getornull(p_body);
+ Body2DSW *body = body_owner.get_or_null(p_body);
ERR_FAIL_COND_V(!body, 0);
return body->get_collision_layer();
};
void PhysicsServer2DSW::body_set_collision_mask(RID p_body, uint32_t p_mask) {
- Body2DSW *body = body_owner.getornull(p_body);
+ Body2DSW *body = body_owner.get_or_null(p_body);
ERR_FAIL_COND(!body);
body->set_collision_mask(p_mask);
};
uint32_t PhysicsServer2DSW::body_get_collision_mask(RID p_body) const {
- Body2DSW *body = body_owner.getornull(p_body);
+ Body2DSW *body = body_owner.get_or_null(p_body);
ERR_FAIL_COND_V(!body, 0);
return body->get_collision_mask();
};
void PhysicsServer2DSW::body_set_param(RID p_body, BodyParameter p_param, const Variant &p_value) {
- Body2DSW *body = body_owner.getornull(p_body);
+ Body2DSW *body = body_owner.get_or_null(p_body);
ERR_FAIL_COND(!body);
body->set_param(p_param, p_value);
};
Variant PhysicsServer2DSW::body_get_param(RID p_body, BodyParameter p_param) const {
- Body2DSW *body = body_owner.getornull(p_body);
+ Body2DSW *body = body_owner.get_or_null(p_body);
ERR_FAIL_COND_V(!body, 0);
return body->get_param(p_param);
};
void PhysicsServer2DSW::body_reset_mass_properties(RID p_body) {
- Body2DSW *body = body_owner.getornull(p_body);
+ Body2DSW *body = body_owner.get_or_null(p_body);
ERR_FAIL_COND(!body);
return body->reset_mass_properties();
}
void PhysicsServer2DSW::body_set_state(RID p_body, BodyState p_state, const Variant &p_variant) {
- Body2DSW *body = body_owner.getornull(p_body);
+ Body2DSW *body = body_owner.get_or_null(p_body);
ERR_FAIL_COND(!body);
body->set_state(p_state, p_variant);
};
Variant PhysicsServer2DSW::body_get_state(RID p_body, BodyState p_state) const {
- Body2DSW *body = body_owner.getornull(p_body);
+ Body2DSW *body = body_owner.get_or_null(p_body);
ERR_FAIL_COND_V(!body, Variant());
return body->get_state(p_state);
};
void PhysicsServer2DSW::body_set_applied_force(RID p_body, const Vector2 &p_force) {
- Body2DSW *body = body_owner.getornull(p_body);
+ Body2DSW *body = body_owner.get_or_null(p_body);
ERR_FAIL_COND(!body);
body->set_applied_force(p_force);
@@ -787,13 +775,13 @@ void PhysicsServer2DSW::body_set_applied_force(RID p_body, const Vector2 &p_forc
};
Vector2 PhysicsServer2DSW::body_get_applied_force(RID p_body) const {
- Body2DSW *body = body_owner.getornull(p_body);
+ Body2DSW *body = body_owner.get_or_null(p_body);
ERR_FAIL_COND_V(!body, Vector2());
return body->get_applied_force();
};
void PhysicsServer2DSW::body_set_applied_torque(RID p_body, real_t p_torque) {
- Body2DSW *body = body_owner.getornull(p_body);
+ Body2DSW *body = body_owner.get_or_null(p_body);
ERR_FAIL_COND(!body);
body->set_applied_torque(p_torque);
@@ -801,14 +789,14 @@ void PhysicsServer2DSW::body_set_applied_torque(RID p_body, real_t p_torque) {
};
real_t PhysicsServer2DSW::body_get_applied_torque(RID p_body) const {
- Body2DSW *body = body_owner.getornull(p_body);
+ Body2DSW *body = body_owner.get_or_null(p_body);
ERR_FAIL_COND_V(!body, 0);
return body->get_applied_torque();
};
void PhysicsServer2DSW::body_apply_central_impulse(RID p_body, const Vector2 &p_impulse) {
- Body2DSW *body = body_owner.getornull(p_body);
+ Body2DSW *body = body_owner.get_or_null(p_body);
ERR_FAIL_COND(!body);
body->apply_central_impulse(p_impulse);
@@ -816,7 +804,7 @@ void PhysicsServer2DSW::body_apply_central_impulse(RID p_body, const Vector2 &p_
}
void PhysicsServer2DSW::body_apply_torque_impulse(RID p_body, real_t p_torque) {
- Body2DSW *body = body_owner.getornull(p_body);
+ Body2DSW *body = body_owner.get_or_null(p_body);
ERR_FAIL_COND(!body);
_update_shapes();
@@ -826,7 +814,7 @@ void PhysicsServer2DSW::body_apply_torque_impulse(RID p_body, real_t p_torque) {
}
void PhysicsServer2DSW::body_apply_impulse(RID p_body, const Vector2 &p_impulse, const Vector2 &p_position) {
- Body2DSW *body = body_owner.getornull(p_body);
+ Body2DSW *body = body_owner.get_or_null(p_body);
ERR_FAIL_COND(!body);
_update_shapes();
@@ -836,7 +824,7 @@ void PhysicsServer2DSW::body_apply_impulse(RID p_body, const Vector2 &p_impulse,
};
void PhysicsServer2DSW::body_add_central_force(RID p_body, const Vector2 &p_force) {
- Body2DSW *body = body_owner.getornull(p_body);
+ Body2DSW *body = body_owner.get_or_null(p_body);
ERR_FAIL_COND(!body);
body->add_central_force(p_force);
@@ -844,7 +832,7 @@ void PhysicsServer2DSW::body_add_central_force(RID p_body, const Vector2 &p_forc
};
void PhysicsServer2DSW::body_add_force(RID p_body, const Vector2 &p_force, const Vector2 &p_position) {
- Body2DSW *body = body_owner.getornull(p_body);
+ Body2DSW *body = body_owner.get_or_null(p_body);
ERR_FAIL_COND(!body);
body->add_force(p_force, p_position);
@@ -852,7 +840,7 @@ void PhysicsServer2DSW::body_add_force(RID p_body, const Vector2 &p_force, const
};
void PhysicsServer2DSW::body_add_torque(RID p_body, real_t p_torque) {
- Body2DSW *body = body_owner.getornull(p_body);
+ Body2DSW *body = body_owner.get_or_null(p_body);
ERR_FAIL_COND(!body);
body->add_torque(p_torque);
@@ -860,7 +848,7 @@ void PhysicsServer2DSW::body_add_torque(RID p_body, real_t p_torque) {
};
void PhysicsServer2DSW::body_set_axis_velocity(RID p_body, const Vector2 &p_axis_velocity) {
- Body2DSW *body = body_owner.getornull(p_body);
+ Body2DSW *body = body_owner.get_or_null(p_body);
ERR_FAIL_COND(!body);
_update_shapes();
@@ -874,7 +862,7 @@ void PhysicsServer2DSW::body_set_axis_velocity(RID p_body, const Vector2 &p_axis
};
void PhysicsServer2DSW::body_add_collision_exception(RID p_body, RID p_body_b) {
- Body2DSW *body = body_owner.getornull(p_body);
+ Body2DSW *body = body_owner.get_or_null(p_body);
ERR_FAIL_COND(!body);
body->add_exception(p_body_b);
@@ -882,7 +870,7 @@ void PhysicsServer2DSW::body_add_collision_exception(RID p_body, RID p_body_b) {
};
void PhysicsServer2DSW::body_remove_collision_exception(RID p_body, RID p_body_b) {
- Body2DSW *body = body_owner.getornull(p_body);
+ Body2DSW *body = body_owner.get_or_null(p_body);
ERR_FAIL_COND(!body);
body->remove_exception(p_body_b);
@@ -890,7 +878,7 @@ void PhysicsServer2DSW::body_remove_collision_exception(RID p_body, RID p_body_b
};
void PhysicsServer2DSW::body_get_collision_exceptions(RID p_body, List<RID> *p_exceptions) {
- Body2DSW *body = body_owner.getornull(p_body);
+ Body2DSW *body = body_owner.get_or_null(p_body);
ERR_FAIL_COND(!body);
for (int i = 0; i < body->get_exceptions().size(); i++) {
@@ -899,55 +887,55 @@ void PhysicsServer2DSW::body_get_collision_exceptions(RID p_body, List<RID> *p_e
};
void PhysicsServer2DSW::body_set_contacts_reported_depth_threshold(RID p_body, real_t p_threshold) {
- Body2DSW *body = body_owner.getornull(p_body);
+ Body2DSW *body = body_owner.get_or_null(p_body);
ERR_FAIL_COND(!body);
};
real_t PhysicsServer2DSW::body_get_contacts_reported_depth_threshold(RID p_body) const {
- Body2DSW *body = body_owner.getornull(p_body);
+ Body2DSW *body = body_owner.get_or_null(p_body);
ERR_FAIL_COND_V(!body, 0);
return 0;
};
void PhysicsServer2DSW::body_set_omit_force_integration(RID p_body, bool p_omit) {
- Body2DSW *body = body_owner.getornull(p_body);
+ Body2DSW *body = body_owner.get_or_null(p_body);
ERR_FAIL_COND(!body);
body->set_omit_force_integration(p_omit);
};
bool PhysicsServer2DSW::body_is_omitting_force_integration(RID p_body) const {
- Body2DSW *body = body_owner.getornull(p_body);
+ Body2DSW *body = body_owner.get_or_null(p_body);
ERR_FAIL_COND_V(!body, false);
return body->get_omit_force_integration();
};
void PhysicsServer2DSW::body_set_max_contacts_reported(RID p_body, int p_contacts) {
- Body2DSW *body = body_owner.getornull(p_body);
+ Body2DSW *body = body_owner.get_or_null(p_body);
ERR_FAIL_COND(!body);
body->set_max_contacts_reported(p_contacts);
}
int PhysicsServer2DSW::body_get_max_contacts_reported(RID p_body) const {
- Body2DSW *body = body_owner.getornull(p_body);
+ Body2DSW *body = body_owner.get_or_null(p_body);
ERR_FAIL_COND_V(!body, -1);
return body->get_max_contacts_reported();
}
void PhysicsServer2DSW::body_set_state_sync_callback(RID p_body, void *p_instance, BodyStateCallback p_callback) {
- Body2DSW *body = body_owner.getornull(p_body);
+ Body2DSW *body = body_owner.get_or_null(p_body);
ERR_FAIL_COND(!body);
body->set_state_sync_callback(p_instance, p_callback);
}
void PhysicsServer2DSW::body_set_force_integration_callback(RID p_body, const Callable &p_callable, const Variant &p_udata) {
- Body2DSW *body = body_owner.getornull(p_body);
+ Body2DSW *body = body_owner.get_or_null(p_body);
ERR_FAIL_COND(!body);
body->set_force_integration_callback(p_callable, p_udata);
}
bool PhysicsServer2DSW::body_collide_shape(RID p_body, int p_body_shape, RID p_shape, const Transform2D &p_shape_xform, const Vector2 &p_motion, Vector2 *r_results, int p_result_max, int &r_result_count) {
- Body2DSW *body = body_owner.getornull(p_body);
+ Body2DSW *body = body_owner.get_or_null(p_body);
ERR_FAIL_COND_V(!body, false);
ERR_FAIL_INDEX_V(p_body_shape, body->get_shape_count(), false);
@@ -955,13 +943,13 @@ bool PhysicsServer2DSW::body_collide_shape(RID p_body, int p_body_shape, RID p_s
}
void PhysicsServer2DSW::body_set_pickable(RID p_body, bool p_pickable) {
- Body2DSW *body = body_owner.getornull(p_body);
+ Body2DSW *body = body_owner.get_or_null(p_body);
ERR_FAIL_COND(!body);
body->set_pickable(p_pickable);
}
bool PhysicsServer2DSW::body_test_motion(RID p_body, const Transform2D &p_from, const Vector2 &p_motion, real_t p_margin, MotionResult *r_result, bool p_collide_separation_ray, const Set<RID> &p_exclude) {
- Body2DSW *body = body_owner.getornull(p_body);
+ Body2DSW *body = body_owner.get_or_null(p_body);
ERR_FAIL_COND_V(!body, false);
ERR_FAIL_COND_V(!body->get_space(), false);
ERR_FAIL_COND_V(body->get_space()->is_locked(), false);
@@ -974,7 +962,7 @@ bool PhysicsServer2DSW::body_test_motion(RID p_body, const Transform2D &p_from,
PhysicsDirectBodyState2D *PhysicsServer2DSW::body_get_direct_state(RID p_body) {
ERR_FAIL_COND_V_MSG((using_threads && !doing_sync), nullptr, "Body state is inaccessible right now, wait for iteration or physics process notification.");
- Body2DSW *body = body_owner.getornull(p_body);
+ Body2DSW *body = body_owner.get_or_null(p_body);
ERR_FAIL_COND_V(!body, nullptr);
ERR_FAIL_COND_V(!body->get_space(), nullptr);
@@ -993,7 +981,7 @@ RID PhysicsServer2DSW::joint_create() {
}
void PhysicsServer2DSW::joint_clear(RID p_joint) {
- Joint2DSW *joint = joint_owner.getornull(p_joint);
+ Joint2DSW *joint = joint_owner.get_or_null(p_joint);
if (joint->get_type() != JOINT_TYPE_MAX) {
Joint2DSW *empty_joint = memnew(Joint2DSW);
empty_joint->copy_settings_from(joint);
@@ -1004,7 +992,7 @@ void PhysicsServer2DSW::joint_clear(RID p_joint) {
}
void PhysicsServer2DSW::joint_set_param(RID p_joint, JointParam p_param, real_t p_value) {
- Joint2DSW *joint = joint_owner.getornull(p_joint);
+ Joint2DSW *joint = joint_owner.get_or_null(p_joint);
ERR_FAIL_COND(!joint);
switch (p_param) {
@@ -1021,7 +1009,7 @@ void PhysicsServer2DSW::joint_set_param(RID p_joint, JointParam p_param, real_t
}
real_t PhysicsServer2DSW::joint_get_param(RID p_joint, JointParam p_param) const {
- const Joint2DSW *joint = joint_owner.getornull(p_joint);
+ const Joint2DSW *joint = joint_owner.get_or_null(p_joint);
ERR_FAIL_COND_V(!joint, -1);
switch (p_param) {
@@ -1040,7 +1028,7 @@ real_t PhysicsServer2DSW::joint_get_param(RID p_joint, JointParam p_param) const
}
void PhysicsServer2DSW::joint_disable_collisions_between_bodies(RID p_joint, const bool p_disable) {
- Joint2DSW *joint = joint_owner.getornull(p_joint);
+ Joint2DSW *joint = joint_owner.get_or_null(p_joint);
ERR_FAIL_COND(!joint);
joint->disable_collisions_between_bodies(p_disable);
@@ -1060,22 +1048,22 @@ void PhysicsServer2DSW::joint_disable_collisions_between_bodies(RID p_joint, con
}
bool PhysicsServer2DSW::joint_is_disabled_collisions_between_bodies(RID p_joint) const {
- const Joint2DSW *joint = joint_owner.getornull(p_joint);
+ const Joint2DSW *joint = joint_owner.get_or_null(p_joint);
ERR_FAIL_COND_V(!joint, true);
return joint->is_disabled_collisions_between_bodies();
}
void PhysicsServer2DSW::joint_make_pin(RID p_joint, const Vector2 &p_pos, RID p_body_a, RID p_body_b) {
- Body2DSW *A = body_owner.getornull(p_body_a);
+ Body2DSW *A = body_owner.get_or_null(p_body_a);
ERR_FAIL_COND(!A);
Body2DSW *B = nullptr;
if (body_owner.owns(p_body_b)) {
- B = body_owner.getornull(p_body_b);
+ B = body_owner.get_or_null(p_body_b);
ERR_FAIL_COND(!B);
}
- Joint2DSW *prev_joint = joint_owner.getornull(p_joint);
+ Joint2DSW *prev_joint = joint_owner.get_or_null(p_joint);
ERR_FAIL_COND(prev_joint == nullptr);
Joint2DSW *joint = memnew(PinJoint2DSW(p_pos, A, B));
@@ -1086,13 +1074,13 @@ void PhysicsServer2DSW::joint_make_pin(RID p_joint, const Vector2 &p_pos, RID p_
}
void PhysicsServer2DSW::joint_make_groove(RID p_joint, const Vector2 &p_a_groove1, const Vector2 &p_a_groove2, const Vector2 &p_b_anchor, RID p_body_a, RID p_body_b) {
- Body2DSW *A = body_owner.getornull(p_body_a);
+ Body2DSW *A = body_owner.get_or_null(p_body_a);
ERR_FAIL_COND(!A);
- Body2DSW *B = body_owner.getornull(p_body_b);
+ Body2DSW *B = body_owner.get_or_null(p_body_b);
ERR_FAIL_COND(!B);
- Joint2DSW *prev_joint = joint_owner.getornull(p_joint);
+ Joint2DSW *prev_joint = joint_owner.get_or_null(p_joint);
ERR_FAIL_COND(prev_joint == nullptr);
Joint2DSW *joint = memnew(GrooveJoint2DSW(p_a_groove1, p_a_groove2, p_b_anchor, A, B));
@@ -1103,13 +1091,13 @@ void PhysicsServer2DSW::joint_make_groove(RID p_joint, const Vector2 &p_a_groove
}
void PhysicsServer2DSW::joint_make_damped_spring(RID p_joint, const Vector2 &p_anchor_a, const Vector2 &p_anchor_b, RID p_body_a, RID p_body_b) {
- Body2DSW *A = body_owner.getornull(p_body_a);
+ Body2DSW *A = body_owner.get_or_null(p_body_a);
ERR_FAIL_COND(!A);
- Body2DSW *B = body_owner.getornull(p_body_b);
+ Body2DSW *B = body_owner.get_or_null(p_body_b);
ERR_FAIL_COND(!B);
- Joint2DSW *prev_joint = joint_owner.getornull(p_joint);
+ Joint2DSW *prev_joint = joint_owner.get_or_null(p_joint);
ERR_FAIL_COND(prev_joint == nullptr);
Joint2DSW *joint = memnew(DampedSpringJoint2DSW(p_anchor_a, p_anchor_b, A, B));
@@ -1120,7 +1108,7 @@ void PhysicsServer2DSW::joint_make_damped_spring(RID p_joint, const Vector2 &p_a
}
void PhysicsServer2DSW::pin_joint_set_param(RID p_joint, PinJointParam p_param, real_t p_value) {
- Joint2DSW *j = joint_owner.getornull(p_joint);
+ Joint2DSW *j = joint_owner.get_or_null(p_joint);
ERR_FAIL_COND(!j);
ERR_FAIL_COND(j->get_type() != JOINT_TYPE_PIN);
@@ -1129,7 +1117,7 @@ void PhysicsServer2DSW::pin_joint_set_param(RID p_joint, PinJointParam p_param,
}
real_t PhysicsServer2DSW::pin_joint_get_param(RID p_joint, PinJointParam p_param) const {
- Joint2DSW *j = joint_owner.getornull(p_joint);
+ Joint2DSW *j = joint_owner.get_or_null(p_joint);
ERR_FAIL_COND_V(!j, 0);
ERR_FAIL_COND_V(j->get_type() != JOINT_TYPE_PIN, 0);
@@ -1138,7 +1126,7 @@ real_t PhysicsServer2DSW::pin_joint_get_param(RID p_joint, PinJointParam p_param
}
void PhysicsServer2DSW::damped_spring_joint_set_param(RID p_joint, DampedSpringParam p_param, real_t p_value) {
- Joint2DSW *j = joint_owner.getornull(p_joint);
+ Joint2DSW *j = joint_owner.get_or_null(p_joint);
ERR_FAIL_COND(!j);
ERR_FAIL_COND(j->get_type() != JOINT_TYPE_DAMPED_SPRING);
@@ -1147,7 +1135,7 @@ void PhysicsServer2DSW::damped_spring_joint_set_param(RID p_joint, DampedSpringP
}
real_t PhysicsServer2DSW::damped_spring_joint_get_param(RID p_joint, DampedSpringParam p_param) const {
- Joint2DSW *j = joint_owner.getornull(p_joint);
+ Joint2DSW *j = joint_owner.get_or_null(p_joint);
ERR_FAIL_COND_V(!j, 0);
ERR_FAIL_COND_V(j->get_type() != JOINT_TYPE_DAMPED_SPRING, 0);
@@ -1156,7 +1144,7 @@ real_t PhysicsServer2DSW::damped_spring_joint_get_param(RID p_joint, DampedSprin
}
PhysicsServer2D::JointType PhysicsServer2DSW::joint_get_type(RID p_joint) const {
- Joint2DSW *joint = joint_owner.getornull(p_joint);
+ Joint2DSW *joint = joint_owner.get_or_null(p_joint);
ERR_FAIL_COND_V(!joint, JOINT_TYPE_PIN);
return joint->get_type();
@@ -1166,7 +1154,7 @@ void PhysicsServer2DSW::free(RID p_rid) {
_update_shapes(); // just in case
if (shape_owner.owns(p_rid)) {
- Shape2DSW *shape = shape_owner.getornull(p_rid);
+ Shape2DSW *shape = shape_owner.get_or_null(p_rid);
while (shape->get_owners().size()) {
ShapeOwner2DSW *so = shape->get_owners().front()->key();
@@ -1176,7 +1164,7 @@ void PhysicsServer2DSW::free(RID p_rid) {
shape_owner.free(p_rid);
memdelete(shape);
} else if (body_owner.owns(p_rid)) {
- Body2DSW *body = body_owner.getornull(p_rid);
+ Body2DSW *body = body_owner.get_or_null(p_rid);
/*
if (body->get_state_query())
@@ -1196,7 +1184,7 @@ void PhysicsServer2DSW::free(RID p_rid) {
memdelete(body);
} else if (area_owner.owns(p_rid)) {
- Area2DSW *area = area_owner.getornull(p_rid);
+ Area2DSW *area = area_owner.get_or_null(p_rid);
/*
if (area->get_monitor_query())
@@ -1212,7 +1200,7 @@ void PhysicsServer2DSW::free(RID p_rid) {
area_owner.free(p_rid);
memdelete(area);
} else if (space_owner.owns(p_rid)) {
- Space2DSW *space = space_owner.getornull(p_rid);
+ Space2DSW *space = space_owner.get_or_null(p_rid);
while (space->get_objects().size()) {
CollisionObject2DSW *co = (CollisionObject2DSW *)space->get_objects().front()->get();
@@ -1224,7 +1212,7 @@ void PhysicsServer2DSW::free(RID p_rid) {
space_owner.free(p_rid);
memdelete(space);
} else if (joint_owner.owns(p_rid)) {
- Joint2DSW *joint = joint_owner.getornull(p_rid);
+ Joint2DSW *joint = joint_owner.get_or_null(p_rid);
joint_owner.free(p_rid);
memdelete(joint);
diff --git a/servers/physics_2d/physics_server_2d_sw.h b/servers/physics_2d/physics_server_2d_sw.h
index 1db4dd8343..1f35e83995 100644
--- a/servers/physics_2d/physics_server_2d_sw.h
+++ b/servers/physics_2d/physics_server_2d_sw.h
@@ -177,12 +177,10 @@ public:
virtual void body_add_shape(RID p_body, RID p_shape, const Transform2D &p_transform = Transform2D(), bool p_disabled = false) override;
virtual void body_set_shape(RID p_body, int p_shape_idx, RID p_shape) override;
virtual void body_set_shape_transform(RID p_body, int p_shape_idx, const Transform2D &p_transform) override;
- virtual void body_set_shape_metadata(RID p_body, int p_shape_idx, const Variant &p_metadata) override;
virtual int body_get_shape_count(RID p_body) const override;
virtual RID body_get_shape(RID p_body, int p_shape_idx) const override;
virtual Transform2D body_get_shape_transform(RID p_body, int p_shape_idx) const override;
- virtual Variant body_get_shape_metadata(RID p_body, int p_shape_idx) const override;
virtual void body_remove_shape(RID p_body, int p_shape_idx) override;
virtual void body_clear_shapes(RID p_body) override;
diff --git a/servers/physics_2d/physics_server_2d_wrap_mt.h b/servers/physics_2d/physics_server_2d_wrap_mt.h
index f8733863aa..7925344d76 100644
--- a/servers/physics_2d/physics_server_2d_wrap_mt.h
+++ b/servers/physics_2d/physics_server_2d_wrap_mt.h
@@ -184,11 +184,9 @@ public:
FUNC4(body_add_shape, RID, RID, const Transform2D &, bool);
FUNC3(body_set_shape, RID, int, RID);
FUNC3(body_set_shape_transform, RID, int, const Transform2D &);
- FUNC3(body_set_shape_metadata, RID, int, const Variant &);
FUNC1RC(int, body_get_shape_count, RID);
FUNC2RC(Transform2D, body_get_shape_transform, RID, int);
- FUNC2RC(Variant, body_get_shape_metadata, RID, int);
FUNC2RC(RID, body_get_shape, RID, int);
FUNC3(body_set_shape_disabled, RID, int, bool);
diff --git a/servers/physics_2d/shape_2d_sw.cpp b/servers/physics_2d/shape_2d_sw.cpp
index b5953bfdaf..bde882ac24 100644
--- a/servers/physics_2d/shape_2d_sw.cpp
+++ b/servers/physics_2d/shape_2d_sw.cpp
@@ -36,8 +36,8 @@
void Shape2DSW::configure(const Rect2 &p_aabb) {
aabb = p_aabb;
configured = true;
- for (Map<ShapeOwner2DSW *, int>::Element *E = owners.front(); E; E = E->next()) {
- ShapeOwner2DSW *co = (ShapeOwner2DSW *)E->key();
+ for (const KeyValue<ShapeOwner2DSW *, int> &E : owners) {
+ ShapeOwner2DSW *co = (ShapeOwner2DSW *)E.key;
co->_shape_changed();
}
}
@@ -875,9 +875,9 @@ void ConcavePolygonShape2DSW::set_data(const Variant &p_data) {
points.resize(pointmap.size());
aabb.position = pointmap.front()->key();
- for (Map<Point2, int>::Element *E = pointmap.front(); E; E = E->next()) {
- aabb.expand_to(E->key());
- points.write[E->get()] = E->key();
+ for (const KeyValue<Point2, int> &E : pointmap) {
+ aabb.expand_to(E.key);
+ points.write[E.value] = E.key;
}
Vector<BVH> main_vbh;
diff --git a/servers/physics_2d/space_2d_sw.cpp b/servers/physics_2d/space_2d_sw.cpp
index 1058f75407..5cd9bf3223 100644
--- a/servers/physics_2d/space_2d_sw.cpp
+++ b/servers/physics_2d/space_2d_sw.cpp
@@ -105,7 +105,6 @@ int PhysicsDirectSpaceState2DSW::_intersect_point_impl(const Vector2 &p_point, S
}
r_results[cc].rid = col_obj->get_self();
r_results[cc].shape = shape_idx;
- r_results[cc].metadata = col_obj->get_shape_metadata(shape_idx);
cc++;
}
@@ -193,7 +192,6 @@ bool PhysicsDirectSpaceState2DSW::intersect_ray(const Vector2 &p_from, const Vec
r_result.collider = ObjectDB::get_instance(r_result.collider_id);
}
r_result.normal = res_normal;
- r_result.metadata = res_obj->get_shape_metadata(res_shape);
r_result.position = res_point;
r_result.rid = res_obj->get_self();
r_result.shape = res_shape;
@@ -206,7 +204,7 @@ int PhysicsDirectSpaceState2DSW::intersect_shape(const RID &p_shape, const Trans
return 0;
}
- Shape2DSW *shape = PhysicsServer2DSW::singletonsw->shape_owner.getornull(p_shape);
+ Shape2DSW *shape = PhysicsServer2DSW::singletonsw->shape_owner.get_or_null(p_shape);
ERR_FAIL_COND_V(!shape, 0);
Rect2 aabb = p_xform.xform(shape->get_aabb());
@@ -242,7 +240,6 @@ int PhysicsDirectSpaceState2DSW::intersect_shape(const RID &p_shape, const Trans
}
r_results[cc].rid = col_obj->get_self();
r_results[cc].shape = shape_idx;
- r_results[cc].metadata = col_obj->get_shape_metadata(shape_idx);
cc++;
}
@@ -251,7 +248,7 @@ int PhysicsDirectSpaceState2DSW::intersect_shape(const RID &p_shape, const Trans
}
bool PhysicsDirectSpaceState2DSW::cast_motion(const RID &p_shape, const Transform2D &p_xform, const Vector2 &p_motion, real_t p_margin, real_t &p_closest_safe, real_t &p_closest_unsafe, const Set<RID> &p_exclude, uint32_t p_collision_mask, bool p_collide_with_bodies, bool p_collide_with_areas) {
- Shape2DSW *shape = PhysicsServer2DSW::singletonsw->shape_owner.getornull(p_shape);
+ Shape2DSW *shape = PhysicsServer2DSW::singletonsw->shape_owner.get_or_null(p_shape);
ERR_FAIL_COND_V(!shape, false);
Rect2 aabb = p_xform.xform(shape->get_aabb());
@@ -338,7 +335,7 @@ bool PhysicsDirectSpaceState2DSW::collide_shape(RID p_shape, const Transform2D &
return false;
}
- Shape2DSW *shape = PhysicsServer2DSW::singletonsw->shape_owner.getornull(p_shape);
+ Shape2DSW *shape = PhysicsServer2DSW::singletonsw->shape_owner.get_or_null(p_shape);
ERR_FAIL_COND_V(!shape, 0);
Rect2 aabb = p_shape_xform.xform(shape->get_aabb());
@@ -435,7 +432,7 @@ static void _rest_cbk_result(const Vector2 &p_point_A, const Vector2 &p_point_B,
}
bool PhysicsDirectSpaceState2DSW::rest_info(RID p_shape, const Transform2D &p_shape_xform, const Vector2 &p_motion, real_t p_margin, ShapeRestInfo *r_info, const Set<RID> &p_exclude, uint32_t p_collision_mask, bool p_collide_with_bodies, bool p_collide_with_areas) {
- Shape2DSW *shape = PhysicsServer2DSW::singletonsw->shape_owner.getornull(p_shape);
+ Shape2DSW *shape = PhysicsServer2DSW::singletonsw->shape_owner.get_or_null(p_shape);
ERR_FAIL_COND_V(!shape, 0);
real_t min_contact_depth = p_margin * TEST_MOTION_MIN_CONTACT_DEPTH_FACTOR;
@@ -484,7 +481,6 @@ bool PhysicsDirectSpaceState2DSW::rest_info(RID p_shape, const Transform2D &p_sh
r_info->normal = rcd.best_normal;
r_info->point = rcd.best_contact;
r_info->rid = rcd.best_object->get_self();
- r_info->metadata = rcd.best_object->get_shape_metadata(rcd.best_shape);
if (rcd.best_object->get_type() == CollisionObject2DSW::TYPE_BODY) {
const Body2DSW *body = static_cast<const Body2DSW *>(rcd.best_object);
Vector2 rel_vec = r_info->point - (body->get_transform().get_origin() + body->get_center_of_mass());
@@ -961,7 +957,6 @@ bool Space2DSW::test_body_motion(Body2DSW *p_body, const Transform2D &p_from, co
r_result->collision_depth = rcd.best_len;
r_result->collision_safe_fraction = safe;
r_result->collision_unsafe_fraction = unsafe;
- r_result->collider_metadata = rcd.best_object->get_shape_metadata(rcd.best_shape);
const Body2DSW *body = static_cast<const Body2DSW *>(rcd.best_object);
Vector2 rel_vec = r_result->collision_point - (body->get_transform().get_origin() + body->get_center_of_mass());
diff --git a/servers/physics_3d/body_3d_sw.cpp b/servers/physics_3d/body_3d_sw.cpp
index 91fe80a3dc..069374d122 100644
--- a/servers/physics_3d/body_3d_sw.cpp
+++ b/servers/physics_3d/body_3d_sw.cpp
@@ -688,13 +688,13 @@ void BodySW::simulate_motion(const Transform3D& p_xform,real_t p_step) {
*/
void Body3DSW::wakeup_neighbours() {
- for (Map<Constraint3DSW *, int>::Element *E = constraint_map.front(); E; E = E->next()) {
- const Constraint3DSW *c = E->key();
+ for (const KeyValue<Constraint3DSW *, int> &E : constraint_map) {
+ const Constraint3DSW *c = E.key;
Body3DSW **n = c->get_body_ptr();
int bc = c->get_body_count();
for (int i = 0; i < bc; i++) {
- if (i == E->get()) {
+ if (i == E.value) {
continue;
}
Body3DSW *b = n[i];
diff --git a/servers/physics_3d/physics_server_3d_sw.cpp b/servers/physics_3d/physics_server_3d_sw.cpp
index 8fbb0ba477..36f81e072d 100644
--- a/servers/physics_3d/physics_server_3d_sw.cpp
+++ b/servers/physics_3d/physics_server_3d_sw.cpp
@@ -102,25 +102,25 @@ RID PhysicsServer3DSW::custom_shape_create() {
}
void PhysicsServer3DSW::shape_set_data(RID p_shape, const Variant &p_data) {
- Shape3DSW *shape = shape_owner.getornull(p_shape);
+ Shape3DSW *shape = shape_owner.get_or_null(p_shape);
ERR_FAIL_COND(!shape);
shape->set_data(p_data);
};
void PhysicsServer3DSW::shape_set_custom_solver_bias(RID p_shape, real_t p_bias) {
- Shape3DSW *shape = shape_owner.getornull(p_shape);
+ Shape3DSW *shape = shape_owner.get_or_null(p_shape);
ERR_FAIL_COND(!shape);
shape->set_custom_bias(p_bias);
}
PhysicsServer3D::ShapeType PhysicsServer3DSW::shape_get_type(RID p_shape) const {
- const Shape3DSW *shape = shape_owner.getornull(p_shape);
+ const Shape3DSW *shape = shape_owner.get_or_null(p_shape);
ERR_FAIL_COND_V(!shape, SHAPE_CUSTOM);
return shape->get_type();
};
Variant PhysicsServer3DSW::shape_get_data(RID p_shape) const {
- const Shape3DSW *shape = shape_owner.getornull(p_shape);
+ const Shape3DSW *shape = shape_owner.get_or_null(p_shape);
ERR_FAIL_COND_V(!shape, Variant());
ERR_FAIL_COND_V(!shape->is_configured(), Variant());
return shape->get_data();
@@ -134,7 +134,7 @@ real_t PhysicsServer3DSW::shape_get_margin(RID p_shape) const {
}
real_t PhysicsServer3DSW::shape_get_custom_solver_bias(RID p_shape) const {
- const Shape3DSW *shape = shape_owner.getornull(p_shape);
+ const Shape3DSW *shape = shape_owner.get_or_null(p_shape);
ERR_FAIL_COND_V(!shape, 0);
return shape->get_custom_bias();
}
@@ -144,7 +144,7 @@ RID PhysicsServer3DSW::space_create() {
RID id = space_owner.make_rid(space);
space->set_self(id);
RID area_id = area_create();
- Area3DSW *area = area_owner.getornull(area_id);
+ Area3DSW *area = area_owner.get_or_null(area_id);
ERR_FAIL_COND_V(!area, RID());
space->set_default_area(area);
area->set_space(space);
@@ -158,7 +158,7 @@ RID PhysicsServer3DSW::space_create() {
};
void PhysicsServer3DSW::space_set_active(RID p_space, bool p_active) {
- Space3DSW *space = space_owner.getornull(p_space);
+ Space3DSW *space = space_owner.get_or_null(p_space);
ERR_FAIL_COND(!space);
if (p_active) {
active_spaces.insert(space);
@@ -168,27 +168,27 @@ void PhysicsServer3DSW::space_set_active(RID p_space, bool p_active) {
}
bool PhysicsServer3DSW::space_is_active(RID p_space) const {
- const Space3DSW *space = space_owner.getornull(p_space);
+ const Space3DSW *space = space_owner.get_or_null(p_space);
ERR_FAIL_COND_V(!space, false);
return active_spaces.has(space);
}
void PhysicsServer3DSW::space_set_param(RID p_space, SpaceParameter p_param, real_t p_value) {
- Space3DSW *space = space_owner.getornull(p_space);
+ Space3DSW *space = space_owner.get_or_null(p_space);
ERR_FAIL_COND(!space);
space->set_param(p_param, p_value);
}
real_t PhysicsServer3DSW::space_get_param(RID p_space, SpaceParameter p_param) const {
- const Space3DSW *space = space_owner.getornull(p_space);
+ const Space3DSW *space = space_owner.get_or_null(p_space);
ERR_FAIL_COND_V(!space, 0);
return space->get_param(p_param);
}
PhysicsDirectSpaceState3D *PhysicsServer3DSW::space_get_direct_state(RID p_space) {
- Space3DSW *space = space_owner.getornull(p_space);
+ Space3DSW *space = space_owner.get_or_null(p_space);
ERR_FAIL_COND_V(!space, nullptr);
ERR_FAIL_COND_V_MSG((using_threads && !doing_sync) || space->is_locked(), nullptr, "Space state is inaccessible right now, wait for iteration or physics process notification.");
@@ -196,19 +196,19 @@ PhysicsDirectSpaceState3D *PhysicsServer3DSW::space_get_direct_state(RID p_space
}
void PhysicsServer3DSW::space_set_debug_contacts(RID p_space, int p_max_contacts) {
- Space3DSW *space = space_owner.getornull(p_space);
+ Space3DSW *space = space_owner.get_or_null(p_space);
ERR_FAIL_COND(!space);
space->set_debug_contacts(p_max_contacts);
}
Vector<Vector3> PhysicsServer3DSW::space_get_contacts(RID p_space) const {
- Space3DSW *space = space_owner.getornull(p_space);
+ Space3DSW *space = space_owner.get_or_null(p_space);
ERR_FAIL_COND_V(!space, Vector<Vector3>());
return space->get_debug_contacts();
}
int PhysicsServer3DSW::space_get_contact_count(RID p_space) const {
- Space3DSW *space = space_owner.getornull(p_space);
+ Space3DSW *space = space_owner.get_or_null(p_space);
ERR_FAIL_COND_V(!space, 0);
return space->get_debug_contact_count();
}
@@ -221,12 +221,12 @@ RID PhysicsServer3DSW::area_create() {
};
void PhysicsServer3DSW::area_set_space(RID p_area, RID p_space) {
- Area3DSW *area = area_owner.getornull(p_area);
+ Area3DSW *area = area_owner.get_or_null(p_area);
ERR_FAIL_COND(!area);
Space3DSW *space = nullptr;
if (p_space.is_valid()) {
- space = space_owner.getornull(p_space);
+ space = space_owner.get_or_null(p_space);
ERR_FAIL_COND(!space);
}
@@ -239,7 +239,7 @@ void PhysicsServer3DSW::area_set_space(RID p_area, RID p_space) {
};
RID PhysicsServer3DSW::area_get_space(RID p_area) const {
- Area3DSW *area = area_owner.getornull(p_area);
+ Area3DSW *area = area_owner.get_or_null(p_area);
ERR_FAIL_COND_V(!area, RID());
Space3DSW *space = area->get_space();
@@ -250,34 +250,34 @@ RID PhysicsServer3DSW::area_get_space(RID p_area) const {
};
void PhysicsServer3DSW::area_set_space_override_mode(RID p_area, AreaSpaceOverrideMode p_mode) {
- Area3DSW *area = area_owner.getornull(p_area);
+ Area3DSW *area = area_owner.get_or_null(p_area);
ERR_FAIL_COND(!area);
area->set_space_override_mode(p_mode);
}
PhysicsServer3D::AreaSpaceOverrideMode PhysicsServer3DSW::area_get_space_override_mode(RID p_area) const {
- const Area3DSW *area = area_owner.getornull(p_area);
+ const Area3DSW *area = area_owner.get_or_null(p_area);
ERR_FAIL_COND_V(!area, AREA_SPACE_OVERRIDE_DISABLED);
return area->get_space_override_mode();
}
void PhysicsServer3DSW::area_add_shape(RID p_area, RID p_shape, const Transform3D &p_transform, bool p_disabled) {
- Area3DSW *area = area_owner.getornull(p_area);
+ Area3DSW *area = area_owner.get_or_null(p_area);
ERR_FAIL_COND(!area);
- Shape3DSW *shape = shape_owner.getornull(p_shape);
+ Shape3DSW *shape = shape_owner.get_or_null(p_shape);
ERR_FAIL_COND(!shape);
area->add_shape(shape, p_transform, p_disabled);
}
void PhysicsServer3DSW::area_set_shape(RID p_area, int p_shape_idx, RID p_shape) {
- Area3DSW *area = area_owner.getornull(p_area);
+ Area3DSW *area = area_owner.get_or_null(p_area);
ERR_FAIL_COND(!area);
- Shape3DSW *shape = shape_owner.getornull(p_shape);
+ Shape3DSW *shape = shape_owner.get_or_null(p_shape);
ERR_FAIL_COND(!shape);
ERR_FAIL_COND(!shape->is_configured());
@@ -285,21 +285,21 @@ void PhysicsServer3DSW::area_set_shape(RID p_area, int p_shape_idx, RID p_shape)
}
void PhysicsServer3DSW::area_set_shape_transform(RID p_area, int p_shape_idx, const Transform3D &p_transform) {
- Area3DSW *area = area_owner.getornull(p_area);
+ Area3DSW *area = area_owner.get_or_null(p_area);
ERR_FAIL_COND(!area);
area->set_shape_transform(p_shape_idx, p_transform);
}
int PhysicsServer3DSW::area_get_shape_count(RID p_area) const {
- Area3DSW *area = area_owner.getornull(p_area);
+ Area3DSW *area = area_owner.get_or_null(p_area);
ERR_FAIL_COND_V(!area, -1);
return area->get_shape_count();
}
RID PhysicsServer3DSW::area_get_shape(RID p_area, int p_shape_idx) const {
- Area3DSW *area = area_owner.getornull(p_area);
+ Area3DSW *area = area_owner.get_or_null(p_area);
ERR_FAIL_COND_V(!area, RID());
Shape3DSW *shape = area->get_shape(p_shape_idx);
@@ -309,21 +309,21 @@ RID PhysicsServer3DSW::area_get_shape(RID p_area, int p_shape_idx) const {
}
Transform3D PhysicsServer3DSW::area_get_shape_transform(RID p_area, int p_shape_idx) const {
- Area3DSW *area = area_owner.getornull(p_area);
+ Area3DSW *area = area_owner.get_or_null(p_area);
ERR_FAIL_COND_V(!area, Transform3D());
return area->get_shape_transform(p_shape_idx);
}
void PhysicsServer3DSW::area_remove_shape(RID p_area, int p_shape_idx) {
- Area3DSW *area = area_owner.getornull(p_area);
+ Area3DSW *area = area_owner.get_or_null(p_area);
ERR_FAIL_COND(!area);
area->remove_shape(p_shape_idx);
}
void PhysicsServer3DSW::area_clear_shapes(RID p_area) {
- Area3DSW *area = area_owner.getornull(p_area);
+ Area3DSW *area = area_owner.get_or_null(p_area);
ERR_FAIL_COND(!area);
while (area->get_shape_count()) {
@@ -332,7 +332,7 @@ void PhysicsServer3DSW::area_clear_shapes(RID p_area) {
}
void PhysicsServer3DSW::area_set_shape_disabled(RID p_area, int p_shape_idx, bool p_disabled) {
- Area3DSW *area = area_owner.getornull(p_area);
+ Area3DSW *area = area_owner.get_or_null(p_area);
ERR_FAIL_COND(!area);
ERR_FAIL_INDEX(p_shape_idx, area->get_shape_count());
FLUSH_QUERY_CHECK(area);
@@ -341,74 +341,74 @@ void PhysicsServer3DSW::area_set_shape_disabled(RID p_area, int p_shape_idx, boo
void PhysicsServer3DSW::area_attach_object_instance_id(RID p_area, ObjectID p_id) {
if (space_owner.owns(p_area)) {
- Space3DSW *space = space_owner.getornull(p_area);
+ Space3DSW *space = space_owner.get_or_null(p_area);
p_area = space->get_default_area()->get_self();
}
- Area3DSW *area = area_owner.getornull(p_area);
+ Area3DSW *area = area_owner.get_or_null(p_area);
ERR_FAIL_COND(!area);
area->set_instance_id(p_id);
}
ObjectID PhysicsServer3DSW::area_get_object_instance_id(RID p_area) const {
if (space_owner.owns(p_area)) {
- Space3DSW *space = space_owner.getornull(p_area);
+ Space3DSW *space = space_owner.get_or_null(p_area);
p_area = space->get_default_area()->get_self();
}
- Area3DSW *area = area_owner.getornull(p_area);
+ Area3DSW *area = area_owner.get_or_null(p_area);
ERR_FAIL_COND_V(!area, ObjectID());
return area->get_instance_id();
}
void PhysicsServer3DSW::area_set_param(RID p_area, AreaParameter p_param, const Variant &p_value) {
if (space_owner.owns(p_area)) {
- Space3DSW *space = space_owner.getornull(p_area);
+ Space3DSW *space = space_owner.get_or_null(p_area);
p_area = space->get_default_area()->get_self();
}
- Area3DSW *area = area_owner.getornull(p_area);
+ Area3DSW *area = area_owner.get_or_null(p_area);
ERR_FAIL_COND(!area);
area->set_param(p_param, p_value);
};
void PhysicsServer3DSW::area_set_transform(RID p_area, const Transform3D &p_transform) {
- Area3DSW *area = area_owner.getornull(p_area);
+ Area3DSW *area = area_owner.get_or_null(p_area);
ERR_FAIL_COND(!area);
area->set_transform(p_transform);
};
Variant PhysicsServer3DSW::area_get_param(RID p_area, AreaParameter p_param) const {
if (space_owner.owns(p_area)) {
- Space3DSW *space = space_owner.getornull(p_area);
+ Space3DSW *space = space_owner.get_or_null(p_area);
p_area = space->get_default_area()->get_self();
}
- Area3DSW *area = area_owner.getornull(p_area);
+ Area3DSW *area = area_owner.get_or_null(p_area);
ERR_FAIL_COND_V(!area, Variant());
return area->get_param(p_param);
};
Transform3D PhysicsServer3DSW::area_get_transform(RID p_area) const {
- Area3DSW *area = area_owner.getornull(p_area);
+ Area3DSW *area = area_owner.get_or_null(p_area);
ERR_FAIL_COND_V(!area, Transform3D());
return area->get_transform();
};
void PhysicsServer3DSW::area_set_collision_layer(RID p_area, uint32_t p_layer) {
- Area3DSW *area = area_owner.getornull(p_area);
+ Area3DSW *area = area_owner.get_or_null(p_area);
ERR_FAIL_COND(!area);
area->set_collision_layer(p_layer);
}
void PhysicsServer3DSW::area_set_collision_mask(RID p_area, uint32_t p_mask) {
- Area3DSW *area = area_owner.getornull(p_area);
+ Area3DSW *area = area_owner.get_or_null(p_area);
ERR_FAIL_COND(!area);
area->set_collision_mask(p_mask);
}
void PhysicsServer3DSW::area_set_monitorable(RID p_area, bool p_monitorable) {
- Area3DSW *area = area_owner.getornull(p_area);
+ Area3DSW *area = area_owner.get_or_null(p_area);
ERR_FAIL_COND(!area);
FLUSH_QUERY_CHECK(area);
@@ -416,21 +416,21 @@ void PhysicsServer3DSW::area_set_monitorable(RID p_area, bool p_monitorable) {
}
void PhysicsServer3DSW::area_set_monitor_callback(RID p_area, Object *p_receiver, const StringName &p_method) {
- Area3DSW *area = area_owner.getornull(p_area);
+ Area3DSW *area = area_owner.get_or_null(p_area);
ERR_FAIL_COND(!area);
area->set_monitor_callback(p_receiver ? p_receiver->get_instance_id() : ObjectID(), p_method);
}
void PhysicsServer3DSW::area_set_ray_pickable(RID p_area, bool p_enable) {
- Area3DSW *area = area_owner.getornull(p_area);
+ Area3DSW *area = area_owner.get_or_null(p_area);
ERR_FAIL_COND(!area);
area->set_ray_pickable(p_enable);
}
void PhysicsServer3DSW::area_set_area_monitor_callback(RID p_area, Object *p_receiver, const StringName &p_method) {
- Area3DSW *area = area_owner.getornull(p_area);
+ Area3DSW *area = area_owner.get_or_null(p_area);
ERR_FAIL_COND(!area);
area->set_area_monitor_callback(p_receiver ? p_receiver->get_instance_id() : ObjectID(), p_method);
@@ -446,12 +446,12 @@ RID PhysicsServer3DSW::body_create() {
};
void PhysicsServer3DSW::body_set_space(RID p_body, RID p_space) {
- Body3DSW *body = body_owner.getornull(p_body);
+ Body3DSW *body = body_owner.get_or_null(p_body);
ERR_FAIL_COND(!body);
Space3DSW *space = nullptr;
if (p_space.is_valid()) {
- space = space_owner.getornull(p_space);
+ space = space_owner.get_or_null(p_space);
ERR_FAIL_COND(!space);
}
@@ -464,7 +464,7 @@ void PhysicsServer3DSW::body_set_space(RID p_body, RID p_space) {
};
RID PhysicsServer3DSW::body_get_space(RID p_body) const {
- Body3DSW *body = body_owner.getornull(p_body);
+ Body3DSW *body = body_owner.get_or_null(p_body);
ERR_FAIL_COND_V(!body, RID());
Space3DSW *space = body->get_space();
@@ -475,55 +475,55 @@ RID PhysicsServer3DSW::body_get_space(RID p_body) const {
};
void PhysicsServer3DSW::body_set_mode(RID p_body, BodyMode p_mode) {
- Body3DSW *body = body_owner.getornull(p_body);
+ Body3DSW *body = body_owner.get_or_null(p_body);
ERR_FAIL_COND(!body);
body->set_mode(p_mode);
};
PhysicsServer3D::BodyMode PhysicsServer3DSW::body_get_mode(RID p_body) const {
- Body3DSW *body = body_owner.getornull(p_body);
+ Body3DSW *body = body_owner.get_or_null(p_body);
ERR_FAIL_COND_V(!body, BODY_MODE_STATIC);
return body->get_mode();
};
void PhysicsServer3DSW::body_add_shape(RID p_body, RID p_shape, const Transform3D &p_transform, bool p_disabled) {
- Body3DSW *body = body_owner.getornull(p_body);
+ Body3DSW *body = body_owner.get_or_null(p_body);
ERR_FAIL_COND(!body);
- Shape3DSW *shape = shape_owner.getornull(p_shape);
+ Shape3DSW *shape = shape_owner.get_or_null(p_shape);
ERR_FAIL_COND(!shape);
body->add_shape(shape, p_transform, p_disabled);
}
void PhysicsServer3DSW::body_set_shape(RID p_body, int p_shape_idx, RID p_shape) {
- Body3DSW *body = body_owner.getornull(p_body);
+ Body3DSW *body = body_owner.get_or_null(p_body);
ERR_FAIL_COND(!body);
- Shape3DSW *shape = shape_owner.getornull(p_shape);
+ Shape3DSW *shape = shape_owner.get_or_null(p_shape);
ERR_FAIL_COND(!shape);
ERR_FAIL_COND(!shape->is_configured());
body->set_shape(p_shape_idx, shape);
}
void PhysicsServer3DSW::body_set_shape_transform(RID p_body, int p_shape_idx, const Transform3D &p_transform) {
- Body3DSW *body = body_owner.getornull(p_body);
+ Body3DSW *body = body_owner.get_or_null(p_body);
ERR_FAIL_COND(!body);
body->set_shape_transform(p_shape_idx, p_transform);
}
int PhysicsServer3DSW::body_get_shape_count(RID p_body) const {
- Body3DSW *body = body_owner.getornull(p_body);
+ Body3DSW *body = body_owner.get_or_null(p_body);
ERR_FAIL_COND_V(!body, -1);
return body->get_shape_count();
}
RID PhysicsServer3DSW::body_get_shape(RID p_body, int p_shape_idx) const {
- Body3DSW *body = body_owner.getornull(p_body);
+ Body3DSW *body = body_owner.get_or_null(p_body);
ERR_FAIL_COND_V(!body, RID());
Shape3DSW *shape = body->get_shape(p_shape_idx);
@@ -533,7 +533,7 @@ RID PhysicsServer3DSW::body_get_shape(RID p_body, int p_shape_idx) const {
}
void PhysicsServer3DSW::body_set_shape_disabled(RID p_body, int p_shape_idx, bool p_disabled) {
- Body3DSW *body = body_owner.getornull(p_body);
+ Body3DSW *body = body_owner.get_or_null(p_body);
ERR_FAIL_COND(!body);
ERR_FAIL_INDEX(p_shape_idx, body->get_shape_count());
FLUSH_QUERY_CHECK(body);
@@ -542,21 +542,21 @@ void PhysicsServer3DSW::body_set_shape_disabled(RID p_body, int p_shape_idx, boo
}
Transform3D PhysicsServer3DSW::body_get_shape_transform(RID p_body, int p_shape_idx) const {
- Body3DSW *body = body_owner.getornull(p_body);
+ Body3DSW *body = body_owner.get_or_null(p_body);
ERR_FAIL_COND_V(!body, Transform3D());
return body->get_shape_transform(p_shape_idx);
}
void PhysicsServer3DSW::body_remove_shape(RID p_body, int p_shape_idx) {
- Body3DSW *body = body_owner.getornull(p_body);
+ Body3DSW *body = body_owner.get_or_null(p_body);
ERR_FAIL_COND(!body);
body->remove_shape(p_shape_idx);
}
void PhysicsServer3DSW::body_clear_shapes(RID p_body) {
- Body3DSW *body = body_owner.getornull(p_body);
+ Body3DSW *body = body_owner.get_or_null(p_body);
ERR_FAIL_COND(!body);
while (body->get_shape_count()) {
@@ -565,21 +565,21 @@ void PhysicsServer3DSW::body_clear_shapes(RID p_body) {
}
void PhysicsServer3DSW::body_set_enable_continuous_collision_detection(RID p_body, bool p_enable) {
- Body3DSW *body = body_owner.getornull(p_body);
+ Body3DSW *body = body_owner.get_or_null(p_body);
ERR_FAIL_COND(!body);
body->set_continuous_collision_detection(p_enable);
}
bool PhysicsServer3DSW::body_is_continuous_collision_detection_enabled(RID p_body) const {
- Body3DSW *body = body_owner.getornull(p_body);
+ Body3DSW *body = body_owner.get_or_null(p_body);
ERR_FAIL_COND_V(!body, false);
return body->is_continuous_collision_detection_enabled();
}
void PhysicsServer3DSW::body_set_collision_layer(RID p_body, uint32_t p_layer) {
- Body3DSW *body = body_owner.getornull(p_body);
+ Body3DSW *body = body_owner.get_or_null(p_body);
ERR_FAIL_COND(!body);
body->set_collision_layer(p_layer);
@@ -587,14 +587,14 @@ void PhysicsServer3DSW::body_set_collision_layer(RID p_body, uint32_t p_layer) {
}
uint32_t PhysicsServer3DSW::body_get_collision_layer(RID p_body) const {
- const Body3DSW *body = body_owner.getornull(p_body);
+ const Body3DSW *body = body_owner.get_or_null(p_body);
ERR_FAIL_COND_V(!body, 0);
return body->get_collision_layer();
}
void PhysicsServer3DSW::body_set_collision_mask(RID p_body, uint32_t p_mask) {
- Body3DSW *body = body_owner.getornull(p_body);
+ Body3DSW *body = body_owner.get_or_null(p_body);
ERR_FAIL_COND(!body);
body->set_collision_mask(p_mask);
@@ -602,20 +602,20 @@ void PhysicsServer3DSW::body_set_collision_mask(RID p_body, uint32_t p_mask) {
}
uint32_t PhysicsServer3DSW::body_get_collision_mask(RID p_body) const {
- const Body3DSW *body = body_owner.getornull(p_body);
+ const Body3DSW *body = body_owner.get_or_null(p_body);
ERR_FAIL_COND_V(!body, 0);
return body->get_collision_mask();
}
void PhysicsServer3DSW::body_attach_object_instance_id(RID p_body, ObjectID p_id) {
- Body3DSW *body = body_owner.getornull(p_body);
+ Body3DSW *body = body_owner.get_or_null(p_body);
if (body) {
body->set_instance_id(p_id);
return;
}
- SoftBody3DSW *soft_body = soft_body_owner.getornull(p_body);
+ SoftBody3DSW *soft_body = soft_body_owner.get_or_null(p_body);
if (soft_body) {
soft_body->set_instance_id(p_id);
return;
@@ -625,61 +625,61 @@ void PhysicsServer3DSW::body_attach_object_instance_id(RID p_body, ObjectID p_id
};
ObjectID PhysicsServer3DSW::body_get_object_instance_id(RID p_body) const {
- Body3DSW *body = body_owner.getornull(p_body);
+ Body3DSW *body = body_owner.get_or_null(p_body);
ERR_FAIL_COND_V(!body, ObjectID());
return body->get_instance_id();
};
void PhysicsServer3DSW::body_set_user_flags(RID p_body, uint32_t p_flags) {
- Body3DSW *body = body_owner.getornull(p_body);
+ Body3DSW *body = body_owner.get_or_null(p_body);
ERR_FAIL_COND(!body);
};
uint32_t PhysicsServer3DSW::body_get_user_flags(RID p_body) const {
- Body3DSW *body = body_owner.getornull(p_body);
+ Body3DSW *body = body_owner.get_or_null(p_body);
ERR_FAIL_COND_V(!body, 0);
return 0;
};
void PhysicsServer3DSW::body_set_param(RID p_body, BodyParameter p_param, const Variant &p_value) {
- Body3DSW *body = body_owner.getornull(p_body);
+ Body3DSW *body = body_owner.get_or_null(p_body);
ERR_FAIL_COND(!body);
body->set_param(p_param, p_value);
};
Variant PhysicsServer3DSW::body_get_param(RID p_body, BodyParameter p_param) const {
- Body3DSW *body = body_owner.getornull(p_body);
+ Body3DSW *body = body_owner.get_or_null(p_body);
ERR_FAIL_COND_V(!body, 0);
return body->get_param(p_param);
};
void PhysicsServer3DSW::body_reset_mass_properties(RID p_body) {
- Body3DSW *body = body_owner.getornull(p_body);
+ Body3DSW *body = body_owner.get_or_null(p_body);
ERR_FAIL_COND(!body);
return body->reset_mass_properties();
}
void PhysicsServer3DSW::body_set_state(RID p_body, BodyState p_state, const Variant &p_variant) {
- Body3DSW *body = body_owner.getornull(p_body);
+ Body3DSW *body = body_owner.get_or_null(p_body);
ERR_FAIL_COND(!body);
body->set_state(p_state, p_variant);
};
Variant PhysicsServer3DSW::body_get_state(RID p_body, BodyState p_state) const {
- Body3DSW *body = body_owner.getornull(p_body);
+ Body3DSW *body = body_owner.get_or_null(p_body);
ERR_FAIL_COND_V(!body, Variant());
return body->get_state(p_state);
};
void PhysicsServer3DSW::body_set_applied_force(RID p_body, const Vector3 &p_force) {
- Body3DSW *body = body_owner.getornull(p_body);
+ Body3DSW *body = body_owner.get_or_null(p_body);
ERR_FAIL_COND(!body);
body->set_applied_force(p_force);
@@ -687,13 +687,13 @@ void PhysicsServer3DSW::body_set_applied_force(RID p_body, const Vector3 &p_forc
};
Vector3 PhysicsServer3DSW::body_get_applied_force(RID p_body) const {
- Body3DSW *body = body_owner.getornull(p_body);
+ Body3DSW *body = body_owner.get_or_null(p_body);
ERR_FAIL_COND_V(!body, Vector3());
return body->get_applied_force();
};
void PhysicsServer3DSW::body_set_applied_torque(RID p_body, const Vector3 &p_torque) {
- Body3DSW *body = body_owner.getornull(p_body);
+ Body3DSW *body = body_owner.get_or_null(p_body);
ERR_FAIL_COND(!body);
body->set_applied_torque(p_torque);
@@ -701,14 +701,14 @@ void PhysicsServer3DSW::body_set_applied_torque(RID p_body, const Vector3 &p_tor
};
Vector3 PhysicsServer3DSW::body_get_applied_torque(RID p_body) const {
- Body3DSW *body = body_owner.getornull(p_body);
+ Body3DSW *body = body_owner.get_or_null(p_body);
ERR_FAIL_COND_V(!body, Vector3());
return body->get_applied_torque();
};
void PhysicsServer3DSW::body_add_central_force(RID p_body, const Vector3 &p_force) {
- Body3DSW *body = body_owner.getornull(p_body);
+ Body3DSW *body = body_owner.get_or_null(p_body);
ERR_FAIL_COND(!body);
body->add_central_force(p_force);
@@ -716,7 +716,7 @@ void PhysicsServer3DSW::body_add_central_force(RID p_body, const Vector3 &p_forc
}
void PhysicsServer3DSW::body_add_force(RID p_body, const Vector3 &p_force, const Vector3 &p_position) {
- Body3DSW *body = body_owner.getornull(p_body);
+ Body3DSW *body = body_owner.get_or_null(p_body);
ERR_FAIL_COND(!body);
body->add_force(p_force, p_position);
@@ -724,7 +724,7 @@ void PhysicsServer3DSW::body_add_force(RID p_body, const Vector3 &p_force, const
};
void PhysicsServer3DSW::body_add_torque(RID p_body, const Vector3 &p_torque) {
- Body3DSW *body = body_owner.getornull(p_body);
+ Body3DSW *body = body_owner.get_or_null(p_body);
ERR_FAIL_COND(!body);
body->add_torque(p_torque);
@@ -732,7 +732,7 @@ void PhysicsServer3DSW::body_add_torque(RID p_body, const Vector3 &p_torque) {
};
void PhysicsServer3DSW::body_apply_central_impulse(RID p_body, const Vector3 &p_impulse) {
- Body3DSW *body = body_owner.getornull(p_body);
+ Body3DSW *body = body_owner.get_or_null(p_body);
ERR_FAIL_COND(!body);
_update_shapes();
@@ -742,7 +742,7 @@ void PhysicsServer3DSW::body_apply_central_impulse(RID p_body, const Vector3 &p_
}
void PhysicsServer3DSW::body_apply_impulse(RID p_body, const Vector3 &p_impulse, const Vector3 &p_position) {
- Body3DSW *body = body_owner.getornull(p_body);
+ Body3DSW *body = body_owner.get_or_null(p_body);
ERR_FAIL_COND(!body);
_update_shapes();
@@ -752,7 +752,7 @@ void PhysicsServer3DSW::body_apply_impulse(RID p_body, const Vector3 &p_impulse,
};
void PhysicsServer3DSW::body_apply_torque_impulse(RID p_body, const Vector3 &p_impulse) {
- Body3DSW *body = body_owner.getornull(p_body);
+ Body3DSW *body = body_owner.get_or_null(p_body);
ERR_FAIL_COND(!body);
_update_shapes();
@@ -762,7 +762,7 @@ void PhysicsServer3DSW::body_apply_torque_impulse(RID p_body, const Vector3 &p_i
};
void PhysicsServer3DSW::body_set_axis_velocity(RID p_body, const Vector3 &p_axis_velocity) {
- Body3DSW *body = body_owner.getornull(p_body);
+ Body3DSW *body = body_owner.get_or_null(p_body);
ERR_FAIL_COND(!body);
_update_shapes();
@@ -776,7 +776,7 @@ void PhysicsServer3DSW::body_set_axis_velocity(RID p_body, const Vector3 &p_axis
};
void PhysicsServer3DSW::body_set_axis_lock(RID p_body, BodyAxis p_axis, bool p_lock) {
- Body3DSW *body = body_owner.getornull(p_body);
+ Body3DSW *body = body_owner.get_or_null(p_body);
ERR_FAIL_COND(!body);
body->set_axis_lock(p_axis, p_lock);
@@ -784,13 +784,13 @@ void PhysicsServer3DSW::body_set_axis_lock(RID p_body, BodyAxis p_axis, bool p_l
}
bool PhysicsServer3DSW::body_is_axis_locked(RID p_body, BodyAxis p_axis) const {
- const Body3DSW *body = body_owner.getornull(p_body);
+ const Body3DSW *body = body_owner.get_or_null(p_body);
ERR_FAIL_COND_V(!body, 0);
return body->is_axis_locked(p_axis);
}
void PhysicsServer3DSW::body_add_collision_exception(RID p_body, RID p_body_b) {
- Body3DSW *body = body_owner.getornull(p_body);
+ Body3DSW *body = body_owner.get_or_null(p_body);
ERR_FAIL_COND(!body);
body->add_exception(p_body_b);
@@ -798,7 +798,7 @@ void PhysicsServer3DSW::body_add_collision_exception(RID p_body, RID p_body_b) {
};
void PhysicsServer3DSW::body_remove_collision_exception(RID p_body, RID p_body_b) {
- Body3DSW *body = body_owner.getornull(p_body);
+ Body3DSW *body = body_owner.get_or_null(p_body);
ERR_FAIL_COND(!body);
body->remove_exception(p_body_b);
@@ -806,7 +806,7 @@ void PhysicsServer3DSW::body_remove_collision_exception(RID p_body, RID p_body_b
};
void PhysicsServer3DSW::body_get_collision_exceptions(RID p_body, List<RID> *p_exceptions) {
- Body3DSW *body = body_owner.getornull(p_body);
+ Body3DSW *body = body_owner.get_or_null(p_body);
ERR_FAIL_COND(!body);
for (int i = 0; i < body->get_exceptions().size(); i++) {
@@ -815,61 +815,61 @@ void PhysicsServer3DSW::body_get_collision_exceptions(RID p_body, List<RID> *p_e
};
void PhysicsServer3DSW::body_set_contacts_reported_depth_threshold(RID p_body, real_t p_threshold) {
- Body3DSW *body = body_owner.getornull(p_body);
+ Body3DSW *body = body_owner.get_or_null(p_body);
ERR_FAIL_COND(!body);
};
real_t PhysicsServer3DSW::body_get_contacts_reported_depth_threshold(RID p_body) const {
- Body3DSW *body = body_owner.getornull(p_body);
+ Body3DSW *body = body_owner.get_or_null(p_body);
ERR_FAIL_COND_V(!body, 0);
return 0;
};
void PhysicsServer3DSW::body_set_omit_force_integration(RID p_body, bool p_omit) {
- Body3DSW *body = body_owner.getornull(p_body);
+ Body3DSW *body = body_owner.get_or_null(p_body);
ERR_FAIL_COND(!body);
body->set_omit_force_integration(p_omit);
};
bool PhysicsServer3DSW::body_is_omitting_force_integration(RID p_body) const {
- Body3DSW *body = body_owner.getornull(p_body);
+ Body3DSW *body = body_owner.get_or_null(p_body);
ERR_FAIL_COND_V(!body, false);
return body->get_omit_force_integration();
};
void PhysicsServer3DSW::body_set_max_contacts_reported(RID p_body, int p_contacts) {
- Body3DSW *body = body_owner.getornull(p_body);
+ Body3DSW *body = body_owner.get_or_null(p_body);
ERR_FAIL_COND(!body);
body->set_max_contacts_reported(p_contacts);
}
int PhysicsServer3DSW::body_get_max_contacts_reported(RID p_body) const {
- Body3DSW *body = body_owner.getornull(p_body);
+ Body3DSW *body = body_owner.get_or_null(p_body);
ERR_FAIL_COND_V(!body, -1);
return body->get_max_contacts_reported();
}
void PhysicsServer3DSW::body_set_state_sync_callback(RID p_body, void *p_instance, BodyStateCallback p_callback) {
- Body3DSW *body = body_owner.getornull(p_body);
+ Body3DSW *body = body_owner.get_or_null(p_body);
ERR_FAIL_COND(!body);
body->set_state_sync_callback(p_instance, p_callback);
}
void PhysicsServer3DSW::body_set_force_integration_callback(RID p_body, const Callable &p_callable, const Variant &p_udata) {
- Body3DSW *body = body_owner.getornull(p_body);
+ Body3DSW *body = body_owner.get_or_null(p_body);
ERR_FAIL_COND(!body);
body->set_force_integration_callback(p_callable, p_udata);
}
void PhysicsServer3DSW::body_set_ray_pickable(RID p_body, bool p_enable) {
- Body3DSW *body = body_owner.getornull(p_body);
+ Body3DSW *body = body_owner.get_or_null(p_body);
ERR_FAIL_COND(!body);
body->set_ray_pickable(p_enable);
}
bool PhysicsServer3DSW::body_test_motion(RID p_body, const Transform3D &p_from, const Vector3 &p_motion, real_t p_margin, MotionResult *r_result, int p_max_collisions, bool p_collide_separation_ray, const Set<RID> &p_exclude) {
- Body3DSW *body = body_owner.getornull(p_body);
+ Body3DSW *body = body_owner.get_or_null(p_body);
ERR_FAIL_COND_V(!body, false);
ERR_FAIL_COND_V(!body->get_space(), false);
ERR_FAIL_COND_V(body->get_space()->is_locked(), false);
@@ -882,7 +882,7 @@ bool PhysicsServer3DSW::body_test_motion(RID p_body, const Transform3D &p_from,
PhysicsDirectBodyState3D *PhysicsServer3DSW::body_get_direct_state(RID p_body) {
ERR_FAIL_COND_V_MSG((using_threads && !doing_sync), nullptr, "Body state is inaccessible right now, wait for iteration or physics process notification.");
- Body3DSW *body = body_owner.getornull(p_body);
+ Body3DSW *body = body_owner.get_or_null(p_body);
ERR_FAIL_NULL_V(body, nullptr);
ERR_FAIL_NULL_V(body->get_space(), nullptr);
@@ -901,19 +901,19 @@ RID PhysicsServer3DSW::soft_body_create() {
}
void PhysicsServer3DSW::soft_body_update_rendering_server(RID p_body, RenderingServerHandler *p_rendering_server_handler) {
- SoftBody3DSW *soft_body = soft_body_owner.getornull(p_body);
+ SoftBody3DSW *soft_body = soft_body_owner.get_or_null(p_body);
ERR_FAIL_COND(!soft_body);
soft_body->update_rendering_server(p_rendering_server_handler);
}
void PhysicsServer3DSW::soft_body_set_space(RID p_body, RID p_space) {
- SoftBody3DSW *soft_body = soft_body_owner.getornull(p_body);
+ SoftBody3DSW *soft_body = soft_body_owner.get_or_null(p_body);
ERR_FAIL_COND(!soft_body);
Space3DSW *space = nullptr;
if (p_space.is_valid()) {
- space = space_owner.getornull(p_space);
+ space = space_owner.get_or_null(p_space);
ERR_FAIL_COND(!space);
}
@@ -925,7 +925,7 @@ void PhysicsServer3DSW::soft_body_set_space(RID p_body, RID p_space) {
}
RID PhysicsServer3DSW::soft_body_get_space(RID p_body) const {
- SoftBody3DSW *soft_body = soft_body_owner.getornull(p_body);
+ SoftBody3DSW *soft_body = soft_body_owner.get_or_null(p_body);
ERR_FAIL_COND_V(!soft_body, RID());
Space3DSW *space = soft_body->get_space();
@@ -936,49 +936,49 @@ RID PhysicsServer3DSW::soft_body_get_space(RID p_body) const {
}
void PhysicsServer3DSW::soft_body_set_collision_layer(RID p_body, uint32_t p_layer) {
- SoftBody3DSW *soft_body = soft_body_owner.getornull(p_body);
+ SoftBody3DSW *soft_body = soft_body_owner.get_or_null(p_body);
ERR_FAIL_COND(!soft_body);
soft_body->set_collision_layer(p_layer);
}
uint32_t PhysicsServer3DSW::soft_body_get_collision_layer(RID p_body) const {
- SoftBody3DSW *soft_body = soft_body_owner.getornull(p_body);
+ SoftBody3DSW *soft_body = soft_body_owner.get_or_null(p_body);
ERR_FAIL_COND_V(!soft_body, 0);
return soft_body->get_collision_layer();
}
void PhysicsServer3DSW::soft_body_set_collision_mask(RID p_body, uint32_t p_mask) {
- SoftBody3DSW *soft_body = soft_body_owner.getornull(p_body);
+ SoftBody3DSW *soft_body = soft_body_owner.get_or_null(p_body);
ERR_FAIL_COND(!soft_body);
soft_body->set_collision_mask(p_mask);
}
uint32_t PhysicsServer3DSW::soft_body_get_collision_mask(RID p_body) const {
- SoftBody3DSW *soft_body = soft_body_owner.getornull(p_body);
+ SoftBody3DSW *soft_body = soft_body_owner.get_or_null(p_body);
ERR_FAIL_COND_V(!soft_body, 0);
return soft_body->get_collision_mask();
}
void PhysicsServer3DSW::soft_body_add_collision_exception(RID p_body, RID p_body_b) {
- SoftBody3DSW *soft_body = soft_body_owner.getornull(p_body);
+ SoftBody3DSW *soft_body = soft_body_owner.get_or_null(p_body);
ERR_FAIL_COND(!soft_body);
soft_body->add_exception(p_body_b);
}
void PhysicsServer3DSW::soft_body_remove_collision_exception(RID p_body, RID p_body_b) {
- SoftBody3DSW *soft_body = soft_body_owner.getornull(p_body);
+ SoftBody3DSW *soft_body = soft_body_owner.get_or_null(p_body);
ERR_FAIL_COND(!soft_body);
soft_body->remove_exception(p_body_b);
}
void PhysicsServer3DSW::soft_body_get_collision_exceptions(RID p_body, List<RID> *p_exceptions) {
- SoftBody3DSW *soft_body = soft_body_owner.getornull(p_body);
+ SoftBody3DSW *soft_body = soft_body_owner.get_or_null(p_body);
ERR_FAIL_COND(!soft_body);
for (int i = 0; i < soft_body->get_exceptions().size(); i++) {
@@ -987,154 +987,154 @@ void PhysicsServer3DSW::soft_body_get_collision_exceptions(RID p_body, List<RID>
}
void PhysicsServer3DSW::soft_body_set_state(RID p_body, BodyState p_state, const Variant &p_variant) {
- SoftBody3DSW *soft_body = soft_body_owner.getornull(p_body);
+ SoftBody3DSW *soft_body = soft_body_owner.get_or_null(p_body);
ERR_FAIL_COND(!soft_body);
soft_body->set_state(p_state, p_variant);
}
Variant PhysicsServer3DSW::soft_body_get_state(RID p_body, BodyState p_state) const {
- SoftBody3DSW *soft_body = soft_body_owner.getornull(p_body);
+ SoftBody3DSW *soft_body = soft_body_owner.get_or_null(p_body);
ERR_FAIL_COND_V(!soft_body, Variant());
return soft_body->get_state(p_state);
}
void PhysicsServer3DSW::soft_body_set_transform(RID p_body, const Transform3D &p_transform) {
- SoftBody3DSW *soft_body = soft_body_owner.getornull(p_body);
+ SoftBody3DSW *soft_body = soft_body_owner.get_or_null(p_body);
ERR_FAIL_COND(!soft_body);
soft_body->set_state(BODY_STATE_TRANSFORM, p_transform);
}
void PhysicsServer3DSW::soft_body_set_ray_pickable(RID p_body, bool p_enable) {
- SoftBody3DSW *soft_body = soft_body_owner.getornull(p_body);
+ SoftBody3DSW *soft_body = soft_body_owner.get_or_null(p_body);
ERR_FAIL_COND(!soft_body);
soft_body->set_ray_pickable(p_enable);
}
void PhysicsServer3DSW::soft_body_set_simulation_precision(RID p_body, int p_simulation_precision) {
- SoftBody3DSW *soft_body = soft_body_owner.getornull(p_body);
+ SoftBody3DSW *soft_body = soft_body_owner.get_or_null(p_body);
ERR_FAIL_COND(!soft_body);
soft_body->set_iteration_count(p_simulation_precision);
}
int PhysicsServer3DSW::soft_body_get_simulation_precision(RID p_body) const {
- SoftBody3DSW *soft_body = soft_body_owner.getornull(p_body);
+ SoftBody3DSW *soft_body = soft_body_owner.get_or_null(p_body);
ERR_FAIL_COND_V(!soft_body, 0.f);
return soft_body->get_iteration_count();
}
void PhysicsServer3DSW::soft_body_set_total_mass(RID p_body, real_t p_total_mass) {
- SoftBody3DSW *soft_body = soft_body_owner.getornull(p_body);
+ SoftBody3DSW *soft_body = soft_body_owner.get_or_null(p_body);
ERR_FAIL_COND(!soft_body);
soft_body->set_total_mass(p_total_mass);
}
real_t PhysicsServer3DSW::soft_body_get_total_mass(RID p_body) const {
- SoftBody3DSW *soft_body = soft_body_owner.getornull(p_body);
+ SoftBody3DSW *soft_body = soft_body_owner.get_or_null(p_body);
ERR_FAIL_COND_V(!soft_body, 0.f);
return soft_body->get_total_mass();
}
void PhysicsServer3DSW::soft_body_set_linear_stiffness(RID p_body, real_t p_stiffness) {
- SoftBody3DSW *soft_body = soft_body_owner.getornull(p_body);
+ SoftBody3DSW *soft_body = soft_body_owner.get_or_null(p_body);
ERR_FAIL_COND(!soft_body);
soft_body->set_linear_stiffness(p_stiffness);
}
real_t PhysicsServer3DSW::soft_body_get_linear_stiffness(RID p_body) const {
- SoftBody3DSW *soft_body = soft_body_owner.getornull(p_body);
+ SoftBody3DSW *soft_body = soft_body_owner.get_or_null(p_body);
ERR_FAIL_COND_V(!soft_body, 0.f);
return soft_body->get_linear_stiffness();
}
void PhysicsServer3DSW::soft_body_set_pressure_coefficient(RID p_body, real_t p_pressure_coefficient) {
- SoftBody3DSW *soft_body = soft_body_owner.getornull(p_body);
+ SoftBody3DSW *soft_body = soft_body_owner.get_or_null(p_body);
ERR_FAIL_COND(!soft_body);
soft_body->set_pressure_coefficient(p_pressure_coefficient);
}
real_t PhysicsServer3DSW::soft_body_get_pressure_coefficient(RID p_body) const {
- SoftBody3DSW *soft_body = soft_body_owner.getornull(p_body);
+ SoftBody3DSW *soft_body = soft_body_owner.get_or_null(p_body);
ERR_FAIL_COND_V(!soft_body, 0.f);
return soft_body->get_pressure_coefficient();
}
void PhysicsServer3DSW::soft_body_set_damping_coefficient(RID p_body, real_t p_damping_coefficient) {
- SoftBody3DSW *soft_body = soft_body_owner.getornull(p_body);
+ SoftBody3DSW *soft_body = soft_body_owner.get_or_null(p_body);
ERR_FAIL_COND(!soft_body);
soft_body->set_damping_coefficient(p_damping_coefficient);
}
real_t PhysicsServer3DSW::soft_body_get_damping_coefficient(RID p_body) const {
- SoftBody3DSW *soft_body = soft_body_owner.getornull(p_body);
+ SoftBody3DSW *soft_body = soft_body_owner.get_or_null(p_body);
ERR_FAIL_COND_V(!soft_body, 0.f);
return soft_body->get_damping_coefficient();
}
void PhysicsServer3DSW::soft_body_set_drag_coefficient(RID p_body, real_t p_drag_coefficient) {
- SoftBody3DSW *soft_body = soft_body_owner.getornull(p_body);
+ SoftBody3DSW *soft_body = soft_body_owner.get_or_null(p_body);
ERR_FAIL_COND(!soft_body);
soft_body->set_drag_coefficient(p_drag_coefficient);
}
real_t PhysicsServer3DSW::soft_body_get_drag_coefficient(RID p_body) const {
- SoftBody3DSW *soft_body = soft_body_owner.getornull(p_body);
+ SoftBody3DSW *soft_body = soft_body_owner.get_or_null(p_body);
ERR_FAIL_COND_V(!soft_body, 0.f);
return soft_body->get_drag_coefficient();
}
-void PhysicsServer3DSW::soft_body_set_mesh(RID p_body, const REF &p_mesh) {
- SoftBody3DSW *soft_body = soft_body_owner.getornull(p_body);
+void PhysicsServer3DSW::soft_body_set_mesh(RID p_body, RID p_mesh) {
+ SoftBody3DSW *soft_body = soft_body_owner.get_or_null(p_body);
ERR_FAIL_COND(!soft_body);
soft_body->set_mesh(p_mesh);
}
AABB PhysicsServer3DSW::soft_body_get_bounds(RID p_body) const {
- SoftBody3DSW *soft_body = soft_body_owner.getornull(p_body);
+ SoftBody3DSW *soft_body = soft_body_owner.get_or_null(p_body);
ERR_FAIL_COND_V(!soft_body, AABB());
return soft_body->get_bounds();
}
void PhysicsServer3DSW::soft_body_move_point(RID p_body, int p_point_index, const Vector3 &p_global_position) {
- SoftBody3DSW *soft_body = soft_body_owner.getornull(p_body);
+ SoftBody3DSW *soft_body = soft_body_owner.get_or_null(p_body);
ERR_FAIL_COND(!soft_body);
soft_body->set_vertex_position(p_point_index, p_global_position);
}
Vector3 PhysicsServer3DSW::soft_body_get_point_global_position(RID p_body, int p_point_index) const {
- SoftBody3DSW *soft_body = soft_body_owner.getornull(p_body);
+ SoftBody3DSW *soft_body = soft_body_owner.get_or_null(p_body);
ERR_FAIL_COND_V(!soft_body, Vector3());
return soft_body->get_vertex_position(p_point_index);
}
void PhysicsServer3DSW::soft_body_remove_all_pinned_points(RID p_body) {
- SoftBody3DSW *soft_body = soft_body_owner.getornull(p_body);
+ SoftBody3DSW *soft_body = soft_body_owner.get_or_null(p_body);
ERR_FAIL_COND(!soft_body);
soft_body->unpin_all_vertices();
}
void PhysicsServer3DSW::soft_body_pin_point(RID p_body, int p_point_index, bool p_pin) {
- SoftBody3DSW *soft_body = soft_body_owner.getornull(p_body);
+ SoftBody3DSW *soft_body = soft_body_owner.get_or_null(p_body);
ERR_FAIL_COND(!soft_body);
if (p_pin) {
@@ -1145,7 +1145,7 @@ void PhysicsServer3DSW::soft_body_pin_point(RID p_body, int p_point_index, bool
}
bool PhysicsServer3DSW::soft_body_is_point_pinned(RID p_body, int p_point_index) const {
- SoftBody3DSW *soft_body = soft_body_owner.getornull(p_body);
+ SoftBody3DSW *soft_body = soft_body_owner.get_or_null(p_body);
ERR_FAIL_COND_V(!soft_body, false);
return soft_body->is_vertex_pinned(p_point_index);
@@ -1161,7 +1161,7 @@ RID PhysicsServer3DSW::joint_create() {
}
void PhysicsServer3DSW::joint_clear(RID p_joint) {
- Joint3DSW *joint = joint_owner.getornull(p_joint);
+ Joint3DSW *joint = joint_owner.get_or_null(p_joint);
if (joint->get_type() != JOINT_TYPE_MAX) {
Joint3DSW *empty_joint = memnew(Joint3DSW);
empty_joint->copy_settings_from(joint);
@@ -1172,7 +1172,7 @@ void PhysicsServer3DSW::joint_clear(RID p_joint) {
}
void PhysicsServer3DSW::joint_make_pin(RID p_joint, RID p_body_A, const Vector3 &p_local_A, RID p_body_B, const Vector3 &p_local_B) {
- Body3DSW *body_A = body_owner.getornull(p_body_A);
+ Body3DSW *body_A = body_owner.get_or_null(p_body_A);
ERR_FAIL_COND(!body_A);
if (!p_body_B.is_valid()) {
@@ -1180,12 +1180,12 @@ void PhysicsServer3DSW::joint_make_pin(RID p_joint, RID p_body_A, const Vector3
p_body_B = body_A->get_space()->get_static_global_body();
}
- Body3DSW *body_B = body_owner.getornull(p_body_B);
+ Body3DSW *body_B = body_owner.get_or_null(p_body_B);
ERR_FAIL_COND(!body_B);
ERR_FAIL_COND(body_A == body_B);
- Joint3DSW *prev_joint = joint_owner.getornull(p_joint);
+ Joint3DSW *prev_joint = joint_owner.get_or_null(p_joint);
ERR_FAIL_COND(prev_joint == nullptr);
Joint3DSW *joint = memnew(PinJoint3DSW(body_A, p_local_A, body_B, p_local_B));
@@ -1196,7 +1196,7 @@ void PhysicsServer3DSW::joint_make_pin(RID p_joint, RID p_body_A, const Vector3
}
void PhysicsServer3DSW::pin_joint_set_param(RID p_joint, PinJointParam p_param, real_t p_value) {
- Joint3DSW *joint = joint_owner.getornull(p_joint);
+ Joint3DSW *joint = joint_owner.get_or_null(p_joint);
ERR_FAIL_COND(!joint);
ERR_FAIL_COND(joint->get_type() != JOINT_TYPE_PIN);
PinJoint3DSW *pin_joint = static_cast<PinJoint3DSW *>(joint);
@@ -1204,7 +1204,7 @@ void PhysicsServer3DSW::pin_joint_set_param(RID p_joint, PinJointParam p_param,
}
real_t PhysicsServer3DSW::pin_joint_get_param(RID p_joint, PinJointParam p_param) const {
- Joint3DSW *joint = joint_owner.getornull(p_joint);
+ Joint3DSW *joint = joint_owner.get_or_null(p_joint);
ERR_FAIL_COND_V(!joint, 0);
ERR_FAIL_COND_V(joint->get_type() != JOINT_TYPE_PIN, 0);
PinJoint3DSW *pin_joint = static_cast<PinJoint3DSW *>(joint);
@@ -1212,7 +1212,7 @@ real_t PhysicsServer3DSW::pin_joint_get_param(RID p_joint, PinJointParam p_param
}
void PhysicsServer3DSW::pin_joint_set_local_a(RID p_joint, const Vector3 &p_A) {
- Joint3DSW *joint = joint_owner.getornull(p_joint);
+ Joint3DSW *joint = joint_owner.get_or_null(p_joint);
ERR_FAIL_COND(!joint);
ERR_FAIL_COND(joint->get_type() != JOINT_TYPE_PIN);
PinJoint3DSW *pin_joint = static_cast<PinJoint3DSW *>(joint);
@@ -1220,7 +1220,7 @@ void PhysicsServer3DSW::pin_joint_set_local_a(RID p_joint, const Vector3 &p_A) {
}
Vector3 PhysicsServer3DSW::pin_joint_get_local_a(RID p_joint) const {
- Joint3DSW *joint = joint_owner.getornull(p_joint);
+ Joint3DSW *joint = joint_owner.get_or_null(p_joint);
ERR_FAIL_COND_V(!joint, Vector3());
ERR_FAIL_COND_V(joint->get_type() != JOINT_TYPE_PIN, Vector3());
PinJoint3DSW *pin_joint = static_cast<PinJoint3DSW *>(joint);
@@ -1228,7 +1228,7 @@ Vector3 PhysicsServer3DSW::pin_joint_get_local_a(RID p_joint) const {
}
void PhysicsServer3DSW::pin_joint_set_local_b(RID p_joint, const Vector3 &p_B) {
- Joint3DSW *joint = joint_owner.getornull(p_joint);
+ Joint3DSW *joint = joint_owner.get_or_null(p_joint);
ERR_FAIL_COND(!joint);
ERR_FAIL_COND(joint->get_type() != JOINT_TYPE_PIN);
PinJoint3DSW *pin_joint = static_cast<PinJoint3DSW *>(joint);
@@ -1236,7 +1236,7 @@ void PhysicsServer3DSW::pin_joint_set_local_b(RID p_joint, const Vector3 &p_B) {
}
Vector3 PhysicsServer3DSW::pin_joint_get_local_b(RID p_joint) const {
- Joint3DSW *joint = joint_owner.getornull(p_joint);
+ Joint3DSW *joint = joint_owner.get_or_null(p_joint);
ERR_FAIL_COND_V(!joint, Vector3());
ERR_FAIL_COND_V(joint->get_type() != JOINT_TYPE_PIN, Vector3());
PinJoint3DSW *pin_joint = static_cast<PinJoint3DSW *>(joint);
@@ -1244,7 +1244,7 @@ Vector3 PhysicsServer3DSW::pin_joint_get_local_b(RID p_joint) const {
}
void PhysicsServer3DSW::joint_make_hinge(RID p_joint, RID p_body_A, const Transform3D &p_frame_A, RID p_body_B, const Transform3D &p_frame_B) {
- Body3DSW *body_A = body_owner.getornull(p_body_A);
+ Body3DSW *body_A = body_owner.get_or_null(p_body_A);
ERR_FAIL_COND(!body_A);
if (!p_body_B.is_valid()) {
@@ -1252,12 +1252,12 @@ void PhysicsServer3DSW::joint_make_hinge(RID p_joint, RID p_body_A, const Transf
p_body_B = body_A->get_space()->get_static_global_body();
}
- Body3DSW *body_B = body_owner.getornull(p_body_B);
+ Body3DSW *body_B = body_owner.get_or_null(p_body_B);
ERR_FAIL_COND(!body_B);
ERR_FAIL_COND(body_A == body_B);
- Joint3DSW *prev_joint = joint_owner.getornull(p_joint);
+ Joint3DSW *prev_joint = joint_owner.get_or_null(p_joint);
ERR_FAIL_COND(prev_joint == nullptr);
Joint3DSW *joint = memnew(HingeJoint3DSW(body_A, body_B, p_frame_A, p_frame_B));
@@ -1268,7 +1268,7 @@ void PhysicsServer3DSW::joint_make_hinge(RID p_joint, RID p_body_A, const Transf
}
void PhysicsServer3DSW::joint_make_hinge_simple(RID p_joint, RID p_body_A, const Vector3 &p_pivot_A, const Vector3 &p_axis_A, RID p_body_B, const Vector3 &p_pivot_B, const Vector3 &p_axis_B) {
- Body3DSW *body_A = body_owner.getornull(p_body_A);
+ Body3DSW *body_A = body_owner.get_or_null(p_body_A);
ERR_FAIL_COND(!body_A);
if (!p_body_B.is_valid()) {
@@ -1276,12 +1276,12 @@ void PhysicsServer3DSW::joint_make_hinge_simple(RID p_joint, RID p_body_A, const
p_body_B = body_A->get_space()->get_static_global_body();
}
- Body3DSW *body_B = body_owner.getornull(p_body_B);
+ Body3DSW *body_B = body_owner.get_or_null(p_body_B);
ERR_FAIL_COND(!body_B);
ERR_FAIL_COND(body_A == body_B);
- Joint3DSW *prev_joint = joint_owner.getornull(p_joint);
+ Joint3DSW *prev_joint = joint_owner.get_or_null(p_joint);
ERR_FAIL_COND(prev_joint == nullptr);
Joint3DSW *joint = memnew(HingeJoint3DSW(body_A, body_B, p_pivot_A, p_pivot_B, p_axis_A, p_axis_B));
@@ -1292,7 +1292,7 @@ void PhysicsServer3DSW::joint_make_hinge_simple(RID p_joint, RID p_body_A, const
}
void PhysicsServer3DSW::hinge_joint_set_param(RID p_joint, HingeJointParam p_param, real_t p_value) {
- Joint3DSW *joint = joint_owner.getornull(p_joint);
+ Joint3DSW *joint = joint_owner.get_or_null(p_joint);
ERR_FAIL_COND(!joint);
ERR_FAIL_COND(joint->get_type() != JOINT_TYPE_HINGE);
HingeJoint3DSW *hinge_joint = static_cast<HingeJoint3DSW *>(joint);
@@ -1300,7 +1300,7 @@ void PhysicsServer3DSW::hinge_joint_set_param(RID p_joint, HingeJointParam p_par
}
real_t PhysicsServer3DSW::hinge_joint_get_param(RID p_joint, HingeJointParam p_param) const {
- Joint3DSW *joint = joint_owner.getornull(p_joint);
+ Joint3DSW *joint = joint_owner.get_or_null(p_joint);
ERR_FAIL_COND_V(!joint, 0);
ERR_FAIL_COND_V(joint->get_type() != JOINT_TYPE_HINGE, 0);
HingeJoint3DSW *hinge_joint = static_cast<HingeJoint3DSW *>(joint);
@@ -1308,7 +1308,7 @@ real_t PhysicsServer3DSW::hinge_joint_get_param(RID p_joint, HingeJointParam p_p
}
void PhysicsServer3DSW::hinge_joint_set_flag(RID p_joint, HingeJointFlag p_flag, bool p_value) {
- Joint3DSW *joint = joint_owner.getornull(p_joint);
+ Joint3DSW *joint = joint_owner.get_or_null(p_joint);
ERR_FAIL_COND(!joint);
ERR_FAIL_COND(joint->get_type() != JOINT_TYPE_HINGE);
HingeJoint3DSW *hinge_joint = static_cast<HingeJoint3DSW *>(joint);
@@ -1316,7 +1316,7 @@ void PhysicsServer3DSW::hinge_joint_set_flag(RID p_joint, HingeJointFlag p_flag,
}
bool PhysicsServer3DSW::hinge_joint_get_flag(RID p_joint, HingeJointFlag p_flag) const {
- Joint3DSW *joint = joint_owner.getornull(p_joint);
+ Joint3DSW *joint = joint_owner.get_or_null(p_joint);
ERR_FAIL_COND_V(!joint, false);
ERR_FAIL_COND_V(joint->get_type() != JOINT_TYPE_HINGE, false);
HingeJoint3DSW *hinge_joint = static_cast<HingeJoint3DSW *>(joint);
@@ -1324,19 +1324,19 @@ bool PhysicsServer3DSW::hinge_joint_get_flag(RID p_joint, HingeJointFlag p_flag)
}
void PhysicsServer3DSW::joint_set_solver_priority(RID p_joint, int p_priority) {
- Joint3DSW *joint = joint_owner.getornull(p_joint);
+ Joint3DSW *joint = joint_owner.get_or_null(p_joint);
ERR_FAIL_COND(!joint);
joint->set_priority(p_priority);
}
int PhysicsServer3DSW::joint_get_solver_priority(RID p_joint) const {
- Joint3DSW *joint = joint_owner.getornull(p_joint);
+ Joint3DSW *joint = joint_owner.get_or_null(p_joint);
ERR_FAIL_COND_V(!joint, 0);
return joint->get_priority();
}
void PhysicsServer3DSW::joint_disable_collisions_between_bodies(RID p_joint, const bool p_disable) {
- Joint3DSW *joint = joint_owner.getornull(p_joint);
+ Joint3DSW *joint = joint_owner.get_or_null(p_joint);
ERR_FAIL_COND(!joint);
joint->disable_collisions_between_bodies(p_disable);
@@ -1356,20 +1356,20 @@ void PhysicsServer3DSW::joint_disable_collisions_between_bodies(RID p_joint, con
}
bool PhysicsServer3DSW::joint_is_disabled_collisions_between_bodies(RID p_joint) const {
- Joint3DSW *joint = joint_owner.getornull(p_joint);
+ Joint3DSW *joint = joint_owner.get_or_null(p_joint);
ERR_FAIL_COND_V(!joint, true);
return joint->is_disabled_collisions_between_bodies();
}
PhysicsServer3DSW::JointType PhysicsServer3DSW::joint_get_type(RID p_joint) const {
- Joint3DSW *joint = joint_owner.getornull(p_joint);
+ Joint3DSW *joint = joint_owner.get_or_null(p_joint);
ERR_FAIL_COND_V(!joint, JOINT_TYPE_PIN);
return joint->get_type();
}
void PhysicsServer3DSW::joint_make_slider(RID p_joint, RID p_body_A, const Transform3D &p_local_frame_A, RID p_body_B, const Transform3D &p_local_frame_B) {
- Body3DSW *body_A = body_owner.getornull(p_body_A);
+ Body3DSW *body_A = body_owner.get_or_null(p_body_A);
ERR_FAIL_COND(!body_A);
if (!p_body_B.is_valid()) {
@@ -1377,12 +1377,12 @@ void PhysicsServer3DSW::joint_make_slider(RID p_joint, RID p_body_A, const Trans
p_body_B = body_A->get_space()->get_static_global_body();
}
- Body3DSW *body_B = body_owner.getornull(p_body_B);
+ Body3DSW *body_B = body_owner.get_or_null(p_body_B);
ERR_FAIL_COND(!body_B);
ERR_FAIL_COND(body_A == body_B);
- Joint3DSW *prev_joint = joint_owner.getornull(p_joint);
+ Joint3DSW *prev_joint = joint_owner.get_or_null(p_joint);
ERR_FAIL_COND(prev_joint == nullptr);
Joint3DSW *joint = memnew(SliderJoint3DSW(body_A, body_B, p_local_frame_A, p_local_frame_B));
@@ -1393,7 +1393,7 @@ void PhysicsServer3DSW::joint_make_slider(RID p_joint, RID p_body_A, const Trans
}
void PhysicsServer3DSW::slider_joint_set_param(RID p_joint, SliderJointParam p_param, real_t p_value) {
- Joint3DSW *joint = joint_owner.getornull(p_joint);
+ Joint3DSW *joint = joint_owner.get_or_null(p_joint);
ERR_FAIL_COND(!joint);
ERR_FAIL_COND(joint->get_type() != JOINT_TYPE_SLIDER);
SliderJoint3DSW *slider_joint = static_cast<SliderJoint3DSW *>(joint);
@@ -1401,7 +1401,7 @@ void PhysicsServer3DSW::slider_joint_set_param(RID p_joint, SliderJointParam p_p
}
real_t PhysicsServer3DSW::slider_joint_get_param(RID p_joint, SliderJointParam p_param) const {
- Joint3DSW *joint = joint_owner.getornull(p_joint);
+ Joint3DSW *joint = joint_owner.get_or_null(p_joint);
ERR_FAIL_COND_V(!joint, 0);
ERR_FAIL_COND_V(joint->get_type() != JOINT_TYPE_CONE_TWIST, 0);
SliderJoint3DSW *slider_joint = static_cast<SliderJoint3DSW *>(joint);
@@ -1409,7 +1409,7 @@ real_t PhysicsServer3DSW::slider_joint_get_param(RID p_joint, SliderJointParam p
}
void PhysicsServer3DSW::joint_make_cone_twist(RID p_joint, RID p_body_A, const Transform3D &p_local_frame_A, RID p_body_B, const Transform3D &p_local_frame_B) {
- Body3DSW *body_A = body_owner.getornull(p_body_A);
+ Body3DSW *body_A = body_owner.get_or_null(p_body_A);
ERR_FAIL_COND(!body_A);
if (!p_body_B.is_valid()) {
@@ -1417,12 +1417,12 @@ void PhysicsServer3DSW::joint_make_cone_twist(RID p_joint, RID p_body_A, const T
p_body_B = body_A->get_space()->get_static_global_body();
}
- Body3DSW *body_B = body_owner.getornull(p_body_B);
+ Body3DSW *body_B = body_owner.get_or_null(p_body_B);
ERR_FAIL_COND(!body_B);
ERR_FAIL_COND(body_A == body_B);
- Joint3DSW *prev_joint = joint_owner.getornull(p_joint);
+ Joint3DSW *prev_joint = joint_owner.get_or_null(p_joint);
ERR_FAIL_COND(prev_joint == nullptr);
Joint3DSW *joint = memnew(ConeTwistJoint3DSW(body_A, body_B, p_local_frame_A, p_local_frame_B));
@@ -1433,7 +1433,7 @@ void PhysicsServer3DSW::joint_make_cone_twist(RID p_joint, RID p_body_A, const T
}
void PhysicsServer3DSW::cone_twist_joint_set_param(RID p_joint, ConeTwistJointParam p_param, real_t p_value) {
- Joint3DSW *joint = joint_owner.getornull(p_joint);
+ Joint3DSW *joint = joint_owner.get_or_null(p_joint);
ERR_FAIL_COND(!joint);
ERR_FAIL_COND(joint->get_type() != JOINT_TYPE_CONE_TWIST);
ConeTwistJoint3DSW *cone_twist_joint = static_cast<ConeTwistJoint3DSW *>(joint);
@@ -1441,7 +1441,7 @@ void PhysicsServer3DSW::cone_twist_joint_set_param(RID p_joint, ConeTwistJointPa
}
real_t PhysicsServer3DSW::cone_twist_joint_get_param(RID p_joint, ConeTwistJointParam p_param) const {
- Joint3DSW *joint = joint_owner.getornull(p_joint);
+ Joint3DSW *joint = joint_owner.get_or_null(p_joint);
ERR_FAIL_COND_V(!joint, 0);
ERR_FAIL_COND_V(joint->get_type() != JOINT_TYPE_CONE_TWIST, 0);
ConeTwistJoint3DSW *cone_twist_joint = static_cast<ConeTwistJoint3DSW *>(joint);
@@ -1449,7 +1449,7 @@ real_t PhysicsServer3DSW::cone_twist_joint_get_param(RID p_joint, ConeTwistJoint
}
void PhysicsServer3DSW::joint_make_generic_6dof(RID p_joint, RID p_body_A, const Transform3D &p_local_frame_A, RID p_body_B, const Transform3D &p_local_frame_B) {
- Body3DSW *body_A = body_owner.getornull(p_body_A);
+ Body3DSW *body_A = body_owner.get_or_null(p_body_A);
ERR_FAIL_COND(!body_A);
if (!p_body_B.is_valid()) {
@@ -1457,12 +1457,12 @@ void PhysicsServer3DSW::joint_make_generic_6dof(RID p_joint, RID p_body_A, const
p_body_B = body_A->get_space()->get_static_global_body();
}
- Body3DSW *body_B = body_owner.getornull(p_body_B);
+ Body3DSW *body_B = body_owner.get_or_null(p_body_B);
ERR_FAIL_COND(!body_B);
ERR_FAIL_COND(body_A == body_B);
- Joint3DSW *prev_joint = joint_owner.getornull(p_joint);
+ Joint3DSW *prev_joint = joint_owner.get_or_null(p_joint);
ERR_FAIL_COND(prev_joint == nullptr);
Joint3DSW *joint = memnew(Generic6DOFJoint3DSW(body_A, body_B, p_local_frame_A, p_local_frame_B, true));
@@ -1473,7 +1473,7 @@ void PhysicsServer3DSW::joint_make_generic_6dof(RID p_joint, RID p_body_A, const
}
void PhysicsServer3DSW::generic_6dof_joint_set_param(RID p_joint, Vector3::Axis p_axis, G6DOFJointAxisParam p_param, real_t p_value) {
- Joint3DSW *joint = joint_owner.getornull(p_joint);
+ Joint3DSW *joint = joint_owner.get_or_null(p_joint);
ERR_FAIL_COND(!joint);
ERR_FAIL_COND(joint->get_type() != JOINT_TYPE_6DOF);
Generic6DOFJoint3DSW *generic_6dof_joint = static_cast<Generic6DOFJoint3DSW *>(joint);
@@ -1481,7 +1481,7 @@ void PhysicsServer3DSW::generic_6dof_joint_set_param(RID p_joint, Vector3::Axis
}
real_t PhysicsServer3DSW::generic_6dof_joint_get_param(RID p_joint, Vector3::Axis p_axis, G6DOFJointAxisParam p_param) const {
- Joint3DSW *joint = joint_owner.getornull(p_joint);
+ Joint3DSW *joint = joint_owner.get_or_null(p_joint);
ERR_FAIL_COND_V(!joint, 0);
ERR_FAIL_COND_V(joint->get_type() != JOINT_TYPE_6DOF, 0);
Generic6DOFJoint3DSW *generic_6dof_joint = static_cast<Generic6DOFJoint3DSW *>(joint);
@@ -1489,7 +1489,7 @@ real_t PhysicsServer3DSW::generic_6dof_joint_get_param(RID p_joint, Vector3::Axi
}
void PhysicsServer3DSW::generic_6dof_joint_set_flag(RID p_joint, Vector3::Axis p_axis, G6DOFJointAxisFlag p_flag, bool p_enable) {
- Joint3DSW *joint = joint_owner.getornull(p_joint);
+ Joint3DSW *joint = joint_owner.get_or_null(p_joint);
ERR_FAIL_COND(!joint);
ERR_FAIL_COND(joint->get_type() != JOINT_TYPE_6DOF);
Generic6DOFJoint3DSW *generic_6dof_joint = static_cast<Generic6DOFJoint3DSW *>(joint);
@@ -1497,7 +1497,7 @@ void PhysicsServer3DSW::generic_6dof_joint_set_flag(RID p_joint, Vector3::Axis p
}
bool PhysicsServer3DSW::generic_6dof_joint_get_flag(RID p_joint, Vector3::Axis p_axis, G6DOFJointAxisFlag p_flag) const {
- Joint3DSW *joint = joint_owner.getornull(p_joint);
+ Joint3DSW *joint = joint_owner.get_or_null(p_joint);
ERR_FAIL_COND_V(!joint, false);
ERR_FAIL_COND_V(joint->get_type() != JOINT_TYPE_6DOF, false);
Generic6DOFJoint3DSW *generic_6dof_joint = static_cast<Generic6DOFJoint3DSW *>(joint);
@@ -1508,7 +1508,7 @@ void PhysicsServer3DSW::free(RID p_rid) {
_update_shapes(); //just in case
if (shape_owner.owns(p_rid)) {
- Shape3DSW *shape = shape_owner.getornull(p_rid);
+ Shape3DSW *shape = shape_owner.get_or_null(p_rid);
while (shape->get_owners().size()) {
ShapeOwner3DSW *so = shape->get_owners().front()->key();
@@ -1518,7 +1518,7 @@ void PhysicsServer3DSW::free(RID p_rid) {
shape_owner.free(p_rid);
memdelete(shape);
} else if (body_owner.owns(p_rid)) {
- Body3DSW *body = body_owner.getornull(p_rid);
+ Body3DSW *body = body_owner.get_or_null(p_rid);
/*
if (body->get_state_query())
@@ -1537,14 +1537,14 @@ void PhysicsServer3DSW::free(RID p_rid) {
body_owner.free(p_rid);
memdelete(body);
} else if (soft_body_owner.owns(p_rid)) {
- SoftBody3DSW *soft_body = soft_body_owner.getornull(p_rid);
+ SoftBody3DSW *soft_body = soft_body_owner.get_or_null(p_rid);
soft_body->set_space(nullptr);
soft_body_owner.free(p_rid);
memdelete(soft_body);
} else if (area_owner.owns(p_rid)) {
- Area3DSW *area = area_owner.getornull(p_rid);
+ Area3DSW *area = area_owner.get_or_null(p_rid);
/*
if (area->get_monitor_query())
@@ -1560,7 +1560,7 @@ void PhysicsServer3DSW::free(RID p_rid) {
area_owner.free(p_rid);
memdelete(area);
} else if (space_owner.owns(p_rid)) {
- Space3DSW *space = space_owner.getornull(p_rid);
+ Space3DSW *space = space_owner.get_or_null(p_rid);
while (space->get_objects().size()) {
CollisionObject3DSW *co = (CollisionObject3DSW *)space->get_objects().front()->get();
@@ -1574,7 +1574,7 @@ void PhysicsServer3DSW::free(RID p_rid) {
space_owner.free(p_rid);
memdelete(space);
} else if (joint_owner.owns(p_rid)) {
- Joint3DSW *joint = joint_owner.getornull(p_rid);
+ Joint3DSW *joint = joint_owner.get_or_null(p_rid);
joint_owner.free(p_rid);
memdelete(joint);
diff --git a/servers/physics_3d/physics_server_3d_sw.h b/servers/physics_3d/physics_server_3d_sw.h
index 357bfba1d7..106e260311 100644
--- a/servers/physics_3d/physics_server_3d_sw.h
+++ b/servers/physics_3d/physics_server_3d_sw.h
@@ -291,7 +291,7 @@ public:
virtual void soft_body_set_drag_coefficient(RID p_body, real_t p_drag_coefficient) override;
virtual real_t soft_body_get_drag_coefficient(RID p_body) const override;
- virtual void soft_body_set_mesh(RID p_body, const REF &p_mesh) override;
+ virtual void soft_body_set_mesh(RID p_body, RID p_mesh) override;
virtual AABB soft_body_get_bounds(RID p_body) const override;
diff --git a/servers/physics_3d/physics_server_3d_wrap_mt.h b/servers/physics_3d/physics_server_3d_wrap_mt.h
index 6869484f8c..a86fb5a3d3 100644
--- a/servers/physics_3d/physics_server_3d_wrap_mt.h
+++ b/servers/physics_3d/physics_server_3d_wrap_mt.h
@@ -308,7 +308,7 @@ public:
FUNC2(soft_body_set_drag_coefficient, RID, real_t);
FUNC1RC(real_t, soft_body_get_drag_coefficient, RID);
- FUNC2(soft_body_set_mesh, RID, const REF &);
+ FUNC2(soft_body_set_mesh, RID, RID);
FUNC1RC(AABB, soft_body_get_bounds, RID);
diff --git a/servers/physics_3d/shape_3d_sw.cpp b/servers/physics_3d/shape_3d_sw.cpp
index 7deddb000e..0fb6d582c8 100644
--- a/servers/physics_3d/shape_3d_sw.cpp
+++ b/servers/physics_3d/shape_3d_sw.cpp
@@ -61,8 +61,8 @@ subject to the following restrictions:
void Shape3DSW::configure(const AABB &p_aabb) {
aabb = p_aabb;
configured = true;
- for (Map<ShapeOwner3DSW *, int>::Element *E = owners.front(); E; E = E->next()) {
- ShapeOwner3DSW *co = (ShapeOwner3DSW *)E->key();
+ for (const KeyValue<ShapeOwner3DSW *, int> &E : owners) {
+ ShapeOwner3DSW *co = (ShapeOwner3DSW *)E.key;
co->_shape_changed();
}
}
diff --git a/servers/physics_3d/soft_body_3d_sw.cpp b/servers/physics_3d/soft_body_3d_sw.cpp
index 5f6e202c73..5e8f8692ba 100644
--- a/servers/physics_3d/soft_body_3d_sw.cpp
+++ b/servers/physics_3d/soft_body_3d_sw.cpp
@@ -33,6 +33,7 @@
#include "core/math/geometry_3d.h"
#include "core/templates/map.h"
+#include "servers/rendering_server.h"
// Based on Bullet soft body.
@@ -127,7 +128,7 @@ void SoftBody3DSW::set_space(Space3DSW *p_space) {
}
}
-void SoftBody3DSW::set_mesh(const Ref<Mesh> &p_mesh) {
+void SoftBody3DSW::set_mesh(RID p_mesh) {
destroy();
soft_mesh = p_mesh;
@@ -136,13 +137,11 @@ void SoftBody3DSW::set_mesh(const Ref<Mesh> &p_mesh) {
return;
}
- Array arrays = soft_mesh->surface_get_arrays(0);
- ERR_FAIL_COND(!(soft_mesh->surface_get_format(0) & RS::ARRAY_FORMAT_INDEX));
+ Array arrays = RenderingServer::get_singleton()->mesh_surface_get_arrays(soft_mesh, 0);
- bool success = create_from_trimesh(arrays[RS::ARRAY_INDEX], arrays[RS::ARRAY_VERTEX]);
+ bool success = create_from_trimesh(arrays[RenderingServer::ARRAY_INDEX], arrays[RenderingServer::ARRAY_VERTEX]);
if (!success) {
destroy();
- soft_mesh = Ref<Mesh>();
}
}
@@ -249,8 +248,10 @@ void SoftBody3DSW::update_area() {
// Node area.
LocalVector<int> counts;
- counts.resize(nodes.size());
- memset(counts.ptr(), 0, counts.size() * sizeof(int));
+ if (nodes.size() > 0) {
+ counts.resize(nodes.size());
+ memset(counts.ptr(), 0, counts.size() * sizeof(int));
+ }
for (i = 0, ni = nodes.size(); i < ni; ++i) {
nodes[i].area = 0.0;
@@ -465,6 +466,9 @@ Vector3 SoftBody3DSW::get_face_normal(uint32_t p_face_index) const {
}
bool SoftBody3DSW::create_from_trimesh(const Vector<int> &p_indices, const Vector<Vector3> &p_vertices) {
+ ERR_FAIL_COND_V(p_indices.is_empty(), false);
+ ERR_FAIL_COND_V(p_vertices.is_empty(), false);
+
uint32_t node_count = 0;
LocalVector<Vector3> vertices;
const int visual_vertex_count(p_vertices.size());
@@ -1225,6 +1229,8 @@ void SoftBody3DSW::deinitialize_shape() {
}
void SoftBody3DSW::destroy() {
+ soft_mesh = RID();
+
map_visual_to_physics.clear();
node_tree.clear();
diff --git a/servers/physics_3d/soft_body_3d_sw.h b/servers/physics_3d/soft_body_3d_sw.h
index 58fd234fde..7d4b83d0ee 100644
--- a/servers/physics_3d/soft_body_3d_sw.h
+++ b/servers/physics_3d/soft_body_3d_sw.h
@@ -40,12 +40,11 @@
#include "core/templates/local_vector.h"
#include "core/templates/set.h"
#include "core/templates/vset.h"
-#include "scene/resources/mesh.h"
class Constraint3DSW;
class SoftBody3DSW : public CollisionObject3DSW {
- Ref<Mesh> soft_mesh;
+ RID soft_mesh;
struct Node {
Vector3 s; // Source position
@@ -159,7 +158,7 @@ public:
virtual void set_space(Space3DSW *p_space);
- void set_mesh(const Ref<Mesh> &p_mesh);
+ void set_mesh(RID p_mesh);
void update_rendering_server(RenderingServerHandler *p_rendering_server_handler);
diff --git a/servers/physics_3d/space_3d_sw.cpp b/servers/physics_3d/space_3d_sw.cpp
index 78c4e30c83..369dad45eb 100644
--- a/servers/physics_3d/space_3d_sw.cpp
+++ b/servers/physics_3d/space_3d_sw.cpp
@@ -187,7 +187,7 @@ int PhysicsDirectSpaceState3DSW::intersect_shape(const RID &p_shape, const Trans
return 0;
}
- Shape3DSW *shape = PhysicsServer3DSW::singletonsw->shape_owner.getornull(p_shape);
+ Shape3DSW *shape = PhysicsServer3DSW::singletonsw->shape_owner.get_or_null(p_shape);
ERR_FAIL_COND_V(!shape, 0);
AABB aabb = p_xform.xform(shape->get_aabb());
@@ -238,7 +238,7 @@ int PhysicsDirectSpaceState3DSW::intersect_shape(const RID &p_shape, const Trans
}
bool PhysicsDirectSpaceState3DSW::cast_motion(const RID &p_shape, const Transform3D &p_xform, const Vector3 &p_motion, real_t p_margin, real_t &p_closest_safe, real_t &p_closest_unsafe, const Set<RID> &p_exclude, uint32_t p_collision_mask, bool p_collide_with_bodies, bool p_collide_with_areas, ShapeRestInfo *r_info) {
- Shape3DSW *shape = PhysicsServer3DSW::singletonsw->shape_owner.getornull(p_shape);
+ Shape3DSW *shape = PhysicsServer3DSW::singletonsw->shape_owner.get_or_null(p_shape);
ERR_FAIL_COND_V(!shape, false);
AABB aabb = p_xform.xform(shape->get_aabb());
@@ -361,7 +361,7 @@ bool PhysicsDirectSpaceState3DSW::collide_shape(RID p_shape, const Transform3D &
return false;
}
- Shape3DSW *shape = PhysicsServer3DSW::singletonsw->shape_owner.getornull(p_shape);
+ Shape3DSW *shape = PhysicsServer3DSW::singletonsw->shape_owner.get_or_null(p_shape);
ERR_FAIL_COND_V(!shape, 0);
AABB aabb = p_shape_xform.xform(shape->get_aabb());
@@ -487,7 +487,7 @@ static void _rest_cbk_result(const Vector3 &p_point_A, int p_index_A, const Vect
}
bool PhysicsDirectSpaceState3DSW::rest_info(RID p_shape, const Transform3D &p_shape_xform, real_t p_margin, ShapeRestInfo *r_info, const Set<RID> &p_exclude, uint32_t p_collision_mask, bool p_collide_with_bodies, bool p_collide_with_areas) {
- Shape3DSW *shape = PhysicsServer3DSW::singletonsw->shape_owner.getornull(p_shape);
+ Shape3DSW *shape = PhysicsServer3DSW::singletonsw->shape_owner.get_or_null(p_shape);
ERR_FAIL_COND_V(!shape, 0);
real_t min_contact_depth = p_margin * TEST_MOTION_MIN_CONTACT_DEPTH_FACTOR;
@@ -543,9 +543,9 @@ bool PhysicsDirectSpaceState3DSW::rest_info(RID p_shape, const Transform3D &p_sh
}
Vector3 PhysicsDirectSpaceState3DSW::get_closest_point_to_object_volume(RID p_object, const Vector3 p_point) const {
- CollisionObject3DSW *obj = PhysicsServer3DSW::singletonsw->area_owner.getornull(p_object);
+ CollisionObject3DSW *obj = PhysicsServer3DSW::singletonsw->area_owner.get_or_null(p_object);
if (!obj) {
- obj = PhysicsServer3DSW::singletonsw->body_owner.getornull(p_object);
+ obj = PhysicsServer3DSW::singletonsw->body_owner.get_or_null(p_object);
}
ERR_FAIL_COND_V(!obj, Vector3());
@@ -941,7 +941,6 @@ bool Space3DSW::test_body_motion(Body3DSW *p_body, const Transform3D &p_from, co
collision.normal = result.normal;
collision.position = result.contact;
collision.depth = result.len;
- //r_result->collider_metadata = result.object->get_shape_metadata(result.shape);
const Body3DSW *body = static_cast<const Body3DSW *>(result.object);
diff --git a/servers/physics_3d/step_3d_sw.cpp b/servers/physics_3d/step_3d_sw.cpp
index 7c18944b4d..6572d58c91 100644
--- a/servers/physics_3d/step_3d_sw.cpp
+++ b/servers/physics_3d/step_3d_sw.cpp
@@ -47,8 +47,8 @@ void Step3DSW::_populate_island(Body3DSW *p_body, LocalVector<Body3DSW *> &p_bod
p_body_island.push_back(p_body);
}
- for (Map<Constraint3DSW *, int>::Element *E = p_body->get_constraint_map().front(); E; E = E->next()) {
- Constraint3DSW *constraint = (Constraint3DSW *)E->key();
+ for (const KeyValue<Constraint3DSW *, int> &E : p_body->get_constraint_map()) {
+ Constraint3DSW *constraint = (Constraint3DSW *)E.key;
if (constraint->get_island_step() == _step) {
continue; // Already processed.
}
@@ -59,7 +59,7 @@ void Step3DSW::_populate_island(Body3DSW *p_body, LocalVector<Body3DSW *> &p_bod
// Find connected rigid bodies.
for (int i = 0; i < constraint->get_body_count(); i++) {
- if (i == E->get()) {
+ if (i == E.value) {
continue;
}
Body3DSW *other_body = constraint->get_body_ptr()[i];
diff --git a/servers/physics_server_2d.cpp b/servers/physics_server_2d.cpp
index 3fc94cd727..8e743e0dc0 100644
--- a/servers/physics_server_2d.cpp
+++ b/servers/physics_server_2d.cpp
@@ -112,7 +112,6 @@ void PhysicsDirectBodyState2D::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_contact_collider_id", "contact_idx"), &PhysicsDirectBodyState2D::get_contact_collider_id);
ClassDB::bind_method(D_METHOD("get_contact_collider_object", "contact_idx"), &PhysicsDirectBodyState2D::get_contact_collider_object);
ClassDB::bind_method(D_METHOD("get_contact_collider_shape", "contact_idx"), &PhysicsDirectBodyState2D::get_contact_collider_shape);
- ClassDB::bind_method(D_METHOD("get_contact_collider_shape_metadata", "contact_idx"), &PhysicsDirectBodyState2D::get_contact_collider_shape_metadata);
ClassDB::bind_method(D_METHOD("get_contact_collider_velocity_at_position", "contact_idx"), &PhysicsDirectBodyState2D::get_contact_collider_velocity_at_position);
ClassDB::bind_method(D_METHOD("get_step"), &PhysicsDirectBodyState2D::get_step);
ClassDB::bind_method(D_METHOD("integrate_forces"), &PhysicsDirectBodyState2D::integrate_forces);
@@ -279,7 +278,6 @@ Dictionary PhysicsDirectSpaceState2D::_intersect_ray(const Vector2 &p_from, cons
d["collider"] = inters.collider;
d["shape"] = inters.shape;
d["rid"] = inters.rid;
- d["metadata"] = inters.metadata;
return d;
}
@@ -298,7 +296,6 @@ Array PhysicsDirectSpaceState2D::_intersect_shape(const Ref<PhysicsShapeQueryPar
d["collider_id"] = sr[i].collider_id;
d["collider"] = sr[i].collider;
d["shape"] = sr[i].shape;
- d["metadata"] = sr[i].metadata;
ret[i] = d;
}
@@ -348,7 +345,6 @@ Array PhysicsDirectSpaceState2D::_intersect_point_impl(const Vector2 &p_point, i
d["collider_id"] = ret[i].collider_id;
d["collider"] = ret[i].collider;
d["shape"] = ret[i].shape;
- d["metadata"] = ret[i].metadata;
r[i] = d;
}
return r;
@@ -397,7 +393,6 @@ Dictionary PhysicsDirectSpaceState2D::_get_rest_info(const Ref<PhysicsShapeQuery
r["collider_id"] = sri.collider_id;
r["shape"] = sri.shape;
r["linear_velocity"] = sri.linear_velocity;
- r["metadata"] = sri.metadata;
return r;
}
@@ -578,12 +573,10 @@ void PhysicsServer2D::_bind_methods() {
ClassDB::bind_method(D_METHOD("body_add_shape", "body", "shape", "transform", "disabled"), &PhysicsServer2D::body_add_shape, DEFVAL(Transform2D()), DEFVAL(false));
ClassDB::bind_method(D_METHOD("body_set_shape", "body", "shape_idx", "shape"), &PhysicsServer2D::body_set_shape);
ClassDB::bind_method(D_METHOD("body_set_shape_transform", "body", "shape_idx", "transform"), &PhysicsServer2D::body_set_shape_transform);
- ClassDB::bind_method(D_METHOD("body_set_shape_metadata", "body", "shape_idx", "metadata"), &PhysicsServer2D::body_set_shape_metadata);
ClassDB::bind_method(D_METHOD("body_get_shape_count", "body"), &PhysicsServer2D::body_get_shape_count);
ClassDB::bind_method(D_METHOD("body_get_shape", "body", "shape_idx"), &PhysicsServer2D::body_get_shape);
ClassDB::bind_method(D_METHOD("body_get_shape_transform", "body", "shape_idx"), &PhysicsServer2D::body_get_shape_transform);
- ClassDB::bind_method(D_METHOD("body_get_shape_metadata", "body", "shape_idx"), &PhysicsServer2D::body_get_shape_metadata);
ClassDB::bind_method(D_METHOD("body_remove_shape", "body", "shape_idx"), &PhysicsServer2D::body_remove_shape);
ClassDB::bind_method(D_METHOD("body_clear_shapes", "body"), &PhysicsServer2D::body_clear_shapes);
diff --git a/servers/physics_server_2d.h b/servers/physics_server_2d.h
index 4b85382fe5..ed0584aaa6 100644
--- a/servers/physics_server_2d.h
+++ b/servers/physics_server_2d.h
@@ -84,7 +84,6 @@ public:
virtual ObjectID get_contact_collider_id(int p_contact_idx) const = 0;
virtual Object *get_contact_collider_object(int p_contact_idx) const;
virtual int get_contact_collider_shape(int p_contact_idx) const = 0;
- virtual Variant get_contact_collider_shape_metadata(int p_contact_idx) const = 0;
virtual Vector2 get_contact_collider_velocity_at_position(int p_contact_idx) const = 0;
virtual real_t get_step() const = 0;
@@ -165,7 +164,6 @@ public:
ObjectID collider_id;
Object *collider = nullptr;
int shape = 0;
- Variant metadata;
};
virtual bool intersect_ray(const Vector2 &p_from, const Vector2 &p_to, RayResult &r_result, const Set<RID> &p_exclude = Set<RID>(), uint32_t p_collision_layer = UINT32_MAX, bool p_collide_with_bodies = true, bool p_collide_with_areas = false) = 0;
@@ -175,7 +173,6 @@ public:
ObjectID collider_id;
Object *collider = nullptr;
int shape = 0;
- Variant metadata;
};
virtual int intersect_point(const Vector2 &p_point, ShapeResult *r_results, int p_result_max, const Set<RID> &p_exclude = Set<RID>(), uint32_t p_collision_layer = UINT32_MAX, bool p_collide_with_bodies = true, bool p_collide_with_areas = false, bool p_pick_point = false) = 0;
@@ -194,7 +191,6 @@ public:
ObjectID collider_id;
int shape = 0;
Vector2 linear_velocity; //velocity at contact point
- Variant metadata;
};
virtual bool rest_info(RID p_shape, const Transform2D &p_shape_xform, const Vector2 &p_motion, real_t p_margin, ShapeRestInfo *r_info, const Set<RID> &p_exclude = Set<RID>(), uint32_t p_collision_layer = UINT32_MAX, bool p_collide_with_bodies = true, bool p_collide_with_areas = false) = 0;
@@ -363,12 +359,10 @@ public:
virtual void body_add_shape(RID p_body, RID p_shape, const Transform2D &p_transform = Transform2D(), bool p_disabled = false) = 0;
virtual void body_set_shape(RID p_body, int p_shape_idx, RID p_shape) = 0;
virtual void body_set_shape_transform(RID p_body, int p_shape_idx, const Transform2D &p_transform) = 0;
- virtual void body_set_shape_metadata(RID p_body, int p_shape_idx, const Variant &p_metadata) = 0;
virtual int body_get_shape_count(RID p_body) const = 0;
virtual RID body_get_shape(RID p_body, int p_shape_idx) const = 0;
virtual Transform2D body_get_shape_transform(RID p_body, int p_shape_idx) const = 0;
- virtual Variant body_get_shape_metadata(RID p_body, int p_shape_idx) const = 0;
virtual void body_set_shape_disabled(RID p_body, int p_shape, bool p_disabled) = 0;
virtual void body_set_shape_as_one_way_collision(RID p_body, int p_shape, bool p_enabled, real_t p_margin = 0) = 0;
@@ -485,7 +479,6 @@ public:
ObjectID collider_id;
RID collider;
int collider_shape = 0;
- Variant collider_metadata;
real_t get_angle(Vector2 p_up_direction) const {
return Math::acos(collision_normal.dot(p_up_direction));
@@ -503,7 +496,6 @@ public:
ObjectID collider_id;
RID collider;
int collider_shape;
- Variant collider_metadata;
};
/* JOINT API */
diff --git a/servers/physics_server_3d.h b/servers/physics_server_3d.h
index 14d395e714..dbd734ba32 100644
--- a/servers/physics_server_3d.h
+++ b/servers/physics_server_3d.h
@@ -492,7 +492,6 @@ public:
ObjectID collider_id;
RID collider;
int collider_shape = 0;
- Variant collider_metadata;
real_t get_angle(Vector3 p_up_direction) const {
return Math::acos(normal.dot(p_up_direction));
@@ -521,7 +520,7 @@ public:
virtual void soft_body_set_space(RID p_body, RID p_space) = 0;
virtual RID soft_body_get_space(RID p_body) const = 0;
- virtual void soft_body_set_mesh(RID p_body, const REF &p_mesh) = 0;
+ virtual void soft_body_set_mesh(RID p_body, RID p_mesh) = 0;
virtual AABB soft_body_get_bounds(RID p_body) const = 0;
diff --git a/servers/register_server_types.cpp b/servers/register_server_types.cpp
index 41c8b45113..d5eccce88e 100644
--- a/servers/register_server_types.cpp
+++ b/servers/register_server_types.cpp
@@ -70,6 +70,7 @@
#include "rendering/rendering_device_binds.h"
#include "rendering_server.h"
#include "servers/rendering/shader_types.h"
+#include "text/text_server_extension.h"
#include "text_server.h"
#include "xr/xr_interface.h"
#include "xr/xr_interface_extension.h"
@@ -107,15 +108,11 @@ static bool has_server_feature_callback(const String &p_feature) {
void preregister_server_types() {
shader_types = memnew(ShaderTypes);
- GLOBAL_DEF("internationalization/rendering/text_driver", "");
- String text_driver_options;
- for (int i = 0; i < TextServerManager::get_interface_count(); i++) {
- if (i > 0) {
- text_driver_options += ",";
- }
- text_driver_options += TextServerManager::get_interface_name(i);
- }
- ProjectSettings::get_singleton()->set_custom_property_info("internationalization/rendering/text_driver", PropertyInfo(Variant::STRING, "internationalization/rendering/text_driver", PROPERTY_HINT_ENUM, text_driver_options));
+ GDREGISTER_CLASS(TextServerManager);
+ GDREGISTER_VIRTUAL_CLASS(TextServer);
+ GDREGISTER_CLASS(TextServerExtension);
+
+ Engine::get_singleton()->add_singleton(Engine::Singleton("TextServerManager", TextServerManager::get_singleton(), "TextServerManager"));
}
void register_server_types() {
@@ -125,8 +122,6 @@ void register_server_types() {
GDREGISTER_VIRTUAL_CLASS(RenderingServer);
GDREGISTER_CLASS(AudioServer);
- GDREGISTER_CLASS(TextServerManager);
- GDREGISTER_VIRTUAL_CLASS(TextServer);
TextServer::initialize_hex_code_box_fonts();
GDREGISTER_VIRTUAL_CLASS(PhysicsServer2D);
@@ -255,7 +250,6 @@ void register_server_singletons() {
Engine::get_singleton()->add_singleton(Engine::Singleton("PhysicsServer3D", PhysicsServer3D::get_singleton(), "PhysicsServer3D"));
Engine::get_singleton()->add_singleton(Engine::Singleton("NavigationServer2D", NavigationServer2D::get_singleton_mut(), "NavigationServer2D"));
Engine::get_singleton()->add_singleton(Engine::Singleton("NavigationServer3D", NavigationServer3D::get_singleton_mut(), "NavigationServer3D"));
- Engine::get_singleton()->add_singleton(Engine::Singleton("TextServerManager", TextServerManager::get_singleton(), "TextServerManager"));
Engine::get_singleton()->add_singleton(Engine::Singleton("XRServer", XRServer::get_singleton(), "XRServer"));
Engine::get_singleton()->add_singleton(Engine::Singleton("CameraServer", CameraServer::get_singleton(), "CameraServer"));
}
diff --git a/servers/rendering/rasterizer_dummy.h b/servers/rendering/rasterizer_dummy.h
index 35bb7722e7..f95221c05b 100644
--- a/servers/rendering/rasterizer_dummy.h
+++ b/servers/rendering/rasterizer_dummy.h
@@ -224,7 +224,7 @@ public:
return texture_owner.make_rid(texture);
}
void texture_2d_initialize(RID p_texture, const Ref<Image> &p_image) override {
- DummyTexture *t = texture_owner.getornull(p_texture);
+ DummyTexture *t = texture_owner.get_or_null(p_texture);
ERR_FAIL_COND(!t);
t->image = p_image->duplicate();
}
@@ -241,7 +241,7 @@ public:
void texture_3d_placeholder_initialize(RID p_texture) override {}
Ref<Image> texture_2d_get(RID p_texture) const override {
- DummyTexture *t = texture_owner.getornull(p_texture);
+ DummyTexture *t = texture_owner.get_or_null(p_texture);
ERR_FAIL_COND_V(!t, Ref<Image>());
return t->image;
}
@@ -661,7 +661,7 @@ public:
bool free(RID p_rid) override {
if (texture_owner.owns(p_rid)) {
// delete the texture
- DummyTexture *texture = texture_owner.getornull(p_rid);
+ DummyTexture *texture = texture_owner.get_or_null(p_rid);
texture_owner.free(p_rid);
memdelete(texture);
return true;
diff --git a/servers/rendering/renderer_canvas_cull.cpp b/servers/rendering/renderer_canvas_cull.cpp
index 456c736731..46683e8e68 100644
--- a/servers/rendering/renderer_canvas_cull.cpp
+++ b/servers/rendering/renderer_canvas_cull.cpp
@@ -100,7 +100,7 @@ void _collect_ysort_children(RendererCanvasCull::Item *p_canvas_item, Transform2
void _mark_ysort_dirty(RendererCanvasCull::Item *ysort_owner, RID_Owner<RendererCanvasCull::Item, true> &canvas_item_owner) {
do {
ysort_owner->ysort_children_count = -1;
- ysort_owner = canvas_item_owner.owns(ysort_owner->parent) ? canvas_item_owner.getornull(ysort_owner->parent) : nullptr;
+ ysort_owner = canvas_item_owner.owns(ysort_owner->parent) ? canvas_item_owner.get_or_null(ysort_owner->parent) : nullptr;
} while (ysort_owner && ysort_owner->sort_y);
}
@@ -396,9 +396,9 @@ void RendererCanvasCull::canvas_initialize(RID p_rid) {
}
void RendererCanvasCull::canvas_set_item_mirroring(RID p_canvas, RID p_item, const Point2 &p_mirroring) {
- Canvas *canvas = canvas_owner.getornull(p_canvas);
+ Canvas *canvas = canvas_owner.get_or_null(p_canvas);
ERR_FAIL_COND(!canvas);
- Item *canvas_item = canvas_item_owner.getornull(p_item);
+ Item *canvas_item = canvas_item_owner.get_or_null(p_item);
ERR_FAIL_COND(!canvas_item);
int idx = canvas->find_item(canvas_item);
@@ -407,7 +407,7 @@ void RendererCanvasCull::canvas_set_item_mirroring(RID p_canvas, RID p_item, con
}
void RendererCanvasCull::canvas_set_modulate(RID p_canvas, const Color &p_color) {
- Canvas *canvas = canvas_owner.getornull(p_canvas);
+ Canvas *canvas = canvas_owner.get_or_null(p_canvas);
ERR_FAIL_COND(!canvas);
canvas->modulate = p_color;
}
@@ -417,7 +417,7 @@ void RendererCanvasCull::canvas_set_disable_scale(bool p_disable) {
}
void RendererCanvasCull::canvas_set_parent(RID p_canvas, RID p_parent, float p_scale) {
- Canvas *canvas = canvas_owner.getornull(p_canvas);
+ Canvas *canvas = canvas_owner.get_or_null(p_canvas);
ERR_FAIL_COND(!canvas);
canvas->parent = p_parent;
@@ -432,15 +432,15 @@ void RendererCanvasCull::canvas_item_initialize(RID p_rid) {
}
void RendererCanvasCull::canvas_item_set_parent(RID p_item, RID p_parent) {
- Item *canvas_item = canvas_item_owner.getornull(p_item);
+ Item *canvas_item = canvas_item_owner.get_or_null(p_item);
ERR_FAIL_COND(!canvas_item);
if (canvas_item->parent.is_valid()) {
if (canvas_owner.owns(canvas_item->parent)) {
- Canvas *canvas = canvas_owner.getornull(canvas_item->parent);
+ Canvas *canvas = canvas_owner.get_or_null(canvas_item->parent);
canvas->erase_item(canvas_item);
} else if (canvas_item_owner.owns(canvas_item->parent)) {
- Item *item_owner = canvas_item_owner.getornull(canvas_item->parent);
+ Item *item_owner = canvas_item_owner.get_or_null(canvas_item->parent);
item_owner->child_items.erase(canvas_item);
if (item_owner->sort_y) {
@@ -453,13 +453,13 @@ void RendererCanvasCull::canvas_item_set_parent(RID p_item, RID p_parent) {
if (p_parent.is_valid()) {
if (canvas_owner.owns(p_parent)) {
- Canvas *canvas = canvas_owner.getornull(p_parent);
+ Canvas *canvas = canvas_owner.get_or_null(p_parent);
Canvas::ChildItem ci;
ci.item = canvas_item;
canvas->child_items.push_back(ci);
canvas->children_order_dirty = true;
} else if (canvas_item_owner.owns(p_parent)) {
- Item *item_owner = canvas_item_owner.getornull(p_parent);
+ Item *item_owner = canvas_item_owner.get_or_null(p_parent);
item_owner->child_items.push_back(canvas_item);
item_owner->children_order_dirty = true;
@@ -476,7 +476,7 @@ void RendererCanvasCull::canvas_item_set_parent(RID p_item, RID p_parent) {
}
void RendererCanvasCull::canvas_item_set_visible(RID p_item, bool p_visible) {
- Item *canvas_item = canvas_item_owner.getornull(p_item);
+ Item *canvas_item = canvas_item_owner.get_or_null(p_item);
ERR_FAIL_COND(!canvas_item);
canvas_item->visible = p_visible;
@@ -485,35 +485,35 @@ void RendererCanvasCull::canvas_item_set_visible(RID p_item, bool p_visible) {
}
void RendererCanvasCull::canvas_item_set_light_mask(RID p_item, int p_mask) {
- Item *canvas_item = canvas_item_owner.getornull(p_item);
+ Item *canvas_item = canvas_item_owner.get_or_null(p_item);
ERR_FAIL_COND(!canvas_item);
canvas_item->light_mask = p_mask;
}
void RendererCanvasCull::canvas_item_set_transform(RID p_item, const Transform2D &p_transform) {
- Item *canvas_item = canvas_item_owner.getornull(p_item);
+ Item *canvas_item = canvas_item_owner.get_or_null(p_item);
ERR_FAIL_COND(!canvas_item);
canvas_item->xform = p_transform;
}
void RendererCanvasCull::canvas_item_set_clip(RID p_item, bool p_clip) {
- Item *canvas_item = canvas_item_owner.getornull(p_item);
+ Item *canvas_item = canvas_item_owner.get_or_null(p_item);
ERR_FAIL_COND(!canvas_item);
canvas_item->clip = p_clip;
}
void RendererCanvasCull::canvas_item_set_distance_field_mode(RID p_item, bool p_enable) {
- Item *canvas_item = canvas_item_owner.getornull(p_item);
+ Item *canvas_item = canvas_item_owner.get_or_null(p_item);
ERR_FAIL_COND(!canvas_item);
canvas_item->distance_field = p_enable;
}
void RendererCanvasCull::canvas_item_set_custom_rect(RID p_item, bool p_custom_rect, const Rect2 &p_rect) {
- Item *canvas_item = canvas_item_owner.getornull(p_item);
+ Item *canvas_item = canvas_item_owner.get_or_null(p_item);
ERR_FAIL_COND(!canvas_item);
canvas_item->custom_rect = p_custom_rect;
@@ -521,35 +521,35 @@ void RendererCanvasCull::canvas_item_set_custom_rect(RID p_item, bool p_custom_r
}
void RendererCanvasCull::canvas_item_set_modulate(RID p_item, const Color &p_color) {
- Item *canvas_item = canvas_item_owner.getornull(p_item);
+ Item *canvas_item = canvas_item_owner.get_or_null(p_item);
ERR_FAIL_COND(!canvas_item);
canvas_item->modulate = p_color;
}
void RendererCanvasCull::canvas_item_set_self_modulate(RID p_item, const Color &p_color) {
- Item *canvas_item = canvas_item_owner.getornull(p_item);
+ Item *canvas_item = canvas_item_owner.get_or_null(p_item);
ERR_FAIL_COND(!canvas_item);
canvas_item->self_modulate = p_color;
}
void RendererCanvasCull::canvas_item_set_draw_behind_parent(RID p_item, bool p_enable) {
- Item *canvas_item = canvas_item_owner.getornull(p_item);
+ Item *canvas_item = canvas_item_owner.get_or_null(p_item);
ERR_FAIL_COND(!canvas_item);
canvas_item->behind = p_enable;
}
void RendererCanvasCull::canvas_item_set_update_when_visible(RID p_item, bool p_update) {
- Item *canvas_item = canvas_item_owner.getornull(p_item);
+ Item *canvas_item = canvas_item_owner.get_or_null(p_item);
ERR_FAIL_COND(!canvas_item);
canvas_item->update_when_visible = p_update;
}
void RendererCanvasCull::canvas_item_add_line(RID p_item, const Point2 &p_from, const Point2 &p_to, const Color &p_color, float p_width) {
- Item *canvas_item = canvas_item_owner.getornull(p_item);
+ Item *canvas_item = canvas_item_owner.get_or_null(p_item);
ERR_FAIL_COND(!canvas_item);
Item::CommandPrimitive *line = canvas_item->alloc_command<Item::CommandPrimitive>();
@@ -573,7 +573,7 @@ void RendererCanvasCull::canvas_item_add_line(RID p_item, const Point2 &p_from,
void RendererCanvasCull::canvas_item_add_polyline(RID p_item, const Vector<Point2> &p_points, const Vector<Color> &p_colors, float p_width, bool p_antialiased) {
ERR_FAIL_COND(p_points.size() < 2);
- Item *canvas_item = canvas_item_owner.getornull(p_item);
+ Item *canvas_item = canvas_item_owner.get_or_null(p_item);
ERR_FAIL_COND(!canvas_item);
Color color = Color(1, 1, 1, 1);
@@ -714,7 +714,7 @@ void RendererCanvasCull::canvas_item_add_polyline(RID p_item, const Vector<Point
void RendererCanvasCull::canvas_item_add_multiline(RID p_item, const Vector<Point2> &p_points, const Vector<Color> &p_colors, float p_width) {
ERR_FAIL_COND(p_points.size() < 2);
- Item *canvas_item = canvas_item_owner.getornull(p_item);
+ Item *canvas_item = canvas_item_owner.get_or_null(p_item);
ERR_FAIL_COND(!canvas_item);
Item::CommandPolygon *pline = canvas_item->alloc_command<Item::CommandPolygon>();
@@ -730,7 +730,7 @@ void RendererCanvasCull::canvas_item_add_multiline(RID p_item, const Vector<Poin
}
void RendererCanvasCull::canvas_item_add_rect(RID p_item, const Rect2 &p_rect, const Color &p_color) {
- Item *canvas_item = canvas_item_owner.getornull(p_item);
+ Item *canvas_item = canvas_item_owner.get_or_null(p_item);
ERR_FAIL_COND(!canvas_item);
Item::CommandRect *rect = canvas_item->alloc_command<Item::CommandRect>();
@@ -740,7 +740,7 @@ void RendererCanvasCull::canvas_item_add_rect(RID p_item, const Rect2 &p_rect, c
}
void RendererCanvasCull::canvas_item_add_circle(RID p_item, const Point2 &p_pos, float p_radius, const Color &p_color) {
- Item *canvas_item = canvas_item_owner.getornull(p_item);
+ Item *canvas_item = canvas_item_owner.get_or_null(p_item);
ERR_FAIL_COND(!canvas_item);
Item::CommandPolygon *circle = canvas_item->alloc_command<Item::CommandPolygon>();
@@ -776,7 +776,7 @@ void RendererCanvasCull::canvas_item_add_circle(RID p_item, const Point2 &p_pos,
}
void RendererCanvasCull::canvas_item_add_texture_rect(RID p_item, const Rect2 &p_rect, RID p_texture, bool p_tile, const Color &p_modulate, bool p_transpose) {
- Item *canvas_item = canvas_item_owner.getornull(p_item);
+ Item *canvas_item = canvas_item_owner.get_or_null(p_item);
ERR_FAIL_COND(!canvas_item);
Item::CommandRect *rect = canvas_item->alloc_command<Item::CommandRect>();
@@ -807,7 +807,7 @@ void RendererCanvasCull::canvas_item_add_texture_rect(RID p_item, const Rect2 &p
}
void RendererCanvasCull::canvas_item_add_msdf_texture_rect_region(RID p_item, const Rect2 &p_rect, RID p_texture, const Rect2 &p_src_rect, const Color &p_modulate, int p_outline_size, float p_px_range) {
- Item *canvas_item = canvas_item_owner.getornull(p_item);
+ Item *canvas_item = canvas_item_owner.get_or_null(p_item);
ERR_FAIL_COND(!canvas_item);
Item::CommandRect *rect = canvas_item->alloc_command<Item::CommandRect>();
@@ -841,7 +841,7 @@ void RendererCanvasCull::canvas_item_add_msdf_texture_rect_region(RID p_item, co
}
void RendererCanvasCull::canvas_item_add_texture_rect_region(RID p_item, const Rect2 &p_rect, RID p_texture, const Rect2 &p_src_rect, const Color &p_modulate, bool p_transpose, bool p_clip_uv) {
- Item *canvas_item = canvas_item_owner.getornull(p_item);
+ Item *canvas_item = canvas_item_owner.get_or_null(p_item);
ERR_FAIL_COND(!canvas_item);
Item::CommandRect *rect = canvas_item->alloc_command<Item::CommandRect>();
@@ -882,7 +882,7 @@ void RendererCanvasCull::canvas_item_add_texture_rect_region(RID p_item, const R
}
void RendererCanvasCull::canvas_item_add_nine_patch(RID p_item, const Rect2 &p_rect, const Rect2 &p_source, RID p_texture, const Vector2 &p_topleft, const Vector2 &p_bottomright, RS::NinePatchAxisMode p_x_axis_mode, RS::NinePatchAxisMode p_y_axis_mode, bool p_draw_center, const Color &p_modulate) {
- Item *canvas_item = canvas_item_owner.getornull(p_item);
+ Item *canvas_item = canvas_item_owner.get_or_null(p_item);
ERR_FAIL_COND(!canvas_item);
Item::CommandNinePatch *style = canvas_item->alloc_command<Item::CommandNinePatch>();
@@ -906,7 +906,7 @@ void RendererCanvasCull::canvas_item_add_primitive(RID p_item, const Vector<Poin
uint32_t pc = p_points.size();
ERR_FAIL_COND(pc == 0 || pc > 4);
- Item *canvas_item = canvas_item_owner.getornull(p_item);
+ Item *canvas_item = canvas_item_owner.get_or_null(p_item);
ERR_FAIL_COND(!canvas_item);
Item::CommandPrimitive *prim = canvas_item->alloc_command<Item::CommandPrimitive>();
@@ -932,7 +932,7 @@ void RendererCanvasCull::canvas_item_add_primitive(RID p_item, const Vector<Poin
}
void RendererCanvasCull::canvas_item_add_polygon(RID p_item, const Vector<Point2> &p_points, const Vector<Color> &p_colors, const Vector<Point2> &p_uvs, RID p_texture) {
- Item *canvas_item = canvas_item_owner.getornull(p_item);
+ Item *canvas_item = canvas_item_owner.get_or_null(p_item);
ERR_FAIL_COND(!canvas_item);
#ifdef DEBUG_ENABLED
int pointcount = p_points.size();
@@ -953,7 +953,7 @@ void RendererCanvasCull::canvas_item_add_polygon(RID p_item, const Vector<Point2
}
void RendererCanvasCull::canvas_item_add_triangle_array(RID p_item, const Vector<int> &p_indices, const Vector<Point2> &p_points, const Vector<Color> &p_colors, const Vector<Point2> &p_uvs, const Vector<int> &p_bones, const Vector<float> &p_weights, RID p_texture, int p_count) {
- Item *canvas_item = canvas_item_owner.getornull(p_item);
+ Item *canvas_item = canvas_item_owner.get_or_null(p_item);
ERR_FAIL_COND(!canvas_item);
int vertex_count = p_points.size();
@@ -976,7 +976,7 @@ void RendererCanvasCull::canvas_item_add_triangle_array(RID p_item, const Vector
}
void RendererCanvasCull::canvas_item_add_set_transform(RID p_item, const Transform2D &p_transform) {
- Item *canvas_item = canvas_item_owner.getornull(p_item);
+ Item *canvas_item = canvas_item_owner.get_or_null(p_item);
ERR_FAIL_COND(!canvas_item);
Item::CommandTransform *tr = canvas_item->alloc_command<Item::CommandTransform>();
@@ -985,7 +985,7 @@ void RendererCanvasCull::canvas_item_add_set_transform(RID p_item, const Transfo
}
void RendererCanvasCull::canvas_item_add_mesh(RID p_item, const RID &p_mesh, const Transform2D &p_transform, const Color &p_modulate, RID p_texture) {
- Item *canvas_item = canvas_item_owner.getornull(p_item);
+ Item *canvas_item = canvas_item_owner.get_or_null(p_item);
ERR_FAIL_COND(!canvas_item);
ERR_FAIL_COND(!p_mesh.is_valid());
@@ -1004,7 +1004,7 @@ void RendererCanvasCull::canvas_item_add_mesh(RID p_item, const RID &p_mesh, con
}
void RendererCanvasCull::canvas_item_add_particles(RID p_item, RID p_particles, RID p_texture) {
- Item *canvas_item = canvas_item_owner.getornull(p_item);
+ Item *canvas_item = canvas_item_owner.get_or_null(p_item);
ERR_FAIL_COND(!canvas_item);
Item::CommandParticles *part = canvas_item->alloc_command<Item::CommandParticles>();
@@ -1018,7 +1018,7 @@ void RendererCanvasCull::canvas_item_add_particles(RID p_item, RID p_particles,
}
void RendererCanvasCull::canvas_item_add_multimesh(RID p_item, RID p_mesh, RID p_texture) {
- Item *canvas_item = canvas_item_owner.getornull(p_item);
+ Item *canvas_item = canvas_item_owner.get_or_null(p_item);
ERR_FAIL_COND(!canvas_item);
Item::CommandMultiMesh *mm = canvas_item->alloc_command<Item::CommandMultiMesh>();
@@ -1029,7 +1029,7 @@ void RendererCanvasCull::canvas_item_add_multimesh(RID p_item, RID p_mesh, RID p
}
void RendererCanvasCull::canvas_item_add_clip_ignore(RID p_item, bool p_ignore) {
- Item *canvas_item = canvas_item_owner.getornull(p_item);
+ Item *canvas_item = canvas_item_owner.get_or_null(p_item);
ERR_FAIL_COND(!canvas_item);
Item::CommandClipIgnore *ci = canvas_item->alloc_command<Item::CommandClipIgnore>();
@@ -1038,7 +1038,7 @@ void RendererCanvasCull::canvas_item_add_clip_ignore(RID p_item, bool p_ignore)
}
void RendererCanvasCull::canvas_item_add_animation_slice(RID p_item, double p_animation_length, double p_slice_begin, double p_slice_end, double p_offset) {
- Item *canvas_item = canvas_item_owner.getornull(p_item);
+ Item *canvas_item = canvas_item_owner.get_or_null(p_item);
ERR_FAIL_COND(!canvas_item);
Item::CommandAnimationSlice *as = canvas_item->alloc_command<Item::CommandAnimationSlice>();
@@ -1050,7 +1050,7 @@ void RendererCanvasCull::canvas_item_add_animation_slice(RID p_item, double p_an
}
void RendererCanvasCull::canvas_item_set_sort_children_by_y(RID p_item, bool p_enable) {
- Item *canvas_item = canvas_item_owner.getornull(p_item);
+ Item *canvas_item = canvas_item_owner.get_or_null(p_item);
ERR_FAIL_COND(!canvas_item);
canvas_item->sort_y = p_enable;
@@ -1061,21 +1061,21 @@ void RendererCanvasCull::canvas_item_set_sort_children_by_y(RID p_item, bool p_e
void RendererCanvasCull::canvas_item_set_z_index(RID p_item, int p_z) {
ERR_FAIL_COND(p_z < RS::CANVAS_ITEM_Z_MIN || p_z > RS::CANVAS_ITEM_Z_MAX);
- Item *canvas_item = canvas_item_owner.getornull(p_item);
+ Item *canvas_item = canvas_item_owner.get_or_null(p_item);
ERR_FAIL_COND(!canvas_item);
canvas_item->z_index = p_z;
}
void RendererCanvasCull::canvas_item_set_z_as_relative_to_parent(RID p_item, bool p_enable) {
- Item *canvas_item = canvas_item_owner.getornull(p_item);
+ Item *canvas_item = canvas_item_owner.get_or_null(p_item);
ERR_FAIL_COND(!canvas_item);
canvas_item->z_relative = p_enable;
}
void RendererCanvasCull::canvas_item_attach_skeleton(RID p_item, RID p_skeleton) {
- Item *canvas_item = canvas_item_owner.getornull(p_item);
+ Item *canvas_item = canvas_item_owner.get_or_null(p_item);
ERR_FAIL_COND(!canvas_item);
if (canvas_item->skeleton == p_skeleton) {
return;
@@ -1104,7 +1104,7 @@ void RendererCanvasCull::canvas_item_attach_skeleton(RID p_item, RID p_skeleton)
}
void RendererCanvasCull::canvas_item_set_copy_to_backbuffer(RID p_item, bool p_enable, const Rect2 &p_rect) {
- Item *canvas_item = canvas_item_owner.getornull(p_item);
+ Item *canvas_item = canvas_item_owner.get_or_null(p_item);
ERR_FAIL_COND(!canvas_item);
if (p_enable && (canvas_item->copy_back_buffer == nullptr)) {
canvas_item->copy_back_buffer = memnew(RendererCanvasRender::Item::CopyBackBuffer);
@@ -1121,25 +1121,25 @@ void RendererCanvasCull::canvas_item_set_copy_to_backbuffer(RID p_item, bool p_e
}
void RendererCanvasCull::canvas_item_clear(RID p_item) {
- Item *canvas_item = canvas_item_owner.getornull(p_item);
+ Item *canvas_item = canvas_item_owner.get_or_null(p_item);
ERR_FAIL_COND(!canvas_item);
canvas_item->clear();
}
void RendererCanvasCull::canvas_item_set_draw_index(RID p_item, int p_index) {
- Item *canvas_item = canvas_item_owner.getornull(p_item);
+ Item *canvas_item = canvas_item_owner.get_or_null(p_item);
ERR_FAIL_COND(!canvas_item);
canvas_item->index = p_index;
if (canvas_item_owner.owns(canvas_item->parent)) {
- Item *canvas_item_parent = canvas_item_owner.getornull(canvas_item->parent);
+ Item *canvas_item_parent = canvas_item_owner.get_or_null(canvas_item->parent);
canvas_item_parent->children_order_dirty = true;
return;
}
- Canvas *canvas = canvas_owner.getornull(canvas_item->parent);
+ Canvas *canvas = canvas_owner.get_or_null(canvas_item->parent);
if (canvas) {
canvas->children_order_dirty = true;
return;
@@ -1147,21 +1147,21 @@ void RendererCanvasCull::canvas_item_set_draw_index(RID p_item, int p_index) {
}
void RendererCanvasCull::canvas_item_set_material(RID p_item, RID p_material) {
- Item *canvas_item = canvas_item_owner.getornull(p_item);
+ Item *canvas_item = canvas_item_owner.get_or_null(p_item);
ERR_FAIL_COND(!canvas_item);
canvas_item->material = p_material;
}
void RendererCanvasCull::canvas_item_set_use_parent_material(RID p_item, bool p_enable) {
- Item *canvas_item = canvas_item_owner.getornull(p_item);
+ Item *canvas_item = canvas_item_owner.get_or_null(p_item);
ERR_FAIL_COND(!canvas_item);
canvas_item->use_parent_material = p_enable;
}
void RendererCanvasCull::canvas_item_set_visibility_notifier(RID p_item, bool p_enable, const Rect2 &p_area, const Callable &p_enter_callable, const Callable &p_exit_callable) {
- Item *canvas_item = canvas_item_owner.getornull(p_item);
+ Item *canvas_item = canvas_item_owner.get_or_null(p_item);
ERR_FAIL_COND(!canvas_item);
if (p_enable) {
@@ -1181,7 +1181,7 @@ void RendererCanvasCull::canvas_item_set_visibility_notifier(RID p_item, bool p_
}
void RendererCanvasCull::canvas_item_set_canvas_group_mode(RID p_item, RS::CanvasGroupMode p_mode, float p_clear_margin, bool p_fit_empty, float p_fit_margin, bool p_blur_mipmaps) {
- Item *canvas_item = canvas_item_owner.getornull(p_item);
+ Item *canvas_item = canvas_item_owner.get_or_null(p_item);
ERR_FAIL_COND(!canvas_item);
if (p_mode == RS::CANVAS_GROUP_MODE_DISABLED) {
@@ -1206,12 +1206,12 @@ RID RendererCanvasCull::canvas_light_allocate() {
}
void RendererCanvasCull::canvas_light_initialize(RID p_rid) {
canvas_light_owner.initialize_rid(p_rid);
- RendererCanvasRender::Light *clight = canvas_light_owner.getornull(p_rid);
+ RendererCanvasRender::Light *clight = canvas_light_owner.get_or_null(p_rid);
clight->light_internal = RSG::canvas_render->light_create();
}
void RendererCanvasCull::canvas_light_set_mode(RID p_light, RS::CanvasLightMode p_mode) {
- RendererCanvasRender::Light *clight = canvas_light_owner.getornull(p_light);
+ RendererCanvasRender::Light *clight = canvas_light_owner.get_or_null(p_light);
ERR_FAIL_COND(!clight);
if (clight->mode == p_mode) {
@@ -1232,11 +1232,11 @@ void RendererCanvasCull::canvas_light_set_mode(RID p_light, RS::CanvasLightMode
}
void RendererCanvasCull::canvas_light_attach_to_canvas(RID p_light, RID p_canvas) {
- RendererCanvasRender::Light *clight = canvas_light_owner.getornull(p_light);
+ RendererCanvasRender::Light *clight = canvas_light_owner.get_or_null(p_light);
ERR_FAIL_COND(!clight);
if (clight->canvas.is_valid()) {
- Canvas *canvas = canvas_owner.getornull(clight->canvas);
+ Canvas *canvas = canvas_owner.get_or_null(clight->canvas);
if (clight->mode == RS::CANVAS_LIGHT_MODE_POINT) {
canvas->lights.erase(clight);
} else {
@@ -1251,7 +1251,7 @@ void RendererCanvasCull::canvas_light_attach_to_canvas(RID p_light, RID p_canvas
clight->canvas = p_canvas;
if (clight->canvas.is_valid()) {
- Canvas *canvas = canvas_owner.getornull(clight->canvas);
+ Canvas *canvas = canvas_owner.get_or_null(clight->canvas);
if (clight->mode == RS::CANVAS_LIGHT_MODE_POINT) {
canvas->lights.insert(clight);
} else {
@@ -1261,28 +1261,28 @@ void RendererCanvasCull::canvas_light_attach_to_canvas(RID p_light, RID p_canvas
}
void RendererCanvasCull::canvas_light_set_enabled(RID p_light, bool p_enabled) {
- RendererCanvasRender::Light *clight = canvas_light_owner.getornull(p_light);
+ RendererCanvasRender::Light *clight = canvas_light_owner.get_or_null(p_light);
ERR_FAIL_COND(!clight);
clight->enabled = p_enabled;
}
void RendererCanvasCull::canvas_light_set_texture_scale(RID p_light, float p_scale) {
- RendererCanvasRender::Light *clight = canvas_light_owner.getornull(p_light);
+ RendererCanvasRender::Light *clight = canvas_light_owner.get_or_null(p_light);
ERR_FAIL_COND(!clight);
clight->scale = p_scale;
}
void RendererCanvasCull::canvas_light_set_transform(RID p_light, const Transform2D &p_transform) {
- RendererCanvasRender::Light *clight = canvas_light_owner.getornull(p_light);
+ RendererCanvasRender::Light *clight = canvas_light_owner.get_or_null(p_light);
ERR_FAIL_COND(!clight);
clight->xform = p_transform;
}
void RendererCanvasCull::canvas_light_set_texture(RID p_light, RID p_texture) {
- RendererCanvasRender::Light *clight = canvas_light_owner.getornull(p_light);
+ RendererCanvasRender::Light *clight = canvas_light_owner.get_or_null(p_light);
ERR_FAIL_COND(!clight);
if (clight->texture == p_texture) {
@@ -1294,35 +1294,35 @@ void RendererCanvasCull::canvas_light_set_texture(RID p_light, RID p_texture) {
}
void RendererCanvasCull::canvas_light_set_texture_offset(RID p_light, const Vector2 &p_offset) {
- RendererCanvasRender::Light *clight = canvas_light_owner.getornull(p_light);
+ RendererCanvasRender::Light *clight = canvas_light_owner.get_or_null(p_light);
ERR_FAIL_COND(!clight);
clight->texture_offset = p_offset;
}
void RendererCanvasCull::canvas_light_set_color(RID p_light, const Color &p_color) {
- RendererCanvasRender::Light *clight = canvas_light_owner.getornull(p_light);
+ RendererCanvasRender::Light *clight = canvas_light_owner.get_or_null(p_light);
ERR_FAIL_COND(!clight);
clight->color = p_color;
}
void RendererCanvasCull::canvas_light_set_height(RID p_light, float p_height) {
- RendererCanvasRender::Light *clight = canvas_light_owner.getornull(p_light);
+ RendererCanvasRender::Light *clight = canvas_light_owner.get_or_null(p_light);
ERR_FAIL_COND(!clight);
clight->height = p_height;
}
void RendererCanvasCull::canvas_light_set_energy(RID p_light, float p_energy) {
- RendererCanvasRender::Light *clight = canvas_light_owner.getornull(p_light);
+ RendererCanvasRender::Light *clight = canvas_light_owner.get_or_null(p_light);
ERR_FAIL_COND(!clight);
clight->energy = p_energy;
}
void RendererCanvasCull::canvas_light_set_z_range(RID p_light, int p_min_z, int p_max_z) {
- RendererCanvasRender::Light *clight = canvas_light_owner.getornull(p_light);
+ RendererCanvasRender::Light *clight = canvas_light_owner.get_or_null(p_light);
ERR_FAIL_COND(!clight);
clight->z_min = p_min_z;
@@ -1330,7 +1330,7 @@ void RendererCanvasCull::canvas_light_set_z_range(RID p_light, int p_min_z, int
}
void RendererCanvasCull::canvas_light_set_layer_range(RID p_light, int p_min_layer, int p_max_layer) {
- RendererCanvasRender::Light *clight = canvas_light_owner.getornull(p_light);
+ RendererCanvasRender::Light *clight = canvas_light_owner.get_or_null(p_light);
ERR_FAIL_COND(!clight);
clight->layer_max = p_max_layer;
@@ -1338,35 +1338,35 @@ void RendererCanvasCull::canvas_light_set_layer_range(RID p_light, int p_min_lay
}
void RendererCanvasCull::canvas_light_set_item_cull_mask(RID p_light, int p_mask) {
- RendererCanvasRender::Light *clight = canvas_light_owner.getornull(p_light);
+ RendererCanvasRender::Light *clight = canvas_light_owner.get_or_null(p_light);
ERR_FAIL_COND(!clight);
clight->item_mask = p_mask;
}
void RendererCanvasCull::canvas_light_set_item_shadow_cull_mask(RID p_light, int p_mask) {
- RendererCanvasRender::Light *clight = canvas_light_owner.getornull(p_light);
+ RendererCanvasRender::Light *clight = canvas_light_owner.get_or_null(p_light);
ERR_FAIL_COND(!clight);
clight->item_shadow_mask = p_mask;
}
void RendererCanvasCull::canvas_light_set_directional_distance(RID p_light, float p_distance) {
- RendererCanvasRender::Light *clight = canvas_light_owner.getornull(p_light);
+ RendererCanvasRender::Light *clight = canvas_light_owner.get_or_null(p_light);
ERR_FAIL_COND(!clight);
clight->directional_distance = p_distance;
}
void RendererCanvasCull::canvas_light_set_blend_mode(RID p_light, RS::CanvasLightBlendMode p_mode) {
- RendererCanvasRender::Light *clight = canvas_light_owner.getornull(p_light);
+ RendererCanvasRender::Light *clight = canvas_light_owner.get_or_null(p_light);
ERR_FAIL_COND(!clight);
clight->blend_mode = p_mode;
}
void RendererCanvasCull::canvas_light_set_shadow_enabled(RID p_light, bool p_enabled) {
- RendererCanvasRender::Light *clight = canvas_light_owner.getornull(p_light);
+ RendererCanvasRender::Light *clight = canvas_light_owner.get_or_null(p_light);
ERR_FAIL_COND(!clight);
if (clight->use_shadow == p_enabled) {
@@ -1378,21 +1378,21 @@ void RendererCanvasCull::canvas_light_set_shadow_enabled(RID p_light, bool p_ena
}
void RendererCanvasCull::canvas_light_set_shadow_filter(RID p_light, RS::CanvasLightShadowFilter p_filter) {
- RendererCanvasRender::Light *clight = canvas_light_owner.getornull(p_light);
+ RendererCanvasRender::Light *clight = canvas_light_owner.get_or_null(p_light);
ERR_FAIL_COND(!clight);
clight->shadow_filter = p_filter;
}
void RendererCanvasCull::canvas_light_set_shadow_color(RID p_light, const Color &p_color) {
- RendererCanvasRender::Light *clight = canvas_light_owner.getornull(p_light);
+ RendererCanvasRender::Light *clight = canvas_light_owner.get_or_null(p_light);
ERR_FAIL_COND(!clight);
clight->shadow_color = p_color;
}
void RendererCanvasCull::canvas_light_set_shadow_smooth(RID p_light, float p_smooth) {
- RendererCanvasRender::Light *clight = canvas_light_owner.getornull(p_light);
+ RendererCanvasRender::Light *clight = canvas_light_owner.get_or_null(p_light);
ERR_FAIL_COND(!clight);
clight->shadow_smooth = p_smooth;
}
@@ -1405,11 +1405,11 @@ void RendererCanvasCull::canvas_light_occluder_initialize(RID p_rid) {
}
void RendererCanvasCull::canvas_light_occluder_attach_to_canvas(RID p_occluder, RID p_canvas) {
- RendererCanvasRender::LightOccluderInstance *occluder = canvas_light_occluder_owner.getornull(p_occluder);
+ RendererCanvasRender::LightOccluderInstance *occluder = canvas_light_occluder_owner.get_or_null(p_occluder);
ERR_FAIL_COND(!occluder);
if (occluder->canvas.is_valid()) {
- Canvas *canvas = canvas_owner.getornull(occluder->canvas);
+ Canvas *canvas = canvas_owner.get_or_null(occluder->canvas);
canvas->occluders.erase(occluder);
}
@@ -1420,24 +1420,24 @@ void RendererCanvasCull::canvas_light_occluder_attach_to_canvas(RID p_occluder,
occluder->canvas = p_canvas;
if (occluder->canvas.is_valid()) {
- Canvas *canvas = canvas_owner.getornull(occluder->canvas);
+ Canvas *canvas = canvas_owner.get_or_null(occluder->canvas);
canvas->occluders.insert(occluder);
}
}
void RendererCanvasCull::canvas_light_occluder_set_enabled(RID p_occluder, bool p_enabled) {
- RendererCanvasRender::LightOccluderInstance *occluder = canvas_light_occluder_owner.getornull(p_occluder);
+ RendererCanvasRender::LightOccluderInstance *occluder = canvas_light_occluder_owner.get_or_null(p_occluder);
ERR_FAIL_COND(!occluder);
occluder->enabled = p_enabled;
}
void RendererCanvasCull::canvas_light_occluder_set_polygon(RID p_occluder, RID p_polygon) {
- RendererCanvasRender::LightOccluderInstance *occluder = canvas_light_occluder_owner.getornull(p_occluder);
+ RendererCanvasRender::LightOccluderInstance *occluder = canvas_light_occluder_owner.get_or_null(p_occluder);
ERR_FAIL_COND(!occluder);
if (occluder->polygon.is_valid()) {
- LightOccluderPolygon *occluder_poly = canvas_light_occluder_polygon_owner.getornull(p_polygon);
+ LightOccluderPolygon *occluder_poly = canvas_light_occluder_polygon_owner.get_or_null(p_polygon);
if (occluder_poly) {
occluder_poly->owners.erase(occluder);
}
@@ -1447,7 +1447,7 @@ void RendererCanvasCull::canvas_light_occluder_set_polygon(RID p_occluder, RID p
occluder->occluder = RID();
if (occluder->polygon.is_valid()) {
- LightOccluderPolygon *occluder_poly = canvas_light_occluder_polygon_owner.getornull(p_polygon);
+ LightOccluderPolygon *occluder_poly = canvas_light_occluder_polygon_owner.get_or_null(p_polygon);
if (!occluder_poly) {
occluder->polygon = RID();
ERR_FAIL_COND(!occluder_poly);
@@ -1461,19 +1461,19 @@ void RendererCanvasCull::canvas_light_occluder_set_polygon(RID p_occluder, RID p
}
void RendererCanvasCull::canvas_light_occluder_set_as_sdf_collision(RID p_occluder, bool p_enable) {
- RendererCanvasRender::LightOccluderInstance *occluder = canvas_light_occluder_owner.getornull(p_occluder);
+ RendererCanvasRender::LightOccluderInstance *occluder = canvas_light_occluder_owner.get_or_null(p_occluder);
ERR_FAIL_COND(!occluder);
}
void RendererCanvasCull::canvas_light_occluder_set_transform(RID p_occluder, const Transform2D &p_xform) {
- RendererCanvasRender::LightOccluderInstance *occluder = canvas_light_occluder_owner.getornull(p_occluder);
+ RendererCanvasRender::LightOccluderInstance *occluder = canvas_light_occluder_owner.get_or_null(p_occluder);
ERR_FAIL_COND(!occluder);
occluder->xform = p_xform;
}
void RendererCanvasCull::canvas_light_occluder_set_light_mask(RID p_occluder, int p_mask) {
- RendererCanvasRender::LightOccluderInstance *occluder = canvas_light_occluder_owner.getornull(p_occluder);
+ RendererCanvasRender::LightOccluderInstance *occluder = canvas_light_occluder_owner.get_or_null(p_occluder);
ERR_FAIL_COND(!occluder);
occluder->light_mask = p_mask;
@@ -1484,12 +1484,12 @@ RID RendererCanvasCull::canvas_occluder_polygon_allocate() {
}
void RendererCanvasCull::canvas_occluder_polygon_initialize(RID p_rid) {
canvas_light_occluder_polygon_owner.initialize_rid(p_rid);
- LightOccluderPolygon *occluder_poly = canvas_light_occluder_polygon_owner.getornull(p_rid);
+ LightOccluderPolygon *occluder_poly = canvas_light_occluder_polygon_owner.get_or_null(p_rid);
occluder_poly->occluder = RSG::canvas_render->occluder_polygon_create();
}
void RendererCanvasCull::canvas_occluder_polygon_set_shape(RID p_occluder_polygon, const Vector<Vector2> &p_shape, bool p_closed) {
- LightOccluderPolygon *occluder_poly = canvas_light_occluder_polygon_owner.getornull(p_occluder_polygon);
+ LightOccluderPolygon *occluder_poly = canvas_light_occluder_polygon_owner.get_or_null(p_occluder_polygon);
ERR_FAIL_COND(!occluder_poly);
uint32_t pc = p_shape.size();
@@ -1513,7 +1513,7 @@ void RendererCanvasCull::canvas_occluder_polygon_set_shape(RID p_occluder_polygo
}
void RendererCanvasCull::canvas_occluder_polygon_set_cull_mode(RID p_occluder_polygon, RS::CanvasOccluderPolygonCullMode p_mode) {
- LightOccluderPolygon *occluder_poly = canvas_light_occluder_polygon_owner.getornull(p_occluder_polygon);
+ LightOccluderPolygon *occluder_poly = canvas_light_occluder_polygon_owner.get_or_null(p_occluder_polygon);
ERR_FAIL_COND(!occluder_poly);
occluder_poly->cull_mode = p_mode;
RSG::canvas_render->occluder_polygon_set_cull_mode(occluder_poly->occluder, p_mode);
@@ -1550,12 +1550,12 @@ void RendererCanvasCull::canvas_texture_set_texture_repeat(RID p_canvas_texture,
}
void RendererCanvasCull::canvas_item_set_default_texture_filter(RID p_item, RS::CanvasItemTextureFilter p_filter) {
- Item *ci = canvas_item_owner.getornull(p_item);
+ Item *ci = canvas_item_owner.get_or_null(p_item);
ERR_FAIL_COND(!ci);
ci->texture_filter = p_filter;
}
void RendererCanvasCull::canvas_item_set_default_texture_repeat(RID p_item, RS::CanvasItemTextureRepeat p_repeat) {
- Item *ci = canvas_item_owner.getornull(p_item);
+ Item *ci = canvas_item_owner.get_or_null(p_item);
ERR_FAIL_COND(!ci);
ci->texture_repeat = p_repeat;
}
@@ -1600,11 +1600,11 @@ void RendererCanvasCull::update_visibility_notifiers() {
bool RendererCanvasCull::free(RID p_rid) {
if (canvas_owner.owns(p_rid)) {
- Canvas *canvas = canvas_owner.getornull(p_rid);
+ Canvas *canvas = canvas_owner.get_or_null(p_rid);
ERR_FAIL_COND_V(!canvas, false);
while (canvas->viewports.size()) {
- RendererViewport::Viewport *vp = RSG::viewport->viewport_owner.getornull(canvas->viewports.front()->get());
+ RendererViewport::Viewport *vp = RSG::viewport->viewport_owner.get_or_null(canvas->viewports.front()->get());
ERR_FAIL_COND_V(!vp, true);
Map<RID, RendererViewport::Viewport::CanvasData>::Element *E = vp->canvas_map.find(p_rid);
@@ -1629,15 +1629,15 @@ bool RendererCanvasCull::free(RID p_rid) {
canvas_owner.free(p_rid);
} else if (canvas_item_owner.owns(p_rid)) {
- Item *canvas_item = canvas_item_owner.getornull(p_rid);
+ Item *canvas_item = canvas_item_owner.get_or_null(p_rid);
ERR_FAIL_COND_V(!canvas_item, true);
if (canvas_item->parent.is_valid()) {
if (canvas_owner.owns(canvas_item->parent)) {
- Canvas *canvas = canvas_owner.getornull(canvas_item->parent);
+ Canvas *canvas = canvas_owner.get_or_null(canvas_item->parent);
canvas->erase_item(canvas_item);
} else if (canvas_item_owner.owns(canvas_item->parent)) {
- Item *item_owner = canvas_item_owner.getornull(canvas_item->parent);
+ Item *item_owner = canvas_item_owner.get_or_null(canvas_item->parent);
item_owner->child_items.erase(canvas_item);
if (item_owner->sort_y) {
@@ -1663,11 +1663,11 @@ bool RendererCanvasCull::free(RID p_rid) {
canvas_item_owner.free(p_rid);
} else if (canvas_light_owner.owns(p_rid)) {
- RendererCanvasRender::Light *canvas_light = canvas_light_owner.getornull(p_rid);
+ RendererCanvasRender::Light *canvas_light = canvas_light_owner.get_or_null(p_rid);
ERR_FAIL_COND_V(!canvas_light, true);
if (canvas_light->canvas.is_valid()) {
- Canvas *canvas = canvas_owner.getornull(canvas_light->canvas);
+ Canvas *canvas = canvas_owner.get_or_null(canvas_light->canvas);
if (canvas) {
canvas->lights.erase(canvas_light);
}
@@ -1678,25 +1678,25 @@ bool RendererCanvasCull::free(RID p_rid) {
canvas_light_owner.free(p_rid);
} else if (canvas_light_occluder_owner.owns(p_rid)) {
- RendererCanvasRender::LightOccluderInstance *occluder = canvas_light_occluder_owner.getornull(p_rid);
+ RendererCanvasRender::LightOccluderInstance *occluder = canvas_light_occluder_owner.get_or_null(p_rid);
ERR_FAIL_COND_V(!occluder, true);
if (occluder->polygon.is_valid()) {
- LightOccluderPolygon *occluder_poly = canvas_light_occluder_polygon_owner.getornull(occluder->polygon);
+ LightOccluderPolygon *occluder_poly = canvas_light_occluder_polygon_owner.get_or_null(occluder->polygon);
if (occluder_poly) {
occluder_poly->owners.erase(occluder);
}
}
if (occluder->canvas.is_valid() && canvas_owner.owns(occluder->canvas)) {
- Canvas *canvas = canvas_owner.getornull(occluder->canvas);
+ Canvas *canvas = canvas_owner.get_or_null(occluder->canvas);
canvas->occluders.erase(occluder);
}
canvas_light_occluder_owner.free(p_rid);
} else if (canvas_light_occluder_polygon_owner.owns(p_rid)) {
- LightOccluderPolygon *occluder_poly = canvas_light_occluder_polygon_owner.getornull(p_rid);
+ LightOccluderPolygon *occluder_poly = canvas_light_occluder_polygon_owner.get_or_null(p_rid);
ERR_FAIL_COND_V(!occluder_poly, true);
RSG::canvas_render->free(occluder_poly->occluder);
diff --git a/servers/rendering/renderer_rd/forward_clustered/render_forward_clustered.cpp b/servers/rendering/renderer_rd/forward_clustered/render_forward_clustered.cpp
index fa3741c077..2377702738 100644
--- a/servers/rendering/renderer_rd/forward_clustered/render_forward_clustered.cpp
+++ b/servers/rendering/renderer_rd/forward_clustered/render_forward_clustered.cpp
@@ -2695,7 +2695,7 @@ void RenderForwardClustered::_geometry_instance_update(GeometryInstance *p_geome
} break;
#if 0
case RS::INSTANCE_IMMEDIATE: {
- RasterizerStorageGLES3::Immediate *immediate = storage->immediate_owner.getornull(inst->base);
+ RasterizerStorageGLES3::Immediate *immediate = storage->immediate_owner.get_or_null(inst->base);
ERR_CONTINUE(!immediate);
_add_geometry(immediate, inst, nullptr, -1, p_depth_pass, p_shadow_pass);
diff --git a/servers/rendering/renderer_rd/forward_clustered/scene_shader_forward_clustered.cpp b/servers/rendering/renderer_rd/forward_clustered/scene_shader_forward_clustered.cpp
index 1947680a7a..0416b06d0d 100644
--- a/servers/rendering/renderer_rd/forward_clustered/scene_shader_forward_clustered.cpp
+++ b/servers/rendering/renderer_rd/forward_clustered/scene_shader_forward_clustered.cpp
@@ -344,36 +344,36 @@ void SceneShaderForwardClustered::ShaderData::set_default_texture_param(const St
void SceneShaderForwardClustered::ShaderData::get_param_list(List<PropertyInfo> *p_param_list) const {
Map<int, StringName> order;
- for (Map<StringName, ShaderLanguage::ShaderNode::Uniform>::Element *E = uniforms.front(); E; E = E->next()) {
- if (E->get().scope != ShaderLanguage::ShaderNode::Uniform::SCOPE_LOCAL) {
+ for (const KeyValue<StringName, ShaderLanguage::ShaderNode::Uniform> &E : uniforms) {
+ if (E.value.scope != ShaderLanguage::ShaderNode::Uniform::SCOPE_LOCAL) {
continue;
}
- if (E->get().texture_order >= 0) {
- order[E->get().texture_order + 100000] = E->key();
+ if (E.value.texture_order >= 0) {
+ order[E.value.texture_order + 100000] = E.key;
} else {
- order[E->get().order] = E->key();
+ order[E.value.order] = E.key;
}
}
- for (Map<int, StringName>::Element *E = order.front(); E; E = E->next()) {
- PropertyInfo pi = ShaderLanguage::uniform_to_property_info(uniforms[E->get()]);
- pi.name = E->get();
+ for (const KeyValue<int, StringName> &E : order) {
+ PropertyInfo pi = ShaderLanguage::uniform_to_property_info(uniforms[E.value]);
+ pi.name = E.value;
p_param_list->push_back(pi);
}
}
void SceneShaderForwardClustered::ShaderData::get_instance_param_list(List<RendererStorage::InstanceShaderParam> *p_param_list) const {
- for (Map<StringName, ShaderLanguage::ShaderNode::Uniform>::Element *E = uniforms.front(); E; E = E->next()) {
- if (E->get().scope != ShaderLanguage::ShaderNode::Uniform::SCOPE_INSTANCE) {
+ for (const KeyValue<StringName, ShaderLanguage::ShaderNode::Uniform> &E : uniforms) {
+ if (E.value.scope != ShaderLanguage::ShaderNode::Uniform::SCOPE_INSTANCE) {
continue;
}
RendererStorage::InstanceShaderParam p;
- p.info = ShaderLanguage::uniform_to_property_info(E->get());
- p.info.name = E->key(); //supply name
- p.index = E->get().instance_index;
- p.default_value = ShaderLanguage::constant_value_to_variant(E->get().default_value, E->get().type, E->get().hint);
+ p.info = ShaderLanguage::uniform_to_property_info(E.value);
+ p.info.name = E.key; //supply name
+ p.index = E.value.instance_index;
+ p.default_value = ShaderLanguage::constant_value_to_variant(E.value.default_value, E.value.type, E.value.hint);
p_param_list->push_back(p);
}
}
diff --git a/servers/rendering/renderer_rd/forward_mobile/render_forward_mobile.cpp b/servers/rendering/renderer_rd/forward_mobile/render_forward_mobile.cpp
index a5cc2db48f..75de2f6fbd 100644
--- a/servers/rendering/renderer_rd/forward_mobile/render_forward_mobile.cpp
+++ b/servers/rendering/renderer_rd/forward_mobile/render_forward_mobile.cpp
@@ -2440,7 +2440,7 @@ void RenderForwardMobile::_geometry_instance_update(GeometryInstance *p_geometry
} break;
#if 0
case RS::INSTANCE_IMMEDIATE: {
- RasterizerStorageGLES3::Immediate *immediate = storage->immediate_owner.getornull(inst->base);
+ RasterizerStorageGLES3::Immediate *immediate = storage->immediate_owner.get_or_null(inst->base);
ERR_CONTINUE(!immediate);
_add_geometry(immediate, inst, nullptr, -1, p_depth_pass, p_shadow_pass);
diff --git a/servers/rendering/renderer_rd/forward_mobile/scene_shader_forward_mobile.cpp b/servers/rendering/renderer_rd/forward_mobile/scene_shader_forward_mobile.cpp
index cd314d8c56..4118735cf2 100644
--- a/servers/rendering/renderer_rd/forward_mobile/scene_shader_forward_mobile.cpp
+++ b/servers/rendering/renderer_rd/forward_mobile/scene_shader_forward_mobile.cpp
@@ -336,36 +336,36 @@ void SceneShaderForwardMobile::ShaderData::set_default_texture_param(const Strin
void SceneShaderForwardMobile::ShaderData::get_param_list(List<PropertyInfo> *p_param_list) const {
Map<int, StringName> order;
- for (Map<StringName, ShaderLanguage::ShaderNode::Uniform>::Element *E = uniforms.front(); E; E = E->next()) {
- if (E->get().scope != ShaderLanguage::ShaderNode::Uniform::SCOPE_LOCAL) {
+ for (const KeyValue<StringName, ShaderLanguage::ShaderNode::Uniform> &E : uniforms) {
+ if (E.value.scope != ShaderLanguage::ShaderNode::Uniform::SCOPE_LOCAL) {
continue;
}
- if (E->get().texture_order >= 0) {
- order[E->get().texture_order + 100000] = E->key();
+ if (E.value.texture_order >= 0) {
+ order[E.value.texture_order + 100000] = E.key;
} else {
- order[E->get().order] = E->key();
+ order[E.value.order] = E.key;
}
}
- for (Map<int, StringName>::Element *E = order.front(); E; E = E->next()) {
- PropertyInfo pi = ShaderLanguage::uniform_to_property_info(uniforms[E->get()]);
- pi.name = E->get();
+ for (const KeyValue<int, StringName> &E : order) {
+ PropertyInfo pi = ShaderLanguage::uniform_to_property_info(uniforms[E.value]);
+ pi.name = E.value;
p_param_list->push_back(pi);
}
}
void SceneShaderForwardMobile::ShaderData::get_instance_param_list(List<RendererStorage::InstanceShaderParam> *p_param_list) const {
- for (Map<StringName, ShaderLanguage::ShaderNode::Uniform>::Element *E = uniforms.front(); E; E = E->next()) {
- if (E->get().scope != ShaderLanguage::ShaderNode::Uniform::SCOPE_INSTANCE) {
+ for (const KeyValue<StringName, ShaderLanguage::ShaderNode::Uniform> &E : uniforms) {
+ if (E.value.scope != ShaderLanguage::ShaderNode::Uniform::SCOPE_INSTANCE) {
continue;
}
RendererStorage::InstanceShaderParam p;
- p.info = ShaderLanguage::uniform_to_property_info(E->get());
- p.info.name = E->key(); //supply name
- p.index = E->get().instance_index;
- p.default_value = ShaderLanguage::constant_value_to_variant(E->get().default_value, E->get().type, E->get().hint);
+ p.info = ShaderLanguage::uniform_to_property_info(E.value);
+ p.info.name = E.key; //supply name
+ p.index = E.value.instance_index;
+ p.default_value = ShaderLanguage::constant_value_to_variant(E.value.default_value, E.value.type, E.value.hint);
p_param_list->push_back(p);
}
}
diff --git a/servers/rendering/renderer_rd/renderer_canvas_render_rd.cpp b/servers/rendering/renderer_rd/renderer_canvas_render_rd.cpp
index c2227587ec..b792ec9971 100644
--- a/servers/rendering/renderer_rd/renderer_canvas_render_rd.cpp
+++ b/servers/rendering/renderer_rd/renderer_canvas_render_rd.cpp
@@ -1144,7 +1144,7 @@ void RendererCanvasRenderRD::canvas_render_items(RID p_to_render_target, Item *p
continue;
}
- CanvasLight *clight = canvas_light_owner.getornull(l->light_internal);
+ CanvasLight *clight = canvas_light_owner.get_or_null(l->light_internal);
if (!clight) { //unused or invalid texture
l->render_index_cache = -1;
l = l->next_ptr;
@@ -1207,7 +1207,7 @@ void RendererCanvasRenderRD::canvas_render_items(RID p_to_render_target, Item *p
continue;
}
- CanvasLight *clight = canvas_light_owner.getornull(l->light_internal);
+ CanvasLight *clight = canvas_light_owner.get_or_null(l->light_internal);
if (!clight) { //unused or invalid texture
l->render_index_cache = -1;
l = l->next_ptr;
@@ -1481,7 +1481,7 @@ RID RendererCanvasRenderRD::light_create() {
}
void RendererCanvasRenderRD::light_set_texture(RID p_rid, RID p_texture) {
- CanvasLight *cl = canvas_light_owner.getornull(p_rid);
+ CanvasLight *cl = canvas_light_owner.get_or_null(p_rid);
ERR_FAIL_COND(!cl);
if (cl->texture == p_texture) {
return;
@@ -1497,7 +1497,7 @@ void RendererCanvasRenderRD::light_set_texture(RID p_rid, RID p_texture) {
}
void RendererCanvasRenderRD::light_set_use_shadow(RID p_rid, bool p_enable) {
- CanvasLight *cl = canvas_light_owner.getornull(p_rid);
+ CanvasLight *cl = canvas_light_owner.get_or_null(p_rid);
ERR_FAIL_COND(!cl);
cl->shadow.enabled = p_enable;
@@ -1537,7 +1537,7 @@ void RendererCanvasRenderRD::_update_shadow_atlas() {
}
}
void RendererCanvasRenderRD::light_update_shadow(RID p_rid, int p_shadow_index, const Transform2D &p_light_xform, int p_light_mask, float p_near, float p_far, LightOccluderInstance *p_occluders) {
- CanvasLight *cl = canvas_light_owner.getornull(p_rid);
+ CanvasLight *cl = canvas_light_owner.get_or_null(p_rid);
ERR_FAIL_COND(!cl->shadow.enabled);
_update_shadow_atlas();
@@ -1591,7 +1591,7 @@ void RendererCanvasRenderRD::light_update_shadow(RID p_rid, int p_shadow_index,
LightOccluderInstance *instance = p_occluders;
while (instance) {
- OccluderPolygon *co = occluder_polygon_owner.getornull(instance->occluder);
+ OccluderPolygon *co = occluder_polygon_owner.get_or_null(instance->occluder);
if (!co || co->index_array.is_null() || !(p_light_mask & instance->light_mask)) {
instance = instance->next;
@@ -1615,7 +1615,7 @@ void RendererCanvasRenderRD::light_update_shadow(RID p_rid, int p_shadow_index,
}
void RendererCanvasRenderRD::light_update_directional_shadow(RID p_rid, int p_shadow_index, const Transform2D &p_light_xform, int p_light_mask, float p_cull_distance, const Rect2 &p_clip_rect, LightOccluderInstance *p_occluders) {
- CanvasLight *cl = canvas_light_owner.getornull(p_rid);
+ CanvasLight *cl = canvas_light_owner.get_or_null(p_rid);
ERR_FAIL_COND(!cl->shadow.enabled);
_update_shadow_atlas();
@@ -1666,7 +1666,7 @@ void RendererCanvasRenderRD::light_update_directional_shadow(RID p_rid, int p_sh
LightOccluderInstance *instance = p_occluders;
while (instance) {
- OccluderPolygon *co = occluder_polygon_owner.getornull(instance->occluder);
+ OccluderPolygon *co = occluder_polygon_owner.get_or_null(instance->occluder);
if (!co || co->index_array.is_null() || !(p_light_mask & instance->light_mask)) {
instance = instance->next;
@@ -1732,7 +1732,7 @@ void RendererCanvasRenderRD::render_sdf(RID p_render_target, LightOccluderInstan
LightOccluderInstance *instance = p_occluders;
while (instance) {
- OccluderPolygon *co = occluder_polygon_owner.getornull(instance->occluder);
+ OccluderPolygon *co = occluder_polygon_owner.get_or_null(instance->occluder);
if (!co || co->sdf_index_array.is_null()) {
instance = instance->next;
@@ -1766,7 +1766,7 @@ RID RendererCanvasRenderRD::occluder_polygon_create() {
}
void RendererCanvasRenderRD::occluder_polygon_set_shape(RID p_occluder, const Vector<Vector2> &p_points, bool p_closed) {
- OccluderPolygon *oc = occluder_polygon_owner.getornull(p_occluder);
+ OccluderPolygon *oc = occluder_polygon_owner.get_or_null(p_occluder);
ERR_FAIL_COND(!oc);
Vector<Vector2> lines;
@@ -1935,7 +1935,7 @@ void RendererCanvasRenderRD::occluder_polygon_set_shape(RID p_occluder, const Ve
}
void RendererCanvasRenderRD::occluder_polygon_set_cull_mode(RID p_occluder, RS::CanvasOccluderPolygonCullMode p_mode) {
- OccluderPolygon *oc = occluder_polygon_owner.getornull(p_occluder);
+ OccluderPolygon *oc = occluder_polygon_owner.get_or_null(p_occluder);
ERR_FAIL_COND(!oc);
oc->cull_mode = p_mode;
}
@@ -2133,35 +2133,35 @@ void RendererCanvasRenderRD::ShaderData::set_default_texture_param(const StringN
void RendererCanvasRenderRD::ShaderData::get_param_list(List<PropertyInfo> *p_param_list) const {
Map<int, StringName> order;
- for (Map<StringName, ShaderLanguage::ShaderNode::Uniform>::Element *E = uniforms.front(); E; E = E->next()) {
- if (E->get().scope != ShaderLanguage::ShaderNode::Uniform::SCOPE_LOCAL) {
+ for (const KeyValue<StringName, ShaderLanguage::ShaderNode::Uniform> &E : uniforms) {
+ if (E.value.scope != ShaderLanguage::ShaderNode::Uniform::SCOPE_LOCAL) {
continue;
}
- if (E->get().texture_order >= 0) {
- order[E->get().texture_order + 100000] = E->key();
+ if (E.value.texture_order >= 0) {
+ order[E.value.texture_order + 100000] = E.key;
} else {
- order[E->get().order] = E->key();
+ order[E.value.order] = E.key;
}
}
- for (Map<int, StringName>::Element *E = order.front(); E; E = E->next()) {
- PropertyInfo pi = ShaderLanguage::uniform_to_property_info(uniforms[E->get()]);
- pi.name = E->get();
+ for (const KeyValue<int, StringName> &E : order) {
+ PropertyInfo pi = ShaderLanguage::uniform_to_property_info(uniforms[E.value]);
+ pi.name = E.value;
p_param_list->push_back(pi);
}
}
void RendererCanvasRenderRD::ShaderData::get_instance_param_list(List<RendererStorage::InstanceShaderParam> *p_param_list) const {
- for (Map<StringName, ShaderLanguage::ShaderNode::Uniform>::Element *E = uniforms.front(); E; E = E->next()) {
- if (E->get().scope != ShaderLanguage::ShaderNode::Uniform::SCOPE_INSTANCE) {
+ for (const KeyValue<StringName, ShaderLanguage::ShaderNode::Uniform> &E : uniforms) {
+ if (E.value.scope != ShaderLanguage::ShaderNode::Uniform::SCOPE_INSTANCE) {
continue;
}
RendererStorage::InstanceShaderParam p;
- p.info = ShaderLanguage::uniform_to_property_info(E->get());
- p.info.name = E->key(); //supply name
- p.index = E->get().instance_index;
- p.default_value = ShaderLanguage::constant_value_to_variant(E->get().default_value, E->get().type, E->get().hint);
+ p.info = ShaderLanguage::uniform_to_property_info(E.value);
+ p.info.name = E.key; //supply name
+ p.index = E.value.instance_index;
+ p.default_value = ShaderLanguage::constant_value_to_variant(E.value.default_value, E.value.type, E.value.hint);
p_param_list->push_back(p);
}
}
@@ -2611,7 +2611,7 @@ void fragment() {
bool RendererCanvasRenderRD::free(RID p_rid) {
if (canvas_light_owner.owns(p_rid)) {
- CanvasLight *cl = canvas_light_owner.getornull(p_rid);
+ CanvasLight *cl = canvas_light_owner.get_or_null(p_rid);
ERR_FAIL_COND_V(!cl, false);
light_set_use_shadow(p_rid, false);
canvas_light_owner.free(p_rid);
diff --git a/servers/rendering/renderer_rd/renderer_scene_gi_rd.cpp b/servers/rendering/renderer_rd/renderer_scene_gi_rd.cpp
index fb308da38d..ecc560fc5d 100644
--- a/servers/rendering/renderer_rd/renderer_scene_gi_rd.cpp
+++ b/servers/rendering/renderer_rd/renderer_scene_gi_rd.cpp
@@ -1450,7 +1450,7 @@ void RendererSceneGIRD::SDFGI::pre_process_gi(const Transform3D &p_transform, Re
break;
}
- RendererSceneRenderRD::LightInstance *li = p_scene_render->light_instance_owner.getornull(p_scene_render->render_state.sdfgi_update_data->directional_lights->get(j));
+ RendererSceneRenderRD::LightInstance *li = p_scene_render->light_instance_owner.get_or_null(p_scene_render->render_state.sdfgi_update_data->directional_lights->get(j));
ERR_CONTINUE(!li);
if (storage->light_directional_is_sky_only(li->light)) {
@@ -1484,7 +1484,7 @@ void RendererSceneGIRD::SDFGI::pre_process_gi(const Transform3D &p_transform, Re
break;
}
- RendererSceneRenderRD::LightInstance *li = p_scene_render->light_instance_owner.getornull(p_scene_render->render_state.sdfgi_update_data->positional_light_instances[j]);
+ RendererSceneRenderRD::LightInstance *li = p_scene_render->light_instance_owner.get_or_null(p_scene_render->render_state.sdfgi_update_data->positional_light_instances[j]);
ERR_CONTINUE(!li);
uint32_t max_sdfgi_cascade = storage->light_get_max_sdfgi_cascade(li->light);
@@ -1534,7 +1534,7 @@ void RendererSceneGIRD::SDFGI::pre_process_gi(const Transform3D &p_transform, Re
void RendererSceneGIRD::SDFGI::render_region(RID p_render_buffers, int p_region, const PagedArray<RendererSceneRender::GeometryInstance *> &p_instances, RendererSceneRenderRD *p_scene_render) {
//print_line("rendering region " + itos(p_region));
- RendererSceneRenderRD::RenderBuffers *rb = p_scene_render->render_buffers_owner.getornull(p_render_buffers);
+ RendererSceneRenderRD::RenderBuffers *rb = p_scene_render->render_buffers_owner.get_or_null(p_render_buffers);
ERR_FAIL_COND(!rb); // we wouldn't be here if this failed but...
AABB bounds;
Vector3i from;
@@ -1892,7 +1892,7 @@ void RendererSceneGIRD::SDFGI::render_region(RID p_render_buffers, int p_region,
}
void RendererSceneGIRD::SDFGI::render_static_lights(RID p_render_buffers, uint32_t p_cascade_count, const uint32_t *p_cascade_indices, const PagedArray<RID> *p_positional_light_cull_result, RendererSceneRenderRD *p_scene_render) {
- RendererSceneRenderRD::RenderBuffers *rb = p_scene_render->render_buffers_owner.getornull(p_render_buffers);
+ RendererSceneRenderRD::RenderBuffers *rb = p_scene_render->render_buffers_owner.get_or_null(p_render_buffers);
ERR_FAIL_COND(!rb); // we wouldn't be here if this failed but...
RD::get_singleton()->draw_command_begin_label("SDFGI Render Static Lighs");
@@ -1921,7 +1921,7 @@ void RendererSceneGIRD::SDFGI::render_static_lights(RID p_render_buffers, uint32
break;
}
- RendererSceneRenderRD::LightInstance *li = p_scene_render->light_instance_owner.getornull(p_positional_light_cull_result[i][j]);
+ RendererSceneRenderRD::LightInstance *li = p_scene_render->light_instance_owner.get_or_null(p_positional_light_cull_result[i][j]);
ERR_CONTINUE(!li);
uint32_t max_sdfgi_cascade = storage->light_get_max_sdfgi_cascade(li->light);
@@ -3024,7 +3024,7 @@ void RendererSceneGIRD::setup_voxel_gi_instances(RID p_render_buffers, const Tra
r_voxel_gi_instances_used = 0;
// feels a little dirty to use our container this way but....
- RendererSceneRenderRD::RenderBuffers *rb = p_scene_render->render_buffers_owner.getornull(p_render_buffers);
+ RendererSceneRenderRD::RenderBuffers *rb = p_scene_render->render_buffers_owner.get_or_null(p_render_buffers);
ERR_FAIL_COND(rb == nullptr);
RID voxel_gi_buffer = p_scene_render->render_buffers_get_voxel_gi_buffer(p_render_buffers);
@@ -3119,9 +3119,9 @@ void RendererSceneGIRD::setup_voxel_gi_instances(RID p_render_buffers, const Tra
void RendererSceneGIRD::process_gi(RID p_render_buffers, RID p_normal_roughness_buffer, RID p_voxel_gi_buffer, RID p_environment, const CameraMatrix &p_projection, const Transform3D &p_transform, const PagedArray<RID> &p_voxel_gi_instances, RendererSceneRenderRD *p_scene_render) {
RD::get_singleton()->draw_command_begin_label("GI Render");
- RendererSceneRenderRD::RenderBuffers *rb = p_scene_render->render_buffers_owner.getornull(p_render_buffers);
+ RendererSceneRenderRD::RenderBuffers *rb = p_scene_render->render_buffers_owner.get_or_null(p_render_buffers);
ERR_FAIL_COND(rb == nullptr);
- RendererSceneEnvironmentRD *env = p_scene_render->environment_owner.getornull(p_environment);
+ RendererSceneEnvironmentRD *env = p_scene_render->environment_owner.get_or_null(p_environment);
if (rb->ambient_buffer.is_null() || rb->gi.using_half_size_gi != half_resolution) {
if (rb->ambient_buffer.is_valid()) {
@@ -3393,7 +3393,7 @@ void RendererSceneGIRD::voxel_gi_update(RID p_probe, bool p_update_light_instanc
}
void RendererSceneGIRD::debug_voxel_gi(RID p_voxel_gi, RD::DrawListID p_draw_list, RID p_framebuffer, const CameraMatrix &p_camera_with_transform, bool p_lighting, bool p_emission, float p_alpha) {
- VoxelGIInstance *voxel_gi = voxel_gi_instance_owner.getornull(p_voxel_gi);
+ VoxelGIInstance *voxel_gi = voxel_gi_instance_owner.get_or_null(p_voxel_gi);
ERR_FAIL_COND(!voxel_gi);
voxel_gi->debug(p_draw_list, p_framebuffer, p_camera_with_transform, p_lighting, p_emission, p_alpha);
diff --git a/servers/rendering/renderer_rd/renderer_scene_gi_rd.h b/servers/rendering/renderer_rd/renderer_scene_gi_rd.h
index 0b4622646f..5bd41a104e 100644
--- a/servers/rendering/renderer_rd/renderer_scene_gi_rd.h
+++ b/servers/rendering/renderer_rd/renderer_scene_gi_rd.h
@@ -383,7 +383,7 @@ public:
mutable RID_Owner<VoxelGIInstance> voxel_gi_instance_owner;
_FORCE_INLINE_ VoxelGIInstance *get_probe_instance(RID p_probe) const {
- return voxel_gi_instance_owner.getornull(p_probe);
+ return voxel_gi_instance_owner.get_or_null(p_probe);
};
_FORCE_INLINE_ RID voxel_gi_instance_get_texture(RID p_probe) {
diff --git a/servers/rendering/renderer_rd/renderer_scene_render_rd.cpp b/servers/rendering/renderer_rd/renderer_scene_render_rd.cpp
index 0f98417215..a1c2f4f49c 100644
--- a/servers/rendering/renderer_rd/renderer_scene_render_rd.cpp
+++ b/servers/rendering/renderer_rd/renderer_scene_render_rd.cpp
@@ -48,8 +48,8 @@ void get_vogel_disk(float *r_kernel, int p_sample_count) {
}
void RendererSceneRenderRD::sdfgi_update(RID p_render_buffers, RID p_environment, const Vector3 &p_world_position) {
- RendererSceneEnvironmentRD *env = environment_owner.getornull(p_environment);
- RenderBuffers *rb = render_buffers_owner.getornull(p_render_buffers);
+ RendererSceneEnvironmentRD *env = environment_owner.get_or_null(p_environment);
+ RenderBuffers *rb = render_buffers_owner.get_or_null(p_render_buffers);
bool needs_sdfgi = env && env->sdfgi_enabled;
if (!needs_sdfgi) {
@@ -83,7 +83,7 @@ void RendererSceneRenderRD::sdfgi_update(RID p_render_buffers, RID p_environment
}
int RendererSceneRenderRD::sdfgi_get_pending_region_count(RID p_render_buffers) const {
- RenderBuffers *rb = render_buffers_owner.getornull(p_render_buffers);
+ RenderBuffers *rb = render_buffers_owner.get_or_null(p_render_buffers);
ERR_FAIL_COND_V(rb == nullptr, 0);
@@ -113,7 +113,7 @@ AABB RendererSceneRenderRD::sdfgi_get_pending_region_bounds(RID p_render_buffers
AABB bounds;
Vector3i from;
Vector3i size;
- RenderBuffers *rb = render_buffers_owner.getornull(p_render_buffers);
+ RenderBuffers *rb = render_buffers_owner.get_or_null(p_render_buffers);
ERR_FAIL_COND_V(rb == nullptr, AABB());
ERR_FAIL_COND_V(rb->sdfgi == nullptr, AABB());
@@ -126,7 +126,7 @@ uint32_t RendererSceneRenderRD::sdfgi_get_pending_region_cascade(RID p_render_bu
AABB bounds;
Vector3i from;
Vector3i size;
- RenderBuffers *rb = render_buffers_owner.getornull(p_render_buffers);
+ RenderBuffers *rb = render_buffers_owner.get_or_null(p_render_buffers);
ERR_FAIL_COND_V(rb == nullptr, -1);
ERR_FAIL_COND_V(rb->sdfgi == nullptr, -1);
@@ -164,139 +164,139 @@ void RendererSceneRenderRD::environment_initialize(RID p_rid) {
}
void RendererSceneRenderRD::environment_set_background(RID p_env, RS::EnvironmentBG p_bg) {
- RendererSceneEnvironmentRD *env = environment_owner.getornull(p_env);
+ RendererSceneEnvironmentRD *env = environment_owner.get_or_null(p_env);
ERR_FAIL_COND(!env);
env->background = p_bg;
}
void RendererSceneRenderRD::environment_set_sky(RID p_env, RID p_sky) {
- RendererSceneEnvironmentRD *env = environment_owner.getornull(p_env);
+ RendererSceneEnvironmentRD *env = environment_owner.get_or_null(p_env);
ERR_FAIL_COND(!env);
env->sky = p_sky;
}
void RendererSceneRenderRD::environment_set_sky_custom_fov(RID p_env, float p_scale) {
- RendererSceneEnvironmentRD *env = environment_owner.getornull(p_env);
+ RendererSceneEnvironmentRD *env = environment_owner.get_or_null(p_env);
ERR_FAIL_COND(!env);
env->sky_custom_fov = p_scale;
}
void RendererSceneRenderRD::environment_set_sky_orientation(RID p_env, const Basis &p_orientation) {
- RendererSceneEnvironmentRD *env = environment_owner.getornull(p_env);
+ RendererSceneEnvironmentRD *env = environment_owner.get_or_null(p_env);
ERR_FAIL_COND(!env);
env->sky_orientation = p_orientation;
}
void RendererSceneRenderRD::environment_set_bg_color(RID p_env, const Color &p_color) {
- RendererSceneEnvironmentRD *env = environment_owner.getornull(p_env);
+ RendererSceneEnvironmentRD *env = environment_owner.get_or_null(p_env);
ERR_FAIL_COND(!env);
env->bg_color = p_color;
}
void RendererSceneRenderRD::environment_set_bg_energy(RID p_env, float p_energy) {
- RendererSceneEnvironmentRD *env = environment_owner.getornull(p_env);
+ RendererSceneEnvironmentRD *env = environment_owner.get_or_null(p_env);
ERR_FAIL_COND(!env);
env->bg_energy = p_energy;
}
void RendererSceneRenderRD::environment_set_canvas_max_layer(RID p_env, int p_max_layer) {
- RendererSceneEnvironmentRD *env = environment_owner.getornull(p_env);
+ RendererSceneEnvironmentRD *env = environment_owner.get_or_null(p_env);
ERR_FAIL_COND(!env);
env->canvas_max_layer = p_max_layer;
}
void RendererSceneRenderRD::environment_set_ambient_light(RID p_env, const Color &p_color, RS::EnvironmentAmbientSource p_ambient, float p_energy, float p_sky_contribution, RS::EnvironmentReflectionSource p_reflection_source, const Color &p_ao_color) {
- RendererSceneEnvironmentRD *env = environment_owner.getornull(p_env);
+ RendererSceneEnvironmentRD *env = environment_owner.get_or_null(p_env);
ERR_FAIL_COND(!env);
env->set_ambient_light(p_color, p_ambient, p_energy, p_sky_contribution, p_reflection_source, p_ao_color);
}
RS::EnvironmentBG RendererSceneRenderRD::environment_get_background(RID p_env) const {
- RendererSceneEnvironmentRD *env = environment_owner.getornull(p_env);
+ RendererSceneEnvironmentRD *env = environment_owner.get_or_null(p_env);
ERR_FAIL_COND_V(!env, RS::ENV_BG_MAX);
return env->background;
}
RID RendererSceneRenderRD::environment_get_sky(RID p_env) const {
- RendererSceneEnvironmentRD *env = environment_owner.getornull(p_env);
+ RendererSceneEnvironmentRD *env = environment_owner.get_or_null(p_env);
ERR_FAIL_COND_V(!env, RID());
return env->sky;
}
float RendererSceneRenderRD::environment_get_sky_custom_fov(RID p_env) const {
- RendererSceneEnvironmentRD *env = environment_owner.getornull(p_env);
+ RendererSceneEnvironmentRD *env = environment_owner.get_or_null(p_env);
ERR_FAIL_COND_V(!env, 0);
return env->sky_custom_fov;
}
Basis RendererSceneRenderRD::environment_get_sky_orientation(RID p_env) const {
- RendererSceneEnvironmentRD *env = environment_owner.getornull(p_env);
+ RendererSceneEnvironmentRD *env = environment_owner.get_or_null(p_env);
ERR_FAIL_COND_V(!env, Basis());
return env->sky_orientation;
}
Color RendererSceneRenderRD::environment_get_bg_color(RID p_env) const {
- RendererSceneEnvironmentRD *env = environment_owner.getornull(p_env);
+ RendererSceneEnvironmentRD *env = environment_owner.get_or_null(p_env);
ERR_FAIL_COND_V(!env, Color());
return env->bg_color;
}
float RendererSceneRenderRD::environment_get_bg_energy(RID p_env) const {
- RendererSceneEnvironmentRD *env = environment_owner.getornull(p_env);
+ RendererSceneEnvironmentRD *env = environment_owner.get_or_null(p_env);
ERR_FAIL_COND_V(!env, 0);
return env->bg_energy;
}
int RendererSceneRenderRD::environment_get_canvas_max_layer(RID p_env) const {
- RendererSceneEnvironmentRD *env = environment_owner.getornull(p_env);
+ RendererSceneEnvironmentRD *env = environment_owner.get_or_null(p_env);
ERR_FAIL_COND_V(!env, 0);
return env->canvas_max_layer;
}
Color RendererSceneRenderRD::environment_get_ambient_light_color(RID p_env) const {
- RendererSceneEnvironmentRD *env = environment_owner.getornull(p_env);
+ RendererSceneEnvironmentRD *env = environment_owner.get_or_null(p_env);
ERR_FAIL_COND_V(!env, Color());
return env->ambient_light;
}
RS::EnvironmentAmbientSource RendererSceneRenderRD::environment_get_ambient_source(RID p_env) const {
- RendererSceneEnvironmentRD *env = environment_owner.getornull(p_env);
+ RendererSceneEnvironmentRD *env = environment_owner.get_or_null(p_env);
ERR_FAIL_COND_V(!env, RS::ENV_AMBIENT_SOURCE_BG);
return env->ambient_source;
}
float RendererSceneRenderRD::environment_get_ambient_light_energy(RID p_env) const {
- RendererSceneEnvironmentRD *env = environment_owner.getornull(p_env);
+ RendererSceneEnvironmentRD *env = environment_owner.get_or_null(p_env);
ERR_FAIL_COND_V(!env, 0);
return env->ambient_light_energy;
}
float RendererSceneRenderRD::environment_get_ambient_sky_contribution(RID p_env) const {
- RendererSceneEnvironmentRD *env = environment_owner.getornull(p_env);
+ RendererSceneEnvironmentRD *env = environment_owner.get_or_null(p_env);
ERR_FAIL_COND_V(!env, 0);
return env->ambient_sky_contribution;
}
RS::EnvironmentReflectionSource RendererSceneRenderRD::environment_get_reflection_source(RID p_env) const {
- RendererSceneEnvironmentRD *env = environment_owner.getornull(p_env);
+ RendererSceneEnvironmentRD *env = environment_owner.get_or_null(p_env);
ERR_FAIL_COND_V(!env, RS::ENV_REFLECTION_SOURCE_DISABLED);
return env->reflection_source;
}
Color RendererSceneRenderRD::environment_get_ao_color(RID p_env) const {
- RendererSceneEnvironmentRD *env = environment_owner.getornull(p_env);
+ RendererSceneEnvironmentRD *env = environment_owner.get_or_null(p_env);
ERR_FAIL_COND_V(!env, Color());
return env->ao_color;
}
void RendererSceneRenderRD::environment_set_tonemap(RID p_env, RS::EnvironmentToneMapper p_tone_mapper, float p_exposure, float p_white, bool p_auto_exposure, float p_min_luminance, float p_max_luminance, float p_auto_exp_speed, float p_auto_exp_scale) {
- RendererSceneEnvironmentRD *env = environment_owner.getornull(p_env);
+ RendererSceneEnvironmentRD *env = environment_owner.get_or_null(p_env);
ERR_FAIL_COND(!env);
env->set_tonemap(p_tone_mapper, p_exposure, p_white, p_auto_exposure, p_min_luminance, p_max_luminance, p_auto_exp_speed, p_auto_exp_scale);
}
void RendererSceneRenderRD::environment_set_glow(RID p_env, bool p_enable, Vector<float> p_levels, float p_intensity, float p_strength, float p_mix, float p_bloom_threshold, RS::EnvironmentGlowBlendMode p_blend_mode, float p_hdr_bleed_threshold, float p_hdr_bleed_scale, float p_hdr_luminance_cap) {
- RendererSceneEnvironmentRD *env = environment_owner.getornull(p_env);
+ RendererSceneEnvironmentRD *env = environment_owner.get_or_null(p_env);
ERR_FAIL_COND(!env);
env->set_glow(p_enable, p_levels, p_intensity, p_strength, p_mix, p_bloom_threshold, p_blend_mode, p_hdr_bleed_threshold, p_hdr_bleed_scale, p_hdr_luminance_cap);
}
@@ -310,7 +310,7 @@ void RendererSceneRenderRD::environment_glow_set_use_high_quality(bool p_enable)
}
void RendererSceneRenderRD::environment_set_sdfgi(RID p_env, bool p_enable, RS::EnvironmentSDFGICascades p_cascades, float p_min_cell_size, RS::EnvironmentSDFGIYScale p_y_scale, bool p_use_occlusion, float p_bounce_feedback, bool p_read_sky, float p_energy, float p_normal_bias, float p_probe_bias) {
- RendererSceneEnvironmentRD *env = environment_owner.getornull(p_env);
+ RendererSceneEnvironmentRD *env = environment_owner.get_or_null(p_env);
ERR_FAIL_COND(!env);
if (!is_dynamic_gi_supported()) {
@@ -321,58 +321,58 @@ void RendererSceneRenderRD::environment_set_sdfgi(RID p_env, bool p_enable, RS::
}
void RendererSceneRenderRD::environment_set_fog(RID p_env, bool p_enable, const Color &p_light_color, float p_light_energy, float p_sun_scatter, float p_density, float p_height, float p_height_density, float p_fog_aerial_perspective) {
- RendererSceneEnvironmentRD *env = environment_owner.getornull(p_env);
+ RendererSceneEnvironmentRD *env = environment_owner.get_or_null(p_env);
ERR_FAIL_COND(!env);
env->set_fog(p_enable, p_light_color, p_light_energy, p_sun_scatter, p_density, p_height, p_height_density, p_fog_aerial_perspective);
}
bool RendererSceneRenderRD::environment_is_fog_enabled(RID p_env) const {
- const RendererSceneEnvironmentRD *env = environment_owner.getornull(p_env);
+ const RendererSceneEnvironmentRD *env = environment_owner.get_or_null(p_env);
ERR_FAIL_COND_V(!env, false);
return env->fog_enabled;
}
Color RendererSceneRenderRD::environment_get_fog_light_color(RID p_env) const {
- const RendererSceneEnvironmentRD *env = environment_owner.getornull(p_env);
+ const RendererSceneEnvironmentRD *env = environment_owner.get_or_null(p_env);
ERR_FAIL_COND_V(!env, Color());
return env->fog_light_color;
}
float RendererSceneRenderRD::environment_get_fog_light_energy(RID p_env) const {
- const RendererSceneEnvironmentRD *env = environment_owner.getornull(p_env);
+ const RendererSceneEnvironmentRD *env = environment_owner.get_or_null(p_env);
ERR_FAIL_COND_V(!env, 0);
return env->fog_light_energy;
}
float RendererSceneRenderRD::environment_get_fog_sun_scatter(RID p_env) const {
- const RendererSceneEnvironmentRD *env = environment_owner.getornull(p_env);
+ const RendererSceneEnvironmentRD *env = environment_owner.get_or_null(p_env);
ERR_FAIL_COND_V(!env, 0);
return env->fog_sun_scatter;
}
float RendererSceneRenderRD::environment_get_fog_density(RID p_env) const {
- const RendererSceneEnvironmentRD *env = environment_owner.getornull(p_env);
+ const RendererSceneEnvironmentRD *env = environment_owner.get_or_null(p_env);
ERR_FAIL_COND_V(!env, 0);
return env->fog_density;
}
float RendererSceneRenderRD::environment_get_fog_height(RID p_env) const {
- const RendererSceneEnvironmentRD *env = environment_owner.getornull(p_env);
+ const RendererSceneEnvironmentRD *env = environment_owner.get_or_null(p_env);
ERR_FAIL_COND_V(!env, 0);
return env->fog_height;
}
float RendererSceneRenderRD::environment_get_fog_height_density(RID p_env) const {
- const RendererSceneEnvironmentRD *env = environment_owner.getornull(p_env);
+ const RendererSceneEnvironmentRD *env = environment_owner.get_or_null(p_env);
ERR_FAIL_COND_V(!env, 0);
return env->fog_height_density;
}
float RendererSceneRenderRD::environment_get_fog_aerial_perspective(RID p_env) const {
- const RendererSceneEnvironmentRD *env = environment_owner.getornull(p_env);
+ const RendererSceneEnvironmentRD *env = environment_owner.get_or_null(p_env);
ERR_FAIL_COND_V(!env, 0);
return env->fog_aerial_perspective;
}
void RendererSceneRenderRD::environment_set_volumetric_fog(RID p_env, bool p_enable, float p_density, const Color &p_light, float p_light_energy, float p_length, float p_detail_spread, float p_gi_inject, bool p_temporal_reprojection, float p_temporal_reprojection_amount) {
- RendererSceneEnvironmentRD *env = environment_owner.getornull(p_env);
+ RendererSceneEnvironmentRD *env = environment_owner.get_or_null(p_env);
ERR_FAIL_COND(!env);
if (!is_volumetric_supported()) {
@@ -403,7 +403,7 @@ void RendererSceneRenderRD::environment_set_sdfgi_frames_to_update_light(RS::Env
}
void RendererSceneRenderRD::environment_set_ssr(RID p_env, bool p_enable, int p_max_steps, float p_fade_int, float p_fade_out, float p_depth_tolerance) {
- RendererSceneEnvironmentRD *env = environment_owner.getornull(p_env);
+ RendererSceneEnvironmentRD *env = environment_owner.get_or_null(p_env);
ERR_FAIL_COND(!env);
env->set_ssr(p_enable, p_max_steps, p_fade_int, p_fade_out, p_depth_tolerance);
@@ -418,7 +418,7 @@ RS::EnvironmentSSRRoughnessQuality RendererSceneRenderRD::environment_get_ssr_ro
}
void RendererSceneRenderRD::environment_set_ssao(RID p_env, bool p_enable, float p_radius, float p_intensity, float p_power, float p_detail, float p_horizon, float p_sharpness, float p_light_affect, float p_ao_channel_affect) {
- RendererSceneEnvironmentRD *env = environment_owner.getornull(p_env);
+ RendererSceneEnvironmentRD *env = environment_owner.get_or_null(p_env);
ERR_FAIL_COND(!env);
env->set_ssao(p_enable, p_radius, p_intensity, p_power, p_detail, p_horizon, p_sharpness, p_light_affect, p_ao_channel_affect);
@@ -434,30 +434,30 @@ void RendererSceneRenderRD::environment_set_ssao_quality(RS::EnvironmentSSAOQual
}
bool RendererSceneRenderRD::environment_is_ssao_enabled(RID p_env) const {
- RendererSceneEnvironmentRD *env = environment_owner.getornull(p_env);
+ RendererSceneEnvironmentRD *env = environment_owner.get_or_null(p_env);
ERR_FAIL_COND_V(!env, false);
return env->ssao_enabled;
}
float RendererSceneRenderRD::environment_get_ssao_ao_affect(RID p_env) const {
- RendererSceneEnvironmentRD *env = environment_owner.getornull(p_env);
+ RendererSceneEnvironmentRD *env = environment_owner.get_or_null(p_env);
ERR_FAIL_COND_V(!env, 0.0);
return env->ssao_ao_channel_affect;
}
float RendererSceneRenderRD::environment_get_ssao_light_affect(RID p_env) const {
- RendererSceneEnvironmentRD *env = environment_owner.getornull(p_env);
+ RendererSceneEnvironmentRD *env = environment_owner.get_or_null(p_env);
ERR_FAIL_COND_V(!env, 0.0);
return env->ssao_direct_light_affect;
}
bool RendererSceneRenderRD::environment_is_ssr_enabled(RID p_env) const {
- RendererSceneEnvironmentRD *env = environment_owner.getornull(p_env);
+ RendererSceneEnvironmentRD *env = environment_owner.get_or_null(p_env);
ERR_FAIL_COND_V(!env, false);
return env->ssr_enabled;
}
bool RendererSceneRenderRD::environment_is_sdfgi_enabled(RID p_env) const {
- RendererSceneEnvironmentRD *env = environment_owner.getornull(p_env);
+ RendererSceneEnvironmentRD *env = environment_owner.get_or_null(p_env);
ERR_FAIL_COND_V(!env, false);
return env->sdfgi_enabled;
}
@@ -467,7 +467,7 @@ bool RendererSceneRenderRD::is_environment(RID p_env) const {
}
Ref<Image> RendererSceneRenderRD::environment_bake_panorama(RID p_env, bool p_bake_irradiance, const Size2i &p_size) {
- RendererSceneEnvironmentRD *env = environment_owner.getornull(p_env);
+ RendererSceneEnvironmentRD *env = environment_owner.get_or_null(p_env);
ERR_FAIL_COND_V(!env, Ref<Image>());
if (env->background == RS::ENV_BG_CAMERA_FEED || env->background == RS::ENV_BG_CANVAS || env->background == RS::ENV_BG_KEEP) {
@@ -522,7 +522,7 @@ RID RendererSceneRenderRD::reflection_atlas_create() {
}
void RendererSceneRenderRD::reflection_atlas_set_size(RID p_ref_atlas, int p_reflection_size, int p_reflection_count) {
- ReflectionAtlas *ra = reflection_atlas_owner.getornull(p_ref_atlas);
+ ReflectionAtlas *ra = reflection_atlas_owner.get_or_null(p_ref_atlas);
ERR_FAIL_COND(!ra);
if (ra->size == p_reflection_size && ra->count == p_reflection_count) {
@@ -557,7 +557,7 @@ void RendererSceneRenderRD::reflection_atlas_set_size(RID p_ref_atlas, int p_ref
}
int RendererSceneRenderRD::reflection_atlas_get_size(RID p_ref_atlas) const {
- ReflectionAtlas *ra = reflection_atlas_owner.getornull(p_ref_atlas);
+ ReflectionAtlas *ra = reflection_atlas_owner.get_or_null(p_ref_atlas);
ERR_FAIL_COND_V(!ra, 0);
return ra->size;
@@ -573,7 +573,7 @@ RID RendererSceneRenderRD::reflection_probe_instance_create(RID p_probe) {
}
void RendererSceneRenderRD::reflection_probe_instance_set_transform(RID p_instance, const Transform3D &p_transform) {
- ReflectionProbeInstance *rpi = reflection_probe_instance_owner.getornull(p_instance);
+ ReflectionProbeInstance *rpi = reflection_probe_instance_owner.get_or_null(p_instance);
ERR_FAIL_COND(!rpi);
rpi->transform = p_transform;
@@ -581,13 +581,13 @@ void RendererSceneRenderRD::reflection_probe_instance_set_transform(RID p_instan
}
void RendererSceneRenderRD::reflection_probe_release_atlas_index(RID p_instance) {
- ReflectionProbeInstance *rpi = reflection_probe_instance_owner.getornull(p_instance);
+ ReflectionProbeInstance *rpi = reflection_probe_instance_owner.get_or_null(p_instance);
ERR_FAIL_COND(!rpi);
if (rpi->atlas.is_null()) {
return; //nothing to release
}
- ReflectionAtlas *atlas = reflection_atlas_owner.getornull(rpi->atlas);
+ ReflectionAtlas *atlas = reflection_atlas_owner.get_or_null(rpi->atlas);
ERR_FAIL_COND(!atlas);
ERR_FAIL_INDEX(rpi->atlas_index, atlas->reflections.size());
atlas->reflections.write[rpi->atlas_index].owner = RID();
@@ -596,7 +596,7 @@ void RendererSceneRenderRD::reflection_probe_release_atlas_index(RID p_instance)
}
bool RendererSceneRenderRD::reflection_probe_instance_needs_redraw(RID p_instance) {
- ReflectionProbeInstance *rpi = reflection_probe_instance_owner.getornull(p_instance);
+ ReflectionProbeInstance *rpi = reflection_probe_instance_owner.get_or_null(p_instance);
ERR_FAIL_COND_V(!rpi, false);
if (rpi->rendering) {
@@ -615,18 +615,18 @@ bool RendererSceneRenderRD::reflection_probe_instance_needs_redraw(RID p_instanc
}
bool RendererSceneRenderRD::reflection_probe_instance_has_reflection(RID p_instance) {
- ReflectionProbeInstance *rpi = reflection_probe_instance_owner.getornull(p_instance);
+ ReflectionProbeInstance *rpi = reflection_probe_instance_owner.get_or_null(p_instance);
ERR_FAIL_COND_V(!rpi, false);
return rpi->atlas.is_valid();
}
bool RendererSceneRenderRD::reflection_probe_instance_begin_render(RID p_instance, RID p_reflection_atlas) {
- ReflectionAtlas *atlas = reflection_atlas_owner.getornull(p_reflection_atlas);
+ ReflectionAtlas *atlas = reflection_atlas_owner.get_or_null(p_reflection_atlas);
ERR_FAIL_COND_V(!atlas, false);
- ReflectionProbeInstance *rpi = reflection_probe_instance_owner.getornull(p_instance);
+ ReflectionProbeInstance *rpi = reflection_probe_instance_owner.get_or_null(p_instance);
ERR_FAIL_COND_V(!rpi, false);
RD::get_singleton()->draw_command_begin_label("Reflection probe render");
@@ -701,7 +701,7 @@ bool RendererSceneRenderRD::reflection_probe_instance_begin_render(RID p_instanc
uint64_t pass_min = 0;
for (int i = 0; i < atlas->reflections.size(); i++) {
- ReflectionProbeInstance *rpi2 = reflection_probe_instance_owner.getornull(atlas->reflections[i].owner);
+ ReflectionProbeInstance *rpi2 = reflection_probe_instance_owner.get_or_null(atlas->reflections[i].owner);
if (rpi2->last_pass < pass_min) {
pass_min = rpi2->last_pass;
rpi->atlas_index = i;
@@ -733,12 +733,12 @@ RID RendererSceneRenderRD::reflection_probe_create_framebuffer(RID p_color, RID
}
bool RendererSceneRenderRD::reflection_probe_instance_postprocess_step(RID p_instance) {
- ReflectionProbeInstance *rpi = reflection_probe_instance_owner.getornull(p_instance);
+ ReflectionProbeInstance *rpi = reflection_probe_instance_owner.get_or_null(p_instance);
ERR_FAIL_COND_V(!rpi, false);
ERR_FAIL_COND_V(!rpi->rendering, false);
ERR_FAIL_COND_V(rpi->atlas.is_null(), false);
- ReflectionAtlas *atlas = reflection_atlas_owner.getornull(rpi->atlas);
+ ReflectionAtlas *atlas = reflection_atlas_owner.get_or_null(rpi->atlas);
if (!atlas || rpi->atlas_index == -1) {
//does not belong to an atlas anymore, cancel (was removed from atlas or atlas changed while rendering)
rpi->rendering = false;
@@ -779,30 +779,30 @@ bool RendererSceneRenderRD::reflection_probe_instance_postprocess_step(RID p_ins
}
uint32_t RendererSceneRenderRD::reflection_probe_instance_get_resolution(RID p_instance) {
- ReflectionProbeInstance *rpi = reflection_probe_instance_owner.getornull(p_instance);
+ ReflectionProbeInstance *rpi = reflection_probe_instance_owner.get_or_null(p_instance);
ERR_FAIL_COND_V(!rpi, 0);
- ReflectionAtlas *atlas = reflection_atlas_owner.getornull(rpi->atlas);
+ ReflectionAtlas *atlas = reflection_atlas_owner.get_or_null(rpi->atlas);
ERR_FAIL_COND_V(!atlas, 0);
return atlas->size;
}
RID RendererSceneRenderRD::reflection_probe_instance_get_framebuffer(RID p_instance, int p_index) {
- ReflectionProbeInstance *rpi = reflection_probe_instance_owner.getornull(p_instance);
+ ReflectionProbeInstance *rpi = reflection_probe_instance_owner.get_or_null(p_instance);
ERR_FAIL_COND_V(!rpi, RID());
ERR_FAIL_INDEX_V(p_index, 6, RID());
- ReflectionAtlas *atlas = reflection_atlas_owner.getornull(rpi->atlas);
+ ReflectionAtlas *atlas = reflection_atlas_owner.get_or_null(rpi->atlas);
ERR_FAIL_COND_V(!atlas, RID());
return atlas->reflections[rpi->atlas_index].fbs[p_index];
}
RID RendererSceneRenderRD::reflection_probe_instance_get_depth_framebuffer(RID p_instance, int p_index) {
- ReflectionProbeInstance *rpi = reflection_probe_instance_owner.getornull(p_instance);
+ ReflectionProbeInstance *rpi = reflection_probe_instance_owner.get_or_null(p_instance);
ERR_FAIL_COND_V(!rpi, RID());
ERR_FAIL_INDEX_V(p_index, 6, RID());
- ReflectionAtlas *atlas = reflection_atlas_owner.getornull(rpi->atlas);
+ ReflectionAtlas *atlas = reflection_atlas_owner.get_or_null(rpi->atlas);
ERR_FAIL_COND_V(!atlas, RID());
return atlas->depth_fb;
}
@@ -829,7 +829,7 @@ void RendererSceneRenderRD::_update_shadow_atlas(ShadowAtlas *shadow_atlas) {
}
void RendererSceneRenderRD::shadow_atlas_set_size(RID p_atlas, int p_size, bool p_16_bits) {
- ShadowAtlas *shadow_atlas = shadow_atlas_owner.getornull(p_atlas);
+ ShadowAtlas *shadow_atlas = shadow_atlas_owner.get_or_null(p_atlas);
ERR_FAIL_COND(!shadow_atlas);
ERR_FAIL_COND(p_size < 0);
p_size = next_power_of_2(p_size);
@@ -850,8 +850,8 @@ void RendererSceneRenderRD::shadow_atlas_set_size(RID p_atlas, int p_size, bool
}
//erase shadow atlas reference from lights
- for (Map<RID, uint32_t>::Element *E = shadow_atlas->shadow_owners.front(); E; E = E->next()) {
- LightInstance *li = light_instance_owner.getornull(E->key());
+ for (const KeyValue<RID, uint32_t> &E : shadow_atlas->shadow_owners) {
+ LightInstance *li = light_instance_owner.get_or_null(E.key);
ERR_CONTINUE(!li);
li->shadow_atlases.erase(p_atlas);
}
@@ -864,7 +864,7 @@ void RendererSceneRenderRD::shadow_atlas_set_size(RID p_atlas, int p_size, bool
}
void RendererSceneRenderRD::shadow_atlas_set_quadrant_subdivision(RID p_atlas, int p_quadrant, int p_subdivision) {
- ShadowAtlas *shadow_atlas = shadow_atlas_owner.getornull(p_atlas);
+ ShadowAtlas *shadow_atlas = shadow_atlas_owner.get_or_null(p_atlas);
ERR_FAIL_COND(!shadow_atlas);
ERR_FAIL_INDEX(p_quadrant, 4);
ERR_FAIL_INDEX(p_subdivision, 16384);
@@ -886,7 +886,7 @@ void RendererSceneRenderRD::shadow_atlas_set_quadrant_subdivision(RID p_atlas, i
for (int i = 0; i < shadow_atlas->quadrants[p_quadrant].shadows.size(); i++) {
if (shadow_atlas->quadrants[p_quadrant].shadows[i].owner.is_valid()) {
shadow_atlas->shadow_owners.erase(shadow_atlas->quadrants[p_quadrant].shadows[i].owner);
- LightInstance *li = light_instance_owner.getornull(shadow_atlas->quadrants[p_quadrant].shadows[i].owner);
+ LightInstance *li = light_instance_owner.get_or_null(shadow_atlas->quadrants[p_quadrant].shadows[i].owner);
ERR_CONTINUE(!li);
li->shadow_atlases.erase(p_atlas);
}
@@ -947,7 +947,7 @@ bool RendererSceneRenderRD::_shadow_atlas_find_shadow(ShadowAtlas *shadow_atlas,
break;
}
- LightInstance *sli = light_instance_owner.getornull(sarr[j].owner);
+ LightInstance *sli = light_instance_owner.get_or_null(sarr[j].owner);
ERR_CONTINUE(!sli);
if (sli->last_scene_pass != scene_pass) {
@@ -999,7 +999,7 @@ bool RendererSceneRenderRD::_shadow_atlas_find_omni_shadows(ShadowAtlas *shadow_
uint64_t pass = 0;
if (sarr[j].owner.is_valid()) {
- LightInstance *sli = light_instance_owner.getornull(sarr[j].owner);
+ LightInstance *sli = light_instance_owner.get_or_null(sarr[j].owner);
ERR_CONTINUE(!sli);
if (sli->last_scene_pass == scene_pass) {
@@ -1014,7 +1014,7 @@ bool RendererSceneRenderRD::_shadow_atlas_find_omni_shadows(ShadowAtlas *shadow_
}
if (sarr[j + 1].owner.is_valid()) {
- LightInstance *sli = light_instance_owner.getornull(sarr[j + 1].owner);
+ LightInstance *sli = light_instance_owner.get_or_null(sarr[j + 1].owner);
ERR_CONTINUE(!sli);
if (sli->last_scene_pass == scene_pass) {
@@ -1053,10 +1053,10 @@ bool RendererSceneRenderRD::_shadow_atlas_find_omni_shadows(ShadowAtlas *shadow_
}
bool RendererSceneRenderRD::shadow_atlas_update_light(RID p_atlas, RID p_light_intance, float p_coverage, uint64_t p_light_version) {
- ShadowAtlas *shadow_atlas = shadow_atlas_owner.getornull(p_atlas);
+ ShadowAtlas *shadow_atlas = shadow_atlas_owner.get_or_null(p_atlas);
ERR_FAIL_COND_V(!shadow_atlas, false);
- LightInstance *li = light_instance_owner.getornull(p_light_intance);
+ LightInstance *li = light_instance_owner.get_or_null(p_light_intance);
ERR_FAIL_COND_V(!li, false);
if (shadow_atlas->size == 0 || shadow_atlas->smallest_subdiv == 0) {
@@ -1179,7 +1179,7 @@ bool RendererSceneRenderRD::shadow_atlas_update_light(RID p_atlas, RID p_light_i
void RendererSceneRenderRD::_shadow_atlas_invalidate_shadow(RendererSceneRenderRD::ShadowAtlas::Quadrant::Shadow *p_shadow, RID p_atlas, RendererSceneRenderRD::ShadowAtlas *p_shadow_atlas, uint32_t p_quadrant, uint32_t p_shadow_idx) {
if (p_shadow->owner.is_valid()) {
- LightInstance *sli = light_instance_owner.getornull(p_shadow->owner);
+ LightInstance *sli = light_instance_owner.get_or_null(p_shadow->owner);
uint32_t old_key = p_shadow_atlas->shadow_owners[p_shadow->owner];
if (old_key & ShadowAtlas::OMNI_LIGHT_FLAG) {
@@ -1260,7 +1260,7 @@ int RendererSceneRenderRD::get_directional_light_shadow_size(RID p_light_intance
Rect2i r = _get_directional_shadow_rect(directional_shadow.size, directional_shadow.light_count, 0);
- LightInstance *light_instance = light_instance_owner.getornull(p_light_intance);
+ LightInstance *light_instance = light_instance_owner.get_or_null(p_light_intance);
ERR_FAIL_COND_V(!light_instance, 0);
switch (storage->light_directional_get_shadow_mode(light_instance->light)) {
@@ -1296,7 +1296,7 @@ void RendererSceneRenderRD::camera_effects_set_dof_blur_bokeh_shape(RS::DOFBokeh
}
void RendererSceneRenderRD::camera_effects_set_dof_blur(RID p_camera_effects, bool p_far_enable, float p_far_distance, float p_far_transition, bool p_near_enable, float p_near_distance, float p_near_transition, float p_amount) {
- CameraEffects *camfx = camera_effects_owner.getornull(p_camera_effects);
+ CameraEffects *camfx = camera_effects_owner.get_or_null(p_camera_effects);
ERR_FAIL_COND(!camfx);
camfx->dof_blur_far_enabled = p_far_enable;
@@ -1311,7 +1311,7 @@ void RendererSceneRenderRD::camera_effects_set_dof_blur(RID p_camera_effects, bo
}
void RendererSceneRenderRD::camera_effects_set_custom_exposure(RID p_camera_effects, bool p_enable, float p_exposure) {
- CameraEffects *camfx = camera_effects_owner.getornull(p_camera_effects);
+ CameraEffects *camfx = camera_effects_owner.get_or_null(p_camera_effects);
ERR_FAIL_COND(!camfx);
camfx->override_exposure_enabled = p_enable;
@@ -1321,7 +1321,7 @@ void RendererSceneRenderRD::camera_effects_set_custom_exposure(RID p_camera_effe
RID RendererSceneRenderRD::light_instance_create(RID p_light) {
RID li = light_instance_owner.make_rid(LightInstance());
- LightInstance *light_instance = light_instance_owner.getornull(li);
+ LightInstance *light_instance = light_instance_owner.get_or_null(li);
light_instance->self = li;
light_instance->light = p_light;
@@ -1334,21 +1334,21 @@ RID RendererSceneRenderRD::light_instance_create(RID p_light) {
}
void RendererSceneRenderRD::light_instance_set_transform(RID p_light_instance, const Transform3D &p_transform) {
- LightInstance *light_instance = light_instance_owner.getornull(p_light_instance);
+ LightInstance *light_instance = light_instance_owner.get_or_null(p_light_instance);
ERR_FAIL_COND(!light_instance);
light_instance->transform = p_transform;
}
void RendererSceneRenderRD::light_instance_set_aabb(RID p_light_instance, const AABB &p_aabb) {
- LightInstance *light_instance = light_instance_owner.getornull(p_light_instance);
+ LightInstance *light_instance = light_instance_owner.get_or_null(p_light_instance);
ERR_FAIL_COND(!light_instance);
light_instance->aabb = p_aabb;
}
void RendererSceneRenderRD::light_instance_set_shadow_transform(RID p_light_instance, const CameraMatrix &p_projection, const Transform3D &p_transform, float p_far, float p_split, int p_pass, float p_shadow_texel_size, float p_bias_scale, float p_range_begin, const Vector2 &p_uv_scale) {
- LightInstance *light_instance = light_instance_owner.getornull(p_light_instance);
+ LightInstance *light_instance = light_instance_owner.get_or_null(p_light_instance);
ERR_FAIL_COND(!light_instance);
ERR_FAIL_INDEX(p_pass, 6);
@@ -1364,7 +1364,7 @@ void RendererSceneRenderRD::light_instance_set_shadow_transform(RID p_light_inst
}
void RendererSceneRenderRD::light_instance_mark_visible(RID p_light_instance) {
- LightInstance *light_instance = light_instance_owner.getornull(p_light_instance);
+ LightInstance *light_instance = light_instance_owner.get_or_null(p_light_instance);
ERR_FAIL_COND(!light_instance);
light_instance->last_scene_pass = scene_pass;
@@ -1407,7 +1407,7 @@ RID RendererSceneRenderRD::decal_instance_create(RID p_decal) {
}
void RendererSceneRenderRD::decal_instance_set_transform(RID p_decal, const Transform3D &p_transform) {
- DecalInstance *di = decal_instance_owner.getornull(p_decal);
+ DecalInstance *di = decal_instance_owner.get_or_null(p_decal);
ERR_FAIL_COND(!di);
di->transform = p_transform;
}
@@ -1420,7 +1420,7 @@ RID RendererSceneRenderRD::lightmap_instance_create(RID p_lightmap) {
return lightmap_instance_owner.make_rid(li);
}
void RendererSceneRenderRD::lightmap_instance_set_transform(RID p_lightmap, const Transform3D &p_transform) {
- LightmapInstance *li = lightmap_instance_owner.getornull(p_lightmap);
+ LightmapInstance *li = lightmap_instance_owner.get_or_null(p_lightmap);
ERR_FAIL_COND(!li);
li->transform = p_transform;
}
@@ -1452,7 +1452,7 @@ void RendererSceneRenderRD::voxel_gi_update(RID p_probe, bool p_update_light_ins
}
void RendererSceneRenderRD::_debug_sdfgi_probes(RID p_render_buffers, RD::DrawListID p_draw_list, RID p_framebuffer, const CameraMatrix &p_camera_with_transform) {
- RenderBuffers *rb = render_buffers_owner.getornull(p_render_buffers);
+ RenderBuffers *rb = render_buffers_owner.get_or_null(p_render_buffers);
ERR_FAIL_COND(!rb);
if (!rb->sdfgi) {
@@ -1790,7 +1790,7 @@ void RendererSceneRenderRD::_free_render_buffer_data(RenderBuffers *rb) {
}
void RendererSceneRenderRD::_process_sss(RID p_render_buffers, const CameraMatrix &p_camera) {
- RenderBuffers *rb = render_buffers_owner.getornull(p_render_buffers);
+ RenderBuffers *rb = render_buffers_owner.get_or_null(p_render_buffers);
ERR_FAIL_COND(!rb);
bool can_use_effects = rb->width >= 8 && rb->height >= 8;
@@ -1808,7 +1808,7 @@ void RendererSceneRenderRD::_process_sss(RID p_render_buffers, const CameraMatri
}
void RendererSceneRenderRD::_process_ssr(RID p_render_buffers, RID p_dest_framebuffer, RID p_normal_buffer, RID p_specular_buffer, RID p_metallic, const Color &p_metallic_mask, RID p_environment, const CameraMatrix &p_projection, bool p_use_additive) {
- RenderBuffers *rb = render_buffers_owner.getornull(p_render_buffers);
+ RenderBuffers *rb = render_buffers_owner.get_or_null(p_render_buffers);
ERR_FAIL_COND(!rb);
bool can_use_effects = rb->width >= 8 && rb->height >= 8;
@@ -1819,7 +1819,7 @@ void RendererSceneRenderRD::_process_ssr(RID p_render_buffers, RID p_dest_frameb
return;
}
- RendererSceneEnvironmentRD *env = environment_owner.getornull(p_environment);
+ RendererSceneEnvironmentRD *env = environment_owner.get_or_null(p_environment);
ERR_FAIL_COND(!env);
ERR_FAIL_COND(!env->ssr_enabled);
@@ -1860,10 +1860,10 @@ void RendererSceneRenderRD::_process_ssr(RID p_render_buffers, RID p_dest_frameb
}
void RendererSceneRenderRD::_process_ssao(RID p_render_buffers, RID p_environment, RID p_normal_buffer, const CameraMatrix &p_projection) {
- RenderBuffers *rb = render_buffers_owner.getornull(p_render_buffers);
+ RenderBuffers *rb = render_buffers_owner.get_or_null(p_render_buffers);
ERR_FAIL_COND(!rb);
- RendererSceneEnvironmentRD *env = environment_owner.getornull(p_environment);
+ RendererSceneEnvironmentRD *env = environment_owner.get_or_null(p_environment);
ERR_FAIL_COND(!env);
RENDER_TIMESTAMP("Process SSAO");
@@ -2005,7 +2005,7 @@ void RendererSceneRenderRD::_process_ssao(RID p_render_buffers, RID p_environmen
}
void RendererSceneRenderRD::_render_buffers_copy_screen_texture(const RenderDataRD *p_render_data) {
- RenderBuffers *rb = render_buffers_owner.getornull(p_render_data->render_buffers);
+ RenderBuffers *rb = render_buffers_owner.get_or_null(p_render_data->render_buffers);
ERR_FAIL_COND(!rb);
RD::get_singleton()->draw_command_begin_label("Copy screen texture");
@@ -2034,7 +2034,7 @@ void RendererSceneRenderRD::_render_buffers_copy_screen_texture(const RenderData
}
void RendererSceneRenderRD::_render_buffers_copy_depth_texture(const RenderDataRD *p_render_data) {
- RenderBuffers *rb = render_buffers_owner.getornull(p_render_data->render_buffers);
+ RenderBuffers *rb = render_buffers_owner.get_or_null(p_render_data->render_buffers);
ERR_FAIL_COND(!rb);
RD::get_singleton()->draw_command_begin_label("Copy depth texture");
@@ -2057,12 +2057,12 @@ void RendererSceneRenderRD::_render_buffers_copy_depth_texture(const RenderDataR
}
void RendererSceneRenderRD::_render_buffers_post_process_and_tonemap(const RenderDataRD *p_render_data) {
- RenderBuffers *rb = render_buffers_owner.getornull(p_render_data->render_buffers);
+ RenderBuffers *rb = render_buffers_owner.get_or_null(p_render_data->render_buffers);
ERR_FAIL_COND(!rb);
- RendererSceneEnvironmentRD *env = environment_owner.getornull(p_render_data->environment);
+ RendererSceneEnvironmentRD *env = environment_owner.get_or_null(p_render_data->environment);
//glow (if enabled)
- CameraEffects *camfx = camera_effects_owner.getornull(p_render_data->camera_effects);
+ CameraEffects *camfx = camera_effects_owner.get_or_null(p_render_data->camera_effects);
bool can_use_effects = rb->width >= 8 && rb->height >= 8;
bool can_use_storage = _render_buffers_can_be_storage();
@@ -2251,10 +2251,10 @@ void RendererSceneRenderRD::_render_buffers_post_process_and_tonemap(const Rende
void RendererSceneRenderRD::_post_process_subpass(RID p_source_texture, RID p_framebuffer, const RenderDataRD *p_render_data) {
RD::get_singleton()->draw_command_begin_label("Post Process Subpass");
- RenderBuffers *rb = render_buffers_owner.getornull(p_render_data->render_buffers);
+ RenderBuffers *rb = render_buffers_owner.get_or_null(p_render_data->render_buffers);
ERR_FAIL_COND(!rb);
- RendererSceneEnvironmentRD *env = environment_owner.getornull(p_render_data->environment);
+ RendererSceneEnvironmentRD *env = environment_owner.get_or_null(p_render_data->environment);
bool can_use_effects = rb->width >= 8 && rb->height >= 8;
@@ -2311,7 +2311,7 @@ void RendererSceneRenderRD::_post_process_subpass(RID p_source_texture, RID p_fr
}
void RendererSceneRenderRD::_disable_clear_request(const RenderDataRD *p_render_data) {
- RenderBuffers *rb = render_buffers_owner.getornull(p_render_data->render_buffers);
+ RenderBuffers *rb = render_buffers_owner.get_or_null(p_render_data->render_buffers);
ERR_FAIL_COND(!rb);
storage->render_target_disable_clear_request(rb->render_target);
@@ -2320,7 +2320,7 @@ void RendererSceneRenderRD::_disable_clear_request(const RenderDataRD *p_render_
void RendererSceneRenderRD::_render_buffers_debug_draw(RID p_render_buffers, RID p_shadow_atlas, RID p_occlusion_buffer) {
EffectsRD *effects = storage->get_effects();
- RenderBuffers *rb = render_buffers_owner.getornull(p_render_buffers);
+ RenderBuffers *rb = render_buffers_owner.get_or_null(p_render_buffers);
ERR_FAIL_COND(!rb);
if (debug_draw == RS::VIEWPORT_DEBUG_DRAW_SHADOW_ATLAS) {
@@ -2386,7 +2386,7 @@ void RendererSceneRenderRD::_render_buffers_debug_draw(RID p_render_buffers, RID
}
void RendererSceneRenderRD::environment_set_adjustment(RID p_env, bool p_enable, float p_brightness, float p_contrast, float p_saturation, bool p_use_1d_color_correction, RID p_color_correction) {
- RendererSceneEnvironmentRD *env = environment_owner.getornull(p_env);
+ RendererSceneEnvironmentRD *env = environment_owner.get_or_null(p_env);
ERR_FAIL_COND(!env);
env->adjustments_enabled = p_enable;
@@ -2398,7 +2398,7 @@ void RendererSceneRenderRD::environment_set_adjustment(RID p_env, bool p_enable,
}
RID RendererSceneRenderRD::render_buffers_get_back_buffer_texture(RID p_render_buffers) {
- RenderBuffers *rb = render_buffers_owner.getornull(p_render_buffers);
+ RenderBuffers *rb = render_buffers_owner.get_or_null(p_render_buffers);
ERR_FAIL_COND_V(!rb, RID());
if (!rb->blur[0].texture.is_valid()) {
return RID(); //not valid at the moment
@@ -2407,7 +2407,7 @@ RID RendererSceneRenderRD::render_buffers_get_back_buffer_texture(RID p_render_b
}
RID RendererSceneRenderRD::render_buffers_get_back_depth_texture(RID p_render_buffers) {
- RenderBuffers *rb = render_buffers_owner.getornull(p_render_buffers);
+ RenderBuffers *rb = render_buffers_owner.get_or_null(p_render_buffers);
ERR_FAIL_COND_V(!rb, RID());
if (!rb->depth_back_texture.is_valid()) {
return RID(); //not valid at the moment
@@ -2416,21 +2416,21 @@ RID RendererSceneRenderRD::render_buffers_get_back_depth_texture(RID p_render_bu
}
RID RendererSceneRenderRD::render_buffers_get_depth_texture(RID p_render_buffers) {
- RenderBuffers *rb = render_buffers_owner.getornull(p_render_buffers);
+ RenderBuffers *rb = render_buffers_owner.get_or_null(p_render_buffers);
ERR_FAIL_COND_V(!rb, RID());
return rb->depth_texture;
}
RID RendererSceneRenderRD::render_buffers_get_ao_texture(RID p_render_buffers) {
- RenderBuffers *rb = render_buffers_owner.getornull(p_render_buffers);
+ RenderBuffers *rb = render_buffers_owner.get_or_null(p_render_buffers);
ERR_FAIL_COND_V(!rb, RID());
return rb->ssao.ao_final;
}
RID RendererSceneRenderRD::render_buffers_get_voxel_gi_buffer(RID p_render_buffers) {
- RenderBuffers *rb = render_buffers_owner.getornull(p_render_buffers);
+ RenderBuffers *rb = render_buffers_owner.get_or_null(p_render_buffers);
ERR_FAIL_COND_V(!rb, RID());
if (rb->gi.voxel_gi_buffer.is_null()) {
rb->gi.voxel_gi_buffer = RD::get_singleton()->uniform_buffer_create(sizeof(RendererSceneGIRD::VoxelGIData) * RendererSceneGIRD::MAX_VOXEL_GI_INSTANCES);
@@ -2443,31 +2443,31 @@ RID RendererSceneRenderRD::render_buffers_get_default_voxel_gi_buffer() {
}
RID RendererSceneRenderRD::render_buffers_get_gi_ambient_texture(RID p_render_buffers) {
- RenderBuffers *rb = render_buffers_owner.getornull(p_render_buffers);
+ RenderBuffers *rb = render_buffers_owner.get_or_null(p_render_buffers);
ERR_FAIL_COND_V(!rb, RID());
return rb->ambient_buffer;
}
RID RendererSceneRenderRD::render_buffers_get_gi_reflection_texture(RID p_render_buffers) {
- RenderBuffers *rb = render_buffers_owner.getornull(p_render_buffers);
+ RenderBuffers *rb = render_buffers_owner.get_or_null(p_render_buffers);
ERR_FAIL_COND_V(!rb, RID());
return rb->reflection_buffer;
}
uint32_t RendererSceneRenderRD::render_buffers_get_sdfgi_cascade_count(RID p_render_buffers) const {
- const RenderBuffers *rb = render_buffers_owner.getornull(p_render_buffers);
+ const RenderBuffers *rb = render_buffers_owner.get_or_null(p_render_buffers);
ERR_FAIL_COND_V(!rb, 0);
ERR_FAIL_COND_V(!rb->sdfgi, 0);
return rb->sdfgi->cascades.size();
}
bool RendererSceneRenderRD::render_buffers_is_sdfgi_enabled(RID p_render_buffers) const {
- const RenderBuffers *rb = render_buffers_owner.getornull(p_render_buffers);
+ const RenderBuffers *rb = render_buffers_owner.get_or_null(p_render_buffers);
ERR_FAIL_COND_V(!rb, false);
return rb->sdfgi != nullptr;
}
RID RendererSceneRenderRD::render_buffers_get_sdfgi_irradiance_probes(RID p_render_buffers) const {
- const RenderBuffers *rb = render_buffers_owner.getornull(p_render_buffers);
+ const RenderBuffers *rb = render_buffers_owner.get_or_null(p_render_buffers);
ERR_FAIL_COND_V(!rb, RID());
ERR_FAIL_COND_V(!rb->sdfgi, RID());
@@ -2475,7 +2475,7 @@ RID RendererSceneRenderRD::render_buffers_get_sdfgi_irradiance_probes(RID p_rend
}
Vector3 RendererSceneRenderRD::render_buffers_get_sdfgi_cascade_offset(RID p_render_buffers, uint32_t p_cascade) const {
- const RenderBuffers *rb = render_buffers_owner.getornull(p_render_buffers);
+ const RenderBuffers *rb = render_buffers_owner.get_or_null(p_render_buffers);
ERR_FAIL_COND_V(!rb, Vector3());
ERR_FAIL_COND_V(!rb->sdfgi, Vector3());
ERR_FAIL_UNSIGNED_INDEX_V(p_cascade, rb->sdfgi->cascades.size(), Vector3());
@@ -2484,7 +2484,7 @@ Vector3 RendererSceneRenderRD::render_buffers_get_sdfgi_cascade_offset(RID p_ren
}
Vector3i RendererSceneRenderRD::render_buffers_get_sdfgi_cascade_probe_offset(RID p_render_buffers, uint32_t p_cascade) const {
- const RenderBuffers *rb = render_buffers_owner.getornull(p_render_buffers);
+ const RenderBuffers *rb = render_buffers_owner.get_or_null(p_render_buffers);
ERR_FAIL_COND_V(!rb, Vector3i());
ERR_FAIL_COND_V(!rb->sdfgi, Vector3i());
ERR_FAIL_UNSIGNED_INDEX_V(p_cascade, rb->sdfgi->cascades.size(), Vector3i());
@@ -2494,14 +2494,14 @@ Vector3i RendererSceneRenderRD::render_buffers_get_sdfgi_cascade_probe_offset(RI
}
float RendererSceneRenderRD::render_buffers_get_sdfgi_normal_bias(RID p_render_buffers) const {
- const RenderBuffers *rb = render_buffers_owner.getornull(p_render_buffers);
+ const RenderBuffers *rb = render_buffers_owner.get_or_null(p_render_buffers);
ERR_FAIL_COND_V(!rb, 0);
ERR_FAIL_COND_V(!rb->sdfgi, 0);
return rb->sdfgi->normal_bias;
}
float RendererSceneRenderRD::render_buffers_get_sdfgi_cascade_probe_size(RID p_render_buffers, uint32_t p_cascade) const {
- const RenderBuffers *rb = render_buffers_owner.getornull(p_render_buffers);
+ const RenderBuffers *rb = render_buffers_owner.get_or_null(p_render_buffers);
ERR_FAIL_COND_V(!rb, 0);
ERR_FAIL_COND_V(!rb->sdfgi, 0);
ERR_FAIL_UNSIGNED_INDEX_V(p_cascade, rb->sdfgi->cascades.size(), 0);
@@ -2509,7 +2509,7 @@ float RendererSceneRenderRD::render_buffers_get_sdfgi_cascade_probe_size(RID p_r
return float(rb->sdfgi->cascade_size) * rb->sdfgi->cascades[p_cascade].cell_size / float(rb->sdfgi->probe_axis_count - 1);
}
uint32_t RendererSceneRenderRD::render_buffers_get_sdfgi_cascade_probe_count(RID p_render_buffers) const {
- const RenderBuffers *rb = render_buffers_owner.getornull(p_render_buffers);
+ const RenderBuffers *rb = render_buffers_owner.get_or_null(p_render_buffers);
ERR_FAIL_COND_V(!rb, 0);
ERR_FAIL_COND_V(!rb->sdfgi, 0);
@@ -2517,7 +2517,7 @@ uint32_t RendererSceneRenderRD::render_buffers_get_sdfgi_cascade_probe_count(RID
}
uint32_t RendererSceneRenderRD::render_buffers_get_sdfgi_cascade_size(RID p_render_buffers) const {
- const RenderBuffers *rb = render_buffers_owner.getornull(p_render_buffers);
+ const RenderBuffers *rb = render_buffers_owner.get_or_null(p_render_buffers);
ERR_FAIL_COND_V(!rb, 0);
ERR_FAIL_COND_V(!rb->sdfgi, 0);
@@ -2525,7 +2525,7 @@ uint32_t RendererSceneRenderRD::render_buffers_get_sdfgi_cascade_size(RID p_rend
}
bool RendererSceneRenderRD::render_buffers_is_sdfgi_using_occlusion(RID p_render_buffers) const {
- const RenderBuffers *rb = render_buffers_owner.getornull(p_render_buffers);
+ const RenderBuffers *rb = render_buffers_owner.get_or_null(p_render_buffers);
ERR_FAIL_COND_V(!rb, false);
ERR_FAIL_COND_V(!rb->sdfgi, false);
@@ -2533,14 +2533,14 @@ bool RendererSceneRenderRD::render_buffers_is_sdfgi_using_occlusion(RID p_render
}
float RendererSceneRenderRD::render_buffers_get_sdfgi_energy(RID p_render_buffers) const {
- const RenderBuffers *rb = render_buffers_owner.getornull(p_render_buffers);
+ const RenderBuffers *rb = render_buffers_owner.get_or_null(p_render_buffers);
ERR_FAIL_COND_V(!rb, 0.0);
ERR_FAIL_COND_V(!rb->sdfgi, 0.0);
return rb->sdfgi->energy;
}
RID RendererSceneRenderRD::render_buffers_get_sdfgi_occlusion_texture(RID p_render_buffers) const {
- const RenderBuffers *rb = render_buffers_owner.getornull(p_render_buffers);
+ const RenderBuffers *rb = render_buffers_owner.get_or_null(p_render_buffers);
ERR_FAIL_COND_V(!rb, RID());
ERR_FAIL_COND_V(!rb->sdfgi, RID());
@@ -2548,20 +2548,20 @@ RID RendererSceneRenderRD::render_buffers_get_sdfgi_occlusion_texture(RID p_rend
}
bool RendererSceneRenderRD::render_buffers_has_volumetric_fog(RID p_render_buffers) const {
- const RenderBuffers *rb = render_buffers_owner.getornull(p_render_buffers);
+ const RenderBuffers *rb = render_buffers_owner.get_or_null(p_render_buffers);
ERR_FAIL_COND_V(!rb, false);
return rb->volumetric_fog != nullptr;
}
RID RendererSceneRenderRD::render_buffers_get_volumetric_fog_texture(RID p_render_buffers) {
- const RenderBuffers *rb = render_buffers_owner.getornull(p_render_buffers);
+ const RenderBuffers *rb = render_buffers_owner.get_or_null(p_render_buffers);
ERR_FAIL_COND_V(!rb || !rb->volumetric_fog, RID());
return rb->volumetric_fog->fog_map;
}
RID RendererSceneRenderRD::render_buffers_get_volumetric_fog_sky_uniform_set(RID p_render_buffers) {
- const RenderBuffers *rb = render_buffers_owner.getornull(p_render_buffers);
+ const RenderBuffers *rb = render_buffers_owner.get_or_null(p_render_buffers);
ERR_FAIL_COND_V(!rb, RID());
if (!rb->volumetric_fog) {
@@ -2572,12 +2572,12 @@ RID RendererSceneRenderRD::render_buffers_get_volumetric_fog_sky_uniform_set(RID
}
float RendererSceneRenderRD::render_buffers_get_volumetric_fog_end(RID p_render_buffers) {
- const RenderBuffers *rb = render_buffers_owner.getornull(p_render_buffers);
+ const RenderBuffers *rb = render_buffers_owner.get_or_null(p_render_buffers);
ERR_FAIL_COND_V(!rb || !rb->volumetric_fog, 0);
return rb->volumetric_fog->length;
}
float RendererSceneRenderRD::render_buffers_get_volumetric_fog_detail_spread(RID p_render_buffers) {
- const RenderBuffers *rb = render_buffers_owner.getornull(p_render_buffers);
+ const RenderBuffers *rb = render_buffers_owner.get_or_null(p_render_buffers);
ERR_FAIL_COND_V(!rb || !rb->volumetric_fog, 0);
return rb->volumetric_fog->spread;
}
@@ -2597,7 +2597,7 @@ bool RendererSceneRenderRD::_render_buffers_can_be_storage() {
void RendererSceneRenderRD::render_buffers_configure(RID p_render_buffers, RID p_render_target, int p_width, int p_height, RS::ViewportMSAA p_msaa, RenderingServer::ViewportScreenSpaceAA p_screen_space_aa, bool p_use_debanding, uint32_t p_view_count) {
ERR_FAIL_COND_MSG(p_view_count == 0, "Must have at least 1 view");
- RenderBuffers *rb = render_buffers_owner.getornull(p_render_buffers);
+ RenderBuffers *rb = render_buffers_owner.get_or_null(p_render_buffers);
// Should we add an overrule per viewport?
rb->width = p_width;
@@ -2801,7 +2801,7 @@ bool RendererSceneRenderRD::is_using_radiance_cubemap_array() const {
}
RendererSceneRenderRD::RenderBufferData *RendererSceneRenderRD::render_buffers_get_data(RID p_render_buffers) {
- RenderBuffers *rb = render_buffers_owner.getornull(p_render_buffers);
+ RenderBuffers *rb = render_buffers_owner.get_or_null(p_render_buffers);
ERR_FAIL_COND_V(!rb, nullptr);
return rb->data;
}
@@ -2814,7 +2814,7 @@ void RendererSceneRenderRD::_setup_reflections(const PagedArray<RID> &p_reflecti
break;
}
- ReflectionProbeInstance *rpi = reflection_probe_instance_owner.getornull(p_reflections[i]);
+ ReflectionProbeInstance *rpi = reflection_probe_instance_owner.get_or_null(p_reflections[i]);
if (!rpi) {
continue;
}
@@ -2900,7 +2900,7 @@ void RendererSceneRenderRD::_setup_lights(const PagedArray<RID> &p_lights, const
r_directional_light_soft_shadows = false;
for (int i = 0; i < (int)p_lights.size(); i++) {
- LightInstance *li = light_instance_owner.getornull(p_lights[i]);
+ LightInstance *li = light_instance_owner.get_or_null(p_lights[i]);
if (!li) {
continue;
}
@@ -3129,7 +3129,7 @@ void RendererSceneRenderRD::_setup_lights(const PagedArray<RID> &p_lights, const
ShadowAtlas *shadow_atlas = nullptr;
if (p_shadow_atlas.is_valid() && p_using_shadows) {
- shadow_atlas = shadow_atlas_owner.getornull(p_shadow_atlas);
+ shadow_atlas = shadow_atlas_owner.get_or_null(p_shadow_atlas);
}
bool using_forward_ids = _uses_forward_ids();
@@ -3312,7 +3312,7 @@ void RendererSceneRenderRD::_setup_decals(const PagedArray<RID> &p_decals, const
break;
}
- DecalInstance *di = decal_instance_owner.getornull(p_decals[i]);
+ DecalInstance *di = decal_instance_owner.get_or_null(p_decals[i]);
if (!di) {
continue;
}
@@ -3495,9 +3495,9 @@ void RendererSceneRenderRD::_volumetric_fog_erase(RenderBuffers *rb) {
void RendererSceneRenderRD::_update_volumetric_fog(RID p_render_buffers, RID p_environment, const CameraMatrix &p_cam_projection, const Transform3D &p_cam_transform, RID p_shadow_atlas, int p_directional_light_count, bool p_use_directional_shadows, int p_positional_light_count, int p_voxel_gi_count) {
ERR_FAIL_COND(!is_clustered_enabled()); // can't use volumetric fog without clustered
- RenderBuffers *rb = render_buffers_owner.getornull(p_render_buffers);
+ RenderBuffers *rb = render_buffers_owner.get_or_null(p_render_buffers);
ERR_FAIL_COND(!rb);
- RendererSceneEnvironmentRD *env = environment_owner.getornull(p_environment);
+ RendererSceneEnvironmentRD *env = environment_owner.get_or_null(p_environment);
float ratio = float(rb->width) / float((rb->width + rb->height) / 2);
uint32_t target_width = uint32_t(float(volumetric_fog_size) * ratio);
@@ -3566,7 +3566,7 @@ void RendererSceneRenderRD::_update_volumetric_fog(RID p_render_buffers, RID p_e
RD::Uniform u;
u.uniform_type = RD::UNIFORM_TYPE_TEXTURE;
u.binding = 1;
- ShadowAtlas *shadow_atlas = shadow_atlas_owner.getornull(p_shadow_atlas);
+ ShadowAtlas *shadow_atlas = shadow_atlas_owner.get_or_null(p_shadow_atlas);
if (shadow_atlas == nullptr || shadow_atlas->depth.is_null()) {
u.ids.push_back(storage->texture_rd_get_default(RendererStorageRD::DEFAULT_RD_TEXTURE_BLACK));
} else {
@@ -3888,7 +3888,7 @@ void RendererSceneRenderRD::_update_volumetric_fog(RID p_render_buffers, RID p_e
bool RendererSceneRenderRD::_needs_post_prepass_render(RenderDataRD *p_render_data, bool p_use_gi) {
if (p_render_data->render_buffers.is_valid()) {
- RenderBuffers *rb = render_buffers_owner.getornull(p_render_data->render_buffers);
+ RenderBuffers *rb = render_buffers_owner.get_or_null(p_render_data->render_buffers);
if (rb->sdfgi != nullptr) {
return true;
}
@@ -3899,14 +3899,14 @@ bool RendererSceneRenderRD::_needs_post_prepass_render(RenderDataRD *p_render_da
void RendererSceneRenderRD::_post_prepass_render(RenderDataRD *p_render_data, bool p_use_gi) {
if (p_render_data->render_buffers.is_valid()) {
if (p_use_gi) {
- RenderBuffers *rb = render_buffers_owner.getornull(p_render_data->render_buffers);
+ RenderBuffers *rb = render_buffers_owner.get_or_null(p_render_data->render_buffers);
ERR_FAIL_COND(rb == nullptr);
if (rb->sdfgi == nullptr) {
return;
}
- RendererSceneEnvironmentRD *env = environment_owner.getornull(p_render_data->environment);
- rb->sdfgi->update_probes(env, sky.sky_owner.getornull(env->sky));
+ RendererSceneEnvironmentRD *env = environment_owner.get_or_null(p_render_data->environment);
+ rb->sdfgi->update_probes(env, sky.sky_owner.get_or_null(env->sky));
}
}
}
@@ -3923,7 +3923,7 @@ void RendererSceneRenderRD::_pre_opaque_render(RenderDataRD *p_render_data, bool
// Render shadows while GI is rendering, due to how barriers are handled, this should happen at the same time
if (p_render_data->render_buffers.is_valid() && p_use_gi) {
- RenderBuffers *rb = render_buffers_owner.getornull(p_render_data->render_buffers);
+ RenderBuffers *rb = render_buffers_owner.get_or_null(p_render_data->render_buffers);
ERR_FAIL_COND(rb == nullptr);
if (rb->sdfgi != nullptr) {
rb->sdfgi->store_probes();
@@ -3938,7 +3938,7 @@ void RendererSceneRenderRD::_pre_opaque_render(RenderDataRD *p_render_data, bool
float lod_distance_multiplier = p_render_data->cam_projection.get_lod_multiplier();
{
for (int i = 0; i < render_state.render_shadow_count; i++) {
- LightInstance *li = light_instance_owner.getornull(render_state.render_shadows[i].light);
+ LightInstance *li = light_instance_owner.get_or_null(render_state.render_shadows[i].light);
if (storage->light_get_type(li->light) == RS::LIGHT_DIRECTIONAL) {
render_state.directional_shadows.push_back(i);
@@ -4058,7 +4058,7 @@ void RendererSceneRenderRD::render_scene(RID p_render_buffers, const CameraData
// getting this here now so we can direct call a bunch of things more easily
RenderBuffers *rb = nullptr;
if (p_render_buffers.is_valid()) {
- rb = render_buffers_owner.getornull(p_render_buffers);
+ rb = render_buffers_owner.get_or_null(p_render_buffers);
ERR_FAIL_COND(!rb);
}
@@ -4140,7 +4140,7 @@ void RendererSceneRenderRD::render_scene(RID p_render_buffers, const CameraData
//assign render indices to voxel_gi_instances
if (is_dynamic_gi_supported()) {
for (uint32_t i = 0; i < (uint32_t)p_voxel_gi_instances.size(); i++) {
- RendererSceneGIRD::VoxelGIInstance *voxel_gi_inst = gi.voxel_gi_instance_owner.getornull(p_voxel_gi_instances[i]);
+ RendererSceneGIRD::VoxelGIInstance *voxel_gi_inst = gi.voxel_gi_instance_owner.get_or_null(p_voxel_gi_instances[i]);
if (voxel_gi_inst) {
voxel_gi_inst->render_index = i;
}
@@ -4151,8 +4151,8 @@ void RendererSceneRenderRD::render_scene(RID p_render_buffers, const CameraData
// render_data.render_buffers == p_render_buffers so we can use our already retrieved rb
current_cluster_builder = rb->cluster_builder;
} else if (reflection_probe_instance_owner.owns(render_data.reflection_probe)) {
- ReflectionProbeInstance *rpi = reflection_probe_instance_owner.getornull(render_data.reflection_probe);
- ReflectionAtlas *ra = reflection_atlas_owner.getornull(rpi->atlas);
+ ReflectionProbeInstance *rpi = reflection_probe_instance_owner.get_or_null(render_data.reflection_probe);
+ ReflectionAtlas *ra = reflection_atlas_owner.get_or_null(rpi->atlas);
if (!ra) {
ERR_PRINT("reflection probe has no reflection atlas! Bug?");
current_cluster_builder = nullptr;
@@ -4230,7 +4230,7 @@ void RendererSceneRenderRD::_debug_draw_cluster(RID p_render_buffers) {
}
void RendererSceneRenderRD::_render_shadow_pass(RID p_light, RID p_shadow_atlas, int p_pass, const PagedArray<GeometryInstance *> &p_instances, const Plane &p_camera_plane, float p_lod_distance_multiplier, float p_screen_lod_threshold, bool p_open_pass, bool p_close_pass, bool p_clear_region, RendererScene::RenderInfo *p_render_info) {
- LightInstance *light_instance = light_instance_owner.getornull(p_light);
+ LightInstance *light_instance = light_instance_owner.get_or_null(p_light);
ERR_FAIL_COND(!light_instance);
Rect2i atlas_rect;
@@ -4301,7 +4301,7 @@ void RendererSceneRenderRD::_render_shadow_pass(RID p_light, RID p_shadow_atlas,
} else {
//set from shadow atlas
- ShadowAtlas *shadow_atlas = shadow_atlas_owner.getornull(p_shadow_atlas);
+ ShadowAtlas *shadow_atlas = shadow_atlas_owner.get_or_null(p_shadow_atlas);
ERR_FAIL_COND(!shadow_atlas);
ERR_FAIL_COND(!shadow_atlas->shadow_owners.has(p_light));
@@ -4424,7 +4424,7 @@ void RendererSceneRenderRD::render_particle_collider_heightfield(RID p_collider,
bool RendererSceneRenderRD::free(RID p_rid) {
if (render_buffers_owner.owns(p_rid)) {
- RenderBuffers *rb = render_buffers_owner.getornull(p_rid);
+ RenderBuffers *rb = render_buffers_owner.get_or_null(p_rid);
_free_render_buffer_data(rb);
memdelete(rb->data);
if (rb->sdfgi) {
@@ -4447,24 +4447,24 @@ bool RendererSceneRenderRD::free(RID p_rid) {
camera_effects_owner.free(p_rid);
} else if (reflection_atlas_owner.owns(p_rid)) {
reflection_atlas_set_size(p_rid, 0, 0);
- ReflectionAtlas *ra = reflection_atlas_owner.getornull(p_rid);
+ ReflectionAtlas *ra = reflection_atlas_owner.get_or_null(p_rid);
if (ra->cluster_builder) {
memdelete(ra->cluster_builder);
}
reflection_atlas_owner.free(p_rid);
} else if (reflection_probe_instance_owner.owns(p_rid)) {
- ReflectionProbeInstance *rpi = reflection_probe_instance_owner.getornull(p_rid);
+ ReflectionProbeInstance *rpi = reflection_probe_instance_owner.get_or_null(p_rid);
_free_forward_id(FORWARD_ID_TYPE_REFLECTION_PROBE, rpi->forward_id);
reflection_probe_release_atlas_index(p_rid);
reflection_probe_instance_owner.free(p_rid);
} else if (decal_instance_owner.owns(p_rid)) {
- DecalInstance *di = decal_instance_owner.getornull(p_rid);
+ DecalInstance *di = decal_instance_owner.get_or_null(p_rid);
_free_forward_id(FORWARD_ID_TYPE_DECAL, di->forward_id);
decal_instance_owner.free(p_rid);
} else if (lightmap_instance_owner.owns(p_rid)) {
lightmap_instance_owner.free(p_rid);
} else if (gi.voxel_gi_instance_owner.owns(p_rid)) {
- RendererSceneGIRD::VoxelGIInstance *voxel_gi = gi.voxel_gi_instance_owner.getornull(p_rid);
+ RendererSceneGIRD::VoxelGIInstance *voxel_gi = gi.voxel_gi_instance_owner.get_or_null(p_rid);
if (voxel_gi->texture.is_valid()) {
RD::get_singleton()->free(voxel_gi->texture);
RD::get_singleton()->free(voxel_gi->write_buffer);
@@ -4480,11 +4480,11 @@ bool RendererSceneRenderRD::free(RID p_rid) {
sky.update_dirty_skys();
sky.free_sky(p_rid);
} else if (light_instance_owner.owns(p_rid)) {
- LightInstance *light_instance = light_instance_owner.getornull(p_rid);
+ LightInstance *light_instance = light_instance_owner.get_or_null(p_rid);
//remove from shadow atlases..
for (Set<RID>::Element *E = light_instance->shadow_atlases.front(); E; E = E->next()) {
- ShadowAtlas *shadow_atlas = shadow_atlas_owner.getornull(E->get());
+ ShadowAtlas *shadow_atlas = shadow_atlas_owner.get_or_null(E->get());
ERR_CONTINUE(!shadow_atlas->shadow_owners.has(p_rid));
uint32_t key = shadow_atlas->shadow_owners[p_rid];
uint32_t q = (key >> ShadowAtlas::QUADRANT_SHIFT) & 0x3;
@@ -4801,8 +4801,8 @@ void RendererSceneRenderRD::init() {
}
RendererSceneRenderRD::~RendererSceneRenderRD() {
- for (Map<int, ShadowCubemap>::Element *E = shadow_cubemaps.front(); E; E = E->next()) {
- RD::get_singleton()->free(E->get().cubemap);
+ for (const KeyValue<int, ShadowCubemap> &E : shadow_cubemaps) {
+ RD::get_singleton()->free(E.value.cubemap);
}
if (sky.sky_scene_state.uniform_set.is_valid() && RD::get_singleton()->uniform_set_is_valid(sky.sky_scene_state.uniform_set)) {
diff --git a/servers/rendering/renderer_rd/renderer_scene_render_rd.h b/servers/rendering/renderer_rd/renderer_scene_render_rd.h
index db423b7d25..fa80b84cfe 100644
--- a/servers/rendering/renderer_rd/renderer_scene_render_rd.h
+++ b/servers/rendering/renderer_rd/renderer_scene_render_rd.h
@@ -149,7 +149,7 @@ protected:
RendererSceneEnvironmentRD *get_environment(RID p_environment) {
if (p_environment.is_valid()) {
- return environment_owner.getornull(p_environment);
+ return environment_owner.get_or_null(p_environment);
} else {
return nullptr;
}
@@ -814,19 +814,19 @@ public:
virtual void shadow_atlas_set_quadrant_subdivision(RID p_atlas, int p_quadrant, int p_subdivision) override;
virtual bool shadow_atlas_update_light(RID p_atlas, RID p_light_intance, float p_coverage, uint64_t p_light_version) override;
_FORCE_INLINE_ bool shadow_atlas_owns_light_instance(RID p_atlas, RID p_light_intance) {
- ShadowAtlas *atlas = shadow_atlas_owner.getornull(p_atlas);
+ ShadowAtlas *atlas = shadow_atlas_owner.get_or_null(p_atlas);
ERR_FAIL_COND_V(!atlas, false);
return atlas->shadow_owners.has(p_light_intance);
}
_FORCE_INLINE_ RID shadow_atlas_get_texture(RID p_atlas) {
- ShadowAtlas *atlas = shadow_atlas_owner.getornull(p_atlas);
+ ShadowAtlas *atlas = shadow_atlas_owner.get_or_null(p_atlas);
ERR_FAIL_COND_V(!atlas, RID());
return atlas->depth;
}
_FORCE_INLINE_ Size2i shadow_atlas_get_size(RID p_atlas) {
- ShadowAtlas *atlas = shadow_atlas_owner.getornull(p_atlas);
+ ShadowAtlas *atlas = shadow_atlas_owner.get_or_null(p_atlas);
ERR_FAIL_COND_V(!atlas, Size2i());
return Size2(atlas->size, atlas->size);
}
@@ -942,7 +942,7 @@ public:
virtual void camera_effects_set_custom_exposure(RID p_camera_effects, bool p_enable, float p_exposure) override;
bool camera_effects_uses_dof(RID p_camera_effects) {
- CameraEffects *camfx = camera_effects_owner.getornull(p_camera_effects);
+ CameraEffects *camfx = camera_effects_owner.get_or_null(p_camera_effects);
return camfx && (camfx->dof_blur_near_enabled || camfx->dof_blur_far_enabled) && camfx->dof_blur_amount > 0.0;
}
@@ -954,18 +954,18 @@ public:
virtual void light_instance_mark_visible(RID p_light_instance) override;
_FORCE_INLINE_ RID light_instance_get_base_light(RID p_light_instance) {
- LightInstance *li = light_instance_owner.getornull(p_light_instance);
+ LightInstance *li = light_instance_owner.get_or_null(p_light_instance);
return li->light;
}
_FORCE_INLINE_ Transform3D light_instance_get_base_transform(RID p_light_instance) {
- LightInstance *li = light_instance_owner.getornull(p_light_instance);
+ LightInstance *li = light_instance_owner.get_or_null(p_light_instance);
return li->transform;
}
_FORCE_INLINE_ Rect2 light_instance_get_shadow_atlas_rect(RID p_light_instance, RID p_shadow_atlas, Vector2i &r_omni_offset) {
- ShadowAtlas *shadow_atlas = shadow_atlas_owner.getornull(p_shadow_atlas);
- LightInstance *li = light_instance_owner.getornull(p_light_instance);
+ ShadowAtlas *shadow_atlas = shadow_atlas_owner.get_or_null(p_shadow_atlas);
+ LightInstance *li = light_instance_owner.get_or_null(p_light_instance);
uint32_t key = shadow_atlas->shadow_owners[li->self];
uint32_t quadrant = (key >> ShadowAtlas::QUADRANT_SHIFT) & 0x3;
@@ -1000,16 +1000,16 @@ public:
}
_FORCE_INLINE_ CameraMatrix light_instance_get_shadow_camera(RID p_light_instance, int p_index) {
- LightInstance *li = light_instance_owner.getornull(p_light_instance);
+ LightInstance *li = light_instance_owner.get_or_null(p_light_instance);
return li->shadow_transform[p_index].camera;
}
_FORCE_INLINE_ float light_instance_get_shadow_texel_size(RID p_light_instance, RID p_shadow_atlas) {
#ifdef DEBUG_ENABLED
- LightInstance *li = light_instance_owner.getornull(p_light_instance);
+ LightInstance *li = light_instance_owner.get_or_null(p_light_instance);
ERR_FAIL_COND_V(!li->shadow_atlases.has(p_shadow_atlas), 0);
#endif
- ShadowAtlas *shadow_atlas = shadow_atlas_owner.getornull(p_shadow_atlas);
+ ShadowAtlas *shadow_atlas = shadow_atlas_owner.get_or_null(p_shadow_atlas);
ERR_FAIL_COND_V(!shadow_atlas, 0);
#ifdef DEBUG_ENABLED
ERR_FAIL_COND_V(!shadow_atlas->shadow_owners.has(p_light_instance), 0);
@@ -1027,59 +1027,59 @@ public:
_FORCE_INLINE_ Transform3D
light_instance_get_shadow_transform(RID p_light_instance, int p_index) {
- LightInstance *li = light_instance_owner.getornull(p_light_instance);
+ LightInstance *li = light_instance_owner.get_or_null(p_light_instance);
return li->shadow_transform[p_index].transform;
}
_FORCE_INLINE_ float light_instance_get_shadow_bias_scale(RID p_light_instance, int p_index) {
- LightInstance *li = light_instance_owner.getornull(p_light_instance);
+ LightInstance *li = light_instance_owner.get_or_null(p_light_instance);
return li->shadow_transform[p_index].bias_scale;
}
_FORCE_INLINE_ float light_instance_get_shadow_range(RID p_light_instance, int p_index) {
- LightInstance *li = light_instance_owner.getornull(p_light_instance);
+ LightInstance *li = light_instance_owner.get_or_null(p_light_instance);
return li->shadow_transform[p_index].farplane;
}
_FORCE_INLINE_ float light_instance_get_shadow_range_begin(RID p_light_instance, int p_index) {
- LightInstance *li = light_instance_owner.getornull(p_light_instance);
+ LightInstance *li = light_instance_owner.get_or_null(p_light_instance);
return li->shadow_transform[p_index].range_begin;
}
_FORCE_INLINE_ Vector2 light_instance_get_shadow_uv_scale(RID p_light_instance, int p_index) {
- LightInstance *li = light_instance_owner.getornull(p_light_instance);
+ LightInstance *li = light_instance_owner.get_or_null(p_light_instance);
return li->shadow_transform[p_index].uv_scale;
}
_FORCE_INLINE_ Rect2 light_instance_get_directional_shadow_atlas_rect(RID p_light_instance, int p_index) {
- LightInstance *li = light_instance_owner.getornull(p_light_instance);
+ LightInstance *li = light_instance_owner.get_or_null(p_light_instance);
return li->shadow_transform[p_index].atlas_rect;
}
_FORCE_INLINE_ float light_instance_get_directional_shadow_split(RID p_light_instance, int p_index) {
- LightInstance *li = light_instance_owner.getornull(p_light_instance);
+ LightInstance *li = light_instance_owner.get_or_null(p_light_instance);
return li->shadow_transform[p_index].split;
}
_FORCE_INLINE_ float light_instance_get_directional_shadow_texel_size(RID p_light_instance, int p_index) {
- LightInstance *li = light_instance_owner.getornull(p_light_instance);
+ LightInstance *li = light_instance_owner.get_or_null(p_light_instance);
return li->shadow_transform[p_index].shadow_texel_size;
}
_FORCE_INLINE_ void light_instance_set_render_pass(RID p_light_instance, uint64_t p_pass) {
- LightInstance *li = light_instance_owner.getornull(p_light_instance);
+ LightInstance *li = light_instance_owner.get_or_null(p_light_instance);
li->last_pass = p_pass;
}
_FORCE_INLINE_ uint64_t light_instance_get_render_pass(RID p_light_instance) {
- LightInstance *li = light_instance_owner.getornull(p_light_instance);
+ LightInstance *li = light_instance_owner.get_or_null(p_light_instance);
return li->last_pass;
}
_FORCE_INLINE_ ForwardID light_instance_get_forward_id(RID p_light_instance) {
- LightInstance *li = light_instance_owner.getornull(p_light_instance);
+ LightInstance *li = light_instance_owner.get_or_null(p_light_instance);
return li->forward_id;
}
_FORCE_INLINE_ RS::LightType light_instance_get_type(RID p_light_instance) {
- LightInstance *li = light_instance_owner.getornull(p_light_instance);
+ LightInstance *li = light_instance_owner.get_or_null(p_light_instance);
return li->light_type;
}
@@ -1088,7 +1088,7 @@ public:
virtual int reflection_atlas_get_size(RID p_ref_atlas) const override;
_FORCE_INLINE_ RID reflection_atlas_get_texture(RID p_ref_atlas) {
- ReflectionAtlas *atlas = reflection_atlas_owner.getornull(p_ref_atlas);
+ ReflectionAtlas *atlas = reflection_atlas_owner.get_or_null(p_ref_atlas);
ERR_FAIL_COND_V(!atlas, RID());
return atlas->reflection;
}
@@ -1107,41 +1107,41 @@ public:
RID reflection_probe_instance_get_depth_framebuffer(RID p_instance, int p_index);
_FORCE_INLINE_ RID reflection_probe_instance_get_probe(RID p_instance) {
- ReflectionProbeInstance *rpi = reflection_probe_instance_owner.getornull(p_instance);
+ ReflectionProbeInstance *rpi = reflection_probe_instance_owner.get_or_null(p_instance);
ERR_FAIL_COND_V(!rpi, RID());
return rpi->probe;
}
_FORCE_INLINE_ ForwardID reflection_probe_instance_get_forward_id(RID p_instance) {
- ReflectionProbeInstance *rpi = reflection_probe_instance_owner.getornull(p_instance);
+ ReflectionProbeInstance *rpi = reflection_probe_instance_owner.get_or_null(p_instance);
ERR_FAIL_COND_V(!rpi, 0);
return rpi->forward_id;
}
_FORCE_INLINE_ void reflection_probe_instance_set_render_pass(RID p_instance, uint32_t p_render_pass) {
- ReflectionProbeInstance *rpi = reflection_probe_instance_owner.getornull(p_instance);
+ ReflectionProbeInstance *rpi = reflection_probe_instance_owner.get_or_null(p_instance);
ERR_FAIL_COND(!rpi);
rpi->last_pass = p_render_pass;
}
_FORCE_INLINE_ uint32_t reflection_probe_instance_get_render_pass(RID p_instance) {
- ReflectionProbeInstance *rpi = reflection_probe_instance_owner.getornull(p_instance);
+ ReflectionProbeInstance *rpi = reflection_probe_instance_owner.get_or_null(p_instance);
ERR_FAIL_COND_V(!rpi, 0);
return rpi->last_pass;
}
_FORCE_INLINE_ Transform3D reflection_probe_instance_get_transform(RID p_instance) {
- ReflectionProbeInstance *rpi = reflection_probe_instance_owner.getornull(p_instance);
+ ReflectionProbeInstance *rpi = reflection_probe_instance_owner.get_or_null(p_instance);
ERR_FAIL_COND_V(!rpi, Transform3D());
return rpi->transform;
}
_FORCE_INLINE_ int reflection_probe_instance_get_atlas_index(RID p_instance) {
- ReflectionProbeInstance *rpi = reflection_probe_instance_owner.getornull(p_instance);
+ ReflectionProbeInstance *rpi = reflection_probe_instance_owner.get_or_null(p_instance);
ERR_FAIL_COND_V(!rpi, -1);
return rpi->atlas_index;
@@ -1151,32 +1151,32 @@ public:
virtual void decal_instance_set_transform(RID p_decal, const Transform3D &p_transform) override;
_FORCE_INLINE_ RID decal_instance_get_base(RID p_decal) const {
- DecalInstance *decal = decal_instance_owner.getornull(p_decal);
+ DecalInstance *decal = decal_instance_owner.get_or_null(p_decal);
return decal->decal;
}
_FORCE_INLINE_ ForwardID decal_instance_get_forward_id(RID p_decal) const {
- DecalInstance *decal = decal_instance_owner.getornull(p_decal);
+ DecalInstance *decal = decal_instance_owner.get_or_null(p_decal);
return decal->forward_id;
}
_FORCE_INLINE_ Transform3D decal_instance_get_transform(RID p_decal) const {
- DecalInstance *decal = decal_instance_owner.getornull(p_decal);
+ DecalInstance *decal = decal_instance_owner.get_or_null(p_decal);
return decal->transform;
}
virtual RID lightmap_instance_create(RID p_lightmap) override;
virtual void lightmap_instance_set_transform(RID p_lightmap, const Transform3D &p_transform) override;
_FORCE_INLINE_ bool lightmap_instance_is_valid(RID p_lightmap_instance) {
- return lightmap_instance_owner.getornull(p_lightmap_instance) != nullptr;
+ return lightmap_instance_owner.get_or_null(p_lightmap_instance) != nullptr;
}
_FORCE_INLINE_ RID lightmap_instance_get_lightmap(RID p_lightmap_instance) {
- LightmapInstance *li = lightmap_instance_owner.getornull(p_lightmap_instance);
+ LightmapInstance *li = lightmap_instance_owner.get_or_null(p_lightmap_instance);
return li->lightmap;
}
_FORCE_INLINE_ Transform3D lightmap_instance_get_transform(RID p_lightmap_instance) {
- LightmapInstance *li = lightmap_instance_owner.getornull(p_lightmap_instance);
+ LightmapInstance *li = lightmap_instance_owner.get_or_null(p_lightmap_instance);
return li->transform;
}
diff --git a/servers/rendering/renderer_rd/renderer_scene_sky_rd.cpp b/servers/rendering/renderer_rd/renderer_scene_sky_rd.cpp
index c388da755c..830b0e7bae 100644
--- a/servers/rendering/renderer_rd/renderer_scene_sky_rd.cpp
+++ b/servers/rendering/renderer_rd/renderer_scene_sky_rd.cpp
@@ -148,36 +148,36 @@ void RendererSceneSkyRD::SkyShaderData::set_default_texture_param(const StringNa
void RendererSceneSkyRD::SkyShaderData::get_param_list(List<PropertyInfo> *p_param_list) const {
Map<int, StringName> order;
- for (Map<StringName, ShaderLanguage::ShaderNode::Uniform>::Element *E = uniforms.front(); E; E = E->next()) {
- if (E->get().scope == ShaderLanguage::ShaderNode::Uniform::SCOPE_GLOBAL || E->get().scope == ShaderLanguage::ShaderNode::Uniform::SCOPE_INSTANCE) {
+ for (const KeyValue<StringName, ShaderLanguage::ShaderNode::Uniform> &E : uniforms) {
+ if (E.value.scope == ShaderLanguage::ShaderNode::Uniform::SCOPE_GLOBAL || E.value.scope == ShaderLanguage::ShaderNode::Uniform::SCOPE_INSTANCE) {
continue;
}
- if (E->get().texture_order >= 0) {
- order[E->get().texture_order + 100000] = E->key();
+ if (E.value.texture_order >= 0) {
+ order[E.value.texture_order + 100000] = E.key;
} else {
- order[E->get().order] = E->key();
+ order[E.value.order] = E.key;
}
}
- for (Map<int, StringName>::Element *E = order.front(); E; E = E->next()) {
- PropertyInfo pi = ShaderLanguage::uniform_to_property_info(uniforms[E->get()]);
- pi.name = E->get();
+ for (const KeyValue<int, StringName> &E : order) {
+ PropertyInfo pi = ShaderLanguage::uniform_to_property_info(uniforms[E.value]);
+ pi.name = E.value;
p_param_list->push_back(pi);
}
}
void RendererSceneSkyRD::SkyShaderData::get_instance_param_list(List<RendererStorage::InstanceShaderParam> *p_param_list) const {
- for (Map<StringName, ShaderLanguage::ShaderNode::Uniform>::Element *E = uniforms.front(); E; E = E->next()) {
- if (E->get().scope != ShaderLanguage::ShaderNode::Uniform::SCOPE_INSTANCE) {
+ for (const KeyValue<StringName, ShaderLanguage::ShaderNode::Uniform> &E : uniforms) {
+ if (E.value.scope != ShaderLanguage::ShaderNode::Uniform::SCOPE_INSTANCE) {
continue;
}
RendererStorage::InstanceShaderParam p;
- p.info = ShaderLanguage::uniform_to_property_info(E->get());
- p.info.name = E->key(); //supply name
- p.index = E->get().instance_index;
- p.default_value = ShaderLanguage::constant_value_to_variant(E->get().default_value, E->get().type, E->get().hint);
+ p.info = ShaderLanguage::uniform_to_property_info(E.value);
+ p.info.name = E.key; //supply name
+ p.index = E.value.instance_index;
+ p.default_value = ShaderLanguage::constant_value_to_variant(E.value.default_value, E.value.type, E.value.hint);
p_param_list->push_back(p);
}
}
@@ -1772,7 +1772,7 @@ void RendererSceneSkyRD::initialize_sky_rid(RID p_rid) {
}
RendererSceneSkyRD::Sky *RendererSceneSkyRD::get_sky(RID p_sky) const {
- return sky_owner.getornull(p_sky);
+ return sky_owner.get_or_null(p_sky);
}
void RendererSceneSkyRD::free_sky(RID p_sky) {
diff --git a/servers/rendering/renderer_rd/renderer_storage_rd.cpp b/servers/rendering/renderer_rd/renderer_storage_rd.cpp
index ed87932762..5ef1f46742 100644
--- a/servers/rendering/renderer_rd/renderer_storage_rd.cpp
+++ b/servers/rendering/renderer_rd/renderer_storage_rd.cpp
@@ -842,7 +842,7 @@ void RendererStorageRD::texture_3d_initialize(RID p_texture, Image::Format p_for
}
void RendererStorageRD::texture_proxy_initialize(RID p_texture, RID p_base) {
- Texture *tex = texture_owner.getornull(p_base);
+ Texture *tex = texture_owner.get_or_null(p_base);
ERR_FAIL_COND(!tex);
Texture proxy_tex = *tex;
@@ -865,7 +865,7 @@ void RendererStorageRD::texture_proxy_initialize(RID p_texture, RID p_base) {
void RendererStorageRD::_texture_2d_update(RID p_texture, const Ref<Image> &p_image, int p_layer, bool p_immediate) {
ERR_FAIL_COND(p_image.is_null() || p_image->is_empty());
- Texture *tex = texture_owner.getornull(p_texture);
+ Texture *tex = texture_owner.get_or_null(p_texture);
ERR_FAIL_COND(!tex);
ERR_FAIL_COND(tex->is_render_target);
ERR_FAIL_COND(p_image->get_width() != tex->width || p_image->get_height() != tex->height);
@@ -889,7 +889,7 @@ void RendererStorageRD::texture_2d_update(RID p_texture, const Ref<Image> &p_ima
}
void RendererStorageRD::texture_3d_update(RID p_texture, const Vector<Ref<Image>> &p_data) {
- Texture *tex = texture_owner.getornull(p_texture);
+ Texture *tex = texture_owner.get_or_null(p_texture);
ERR_FAIL_COND(!tex);
ERR_FAIL_COND(tex->type != Texture::TYPE_3D);
Image::Image3DValidateError verr = Image::validate_3d_image(tex->format, tex->width, tex->height, tex->depth, tex->mipmaps > 1, p_data);
@@ -926,10 +926,10 @@ void RendererStorageRD::texture_3d_update(RID p_texture, const Vector<Ref<Image>
}
void RendererStorageRD::texture_proxy_update(RID p_texture, RID p_proxy_to) {
- Texture *tex = texture_owner.getornull(p_texture);
+ Texture *tex = texture_owner.get_or_null(p_texture);
ERR_FAIL_COND(!tex);
ERR_FAIL_COND(!tex->is_proxy);
- Texture *proxy_to = texture_owner.getornull(p_proxy_to);
+ Texture *proxy_to = texture_owner.get_or_null(p_proxy_to);
ERR_FAIL_COND(!proxy_to);
ERR_FAIL_COND(proxy_to->is_proxy);
@@ -943,7 +943,7 @@ void RendererStorageRD::texture_proxy_update(RID p_texture, RID p_proxy_to) {
RD::get_singleton()->free(tex->rd_texture_srgb);
tex->rd_texture_srgb = RID();
}
- Texture *prev_tex = texture_owner.getornull(tex->proxy_to);
+ Texture *prev_tex = texture_owner.get_or_null(tex->proxy_to);
ERR_FAIL_COND(!prev_tex);
prev_tex->proxies.erase(p_texture);
}
@@ -1030,7 +1030,7 @@ void RendererStorageRD::texture_3d_placeholder_initialize(RID p_texture) {
}
Ref<Image> RendererStorageRD::texture_2d_get(RID p_texture) const {
- Texture *tex = texture_owner.getornull(p_texture);
+ Texture *tex = texture_owner.get_or_null(p_texture);
ERR_FAIL_COND_V(!tex, Ref<Image>());
#ifdef TOOLS_ENABLED
@@ -1058,7 +1058,7 @@ Ref<Image> RendererStorageRD::texture_2d_get(RID p_texture) const {
}
Ref<Image> RendererStorageRD::texture_2d_layer_get(RID p_texture, int p_layer) const {
- Texture *tex = texture_owner.getornull(p_texture);
+ Texture *tex = texture_owner.get_or_null(p_texture);
ERR_FAIL_COND_V(!tex, Ref<Image>());
Vector<uint8_t> data = RD::get_singleton()->texture_get_data(tex->rd_texture, p_layer);
@@ -1075,7 +1075,7 @@ Ref<Image> RendererStorageRD::texture_2d_layer_get(RID p_texture, int p_layer) c
}
Vector<Ref<Image>> RendererStorageRD::texture_3d_get(RID p_texture) const {
- Texture *tex = texture_owner.getornull(p_texture);
+ Texture *tex = texture_owner.get_or_null(p_texture);
ERR_FAIL_COND_V(!tex, Vector<Ref<Image>>());
ERR_FAIL_COND_V(tex->type != Texture::TYPE_3D, Vector<Ref<Image>>());
@@ -1106,10 +1106,10 @@ Vector<Ref<Image>> RendererStorageRD::texture_3d_get(RID p_texture) const {
}
void RendererStorageRD::texture_replace(RID p_texture, RID p_by_texture) {
- Texture *tex = texture_owner.getornull(p_texture);
+ Texture *tex = texture_owner.get_or_null(p_texture);
ERR_FAIL_COND(!tex);
ERR_FAIL_COND(tex->proxy_to.is_valid()); //can't replace proxy
- Texture *by_tex = texture_owner.getornull(p_by_texture);
+ Texture *by_tex = texture_owner.get_or_null(p_by_texture);
ERR_FAIL_COND(!by_tex);
ERR_FAIL_COND(by_tex->proxy_to.is_valid()); //can't replace proxy
@@ -1155,7 +1155,7 @@ void RendererStorageRD::texture_replace(RID p_texture, RID p_by_texture) {
}
void RendererStorageRD::texture_set_size_override(RID p_texture, int p_width, int p_height) {
- Texture *tex = texture_owner.getornull(p_texture);
+ Texture *tex = texture_owner.get_or_null(p_texture);
ERR_FAIL_COND(!tex);
ERR_FAIL_COND(tex->type != Texture::TYPE_2D);
tex->width_2d = p_width;
@@ -1163,7 +1163,7 @@ void RendererStorageRD::texture_set_size_override(RID p_texture, int p_width, in
}
void RendererStorageRD::texture_set_path(RID p_texture, const String &p_path) {
- Texture *tex = texture_owner.getornull(p_texture);
+ Texture *tex = texture_owner.get_or_null(p_texture);
ERR_FAIL_COND(!tex);
tex->path = p_path;
}
@@ -1173,21 +1173,21 @@ String RendererStorageRD::texture_get_path(RID p_texture) const {
}
void RendererStorageRD::texture_set_detect_3d_callback(RID p_texture, RS::TextureDetectCallback p_callback, void *p_userdata) {
- Texture *tex = texture_owner.getornull(p_texture);
+ Texture *tex = texture_owner.get_or_null(p_texture);
ERR_FAIL_COND(!tex);
tex->detect_3d_callback_ud = p_userdata;
tex->detect_3d_callback = p_callback;
}
void RendererStorageRD::texture_set_detect_normal_callback(RID p_texture, RS::TextureDetectCallback p_callback, void *p_userdata) {
- Texture *tex = texture_owner.getornull(p_texture);
+ Texture *tex = texture_owner.get_or_null(p_texture);
ERR_FAIL_COND(!tex);
tex->detect_normal_callback_ud = p_userdata;
tex->detect_normal_callback = p_callback;
}
void RendererStorageRD::texture_set_detect_roughness_callback(RID p_texture, RS::TextureDetectRoughnessCallback p_callback, void *p_userdata) {
- Texture *tex = texture_owner.getornull(p_texture);
+ Texture *tex = texture_owner.get_or_null(p_texture);
ERR_FAIL_COND(!tex);
tex->detect_roughness_callback_ud = p_userdata;
tex->detect_roughness_callback = p_callback;
@@ -1235,7 +1235,7 @@ void RendererStorageRD::canvas_texture_initialize(RID p_rid) {
}
void RendererStorageRD::canvas_texture_set_channel(RID p_canvas_texture, RS::CanvasTextureChannel p_channel, RID p_texture) {
- CanvasTexture *ct = canvas_texture_owner.getornull(p_canvas_texture);
+ CanvasTexture *ct = canvas_texture_owner.get_or_null(p_canvas_texture);
switch (p_channel) {
case RS::CANVAS_TEXTURE_CHANNEL_DIFFUSE: {
ct->diffuse = p_texture;
@@ -1252,7 +1252,7 @@ void RendererStorageRD::canvas_texture_set_channel(RID p_canvas_texture, RS::Can
}
void RendererStorageRD::canvas_texture_set_shading_parameters(RID p_canvas_texture, const Color &p_specular_color, float p_shininess) {
- CanvasTexture *ct = canvas_texture_owner.getornull(p_canvas_texture);
+ CanvasTexture *ct = canvas_texture_owner.get_or_null(p_canvas_texture);
ct->specular_color.r = p_specular_color.r;
ct->specular_color.g = p_specular_color.g;
ct->specular_color.b = p_specular_color.b;
@@ -1261,13 +1261,13 @@ void RendererStorageRD::canvas_texture_set_shading_parameters(RID p_canvas_textu
}
void RendererStorageRD::canvas_texture_set_texture_filter(RID p_canvas_texture, RS::CanvasItemTextureFilter p_filter) {
- CanvasTexture *ct = canvas_texture_owner.getornull(p_canvas_texture);
+ CanvasTexture *ct = canvas_texture_owner.get_or_null(p_canvas_texture);
ct->texture_filter = p_filter;
ct->clear_sets();
}
void RendererStorageRD::canvas_texture_set_texture_repeat(RID p_canvas_texture, RS::CanvasItemTextureRepeat p_repeat) {
- CanvasTexture *ct = canvas_texture_owner.getornull(p_canvas_texture);
+ CanvasTexture *ct = canvas_texture_owner.get_or_null(p_canvas_texture);
ct->texture_repeat = p_repeat;
ct->clear_sets();
}
@@ -1275,7 +1275,7 @@ void RendererStorageRD::canvas_texture_set_texture_repeat(RID p_canvas_texture,
bool RendererStorageRD::canvas_texture_get_uniform_set(RID p_texture, RS::CanvasItemTextureFilter p_base_filter, RS::CanvasItemTextureRepeat p_base_repeat, RID p_base_shader, int p_base_set, RID &r_uniform_set, Size2i &r_size, Color &r_specular_shininess, bool &r_use_normal, bool &r_use_specular) {
CanvasTexture *ct = nullptr;
- Texture *t = texture_owner.getornull(p_texture);
+ Texture *t = texture_owner.get_or_null(p_texture);
if (t) {
//regular texture
@@ -1286,7 +1286,7 @@ bool RendererStorageRD::canvas_texture_get_uniform_set(RID p_texture, RS::Canvas
ct = t->canvas_texture;
} else {
- ct = canvas_texture_owner.getornull(p_texture);
+ ct = canvas_texture_owner.get_or_null(p_texture);
}
if (!ct) {
@@ -1308,7 +1308,7 @@ bool RendererStorageRD::canvas_texture_get_uniform_set(RID p_texture, RS::Canvas
u.uniform_type = RD::UNIFORM_TYPE_TEXTURE;
u.binding = 0;
- t = texture_owner.getornull(ct->diffuse);
+ t = texture_owner.get_or_null(ct->diffuse);
if (!t) {
u.ids.push_back(texture_rd_get_default(DEFAULT_RD_TEXTURE_WHITE));
ct->size_cache = Size2i(1, 1);
@@ -1323,7 +1323,7 @@ bool RendererStorageRD::canvas_texture_get_uniform_set(RID p_texture, RS::Canvas
u.uniform_type = RD::UNIFORM_TYPE_TEXTURE;
u.binding = 1;
- t = texture_owner.getornull(ct->normal_map);
+ t = texture_owner.get_or_null(ct->normal_map);
if (!t) {
u.ids.push_back(texture_rd_get_default(DEFAULT_RD_TEXTURE_NORMAL));
ct->use_normal_cache = false;
@@ -1338,7 +1338,7 @@ bool RendererStorageRD::canvas_texture_get_uniform_set(RID p_texture, RS::Canvas
u.uniform_type = RD::UNIFORM_TYPE_TEXTURE;
u.binding = 2;
- t = texture_owner.getornull(ct->specular);
+ t = texture_owner.get_or_null(ct->specular);
if (!t) {
u.ids.push_back(texture_rd_get_default(DEFAULT_RD_TEXTURE_WHITE));
ct->use_specular_cache = false;
@@ -1384,7 +1384,7 @@ void RendererStorageRD::shader_initialize(RID p_rid) {
}
void RendererStorageRD::shader_set_code(RID p_shader, const String &p_code) {
- Shader *shader = shader_owner.getornull(p_shader);
+ Shader *shader = shader_owner.get_or_null(p_shader);
ERR_FAIL_COND(!shader);
shader->code = p_code;
@@ -1438,8 +1438,8 @@ void RendererStorageRD::shader_set_code(RID p_shader, const String &p_code) {
}
if (shader->data) {
- for (Map<StringName, RID>::Element *E = shader->default_texture_parameter.front(); E; E = E->next()) {
- shader->data->set_default_texture_param(E->key(), E->get());
+ for (const KeyValue<StringName, RID> &E : shader->default_texture_parameter) {
+ shader->data->set_default_texture_param(E.key, E.value);
}
}
}
@@ -1456,13 +1456,13 @@ void RendererStorageRD::shader_set_code(RID p_shader, const String &p_code) {
}
String RendererStorageRD::shader_get_code(RID p_shader) const {
- Shader *shader = shader_owner.getornull(p_shader);
+ Shader *shader = shader_owner.get_or_null(p_shader);
ERR_FAIL_COND_V(!shader, String());
return shader->code;
}
void RendererStorageRD::shader_get_param_list(RID p_shader, List<PropertyInfo> *p_param_list) const {
- Shader *shader = shader_owner.getornull(p_shader);
+ Shader *shader = shader_owner.get_or_null(p_shader);
ERR_FAIL_COND(!shader);
if (shader->data) {
return shader->data->get_param_list(p_param_list);
@@ -1470,7 +1470,7 @@ void RendererStorageRD::shader_get_param_list(RID p_shader, List<PropertyInfo> *
}
void RendererStorageRD::shader_set_default_texture_param(RID p_shader, const StringName &p_name, RID p_texture) {
- Shader *shader = shader_owner.getornull(p_shader);
+ Shader *shader = shader_owner.get_or_null(p_shader);
ERR_FAIL_COND(!shader);
if (p_texture.is_valid() && texture_owner.owns(p_texture)) {
@@ -1488,7 +1488,7 @@ void RendererStorageRD::shader_set_default_texture_param(RID p_shader, const Str
}
RID RendererStorageRD::shader_get_default_texture_param(RID p_shader, const StringName &p_name) const {
- Shader *shader = shader_owner.getornull(p_shader);
+ Shader *shader = shader_owner.get_or_null(p_shader);
ERR_FAIL_COND_V(!shader, RID());
if (shader->default_texture_parameter.has(p_name)) {
return shader->default_texture_parameter[p_name];
@@ -1498,7 +1498,7 @@ RID RendererStorageRD::shader_get_default_texture_param(RID p_shader, const Stri
}
Variant RendererStorageRD::shader_get_param_default(RID p_shader, const StringName &p_param) const {
- Shader *shader = shader_owner.getornull(p_shader);
+ Shader *shader = shader_owner.get_or_null(p_shader);
ERR_FAIL_COND_V(!shader, Variant());
if (shader->data) {
return shader->data->get_default_parameter(p_param);
@@ -1512,7 +1512,7 @@ void RendererStorageRD::shader_set_data_request_function(ShaderType p_shader_typ
}
RS::ShaderNativeSourceCode RendererStorageRD::shader_get_native_source_code(RID p_shader) const {
- Shader *shader = shader_owner.getornull(p_shader);
+ Shader *shader = shader_owner.get_or_null(p_shader);
ERR_FAIL_COND_V(!shader, RS::ShaderNativeSourceCode());
if (shader->data) {
return shader->data->get_native_source_code();
@@ -1527,7 +1527,7 @@ RID RendererStorageRD::material_allocate() {
}
void RendererStorageRD::material_initialize(RID p_rid) {
material_owner.initialize_rid(p_rid);
- Material *material = material_owner.getornull(p_rid);
+ Material *material = material_owner.get_or_null(p_rid);
material->self = p_rid;
}
@@ -1543,7 +1543,7 @@ void RendererStorageRD::_material_queue_update(Material *material, bool p_unifor
}
void RendererStorageRD::material_set_shader(RID p_material, RID p_shader) {
- Material *material = material_owner.getornull(p_material);
+ Material *material = material_owner.get_or_null(p_material);
ERR_FAIL_COND(!material);
if (material->data) {
@@ -1563,7 +1563,7 @@ void RendererStorageRD::material_set_shader(RID p_material, RID p_shader) {
return;
}
- Shader *shader = shader_owner.getornull(p_shader);
+ Shader *shader = shader_owner.get_or_null(p_shader);
ERR_FAIL_COND(!shader);
material->shader = shader;
material->shader_type = shader->type;
@@ -1586,7 +1586,7 @@ void RendererStorageRD::material_set_shader(RID p_material, RID p_shader) {
}
void RendererStorageRD::material_set_param(RID p_material, const StringName &p_param, const Variant &p_value) {
- Material *material = material_owner.getornull(p_material);
+ Material *material = material_owner.get_or_null(p_material);
ERR_FAIL_COND(!material);
if (p_value.get_type() == Variant::NIL) {
@@ -1605,7 +1605,7 @@ void RendererStorageRD::material_set_param(RID p_material, const StringName &p_p
}
Variant RendererStorageRD::material_get_param(RID p_material, const StringName &p_param) const {
- Material *material = material_owner.getornull(p_material);
+ Material *material = material_owner.get_or_null(p_material);
ERR_FAIL_COND_V(!material, Variant());
if (material->params.has(p_param)) {
return material->params[p_param];
@@ -1615,7 +1615,7 @@ Variant RendererStorageRD::material_get_param(RID p_material, const StringName &
}
void RendererStorageRD::material_set_next_pass(RID p_material, RID p_next_material) {
- Material *material = material_owner.getornull(p_material);
+ Material *material = material_owner.get_or_null(p_material);
ERR_FAIL_COND(!material);
if (material->next_pass == p_next_material) {
@@ -1631,7 +1631,7 @@ void RendererStorageRD::material_set_next_pass(RID p_material, RID p_next_materi
}
void RendererStorageRD::material_set_render_priority(RID p_material, int priority) {
- Material *material = material_owner.getornull(p_material);
+ Material *material = material_owner.get_or_null(p_material);
ERR_FAIL_COND(!material);
material->priority = priority;
if (material->data) {
@@ -1640,7 +1640,7 @@ void RendererStorageRD::material_set_render_priority(RID p_material, int priorit
}
bool RendererStorageRD::material_is_animated(RID p_material) {
- Material *material = material_owner.getornull(p_material);
+ Material *material = material_owner.get_or_null(p_material);
ERR_FAIL_COND_V(!material, false);
if (material->shader && material->shader->data) {
if (material->shader->data->is_animated()) {
@@ -1653,7 +1653,7 @@ bool RendererStorageRD::material_is_animated(RID p_material) {
}
bool RendererStorageRD::material_casts_shadows(RID p_material) {
- Material *material = material_owner.getornull(p_material);
+ Material *material = material_owner.get_or_null(p_material);
ERR_FAIL_COND_V(!material, true);
if (material->shader && material->shader->data) {
if (material->shader->data->casts_shadows()) {
@@ -1666,7 +1666,7 @@ bool RendererStorageRD::material_casts_shadows(RID p_material) {
}
void RendererStorageRD::material_get_instance_shader_parameters(RID p_material, List<InstanceShaderParam> *r_parameters) {
- Material *material = material_owner.getornull(p_material);
+ Material *material = material_owner.get_or_null(p_material);
ERR_FAIL_COND(!material);
if (material->shader && material->shader->data) {
material->shader->data->get_instance_param_list(r_parameters);
@@ -1678,7 +1678,7 @@ void RendererStorageRD::material_get_instance_shader_parameters(RID p_material,
}
void RendererStorageRD::material_update_dependency(RID p_material, DependencyTracker *p_instance) {
- Material *material = material_owner.getornull(p_material);
+ Material *material = material_owner.get_or_null(p_material);
ERR_FAIL_COND(!material);
p_instance->update_dependency(&material->dependency);
if (material->next_pass.is_valid()) {
@@ -2136,28 +2136,28 @@ _FORCE_INLINE_ static void _fill_std140_ubo_empty(ShaderLanguage::DataType type,
void RendererStorageRD::MaterialData::update_uniform_buffer(const Map<StringName, ShaderLanguage::ShaderNode::Uniform> &p_uniforms, const uint32_t *p_uniform_offsets, const Map<StringName, Variant> &p_parameters, uint8_t *p_buffer, uint32_t p_buffer_size, bool p_use_linear_color) {
bool uses_global_buffer = false;
- for (Map<StringName, ShaderLanguage::ShaderNode::Uniform>::Element *E = p_uniforms.front(); E; E = E->next()) {
- if (E->get().order < 0) {
+ for (const KeyValue<StringName, ShaderLanguage::ShaderNode::Uniform> &E : p_uniforms) {
+ if (E.value.order < 0) {
continue; // texture, does not go here
}
- if (E->get().scope == ShaderLanguage::ShaderNode::Uniform::SCOPE_INSTANCE) {
+ if (E.value.scope == ShaderLanguage::ShaderNode::Uniform::SCOPE_INSTANCE) {
continue; //instance uniforms don't appear in the bufferr
}
- if (E->get().scope == ShaderLanguage::ShaderNode::Uniform::SCOPE_GLOBAL) {
+ if (E.value.scope == ShaderLanguage::ShaderNode::Uniform::SCOPE_GLOBAL) {
//this is a global variable, get the index to it
RendererStorageRD *rs = base_singleton;
- GlobalVariables::Variable *gv = rs->global_variables.variables.getptr(E->key());
+ GlobalVariables::Variable *gv = rs->global_variables.variables.getptr(E.key);
uint32_t index = 0;
if (gv) {
index = gv->buffer_index;
} else {
- WARN_PRINT("Shader uses global uniform '" + E->key() + "', but it was removed at some point. Material will not display correctly.");
+ WARN_PRINT("Shader uses global uniform '" + E.key + "', but it was removed at some point. Material will not display correctly.");
}
- uint32_t offset = p_uniform_offsets[E->get().order];
+ uint32_t offset = p_uniform_offsets[E.value.order];
uint32_t *intptr = (uint32_t *)&p_buffer[offset];
*intptr = index;
uses_global_buffer = true;
@@ -2165,30 +2165,30 @@ void RendererStorageRD::MaterialData::update_uniform_buffer(const Map<StringName
}
//regular uniform
- uint32_t offset = p_uniform_offsets[E->get().order];
+ uint32_t offset = p_uniform_offsets[E.value.order];
#ifdef DEBUG_ENABLED
- uint32_t size = ShaderLanguage::get_type_size(E->get().type);
+ uint32_t size = ShaderLanguage::get_type_size(E.value.type);
ERR_CONTINUE(offset + size > p_buffer_size);
#endif
uint8_t *data = &p_buffer[offset];
- const Map<StringName, Variant>::Element *V = p_parameters.find(E->key());
+ const Map<StringName, Variant>::Element *V = p_parameters.find(E.key);
if (V) {
//user provided
- _fill_std140_variant_ubo_value(E->get().type, V->get(), data, p_use_linear_color);
+ _fill_std140_variant_ubo_value(E.value.type, V->get(), data, p_use_linear_color);
- } else if (E->get().default_value.size()) {
+ } else if (E.value.default_value.size()) {
//default value
- _fill_std140_ubo_value(E->get().type, E->get().default_value, data);
- //value=E->get().default_value;
+ _fill_std140_ubo_value(E.value.type, E.value.default_value, data);
+ //value=E.value.default_value;
} else {
//zero because it was not provided
- if (E->get().type == ShaderLanguage::TYPE_VEC4 && E->get().hint == ShaderLanguage::ShaderNode::Uniform::HINT_COLOR) {
+ if (E.value.type == ShaderLanguage::TYPE_VEC4 && E.value.hint == ShaderLanguage::ShaderNode::Uniform::HINT_COLOR) {
//colors must be set as black, with alpha as 1.0
- _fill_std140_variant_ubo_value(E->get().type, Color(0, 0, 0, 1), data, p_use_linear_color);
+ _fill_std140_variant_ubo_value(E.value.type, Color(0, 0, 0, 1), data, p_use_linear_color);
} else {
//else just zero it out
- _fill_std140_ubo_empty(E->get().type, data);
+ _fill_std140_ubo_empty(E.value.type, data);
}
}
}
@@ -2215,8 +2215,8 @@ RendererStorageRD::MaterialData::~MaterialData() {
//unregister global textures
RendererStorageRD *rs = base_singleton;
- for (Map<StringName, uint64_t>::Element *E = used_global_textures.front(); E; E = E->next()) {
- GlobalVariables::Variable *v = rs->global_variables.variables.getptr(E->key());
+ for (const KeyValue<StringName, uint64_t> &E : used_global_textures) {
+ GlobalVariables::Variable *v = rs->global_variables.variables.getptr(E.key);
if (v) {
v->texture_materials.erase(self);
}
@@ -2309,7 +2309,7 @@ void RendererStorageRD::MaterialData::update_textures(const Map<StringName, Vari
} else {
bool srgb = p_use_linear_color && (p_texture_uniforms[i].hint == ShaderLanguage::ShaderNode::Uniform::HINT_ALBEDO || p_texture_uniforms[i].hint == ShaderLanguage::ShaderNode::Uniform::HINT_BLACK_ALBEDO);
- Texture *tex = singleton->texture_owner.getornull(texture);
+ Texture *tex = singleton->texture_owner.get_or_null(texture);
if (tex) {
rd_texture = (srgb && tex->rd_texture_srgb.is_valid()) ? tex->rd_texture_srgb : tex->rd_texture;
@@ -2470,14 +2470,14 @@ bool RendererStorageRD::MaterialData::update_parameters_uniform_set(const Map<St
void RendererStorageRD::_material_uniform_set_erased(const RID &p_set, void *p_material) {
RID rid = *(RID *)p_material;
- Material *material = base_singleton->material_owner.getornull(rid);
+ Material *material = base_singleton->material_owner.get_or_null(rid);
if (material) {
material->dependency.changed_notify(DEPENDENCY_CHANGED_MATERIAL);
}
}
void RendererStorageRD::material_force_update_textures(RID p_material, ShaderType p_shader_type) {
- Material *material = material_owner.getornull(p_material);
+ Material *material = material_owner.get_or_null(p_material);
if (material->shader_type != p_shader_type) {
return;
}
@@ -2518,7 +2518,7 @@ void RendererStorageRD::mesh_initialize(RID p_rid) {
void RendererStorageRD::mesh_set_blend_shape_count(RID p_mesh, int p_blend_shape_count) {
ERR_FAIL_COND(p_blend_shape_count < 0);
- Mesh *mesh = mesh_owner.getornull(p_mesh);
+ Mesh *mesh = mesh_owner.get_or_null(p_mesh);
ERR_FAIL_COND(!mesh);
ERR_FAIL_COND(mesh->surface_count > 0); //surfaces already exist
@@ -2528,7 +2528,7 @@ void RendererStorageRD::mesh_set_blend_shape_count(RID p_mesh, int p_blend_shape
/// Returns stride
void RendererStorageRD::mesh_add_surface(RID p_mesh, const RS::SurfaceData &p_surface) {
- Mesh *mesh = mesh_owner.getornull(p_mesh);
+ Mesh *mesh = mesh_owner.get_or_null(p_mesh);
ERR_FAIL_COND(!mesh);
ERR_FAIL_COND(mesh->surface_count == RS::MAX_MESH_SURFACES);
@@ -2732,13 +2732,13 @@ void RendererStorageRD::mesh_add_surface(RID p_mesh, const RS::SurfaceData &p_su
}
int RendererStorageRD::mesh_get_blend_shape_count(RID p_mesh) const {
- const Mesh *mesh = mesh_owner.getornull(p_mesh);
+ const Mesh *mesh = mesh_owner.get_or_null(p_mesh);
ERR_FAIL_COND_V(!mesh, -1);
return mesh->blend_shape_count;
}
void RendererStorageRD::mesh_set_blend_shape_mode(RID p_mesh, RS::BlendShapeMode p_mode) {
- Mesh *mesh = mesh_owner.getornull(p_mesh);
+ Mesh *mesh = mesh_owner.get_or_null(p_mesh);
ERR_FAIL_COND(!mesh);
ERR_FAIL_INDEX((int)p_mode, 2);
@@ -2746,13 +2746,13 @@ void RendererStorageRD::mesh_set_blend_shape_mode(RID p_mesh, RS::BlendShapeMode
}
RS::BlendShapeMode RendererStorageRD::mesh_get_blend_shape_mode(RID p_mesh) const {
- Mesh *mesh = mesh_owner.getornull(p_mesh);
+ Mesh *mesh = mesh_owner.get_or_null(p_mesh);
ERR_FAIL_COND_V(!mesh, RS::BLEND_SHAPE_MODE_NORMALIZED);
return mesh->blend_shape_mode;
}
void RendererStorageRD::mesh_surface_update_vertex_region(RID p_mesh, int p_surface, int p_offset, const Vector<uint8_t> &p_data) {
- Mesh *mesh = mesh_owner.getornull(p_mesh);
+ Mesh *mesh = mesh_owner.get_or_null(p_mesh);
ERR_FAIL_COND(!mesh);
ERR_FAIL_UNSIGNED_INDEX((uint32_t)p_surface, mesh->surface_count);
ERR_FAIL_COND(p_data.size() == 0);
@@ -2763,7 +2763,7 @@ void RendererStorageRD::mesh_surface_update_vertex_region(RID p_mesh, int p_surf
}
void RendererStorageRD::mesh_surface_update_attribute_region(RID p_mesh, int p_surface, int p_offset, const Vector<uint8_t> &p_data) {
- Mesh *mesh = mesh_owner.getornull(p_mesh);
+ Mesh *mesh = mesh_owner.get_or_null(p_mesh);
ERR_FAIL_COND(!mesh);
ERR_FAIL_UNSIGNED_INDEX((uint32_t)p_surface, mesh->surface_count);
ERR_FAIL_COND(p_data.size() == 0);
@@ -2775,7 +2775,7 @@ void RendererStorageRD::mesh_surface_update_attribute_region(RID p_mesh, int p_s
}
void RendererStorageRD::mesh_surface_update_skin_region(RID p_mesh, int p_surface, int p_offset, const Vector<uint8_t> &p_data) {
- Mesh *mesh = mesh_owner.getornull(p_mesh);
+ Mesh *mesh = mesh_owner.get_or_null(p_mesh);
ERR_FAIL_COND(!mesh);
ERR_FAIL_UNSIGNED_INDEX((uint32_t)p_surface, mesh->surface_count);
ERR_FAIL_COND(p_data.size() == 0);
@@ -2787,7 +2787,7 @@ void RendererStorageRD::mesh_surface_update_skin_region(RID p_mesh, int p_surfac
}
void RendererStorageRD::mesh_surface_set_material(RID p_mesh, int p_surface, RID p_material) {
- Mesh *mesh = mesh_owner.getornull(p_mesh);
+ Mesh *mesh = mesh_owner.get_or_null(p_mesh);
ERR_FAIL_COND(!mesh);
ERR_FAIL_UNSIGNED_INDEX((uint32_t)p_surface, mesh->surface_count);
mesh->surfaces[p_surface]->material = p_material;
@@ -2797,7 +2797,7 @@ void RendererStorageRD::mesh_surface_set_material(RID p_mesh, int p_surface, RID
}
RID RendererStorageRD::mesh_surface_get_material(RID p_mesh, int p_surface) const {
- Mesh *mesh = mesh_owner.getornull(p_mesh);
+ Mesh *mesh = mesh_owner.get_or_null(p_mesh);
ERR_FAIL_COND_V(!mesh, RID());
ERR_FAIL_UNSIGNED_INDEX_V((uint32_t)p_surface, mesh->surface_count, RID());
@@ -2805,7 +2805,7 @@ RID RendererStorageRD::mesh_surface_get_material(RID p_mesh, int p_surface) cons
}
RS::SurfaceData RendererStorageRD::mesh_get_surface(RID p_mesh, int p_surface) const {
- Mesh *mesh = mesh_owner.getornull(p_mesh);
+ Mesh *mesh = mesh_owner.get_or_null(p_mesh);
ERR_FAIL_COND_V(!mesh, RS::SurfaceData());
ERR_FAIL_UNSIGNED_INDEX_V((uint32_t)p_surface, mesh->surface_count, RS::SurfaceData());
@@ -2845,32 +2845,32 @@ RS::SurfaceData RendererStorageRD::mesh_get_surface(RID p_mesh, int p_surface) c
}
int RendererStorageRD::mesh_get_surface_count(RID p_mesh) const {
- Mesh *mesh = mesh_owner.getornull(p_mesh);
+ Mesh *mesh = mesh_owner.get_or_null(p_mesh);
ERR_FAIL_COND_V(!mesh, 0);
return mesh->surface_count;
}
void RendererStorageRD::mesh_set_custom_aabb(RID p_mesh, const AABB &p_aabb) {
- Mesh *mesh = mesh_owner.getornull(p_mesh);
+ Mesh *mesh = mesh_owner.get_or_null(p_mesh);
ERR_FAIL_COND(!mesh);
mesh->custom_aabb = p_aabb;
}
AABB RendererStorageRD::mesh_get_custom_aabb(RID p_mesh) const {
- Mesh *mesh = mesh_owner.getornull(p_mesh);
+ Mesh *mesh = mesh_owner.get_or_null(p_mesh);
ERR_FAIL_COND_V(!mesh, AABB());
return mesh->custom_aabb;
}
AABB RendererStorageRD::mesh_get_aabb(RID p_mesh, RID p_skeleton) {
- Mesh *mesh = mesh_owner.getornull(p_mesh);
+ Mesh *mesh = mesh_owner.get_or_null(p_mesh);
ERR_FAIL_COND_V(!mesh, AABB());
if (mesh->custom_aabb != AABB()) {
return mesh->custom_aabb;
}
- Skeleton *skeleton = skeleton_owner.getornull(p_skeleton);
+ Skeleton *skeleton = skeleton_owner.get_or_null(p_skeleton);
if (!skeleton || skeleton->size == 0) {
return mesh->aabb;
@@ -2968,16 +2968,16 @@ AABB RendererStorageRD::mesh_get_aabb(RID p_mesh, RID p_skeleton) {
}
void RendererStorageRD::mesh_set_shadow_mesh(RID p_mesh, RID p_shadow_mesh) {
- Mesh *mesh = mesh_owner.getornull(p_mesh);
+ Mesh *mesh = mesh_owner.get_or_null(p_mesh);
ERR_FAIL_COND(!mesh);
- Mesh *shadow_mesh = mesh_owner.getornull(mesh->shadow_mesh);
+ Mesh *shadow_mesh = mesh_owner.get_or_null(mesh->shadow_mesh);
if (shadow_mesh) {
shadow_mesh->shadow_owners.erase(mesh);
}
mesh->shadow_mesh = p_shadow_mesh;
- shadow_mesh = mesh_owner.getornull(mesh->shadow_mesh);
+ shadow_mesh = mesh_owner.get_or_null(mesh->shadow_mesh);
if (shadow_mesh) {
shadow_mesh->shadow_owners.insert(mesh);
@@ -2987,7 +2987,7 @@ void RendererStorageRD::mesh_set_shadow_mesh(RID p_mesh, RID p_shadow_mesh) {
}
void RendererStorageRD::mesh_clear(RID p_mesh) {
- Mesh *mesh = mesh_owner.getornull(p_mesh);
+ Mesh *mesh = mesh_owner.get_or_null(p_mesh);
ERR_FAIL_COND(!mesh);
for (uint32_t i = 0; i < mesh->surface_count; i++) {
Mesh::Surface &s = *mesh->surfaces[i];
@@ -3041,7 +3041,7 @@ void RendererStorageRD::mesh_clear(RID p_mesh) {
}
bool RendererStorageRD::mesh_needs_instance(RID p_mesh, bool p_has_skeleton) {
- Mesh *mesh = mesh_owner.getornull(p_mesh);
+ Mesh *mesh = mesh_owner.get_or_null(p_mesh);
ERR_FAIL_COND_V(!mesh, false);
return mesh->blend_shape_count > 0 || (mesh->has_bone_weights && p_has_skeleton);
@@ -3050,11 +3050,11 @@ bool RendererStorageRD::mesh_needs_instance(RID p_mesh, bool p_has_skeleton) {
/* MESH INSTANCE */
RID RendererStorageRD::mesh_instance_create(RID p_base) {
- Mesh *mesh = mesh_owner.getornull(p_base);
+ Mesh *mesh = mesh_owner.get_or_null(p_base);
ERR_FAIL_COND_V(!mesh, RID());
RID rid = mesh_instance_owner.make_rid();
- MeshInstance *mi = mesh_instance_owner.getornull(rid);
+ MeshInstance *mi = mesh_instance_owner.get_or_null(rid);
mi->mesh = mesh;
@@ -3069,7 +3069,7 @@ RID RendererStorageRD::mesh_instance_create(RID p_base) {
return rid;
}
void RendererStorageRD::mesh_instance_set_skeleton(RID p_mesh_instance, RID p_skeleton) {
- MeshInstance *mi = mesh_instance_owner.getornull(p_mesh_instance);
+ MeshInstance *mi = mesh_instance_owner.get_or_null(p_mesh_instance);
if (mi->skeleton == p_skeleton) {
return;
}
@@ -3079,7 +3079,7 @@ void RendererStorageRD::mesh_instance_set_skeleton(RID p_mesh_instance, RID p_sk
}
void RendererStorageRD::mesh_instance_set_blend_shape_weight(RID p_mesh_instance, int p_shape, float p_weight) {
- MeshInstance *mi = mesh_instance_owner.getornull(p_mesh_instance);
+ MeshInstance *mi = mesh_instance_owner.get_or_null(p_mesh_instance);
ERR_FAIL_COND(!mi);
ERR_FAIL_INDEX(p_shape, (int)mi->blend_weights.size());
mi->blend_weights[p_shape] = p_weight;
@@ -3151,7 +3151,7 @@ void RendererStorageRD::_mesh_instance_add_surface(MeshInstance *mi, Mesh *mesh,
}
void RendererStorageRD::mesh_instance_check_for_update(RID p_mesh_instance) {
- MeshInstance *mi = mesh_instance_owner.getornull(p_mesh_instance);
+ MeshInstance *mi = mesh_instance_owner.get_or_null(p_mesh_instance);
bool needs_update = mi->dirty;
@@ -3165,7 +3165,7 @@ void RendererStorageRD::mesh_instance_check_for_update(RID p_mesh_instance) {
}
if (!needs_update && mi->skeleton.is_valid()) {
- Skeleton *sk = skeleton_owner.getornull(mi->skeleton);
+ Skeleton *sk = skeleton_owner.get_or_null(mi->skeleton);
if (sk && sk->version != mi->skeleton_version) {
needs_update = true;
}
@@ -3196,7 +3196,7 @@ void RendererStorageRD::update_mesh_instances() {
while (dirty_mesh_instance_arrays.first()) {
MeshInstance *mi = dirty_mesh_instance_arrays.first()->self();
- Skeleton *sk = skeleton_owner.getornull(mi->skeleton);
+ Skeleton *sk = skeleton_owner.get_or_null(mi->skeleton);
for (uint32_t i = 0; i < mi->surfaces.size(); i++) {
if (mi->surfaces[i].uniform_set == RID() || mi->mesh->surfaces[i]->uniform_set == RID()) {
@@ -3443,7 +3443,7 @@ void RendererStorageRD::multimesh_initialize(RID p_rid) {
}
void RendererStorageRD::multimesh_allocate_data(RID p_multimesh, int p_instances, RS::MultimeshTransformFormat p_transform_format, bool p_use_colors, bool p_use_custom_data) {
- MultiMesh *multimesh = multimesh_owner.getornull(p_multimesh);
+ MultiMesh *multimesh = multimesh_owner.get_or_null(p_multimesh);
ERR_FAIL_COND(!multimesh);
if (multimesh->instances == p_instances && multimesh->xform_format == p_transform_format && multimesh->uses_colors == p_use_colors && multimesh->uses_custom_data == p_use_custom_data) {
@@ -3486,13 +3486,13 @@ void RendererStorageRD::multimesh_allocate_data(RID p_multimesh, int p_instances
}
int RendererStorageRD::multimesh_get_instance_count(RID p_multimesh) const {
- MultiMesh *multimesh = multimesh_owner.getornull(p_multimesh);
+ MultiMesh *multimesh = multimesh_owner.get_or_null(p_multimesh);
ERR_FAIL_COND_V(!multimesh, 0);
return multimesh->instances;
}
void RendererStorageRD::multimesh_set_mesh(RID p_multimesh, RID p_mesh) {
- MultiMesh *multimesh = multimesh_owner.getornull(p_multimesh);
+ MultiMesh *multimesh = multimesh_owner.get_or_null(p_multimesh);
ERR_FAIL_COND(!multimesh);
if (multimesh->mesh == p_mesh) {
return;
@@ -3638,7 +3638,7 @@ void RendererStorageRD::_multimesh_re_create_aabb(MultiMesh *multimesh, const fl
}
void RendererStorageRD::multimesh_instance_set_transform(RID p_multimesh, int p_index, const Transform3D &p_transform) {
- MultiMesh *multimesh = multimesh_owner.getornull(p_multimesh);
+ MultiMesh *multimesh = multimesh_owner.get_or_null(p_multimesh);
ERR_FAIL_COND(!multimesh);
ERR_FAIL_INDEX(p_index, multimesh->instances);
ERR_FAIL_COND(multimesh->xform_format != RS::MULTIMESH_TRANSFORM_3D);
@@ -3668,7 +3668,7 @@ void RendererStorageRD::multimesh_instance_set_transform(RID p_multimesh, int p_
}
void RendererStorageRD::multimesh_instance_set_transform_2d(RID p_multimesh, int p_index, const Transform2D &p_transform) {
- MultiMesh *multimesh = multimesh_owner.getornull(p_multimesh);
+ MultiMesh *multimesh = multimesh_owner.get_or_null(p_multimesh);
ERR_FAIL_COND(!multimesh);
ERR_FAIL_INDEX(p_index, multimesh->instances);
ERR_FAIL_COND(multimesh->xform_format != RS::MULTIMESH_TRANSFORM_2D);
@@ -3694,7 +3694,7 @@ void RendererStorageRD::multimesh_instance_set_transform_2d(RID p_multimesh, int
}
void RendererStorageRD::multimesh_instance_set_color(RID p_multimesh, int p_index, const Color &p_color) {
- MultiMesh *multimesh = multimesh_owner.getornull(p_multimesh);
+ MultiMesh *multimesh = multimesh_owner.get_or_null(p_multimesh);
ERR_FAIL_COND(!multimesh);
ERR_FAIL_INDEX(p_index, multimesh->instances);
ERR_FAIL_COND(!multimesh->uses_colors);
@@ -3716,7 +3716,7 @@ void RendererStorageRD::multimesh_instance_set_color(RID p_multimesh, int p_inde
}
void RendererStorageRD::multimesh_instance_set_custom_data(RID p_multimesh, int p_index, const Color &p_color) {
- MultiMesh *multimesh = multimesh_owner.getornull(p_multimesh);
+ MultiMesh *multimesh = multimesh_owner.get_or_null(p_multimesh);
ERR_FAIL_COND(!multimesh);
ERR_FAIL_INDEX(p_index, multimesh->instances);
ERR_FAIL_COND(!multimesh->uses_custom_data);
@@ -3738,14 +3738,14 @@ void RendererStorageRD::multimesh_instance_set_custom_data(RID p_multimesh, int
}
RID RendererStorageRD::multimesh_get_mesh(RID p_multimesh) const {
- MultiMesh *multimesh = multimesh_owner.getornull(p_multimesh);
+ MultiMesh *multimesh = multimesh_owner.get_or_null(p_multimesh);
ERR_FAIL_COND_V(!multimesh, RID());
return multimesh->mesh;
}
Transform3D RendererStorageRD::multimesh_instance_get_transform(RID p_multimesh, int p_index) const {
- MultiMesh *multimesh = multimesh_owner.getornull(p_multimesh);
+ MultiMesh *multimesh = multimesh_owner.get_or_null(p_multimesh);
ERR_FAIL_COND_V(!multimesh, Transform3D());
ERR_FAIL_INDEX_V(p_index, multimesh->instances, Transform3D());
ERR_FAIL_COND_V(multimesh->xform_format != RS::MULTIMESH_TRANSFORM_3D, Transform3D());
@@ -3776,7 +3776,7 @@ Transform3D RendererStorageRD::multimesh_instance_get_transform(RID p_multimesh,
}
Transform2D RendererStorageRD::multimesh_instance_get_transform_2d(RID p_multimesh, int p_index) const {
- MultiMesh *multimesh = multimesh_owner.getornull(p_multimesh);
+ MultiMesh *multimesh = multimesh_owner.get_or_null(p_multimesh);
ERR_FAIL_COND_V(!multimesh, Transform2D());
ERR_FAIL_INDEX_V(p_index, multimesh->instances, Transform2D());
ERR_FAIL_COND_V(multimesh->xform_format != RS::MULTIMESH_TRANSFORM_2D, Transform2D());
@@ -3801,7 +3801,7 @@ Transform2D RendererStorageRD::multimesh_instance_get_transform_2d(RID p_multime
}
Color RendererStorageRD::multimesh_instance_get_color(RID p_multimesh, int p_index) const {
- MultiMesh *multimesh = multimesh_owner.getornull(p_multimesh);
+ MultiMesh *multimesh = multimesh_owner.get_or_null(p_multimesh);
ERR_FAIL_COND_V(!multimesh, Color());
ERR_FAIL_INDEX_V(p_index, multimesh->instances, Color());
ERR_FAIL_COND_V(!multimesh->uses_colors, Color());
@@ -3824,7 +3824,7 @@ Color RendererStorageRD::multimesh_instance_get_color(RID p_multimesh, int p_ind
}
Color RendererStorageRD::multimesh_instance_get_custom_data(RID p_multimesh, int p_index) const {
- MultiMesh *multimesh = multimesh_owner.getornull(p_multimesh);
+ MultiMesh *multimesh = multimesh_owner.get_or_null(p_multimesh);
ERR_FAIL_COND_V(!multimesh, Color());
ERR_FAIL_INDEX_V(p_index, multimesh->instances, Color());
ERR_FAIL_COND_V(!multimesh->uses_custom_data, Color());
@@ -3847,7 +3847,7 @@ Color RendererStorageRD::multimesh_instance_get_custom_data(RID p_multimesh, int
}
void RendererStorageRD::multimesh_set_buffer(RID p_multimesh, const Vector<float> &p_buffer) {
- MultiMesh *multimesh = multimesh_owner.getornull(p_multimesh);
+ MultiMesh *multimesh = multimesh_owner.get_or_null(p_multimesh);
ERR_FAIL_COND(!multimesh);
ERR_FAIL_COND(p_buffer.size() != (multimesh->instances * (int)multimesh->stride_cache));
@@ -3880,7 +3880,7 @@ void RendererStorageRD::multimesh_set_buffer(RID p_multimesh, const Vector<float
}
Vector<float> RendererStorageRD::multimesh_get_buffer(RID p_multimesh) const {
- MultiMesh *multimesh = multimesh_owner.getornull(p_multimesh);
+ MultiMesh *multimesh = multimesh_owner.get_or_null(p_multimesh);
ERR_FAIL_COND_V(!multimesh, Vector<float>());
if (multimesh->buffer.is_null()) {
return Vector<float>();
@@ -3903,7 +3903,7 @@ Vector<float> RendererStorageRD::multimesh_get_buffer(RID p_multimesh) const {
}
void RendererStorageRD::multimesh_set_visible_instances(RID p_multimesh, int p_visible) {
- MultiMesh *multimesh = multimesh_owner.getornull(p_multimesh);
+ MultiMesh *multimesh = multimesh_owner.get_or_null(p_multimesh);
ERR_FAIL_COND(!multimesh);
ERR_FAIL_COND(p_visible < -1 || p_visible > multimesh->instances);
if (multimesh->visible_instances == p_visible) {
@@ -3921,13 +3921,13 @@ void RendererStorageRD::multimesh_set_visible_instances(RID p_multimesh, int p_v
}
int RendererStorageRD::multimesh_get_visible_instances(RID p_multimesh) const {
- MultiMesh *multimesh = multimesh_owner.getornull(p_multimesh);
+ MultiMesh *multimesh = multimesh_owner.get_or_null(p_multimesh);
ERR_FAIL_COND_V(!multimesh, 0);
return multimesh->visible_instances;
}
AABB RendererStorageRD::multimesh_get_aabb(RID p_multimesh) const {
- MultiMesh *multimesh = multimesh_owner.getornull(p_multimesh);
+ MultiMesh *multimesh = multimesh_owner.get_or_null(p_multimesh);
ERR_FAIL_COND_V(!multimesh, AABB());
if (multimesh->aabb_dirty) {
const_cast<RendererStorageRD *>(this)->_update_dirty_multimeshes();
@@ -3998,7 +3998,7 @@ void RendererStorageRD::particles_initialize(RID p_rid) {
}
void RendererStorageRD::particles_set_mode(RID p_particles, RS::ParticlesMode p_mode) {
- Particles *particles = particles_owner.getornull(p_particles);
+ Particles *particles = particles_owner.get_or_null(p_particles);
ERR_FAIL_COND(!particles);
if (particles->mode == p_mode) {
return;
@@ -4010,7 +4010,7 @@ void RendererStorageRD::particles_set_mode(RID p_particles, RS::ParticlesMode p_
}
void RendererStorageRD::particles_set_emitting(RID p_particles, bool p_emitting) {
- Particles *particles = particles_owner.getornull(p_particles);
+ Particles *particles = particles_owner.get_or_null(p_particles);
ERR_FAIL_COND(!particles);
particles->emitting = p_emitting;
@@ -4018,7 +4018,7 @@ void RendererStorageRD::particles_set_emitting(RID p_particles, bool p_emitting)
bool RendererStorageRD::particles_get_emitting(RID p_particles) {
ERR_FAIL_COND_V_MSG(RSG::threaded, false, "This function should never be used with threaded rendering, as it stalls the renderer.");
- Particles *particles = particles_owner.getornull(p_particles);
+ Particles *particles = particles_owner.get_or_null(p_particles);
ERR_FAIL_COND_V(!particles, false);
return particles->emitting;
@@ -4073,7 +4073,7 @@ void RendererStorageRD::_particles_free_data(Particles *particles) {
}
void RendererStorageRD::particles_set_amount(RID p_particles, int p_amount) {
- Particles *particles = particles_owner.getornull(p_particles);
+ Particles *particles = particles_owner.get_or_null(p_particles);
ERR_FAIL_COND(!particles);
if (particles->amount == p_amount) {
@@ -4093,48 +4093,48 @@ void RendererStorageRD::particles_set_amount(RID p_particles, int p_amount) {
}
void RendererStorageRD::particles_set_lifetime(RID p_particles, double p_lifetime) {
- Particles *particles = particles_owner.getornull(p_particles);
+ Particles *particles = particles_owner.get_or_null(p_particles);
ERR_FAIL_COND(!particles);
particles->lifetime = p_lifetime;
}
void RendererStorageRD::particles_set_one_shot(RID p_particles, bool p_one_shot) {
- Particles *particles = particles_owner.getornull(p_particles);
+ Particles *particles = particles_owner.get_or_null(p_particles);
ERR_FAIL_COND(!particles);
particles->one_shot = p_one_shot;
}
void RendererStorageRD::particles_set_pre_process_time(RID p_particles, double p_time) {
- Particles *particles = particles_owner.getornull(p_particles);
+ Particles *particles = particles_owner.get_or_null(p_particles);
ERR_FAIL_COND(!particles);
particles->pre_process_time = p_time;
}
void RendererStorageRD::particles_set_explosiveness_ratio(RID p_particles, real_t p_ratio) {
- Particles *particles = particles_owner.getornull(p_particles);
+ Particles *particles = particles_owner.get_or_null(p_particles);
ERR_FAIL_COND(!particles);
particles->explosiveness = p_ratio;
}
void RendererStorageRD::particles_set_randomness_ratio(RID p_particles, real_t p_ratio) {
- Particles *particles = particles_owner.getornull(p_particles);
+ Particles *particles = particles_owner.get_or_null(p_particles);
ERR_FAIL_COND(!particles);
particles->randomness = p_ratio;
}
void RendererStorageRD::particles_set_custom_aabb(RID p_particles, const AABB &p_aabb) {
- Particles *particles = particles_owner.getornull(p_particles);
+ Particles *particles = particles_owner.get_or_null(p_particles);
ERR_FAIL_COND(!particles);
particles->custom_aabb = p_aabb;
particles->dependency.changed_notify(DEPENDENCY_CHANGED_AABB);
}
void RendererStorageRD::particles_set_speed_scale(RID p_particles, double p_scale) {
- Particles *particles = particles_owner.getornull(p_particles);
+ Particles *particles = particles_owner.get_or_null(p_particles);
ERR_FAIL_COND(!particles);
particles->speed_scale = p_scale;
}
void RendererStorageRD::particles_set_use_local_coordinates(RID p_particles, bool p_enable) {
- Particles *particles = particles_owner.getornull(p_particles);
+ Particles *particles = particles_owner.get_or_null(p_particles);
ERR_FAIL_COND(!particles);
particles->use_local_coords = p_enable;
@@ -4142,7 +4142,7 @@ void RendererStorageRD::particles_set_use_local_coordinates(RID p_particles, boo
}
void RendererStorageRD::particles_set_fixed_fps(RID p_particles, int p_fps) {
- Particles *particles = particles_owner.getornull(p_particles);
+ Particles *particles = particles_owner.get_or_null(p_particles);
ERR_FAIL_COND(!particles);
particles->fixed_fps = p_fps;
@@ -4158,21 +4158,21 @@ void RendererStorageRD::particles_set_fixed_fps(RID p_particles, int p_fps) {
}
void RendererStorageRD::particles_set_interpolate(RID p_particles, bool p_enable) {
- Particles *particles = particles_owner.getornull(p_particles);
+ Particles *particles = particles_owner.get_or_null(p_particles);
ERR_FAIL_COND(!particles);
particles->interpolate = p_enable;
}
void RendererStorageRD::particles_set_fractional_delta(RID p_particles, bool p_enable) {
- Particles *particles = particles_owner.getornull(p_particles);
+ Particles *particles = particles_owner.get_or_null(p_particles);
ERR_FAIL_COND(!particles);
particles->fractional_delta = p_enable;
}
void RendererStorageRD::particles_set_trails(RID p_particles, bool p_enable, double p_length) {
- Particles *particles = particles_owner.getornull(p_particles);
+ Particles *particles = particles_owner.get_or_null(p_particles);
ERR_FAIL_COND(!particles);
ERR_FAIL_COND(p_length < 0.1);
p_length = MIN(10.0, p_length);
@@ -4191,7 +4191,7 @@ void RendererStorageRD::particles_set_trails(RID p_particles, bool p_enable, dou
}
void RendererStorageRD::particles_set_trail_bind_poses(RID p_particles, const Vector<Transform3D> &p_bind_poses) {
- Particles *particles = particles_owner.getornull(p_particles);
+ Particles *particles = particles_owner.get_or_null(p_particles);
ERR_FAIL_COND(!particles);
if (particles->trail_bind_pose_buffer.is_valid() && particles->trail_bind_poses.size() != p_bind_poses.size()) {
_particles_free_data(particles);
@@ -4208,49 +4208,49 @@ void RendererStorageRD::particles_set_trail_bind_poses(RID p_particles, const Ve
}
void RendererStorageRD::particles_set_collision_base_size(RID p_particles, real_t p_size) {
- Particles *particles = particles_owner.getornull(p_particles);
+ Particles *particles = particles_owner.get_or_null(p_particles);
ERR_FAIL_COND(!particles);
particles->collision_base_size = p_size;
}
void RendererStorageRD::particles_set_transform_align(RID p_particles, RS::ParticlesTransformAlign p_transform_align) {
- Particles *particles = particles_owner.getornull(p_particles);
+ Particles *particles = particles_owner.get_or_null(p_particles);
ERR_FAIL_COND(!particles);
particles->transform_align = p_transform_align;
}
void RendererStorageRD::particles_set_process_material(RID p_particles, RID p_material) {
- Particles *particles = particles_owner.getornull(p_particles);
+ Particles *particles = particles_owner.get_or_null(p_particles);
ERR_FAIL_COND(!particles);
particles->process_material = p_material;
}
void RendererStorageRD::particles_set_draw_order(RID p_particles, RS::ParticlesDrawOrder p_order) {
- Particles *particles = particles_owner.getornull(p_particles);
+ Particles *particles = particles_owner.get_or_null(p_particles);
ERR_FAIL_COND(!particles);
particles->draw_order = p_order;
}
void RendererStorageRD::particles_set_draw_passes(RID p_particles, int p_passes) {
- Particles *particles = particles_owner.getornull(p_particles);
+ Particles *particles = particles_owner.get_or_null(p_particles);
ERR_FAIL_COND(!particles);
particles->draw_passes.resize(p_passes);
}
void RendererStorageRD::particles_set_draw_pass_mesh(RID p_particles, int p_pass, RID p_mesh) {
- Particles *particles = particles_owner.getornull(p_particles);
+ Particles *particles = particles_owner.get_or_null(p_particles);
ERR_FAIL_COND(!particles);
ERR_FAIL_INDEX(p_pass, particles->draw_passes.size());
particles->draw_passes.write[p_pass] = p_mesh;
}
void RendererStorageRD::particles_restart(RID p_particles) {
- Particles *particles = particles_owner.getornull(p_particles);
+ Particles *particles = particles_owner.get_or_null(p_particles);
ERR_FAIL_COND(!particles);
particles->restart_request = true;
@@ -4274,7 +4274,7 @@ void RendererStorageRD::_particles_allocate_emission_buffer(Particles *particles
}
void RendererStorageRD::particles_set_subemitter(RID p_particles, RID p_subemitter_particles) {
- Particles *particles = particles_owner.getornull(p_particles);
+ Particles *particles = particles_owner.get_or_null(p_particles);
ERR_FAIL_COND(!particles);
ERR_FAIL_COND(p_particles == p_subemitter_particles);
@@ -4287,7 +4287,7 @@ void RendererStorageRD::particles_set_subemitter(RID p_particles, RID p_subemitt
}
void RendererStorageRD::particles_emit(RID p_particles, const Transform3D &p_transform, const Vector3 &p_velocity, const Color &p_color, const Color &p_custom, uint32_t p_emit_flags) {
- Particles *particles = particles_owner.getornull(p_particles);
+ Particles *particles = particles_owner.get_or_null(p_particles);
ERR_FAIL_COND(!particles);
ERR_FAIL_COND(particles->amount == 0);
@@ -4330,7 +4330,7 @@ void RendererStorageRD::particles_emit(RID p_particles, const Transform3D &p_tra
}
void RendererStorageRD::particles_request_process(RID p_particles) {
- Particles *particles = particles_owner.getornull(p_particles);
+ Particles *particles = particles_owner.get_or_null(p_particles);
ERR_FAIL_COND(!particles);
if (!particles->dirty) {
@@ -4345,7 +4345,7 @@ AABB RendererStorageRD::particles_get_current_aabb(RID p_particles) {
WARN_PRINT_ONCE("Calling this function with threaded rendering enabled stalls the renderer, use with care.");
}
- const Particles *particles = particles_owner.getornull(p_particles);
+ const Particles *particles = particles_owner.get_or_null(p_particles);
ERR_FAIL_COND_V(!particles, AABB());
int total_amount = particles->amount;
@@ -4393,28 +4393,28 @@ AABB RendererStorageRD::particles_get_current_aabb(RID p_particles) {
}
AABB RendererStorageRD::particles_get_aabb(RID p_particles) const {
- const Particles *particles = particles_owner.getornull(p_particles);
+ const Particles *particles = particles_owner.get_or_null(p_particles);
ERR_FAIL_COND_V(!particles, AABB());
return particles->custom_aabb;
}
void RendererStorageRD::particles_set_emission_transform(RID p_particles, const Transform3D &p_transform) {
- Particles *particles = particles_owner.getornull(p_particles);
+ Particles *particles = particles_owner.get_or_null(p_particles);
ERR_FAIL_COND(!particles);
particles->emission_transform = p_transform;
}
int RendererStorageRD::particles_get_draw_passes(RID p_particles) const {
- const Particles *particles = particles_owner.getornull(p_particles);
+ const Particles *particles = particles_owner.get_or_null(p_particles);
ERR_FAIL_COND_V(!particles, 0);
return particles->draw_passes.size();
}
RID RendererStorageRD::particles_get_draw_pass_mesh(RID p_particles, int p_pass) const {
- const Particles *particles = particles_owner.getornull(p_particles);
+ const Particles *particles = particles_owner.get_or_null(p_particles);
ERR_FAIL_COND_V(!particles, RID());
ERR_FAIL_INDEX_V(p_pass, particles->draw_passes.size(), RID());
@@ -4422,19 +4422,19 @@ RID RendererStorageRD::particles_get_draw_pass_mesh(RID p_particles, int p_pass)
}
void RendererStorageRD::particles_add_collision(RID p_particles, RID p_particles_collision_instance) {
- Particles *particles = particles_owner.getornull(p_particles);
+ Particles *particles = particles_owner.get_or_null(p_particles);
ERR_FAIL_COND(!particles);
particles->collisions.insert(p_particles_collision_instance);
}
void RendererStorageRD::particles_remove_collision(RID p_particles, RID p_particles_collision_instance) {
- Particles *particles = particles_owner.getornull(p_particles);
+ Particles *particles = particles_owner.get_or_null(p_particles);
ERR_FAIL_COND(!particles);
particles->collisions.erase(p_particles_collision_instance);
}
void RendererStorageRD::particles_set_canvas_sdf_collision(RID p_particles, bool p_enable, const Transform2D &p_xform, const Rect2 &p_to_screen, RID p_texture) {
- Particles *particles = particles_owner.getornull(p_particles);
+ Particles *particles = particles_owner.get_or_null(p_particles);
ERR_FAIL_COND(!particles);
particles->has_sdf_collision = p_enable;
particles->sdf_collision_transform = p_xform;
@@ -4476,7 +4476,7 @@ void RendererStorageRD::_particles_process(Particles *p_particles, double p_delt
RD::Uniform u;
u.uniform_type = RD::UNIFORM_TYPE_STORAGE_BUFFER;
u.binding = 3;
- Particles *sub_emitter = particles_owner.getornull(p_particles->sub_emitter);
+ Particles *sub_emitter = particles_owner.get_or_null(p_particles->sub_emitter);
if (sub_emitter) {
if (sub_emitter->emission_buffer == nullptr) { //no emission buffer, allocate emission buffer
_particles_allocate_emission_buffer(sub_emitter);
@@ -4593,11 +4593,11 @@ void RendererStorageRD::_particles_process(Particles *p_particles, double p_delt
uint32_t collision_3d_textures_used = 0;
for (const Set<RID>::Element *E = p_particles->collisions.front(); E; E = E->next()) {
- ParticlesCollisionInstance *pci = particles_collision_instance_owner.getornull(E->get());
+ ParticlesCollisionInstance *pci = particles_collision_instance_owner.get_or_null(E->get());
if (!pci || !pci->active) {
continue;
}
- ParticlesCollision *pc = particles_collision_owner.getornull(pci->collision);
+ ParticlesCollision *pc = particles_collision_owner.get_or_null(pci->collision);
ERR_CONTINUE(!pc);
Transform3D to_collider = pci->transform;
@@ -4745,7 +4745,7 @@ void RendererStorageRD::_particles_process(Particles *p_particles, double p_delt
for (uint32_t i = 0; i < ParticlesFrameParams::MAX_3D_TEXTURES; i++) {
RID rd_tex;
if (i < collision_3d_textures_used) {
- Texture *t = texture_owner.getornull(collision_3d_textures[i]);
+ Texture *t = texture_owner.get_or_null(collision_3d_textures[i]);
if (t && t->type == Texture::TYPE_3D) {
rd_tex = t->rd_texture;
}
@@ -4790,7 +4790,7 @@ void RendererStorageRD::_particles_process(Particles *p_particles, double p_delt
p_particles->force_sub_emit = false; //reset
- Particles *sub_emitter = particles_owner.getornull(p_particles->sub_emitter);
+ Particles *sub_emitter = particles_owner.get_or_null(p_particles->sub_emitter);
if (sub_emitter && sub_emitter->emission_storage_buffer.is_valid()) {
// print_line("updating subemitter buffer");
@@ -4870,7 +4870,7 @@ void RendererStorageRD::_particles_process(Particles *p_particles, double p_delt
}
void RendererStorageRD::particles_set_view_axis(RID p_particles, const Vector3 &p_axis, const Vector3 &p_up_axis) {
- Particles *particles = particles_owner.getornull(p_particles);
+ Particles *particles = particles_owner.get_or_null(p_particles);
ERR_FAIL_COND(!particles);
if (particles->draw_order != RS::PARTICLES_DRAW_ORDER_VIEW_DEPTH && particles->transform_align != RS::PARTICLES_TRANSFORM_ALIGN_Z_BILLBOARD && particles->transform_align != RS::PARTICLES_TRANSFORM_ALIGN_Z_BILLBOARD_Y_TO_VELOCITY) {
@@ -5228,7 +5228,7 @@ void RendererStorageRD::update_particles() {
bool RendererStorageRD::particles_is_inactive(RID p_particles) const {
ERR_FAIL_COND_V_MSG(RSG::threaded, false, "This function should never be used with threaded rendering, as it stalls the renderer.");
- const Particles *particles = particles_owner.getornull(p_particles);
+ const Particles *particles = particles_owner.get_or_null(p_particles);
ERR_FAIL_COND_V(!particles, false);
return !particles->emitting && particles->inactive;
}
@@ -5298,36 +5298,36 @@ void RendererStorageRD::ParticlesShaderData::set_default_texture_param(const Str
void RendererStorageRD::ParticlesShaderData::get_param_list(List<PropertyInfo> *p_param_list) const {
Map<int, StringName> order;
- for (Map<StringName, ShaderLanguage::ShaderNode::Uniform>::Element *E = uniforms.front(); E; E = E->next()) {
- if (E->get().scope == ShaderLanguage::ShaderNode::Uniform::SCOPE_GLOBAL || E->get().scope == ShaderLanguage::ShaderNode::Uniform::SCOPE_INSTANCE) {
+ for (const KeyValue<StringName, ShaderLanguage::ShaderNode::Uniform> &E : uniforms) {
+ if (E.value.scope == ShaderLanguage::ShaderNode::Uniform::SCOPE_GLOBAL || E.value.scope == ShaderLanguage::ShaderNode::Uniform::SCOPE_INSTANCE) {
continue;
}
- if (E->get().texture_order >= 0) {
- order[E->get().texture_order + 100000] = E->key();
+ if (E.value.texture_order >= 0) {
+ order[E.value.texture_order + 100000] = E.key;
} else {
- order[E->get().order] = E->key();
+ order[E.value.order] = E.key;
}
}
- for (Map<int, StringName>::Element *E = order.front(); E; E = E->next()) {
- PropertyInfo pi = ShaderLanguage::uniform_to_property_info(uniforms[E->get()]);
- pi.name = E->get();
+ for (const KeyValue<int, StringName> &E : order) {
+ PropertyInfo pi = ShaderLanguage::uniform_to_property_info(uniforms[E.value]);
+ pi.name = E.value;
p_param_list->push_back(pi);
}
}
void RendererStorageRD::ParticlesShaderData::get_instance_param_list(List<RendererStorage::InstanceShaderParam> *p_param_list) const {
- for (Map<StringName, ShaderLanguage::ShaderNode::Uniform>::Element *E = uniforms.front(); E; E = E->next()) {
- if (E->get().scope != ShaderLanguage::ShaderNode::Uniform::SCOPE_INSTANCE) {
+ for (const KeyValue<StringName, ShaderLanguage::ShaderNode::Uniform> &E : uniforms) {
+ if (E.value.scope != ShaderLanguage::ShaderNode::Uniform::SCOPE_INSTANCE) {
continue;
}
RendererStorage::InstanceShaderParam p;
- p.info = ShaderLanguage::uniform_to_property_info(E->get());
- p.info.name = E->key(); //supply name
- p.index = E->get().instance_index;
- p.default_value = ShaderLanguage::constant_value_to_variant(E->get().default_value, E->get().type, E->get().hint);
+ p.info = ShaderLanguage::uniform_to_property_info(E.value);
+ p.info.name = E.key; //supply name
+ p.index = E.value.instance_index;
+ p.default_value = ShaderLanguage::constant_value_to_variant(E.value.default_value, E.value.type, E.value.hint);
p_param_list->push_back(p);
}
}
@@ -5406,7 +5406,7 @@ void RendererStorageRD::particles_collision_initialize(RID p_rid) {
}
RID RendererStorageRD::particles_collision_get_heightfield_framebuffer(RID p_particles_collision) const {
- ParticlesCollision *particles_collision = particles_collision_owner.getornull(p_particles_collision);
+ ParticlesCollision *particles_collision = particles_collision_owner.get_or_null(p_particles_collision);
ERR_FAIL_COND_V(!particles_collision, RID());
ERR_FAIL_COND_V(particles_collision->type != RS::PARTICLES_COLLISION_TYPE_HEIGHTFIELD_COLLIDE, RID());
@@ -5441,7 +5441,7 @@ RID RendererStorageRD::particles_collision_get_heightfield_framebuffer(RID p_par
}
void RendererStorageRD::particles_collision_set_collision_type(RID p_particles_collision, RS::ParticlesCollisionType p_type) {
- ParticlesCollision *particles_collision = particles_collision_owner.getornull(p_particles_collision);
+ ParticlesCollision *particles_collision = particles_collision_owner.get_or_null(p_particles_collision);
ERR_FAIL_COND(!particles_collision);
if (p_type == particles_collision->type) {
@@ -5457,13 +5457,13 @@ void RendererStorageRD::particles_collision_set_collision_type(RID p_particles_c
}
void RendererStorageRD::particles_collision_set_cull_mask(RID p_particles_collision, uint32_t p_cull_mask) {
- ParticlesCollision *particles_collision = particles_collision_owner.getornull(p_particles_collision);
+ ParticlesCollision *particles_collision = particles_collision_owner.get_or_null(p_particles_collision);
ERR_FAIL_COND(!particles_collision);
particles_collision->cull_mask = p_cull_mask;
}
void RendererStorageRD::particles_collision_set_sphere_radius(RID p_particles_collision, real_t p_radius) {
- ParticlesCollision *particles_collision = particles_collision_owner.getornull(p_particles_collision);
+ ParticlesCollision *particles_collision = particles_collision_owner.get_or_null(p_particles_collision);
ERR_FAIL_COND(!particles_collision);
particles_collision->radius = p_radius;
@@ -5471,7 +5471,7 @@ void RendererStorageRD::particles_collision_set_sphere_radius(RID p_particles_co
}
void RendererStorageRD::particles_collision_set_box_extents(RID p_particles_collision, const Vector3 &p_extents) {
- ParticlesCollision *particles_collision = particles_collision_owner.getornull(p_particles_collision);
+ ParticlesCollision *particles_collision = particles_collision_owner.get_or_null(p_particles_collision);
ERR_FAIL_COND(!particles_collision);
particles_collision->extents = p_extents;
@@ -5479,41 +5479,41 @@ void RendererStorageRD::particles_collision_set_box_extents(RID p_particles_coll
}
void RendererStorageRD::particles_collision_set_attractor_strength(RID p_particles_collision, real_t p_strength) {
- ParticlesCollision *particles_collision = particles_collision_owner.getornull(p_particles_collision);
+ ParticlesCollision *particles_collision = particles_collision_owner.get_or_null(p_particles_collision);
ERR_FAIL_COND(!particles_collision);
particles_collision->attractor_strength = p_strength;
}
void RendererStorageRD::particles_collision_set_attractor_directionality(RID p_particles_collision, real_t p_directionality) {
- ParticlesCollision *particles_collision = particles_collision_owner.getornull(p_particles_collision);
+ ParticlesCollision *particles_collision = particles_collision_owner.get_or_null(p_particles_collision);
ERR_FAIL_COND(!particles_collision);
particles_collision->attractor_directionality = p_directionality;
}
void RendererStorageRD::particles_collision_set_attractor_attenuation(RID p_particles_collision, real_t p_curve) {
- ParticlesCollision *particles_collision = particles_collision_owner.getornull(p_particles_collision);
+ ParticlesCollision *particles_collision = particles_collision_owner.get_or_null(p_particles_collision);
ERR_FAIL_COND(!particles_collision);
particles_collision->attractor_attenuation = p_curve;
}
void RendererStorageRD::particles_collision_set_field_texture(RID p_particles_collision, RID p_texture) {
- ParticlesCollision *particles_collision = particles_collision_owner.getornull(p_particles_collision);
+ ParticlesCollision *particles_collision = particles_collision_owner.get_or_null(p_particles_collision);
ERR_FAIL_COND(!particles_collision);
particles_collision->field_texture = p_texture;
}
void RendererStorageRD::particles_collision_height_field_update(RID p_particles_collision) {
- ParticlesCollision *particles_collision = particles_collision_owner.getornull(p_particles_collision);
+ ParticlesCollision *particles_collision = particles_collision_owner.get_or_null(p_particles_collision);
ERR_FAIL_COND(!particles_collision);
particles_collision->dependency.changed_notify(DEPENDENCY_CHANGED_AABB);
}
void RendererStorageRD::particles_collision_set_height_field_resolution(RID p_particles_collision, RS::ParticlesCollisionHeightfieldResolution p_resolution) {
- ParticlesCollision *particles_collision = particles_collision_owner.getornull(p_particles_collision);
+ ParticlesCollision *particles_collision = particles_collision_owner.get_or_null(p_particles_collision);
ERR_FAIL_COND(!particles_collision);
ERR_FAIL_INDEX(p_resolution, RS::PARTICLES_COLLISION_HEIGHTFIELD_RESOLUTION_MAX);
@@ -5530,7 +5530,7 @@ void RendererStorageRD::particles_collision_set_height_field_resolution(RID p_pa
}
AABB RendererStorageRD::particles_collision_get_aabb(RID p_particles_collision) const {
- ParticlesCollision *particles_collision = particles_collision_owner.getornull(p_particles_collision);
+ ParticlesCollision *particles_collision = particles_collision_owner.get_or_null(p_particles_collision);
ERR_FAIL_COND_V(!particles_collision, AABB());
switch (particles_collision->type) {
@@ -5553,13 +5553,13 @@ AABB RendererStorageRD::particles_collision_get_aabb(RID p_particles_collision)
}
Vector3 RendererStorageRD::particles_collision_get_extents(RID p_particles_collision) const {
- const ParticlesCollision *particles_collision = particles_collision_owner.getornull(p_particles_collision);
+ const ParticlesCollision *particles_collision = particles_collision_owner.get_or_null(p_particles_collision);
ERR_FAIL_COND_V(!particles_collision, Vector3());
return particles_collision->extents;
}
bool RendererStorageRD::particles_collision_is_heightfield(RID p_particles_collision) const {
- const ParticlesCollision *particles_collision = particles_collision_owner.getornull(p_particles_collision);
+ const ParticlesCollision *particles_collision = particles_collision_owner.get_or_null(p_particles_collision);
ERR_FAIL_COND_V(!particles_collision, false);
return particles_collision->type == RS::PARTICLES_COLLISION_TYPE_HEIGHTFIELD_COLLIDE;
}
@@ -5570,12 +5570,12 @@ RID RendererStorageRD::particles_collision_instance_create(RID p_collision) {
return particles_collision_instance_owner.make_rid(pci);
}
void RendererStorageRD::particles_collision_instance_set_transform(RID p_collision_instance, const Transform3D &p_transform) {
- ParticlesCollisionInstance *pci = particles_collision_instance_owner.getornull(p_collision_instance);
+ ParticlesCollisionInstance *pci = particles_collision_instance_owner.get_or_null(p_collision_instance);
ERR_FAIL_COND(!pci);
pci->transform = p_transform;
}
void RendererStorageRD::particles_collision_instance_set_active(RID p_collision_instance, bool p_active) {
- ParticlesCollisionInstance *pci = particles_collision_instance_owner.getornull(p_collision_instance);
+ ParticlesCollisionInstance *pci = particles_collision_instance_owner.get_or_null(p_collision_instance);
ERR_FAIL_COND(!pci);
pci->active = p_active;
}
@@ -5589,25 +5589,25 @@ void RendererStorageRD::visibility_notifier_initialize(RID p_notifier) {
visibility_notifier_owner.initialize_rid(p_notifier, VisibilityNotifier());
}
void RendererStorageRD::visibility_notifier_set_aabb(RID p_notifier, const AABB &p_aabb) {
- VisibilityNotifier *vn = visibility_notifier_owner.getornull(p_notifier);
+ VisibilityNotifier *vn = visibility_notifier_owner.get_or_null(p_notifier);
ERR_FAIL_COND(!vn);
vn->aabb = p_aabb;
vn->dependency.changed_notify(DEPENDENCY_CHANGED_AABB);
}
void RendererStorageRD::visibility_notifier_set_callbacks(RID p_notifier, const Callable &p_enter_callbable, const Callable &p_exit_callable) {
- VisibilityNotifier *vn = visibility_notifier_owner.getornull(p_notifier);
+ VisibilityNotifier *vn = visibility_notifier_owner.get_or_null(p_notifier);
ERR_FAIL_COND(!vn);
vn->enter_callback = p_enter_callbable;
vn->exit_callback = p_exit_callable;
}
AABB RendererStorageRD::visibility_notifier_get_aabb(RID p_notifier) const {
- const VisibilityNotifier *vn = visibility_notifier_owner.getornull(p_notifier);
+ const VisibilityNotifier *vn = visibility_notifier_owner.get_or_null(p_notifier);
ERR_FAIL_COND_V(!vn, AABB());
return vn->aabb;
}
void RendererStorageRD::visibility_notifier_call(RID p_notifier, bool p_enter, bool p_deferred) {
- VisibilityNotifier *vn = visibility_notifier_owner.getornull(p_notifier);
+ VisibilityNotifier *vn = visibility_notifier_owner.get_or_null(p_notifier);
ERR_FAIL_COND(!vn);
if (p_enter) {
@@ -5651,7 +5651,7 @@ void RendererStorageRD::_skeleton_make_dirty(Skeleton *skeleton) {
}
void RendererStorageRD::skeleton_allocate_data(RID p_skeleton, int p_bones, bool p_2d_skeleton) {
- Skeleton *skeleton = skeleton_owner.getornull(p_skeleton);
+ Skeleton *skeleton = skeleton_owner.get_or_null(p_skeleton);
ERR_FAIL_COND(!skeleton);
ERR_FAIL_COND(p_bones < 0);
@@ -5694,14 +5694,14 @@ void RendererStorageRD::skeleton_allocate_data(RID p_skeleton, int p_bones, bool
}
int RendererStorageRD::skeleton_get_bone_count(RID p_skeleton) const {
- Skeleton *skeleton = skeleton_owner.getornull(p_skeleton);
+ Skeleton *skeleton = skeleton_owner.get_or_null(p_skeleton);
ERR_FAIL_COND_V(!skeleton, 0);
return skeleton->size;
}
void RendererStorageRD::skeleton_bone_set_transform(RID p_skeleton, int p_bone, const Transform3D &p_transform) {
- Skeleton *skeleton = skeleton_owner.getornull(p_skeleton);
+ Skeleton *skeleton = skeleton_owner.get_or_null(p_skeleton);
ERR_FAIL_COND(!skeleton);
ERR_FAIL_INDEX(p_bone, skeleton->size);
@@ -5726,7 +5726,7 @@ void RendererStorageRD::skeleton_bone_set_transform(RID p_skeleton, int p_bone,
}
Transform3D RendererStorageRD::skeleton_bone_get_transform(RID p_skeleton, int p_bone) const {
- Skeleton *skeleton = skeleton_owner.getornull(p_skeleton);
+ Skeleton *skeleton = skeleton_owner.get_or_null(p_skeleton);
ERR_FAIL_COND_V(!skeleton, Transform3D());
ERR_FAIL_INDEX_V(p_bone, skeleton->size, Transform3D());
@@ -5753,7 +5753,7 @@ Transform3D RendererStorageRD::skeleton_bone_get_transform(RID p_skeleton, int p
}
void RendererStorageRD::skeleton_bone_set_transform_2d(RID p_skeleton, int p_bone, const Transform2D &p_transform) {
- Skeleton *skeleton = skeleton_owner.getornull(p_skeleton);
+ Skeleton *skeleton = skeleton_owner.get_or_null(p_skeleton);
ERR_FAIL_COND(!skeleton);
ERR_FAIL_INDEX(p_bone, skeleton->size);
@@ -5774,7 +5774,7 @@ void RendererStorageRD::skeleton_bone_set_transform_2d(RID p_skeleton, int p_bon
}
Transform2D RendererStorageRD::skeleton_bone_get_transform_2d(RID p_skeleton, int p_bone) const {
- Skeleton *skeleton = skeleton_owner.getornull(p_skeleton);
+ Skeleton *skeleton = skeleton_owner.get_or_null(p_skeleton);
ERR_FAIL_COND_V(!skeleton, Transform2D());
ERR_FAIL_INDEX_V(p_bone, skeleton->size, Transform2D());
@@ -5794,7 +5794,7 @@ Transform2D RendererStorageRD::skeleton_bone_get_transform_2d(RID p_skeleton, in
}
void RendererStorageRD::skeleton_set_base_transform_2d(RID p_skeleton, const Transform2D &p_base_transform) {
- Skeleton *skeleton = skeleton_owner.getornull(p_skeleton);
+ Skeleton *skeleton = skeleton_owner.get_or_null(p_skeleton);
ERR_FAIL_COND(!skeleton->use_2d);
@@ -5873,14 +5873,14 @@ void RendererStorageRD::spot_light_initialize(RID p_light) {
}
void RendererStorageRD::light_set_color(RID p_light, const Color &p_color) {
- Light *light = light_owner.getornull(p_light);
+ Light *light = light_owner.get_or_null(p_light);
ERR_FAIL_COND(!light);
light->color = p_color;
}
void RendererStorageRD::light_set_param(RID p_light, RS::LightParam p_param, float p_value) {
- Light *light = light_owner.getornull(p_light);
+ Light *light = light_owner.get_or_null(p_light);
ERR_FAIL_COND(!light);
ERR_FAIL_INDEX(p_param, RS::LIGHT_PARAM_MAX);
@@ -5915,7 +5915,7 @@ void RendererStorageRD::light_set_param(RID p_light, RS::LightParam p_param, flo
}
void RendererStorageRD::light_set_shadow(RID p_light, bool p_enabled) {
- Light *light = light_owner.getornull(p_light);
+ Light *light = light_owner.get_or_null(p_light);
ERR_FAIL_COND(!light);
light->shadow = p_enabled;
@@ -5924,13 +5924,13 @@ void RendererStorageRD::light_set_shadow(RID p_light, bool p_enabled) {
}
void RendererStorageRD::light_set_shadow_color(RID p_light, const Color &p_color) {
- Light *light = light_owner.getornull(p_light);
+ Light *light = light_owner.get_or_null(p_light);
ERR_FAIL_COND(!light);
light->shadow_color = p_color;
}
void RendererStorageRD::light_set_projector(RID p_light, RID p_texture) {
- Light *light = light_owner.getornull(p_light);
+ Light *light = light_owner.get_or_null(p_light);
ERR_FAIL_COND(!light);
if (light->projector == p_texture) {
@@ -5952,14 +5952,14 @@ void RendererStorageRD::light_set_projector(RID p_light, RID p_texture) {
}
void RendererStorageRD::light_set_negative(RID p_light, bool p_enable) {
- Light *light = light_owner.getornull(p_light);
+ Light *light = light_owner.get_or_null(p_light);
ERR_FAIL_COND(!light);
light->negative = p_enable;
}
void RendererStorageRD::light_set_cull_mask(RID p_light, uint32_t p_mask) {
- Light *light = light_owner.getornull(p_light);
+ Light *light = light_owner.get_or_null(p_light);
ERR_FAIL_COND(!light);
light->cull_mask = p_mask;
@@ -5969,7 +5969,7 @@ void RendererStorageRD::light_set_cull_mask(RID p_light, uint32_t p_mask) {
}
void RendererStorageRD::light_set_reverse_cull_face_mode(RID p_light, bool p_enabled) {
- Light *light = light_owner.getornull(p_light);
+ Light *light = light_owner.get_or_null(p_light);
ERR_FAIL_COND(!light);
light->reverse_cull = p_enabled;
@@ -5979,7 +5979,7 @@ void RendererStorageRD::light_set_reverse_cull_face_mode(RID p_light, bool p_ena
}
void RendererStorageRD::light_set_bake_mode(RID p_light, RS::LightBakeMode p_bake_mode) {
- Light *light = light_owner.getornull(p_light);
+ Light *light = light_owner.get_or_null(p_light);
ERR_FAIL_COND(!light);
light->bake_mode = p_bake_mode;
@@ -5989,7 +5989,7 @@ void RendererStorageRD::light_set_bake_mode(RID p_light, RS::LightBakeMode p_bak
}
void RendererStorageRD::light_set_max_sdfgi_cascade(RID p_light, uint32_t p_cascade) {
- Light *light = light_owner.getornull(p_light);
+ Light *light = light_owner.get_or_null(p_light);
ERR_FAIL_COND(!light);
light->max_sdfgi_cascade = p_cascade;
@@ -5999,7 +5999,7 @@ void RendererStorageRD::light_set_max_sdfgi_cascade(RID p_light, uint32_t p_casc
}
void RendererStorageRD::light_omni_set_shadow_mode(RID p_light, RS::LightOmniShadowMode p_mode) {
- Light *light = light_owner.getornull(p_light);
+ Light *light = light_owner.get_or_null(p_light);
ERR_FAIL_COND(!light);
light->omni_shadow_mode = p_mode;
@@ -6009,14 +6009,14 @@ void RendererStorageRD::light_omni_set_shadow_mode(RID p_light, RS::LightOmniSha
}
RS::LightOmniShadowMode RendererStorageRD::light_omni_get_shadow_mode(RID p_light) {
- const Light *light = light_owner.getornull(p_light);
+ const Light *light = light_owner.get_or_null(p_light);
ERR_FAIL_COND_V(!light, RS::LIGHT_OMNI_SHADOW_CUBE);
return light->omni_shadow_mode;
}
void RendererStorageRD::light_directional_set_shadow_mode(RID p_light, RS::LightDirectionalShadowMode p_mode) {
- Light *light = light_owner.getornull(p_light);
+ Light *light = light_owner.get_or_null(p_light);
ERR_FAIL_COND(!light);
light->directional_shadow_mode = p_mode;
@@ -6025,7 +6025,7 @@ void RendererStorageRD::light_directional_set_shadow_mode(RID p_light, RS::Light
}
void RendererStorageRD::light_directional_set_blend_splits(RID p_light, bool p_enable) {
- Light *light = light_owner.getornull(p_light);
+ Light *light = light_owner.get_or_null(p_light);
ERR_FAIL_COND(!light);
light->directional_blend_splits = p_enable;
@@ -6034,56 +6034,56 @@ void RendererStorageRD::light_directional_set_blend_splits(RID p_light, bool p_e
}
bool RendererStorageRD::light_directional_get_blend_splits(RID p_light) const {
- const Light *light = light_owner.getornull(p_light);
+ const Light *light = light_owner.get_or_null(p_light);
ERR_FAIL_COND_V(!light, false);
return light->directional_blend_splits;
}
void RendererStorageRD::light_directional_set_sky_only(RID p_light, bool p_sky_only) {
- Light *light = light_owner.getornull(p_light);
+ Light *light = light_owner.get_or_null(p_light);
ERR_FAIL_COND(!light);
light->directional_sky_only = p_sky_only;
}
bool RendererStorageRD::light_directional_is_sky_only(RID p_light) const {
- const Light *light = light_owner.getornull(p_light);
+ const Light *light = light_owner.get_or_null(p_light);
ERR_FAIL_COND_V(!light, false);
return light->directional_sky_only;
}
RS::LightDirectionalShadowMode RendererStorageRD::light_directional_get_shadow_mode(RID p_light) {
- const Light *light = light_owner.getornull(p_light);
+ const Light *light = light_owner.get_or_null(p_light);
ERR_FAIL_COND_V(!light, RS::LIGHT_DIRECTIONAL_SHADOW_ORTHOGONAL);
return light->directional_shadow_mode;
}
uint32_t RendererStorageRD::light_get_max_sdfgi_cascade(RID p_light) {
- const Light *light = light_owner.getornull(p_light);
+ const Light *light = light_owner.get_or_null(p_light);
ERR_FAIL_COND_V(!light, 0);
return light->max_sdfgi_cascade;
}
RS::LightBakeMode RendererStorageRD::light_get_bake_mode(RID p_light) {
- const Light *light = light_owner.getornull(p_light);
+ const Light *light = light_owner.get_or_null(p_light);
ERR_FAIL_COND_V(!light, RS::LIGHT_BAKE_DISABLED);
return light->bake_mode;
}
uint64_t RendererStorageRD::light_get_version(RID p_light) const {
- const Light *light = light_owner.getornull(p_light);
+ const Light *light = light_owner.get_or_null(p_light);
ERR_FAIL_COND_V(!light, 0);
return light->version;
}
AABB RendererStorageRD::light_get_aabb(RID p_light) const {
- const Light *light = light_owner.getornull(p_light);
+ const Light *light = light_owner.get_or_null(p_light);
ERR_FAIL_COND_V(!light, AABB());
switch (light->type) {
@@ -6114,7 +6114,7 @@ void RendererStorageRD::reflection_probe_initialize(RID p_reflection_probe) {
}
void RendererStorageRD::reflection_probe_set_update_mode(RID p_probe, RS::ReflectionProbeUpdateMode p_mode) {
- ReflectionProbe *reflection_probe = reflection_probe_owner.getornull(p_probe);
+ ReflectionProbe *reflection_probe = reflection_probe_owner.get_or_null(p_probe);
ERR_FAIL_COND(!reflection_probe);
reflection_probe->update_mode = p_mode;
@@ -6122,35 +6122,35 @@ void RendererStorageRD::reflection_probe_set_update_mode(RID p_probe, RS::Reflec
}
void RendererStorageRD::reflection_probe_set_intensity(RID p_probe, float p_intensity) {
- ReflectionProbe *reflection_probe = reflection_probe_owner.getornull(p_probe);
+ ReflectionProbe *reflection_probe = reflection_probe_owner.get_or_null(p_probe);
ERR_FAIL_COND(!reflection_probe);
reflection_probe->intensity = p_intensity;
}
void RendererStorageRD::reflection_probe_set_ambient_mode(RID p_probe, RS::ReflectionProbeAmbientMode p_mode) {
- ReflectionProbe *reflection_probe = reflection_probe_owner.getornull(p_probe);
+ ReflectionProbe *reflection_probe = reflection_probe_owner.get_or_null(p_probe);
ERR_FAIL_COND(!reflection_probe);
reflection_probe->ambient_mode = p_mode;
}
void RendererStorageRD::reflection_probe_set_ambient_color(RID p_probe, const Color &p_color) {
- ReflectionProbe *reflection_probe = reflection_probe_owner.getornull(p_probe);
+ ReflectionProbe *reflection_probe = reflection_probe_owner.get_or_null(p_probe);
ERR_FAIL_COND(!reflection_probe);
reflection_probe->ambient_color = p_color;
}
void RendererStorageRD::reflection_probe_set_ambient_energy(RID p_probe, float p_energy) {
- ReflectionProbe *reflection_probe = reflection_probe_owner.getornull(p_probe);
+ ReflectionProbe *reflection_probe = reflection_probe_owner.get_or_null(p_probe);
ERR_FAIL_COND(!reflection_probe);
reflection_probe->ambient_color_energy = p_energy;
}
void RendererStorageRD::reflection_probe_set_max_distance(RID p_probe, float p_distance) {
- ReflectionProbe *reflection_probe = reflection_probe_owner.getornull(p_probe);
+ ReflectionProbe *reflection_probe = reflection_probe_owner.get_or_null(p_probe);
ERR_FAIL_COND(!reflection_probe);
reflection_probe->max_distance = p_distance;
@@ -6159,7 +6159,7 @@ void RendererStorageRD::reflection_probe_set_max_distance(RID p_probe, float p_d
}
void RendererStorageRD::reflection_probe_set_extents(RID p_probe, const Vector3 &p_extents) {
- ReflectionProbe *reflection_probe = reflection_probe_owner.getornull(p_probe);
+ ReflectionProbe *reflection_probe = reflection_probe_owner.get_or_null(p_probe);
ERR_FAIL_COND(!reflection_probe);
if (reflection_probe->extents == p_extents) {
@@ -6170,7 +6170,7 @@ void RendererStorageRD::reflection_probe_set_extents(RID p_probe, const Vector3
}
void RendererStorageRD::reflection_probe_set_origin_offset(RID p_probe, const Vector3 &p_offset) {
- ReflectionProbe *reflection_probe = reflection_probe_owner.getornull(p_probe);
+ ReflectionProbe *reflection_probe = reflection_probe_owner.get_or_null(p_probe);
ERR_FAIL_COND(!reflection_probe);
reflection_probe->origin_offset = p_offset;
@@ -6178,7 +6178,7 @@ void RendererStorageRD::reflection_probe_set_origin_offset(RID p_probe, const Ve
}
void RendererStorageRD::reflection_probe_set_as_interior(RID p_probe, bool p_enable) {
- ReflectionProbe *reflection_probe = reflection_probe_owner.getornull(p_probe);
+ ReflectionProbe *reflection_probe = reflection_probe_owner.get_or_null(p_probe);
ERR_FAIL_COND(!reflection_probe);
reflection_probe->interior = p_enable;
@@ -6186,14 +6186,14 @@ void RendererStorageRD::reflection_probe_set_as_interior(RID p_probe, bool p_ena
}
void RendererStorageRD::reflection_probe_set_enable_box_projection(RID p_probe, bool p_enable) {
- ReflectionProbe *reflection_probe = reflection_probe_owner.getornull(p_probe);
+ ReflectionProbe *reflection_probe = reflection_probe_owner.get_or_null(p_probe);
ERR_FAIL_COND(!reflection_probe);
reflection_probe->box_projection = p_enable;
}
void RendererStorageRD::reflection_probe_set_enable_shadows(RID p_probe, bool p_enable) {
- ReflectionProbe *reflection_probe = reflection_probe_owner.getornull(p_probe);
+ ReflectionProbe *reflection_probe = reflection_probe_owner.get_or_null(p_probe);
ERR_FAIL_COND(!reflection_probe);
reflection_probe->enable_shadows = p_enable;
@@ -6201,7 +6201,7 @@ void RendererStorageRD::reflection_probe_set_enable_shadows(RID p_probe, bool p_
}
void RendererStorageRD::reflection_probe_set_cull_mask(RID p_probe, uint32_t p_layers) {
- ReflectionProbe *reflection_probe = reflection_probe_owner.getornull(p_probe);
+ ReflectionProbe *reflection_probe = reflection_probe_owner.get_or_null(p_probe);
ERR_FAIL_COND(!reflection_probe);
reflection_probe->cull_mask = p_layers;
@@ -6209,7 +6209,7 @@ void RendererStorageRD::reflection_probe_set_cull_mask(RID p_probe, uint32_t p_l
}
void RendererStorageRD::reflection_probe_set_resolution(RID p_probe, int p_resolution) {
- ReflectionProbe *reflection_probe = reflection_probe_owner.getornull(p_probe);
+ ReflectionProbe *reflection_probe = reflection_probe_owner.get_or_null(p_probe);
ERR_FAIL_COND(!reflection_probe);
ERR_FAIL_COND(p_resolution < 32);
@@ -6217,7 +6217,7 @@ void RendererStorageRD::reflection_probe_set_resolution(RID p_probe, int p_resol
}
void RendererStorageRD::reflection_probe_set_lod_threshold(RID p_probe, float p_ratio) {
- ReflectionProbe *reflection_probe = reflection_probe_owner.getornull(p_probe);
+ ReflectionProbe *reflection_probe = reflection_probe_owner.get_or_null(p_probe);
ERR_FAIL_COND(!reflection_probe);
reflection_probe->lod_threshold = p_ratio;
@@ -6226,7 +6226,7 @@ void RendererStorageRD::reflection_probe_set_lod_threshold(RID p_probe, float p_
}
AABB RendererStorageRD::reflection_probe_get_aabb(RID p_probe) const {
- const ReflectionProbe *reflection_probe = reflection_probe_owner.getornull(p_probe);
+ const ReflectionProbe *reflection_probe = reflection_probe_owner.get_or_null(p_probe);
ERR_FAIL_COND_V(!reflection_probe, AABB());
AABB aabb;
@@ -6237,96 +6237,96 @@ AABB RendererStorageRD::reflection_probe_get_aabb(RID p_probe) const {
}
RS::ReflectionProbeUpdateMode RendererStorageRD::reflection_probe_get_update_mode(RID p_probe) const {
- const ReflectionProbe *reflection_probe = reflection_probe_owner.getornull(p_probe);
+ const ReflectionProbe *reflection_probe = reflection_probe_owner.get_or_null(p_probe);
ERR_FAIL_COND_V(!reflection_probe, RS::REFLECTION_PROBE_UPDATE_ALWAYS);
return reflection_probe->update_mode;
}
uint32_t RendererStorageRD::reflection_probe_get_cull_mask(RID p_probe) const {
- const ReflectionProbe *reflection_probe = reflection_probe_owner.getornull(p_probe);
+ const ReflectionProbe *reflection_probe = reflection_probe_owner.get_or_null(p_probe);
ERR_FAIL_COND_V(!reflection_probe, 0);
return reflection_probe->cull_mask;
}
Vector3 RendererStorageRD::reflection_probe_get_extents(RID p_probe) const {
- const ReflectionProbe *reflection_probe = reflection_probe_owner.getornull(p_probe);
+ const ReflectionProbe *reflection_probe = reflection_probe_owner.get_or_null(p_probe);
ERR_FAIL_COND_V(!reflection_probe, Vector3());
return reflection_probe->extents;
}
Vector3 RendererStorageRD::reflection_probe_get_origin_offset(RID p_probe) const {
- const ReflectionProbe *reflection_probe = reflection_probe_owner.getornull(p_probe);
+ const ReflectionProbe *reflection_probe = reflection_probe_owner.get_or_null(p_probe);
ERR_FAIL_COND_V(!reflection_probe, Vector3());
return reflection_probe->origin_offset;
}
bool RendererStorageRD::reflection_probe_renders_shadows(RID p_probe) const {
- const ReflectionProbe *reflection_probe = reflection_probe_owner.getornull(p_probe);
+ const ReflectionProbe *reflection_probe = reflection_probe_owner.get_or_null(p_probe);
ERR_FAIL_COND_V(!reflection_probe, false);
return reflection_probe->enable_shadows;
}
float RendererStorageRD::reflection_probe_get_origin_max_distance(RID p_probe) const {
- const ReflectionProbe *reflection_probe = reflection_probe_owner.getornull(p_probe);
+ const ReflectionProbe *reflection_probe = reflection_probe_owner.get_or_null(p_probe);
ERR_FAIL_COND_V(!reflection_probe, 0);
return reflection_probe->max_distance;
}
float RendererStorageRD::reflection_probe_get_lod_threshold(RID p_probe) const {
- const ReflectionProbe *reflection_probe = reflection_probe_owner.getornull(p_probe);
+ const ReflectionProbe *reflection_probe = reflection_probe_owner.get_or_null(p_probe);
ERR_FAIL_COND_V(!reflection_probe, 0);
return reflection_probe->lod_threshold;
}
int RendererStorageRD::reflection_probe_get_resolution(RID p_probe) const {
- const ReflectionProbe *reflection_probe = reflection_probe_owner.getornull(p_probe);
+ const ReflectionProbe *reflection_probe = reflection_probe_owner.get_or_null(p_probe);
ERR_FAIL_COND_V(!reflection_probe, 0);
return reflection_probe->resolution;
}
float RendererStorageRD::reflection_probe_get_intensity(RID p_probe) const {
- const ReflectionProbe *reflection_probe = reflection_probe_owner.getornull(p_probe);
+ const ReflectionProbe *reflection_probe = reflection_probe_owner.get_or_null(p_probe);
ERR_FAIL_COND_V(!reflection_probe, 0);
return reflection_probe->intensity;
}
bool RendererStorageRD::reflection_probe_is_interior(RID p_probe) const {
- const ReflectionProbe *reflection_probe = reflection_probe_owner.getornull(p_probe);
+ const ReflectionProbe *reflection_probe = reflection_probe_owner.get_or_null(p_probe);
ERR_FAIL_COND_V(!reflection_probe, false);
return reflection_probe->interior;
}
bool RendererStorageRD::reflection_probe_is_box_projection(RID p_probe) const {
- const ReflectionProbe *reflection_probe = reflection_probe_owner.getornull(p_probe);
+ const ReflectionProbe *reflection_probe = reflection_probe_owner.get_or_null(p_probe);
ERR_FAIL_COND_V(!reflection_probe, false);
return reflection_probe->box_projection;
}
RS::ReflectionProbeAmbientMode RendererStorageRD::reflection_probe_get_ambient_mode(RID p_probe) const {
- const ReflectionProbe *reflection_probe = reflection_probe_owner.getornull(p_probe);
+ const ReflectionProbe *reflection_probe = reflection_probe_owner.get_or_null(p_probe);
ERR_FAIL_COND_V(!reflection_probe, RS::REFLECTION_PROBE_AMBIENT_DISABLED);
return reflection_probe->ambient_mode;
}
Color RendererStorageRD::reflection_probe_get_ambient_color(RID p_probe) const {
- const ReflectionProbe *reflection_probe = reflection_probe_owner.getornull(p_probe);
+ const ReflectionProbe *reflection_probe = reflection_probe_owner.get_or_null(p_probe);
ERR_FAIL_COND_V(!reflection_probe, Color());
return reflection_probe->ambient_color;
}
float RendererStorageRD::reflection_probe_get_ambient_color_energy(RID p_probe) const {
- const ReflectionProbe *reflection_probe = reflection_probe_owner.getornull(p_probe);
+ const ReflectionProbe *reflection_probe = reflection_probe_owner.get_or_null(p_probe);
ERR_FAIL_COND_V(!reflection_probe, 0);
return reflection_probe->ambient_color_energy;
@@ -6340,14 +6340,14 @@ void RendererStorageRD::decal_initialize(RID p_decal) {
}
void RendererStorageRD::decal_set_extents(RID p_decal, const Vector3 &p_extents) {
- Decal *decal = decal_owner.getornull(p_decal);
+ Decal *decal = decal_owner.get_or_null(p_decal);
ERR_FAIL_COND(!decal);
decal->extents = p_extents;
decal->dependency.changed_notify(DEPENDENCY_CHANGED_AABB);
}
void RendererStorageRD::decal_set_texture(RID p_decal, RS::DecalTexture p_type, RID p_texture) {
- Decal *decal = decal_owner.getornull(p_decal);
+ Decal *decal = decal_owner.get_or_null(p_decal);
ERR_FAIL_COND(!decal);
ERR_FAIL_INDEX(p_type, RS::DECAL_TEXTURE_MAX);
@@ -6371,32 +6371,32 @@ void RendererStorageRD::decal_set_texture(RID p_decal, RS::DecalTexture p_type,
}
void RendererStorageRD::decal_set_emission_energy(RID p_decal, float p_energy) {
- Decal *decal = decal_owner.getornull(p_decal);
+ Decal *decal = decal_owner.get_or_null(p_decal);
ERR_FAIL_COND(!decal);
decal->emission_energy = p_energy;
}
void RendererStorageRD::decal_set_albedo_mix(RID p_decal, float p_mix) {
- Decal *decal = decal_owner.getornull(p_decal);
+ Decal *decal = decal_owner.get_or_null(p_decal);
ERR_FAIL_COND(!decal);
decal->albedo_mix = p_mix;
}
void RendererStorageRD::decal_set_modulate(RID p_decal, const Color &p_modulate) {
- Decal *decal = decal_owner.getornull(p_decal);
+ Decal *decal = decal_owner.get_or_null(p_decal);
ERR_FAIL_COND(!decal);
decal->modulate = p_modulate;
}
void RendererStorageRD::decal_set_cull_mask(RID p_decal, uint32_t p_layers) {
- Decal *decal = decal_owner.getornull(p_decal);
+ Decal *decal = decal_owner.get_or_null(p_decal);
ERR_FAIL_COND(!decal);
decal->cull_mask = p_layers;
decal->dependency.changed_notify(DEPENDENCY_CHANGED_AABB);
}
void RendererStorageRD::decal_set_distance_fade(RID p_decal, bool p_enabled, float p_begin, float p_length) {
- Decal *decal = decal_owner.getornull(p_decal);
+ Decal *decal = decal_owner.get_or_null(p_decal);
ERR_FAIL_COND(!decal);
decal->distance_fade = p_enabled;
decal->distance_fade_begin = p_begin;
@@ -6404,20 +6404,20 @@ void RendererStorageRD::decal_set_distance_fade(RID p_decal, bool p_enabled, flo
}
void RendererStorageRD::decal_set_fade(RID p_decal, float p_above, float p_below) {
- Decal *decal = decal_owner.getornull(p_decal);
+ Decal *decal = decal_owner.get_or_null(p_decal);
ERR_FAIL_COND(!decal);
decal->upper_fade = p_above;
decal->lower_fade = p_below;
}
void RendererStorageRD::decal_set_normal_fade(RID p_decal, float p_fade) {
- Decal *decal = decal_owner.getornull(p_decal);
+ Decal *decal = decal_owner.get_or_null(p_decal);
ERR_FAIL_COND(!decal);
decal->normal_fade = p_fade;
}
AABB RendererStorageRD::decal_get_aabb(RID p_decal) const {
- Decal *decal = decal_owner.getornull(p_decal);
+ Decal *decal = decal_owner.get_or_null(p_decal);
ERR_FAIL_COND_V(!decal, AABB());
return AABB(-decal->extents, decal->extents * 2.0);
@@ -6431,7 +6431,7 @@ void RendererStorageRD::voxel_gi_initialize(RID p_voxel_gi) {
}
void RendererStorageRD::voxel_gi_allocate_data(RID p_voxel_gi, const Transform3D &p_to_cell_xform, const AABB &p_aabb, const Vector3i &p_octree_size, const Vector<uint8_t> &p_octree_cells, const Vector<uint8_t> &p_data_cells, const Vector<uint8_t> &p_distance_field, const Vector<int> &p_level_counts) {
- VoxelGI *voxel_gi = voxel_gi_owner.getornull(p_voxel_gi);
+ VoxelGI *voxel_gi = voxel_gi_owner.get_or_null(p_voxel_gi);
ERR_FAIL_COND(!voxel_gi);
if (voxel_gi->octree_buffer.is_valid()) {
@@ -6556,20 +6556,20 @@ void RendererStorageRD::voxel_gi_allocate_data(RID p_voxel_gi, const Transform3D
}
AABB RendererStorageRD::voxel_gi_get_bounds(RID p_voxel_gi) const {
- VoxelGI *voxel_gi = voxel_gi_owner.getornull(p_voxel_gi);
+ VoxelGI *voxel_gi = voxel_gi_owner.get_or_null(p_voxel_gi);
ERR_FAIL_COND_V(!voxel_gi, AABB());
return voxel_gi->bounds;
}
Vector3i RendererStorageRD::voxel_gi_get_octree_size(RID p_voxel_gi) const {
- VoxelGI *voxel_gi = voxel_gi_owner.getornull(p_voxel_gi);
+ VoxelGI *voxel_gi = voxel_gi_owner.get_or_null(p_voxel_gi);
ERR_FAIL_COND_V(!voxel_gi, Vector3i());
return voxel_gi->octree_size;
}
Vector<uint8_t> RendererStorageRD::voxel_gi_get_octree_cells(RID p_voxel_gi) const {
- VoxelGI *voxel_gi = voxel_gi_owner.getornull(p_voxel_gi);
+ VoxelGI *voxel_gi = voxel_gi_owner.get_or_null(p_voxel_gi);
ERR_FAIL_COND_V(!voxel_gi, Vector<uint8_t>());
if (voxel_gi->octree_buffer.is_valid()) {
@@ -6579,7 +6579,7 @@ Vector<uint8_t> RendererStorageRD::voxel_gi_get_octree_cells(RID p_voxel_gi) con
}
Vector<uint8_t> RendererStorageRD::voxel_gi_get_data_cells(RID p_voxel_gi) const {
- VoxelGI *voxel_gi = voxel_gi_owner.getornull(p_voxel_gi);
+ VoxelGI *voxel_gi = voxel_gi_owner.get_or_null(p_voxel_gi);
ERR_FAIL_COND_V(!voxel_gi, Vector<uint8_t>());
if (voxel_gi->data_buffer.is_valid()) {
@@ -6589,7 +6589,7 @@ Vector<uint8_t> RendererStorageRD::voxel_gi_get_data_cells(RID p_voxel_gi) const
}
Vector<uint8_t> RendererStorageRD::voxel_gi_get_distance_field(RID p_voxel_gi) const {
- VoxelGI *voxel_gi = voxel_gi_owner.getornull(p_voxel_gi);
+ VoxelGI *voxel_gi = voxel_gi_owner.get_or_null(p_voxel_gi);
ERR_FAIL_COND_V(!voxel_gi, Vector<uint8_t>());
if (voxel_gi->data_buffer.is_valid()) {
@@ -6599,21 +6599,21 @@ Vector<uint8_t> RendererStorageRD::voxel_gi_get_distance_field(RID p_voxel_gi) c
}
Vector<int> RendererStorageRD::voxel_gi_get_level_counts(RID p_voxel_gi) const {
- VoxelGI *voxel_gi = voxel_gi_owner.getornull(p_voxel_gi);
+ VoxelGI *voxel_gi = voxel_gi_owner.get_or_null(p_voxel_gi);
ERR_FAIL_COND_V(!voxel_gi, Vector<int>());
return voxel_gi->level_counts;
}
Transform3D RendererStorageRD::voxel_gi_get_to_cell_xform(RID p_voxel_gi) const {
- VoxelGI *voxel_gi = voxel_gi_owner.getornull(p_voxel_gi);
+ VoxelGI *voxel_gi = voxel_gi_owner.get_or_null(p_voxel_gi);
ERR_FAIL_COND_V(!voxel_gi, Transform3D());
return voxel_gi->to_cell_xform;
}
void RendererStorageRD::voxel_gi_set_dynamic_range(RID p_voxel_gi, float p_range) {
- VoxelGI *voxel_gi = voxel_gi_owner.getornull(p_voxel_gi);
+ VoxelGI *voxel_gi = voxel_gi_owner.get_or_null(p_voxel_gi);
ERR_FAIL_COND(!voxel_gi);
voxel_gi->dynamic_range = p_range;
@@ -6621,14 +6621,14 @@ void RendererStorageRD::voxel_gi_set_dynamic_range(RID p_voxel_gi, float p_range
}
float RendererStorageRD::voxel_gi_get_dynamic_range(RID p_voxel_gi) const {
- VoxelGI *voxel_gi = voxel_gi_owner.getornull(p_voxel_gi);
+ VoxelGI *voxel_gi = voxel_gi_owner.get_or_null(p_voxel_gi);
ERR_FAIL_COND_V(!voxel_gi, 0);
return voxel_gi->dynamic_range;
}
void RendererStorageRD::voxel_gi_set_propagation(RID p_voxel_gi, float p_range) {
- VoxelGI *voxel_gi = voxel_gi_owner.getornull(p_voxel_gi);
+ VoxelGI *voxel_gi = voxel_gi_owner.get_or_null(p_voxel_gi);
ERR_FAIL_COND(!voxel_gi);
voxel_gi->propagation = p_range;
@@ -6636,72 +6636,72 @@ void RendererStorageRD::voxel_gi_set_propagation(RID p_voxel_gi, float p_range)
}
float RendererStorageRD::voxel_gi_get_propagation(RID p_voxel_gi) const {
- VoxelGI *voxel_gi = voxel_gi_owner.getornull(p_voxel_gi);
+ VoxelGI *voxel_gi = voxel_gi_owner.get_or_null(p_voxel_gi);
ERR_FAIL_COND_V(!voxel_gi, 0);
return voxel_gi->propagation;
}
void RendererStorageRD::voxel_gi_set_energy(RID p_voxel_gi, float p_energy) {
- VoxelGI *voxel_gi = voxel_gi_owner.getornull(p_voxel_gi);
+ VoxelGI *voxel_gi = voxel_gi_owner.get_or_null(p_voxel_gi);
ERR_FAIL_COND(!voxel_gi);
voxel_gi->energy = p_energy;
}
float RendererStorageRD::voxel_gi_get_energy(RID p_voxel_gi) const {
- VoxelGI *voxel_gi = voxel_gi_owner.getornull(p_voxel_gi);
+ VoxelGI *voxel_gi = voxel_gi_owner.get_or_null(p_voxel_gi);
ERR_FAIL_COND_V(!voxel_gi, 0);
return voxel_gi->energy;
}
void RendererStorageRD::voxel_gi_set_bias(RID p_voxel_gi, float p_bias) {
- VoxelGI *voxel_gi = voxel_gi_owner.getornull(p_voxel_gi);
+ VoxelGI *voxel_gi = voxel_gi_owner.get_or_null(p_voxel_gi);
ERR_FAIL_COND(!voxel_gi);
voxel_gi->bias = p_bias;
}
float RendererStorageRD::voxel_gi_get_bias(RID p_voxel_gi) const {
- VoxelGI *voxel_gi = voxel_gi_owner.getornull(p_voxel_gi);
+ VoxelGI *voxel_gi = voxel_gi_owner.get_or_null(p_voxel_gi);
ERR_FAIL_COND_V(!voxel_gi, 0);
return voxel_gi->bias;
}
void RendererStorageRD::voxel_gi_set_normal_bias(RID p_voxel_gi, float p_normal_bias) {
- VoxelGI *voxel_gi = voxel_gi_owner.getornull(p_voxel_gi);
+ VoxelGI *voxel_gi = voxel_gi_owner.get_or_null(p_voxel_gi);
ERR_FAIL_COND(!voxel_gi);
voxel_gi->normal_bias = p_normal_bias;
}
float RendererStorageRD::voxel_gi_get_normal_bias(RID p_voxel_gi) const {
- VoxelGI *voxel_gi = voxel_gi_owner.getornull(p_voxel_gi);
+ VoxelGI *voxel_gi = voxel_gi_owner.get_or_null(p_voxel_gi);
ERR_FAIL_COND_V(!voxel_gi, 0);
return voxel_gi->normal_bias;
}
void RendererStorageRD::voxel_gi_set_anisotropy_strength(RID p_voxel_gi, float p_strength) {
- VoxelGI *voxel_gi = voxel_gi_owner.getornull(p_voxel_gi);
+ VoxelGI *voxel_gi = voxel_gi_owner.get_or_null(p_voxel_gi);
ERR_FAIL_COND(!voxel_gi);
voxel_gi->anisotropy_strength = p_strength;
}
float RendererStorageRD::voxel_gi_get_anisotropy_strength(RID p_voxel_gi) const {
- VoxelGI *voxel_gi = voxel_gi_owner.getornull(p_voxel_gi);
+ VoxelGI *voxel_gi = voxel_gi_owner.get_or_null(p_voxel_gi);
ERR_FAIL_COND_V(!voxel_gi, 0);
return voxel_gi->anisotropy_strength;
}
void RendererStorageRD::voxel_gi_set_interior(RID p_voxel_gi, bool p_enable) {
- VoxelGI *voxel_gi = voxel_gi_owner.getornull(p_voxel_gi);
+ VoxelGI *voxel_gi = voxel_gi_owner.get_or_null(p_voxel_gi);
ERR_FAIL_COND(!voxel_gi);
voxel_gi->interior = p_enable;
}
void RendererStorageRD::voxel_gi_set_use_two_bounces(RID p_voxel_gi, bool p_enable) {
- VoxelGI *voxel_gi = voxel_gi_owner.getornull(p_voxel_gi);
+ VoxelGI *voxel_gi = voxel_gi_owner.get_or_null(p_voxel_gi);
ERR_FAIL_COND(!voxel_gi);
voxel_gi->use_two_bounces = p_enable;
@@ -6709,43 +6709,43 @@ void RendererStorageRD::voxel_gi_set_use_two_bounces(RID p_voxel_gi, bool p_enab
}
bool RendererStorageRD::voxel_gi_is_using_two_bounces(RID p_voxel_gi) const {
- VoxelGI *voxel_gi = voxel_gi_owner.getornull(p_voxel_gi);
+ VoxelGI *voxel_gi = voxel_gi_owner.get_or_null(p_voxel_gi);
ERR_FAIL_COND_V(!voxel_gi, false);
return voxel_gi->use_two_bounces;
}
bool RendererStorageRD::voxel_gi_is_interior(RID p_voxel_gi) const {
- VoxelGI *voxel_gi = voxel_gi_owner.getornull(p_voxel_gi);
+ VoxelGI *voxel_gi = voxel_gi_owner.get_or_null(p_voxel_gi);
ERR_FAIL_COND_V(!voxel_gi, 0);
return voxel_gi->interior;
}
uint32_t RendererStorageRD::voxel_gi_get_version(RID p_voxel_gi) {
- VoxelGI *voxel_gi = voxel_gi_owner.getornull(p_voxel_gi);
+ VoxelGI *voxel_gi = voxel_gi_owner.get_or_null(p_voxel_gi);
ERR_FAIL_COND_V(!voxel_gi, 0);
return voxel_gi->version;
}
uint32_t RendererStorageRD::voxel_gi_get_data_version(RID p_voxel_gi) {
- VoxelGI *voxel_gi = voxel_gi_owner.getornull(p_voxel_gi);
+ VoxelGI *voxel_gi = voxel_gi_owner.get_or_null(p_voxel_gi);
ERR_FAIL_COND_V(!voxel_gi, 0);
return voxel_gi->data_version;
}
RID RendererStorageRD::voxel_gi_get_octree_buffer(RID p_voxel_gi) const {
- VoxelGI *voxel_gi = voxel_gi_owner.getornull(p_voxel_gi);
+ VoxelGI *voxel_gi = voxel_gi_owner.get_or_null(p_voxel_gi);
ERR_FAIL_COND_V(!voxel_gi, RID());
return voxel_gi->octree_buffer;
}
RID RendererStorageRD::voxel_gi_get_data_buffer(RID p_voxel_gi) const {
- VoxelGI *voxel_gi = voxel_gi_owner.getornull(p_voxel_gi);
+ VoxelGI *voxel_gi = voxel_gi_owner.get_or_null(p_voxel_gi);
ERR_FAIL_COND_V(!voxel_gi, RID());
return voxel_gi->data_buffer;
}
RID RendererStorageRD::voxel_gi_get_sdf_texture(RID p_voxel_gi) {
- VoxelGI *voxel_gi = voxel_gi_owner.getornull(p_voxel_gi);
+ VoxelGI *voxel_gi = voxel_gi_owner.get_or_null(p_voxel_gi);
ERR_FAIL_COND_V(!voxel_gi, RID());
return voxel_gi->sdf_texture;
@@ -6762,20 +6762,20 @@ void RendererStorageRD::lightmap_initialize(RID p_lightmap) {
}
void RendererStorageRD::lightmap_set_textures(RID p_lightmap, RID p_light, bool p_uses_spherical_haromics) {
- Lightmap *lm = lightmap_owner.getornull(p_lightmap);
+ Lightmap *lm = lightmap_owner.get_or_null(p_lightmap);
ERR_FAIL_COND(!lm);
lightmap_array_version++;
//erase lightmap users
if (lm->light_texture.is_valid()) {
- Texture *t = texture_owner.getornull(lm->light_texture);
+ Texture *t = texture_owner.get_or_null(lm->light_texture);
if (t) {
t->lightmap_users.erase(p_lightmap);
}
}
- Texture *t = texture_owner.getornull(p_light);
+ Texture *t = texture_owner.get_or_null(p_light);
lm->light_texture = p_light;
lm->uses_spherical_harmonics = p_uses_spherical_haromics;
@@ -6810,19 +6810,19 @@ void RendererStorageRD::lightmap_set_textures(RID p_lightmap, RID p_light, bool
}
void RendererStorageRD::lightmap_set_probe_bounds(RID p_lightmap, const AABB &p_bounds) {
- Lightmap *lm = lightmap_owner.getornull(p_lightmap);
+ Lightmap *lm = lightmap_owner.get_or_null(p_lightmap);
ERR_FAIL_COND(!lm);
lm->bounds = p_bounds;
}
void RendererStorageRD::lightmap_set_probe_interior(RID p_lightmap, bool p_interior) {
- Lightmap *lm = lightmap_owner.getornull(p_lightmap);
+ Lightmap *lm = lightmap_owner.get_or_null(p_lightmap);
ERR_FAIL_COND(!lm);
lm->interior = p_interior;
}
void RendererStorageRD::lightmap_set_probe_capture_data(RID p_lightmap, const PackedVector3Array &p_points, const PackedColorArray &p_point_sh, const PackedInt32Array &p_tetrahedra, const PackedInt32Array &p_bsp_tree) {
- Lightmap *lm = lightmap_owner.getornull(p_lightmap);
+ Lightmap *lm = lightmap_owner.get_or_null(p_lightmap);
ERR_FAIL_COND(!lm);
if (p_points.size()) {
@@ -6838,26 +6838,26 @@ void RendererStorageRD::lightmap_set_probe_capture_data(RID p_lightmap, const Pa
}
PackedVector3Array RendererStorageRD::lightmap_get_probe_capture_points(RID p_lightmap) const {
- Lightmap *lm = lightmap_owner.getornull(p_lightmap);
+ Lightmap *lm = lightmap_owner.get_or_null(p_lightmap);
ERR_FAIL_COND_V(!lm, PackedVector3Array());
return lm->points;
}
PackedColorArray RendererStorageRD::lightmap_get_probe_capture_sh(RID p_lightmap) const {
- Lightmap *lm = lightmap_owner.getornull(p_lightmap);
+ Lightmap *lm = lightmap_owner.get_or_null(p_lightmap);
ERR_FAIL_COND_V(!lm, PackedColorArray());
return lm->point_sh;
}
PackedInt32Array RendererStorageRD::lightmap_get_probe_capture_tetrahedra(RID p_lightmap) const {
- Lightmap *lm = lightmap_owner.getornull(p_lightmap);
+ Lightmap *lm = lightmap_owner.get_or_null(p_lightmap);
ERR_FAIL_COND_V(!lm, PackedInt32Array());
return lm->tetrahedra;
}
PackedInt32Array RendererStorageRD::lightmap_get_probe_capture_bsp_tree(RID p_lightmap) const {
- Lightmap *lm = lightmap_owner.getornull(p_lightmap);
+ Lightmap *lm = lightmap_owner.get_or_null(p_lightmap);
ERR_FAIL_COND_V(!lm, PackedInt32Array());
return lm->bsp_tree;
}
@@ -6867,7 +6867,7 @@ void RendererStorageRD::lightmap_set_probe_capture_update_speed(float p_speed) {
}
void RendererStorageRD::lightmap_tap_sh_light(RID p_lightmap, const Vector3 &p_point, Color *r_sh) {
- Lightmap *lm = lightmap_owner.getornull(p_lightmap);
+ Lightmap *lm = lightmap_owner.get_or_null(p_lightmap);
ERR_FAIL_COND(!lm);
for (int i = 0; i < 9; i++) {
@@ -6917,13 +6917,13 @@ void RendererStorageRD::lightmap_tap_sh_light(RID p_lightmap, const Vector3 &p_p
}
bool RendererStorageRD::lightmap_is_interior(RID p_lightmap) const {
- const Lightmap *lm = lightmap_owner.getornull(p_lightmap);
+ const Lightmap *lm = lightmap_owner.get_or_null(p_lightmap);
ERR_FAIL_COND_V(!lm, false);
return lm->interior;
}
AABB RendererStorageRD::lightmap_get_aabb(RID p_lightmap) const {
- const Lightmap *lm = lightmap_owner.getornull(p_lightmap);
+ const Lightmap *lm = lightmap_owner.get_or_null(p_lightmap);
ERR_FAIL_COND_V(!lm, AABB());
return lm->bounds;
}
@@ -6963,7 +6963,7 @@ void RendererStorageRD::_update_render_target(RenderTarget *rt) {
//create a placeholder until updated
rt->texture = texture_allocate();
texture_2d_placeholder_initialize(rt->texture);
- Texture *tex = texture_owner.getornull(rt->texture);
+ Texture *tex = texture_owner.get_or_null(rt->texture);
tex->is_render_target = true;
}
@@ -7010,7 +7010,7 @@ void RendererStorageRD::_update_render_target(RenderTarget *rt) {
{ //update texture
- Texture *tex = texture_owner.getornull(rt->texture);
+ Texture *tex = texture_owner.get_or_null(rt->texture);
//free existing textures
if (RD::get_singleton()->texture_is_valid(tex->rd_texture)) {
@@ -7117,7 +7117,7 @@ void RendererStorageRD::render_target_set_position(RID p_render_target, int p_x,
}
void RendererStorageRD::render_target_set_size(RID p_render_target, int p_width, int p_height, uint32_t p_view_count) {
- RenderTarget *rt = render_target_owner.getornull(p_render_target);
+ RenderTarget *rt = render_target_owner.get_or_null(p_render_target);
ERR_FAIL_COND(!rt);
if (rt->size.x != p_width || rt->size.y != p_height || rt->view_count != p_view_count) {
rt->size.x = p_width;
@@ -7128,7 +7128,7 @@ void RendererStorageRD::render_target_set_size(RID p_render_target, int p_width,
}
RID RendererStorageRD::render_target_get_texture(RID p_render_target) {
- RenderTarget *rt = render_target_owner.getornull(p_render_target);
+ RenderTarget *rt = render_target_owner.get_or_null(p_render_target);
ERR_FAIL_COND_V(!rt, RID());
return rt->texture;
@@ -7138,53 +7138,53 @@ void RendererStorageRD::render_target_set_external_texture(RID p_render_target,
}
void RendererStorageRD::render_target_set_flag(RID p_render_target, RenderTargetFlags p_flag, bool p_value) {
- RenderTarget *rt = render_target_owner.getornull(p_render_target);
+ RenderTarget *rt = render_target_owner.get_or_null(p_render_target);
ERR_FAIL_COND(!rt);
rt->flags[p_flag] = p_value;
_update_render_target(rt);
}
bool RendererStorageRD::render_target_was_used(RID p_render_target) {
- RenderTarget *rt = render_target_owner.getornull(p_render_target);
+ RenderTarget *rt = render_target_owner.get_or_null(p_render_target);
ERR_FAIL_COND_V(!rt, false);
return rt->was_used;
}
void RendererStorageRD::render_target_set_as_unused(RID p_render_target) {
- RenderTarget *rt = render_target_owner.getornull(p_render_target);
+ RenderTarget *rt = render_target_owner.get_or_null(p_render_target);
ERR_FAIL_COND(!rt);
rt->was_used = false;
}
Size2 RendererStorageRD::render_target_get_size(RID p_render_target) {
- RenderTarget *rt = render_target_owner.getornull(p_render_target);
+ RenderTarget *rt = render_target_owner.get_or_null(p_render_target);
ERR_FAIL_COND_V(!rt, Size2());
return rt->size;
}
RID RendererStorageRD::render_target_get_rd_framebuffer(RID p_render_target) {
- RenderTarget *rt = render_target_owner.getornull(p_render_target);
+ RenderTarget *rt = render_target_owner.get_or_null(p_render_target);
ERR_FAIL_COND_V(!rt, RID());
return rt->framebuffer;
}
RID RendererStorageRD::render_target_get_rd_texture(RID p_render_target) {
- RenderTarget *rt = render_target_owner.getornull(p_render_target);
+ RenderTarget *rt = render_target_owner.get_or_null(p_render_target);
ERR_FAIL_COND_V(!rt, RID());
return rt->color;
}
RID RendererStorageRD::render_target_get_rd_backbuffer(RID p_render_target) {
- RenderTarget *rt = render_target_owner.getornull(p_render_target);
+ RenderTarget *rt = render_target_owner.get_or_null(p_render_target);
ERR_FAIL_COND_V(!rt, RID());
return rt->backbuffer;
}
RID RendererStorageRD::render_target_get_rd_backbuffer_framebuffer(RID p_render_target) {
- RenderTarget *rt = render_target_owner.getornull(p_render_target);
+ RenderTarget *rt = render_target_owner.get_or_null(p_render_target);
ERR_FAIL_COND_V(!rt, RID());
if (!rt->backbuffer.is_valid()) {
@@ -7195,32 +7195,32 @@ RID RendererStorageRD::render_target_get_rd_backbuffer_framebuffer(RID p_render_
}
void RendererStorageRD::render_target_request_clear(RID p_render_target, const Color &p_clear_color) {
- RenderTarget *rt = render_target_owner.getornull(p_render_target);
+ RenderTarget *rt = render_target_owner.get_or_null(p_render_target);
ERR_FAIL_COND(!rt);
rt->clear_requested = true;
rt->clear_color = p_clear_color;
}
bool RendererStorageRD::render_target_is_clear_requested(RID p_render_target) {
- RenderTarget *rt = render_target_owner.getornull(p_render_target);
+ RenderTarget *rt = render_target_owner.get_or_null(p_render_target);
ERR_FAIL_COND_V(!rt, false);
return rt->clear_requested;
}
Color RendererStorageRD::render_target_get_clear_request_color(RID p_render_target) {
- RenderTarget *rt = render_target_owner.getornull(p_render_target);
+ RenderTarget *rt = render_target_owner.get_or_null(p_render_target);
ERR_FAIL_COND_V(!rt, Color());
return rt->clear_color;
}
void RendererStorageRD::render_target_disable_clear_request(RID p_render_target) {
- RenderTarget *rt = render_target_owner.getornull(p_render_target);
+ RenderTarget *rt = render_target_owner.get_or_null(p_render_target);
ERR_FAIL_COND(!rt);
rt->clear_requested = false;
}
void RendererStorageRD::render_target_do_clear_request(RID p_render_target) {
- RenderTarget *rt = render_target_owner.getornull(p_render_target);
+ RenderTarget *rt = render_target_owner.get_or_null(p_render_target);
ERR_FAIL_COND(!rt);
if (!rt->clear_requested) {
return;
@@ -7233,7 +7233,7 @@ void RendererStorageRD::render_target_do_clear_request(RID p_render_target) {
}
void RendererStorageRD::render_target_set_sdf_size_and_scale(RID p_render_target, RS::ViewportSDFOversize p_size, RS::ViewportSDFScale p_scale) {
- RenderTarget *rt = render_target_owner.getornull(p_render_target);
+ RenderTarget *rt = render_target_owner.get_or_null(p_render_target);
ERR_FAIL_COND(!rt);
if (rt->sdf_oversize == p_size && rt->sdf_scale == p_scale) {
return;
@@ -7275,28 +7275,28 @@ Rect2i RendererStorageRD::_render_target_get_sdf_rect(const RenderTarget *rt) co
}
Rect2i RendererStorageRD::render_target_get_sdf_rect(RID p_render_target) const {
- const RenderTarget *rt = render_target_owner.getornull(p_render_target);
+ const RenderTarget *rt = render_target_owner.get_or_null(p_render_target);
ERR_FAIL_COND_V(!rt, Rect2i());
return _render_target_get_sdf_rect(rt);
}
void RendererStorageRD::render_target_mark_sdf_enabled(RID p_render_target, bool p_enabled) {
- RenderTarget *rt = render_target_owner.getornull(p_render_target);
+ RenderTarget *rt = render_target_owner.get_or_null(p_render_target);
ERR_FAIL_COND(!rt);
rt->sdf_enabled = p_enabled;
}
bool RendererStorageRD::render_target_is_sdf_enabled(RID p_render_target) const {
- const RenderTarget *rt = render_target_owner.getornull(p_render_target);
+ const RenderTarget *rt = render_target_owner.get_or_null(p_render_target);
ERR_FAIL_COND_V(!rt, false);
return rt->sdf_enabled;
}
RID RendererStorageRD::render_target_get_sdf_texture(RID p_render_target) {
- RenderTarget *rt = render_target_owner.getornull(p_render_target);
+ RenderTarget *rt = render_target_owner.get_or_null(p_render_target);
ERR_FAIL_COND_V(!rt, RID());
if (rt->sdf_buffer_read.is_null()) {
// no texture, create a dummy one for the 2D uniform set
@@ -7431,7 +7431,7 @@ void RendererStorageRD::_render_target_clear_sdf(RenderTarget *rt) {
}
RID RendererStorageRD::render_target_get_sdf_framebuffer(RID p_render_target) {
- RenderTarget *rt = render_target_owner.getornull(p_render_target);
+ RenderTarget *rt = render_target_owner.get_or_null(p_render_target);
ERR_FAIL_COND_V(!rt, RID());
if (rt->sdf_buffer_write_fb.is_null()) {
@@ -7441,7 +7441,7 @@ RID RendererStorageRD::render_target_get_sdf_framebuffer(RID p_render_target) {
return rt->sdf_buffer_write_fb;
}
void RendererStorageRD::render_target_sdf_process(RID p_render_target) {
- RenderTarget *rt = render_target_owner.getornull(p_render_target);
+ RenderTarget *rt = render_target_owner.get_or_null(p_render_target);
ERR_FAIL_COND(!rt);
ERR_FAIL_COND(rt->sdf_buffer_write_fb.is_null());
@@ -7516,7 +7516,7 @@ void RendererStorageRD::render_target_sdf_process(RID p_render_target) {
}
void RendererStorageRD::render_target_copy_to_back_buffer(RID p_render_target, const Rect2i &p_region, bool p_gen_mipmaps) {
- RenderTarget *rt = render_target_owner.getornull(p_render_target);
+ RenderTarget *rt = render_target_owner.get_or_null(p_render_target);
ERR_FAIL_COND(!rt);
if (!rt->backbuffer.is_valid()) {
_create_render_target_backbuffer(rt);
@@ -7556,7 +7556,7 @@ void RendererStorageRD::render_target_copy_to_back_buffer(RID p_render_target, c
}
void RendererStorageRD::render_target_clear_back_buffer(RID p_render_target, const Rect2i &p_region, const Color &p_color) {
- RenderTarget *rt = render_target_owner.getornull(p_render_target);
+ RenderTarget *rt = render_target_owner.get_or_null(p_render_target);
ERR_FAIL_COND(!rt);
if (!rt->backbuffer.is_valid()) {
_create_render_target_backbuffer(rt);
@@ -7577,7 +7577,7 @@ void RendererStorageRD::render_target_clear_back_buffer(RID p_render_target, con
}
void RendererStorageRD::render_target_gen_back_buffer_mipmaps(RID p_render_target, const Rect2i &p_region) {
- RenderTarget *rt = render_target_owner.getornull(p_render_target);
+ RenderTarget *rt = render_target_owner.get_or_null(p_render_target);
ERR_FAIL_COND(!rt);
if (!rt->backbuffer.is_valid()) {
_create_render_target_backbuffer(rt);
@@ -7609,66 +7609,66 @@ void RendererStorageRD::render_target_gen_back_buffer_mipmaps(RID p_render_targe
}
RID RendererStorageRD::render_target_get_framebuffer_uniform_set(RID p_render_target) {
- RenderTarget *rt = render_target_owner.getornull(p_render_target);
+ RenderTarget *rt = render_target_owner.get_or_null(p_render_target);
ERR_FAIL_COND_V(!rt, RID());
return rt->framebuffer_uniform_set;
}
RID RendererStorageRD::render_target_get_backbuffer_uniform_set(RID p_render_target) {
- RenderTarget *rt = render_target_owner.getornull(p_render_target);
+ RenderTarget *rt = render_target_owner.get_or_null(p_render_target);
ERR_FAIL_COND_V(!rt, RID());
return rt->backbuffer_uniform_set;
}
void RendererStorageRD::render_target_set_framebuffer_uniform_set(RID p_render_target, RID p_uniform_set) {
- RenderTarget *rt = render_target_owner.getornull(p_render_target);
+ RenderTarget *rt = render_target_owner.get_or_null(p_render_target);
ERR_FAIL_COND(!rt);
rt->framebuffer_uniform_set = p_uniform_set;
}
void RendererStorageRD::render_target_set_backbuffer_uniform_set(RID p_render_target, RID p_uniform_set) {
- RenderTarget *rt = render_target_owner.getornull(p_render_target);
+ RenderTarget *rt = render_target_owner.get_or_null(p_render_target);
ERR_FAIL_COND(!rt);
rt->backbuffer_uniform_set = p_uniform_set;
}
void RendererStorageRD::base_update_dependency(RID p_base, DependencyTracker *p_instance) {
if (mesh_owner.owns(p_base)) {
- Mesh *mesh = mesh_owner.getornull(p_base);
+ Mesh *mesh = mesh_owner.get_or_null(p_base);
p_instance->update_dependency(&mesh->dependency);
} else if (multimesh_owner.owns(p_base)) {
- MultiMesh *multimesh = multimesh_owner.getornull(p_base);
+ MultiMesh *multimesh = multimesh_owner.get_or_null(p_base);
p_instance->update_dependency(&multimesh->dependency);
if (multimesh->mesh.is_valid()) {
base_update_dependency(multimesh->mesh, p_instance);
}
} else if (reflection_probe_owner.owns(p_base)) {
- ReflectionProbe *rp = reflection_probe_owner.getornull(p_base);
+ ReflectionProbe *rp = reflection_probe_owner.get_or_null(p_base);
p_instance->update_dependency(&rp->dependency);
} else if (decal_owner.owns(p_base)) {
- Decal *decal = decal_owner.getornull(p_base);
+ Decal *decal = decal_owner.get_or_null(p_base);
p_instance->update_dependency(&decal->dependency);
} else if (voxel_gi_owner.owns(p_base)) {
- VoxelGI *gip = voxel_gi_owner.getornull(p_base);
+ VoxelGI *gip = voxel_gi_owner.get_or_null(p_base);
p_instance->update_dependency(&gip->dependency);
} else if (lightmap_owner.owns(p_base)) {
- Lightmap *lm = lightmap_owner.getornull(p_base);
+ Lightmap *lm = lightmap_owner.get_or_null(p_base);
p_instance->update_dependency(&lm->dependency);
} else if (light_owner.owns(p_base)) {
- Light *l = light_owner.getornull(p_base);
+ Light *l = light_owner.get_or_null(p_base);
p_instance->update_dependency(&l->dependency);
} else if (particles_owner.owns(p_base)) {
- Particles *p = particles_owner.getornull(p_base);
+ Particles *p = particles_owner.get_or_null(p_base);
p_instance->update_dependency(&p->dependency);
} else if (particles_collision_owner.owns(p_base)) {
- ParticlesCollision *pc = particles_collision_owner.getornull(p_base);
+ ParticlesCollision *pc = particles_collision_owner.get_or_null(p_base);
p_instance->update_dependency(&pc->dependency);
} else if (visibility_notifier_owner.owns(p_base)) {
- VisibilityNotifier *vn = visibility_notifier_owner.getornull(p_base);
+ VisibilityNotifier *vn = visibility_notifier_owner.get_or_null(p_base);
p_instance->update_dependency(&vn->dependency);
}
}
void RendererStorageRD::skeleton_update_dependency(RID p_skeleton, DependencyTracker *p_instance) {
- Skeleton *skeleton = skeleton_owner.getornull(p_skeleton);
+ Skeleton *skeleton = skeleton_owner.get_or_null(p_skeleton);
ERR_FAIL_COND(!skeleton);
p_instance->update_dependency(&skeleton->dependency);
@@ -7774,7 +7774,7 @@ void RendererStorageRD::_update_decal_atlas() {
while ((K = decal_atlas.textures.next(K))) {
DecalAtlas::SortItem &si = itemsv.write[idx];
- Texture *src_tex = texture_owner.getornull(*K);
+ Texture *src_tex = texture_owner.get_or_null(*K);
si.size.width = (src_tex->width / border) + 1;
si.size.height = (src_tex->height / border) + 1;
@@ -7923,7 +7923,7 @@ void RendererStorageRD::_update_decal_atlas() {
const RID *K = nullptr;
while ((K = decal_atlas.textures.next(K))) {
DecalAtlas::Texture *t = decal_atlas.textures.getptr(*K);
- Texture *src_tex = texture_owner.getornull(*K);
+ Texture *src_tex = texture_owner.get_or_null(*K);
effects->copy_to_atlas_fb(src_tex->rd_texture, mm.fb, t->uv_rect, draw_list, false, t->panorama_to_dp_users > 0);
}
@@ -8339,7 +8339,7 @@ void RendererStorageRD::global_variable_set(const StringName &p_name, const Vari
} else {
//texture
for (Set<RID>::Element *E = gv.texture_materials.front(); E; E = E->next()) {
- Material *material = material_owner.getornull(E->get());
+ Material *material = material_owner.get_or_null(E->get());
ERR_CONTINUE(!material);
_material_queue_update(material, false, true);
}
@@ -8370,7 +8370,7 @@ void RendererStorageRD::global_variable_set_override(const StringName &p_name, c
} else {
//texture
for (Set<RID>::Element *E = gv.texture_materials.front(); E; E = E->next()) {
- Material *material = material_owner.getornull(E->get());
+ Material *material = material_owner.get_or_null(E->get());
ERR_CONTINUE(!material);
_material_queue_update(material, false, true);
}
@@ -8581,7 +8581,7 @@ void RendererStorageRD::_update_global_variables() {
// only happens in the case of a buffer variable added or removed,
// so not often.
for (const RID &E : global_variables.materials_using_buffer) {
- Material *material = material_owner.getornull(E);
+ Material *material = material_owner.get_or_null(E);
ERR_CONTINUE(!material); //wtf
_material_queue_update(material, true, false);
@@ -8594,7 +8594,7 @@ void RendererStorageRD::_update_global_variables() {
// only happens in the case of a buffer variable added or removed,
// so not often.
for (const RID &E : global_variables.materials_using_texture) {
- Material *material = material_owner.getornull(E);
+ Material *material = material_owner.get_or_null(E);
ERR_CONTINUE(!material); //wtf
_material_queue_update(material, false, true);
@@ -8639,7 +8639,7 @@ bool RendererStorageRD::has_os_feature(const String &p_feature) const {
bool RendererStorageRD::free(RID p_rid) {
if (texture_owner.owns(p_rid)) {
- Texture *t = texture_owner.getornull(p_rid);
+ Texture *t = texture_owner.get_or_null(p_rid);
ERR_FAIL_COND_V(!t, false);
ERR_FAIL_COND_V(t->is_render_target, false);
@@ -8653,7 +8653,7 @@ bool RendererStorageRD::free(RID p_rid) {
}
if (t->is_proxy && t->proxy_to.is_valid()) {
- Texture *proxy_to = texture_owner.getornull(t->proxy_to);
+ Texture *proxy_to = texture_owner.get_or_null(t->proxy_to);
if (proxy_to) {
proxy_to->proxies.erase(p_rid);
}
@@ -8665,7 +8665,7 @@ bool RendererStorageRD::free(RID p_rid) {
}
for (int i = 0; i < t->proxies.size(); i++) {
- Texture *p = texture_owner.getornull(t->proxies[i]);
+ Texture *p = texture_owner.get_or_null(t->proxies[i]);
ERR_CONTINUE(!p);
p->proxy_to = RID();
p->rd_texture = RID();
@@ -8680,7 +8680,7 @@ bool RendererStorageRD::free(RID p_rid) {
} else if (canvas_texture_owner.owns(p_rid)) {
canvas_texture_owner.free(p_rid);
} else if (shader_owner.owns(p_rid)) {
- Shader *shader = shader_owner.getornull(p_rid);
+ Shader *shader = shader_owner.get_or_null(p_rid);
//make material unreference this
while (shader->owners.size()) {
material_set_shader(shader->owners.front()->get()->self, RID());
@@ -8692,7 +8692,7 @@ bool RendererStorageRD::free(RID p_rid) {
shader_owner.free(p_rid);
} else if (material_owner.owns(p_rid)) {
- Material *material = material_owner.getornull(p_rid);
+ Material *material = material_owner.get_or_null(p_rid);
material_set_shader(p_rid, RID()); //clean up shader
material->dependency.deleted_notify(p_rid);
@@ -8700,7 +8700,7 @@ bool RendererStorageRD::free(RID p_rid) {
} else if (mesh_owner.owns(p_rid)) {
mesh_clear(p_rid);
mesh_set_shadow_mesh(p_rid, RID());
- Mesh *mesh = mesh_owner.getornull(p_rid);
+ Mesh *mesh = mesh_owner.get_or_null(p_rid);
mesh->dependency.deleted_notify(p_rid);
if (mesh->instances.size()) {
ERR_PRINT("deleting mesh with active instances");
@@ -8714,7 +8714,7 @@ bool RendererStorageRD::free(RID p_rid) {
}
mesh_owner.free(p_rid);
} else if (mesh_instance_owner.owns(p_rid)) {
- MeshInstance *mi = mesh_instance_owner.getornull(p_rid);
+ MeshInstance *mi = mesh_instance_owner.get_or_null(p_rid);
_mesh_instance_clear(mi);
mi->mesh->instances.erase(mi->I);
mi->I = nullptr;
@@ -8724,21 +8724,21 @@ bool RendererStorageRD::free(RID p_rid) {
} else if (multimesh_owner.owns(p_rid)) {
_update_dirty_multimeshes();
multimesh_allocate_data(p_rid, 0, RS::MULTIMESH_TRANSFORM_2D);
- MultiMesh *multimesh = multimesh_owner.getornull(p_rid);
+ MultiMesh *multimesh = multimesh_owner.get_or_null(p_rid);
multimesh->dependency.deleted_notify(p_rid);
multimesh_owner.free(p_rid);
} else if (skeleton_owner.owns(p_rid)) {
_update_dirty_skeletons();
skeleton_allocate_data(p_rid, 0);
- Skeleton *skeleton = skeleton_owner.getornull(p_rid);
+ Skeleton *skeleton = skeleton_owner.get_or_null(p_rid);
skeleton->dependency.deleted_notify(p_rid);
skeleton_owner.free(p_rid);
} else if (reflection_probe_owner.owns(p_rid)) {
- ReflectionProbe *reflection_probe = reflection_probe_owner.getornull(p_rid);
+ ReflectionProbe *reflection_probe = reflection_probe_owner.get_or_null(p_rid);
reflection_probe->dependency.deleted_notify(p_rid);
reflection_probe_owner.free(p_rid);
} else if (decal_owner.owns(p_rid)) {
- Decal *decal = decal_owner.getornull(p_rid);
+ Decal *decal = decal_owner.get_or_null(p_rid);
for (int i = 0; i < RS::DECAL_TEXTURE_MAX; i++) {
if (decal->textures[i].is_valid() && texture_owner.owns(decal->textures[i])) {
texture_remove_from_decal_atlas(decal->textures[i]);
@@ -8748,30 +8748,30 @@ bool RendererStorageRD::free(RID p_rid) {
decal_owner.free(p_rid);
} else if (voxel_gi_owner.owns(p_rid)) {
voxel_gi_allocate_data(p_rid, Transform3D(), AABB(), Vector3i(), Vector<uint8_t>(), Vector<uint8_t>(), Vector<uint8_t>(), Vector<int>()); //deallocate
- VoxelGI *voxel_gi = voxel_gi_owner.getornull(p_rid);
+ VoxelGI *voxel_gi = voxel_gi_owner.get_or_null(p_rid);
voxel_gi->dependency.deleted_notify(p_rid);
voxel_gi_owner.free(p_rid);
} else if (lightmap_owner.owns(p_rid)) {
lightmap_set_textures(p_rid, RID(), false);
- Lightmap *lightmap = lightmap_owner.getornull(p_rid);
+ Lightmap *lightmap = lightmap_owner.get_or_null(p_rid);
lightmap->dependency.deleted_notify(p_rid);
lightmap_owner.free(p_rid);
} else if (light_owner.owns(p_rid)) {
light_set_projector(p_rid, RID()); //clear projector
// delete the texture
- Light *light = light_owner.getornull(p_rid);
+ Light *light = light_owner.get_or_null(p_rid);
light->dependency.deleted_notify(p_rid);
light_owner.free(p_rid);
} else if (particles_owner.owns(p_rid)) {
update_particles();
- Particles *particles = particles_owner.getornull(p_rid);
+ Particles *particles = particles_owner.get_or_null(p_rid);
particles->dependency.deleted_notify(p_rid);
_particles_free_data(particles);
particles_owner.free(p_rid);
} else if (particles_collision_owner.owns(p_rid)) {
- ParticlesCollision *particles_collision = particles_collision_owner.getornull(p_rid);
+ ParticlesCollision *particles_collision = particles_collision_owner.get_or_null(p_rid);
if (particles_collision->heightfield_texture.is_valid()) {
RD::get_singleton()->free(particles_collision->heightfield_texture);
@@ -8779,18 +8779,18 @@ bool RendererStorageRD::free(RID p_rid) {
particles_collision->dependency.deleted_notify(p_rid);
particles_collision_owner.free(p_rid);
} else if (visibility_notifier_owner.owns(p_rid)) {
- VisibilityNotifier *vn = visibility_notifier_owner.getornull(p_rid);
+ VisibilityNotifier *vn = visibility_notifier_owner.get_or_null(p_rid);
vn->dependency.deleted_notify(p_rid);
visibility_notifier_owner.free(p_rid);
} else if (particles_collision_instance_owner.owns(p_rid)) {
particles_collision_instance_owner.free(p_rid);
} else if (render_target_owner.owns(p_rid)) {
- RenderTarget *rt = render_target_owner.getornull(p_rid);
+ RenderTarget *rt = render_target_owner.get_or_null(p_rid);
_clear_render_target(rt);
if (rt->texture.is_valid()) {
- Texture *tex = texture_owner.getornull(rt->texture);
+ Texture *tex = texture_owner.get_or_null(rt->texture);
tex->is_render_target = false;
free(rt->texture);
}
diff --git a/servers/rendering/renderer_rd/renderer_storage_rd.h b/servers/rendering/renderer_rd/renderer_storage_rd.h
index 4950b7d5e5..d56afcc448 100644
--- a/servers/rendering/renderer_rd/renderer_storage_rd.h
+++ b/servers/rendering/renderer_rd/renderer_storage_rd.h
@@ -1350,7 +1350,7 @@ public:
if (p_texture.is_null()) {
return RID();
}
- Texture *tex = texture_owner.getornull(p_texture);
+ Texture *tex = texture_owner.get_or_null(p_texture);
if (!tex) {
return RID();
@@ -1362,7 +1362,7 @@ public:
if (p_texture.is_null()) {
return Size2i();
}
- Texture *tex = texture_owner.getornull(p_texture);
+ Texture *tex = texture_owner.get_or_null(p_texture);
if (!tex) {
return Size2i();
@@ -1430,12 +1430,12 @@ public:
void material_set_data_request_function(ShaderType p_shader_type, MaterialDataRequestFunction p_function);
_FORCE_INLINE_ uint32_t material_get_shader_id(RID p_material) {
- Material *material = material_owner.getornull(p_material);
+ Material *material = material_owner.get_or_null(p_material);
return material->shader_id;
}
_FORCE_INLINE_ MaterialData *material_get_data(RID p_material, ShaderType p_shader_type) {
- Material *material = material_owner.getornull(p_material);
+ Material *material = material_owner.get_or_null(p_material);
if (!material || material->shader_type != p_shader_type) {
return nullptr;
} else {
@@ -1488,7 +1488,7 @@ public:
virtual void update_mesh_instances();
_FORCE_INLINE_ const RID *mesh_get_surface_count_and_materials(RID p_mesh, uint32_t &r_surface_count) {
- Mesh *mesh = mesh_owner.getornull(p_mesh);
+ Mesh *mesh = mesh_owner.get_or_null(p_mesh);
ERR_FAIL_COND_V(!mesh, nullptr);
r_surface_count = mesh->surface_count;
if (r_surface_count == 0) {
@@ -1505,7 +1505,7 @@ public:
}
_FORCE_INLINE_ void *mesh_get_surface(RID p_mesh, uint32_t p_surface_index) {
- Mesh *mesh = mesh_owner.getornull(p_mesh);
+ Mesh *mesh = mesh_owner.get_or_null(p_mesh);
ERR_FAIL_COND_V(!mesh, nullptr);
ERR_FAIL_UNSIGNED_INDEX_V(p_surface_index, mesh->surface_count, nullptr);
@@ -1513,7 +1513,7 @@ public:
}
_FORCE_INLINE_ RID mesh_get_shadow_mesh(RID p_mesh) {
- Mesh *mesh = mesh_owner.getornull(p_mesh);
+ Mesh *mesh = mesh_owner.get_or_null(p_mesh);
ERR_FAIL_COND_V(!mesh, RID());
return mesh->shadow_mesh;
@@ -1599,7 +1599,7 @@ public:
}
_FORCE_INLINE_ void mesh_instance_surface_get_vertex_arrays_and_format(RID p_mesh_instance, uint32_t p_surface_index, uint32_t p_input_mask, RID &r_vertex_array_rd, RD::VertexFormatID &r_vertex_format) {
- MeshInstance *mi = mesh_instance_owner.getornull(p_mesh_instance);
+ MeshInstance *mi = mesh_instance_owner.get_or_null(p_mesh_instance);
ERR_FAIL_COND(!mi);
Mesh *mesh = mi->mesh;
ERR_FAIL_UNSIGNED_INDEX(p_surface_index, mesh->surface_count);
@@ -1640,7 +1640,7 @@ public:
}
_FORCE_INLINE_ uint32_t mesh_surface_get_render_pass_index(RID p_mesh, uint32_t p_surface_index, uint64_t p_render_pass, uint32_t *r_index) {
- Mesh *mesh = mesh_owner.getornull(p_mesh);
+ Mesh *mesh = mesh_owner.get_or_null(p_mesh);
Mesh::Surface *s = mesh->surfaces[p_surface_index];
if (s->render_pass != p_render_pass) {
@@ -1653,7 +1653,7 @@ public:
}
_FORCE_INLINE_ uint32_t mesh_surface_get_multimesh_render_pass_index(RID p_mesh, uint32_t p_surface_index, uint64_t p_render_pass, uint32_t *r_index) {
- Mesh *mesh = mesh_owner.getornull(p_mesh);
+ Mesh *mesh = mesh_owner.get_or_null(p_mesh);
Mesh::Surface *s = mesh->surfaces[p_surface_index];
if (s->multimesh_render_pass != p_render_pass) {
@@ -1666,7 +1666,7 @@ public:
}
_FORCE_INLINE_ uint32_t mesh_surface_get_particles_render_pass_index(RID p_mesh, uint32_t p_surface_index, uint64_t p_render_pass, uint32_t *r_index) {
- Mesh *mesh = mesh_owner.getornull(p_mesh);
+ Mesh *mesh = mesh_owner.get_or_null(p_mesh);
Mesh::Surface *s = mesh->surfaces[p_surface_index];
if (s->particles_render_pass != p_render_pass) {
@@ -1708,22 +1708,22 @@ public:
AABB multimesh_get_aabb(RID p_multimesh) const;
_FORCE_INLINE_ RS::MultimeshTransformFormat multimesh_get_transform_format(RID p_multimesh) const {
- MultiMesh *multimesh = multimesh_owner.getornull(p_multimesh);
+ MultiMesh *multimesh = multimesh_owner.get_or_null(p_multimesh);
return multimesh->xform_format;
}
_FORCE_INLINE_ bool multimesh_uses_colors(RID p_multimesh) const {
- MultiMesh *multimesh = multimesh_owner.getornull(p_multimesh);
+ MultiMesh *multimesh = multimesh_owner.get_or_null(p_multimesh);
return multimesh->uses_colors;
}
_FORCE_INLINE_ bool multimesh_uses_custom_data(RID p_multimesh) const {
- MultiMesh *multimesh = multimesh_owner.getornull(p_multimesh);
+ MultiMesh *multimesh = multimesh_owner.get_or_null(p_multimesh);
return multimesh->uses_custom_data;
}
_FORCE_INLINE_ uint32_t multimesh_get_instances_to_draw(RID p_multimesh) const {
- MultiMesh *multimesh = multimesh_owner.getornull(p_multimesh);
+ MultiMesh *multimesh = multimesh_owner.get_or_null(p_multimesh);
if (multimesh->visible_instances >= 0) {
return multimesh->visible_instances;
}
@@ -1731,7 +1731,7 @@ public:
}
_FORCE_INLINE_ RID multimesh_get_3d_uniform_set(RID p_multimesh, RID p_shader, uint32_t p_set) const {
- MultiMesh *multimesh = multimesh_owner.getornull(p_multimesh);
+ MultiMesh *multimesh = multimesh_owner.get_or_null(p_multimesh);
if (!multimesh->uniform_set_3d.is_valid()) {
Vector<RD::Uniform> uniforms;
RD::Uniform u;
@@ -1746,7 +1746,7 @@ public:
}
_FORCE_INLINE_ RID multimesh_get_2d_uniform_set(RID p_multimesh, RID p_shader, uint32_t p_set) const {
- MultiMesh *multimesh = multimesh_owner.getornull(p_multimesh);
+ MultiMesh *multimesh = multimesh_owner.get_or_null(p_multimesh);
if (!multimesh->uniform_set_2d.is_valid()) {
Vector<RD::Uniform> uniforms;
RD::Uniform u;
@@ -1775,11 +1775,11 @@ public:
Transform2D skeleton_bone_get_transform_2d(RID p_skeleton, int p_bone) const;
_FORCE_INLINE_ bool skeleton_is_valid(RID p_skeleton) {
- return skeleton_owner.getornull(p_skeleton) != nullptr;
+ return skeleton_owner.get_or_null(p_skeleton) != nullptr;
}
_FORCE_INLINE_ RID skeleton_get_3d_uniform_set(RID p_skeleton, RID p_shader, uint32_t p_set) const {
- Skeleton *skeleton = skeleton_owner.getornull(p_skeleton);
+ Skeleton *skeleton = skeleton_owner.get_or_null(p_skeleton);
ERR_FAIL_COND_V(!skeleton, RID());
ERR_FAIL_COND_V(skeleton->size == 0, RID());
if (skeleton->use_2d) {
@@ -1833,7 +1833,7 @@ public:
RS::LightOmniShadowMode light_omni_get_shadow_mode(RID p_light);
_FORCE_INLINE_ RS::LightType light_get_type(RID p_light) const {
- const Light *light = light_owner.getornull(p_light);
+ const Light *light = light_owner.get_or_null(p_light);
ERR_FAIL_COND_V(!light, RS::LIGHT_DIRECTIONAL);
return light->type;
@@ -1841,70 +1841,70 @@ public:
AABB light_get_aabb(RID p_light) const;
_FORCE_INLINE_ float light_get_param(RID p_light, RS::LightParam p_param) {
- const Light *light = light_owner.getornull(p_light);
+ const Light *light = light_owner.get_or_null(p_light);
ERR_FAIL_COND_V(!light, 0);
return light->param[p_param];
}
_FORCE_INLINE_ RID light_get_projector(RID p_light) {
- const Light *light = light_owner.getornull(p_light);
+ const Light *light = light_owner.get_or_null(p_light);
ERR_FAIL_COND_V(!light, RID());
return light->projector;
}
_FORCE_INLINE_ Color light_get_color(RID p_light) {
- const Light *light = light_owner.getornull(p_light);
+ const Light *light = light_owner.get_or_null(p_light);
ERR_FAIL_COND_V(!light, Color());
return light->color;
}
_FORCE_INLINE_ Color light_get_shadow_color(RID p_light) {
- const Light *light = light_owner.getornull(p_light);
+ const Light *light = light_owner.get_or_null(p_light);
ERR_FAIL_COND_V(!light, Color());
return light->shadow_color;
}
_FORCE_INLINE_ uint32_t light_get_cull_mask(RID p_light) {
- const Light *light = light_owner.getornull(p_light);
+ const Light *light = light_owner.get_or_null(p_light);
ERR_FAIL_COND_V(!light, 0);
return light->cull_mask;
}
_FORCE_INLINE_ bool light_has_shadow(RID p_light) const {
- const Light *light = light_owner.getornull(p_light);
+ const Light *light = light_owner.get_or_null(p_light);
ERR_FAIL_COND_V(!light, RS::LIGHT_DIRECTIONAL);
return light->shadow;
}
_FORCE_INLINE_ bool light_has_projector(RID p_light) const {
- const Light *light = light_owner.getornull(p_light);
+ const Light *light = light_owner.get_or_null(p_light);
ERR_FAIL_COND_V(!light, RS::LIGHT_DIRECTIONAL);
return texture_owner.owns(light->projector);
}
_FORCE_INLINE_ bool light_is_negative(RID p_light) const {
- const Light *light = light_owner.getornull(p_light);
+ const Light *light = light_owner.get_or_null(p_light);
ERR_FAIL_COND_V(!light, RS::LIGHT_DIRECTIONAL);
return light->negative;
}
_FORCE_INLINE_ float light_get_transmittance_bias(RID p_light) const {
- const Light *light = light_owner.getornull(p_light);
+ const Light *light = light_owner.get_or_null(p_light);
ERR_FAIL_COND_V(!light, 0.0);
return light->param[RS::LIGHT_PARAM_TRANSMITTANCE_BIAS];
}
_FORCE_INLINE_ float light_get_shadow_volumetric_fog_fade(RID p_light) const {
- const Light *light = light_owner.getornull(p_light);
+ const Light *light = light_owner.get_or_null(p_light);
ERR_FAIL_COND_V(!light, 0.0);
return light->param[RS::LIGHT_PARAM_SHADOW_VOLUMETRIC_FOG_FADE];
@@ -1971,62 +1971,62 @@ public:
virtual void decal_set_normal_fade(RID p_decal, float p_fade);
_FORCE_INLINE_ Vector3 decal_get_extents(RID p_decal) {
- const Decal *decal = decal_owner.getornull(p_decal);
+ const Decal *decal = decal_owner.get_or_null(p_decal);
return decal->extents;
}
_FORCE_INLINE_ RID decal_get_texture(RID p_decal, RS::DecalTexture p_texture) {
- const Decal *decal = decal_owner.getornull(p_decal);
+ const Decal *decal = decal_owner.get_or_null(p_decal);
return decal->textures[p_texture];
}
_FORCE_INLINE_ Color decal_get_modulate(RID p_decal) {
- const Decal *decal = decal_owner.getornull(p_decal);
+ const Decal *decal = decal_owner.get_or_null(p_decal);
return decal->modulate;
}
_FORCE_INLINE_ float decal_get_emission_energy(RID p_decal) {
- const Decal *decal = decal_owner.getornull(p_decal);
+ const Decal *decal = decal_owner.get_or_null(p_decal);
return decal->emission_energy;
}
_FORCE_INLINE_ float decal_get_albedo_mix(RID p_decal) {
- const Decal *decal = decal_owner.getornull(p_decal);
+ const Decal *decal = decal_owner.get_or_null(p_decal);
return decal->albedo_mix;
}
_FORCE_INLINE_ uint32_t decal_get_cull_mask(RID p_decal) {
- const Decal *decal = decal_owner.getornull(p_decal);
+ const Decal *decal = decal_owner.get_or_null(p_decal);
return decal->cull_mask;
}
_FORCE_INLINE_ float decal_get_upper_fade(RID p_decal) {
- const Decal *decal = decal_owner.getornull(p_decal);
+ const Decal *decal = decal_owner.get_or_null(p_decal);
return decal->upper_fade;
}
_FORCE_INLINE_ float decal_get_lower_fade(RID p_decal) {
- const Decal *decal = decal_owner.getornull(p_decal);
+ const Decal *decal = decal_owner.get_or_null(p_decal);
return decal->lower_fade;
}
_FORCE_INLINE_ float decal_get_normal_fade(RID p_decal) {
- const Decal *decal = decal_owner.getornull(p_decal);
+ const Decal *decal = decal_owner.get_or_null(p_decal);
return decal->normal_fade;
}
_FORCE_INLINE_ bool decal_is_distance_fade_enabled(RID p_decal) {
- const Decal *decal = decal_owner.getornull(p_decal);
+ const Decal *decal = decal_owner.get_or_null(p_decal);
return decal->distance_fade;
}
_FORCE_INLINE_ float decal_get_distance_fade_begin(RID p_decal) {
- const Decal *decal = decal_owner.getornull(p_decal);
+ const Decal *decal = decal_owner.get_or_null(p_decal);
return decal->distance_fade_begin;
}
_FORCE_INLINE_ float decal_get_distance_fade_length(RID p_decal) {
- const Decal *decal = decal_owner.getornull(p_decal);
+ const Decal *decal = decal_owner.get_or_null(p_decal);
return decal->distance_fade_length;
}
@@ -2101,18 +2101,18 @@ public:
return lightmap_probe_capture_update_speed;
}
_FORCE_INLINE_ RID lightmap_get_texture(RID p_lightmap) const {
- const Lightmap *lm = lightmap_owner.getornull(p_lightmap);
+ const Lightmap *lm = lightmap_owner.get_or_null(p_lightmap);
ERR_FAIL_COND_V(!lm, RID());
return lm->light_texture;
}
_FORCE_INLINE_ int32_t lightmap_get_array_index(RID p_lightmap) const {
ERR_FAIL_COND_V(!using_lightmap_array, -1); //only for arrays
- const Lightmap *lm = lightmap_owner.getornull(p_lightmap);
+ const Lightmap *lm = lightmap_owner.get_or_null(p_lightmap);
return lm->array_index;
}
_FORCE_INLINE_ bool lightmap_uses_spherical_harmonics(RID p_lightmap) const {
ERR_FAIL_COND_V(!using_lightmap_array, false); //only for arrays
- const Lightmap *lm = lightmap_owner.getornull(p_lightmap);
+ const Lightmap *lm = lightmap_owner.get_or_null(p_lightmap);
return lm->uses_spherical_harmonics;
}
_FORCE_INLINE_ uint64_t lightmap_array_get_version() const {
@@ -2181,13 +2181,13 @@ public:
virtual bool particles_is_inactive(RID p_particles) const;
_FORCE_INLINE_ RS::ParticlesMode particles_get_mode(RID p_particles) {
- Particles *particles = particles_owner.getornull(p_particles);
+ Particles *particles = particles_owner.get_or_null(p_particles);
ERR_FAIL_COND_V(!particles, RS::PARTICLES_MODE_2D);
return particles->mode;
}
_FORCE_INLINE_ uint32_t particles_get_amount(RID p_particles, uint32_t &r_trail_divisor) {
- Particles *particles = particles_owner.getornull(p_particles);
+ Particles *particles = particles_owner.get_or_null(p_particles);
ERR_FAIL_COND_V(!particles, 0);
if (particles->trails_enabled && particles->trail_bind_poses.size() > 1) {
@@ -2200,21 +2200,21 @@ public:
}
_FORCE_INLINE_ bool particles_has_collision(RID p_particles) {
- Particles *particles = particles_owner.getornull(p_particles);
+ Particles *particles = particles_owner.get_or_null(p_particles);
ERR_FAIL_COND_V(!particles, 0);
return particles->has_collision_cache;
}
_FORCE_INLINE_ uint32_t particles_is_using_local_coords(RID p_particles) {
- Particles *particles = particles_owner.getornull(p_particles);
+ Particles *particles = particles_owner.get_or_null(p_particles);
ERR_FAIL_COND_V(!particles, false);
return particles->use_local_coords;
}
_FORCE_INLINE_ RID particles_get_instance_buffer_uniform_set(RID p_particles, RID p_shader, uint32_t p_set) {
- Particles *particles = particles_owner.getornull(p_particles);
+ Particles *particles = particles_owner.get_or_null(p_particles);
ERR_FAIL_COND_V(!particles, RID());
if (particles->particles_transforms_buffer_uniform_set.is_null()) {
_particles_update_buffers(particles);
diff --git a/servers/rendering/renderer_rd/shader_compiler_rd.cpp b/servers/rendering/renderer_rd/shader_compiler_rd.cpp
index b95d4b642c..cddb679eba 100644
--- a/servers/rendering/renderer_rd/shader_compiler_rd.cpp
+++ b/servers/rendering/renderer_rd/shader_compiler_rd.cpp
@@ -566,11 +566,11 @@ String ShaderCompilerRD::_dump_node_code(const SL::Node *p_node, int p_level, Ge
int max_texture_uniforms = 0;
int max_uniforms = 0;
- for (Map<StringName, SL::ShaderNode::Uniform>::Element *E = pnode->uniforms.front(); E; E = E->next()) {
- if (SL::is_sampler_type(E->get().type)) {
+ for (const KeyValue<StringName, SL::ShaderNode::Uniform> &E : pnode->uniforms) {
+ if (SL::is_sampler_type(E.value.type)) {
max_texture_uniforms++;
} else {
- if (E->get().scope == SL::ShaderNode::Uniform::SCOPE_INSTANCE) {
+ if (E.value.scope == SL::ShaderNode::Uniform::SCOPE_INSTANCE) {
continue; // Instances are indexed directly, don't need index uniforms.
}
@@ -590,8 +590,8 @@ String ShaderCompilerRD::_dump_node_code(const SL::Node *p_node, int p_level, Ge
Vector<StringName> uniform_names;
- for (Map<StringName, SL::ShaderNode::Uniform>::Element *E = pnode->uniforms.front(); E; E = E->next()) {
- uniform_names.push_back(E->key());
+ for (const KeyValue<StringName, SL::ShaderNode::Uniform> &E : pnode->uniforms) {
+ uniform_names.push_back(E.key);
}
uniform_names.sort_custom<StringName::AlphCompare>(); //ensure order is deterministic so the same shader is always produced
@@ -724,8 +724,8 @@ String ShaderCompilerRD::_dump_node_code(const SL::Node *p_node, int p_level, Ge
Vector<StringName> varying_names;
- for (Map<StringName, SL::ShaderNode::Varying>::Element *E = pnode->varyings.front(); E; E = E->next()) {
- varying_names.push_back(E->key());
+ for (const KeyValue<StringName, SL::ShaderNode::Varying> &E : pnode->varyings) {
+ varying_names.push_back(E.key);
}
varying_names.sort_custom<StringName::AlphCompare>(); //ensure order is deterministic so the same shader is always produced
diff --git a/servers/rendering/renderer_rd/shader_rd.cpp b/servers/rendering/renderer_rd/shader_rd.cpp
index 82efa1318c..b9a8947fa2 100644
--- a/servers/rendering/renderer_rd/shader_rd.cpp
+++ b/servers/rendering/renderer_rd/shader_rd.cpp
@@ -174,8 +174,8 @@ void ShaderRD::_build_variant_code(StringBuilder &builder, uint32_t p_variant, c
if (p_version->uniforms.size()) {
builder.append("#define MATERIAL_UNIFORMS_USED\n");
}
- for (Map<StringName, CharString>::Element *E = p_version->code_sections.front(); E; E = E->next()) {
- builder.append(String("#define ") + String(E->key()) + "_CODE_USED\n");
+ for (const KeyValue<StringName, CharString> &E : p_version->code_sections) {
+ builder.append(String("#define ") + String(E.key) + "_CODE_USED\n");
}
} break;
case StageTemplate::Chunk::TYPE_MATERIAL_UNIFORMS: {
@@ -292,7 +292,7 @@ void ShaderRD::_compile_variant(uint32_t p_variant, Version *p_version) {
}
RS::ShaderNativeSourceCode ShaderRD::version_get_native_source_code(RID p_version) {
- Version *version = version_owner.getornull(p_version);
+ Version *version = version_owner.get_or_null(p_version);
RS::ShaderNativeSourceCode source_code;
ERR_FAIL_COND_V(!version, source_code);
@@ -355,8 +355,8 @@ String ShaderRD::_version_get_sha1(Version *p_version) const {
hash_build.append(p_version->compute_globals.get_data());
Vector<StringName> code_sections;
- for (Map<StringName, CharString>::Element *E = p_version->code_sections.front(); E; E = E->next()) {
- code_sections.push_back(E->key());
+ for (const KeyValue<StringName, CharString> &E : p_version->code_sections) {
+ code_sections.push_back(E.key);
}
code_sections.sort_custom<StringName::AlphCompare>();
@@ -524,14 +524,14 @@ void ShaderRD::_compile_version(Version *p_version) {
void ShaderRD::version_set_code(RID p_version, const Map<String, String> &p_code, const String &p_uniforms, const String &p_vertex_globals, const String &p_fragment_globals, const Vector<String> &p_custom_defines) {
ERR_FAIL_COND(is_compute);
- Version *version = version_owner.getornull(p_version);
+ Version *version = version_owner.get_or_null(p_version);
ERR_FAIL_COND(!version);
version->vertex_globals = p_vertex_globals.utf8();
version->fragment_globals = p_fragment_globals.utf8();
version->uniforms = p_uniforms.utf8();
version->code_sections.clear();
- for (Map<String, String>::Element *E = p_code.front(); E; E = E->next()) {
- version->code_sections[StringName(E->key().to_upper())] = E->get().utf8();
+ for (const KeyValue<String, String> &E : p_code) {
+ version->code_sections[StringName(E.key.to_upper())] = E.value.utf8();
}
version->custom_defines.clear();
@@ -549,15 +549,15 @@ void ShaderRD::version_set_code(RID p_version, const Map<String, String> &p_code
void ShaderRD::version_set_compute_code(RID p_version, const Map<String, String> &p_code, const String &p_uniforms, const String &p_compute_globals, const Vector<String> &p_custom_defines) {
ERR_FAIL_COND(!is_compute);
- Version *version = version_owner.getornull(p_version);
+ Version *version = version_owner.get_or_null(p_version);
ERR_FAIL_COND(!version);
version->compute_globals = p_compute_globals.utf8();
version->uniforms = p_uniforms.utf8();
version->code_sections.clear();
- for (Map<String, String>::Element *E = p_code.front(); E; E = E->next()) {
- version->code_sections[StringName(E->key().to_upper())] = E->get().utf8();
+ for (const KeyValue<String, String> &E : p_code) {
+ version->code_sections[StringName(E.key.to_upper())] = E.value.utf8();
}
version->custom_defines.clear();
@@ -573,7 +573,7 @@ void ShaderRD::version_set_compute_code(RID p_version, const Map<String, String>
}
bool ShaderRD::version_is_valid(RID p_version) {
- Version *version = version_owner.getornull(p_version);
+ Version *version = version_owner.get_or_null(p_version);
ERR_FAIL_COND_V(!version, false);
if (version->dirty) {
@@ -585,7 +585,7 @@ bool ShaderRD::version_is_valid(RID p_version) {
bool ShaderRD::version_free(RID p_version) {
if (version_owner.owns(p_version)) {
- Version *version = version_owner.getornull(p_version);
+ Version *version = version_owner.get_or_null(p_version);
_clear_version(version);
version_owner.free(p_version);
} else {
diff --git a/servers/rendering/renderer_rd/shader_rd.h b/servers/rendering/renderer_rd/shader_rd.h
index 529328f0ed..984b168659 100644
--- a/servers/rendering/renderer_rd/shader_rd.h
+++ b/servers/rendering/renderer_rd/shader_rd.h
@@ -141,7 +141,7 @@ public:
ERR_FAIL_INDEX_V(p_variant, variant_defines.size(), RID());
ERR_FAIL_COND_V(!variants_enabled[p_variant], RID());
- Version *version = version_owner.getornull(p_version);
+ Version *version = version_owner.get_or_null(p_version);
ERR_FAIL_COND_V(!version, RID());
if (version->dirty) {
diff --git a/servers/rendering/renderer_rd/shaders/scene_forward_clustered.glsl b/servers/rendering/renderer_rd/shaders/scene_forward_clustered.glsl
index 8cb56fbc83..f0fb31a457 100644
--- a/servers/rendering/renderer_rd/shaders/scene_forward_clustered.glsl
+++ b/servers/rendering/renderer_rd/shaders/scene_forward_clustered.glsl
@@ -524,7 +524,7 @@ vec4 fog_process(vec3 vertex) {
}
}
- float fog_amount = 1.0 - exp(min(0.0, vertex.z * scene_data.fog_density));
+ float fog_amount = 1.0 - exp(min(0.0, -length(vertex) * scene_data.fog_density));
if (abs(scene_data.fog_height_density) > 0.001) {
float y = (scene_data.camera_matrix * vec4(vertex, 1.0)).y;
diff --git a/servers/rendering/renderer_rd/shaders/scene_forward_mobile.glsl b/servers/rendering/renderer_rd/shaders/scene_forward_mobile.glsl
index c3c4139450..750ec5f00a 100644
--- a/servers/rendering/renderer_rd/shaders/scene_forward_mobile.glsl
+++ b/servers/rendering/renderer_rd/shaders/scene_forward_mobile.glsl
@@ -550,7 +550,7 @@ vec4 fog_process(vec3 vertex) {
}
}
- float fog_amount = 1.0 - exp(min(0.0, vertex.z * scene_data.fog_density));
+ float fog_amount = 1.0 - exp(min(0.0, -length(vertex) * scene_data.fog_density));
if (abs(scene_data.fog_height_density) > 0.001) {
float y = (scene_data.camera_matrix * vec4(vertex, 1.0)).y;
diff --git a/servers/rendering/renderer_scene_cull.cpp b/servers/rendering/renderer_scene_cull.cpp
index a4e4715292..558516ac7c 100644
--- a/servers/rendering/renderer_scene_cull.cpp
+++ b/servers/rendering/renderer_scene_cull.cpp
@@ -47,7 +47,7 @@ void RendererSceneCull::camera_initialize(RID p_rid) {
}
void RendererSceneCull::camera_set_perspective(RID p_camera, float p_fovy_degrees, float p_z_near, float p_z_far) {
- Camera *camera = camera_owner.getornull(p_camera);
+ Camera *camera = camera_owner.get_or_null(p_camera);
ERR_FAIL_COND(!camera);
camera->type = Camera::PERSPECTIVE;
camera->fov = p_fovy_degrees;
@@ -56,7 +56,7 @@ void RendererSceneCull::camera_set_perspective(RID p_camera, float p_fovy_degree
}
void RendererSceneCull::camera_set_orthogonal(RID p_camera, float p_size, float p_z_near, float p_z_far) {
- Camera *camera = camera_owner.getornull(p_camera);
+ Camera *camera = camera_owner.get_or_null(p_camera);
ERR_FAIL_COND(!camera);
camera->type = Camera::ORTHOGONAL;
camera->size = p_size;
@@ -65,7 +65,7 @@ void RendererSceneCull::camera_set_orthogonal(RID p_camera, float p_size, float
}
void RendererSceneCull::camera_set_frustum(RID p_camera, float p_size, Vector2 p_offset, float p_z_near, float p_z_far) {
- Camera *camera = camera_owner.getornull(p_camera);
+ Camera *camera = camera_owner.get_or_null(p_camera);
ERR_FAIL_COND(!camera);
camera->type = Camera::FRUSTUM;
camera->size = p_size;
@@ -75,32 +75,32 @@ void RendererSceneCull::camera_set_frustum(RID p_camera, float p_size, Vector2 p
}
void RendererSceneCull::camera_set_transform(RID p_camera, const Transform3D &p_transform) {
- Camera *camera = camera_owner.getornull(p_camera);
+ Camera *camera = camera_owner.get_or_null(p_camera);
ERR_FAIL_COND(!camera);
camera->transform = p_transform.orthonormalized();
}
void RendererSceneCull::camera_set_cull_mask(RID p_camera, uint32_t p_layers) {
- Camera *camera = camera_owner.getornull(p_camera);
+ Camera *camera = camera_owner.get_or_null(p_camera);
ERR_FAIL_COND(!camera);
camera->visible_layers = p_layers;
}
void RendererSceneCull::camera_set_environment(RID p_camera, RID p_env) {
- Camera *camera = camera_owner.getornull(p_camera);
+ Camera *camera = camera_owner.get_or_null(p_camera);
ERR_FAIL_COND(!camera);
camera->env = p_env;
}
void RendererSceneCull::camera_set_camera_effects(RID p_camera, RID p_fx) {
- Camera *camera = camera_owner.getornull(p_camera);
+ Camera *camera = camera_owner.get_or_null(p_camera);
ERR_FAIL_COND(!camera);
camera->effects = p_fx;
}
void RendererSceneCull::camera_set_use_vertical_aspect(RID p_camera, bool p_enable) {
- Camera *camera = camera_owner.getornull(p_camera);
+ Camera *camera = camera_owner.get_or_null(p_camera);
ERR_FAIL_COND(!camera);
camera->vaspect = p_enable;
}
@@ -354,7 +354,7 @@ RID RendererSceneCull::scenario_allocate() {
void RendererSceneCull::scenario_initialize(RID p_rid) {
scenario_owner.initialize_rid(p_rid);
- Scenario *scenario = scenario_owner.getornull(p_rid);
+ Scenario *scenario = scenario_owner.get_or_null(p_rid);
scenario->self = p_rid;
scenario->reflection_probe_shadow_atlas = scene_render->shadow_atlas_create();
@@ -373,25 +373,25 @@ void RendererSceneCull::scenario_initialize(RID p_rid) {
}
void RendererSceneCull::scenario_set_environment(RID p_scenario, RID p_environment) {
- Scenario *scenario = scenario_owner.getornull(p_scenario);
+ Scenario *scenario = scenario_owner.get_or_null(p_scenario);
ERR_FAIL_COND(!scenario);
scenario->environment = p_environment;
}
void RendererSceneCull::scenario_set_camera_effects(RID p_scenario, RID p_camera_effects) {
- Scenario *scenario = scenario_owner.getornull(p_scenario);
+ Scenario *scenario = scenario_owner.get_or_null(p_scenario);
ERR_FAIL_COND(!scenario);
scenario->camera_effects = p_camera_effects;
}
void RendererSceneCull::scenario_set_fallback_environment(RID p_scenario, RID p_environment) {
- Scenario *scenario = scenario_owner.getornull(p_scenario);
+ Scenario *scenario = scenario_owner.get_or_null(p_scenario);
ERR_FAIL_COND(!scenario);
scenario->fallback_environment = p_environment;
}
void RendererSceneCull::scenario_set_reflection_atlas_size(RID p_scenario, int p_reflection_size, int p_reflection_count) {
- Scenario *scenario = scenario_owner.getornull(p_scenario);
+ Scenario *scenario = scenario_owner.get_or_null(p_scenario);
ERR_FAIL_COND(!scenario);
scene_render->reflection_atlas_set_size(scenario->reflection_atlas, p_reflection_size, p_reflection_count);
}
@@ -401,13 +401,13 @@ bool RendererSceneCull::is_scenario(RID p_scenario) const {
}
RID RendererSceneCull::scenario_get_environment(RID p_scenario) {
- Scenario *scenario = scenario_owner.getornull(p_scenario);
+ Scenario *scenario = scenario_owner.get_or_null(p_scenario);
ERR_FAIL_COND_V(!scenario, RID());
return scenario->environment;
}
void RendererSceneCull::scenario_remove_viewport_visibility_mask(RID p_scenario, RID p_viewport) {
- Scenario *scenario = scenario_owner.getornull(p_scenario);
+ Scenario *scenario = scenario_owner.get_or_null(p_scenario);
ERR_FAIL_COND(!scenario);
if (!scenario->viewport_visibility_masks.has(p_viewport)) {
return;
@@ -419,7 +419,7 @@ void RendererSceneCull::scenario_remove_viewport_visibility_mask(RID p_scenario,
}
void RendererSceneCull::scenario_add_viewport_visibility_mask(RID p_scenario, RID p_viewport) {
- Scenario *scenario = scenario_owner.getornull(p_scenario);
+ Scenario *scenario = scenario_owner.get_or_null(p_scenario);
ERR_FAIL_COND(!scenario);
ERR_FAIL_COND(scenario->viewport_visibility_masks.has(p_viewport));
@@ -459,7 +459,7 @@ RID RendererSceneCull::instance_allocate() {
}
void RendererSceneCull::instance_initialize(RID p_rid) {
instance_owner.initialize_rid(p_rid);
- Instance *instance = instance_owner.getornull(p_rid);
+ Instance *instance = instance_owner.get_or_null(p_rid);
instance->self = p_rid;
}
@@ -493,7 +493,7 @@ void RendererSceneCull::_instance_update_mesh_instance(Instance *p_instance) {
}
void RendererSceneCull::instance_set_base(RID p_instance, RID p_base) {
- Instance *instance = instance_owner.getornull(p_instance);
+ Instance *instance = instance_owner.get_or_null(p_instance);
ERR_FAIL_COND(!instance);
Scenario *scenario = instance->scenario;
@@ -710,7 +710,7 @@ void RendererSceneCull::instance_set_base(RID p_instance, RID p_base) {
}
void RendererSceneCull::instance_set_scenario(RID p_instance, RID p_scenario) {
- Instance *instance = instance_owner.getornull(p_instance);
+ Instance *instance = instance_owner.get_or_null(p_instance);
ERR_FAIL_COND(!instance);
if (instance->scenario) {
@@ -772,7 +772,7 @@ void RendererSceneCull::instance_set_scenario(RID p_instance, RID p_scenario) {
}
if (p_scenario.is_valid()) {
- Scenario *scenario = scenario_owner.getornull(p_scenario);
+ Scenario *scenario = scenario_owner.get_or_null(p_scenario);
ERR_FAIL_COND(!scenario);
instance->scenario = scenario;
@@ -805,7 +805,7 @@ void RendererSceneCull::instance_set_scenario(RID p_instance, RID p_scenario) {
}
void RendererSceneCull::instance_set_layer_mask(RID p_instance, uint32_t p_mask) {
- Instance *instance = instance_owner.getornull(p_instance);
+ Instance *instance = instance_owner.get_or_null(p_instance);
ERR_FAIL_COND(!instance);
instance->layer_mask = p_mask;
@@ -820,7 +820,7 @@ void RendererSceneCull::instance_set_layer_mask(RID p_instance, uint32_t p_mask)
}
void RendererSceneCull::instance_set_transform(RID p_instance, const Transform3D &p_transform) {
- Instance *instance = instance_owner.getornull(p_instance);
+ Instance *instance = instance_owner.get_or_null(p_instance);
ERR_FAIL_COND(!instance);
if (instance->transform == p_transform) {
@@ -845,14 +845,14 @@ void RendererSceneCull::instance_set_transform(RID p_instance, const Transform3D
}
void RendererSceneCull::instance_attach_object_instance_id(RID p_instance, ObjectID p_id) {
- Instance *instance = instance_owner.getornull(p_instance);
+ Instance *instance = instance_owner.get_or_null(p_instance);
ERR_FAIL_COND(!instance);
instance->object_id = p_id;
}
void RendererSceneCull::instance_set_blend_shape_weight(RID p_instance, int p_shape, float p_weight) {
- Instance *instance = instance_owner.getornull(p_instance);
+ Instance *instance = instance_owner.get_or_null(p_instance);
ERR_FAIL_COND(!instance);
if (instance->update_item.in_list()) {
@@ -865,7 +865,7 @@ void RendererSceneCull::instance_set_blend_shape_weight(RID p_instance, int p_sh
}
void RendererSceneCull::instance_set_surface_override_material(RID p_instance, int p_surface, RID p_material) {
- Instance *instance = instance_owner.getornull(p_instance);
+ Instance *instance = instance_owner.get_or_null(p_instance);
ERR_FAIL_COND(!instance);
if (instance->base_type == RS::INSTANCE_MESH) {
@@ -881,7 +881,7 @@ void RendererSceneCull::instance_set_surface_override_material(RID p_instance, i
}
void RendererSceneCull::instance_set_visible(RID p_instance, bool p_visible) {
- Instance *instance = instance_owner.getornull(p_instance);
+ Instance *instance = instance_owner.get_or_null(p_instance);
ERR_FAIL_COND(!instance);
if (instance->visible == p_visible) {
@@ -926,7 +926,7 @@ inline bool is_geometry_instance(RenderingServer::InstanceType p_type) {
}
void RendererSceneCull::instance_set_custom_aabb(RID p_instance, AABB p_aabb) {
- Instance *instance = instance_owner.getornull(p_instance);
+ Instance *instance = instance_owner.get_or_null(p_instance);
ERR_FAIL_COND(!instance);
ERR_FAIL_COND(!is_geometry_instance(instance->base_type));
@@ -951,7 +951,7 @@ void RendererSceneCull::instance_set_custom_aabb(RID p_instance, AABB p_aabb) {
}
void RendererSceneCull::instance_attach_skeleton(RID p_instance, RID p_skeleton) {
- Instance *instance = instance_owner.getornull(p_instance);
+ Instance *instance = instance_owner.get_or_null(p_instance);
ERR_FAIL_COND(!instance);
if (instance->skeleton == p_skeleton) {
@@ -976,7 +976,7 @@ void RendererSceneCull::instance_attach_skeleton(RID p_instance, RID p_skeleton)
}
void RendererSceneCull::instance_set_extra_visibility_margin(RID p_instance, real_t p_margin) {
- Instance *instance = instance_owner.getornull(p_instance);
+ Instance *instance = instance_owner.get_or_null(p_instance);
ERR_FAIL_COND(!instance);
instance->extra_margin = p_margin;
@@ -985,7 +985,7 @@ void RendererSceneCull::instance_set_extra_visibility_margin(RID p_instance, rea
Vector<ObjectID> RendererSceneCull::instances_cull_aabb(const AABB &p_aabb, RID p_scenario) const {
Vector<ObjectID> instances;
- Scenario *scenario = scenario_owner.getornull(p_scenario);
+ Scenario *scenario = scenario_owner.get_or_null(p_scenario);
ERR_FAIL_COND_V(!scenario, instances);
const_cast<RendererSceneCull *>(this)->update_dirty_instances(); // check dirty instances before culling
@@ -1009,7 +1009,7 @@ Vector<ObjectID> RendererSceneCull::instances_cull_aabb(const AABB &p_aabb, RID
Vector<ObjectID> RendererSceneCull::instances_cull_ray(const Vector3 &p_from, const Vector3 &p_to, RID p_scenario) const {
Vector<ObjectID> instances;
- Scenario *scenario = scenario_owner.getornull(p_scenario);
+ Scenario *scenario = scenario_owner.get_or_null(p_scenario);
ERR_FAIL_COND_V(!scenario, instances);
const_cast<RendererSceneCull *>(this)->update_dirty_instances(); // check dirty instances before culling
@@ -1032,7 +1032,7 @@ Vector<ObjectID> RendererSceneCull::instances_cull_ray(const Vector3 &p_from, co
Vector<ObjectID> RendererSceneCull::instances_cull_convex(const Vector<Plane> &p_convex, RID p_scenario) const {
Vector<ObjectID> instances;
- Scenario *scenario = scenario_owner.getornull(p_scenario);
+ Scenario *scenario = scenario_owner.get_or_null(p_scenario);
ERR_FAIL_COND_V(!scenario, instances);
const_cast<RendererSceneCull *>(this)->update_dirty_instances(); // check dirty instances before culling
@@ -1056,7 +1056,7 @@ Vector<ObjectID> RendererSceneCull::instances_cull_convex(const Vector<Plane> &p
}
void RendererSceneCull::instance_geometry_set_flag(RID p_instance, RS::InstanceFlags p_flags, bool p_enabled) {
- Instance *instance = instance_owner.getornull(p_instance);
+ Instance *instance = instance_owner.get_or_null(p_instance);
ERR_FAIL_COND(!instance);
//ERR_FAIL_COND(((1 << instance->base_type) & RS::INSTANCE_GEOMETRY_MASK));
@@ -1131,7 +1131,7 @@ void RendererSceneCull::instance_geometry_set_flag(RID p_instance, RS::InstanceF
}
void RendererSceneCull::instance_geometry_set_cast_shadows_setting(RID p_instance, RS::ShadowCastingSetting p_shadow_casting_setting) {
- Instance *instance = instance_owner.getornull(p_instance);
+ Instance *instance = instance_owner.get_or_null(p_instance);
ERR_FAIL_COND(!instance);
instance->cast_shadows = p_shadow_casting_setting;
@@ -1161,7 +1161,7 @@ void RendererSceneCull::instance_geometry_set_cast_shadows_setting(RID p_instanc
}
void RendererSceneCull::instance_geometry_set_material_override(RID p_instance, RID p_material) {
- Instance *instance = instance_owner.getornull(p_instance);
+ Instance *instance = instance_owner.get_or_null(p_instance);
ERR_FAIL_COND(!instance);
instance->material_override = p_material;
@@ -1174,7 +1174,7 @@ void RendererSceneCull::instance_geometry_set_material_override(RID p_instance,
}
void RendererSceneCull::instance_geometry_set_visibility_range(RID p_instance, float p_min, float p_max, float p_min_margin, float p_max_margin) {
- Instance *instance = instance_owner.getornull(p_instance);
+ Instance *instance = instance_owner.get_or_null(p_instance);
ERR_FAIL_COND(!instance);
instance->visibility_range_begin = p_min;
@@ -1194,7 +1194,7 @@ void RendererSceneCull::instance_geometry_set_visibility_range(RID p_instance, f
}
void RendererSceneCull::instance_set_visibility_parent(RID p_instance, RID p_parent_instance) {
- Instance *instance = instance_owner.getornull(p_instance);
+ Instance *instance = instance_owner.get_or_null(p_instance);
ERR_FAIL_COND(!instance);
Instance *old_parent = instance->visibility_parent;
@@ -1207,7 +1207,7 @@ void RendererSceneCull::instance_set_visibility_parent(RID p_instance, RID p_par
instance->visibility_parent = nullptr;
}
- Instance *parent = instance_owner.getornull(p_parent_instance);
+ Instance *parent = instance_owner.get_or_null(p_parent_instance);
ERR_FAIL_COND(p_parent_instance.is_valid() && !parent);
if (parent) {
@@ -1312,7 +1312,7 @@ void RendererSceneCull::_update_instance_visibility_dependencies(Instance *p_ins
}
void RendererSceneCull::instance_geometry_set_lightmap(RID p_instance, RID p_lightmap, const Rect2 &p_lightmap_uv_scale, int p_slice_index) {
- Instance *instance = instance_owner.getornull(p_instance);
+ Instance *instance = instance_owner.get_or_null(p_instance);
ERR_FAIL_COND(!instance);
if (instance->lightmap) {
@@ -1321,7 +1321,7 @@ void RendererSceneCull::instance_geometry_set_lightmap(RID p_instance, RID p_lig
instance->lightmap = nullptr;
}
- Instance *lightmap_instance = instance_owner.getornull(p_lightmap);
+ Instance *lightmap_instance = instance_owner.get_or_null(p_lightmap);
instance->lightmap = lightmap_instance;
instance->lightmap_uv_scale = p_lightmap_uv_scale;
@@ -1342,7 +1342,7 @@ void RendererSceneCull::instance_geometry_set_lightmap(RID p_instance, RID p_lig
}
void RendererSceneCull::instance_geometry_set_lod_bias(RID p_instance, float p_lod_bias) {
- Instance *instance = instance_owner.getornull(p_instance);
+ Instance *instance = instance_owner.get_or_null(p_instance);
ERR_FAIL_COND(!instance);
instance->lod_bias = p_lod_bias;
@@ -1354,7 +1354,7 @@ void RendererSceneCull::instance_geometry_set_lod_bias(RID p_instance, float p_l
}
void RendererSceneCull::instance_geometry_set_shader_parameter(RID p_instance, const StringName &p_parameter, const Variant &p_value) {
- Instance *instance = instance_owner.getornull(p_instance);
+ Instance *instance = instance_owner.get_or_null(p_instance);
ERR_FAIL_COND(!instance);
ERR_FAIL_COND(p_value.get_type() == Variant::OBJECT);
@@ -1377,7 +1377,7 @@ void RendererSceneCull::instance_geometry_set_shader_parameter(RID p_instance, c
}
Variant RendererSceneCull::instance_geometry_get_shader_parameter(RID p_instance, const StringName &p_parameter) const {
- const Instance *instance = const_cast<RendererSceneCull *>(this)->instance_owner.getornull(p_instance);
+ const Instance *instance = const_cast<RendererSceneCull *>(this)->instance_owner.get_or_null(p_instance);
ERR_FAIL_COND_V(!instance, Variant());
if (instance->instance_shader_parameters.has(p_parameter)) {
@@ -1387,7 +1387,7 @@ Variant RendererSceneCull::instance_geometry_get_shader_parameter(RID p_instance
}
Variant RendererSceneCull::instance_geometry_get_shader_parameter_default_value(RID p_instance, const StringName &p_parameter) const {
- const Instance *instance = const_cast<RendererSceneCull *>(this)->instance_owner.getornull(p_instance);
+ const Instance *instance = const_cast<RendererSceneCull *>(this)->instance_owner.get_or_null(p_instance);
ERR_FAIL_COND_V(!instance, Variant());
if (instance->instance_shader_parameters.has(p_parameter)) {
@@ -1397,14 +1397,14 @@ Variant RendererSceneCull::instance_geometry_get_shader_parameter_default_value(
}
void RendererSceneCull::instance_geometry_get_shader_parameter_list(RID p_instance, List<PropertyInfo> *p_parameters) const {
- const Instance *instance = const_cast<RendererSceneCull *>(this)->instance_owner.getornull(p_instance);
+ const Instance *instance = const_cast<RendererSceneCull *>(this)->instance_owner.get_or_null(p_instance);
ERR_FAIL_COND(!instance);
const_cast<RendererSceneCull *>(this)->update_dirty_instances();
Vector<StringName> names;
- for (Map<StringName, Instance::InstanceShaderParameter>::Element *E = instance->instance_shader_parameters.front(); E; E = E->next()) {
- names.push_back(E->key());
+ for (const KeyValue<StringName, Instance::InstanceShaderParameter> &E : instance->instance_shader_parameters) {
+ names.push_back(E.key);
}
names.sort_custom<StringName::AlphCompare>();
for (int i = 0; i < names.size(); i++) {
@@ -2354,7 +2354,7 @@ bool RendererSceneCull::_light_instance_update_shadow(Instance *p_instance, cons
void RendererSceneCull::render_camera(RID p_render_buffers, RID p_camera, RID p_scenario, RID p_viewport, Size2 p_viewport_size, float p_screen_lod_threshold, RID p_shadow_atlas, Ref<XRInterface> &p_xr_interface, RenderInfo *r_render_info) {
#ifndef _3D_DISABLED
- Camera *camera = camera_owner.getornull(p_camera);
+ Camera *camera = camera_owner.get_or_null(p_camera);
ERR_FAIL_COND(!camera);
RendererSceneRender::CameraData camera_data;
@@ -2747,9 +2747,9 @@ void RendererSceneCull::_scene_cull(CullData &cull_data, InstanceCullResult &cul
}
void RendererSceneCull::_render_scene(const RendererSceneRender::CameraData *p_camera_data, RID p_render_buffers, RID p_environment, RID p_force_camera_effects, uint32_t p_visible_layers, RID p_scenario, RID p_viewport, RID p_shadow_atlas, RID p_reflection_probe, int p_reflection_probe_pass, float p_screen_lod_threshold, bool p_using_shadows, RendererScene::RenderInfo *r_render_info) {
- Instance *render_reflection_probe = instance_owner.getornull(p_reflection_probe); //if null, not rendering to it
+ Instance *render_reflection_probe = instance_owner.get_or_null(p_reflection_probe); //if null, not rendering to it
- Scenario *scenario = scenario_owner.getornull(p_scenario);
+ Scenario *scenario = scenario_owner.get_or_null(p_scenario);
render_pass++;
@@ -3103,12 +3103,12 @@ void RendererSceneCull::_render_scene(const RendererSceneRender::CameraData *p_c
}
RID RendererSceneCull::_render_get_environment(RID p_camera, RID p_scenario) {
- Camera *camera = camera_owner.getornull(p_camera);
+ Camera *camera = camera_owner.get_or_null(p_camera);
if (camera && scene_render->is_environment(camera->env)) {
return camera->env;
}
- Scenario *scenario = scenario_owner.getornull(p_scenario);
+ Scenario *scenario = scenario_owner.get_or_null(p_scenario);
if (!scenario) {
return RID();
}
@@ -3125,7 +3125,7 @@ RID RendererSceneCull::_render_get_environment(RID p_camera, RID p_scenario) {
void RendererSceneCull::render_empty_scene(RID p_render_buffers, RID p_scenario, RID p_shadow_atlas) {
#ifndef _3D_DISABLED
- Scenario *scenario = scenario_owner.getornull(p_scenario);
+ Scenario *scenario = scenario_owner.get_or_null(p_scenario);
RID environment;
if (scenario->environment.is_valid()) {
@@ -3688,9 +3688,9 @@ void RendererSceneCull::_update_dirty_instance(Instance *p_instance) {
p_instance->instance_allocated_shader_parameters_offset = RSG::storage->global_variables_instance_allocate(p_instance->self);
scene_render->geometry_instance_set_instance_shader_parameters_offset(geom->geometry_instance, p_instance->instance_allocated_shader_parameters_offset);
- for (Map<StringName, Instance::InstanceShaderParameter>::Element *E = p_instance->instance_shader_parameters.front(); E; E = E->next()) {
- if (E->get().value.get_type() != Variant::NIL) {
- RSG::storage->global_variables_instance_update(p_instance->self, E->get().index, E->get().value);
+ for (const KeyValue<StringName, Instance::InstanceShaderParameter> &E : p_instance->instance_shader_parameters) {
+ if (E.value.value.get_type() != Variant::NIL) {
+ RSG::storage->global_variables_instance_update(p_instance->self, E.value.index, E.value.value);
}
}
} else {
@@ -3750,7 +3750,7 @@ bool RendererSceneCull::free(RID p_rid) {
camera_owner.free(p_rid);
} else if (scenario_owner.owns(p_rid)) {
- Scenario *scenario = scenario_owner.getornull(p_rid);
+ Scenario *scenario = scenario_owner.get_or_null(p_rid);
while (scenario->instances.first()) {
instance_set_scenario(scenario->instances.first()->self()->self, RID());
@@ -3771,7 +3771,7 @@ bool RendererSceneCull::free(RID p_rid) {
update_dirty_instances();
- Instance *instance = instance_owner.getornull(p_rid);
+ Instance *instance = instance_owner.get_or_null(p_rid);
instance_geometry_set_lightmap(p_rid, RID(), Rect2(), 0);
instance_set_scenario(p_rid, RID());
diff --git a/servers/rendering/renderer_storage.cpp b/servers/rendering/renderer_storage.cpp
index a402ecc668..aa005fac0a 100644
--- a/servers/rendering/renderer_storage.cpp
+++ b/servers/rendering/renderer_storage.cpp
@@ -33,21 +33,21 @@
RendererStorage *RendererStorage::base_singleton = nullptr;
void RendererStorage::Dependency::changed_notify(DependencyChangedNotification p_notification) {
- for (Map<DependencyTracker *, uint32_t>::Element *E = instances.front(); E; E = E->next()) {
- if (E->key()->changed_callback) {
- E->key()->changed_callback(p_notification, E->key());
+ for (const KeyValue<DependencyTracker *, uint32_t> &E : instances) {
+ if (E.key->changed_callback) {
+ E.key->changed_callback(p_notification, E.key);
}
}
}
void RendererStorage::Dependency::deleted_notify(const RID &p_rid) {
- for (Map<DependencyTracker *, uint32_t>::Element *E = instances.front(); E; E = E->next()) {
- if (E->key()->deleted_callback) {
- E->key()->deleted_callback(p_rid, E->key());
+ for (const KeyValue<DependencyTracker *, uint32_t> &E : instances) {
+ if (E.key->deleted_callback) {
+ E.key->deleted_callback(p_rid, E.key);
}
}
- for (Map<DependencyTracker *, uint32_t>::Element *E = instances.front(); E; E = E->next()) {
- E->key()->dependencies.erase(this);
+ for (const KeyValue<DependencyTracker *, uint32_t> &E : instances) {
+ E.key->dependencies.erase(this);
}
instances.clear();
}
@@ -56,8 +56,8 @@ RendererStorage::Dependency::~Dependency() {
#ifdef DEBUG_ENABLED
if (instances.size()) {
WARN_PRINT("Leaked instance dependency: Bug - did not call instance_notify_deleted when freeing.");
- for (Map<DependencyTracker *, uint32_t>::Element *E = instances.front(); E; E = E->next()) {
- E->key()->dependencies.erase(this);
+ for (const KeyValue<DependencyTracker *, uint32_t> &E : instances) {
+ E.key->dependencies.erase(this);
}
}
#endif
diff --git a/servers/rendering/renderer_viewport.cpp b/servers/rendering/renderer_viewport.cpp
index 8af2049ab3..74f18b1da5 100644
--- a/servers/rendering/renderer_viewport.cpp
+++ b/servers/rendering/renderer_viewport.cpp
@@ -210,9 +210,9 @@ void RendererViewport::_draw_viewport(Viewport *p_viewport) {
RendererCanvasRender::LightOccluderInstance *occluders = nullptr;
//make list of occluders
- for (Map<RID, Viewport::CanvasData>::Element *E = p_viewport->canvas_map.front(); E; E = E->next()) {
- RendererCanvasCull::Canvas *canvas = static_cast<RendererCanvasCull::Canvas *>(E->get().canvas);
- Transform2D xf = _canvas_get_transform(p_viewport, canvas, &E->get(), clip_rect.size);
+ for (KeyValue<RID, Viewport::CanvasData> &E : p_viewport->canvas_map) {
+ RendererCanvasCull::Canvas *canvas = static_cast<RendererCanvasCull::Canvas *>(E.value.canvas);
+ Transform2D xf = _canvas_get_transform(p_viewport, canvas, &E.value, clip_rect.size);
for (Set<RendererCanvasRender::LightOccluderInstance *>::Element *F = canvas->occluders.front(); F; F = F->next()) {
if (!F->get()->enabled) {
@@ -242,10 +242,10 @@ void RendererViewport::_draw_viewport(Viewport *p_viewport) {
int directional_light_count = 0;
RENDER_TIMESTAMP("Cull Canvas Lights");
- for (Map<RID, Viewport::CanvasData>::Element *E = p_viewport->canvas_map.front(); E; E = E->next()) {
- RendererCanvasCull::Canvas *canvas = static_cast<RendererCanvasCull::Canvas *>(E->get().canvas);
+ for (KeyValue<RID, Viewport::CanvasData> &E : p_viewport->canvas_map) {
+ RendererCanvasCull::Canvas *canvas = static_cast<RendererCanvasCull::Canvas *>(E.value.canvas);
- Transform2D xf = _canvas_get_transform(p_viewport, canvas, &E->get(), clip_rect.size);
+ Transform2D xf = _canvas_get_transform(p_viewport, canvas, &E.value, clip_rect.size);
//find lights in canvas
@@ -307,7 +307,7 @@ void RendererViewport::_draw_viewport(Viewport *p_viewport) {
}
}
- canvas_map[Viewport::CanvasKey(E->key(), E->get().layer, E->get().sublayer)] = &E->get();
+ canvas_map[Viewport::CanvasKey(E.key, E.value.layer, E.value.sublayer)] = &E.value;
}
if (lights_with_shadow) {
@@ -319,9 +319,9 @@ void RendererViewport::_draw_viewport(Viewport *p_viewport) {
RENDER_TIMESTAMP("Cull Occluders");
//make list of occluders
- for (Map<RID, Viewport::CanvasData>::Element *E = p_viewport->canvas_map.front(); E; E = E->next()) {
- RendererCanvasCull::Canvas *canvas = static_cast<RendererCanvasCull::Canvas *>(E->get().canvas);
- Transform2D xf = _canvas_get_transform(p_viewport, canvas, &E->get(), clip_rect.size);
+ for (KeyValue<RID, Viewport::CanvasData> &E : p_viewport->canvas_map) {
+ RendererCanvasCull::Canvas *canvas = static_cast<RendererCanvasCull::Canvas *>(E.value.canvas);
+ Transform2D xf = _canvas_get_transform(p_viewport, canvas, &E.value, clip_rect.size);
for (Set<RendererCanvasRender::LightOccluderInstance *>::Element *F = canvas->occluders.front(); F; F = F->next()) {
if (!F->get()->enabled) {
@@ -400,9 +400,9 @@ void RendererViewport::_draw_viewport(Viewport *p_viewport) {
//make list of occluders
int occ_cullded = 0;
- for (Map<RID, Viewport::CanvasData>::Element *E = p_viewport->canvas_map.front(); E; E = E->next()) {
- RendererCanvasCull::Canvas *canvas = static_cast<RendererCanvasCull::Canvas *>(E->get().canvas);
- Transform2D xf = _canvas_get_transform(p_viewport, canvas, &E->get(), clip_rect.size);
+ for (KeyValue<RID, Viewport::CanvasData> &E : p_viewport->canvas_map) {
+ RendererCanvasCull::Canvas *canvas = static_cast<RendererCanvasCull::Canvas *>(E.value.canvas);
+ Transform2D xf = _canvas_get_transform(p_viewport, canvas, &E.value, clip_rect.size);
for (Set<RendererCanvasRender::LightOccluderInstance *>::Element *F = canvas->occluders.front(); F; F = F->next()) {
if (!F->get()->enabled) {
@@ -439,17 +439,17 @@ void RendererViewport::_draw_viewport(Viewport *p_viewport) {
scenario_draw_canvas_bg = false;
}
- for (Map<Viewport::CanvasKey, Viewport::CanvasData *>::Element *E = canvas_map.front(); E; E = E->next()) {
- RendererCanvasCull::Canvas *canvas = static_cast<RendererCanvasCull::Canvas *>(E->get()->canvas);
+ for (const KeyValue<Viewport::CanvasKey, Viewport::CanvasData *> &E : canvas_map) {
+ RendererCanvasCull::Canvas *canvas = static_cast<RendererCanvasCull::Canvas *>(E.value->canvas);
- Transform2D xform = _canvas_get_transform(p_viewport, canvas, E->get(), clip_rect.size);
+ Transform2D xform = _canvas_get_transform(p_viewport, canvas, E.value, clip_rect.size);
RendererCanvasRender::Light *canvas_lights = nullptr;
RendererCanvasRender::Light *canvas_directional_lights = nullptr;
RendererCanvasRender::Light *ptr = lights;
while (ptr) {
- if (E->get()->layer >= ptr->layer_min && E->get()->layer <= ptr->layer_max) {
+ if (E.value->layer >= ptr->layer_min && E.value->layer <= ptr->layer_max) {
ptr->next_ptr = canvas_lights;
canvas_lights = ptr;
}
@@ -458,7 +458,7 @@ void RendererViewport::_draw_viewport(Viewport *p_viewport) {
ptr = directional_lights;
while (ptr) {
- if (E->get()->layer >= ptr->layer_min && E->get()->layer <= ptr->layer_max) {
+ if (E.value->layer >= ptr->layer_min && E.value->layer <= ptr->layer_max) {
ptr->next_ptr = canvas_directional_lights;
canvas_directional_lights = ptr;
}
@@ -471,7 +471,7 @@ void RendererViewport::_draw_viewport(Viewport *p_viewport) {
}
i++;
- if (scenario_draw_canvas_bg && E->key().get_layer() >= scenario_canvas_max_layer) {
+ if (scenario_draw_canvas_bg && E.key.get_layer() >= scenario_canvas_max_layer) {
if (!can_draw_3d) {
RSG::scene->render_empty_scene(p_viewport->render_buffers, p_viewport->scenario, p_viewport->shadow_atlas);
} else {
@@ -554,7 +554,7 @@ void RendererViewport::draw_viewports() {
}
if (vp->update_mode == RS::VIEWPORT_UPDATE_WHEN_PARENT_VISIBLE) {
- Viewport *parent = viewport_owner.getornull(vp->parent);
+ Viewport *parent = viewport_owner.get_or_null(vp->parent);
if (parent && parent->last_pass == draw_viewports_pass) {
visible = true;
}
@@ -660,8 +660,8 @@ void RendererViewport::draw_viewports() {
//this needs to be called to make screen swapping more efficient
RSG::rasterizer->prepare_for_blitting_render_targets();
- for (Map<int, Vector<BlitToScreen>>::Element *E = blit_to_screen_list.front(); E; E = E->next()) {
- RSG::rasterizer->blit_render_targets_to_screen(E->key(), E->get().ptr(), E->get().size());
+ for (const KeyValue<int, Vector<BlitToScreen>> &E : blit_to_screen_list) {
+ RSG::rasterizer->blit_render_targets_to_screen(E.key, E.value.ptr(), E.value.size());
}
}
@@ -671,7 +671,7 @@ RID RendererViewport::viewport_allocate() {
void RendererViewport::viewport_initialize(RID p_rid) {
viewport_owner.initialize_rid(p_rid);
- Viewport *viewport = viewport_owner.getornull(p_rid);
+ Viewport *viewport = viewport_owner.get_or_null(p_rid);
viewport->self = p_rid;
viewport->render_target = RSG::storage->render_target_create();
viewport->shadow_atlas = RSG::scene->shadow_atlas_create();
@@ -679,7 +679,7 @@ void RendererViewport::viewport_initialize(RID p_rid) {
}
void RendererViewport::viewport_set_use_xr(RID p_viewport, bool p_use_xr) {
- Viewport *viewport = viewport_owner.getornull(p_viewport);
+ Viewport *viewport = viewport_owner.get_or_null(p_viewport);
ERR_FAIL_COND(!viewport);
if (viewport->use_xr == p_use_xr) {
@@ -691,7 +691,7 @@ void RendererViewport::viewport_set_use_xr(RID p_viewport, bool p_use_xr) {
}
void RendererViewport::viewport_set_scale_3d(RID p_viewport, RenderingServer::ViewportScale3D p_scale_3d) {
- Viewport *viewport = viewport_owner.getornull(p_viewport);
+ Viewport *viewport = viewport_owner.get_or_null(p_viewport);
ERR_FAIL_COND(!viewport);
if (viewport->scale_3d == p_scale_3d) {
@@ -720,7 +720,7 @@ uint32_t RendererViewport::Viewport::get_view_count() {
void RendererViewport::viewport_set_size(RID p_viewport, int p_width, int p_height) {
ERR_FAIL_COND(p_width < 0 && p_height < 0);
- Viewport *viewport = viewport_owner.getornull(p_viewport);
+ Viewport *viewport = viewport_owner.get_or_null(p_viewport);
ERR_FAIL_COND(!viewport);
viewport->size = Size2(p_width, p_height);
@@ -732,7 +732,7 @@ void RendererViewport::viewport_set_size(RID p_viewport, int p_width, int p_heig
}
void RendererViewport::viewport_set_active(RID p_viewport, bool p_active) {
- Viewport *viewport = viewport_owner.getornull(p_viewport);
+ Viewport *viewport = viewport_owner.get_or_null(p_viewport);
ERR_FAIL_COND(!viewport);
if (p_active) {
@@ -745,21 +745,21 @@ void RendererViewport::viewport_set_active(RID p_viewport, bool p_active) {
}
void RendererViewport::viewport_set_parent_viewport(RID p_viewport, RID p_parent_viewport) {
- Viewport *viewport = viewport_owner.getornull(p_viewport);
+ Viewport *viewport = viewport_owner.get_or_null(p_viewport);
ERR_FAIL_COND(!viewport);
viewport->parent = p_parent_viewport;
}
void RendererViewport::viewport_set_clear_mode(RID p_viewport, RS::ViewportClearMode p_clear_mode) {
- Viewport *viewport = viewport_owner.getornull(p_viewport);
+ Viewport *viewport = viewport_owner.get_or_null(p_viewport);
ERR_FAIL_COND(!viewport);
viewport->clear_mode = p_clear_mode;
}
void RendererViewport::viewport_attach_to_screen(RID p_viewport, const Rect2 &p_rect, DisplayServer::WindowID p_screen) {
- Viewport *viewport = viewport_owner.getornull(p_viewport);
+ Viewport *viewport = viewport_owner.get_or_null(p_viewport);
ERR_FAIL_COND(!viewport);
if (p_screen != DisplayServer::INVALID_WINDOW_ID) {
@@ -785,7 +785,7 @@ void RendererViewport::viewport_attach_to_screen(RID p_viewport, const Rect2 &p_
}
void RendererViewport::viewport_set_render_direct_to_screen(RID p_viewport, bool p_enable) {
- Viewport *viewport = viewport_owner.getornull(p_viewport);
+ Viewport *viewport = viewport_owner.get_or_null(p_viewport);
ERR_FAIL_COND(!viewport);
if (p_enable == viewport->viewport_render_direct_to_screen) {
@@ -809,21 +809,21 @@ void RendererViewport::viewport_set_render_direct_to_screen(RID p_viewport, bool
}
void RendererViewport::viewport_set_update_mode(RID p_viewport, RS::ViewportUpdateMode p_mode) {
- Viewport *viewport = viewport_owner.getornull(p_viewport);
+ Viewport *viewport = viewport_owner.get_or_null(p_viewport);
ERR_FAIL_COND(!viewport);
viewport->update_mode = p_mode;
}
RID RendererViewport::viewport_get_texture(RID p_viewport) const {
- const Viewport *viewport = viewport_owner.getornull(p_viewport);
+ const Viewport *viewport = viewport_owner.get_or_null(p_viewport);
ERR_FAIL_COND_V(!viewport, RID());
return RSG::storage->render_target_get_texture(viewport->render_target);
}
RID RendererViewport::viewport_get_occluder_debug_texture(RID p_viewport) const {
- const Viewport *viewport = viewport_owner.getornull(p_viewport);
+ const Viewport *viewport = viewport_owner.get_or_null(p_viewport);
ERR_FAIL_COND_V(!viewport, RID());
if (viewport->use_occlusion_culling && viewport->debug_draw == RenderingServer::VIEWPORT_DEBUG_DRAW_OCCLUDERS) {
@@ -833,35 +833,35 @@ RID RendererViewport::viewport_get_occluder_debug_texture(RID p_viewport) const
}
void RendererViewport::viewport_set_disable_2d(RID p_viewport, bool p_disable) {
- Viewport *viewport = viewport_owner.getornull(p_viewport);
+ Viewport *viewport = viewport_owner.get_or_null(p_viewport);
ERR_FAIL_COND(!viewport);
viewport->disable_2d = p_disable;
}
void RendererViewport::viewport_set_disable_environment(RID p_viewport, bool p_disable) {
- Viewport *viewport = viewport_owner.getornull(p_viewport);
+ Viewport *viewport = viewport_owner.get_or_null(p_viewport);
ERR_FAIL_COND(!viewport);
viewport->disable_environment = p_disable;
}
void RendererViewport::viewport_set_disable_3d(RID p_viewport, bool p_disable) {
- Viewport *viewport = viewport_owner.getornull(p_viewport);
+ Viewport *viewport = viewport_owner.get_or_null(p_viewport);
ERR_FAIL_COND(!viewport);
viewport->disable_3d = p_disable;
}
void RendererViewport::viewport_attach_camera(RID p_viewport, RID p_camera) {
- Viewport *viewport = viewport_owner.getornull(p_viewport);
+ Viewport *viewport = viewport_owner.get_or_null(p_viewport);
ERR_FAIL_COND(!viewport);
viewport->camera = p_camera;
}
void RendererViewport::viewport_set_scenario(RID p_viewport, RID p_scenario) {
- Viewport *viewport = viewport_owner.getornull(p_viewport);
+ Viewport *viewport = viewport_owner.get_or_null(p_viewport);
ERR_FAIL_COND(!viewport);
if (viewport->scenario.is_valid()) {
@@ -875,11 +875,11 @@ void RendererViewport::viewport_set_scenario(RID p_viewport, RID p_scenario) {
}
void RendererViewport::viewport_attach_canvas(RID p_viewport, RID p_canvas) {
- Viewport *viewport = viewport_owner.getornull(p_viewport);
+ Viewport *viewport = viewport_owner.get_or_null(p_viewport);
ERR_FAIL_COND(!viewport);
ERR_FAIL_COND(viewport->canvas_map.has(p_canvas));
- RendererCanvasCull::Canvas *canvas = RSG::canvas->canvas_owner.getornull(p_canvas);
+ RendererCanvasCull::Canvas *canvas = RSG::canvas->canvas_owner.get_or_null(p_canvas);
ERR_FAIL_COND(!canvas);
canvas->viewports.insert(p_viewport);
@@ -890,10 +890,10 @@ void RendererViewport::viewport_attach_canvas(RID p_viewport, RID p_canvas) {
}
void RendererViewport::viewport_remove_canvas(RID p_viewport, RID p_canvas) {
- Viewport *viewport = viewport_owner.getornull(p_viewport);
+ Viewport *viewport = viewport_owner.get_or_null(p_viewport);
ERR_FAIL_COND(!viewport);
- RendererCanvasCull::Canvas *canvas = RSG::canvas->canvas_owner.getornull(p_canvas);
+ RendererCanvasCull::Canvas *canvas = RSG::canvas->canvas_owner.get_or_null(p_canvas);
ERR_FAIL_COND(!canvas);
viewport->canvas_map.erase(p_canvas);
@@ -901,7 +901,7 @@ void RendererViewport::viewport_remove_canvas(RID p_viewport, RID p_canvas) {
}
void RendererViewport::viewport_set_canvas_transform(RID p_viewport, RID p_canvas, const Transform2D &p_offset) {
- Viewport *viewport = viewport_owner.getornull(p_viewport);
+ Viewport *viewport = viewport_owner.get_or_null(p_viewport);
ERR_FAIL_COND(!viewport);
ERR_FAIL_COND(!viewport->canvas_map.has(p_canvas));
@@ -909,7 +909,7 @@ void RendererViewport::viewport_set_canvas_transform(RID p_viewport, RID p_canva
}
void RendererViewport::viewport_set_transparent_background(RID p_viewport, bool p_enabled) {
- Viewport *viewport = viewport_owner.getornull(p_viewport);
+ Viewport *viewport = viewport_owner.get_or_null(p_viewport);
ERR_FAIL_COND(!viewport);
RSG::storage->render_target_set_flag(viewport->render_target, RendererStorage::RENDER_TARGET_TRANSPARENT, p_enabled);
@@ -917,14 +917,14 @@ void RendererViewport::viewport_set_transparent_background(RID p_viewport, bool
}
void RendererViewport::viewport_set_global_canvas_transform(RID p_viewport, const Transform2D &p_transform) {
- Viewport *viewport = viewport_owner.getornull(p_viewport);
+ Viewport *viewport = viewport_owner.get_or_null(p_viewport);
ERR_FAIL_COND(!viewport);
viewport->global_transform = p_transform;
}
void RendererViewport::viewport_set_canvas_stacking(RID p_viewport, RID p_canvas, int p_layer, int p_sublayer) {
- Viewport *viewport = viewport_owner.getornull(p_viewport);
+ Viewport *viewport = viewport_owner.get_or_null(p_viewport);
ERR_FAIL_COND(!viewport);
ERR_FAIL_COND(!viewport->canvas_map.has(p_canvas));
@@ -933,7 +933,7 @@ void RendererViewport::viewport_set_canvas_stacking(RID p_viewport, RID p_canvas
}
void RendererViewport::viewport_set_shadow_atlas_size(RID p_viewport, int p_size, bool p_16_bits) {
- Viewport *viewport = viewport_owner.getornull(p_viewport);
+ Viewport *viewport = viewport_owner.get_or_null(p_viewport);
ERR_FAIL_COND(!viewport);
viewport->shadow_atlas_size = p_size;
@@ -943,14 +943,14 @@ void RendererViewport::viewport_set_shadow_atlas_size(RID p_viewport, int p_size
}
void RendererViewport::viewport_set_shadow_atlas_quadrant_subdivision(RID p_viewport, int p_quadrant, int p_subdiv) {
- Viewport *viewport = viewport_owner.getornull(p_viewport);
+ Viewport *viewport = viewport_owner.get_or_null(p_viewport);
ERR_FAIL_COND(!viewport);
RSG::scene->shadow_atlas_set_quadrant_subdivision(viewport->shadow_atlas, p_quadrant, p_subdiv);
}
void RendererViewport::viewport_set_msaa(RID p_viewport, RS::ViewportMSAA p_msaa) {
- Viewport *viewport = viewport_owner.getornull(p_viewport);
+ Viewport *viewport = viewport_owner.get_or_null(p_viewport);
ERR_FAIL_COND(!viewport);
if (viewport->msaa == p_msaa) {
@@ -961,7 +961,7 @@ void RendererViewport::viewport_set_msaa(RID p_viewport, RS::ViewportMSAA p_msaa
}
void RendererViewport::viewport_set_screen_space_aa(RID p_viewport, RS::ViewportScreenSpaceAA p_mode) {
- Viewport *viewport = viewport_owner.getornull(p_viewport);
+ Viewport *viewport = viewport_owner.get_or_null(p_viewport);
ERR_FAIL_COND(!viewport);
if (viewport->screen_space_aa == p_mode) {
@@ -972,7 +972,7 @@ void RendererViewport::viewport_set_screen_space_aa(RID p_viewport, RS::Viewport
}
void RendererViewport::viewport_set_use_debanding(RID p_viewport, bool p_use_debanding) {
- Viewport *viewport = viewport_owner.getornull(p_viewport);
+ Viewport *viewport = viewport_owner.get_or_null(p_viewport);
ERR_FAIL_COND(!viewport);
if (viewport->use_debanding == p_use_debanding) {
@@ -983,7 +983,7 @@ void RendererViewport::viewport_set_use_debanding(RID p_viewport, bool p_use_deb
}
void RendererViewport::viewport_set_use_occlusion_culling(RID p_viewport, bool p_use_occlusion_culling) {
- Viewport *viewport = viewport_owner.getornull(p_viewport);
+ Viewport *viewport = viewport_owner.get_or_null(p_viewport);
ERR_FAIL_COND(!viewport);
if (viewport->use_occlusion_culling == p_use_occlusion_culling) {
@@ -1018,7 +1018,7 @@ void RendererViewport::viewport_set_occlusion_culling_build_quality(RS::Viewport
}
void RendererViewport::viewport_set_lod_threshold(RID p_viewport, float p_pixels) {
- Viewport *viewport = viewport_owner.getornull(p_viewport);
+ Viewport *viewport = viewport_owner.get_or_null(p_viewport);
ERR_FAIL_COND(!viewport);
viewport->lod_threshold = p_pixels;
@@ -1027,7 +1027,7 @@ void RendererViewport::viewport_set_lod_threshold(RID p_viewport, float p_pixels
int RendererViewport::viewport_get_render_info(RID p_viewport, RS::ViewportRenderInfoType p_type, RS::ViewportRenderInfo p_info) {
ERR_FAIL_INDEX_V(p_info, RS::VIEWPORT_RENDER_INFO_MAX, -1);
- Viewport *viewport = viewport_owner.getornull(p_viewport);
+ Viewport *viewport = viewport_owner.get_or_null(p_viewport);
if (!viewport) {
return 0; //there should be a lock here..
}
@@ -1036,62 +1036,62 @@ int RendererViewport::viewport_get_render_info(RID p_viewport, RS::ViewportRende
}
void RendererViewport::viewport_set_debug_draw(RID p_viewport, RS::ViewportDebugDraw p_draw) {
- Viewport *viewport = viewport_owner.getornull(p_viewport);
+ Viewport *viewport = viewport_owner.get_or_null(p_viewport);
ERR_FAIL_COND(!viewport);
viewport->debug_draw = p_draw;
}
void RendererViewport::viewport_set_measure_render_time(RID p_viewport, bool p_enable) {
- Viewport *viewport = viewport_owner.getornull(p_viewport);
+ Viewport *viewport = viewport_owner.get_or_null(p_viewport);
ERR_FAIL_COND(!viewport);
viewport->measure_render_time = p_enable;
}
float RendererViewport::viewport_get_measured_render_time_cpu(RID p_viewport) const {
- Viewport *viewport = viewport_owner.getornull(p_viewport);
+ Viewport *viewport = viewport_owner.get_or_null(p_viewport);
ERR_FAIL_COND_V(!viewport, 0);
return double(viewport->time_cpu_end - viewport->time_cpu_begin) / 1000.0;
}
float RendererViewport::viewport_get_measured_render_time_gpu(RID p_viewport) const {
- Viewport *viewport = viewport_owner.getornull(p_viewport);
+ Viewport *viewport = viewport_owner.get_or_null(p_viewport);
ERR_FAIL_COND_V(!viewport, 0);
return double((viewport->time_gpu_end - viewport->time_gpu_begin) / 1000) / 1000.0;
}
void RendererViewport::viewport_set_snap_2d_transforms_to_pixel(RID p_viewport, bool p_enabled) {
- Viewport *viewport = viewport_owner.getornull(p_viewport);
+ Viewport *viewport = viewport_owner.get_or_null(p_viewport);
ERR_FAIL_COND(!viewport);
viewport->snap_2d_transforms_to_pixel = p_enabled;
}
void RendererViewport::viewport_set_snap_2d_vertices_to_pixel(RID p_viewport, bool p_enabled) {
- Viewport *viewport = viewport_owner.getornull(p_viewport);
+ Viewport *viewport = viewport_owner.get_or_null(p_viewport);
ERR_FAIL_COND(!viewport);
viewport->snap_2d_vertices_to_pixel = p_enabled;
}
void RendererViewport::viewport_set_default_canvas_item_texture_filter(RID p_viewport, RS::CanvasItemTextureFilter p_filter) {
ERR_FAIL_COND_MSG(p_filter == RS::CANVAS_ITEM_TEXTURE_FILTER_DEFAULT, "Viewport does not accept DEFAULT as texture filter (it's the topmost choice already).)");
- Viewport *viewport = viewport_owner.getornull(p_viewport);
+ Viewport *viewport = viewport_owner.get_or_null(p_viewport);
ERR_FAIL_COND(!viewport);
viewport->texture_filter = p_filter;
}
void RendererViewport::viewport_set_default_canvas_item_texture_repeat(RID p_viewport, RS::CanvasItemTextureRepeat p_repeat) {
ERR_FAIL_COND_MSG(p_repeat == RS::CANVAS_ITEM_TEXTURE_REPEAT_DEFAULT, "Viewport does not accept DEFAULT as texture repeat (it's the topmost choice already).)");
- Viewport *viewport = viewport_owner.getornull(p_viewport);
+ Viewport *viewport = viewport_owner.get_or_null(p_viewport);
ERR_FAIL_COND(!viewport);
viewport->texture_repeat = p_repeat;
}
void RendererViewport::viewport_set_sdf_oversize_and_scale(RID p_viewport, RS::ViewportSDFOversize p_size, RS::ViewportSDFScale p_scale) {
- Viewport *viewport = viewport_owner.getornull(p_viewport);
+ Viewport *viewport = viewport_owner.get_or_null(p_viewport);
ERR_FAIL_COND(!viewport);
RSG::storage->render_target_set_sdf_size_and_scale(viewport->render_target, p_size, p_scale);
@@ -1099,7 +1099,7 @@ void RendererViewport::viewport_set_sdf_oversize_and_scale(RID p_viewport, RS::V
bool RendererViewport::free(RID p_rid) {
if (viewport_owner.owns(p_rid)) {
- Viewport *viewport = viewport_owner.getornull(p_rid);
+ Viewport *viewport = viewport_owner.get_or_null(p_rid);
RSG::storage->free(viewport->render_target);
RSG::scene->free(viewport->shadow_atlas);
@@ -1132,7 +1132,7 @@ void RendererViewport::handle_timestamp(String p_timestamp, uint64_t p_cpu_time,
return;
}
- Viewport *viewport = viewport_owner.getornull(*vp);
+ Viewport *viewport = viewport_owner.get_or_null(*vp);
if (!viewport) {
return;
}
diff --git a/servers/rendering/rendering_device_binds.cpp b/servers/rendering/rendering_device_binds.cpp
index fa3f2f3895..a21f28989b 100644
--- a/servers/rendering/rendering_device_binds.cpp
+++ b/servers/rendering/rendering_device_binds.cpp
@@ -171,7 +171,7 @@ Error RDShaderFile::parse_versions_from_text(const String &p_text, const String
/* STEP 2, Compile the versions, add to shader file */
- for (Map<StringName, String>::Element *E = version_texts.front(); E; E = E->next()) {
+ for (const KeyValue<StringName, String> &E : version_texts) {
Ref<RDShaderSPIRV> bytecode;
bytecode.instantiate();
@@ -180,7 +180,7 @@ Error RDShaderFile::parse_versions_from_text(const String &p_text, const String
if (code == String()) {
continue;
}
- code = code.replace("VERSION_DEFINES", E->get());
+ code = code.replace("VERSION_DEFINES", E.value);
String error;
Vector<uint8_t> spirv = RenderingDevice::get_singleton()->shader_compile_spirv_from_source(RD::ShaderStage(i), code, RD::SHADER_LANGUAGE_GLSL, &error, false);
bytecode->set_stage_bytecode(RD::ShaderStage(i), spirv);
@@ -195,7 +195,7 @@ Error RDShaderFile::parse_versions_from_text(const String &p_text, const String
bytecode->set_stage_compile_error(RD::ShaderStage(i), error);
}
- set_bytecode(bytecode, E->key());
+ set_bytecode(bytecode, E.key);
}
return errors_found ? ERR_PARSE_ERROR : OK;
diff --git a/servers/rendering/rendering_device_binds.h b/servers/rendering/rendering_device_binds.h
index ccc3e2fb39..da614877c4 100644
--- a/servers/rendering/rendering_device_binds.h
+++ b/servers/rendering/rendering_device_binds.h
@@ -351,8 +351,8 @@ public:
Vector<StringName> get_version_list() const {
Vector<StringName> vnames;
- for (Map<StringName, Ref<RDShaderSPIRV>>::Element *E = versions.front(); E; E = E->next()) {
- vnames.push_back(E->key());
+ for (const KeyValue<StringName, Ref<RDShaderSPIRV>> &E : versions) {
+ vnames.push_back(E.key);
}
vnames.sort_custom<StringName::AlphCompare>();
return vnames;
@@ -371,9 +371,9 @@ public:
if (base_error != "") {
ERR_PRINT("Error parsing shader '" + p_file + "':\n\n" + base_error);
} else {
- for (Map<StringName, Ref<RDShaderSPIRV>>::Element *E = versions.front(); E; E = E->next()) {
+ for (KeyValue<StringName, Ref<RDShaderSPIRV>> &E : versions) {
for (int i = 0; i < RD::SHADER_STAGE_MAX; i++) {
- String error = E->get()->get_stage_compile_error(RD::ShaderStage(i));
+ String error = E.value->get_stage_compile_error(RD::ShaderStage(i));
if (error != String()) {
static const char *stage_str[RD::SHADER_STAGE_MAX] = {
"vertex",
@@ -383,7 +383,7 @@ public:
"compute"
};
- ERR_PRINT("Error parsing shader '" + p_file + "', version '" + String(E->key()) + "', stage '" + stage_str[i] + "':\n\n" + error);
+ ERR_PRINT("Error parsing shader '" + p_file + "', version '" + String(E.key) + "', stage '" + stage_str[i] + "':\n\n" + error);
}
}
}
diff --git a/servers/rendering/rendering_server_default.cpp b/servers/rendering/rendering_server_default.cpp
index bed6ade1f6..62390f9d4d 100644
--- a/servers/rendering/rendering_server_default.cpp
+++ b/servers/rendering/rendering_server_default.cpp
@@ -45,6 +45,9 @@ int RenderingServerDefault::changes = 0;
/* FREE */
void RenderingServerDefault::_free(RID p_rid) {
+ if (unlikely(p_rid.is_null())) {
+ return;
+ }
if (RSG::storage->free(p_rid)) {
return;
}
diff --git a/servers/rendering/shader_language.cpp b/servers/rendering/shader_language.cpp
index d6f8fe85c9..f960d4af5f 100644
--- a/servers/rendering/shader_language.cpp
+++ b/servers/rendering/shader_language.cpp
@@ -3546,9 +3546,9 @@ bool ShaderLanguage::_propagate_function_call_sampler_uniform_settings(StringNam
arg->tex_argument_check = true;
arg->tex_argument_filter = p_filter;
arg->tex_argument_repeat = p_repeat;
- for (Map<StringName, Set<int>>::Element *E = arg->tex_argument_connect.front(); E; E = E->next()) {
- for (Set<int>::Element *F = E->get().front(); F; F = F->next()) {
- if (!_propagate_function_call_sampler_uniform_settings(E->key(), F->get(), p_filter, p_repeat)) {
+ for (KeyValue<StringName, Set<int>> &E : arg->tex_argument_connect) {
+ for (Set<int>::Element *F = E.value.front(); F; F = F->next()) {
+ if (!_propagate_function_call_sampler_uniform_settings(E.key, F->get(), p_filter, p_repeat)) {
return false;
}
}
@@ -3580,9 +3580,9 @@ bool ShaderLanguage::_propagate_function_call_sampler_builtin_reference(StringNa
arg->tex_builtin_check = true;
arg->tex_builtin = p_builtin;
- for (Map<StringName, Set<int>>::Element *E = arg->tex_argument_connect.front(); E; E = E->next()) {
- for (Set<int>::Element *F = E->get().front(); F; F = F->next()) {
- if (!_propagate_function_call_sampler_builtin_reference(E->key(), F->get(), p_builtin)) {
+ for (KeyValue<StringName, Set<int>> &E : arg->tex_argument_connect) {
+ for (Set<int>::Element *F = E.value.front(); F; F = F->next()) {
+ if (!_propagate_function_call_sampler_builtin_reference(E.key, F->get(), p_builtin)) {
return false;
}
}
@@ -7712,8 +7712,8 @@ Error ShaderLanguage::_parse_shader(const Map<StringName, FunctionInfo> &p_funct
}
if (p_functions.has("global")) { // Adds global variables: 'TIME'
- for (Map<StringName, BuiltInInfo>::Element *E = p_functions["global"].built_ins.front(); E; E = E->next()) {
- builtins.built_ins.insert(E->key(), E->value());
+ for (const KeyValue<StringName, BuiltInInfo> &E : p_functions["global"].built_ins) {
+ builtins.built_ins.insert(E.key, E.value);
}
}
@@ -7985,8 +7985,8 @@ Error ShaderLanguage::_parse_shader(const Map<StringName, FunctionInfo> &p_funct
}
bool ShaderLanguage::has_builtin(const Map<StringName, ShaderLanguage::FunctionInfo> &p_functions, const StringName &p_name) {
- for (Map<StringName, ShaderLanguage::FunctionInfo>::Element *E = p_functions.front(); E; E = E->next()) {
- if (E->get().built_ins.has(p_name)) {
+ for (const KeyValue<StringName, ShaderLanguage::FunctionInfo> &E : p_functions) {
+ if (E.value.built_ins.has(p_name)) {
return true;
}
}
@@ -8126,19 +8126,19 @@ String ShaderLanguage::get_shader_type(const String &p_code) {
#ifdef DEBUG_ENABLED
void ShaderLanguage::_check_warning_accums() {
- for (Map<ShaderWarning::Code, Map<StringName, Map<StringName, Usage>> *>::Element *E = warnings_check_map2.front(); E; E = E->next()) {
- for (Map<StringName, Map<StringName, Usage>>::Element *T = (*E->get()).front(); T; T = T->next()) {
- for (const Map<StringName, Usage>::Element *U = T->get().front(); U; U = U->next()) {
- if (!U->get().used) {
- _add_warning(E->key(), U->get().decl_line, U->key());
+ for (const KeyValue<ShaderWarning::Code, Map<StringName, Map<StringName, Usage>> *> &E : warnings_check_map2) {
+ for (Map<StringName, Map<StringName, Usage>>::Element *T = (*E.value).front(); T; T = T->next()) {
+ for (const KeyValue<StringName, Usage> &U : T->get()) {
+ if (!U.value.used) {
+ _add_warning(E.key, U.value.decl_line, U.key);
}
}
}
}
- for (Map<ShaderWarning::Code, Map<StringName, Usage> *>::Element *E = warnings_check_map.front(); E; E = E->next()) {
- for (const Map<StringName, Usage>::Element *U = (*E->get()).front(); U; U = U->next()) {
+ for (const KeyValue<ShaderWarning::Code, Map<StringName, Usage> *> &E : warnings_check_map) {
+ for (const Map<StringName, Usage>::Element *U = (*E.value).front(); U; U = U->next()) {
if (!U->get().used) {
- _add_warning(E->key(), U->get().decl_line, U->key());
+ _add_warning(E.key, U->get().decl_line, U->key());
}
}
}
@@ -8221,8 +8221,8 @@ Error ShaderLanguage::complete(const String &p_code, const Map<StringName, Funct
return OK;
} break;
case COMPLETION_MAIN_FUNCTION: {
- for (const Map<StringName, FunctionInfo>::Element *E = p_functions.front(); E; E = E->next()) {
- ScriptCodeCompletionOption option(E->key(), ScriptCodeCompletionOption::KIND_FUNCTION);
+ for (const KeyValue<StringName, FunctionInfo> &E : p_functions) {
+ ScriptCodeCompletionOption option(E.key, ScriptCodeCompletionOption::KIND_FUNCTION);
r_options->push_back(option);
}
@@ -8238,9 +8238,9 @@ Error ShaderLanguage::complete(const String &p_code, const Map<StringName, Funct
if (completion_class == TAG_GLOBAL) {
while (block) {
if (comp_ident) {
- for (const Map<StringName, BlockNode::Variable>::Element *E = block->variables.front(); E; E = E->next()) {
- if (E->get().line < completion_line) {
- matches.insert(E->key(), ScriptCodeCompletionOption::KIND_VARIABLE);
+ for (const KeyValue<StringName, BlockNode::Variable> &E : block->variables) {
+ if (E.value.line < completion_line) {
+ matches.insert(E.key, ScriptCodeCompletionOption::KIND_VARIABLE);
}
}
}
@@ -8258,30 +8258,30 @@ Error ShaderLanguage::complete(const String &p_code, const Map<StringName, Funct
if (comp_ident) {
if (p_functions.has("global")) {
- for (Map<StringName, BuiltInInfo>::Element *E = p_functions["global"].built_ins.front(); E; E = E->next()) {
+ for (const KeyValue<StringName, BuiltInInfo> &E : p_functions["global"].built_ins) {
ScriptCodeCompletionOption::Kind kind = ScriptCodeCompletionOption::KIND_MEMBER;
- if (E->get().constant) {
+ if (E.value.constant) {
kind = ScriptCodeCompletionOption::KIND_CONSTANT;
}
- matches.insert(E->key(), kind);
+ matches.insert(E.key, kind);
}
}
if (skip_function != StringName() && p_functions.has(skip_function)) {
- for (Map<StringName, BuiltInInfo>::Element *E = p_functions[skip_function].built_ins.front(); E; E = E->next()) {
+ for (const KeyValue<StringName, BuiltInInfo> &E : p_functions[skip_function].built_ins) {
ScriptCodeCompletionOption::Kind kind = ScriptCodeCompletionOption::KIND_MEMBER;
- if (E->get().constant) {
+ if (E.value.constant) {
kind = ScriptCodeCompletionOption::KIND_CONSTANT;
}
- matches.insert(E->key(), kind);
+ matches.insert(E.key, kind);
}
}
- for (const Map<StringName, ShaderNode::Varying>::Element *E = shader->varyings.front(); E; E = E->next()) {
- matches.insert(E->key(), ScriptCodeCompletionOption::KIND_VARIABLE);
+ for (const KeyValue<StringName, ShaderNode::Varying> &E : shader->varyings) {
+ matches.insert(E.key, ScriptCodeCompletionOption::KIND_VARIABLE);
}
- for (const Map<StringName, ShaderNode::Uniform>::Element *E = shader->uniforms.front(); E; E = E->next()) {
- matches.insert(E->key(), ScriptCodeCompletionOption::KIND_MEMBER);
+ for (const KeyValue<StringName, ShaderNode::Uniform> &E : shader->uniforms) {
+ matches.insert(E.key, ScriptCodeCompletionOption::KIND_MEMBER);
}
}
@@ -8296,8 +8296,8 @@ Error ShaderLanguage::complete(const String &p_code, const Map<StringName, Funct
bool low_end = RenderingServer::get_singleton()->is_low_end();
if (stages && stages->has(skip_function)) {
- for (const Map<StringName, StageFunctionInfo>::Element *E = (*stages)[skip_function].stage_functions.front(); E; E = E->next()) {
- matches.insert(String(E->key()), ScriptCodeCompletionOption::KIND_FUNCTION);
+ for (const KeyValue<StringName, StageFunctionInfo> &E : (*stages)[skip_function].stage_functions) {
+ matches.insert(String(E.key), ScriptCodeCompletionOption::KIND_FUNCTION);
}
}
@@ -8326,9 +8326,9 @@ Error ShaderLanguage::complete(const String &p_code, const Map<StringName, Funct
}
}
- for (Map<String, ScriptCodeCompletionOption::Kind>::Element *E = matches.front(); E; E = E->next()) {
- ScriptCodeCompletionOption option(E->key(), E->value());
- if (E->value() == ScriptCodeCompletionOption::KIND_FUNCTION) {
+ for (const KeyValue<String, ScriptCodeCompletionOption::Kind> &E : matches) {
+ ScriptCodeCompletionOption option(E.key, E.value);
+ if (E.value == ScriptCodeCompletionOption::KIND_FUNCTION) {
option.insert_text += "(";
}
r_options->push_back(option);
@@ -8420,14 +8420,14 @@ Error ShaderLanguage::complete(const String &p_code, const Map<StringName, Funct
bool low_end = RenderingServer::get_singleton()->is_low_end();
if (stages && stages->has(block_function)) {
- for (const Map<StringName, StageFunctionInfo>::Element *E = (*stages)[block_function].stage_functions.front(); E; E = E->next()) {
- if (completion_function == E->key()) {
- calltip += get_datatype_name(E->get().return_type);
+ for (const KeyValue<StringName, StageFunctionInfo> &E : (*stages)[block_function].stage_functions) {
+ if (completion_function == E.key) {
+ calltip += get_datatype_name(E.value.return_type);
calltip += " ";
- calltip += E->key();
+ calltip += E.key;
calltip += "(";
- for (int i = 0; i < E->get().arguments.size(); i++) {
+ for (int i = 0; i < E.value.arguments.size(); i++) {
if (i > 0) {
calltip += ", ";
} else {
@@ -8438,16 +8438,16 @@ Error ShaderLanguage::complete(const String &p_code, const Map<StringName, Funct
calltip += char32_t(0xFFFF);
}
- calltip += get_datatype_name(E->get().arguments[i].type);
+ calltip += get_datatype_name(E.value.arguments[i].type);
calltip += " ";
- calltip += E->get().arguments[i].name;
+ calltip += E.value.arguments[i].name;
if (i == completion_argument) {
calltip += char32_t(0xFFFF);
}
}
- if (E->get().arguments.size()) {
+ if (E.value.arguments.size()) {
calltip += " ";
}
calltip += ")";
diff --git a/servers/rendering/shader_warnings.cpp b/servers/rendering/shader_warnings.cpp
index 0c1d6408c9..0b8476478c 100644
--- a/servers/rendering/shader_warnings.cpp
+++ b/servers/rendering/shader_warnings.cpp
@@ -119,10 +119,10 @@ ShaderWarning::CodeFlags ShaderWarning::get_flags_from_codemap(const Map<Code, b
init_code_to_flags_map();
}
- for (Map<Code, bool>::Element *E = p_map.front(); E; E = E->next()) {
- if (E->get()) {
- ERR_FAIL_COND_V(!code_to_flags_map->has((int)E->key()), ShaderWarning::NONE_FLAG);
- result |= (*code_to_flags_map)[(int)E->key()];
+ for (const KeyValue<Code, bool> &E : p_map) {
+ if (E.value) {
+ ERR_FAIL_COND_V(!code_to_flags_map->has((int)E.key), ShaderWarning::NONE_FLAG);
+ result |= (*code_to_flags_map)[(int)E.key];
}
}
return (CodeFlags)result;
diff --git a/servers/rendering_server.cpp b/servers/rendering_server.cpp
index 1b10e4dcbe..58e99f0e91 100644
--- a/servers/rendering_server.cpp
+++ b/servers/rendering_server.cpp
@@ -2539,6 +2539,7 @@ void RenderingServer::_bind_methods() {
ClassDB::bind_method(D_METHOD("canvas_item_add_rect", "item", "rect", "color"), &RenderingServer::canvas_item_add_rect);
ClassDB::bind_method(D_METHOD("canvas_item_add_circle", "item", "pos", "radius", "color"), &RenderingServer::canvas_item_add_circle);
ClassDB::bind_method(D_METHOD("canvas_item_add_texture_rect", "item", "rect", "texture", "tile", "modulate", "transpose"), &RenderingServer::canvas_item_add_texture_rect, DEFVAL(false), DEFVAL(Color(1, 1, 1)), DEFVAL(false));
+ ClassDB::bind_method(D_METHOD("canvas_item_add_msdf_texture_rect_region", "item", "rect", "texture", "src_rect", "modulate", "outline_size", "px_range"), &RenderingServer::canvas_item_add_msdf_texture_rect_region, DEFVAL(Color(1, 1, 1)), DEFVAL(0), DEFVAL(1.0));
ClassDB::bind_method(D_METHOD("canvas_item_add_texture_rect_region", "item", "rect", "texture", "src_rect", "modulate", "transpose", "clip_uv"), &RenderingServer::canvas_item_add_texture_rect_region, DEFVAL(Color(1, 1, 1)), DEFVAL(false), DEFVAL(true));
ClassDB::bind_method(D_METHOD("canvas_item_add_nine_patch", "item", "rect", "source", "texture", "topleft", "bottomright", "x_axis_mode", "y_axis_mode", "draw_center", "modulate"), &RenderingServer::canvas_item_add_nine_patch, DEFVAL(NINE_PATCH_STRETCH), DEFVAL(NINE_PATCH_STRETCH), DEFVAL(true), DEFVAL(Color(1, 1, 1)));
ClassDB::bind_method(D_METHOD("canvas_item_add_primitive", "item", "points", "colors", "uvs", "texture", "width"), &RenderingServer::canvas_item_add_primitive, DEFVAL(1.0));
diff --git a/servers/rendering_server.h b/servers/rendering_server.h
index 1b04a6e5e2..579f8abbe6 100644
--- a/servers/rendering_server.h
+++ b/servers/rendering_server.h
@@ -295,7 +295,7 @@ public:
AABB aabb;
struct LOD {
- float edge_length;
+ float edge_length = 0.0f;
Vector<uint8_t> index_data;
};
Vector<LOD> lods;
diff --git a/servers/text/SCsub b/servers/text/SCsub
new file mode 100644
index 0000000000..86681f9c74
--- /dev/null
+++ b/servers/text/SCsub
@@ -0,0 +1,5 @@
+#!/usr/bin/env python
+
+Import("env")
+
+env.add_source_files(env.servers_sources, "*.cpp")
diff --git a/servers/text/text_server_extension.cpp b/servers/text/text_server_extension.cpp
new file mode 100644
index 0000000000..a44fee7c95
--- /dev/null
+++ b/servers/text/text_server_extension.cpp
@@ -0,0 +1,1281 @@
+/*************************************************************************/
+/* text_server_extension.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 "text_server_extension.h"
+
+void TextServerExtension::_bind_methods() {
+ GDVIRTUAL_BIND(_has_feature, "feature");
+ GDVIRTUAL_BIND(_get_name);
+ GDVIRTUAL_BIND(_get_features);
+
+ GDVIRTUAL_BIND(_free, "rid");
+ GDVIRTUAL_BIND(_has, "rid");
+ GDVIRTUAL_BIND(_load_support_data, "filename");
+
+ GDVIRTUAL_BIND(_get_support_data_filename);
+ GDVIRTUAL_BIND(_get_support_data_info);
+ GDVIRTUAL_BIND(_save_support_data, "filename");
+
+ GDVIRTUAL_BIND(_is_locale_right_to_left, "locale");
+
+ GDVIRTUAL_BIND(_name_to_tag, "name");
+ GDVIRTUAL_BIND(_tag_to_name, "tag");
+
+ /* Font interface */
+
+ GDVIRTUAL_BIND(_create_font);
+
+ GDVIRTUAL_BIND(_font_set_data, "font_rid", "data");
+ GDVIRTUAL_BIND(_font_set_data_ptr, "font_rid", "data_ptr", "data_size");
+
+ GDVIRTUAL_BIND(_font_set_antialiased, "font_rid", "antialiased");
+ GDVIRTUAL_BIND(_font_is_antialiased, "font_rid");
+
+ GDVIRTUAL_BIND(_font_set_multichannel_signed_distance_field, "font_rid", "msdf");
+ GDVIRTUAL_BIND(_font_is_multichannel_signed_distance_field, "font_rid");
+
+ GDVIRTUAL_BIND(_font_set_msdf_pixel_range, "font_rid", "msdf_pixel_range");
+ GDVIRTUAL_BIND(_font_get_msdf_pixel_range, "font_rid");
+
+ GDVIRTUAL_BIND(_font_set_msdf_size, "font_rid", "msdf_size");
+ GDVIRTUAL_BIND(_font_get_msdf_size, "font_rid");
+
+ GDVIRTUAL_BIND(_font_set_fixed_size, "font_rid", "fixed_size");
+ GDVIRTUAL_BIND(_font_get_fixed_size, "font_rid");
+
+ GDVIRTUAL_BIND(_font_set_force_autohinter, "font_rid", "force_autohinter");
+ GDVIRTUAL_BIND(_font_is_force_autohinter, "font_rid");
+
+ GDVIRTUAL_BIND(_font_set_hinting, "font_rid", "hinting");
+ GDVIRTUAL_BIND(_font_get_hinting, "font_rid");
+
+ GDVIRTUAL_BIND(_font_set_variation_coordinates, "font_rid", "variation_coordinates");
+ GDVIRTUAL_BIND(_font_get_variation_coordinates, "font_rid");
+
+ GDVIRTUAL_BIND(_font_set_oversampling, "font_rid", "oversampling");
+ GDVIRTUAL_BIND(_font_get_oversampling, "font_rid");
+
+ GDVIRTUAL_BIND(_font_get_size_cache_list, "font_rid");
+ GDVIRTUAL_BIND(_font_clear_size_cache, "font_rid");
+ GDVIRTUAL_BIND(_font_remove_size_cache, "font_rid", "size");
+
+ GDVIRTUAL_BIND(_font_set_ascent, "font_rid", "size", "ascent");
+ GDVIRTUAL_BIND(_font_get_ascent, "font_rid", "size");
+
+ GDVIRTUAL_BIND(_font_set_descent, "font_rid", "size", "descent");
+ GDVIRTUAL_BIND(_font_get_descent, "font_rid", "size");
+
+ GDVIRTUAL_BIND(_font_set_underline_position, "font_rid", "size", "underline_position");
+ GDVIRTUAL_BIND(_font_get_underline_position, "font_rid", "size");
+
+ GDVIRTUAL_BIND(_font_set_underline_thickness, "font_rid", "size", "underline_thickness");
+ GDVIRTUAL_BIND(_font_get_underline_thickness, "font_rid", "size");
+
+ GDVIRTUAL_BIND(_font_set_scale, "font_rid", "size", "scale");
+ GDVIRTUAL_BIND(_font_get_scale, "font_rid", "size");
+
+ GDVIRTUAL_BIND(_font_set_spacing, "font_rid", "size", "spacing", "value");
+ GDVIRTUAL_BIND(_font_get_spacing, "font_rid", "size", "spacing");
+
+ GDVIRTUAL_BIND(_font_get_texture_count, "font_rid", "size");
+ GDVIRTUAL_BIND(_font_clear_textures, "font_rid", "size");
+ GDVIRTUAL_BIND(_font_remove_texture, "font_rid", "size", "texture_index");
+
+ GDVIRTUAL_BIND(_font_set_texture_image, "font_rid", "size", "texture_index", "image");
+ GDVIRTUAL_BIND(_font_get_texture_image, "font_rid", "size", "texture_index");
+
+ GDVIRTUAL_BIND(_font_set_texture_offsets, "font_rid", "size", "texture_index", "offset");
+ GDVIRTUAL_BIND(_font_get_texture_offsets, "font_rid", "size", "texture_index");
+
+ GDVIRTUAL_BIND(_font_get_glyph_list, "font_rid", "size");
+ GDVIRTUAL_BIND(_font_clear_glyphs, "font_rid", "size");
+ GDVIRTUAL_BIND(_font_remove_glyph, "font_rid", "size", "glyph");
+
+ GDVIRTUAL_BIND(_font_get_glyph_advance, "font_rid", "size", "glyph");
+ GDVIRTUAL_BIND(_font_set_glyph_advance, "font_rid", "size", "glyph", "advance");
+
+ GDVIRTUAL_BIND(_font_get_glyph_offset, "font_rid", "size", "glyph");
+ GDVIRTUAL_BIND(_font_set_glyph_offset, "font_rid", "size", "glyph", "offset");
+
+ GDVIRTUAL_BIND(_font_get_glyph_size, "font_rid", "size", "glyph");
+ GDVIRTUAL_BIND(_font_set_glyph_size, "font_rid", "size", "glyph", "gl_size");
+
+ GDVIRTUAL_BIND(_font_get_glyph_uv_rect, "font_rid", "size", "glyph");
+ GDVIRTUAL_BIND(_font_set_glyph_uv_rect, "font_rid", "size", "glyph", "uv_rect");
+
+ GDVIRTUAL_BIND(_font_get_glyph_texture_idx, "font_rid", "size", "glyph");
+ GDVIRTUAL_BIND(_font_set_glyph_texture_idx, "font_rid", "size", "glyph", "texture_idx");
+
+ GDVIRTUAL_BIND(_font_get_glyph_contours, "font_rid", "size", "index");
+
+ GDVIRTUAL_BIND(_font_get_kerning_list, "font_rid", "size");
+ GDVIRTUAL_BIND(_font_clear_kerning_map, "font_rid", "size");
+ GDVIRTUAL_BIND(_font_remove_kerning, "font_rid", "size", "glyph_pair");
+
+ GDVIRTUAL_BIND(_font_set_kerning, "font_rid", "size", "glyph_pair", "kerning");
+ GDVIRTUAL_BIND(_font_get_kerning, "font_rid", "size", "glyph_pair");
+
+ GDVIRTUAL_BIND(_font_get_glyph_index, "font_rid", "size", "char", "variation_selector");
+
+ GDVIRTUAL_BIND(_font_has_char, "font_rid", "char");
+ GDVIRTUAL_BIND(_font_get_supported_chars, "font_rid");
+
+ GDVIRTUAL_BIND(_font_render_range, "font_rid", "size", "start", "end");
+ GDVIRTUAL_BIND(_font_render_glyph, "font_rid", "size", "index");
+
+ GDVIRTUAL_BIND(_font_draw_glyph, "font_rid", "canvas", "size", "pos", "index", "color");
+ GDVIRTUAL_BIND(_font_draw_glyph_outline, "font_rid", "canvas", "size", "outline_size", "pos", "index", "color");
+
+ GDVIRTUAL_BIND(_font_is_language_supported, "font_rid", "language");
+ GDVIRTUAL_BIND(_font_set_language_support_override, "font_rid", "language", "supported");
+ GDVIRTUAL_BIND(_font_get_language_support_override, "font_rid", "language");
+ GDVIRTUAL_BIND(_font_remove_language_support_override, "font_rid", "language");
+ GDVIRTUAL_BIND(_font_get_language_support_overrides, "font_rid");
+
+ GDVIRTUAL_BIND(_font_is_script_supported, "font_rid", "script");
+ GDVIRTUAL_BIND(_font_set_script_support_override, "font_rid", "script", "supported");
+ GDVIRTUAL_BIND(_font_get_script_support_override, "font_rid", "script");
+ GDVIRTUAL_BIND(_font_remove_script_support_override, "font_rid", "script");
+ GDVIRTUAL_BIND(_font_get_script_support_overrides, "font_rid");
+
+ GDVIRTUAL_BIND(_font_supported_feature_list, "font_rid");
+ GDVIRTUAL_BIND(_font_supported_variation_list, "font_rid");
+
+ GDVIRTUAL_BIND(_font_get_global_oversampling);
+ GDVIRTUAL_BIND(_font_set_global_oversampling, "oversampling");
+
+ GDVIRTUAL_BIND(_get_hex_code_box_size, "size", "index");
+ GDVIRTUAL_BIND(_draw_hex_code_box, "canvas", "size", "pos", "index", "color");
+
+ /* Shaped text buffer interface */
+
+ GDVIRTUAL_BIND(_create_shaped_text, "direction", "orientation");
+
+ GDVIRTUAL_BIND(_shaped_text_clear, "shaped");
+
+ GDVIRTUAL_BIND(_shaped_text_set_direction, "shaped", "direction");
+ GDVIRTUAL_BIND(_shaped_text_get_direction, "shaped");
+
+ GDVIRTUAL_BIND(_shaped_text_set_bidi_override, "shaped", "override");
+
+ GDVIRTUAL_BIND(_shaped_text_set_orientation, "shaped", "orientation");
+ GDVIRTUAL_BIND(_shaped_text_get_orientation, "shaped");
+
+ GDVIRTUAL_BIND(_shaped_text_set_preserve_invalid, "shaped", "enabled");
+ GDVIRTUAL_BIND(_shaped_text_get_preserve_invalid, "shaped");
+
+ GDVIRTUAL_BIND(_shaped_text_set_preserve_control, "shaped", "enabled");
+ GDVIRTUAL_BIND(_shaped_text_get_preserve_control, "shaped");
+
+ GDVIRTUAL_BIND(_shaped_text_add_string, "shaped", "text", "fonts", "size", "opentype_features", "language");
+ GDVIRTUAL_BIND(_shaped_text_add_object, "shaped", "key", "size", "inline_align", "length");
+ GDVIRTUAL_BIND(_shaped_text_resize_object, "shaped", "key", "size", "inline_align");
+
+ GDVIRTUAL_BIND(_shaped_text_substr, "shaped", "start", "length");
+ GDVIRTUAL_BIND(_shaped_text_get_parent, "shaped");
+
+ GDVIRTUAL_BIND(_shaped_text_fit_to_width, "shaped", "width", "jst_flags");
+ GDVIRTUAL_BIND(_shaped_text_tab_align, "shaped", "tab_stops");
+
+ GDVIRTUAL_BIND(_shaped_text_shape, "shaped");
+ GDVIRTUAL_BIND(_shaped_text_update_breaks, "shaped");
+ GDVIRTUAL_BIND(_shaped_text_update_justification_ops, "shaped");
+
+ GDVIRTUAL_BIND(_shaped_text_is_ready, "shaped");
+
+ GDVIRTUAL_BIND(_shaped_text_get_glyphs, "shaped", "r_glyphs");
+ GDVIRTUAL_BIND(_shaped_text_sort_logical, "shaped", "r_glyphs");
+ GDVIRTUAL_BIND(_shaped_text_get_glyph_count, "shaped");
+
+ GDVIRTUAL_BIND(_shaped_text_get_range, "shaped");
+
+ GDVIRTUAL_BIND(_shaped_text_get_line_breaks_adv, "shaped", "width", "start", "once", "break_flags");
+ GDVIRTUAL_BIND(_shaped_text_get_line_breaks, "shaped", "width", "start", "break_flags");
+ GDVIRTUAL_BIND(_shaped_text_get_word_breaks, "shaped", "grapheme_flags");
+
+ GDVIRTUAL_BIND(_shaped_text_get_trim_pos, "shaped");
+ GDVIRTUAL_BIND(_shaped_text_get_ellipsis_pos, "shaped");
+ GDVIRTUAL_BIND(_shaped_text_get_ellipsis_glyph_count, "shaped");
+ GDVIRTUAL_BIND(_shaped_text_get_ellipsis_glyphs, "shaped", "r_glyphs");
+
+ GDVIRTUAL_BIND(_shaped_text_overrun_trim_to_width, "shaped", "width", "trim_flags");
+
+ GDVIRTUAL_BIND(_shaped_text_get_objects, "shaped");
+ GDVIRTUAL_BIND(_shaped_text_get_object_rect, "shaped", "key");
+
+ GDVIRTUAL_BIND(_shaped_text_get_size, "shaped");
+ GDVIRTUAL_BIND(_shaped_text_get_ascent, "shaped");
+ GDVIRTUAL_BIND(_shaped_text_get_descent, "shaped");
+ GDVIRTUAL_BIND(_shaped_text_get_width, "shaped");
+ GDVIRTUAL_BIND(_shaped_text_get_underline_position, "shaped");
+ GDVIRTUAL_BIND(_shaped_text_get_underline_thickness, "shaped");
+
+ GDVIRTUAL_BIND(_shaped_text_get_dominant_direction_in_range, "shaped", "start", "end");
+
+ GDVIRTUAL_BIND(_shaped_text_get_carets, "shaped", "position", "caret");
+ GDVIRTUAL_BIND(_shaped_text_get_selection, "shaped", "start", "end");
+
+ GDVIRTUAL_BIND(_shaped_text_hit_test_grapheme, "shaped", "coord");
+ GDVIRTUAL_BIND(_shaped_text_hit_test_position, "shaped", "coord");
+
+ GDVIRTUAL_BIND(_shaped_text_draw, "shaped", "canvas", "pos", "clip_l", "clip_r", "color");
+ GDVIRTUAL_BIND(_shaped_text_draw_outline, "shaped", "canvas", "pos", "clip_l", "clip_r", "outline_size", "color");
+
+ GDVIRTUAL_BIND(_shaped_text_next_grapheme_pos, "shaped", "pos");
+ GDVIRTUAL_BIND(_shaped_text_prev_grapheme_pos, "shaped", "pos");
+
+ GDVIRTUAL_BIND(_format_number, "string", "language");
+ GDVIRTUAL_BIND(_parse_number, "string", "language");
+ GDVIRTUAL_BIND(_percent_sign, "language");
+}
+
+bool TextServerExtension::has_feature(Feature p_feature) const {
+ bool ret;
+ if (GDVIRTUAL_CALL(_has_feature, p_feature, ret)) {
+ return ret;
+ }
+ return false;
+}
+
+String TextServerExtension::get_name() const {
+ String ret;
+ if (GDVIRTUAL_CALL(_get_name, ret)) {
+ return ret;
+ }
+ return "Unknown";
+}
+
+uint32_t TextServerExtension::get_features() const {
+ uint32_t ret;
+ if (GDVIRTUAL_CALL(_get_features, ret)) {
+ return ret;
+ }
+ return 0;
+}
+
+void TextServerExtension::free(RID p_rid) {
+ GDVIRTUAL_CALL(_free, p_rid);
+}
+
+bool TextServerExtension::has(RID p_rid) {
+ bool ret;
+ if (GDVIRTUAL_CALL(_has, p_rid, ret)) {
+ return ret;
+ }
+ return false;
+}
+
+bool TextServerExtension::load_support_data(const String &p_filename) {
+ bool ret;
+ if (GDVIRTUAL_CALL(_load_support_data, p_filename, ret)) {
+ return ret;
+ }
+ return false;
+}
+
+String TextServerExtension::get_support_data_filename() const {
+ String ret;
+ if (GDVIRTUAL_CALL(_get_support_data_filename, ret)) {
+ return ret;
+ }
+ return String();
+}
+
+String TextServerExtension::get_support_data_info() const {
+ String ret;
+ if (GDVIRTUAL_CALL(_get_support_data_info, ret)) {
+ return ret;
+ }
+ return String();
+}
+
+bool TextServerExtension::save_support_data(const String &p_filename) const {
+ bool ret;
+ if (GDVIRTUAL_CALL(_save_support_data, p_filename, ret)) {
+ return ret;
+ }
+ return false;
+}
+
+bool TextServerExtension::is_locale_right_to_left(const String &p_locale) const {
+ bool ret;
+ if (GDVIRTUAL_CALL(_is_locale_right_to_left, p_locale, ret)) {
+ return ret;
+ }
+ return false;
+}
+
+int32_t TextServerExtension::name_to_tag(const String &p_name) const {
+ int32_t ret;
+ if (GDVIRTUAL_CALL(_name_to_tag, p_name, ret)) {
+ return ret;
+ }
+ return 0;
+}
+
+String TextServerExtension::tag_to_name(int32_t p_tag) const {
+ String ret;
+ if (GDVIRTUAL_CALL(_tag_to_name, p_tag, ret)) {
+ return ret;
+ }
+ return "";
+}
+
+/*************************************************************************/
+/* Font */
+/*************************************************************************/
+
+RID TextServerExtension::create_font() {
+ RID ret;
+ if (GDVIRTUAL_CALL(_create_font, ret)) {
+ return ret;
+ }
+ return RID();
+}
+
+void TextServerExtension::font_set_data(RID p_font_rid, const PackedByteArray &p_data) {
+ GDVIRTUAL_CALL(_font_set_data, p_font_rid, p_data);
+}
+
+void TextServerExtension::font_set_data_ptr(RID p_font_rid, const uint8_t *p_data_ptr, size_t p_data_size) {
+ GDVIRTUAL_CALL(_font_set_data_ptr, p_font_rid, p_data_ptr, p_data_size);
+}
+
+void TextServerExtension::font_set_antialiased(RID p_font_rid, bool p_antialiased) {
+ GDVIRTUAL_CALL(_font_set_antialiased, p_font_rid, p_antialiased);
+}
+
+bool TextServerExtension::font_is_antialiased(RID p_font_rid) const {
+ bool ret;
+ if (GDVIRTUAL_CALL(_font_is_antialiased, p_font_rid, ret)) {
+ return ret;
+ }
+ return false;
+}
+
+void TextServerExtension::font_set_multichannel_signed_distance_field(RID p_font_rid, bool p_msdf) {
+ GDVIRTUAL_CALL(_font_set_multichannel_signed_distance_field, p_font_rid, p_msdf);
+}
+
+bool TextServerExtension::font_is_multichannel_signed_distance_field(RID p_font_rid) const {
+ bool ret;
+ if (GDVIRTUAL_CALL(_font_is_multichannel_signed_distance_field, p_font_rid, ret)) {
+ return ret;
+ }
+ return false;
+}
+
+void TextServerExtension::font_set_msdf_pixel_range(RID p_font_rid, int p_msdf_pixel_range) {
+ GDVIRTUAL_CALL(_font_set_msdf_pixel_range, p_font_rid, p_msdf_pixel_range);
+}
+
+int TextServerExtension::font_get_msdf_pixel_range(RID p_font_rid) const {
+ int ret;
+ if (GDVIRTUAL_CALL(_font_get_msdf_pixel_range, p_font_rid, ret)) {
+ return ret;
+ }
+ return 0;
+}
+
+void TextServerExtension::font_set_msdf_size(RID p_font_rid, int p_msdf_size) {
+ GDVIRTUAL_CALL(_font_set_msdf_size, p_font_rid, p_msdf_size);
+}
+
+int TextServerExtension::font_get_msdf_size(RID p_font_rid) const {
+ int ret;
+ if (GDVIRTUAL_CALL(_font_get_msdf_size, p_font_rid, ret)) {
+ return ret;
+ }
+ return 0;
+}
+
+void TextServerExtension::font_set_fixed_size(RID p_font_rid, int p_fixed_size) {
+ GDVIRTUAL_CALL(_font_set_fixed_size, p_font_rid, p_fixed_size);
+}
+
+int TextServerExtension::font_get_fixed_size(RID p_font_rid) const {
+ int ret;
+ if (GDVIRTUAL_CALL(_font_get_fixed_size, p_font_rid, ret)) {
+ return ret;
+ }
+ return 0;
+}
+
+void TextServerExtension::font_set_force_autohinter(RID p_font_rid, bool p_force_autohinter) {
+ GDVIRTUAL_CALL(_font_set_force_autohinter, p_font_rid, p_force_autohinter);
+}
+
+bool TextServerExtension::font_is_force_autohinter(RID p_font_rid) const {
+ bool ret;
+ if (GDVIRTUAL_CALL(_font_is_force_autohinter, p_font_rid, ret)) {
+ return ret;
+ }
+ return false;
+}
+
+void TextServerExtension::font_set_hinting(RID p_font_rid, TextServer::Hinting p_hinting) {
+ GDVIRTUAL_CALL(_font_set_hinting, p_font_rid, p_hinting);
+}
+
+TextServer::Hinting TextServerExtension::font_get_hinting(RID p_font_rid) const {
+ int ret;
+ if (GDVIRTUAL_CALL(_font_get_hinting, p_font_rid, ret)) {
+ return (TextServer::Hinting)ret;
+ }
+ return TextServer::Hinting::HINTING_NONE;
+}
+
+void TextServerExtension::font_set_variation_coordinates(RID p_font_rid, const Dictionary &p_variation_coordinates) {
+ GDVIRTUAL_CALL(_font_set_variation_coordinates, p_font_rid, p_variation_coordinates);
+}
+
+Dictionary TextServerExtension::font_get_variation_coordinates(RID p_font_rid) const {
+ Dictionary ret;
+ if (GDVIRTUAL_CALL(_font_get_variation_coordinates, p_font_rid, ret)) {
+ return ret;
+ }
+ return Dictionary();
+}
+
+void TextServerExtension::font_set_oversampling(RID p_font_rid, float p_oversampling) {
+ GDVIRTUAL_CALL(_font_set_oversampling, p_font_rid, p_oversampling);
+}
+
+float TextServerExtension::font_get_oversampling(RID p_font_rid) const {
+ float ret;
+ if (GDVIRTUAL_CALL(_font_get_oversampling, p_font_rid, ret)) {
+ return ret;
+ }
+ return 0.f;
+}
+
+Array TextServerExtension::font_get_size_cache_list(RID p_font_rid) const {
+ Array ret;
+ if (GDVIRTUAL_CALL(_font_get_size_cache_list, p_font_rid, ret)) {
+ return ret;
+ }
+ return Array();
+}
+
+void TextServerExtension::font_clear_size_cache(RID p_font_rid) {
+ GDVIRTUAL_CALL(_font_clear_size_cache, p_font_rid);
+}
+
+void TextServerExtension::font_remove_size_cache(RID p_font_rid, const Vector2i &p_size) {
+ GDVIRTUAL_CALL(_font_remove_size_cache, p_font_rid, p_size);
+}
+
+void TextServerExtension::font_set_ascent(RID p_font_rid, int p_size, float p_ascent) {
+ GDVIRTUAL_CALL(_font_set_ascent, p_font_rid, p_size, p_ascent);
+}
+
+float TextServerExtension::font_get_ascent(RID p_font_rid, int p_size) const {
+ float ret;
+ if (GDVIRTUAL_CALL(_font_get_ascent, p_font_rid, p_size, ret)) {
+ return ret;
+ }
+ return 0.f;
+}
+
+void TextServerExtension::font_set_descent(RID p_font_rid, int p_size, float p_descent) {
+ GDVIRTUAL_CALL(_font_set_descent, p_font_rid, p_size, p_descent);
+}
+
+float TextServerExtension::font_get_descent(RID p_font_rid, int p_size) const {
+ float ret;
+ if (GDVIRTUAL_CALL(_font_get_descent, p_font_rid, p_size, ret)) {
+ return ret;
+ }
+ return 0.f;
+}
+
+void TextServerExtension::font_set_underline_position(RID p_font_rid, int p_size, float p_underline_position) {
+ GDVIRTUAL_CALL(_font_set_underline_position, p_font_rid, p_size, p_underline_position);
+}
+
+float TextServerExtension::font_get_underline_position(RID p_font_rid, int p_size) const {
+ float ret;
+ if (GDVIRTUAL_CALL(_font_get_underline_position, p_font_rid, p_size, ret)) {
+ return ret;
+ }
+ return 0.f;
+}
+
+void TextServerExtension::font_set_underline_thickness(RID p_font_rid, int p_size, float p_underline_thickness) {
+ GDVIRTUAL_CALL(_font_set_underline_thickness, p_font_rid, p_size, p_underline_thickness);
+}
+
+float TextServerExtension::font_get_underline_thickness(RID p_font_rid, int p_size) const {
+ float ret;
+ if (GDVIRTUAL_CALL(_font_get_underline_thickness, p_font_rid, p_size, ret)) {
+ return ret;
+ }
+ return 0.f;
+}
+
+void TextServerExtension::font_set_scale(RID p_font_rid, int p_size, float p_scale) {
+ GDVIRTUAL_CALL(_font_set_scale, p_font_rid, p_size, p_scale);
+}
+
+float TextServerExtension::font_get_scale(RID p_font_rid, int p_size) const {
+ float ret;
+ if (GDVIRTUAL_CALL(_font_get_scale, p_font_rid, p_size, ret)) {
+ return ret;
+ }
+ return 0.f;
+}
+
+void TextServerExtension::font_set_spacing(RID p_font_rid, int p_size, TextServer::SpacingType p_spacing, int p_value) {
+ GDVIRTUAL_CALL(_font_set_spacing, p_font_rid, p_size, p_spacing, p_value);
+}
+
+int TextServerExtension::font_get_spacing(RID p_font_rid, int p_size, TextServer::SpacingType p_spacing) const {
+ int ret;
+ if (GDVIRTUAL_CALL(_font_get_spacing, p_font_rid, p_size, p_spacing, ret)) {
+ return ret;
+ }
+ return 0;
+}
+
+int TextServerExtension::font_get_texture_count(RID p_font_rid, const Vector2i &p_size) const {
+ int ret;
+ if (GDVIRTUAL_CALL(_font_get_texture_count, p_font_rid, p_size, ret)) {
+ return ret;
+ }
+ return 0;
+}
+
+void TextServerExtension::font_clear_textures(RID p_font_rid, const Vector2i &p_size) {
+ GDVIRTUAL_CALL(_font_clear_textures, p_font_rid, p_size);
+}
+
+void TextServerExtension::font_remove_texture(RID p_font_rid, const Vector2i &p_size, int p_texture_index) {
+ GDVIRTUAL_CALL(_font_remove_texture, p_font_rid, p_size, p_texture_index);
+}
+
+void TextServerExtension::font_set_texture_image(RID p_font_rid, const Vector2i &p_size, int p_texture_index, const Ref<Image> &p_image) {
+ GDVIRTUAL_CALL(_font_set_texture_image, p_font_rid, p_size, p_texture_index, p_image);
+}
+
+Ref<Image> TextServerExtension::font_get_texture_image(RID p_font_rid, const Vector2i &p_size, int p_texture_index) const {
+ Ref<Image> ret;
+ if (GDVIRTUAL_CALL(_font_get_texture_image, p_font_rid, p_size, p_texture_index, ret)) {
+ return ret;
+ }
+ return Ref<Image>();
+}
+
+void TextServerExtension::font_set_texture_offsets(RID p_font_rid, const Vector2i &p_size, int p_texture_index, const PackedInt32Array &p_offset) {
+ GDVIRTUAL_CALL(_font_set_texture_offsets, p_font_rid, p_size, p_texture_index, p_offset);
+}
+
+PackedInt32Array TextServerExtension::font_get_texture_offsets(RID p_font_rid, const Vector2i &p_size, int p_texture_index) const {
+ PackedInt32Array ret;
+ if (GDVIRTUAL_CALL(_font_get_texture_offsets, p_font_rid, p_size, p_texture_index, ret)) {
+ return ret;
+ }
+ return PackedInt32Array();
+}
+
+Array TextServerExtension::font_get_glyph_list(RID p_font_rid, const Vector2i &p_size) const {
+ Array ret;
+ if (GDVIRTUAL_CALL(_font_get_glyph_list, p_font_rid, p_size, ret)) {
+ return ret;
+ }
+ return Array();
+}
+
+void TextServerExtension::font_clear_glyphs(RID p_font_rid, const Vector2i &p_size) {
+ GDVIRTUAL_CALL(_font_clear_glyphs, p_font_rid, p_size);
+}
+
+void TextServerExtension::font_remove_glyph(RID p_font_rid, const Vector2i &p_size, int32_t p_glyph) {
+ GDVIRTUAL_CALL(_font_remove_glyph, p_font_rid, p_size, p_glyph);
+}
+
+Vector2 TextServerExtension::font_get_glyph_advance(RID p_font_rid, int p_size, int32_t p_glyph) const {
+ Vector2 ret;
+ if (GDVIRTUAL_CALL(_font_get_glyph_advance, p_font_rid, p_size, p_glyph, ret)) {
+ return ret;
+ }
+ return Vector2();
+}
+
+void TextServerExtension::font_set_glyph_advance(RID p_font_rid, int p_size, int32_t p_glyph, const Vector2 &p_advance) {
+ GDVIRTUAL_CALL(_font_set_glyph_advance, p_font_rid, p_size, p_glyph, p_advance);
+}
+
+Vector2 TextServerExtension::font_get_glyph_offset(RID p_font_rid, const Vector2i &p_size, int32_t p_glyph) const {
+ Vector2 ret;
+ if (GDVIRTUAL_CALL(_font_get_glyph_offset, p_font_rid, p_size, p_glyph, ret)) {
+ return ret;
+ }
+ return Vector2();
+}
+
+void TextServerExtension::font_set_glyph_offset(RID p_font_rid, const Vector2i &p_size, int32_t p_glyph, const Vector2 &p_offset) {
+ GDVIRTUAL_CALL(_font_set_glyph_offset, p_font_rid, p_size, p_glyph, p_offset);
+}
+
+Vector2 TextServerExtension::font_get_glyph_size(RID p_font_rid, const Vector2i &p_size, int32_t p_glyph) const {
+ Vector2 ret;
+ if (GDVIRTUAL_CALL(_font_get_glyph_size, p_font_rid, p_size, p_glyph, ret)) {
+ return ret;
+ }
+ return Vector2();
+}
+
+void TextServerExtension::font_set_glyph_size(RID p_font_rid, const Vector2i &p_size, int32_t p_glyph, const Vector2 &p_gl_size) {
+ GDVIRTUAL_CALL(_font_set_glyph_size, p_font_rid, p_size, p_glyph, p_gl_size);
+}
+
+Rect2 TextServerExtension::font_get_glyph_uv_rect(RID p_font_rid, const Vector2i &p_size, int32_t p_glyph) const {
+ Rect2 ret;
+ if (GDVIRTUAL_CALL(_font_get_glyph_uv_rect, p_font_rid, p_size, p_glyph, ret)) {
+ return ret;
+ }
+ return Rect2();
+}
+
+void TextServerExtension::font_set_glyph_uv_rect(RID p_font_rid, const Vector2i &p_size, int32_t p_glyph, const Rect2 &p_uv_rect) {
+ GDVIRTUAL_CALL(_font_set_glyph_uv_rect, p_font_rid, p_size, p_glyph, p_uv_rect);
+}
+
+int TextServerExtension::font_get_glyph_texture_idx(RID p_font_rid, const Vector2i &p_size, int32_t p_glyph) const {
+ int ret;
+ if (GDVIRTUAL_CALL(_font_get_glyph_texture_idx, p_font_rid, p_size, p_glyph, ret)) {
+ return ret;
+ }
+ return 0;
+}
+
+void TextServerExtension::font_set_glyph_texture_idx(RID p_font_rid, const Vector2i &p_size, int32_t p_glyph, int p_texture_idx) {
+ GDVIRTUAL_CALL(_font_set_glyph_texture_idx, p_font_rid, p_size, p_glyph, p_texture_idx);
+}
+
+Dictionary TextServerExtension::font_get_glyph_contours(RID p_font_rid, int p_size, int32_t p_index) const {
+ Dictionary ret;
+ if (GDVIRTUAL_CALL(_font_get_glyph_contours, p_font_rid, p_size, p_index, ret)) {
+ return ret;
+ }
+ return Dictionary();
+}
+
+Array TextServerExtension::font_get_kerning_list(RID p_font_rid, int p_size) const {
+ Array ret;
+ if (GDVIRTUAL_CALL(_font_get_kerning_list, p_font_rid, p_size, ret)) {
+ return ret;
+ }
+ return Array();
+}
+
+void TextServerExtension::font_clear_kerning_map(RID p_font_rid, int p_size) {
+ GDVIRTUAL_CALL(_font_clear_kerning_map, p_font_rid, p_size);
+}
+
+void TextServerExtension::font_remove_kerning(RID p_font_rid, int p_size, const Vector2i &p_glyph_pair) {
+ GDVIRTUAL_CALL(_font_remove_kerning, p_font_rid, p_size, p_glyph_pair);
+}
+
+void TextServerExtension::font_set_kerning(RID p_font_rid, int p_size, const Vector2i &p_glyph_pair, const Vector2 &p_kerning) {
+ GDVIRTUAL_CALL(_font_set_kerning, p_font_rid, p_size, p_glyph_pair, p_kerning);
+}
+
+Vector2 TextServerExtension::font_get_kerning(RID p_font_rid, int p_size, const Vector2i &p_glyph_pair) const {
+ Vector2 ret;
+ if (GDVIRTUAL_CALL(_font_get_kerning, p_font_rid, p_size, p_glyph_pair, ret)) {
+ return ret;
+ }
+ return Vector2();
+}
+
+int32_t TextServerExtension::font_get_glyph_index(RID p_font_rid, int p_size, char32_t p_char, char32_t p_variation_selector) const {
+ int32_t ret;
+ if (GDVIRTUAL_CALL(_font_get_glyph_index, p_font_rid, p_size, p_char, p_variation_selector, ret)) {
+ return ret;
+ }
+ return 0;
+}
+
+bool TextServerExtension::font_has_char(RID p_font_rid, char32_t p_char) const {
+ bool ret;
+ if (GDVIRTUAL_CALL(_font_has_char, p_font_rid, p_char, ret)) {
+ return ret;
+ }
+ return false;
+}
+
+String TextServerExtension::font_get_supported_chars(RID p_font_rid) const {
+ String ret;
+ if (GDVIRTUAL_CALL(_font_get_supported_chars, p_font_rid, ret)) {
+ return ret;
+ }
+ return String();
+}
+
+void TextServerExtension::font_render_range(RID p_font_rid, const Vector2i &p_size, char32_t p_start, char32_t p_end) {
+ GDVIRTUAL_CALL(_font_render_range, p_font_rid, p_size, p_start, p_end);
+}
+
+void TextServerExtension::font_render_glyph(RID p_font_rid, const Vector2i &p_size, int32_t p_index) {
+ GDVIRTUAL_CALL(_font_render_glyph, p_font_rid, p_size, p_index);
+}
+
+void TextServerExtension::font_draw_glyph(RID p_font_rid, RID p_canvas, int p_size, const Vector2 &p_pos, int32_t p_index, const Color &p_color) const {
+ GDVIRTUAL_CALL(_font_draw_glyph, p_font_rid, p_canvas, p_size, p_pos, p_index, p_color);
+}
+
+void TextServerExtension::font_draw_glyph_outline(RID p_font_rid, RID p_canvas, int p_size, int p_outline_size, const Vector2 &p_pos, int32_t p_index, const Color &p_color) const {
+ GDVIRTUAL_CALL(_font_draw_glyph_outline, p_font_rid, p_canvas, p_size, p_outline_size, p_pos, p_index, p_color);
+}
+
+bool TextServerExtension::font_is_language_supported(RID p_font_rid, const String &p_language) const {
+ bool ret;
+ if (GDVIRTUAL_CALL(_font_is_language_supported, p_font_rid, p_language, ret)) {
+ return ret;
+ }
+ return false;
+}
+
+void TextServerExtension::font_set_language_support_override(RID p_font_rid, const String &p_language, bool p_supported) {
+ GDVIRTUAL_CALL(_font_set_language_support_override, p_font_rid, p_language, p_supported);
+}
+
+bool TextServerExtension::font_get_language_support_override(RID p_font_rid, const String &p_language) {
+ bool ret;
+ if (GDVIRTUAL_CALL(_font_get_language_support_override, p_font_rid, p_language, ret)) {
+ return ret;
+ }
+ return false;
+}
+
+void TextServerExtension::font_remove_language_support_override(RID p_font_rid, const String &p_language) {
+ GDVIRTUAL_CALL(_font_remove_language_support_override, p_font_rid, p_language);
+}
+
+Vector<String> TextServerExtension::font_get_language_support_overrides(RID p_font_rid) {
+ Vector<String> ret;
+ if (GDVIRTUAL_CALL(_font_get_language_support_overrides, p_font_rid, ret)) {
+ return ret;
+ }
+ return Vector<String>();
+}
+
+bool TextServerExtension::font_is_script_supported(RID p_font_rid, const String &p_script) const {
+ bool ret;
+ if (GDVIRTUAL_CALL(_font_is_script_supported, p_font_rid, p_script, ret)) {
+ return ret;
+ }
+ return false;
+}
+
+void TextServerExtension::font_set_script_support_override(RID p_font_rid, const String &p_script, bool p_supported) {
+ GDVIRTUAL_CALL(_font_set_script_support_override, p_font_rid, p_script, p_supported);
+}
+
+bool TextServerExtension::font_get_script_support_override(RID p_font_rid, const String &p_script) {
+ bool ret;
+ if (GDVIRTUAL_CALL(_font_get_script_support_override, p_font_rid, p_script, ret)) {
+ return ret;
+ }
+ return false;
+}
+
+void TextServerExtension::font_remove_script_support_override(RID p_font_rid, const String &p_script) {
+ GDVIRTUAL_CALL(_font_remove_script_support_override, p_font_rid, p_script);
+}
+
+Vector<String> TextServerExtension::font_get_script_support_overrides(RID p_font_rid) {
+ Vector<String> ret;
+ if (GDVIRTUAL_CALL(_font_get_script_support_overrides, p_font_rid, ret)) {
+ return ret;
+ }
+ return Vector<String>();
+}
+
+Dictionary TextServerExtension::font_supported_feature_list(RID p_font_rid) const {
+ Dictionary ret;
+ if (GDVIRTUAL_CALL(_font_supported_feature_list, p_font_rid, ret)) {
+ return ret;
+ }
+ return Dictionary();
+}
+
+Dictionary TextServerExtension::font_supported_variation_list(RID p_font_rid) const {
+ Dictionary ret;
+ if (GDVIRTUAL_CALL(_font_supported_variation_list, p_font_rid, ret)) {
+ return ret;
+ }
+ return Dictionary();
+}
+
+float TextServerExtension::font_get_global_oversampling() const {
+ float ret;
+ if (GDVIRTUAL_CALL(_font_get_global_oversampling, ret)) {
+ return ret;
+ }
+ return 0.f;
+}
+
+void TextServerExtension::font_set_global_oversampling(float p_oversampling) {
+ GDVIRTUAL_CALL(_font_set_global_oversampling, p_oversampling);
+}
+
+Vector2 TextServerExtension::get_hex_code_box_size(int p_size, char32_t p_index) const {
+ Vector2 ret;
+ if (GDVIRTUAL_CALL(_get_hex_code_box_size, p_size, p_index, ret)) {
+ return ret;
+ }
+ return TextServer::get_hex_code_box_size(p_size, p_index);
+}
+
+void TextServerExtension::draw_hex_code_box(RID p_canvas, int p_size, const Vector2 &p_pos, char32_t p_index, const Color &p_color) const {
+ if (!GDVIRTUAL_CALL(_draw_hex_code_box, p_canvas, p_size, p_pos, p_index, p_color)) {
+ TextServer::draw_hex_code_box(p_canvas, p_size, p_pos, p_index, p_color);
+ }
+}
+
+/*************************************************************************/
+/* Shaped text buffer interface */
+/*************************************************************************/
+
+RID TextServerExtension::create_shaped_text(TextServer::Direction p_direction, TextServer::Orientation p_orientation) {
+ RID ret;
+ if (GDVIRTUAL_CALL(_create_shaped_text, p_direction, p_orientation, ret)) {
+ return ret;
+ }
+ return RID();
+}
+
+void TextServerExtension::shaped_text_clear(RID p_shaped) {
+ GDVIRTUAL_CALL(_shaped_text_clear, p_shaped);
+}
+
+void TextServerExtension::shaped_text_set_direction(RID p_shaped, TextServer::Direction p_direction) {
+ GDVIRTUAL_CALL(_shaped_text_set_direction, p_shaped, p_direction);
+}
+
+TextServer::Direction TextServerExtension::shaped_text_get_direction(RID p_shaped) const {
+ int ret;
+ if (GDVIRTUAL_CALL(_shaped_text_get_direction, p_shaped, ret)) {
+ return (TextServer::Direction)ret;
+ }
+ return TextServer::Direction::DIRECTION_AUTO;
+}
+
+void TextServerExtension::shaped_text_set_orientation(RID p_shaped, TextServer::Orientation p_orientation) {
+ GDVIRTUAL_CALL(_shaped_text_set_orientation, p_shaped, p_orientation);
+}
+
+TextServer::Orientation TextServerExtension::shaped_text_get_orientation(RID p_shaped) const {
+ int ret;
+ if (GDVIRTUAL_CALL(_shaped_text_get_orientation, p_shaped, ret)) {
+ return (TextServer::Orientation)ret;
+ }
+ return TextServer::Orientation::ORIENTATION_HORIZONTAL;
+}
+
+void TextServerExtension::shaped_text_set_bidi_override(RID p_shaped, const Array &p_override) {
+ GDVIRTUAL_CALL(_shaped_text_set_bidi_override, p_shaped, p_override);
+}
+
+void TextServerExtension::shaped_text_set_preserve_invalid(RID p_shaped, bool p_enabled) {
+ GDVIRTUAL_CALL(_shaped_text_set_preserve_invalid, p_shaped, p_enabled);
+}
+
+bool TextServerExtension::shaped_text_get_preserve_invalid(RID p_shaped) const {
+ bool ret;
+ if (GDVIRTUAL_CALL(_shaped_text_get_preserve_invalid, p_shaped, ret)) {
+ return ret;
+ }
+ return false;
+}
+
+void TextServerExtension::shaped_text_set_preserve_control(RID p_shaped, bool p_enabled) {
+ GDVIRTUAL_CALL(_shaped_text_set_preserve_control, p_shaped, p_enabled);
+}
+
+bool TextServerExtension::shaped_text_get_preserve_control(RID p_shaped) const {
+ bool ret;
+ if (GDVIRTUAL_CALL(_shaped_text_get_preserve_control, p_shaped, ret)) {
+ return ret;
+ }
+ return false;
+}
+
+bool TextServerExtension::shaped_text_add_string(RID p_shaped, const String &p_text, const Vector<RID> &p_fonts, int p_size, const Dictionary &p_opentype_features, const String &p_language) {
+ bool ret;
+ Array fonts;
+ for (int i = 0; i < p_fonts.size(); i++) {
+ fonts.push_back(p_fonts[i]);
+ }
+ if (GDVIRTUAL_CALL(_shaped_text_add_string, p_shaped, p_text, fonts, p_size, p_opentype_features, p_language, ret)) {
+ return ret;
+ }
+ return false;
+}
+
+bool TextServerExtension::shaped_text_add_object(RID p_shaped, Variant p_key, const Size2 &p_size, InlineAlign p_inline_align, int p_length) {
+ bool ret;
+ if (GDVIRTUAL_CALL(_shaped_text_add_object, p_shaped, p_key, p_size, p_inline_align, p_length, ret)) {
+ return ret;
+ }
+ return false;
+}
+
+bool TextServerExtension::shaped_text_resize_object(RID p_shaped, Variant p_key, const Size2 &p_size, InlineAlign p_inline_align) {
+ bool ret;
+ if (GDVIRTUAL_CALL(_shaped_text_resize_object, p_shaped, p_key, p_size, p_inline_align, ret)) {
+ return ret;
+ }
+ return false;
+}
+
+RID TextServerExtension::shaped_text_substr(RID p_shaped, int p_start, int p_length) const {
+ RID ret;
+ if (GDVIRTUAL_CALL(_shaped_text_substr, p_shaped, p_start, p_length, ret)) {
+ return ret;
+ }
+ return RID();
+}
+
+RID TextServerExtension::shaped_text_get_parent(RID p_shaped) const {
+ RID ret;
+ if (GDVIRTUAL_CALL(_shaped_text_get_parent, p_shaped, ret)) {
+ return ret;
+ }
+ return RID();
+}
+
+float TextServerExtension::shaped_text_fit_to_width(RID p_shaped, float p_width, uint16_t p_jst_flags) {
+ float ret;
+ if (GDVIRTUAL_CALL(_shaped_text_fit_to_width, p_shaped, p_width, p_jst_flags, ret)) {
+ return ret;
+ }
+ return 0.f;
+}
+
+float TextServerExtension::shaped_text_tab_align(RID p_shaped, const PackedFloat32Array &p_tab_stops) {
+ float ret;
+ if (GDVIRTUAL_CALL(_shaped_text_tab_align, p_shaped, p_tab_stops, ret)) {
+ return ret;
+ }
+ return 0.f;
+}
+
+bool TextServerExtension::shaped_text_shape(RID p_shaped) {
+ bool ret;
+ if (GDVIRTUAL_CALL(_shaped_text_shape, p_shaped, ret)) {
+ return ret;
+ }
+ return false;
+}
+
+bool TextServerExtension::shaped_text_update_breaks(RID p_shaped) {
+ bool ret;
+ if (GDVIRTUAL_CALL(_shaped_text_update_breaks, p_shaped, ret)) {
+ return ret;
+ }
+ return false;
+}
+
+bool TextServerExtension::shaped_text_update_justification_ops(RID p_shaped) {
+ bool ret;
+ if (GDVIRTUAL_CALL(_shaped_text_update_justification_ops, p_shaped, ret)) {
+ return ret;
+ }
+ return false;
+}
+
+bool TextServerExtension::shaped_text_is_ready(RID p_shaped) const {
+ bool ret;
+ if (GDVIRTUAL_CALL(_shaped_text_is_ready, p_shaped, ret)) {
+ return ret;
+ }
+ return false;
+}
+
+const Glyph *TextServerExtension::shaped_text_get_glyphs(RID p_shaped) const {
+ const Glyph *ret;
+ if (GDVIRTUAL_CALL(_shaped_text_get_glyphs, p_shaped, &ret)) {
+ return ret;
+ }
+ return nullptr;
+}
+
+const Glyph *TextServerExtension::shaped_text_sort_logical(RID p_shaped) {
+ const Glyph *ret;
+ if (GDVIRTUAL_CALL(_shaped_text_sort_logical, p_shaped, &ret)) {
+ return ret;
+ }
+ return nullptr;
+}
+
+int TextServerExtension::shaped_text_get_glyph_count(RID p_shaped) const {
+ int ret;
+ if (GDVIRTUAL_CALL(_shaped_text_get_glyph_count, p_shaped, ret)) {
+ return ret;
+ }
+ return 0;
+}
+
+Vector2i TextServerExtension::shaped_text_get_range(RID p_shaped) const {
+ Vector2i ret;
+ if (GDVIRTUAL_CALL(_shaped_text_get_range, p_shaped, ret)) {
+ return ret;
+ }
+ return Vector2i();
+}
+
+PackedInt32Array TextServerExtension::shaped_text_get_line_breaks_adv(RID p_shaped, const PackedFloat32Array &p_width, int p_start, bool p_once, uint16_t p_break_flags) const {
+ PackedInt32Array ret;
+ if (GDVIRTUAL_CALL(_shaped_text_get_line_breaks_adv, p_shaped, p_width, p_start, p_once, p_break_flags, ret)) {
+ return ret;
+ }
+ return TextServer::shaped_text_get_line_breaks_adv(p_shaped, p_width, p_start, p_once, p_break_flags);
+}
+
+PackedInt32Array TextServerExtension::shaped_text_get_line_breaks(RID p_shaped, float p_width, int p_start, uint16_t p_break_flags) const {
+ PackedInt32Array ret;
+ if (GDVIRTUAL_CALL(_shaped_text_get_line_breaks, p_shaped, p_width, p_start, p_break_flags, ret)) {
+ return ret;
+ }
+ return TextServer::shaped_text_get_line_breaks(p_shaped, p_width, p_start, p_break_flags);
+}
+
+PackedInt32Array TextServerExtension::shaped_text_get_word_breaks(RID p_shaped, int p_grapheme_flags) const {
+ PackedInt32Array ret;
+ if (GDVIRTUAL_CALL(_shaped_text_get_word_breaks, p_shaped, p_grapheme_flags, ret)) {
+ return ret;
+ }
+ return TextServer::shaped_text_get_word_breaks(p_shaped, p_grapheme_flags);
+}
+
+int TextServerExtension::shaped_text_get_trim_pos(RID p_shaped) const {
+ int ret;
+ if (GDVIRTUAL_CALL(_shaped_text_get_trim_pos, p_shaped, ret)) {
+ return ret;
+ }
+ return -1;
+}
+
+int TextServerExtension::shaped_text_get_ellipsis_pos(RID p_shaped) const {
+ int ret;
+ if (GDVIRTUAL_CALL(_shaped_text_get_ellipsis_pos, p_shaped, ret)) {
+ return ret;
+ }
+ return -1;
+}
+
+const Glyph *TextServerExtension::shaped_text_get_ellipsis_glyphs(RID p_shaped) const {
+ const Glyph *ret;
+ if (GDVIRTUAL_CALL(_shaped_text_get_ellipsis_glyphs, p_shaped, &ret)) {
+ return ret;
+ }
+ return nullptr;
+}
+
+int TextServerExtension::shaped_text_get_ellipsis_glyph_count(RID p_shaped) const {
+ int ret;
+ if (GDVIRTUAL_CALL(_shaped_text_get_ellipsis_glyph_count, p_shaped, ret)) {
+ return ret;
+ }
+ return -1;
+}
+
+void TextServerExtension::shaped_text_overrun_trim_to_width(RID p_shaped_line, float p_width, uint16_t p_trim_flags) {
+ GDVIRTUAL_CALL(_shaped_text_overrun_trim_to_width, p_shaped_line, p_width, p_trim_flags);
+}
+
+Array TextServerExtension::shaped_text_get_objects(RID p_shaped) const {
+ Array ret;
+ if (GDVIRTUAL_CALL(_shaped_text_get_objects, p_shaped, ret)) {
+ return ret;
+ }
+ return Array();
+}
+
+Rect2 TextServerExtension::shaped_text_get_object_rect(RID p_shaped, Variant p_key) const {
+ Rect2 ret;
+ if (GDVIRTUAL_CALL(_shaped_text_get_object_rect, p_shaped, p_key, ret)) {
+ return ret;
+ }
+ return Rect2();
+}
+
+Size2 TextServerExtension::shaped_text_get_size(RID p_shaped) const {
+ Size2 ret;
+ if (GDVIRTUAL_CALL(_shaped_text_get_size, p_shaped, ret)) {
+ return ret;
+ }
+ return Size2();
+}
+
+float TextServerExtension::shaped_text_get_ascent(RID p_shaped) const {
+ float ret;
+ if (GDVIRTUAL_CALL(_shaped_text_get_ascent, p_shaped, ret)) {
+ return ret;
+ }
+ return 0.f;
+}
+
+float TextServerExtension::shaped_text_get_descent(RID p_shaped) const {
+ float ret;
+ if (GDVIRTUAL_CALL(_shaped_text_get_descent, p_shaped, ret)) {
+ return ret;
+ }
+ return 0.f;
+}
+
+float TextServerExtension::shaped_text_get_width(RID p_shaped) const {
+ float ret;
+ if (GDVIRTUAL_CALL(_shaped_text_get_width, p_shaped, ret)) {
+ return ret;
+ }
+ return 0.f;
+}
+
+float TextServerExtension::shaped_text_get_underline_position(RID p_shaped) const {
+ float ret;
+ if (GDVIRTUAL_CALL(_shaped_text_get_underline_position, p_shaped, ret)) {
+ return ret;
+ }
+ return 0.f;
+}
+
+float TextServerExtension::shaped_text_get_underline_thickness(RID p_shaped) const {
+ float ret;
+ if (GDVIRTUAL_CALL(_shaped_text_get_underline_thickness, p_shaped, ret)) {
+ return ret;
+ }
+ return 0.f;
+}
+
+TextServer::Direction TextServerExtension::shaped_text_get_dominant_direction_in_range(RID p_shaped, int p_start, int p_end) const {
+ int ret;
+ if (GDVIRTUAL_CALL(_shaped_text_get_dominant_direction_in_range, p_shaped, p_start, p_end, ret)) {
+ return (TextServer::Direction)ret;
+ }
+ return TextServer::shaped_text_get_dominant_direction_in_range(p_shaped, p_start, p_end);
+}
+
+CaretInfo TextServerExtension::shaped_text_get_carets(RID p_shaped, int p_position) const {
+ CaretInfo ret;
+ if (GDVIRTUAL_CALL(_shaped_text_get_carets, p_shaped, p_position, &ret)) {
+ return ret;
+ }
+ return TextServer::shaped_text_get_carets(p_shaped, p_position);
+}
+
+Vector<Vector2> TextServerExtension::shaped_text_get_selection(RID p_shaped, int p_start, int p_end) const {
+ Vector<Vector2> ret;
+ if (GDVIRTUAL_CALL(_shaped_text_get_selection, p_shaped, p_start, p_end, ret)) {
+ return ret;
+ }
+ return TextServer::shaped_text_get_selection(p_shaped, p_start, p_end);
+}
+
+int TextServerExtension::shaped_text_hit_test_grapheme(RID p_shaped, float p_coords) const {
+ int ret;
+ if (GDVIRTUAL_CALL(_shaped_text_hit_test_grapheme, p_shaped, p_coords, ret)) {
+ return ret;
+ }
+ return TextServer::shaped_text_hit_test_grapheme(p_shaped, p_coords);
+}
+
+int TextServerExtension::shaped_text_hit_test_position(RID p_shaped, float p_coords) const {
+ int ret;
+ if (GDVIRTUAL_CALL(_shaped_text_hit_test_position, p_shaped, p_coords, ret)) {
+ return ret;
+ }
+ return TextServer::shaped_text_hit_test_position(p_shaped, p_coords);
+}
+
+void TextServerExtension::shaped_text_draw(RID p_shaped, RID p_canvas, const Vector2 &p_pos, float p_clip_l, float p_clip_r, const Color &p_color) const {
+ if (GDVIRTUAL_CALL(_shaped_text_draw, p_shaped, p_canvas, p_pos, p_clip_l, p_clip_r, p_color)) {
+ return;
+ }
+ TextServer::shaped_text_draw(p_shaped, p_canvas, p_pos, p_clip_l, p_clip_r, p_color);
+}
+
+void TextServerExtension::shaped_text_draw_outline(RID p_shaped, RID p_canvas, const Vector2 &p_pos, float p_clip_l, float p_clip_r, int p_outline_size, const Color &p_color) const {
+ if (GDVIRTUAL_CALL(_shaped_text_draw_outline, p_shaped, p_canvas, p_pos, p_clip_l, p_clip_r, p_outline_size, p_color)) {
+ return;
+ }
+ shaped_text_draw_outline(p_shaped, p_canvas, p_pos, p_clip_l, p_clip_r, p_outline_size, p_color);
+}
+
+int TextServerExtension::shaped_text_next_grapheme_pos(RID p_shaped, int p_pos) const {
+ int ret;
+ if (GDVIRTUAL_CALL(_shaped_text_next_grapheme_pos, p_shaped, p_pos, ret)) {
+ return ret;
+ }
+ return TextServer::shaped_text_next_grapheme_pos(p_shaped, p_pos);
+}
+
+int TextServerExtension::shaped_text_prev_grapheme_pos(RID p_shaped, int p_pos) const {
+ int ret;
+ if (GDVIRTUAL_CALL(_shaped_text_prev_grapheme_pos, p_shaped, p_pos, ret)) {
+ return ret;
+ }
+ return TextServer::shaped_text_prev_grapheme_pos(p_shaped, p_pos);
+}
+
+String TextServerExtension::format_number(const String &p_string, const String &p_language) const {
+ String ret;
+ if (GDVIRTUAL_CALL(_format_number, p_string, p_language, ret)) {
+ return ret;
+ }
+ return TextServer::format_number(p_string, p_language);
+}
+
+String TextServerExtension::parse_number(const String &p_string, const String &p_language) const {
+ String ret;
+ if (GDVIRTUAL_CALL(_parse_number, p_string, p_language, ret)) {
+ return ret;
+ }
+ return TextServer::parse_number(p_string, p_language);
+}
+
+String TextServerExtension::percent_sign(const String &p_language) const {
+ String ret;
+ if (GDVIRTUAL_CALL(_percent_sign, p_language, ret)) {
+ return ret;
+ }
+ return TextServer::percent_sign(p_language);
+}
+
+TextServerExtension::TextServerExtension() {
+ //NOP
+}
+
+TextServerExtension::~TextServerExtension() {
+ //NOP
+}
diff --git a/servers/text/text_server_extension.h b/servers/text/text_server_extension.h
new file mode 100644
index 0000000000..88a8c0cb0c
--- /dev/null
+++ b/servers/text/text_server_extension.h
@@ -0,0 +1,426 @@
+/*************************************************************************/
+/* text_server_extension.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 TEXT_SERVER_EXTENSION_H
+#define TEXT_SERVER_EXTENSION_H
+
+#include "core/object/gdvirtual.gen.inc"
+#include "core/object/script_language.h"
+#include "core/variant/native_ptr.h"
+#include "servers/text_server.h"
+
+class TextServerExtension : public TextServer {
+ GDCLASS(TextServerExtension, TextServer);
+
+protected:
+ _THREAD_SAFE_CLASS_
+
+ static void _bind_methods();
+
+public:
+ virtual bool has_feature(Feature p_feature) const override;
+ virtual String get_name() const override;
+ virtual uint32_t get_features() const override;
+ GDVIRTUAL1RC(bool, _has_feature, Feature);
+ GDVIRTUAL0RC(String, _get_name);
+ GDVIRTUAL0RC(uint32_t, _get_features);
+
+ virtual void free(RID p_rid) override;
+ virtual bool has(RID p_rid) override;
+ virtual bool load_support_data(const String &p_filename) override;
+ GDVIRTUAL1(_free, RID);
+ GDVIRTUAL1R(bool, _has, RID);
+ GDVIRTUAL1R(bool, _load_support_data, const String &);
+
+ virtual String get_support_data_filename() const override;
+ virtual String get_support_data_info() const override;
+ virtual bool save_support_data(const String &p_filename) const override;
+ GDVIRTUAL0RC(String, _get_support_data_filename);
+ GDVIRTUAL0RC(String, _get_support_data_info);
+ GDVIRTUAL1RC(bool, _save_support_data, const String &);
+
+ virtual bool is_locale_right_to_left(const String &p_locale) const override;
+ GDVIRTUAL1RC(bool, _is_locale_right_to_left, const String &);
+
+ virtual int32_t name_to_tag(const String &p_name) const override;
+ virtual String tag_to_name(int32_t p_tag) const override;
+ GDVIRTUAL1RC(int32_t, _name_to_tag, const String &);
+ GDVIRTUAL1RC(String, _tag_to_name, int32_t);
+
+ /* Font interface */
+ virtual RID create_font() override;
+ GDVIRTUAL0R(RID, _create_font);
+
+ virtual void font_set_data(RID p_font_rid, const PackedByteArray &p_data) override;
+ virtual void font_set_data_ptr(RID p_font_rid, const uint8_t *p_data_ptr, size_t p_data_size) override;
+ GDVIRTUAL2(_font_set_data, RID, const PackedByteArray &);
+ GDVIRTUAL3(_font_set_data_ptr, RID, GDNativeConstPtr<const uint8_t>, uint64_t);
+
+ virtual void font_set_antialiased(RID p_font_rid, bool p_antialiased) override;
+ virtual bool font_is_antialiased(RID p_font_rid) const override;
+ GDVIRTUAL2(_font_set_antialiased, RID, bool);
+ GDVIRTUAL1RC(bool, _font_is_antialiased, RID);
+
+ virtual void font_set_multichannel_signed_distance_field(RID p_font_rid, bool p_msdf) override;
+ virtual bool font_is_multichannel_signed_distance_field(RID p_font_rid) const override;
+ GDVIRTUAL2(_font_set_multichannel_signed_distance_field, RID, bool);
+ GDVIRTUAL1RC(bool, _font_is_multichannel_signed_distance_field, RID);
+
+ virtual void font_set_msdf_pixel_range(RID p_font_rid, int p_msdf_pixel_range) override;
+ virtual int font_get_msdf_pixel_range(RID p_font_rid) const override;
+ GDVIRTUAL2(_font_set_msdf_pixel_range, RID, int);
+ GDVIRTUAL1RC(int, _font_get_msdf_pixel_range, RID);
+
+ virtual void font_set_msdf_size(RID p_font_rid, int p_msdf_size) override;
+ virtual int font_get_msdf_size(RID p_font_rid) const override;
+ GDVIRTUAL2(_font_set_msdf_size, RID, int);
+ GDVIRTUAL1RC(int, _font_get_msdf_size, RID);
+
+ virtual void font_set_fixed_size(RID p_font_rid, int p_fixed_size) override;
+ virtual int font_get_fixed_size(RID p_font_rid) const override;
+ GDVIRTUAL2(_font_set_fixed_size, RID, int);
+ GDVIRTUAL1RC(int, _font_get_fixed_size, RID);
+
+ virtual void font_set_force_autohinter(RID p_font_rid, bool p_force_autohinter) override;
+ virtual bool font_is_force_autohinter(RID p_font_rid) const override;
+ GDVIRTUAL2(_font_set_force_autohinter, RID, bool);
+ GDVIRTUAL1RC(bool, _font_is_force_autohinter, RID);
+
+ virtual void font_set_hinting(RID p_font_rid, Hinting p_hinting) override;
+ virtual Hinting font_get_hinting(RID p_font_rid) const override;
+ GDVIRTUAL2(_font_set_hinting, RID, Hinting);
+ GDVIRTUAL1RC(/*Hinting*/ int, _font_get_hinting, RID);
+
+ virtual void font_set_variation_coordinates(RID p_font_rid, const Dictionary &p_variation_coordinates) override;
+ virtual Dictionary font_get_variation_coordinates(RID p_font_rid) const override;
+ GDVIRTUAL2(_font_set_variation_coordinates, RID, Dictionary);
+ GDVIRTUAL1RC(Dictionary, _font_get_variation_coordinates, RID);
+
+ virtual void font_set_oversampling(RID p_font_rid, float p_oversampling) override;
+ virtual float font_get_oversampling(RID p_font_rid) const override;
+ GDVIRTUAL2(_font_set_oversampling, RID, float);
+ GDVIRTUAL1RC(float, _font_get_oversampling, RID);
+
+ virtual Array font_get_size_cache_list(RID p_font_rid) const override;
+ virtual void font_clear_size_cache(RID p_font_rid) override;
+ virtual void font_remove_size_cache(RID p_font_rid, const Vector2i &p_size) override;
+ GDVIRTUAL1RC(Array, _font_get_size_cache_list, RID);
+ GDVIRTUAL1(_font_clear_size_cache, RID);
+ GDVIRTUAL2(_font_remove_size_cache, RID, const Vector2i &);
+
+ virtual void font_set_ascent(RID p_font_rid, int p_size, float p_ascent) override;
+ virtual float font_get_ascent(RID p_font_rid, int p_size) const override;
+ GDVIRTUAL3(_font_set_ascent, RID, int, float);
+ GDVIRTUAL2RC(float, _font_get_ascent, RID, int);
+
+ virtual void font_set_descent(RID p_font_rid, int p_size, float p_descent) override;
+ virtual float font_get_descent(RID p_font_rid, int p_size) const override;
+ GDVIRTUAL3(_font_set_descent, RID, int, float);
+ GDVIRTUAL2RC(float, _font_get_descent, RID, int);
+
+ virtual void font_set_underline_position(RID p_font_rid, int p_size, float p_underline_position) override;
+ virtual float font_get_underline_position(RID p_font_rid, int p_size) const override;
+ GDVIRTUAL3(_font_set_underline_position, RID, int, float);
+ GDVIRTUAL2RC(float, _font_get_underline_position, RID, int);
+
+ virtual void font_set_underline_thickness(RID p_font_rid, int p_size, float p_underline_thickness) override;
+ virtual float font_get_underline_thickness(RID p_font_rid, int p_size) const override;
+ GDVIRTUAL3(_font_set_underline_thickness, RID, int, float);
+ GDVIRTUAL2RC(float, _font_get_underline_thickness, RID, int);
+
+ virtual void font_set_scale(RID p_font_rid, int p_size, float p_scale) override;
+ virtual float font_get_scale(RID p_font_rid, int p_size) const override;
+ GDVIRTUAL3(_font_set_scale, RID, int, float);
+ GDVIRTUAL2RC(float, _font_get_scale, RID, int);
+
+ virtual void font_set_spacing(RID p_font_rid, int p_size, SpacingType p_spacing, int p_value) override;
+ virtual int font_get_spacing(RID p_font_rid, int p_size, SpacingType p_spacing) const override;
+ GDVIRTUAL4(_font_set_spacing, RID, int, SpacingType, int);
+ GDVIRTUAL3RC(int, _font_get_spacing, RID, int, SpacingType);
+
+ virtual int font_get_texture_count(RID p_font_rid, const Vector2i &p_size) const override;
+ virtual void font_clear_textures(RID p_font_rid, const Vector2i &p_size) override;
+ virtual void font_remove_texture(RID p_font_rid, const Vector2i &p_size, int p_texture_index) override;
+ GDVIRTUAL2RC(int, _font_get_texture_count, RID, const Vector2i &);
+ GDVIRTUAL2(_font_clear_textures, RID, const Vector2i &);
+ GDVIRTUAL3(_font_remove_texture, RID, const Vector2i &, int);
+
+ virtual void font_set_texture_image(RID p_font_rid, const Vector2i &p_size, int p_texture_index, const Ref<Image> &p_image) override;
+ virtual Ref<Image> font_get_texture_image(RID p_font_rid, const Vector2i &p_size, int p_texture_index) const override;
+ GDVIRTUAL4(_font_set_texture_image, RID, const Vector2i &, int, const Ref<Image> &);
+ GDVIRTUAL3RC(Ref<Image>, _font_get_texture_image, RID, const Vector2i &, int);
+
+ virtual void font_set_texture_offsets(RID p_font_rid, const Vector2i &p_size, int p_texture_index, const PackedInt32Array &p_offset) override;
+ virtual PackedInt32Array font_get_texture_offsets(RID p_font_rid, const Vector2i &p_size, int p_texture_index) const override;
+ GDVIRTUAL4(_font_set_texture_offsets, RID, const Vector2i &, int, const PackedInt32Array &);
+ GDVIRTUAL3RC(PackedInt32Array, _font_get_texture_offsets, RID, const Vector2i &, int);
+
+ virtual Array font_get_glyph_list(RID p_font_rid, const Vector2i &p_size) const override;
+ virtual void font_clear_glyphs(RID p_font_rid, const Vector2i &p_size) override;
+ virtual void font_remove_glyph(RID p_font_rid, const Vector2i &p_size, int32_t p_glyph) override;
+ GDVIRTUAL2RC(Array, _font_get_glyph_list, RID, const Vector2i &);
+ GDVIRTUAL2(_font_clear_glyphs, RID, const Vector2i &);
+ GDVIRTUAL3(_font_remove_glyph, RID, const Vector2i &, int32_t);
+
+ virtual Vector2 font_get_glyph_advance(RID p_font_rid, int p_size, int32_t p_glyph) const override;
+ virtual void font_set_glyph_advance(RID p_font_rid, int p_size, int32_t p_glyph, const Vector2 &p_advance) override;
+ GDVIRTUAL3RC(Vector2, _font_get_glyph_advance, RID, int, int32_t);
+ GDVIRTUAL4(_font_set_glyph_advance, RID, int, int32_t, const Vector2 &);
+
+ virtual Vector2 font_get_glyph_offset(RID p_font_rid, const Vector2i &p_size, int32_t p_glyph) const override;
+ virtual void font_set_glyph_offset(RID p_font_rid, const Vector2i &p_size, int32_t p_glyph, const Vector2 &p_offset) override;
+ GDVIRTUAL3RC(Vector2, _font_get_glyph_offset, RID, const Vector2i &, int32_t);
+ GDVIRTUAL4(_font_set_glyph_offset, RID, const Vector2i &, int32_t, const Vector2 &);
+
+ virtual Vector2 font_get_glyph_size(RID p_font_rid, const Vector2i &p_size, int32_t p_glyph) const override;
+ virtual void font_set_glyph_size(RID p_font_rid, const Vector2i &p_size, int32_t p_glyph, const Vector2 &p_gl_size) override;
+ GDVIRTUAL3RC(Vector2, _font_get_glyph_size, RID, const Vector2i &, int32_t);
+ GDVIRTUAL4(_font_set_glyph_size, RID, const Vector2i &, int32_t, const Vector2 &);
+
+ virtual Rect2 font_get_glyph_uv_rect(RID p_font_rid, const Vector2i &p_size, int32_t p_glyph) const override;
+ virtual void font_set_glyph_uv_rect(RID p_font_rid, const Vector2i &p_size, int32_t p_glyph, const Rect2 &p_uv_rect) override;
+ GDVIRTUAL3RC(Rect2, _font_get_glyph_uv_rect, RID, const Vector2i &, int32_t);
+ GDVIRTUAL4(_font_set_glyph_uv_rect, RID, const Vector2i &, int32_t, const Rect2 &);
+
+ virtual int font_get_glyph_texture_idx(RID p_font_rid, const Vector2i &p_size, int32_t p_glyph) const override;
+ virtual void font_set_glyph_texture_idx(RID p_font_rid, const Vector2i &p_size, int32_t p_glyph, int p_texture_idx) override;
+ GDVIRTUAL3RC(int, _font_get_glyph_texture_idx, RID, const Vector2i &, int32_t);
+ GDVIRTUAL4(_font_set_glyph_texture_idx, RID, const Vector2i &, int32_t, int);
+
+ virtual Dictionary font_get_glyph_contours(RID p_font, int p_size, int32_t p_index) const override;
+ GDVIRTUAL3RC(Dictionary, _font_get_glyph_contours, RID, int, int32_t);
+
+ virtual Array font_get_kerning_list(RID p_font_rid, int p_size) const override;
+ virtual void font_clear_kerning_map(RID p_font_rid, int p_size) override;
+ virtual void font_remove_kerning(RID p_font_rid, int p_size, const Vector2i &p_glyph_pair) override;
+ GDVIRTUAL2RC(Array, _font_get_kerning_list, RID, int);
+ GDVIRTUAL2(_font_clear_kerning_map, RID, int);
+ GDVIRTUAL3(_font_remove_kerning, RID, int, const Vector2i &);
+
+ virtual void font_set_kerning(RID p_font_rid, int p_size, const Vector2i &p_glyph_pair, const Vector2 &p_kerning) override;
+ virtual Vector2 font_get_kerning(RID p_font_rid, int p_size, const Vector2i &p_glyph_pair) const override;
+ GDVIRTUAL4(_font_set_kerning, RID, int, const Vector2i &, const Vector2 &);
+ GDVIRTUAL3RC(Vector2, _font_get_kerning, RID, int, const Vector2i &);
+
+ virtual int32_t font_get_glyph_index(RID p_font_rid, int p_size, char32_t p_char, char32_t p_variation_selector = 0) const override;
+ GDVIRTUAL4RC(int32_t, _font_get_glyph_index, RID, int, char32_t, char32_t);
+
+ virtual bool font_has_char(RID p_font_rid, char32_t p_char) const override;
+ virtual String font_get_supported_chars(RID p_font_rid) const override;
+ GDVIRTUAL2RC(bool, _font_has_char, RID, char32_t);
+ GDVIRTUAL1RC(String, _font_get_supported_chars, RID);
+
+ virtual void font_render_range(RID p_font, const Vector2i &p_size, char32_t p_start, char32_t p_end) override;
+ virtual void font_render_glyph(RID p_font_rid, const Vector2i &p_size, int32_t p_index) override;
+ GDVIRTUAL4(_font_render_range, RID, const Vector2i &, char32_t, char32_t);
+ GDVIRTUAL3(_font_render_glyph, RID, const Vector2i &, int32_t);
+
+ virtual void font_draw_glyph(RID p_font, RID p_canvas, int p_size, const Vector2 &p_pos, int32_t p_index, const Color &p_color = Color(1, 1, 1)) const override;
+ virtual void font_draw_glyph_outline(RID p_font, RID p_canvas, int p_size, int p_outline_size, const Vector2 &p_pos, int32_t p_index, const Color &p_color = Color(1, 1, 1)) const override;
+ GDVIRTUAL6C(_font_draw_glyph, RID, RID, int, const Vector2 &, int32_t, const Color &);
+ GDVIRTUAL7C(_font_draw_glyph_outline, RID, RID, int, int, const Vector2 &, int32_t, const Color &);
+
+ virtual bool font_is_language_supported(RID p_font_rid, const String &p_language) const override;
+ virtual void font_set_language_support_override(RID p_font_rid, const String &p_language, bool p_supported) override;
+ virtual bool font_get_language_support_override(RID p_font_rid, const String &p_language) override;
+ virtual void font_remove_language_support_override(RID p_font_rid, const String &p_language) override;
+ virtual Vector<String> font_get_language_support_overrides(RID p_font_rid) override;
+ GDVIRTUAL2RC(bool, _font_is_language_supported, RID, const String &);
+ GDVIRTUAL3(_font_set_language_support_override, RID, const String &, bool);
+ GDVIRTUAL2R(bool, _font_get_language_support_override, RID, const String &);
+ GDVIRTUAL2(_font_remove_language_support_override, RID, const String &);
+ GDVIRTUAL1R(Vector<String>, _font_get_language_support_overrides, RID);
+
+ virtual bool font_is_script_supported(RID p_font_rid, const String &p_script) const override;
+ virtual void font_set_script_support_override(RID p_font_rid, const String &p_script, bool p_supported) override;
+ virtual bool font_get_script_support_override(RID p_font_rid, const String &p_script) override;
+ virtual void font_remove_script_support_override(RID p_font_rid, const String &p_script) override;
+ virtual Vector<String> font_get_script_support_overrides(RID p_font_rid) override;
+ GDVIRTUAL2RC(bool, _font_is_script_supported, RID, const String &);
+ GDVIRTUAL3(_font_set_script_support_override, RID, const String &, bool);
+ GDVIRTUAL2R(bool, _font_get_script_support_override, RID, const String &);
+ GDVIRTUAL2(_font_remove_script_support_override, RID, const String &);
+ GDVIRTUAL1R(Vector<String>, _font_get_script_support_overrides, RID);
+
+ virtual Dictionary font_supported_feature_list(RID p_font_rid) const override;
+ virtual Dictionary font_supported_variation_list(RID p_font_rid) const override;
+ GDVIRTUAL1RC(Dictionary, _font_supported_feature_list, RID);
+ GDVIRTUAL1RC(Dictionary, _font_supported_variation_list, RID);
+
+ virtual float font_get_global_oversampling() const override;
+ virtual void font_set_global_oversampling(float p_oversampling) override;
+ GDVIRTUAL0RC(float, _font_get_global_oversampling);
+ GDVIRTUAL1(_font_set_global_oversampling, float);
+
+ virtual Vector2 get_hex_code_box_size(int p_size, char32_t p_index) const override;
+ virtual void draw_hex_code_box(RID p_canvas, int p_size, const Vector2 &p_pos, char32_t p_index, const Color &p_color) const override;
+ GDVIRTUAL2RC(Vector2, _get_hex_code_box_size, int, char32_t);
+ GDVIRTUAL5C(_draw_hex_code_box, RID, int, const Vector2 &, char32_t, const Color &);
+
+ /* Shaped text buffer interface */
+
+ virtual RID create_shaped_text(Direction p_direction = DIRECTION_AUTO, Orientation p_orientation = ORIENTATION_HORIZONTAL) override;
+ GDVIRTUAL2R(RID, _create_shaped_text, Direction, Orientation);
+
+ virtual void shaped_text_clear(RID p_shaped) override;
+ GDVIRTUAL1(_shaped_text_clear, RID);
+
+ virtual void shaped_text_set_direction(RID p_shaped, Direction p_direction = DIRECTION_AUTO) override;
+ virtual Direction shaped_text_get_direction(RID p_shaped) const override;
+ GDVIRTUAL2(_shaped_text_set_direction, RID, Direction);
+ GDVIRTUAL1RC(/*Direction*/ int, _shaped_text_get_direction, RID);
+
+ virtual void shaped_text_set_bidi_override(RID p_shaped, const Array &p_override) override;
+ GDVIRTUAL2(_shaped_text_set_bidi_override, RID, const Array &);
+
+ virtual void shaped_text_set_orientation(RID p_shaped, Orientation p_orientation = ORIENTATION_HORIZONTAL) override;
+ virtual Orientation shaped_text_get_orientation(RID p_shaped) const override;
+ GDVIRTUAL2(_shaped_text_set_orientation, RID, Orientation);
+ GDVIRTUAL1RC(/*Orientation*/ int, _shaped_text_get_orientation, RID);
+
+ virtual void shaped_text_set_preserve_invalid(RID p_shaped, bool p_enabled) override;
+ virtual bool shaped_text_get_preserve_invalid(RID p_shaped) const override;
+ GDVIRTUAL2(_shaped_text_set_preserve_invalid, RID, bool);
+ GDVIRTUAL1RC(bool, _shaped_text_get_preserve_invalid, RID);
+
+ virtual void shaped_text_set_preserve_control(RID p_shaped, bool p_enabled) override;
+ virtual bool shaped_text_get_preserve_control(RID p_shaped) const override;
+ GDVIRTUAL2(_shaped_text_set_preserve_control, RID, bool);
+ GDVIRTUAL1RC(bool, _shaped_text_get_preserve_control, RID);
+
+ virtual bool shaped_text_add_string(RID p_shaped, const String &p_text, const Vector<RID> &p_fonts, int p_size, const Dictionary &p_opentype_features = Dictionary(), const String &p_language = "") override;
+ virtual bool shaped_text_add_object(RID p_shaped, Variant p_key, const Size2 &p_size, InlineAlign p_inline_align = INLINE_ALIGN_CENTER, int p_length = 1) override;
+ virtual bool shaped_text_resize_object(RID p_shaped, Variant p_key, const Size2 &p_size, InlineAlign p_inline_align = INLINE_ALIGN_CENTER) override;
+ GDVIRTUAL6R(bool, _shaped_text_add_string, RID, const String &, const Array &, int, const Dictionary &, const String &);
+ GDVIRTUAL5R(bool, _shaped_text_add_object, RID, Variant, const Size2 &, InlineAlign, int);
+ GDVIRTUAL4R(bool, _shaped_text_resize_object, RID, Variant, const Size2 &, InlineAlign);
+
+ virtual RID shaped_text_substr(RID p_shaped, int p_start, int p_length) const override;
+ virtual RID shaped_text_get_parent(RID p_shaped) const override;
+ GDVIRTUAL3RC(RID, _shaped_text_substr, RID, int, int);
+ GDVIRTUAL1RC(RID, _shaped_text_get_parent, RID);
+
+ virtual float shaped_text_fit_to_width(RID p_shaped, float p_width, uint16_t /*JustificationFlag*/ p_jst_flags = JUSTIFICATION_WORD_BOUND | JUSTIFICATION_KASHIDA) override;
+ virtual float shaped_text_tab_align(RID p_shaped, const PackedFloat32Array &p_tab_stops) override;
+ GDVIRTUAL3R(float, _shaped_text_fit_to_width, RID, float, uint16_t);
+ GDVIRTUAL2R(float, _shaped_text_tab_align, RID, const PackedFloat32Array &);
+
+ virtual bool shaped_text_shape(RID p_shaped) override;
+ virtual bool shaped_text_update_breaks(RID p_shaped) override;
+ virtual bool shaped_text_update_justification_ops(RID p_shaped) override;
+ GDVIRTUAL1R(bool, _shaped_text_shape, RID);
+ GDVIRTUAL1R(bool, _shaped_text_update_breaks, RID);
+ GDVIRTUAL1R(bool, _shaped_text_update_justification_ops, RID);
+
+ virtual bool shaped_text_is_ready(RID p_shaped) const override;
+ GDVIRTUAL1RC(bool, _shaped_text_is_ready, RID);
+
+ virtual const Glyph *shaped_text_get_glyphs(RID p_shaped) const override;
+ virtual const Glyph *shaped_text_sort_logical(RID p_shaped) override;
+ virtual int shaped_text_get_glyph_count(RID p_shaped) const override;
+ GDVIRTUAL2C(_shaped_text_get_glyphs, RID, GDNativePtr<const Glyph *>);
+ GDVIRTUAL2(_shaped_text_sort_logical, RID, GDNativePtr<const Glyph *>);
+ GDVIRTUAL1RC(int, _shaped_text_get_glyph_count, RID);
+
+ virtual Vector2i shaped_text_get_range(RID p_shaped) const override;
+ GDVIRTUAL1RC(Vector2i, _shaped_text_get_range, RID);
+
+ virtual PackedInt32Array shaped_text_get_line_breaks_adv(RID p_shaped, const PackedFloat32Array &p_width, int p_start = 0, bool p_once = true, uint16_t /*TextBreakFlag*/ p_break_flags = BREAK_MANDATORY | BREAK_WORD_BOUND) const override;
+ virtual PackedInt32Array shaped_text_get_line_breaks(RID p_shaped, float p_width, int p_start = 0, uint16_t p_break_flags = BREAK_MANDATORY | BREAK_WORD_BOUND) const override;
+ virtual PackedInt32Array shaped_text_get_word_breaks(RID p_shaped, int p_grapheme_flags = GRAPHEME_IS_SPACE | GRAPHEME_IS_PUNCTUATION) const override;
+ GDVIRTUAL5RC(PackedInt32Array, _shaped_text_get_line_breaks_adv, RID, const PackedFloat32Array &, int, bool, uint16_t);
+ GDVIRTUAL4RC(PackedInt32Array, _shaped_text_get_line_breaks, RID, float, int, uint16_t);
+ GDVIRTUAL2RC(PackedInt32Array, _shaped_text_get_word_breaks, RID, int);
+
+ virtual int shaped_text_get_trim_pos(RID p_shaped) const override;
+ virtual int shaped_text_get_ellipsis_pos(RID p_shaped) const override;
+ virtual const Glyph *shaped_text_get_ellipsis_glyphs(RID p_shaped) const override;
+ virtual int shaped_text_get_ellipsis_glyph_count(RID p_shaped) const override;
+ GDVIRTUAL1RC(int, _shaped_text_get_trim_pos, RID);
+ GDVIRTUAL1RC(int, _shaped_text_get_ellipsis_pos, RID);
+ GDVIRTUAL2C(_shaped_text_get_ellipsis_glyphs, RID, GDNativePtr<const Glyph *>);
+ GDVIRTUAL1RC(int, _shaped_text_get_ellipsis_glyph_count, RID);
+
+ virtual void shaped_text_overrun_trim_to_width(RID p_shaped, float p_width, uint16_t p_trim_flags) override;
+ GDVIRTUAL3(_shaped_text_overrun_trim_to_width, RID, float, uint16_t);
+
+ virtual Array shaped_text_get_objects(RID p_shaped) const override;
+ virtual Rect2 shaped_text_get_object_rect(RID p_shaped, Variant p_key) const override;
+ GDVIRTUAL1RC(Array, _shaped_text_get_objects, RID);
+ GDVIRTUAL2RC(Rect2, _shaped_text_get_object_rect, RID, Variant);
+
+ virtual Size2 shaped_text_get_size(RID p_shaped) const override;
+ virtual float shaped_text_get_ascent(RID p_shaped) const override;
+ virtual float shaped_text_get_descent(RID p_shaped) const override;
+ virtual float shaped_text_get_width(RID p_shaped) const override;
+ virtual float shaped_text_get_underline_position(RID p_shaped) const override;
+ virtual float shaped_text_get_underline_thickness(RID p_shaped) const override;
+ GDVIRTUAL1RC(Size2, _shaped_text_get_size, RID);
+ GDVIRTUAL1RC(float, _shaped_text_get_ascent, RID);
+ GDVIRTUAL1RC(float, _shaped_text_get_descent, RID);
+ GDVIRTUAL1RC(float, _shaped_text_get_width, RID);
+ GDVIRTUAL1RC(float, _shaped_text_get_underline_position, RID);
+ GDVIRTUAL1RC(float, _shaped_text_get_underline_thickness, RID);
+
+ virtual Direction shaped_text_get_dominant_direction_in_range(RID p_shaped, int p_start, int p_end) const override;
+ GDVIRTUAL3RC(int, _shaped_text_get_dominant_direction_in_range, RID, int, int);
+
+ virtual CaretInfo shaped_text_get_carets(RID p_shaped, int p_position) const override;
+ virtual Vector<Vector2> shaped_text_get_selection(RID p_shaped, int p_start, int p_end) const override;
+ GDVIRTUAL3C(_shaped_text_get_carets, RID, int, GDNativePtr<CaretInfo>);
+ GDVIRTUAL3RC(Vector<Vector2>, _shaped_text_get_selection, RID, int, int);
+
+ virtual int shaped_text_hit_test_grapheme(RID p_shaped, float p_coords) const override;
+ virtual int shaped_text_hit_test_position(RID p_shaped, float p_coords) const override;
+ GDVIRTUAL2RC(int, _shaped_text_hit_test_grapheme, RID, float);
+ GDVIRTUAL2RC(int, _shaped_text_hit_test_position, RID, float);
+
+ virtual void shaped_text_draw(RID p_shaped, RID p_canvas, const Vector2 &p_pos, float p_clip_l = -1.f, float p_clip_r = -1.f, const Color &p_color = Color(1, 1, 1)) const override;
+ virtual void shaped_text_draw_outline(RID p_shaped, RID p_canvas, const Vector2 &p_pos, float p_clip_l = -1.f, float p_clip_r = -1.f, int p_outline_size = 1, const Color &p_color = Color(1, 1, 1)) const override;
+ GDVIRTUAL6C(_shaped_text_draw, RID, RID, const Vector2 &, float, float, const Color &);
+ GDVIRTUAL7C(_shaped_text_draw_outline, RID, RID, const Vector2 &, float, float, int, const Color &);
+
+ virtual int shaped_text_next_grapheme_pos(RID p_shaped, int p_pos) const override;
+ virtual int shaped_text_prev_grapheme_pos(RID p_shaped, int p_pos) const override;
+ GDVIRTUAL2RC(int, _shaped_text_next_grapheme_pos, RID, int);
+ GDVIRTUAL2RC(int, _shaped_text_prev_grapheme_pos, RID, int);
+
+ virtual String format_number(const String &p_string, const String &p_language = "") const override;
+ virtual String parse_number(const String &p_string, const String &p_language = "") const override;
+ virtual String percent_sign(const String &p_language = "") const override;
+ GDVIRTUAL2RC(String, _format_number, const String &, const String &);
+ GDVIRTUAL2RC(String, _parse_number, const String &, const String &);
+ GDVIRTUAL1RC(String, _percent_sign, const String &);
+
+ TextServerExtension();
+ ~TextServerExtension();
+};
+
+#endif // TEXT_SERVER_EXTENSION_H
diff --git a/servers/text_server.cpp b/servers/text_server.cpp
index 4886a6f582..a365fde64a 100644
--- a/servers/text_server.cpp
+++ b/servers/text_server.cpp
@@ -32,122 +32,108 @@
#include "scene/main/canvas_item.h"
TextServerManager *TextServerManager::singleton = nullptr;
-TextServer *TextServerManager::server = nullptr;
-TextServerManager::TextServerCreate TextServerManager::server_create_functions[TextServerManager::MAX_SERVERS];
-int TextServerManager::server_create_count = 0;
void TextServerManager::_bind_methods() {
- ClassDB::bind_method(D_METHOD("get_interface_count"), &TextServerManager::_get_interface_count);
- ClassDB::bind_method(D_METHOD("get_interface_name", "index"), &TextServerManager::_get_interface_name);
- ClassDB::bind_method(D_METHOD("get_interface_features", "index"), &TextServerManager::_get_interface_features);
- ClassDB::bind_method(D_METHOD("get_interface", "index"), &TextServerManager::_get_interface);
- ClassDB::bind_method(D_METHOD("get_interfaces"), &TextServerManager::_get_interfaces);
- ClassDB::bind_method(D_METHOD("find_interface", "name"), &TextServerManager::_find_interface);
-
- ClassDB::bind_method(D_METHOD("set_primary_interface", "index"), &TextServerManager::_set_primary_interface);
+ ClassDB::bind_method(D_METHOD("add_interface", "interface"), &TextServerManager::add_interface);
+ ClassDB::bind_method(D_METHOD("get_interface_count"), &TextServerManager::get_interface_count);
+ ClassDB::bind_method(D_METHOD("remove_interface", "interface"), &TextServerManager::remove_interface);
+ ClassDB::bind_method(D_METHOD("get_interface", "idx"), &TextServerManager::get_interface);
+ ClassDB::bind_method(D_METHOD("get_interfaces"), &TextServerManager::get_interfaces);
+ ClassDB::bind_method(D_METHOD("find_interface", "name"), &TextServerManager::find_interface);
+
+ ClassDB::bind_method(D_METHOD("set_primary_interface", "index"), &TextServerManager::set_primary_interface);
ClassDB::bind_method(D_METHOD("get_primary_interface"), &TextServerManager::_get_primary_interface);
-}
-void TextServerManager::register_create_function(const String &p_name, uint32_t p_features, TextServerManager::CreateFunction p_function, void *p_user_data) {
- ERR_FAIL_COND(server_create_count == MAX_SERVERS);
- server_create_functions[server_create_count].name = p_name;
- server_create_functions[server_create_count].create_function = p_function;
- server_create_functions[server_create_count].user_data = p_user_data;
- server_create_functions[server_create_count].features = p_features;
- server_create_count++;
+ ADD_SIGNAL(MethodInfo("interface_added", PropertyInfo(Variant::STRING_NAME, "interface_name")));
+ ADD_SIGNAL(MethodInfo("interface_removed", PropertyInfo(Variant::STRING_NAME, "interface_name")));
}
-int TextServerManager::get_interface_count() {
- return server_create_count;
-}
+void TextServerManager::add_interface(const Ref<TextServer> &p_interface) {
+ ERR_FAIL_COND(p_interface.is_null());
-String TextServerManager::get_interface_name(int p_index) {
- ERR_FAIL_INDEX_V(p_index, server_create_count, String());
- return server_create_functions[p_index].name;
-}
+ for (int i = 0; i < interfaces.size(); i++) {
+ if (interfaces[i] == p_interface) {
+ ERR_PRINT("TextServer: Interface was already added.");
+ return;
+ };
+ };
-uint32_t TextServerManager::get_interface_features(int p_index) {
- ERR_FAIL_INDEX_V(p_index, server_create_count, 0);
- return server_create_functions[p_index].features;
+ interfaces.push_back(p_interface);
+ print_verbose("TextServer: Added interface \"" + p_interface->get_name() + "\"");
+ emit_signal(SNAME("interface_added"), p_interface->get_name());
}
-TextServer *TextServerManager::initialize(int p_index, Error &r_error) {
- ERR_FAIL_INDEX_V(p_index, server_create_count, nullptr);
- if (server_create_functions[p_index].instance == nullptr) {
- server_create_functions[p_index].instance = server_create_functions[p_index].create_function(r_error, server_create_functions[p_index].user_data);
- if (server_create_functions[p_index].instance != nullptr) {
- server_create_functions[p_index].instance->load_support_data(""); // Try loading default data.
- }
- }
- if (server_create_functions[p_index].instance != nullptr) {
- server = server_create_functions[p_index].instance;
- if (OS::get_singleton()->get_main_loop()) {
- OS::get_singleton()->get_main_loop()->notification(MainLoop::NOTIFICATION_TEXT_SERVER_CHANGED);
- }
- }
- return server_create_functions[p_index].instance;
-}
+void TextServerManager::remove_interface(const Ref<TextServer> &p_interface) {
+ ERR_FAIL_COND(p_interface.is_null());
+ ERR_FAIL_COND_MSG(p_interface == primary_interface, "TextServer: Can't remove primary interface.");
-TextServer *TextServerManager::get_primary_interface() {
- return server;
-}
+ int idx = -1;
+ for (int i = 0; i < interfaces.size(); i++) {
+ if (interfaces[i] == p_interface) {
+ idx = i;
+ break;
+ };
+ };
-int TextServerManager::_get_interface_count() const {
- return server_create_count;
+ ERR_FAIL_COND(idx == -1);
+ print_verbose("TextServer: Removed interface \"" + p_interface->get_name() + "\"");
+ emit_signal(SNAME("interface_removed"), p_interface->get_name());
+ interfaces.remove(idx);
}
-String TextServerManager::_get_interface_name(int p_index) const {
- return get_interface_name(p_index);
+int TextServerManager::get_interface_count() const {
+ return interfaces.size();
}
-uint32_t TextServerManager::_get_interface_features(int p_index) const {
- return get_interface_features(p_index);
+Ref<TextServer> TextServerManager::get_interface(int p_index) const {
+ ERR_FAIL_INDEX_V(p_index, interfaces.size(), nullptr);
+ return interfaces[p_index];
}
-TextServer *TextServerManager::_get_interface(int p_index) const {
- ERR_FAIL_INDEX_V(p_index, server_create_count, nullptr);
- if (server_create_functions[p_index].instance == nullptr) {
- Error error;
- server_create_functions[p_index].instance = server_create_functions[p_index].create_function(error, server_create_functions[p_index].user_data);
- if (server_create_functions[p_index].instance != nullptr) {
- server_create_functions[p_index].instance->load_support_data(""); // Try loading default data.
- }
- }
- return server_create_functions[p_index].instance;
-}
+Ref<TextServer> TextServerManager::find_interface(const String &p_name) const {
+ int idx = -1;
+ for (int i = 0; i < interfaces.size(); i++) {
+ if (interfaces[i]->get_name() == p_name) {
+ idx = i;
+ break;
+ };
+ };
-TextServer *TextServerManager::_find_interface(const String &p_name) const {
- for (int i = 0; i < server_create_count; i++) {
- if (server_create_functions[i].name == p_name) {
- return _get_interface(i);
- }
- }
- return nullptr;
+ ERR_FAIL_COND_V(idx == -1, nullptr);
+ return interfaces[idx];
}
-Array TextServerManager::_get_interfaces() const {
+Array TextServerManager::get_interfaces() const {
Array ret;
- for (int i = 0; i < server_create_count; i++) {
+ for (int i = 0; i < interfaces.size(); i++) {
Dictionary iface_info;
iface_info["id"] = i;
- iface_info["name"] = server_create_functions[i].name;
+ iface_info["name"] = interfaces[i]->get_name();
ret.push_back(iface_info);
};
return ret;
-};
+}
-bool TextServerManager::_set_primary_interface(int p_index) {
- Error error;
- TextServerManager::initialize(p_index, error);
- return (error == OK);
+Ref<TextServer> TextServerManager::_get_primary_interface() const {
+ return primary_interface;
}
-TextServer *TextServerManager::_get_primary_interface() const {
- return server;
+void TextServerManager::set_primary_interface(const Ref<TextServer> &p_primary_interface) {
+ if (p_primary_interface.is_null()) {
+ print_verbose("TextServer: Clearing primary interface");
+ primary_interface.unref();
+ } else {
+ primary_interface = p_primary_interface;
+ print_verbose("TextServer: Primary interface set to: \"" + primary_interface->get_name() + "\".");
+
+ if (OS::get_singleton()->get_main_loop()) {
+ OS::get_singleton()->get_main_loop()->notification(MainLoop::NOTIFICATION_TEXT_SERVER_CHANGED);
+ }
+ }
}
TextServerManager::TextServerManager() {
@@ -155,29 +141,29 @@ TextServerManager::TextServerManager() {
}
TextServerManager::~TextServerManager() {
- singleton = nullptr;
- for (int i = 0; i < server_create_count; i++) {
- if (server_create_functions[i].instance != nullptr) {
- memdelete(server_create_functions[i].instance);
- server_create_functions[i].instance = nullptr;
- }
+ if (primary_interface.is_valid()) {
+ primary_interface.unref();
}
+ while (interfaces.size() > 0) {
+ interfaces.remove(0);
+ }
+ singleton = nullptr;
}
/*************************************************************************/
-bool TextServer::Glyph::operator==(const Glyph &p_a) const {
+bool Glyph::operator==(const Glyph &p_a) const {
return (p_a.index == index) && (p_a.font_rid == font_rid) && (p_a.font_size == font_size) && (p_a.start == start);
}
-bool TextServer::Glyph::operator!=(const Glyph &p_a) const {
+bool Glyph::operator!=(const Glyph &p_a) const {
return (p_a.index != index) || (p_a.font_rid != font_rid) || (p_a.font_size != font_size) || (p_a.start != start);
}
-bool TextServer::Glyph::operator<(const Glyph &p_a) const {
+bool Glyph::operator<(const Glyph &p_a) const {
if (p_a.start == start) {
if (p_a.count == count) {
- if ((p_a.flags & GRAPHEME_IS_VIRTUAL) == GRAPHEME_IS_VIRTUAL) {
+ if ((p_a.flags & TextServer::GRAPHEME_IS_VIRTUAL) == TextServer::GRAPHEME_IS_VIRTUAL) {
return true;
} else {
return false;
@@ -188,10 +174,10 @@ bool TextServer::Glyph::operator<(const Glyph &p_a) const {
return p_a.start < start;
}
-bool TextServer::Glyph::operator>(const Glyph &p_a) const {
+bool Glyph::operator>(const Glyph &p_a) const {
if (p_a.start == start) {
if (p_a.count == count) {
- if ((p_a.flags & GRAPHEME_IS_VIRTUAL) == GRAPHEME_IS_VIRTUAL) {
+ if ((p_a.flags & TextServer::GRAPHEME_IS_VIRTUAL) == TextServer::GRAPHEME_IS_VIRTUAL) {
return false;
} else {
return true;
@@ -205,8 +191,13 @@ bool TextServer::Glyph::operator>(const Glyph &p_a) const {
void TextServer::_bind_methods() {
ClassDB::bind_method(D_METHOD("has_feature", "feature"), &TextServer::has_feature);
ClassDB::bind_method(D_METHOD("get_name"), &TextServer::get_name);
+ ClassDB::bind_method(D_METHOD("get_features"), &TextServer::get_features);
ClassDB::bind_method(D_METHOD("load_support_data", "filename"), &TextServer::load_support_data);
+ ClassDB::bind_method(D_METHOD("get_support_data_filename"), &TextServer::get_support_data_filename);
+ ClassDB::bind_method(D_METHOD("get_support_data_info"), &TextServer::get_support_data_info);
+ ClassDB::bind_method(D_METHOD("save_support_data", "filename"), &TextServer::save_support_data);
+
ClassDB::bind_method(D_METHOD("is_locale_right_to_left", "locale"), &TextServer::is_locale_right_to_left);
ClassDB::bind_method(D_METHOD("name_to_tag", "name"), &TextServer::name_to_tag);
@@ -219,7 +210,7 @@ void TextServer::_bind_methods() {
ClassDB::bind_method(D_METHOD("create_font"), &TextServer::create_font);
- ClassDB::bind_method(D_METHOD("font_set_data", "data"), &TextServer::font_set_data);
+ ClassDB::bind_method(D_METHOD("font_set_data", "font_rid", "data"), &TextServer::font_set_data);
ClassDB::bind_method(D_METHOD("font_set_antialiased", "font_rid", "antialiased"), &TextServer::font_set_antialiased);
ClassDB::bind_method(D_METHOD("font_is_antialiased", "font_rid"), &TextServer::font_is_antialiased);
@@ -299,7 +290,7 @@ void TextServer::_bind_methods() {
ClassDB::bind_method(D_METHOD("font_get_glyph_texture_idx", "font_rid", "size", "glyph"), &TextServer::font_get_glyph_texture_idx);
ClassDB::bind_method(D_METHOD("font_set_glyph_texture_idx", "font_rid", "size", "glyph", "texture_idx"), &TextServer::font_set_glyph_texture_idx);
- ClassDB::bind_method(D_METHOD("font_get_glyph_contours", "font", "size", "index"), &TextServer::_font_get_glyph_contours);
+ ClassDB::bind_method(D_METHOD("font_get_glyph_contours", "font", "size", "index"), &TextServer::font_get_glyph_contours);
ClassDB::bind_method(D_METHOD("font_get_kerning_list", "font_rid", "size"), &TextServer::font_get_kerning_list);
ClassDB::bind_method(D_METHOD("font_clear_kerning_map", "font_rid", "size"), &TextServer::font_clear_kerning_map);
@@ -349,7 +340,7 @@ void TextServer::_bind_methods() {
ClassDB::bind_method(D_METHOD("shaped_text_set_direction", "shaped", "direction"), &TextServer::shaped_text_set_direction, DEFVAL(DIRECTION_AUTO));
ClassDB::bind_method(D_METHOD("shaped_text_get_direction", "shaped"), &TextServer::shaped_text_get_direction);
- ClassDB::bind_method(D_METHOD("shaped_text_set_bidi_override", "shaped", "override"), &TextServer::_shaped_text_set_bidi_override);
+ ClassDB::bind_method(D_METHOD("shaped_text_set_bidi_override", "shaped", "override"), &TextServer::shaped_text_set_bidi_override);
ClassDB::bind_method(D_METHOD("shaped_text_set_orientation", "shaped", "orientation"), &TextServer::shaped_text_set_orientation, DEFVAL(ORIENTATION_HORIZONTAL));
ClassDB::bind_method(D_METHOD("shaped_text_get_orientation", "shaped"), &TextServer::shaped_text_get_orientation);
@@ -372,12 +363,19 @@ void TextServer::_bind_methods() {
ClassDB::bind_method(D_METHOD("shaped_text_shape", "shaped"), &TextServer::shaped_text_shape);
ClassDB::bind_method(D_METHOD("shaped_text_is_ready", "shaped"), &TextServer::shaped_text_is_ready);
- ClassDB::bind_method(D_METHOD("shaped_text_get_glyphs", "shaped"), &TextServer::_shaped_text_get_glyphs);
+ ClassDB::bind_method(D_METHOD("shaped_text_get_glyphs", "shaped"), &TextServer::_shaped_text_get_glyphs_wrapper);
+ ClassDB::bind_method(D_METHOD("shaped_text_sort_logical", "shaped"), &TextServer::_shaped_text_sort_logical_wrapper);
+ ClassDB::bind_method(D_METHOD("shaped_text_get_glyph_count", "shaped"), &TextServer::shaped_text_get_glyph_count);
ClassDB::bind_method(D_METHOD("shaped_text_get_range", "shaped"), &TextServer::shaped_text_get_range);
- ClassDB::bind_method(D_METHOD("shaped_text_get_line_breaks_adv", "shaped", "width", "start", "once", "break_flags"), &TextServer::_shaped_text_get_line_breaks_adv, DEFVAL(0), DEFVAL(true), DEFVAL(BREAK_MANDATORY | BREAK_WORD_BOUND));
- ClassDB::bind_method(D_METHOD("shaped_text_get_line_breaks", "shaped", "width", "start", "break_flags"), &TextServer::_shaped_text_get_line_breaks, DEFVAL(0), DEFVAL(BREAK_MANDATORY | BREAK_WORD_BOUND));
- ClassDB::bind_method(D_METHOD("shaped_text_get_word_breaks", "shaped"), &TextServer::_shaped_text_get_word_breaks);
+ ClassDB::bind_method(D_METHOD("shaped_text_get_line_breaks_adv", "shaped", "width", "start", "once", "break_flags"), &TextServer::shaped_text_get_line_breaks_adv, DEFVAL(0), DEFVAL(true), DEFVAL(BREAK_MANDATORY | BREAK_WORD_BOUND));
+ ClassDB::bind_method(D_METHOD("shaped_text_get_line_breaks", "shaped", "width", "start", "break_flags"), &TextServer::shaped_text_get_line_breaks, DEFVAL(0), DEFVAL(BREAK_MANDATORY | BREAK_WORD_BOUND));
+ ClassDB::bind_method(D_METHOD("shaped_text_get_word_breaks", "shaped", "grapheme_flags"), &TextServer::shaped_text_get_word_breaks);
+
+ ClassDB::bind_method(D_METHOD("shaped_text_get_trim_pos", "shaped"), &TextServer::shaped_text_get_trim_pos);
+ ClassDB::bind_method(D_METHOD("shaped_text_get_ellipsis_pos", "shaped"), &TextServer::shaped_text_get_ellipsis_pos);
+ ClassDB::bind_method(D_METHOD("shaped_text_get_ellipsis_glyphs", "shaped"), &TextServer::_shaped_text_get_ellipsis_glyphs_wrapper);
+ ClassDB::bind_method(D_METHOD("shaped_text_get_ellipsis_glyph_count", "shaped"), &TextServer::shaped_text_get_ellipsis_glyph_count);
ClassDB::bind_method(D_METHOD("shaped_text_overrun_trim_to_width", "shaped", "width", "overrun_trim_flags"), &TextServer::shaped_text_overrun_trim_to_width, DEFVAL(0), DEFVAL(OVERRUN_NO_TRIMMING));
@@ -391,8 +389,8 @@ void TextServer::_bind_methods() {
ClassDB::bind_method(D_METHOD("shaped_text_get_underline_position", "shaped"), &TextServer::shaped_text_get_underline_position);
ClassDB::bind_method(D_METHOD("shaped_text_get_underline_thickness", "shaped"), &TextServer::shaped_text_get_underline_thickness);
- ClassDB::bind_method(D_METHOD("shaped_text_get_carets", "shaped", "position"), &TextServer::_shaped_text_get_carets);
- ClassDB::bind_method(D_METHOD("shaped_text_get_selection", "shaped", "start", "end"), &TextServer::_shaped_text_get_selection);
+ ClassDB::bind_method(D_METHOD("shaped_text_get_carets", "shaped", "position"), &TextServer::_shaped_text_get_carets_wrapper);
+ ClassDB::bind_method(D_METHOD("shaped_text_get_selection", "shaped", "start", "end"), &TextServer::shaped_text_get_selection);
ClassDB::bind_method(D_METHOD("shaped_text_hit_test_grapheme", "shaped", "coords"), &TextServer::shaped_text_hit_test_grapheme);
ClassDB::bind_method(D_METHOD("shaped_text_hit_test_position", "shaped", "coords"), &TextServer::shaped_text_hit_test_position);
@@ -403,7 +401,7 @@ void TextServer::_bind_methods() {
ClassDB::bind_method(D_METHOD("shaped_text_draw", "shaped", "canvas", "pos", "clip_l", "clip_r", "color"), &TextServer::shaped_text_draw, DEFVAL(-1), DEFVAL(-1), DEFVAL(Color(1, 1, 1)));
ClassDB::bind_method(D_METHOD("shaped_text_draw_outline", "shaped", "canvas", "pos", "clip_l", "clip_r", "outline_size", "color"), &TextServer::shaped_text_draw_outline, DEFVAL(-1), DEFVAL(-1), DEFVAL(1), DEFVAL(Color(1, 1, 1)));
- ClassDB::bind_method(D_METHOD("shaped_text_get_dominant_direciton_in_range", "shaped", "start", "end"), &TextServer::shaped_text_get_dominant_direciton_in_range);
+ ClassDB::bind_method(D_METHOD("shaped_text_get_dominant_direction_in_range", "shaped", "start", "end"), &TextServer::shaped_text_get_dominant_direction_in_range);
ClassDB::bind_method(D_METHOD("format_number", "number", "language"), &TextServer::format_number, DEFVAL(""));
ClassDB::bind_method(D_METHOD("parse_number", "number", "language"), &TextServer::parse_number, DEFVAL(""));
@@ -424,12 +422,14 @@ void TextServer::_bind_methods() {
BIND_ENUM_CONSTANT(JUSTIFICATION_WORD_BOUND);
BIND_ENUM_CONSTANT(JUSTIFICATION_TRIM_EDGE_SPACES);
BIND_ENUM_CONSTANT(JUSTIFICATION_AFTER_LAST_TAB);
+ BIND_ENUM_CONSTANT(JUSTIFICATION_CONSTRAIN_ELLIPSIS);
/* LineBreakFlag */
BIND_ENUM_CONSTANT(BREAK_NONE);
BIND_ENUM_CONSTANT(BREAK_MANDATORY);
BIND_ENUM_CONSTANT(BREAK_WORD_BOUND);
BIND_ENUM_CONSTANT(BREAK_GRAPHEME_BOUND);
+ BIND_ENUM_CONSTANT(BREAK_WORD_BOUND_ADAPTIVE);
/* TextOverrunFlag */
BIND_ENUM_CONSTANT(OVERRUN_NO_TRIMMING);
@@ -437,8 +437,10 @@ void TextServer::_bind_methods() {
BIND_ENUM_CONSTANT(OVERRUN_TRIM_WORD_ONLY);
BIND_ENUM_CONSTANT(OVERRUN_ADD_ELLIPSIS);
BIND_ENUM_CONSTANT(OVERRUN_ENFORCE_ELLIPSIS);
+ BIND_ENUM_CONSTANT(OVERRUN_JUSTIFICATION_AWARE);
/* GraphemeFlag */
+ BIND_ENUM_CONSTANT(GRAPHEME_IS_VALID);
BIND_ENUM_CONSTANT(GRAPHEME_IS_RTL);
BIND_ENUM_CONSTANT(GRAPHEME_IS_VIRTUAL);
BIND_ENUM_CONSTANT(GRAPHEME_IS_SPACE);
@@ -578,6 +580,9 @@ void TextServer::draw_hex_code_box(RID p_canvas, int p_size, const Vector2 &p_po
int fnt = (p_size < 20) ? 0 : 1;
ERR_FAIL_COND(hex_code_box_font_tex[fnt].is_null());
+ if (p_index == 0) {
+ return;
+ }
uint8_t a = p_index & 0x0F;
uint8_t b = (p_index >> 4) & 0x0F;
@@ -592,12 +597,12 @@ void TextServer::draw_hex_code_box(RID p_canvas, int p_size, const Vector2 &p_po
real_t w = ((p_index <= 0xFF) ? 1 : ((p_index <= 0xFFFF) ? 2 : 3)) * hex_code_box_font_size[fnt].x;
real_t h = 2 * hex_code_box_font_size[fnt].y;
- pos.y -= Math::floor((h + 3 + hex_code_box_font_size[fnt].z) * 0.75);
+ pos.y -= Math::floor((h + 3 + hex_code_box_font_size[fnt].z));
RenderingServer::get_singleton()->canvas_item_add_rect(p_canvas, Rect2(pos + Point2(0, 0), Size2(1, h + 2 + 2 * hex_code_box_font_size[fnt].z)), p_color);
RenderingServer::get_singleton()->canvas_item_add_rect(p_canvas, Rect2(pos + Point2(w + 2, 0), Size2(1, h + 2 + 2 * hex_code_box_font_size[fnt].z)), p_color);
- RenderingServer::get_singleton()->canvas_item_add_rect(p_canvas, Rect2(pos + Point2(0, 0), Size2(w + 2, 1)), p_color);
- RenderingServer::get_singleton()->canvas_item_add_rect(p_canvas, Rect2(pos + Point2(0, h + 2 + 2 * hex_code_box_font_size[fnt].z), Size2(w + 2, 1)), p_color);
+ RenderingServer::get_singleton()->canvas_item_add_rect(p_canvas, Rect2(pos + Point2(0, 0), Size2(w + 3, 1)), p_color);
+ RenderingServer::get_singleton()->canvas_item_add_rect(p_canvas, Rect2(pos + Point2(0, h + 2 + 2 * hex_code_box_font_size[fnt].z), Size2(w + 3, 1)), p_color);
pos += Point2(2, 2);
if (p_index <= 0xFF) {
@@ -630,13 +635,12 @@ void TextServer::draw_hex_code_box(RID p_canvas, int p_size, const Vector2 &p_po
}
}
-Vector<Vector2i> TextServer::shaped_text_get_line_breaks_adv(RID p_shaped, const Vector<real_t> &p_width, int p_start, bool p_once, uint8_t /*TextBreakFlag*/ p_break_flags) const {
- Vector<Vector2i> lines;
+PackedInt32Array TextServer::shaped_text_get_line_breaks_adv(RID p_shaped, const PackedFloat32Array &p_width, int p_start, bool p_once, uint16_t /*TextBreakFlag*/ p_break_flags) const {
+ PackedInt32Array lines;
ERR_FAIL_COND_V(p_width.is_empty(), lines);
const_cast<TextServer *>(this)->shaped_text_update_breaks(p_shaped);
- const Vector<Glyph> &logical = const_cast<TextServer *>(this)->shaped_text_sort_logical(p_shaped);
const Vector2i &range = shaped_text_get_range(p_shaped);
real_t width = 0.f;
@@ -644,8 +648,8 @@ Vector<Vector2i> TextServer::shaped_text_get_line_breaks_adv(RID p_shaped, const
int last_safe_break = -1;
int chunk = 0;
- int l_size = logical.size();
- const Glyph *l_gl = logical.ptr();
+ int l_size = shaped_text_get_glyph_count(p_shaped);
+ const Glyph *l_gl = const_cast<TextServer *>(this)->shaped_text_sort_logical(p_shaped);
for (int i = 0; i < l_size; i++) {
if (l_gl[i].start < p_start) {
@@ -653,7 +657,8 @@ Vector<Vector2i> TextServer::shaped_text_get_line_breaks_adv(RID p_shaped, const
}
if (l_gl[i].count > 0) {
if ((p_width[chunk] > 0) && (width + l_gl[i].advance > p_width[chunk]) && (last_safe_break >= 0)) {
- lines.push_back(Vector2i(line_start, l_gl[last_safe_break].end));
+ lines.push_back(line_start);
+ lines.push_back(l_gl[last_safe_break].end);
line_start = l_gl[last_safe_break].end;
i = last_safe_break;
last_safe_break = -1;
@@ -669,7 +674,8 @@ Vector<Vector2i> TextServer::shaped_text_get_line_breaks_adv(RID p_shaped, const
}
if ((p_break_flags & BREAK_MANDATORY) == BREAK_MANDATORY) {
if ((l_gl[i].flags & GRAPHEME_IS_BREAK_HARD) == GRAPHEME_IS_BREAK_HARD) {
- lines.push_back(Vector2i(line_start, l_gl[i].end));
+ lines.push_back(line_start);
+ lines.push_back(l_gl[i].end);
line_start = l_gl[i].end;
last_safe_break = -1;
width = 0;
@@ -693,27 +699,31 @@ Vector<Vector2i> TextServer::shaped_text_get_line_breaks_adv(RID p_shaped, const
}
if (l_size > 0) {
- lines.push_back(Vector2i(line_start, range.y));
+ if (lines.size() == 0 || lines[lines.size() - 1] < range.y) {
+ lines.push_back(line_start);
+ lines.push_back(range.y);
+ }
} else {
- lines.push_back(Vector2i(0, 0));
+ lines.push_back(0);
+ lines.push_back(0);
}
return lines;
}
-Vector<Vector2i> TextServer::shaped_text_get_line_breaks(RID p_shaped, real_t p_width, int p_start, uint8_t /*TextBreakFlag*/ p_break_flags) const {
- Vector<Vector2i> lines;
+PackedInt32Array TextServer::shaped_text_get_line_breaks(RID p_shaped, real_t p_width, int p_start, uint16_t /*TextBreakFlag*/ p_break_flags) const {
+ PackedInt32Array lines;
const_cast<TextServer *>(this)->shaped_text_update_breaks(p_shaped);
- const Vector<Glyph> &logical = const_cast<TextServer *>(this)->shaped_text_sort_logical(p_shaped);
const Vector2i &range = shaped_text_get_range(p_shaped);
real_t width = 0.f;
int line_start = MAX(p_start, range.x);
int last_safe_break = -1;
int word_count = 0;
- int l_size = logical.size();
- const Glyph *l_gl = logical.ptr();
+
+ int l_size = shaped_text_get_glyph_count(p_shaped);
+ const Glyph *l_gl = const_cast<TextServer *>(this)->shaped_text_sort_logical(p_shaped);
for (int i = 0; i < l_size; i++) {
if (l_gl[i].start < p_start) {
@@ -721,7 +731,8 @@ Vector<Vector2i> TextServer::shaped_text_get_line_breaks(RID p_shaped, real_t p_
}
if (l_gl[i].count > 0) {
if ((p_width > 0) && (width + l_gl[i].advance * l_gl[i].repeat > p_width) && (last_safe_break >= 0)) {
- lines.push_back(Vector2i(line_start, l_gl[last_safe_break].end));
+ lines.push_back(line_start);
+ lines.push_back(l_gl[last_safe_break].end);
line_start = l_gl[last_safe_break].end;
i = last_safe_break;
last_safe_break = -1;
@@ -731,7 +742,8 @@ Vector<Vector2i> TextServer::shaped_text_get_line_breaks(RID p_shaped, real_t p_
}
if ((p_break_flags & BREAK_MANDATORY) == BREAK_MANDATORY) {
if ((l_gl[i].flags & GRAPHEME_IS_BREAK_HARD) == GRAPHEME_IS_BREAK_HARD) {
- lines.push_back(Vector2i(line_start, l_gl[i].end));
+ lines.push_back(line_start);
+ lines.push_back(l_gl[i].end);
line_start = l_gl[i].end;
last_safe_break = -1;
width = 0;
@@ -755,51 +767,49 @@ Vector<Vector2i> TextServer::shaped_text_get_line_breaks(RID p_shaped, real_t p_
}
if (l_size > 0) {
- if (lines.size() == 0 || lines[lines.size() - 1].y < range.y) {
- lines.push_back(Vector2i(line_start, range.y));
+ if (lines.size() == 0 || lines[lines.size() - 1] < range.y) {
+ lines.push_back(line_start);
+ lines.push_back(range.y);
}
} else {
- lines.push_back(Vector2i(0, 0));
+ lines.push_back(0);
+ lines.push_back(0);
}
return lines;
}
-Vector<Vector2i> TextServer::shaped_text_get_word_breaks(RID p_shaped, int p_grapheme_flags) const {
- Vector<Vector2i> words;
+PackedInt32Array TextServer::shaped_text_get_word_breaks(RID p_shaped, int p_grapheme_flags) const {
+ PackedInt32Array words;
const_cast<TextServer *>(this)->shaped_text_update_justification_ops(p_shaped);
- const Vector<Glyph> &logical = const_cast<TextServer *>(this)->shaped_text_sort_logical(p_shaped);
const Vector2i &range = shaped_text_get_range(p_shaped);
int word_start = range.x;
- int l_size = logical.size();
- const Glyph *l_gl = logical.ptr();
+ int l_size = shaped_text_get_glyph_count(p_shaped);
+ const Glyph *l_gl = const_cast<TextServer *>(this)->shaped_text_sort_logical(p_shaped);
for (int i = 0; i < l_size; i++) {
if (l_gl[i].count > 0) {
if ((l_gl[i].flags & p_grapheme_flags) != 0) {
- words.push_back(Vector2i(word_start, l_gl[i].start));
+ words.push_back(word_start);
+ words.push_back(l_gl[i].start);
word_start = l_gl[i].end;
}
}
}
if (l_size > 0) {
- words.push_back(Vector2i(word_start, range.y));
+ words.push_back(word_start);
+ words.push_back(range.y);
}
return words;
}
-TextServer::TrimData TextServer::shaped_text_get_trim_data(RID p_shaped) const {
- WARN_PRINT("Getting overrun data not supported by this TextServer.");
- return TrimData();
-}
-
-void TextServer::shaped_text_get_carets(RID p_shaped, int p_position, Rect2 &p_leading_caret, Direction &p_leading_dir, Rect2 &p_trailing_caret, Direction &p_trailing_dir) const {
+CaretInfo TextServer::shaped_text_get_carets(RID p_shaped, int p_position) const {
Vector<Rect2> carets;
- const Vector<TextServer::Glyph> visual = shaped_text_get_glyphs(p_shaped);
+
TextServer::Orientation orientation = shaped_text_get_orientation(p_shaped);
const Vector2 &range = shaped_text_get_range(p_shaped);
real_t ascent = shaped_text_get_ascent(p_shaped);
@@ -807,11 +817,12 @@ void TextServer::shaped_text_get_carets(RID p_shaped, int p_position, Rect2 &p_l
real_t height = (ascent + descent) / 2;
real_t off = 0.0f;
- p_leading_dir = DIRECTION_AUTO;
- p_trailing_dir = DIRECTION_AUTO;
+ CaretInfo caret;
+ caret.l_dir = DIRECTION_AUTO;
+ caret.t_dir = DIRECTION_AUTO;
- int v_size = visual.size();
- const Glyph *glyphs = visual.ptr();
+ int v_size = shaped_text_get_glyph_count(p_shaped);
+ const Glyph *glyphs = shaped_text_get_glyphs(p_shaped);
for (int i = 0; i < v_size; i++) {
if (glyphs[i].count > 0) {
@@ -827,13 +838,13 @@ void TextServer::shaped_text_get_carets(RID p_shaped, int p_position, Rect2 &p_l
cr.position.y = -ascent;
cr.position.x = off;
if ((glyphs[i].flags & GRAPHEME_IS_RTL) == GRAPHEME_IS_RTL) {
- p_trailing_dir = DIRECTION_RTL;
+ caret.t_dir = DIRECTION_RTL;
for (int j = 0; j < glyphs[i].count; j++) {
cr.position.x += glyphs[i + j].advance * glyphs[i + j].repeat;
cr.size.x -= glyphs[i + j].advance * glyphs[i + j].repeat;
}
} else {
- p_trailing_dir = DIRECTION_LTR;
+ caret.t_dir = DIRECTION_LTR;
for (int j = 0; j < glyphs[i].count; j++) {
cr.size.x += glyphs[i + j].advance * glyphs[i + j].repeat;
}
@@ -847,19 +858,19 @@ void TextServer::shaped_text_get_carets(RID p_shaped, int p_position, Rect2 &p_l
cr.position.x = -ascent;
cr.position.y = off;
if ((glyphs[i].flags & GRAPHEME_IS_RTL) == GRAPHEME_IS_RTL) {
- p_trailing_dir = DIRECTION_RTL;
+ caret.t_dir = DIRECTION_RTL;
for (int j = 0; j < glyphs[i].count; j++) {
cr.position.y += glyphs[i + j].advance * glyphs[i + j].repeat;
cr.size.y -= glyphs[i + j].advance * glyphs[i + j].repeat;
}
} else {
- p_trailing_dir = DIRECTION_LTR;
+ caret.t_dir = DIRECTION_LTR;
for (int j = 0; j < glyphs[i].count; j++) {
cr.size.y += glyphs[i + j].advance * glyphs[i + j].repeat;
}
}
}
- p_trailing_caret = cr;
+ caret.t_caret = cr;
}
// Caret after grapheme (bottom / right).
if (p_position == glyphs[i].end && ((glyphs[i].flags & GRAPHEME_IS_VIRTUAL) != GRAPHEME_IS_VIRTUAL)) {
@@ -874,13 +885,13 @@ void TextServer::shaped_text_get_carets(RID p_shaped, int p_position, Rect2 &p_l
}
cr.position.x = off;
if ((glyphs[i].flags & GRAPHEME_IS_RTL) != GRAPHEME_IS_RTL) {
- p_leading_dir = DIRECTION_LTR;
+ caret.l_dir = DIRECTION_LTR;
for (int j = 0; j < glyphs[i].count; j++) {
cr.position.x += glyphs[i + j].advance * glyphs[i + j].repeat;
cr.size.x -= glyphs[i + j].advance * glyphs[i + j].repeat;
}
} else {
- p_leading_dir = DIRECTION_RTL;
+ caret.l_dir = DIRECTION_RTL;
for (int j = 0; j < glyphs[i].count; j++) {
cr.size.x += glyphs[i + j].advance * glyphs[i + j].repeat;
}
@@ -896,19 +907,19 @@ void TextServer::shaped_text_get_carets(RID p_shaped, int p_position, Rect2 &p_l
}
cr.position.y = off;
if ((glyphs[i].flags & GRAPHEME_IS_RTL) != GRAPHEME_IS_RTL) {
- p_leading_dir = DIRECTION_LTR;
+ caret.l_dir = DIRECTION_LTR;
for (int j = 0; j < glyphs[i].count; j++) {
cr.position.y += glyphs[i + j].advance * glyphs[i + j].repeat;
cr.size.y -= glyphs[i + j].advance * glyphs[i + j].repeat;
}
} else {
- p_leading_dir = DIRECTION_RTL;
+ caret.l_dir = DIRECTION_RTL;
for (int j = 0; j < glyphs[i].count; j++) {
cr.size.y += glyphs[i + j].advance * glyphs[i + j].repeat;
}
}
}
- p_leading_caret = cr;
+ caret.l_caret = cr;
}
// Caret inside grapheme (middle).
if (p_position > glyphs[i].start && p_position < glyphs[i].end && (glyphs[i].flags & GRAPHEME_IS_VIRTUAL) != GRAPHEME_IS_VIRTUAL) {
@@ -937,17 +948,29 @@ void TextServer::shaped_text_get_carets(RID p_shaped, int p_position, Rect2 &p_l
cr.position.y = off + char_adv * (p_position - glyphs[i].start);
}
}
- p_trailing_caret = cr;
- p_leading_caret = cr;
+ caret.t_caret = cr;
+ caret.l_caret = cr;
}
}
off += glyphs[i].advance * glyphs[i].repeat;
}
+ return caret;
}
-TextServer::Direction TextServer::shaped_text_get_dominant_direciton_in_range(RID p_shaped, int p_start, int p_end) const {
- const Vector<TextServer::Glyph> visual = shaped_text_get_glyphs(p_shaped);
+Dictionary TextServer::_shaped_text_get_carets_wrapper(RID p_shaped, int p_position) const {
+ Dictionary ret;
+
+ CaretInfo caret = shaped_text_get_carets(p_shaped, p_position);
+
+ ret["leading_rect"] = caret.l_caret;
+ ret["leading_direction"] = caret.l_dir;
+ ret["trailing_rect"] = caret.t_caret;
+ ret["trailing_direction"] = caret.t_dir;
+
+ return ret;
+}
+TextServer::Direction TextServer::shaped_text_get_dominant_direction_in_range(RID p_shaped, int p_start, int p_end) const {
if (p_start == p_end) {
return DIRECTION_AUTO;
}
@@ -958,8 +981,8 @@ TextServer::Direction TextServer::shaped_text_get_dominant_direciton_in_range(RI
int rtl = 0;
int ltr = 0;
- int v_size = visual.size();
- const Glyph *glyphs = visual.ptr();
+ int v_size = shaped_text_get_glyph_count(p_shaped);
+ const Glyph *glyphs = shaped_text_get_glyphs(p_shaped);
for (int i = 0; i < v_size; i++) {
if ((glyphs[i].end > start) && (glyphs[i].start < end)) {
@@ -983,7 +1006,6 @@ TextServer::Direction TextServer::shaped_text_get_dominant_direciton_in_range(RI
Vector<Vector2> TextServer::shaped_text_get_selection(RID p_shaped, int p_start, int p_end) const {
Vector<Vector2> ranges;
- const Vector<TextServer::Glyph> visual = shaped_text_get_glyphs(p_shaped);
if (p_start == p_end) {
return ranges;
@@ -992,8 +1014,8 @@ Vector<Vector2> TextServer::shaped_text_get_selection(RID p_shaped, int p_start,
int start = MIN(p_start, p_end);
int end = MAX(p_start, p_end);
- int v_size = visual.size();
- const Glyph *glyphs = visual.ptr();
+ int v_size = shaped_text_get_glyph_count(p_shaped);
+ const Glyph *glyphs = shaped_text_get_glyphs(p_shaped);
real_t off = 0.0f;
for (int i = 0; i < v_size; i++) {
@@ -1076,13 +1098,11 @@ Vector<Vector2> TextServer::shaped_text_get_selection(RID p_shaped, int p_start,
}
int TextServer::shaped_text_hit_test_grapheme(RID p_shaped, real_t p_coords) const {
- const Vector<TextServer::Glyph> visual = shaped_text_get_glyphs(p_shaped);
-
// Exact grapheme hit test, return -1 if missed.
real_t off = 0.0f;
- int v_size = visual.size();
- const Glyph *glyphs = visual.ptr();
+ int v_size = shaped_text_get_glyph_count(p_shaped);
+ const Glyph *glyphs = shaped_text_get_glyphs(p_shaped);
for (int i = 0; i < v_size; i++) {
for (int j = 0; j < glyphs[i].repeat; j++) {
@@ -1096,10 +1116,8 @@ int TextServer::shaped_text_hit_test_grapheme(RID p_shaped, real_t p_coords) con
}
int TextServer::shaped_text_hit_test_position(RID p_shaped, real_t p_coords) const {
- const Vector<TextServer::Glyph> visual = shaped_text_get_glyphs(p_shaped);
-
- int v_size = visual.size();
- const Glyph *glyphs = visual.ptr();
+ int v_size = shaped_text_get_glyph_count(p_shaped);
+ const Glyph *glyphs = shaped_text_get_glyphs(p_shaped);
// Cursor placement hit test.
@@ -1165,10 +1183,9 @@ int TextServer::shaped_text_hit_test_position(RID p_shaped, real_t p_coords) con
return 0;
}
-int TextServer::shaped_text_next_grapheme_pos(RID p_shaped, int p_pos) {
- const Vector<TextServer::Glyph> visual = shaped_text_get_glyphs(p_shaped);
- int v_size = visual.size();
- const Glyph *glyphs = visual.ptr();
+int TextServer::shaped_text_next_grapheme_pos(RID p_shaped, int p_pos) const {
+ int v_size = shaped_text_get_glyph_count(p_shaped);
+ const Glyph *glyphs = shaped_text_get_glyphs(p_shaped);
for (int i = 0; i < v_size; i++) {
if (p_pos >= glyphs[i].start && p_pos < glyphs[i].end) {
return glyphs[i].end;
@@ -1177,10 +1194,9 @@ int TextServer::shaped_text_next_grapheme_pos(RID p_shaped, int p_pos) {
return p_pos;
}
-int TextServer::shaped_text_prev_grapheme_pos(RID p_shaped, int p_pos) {
- const Vector<TextServer::Glyph> visual = shaped_text_get_glyphs(p_shaped);
- int v_size = visual.size();
- const Glyph *glyphs = visual.ptr();
+int TextServer::shaped_text_prev_grapheme_pos(RID p_shaped, int p_pos) const {
+ int v_size = shaped_text_get_glyph_count(p_shaped);
+ const Glyph *glyphs = shaped_text_get_glyphs(p_shaped);
for (int i = 0; i < v_size; i++) {
if (p_pos > glyphs[i].start && p_pos <= glyphs[i].end) {
return glyphs[i].start;
@@ -1191,26 +1207,30 @@ int TextServer::shaped_text_prev_grapheme_pos(RID p_shaped, int p_pos) {
}
void TextServer::shaped_text_draw(RID p_shaped, RID p_canvas, const Vector2 &p_pos, real_t p_clip_l, real_t p_clip_r, const Color &p_color) const {
- const Vector<TextServer::Glyph> visual = shaped_text_get_glyphs(p_shaped);
TextServer::Orientation orientation = shaped_text_get_orientation(p_shaped);
bool hex_codes = shaped_text_get_preserve_control(p_shaped) || shaped_text_get_preserve_invalid(p_shaped);
bool rtl = shaped_text_get_direction(p_shaped) == DIRECTION_RTL;
- TrimData trim_data = shaped_text_get_trim_data(p_shaped);
- int v_size = visual.size();
- const Glyph *glyphs = visual.ptr();
+ int ellipsis_pos = shaped_text_get_ellipsis_pos(p_shaped);
+ int trim_pos = shaped_text_get_trim_pos(p_shaped);
+
+ const Glyph *ellipsis_glyphs = shaped_text_get_ellipsis_glyphs(p_shaped);
+ int ellipsis_gl_size = shaped_text_get_ellipsis_glyph_count(p_shaped);
+
+ int v_size = shaped_text_get_glyph_count(p_shaped);
+ const Glyph *glyphs = shaped_text_get_glyphs(p_shaped);
Vector2 ofs = p_pos;
// Draw RTL ellipsis string when needed.
- if (rtl && trim_data.ellipsis_pos >= 0) {
- for (int i = trim_data.ellipsis_glyph_buf.size() - 1; i >= 0; i--) {
- for (int j = 0; j < trim_data.ellipsis_glyph_buf[i].repeat; j++) {
- font_draw_glyph(trim_data.ellipsis_glyph_buf[i].font_rid, p_canvas, trim_data.ellipsis_glyph_buf[i].font_size, ofs + Vector2(trim_data.ellipsis_glyph_buf[i].x_off, trim_data.ellipsis_glyph_buf[i].y_off), trim_data.ellipsis_glyph_buf[i].index, p_color);
+ if (rtl && ellipsis_pos >= 0) {
+ for (int i = ellipsis_gl_size - 1; i >= 0; i--) {
+ for (int j = 0; j < ellipsis_glyphs[i].repeat; j++) {
+ font_draw_glyph(ellipsis_glyphs[i].font_rid, p_canvas, ellipsis_glyphs[i].font_size, ofs + Vector2(ellipsis_glyphs[i].x_off, ellipsis_glyphs[i].y_off), ellipsis_glyphs[i].index, p_color);
if (orientation == ORIENTATION_HORIZONTAL) {
- ofs.x += trim_data.ellipsis_glyph_buf[i].advance;
+ ofs.x += ellipsis_glyphs[i].advance;
} else {
- ofs.y += trim_data.ellipsis_glyph_buf[i].advance;
+ ofs.y += ellipsis_glyphs[i].advance;
}
}
}
@@ -1244,13 +1264,13 @@ void TextServer::shaped_text_draw(RID p_shaped, RID p_canvas, const Vector2 &p_p
}
}
}
- if (trim_data.trim_pos >= 0) {
+ if (trim_pos >= 0) {
if (rtl) {
- if (i < trim_data.trim_pos && (glyphs[j].flags & TextServer::GRAPHEME_IS_VIRTUAL) != TextServer::GRAPHEME_IS_VIRTUAL) {
+ if (i < trim_pos && (glyphs[j].flags & TextServer::GRAPHEME_IS_VIRTUAL) != TextServer::GRAPHEME_IS_VIRTUAL) {
continue;
}
} else {
- if (i >= trim_data.trim_pos && (glyphs[j].flags & TextServer::GRAPHEME_IS_VIRTUAL) != TextServer::GRAPHEME_IS_VIRTUAL) {
+ if (i >= trim_pos && (glyphs[j].flags & TextServer::GRAPHEME_IS_VIRTUAL) != TextServer::GRAPHEME_IS_VIRTUAL) {
break;
}
}
@@ -1269,14 +1289,14 @@ void TextServer::shaped_text_draw(RID p_shaped, RID p_canvas, const Vector2 &p_p
}
}
// Draw LTR ellipsis string when needed.
- if (!rtl && trim_data.ellipsis_pos >= 0) {
- for (int i = 0; i < trim_data.ellipsis_glyph_buf.size(); i++) {
- for (int j = 0; j < trim_data.ellipsis_glyph_buf[i].repeat; j++) {
- font_draw_glyph(trim_data.ellipsis_glyph_buf[i].font_rid, p_canvas, trim_data.ellipsis_glyph_buf[i].font_size, ofs + Vector2(trim_data.ellipsis_glyph_buf[i].x_off, trim_data.ellipsis_glyph_buf[i].y_off), trim_data.ellipsis_glyph_buf[i].index, p_color);
+ if (!rtl && ellipsis_pos >= 0) {
+ for (int i = 0; i < ellipsis_gl_size; i++) {
+ for (int j = 0; j < ellipsis_glyphs[i].repeat; j++) {
+ font_draw_glyph(ellipsis_glyphs[i].font_rid, p_canvas, ellipsis_glyphs[i].font_size, ofs + Vector2(ellipsis_glyphs[i].x_off, ellipsis_glyphs[i].y_off), ellipsis_glyphs[i].index, p_color);
if (orientation == ORIENTATION_HORIZONTAL) {
- ofs.x += trim_data.ellipsis_glyph_buf[i].advance;
+ ofs.x += ellipsis_glyphs[i].advance;
} else {
- ofs.y += trim_data.ellipsis_glyph_buf[i].advance;
+ ofs.y += ellipsis_glyphs[i].advance;
}
}
}
@@ -1284,24 +1304,28 @@ void TextServer::shaped_text_draw(RID p_shaped, RID p_canvas, const Vector2 &p_p
}
void TextServer::shaped_text_draw_outline(RID p_shaped, RID p_canvas, const Vector2 &p_pos, real_t p_clip_l, real_t p_clip_r, int p_outline_size, const Color &p_color) const {
- const Vector<TextServer::Glyph> visual = shaped_text_get_glyphs(p_shaped);
TextServer::Orientation orientation = shaped_text_get_orientation(p_shaped);
bool rtl = (shaped_text_get_direction(p_shaped) == DIRECTION_RTL);
- TrimData trim_data = shaped_text_get_trim_data(p_shaped);
- int v_size = visual.size();
- const Glyph *glyphs = visual.ptr();
+ int ellipsis_pos = shaped_text_get_ellipsis_pos(p_shaped);
+ int trim_pos = shaped_text_get_trim_pos(p_shaped);
+
+ const Glyph *ellipsis_glyphs = shaped_text_get_ellipsis_glyphs(p_shaped);
+ int ellipsis_gl_size = shaped_text_get_ellipsis_glyph_count(p_shaped);
+
+ int v_size = shaped_text_get_glyph_count(p_shaped);
+ const Glyph *glyphs = shaped_text_get_glyphs(p_shaped);
Vector2 ofs = p_pos;
// Draw RTL ellipsis string when needed.
- if (rtl && trim_data.ellipsis_pos >= 0) {
- for (int i = trim_data.ellipsis_glyph_buf.size() - 1; i >= 0; i--) {
- for (int j = 0; j < trim_data.ellipsis_glyph_buf[i].repeat; j++) {
- font_draw_glyph(trim_data.ellipsis_glyph_buf[i].font_rid, p_canvas, trim_data.ellipsis_glyph_buf[i].font_size, ofs + Vector2(trim_data.ellipsis_glyph_buf[i].x_off, trim_data.ellipsis_glyph_buf[i].y_off), trim_data.ellipsis_glyph_buf[i].index, p_color);
+ if (rtl && ellipsis_pos >= 0) {
+ for (int i = ellipsis_gl_size - 1; i >= 0; i--) {
+ for (int j = 0; j < ellipsis_glyphs[i].repeat; j++) {
+ font_draw_glyph(ellipsis_glyphs[i].font_rid, p_canvas, ellipsis_glyphs[i].font_size, ofs + Vector2(ellipsis_glyphs[i].x_off, ellipsis_glyphs[i].y_off), ellipsis_glyphs[i].index, p_color);
if (orientation == ORIENTATION_HORIZONTAL) {
- ofs.x += trim_data.ellipsis_glyph_buf[i].advance;
+ ofs.x += ellipsis_glyphs[i].advance;
} else {
- ofs.y += trim_data.ellipsis_glyph_buf[i].advance;
+ ofs.y += ellipsis_glyphs[i].advance;
}
}
}
@@ -1335,13 +1359,13 @@ void TextServer::shaped_text_draw_outline(RID p_shaped, RID p_canvas, const Vect
}
}
}
- if (trim_data.trim_pos >= 0) {
+ if (trim_pos >= 0) {
if (rtl) {
- if (i < trim_data.trim_pos) {
+ if (i < trim_pos) {
continue;
}
} else {
- if (i >= trim_data.trim_pos && (glyphs[j].flags & TextServer::GRAPHEME_IS_VIRTUAL) != TextServer::GRAPHEME_IS_VIRTUAL) {
+ if (i >= trim_pos && (glyphs[j].flags & TextServer::GRAPHEME_IS_VIRTUAL) != TextServer::GRAPHEME_IS_VIRTUAL) {
break;
}
}
@@ -1357,48 +1381,26 @@ void TextServer::shaped_text_draw_outline(RID p_shaped, RID p_canvas, const Vect
}
}
// Draw LTR ellipsis string when needed.
- if (!rtl && trim_data.ellipsis_pos >= 0) {
- for (int i = 0; i < trim_data.ellipsis_glyph_buf.size(); i++) {
- for (int j = 0; j < trim_data.ellipsis_glyph_buf[i].repeat; j++) {
- font_draw_glyph(trim_data.ellipsis_glyph_buf[i].font_rid, p_canvas, trim_data.ellipsis_glyph_buf[i].font_size, ofs + Vector2(trim_data.ellipsis_glyph_buf[i].x_off, trim_data.ellipsis_glyph_buf[i].y_off), trim_data.ellipsis_glyph_buf[i].index, p_color);
+ if (!rtl && ellipsis_pos >= 0) {
+ for (int i = 0; i < ellipsis_gl_size; i++) {
+ for (int j = 0; j < ellipsis_glyphs[i].repeat; j++) {
+ font_draw_glyph(ellipsis_glyphs[i].font_rid, p_canvas, ellipsis_glyphs[i].font_size, ofs + Vector2(ellipsis_glyphs[i].x_off, ellipsis_glyphs[i].y_off), ellipsis_glyphs[i].index, p_color);
if (orientation == ORIENTATION_HORIZONTAL) {
- ofs.x += trim_data.ellipsis_glyph_buf[i].advance;
+ ofs.x += ellipsis_glyphs[i].advance;
} else {
- ofs.y += trim_data.ellipsis_glyph_buf[i].advance;
+ ofs.y += ellipsis_glyphs[i].advance;
}
}
}
}
}
-Dictionary TextServer::_font_get_glyph_contours(RID p_font, int p_size, int32_t p_index) const {
- Vector<Vector3> points;
- Vector<int32_t> contours;
- bool orientation;
- bool ok = font_get_glyph_contours(p_font, p_size, p_index, points, contours, orientation);
- Dictionary out;
-
- if (ok) {
- out["points"] = points;
- out["contours"] = contours;
- out["orientation"] = orientation;
- }
- return out;
-}
-
-void TextServer::_shaped_text_set_bidi_override(RID p_shaped, const Array &p_override) {
- Vector<Vector2i> overrides;
- for (int i = 0; i < p_override.size(); i++) {
- overrides.push_back(p_override[i]);
- }
- shaped_text_set_bidi_override(p_shaped, overrides);
-}
-
-Array TextServer::_shaped_text_get_glyphs(RID p_shaped) const {
+Array TextServer::_shaped_text_get_glyphs_wrapper(RID p_shaped) const {
Array ret;
- Vector<Glyph> glyphs = shaped_text_get_glyphs(p_shaped);
- for (int i = 0; i < glyphs.size(); i++) {
+ const Glyph *glyphs = shaped_text_get_glyphs(p_shaped);
+ int gl_size = shaped_text_get_glyph_count(p_shaped);
+ for (int i = 0; i < gl_size; i++) {
Dictionary glyph;
glyph["start"] = glyphs[i].start;
@@ -1418,60 +1420,51 @@ Array TextServer::_shaped_text_get_glyphs(RID p_shaped) const {
return ret;
}
-Array TextServer::_shaped_text_get_line_breaks_adv(RID p_shaped, const PackedFloat32Array &p_width, int p_start, bool p_once, uint8_t p_break_flags) const {
+Array TextServer::_shaped_text_sort_logical_wrapper(RID p_shaped) {
Array ret;
- Vector<Vector2i> lines = shaped_text_get_line_breaks_adv(p_shaped, p_width, p_start, p_once, p_break_flags);
- for (int i = 0; i < lines.size(); i++) {
- ret.push_back(lines[i]);
- }
-
- return ret;
-}
+ const Glyph *glyphs = shaped_text_sort_logical(p_shaped);
+ int gl_size = shaped_text_get_glyph_count(p_shaped);
+ for (int i = 0; i < gl_size; i++) {
+ Dictionary glyph;
-Array TextServer::_shaped_text_get_line_breaks(RID p_shaped, real_t p_width, int p_start, uint8_t p_break_flags) const {
- Array ret;
+ glyph["start"] = glyphs[i].start;
+ glyph["end"] = glyphs[i].end;
+ glyph["repeat"] = glyphs[i].repeat;
+ glyph["count"] = glyphs[i].count;
+ glyph["flags"] = glyphs[i].flags;
+ glyph["offset"] = Vector2(glyphs[i].x_off, glyphs[i].y_off);
+ glyph["advance"] = glyphs[i].advance;
+ glyph["font_rid"] = glyphs[i].font_rid;
+ glyph["font_size"] = glyphs[i].font_size;
+ glyph["index"] = glyphs[i].index;
- Vector<Vector2i> lines = shaped_text_get_line_breaks(p_shaped, p_width, p_start, p_break_flags);
- for (int i = 0; i < lines.size(); i++) {
- ret.push_back(lines[i]);
+ ret.push_back(glyph);
}
return ret;
}
-Array TextServer::_shaped_text_get_word_breaks(RID p_shaped) const {
+Array TextServer::_shaped_text_get_ellipsis_glyphs_wrapper(RID p_shaped) const {
Array ret;
- Vector<Vector2i> words = shaped_text_get_word_breaks(p_shaped);
- for (int i = 0; i < words.size(); i++) {
- ret.push_back(words[i]);
- }
-
- return ret;
-}
-
-Dictionary TextServer::_shaped_text_get_carets(RID p_shaped, int p_position) const {
- Dictionary ret;
-
- Rect2 l_caret, t_caret;
- Direction l_dir, t_dir;
- shaped_text_get_carets(p_shaped, p_position, l_caret, l_dir, t_caret, t_dir);
-
- ret["leading_rect"] = l_caret;
- ret["leading_direction"] = l_dir;
- ret["trailing_rect"] = t_caret;
- ret["trailing_direction"] = t_dir;
-
- return ret;
-}
+ const Glyph *glyphs = shaped_text_get_ellipsis_glyphs(p_shaped);
+ int gl_size = shaped_text_get_ellipsis_glyph_count(p_shaped);
+ for (int i = 0; i < gl_size; i++) {
+ Dictionary glyph;
-Array TextServer::_shaped_text_get_selection(RID p_shaped, int p_start, int p_end) const {
- Array ret;
+ glyph["start"] = glyphs[i].start;
+ glyph["end"] = glyphs[i].end;
+ glyph["repeat"] = glyphs[i].repeat;
+ glyph["count"] = glyphs[i].count;
+ glyph["flags"] = glyphs[i].flags;
+ glyph["offset"] = Vector2(glyphs[i].x_off, glyphs[i].y_off);
+ glyph["advance"] = glyphs[i].advance;
+ glyph["font_rid"] = glyphs[i].font_rid;
+ glyph["font_size"] = glyphs[i].font_size;
+ glyph["index"] = glyphs[i].index;
- Vector<Vector2> ranges = shaped_text_get_selection(p_shaped, p_start, p_end);
- for (int i = 0; i < ranges.size(); i++) {
- ret.push_back(ranges[i]);
+ ret.push_back(glyph);
}
return ret;
diff --git a/servers/text_server.h b/servers/text_server.h
index 90ad9b493b..da62ff8ef4 100644
--- a/servers/text_server.h
+++ b/servers/text_server.h
@@ -34,13 +34,17 @@
#include "core/object/ref_counted.h"
#include "core/os/os.h"
#include "core/templates/rid.h"
+#include "core/variant/native_ptr.h"
#include "core/variant/variant.h"
#include "scene/resources/texture.h"
class CanvasTexture;
-class TextServer : public Object {
- GDCLASS(TextServer, Object);
+struct Glyph;
+struct CaretInfo;
+
+class TextServer : public RefCounted {
+ GDCLASS(TextServer, RefCounted);
public:
enum Direction {
@@ -63,12 +67,12 @@ public:
JUSTIFICATION_CONSTRAIN_ELLIPSIS = 1 << 4,
};
- enum LineBreakFlag {
+ enum LineBreakFlag { // LineBreakFlag can be passed in the same value as the JustificationFlag, do not use the same values.
BREAK_NONE = 0,
- BREAK_MANDATORY = 1 << 4,
- BREAK_WORD_BOUND = 1 << 5,
- BREAK_GRAPHEME_BOUND = 1 << 6,
- BREAK_WORD_BOUND_ADAPTIVE = 1 << 5 | 1 << 7,
+ BREAK_MANDATORY = 1 << 5,
+ BREAK_WORD_BOUND = 1 << 6,
+ BREAK_GRAPHEME_BOUND = 1 << 7,
+ BREAK_WORD_BOUND_ADAPTIVE = 1 << 6 | 1 << 8,
};
enum TextOverrunFlag {
@@ -124,50 +128,11 @@ public:
SPACING_BOTTOM,
};
- struct Glyph {
- int start = -1; // Start offset in the source string.
- int end = -1; // End offset in the source string.
-
- uint8_t count = 0; // Number of glyphs in the grapheme, set in the first glyph only.
- uint8_t repeat = 1; // Draw multiple times in the row.
- uint16_t flags = 0; // Grapheme flags (valid, rtl, virtual), set in the first glyph only.
-
- real_t x_off = 0.f; // Offset from the origin of the glyph on baseline.
- real_t y_off = 0.f;
- real_t advance = 0.f; // Advance to the next glyph along baseline(x for horizontal layout, y for vertical).
-
- RID font_rid; // Font resource.
- int font_size = 0; // Font size;
- int32_t index = 0; // Glyph index (font specific) or UTF-32 codepoint (for the invalid glyphs).
-
- bool operator==(const Glyph &p_a) const;
- bool operator!=(const Glyph &p_a) const;
-
- bool operator<(const Glyph &p_a) const;
- bool operator>(const Glyph &p_a) const;
- };
-
- struct GlyphCompare { // For line breaking reordering.
- _FORCE_INLINE_ bool operator()(const Glyph &l, const Glyph &r) const {
- if (l.start == r.start) {
- if (l.count == r.count) {
- if ((l.flags & GRAPHEME_IS_VIRTUAL) == GRAPHEME_IS_VIRTUAL) {
- return false;
- } else {
- return true;
- }
- }
- return l.count > r.count; // Sort first glyph with count & flags, order of the rest are irrelevant.
- } else {
- return l.start < r.start;
- }
- }
- };
-
+protected:
struct TrimData {
int trim_pos = -1;
int ellipsis_pos = -1;
- Vector<TextServer::Glyph> ellipsis_glyph_buf;
+ Vector<Glyph> ellipsis_glyph_buf;
};
struct ShapedTextData {
@@ -215,22 +180,21 @@ public:
bool preserve_invalid = true; // Draw hex code box instead of missing characters.
bool preserve_control = false; // Draw control characters.
- real_t ascent = 0.f; // Ascent for horizontal layout, 1/2 of width for vertical.
- real_t descent = 0.f; // Descent for horizontal layout, 1/2 of width for vertical.
- real_t width = 0.f; // Width for horizontal layout, height for vertical.
- real_t width_trimmed = 0.f;
+ float ascent = 0.f; // Ascent for horizontal layout, 1/2 of width for vertical.
+ float descent = 0.f; // Descent for horizontal layout, 1/2 of width for vertical.
+ float width = 0.f; // Width for horizontal layout, height for vertical.
+ float width_trimmed = 0.f;
- real_t upos = 0.f;
- real_t uthk = 0.f;
+ float upos = 0.f;
+ float uthk = 0.f;
TrimData overrun_trim_data;
bool fit_width_minimum_reached = false;
- Vector<TextServer::Glyph> glyphs;
- Vector<TextServer::Glyph> glyphs_logical;
+ Vector<Glyph> glyphs;
+ Vector<Glyph> glyphs_logical;
};
-protected:
static void _bind_methods();
static Vector3 hex_code_box_font_size[2];
@@ -240,20 +204,19 @@ public:
static void initialize_hex_code_box_fonts();
static void finish_hex_code_box_fonts();
- virtual bool has_feature(Feature p_feature) = 0;
+ virtual bool has_feature(Feature p_feature) const = 0;
virtual String get_name() const = 0;
+ virtual uint32_t get_features() const = 0;
virtual void free(RID p_rid) = 0;
virtual bool has(RID p_rid) = 0;
virtual bool load_support_data(const String &p_filename) = 0;
-#ifdef TOOLS_ENABLED
- virtual String get_support_data_filename() = 0;
- virtual String get_support_data_info() = 0;
- virtual bool save_support_data(const String &p_filename) = 0;
-#endif
+ virtual String get_support_data_filename() const = 0;
+ virtual String get_support_data_info() const = 0;
+ virtual bool save_support_data(const String &p_filename) const = 0;
- virtual bool is_locale_right_to_left(const String &p_locale) = 0;
+ virtual bool is_locale_right_to_left(const String &p_locale) const = 0;
virtual int32_t name_to_tag(const String &p_name) const { return 0; };
virtual String tag_to_name(int32_t p_tag) const { return ""; };
@@ -282,33 +245,33 @@ public:
virtual void font_set_force_autohinter(RID p_font_rid, bool p_force_autohinter) = 0;
virtual bool font_is_force_autohinter(RID p_font_rid) const = 0;
- virtual void font_set_hinting(RID p_font_rid, TextServer::Hinting p_hinting) = 0;
- virtual TextServer::Hinting font_get_hinting(RID p_font_rid) const = 0;
+ virtual void font_set_hinting(RID p_font_rid, Hinting p_hinting) = 0;
+ virtual Hinting font_get_hinting(RID p_font_rid) const = 0;
virtual void font_set_variation_coordinates(RID p_font_rid, const Dictionary &p_variation_coordinates) = 0;
virtual Dictionary font_get_variation_coordinates(RID p_font_rid) const = 0;
- virtual void font_set_oversampling(RID p_font_rid, real_t p_oversampling) = 0;
- virtual real_t font_get_oversampling(RID p_font_rid) const = 0;
+ virtual void font_set_oversampling(RID p_font_rid, float p_oversampling) = 0;
+ virtual float font_get_oversampling(RID p_font_rid) const = 0;
virtual Array font_get_size_cache_list(RID p_font_rid) const = 0;
virtual void font_clear_size_cache(RID p_font_rid) = 0;
virtual void font_remove_size_cache(RID p_font_rid, const Vector2i &p_size) = 0;
- virtual void font_set_ascent(RID p_font_rid, int p_size, real_t p_ascent) = 0;
- virtual real_t font_get_ascent(RID p_font_rid, int p_size) const = 0;
+ virtual void font_set_ascent(RID p_font_rid, int p_size, float p_ascent) = 0;
+ virtual float font_get_ascent(RID p_font_rid, int p_size) const = 0;
- virtual void font_set_descent(RID p_font_rid, int p_size, real_t p_descent) = 0;
- virtual real_t font_get_descent(RID p_font_rid, int p_size) const = 0;
+ virtual void font_set_descent(RID p_font_rid, int p_size, float p_descent) = 0;
+ virtual float font_get_descent(RID p_font_rid, int p_size) const = 0;
- virtual void font_set_underline_position(RID p_font_rid, int p_size, real_t p_underline_position) = 0;
- virtual real_t font_get_underline_position(RID p_font_rid, int p_size) const = 0;
+ virtual void font_set_underline_position(RID p_font_rid, int p_size, float p_underline_position) = 0;
+ virtual float font_get_underline_position(RID p_font_rid, int p_size) const = 0;
- virtual void font_set_underline_thickness(RID p_font_rid, int p_size, real_t p_underline_thickness) = 0;
- virtual real_t font_get_underline_thickness(RID p_font_rid, int p_size) const = 0;
+ virtual void font_set_underline_thickness(RID p_font_rid, int p_size, float p_underline_thickness) = 0;
+ virtual float font_get_underline_thickness(RID p_font_rid, int p_size) const = 0;
- virtual void font_set_scale(RID p_font_rid, int p_size, real_t p_scale) = 0;
- virtual real_t font_get_scale(RID p_font_rid, int p_size) const = 0;
+ virtual void font_set_scale(RID p_font_rid, int p_size, float p_scale) = 0;
+ virtual float font_get_scale(RID p_font_rid, int p_size) const = 0;
virtual void font_set_spacing(RID p_font_rid, int p_size, SpacingType p_spacing, int p_value) = 0;
virtual int font_get_spacing(RID p_font_rid, int p_size, SpacingType p_spacing) const = 0;
@@ -342,7 +305,7 @@ public:
virtual int font_get_glyph_texture_idx(RID p_font_rid, const Vector2i &p_size, int32_t p_glyph) const = 0;
virtual void font_set_glyph_texture_idx(RID p_font_rid, const Vector2i &p_size, int32_t p_glyph, int p_texture_idx) = 0;
- virtual bool font_get_glyph_contours(RID p_font, int p_size, int32_t p_index, Vector<Vector3> &r_points, Vector<int32_t> &r_contours, bool &r_orientation) const = 0;
+ virtual Dictionary font_get_glyph_contours(RID p_font, int p_size, int32_t p_index) const = 0;
virtual Array font_get_kerning_list(RID p_font_rid, int p_size) const = 0;
virtual void font_clear_kerning_map(RID p_font_rid, int p_size) = 0;
@@ -377,11 +340,11 @@ public:
virtual Dictionary font_supported_feature_list(RID p_font_rid) const = 0;
virtual Dictionary font_supported_variation_list(RID p_font_rid) const = 0;
- virtual real_t font_get_global_oversampling() const = 0;
- virtual void font_set_global_oversampling(real_t p_oversampling) = 0;
+ virtual float font_get_global_oversampling() const = 0;
+ virtual void font_set_global_oversampling(float p_oversampling) = 0;
- Vector2 get_hex_code_box_size(int p_size, char32_t p_index) const;
- void draw_hex_code_box(RID p_canvas, int p_size, const Vector2 &p_pos, char32_t p_index, const Color &p_color) const;
+ virtual Vector2 get_hex_code_box_size(int p_size, char32_t p_index) const;
+ virtual void draw_hex_code_box(RID p_canvas, int p_size, const Vector2 &p_pos, char32_t p_index, const Color &p_color) const;
/* Shaped text buffer interface */
@@ -392,7 +355,7 @@ public:
virtual void shaped_text_set_direction(RID p_shaped, Direction p_direction = DIRECTION_AUTO) = 0;
virtual Direction shaped_text_get_direction(RID p_shaped) const = 0;
- virtual void shaped_text_set_bidi_override(RID p_shaped, const Vector<Vector2i> &p_override) = 0;
+ virtual void shaped_text_set_bidi_override(RID p_shaped, const Array &p_override) = 0;
virtual void shaped_text_set_orientation(RID p_shaped, Orientation p_orientation = ORIENTATION_HORIZONTAL) = 0;
virtual Orientation shaped_text_get_orientation(RID p_shaped) const = 0;
@@ -410,8 +373,8 @@ public:
virtual RID shaped_text_substr(RID p_shaped, int p_start, int p_length) const = 0; // Copy shaped substring (e.g. line break) without reshaping, but correctly reordered, preservers range.
virtual RID shaped_text_get_parent(RID p_shaped) const = 0;
- virtual real_t shaped_text_fit_to_width(RID p_shaped, real_t p_width, uint8_t /*JustificationFlag*/ p_jst_flags = JUSTIFICATION_WORD_BOUND | JUSTIFICATION_KASHIDA) = 0;
- virtual real_t shaped_text_tab_align(RID p_shaped, const Vector<real_t> &p_tab_stops) = 0;
+ virtual float shaped_text_fit_to_width(RID p_shaped, float p_width, uint16_t /*JustificationFlag*/ p_jst_flags = JUSTIFICATION_WORD_BOUND | JUSTIFICATION_KASHIDA) = 0;
+ virtual float shaped_text_tab_align(RID p_shaped, const PackedFloat32Array &p_tab_stops) = 0;
virtual bool shaped_text_shape(RID p_shaped) = 0;
virtual bool shaped_text_update_breaks(RID p_shaped) = 0;
@@ -419,66 +382,109 @@ public:
virtual bool shaped_text_is_ready(RID p_shaped) const = 0;
- virtual Vector<Glyph> shaped_text_get_glyphs(RID p_shaped) const = 0;
+ virtual const Glyph *shaped_text_get_glyphs(RID p_shaped) const = 0;
+ Array _shaped_text_get_glyphs_wrapper(RID p_shaped) const;
+ virtual const Glyph *shaped_text_sort_logical(RID p_shaped) = 0;
+ Array _shaped_text_sort_logical_wrapper(RID p_shaped);
+ virtual int shaped_text_get_glyph_count(RID p_shaped) const = 0;
virtual Vector2i shaped_text_get_range(RID p_shaped) const = 0;
- virtual Vector<Glyph> shaped_text_sort_logical(RID p_shaped) = 0;
+ virtual PackedInt32Array shaped_text_get_line_breaks_adv(RID p_shaped, const PackedFloat32Array &p_width, int p_start = 0, bool p_once = true, uint16_t /*TextBreakFlag*/ p_break_flags = BREAK_MANDATORY | BREAK_WORD_BOUND) const;
+ virtual PackedInt32Array shaped_text_get_line_breaks(RID p_shaped, float p_width, int p_start = 0, uint16_t /*TextBreakFlag*/ p_break_flags = BREAK_MANDATORY | BREAK_WORD_BOUND) const;
+ virtual PackedInt32Array shaped_text_get_word_breaks(RID p_shaped, int p_grapheme_flags = GRAPHEME_IS_SPACE | GRAPHEME_IS_PUNCTUATION) const;
- virtual Vector<Vector2i> shaped_text_get_line_breaks_adv(RID p_shaped, const Vector<real_t> &p_width, int p_start = 0, bool p_once = true, uint8_t /*TextBreakFlag*/ p_break_flags = BREAK_MANDATORY | BREAK_WORD_BOUND) const;
- virtual Vector<Vector2i> shaped_text_get_line_breaks(RID p_shaped, real_t p_width, int p_start = 0, uint8_t /*TextBreakFlag*/ p_break_flags = BREAK_MANDATORY | BREAK_WORD_BOUND) const;
- virtual Vector<Vector2i> shaped_text_get_word_breaks(RID p_shaped, int p_grapheme_flags = GRAPHEME_IS_SPACE | GRAPHEME_IS_PUNCTUATION) const;
+ virtual int shaped_text_get_trim_pos(RID p_shaped) const = 0;
+ virtual int shaped_text_get_ellipsis_pos(RID p_shaped) const = 0;
+ virtual const Glyph *shaped_text_get_ellipsis_glyphs(RID p_shaped) const = 0;
+ Array _shaped_text_get_ellipsis_glyphs_wrapper(RID p_shaped) const;
+ virtual int shaped_text_get_ellipsis_glyph_count(RID p_shaped) const = 0;
+
+ virtual void shaped_text_overrun_trim_to_width(RID p_shaped, float p_width, uint16_t p_trim_flags) = 0;
- virtual TrimData shaped_text_get_trim_data(RID p_shaped) const;
- virtual void shaped_text_overrun_trim_to_width(RID p_shaped, real_t p_width, uint8_t p_trim_flags) = 0;
virtual Array shaped_text_get_objects(RID p_shaped) const = 0;
virtual Rect2 shaped_text_get_object_rect(RID p_shaped, Variant p_key) const = 0;
virtual Size2 shaped_text_get_size(RID p_shaped) const = 0;
- virtual real_t shaped_text_get_ascent(RID p_shaped) const = 0;
- virtual real_t shaped_text_get_descent(RID p_shaped) const = 0;
- virtual real_t shaped_text_get_width(RID p_shaped) const = 0;
- virtual real_t shaped_text_get_underline_position(RID p_shaped) const = 0;
- virtual real_t shaped_text_get_underline_thickness(RID p_shaped) const = 0;
+ virtual float shaped_text_get_ascent(RID p_shaped) const = 0;
+ virtual float shaped_text_get_descent(RID p_shaped) const = 0;
+ virtual float shaped_text_get_width(RID p_shaped) const = 0;
+ virtual float shaped_text_get_underline_position(RID p_shaped) const = 0;
+ virtual float shaped_text_get_underline_thickness(RID p_shaped) const = 0;
+
+ virtual Direction shaped_text_get_dominant_direction_in_range(RID p_shaped, int p_start, int p_end) const;
- virtual Direction shaped_text_get_dominant_direciton_in_range(RID p_shaped, int p_start, int p_end) const;
+ virtual CaretInfo shaped_text_get_carets(RID p_shaped, int p_position) const;
+ Dictionary _shaped_text_get_carets_wrapper(RID p_shaped, int p_position) const;
- virtual void shaped_text_get_carets(RID p_shaped, int p_position, Rect2 &p_leading_caret, Direction &p_leading_dir, Rect2 &p_trailing_caret, Direction &p_trailing_dir) const;
virtual Vector<Vector2> shaped_text_get_selection(RID p_shaped, int p_start, int p_end) const;
- virtual int shaped_text_hit_test_grapheme(RID p_shaped, real_t p_coords) const; // Return grapheme index.
- virtual int shaped_text_hit_test_position(RID p_shaped, real_t p_coords) const; // Return caret/selection position.
+ virtual int shaped_text_hit_test_grapheme(RID p_shaped, float p_coords) const; // Return grapheme index.
+ virtual int shaped_text_hit_test_position(RID p_shaped, float p_coords) const; // Return caret/selection position.
- virtual int shaped_text_next_grapheme_pos(RID p_shaped, int p_pos);
- virtual int shaped_text_prev_grapheme_pos(RID p_shaped, int p_pos);
+ virtual int shaped_text_next_grapheme_pos(RID p_shaped, int p_pos) const;
+ virtual int shaped_text_prev_grapheme_pos(RID p_shaped, int p_pos) const;
// The pen position is always placed on the baseline and moveing left to right.
- virtual void shaped_text_draw(RID p_shaped, RID p_canvas, const Vector2 &p_pos, real_t p_clip_l = -1.f, real_t p_clip_r = -1.f, const Color &p_color = Color(1, 1, 1)) const;
- virtual void shaped_text_draw_outline(RID p_shaped, RID p_canvas, const Vector2 &p_pos, real_t p_clip_l = -1.f, real_t p_clip_r = -1.f, int p_outline_size = 1, const Color &p_color = Color(1, 1, 1)) const;
+ virtual void shaped_text_draw(RID p_shaped, RID p_canvas, const Vector2 &p_pos, float p_clip_l = -1.f, float p_clip_r = -1.f, const Color &p_color = Color(1, 1, 1)) const;
+ virtual void shaped_text_draw_outline(RID p_shaped, RID p_canvas, const Vector2 &p_pos, float p_clip_l = -1.f, float p_clip_r = -1.f, int p_outline_size = 1, const Color &p_color = Color(1, 1, 1)) const;
// Number conversion.
virtual String format_number(const String &p_string, const String &p_language = "") const { return p_string; };
virtual String parse_number(const String &p_string, const String &p_language = "") const { return p_string; };
virtual String percent_sign(const String &p_language = "") const { return "%"; };
- /* GDScript wrappers */
- RID _create_font_memory(const PackedByteArray &p_data, int p_base_size = 16);
+ TextServer();
+ ~TextServer();
+};
+
+/*************************************************************************/
- Dictionary _font_get_glyph_contours(RID p_font, int p_size, int32_t p_index) const;
+struct Glyph {
+ int start = -1; // Start offset in the source string.
+ int end = -1; // End offset in the source string.
- Array _shaped_text_get_glyphs(RID p_shaped) const;
- Dictionary _shaped_text_get_carets(RID p_shaped, int p_position) const;
+ uint8_t count = 0; // Number of glyphs in the grapheme, set in the first glyph only.
+ uint8_t repeat = 1; // Draw multiple times in the row.
+ uint16_t flags = 0; // Grapheme flags (valid, rtl, virtual), set in the first glyph only.
- void _shaped_text_set_bidi_override(RID p_shaped, const Array &p_override);
+ float x_off = 0.f; // Offset from the origin of the glyph on baseline.
+ float y_off = 0.f;
+ float advance = 0.f; // Advance to the next glyph along baseline(x for horizontal layout, y for vertical).
- Array _shaped_text_get_line_breaks_adv(RID p_shaped, const PackedFloat32Array &p_width, int p_start, bool p_once, uint8_t p_break_flags) const;
- Array _shaped_text_get_line_breaks(RID p_shaped, real_t p_width, int p_start, uint8_t p_break_flags) const;
- Array _shaped_text_get_word_breaks(RID p_shaped) const;
+ RID font_rid; // Font resource.
+ int font_size = 0; // Font size;
+ int32_t index = 0; // Glyph index (font specific) or UTF-32 codepoint (for the invalid glyphs).
- Array _shaped_text_get_selection(RID p_shaped, int p_start, int p_end) const;
+ bool operator==(const Glyph &p_a) const;
+ bool operator!=(const Glyph &p_a) const;
- TextServer();
- ~TextServer();
+ bool operator<(const Glyph &p_a) const;
+ bool operator>(const Glyph &p_a) const;
+};
+
+struct CaretInfo {
+ Rect2 l_caret;
+ Rect2 t_caret;
+ TextServer::Direction l_dir;
+ TextServer::Direction t_dir;
+};
+
+struct GlyphCompare { // For line breaking reordering.
+ _FORCE_INLINE_ bool operator()(const Glyph &l, const Glyph &r) const {
+ if (l.start == r.start) {
+ if (l.count == r.count) {
+ if ((l.flags & TextServer::GRAPHEME_IS_VIRTUAL) == TextServer::GRAPHEME_IS_VIRTUAL) {
+ return false;
+ } else {
+ return true;
+ }
+ }
+ return l.count > r.count; // Sort first glyph with count & flags, order of the rest are irrelevant.
+ } else {
+ return l.start < r.start;
+ }
+ }
};
/*************************************************************************/
@@ -486,52 +492,32 @@ public:
class TextServerManager : public Object {
GDCLASS(TextServerManager, Object);
-public:
- typedef TextServer *(*CreateFunction)(Error &r_error, void *p_user_data);
-
protected:
static void _bind_methods();
private:
static TextServerManager *singleton;
- static TextServer *server;
- enum {
- MAX_SERVERS = 64
- };
- struct TextServerCreate {
- String name;
- CreateFunction create_function = nullptr;
- uint32_t features = 0;
- TextServer *instance = nullptr;
- void *user_data = nullptr;
- };
-
- static TextServerCreate server_create_functions[MAX_SERVERS];
- static int server_create_count;
+ Ref<TextServer> primary_interface;
+ Vector<Ref<TextServer>> interfaces;
public:
_FORCE_INLINE_ static TextServerManager *get_singleton() {
return singleton;
}
- static void register_create_function(const String &p_name, uint32_t p_features, CreateFunction p_function, void *p_user_data);
- static int get_interface_count();
- static String get_interface_name(int p_index);
- static uint32_t get_interface_features(int p_index);
- static TextServer *initialize(int p_index, Error &r_error);
- static TextServer *get_primary_interface();
-
- /* GDScript wrappers */
- int _get_interface_count() const;
- String _get_interface_name(int p_index) const;
- uint32_t _get_interface_features(int p_index) const;
- TextServer *_get_interface(int p_index) const;
- Array _get_interfaces() const;
- TextServer *_find_interface(const String &p_name) const;
+ void add_interface(const Ref<TextServer> &p_interface);
+ void remove_interface(const Ref<TextServer> &p_interface);
+ int get_interface_count() const;
+ Ref<TextServer> get_interface(int p_index) const;
+ Ref<TextServer> find_interface(const String &p_name) const;
+ Array get_interfaces() const;
- bool _set_primary_interface(int p_index);
- TextServer *_get_primary_interface() const;
+ _FORCE_INLINE_ Ref<TextServer> get_primary_interface() const {
+ return primary_interface;
+ }
+ Ref<TextServer> _get_primary_interface() const;
+ void set_primary_interface(const Ref<TextServer> &p_primary_interface);
TextServerManager();
~TextServerManager();
@@ -539,7 +525,7 @@ public:
/*************************************************************************/
-#define TS TextServerManager::get_primary_interface()
+#define TS TextServerManager::get_singleton()->get_primary_interface()
VARIANT_ENUM_CAST(TextServer::Direction);
VARIANT_ENUM_CAST(TextServer::Orientation);
@@ -552,4 +538,8 @@ VARIANT_ENUM_CAST(TextServer::Feature);
VARIANT_ENUM_CAST(TextServer::ContourPointTag);
VARIANT_ENUM_CAST(TextServer::SpacingType);
+GDVIRTUAL_NATIVE_PTR(Glyph);
+GDVIRTUAL_NATIVE_PTR(Glyph *);
+GDVIRTUAL_NATIVE_PTR(CaretInfo);
+
#endif // TEXT_SERVER_H