diff options
-rw-r--r-- | core/extension/native_extension.cpp | 3 | ||||
-rw-r--r-- | core/register_core_types.cpp | 11 | ||||
-rw-r--r-- | core/register_core_types.h | 1 | ||||
-rw-r--r-- | editor/editor_atlas_packer.cpp | 62 | ||||
-rw-r--r-- | editor/editor_atlas_packer.h | 2 | ||||
-rw-r--r-- | main/main.cpp | 7 | ||||
-rw-r--r-- | servers/rendering/renderer_rd/effects_rd.cpp | 4 |
7 files changed, 29 insertions, 61 deletions
diff --git a/core/extension/native_extension.cpp b/core/extension/native_extension.cpp index 1512852234..e1db99fe5d 100644 --- a/core/extension/native_extension.cpp +++ b/core/extension/native_extension.cpp @@ -295,9 +295,10 @@ NativeExtension::InitializationLevel NativeExtension::get_minimum_library_initia ERR_FAIL_COND_V(library == nullptr, INITIALIZATION_LEVEL_CORE); return InitializationLevel(initialization.minimum_initialization_level); } + void NativeExtension::initialize_library(InitializationLevel p_level) { ERR_FAIL_COND(library == nullptr); - ERR_FAIL_COND(p_level <= int32_t(level_initialized)); + ERR_FAIL_COND_MSG(p_level <= int32_t(level_initialized), vformat("Level '%d' must be higher than the current level '%d'", p_level, level_initialized)); level_initialized = int32_t(p_level); diff --git a/core/register_core_types.cpp b/core/register_core_types.cpp index a4b6a589f3..63aa8050c4 100644 --- a/core/register_core_types.cpp +++ b/core/register_core_types.cpp @@ -108,6 +108,8 @@ extern void unregister_global_constants(); static ResourceUID *resource_uid = nullptr; +static bool _is_core_extensions_registered = false; + void register_core_types() { //consistency check static_assert(sizeof(Callable) <= 16); @@ -314,11 +316,16 @@ void register_core_extensions() { NativeExtension::initialize_native_extensions(); native_extension_manager->load_extensions(); native_extension_manager->initialize_extensions(NativeExtension::INITIALIZATION_LEVEL_CORE); + _is_core_extensions_registered = true; } -void unregister_core_types() { - native_extension_manager->deinitialize_extensions(NativeExtension::INITIALIZATION_LEVEL_CORE); +void unregister_core_extensions() { + if (_is_core_extensions_registered) { + native_extension_manager->deinitialize_extensions(NativeExtension::INITIALIZATION_LEVEL_CORE); + } +} +void unregister_core_types() { memdelete(native_extension_manager); memdelete(resource_uid); diff --git a/core/register_core_types.h b/core/register_core_types.h index 0fd4e73c40..dfb2d8ac80 100644 --- a/core/register_core_types.h +++ b/core/register_core_types.h @@ -36,5 +36,6 @@ void register_core_settings(); void register_core_extensions(); void register_core_singletons(); void unregister_core_types(); +void unregister_core_extensions(); #endif // REGISTER_CORE_TYPES_H diff --git a/editor/editor_atlas_packer.cpp b/editor/editor_atlas_packer.cpp index aad32968de..9c6bcd769a 100644 --- a/editor/editor_atlas_packer.cpp +++ b/editor/editor_atlas_packer.cpp @@ -30,60 +30,10 @@ #include "editor_atlas_packer.h" +#include "core/math/geometry_2d.h" #include "core/math/vector2.h" #include "core/math/vector2i.h" -void EditorAtlasPacker::_plot_triangle(Ref<BitMap> p_bitmap, Vector2i *vertices) { - int width = p_bitmap->get_size().width; - int height = p_bitmap->get_size().height; - int x[3]; - int y[3]; - - for (int j = 0; j < 3; j++) { - x[j] = vertices[j].x; - y[j] = vertices[j].y; - } - - // sort the points vertically - if (y[1] > y[2]) { - SWAP(x[1], x[2]); - SWAP(y[1], y[2]); - } - if (y[0] > y[1]) { - SWAP(x[0], x[1]); - SWAP(y[0], y[1]); - } - if (y[1] > y[2]) { - SWAP(x[1], x[2]); - SWAP(y[1], y[2]); - } - - double dx_far = double(x[2] - x[0]) / (y[2] - y[0] + 1); - double dx_upper = double(x[1] - x[0]) / (y[1] - y[0] + 1); - double dx_low = double(x[2] - x[1]) / (y[2] - y[1] + 1); - double xf = x[0]; - double xt = x[0] + dx_upper; // if y[0] == y[1], special case - for (int yi = y[0]; yi <= (y[2] > height - 1 ? height - 1 : y[2]); yi++) { - if (yi >= 0) { - for (int xi = (xf > 0 ? int(xf) : 0); xi <= (xt < width ? xt : width - 1); xi++) { - //pixels[int(x + y * width)] = color; - - p_bitmap->set_bit(Point2(xi, yi), true); - } - - for (int xi = (xf < width ? int(xf) : width - 1); xi >= (xt > 0 ? xt : 0); xi--) { - p_bitmap->set_bit(Point2(xi, yi), true); - } - } - xf += dx_far; - if (yi < y[1]) { - xt += dx_upper; - } else { - xt += dx_low; - } - } -} - void EditorAtlasPacker::chart_pack(Vector<Chart> &charts, int &r_width, int &r_height, int p_atlas_max_size, int p_cell_resolution) { int divide_by = MIN(64, p_cell_resolution); Vector<PlottedBitmap> bitmaps; @@ -122,10 +72,18 @@ void EditorAtlasPacker::chart_pack(Vector<Chart> &charts, int &r_width, int &r_h Vector2 vtx = chart.vertices[chart.faces[j].vertex[k]]; vtx -= aabb.position; vtx /= divide_by; + vtx.x = MIN(vtx.x, w - 1); + vtx.y = MIN(vtx.y, h - 1); v[k] = vtx; } - _plot_triangle(src_bitmap, v); + for (int k = 0; k < 3; k++) { + int l = k == 0 ? 2 : k - 1; + Vector<Point2i> points = Geometry2D::bresenham_line(v[k], v[l]); + for (Point2i point : points) { + src_bitmap->set_bit(point, true); + } + } } //src_bitmap->convert_to_image()->save_png("bitmap" + itos(i) + ".png"); diff --git a/editor/editor_atlas_packer.h b/editor/editor_atlas_packer.h index 169a6bead8..7b7692011f 100644 --- a/editor/editor_atlas_packer.h +++ b/editor/editor_atlas_packer.h @@ -67,8 +67,6 @@ private: } }; - static void _plot_triangle(Ref<BitMap> p_bitmap, Vector2i *vertices); - public: static void chart_pack(Vector<Chart> &charts, int &r_width, int &r_height, int p_atlas_max_size = 2048, int p_cell_resolution = 4); }; diff --git a/main/main.cpp b/main/main.cpp index 21199fe227..a68792105e 100644 --- a/main/main.cpp +++ b/main/main.cpp @@ -487,6 +487,7 @@ void Main::test_cleanup() { } unregister_core_driver_types(); + unregister_core_extensions(); unregister_core_types(); OS::get_singleton()->finalize_core(); @@ -634,7 +635,6 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph continue; } #endif - List<String>::Element *N = I->next(); if (I->get() == "-h" || I->get() == "--help" || I->get() == "/?") { // display help @@ -1157,6 +1157,8 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph // Initialize user data dir. OS::get_singleton()->ensure_user_data_dir(); + register_core_extensions(); // core extensions must be registered after globals setup and before display + ResourceUID::get_singleton()->load_from_cache(); // load UUIDs from cache. GLOBAL_DEF("memory/limits/multithreaded_server/rid_pool_prealloc", 60); @@ -1272,7 +1274,6 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph OS::get_singleton()->set_cmdline(execpath, main_args); - register_core_extensions(); //before display // possibly be worth changing the default from vulkan to something lower spec, // for the project manager, depending on how smooth the fallback is. GLOBAL_DEF_RST("rendering/driver/driver_name", "vulkan"); @@ -1529,6 +1530,7 @@ error: } unregister_core_driver_types(); + unregister_core_extensions(); unregister_core_types(); OS::get_singleton()->_cmdline.clear(); @@ -2888,6 +2890,7 @@ void Main::cleanup(bool p_force) { memdelete(message_queue); unregister_core_driver_types(); + unregister_core_extensions(); unregister_core_types(); OS::get_singleton()->finalize_core(); diff --git a/servers/rendering/renderer_rd/effects_rd.cpp b/servers/rendering/renderer_rd/effects_rd.cpp index 6c28cfd134..f16a4b1d19 100644 --- a/servers/rendering/renderer_rd/effects_rd.cpp +++ b/servers/rendering/renderer_rd/effects_rd.cpp @@ -2032,7 +2032,7 @@ void EffectsRD::cubemap_roughness(RID p_source_rd_texture, RID p_dest_texture, u memset(&roughness.push_constant, 0, sizeof(CubemapRoughnessPushConstant)); roughness.push_constant.face_id = p_face_id > 9 ? 0 : p_face_id; - roughness.push_constant.roughness = p_roughness; + roughness.push_constant.roughness = p_roughness * p_roughness; // Shader expects roughness, not perceptual roughness, so multiply before passing in. roughness.push_constant.sample_count = p_sample_count; roughness.push_constant.use_direct_write = p_roughness == 0.0; roughness.push_constant.face_size = p_size; @@ -2060,7 +2060,7 @@ void EffectsRD::cubemap_roughness_raster(RID p_source_rd_texture, RID p_dest_fra memset(&roughness.push_constant, 0, sizeof(CubemapRoughnessPushConstant)); roughness.push_constant.face_id = p_face_id; - roughness.push_constant.roughness = p_roughness; + roughness.push_constant.roughness = p_roughness * p_roughness; // Shader expects roughness, not perceptual roughness, so multiply before passing in. roughness.push_constant.sample_count = p_sample_count; roughness.push_constant.use_direct_write = p_roughness == 0.0; roughness.push_constant.face_size = p_size; |