summaryrefslogtreecommitdiff
path: root/scene
diff options
context:
space:
mode:
Diffstat (limited to 'scene')
-rw-r--r--scene/2d/canvas_item.cpp40
-rw-r--r--scene/2d/canvas_item.h2
-rw-r--r--scene/2d/cpu_particles_2d.cpp151
-rw-r--r--scene/2d/cpu_particles_2d.h2
-rw-r--r--scene/2d/navigation_polygon.cpp80
-rw-r--r--scene/2d/navigation_polygon.h12
-rw-r--r--scene/3d/collision_shape.cpp6
-rw-r--r--scene/3d/cpu_particles.cpp187
-rw-r--r--scene/3d/cpu_particles.h2
-rw-r--r--scene/3d/navigation.h2
-rw-r--r--scene/3d/navigation_region.cpp (renamed from scene/3d/navigation_mesh_instance.cpp)44
-rw-r--r--scene/3d/navigation_region.h (renamed from scene/3d/navigation_mesh_instance.h)16
-rw-r--r--scene/gui/tab_container.cpp2
-rw-r--r--scene/gui/text_edit.cpp34
-rw-r--r--scene/gui/text_edit.h10
-rw-r--r--scene/main/node.cpp2
-rw-r--r--scene/register_scene_types.cpp13
-rw-r--r--scene/resources/dynamic_font.cpp59
-rw-r--r--scene/resources/dynamic_font.h2
-rw-r--r--scene/resources/material.cpp40
-rw-r--r--scene/resources/material.h2
-rw-r--r--scene/resources/mesh_library.cpp6
-rw-r--r--scene/resources/mesh_library.h2
-rw-r--r--scene/resources/particles_material.cpp40
-rw-r--r--scene/resources/particles_material.h2
-rw-r--r--scene/resources/world_margin_shape.cpp (renamed from scene/resources/plane_shape.cpp)20
-rw-r--r--scene/resources/world_margin_shape.h (renamed from scene/resources/plane_shape.h)14
27 files changed, 331 insertions, 461 deletions
diff --git a/scene/2d/canvas_item.cpp b/scene/2d/canvas_item.cpp
index 942b63898d..ef7aa9ba01 100644
--- a/scene/2d/canvas_item.cpp
+++ b/scene/2d/canvas_item.cpp
@@ -41,17 +41,13 @@
#include "servers/visual/visual_server_raster.h"
#include "servers/visual_server.h"
-Mutex *CanvasItemMaterial::material_mutex = NULL;
+Mutex CanvasItemMaterial::material_mutex;
SelfList<CanvasItemMaterial>::List *CanvasItemMaterial::dirty_materials = NULL;
Map<CanvasItemMaterial::MaterialKey, CanvasItemMaterial::ShaderData> CanvasItemMaterial::shader_map;
CanvasItemMaterial::ShaderNames *CanvasItemMaterial::shader_names = NULL;
void CanvasItemMaterial::init_shaders() {
-#ifndef NO_THREADS
- material_mutex = Mutex::create();
-#endif
-
dirty_materials = memnew(SelfList<CanvasItemMaterial>::List);
shader_names = memnew(ShaderNames);
@@ -66,10 +62,6 @@ void CanvasItemMaterial::finish_shaders() {
memdelete(dirty_materials);
memdelete(shader_names);
dirty_materials = NULL;
-
-#ifndef NO_THREADS
- memdelete(material_mutex);
-#endif
}
void CanvasItemMaterial::_update_shader() {
@@ -156,44 +148,28 @@ void CanvasItemMaterial::_update_shader() {
void CanvasItemMaterial::flush_changes() {
- if (material_mutex)
- material_mutex->lock();
+ MutexLock lock(material_mutex);
while (dirty_materials->first()) {
dirty_materials->first()->self()->_update_shader();
}
-
- if (material_mutex)
- material_mutex->unlock();
}
void CanvasItemMaterial::_queue_shader_change() {
- if (material_mutex)
- material_mutex->lock();
+ MutexLock lock(material_mutex);
if (!element.in_list()) {
dirty_materials->add(&element);
}
-
- if (material_mutex)
- material_mutex->unlock();
}
bool CanvasItemMaterial::_is_shader_dirty() const {
- bool dirty = false;
-
- if (material_mutex)
- material_mutex->lock();
-
- dirty = element.in_list();
+ MutexLock lock(material_mutex);
- if (material_mutex)
- material_mutex->unlock();
-
- return dirty;
+ return element.in_list();
}
void CanvasItemMaterial::set_blend_mode(BlendMode p_blend_mode) {
@@ -332,8 +308,7 @@ CanvasItemMaterial::CanvasItemMaterial() :
CanvasItemMaterial::~CanvasItemMaterial() {
- if (material_mutex)
- material_mutex->lock();
+ MutexLock lock(material_mutex);
if (shader_map.has(current_key)) {
shader_map[current_key].users--;
@@ -345,9 +320,6 @@ CanvasItemMaterial::~CanvasItemMaterial() {
VS::get_singleton()->material_set_shader(_get_material(), RID());
}
-
- if (material_mutex)
- material_mutex->unlock();
}
///////////////////////////////////////////////////////////////////
diff --git a/scene/2d/canvas_item.h b/scene/2d/canvas_item.h
index 3cd8e6ef74..c7f9500ea1 100644
--- a/scene/2d/canvas_item.h
+++ b/scene/2d/canvas_item.h
@@ -108,7 +108,7 @@ private:
return mk;
}
- static Mutex *material_mutex;
+ static Mutex material_mutex;
static SelfList<CanvasItemMaterial>::List *dirty_materials;
SelfList<CanvasItemMaterial> element;
diff --git a/scene/2d/cpu_particles_2d.cpp b/scene/2d/cpu_particles_2d.cpp
index 35df6c8945..f781f06b0f 100644
--- a/scene/2d/cpu_particles_2d.cpp
+++ b/scene/2d/cpu_particles_2d.cpp
@@ -970,118 +970,103 @@ void CPUParticles2D::_particles_process(float p_delta) {
}
void CPUParticles2D::_update_particle_data_buffer() {
-#ifndef NO_THREADS
- update_mutex->lock();
-#endif
+ MutexLock lock(update_mutex);
- {
-
- int pc = particles.size();
+ int pc = particles.size();
- int *ow;
- int *order = NULL;
+ int *ow;
+ int *order = NULL;
- float *w = particle_data.ptrw();
- const Particle *r = particles.ptr();
- float *ptr = w;
+ float *w = particle_data.ptrw();
+ const Particle *r = particles.ptr();
+ float *ptr = w;
- if (draw_order != DRAW_ORDER_INDEX) {
- ow = particle_order.ptrw();
- order = ow;
+ if (draw_order != DRAW_ORDER_INDEX) {
+ ow = particle_order.ptrw();
+ order = ow;
- for (int i = 0; i < pc; i++) {
- order[i] = i;
- }
- if (draw_order == DRAW_ORDER_LIFETIME) {
- SortArray<int, SortLifetime> sorter;
- sorter.compare.particles = r;
- sorter.sort(order, pc);
- }
+ for (int i = 0; i < pc; i++) {
+ order[i] = i;
+ }
+ if (draw_order == DRAW_ORDER_LIFETIME) {
+ SortArray<int, SortLifetime> sorter;
+ sorter.compare.particles = r;
+ sorter.sort(order, pc);
}
+ }
- for (int i = 0; i < pc; i++) {
+ for (int i = 0; i < pc; i++) {
- int idx = order ? order[i] : i;
+ int idx = order ? order[i] : i;
- Transform2D t = r[idx].transform;
+ Transform2D t = r[idx].transform;
- if (!local_coords) {
- t = inv_emission_transform * t;
- }
+ if (!local_coords) {
+ t = inv_emission_transform * t;
+ }
- if (r[idx].active) {
+ if (r[idx].active) {
- ptr[0] = t.elements[0][0];
- ptr[1] = t.elements[1][0];
- ptr[2] = 0;
- ptr[3] = t.elements[2][0];
- ptr[4] = t.elements[0][1];
- ptr[5] = t.elements[1][1];
- ptr[6] = 0;
- ptr[7] = t.elements[2][1];
+ ptr[0] = t.elements[0][0];
+ ptr[1] = t.elements[1][0];
+ ptr[2] = 0;
+ ptr[3] = t.elements[2][0];
+ ptr[4] = t.elements[0][1];
+ ptr[5] = t.elements[1][1];
+ ptr[6] = 0;
+ ptr[7] = t.elements[2][1];
- } else {
- zeromem(ptr, sizeof(float) * 8);
- }
+ } else {
+ zeromem(ptr, sizeof(float) * 8);
+ }
- Color c = r[idx].color;
+ Color c = r[idx].color;
- ptr[8] = c.r;
- ptr[9] = c.g;
- ptr[10] = c.b;
- ptr[11] = c.a;
+ ptr[8] = c.r;
+ ptr[9] = c.g;
+ ptr[10] = c.b;
+ ptr[11] = c.a;
- ptr[12] = r[idx].custom[0];
- ptr[13] = r[idx].custom[1];
- ptr[14] = r[idx].custom[2];
- ptr[15] = r[idx].custom[3];
+ ptr[12] = r[idx].custom[0];
+ ptr[13] = r[idx].custom[1];
+ ptr[14] = r[idx].custom[2];
+ ptr[15] = r[idx].custom[3];
- ptr += 16;
- }
+ ptr += 16;
}
-
-#ifndef NO_THREADS
- update_mutex->unlock();
-#endif
}
void CPUParticles2D::_set_redraw(bool p_redraw) {
if (redraw == p_redraw)
return;
redraw = p_redraw;
-#ifndef NO_THREADS
- update_mutex->lock();
-#endif
- if (redraw) {
- VS::get_singleton()->connect_compat("frame_pre_draw", this, "_update_render_thread");
- VS::get_singleton()->canvas_item_set_update_when_visible(get_canvas_item(), true);
-
- VS::get_singleton()->multimesh_set_visible_instances(multimesh, -1);
- } else {
- if (VS::get_singleton()->is_connected_compat("frame_pre_draw", this, "_update_render_thread")) {
- VS::get_singleton()->disconnect_compat("frame_pre_draw", this, "_update_render_thread");
- }
- VS::get_singleton()->canvas_item_set_update_when_visible(get_canvas_item(), false);
- VS::get_singleton()->multimesh_set_visible_instances(multimesh, 0);
+ {
+ MutexLock lock(update_mutex);
+
+ if (redraw) {
+ VS::get_singleton()->connect_compat("frame_pre_draw", this, "_update_render_thread");
+ VS::get_singleton()->canvas_item_set_update_when_visible(get_canvas_item(), true);
+
+ VS::get_singleton()->multimesh_set_visible_instances(multimesh, -1);
+ } else {
+ if (VS::get_singleton()->is_connected_compat("frame_pre_draw", this, "_update_render_thread")) {
+ VS::get_singleton()->disconnect_compat("frame_pre_draw", this, "_update_render_thread");
+ }
+ VS::get_singleton()->canvas_item_set_update_when_visible(get_canvas_item(), false);
+
+ VS::get_singleton()->multimesh_set_visible_instances(multimesh, 0);
+ }
}
-#ifndef NO_THREADS
- update_mutex->unlock();
-#endif
+
update(); // redraw to update render list
}
void CPUParticles2D::_update_render_thread() {
-#ifndef NO_THREADS
- update_mutex->lock();
-#endif
+ MutexLock lock(update_mutex);
VS::get_singleton()->multimesh_set_buffer(multimesh, particle_data);
-
-#ifndef NO_THREADS
- update_mutex->unlock();
-#endif
}
void CPUParticles2D::_notification(int p_what) {
@@ -1494,18 +1479,10 @@ CPUParticles2D::CPUParticles2D() {
set_color(Color(1, 1, 1, 1));
-#ifndef NO_THREADS
- update_mutex = Mutex::create();
-#endif
-
_update_mesh_texture();
}
CPUParticles2D::~CPUParticles2D() {
VS::get_singleton()->free(multimesh);
VS::get_singleton()->free(mesh);
-
-#ifndef NO_THREADS
- memdelete(update_mutex);
-#endif
}
diff --git a/scene/2d/cpu_particles_2d.h b/scene/2d/cpu_particles_2d.h
index 6f85631fe1..18d0caceed 100644
--- a/scene/2d/cpu_particles_2d.h
+++ b/scene/2d/cpu_particles_2d.h
@@ -178,7 +178,7 @@ private:
void _particles_process(float p_delta);
void _update_particle_data_buffer();
- Mutex *update_mutex;
+ Mutex update_mutex;
void _update_render_thread();
diff --git a/scene/2d/navigation_polygon.cpp b/scene/2d/navigation_polygon.cpp
index 6754c1c9a6..8fb9a8427e 100644
--- a/scene/2d/navigation_polygon.cpp
+++ b/scene/2d/navigation_polygon.cpp
@@ -82,9 +82,10 @@ bool NavigationPolygon::_edit_is_selected_on_click(const Point2 &p_point, double
void NavigationPolygon::set_vertices(const Vector<Vector2> &p_vertices) {
- navmesh_generation->lock();
- navmesh.unref();
- navmesh_generation->unlock();
+ {
+ MutexLock lock(navmesh_generation);
+ navmesh.unref();
+ }
vertices = p_vertices;
rect_cache_dirty = true;
}
@@ -96,9 +97,10 @@ Vector<Vector2> NavigationPolygon::get_vertices() const {
void NavigationPolygon::_set_polygons(const Array &p_array) {
- navmesh_generation->lock();
- navmesh.unref();
- navmesh_generation->unlock();
+ {
+ MutexLock lock(navmesh_generation);
+ navmesh.unref();
+ }
polygons.resize(p_array.size());
for (int i = 0; i < p_array.size(); i++) {
polygons.write[i].indices = p_array[i];
@@ -141,9 +143,10 @@ void NavigationPolygon::add_polygon(const Vector<int> &p_polygon) {
Polygon polygon;
polygon.indices = p_polygon;
polygons.push_back(polygon);
- navmesh_generation->lock();
- navmesh.unref();
- navmesh_generation->unlock();
+ {
+ MutexLock lock(navmesh_generation);
+ navmesh.unref();
+ }
}
void NavigationPolygon::add_outline_at_index(const Vector<Vector2> &p_outline, int p_index) {
@@ -164,13 +167,15 @@ Vector<int> NavigationPolygon::get_polygon(int p_idx) {
void NavigationPolygon::clear_polygons() {
polygons.clear();
- navmesh_generation->lock();
- navmesh.unref();
- navmesh_generation->unlock();
+ {
+ MutexLock lock(navmesh_generation);
+ navmesh.unref();
+ }
}
Ref<NavigationMesh> NavigationPolygon::get_mesh() {
- navmesh_generation->lock();
+ MutexLock lock(navmesh_generation);
+
if (navmesh.is_null()) {
navmesh.instance();
Vector<Vector3> verts;
@@ -190,7 +195,7 @@ Ref<NavigationMesh> NavigationPolygon::get_mesh() {
navmesh->add_polygon(get_polygon(i));
}
}
- navmesh_generation->unlock();
+
return navmesh;
}
@@ -230,9 +235,10 @@ void NavigationPolygon::clear_outlines() {
}
void NavigationPolygon::make_polygons_from_outlines() {
- navmesh_generation->lock();
- navmesh.unref();
- navmesh_generation->unlock();
+ {
+ MutexLock lock(navmesh_generation);
+ navmesh.unref();
+ }
List<TriangulatorPoly> in_poly, out_poly;
Vector2 outside_point(-1e10, -1e10);
@@ -362,15 +368,13 @@ void NavigationPolygon::_bind_methods() {
}
NavigationPolygon::NavigationPolygon() :
- rect_cache_dirty(true),
- navmesh_generation(Mutex::create()) {
+ rect_cache_dirty(true) {
}
NavigationPolygon::~NavigationPolygon() {
- memdelete(navmesh_generation);
}
-void NavigationPolygonInstance::set_enabled(bool p_enabled) {
+void NavigationRegion2D::set_enabled(bool p_enabled) {
if (enabled == p_enabled)
return;
@@ -394,25 +398,25 @@ void NavigationPolygonInstance::set_enabled(bool p_enabled) {
update();
}
-bool NavigationPolygonInstance::is_enabled() const {
+bool NavigationRegion2D::is_enabled() const {
return enabled;
}
/////////////////////////////
#ifdef TOOLS_ENABLED
-Rect2 NavigationPolygonInstance::_edit_get_rect() const {
+Rect2 NavigationRegion2D::_edit_get_rect() const {
return navpoly.is_valid() ? navpoly->_edit_get_rect() : Rect2();
}
-bool NavigationPolygonInstance::_edit_is_selected_on_click(const Point2 &p_point, double p_tolerance) const {
+bool NavigationRegion2D::_edit_is_selected_on_click(const Point2 &p_point, double p_tolerance) const {
return navpoly.is_valid() ? navpoly->_edit_is_selected_on_click(p_point, p_tolerance) : false;
}
#endif
-void NavigationPolygonInstance::_notification(int p_what) {
+void NavigationRegion2D::_notification(int p_what) {
switch (p_what) {
case NOTIFICATION_ENTER_TREE: {
@@ -496,7 +500,7 @@ void NavigationPolygonInstance::_notification(int p_what) {
}
}
-void NavigationPolygonInstance::set_navigation_polygon(const Ref<NavigationPolygon> &p_navpoly) {
+void NavigationRegion2D::set_navigation_polygon(const Ref<NavigationPolygon> &p_navpoly) {
if (p_navpoly == navpoly) {
return;
@@ -518,18 +522,18 @@ void NavigationPolygonInstance::set_navigation_polygon(const Ref<NavigationPolyg
update_configuration_warning();
}
-Ref<NavigationPolygon> NavigationPolygonInstance::get_navigation_polygon() const {
+Ref<NavigationPolygon> NavigationRegion2D::get_navigation_polygon() const {
return navpoly;
}
-void NavigationPolygonInstance::_navpoly_changed() {
+void NavigationRegion2D::_navpoly_changed() {
if (is_inside_tree() && (Engine::get_singleton()->is_editor_hint() || get_tree()->is_debugging_navigation_hint()))
update();
}
-String NavigationPolygonInstance::get_configuration_warning() const {
+String NavigationRegion2D::get_configuration_warning() const {
if (!is_visible_in_tree() || !is_inside_tree())
return String();
@@ -547,24 +551,24 @@ String NavigationPolygonInstance::get_configuration_warning() const {
c = Object::cast_to<Node2D>(c->get_parent());
}
- return TTR("NavigationPolygonInstance must be a child or grandchild to a Navigation2D node. It only provides navigation data.");
+ return TTR("NavigationRegion2D must be a child or grandchild to a Navigation2D node. It only provides navigation data.");
}
-void NavigationPolygonInstance::_bind_methods() {
+void NavigationRegion2D::_bind_methods() {
- ClassDB::bind_method(D_METHOD("set_navigation_polygon", "navpoly"), &NavigationPolygonInstance::set_navigation_polygon);
- ClassDB::bind_method(D_METHOD("get_navigation_polygon"), &NavigationPolygonInstance::get_navigation_polygon);
+ ClassDB::bind_method(D_METHOD("set_navigation_polygon", "navpoly"), &NavigationRegion2D::set_navigation_polygon);
+ ClassDB::bind_method(D_METHOD("get_navigation_polygon"), &NavigationRegion2D::get_navigation_polygon);
- ClassDB::bind_method(D_METHOD("set_enabled", "enabled"), &NavigationPolygonInstance::set_enabled);
- ClassDB::bind_method(D_METHOD("is_enabled"), &NavigationPolygonInstance::is_enabled);
+ ClassDB::bind_method(D_METHOD("set_enabled", "enabled"), &NavigationRegion2D::set_enabled);
+ ClassDB::bind_method(D_METHOD("is_enabled"), &NavigationRegion2D::is_enabled);
- ClassDB::bind_method(D_METHOD("_navpoly_changed"), &NavigationPolygonInstance::_navpoly_changed);
+ ClassDB::bind_method(D_METHOD("_navpoly_changed"), &NavigationRegion2D::_navpoly_changed);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "navpoly", PROPERTY_HINT_RESOURCE_TYPE, "NavigationPolygon"), "set_navigation_polygon", "get_navigation_polygon");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "enabled"), "set_enabled", "is_enabled");
}
-NavigationPolygonInstance::NavigationPolygonInstance() {
+NavigationRegion2D::NavigationRegion2D() {
enabled = true;
set_notify_transform(true);
@@ -573,6 +577,6 @@ NavigationPolygonInstance::NavigationPolygonInstance() {
navigation = NULL;
}
-NavigationPolygonInstance::~NavigationPolygonInstance() {
+NavigationRegion2D::~NavigationRegion2D() {
Navigation2DServer::get_singleton()->free(region);
}
diff --git a/scene/2d/navigation_polygon.h b/scene/2d/navigation_polygon.h
index 557ce4b3e7..579d6b0e0e 100644
--- a/scene/2d/navigation_polygon.h
+++ b/scene/2d/navigation_polygon.h
@@ -34,8 +34,6 @@
#include "scene/2d/node_2d.h"
#include "scene/resources/navigation_mesh.h"
-class Mutex;
-
class NavigationPolygon : public Resource {
GDCLASS(NavigationPolygon, Resource);
@@ -50,7 +48,7 @@ class NavigationPolygon : public Resource {
mutable Rect2 item_rect;
mutable bool rect_cache_dirty;
- Mutex *navmesh_generation;
+ Mutex navmesh_generation;
// Navigation mesh
Ref<NavigationMesh> navmesh;
@@ -96,9 +94,9 @@ public:
class Navigation2D;
-class NavigationPolygonInstance : public Node2D {
+class NavigationRegion2D : public Node2D {
- GDCLASS(NavigationPolygonInstance, Node2D);
+ GDCLASS(NavigationRegion2D, Node2D);
bool enabled;
RID region;
@@ -125,8 +123,8 @@ public:
String get_configuration_warning() const;
- NavigationPolygonInstance();
- ~NavigationPolygonInstance();
+ NavigationRegion2D();
+ ~NavigationRegion2D();
};
#endif // NAVIGATIONPOLYGON_H
diff --git a/scene/3d/collision_shape.cpp b/scene/3d/collision_shape.cpp
index d0d775d557..c7a92b66e1 100644
--- a/scene/3d/collision_shape.cpp
+++ b/scene/3d/collision_shape.cpp
@@ -33,9 +33,9 @@
#include "scene/resources/capsule_shape.h"
#include "scene/resources/concave_polygon_shape.h"
#include "scene/resources/convex_polygon_shape.h"
-#include "scene/resources/plane_shape.h"
#include "scene/resources/ray_shape.h"
#include "scene/resources/sphere_shape.h"
+#include "scene/resources/world_margin_shape.h"
#include "servers/visual_server.h"
//TODO: Implement CylinderShape and HeightMapShape?
#include "core/math/quick_hull.h"
@@ -123,10 +123,6 @@ String CollisionShape::get_configuration_warning() const {
return TTR("A shape must be provided for CollisionShape to function. Please create a shape resource for it.");
}
- if (shape->is_class("PlaneShape")) {
- return TTR("Plane shapes don't work well and will be removed in future versions. Please don't use them.");
- }
-
return String();
}
diff --git a/scene/3d/cpu_particles.cpp b/scene/3d/cpu_particles.cpp
index cddbe4bbbb..eefda96caa 100644
--- a/scene/3d/cpu_particles.cpp
+++ b/scene/3d/cpu_particles.cpp
@@ -1017,140 +1017,125 @@ void CPUParticles::_particles_process(float p_delta) {
}
void CPUParticles::_update_particle_data_buffer() {
-#ifndef NO_THREADS
- update_mutex->lock();
-#endif
+ MutexLock lock(update_mutex);
- {
+ int pc = particles.size();
- int pc = particles.size();
+ int *ow;
+ int *order = NULL;
- int *ow;
- int *order = NULL;
+ float *w = particle_data.ptrw();
+ const Particle *r = particles.ptr();
+ float *ptr = w;
- float *w = particle_data.ptrw();
- const Particle *r = particles.ptr();
- float *ptr = w;
+ if (draw_order != DRAW_ORDER_INDEX) {
+ ow = particle_order.ptrw();
+ order = ow;
- if (draw_order != DRAW_ORDER_INDEX) {
- ow = particle_order.ptrw();
- order = ow;
+ for (int i = 0; i < pc; i++) {
+ order[i] = i;
+ }
+ if (draw_order == DRAW_ORDER_LIFETIME) {
+ SortArray<int, SortLifetime> sorter;
+ sorter.compare.particles = r;
+ sorter.sort(order, pc);
+ } else if (draw_order == DRAW_ORDER_VIEW_DEPTH) {
+ Camera *c = get_viewport()->get_camera();
+ if (c) {
+ Vector3 dir = c->get_global_transform().basis.get_axis(2); //far away to close
+
+ if (local_coords) {
+
+ // will look different from Particles in editor as this is based on the camera in the scenetree
+ // and not the editor camera
+ dir = inv_emission_transform.xform(dir).normalized();
+ } else {
+ dir = dir.normalized();
+ }
- for (int i = 0; i < pc; i++) {
- order[i] = i;
- }
- if (draw_order == DRAW_ORDER_LIFETIME) {
- SortArray<int, SortLifetime> sorter;
+ SortArray<int, SortAxis> sorter;
sorter.compare.particles = r;
+ sorter.compare.axis = dir;
sorter.sort(order, pc);
- } else if (draw_order == DRAW_ORDER_VIEW_DEPTH) {
- Camera *c = get_viewport()->get_camera();
- if (c) {
- Vector3 dir = c->get_global_transform().basis.get_axis(2); //far away to close
-
- if (local_coords) {
-
- // will look different from Particles in editor as this is based on the camera in the scenetree
- // and not the editor camera
- dir = inv_emission_transform.xform(dir).normalized();
- } else {
- dir = dir.normalized();
- }
-
- SortArray<int, SortAxis> sorter;
- sorter.compare.particles = r;
- sorter.compare.axis = dir;
- sorter.sort(order, pc);
- }
}
}
+ }
- for (int i = 0; i < pc; i++) {
-
- int idx = order ? order[i] : i;
+ for (int i = 0; i < pc; i++) {
- Transform t = r[idx].transform;
+ int idx = order ? order[i] : i;
- if (!local_coords) {
- t = inv_emission_transform * t;
- }
+ Transform t = r[idx].transform;
- if (r[idx].active) {
- ptr[0] = t.basis.elements[0][0];
- ptr[1] = t.basis.elements[0][1];
- ptr[2] = t.basis.elements[0][2];
- ptr[3] = t.origin.x;
- ptr[4] = t.basis.elements[1][0];
- ptr[5] = t.basis.elements[1][1];
- ptr[6] = t.basis.elements[1][2];
- ptr[7] = t.origin.y;
- ptr[8] = t.basis.elements[2][0];
- ptr[9] = t.basis.elements[2][1];
- ptr[10] = t.basis.elements[2][2];
- ptr[11] = t.origin.z;
- } else {
- zeromem(ptr, sizeof(float) * 12);
- }
+ if (!local_coords) {
+ t = inv_emission_transform * t;
+ }
- Color c = r[idx].color;
+ if (r[idx].active) {
+ ptr[0] = t.basis.elements[0][0];
+ ptr[1] = t.basis.elements[0][1];
+ ptr[2] = t.basis.elements[0][2];
+ ptr[3] = t.origin.x;
+ ptr[4] = t.basis.elements[1][0];
+ ptr[5] = t.basis.elements[1][1];
+ ptr[6] = t.basis.elements[1][2];
+ ptr[7] = t.origin.y;
+ ptr[8] = t.basis.elements[2][0];
+ ptr[9] = t.basis.elements[2][1];
+ ptr[10] = t.basis.elements[2][2];
+ ptr[11] = t.origin.z;
+ } else {
+ zeromem(ptr, sizeof(float) * 12);
+ }
- ptr[12] = c.r;
- ptr[13] = c.g;
- ptr[14] = c.b;
- ptr[15] = c.a;
+ Color c = r[idx].color;
- ptr[16] = r[idx].custom[0];
- ptr[17] = r[idx].custom[1];
- ptr[18] = r[idx].custom[2];
- ptr[19] = r[idx].custom[3];
+ ptr[12] = c.r;
+ ptr[13] = c.g;
+ ptr[14] = c.b;
+ ptr[15] = c.a;
- ptr += 20;
- }
+ ptr[16] = r[idx].custom[0];
+ ptr[17] = r[idx].custom[1];
+ ptr[18] = r[idx].custom[2];
+ ptr[19] = r[idx].custom[3];
- can_update = true;
+ ptr += 20;
}
-#ifndef NO_THREADS
- update_mutex->unlock();
-#endif
+ can_update = true;
}
void CPUParticles::_set_redraw(bool p_redraw) {
if (redraw == p_redraw)
return;
redraw = p_redraw;
-#ifndef NO_THREADS
- update_mutex->lock();
-#endif
- if (redraw) {
- VS::get_singleton()->connect_compat("frame_pre_draw", this, "_update_render_thread");
- VS::get_singleton()->instance_geometry_set_flag(get_instance(), VS::INSTANCE_FLAG_DRAW_NEXT_FRAME_IF_VISIBLE, true);
- VS::get_singleton()->multimesh_set_visible_instances(multimesh, -1);
- } else {
- if (VS::get_singleton()->is_connected_compat("frame_pre_draw", this, "_update_render_thread")) {
- VS::get_singleton()->disconnect_compat("frame_pre_draw", this, "_update_render_thread");
+
+ {
+ MutexLock lock(update_mutex);
+
+ if (redraw) {
+ VS::get_singleton()->connect_compat("frame_pre_draw", this, "_update_render_thread");
+ VS::get_singleton()->instance_geometry_set_flag(get_instance(), VS::INSTANCE_FLAG_DRAW_NEXT_FRAME_IF_VISIBLE, true);
+ VS::get_singleton()->multimesh_set_visible_instances(multimesh, -1);
+ } else {
+ if (VS::get_singleton()->is_connected_compat("frame_pre_draw", this, "_update_render_thread")) {
+ VS::get_singleton()->disconnect_compat("frame_pre_draw", this, "_update_render_thread");
+ }
+ VS::get_singleton()->instance_geometry_set_flag(get_instance(), VS::INSTANCE_FLAG_DRAW_NEXT_FRAME_IF_VISIBLE, false);
+ VS::get_singleton()->multimesh_set_visible_instances(multimesh, 0);
}
- VS::get_singleton()->instance_geometry_set_flag(get_instance(), VS::INSTANCE_FLAG_DRAW_NEXT_FRAME_IF_VISIBLE, false);
- VS::get_singleton()->multimesh_set_visible_instances(multimesh, 0);
}
-#ifndef NO_THREADS
- update_mutex->unlock();
-#endif
}
void CPUParticles::_update_render_thread() {
-#ifndef NO_THREADS
- update_mutex->lock();
-#endif
+ MutexLock lock(update_mutex);
+
if (can_update) {
VS::get_singleton()->multimesh_set_buffer(multimesh, particle_data);
can_update = false; //wait for next time
}
-
-#ifndef NO_THREADS
- update_mutex->unlock();
-#endif
}
void CPUParticles::_notification(int p_what) {
@@ -1556,16 +1541,8 @@ CPUParticles::CPUParticles() {
can_update = false;
set_color(Color(1, 1, 1, 1));
-
-#ifndef NO_THREADS
- update_mutex = Mutex::create();
-#endif
}
CPUParticles::~CPUParticles() {
VS::get_singleton()->free(multimesh);
-
-#ifndef NO_THREADS
- memdelete(update_mutex);
-#endif
}
diff --git a/scene/3d/cpu_particles.h b/scene/3d/cpu_particles.h
index 1a5537e4f2..231e1f1ad9 100644
--- a/scene/3d/cpu_particles.h
+++ b/scene/3d/cpu_particles.h
@@ -178,7 +178,7 @@ private:
void _particles_process(float p_delta);
void _update_particle_data_buffer();
- Mutex *update_mutex;
+ Mutex update_mutex;
void _update_render_thread();
diff --git a/scene/3d/navigation.h b/scene/3d/navigation.h
index 85887651ff..08f306611f 100644
--- a/scene/3d/navigation.h
+++ b/scene/3d/navigation.h
@@ -31,7 +31,7 @@
#ifndef NAVIGATION_H
#define NAVIGATION_H
-#include "scene/3d/navigation_mesh_instance.h"
+#include "scene/3d/navigation_region.h"
#include "scene/3d/spatial.h"
class Navigation : public Spatial {
diff --git a/scene/3d/navigation_mesh_instance.cpp b/scene/3d/navigation_region.cpp
index 8f8574ba2d..d96d095797 100644
--- a/scene/3d/navigation_mesh_instance.cpp
+++ b/scene/3d/navigation_region.cpp
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* navigation_mesh_instance.cpp */
+/* navigation_region.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -28,13 +28,13 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#include "navigation_mesh_instance.h"
+#include "navigation_region.h"
#include "core/os/thread.h"
#include "mesh_instance.h"
#include "navigation.h"
#include "servers/navigation_server.h"
-void NavigationMeshInstance::set_enabled(bool p_enabled) {
+void NavigationRegion::set_enabled(bool p_enabled) {
if (enabled == p_enabled)
return;
@@ -66,14 +66,14 @@ void NavigationMeshInstance::set_enabled(bool p_enabled) {
update_gizmo();
}
-bool NavigationMeshInstance::is_enabled() const {
+bool NavigationRegion::is_enabled() const {
return enabled;
}
/////////////////////////////
-void NavigationMeshInstance::_notification(int p_what) {
+void NavigationRegion::_notification(int p_what) {
switch (p_what) {
case NOTIFICATION_ENTER_TREE: {
@@ -129,7 +129,7 @@ void NavigationMeshInstance::_notification(int p_what) {
}
}
-void NavigationMeshInstance::set_navigation_mesh(const Ref<NavigationMesh> &p_navmesh) {
+void NavigationRegion::set_navigation_mesh(const Ref<NavigationMesh> &p_navmesh) {
if (p_navmesh == navmesh)
return;
@@ -156,13 +156,13 @@ void NavigationMeshInstance::set_navigation_mesh(const Ref<NavigationMesh> &p_na
update_configuration_warning();
}
-Ref<NavigationMesh> NavigationMeshInstance::get_navigation_mesh() const {
+Ref<NavigationMesh> NavigationRegion::get_navigation_mesh() const {
return navmesh;
}
struct BakeThreadsArgs {
- NavigationMeshInstance *nav_mesh_instance;
+ NavigationRegion *nav_mesh_instance;
};
void _bake_navigation_mesh(void *p_user_data) {
@@ -182,7 +182,7 @@ void _bake_navigation_mesh(void *p_user_data) {
}
}
-void NavigationMeshInstance::bake_navigation_mesh() {
+void NavigationRegion::bake_navigation_mesh() {
ERR_FAIL_COND(bake_thread != NULL);
BakeThreadsArgs *args = memnew(BakeThreadsArgs);
@@ -192,12 +192,12 @@ void NavigationMeshInstance::bake_navigation_mesh() {
ERR_FAIL_COND(bake_thread == NULL);
}
-void NavigationMeshInstance::_bake_finished(Ref<NavigationMesh> p_nav_mesh) {
+void NavigationRegion::_bake_finished(Ref<NavigationMesh> p_nav_mesh) {
set_navigation_mesh(p_nav_mesh);
bake_thread = NULL;
}
-String NavigationMeshInstance::get_configuration_warning() const {
+String NavigationRegion::get_configuration_warning() const {
if (!is_visible_in_tree() || !is_inside_tree())
return String();
@@ -214,19 +214,19 @@ String NavigationMeshInstance::get_configuration_warning() const {
c = Object::cast_to<Spatial>(c->get_parent());
}
- return TTR("NavigationMeshInstance must be a child or grandchild to a Navigation node. It only provides navigation data.");
+ return TTR("NavigationRegion must be a child or grandchild to a Navigation node. It only provides navigation data.");
}
-void NavigationMeshInstance::_bind_methods() {
+void NavigationRegion::_bind_methods() {
- ClassDB::bind_method(D_METHOD("set_navigation_mesh", "navmesh"), &NavigationMeshInstance::set_navigation_mesh);
- ClassDB::bind_method(D_METHOD("get_navigation_mesh"), &NavigationMeshInstance::get_navigation_mesh);
+ ClassDB::bind_method(D_METHOD("set_navigation_mesh", "navmesh"), &NavigationRegion::set_navigation_mesh);
+ ClassDB::bind_method(D_METHOD("get_navigation_mesh"), &NavigationRegion::get_navigation_mesh);
- ClassDB::bind_method(D_METHOD("set_enabled", "enabled"), &NavigationMeshInstance::set_enabled);
- ClassDB::bind_method(D_METHOD("is_enabled"), &NavigationMeshInstance::is_enabled);
+ ClassDB::bind_method(D_METHOD("set_enabled", "enabled"), &NavigationRegion::set_enabled);
+ ClassDB::bind_method(D_METHOD("is_enabled"), &NavigationRegion::is_enabled);
- ClassDB::bind_method(D_METHOD("bake_navigation_mesh"), &NavigationMeshInstance::bake_navigation_mesh);
- ClassDB::bind_method(D_METHOD("_bake_finished", "nav_mesh"), &NavigationMeshInstance::_bake_finished);
+ ClassDB::bind_method(D_METHOD("bake_navigation_mesh"), &NavigationRegion::bake_navigation_mesh);
+ ClassDB::bind_method(D_METHOD("_bake_finished", "nav_mesh"), &NavigationRegion::_bake_finished);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "navmesh", PROPERTY_HINT_RESOURCE_TYPE, "NavigationMesh"), "set_navigation_mesh", "get_navigation_mesh");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "enabled"), "set_enabled", "is_enabled");
@@ -235,12 +235,12 @@ void NavigationMeshInstance::_bind_methods() {
ADD_SIGNAL(MethodInfo("bake_finished"));
}
-void NavigationMeshInstance::_changed_callback(Object *p_changed, const char *p_prop) {
+void NavigationRegion::_changed_callback(Object *p_changed, const char *p_prop) {
update_gizmo();
update_configuration_warning();
}
-NavigationMeshInstance::NavigationMeshInstance() {
+NavigationRegion::NavigationRegion() {
enabled = true;
set_notify_transform(true);
@@ -251,7 +251,7 @@ NavigationMeshInstance::NavigationMeshInstance() {
bake_thread = NULL;
}
-NavigationMeshInstance::~NavigationMeshInstance() {
+NavigationRegion::~NavigationRegion() {
if (navmesh.is_valid())
navmesh->remove_change_receptor(this);
NavigationServer::get_singleton()->free(region);
diff --git a/scene/3d/navigation_mesh_instance.h b/scene/3d/navigation_region.h
index 1135bf47d2..f215e92c97 100644
--- a/scene/3d/navigation_mesh_instance.h
+++ b/scene/3d/navigation_region.h
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* navigation_mesh_instance.h */
+/* navigation_region.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -28,8 +28,8 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#ifndef NAVIGATION_MESH_INSTANCE_H
-#define NAVIGATION_MESH_INSTANCE_H
+#ifndef NAVIGATION_REGION_H
+#define NAVIGATION_REGION_H
#include "scene/3d/spatial.h"
#include "scene/resources/mesh.h"
@@ -37,9 +37,9 @@
class Navigation;
-class NavigationMeshInstance : public Spatial {
+class NavigationRegion : public Spatial {
- GDCLASS(NavigationMeshInstance, Spatial);
+ GDCLASS(NavigationRegion, Spatial);
bool enabled;
RID region;
@@ -68,8 +68,8 @@ public:
String get_configuration_warning() const;
- NavigationMeshInstance();
- ~NavigationMeshInstance();
+ NavigationRegion();
+ ~NavigationRegion();
};
-#endif // NAVIGATION_MESH_INSTANCE_H
+#endif // NAVIGATION_REGION_H
diff --git a/scene/gui/tab_container.cpp b/scene/gui/tab_container.cpp
index 66ecbea378..b3c4e3fa3c 100644
--- a/scene/gui/tab_container.cpp
+++ b/scene/gui/tab_container.cpp
@@ -538,7 +538,7 @@ void TabContainer::add_child_notify(Node *p_child) {
update();
p_child->connect_compat("renamed", this, "_child_renamed_callback");
- if (first)
+ if (first && is_inside_tree())
emit_signal("tab_changed", current);
}
diff --git a/scene/gui/text_edit.cpp b/scene/gui/text_edit.cpp
index 2fd1ba5535..379e70b951 100644
--- a/scene/gui/text_edit.cpp
+++ b/scene/gui/text_edit.cpp
@@ -753,10 +753,18 @@ void TextEdit::_notification(int p_what) {
}
}
- if (line_length_guideline) {
- int x = xmargin_beg + (int)cache.font->get_char_size('0').width * line_length_guideline_col - cursor.x_ofs;
- if (x > xmargin_beg && x < xmargin_end) {
- VisualServer::get_singleton()->canvas_item_add_line(ci, Point2(x, 0), Point2(x, size.height), cache.line_length_guideline_color);
+ if (line_length_guidelines) {
+ const int hard_x = xmargin_beg + (int)cache.font->get_char_size('0').width * line_length_guideline_hard_col - cursor.x_ofs;
+ if (hard_x > xmargin_beg && hard_x < xmargin_end) {
+ VisualServer::get_singleton()->canvas_item_add_line(ci, Point2(hard_x, 0), Point2(hard_x, size.height), cache.line_length_guideline_color);
+ }
+
+ // Draw a "Soft" line length guideline, less visible than the hard line length guideline.
+ // It's usually set to a lower column compared to the hard line length guideline.
+ // Only drawn if its column differs from the hard line length guideline.
+ const int soft_x = xmargin_beg + (int)cache.font->get_char_size('0').width * line_length_guideline_soft_col - cursor.x_ofs;
+ if (hard_x != soft_x && soft_x > xmargin_beg && soft_x < xmargin_end) {
+ VisualServer::get_singleton()->canvas_item_add_line(ci, Point2(soft_x, 0), Point2(soft_x, size.height), cache.line_length_guideline_color * Color(1, 1, 1, 0.5));
}
}
@@ -6834,13 +6842,18 @@ bool TextEdit::is_show_line_numbers_enabled() const {
return line_numbers;
}
-void TextEdit::set_show_line_length_guideline(bool p_show) {
- line_length_guideline = p_show;
+void TextEdit::set_show_line_length_guidelines(bool p_show) {
+ line_length_guidelines = p_show;
+ update();
+}
+
+void TextEdit::set_line_length_guideline_soft_column(int p_column) {
+ line_length_guideline_soft_col = p_column;
update();
}
-void TextEdit::set_line_length_guideline_column(int p_column) {
- line_length_guideline_col = p_column;
+void TextEdit::set_line_length_guideline_hard_column(int p_column) {
+ line_length_guideline_hard_col = p_column;
update();
}
@@ -7309,8 +7322,9 @@ TextEdit::TextEdit() {
tooltip_obj = NULL;
line_numbers = false;
line_numbers_zero_padded = false;
- line_length_guideline = false;
- line_length_guideline_col = 80;
+ line_length_guidelines = false;
+ line_length_guideline_soft_col = 80;
+ line_length_guideline_hard_col = 100;
draw_bookmark_gutter = false;
draw_breakpoint_gutter = false;
draw_fold_gutter = false;
diff --git a/scene/gui/text_edit.h b/scene/gui/text_edit.h
index 9986b80fd5..6e267f5a47 100644
--- a/scene/gui/text_edit.h
+++ b/scene/gui/text_edit.h
@@ -369,8 +369,9 @@ private:
bool undo_enabled;
bool line_numbers;
bool line_numbers_zero_padded;
- bool line_length_guideline;
- int line_length_guideline_col;
+ bool line_length_guidelines;
+ int line_length_guideline_soft_col;
+ int line_length_guideline_hard_col;
bool draw_bookmark_gutter;
bool draw_breakpoint_gutter;
int breakpoint_gutter_width;
@@ -765,8 +766,9 @@ public:
void set_line_numbers_zero_padded(bool p_zero_padded);
- void set_show_line_length_guideline(bool p_show);
- void set_line_length_guideline_column(int p_column);
+ void set_show_line_length_guidelines(bool p_show);
+ void set_line_length_guideline_soft_column(int p_column);
+ void set_line_length_guideline_hard_column(int p_column);
void set_bookmark_gutter_enabled(bool p_draw);
bool is_bookmark_gutter_enabled() const;
diff --git a/scene/main/node.cpp b/scene/main/node.cpp
index 5baa59fe7c..a0159c3858 100644
--- a/scene/main/node.cpp
+++ b/scene/main/node.cpp
@@ -2800,7 +2800,7 @@ void Node::_bind_methods() {
GLOBAL_DEF("node/name_casing", NAME_CASING_PASCAL_CASE);
ProjectSettings::get_singleton()->set_custom_property_info("node/name_casing", PropertyInfo(Variant::INT, "node/name_casing", PROPERTY_HINT_ENUM, "PascalCase,camelCase,snake_case"));
- ClassDB::bind_method(D_METHOD("add_child_below_node", "node", "child_node", "legible_unique_name"), &Node::add_child_below_node, DEFVAL(false));
+ ClassDB::bind_method(D_METHOD("add_child_below_node", "preceding_node", "node", "legible_unique_name"), &Node::add_child_below_node, DEFVAL(false));
ClassDB::bind_method(D_METHOD("set_name", "name"), &Node::set_name);
ClassDB::bind_method(D_METHOD("get_name"), &Node::get_name);
diff --git a/scene/register_scene_types.cpp b/scene/register_scene_types.cpp
index 6288598ce2..dd00565929 100644
--- a/scene/register_scene_types.cpp
+++ b/scene/register_scene_types.cpp
@@ -151,7 +151,6 @@
#include "scene/resources/packed_scene.h"
#include "scene/resources/particles_material.h"
#include "scene/resources/physics_material.h"
-#include "scene/resources/plane_shape.h"
#include "scene/resources/polygon_path_finder.h"
#include "scene/resources/primitive_meshes.h"
#include "scene/resources/ray_shape.h"
@@ -169,6 +168,7 @@
#include "scene/resources/visual_shader_nodes.h"
#include "scene/resources/world.h"
#include "scene/resources/world_2d.h"
+#include "scene/resources/world_margin_shape.h"
#include "scene/scene_string_names.h"
#ifndef _3D_DISABLED
@@ -190,8 +190,8 @@
#include "scene/3d/multimesh_instance.h"
#include "scene/3d/navigation.h"
#include "scene/3d/navigation_agent.h"
-#include "scene/3d/navigation_mesh_instance.h"
#include "scene/3d/navigation_obstacle.h"
+#include "scene/3d/navigation_region.h"
#include "scene/3d/particles.h"
#include "scene/3d/path.h"
#include "scene/3d/physics_body.h"
@@ -470,7 +470,7 @@ void register_scene_types() {
ClassDB::register_class<Generic6DOFJoint>();
ClassDB::register_class<Navigation>();
- ClassDB::register_class<NavigationMeshInstance>();
+ ClassDB::register_class<NavigationRegion>();
ClassDB::register_class<NavigationAgent>();
ClassDB::register_class<NavigationObstacle>();
@@ -643,7 +643,7 @@ void register_scene_types() {
ClassDB::register_class<CapsuleShape>();
ClassDB::register_class<CylinderShape>();
ClassDB::register_class<HeightMapShape>();
- ClassDB::register_class<PlaneShape>();
+ ClassDB::register_class<WorldMarginShape>();
ClassDB::register_class<ConvexPolygonShape>();
ClassDB::register_class<ConcavePolygonShape>();
@@ -726,7 +726,7 @@ void register_scene_types() {
ClassDB::register_class<Navigation2D>();
ClassDB::register_class<NavigationPolygon>();
- ClassDB::register_class<NavigationPolygonInstance>();
+ ClassDB::register_class<NavigationRegion2D>();
ClassDB::register_class<NavigationAgent2D>();
ClassDB::register_class<NavigationObstacle2D>();
@@ -746,6 +746,9 @@ void register_scene_types() {
ClassDB::add_compatibility_class("VisualShaderNodeScalarUniform", "VisualShaderNodeFloatUniform");
ClassDB::add_compatibility_class("VisualShaderNodeScalarOp", "VisualShaderNodeFloatOp");
ClassDB::add_compatibility_class("VisualShaderNodeScalarFunc", "VisualShaderNodeFloatFunc");
+ ClassDB::add_compatibility_class("NavigationMeshInstance", "NavigationRegion");
+ ClassDB::add_compatibility_class("NavigationPolygonInstance", "NavigationRegion2D");
+ ClassDB::add_compatibility_class("PlaneShape", "WorldMarginShape");
#endif
OS::get_singleton()->yield(); //may take time to init
diff --git a/scene/resources/dynamic_font.cpp b/scene/resources/dynamic_font.cpp
index 79a1500129..fc53dfe376 100644
--- a/scene/resources/dynamic_font.cpp
+++ b/scene/resources/dynamic_font.cpp
@@ -990,7 +990,7 @@ void DynamicFont::_bind_methods() {
BIND_ENUM_CONSTANT(SPACING_SPACE);
}
-Mutex *DynamicFont::dynamic_font_mutex = NULL;
+Mutex DynamicFont::dynamic_font_mutex;
SelfList<DynamicFont>::List *DynamicFont::dynamic_fonts = NULL;
@@ -1004,29 +1004,21 @@ DynamicFont::DynamicFont() :
spacing_char = 0;
spacing_space = 0;
outline_color = Color(1, 1, 1);
- if (dynamic_font_mutex) {
- dynamic_font_mutex->lock();
- dynamic_fonts->add(&font_list);
- dynamic_font_mutex->unlock();
- }
+
+ MutexLock lock(dynamic_font_mutex);
+ dynamic_fonts->add(&font_list);
}
DynamicFont::~DynamicFont() {
- if (dynamic_font_mutex) {
- dynamic_font_mutex->lock();
- dynamic_fonts->remove(&font_list);
- dynamic_font_mutex->unlock();
- }
+ MutexLock lock(dynamic_font_mutex);
+ dynamic_fonts->remove(&font_list);
}
void DynamicFont::initialize_dynamic_fonts() {
dynamic_fonts = memnew(SelfList<DynamicFont>::List());
- dynamic_font_mutex = Mutex::create();
}
void DynamicFont::finish_dynamic_fonts() {
- memdelete(dynamic_font_mutex);
- dynamic_font_mutex = NULL;
memdelete(dynamic_fonts);
dynamic_fonts = NULL;
}
@@ -1034,39 +1026,36 @@ void DynamicFont::finish_dynamic_fonts() {
void DynamicFont::update_oversampling() {
Vector<Ref<DynamicFont> > changed;
+ {
+ MutexLock lock(dynamic_font_mutex);
- if (dynamic_font_mutex)
- dynamic_font_mutex->lock();
-
- SelfList<DynamicFont> *E = dynamic_fonts->first();
- while (E) {
+ SelfList<DynamicFont> *E = dynamic_fonts->first();
+ while (E) {
- if (E->self()->data_at_size.is_valid()) {
- E->self()->data_at_size->update_oversampling();
+ if (E->self()->data_at_size.is_valid()) {
+ E->self()->data_at_size->update_oversampling();
- if (E->self()->outline_data_at_size.is_valid()) {
- E->self()->outline_data_at_size->update_oversampling();
- }
+ if (E->self()->outline_data_at_size.is_valid()) {
+ E->self()->outline_data_at_size->update_oversampling();
+ }
- for (int i = 0; i < E->self()->fallback_data_at_size.size(); i++) {
- if (E->self()->fallback_data_at_size[i].is_valid()) {
- E->self()->fallback_data_at_size.write[i]->update_oversampling();
+ for (int i = 0; i < E->self()->fallback_data_at_size.size(); i++) {
+ if (E->self()->fallback_data_at_size[i].is_valid()) {
+ E->self()->fallback_data_at_size.write[i]->update_oversampling();
- if (E->self()->has_outline() && E->self()->fallback_outline_data_at_size[i].is_valid()) {
- E->self()->fallback_outline_data_at_size.write[i]->update_oversampling();
+ if (E->self()->has_outline() && E->self()->fallback_outline_data_at_size[i].is_valid()) {
+ E->self()->fallback_outline_data_at_size.write[i]->update_oversampling();
+ }
}
}
+
+ changed.push_back(Ref<DynamicFont>(E->self()));
}
- changed.push_back(Ref<DynamicFont>(E->self()));
+ E = E->next();
}
-
- E = E->next();
}
- if (dynamic_font_mutex)
- dynamic_font_mutex->unlock();
-
for (int i = 0; i < changed.size(); i++) {
changed.write[i]->emit_changed();
}
diff --git a/scene/resources/dynamic_font.h b/scene/resources/dynamic_font.h
index fa6db370f8..6a0b51fb93 100644
--- a/scene/resources/dynamic_font.h
+++ b/scene/resources/dynamic_font.h
@@ -285,7 +285,7 @@ public:
SelfList<DynamicFont> font_list;
- static Mutex *dynamic_font_mutex;
+ static Mutex dynamic_font_mutex;
static SelfList<DynamicFont>::List *dynamic_fonts;
static void initialize_dynamic_fonts();
diff --git a/scene/resources/material.cpp b/scene/resources/material.cpp
index ff51cab0a4..54e9067abb 100644
--- a/scene/resources/material.cpp
+++ b/scene/resources/material.cpp
@@ -290,17 +290,13 @@ ShaderMaterial::~ShaderMaterial() {
/////////////////////////////////
-Mutex *BaseMaterial3D::material_mutex = NULL;
+Mutex BaseMaterial3D::material_mutex;
SelfList<BaseMaterial3D>::List *BaseMaterial3D::dirty_materials = NULL;
Map<BaseMaterial3D::MaterialKey, BaseMaterial3D::ShaderData> BaseMaterial3D::shader_map;
BaseMaterial3D::ShaderNames *BaseMaterial3D::shader_names = NULL;
void BaseMaterial3D::init_shaders() {
-#ifndef NO_THREADS
- material_mutex = Mutex::create();
-#endif
-
dirty_materials = memnew(SelfList<BaseMaterial3D>::List);
shader_names = memnew(ShaderNames);
@@ -379,10 +375,6 @@ void BaseMaterial3D::finish_shaders() {
materials_for_2d[i].unref();
}
-#ifndef NO_THREADS
- memdelete(material_mutex);
-#endif
-
memdelete(dirty_materials);
dirty_materials = NULL;
@@ -1133,44 +1125,28 @@ void BaseMaterial3D::_update_shader() {
void BaseMaterial3D::flush_changes() {
- if (material_mutex)
- material_mutex->lock();
+ MutexLock lock(material_mutex);
while (dirty_materials->first()) {
dirty_materials->first()->self()->_update_shader();
}
-
- if (material_mutex)
- material_mutex->unlock();
}
void BaseMaterial3D::_queue_shader_change() {
- if (material_mutex)
- material_mutex->lock();
+ MutexLock lock(material_mutex);
if (!element.in_list()) {
dirty_materials->add(&element);
}
-
- if (material_mutex)
- material_mutex->unlock();
}
bool BaseMaterial3D::_is_shader_dirty() const {
- bool dirty = false;
-
- if (material_mutex)
- material_mutex->lock();
-
- dirty = element.in_list();
+ MutexLock lock(material_mutex);
- if (material_mutex)
- material_mutex->unlock();
-
- return dirty;
+ return element.in_list();
}
void BaseMaterial3D::set_albedo(const Color &p_albedo) {
@@ -2580,8 +2556,7 @@ BaseMaterial3D::BaseMaterial3D(bool p_orm) :
BaseMaterial3D::~BaseMaterial3D() {
- if (material_mutex)
- material_mutex->lock();
+ MutexLock lock(material_mutex);
if (shader_map.has(current_key)) {
shader_map[current_key].users--;
@@ -2593,9 +2568,6 @@ BaseMaterial3D::~BaseMaterial3D() {
VS::get_singleton()->material_set_shader(_get_material(), RID());
}
-
- if (material_mutex)
- material_mutex->unlock();
}
//////////////////////
diff --git a/scene/resources/material.h b/scene/resources/material.h
index 927334c74d..fc77226fb9 100644
--- a/scene/resources/material.h
+++ b/scene/resources/material.h
@@ -388,7 +388,7 @@ private:
StringName texture_names[TEXTURE_MAX];
};
- static Mutex *material_mutex;
+ static Mutex material_mutex;
static SelfList<BaseMaterial3D>::List *dirty_materials;
static ShaderNames *shader_names;
diff --git a/scene/resources/mesh_library.cpp b/scene/resources/mesh_library.cpp
index ac016bec5d..fffd192348 100644
--- a/scene/resources/mesh_library.cpp
+++ b/scene/resources/mesh_library.cpp
@@ -29,7 +29,6 @@
/*************************************************************************/
#include "mesh_library.h"
-#include "core/engine.h"
bool MeshLibrary::_set(const StringName &p_name, const Variant &p_value) {
@@ -202,11 +201,6 @@ Transform MeshLibrary::get_item_navmesh_transform(int p_item) const {
Ref<Texture2D> MeshLibrary::get_item_preview(int p_item) const {
- if (!Engine::get_singleton()->is_editor_hint()) {
- ERR_PRINT("MeshLibrary item previews are only generated in an editor context, which means they aren't available in a running project.");
- return Ref<Texture2D>();
- }
-
ERR_FAIL_COND_V_MSG(!item_map.has(p_item), Ref<Texture2D>(), "Requested for nonexistent MeshLibrary item '" + itos(p_item) + "'.");
return item_map[p_item].preview;
}
diff --git a/scene/resources/mesh_library.h b/scene/resources/mesh_library.h
index 9155975f47..b256e86b96 100644
--- a/scene/resources/mesh_library.h
+++ b/scene/resources/mesh_library.h
@@ -34,7 +34,7 @@
#include "core/map.h"
#include "core/resource.h"
#include "mesh.h"
-#include "scene/3d/navigation_mesh_instance.h"
+#include "scene/3d/navigation_region.h"
#include "shape.h"
class MeshLibrary : public Resource {
diff --git a/scene/resources/particles_material.cpp b/scene/resources/particles_material.cpp
index e820aec2ed..f18e8956f1 100644
--- a/scene/resources/particles_material.cpp
+++ b/scene/resources/particles_material.cpp
@@ -30,17 +30,13 @@
#include "particles_material.h"
-Mutex *ParticlesMaterial::material_mutex = NULL;
+Mutex ParticlesMaterial::material_mutex;
SelfList<ParticlesMaterial>::List *ParticlesMaterial::dirty_materials = NULL;
Map<ParticlesMaterial::MaterialKey, ParticlesMaterial::ShaderData> ParticlesMaterial::shader_map;
ParticlesMaterial::ShaderNames *ParticlesMaterial::shader_names = NULL;
void ParticlesMaterial::init_shaders() {
-#ifndef NO_THREADS
- material_mutex = Mutex::create();
-#endif
-
dirty_materials = memnew(SelfList<ParticlesMaterial>::List);
shader_names = memnew(ShaderNames);
@@ -107,10 +103,6 @@ void ParticlesMaterial::init_shaders() {
void ParticlesMaterial::finish_shaders() {
-#ifndef NO_THREADS
- memdelete(material_mutex);
-#endif
-
memdelete(dirty_materials);
dirty_materials = NULL;
@@ -612,44 +604,28 @@ void ParticlesMaterial::_update_shader() {
void ParticlesMaterial::flush_changes() {
- if (material_mutex)
- material_mutex->lock();
+ MutexLock lock(material_mutex);
while (dirty_materials->first()) {
dirty_materials->first()->self()->_update_shader();
}
-
- if (material_mutex)
- material_mutex->unlock();
}
void ParticlesMaterial::_queue_shader_change() {
- if (material_mutex)
- material_mutex->lock();
+ MutexLock lock(material_mutex);
if (!element.in_list()) {
dirty_materials->add(&element);
}
-
- if (material_mutex)
- material_mutex->unlock();
}
bool ParticlesMaterial::_is_shader_dirty() const {
- bool dirty = false;
+ MutexLock lock(material_mutex);
- if (material_mutex)
- material_mutex->lock();
-
- dirty = element.in_list();
-
- if (material_mutex)
- material_mutex->unlock();
-
- return dirty;
+ return element.in_list();
}
void ParticlesMaterial::set_direction(Vector3 p_direction) {
@@ -1298,8 +1274,7 @@ ParticlesMaterial::ParticlesMaterial() :
ParticlesMaterial::~ParticlesMaterial() {
- if (material_mutex)
- material_mutex->lock();
+ MutexLock lock(material_mutex);
if (shader_map.has(current_key)) {
shader_map[current_key].users--;
@@ -1311,7 +1286,4 @@ ParticlesMaterial::~ParticlesMaterial() {
VS::get_singleton()->material_set_shader(_get_material(), RID());
}
-
- if (material_mutex)
- material_mutex->unlock();
}
diff --git a/scene/resources/particles_material.h b/scene/resources/particles_material.h
index 246ce58a21..c6c8316995 100644
--- a/scene/resources/particles_material.h
+++ b/scene/resources/particles_material.h
@@ -126,7 +126,7 @@ private:
return mk;
}
- static Mutex *material_mutex;
+ static Mutex material_mutex;
static SelfList<ParticlesMaterial>::List *dirty_materials;
struct ShaderNames {
diff --git a/scene/resources/plane_shape.cpp b/scene/resources/world_margin_shape.cpp
index ddc820233e..b5b701327c 100644
--- a/scene/resources/plane_shape.cpp
+++ b/scene/resources/world_margin_shape.cpp
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* plane_shape.cpp */
+/* world_margin_shape.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -28,11 +28,11 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#include "plane_shape.h"
+#include "world_margin_shape.h"
#include "servers/physics_server.h"
-Vector<Vector3> PlaneShape::get_debug_mesh_lines() {
+Vector<Vector3> WorldMarginShape::get_debug_mesh_lines() {
Plane p = get_plane();
Vector<Vector3> points;
@@ -61,13 +61,13 @@ Vector<Vector3> PlaneShape::get_debug_mesh_lines() {
return points;
}
-void PlaneShape::_update_shape() {
+void WorldMarginShape::_update_shape() {
PhysicsServer::get_singleton()->shape_set_data(get_shape(), plane);
Shape::_update_shape();
}
-void PlaneShape::set_plane(Plane p_plane) {
+void WorldMarginShape::set_plane(Plane p_plane) {
plane = p_plane;
_update_shape();
@@ -75,20 +75,20 @@ void PlaneShape::set_plane(Plane p_plane) {
_change_notify("plane");
}
-Plane PlaneShape::get_plane() const {
+Plane WorldMarginShape::get_plane() const {
return plane;
}
-void PlaneShape::_bind_methods() {
+void WorldMarginShape::_bind_methods() {
- ClassDB::bind_method(D_METHOD("set_plane", "plane"), &PlaneShape::set_plane);
- ClassDB::bind_method(D_METHOD("get_plane"), &PlaneShape::get_plane);
+ ClassDB::bind_method(D_METHOD("set_plane", "plane"), &WorldMarginShape::set_plane);
+ ClassDB::bind_method(D_METHOD("get_plane"), &WorldMarginShape::get_plane);
ADD_PROPERTY(PropertyInfo(Variant::PLANE, "plane"), "set_plane", "get_plane");
}
-PlaneShape::PlaneShape() :
+WorldMarginShape::WorldMarginShape() :
Shape(PhysicsServer::get_singleton()->shape_create(PhysicsServer::SHAPE_PLANE)) {
set_plane(Plane(0, 1, 0, 0));
diff --git a/scene/resources/plane_shape.h b/scene/resources/world_margin_shape.h
index 360f9dbbe9..78ea570212 100644
--- a/scene/resources/plane_shape.h
+++ b/scene/resources/world_margin_shape.h
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* plane_shape.h */
+/* world_margin_shape.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -28,14 +28,14 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#ifndef PLANE_SHAPE_H
-#define PLANE_SHAPE_H
+#ifndef WORLD_MARGIN_SHAPE_H
+#define WORLD_MARGIN_SHAPE_H
#include "scene/resources/shape.h"
-class PlaneShape : public Shape {
+class WorldMarginShape : public Shape {
- GDCLASS(PlaneShape, Shape);
+ GDCLASS(WorldMarginShape, Shape);
Plane plane;
protected:
@@ -52,6 +52,6 @@ public:
return 0;
}
- PlaneShape();
+ WorldMarginShape();
};
-#endif // PLANE_SHAPE_H
+#endif // WORLD_MARGIN_SHAPE_H