diff options
Diffstat (limited to 'scene')
-rw-r--r-- | scene/2d/cpu_particles_2d.cpp | 2 | ||||
-rw-r--r-- | scene/2d/particles_2d.cpp | 1 | ||||
-rw-r--r-- | scene/3d/cpu_particles.cpp | 2 | ||||
-rw-r--r-- | scene/3d/particles.cpp | 1 | ||||
-rw-r--r-- | scene/3d/sprite_3d.cpp | 1 | ||||
-rw-r--r-- | scene/gui/text_edit.cpp | 15 | ||||
-rw-r--r-- | scene/gui/text_edit.h | 2 | ||||
-rw-r--r-- | scene/resources/texture.cpp | 1 | ||||
-rw-r--r-- | scene/resources/tile_set.cpp | 29 | ||||
-rw-r--r-- | scene/resources/visual_shader.cpp | 38 | ||||
-rw-r--r-- | scene/resources/visual_shader.h | 2 |
11 files changed, 73 insertions, 21 deletions
diff --git a/scene/2d/cpu_particles_2d.cpp b/scene/2d/cpu_particles_2d.cpp index 2396faa84b..fba1c26d1c 100644 --- a/scene/2d/cpu_particles_2d.cpp +++ b/scene/2d/cpu_particles_2d.cpp @@ -250,6 +250,8 @@ void CPUParticles2D::restart() { frame_remainder = 0; cycle = 0; + set_emitting(true); + { int pc = particles.size(); PoolVector<Particle>::Write w = particles.write(); diff --git a/scene/2d/particles_2d.cpp b/scene/2d/particles_2d.cpp index 9701998f5d..823794c3ba 100644 --- a/scene/2d/particles_2d.cpp +++ b/scene/2d/particles_2d.cpp @@ -278,6 +278,7 @@ void Particles2D::_validate_property(PropertyInfo &property) const { void Particles2D::restart() { VS::get_singleton()->particles_restart(particles); + VS::get_singleton()->particles_set_emitting(particles, true); } void Particles2D::_notification(int p_what) { diff --git a/scene/3d/cpu_particles.cpp b/scene/3d/cpu_particles.cpp index 6dc1b93576..ee5d416930 100644 --- a/scene/3d/cpu_particles.cpp +++ b/scene/3d/cpu_particles.cpp @@ -225,6 +225,8 @@ void CPUParticles::restart() { frame_remainder = 0; cycle = 0; + set_emitting(true); + { int pc = particles.size(); PoolVector<Particle>::Write w = particles.write(); diff --git a/scene/3d/particles.cpp b/scene/3d/particles.cpp index 156560f802..949de110f5 100644 --- a/scene/3d/particles.cpp +++ b/scene/3d/particles.cpp @@ -278,6 +278,7 @@ String Particles::get_configuration_warning() const { void Particles::restart() { VisualServer::get_singleton()->particles_restart(particles); + VisualServer::get_singleton()->particles_set_emitting(particles, true); } AABB Particles::capture_aabb() const { diff --git a/scene/3d/sprite_3d.cpp b/scene/3d/sprite_3d.cpp index 6b70eef662..9f73484b6a 100644 --- a/scene/3d/sprite_3d.cpp +++ b/scene/3d/sprite_3d.cpp @@ -163,6 +163,7 @@ float SpriteBase3D::get_opacity() const { void SpriteBase3D::set_axis(Vector3::Axis p_axis) { + ERR_FAIL_INDEX(p_axis, 3); axis = p_axis; _queue_update(); } diff --git a/scene/gui/text_edit.cpp b/scene/gui/text_edit.cpp index 36d7dad1d3..4e86e4bb1e 100644 --- a/scene/gui/text_edit.cpp +++ b/scene/gui/text_edit.cpp @@ -1178,7 +1178,7 @@ void TextEdit::_notification(int p_what) { if (brace_open_mismatch) color = cache.brace_mismatch_color; - drawer.draw_char(ci, Point2i(char_ofs + char_margin + ofs_x, yofs + ascent), '_', str[j + 1], in_selection && override_selected_font_color ? cache.font_selected_color : color); + drawer.draw_char(ci, Point2i(char_ofs + char_margin + ofs_x, yofs + ascent), '_', str[j + 1], in_selection && override_selected_font_color ? cache.font_color_selected : color); } if ((brace_close_match_line == line && brace_close_match_column == last_wrap_column + j) || @@ -1186,7 +1186,7 @@ void TextEdit::_notification(int p_what) { if (brace_close_mismatch) color = cache.brace_mismatch_color; - drawer.draw_char(ci, Point2i(char_ofs + char_margin + ofs_x, yofs + ascent), '_', str[j + 1], in_selection && override_selected_font_color ? cache.font_selected_color : color); + drawer.draw_char(ci, Point2i(char_ofs + char_margin + ofs_x, yofs + ascent), '_', str[j + 1], in_selection && override_selected_font_color ? cache.font_color_selected : color); } } @@ -1258,23 +1258,23 @@ void TextEdit::_notification(int p_what) { if (str[j] >= 32) { int yofs = ofs_y + (get_row_height() - cache.font->get_height()) / 2; - int w = drawer.draw_char(ci, Point2i(char_ofs + char_margin + ofs_x, yofs + ascent), str[j], str[j + 1], in_selection && override_selected_font_color ? cache.font_selected_color : color); + int w = drawer.draw_char(ci, Point2i(char_ofs + char_margin + ofs_x, yofs + ascent), str[j], str[j + 1], in_selection && override_selected_font_color ? cache.font_color_selected : color); if (underlined) { float line_width = 1.0; #ifdef TOOLS_ENABLED line_width *= EDSCALE; #endif - draw_rect(Rect2(char_ofs + char_margin + ofs_x, yofs + ascent + 2, w, line_width), in_selection && override_selected_font_color ? cache.font_selected_color : color); + draw_rect(Rect2(char_ofs + char_margin + ofs_x, yofs + ascent + 2, w, line_width), in_selection && override_selected_font_color ? cache.font_color_selected : color); } } else if (draw_tabs && str[j] == '\t') { int yofs = (get_row_height() - cache.tab_icon->get_height()) / 2; - cache.tab_icon->draw(ci, Point2(char_ofs + char_margin + ofs_x, ofs_y + yofs), in_selection && override_selected_font_color ? cache.font_selected_color : color); + cache.tab_icon->draw(ci, Point2(char_ofs + char_margin + ofs_x, ofs_y + yofs), in_selection && override_selected_font_color ? cache.font_color_selected : color); } if (draw_spaces && str[j] == ' ') { int yofs = (get_row_height() - cache.space_icon->get_height()) / 2; - cache.space_icon->draw(ci, Point2(char_ofs + char_margin + ofs_x, ofs_y + yofs), in_selection && override_selected_font_color ? cache.font_selected_color : color); + cache.space_icon->draw(ci, Point2(char_ofs + char_margin + ofs_x, ofs_y + yofs), in_selection && override_selected_font_color ? cache.font_color_selected : color); } char_ofs += char_w; @@ -4554,7 +4554,7 @@ void TextEdit::_update_caches() { cache.line_number_color = get_color("line_number_color"); cache.safe_line_number_color = get_color("safe_line_number_color"); cache.font_color = get_color("font_color"); - cache.font_selected_color = get_color("font_selected_color"); + cache.font_color_selected = get_color("font_color_selected"); cache.keyword_color = get_color("keyword_color"); cache.function_color = get_color("function_color"); cache.member_variable_color = get_color("member_variable_color"); @@ -6452,6 +6452,7 @@ void TextEdit::_bind_methods() { ClassDB::bind_method(D_METHOD("get_text"), &TextEdit::get_text); ClassDB::bind_method(D_METHOD("get_line", "line"), &TextEdit::get_line); + ClassDB::bind_method(D_METHOD("center_viewport_to_cursor"), &TextEdit::center_viewport_to_cursor); ClassDB::bind_method(D_METHOD("cursor_set_column", "column", "adjust_viewport"), &TextEdit::cursor_set_column, DEFVAL(true)); ClassDB::bind_method(D_METHOD("cursor_set_line", "line", "adjust_viewport", "can_be_hidden", "wrap_index"), &TextEdit::cursor_set_line, DEFVAL(true), DEFVAL(true), DEFVAL(0)); diff --git a/scene/gui/text_edit.h b/scene/gui/text_edit.h index 3e852deda6..c721cf992e 100644 --- a/scene/gui/text_edit.h +++ b/scene/gui/text_edit.h @@ -184,7 +184,7 @@ private: Color line_number_color; Color safe_line_number_color; Color font_color; - Color font_selected_color; + Color font_color_selected; Color keyword_color; Color number_color; Color function_color; diff --git a/scene/resources/texture.cpp b/scene/resources/texture.cpp index 6e0bc43296..3a0144849a 100644 --- a/scene/resources/texture.cpp +++ b/scene/resources/texture.cpp @@ -1502,6 +1502,7 @@ void CubeMap::set_side(Side p_side, const Ref<Image> &p_image) { Ref<Image> CubeMap::get_side(Side p_side) const { + ERR_FAIL_INDEX_V(p_side, 6, Ref<Image>()); if (!valid[p_side]) return Ref<Image>(); return VS::get_singleton()->texture_get_data(cubemap, VS::CubeMapSide(p_side)); diff --git a/scene/resources/tile_set.cpp b/scene/resources/tile_set.cpp index f577a2e144..899abfc9f9 100644 --- a/scene/resources/tile_set.cpp +++ b/scene/resources/tile_set.cpp @@ -721,7 +721,7 @@ void TileSet::tile_set_shape(int p_id, int p_shape_id, const Ref<Shape2D> &p_sha ERR_FAIL_COND(!tile_map.has(p_id)); ERR_FAIL_COND(p_shape_id < 0); - if (tile_map[p_id].shapes_data.size() <= p_shape_id) + if (p_shape_id >= tile_map[p_id].shapes_data.size()) tile_map[p_id].shapes_data.resize(p_shape_id + 1); tile_map[p_id].shapes_data.write[p_shape_id].shape = p_shape; _decompose_convex_shape(p_shape); @@ -731,17 +731,17 @@ void TileSet::tile_set_shape(int p_id, int p_shape_id, const Ref<Shape2D> &p_sha Ref<Shape2D> TileSet::tile_get_shape(int p_id, int p_shape_id) const { ERR_FAIL_COND_V(!tile_map.has(p_id), Ref<Shape2D>()); - ERR_FAIL_INDEX_V(p_shape_id, tile_map[p_id].shapes_data.size(), Ref<Shape2D>()); + if (p_shape_id < tile_map[p_id].shapes_data.size()) + return tile_map[p_id].shapes_data[p_shape_id].shape; - return tile_map[p_id].shapes_data[p_shape_id].shape; + return Ref<Shape2D>(); } void TileSet::tile_set_shape_transform(int p_id, int p_shape_id, const Transform2D &p_offset) { ERR_FAIL_COND(!tile_map.has(p_id)); - ERR_FAIL_INDEX(p_shape_id, tile_map[p_id].shapes_data.size()); - if (tile_map[p_id].shapes_data.size() <= p_shape_id) + if (p_shape_id >= tile_map[p_id].shapes_data.size()) tile_map[p_id].shapes_data.resize(p_shape_id + 1); tile_map[p_id].shapes_data.write[p_shape_id].shape_transform = p_offset; emit_changed(); @@ -750,9 +750,10 @@ void TileSet::tile_set_shape_transform(int p_id, int p_shape_id, const Transform Transform2D TileSet::tile_get_shape_transform(int p_id, int p_shape_id) const { ERR_FAIL_COND_V(!tile_map.has(p_id), Transform2D()); - ERR_FAIL_INDEX_V(p_shape_id, tile_map[p_id].shapes_data.size(), Transform2D()); + if (p_shape_id < tile_map[p_id].shapes_data.size()) + return tile_map[p_id].shapes_data[p_shape_id].shape_transform; - return tile_map[p_id].shapes_data[p_shape_id].shape_transform; + return Transform2D(); } void TileSet::tile_set_shape_offset(int p_id, int p_shape_id, const Vector2 &p_offset) { @@ -770,7 +771,7 @@ void TileSet::tile_set_shape_one_way(int p_id, int p_shape_id, const bool p_one_ ERR_FAIL_COND(!tile_map.has(p_id)); ERR_FAIL_COND(p_shape_id < 0); - if (tile_map[p_id].shapes_data.size() <= p_shape_id) + if (p_shape_id >= tile_map[p_id].shapes_data.size()) tile_map[p_id].shapes_data.resize(p_shape_id + 1); tile_map[p_id].shapes_data.write[p_shape_id].one_way_collision = p_one_way; emit_changed(); @@ -779,9 +780,10 @@ void TileSet::tile_set_shape_one_way(int p_id, int p_shape_id, const bool p_one_ bool TileSet::tile_get_shape_one_way(int p_id, int p_shape_id) const { ERR_FAIL_COND_V(!tile_map.has(p_id), false); - ERR_FAIL_INDEX_V(p_shape_id, tile_map[p_id].shapes_data.size(), false); + if (p_shape_id < tile_map[p_id].shapes_data.size()) + return tile_map[p_id].shapes_data[p_shape_id].one_way_collision; - return tile_map[p_id].shapes_data[p_shape_id].one_way_collision; + return false; } void TileSet::tile_set_shape_one_way_margin(int p_id, int p_shape_id, float p_margin) { @@ -789,7 +791,7 @@ void TileSet::tile_set_shape_one_way_margin(int p_id, int p_shape_id, float p_ma ERR_FAIL_COND(!tile_map.has(p_id)); ERR_FAIL_COND(p_shape_id < 0); - if (tile_map[p_id].shapes_data.size() <= p_shape_id) + if (p_shape_id >= tile_map[p_id].shapes_data.size()) tile_map[p_id].shapes_data.resize(p_shape_id + 1); tile_map[p_id].shapes_data.write[p_shape_id].one_way_collision_margin = p_margin; emit_changed(); @@ -798,9 +800,10 @@ void TileSet::tile_set_shape_one_way_margin(int p_id, int p_shape_id, float p_ma float TileSet::tile_get_shape_one_way_margin(int p_id, int p_shape_id) const { ERR_FAIL_COND_V(!tile_map.has(p_id), 0); - ERR_FAIL_INDEX_V(p_shape_id, tile_map[p_id].shapes_data.size(), 0.0); + if (p_shape_id < tile_map[p_id].shapes_data.size()) + return tile_map[p_id].shapes_data[p_shape_id].one_way_collision_margin; - return tile_map[p_id].shapes_data[p_shape_id].one_way_collision_margin; + return 0; } void TileSet::tile_set_light_occluder(int p_id, const Ref<OccluderPolygon2D> &p_light_occluder) { diff --git a/scene/resources/visual_shader.cpp b/scene/resources/visual_shader.cpp index dd595d9ff8..a3813f8fc6 100644 --- a/scene/resources/visual_shader.cpp +++ b/scene/resources/visual_shader.cpp @@ -1762,6 +1762,7 @@ void VisualShaderNodeGroupBase::set_inputs(const String &p_inputs) { for (int i = 0; i < input_port_count; i++) { Vector<String> arr = input_strings[i].split(","); + ERR_FAIL_COND(arr.size() != 3); int port_idx = arr[0].to_int(); int port_type = arr[1].to_int(); @@ -1794,6 +1795,7 @@ void VisualShaderNodeGroupBase::set_outputs(const String &p_outputs) { for (int i = 0; i < output_port_count; i++) { Vector<String> arr = output_strings[i].split(","); + ERR_FAIL_COND(arr.size() != 3); int port_idx = arr[0].to_int(); int port_type = arr[1].to_int(); @@ -1810,6 +1812,23 @@ String VisualShaderNodeGroupBase::get_outputs() const { return outputs; } +bool VisualShaderNodeGroupBase::is_valid_port_name(const String &p_name) const { + if (!p_name.is_valid_identifier()) { + return false; + } + for (int i = 0; i < get_input_port_count(); i++) { + if (get_input_port_name(i) == p_name) { + return false; + } + } + for (int i = 0; i < get_output_port_count(); i++) { + if (get_output_port_name(i) == p_name) { + return false; + } + } + return true; +} + void VisualShaderNodeGroupBase::add_input_port(int p_id, int p_type, const String &p_name) { String str = itos(p_id) + "," + itos(p_type) + "," + p_name + ";"; @@ -1849,6 +1868,8 @@ void VisualShaderNodeGroupBase::add_input_port(int p_id, int p_type, const Strin void VisualShaderNodeGroupBase::remove_input_port(int p_id) { + ERR_FAIL_COND(!has_input_port(p_id)); + Vector<String> inputs_strings = inputs.split(";", false); int count = 0; int index = 0; @@ -1917,6 +1938,8 @@ void VisualShaderNodeGroupBase::add_output_port(int p_id, int p_type, const Stri void VisualShaderNodeGroupBase::remove_output_port(int p_id) { + ERR_FAIL_COND(!has_output_port(p_id)); + Vector<String> outputs_strings = outputs.split(";", false); int count = 0; int index = 0; @@ -1956,6 +1979,9 @@ void VisualShaderNodeGroupBase::clear_output_ports() { void VisualShaderNodeGroupBase::set_input_port_type(int p_id, int p_type) { + ERR_FAIL_COND(!has_input_port(p_id)); + ERR_FAIL_COND(p_type < 0 || p_type > PORT_TYPE_TRANSFORM); + if (input_ports[p_id].type == p_type) return; @@ -1986,6 +2012,9 @@ VisualShaderNodeGroupBase::PortType VisualShaderNodeGroupBase::get_input_port_ty void VisualShaderNodeGroupBase::set_input_port_name(int p_id, const String &p_name) { + ERR_FAIL_COND(!has_input_port(p_id)); + ERR_FAIL_COND(!is_valid_port_name(p_name)); + if (input_ports[p_id].name == p_name) return; @@ -2016,6 +2045,9 @@ String VisualShaderNodeGroupBase::get_input_port_name(int p_id) const { void VisualShaderNodeGroupBase::set_output_port_type(int p_id, int p_type) { + ERR_FAIL_COND(!has_output_port(p_id)); + ERR_FAIL_COND(p_type < 0 || p_type > PORT_TYPE_TRANSFORM); + if (output_ports[p_id].type == p_type) return; @@ -2045,6 +2077,10 @@ VisualShaderNodeGroupBase::PortType VisualShaderNodeGroupBase::get_output_port_t } void VisualShaderNodeGroupBase::set_output_port_name(int p_id, const String &p_name) { + + ERR_FAIL_COND(!has_output_port(p_id)); + ERR_FAIL_COND(!is_valid_port_name(p_name)); + if (output_ports[p_id].name == p_name) return; @@ -2125,6 +2161,8 @@ void VisualShaderNodeGroupBase::_bind_methods() { ClassDB::bind_method(D_METHOD("set_outputs", "outputs"), &VisualShaderNodeGroupBase::set_outputs); ClassDB::bind_method(D_METHOD("get_outputs"), &VisualShaderNodeGroupBase::get_outputs); + ClassDB::bind_method(D_METHOD("is_valid_port_name", "name"), &VisualShaderNodeGroupBase::is_valid_port_name); + ClassDB::bind_method(D_METHOD("add_input_port", "id", "type", "name"), &VisualShaderNodeGroupBase::add_input_port); ClassDB::bind_method(D_METHOD("remove_input_port", "id"), &VisualShaderNodeGroupBase::remove_input_port); ClassDB::bind_method(D_METHOD("get_input_port_count"), &VisualShaderNodeGroupBase::get_input_port_count); diff --git a/scene/resources/visual_shader.h b/scene/resources/visual_shader.h index 1ab3c0c9cc..a36776e701 100644 --- a/scene/resources/visual_shader.h +++ b/scene/resources/visual_shader.h @@ -355,6 +355,8 @@ public: void set_outputs(const String &p_outputs); String get_outputs() const; + bool is_valid_port_name(const String &p_name) const; + void add_input_port(int p_id, int p_type, const String &p_name); void remove_input_port(int p_id); virtual int get_input_port_count() const; |