summaryrefslogtreecommitdiff
path: root/scene
diff options
context:
space:
mode:
Diffstat (limited to 'scene')
-rw-r--r--scene/3d/physics_body.cpp11
-rw-r--r--scene/gui/color_picker.cpp4
-rw-r--r--scene/gui/graph_edit.cpp10
-rw-r--r--scene/gui/label.cpp26
-rw-r--r--scene/gui/rich_text_label.cpp43
-rw-r--r--scene/gui/text_edit.cpp6
-rw-r--r--scene/main/node.cpp3
-rw-r--r--scene/main/viewport.cpp52
-rw-r--r--scene/main/viewport.h2
-rw-r--r--scene/register_scene_types.cpp44
-rw-r--r--scene/resources/default_theme/default_theme.cpp2
-rw-r--r--scene/resources/dynamic_font.cpp22
-rw-r--r--scene/resources/dynamic_font.h2
-rw-r--r--scene/resources/mesh.cpp4
-rw-r--r--scene/resources/packed_scene.cpp34
-rw-r--r--scene/resources/style_box.cpp6
-rw-r--r--scene/resources/texture.cpp2
-rw-r--r--scene/resources/world.cpp10
18 files changed, 176 insertions, 107 deletions
diff --git a/scene/3d/physics_body.cpp b/scene/3d/physics_body.cpp
index 44dc3d0c26..c2860c25d8 100644
--- a/scene/3d/physics_body.cpp
+++ b/scene/3d/physics_body.cpp
@@ -1151,17 +1151,8 @@ Vector3 KinematicBody::move_and_slide(const Vector3 &p_linear_velocity, const Ve
}
}
- Vector3 current_floor_velocity = floor_velocity;
- if (on_floor && on_floor_body.is_valid()) {
- //this approach makes sure there is less delay between the actual body velocity and the one we saved
- PhysicsDirectBodyState *bs = PhysicsServer::get_singleton()->body_get_direct_state(on_floor_body);
- if (bs) {
- current_floor_velocity = bs->get_linear_velocity();
- }
- }
-
// Hack in order to work with calling from _process as well as from _physics_process; calling from thread is risky
- Vector3 motion = (current_floor_velocity + body_velocity) * (Engine::get_singleton()->is_in_physics_frame() ? get_physics_process_delta_time() : get_process_delta_time());
+ Vector3 motion = (floor_velocity + body_velocity) * (Engine::get_singleton()->is_in_physics_frame() ? get_physics_process_delta_time() : get_process_delta_time());
on_floor = false;
on_floor_body = RID();
diff --git a/scene/gui/color_picker.cpp b/scene/gui/color_picker.cpp
index bab8d9167b..01f4070883 100644
--- a/scene/gui/color_picker.cpp
+++ b/scene/gui/color_picker.cpp
@@ -573,9 +573,7 @@ void ColorPicker::_preset_input(const Ref<InputEvent> &p_event) {
}
if (index < 0 || index >= presets.size())
return;
- preset->set_tooltip("Color: #" + presets[index].to_html(presets[index].a < 1) + "\n"
- "LMB: Set color\n"
- "RMB: Remove preset");
+ preset->set_tooltip(vformat(RTR("Color: #%s\nLMB: Set color\nRMB: Remove preset"), presets[index].to_html(presets[index].a < 1)));
}
}
diff --git a/scene/gui/graph_edit.cpp b/scene/gui/graph_edit.cpp
index d1650fea1e..be465751b6 100644
--- a/scene/gui/graph_edit.cpp
+++ b/scene/gui/graph_edit.cpp
@@ -777,14 +777,8 @@ void GraphEdit::_top_layer_draw() {
}
if (box_selecting) {
- top_layer->draw_rect(
- box_selecting_rect,
- get_color("box_selection_fill_color", "Editor"));
-
- top_layer->draw_rect(
- box_selecting_rect,
- get_color("box_selection_stroke_color", "Editor"),
- false);
+ top_layer->draw_rect(box_selecting_rect, get_color("selection_fill"));
+ top_layer->draw_rect(box_selecting_rect, get_color("selection_stroke"), false);
}
}
diff --git a/scene/gui/label.cpp b/scene/gui/label.cpp
index 11172ac7a9..6b12947651 100644
--- a/scene/gui/label.cpp
+++ b/scene/gui/label.cpp
@@ -103,8 +103,7 @@ void Label::_notification(int p_what) {
int lines_visible = (size.y + line_spacing) / font_h;
- // ceiling to ensure autowrapping does not cut text
- int space_w = Math::ceil(font->get_char_size(' ').width);
+ real_t space_w = font->get_char_size(' ').width;
int chars_total = 0;
int vbegin = 0, vsep = 0;
@@ -225,6 +224,7 @@ void Label::_notification(int p_what) {
return;
}
if (from->space_count) {
+ chars_total += from->space_count;
/* spacing */
x_ofs += space_w * from->space_count;
if (can_fill && align == ALIGN_FILL && spaces) {
@@ -313,8 +313,8 @@ Size2 Label::get_minimum_size() const {
int Label::get_longest_line_width() const {
Ref<Font> font = get_font("font");
- int max_line_width = 0;
- int line_width = 0;
+ real_t max_line_width = 0;
+ real_t line_width = 0;
for (int i = 0; i < xl_text.size(); i++) {
@@ -332,8 +332,7 @@ int Label::get_longest_line_width() const {
}
} else {
- // ceiling to ensure autowrapping does not cut text
- int char_width = Math::ceil(font->get_char_size(current, xl_text[i + 1]).width);
+ real_t char_width = font->get_char_size(current, xl_text[i + 1]).width;
line_width += char_width;
}
}
@@ -341,7 +340,8 @@ int Label::get_longest_line_width() const {
if (line_width > max_line_width)
max_line_width = line_width;
- return max_line_width;
+ // ceiling to ensure autowrapping does not cut text
+ return Math::ceil(max_line_width);
}
int Label::get_line_count() const {
@@ -388,12 +388,11 @@ void Label::regenerate_word_cache() {
Ref<Font> font = get_font("font");
- int current_word_size = 0;
+ real_t current_word_size = 0;
int word_pos = 0;
- int line_width = 0;
+ real_t line_width = 0;
int space_count = 0;
- // ceiling to ensure autowrapping does not cut text
- int space_width = Math::ceil(font->get_char_size(' ').width);
+ real_t space_width = font->get_char_size(' ').width;
int line_spacing = get_constant("line_spacing");
line_count = 1;
total_char_cache = 0;
@@ -413,7 +412,7 @@ void Label::regenerate_word_cache() {
bool separatable = (current >= 0x2E08 && current <= 0xFAFF) || (current >= 0xFE30 && current <= 0xFE4F);
//current>=33 && (current < 65||current >90) && (current<97||current>122) && (current<48||current>57);
bool insert_newline = false;
- int char_width = 0;
+ real_t char_width = 0;
if (current < 33) {
@@ -454,8 +453,7 @@ void Label::regenerate_word_cache() {
if (current_word_size == 0) {
word_pos = i;
}
- // ceiling to ensure autowrapping does not cut text
- char_width = Math::ceil(font->get_char_size(current, xl_text[i + 1]).width);
+ char_width = font->get_char_size(current, xl_text[i + 1]).width;
current_word_size += char_width;
line_width += char_width;
total_char_cache++;
diff --git a/scene/gui/rich_text_label.cpp b/scene/gui/rich_text_label.cpp
index 5b7d7403ae..100c06955a 100644
--- a/scene/gui/rich_text_label.cpp
+++ b/scene/gui/rich_text_label.cpp
@@ -253,24 +253,25 @@ int RichTextLabel::_process_line(ItemFrame *p_frame, const Vector2 &p_ofs, int &
} \
}
-#define ENSURE_WIDTH(m_width) \
- if (p_mode == PROCESS_CACHE) { \
- l.maximum_width = MAX(l.maximum_width, MIN(p_width, wofs + m_width)); \
- l.minimum_width = MAX(l.minimum_width, m_width); \
- } \
- if (wofs + m_width > p_width) { \
- line_wrapped = true; \
- if (p_mode == PROCESS_CACHE) { \
- if (spaces > 0) \
- spaces -= 1; \
- } \
- if (p_mode == PROCESS_POINTER && r_click_item && p_click_pos.y >= p_ofs.y + y && p_click_pos.y <= p_ofs.y + y + lh && p_click_pos.x > p_ofs.x + wofs) { \
- if (r_outside) *r_outside = true; \
- *r_click_item = it; \
- *r_click_char = rchar; \
- RETURN; \
- } \
- NEW_LINE \
+#define ENSURE_WIDTH(m_width) \
+ if (p_mode == PROCESS_CACHE) { \
+ l.maximum_width = MAX(l.maximum_width, MIN(p_width, wofs + m_width)); \
+ l.minimum_width = MAX(l.minimum_width, m_width); \
+ } \
+ if (wofs + m_width > p_width) { \
+ line_wrapped = true; \
+ if (p_mode == PROCESS_CACHE) { \
+ if (spaces > 0) \
+ spaces -= 1; \
+ } \
+ const bool x_in_range = (p_click_pos.x > p_ofs.x + wofs) && (!p_frame->cell || p_click_pos.x < p_ofs.x + p_width); \
+ if (p_mode == PROCESS_POINTER && r_click_item && p_click_pos.y >= p_ofs.y + y && p_click_pos.y <= p_ofs.y + y + lh && x_in_range) { \
+ if (r_outside) *r_outside = true; \
+ *r_click_item = it; \
+ *r_click_char = rchar; \
+ RETURN; \
+ } \
+ NEW_LINE \
}
#define ADVANCE(m_width) \
@@ -1063,10 +1064,10 @@ Control::CursorShape RichTextLabel::get_cursor_shape(const Point2 &p_pos) const
int line = 0;
Item *item = NULL;
+ bool outside;
+ ((RichTextLabel *)(this))->_find_click(main, p_pos, &item, &line, &outside);
- ((RichTextLabel *)(this))->_find_click(main, p_pos, &item, &line);
-
- if (item && ((RichTextLabel *)(this))->_find_meta(item, NULL))
+ if (item && !outside && ((RichTextLabel *)(this))->_find_meta(item, NULL))
return CURSOR_POINTING_HAND;
return CURSOR_ARROW;
diff --git a/scene/gui/text_edit.cpp b/scene/gui/text_edit.cpp
index d7e469ca26..6de2f0b570 100644
--- a/scene/gui/text_edit.cpp
+++ b/scene/gui/text_edit.cpp
@@ -7070,6 +7070,10 @@ void TextEdit::_bind_methods() {
ClassDB::bind_method(D_METHOD("is_smooth_scroll_enabled"), &TextEdit::is_smooth_scroll_enabled);
ClassDB::bind_method(D_METHOD("set_v_scroll_speed", "speed"), &TextEdit::set_v_scroll_speed);
ClassDB::bind_method(D_METHOD("get_v_scroll_speed"), &TextEdit::get_v_scroll_speed);
+ ClassDB::bind_method(D_METHOD("set_v_scroll", "value"), &TextEdit::set_v_scroll);
+ ClassDB::bind_method(D_METHOD("get_v_scroll"), &TextEdit::get_v_scroll);
+ ClassDB::bind_method(D_METHOD("set_h_scroll", "value"), &TextEdit::set_h_scroll);
+ ClassDB::bind_method(D_METHOD("get_h_scroll"), &TextEdit::get_h_scroll);
ClassDB::bind_method(D_METHOD("add_keyword_color", "keyword", "color"), &TextEdit::add_keyword_color);
ClassDB::bind_method(D_METHOD("has_keyword_color", "keyword"), &TextEdit::has_keyword_color);
@@ -7105,6 +7109,8 @@ void TextEdit::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::REAL, "v_scroll_speed"), "set_v_scroll_speed", "get_v_scroll_speed");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "hiding_enabled"), "set_hiding_enabled", "is_hiding_enabled");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "wrap_enabled"), "set_wrap_enabled", "is_wrap_enabled");
+ ADD_PROPERTY(PropertyInfo(Variant::REAL, "scroll_vertical"), "set_v_scroll", "get_v_scroll");
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "scroll_horizontal"), "set_h_scroll", "get_h_scroll");
ADD_GROUP("Minimap", "minimap_");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "minimap_draw"), "draw_minimap", "is_drawing_minimap");
diff --git a/scene/main/node.cpp b/scene/main/node.cpp
index 1e2b7c094e..350959dcc3 100644
--- a/scene/main/node.cpp
+++ b/scene/main/node.cpp
@@ -2680,7 +2680,8 @@ void Node::clear_internal_tree_resource_paths() {
String Node::get_configuration_warning() const {
- if (get_script_instance() && get_script_instance()->has_method("_get_configuration_warning")) {
+ if (get_script_instance() && get_script_instance()->get_script().is_valid() &&
+ get_script_instance()->get_script()->is_tool() && get_script_instance()->has_method("_get_configuration_warning")) {
return get_script_instance()->call("_get_configuration_warning");
}
return String();
diff --git a/scene/main/viewport.cpp b/scene/main/viewport.cpp
index 9e9a25883e..a56903636f 100644
--- a/scene/main/viewport.cpp
+++ b/scene/main/viewport.cpp
@@ -30,6 +30,7 @@
#include "viewport.h"
+#include "core/core_string_names.h"
#include "core/os/input.h"
#include "core/os/os.h"
#include "core/project_settings.h"
@@ -251,6 +252,27 @@ void Viewport::_collision_object_input_event(CollisionObject *p_object, Camera *
physics_last_id = id;
}
+void Viewport::_own_world_changed() {
+ ERR_FAIL_COND(world.is_null());
+ ERR_FAIL_COND(own_world.is_null());
+
+ if (is_inside_tree()) {
+ _propagate_exit_world(this);
+ }
+
+ own_world = world->duplicate();
+
+ if (is_inside_tree()) {
+ _propagate_enter_world(this);
+ }
+
+ if (is_inside_tree()) {
+ VisualServer::get_singleton()->viewport_set_scenario(viewport, find_world()->get_scenario());
+ }
+
+ _update_listener();
+}
+
void Viewport::_notification(int p_what) {
switch (p_what) {
@@ -1105,8 +1127,21 @@ void Viewport::set_world(const Ref<World> &p_world) {
if (is_inside_tree())
_propagate_exit_world(this);
+ if (own_world.is_valid() && world.is_valid()) {
+ world->disconnect(CoreStringNames::get_singleton()->changed, this, "_own_world_changed");
+ }
+
world = p_world;
+ if (own_world.is_valid()) {
+ if (world.is_valid()) {
+ own_world = world->duplicate();
+ world->connect(CoreStringNames::get_singleton()->changed, this, "_own_world_changed");
+ } else {
+ own_world = Ref<World>(memnew(World));
+ }
+ }
+
if (is_inside_tree())
_propagate_enter_world(this);
@@ -2826,10 +2861,19 @@ void Viewport::set_use_own_world(bool p_world) {
if (is_inside_tree())
_propagate_exit_world(this);
- if (!p_world)
+ if (!p_world) {
own_world = Ref<World>();
- else
- own_world = Ref<World>(memnew(World));
+ if (world.is_valid()) {
+ world->disconnect(CoreStringNames::get_singleton()->changed, this, "_own_world_changed");
+ }
+ } else {
+ if (world.is_valid()) {
+ own_world = world->duplicate();
+ world->connect(CoreStringNames::get_singleton()->changed, this, "_own_world_changed");
+ } else {
+ own_world = Ref<World>(memnew(World));
+ }
+ }
if (is_inside_tree())
_propagate_enter_world(this);
@@ -3178,6 +3222,8 @@ void Viewport::_bind_methods() {
ClassDB::bind_method(D_METHOD("_subwindow_visibility_changed"), &Viewport::_subwindow_visibility_changed);
+ ClassDB::bind_method(D_METHOD("_own_world_changed"), &Viewport::_own_world_changed);
+
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "arvr"), "set_use_arvr", "use_arvr");
ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "size"), "set_size", "get_size");
diff --git a/scene/main/viewport.h b/scene/main/viewport.h
index 396bbc91cd..79b606cda3 100644
--- a/scene/main/viewport.h
+++ b/scene/main/viewport.h
@@ -406,6 +406,8 @@ private:
void _update_canvas_items(Node *p_node);
+ void _own_world_changed();
+
protected:
void _notification(int p_what);
static void _bind_methods();
diff --git a/scene/register_scene_types.cpp b/scene/register_scene_types.cpp
index 21fc9ccf6a..09d4505458 100644
--- a/scene/register_scene_types.cpp
+++ b/scene/register_scene_types.cpp
@@ -372,6 +372,28 @@ void register_scene_types() {
ClassDB::register_class<AnimationPlayer>();
ClassDB::register_class<Tween>();
+ ClassDB::register_class<AnimationTreePlayer>();
+ ClassDB::register_class<AnimationTree>();
+ ClassDB::register_class<AnimationNode>();
+ ClassDB::register_class<AnimationRootNode>();
+ ClassDB::register_class<AnimationNodeBlendTree>();
+ ClassDB::register_class<AnimationNodeBlendSpace1D>();
+ ClassDB::register_class<AnimationNodeBlendSpace2D>();
+ ClassDB::register_class<AnimationNodeStateMachine>();
+ ClassDB::register_class<AnimationNodeStateMachinePlayback>();
+
+ ClassDB::register_class<AnimationNodeStateMachineTransition>();
+ ClassDB::register_class<AnimationNodeOutput>();
+ ClassDB::register_class<AnimationNodeOneShot>();
+ ClassDB::register_class<AnimationNodeAnimation>();
+ ClassDB::register_class<AnimationNodeAdd2>();
+ ClassDB::register_class<AnimationNodeAdd3>();
+ ClassDB::register_class<AnimationNodeBlend2>();
+ ClassDB::register_class<AnimationNodeBlend3>();
+ ClassDB::register_class<AnimationNodeTimeScale>();
+ ClassDB::register_class<AnimationNodeTimeSeek>();
+ ClassDB::register_class<AnimationNodeTransition>();
+
OS::get_singleton()->yield(); //may take time to init
#ifndef _3D_DISABLED
@@ -399,7 +421,6 @@ void register_scene_types() {
ClassDB::register_class<GIProbeData>();
ClassDB::register_class<BakedLightmap>();
ClassDB::register_class<BakedLightmapData>();
- ClassDB::register_class<AnimationTreePlayer>();
ClassDB::register_class<Particles>();
ClassDB::register_class<CPUParticles>();
ClassDB::register_class<Position3D>();
@@ -410,27 +431,6 @@ void register_scene_types() {
ClassDB::register_class<RootMotionView>();
ClassDB::set_class_enabled("RootMotionView", false); //disabled by default, enabled by editor
- ClassDB::register_class<AnimationTree>();
- ClassDB::register_class<AnimationNode>();
- ClassDB::register_class<AnimationRootNode>();
- ClassDB::register_class<AnimationNodeBlendTree>();
- ClassDB::register_class<AnimationNodeBlendSpace1D>();
- ClassDB::register_class<AnimationNodeBlendSpace2D>();
- ClassDB::register_class<AnimationNodeStateMachine>();
- ClassDB::register_class<AnimationNodeStateMachinePlayback>();
-
- ClassDB::register_class<AnimationNodeStateMachineTransition>();
- ClassDB::register_class<AnimationNodeOutput>();
- ClassDB::register_class<AnimationNodeOneShot>();
- ClassDB::register_class<AnimationNodeAnimation>();
- ClassDB::register_class<AnimationNodeAdd2>();
- ClassDB::register_class<AnimationNodeAdd3>();
- ClassDB::register_class<AnimationNodeBlend2>();
- ClassDB::register_class<AnimationNodeBlend3>();
- ClassDB::register_class<AnimationNodeTimeScale>();
- ClassDB::register_class<AnimationNodeTimeSeek>();
- ClassDB::register_class<AnimationNodeTransition>();
-
OS::get_singleton()->yield(); //may take time to init
ClassDB::register_virtual_class<CollisionObject>();
diff --git a/scene/resources/default_theme/default_theme.cpp b/scene/resources/default_theme/default_theme.cpp
index 67351f07d2..cc76df62e5 100644
--- a/scene/resources/default_theme/default_theme.cpp
+++ b/scene/resources/default_theme/default_theme.cpp
@@ -851,6 +851,8 @@ void fill_default_theme(Ref<Theme> &theme, const Ref<Font> &default_font, const
theme->set_stylebox("bg", "GraphEdit", make_stylebox(tree_bg_png, 4, 4, 4, 5));
theme->set_color("grid_minor", "GraphEdit", Color(1, 1, 1, 0.05));
theme->set_color("grid_major", "GraphEdit", Color(1, 1, 1, 0.2));
+ theme->set_color("selection_fill", "GraphEdit", Color(1, 1, 1, 0.3));
+ theme->set_color("selection_stroke", "GraphEdit", Color(1, 1, 1, 0.8));
theme->set_color("activity", "GraphEdit", Color(1, 1, 1));
theme->set_constant("bezier_len_pos", "GraphEdit", 80 * scale);
theme->set_constant("bezier_len_neg", "GraphEdit", 160 * scale);
diff --git a/scene/resources/dynamic_font.cpp b/scene/resources/dynamic_font.cpp
index 42fec3a0a7..10d871aa92 100644
--- a/scene/resources/dynamic_font.cpp
+++ b/scene/resources/dynamic_font.cpp
@@ -195,13 +195,13 @@ Error DynamicFontAtSize::_load() {
if (FT_HAS_COLOR(face) && face->num_fixed_sizes > 0) {
int best_match = 0;
int diff = ABS(id.size - ((int64_t)face->available_sizes[0].width));
- scale_color_font = float(id.size) / face->available_sizes[0].width;
+ scale_color_font = float(id.size * oversampling) / face->available_sizes[0].width;
for (int i = 1; i < face->num_fixed_sizes; i++) {
int ndiff = ABS(id.size - ((int64_t)face->available_sizes[i].width));
if (ndiff < diff) {
best_match = i;
diff = ndiff;
- scale_color_font = float(id.size) / face->available_sizes[i].width;
+ scale_color_font = float(id.size * oversampling) / face->available_sizes[i].width;
}
}
FT_Select_Size(face, best_match);
@@ -299,7 +299,7 @@ void DynamicFontAtSize::set_texture_flags(uint32_t p_flags) {
}
}
-float DynamicFontAtSize::draw_char(RID p_canvas_item, const Point2 &p_pos, CharType p_char, CharType p_next, const Color &p_modulate, const Vector<Ref<DynamicFontAtSize> > &p_fallbacks, bool p_advance_only) const {
+float DynamicFontAtSize::draw_char(RID p_canvas_item, const Point2 &p_pos, CharType p_char, CharType p_next, const Color &p_modulate, const Vector<Ref<DynamicFontAtSize> > &p_fallbacks, bool p_advance_only, bool p_outline) const {
if (!valid)
return 0;
@@ -314,6 +314,20 @@ float DynamicFontAtSize::draw_char(RID p_canvas_item, const Point2 &p_pos, CharT
float advance = 0.0;
+ // use normal character size if there's no outline charater
+ if (p_outline && !ch->found) {
+ FT_GlyphSlot slot = face->glyph;
+ int error = FT_Load_Char(face, p_char, FT_HAS_COLOR(face) ? FT_LOAD_COLOR : FT_LOAD_DEFAULT);
+ if (!error) {
+ error = FT_Render_Glyph(face->glyph, FT_RENDER_MODE_NORMAL);
+ if (!error) {
+ Character character = Character::not_found();
+ character = const_cast<DynamicFontAtSize *>(this)->_bitmap_to_character(slot->bitmap, slot->bitmap_top, slot->bitmap_left, slot->advance.x / 64.0);
+ advance = character.advance;
+ }
+ }
+ }
+
if (ch->found) {
ERR_FAIL_COND_V(ch->texture_idx < -1 || ch->texture_idx >= font->textures.size(), 0);
@@ -875,7 +889,7 @@ float DynamicFont::draw_char(RID p_canvas_item, const Point2 &p_pos, CharType p_
// If requested outline draw, but no outline is present, simply return advance without drawing anything
bool advance_only = p_outline && outline_cache_id.outline_size == 0;
- return font_at_size->draw_char(p_canvas_item, p_pos, p_char, p_next, color, fallbacks, advance_only) + spacing_char;
+ return font_at_size->draw_char(p_canvas_item, p_pos, p_char, p_next, color, fallbacks, advance_only, p_outline) + spacing_char;
}
void DynamicFont::set_fallback(int p_idx, const Ref<DynamicFontData> &p_data) {
diff --git a/scene/resources/dynamic_font.h b/scene/resources/dynamic_font.h
index ece150c4ce..2dafd3ce4f 100644
--- a/scene/resources/dynamic_font.h
+++ b/scene/resources/dynamic_font.h
@@ -192,7 +192,7 @@ public:
Size2 get_char_size(CharType p_char, CharType p_next, const Vector<Ref<DynamicFontAtSize> > &p_fallbacks) const;
- float draw_char(RID p_canvas_item, const Point2 &p_pos, CharType p_char, CharType p_next, const Color &p_modulate, const Vector<Ref<DynamicFontAtSize> > &p_fallbacks, bool p_advance_only = false) const;
+ float draw_char(RID p_canvas_item, const Point2 &p_pos, CharType p_char, CharType p_next, const Color &p_modulate, const Vector<Ref<DynamicFontAtSize> > &p_fallbacks, bool p_advance_only = false, bool p_outline = false) const;
void set_texture_flags(uint32_t p_flags);
void update_oversampling();
diff --git a/scene/resources/mesh.cpp b/scene/resources/mesh.cpp
index 13721191c0..0599920303 100644
--- a/scene/resources/mesh.cpp
+++ b/scene/resources/mesh.cpp
@@ -75,6 +75,7 @@ Ref<TriangleMesh> Mesh::generate_triangle_mesh() const {
continue;
Array a = surface_get_arrays(i);
+ ERR_FAIL_COND_V(a.empty(), Ref<TriangleMesh>());
int vc = surface_get_array_len(i);
PoolVector<Vector3> vertices = a[ARRAY_VERTEX];
@@ -234,6 +235,7 @@ Ref<Shape> Mesh::create_convex_shape() const {
for (int i = 0; i < get_surface_count(); i++) {
Array a = surface_get_arrays(i);
+ ERR_FAIL_COND_V(a.empty(), Ref<ConvexPolygonShape>());
PoolVector<Vector3> v = a[ARRAY_VERTEX];
vertices.append_array(v);
}
@@ -273,6 +275,7 @@ Ref<Mesh> Mesh::create_outline(float p_margin) const {
continue;
Array a = surface_get_arrays(i);
+ ERR_FAIL_COND_V(a.empty(), Ref<ArrayMesh>());
if (i == 0) {
arrays = a;
@@ -378,6 +381,7 @@ Ref<Mesh> Mesh::create_outline(float p_margin) const {
PoolVector<Vector3>::Write r = vertices.write();
if (indices.size()) {
+ ERR_FAIL_COND_V(indices.size() % 3 != 0, Ref<ArrayMesh>());
vc = indices.size();
ir = indices.write();
has_indices = true;
diff --git a/scene/resources/packed_scene.cpp b/scene/resources/packed_scene.cpp
index 5a2cd9a1c2..3e7d350eec 100644
--- a/scene/resources/packed_scene.cpp
+++ b/scene/resources/packed_scene.cpp
@@ -39,7 +39,7 @@
#include "scene/gui/control.h"
#include "scene/main/instance_placeholder.h"
-#define PACK_VERSION 2
+#define PACKED_SCENE_VERSION 2
bool SceneState::can_instance() const {
@@ -1095,7 +1095,15 @@ void SceneState::set_bundled_scene(const Dictionary &p_dictionary) {
if (p_dictionary.has("version"))
version = p_dictionary["version"];
- ERR_FAIL_COND_MSG(version > PACK_VERSION, "Save format version too new.");
+ ERR_FAIL_COND_MSG(version > PACKED_SCENE_VERSION, "Save format version too new.");
+
+ const int node_count = p_dictionary["node_count"];
+ const PoolVector<int> snodes = p_dictionary["nodes"];
+ ERR_FAIL_COND(snodes.size() < node_count);
+
+ const int conn_count = p_dictionary["conn_count"];
+ const PoolVector<int> sconns = p_dictionary["conns"];
+ ERR_FAIL_COND(sconns.size() < conn_count);
PoolVector<String> snames = p_dictionary["names"];
if (snames.size()) {
@@ -1121,13 +1129,11 @@ void SceneState::set_bundled_scene(const Dictionary &p_dictionary) {
variants.clear();
}
- nodes.resize(p_dictionary["node_count"]);
- int nc = nodes.size();
- if (nc) {
- PoolVector<int> snodes = p_dictionary["nodes"];
+ nodes.resize(node_count);
+ if (node_count) {
PoolVector<int>::Read r = snodes.read();
int idx = 0;
- for (int i = 0; i < nc; i++) {
+ for (int i = 0; i < node_count; i++) {
NodeData &nd = nodes.write[i];
nd.parent = r[idx++];
nd.owner = r[idx++];
@@ -1151,15 +1157,11 @@ void SceneState::set_bundled_scene(const Dictionary &p_dictionary) {
}
}
- connections.resize(p_dictionary["conn_count"]);
- int cc = connections.size();
-
- if (cc) {
-
- PoolVector<int> sconns = p_dictionary["conns"];
+ connections.resize(conn_count);
+ if (conn_count) {
PoolVector<int>::Read r = sconns.read();
int idx = 0;
- for (int i = 0; i < cc; i++) {
+ for (int i = 0; i < conn_count; i++) {
ConnectionData &cd = connections.write[i];
cd.from = r[idx++];
cd.to = r[idx++];
@@ -1283,9 +1285,7 @@ Dictionary SceneState::get_bundled_scene() const {
d["base_scene"] = base_scene_idx;
}
- d["version"] = PACK_VERSION;
-
- //d["path"]=path;
+ d["version"] = PACKED_SCENE_VERSION;
return d;
}
diff --git a/scene/resources/style_box.cpp b/scene/resources/style_box.cpp
index c59fa8cab8..9408d1aa71 100644
--- a/scene/resources/style_box.cpp
+++ b/scene/resources/style_box.cpp
@@ -719,6 +719,7 @@ void StyleBoxFlat::draw(RID p_canvas_item, const Rect2 &p_rect) const {
bool rounded_corners = (corner_radius[0] > 0) || (corner_radius[1] > 0) || (corner_radius[2] > 0) || (corner_radius[3] > 0);
bool aa_on = rounded_corners && anti_aliased;
+ float aa_size_grow = 0.5 * ((float)aa_size + 1.0);
bool blend_on = blend_border && draw_border;
@@ -744,7 +745,6 @@ void StyleBoxFlat::draw(RID p_canvas_item, const Rect2 &p_rect) const {
Rect2 border_style_rect = style_rect;
if (aa_on) {
- float aa_size_grow = 0.5 * ((aa_size + 1) / 2);
for (int i = 0; i < 4; i++) {
if (border_width[i] > 0) {
border_style_rect = border_style_rect.grow_margin((Margin)i, -aa_size_grow);
@@ -789,7 +789,6 @@ void StyleBoxFlat::draw(RID p_canvas_item, const Rect2 &p_rect) const {
}
if (aa_on) {
- float aa_size_grow = 0.5 * ((aa_size + 1) / 2);
int aa_border_width[4];
int aa_fill_width[4];
if (draw_border) {
@@ -804,6 +803,7 @@ void StyleBoxFlat::draw(RID p_canvas_item, const Rect2 &p_rect) const {
}
} else {
for (int i = 0; i < 4; i++) {
+ aa_border_width[i] = 0;
aa_fill_width[i] = aa_size_grow;
}
}
@@ -844,7 +844,7 @@ void StyleBoxFlat::draw(RID p_canvas_item, const Rect2 &p_rect) const {
}
//COMPUTE UV COORDINATES
- Rect2 uv_rect = style_rect.grow(aa_on ? aa_size : 0);
+ Rect2 uv_rect = style_rect.grow(aa_on ? aa_size_grow : 0);
uvs.resize(verts.size());
for (int i = 0; i < verts.size(); i++) {
uvs.write[i].x = (verts[i].x - uv_rect.position.x) / uv_rect.size.width;
diff --git a/scene/resources/texture.cpp b/scene/resources/texture.cpp
index dc2b708ae7..4d23f0eb41 100644
--- a/scene/resources/texture.cpp
+++ b/scene/resources/texture.cpp
@@ -2271,6 +2271,7 @@ void TextureLayered::create(uint32_t p_width, uint32_t p_height, uint32_t p_dept
void TextureLayered::set_layer_data(const Ref<Image> &p_image, int p_layer) {
ERR_FAIL_COND(!texture.is_valid());
+ ERR_FAIL_COND(!p_image.is_valid());
VS::get_singleton()->texture_set_data(texture, p_image, p_layer);
}
@@ -2282,6 +2283,7 @@ Ref<Image> TextureLayered::get_layer_data(int p_layer) const {
void TextureLayered::set_data_partial(const Ref<Image> &p_image, int p_x_ofs, int p_y_ofs, int p_z, int p_mipmap) {
ERR_FAIL_COND(!texture.is_valid());
+ ERR_FAIL_COND(!p_image.is_valid());
VS::get_singleton()->texture_set_data_partial(texture, p_image, 0, 0, p_image->get_width(), p_image->get_height(), p_x_ofs, p_y_ofs, p_mipmap, p_z);
}
diff --git a/scene/resources/world.cpp b/scene/resources/world.cpp
index b498acd707..1099852098 100644
--- a/scene/resources/world.cpp
+++ b/scene/resources/world.cpp
@@ -268,12 +268,17 @@ RID World::get_scenario() const {
}
void World::set_environment(const Ref<Environment> &p_environment) {
+ if (environment == p_environment) {
+ return;
+ }
environment = p_environment;
if (environment.is_valid())
VS::get_singleton()->scenario_set_environment(scenario, environment->get_rid());
else
VS::get_singleton()->scenario_set_environment(scenario, RID());
+
+ emit_changed();
}
Ref<Environment> World::get_environment() const {
@@ -282,12 +287,17 @@ Ref<Environment> World::get_environment() const {
}
void World::set_fallback_environment(const Ref<Environment> &p_environment) {
+ if (fallback_environment == p_environment) {
+ return;
+ }
fallback_environment = p_environment;
if (fallback_environment.is_valid())
VS::get_singleton()->scenario_set_fallback_environment(scenario, p_environment->get_rid());
else
VS::get_singleton()->scenario_set_fallback_environment(scenario, RID());
+
+ emit_changed();
}
Ref<Environment> World::get_fallback_environment() const {