diff options
author | Hein-Pieter van Braam <hp@tmm.cx> | 2018-07-25 03:11:03 +0200 |
---|---|---|
committer | Hein-Pieter van Braam <hp@tmm.cx> | 2018-07-26 00:54:16 +0200 |
commit | 0e29f7974b59e4440cf02e1388fb9d8ab2b5c5fd (patch) | |
tree | 18b7ff35f1eeee39031a16e9c1d834ebf03d44cf /editor | |
parent | 9423f23ffb80c946dec380f73f3f313ec44d0d18 (diff) |
Reduce unnecessary COW on Vector by make writing explicit
This commit makes operator[] on Vector const and adds a write proxy to it. From
now on writes to Vectors need to happen through the .write proxy. So for
instance:
Vector<int> vec;
vec.push_back(10);
std::cout << vec[0] << std::endl;
vec.write[0] = 20;
Failing to use the .write proxy will cause a compilation error.
In addition COWable datatypes can now embed a CowData pointer to their data.
This means that String, CharString, and VMap no longer use or derive from
Vector.
_ALWAYS_INLINE_ and _FORCE_INLINE_ are now equivalent for debug and non-debug
builds. This is a lot faster for Vector in the editor and while running tests.
The reason why this difference used to exist is because force-inlined methods
used to give a bad debugging experience. After extensive testing with modern
compilers this is no longer the case.
Diffstat (limited to 'editor')
49 files changed, 264 insertions, 264 deletions
diff --git a/editor/animation_track_editor.cpp b/editor/animation_track_editor.cpp index 42d5ea120e..ffa179b093 100644 --- a/editor/animation_track_editor.cpp +++ b/editor/animation_track_editor.cpp @@ -231,10 +231,10 @@ public: if (Variant::can_convert(args[idx].get_type(), t)) { Variant old = args[idx]; Variant *ptrs[1] = { &old }; - args[idx] = Variant::construct(t, (const Variant **)ptrs, 1, err); + args.write[idx] = Variant::construct(t, (const Variant **)ptrs, 1, err); } else { - args[idx] = Variant::construct(t, NULL, 0, err); + args.write[idx] = Variant::construct(t, NULL, 0, err); } change_notify_deserved = true; d_new["args"] = args; @@ -248,7 +248,7 @@ public: _fix_node_path(value); } - args[idx] = value; + args.write[idx] = value; d_new["args"] = args; mergeable = true; } @@ -3316,7 +3316,7 @@ void AnimationTrackEditor::_update_tracks() { } for (int j = 0; j < track_edit_plugins.size(); j++) { - track_edit = track_edit_plugins[j]->create_value_track_edit(object, pinfo.type, pinfo.name, pinfo.hint, pinfo.hint_string, pinfo.usage); + track_edit = track_edit_plugins.write[j]->create_value_track_edit(object, pinfo.type, pinfo.name, pinfo.hint, pinfo.hint_string, pinfo.usage); if (track_edit) { break; } @@ -3327,7 +3327,7 @@ void AnimationTrackEditor::_update_tracks() { if (animation->track_get_type(i) == Animation::TYPE_AUDIO) { for (int j = 0; j < track_edit_plugins.size(); j++) { - track_edit = track_edit_plugins[j]->create_audio_track_edit(); + track_edit = track_edit_plugins.write[j]->create_audio_track_edit(); if (track_edit) { break; } @@ -3344,7 +3344,7 @@ void AnimationTrackEditor::_update_tracks() { if (node && Object::cast_to<AnimationPlayer>(node)) { for (int j = 0; j < track_edit_plugins.size(); j++) { - track_edit = track_edit_plugins[j]->create_animation_track_edit(node); + track_edit = track_edit_plugins.write[j]->create_animation_track_edit(node); if (track_edit) { break; } diff --git a/editor/animation_track_editor_plugins.cpp b/editor/animation_track_editor_plugins.cpp index d0c91f10d9..6d444c5422 100644 --- a/editor/animation_track_editor_plugins.cpp +++ b/editor/animation_track_editor_plugins.cpp @@ -271,8 +271,8 @@ void AnimationTrackEditAudio::draw_key(int p_index, float p_pixels_sec, int p_x, float min = preview->get_min(ofs, ofs_n) * 0.5 + 0.5; int idx = i - from_x; - lines[idx * 2 + 0] = Vector2(i, rect.position.y + min * rect.size.y); - lines[idx * 2 + 1] = Vector2(i, rect.position.y + max * rect.size.y); + lines.write[idx * 2 + 0] = Vector2(i, rect.position.y + min * rect.size.y); + lines.write[idx * 2 + 1] = Vector2(i, rect.position.y + max * rect.size.y); } Vector<Color> color; @@ -883,8 +883,8 @@ void AnimationTrackEditTypeAudio::draw_key(int p_index, float p_pixels_sec, int float min = preview->get_min(ofs, ofs_n) * 0.5 + 0.5; int idx = i - from_x; - lines[idx * 2 + 0] = Vector2(i, rect.position.y + min * rect.size.y); - lines[idx * 2 + 1] = Vector2(i, rect.position.y + max * rect.size.y); + lines.write[idx * 2 + 0] = Vector2(i, rect.position.y + min * rect.size.y); + lines.write[idx * 2 + 1] = Vector2(i, rect.position.y + max * rect.size.y); } Vector<Color> color; diff --git a/editor/audio_stream_preview.cpp b/editor/audio_stream_preview.cpp index 6ee4d7f4b0..6ae5ec43a9 100644 --- a/editor/audio_stream_preview.cpp +++ b/editor/audio_stream_preview.cpp @@ -118,8 +118,8 @@ void AudioStreamPreviewGenerator::_preview_thread(void *p_preview) { uint8_t pfrom = CLAMP((min * 0.5 + 0.5) * 255, 0, 255); uint8_t pto = CLAMP((max * 0.5 + 0.5) * 255, 0, 255); - preview->preview->preview[(ofs_write + i) * 2 + 0] = pfrom; - preview->preview->preview[(ofs_write + i) * 2 + 1] = pto; + preview->preview->preview.write[(ofs_write + i) * 2 + 0] = pfrom; + preview->preview->preview.write[(ofs_write + i) * 2 + 1] = pto; } frames_todo -= to_read; diff --git a/editor/code_editor.cpp b/editor/code_editor.cpp index 925f97de8e..4ce8556add 100644 --- a/editor/code_editor.cpp +++ b/editor/code_editor.cpp @@ -725,7 +725,7 @@ void CodeTextEditor::_complete_request() { int i = 0; for (List<String>::Element *E = entries.front(); E; E = E->next()) { - strs[i++] = E->get(); + strs.write[i++] = E->get(); } text_editor->code_complete(strs, forced); diff --git a/editor/collada/collada.cpp b/editor/collada/collada.cpp index 734229d014..fa7e37eb1f 100644 --- a/editor/collada/collada.cpp +++ b/editor/collada/collada.cpp @@ -191,7 +191,7 @@ Transform Collada::Node::get_global_transform() const { return default_transform; } -Vector<float> Collada::AnimationTrack::get_value_at_time(float p_time) { +Vector<float> Collada::AnimationTrack::get_value_at_time(float p_time) const { ERR_FAIL_COND_V(keys.size() == 0, Vector<float>()); int i = 0; @@ -225,22 +225,22 @@ Vector<float> Collada::AnimationTrack::get_value_at_time(float p_time) { ret.resize(16); Transform tr; // i wonder why collada matrices are transposed, given that's opposed to opengl.. - ret[0] = interp.basis.elements[0][0]; - ret[1] = interp.basis.elements[0][1]; - ret[2] = interp.basis.elements[0][2]; - ret[4] = interp.basis.elements[1][0]; - ret[5] = interp.basis.elements[1][1]; - ret[6] = interp.basis.elements[1][2]; - ret[8] = interp.basis.elements[2][0]; - ret[9] = interp.basis.elements[2][1]; - ret[10] = interp.basis.elements[2][2]; - ret[3] = interp.origin.x; - ret[7] = interp.origin.y; - ret[11] = interp.origin.z; - ret[12] = 0; - ret[13] = 0; - ret[14] = 0; - ret[15] = 1; + ret.write[0] = interp.basis.elements[0][0]; + ret.write[1] = interp.basis.elements[0][1]; + ret.write[2] = interp.basis.elements[0][2]; + ret.write[4] = interp.basis.elements[1][0]; + ret.write[5] = interp.basis.elements[1][1]; + ret.write[6] = interp.basis.elements[1][2]; + ret.write[8] = interp.basis.elements[2][0]; + ret.write[9] = interp.basis.elements[2][1]; + ret.write[10] = interp.basis.elements[2][2]; + ret.write[3] = interp.origin.x; + ret.write[7] = interp.origin.y; + ret.write[11] = interp.origin.z; + ret.write[12] = 0; + ret.write[13] = 0; + ret.write[14] = 0; + ret.write[15] = 1; return ret; } else { @@ -249,7 +249,7 @@ Vector<float> Collada::AnimationTrack::get_value_at_time(float p_time) { dest.resize(keys[i].data.size()); for (int j = 0; j < dest.size(); j++) { - dest[j] = keys[i].data[j] * c + keys[i - 1].data[j] * (1.0 - c); + dest.write[j] = keys[i].data[j] * c + keys[i - 1].data[j] * (1.0 - c); } return dest; //interpolate one by one @@ -452,7 +452,7 @@ Transform Collada::_read_transform(XMLParser &parser) { Vector<float> farr; farr.resize(16); for (int i = 0; i < 16; i++) { - farr[i] = array[i].to_double(); + farr.write[i] = array[i].to_double(); } return _read_transform_from_array(farr); @@ -1104,7 +1104,7 @@ void Collada::_parse_mesh_geometry(XMLParser &parser, String p_id, String p_name int from = prim.indices.size(); prim.indices.resize(from + values.size()); for (int i = 0; i < values.size(); i++) - prim.indices[from + i] = values[i]; + prim.indices.write[from + i] = values[i]; } else if (prim.vertex_size > 0) { prim.indices = values; @@ -1884,7 +1884,7 @@ void Collada::_parse_animation(XMLParser &parser) { track.keys.resize(key_count); for (int j = 0; j < key_count; j++) { - track.keys[j].time = time_keys[j]; + track.keys.write[j].time = time_keys[j]; state.animation_length = MAX(state.animation_length, time_keys[j]); } @@ -1905,9 +1905,9 @@ void Collada::_parse_animation(XMLParser &parser) { ERR_CONTINUE((output.size() / stride) != key_count); for (int j = 0; j < key_count; j++) { - track.keys[j].data.resize(output_len); + track.keys.write[j].data.resize(output_len); for (int k = 0; k < output_len; k++) - track.keys[j].data[k] = output[l + j * stride + k]; //super weird but should work: + track.keys.write[j].data.write[k] = output[l + j * stride + k]; //super weird but should work: } if (sampler.has("INTERPOLATION")) { @@ -1919,9 +1919,9 @@ void Collada::_parse_animation(XMLParser &parser) { for (int j = 0; j < key_count; j++) { if (interps[j] == "BEZIER") - track.keys[j].interp_type = AnimationTrack::INTERP_BEZIER; + track.keys.write[j].interp_type = AnimationTrack::INTERP_BEZIER; else - track.keys[j].interp_type = AnimationTrack::INTERP_LINEAR; + track.keys.write[j].interp_type = AnimationTrack::INTERP_LINEAR; } } @@ -1939,8 +1939,8 @@ void Collada::_parse_animation(XMLParser &parser) { ERR_CONTINUE(outangents.size() != key_count * 2 * names.size()); for (int j = 0; j < key_count; j++) { - track.keys[j].in_tangent = Vector2(intangents[j * 2 * names.size() + 0 + l * 2], intangents[j * 2 * names.size() + 1 + l * 2]); - track.keys[j].out_tangent = Vector2(outangents[j * 2 * names.size() + 0 + l * 2], outangents[j * 2 * names.size() + 1 + l * 2]); + track.keys.write[j].in_tangent = Vector2(intangents[j * 2 * names.size() + 0 + l * 2], intangents[j * 2 * names.size() + 1 + l * 2]); + track.keys.write[j].out_tangent = Vector2(outangents[j * 2 * names.size() + 0 + l * 2], outangents[j * 2 * names.size() + 1 + l * 2]); } } @@ -2118,7 +2118,7 @@ void Collada::_joint_set_owner(Collada::Node *p_node, NodeSkeleton *p_owner) { for (int i = 0; i < nj->children.size(); i++) { - _joint_set_owner(nj->children[i], p_owner); + _joint_set_owner(nj->children.write[i], p_owner); } } } @@ -2147,7 +2147,7 @@ void Collada::_create_skeletons(Collada::Node **p_node, NodeSkeleton *p_skeleton } for (int i = 0; i < node->children.size(); i++) { - _create_skeletons(&node->children[i], p_skeleton); + _create_skeletons(&node->children.write[i], p_skeleton); } } @@ -2314,7 +2314,7 @@ bool Collada::_optimize_skeletons(VisualScene *p_vscene, Node *p_node) { for (int i = 0; i < gp->children.size(); i++) { if (gp->children[i] == parent) { - gp->children[i] = node; + gp->children.write[i] = node; found = true; break; } @@ -2330,7 +2330,7 @@ bool Collada::_optimize_skeletons(VisualScene *p_vscene, Node *p_node) { if (p_vscene->root_nodes[i] == parent) { - p_vscene->root_nodes[i] = node; + p_vscene->root_nodes.write[i] = node; found = true; break; } @@ -2466,7 +2466,7 @@ void Collada::_optimize() { VisualScene &vs = E->get(); for (int i = 0; i < vs.root_nodes.size(); i++) { - _create_skeletons(&vs.root_nodes[i]); + _create_skeletons(&vs.root_nodes.write[i]); } for (int i = 0; i < vs.root_nodes.size(); i++) { diff --git a/editor/collada/collada.h b/editor/collada/collada.h index ec3284bc5c..7535162f74 100644 --- a/editor/collada/collada.h +++ b/editor/collada/collada.h @@ -312,7 +312,7 @@ public: total += weights[i].weight; if (total) for (int i = 0; i < 4; i++) - weights[i].weight /= total; + weights.write[i].weight /= total; } } @@ -515,7 +515,7 @@ public: Key() { interp_type = INTERP_LINEAR; } }; - Vector<float> get_value_at_time(float p_time); + Vector<float> get_value_at_time(float p_time) const; Vector<Key> keys; diff --git a/editor/connections_dialog.cpp b/editor/connections_dialog.cpp index c4f4e28fec..da73a3930a 100644 --- a/editor/connections_dialog.cpp +++ b/editor/connections_dialog.cpp @@ -51,7 +51,7 @@ public: if (name.begins_with("bind/")) { int which = name.get_slice("/", 1).to_int() - 1; ERR_FAIL_INDEX_V(which, params.size(), false); - params[which] = p_value; + params.write[which] = p_value; } else return false; diff --git a/editor/doc/doc_data.cpp b/editor/doc/doc_data.cpp index 542dca74e0..2803762973 100644 --- a/editor/doc/doc_data.cpp +++ b/editor/doc/doc_data.cpp @@ -58,7 +58,7 @@ void DocData::merge_from(const DocData &p_data) { for (int i = 0; i < c.methods.size(); i++) { - MethodDoc &m = c.methods[i]; + MethodDoc &m = c.methods.write[i]; for (int j = 0; j < cf.methods.size(); j++) { @@ -72,13 +72,13 @@ void DocData::merge_from(const DocData &p_data) { Vector<bool> arg_used; arg_used.resize(arg_count); for (int l = 0; l < arg_count; ++l) - arg_used[l] = false; + arg_used.write[l] = false; // also there is no guarantee that argument ordering will match, so we // have to check one by one so we make sure we have an exact match for (int k = 0; k < arg_count; ++k) { for (int l = 0; l < arg_count; ++l) if (cf.methods[j].arguments[k].type == m.arguments[l].type && !arg_used[l]) { - arg_used[l] = true; + arg_used.write[l] = true; break; } } @@ -98,7 +98,7 @@ void DocData::merge_from(const DocData &p_data) { for (int i = 0; i < c.signals.size(); i++) { - MethodDoc &m = c.signals[i]; + MethodDoc &m = c.signals.write[i]; for (int j = 0; j < cf.signals.size(); j++) { @@ -113,7 +113,7 @@ void DocData::merge_from(const DocData &p_data) { for (int i = 0; i < c.constants.size(); i++) { - ConstantDoc &m = c.constants[i]; + ConstantDoc &m = c.constants.write[i]; for (int j = 0; j < cf.constants.size(); j++) { @@ -128,7 +128,7 @@ void DocData::merge_from(const DocData &p_data) { for (int i = 0; i < c.properties.size(); i++) { - PropertyDoc &p = c.properties[i]; + PropertyDoc &p = c.properties.write[i]; for (int j = 0; j < cf.properties.size(); j++) { @@ -146,7 +146,7 @@ void DocData::merge_from(const DocData &p_data) { for (int i = 0; i < c.theme_properties.size(); i++) { - PropertyDoc &p = c.theme_properties[i]; + PropertyDoc &p = c.theme_properties.write[i]; for (int j = 0; j < cf.theme_properties.size(); j++) { @@ -1020,7 +1020,7 @@ Error DocData::save_classes(const String &p_default_path, const Map<String, Stri for (int i = 0; i < c.methods.size(); i++) { - MethodDoc &m = c.methods[i]; + const MethodDoc &m = c.methods[i]; String qualifiers; if (m.qualifiers != "") @@ -1040,7 +1040,7 @@ Error DocData::save_classes(const String &p_default_path, const Map<String, Stri for (int j = 0; j < m.arguments.size(); j++) { - ArgumentDoc &a = m.arguments[j]; + const ArgumentDoc &a = m.arguments[j]; String enum_text; if (a.enumeration != String()) { @@ -1075,7 +1075,7 @@ Error DocData::save_classes(const String &p_default_path, const Map<String, Stri if (c.properties[i].enumeration != String()) { enum_text = " enum=\"" + c.properties[i].enumeration + "\""; } - PropertyDoc &p = c.properties[i]; + const PropertyDoc &p = c.properties[i]; _write_string(f, 2, "<member name=\"" + p.name + "\" type=\"" + p.type + "\" setter=\"" + p.setter + "\" getter=\"" + p.getter + "\"" + enum_text + ">"); _write_string(f, 3, p.description.strip_edges().xml_escape()); _write_string(f, 2, "</member>"); @@ -1090,11 +1090,11 @@ Error DocData::save_classes(const String &p_default_path, const Map<String, Stri _write_string(f, 1, "<signals>"); for (int i = 0; i < c.signals.size(); i++) { - MethodDoc &m = c.signals[i]; + const MethodDoc &m = c.signals[i]; _write_string(f, 2, "<signal name=\"" + m.name + "\">"); for (int j = 0; j < m.arguments.size(); j++) { - ArgumentDoc &a = m.arguments[j]; + const ArgumentDoc &a = m.arguments[j]; _write_string(f, 3, "<argument index=\"" + itos(j) + "\" name=\"" + a.name.xml_escape() + "\" type=\"" + a.type.xml_escape() + "\">"); _write_string(f, 3, "</argument>"); } @@ -1113,7 +1113,7 @@ Error DocData::save_classes(const String &p_default_path, const Map<String, Stri for (int i = 0; i < c.constants.size(); i++) { - ConstantDoc &k = c.constants[i]; + const ConstantDoc &k = c.constants[i]; if (k.enumeration != String()) { _write_string(f, 2, "<constant name=\"" + k.name + "\" value=\"" + k.value + "\" enum=\"" + k.enumeration + "\">"); } else { @@ -1132,7 +1132,7 @@ Error DocData::save_classes(const String &p_default_path, const Map<String, Stri _write_string(f, 1, "<theme_items>"); for (int i = 0; i < c.theme_properties.size(); i++) { - PropertyDoc &p = c.theme_properties[i]; + const PropertyDoc &p = c.theme_properties[i]; _write_string(f, 2, "<theme_item name=\"" + p.name + "\" type=\"" + p.type + "\">"); _write_string(f, 2, "</theme_item>"); } diff --git a/editor/editor_autoload_settings.cpp b/editor/editor_autoload_settings.cpp index 2f0982e5d9..d12c85861b 100644 --- a/editor/editor_autoload_settings.cpp +++ b/editor/editor_autoload_settings.cpp @@ -598,7 +598,7 @@ void EditorAutoloadSettings::drop_data_fw(const Point2 &p_point, const Variant & int i = 0; for (List<AutoLoadInfo>::Element *E = autoload_cache.front(); E; E = E->next()) { - orders[i++] = E->get().order; + orders.write[i++] = E->get().order; } orders.sort(); diff --git a/editor/editor_data.cpp b/editor/editor_data.cpp index 4dde893c6d..729f6f50ef 100644 --- a/editor/editor_data.cpp +++ b/editor/editor_data.cpp @@ -62,7 +62,7 @@ void EditorHistory::cleanup_history() { fail = true; } else { //after level, clip - history[i].path.resize(j); + history.write[i].path.resize(j); } break; @@ -100,14 +100,14 @@ void EditorHistory::_add_object(ObjectID p_object, const String &p_property, int if (p_property != "" && has_prev) { //add a sub property - History &pr = history[current]; + History &pr = history.write[current]; h = pr; h.path.resize(h.level + 1); h.path.push_back(o); h.level++; } else if (p_level_change != -1 && has_prev) { //add a sub property - History &pr = history[current]; + History &pr = history.write[current]; h = pr; ERR_FAIL_INDEX(p_level_change, h.path.size()); h.level = p_level_change; @@ -206,7 +206,7 @@ ObjectID EditorHistory::get_current() { if (current < 0 || current >= history.size()) return 0; - History &h = history[current]; + History &h = history.write[current]; Object *obj = ObjectDB::get_instance(h.path[h.level].object); if (!obj) return 0; @@ -558,7 +558,7 @@ void EditorData::move_edited_scene_index(int p_idx, int p_to_idx) { ERR_FAIL_INDEX(p_idx, edited_scene.size()); ERR_FAIL_INDEX(p_to_idx, edited_scene.size()); - SWAP(edited_scene[p_idx], edited_scene[p_to_idx]); + SWAP(edited_scene.write[p_idx], edited_scene.write[p_to_idx]); } void EditorData::remove_scene(int p_idx) { ERR_FAIL_INDEX(p_idx, edited_scene.size()); @@ -644,7 +644,7 @@ bool EditorData::check_and_update_scene(int p_idx) { //transfer selection List<Node *> new_selection; - for (List<Node *>::Element *E = edited_scene[p_idx].selection.front(); E; E = E->next()) { + for (List<Node *>::Element *E = edited_scene.write[p_idx].selection.front(); E; E = E->next()) { NodePath p = edited_scene[p_idx].root->get_path_to(E->get()); Node *new_node = new_scene->get_node(p); if (new_node) @@ -654,8 +654,8 @@ bool EditorData::check_and_update_scene(int p_idx) { new_scene->set_filename(edited_scene[p_idx].root->get_filename()); memdelete(edited_scene[p_idx].root); - edited_scene[p_idx].root = new_scene; - edited_scene[p_idx].selection = new_selection; + edited_scene.write[p_idx].root = new_scene; + edited_scene.write[p_idx].selection = new_selection; return true; } @@ -685,7 +685,7 @@ Node *EditorData::get_edited_scene_root(int p_idx) { void EditorData::set_edited_scene_root(Node *p_root) { ERR_FAIL_INDEX(current_edited_scene, edited_scene.size()); - edited_scene[current_edited_scene].root = p_root; + edited_scene.write[current_edited_scene].root = p_root; } int EditorData::get_edited_scene_count() const { @@ -707,10 +707,10 @@ Vector<EditorData::EditedScene> EditorData::get_edited_scenes() const { void EditorData::set_edited_scene_version(uint64_t version, int p_scene_idx) { ERR_FAIL_INDEX(current_edited_scene, edited_scene.size()); if (p_scene_idx < 0) { - edited_scene[current_edited_scene].version = version; + edited_scene.write[current_edited_scene].version = version; } else { ERR_FAIL_INDEX(p_scene_idx, edited_scene.size()); - edited_scene[p_scene_idx].version = version; + edited_scene.write[p_scene_idx].version = version; } } @@ -793,7 +793,7 @@ String EditorData::get_scene_path(int p_idx) const { void EditorData::set_edited_scene_live_edit_root(const NodePath &p_root) { ERR_FAIL_INDEX(current_edited_scene, edited_scene.size()); - edited_scene[current_edited_scene].live_edit_root = p_root; + edited_scene.write[current_edited_scene].live_edit_root = p_root; } NodePath EditorData::get_edited_scene_live_edit_root() { @@ -806,7 +806,7 @@ void EditorData::save_edited_scene_state(EditorSelection *p_selection, EditorHis ERR_FAIL_INDEX(current_edited_scene, edited_scene.size()); - EditedScene &es = edited_scene[current_edited_scene]; + EditedScene &es = edited_scene.write[current_edited_scene]; es.selection = p_selection->get_selected_node_list(); es.history_current = p_history->current; es.history_stored = p_history->history; @@ -817,7 +817,7 @@ void EditorData::save_edited_scene_state(EditorSelection *p_selection, EditorHis Dictionary EditorData::restore_edited_scene_state(EditorSelection *p_selection, EditorHistory *p_history) { ERR_FAIL_INDEX_V(current_edited_scene, edited_scene.size(), Dictionary()); - EditedScene &es = edited_scene[current_edited_scene]; + EditedScene &es = edited_scene.write[current_edited_scene]; p_history->current = es.history_current; p_history->history = es.history_stored; diff --git a/editor/editor_export.cpp b/editor/editor_export.cpp index 317fffad64..5c911a00ca 100644 --- a/editor/editor_export.cpp +++ b/editor/editor_export.cpp @@ -187,7 +187,7 @@ void EditorExportPreset::remove_patch(int p_idx) { void EditorExportPreset::set_patch(int p_index, const String &p_path) { ERR_FAIL_INDEX(p_index, patches.size()); - patches[p_index] = p_path; + patches.write[p_index] = p_path; EditorExport::singleton->save_presets(); } String EditorExportPreset::get_patch(int p_index) { @@ -295,7 +295,7 @@ Error EditorExportPlatform::_save_pack_file(void *p_userdata, const String &p_pa MD5Final(&ctx); sd.md5.resize(16); for (int i = 0; i < 16; i++) { - sd.md5[i] = ctx.digest[i]; + sd.md5.write[i] = ctx.digest[i]; } } @@ -584,9 +584,9 @@ EditorExportPlatform::ExportNotifier::ExportNotifier(EditorExportPlatform &p_pla //initial export plugin callback for (int i = 0; i < export_plugins.size(); i++) { if (export_plugins[i]->get_script_instance()) { //script based - export_plugins[i]->_export_begin_script(features.features_pv, p_debug, p_path, p_flags); + export_plugins.write[i]->_export_begin_script(features.features_pv, p_debug, p_path, p_flags); } else { - export_plugins[i]->_export_begin(features.features, p_debug, p_path, p_flags); + export_plugins.write[i]->_export_begin(features.features, p_debug, p_path, p_flags); } } } @@ -594,7 +594,7 @@ EditorExportPlatform::ExportNotifier::ExportNotifier(EditorExportPlatform &p_pla EditorExportPlatform::ExportNotifier::~ExportNotifier() { Vector<Ref<EditorExportPlugin> > export_plugins = EditorExport::get_singleton()->get_export_plugins(); for (int i = 0; i < export_plugins.size(); i++) { - export_plugins[i]->_export_end(); + export_plugins.write[i]->_export_end(); } } @@ -632,7 +632,7 @@ Error EditorExportPlatform::export_project_files(const Ref<EditorExportPreset> & p_func(p_udata, export_plugins[i]->extra_files[j].path, export_plugins[i]->extra_files[j].data, 0, paths.size()); } - export_plugins[i]->_clear(); + export_plugins.write[i]->_clear(); } FeatureContainers feature_containers = get_feature_containers(p_preset); @@ -687,9 +687,9 @@ Error EditorExportPlatform::export_project_files(const Ref<EditorExportPreset> & bool do_export = true; for (int i = 0; i < export_plugins.size(); i++) { if (export_plugins[i]->get_script_instance()) { //script based - export_plugins[i]->_export_file_script(path, type, features_pv); + export_plugins.write[i]->_export_file_script(path, type, features_pv); } else { - export_plugins[i]->_export_file(path, type, features); + export_plugins.write[i]->_export_file(path, type, features); } if (p_so_func) { for (int j = 0; j < export_plugins[i]->shared_objects.size(); j++) { @@ -709,7 +709,7 @@ Error EditorExportPlatform::export_project_files(const Ref<EditorExportPreset> & if (export_plugins[i]->skipped) { do_export = false; } - export_plugins[i]->_clear(); + export_plugins.write[i]->_clear(); if (!do_export) break; //apologies, not exporting @@ -751,7 +751,7 @@ Error EditorExportPlatform::export_project_files(const Ref<EditorExportPreset> & Vector<uint8_t> new_file; new_file.resize(utf8.length()); for (int j = 0; j < utf8.length(); j++) { - new_file[j] = utf8[j]; + new_file.write[j] = utf8[j]; } p_func(p_udata, from + ".remap", new_file, idx, total); @@ -1130,7 +1130,7 @@ void EditorExport::load_config() { for (int i = 0; i < export_platforms.size(); i++) { if (export_platforms[i]->get_name() == platform) { - preset = export_platforms[i]->create_preset(); + preset = export_platforms.write[i]->create_preset(); break; } } @@ -1203,7 +1203,7 @@ bool EditorExport::poll_export_platforms() { bool changed = false; for (int i = 0; i < export_platforms.size(); i++) { - if (export_platforms[i]->poll_devices()) { + if (export_platforms.write[i]->poll_devices()) { changed = true; } } diff --git a/editor/editor_file_dialog.cpp b/editor/editor_file_dialog.cpp index 8a8a21543b..7d56c4985a 100644 --- a/editor/editor_file_dialog.cpp +++ b/editor/editor_file_dialog.cpp @@ -1135,7 +1135,7 @@ void EditorFileDialog::_favorite_move_up() { if (a_idx == -1 || b_idx == -1) return; - SWAP(favorited[a_idx], favorited[b_idx]); + SWAP(favorited.write[a_idx], favorited.write[b_idx]); EditorSettings::get_singleton()->set_favorite_dirs(favorited); @@ -1155,7 +1155,7 @@ void EditorFileDialog::_favorite_move_down() { if (a_idx == -1 || b_idx == -1) return; - SWAP(favorited[a_idx], favorited[b_idx]); + SWAP(favorited.write[a_idx], favorited.write[b_idx]); EditorSettings::get_singleton()->set_favorite_dirs(favorited); diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp index 4eccadd36c..527ad0b72d 100644 --- a/editor/editor_node.cpp +++ b/editor/editor_node.cpp @@ -3947,7 +3947,7 @@ void EditorNode::raise_bottom_panel_item(Control *p_item) { if (bottom_panel_items[i].control == p_item) { bottom_panel_items[i].button->raise(); - SWAP(bottom_panel_items[i], bottom_panel_items[bottom_panel_items.size() - 1]); + SWAP(bottom_panel_items.write[i], bottom_panel_items.write[bottom_panel_items.size() - 1]); break; } } diff --git a/editor/editor_profiler.cpp b/editor/editor_profiler.cpp index d4a97b7095..67700b59de 100644 --- a/editor/editor_profiler.cpp +++ b/editor/editor_profiler.cpp @@ -37,9 +37,9 @@ void EditorProfiler::_make_metric_ptrs(Metric &m) { for (int i = 0; i < m.categories.size(); i++) { - m.category_ptrs[m.categories[i].signature] = &m.categories[i]; + m.category_ptrs[m.categories[i].signature] = &m.categories.write[i]; for (int j = 0; j < m.categories[i].items.size(); j++) { - m.item_ptrs[m.categories[i].items[j].signature] = &m.categories[i].items[j]; + m.item_ptrs[m.categories[i].items[j].signature] = &m.categories.write[i].items.write[j]; } } } @@ -50,8 +50,8 @@ void EditorProfiler::add_frame_metric(const Metric &p_metric, bool p_final) { if (last_metric >= frame_metrics.size()) last_metric = 0; - frame_metrics[last_metric] = p_metric; - _make_metric_ptrs(frame_metrics[last_metric]); + frame_metrics.write[last_metric] = p_metric; + _make_metric_ptrs(frame_metrics.write[last_metric]); updating_frame = true; cursor_metric_edit->set_max(frame_metrics[last_metric].frame_number); @@ -108,7 +108,7 @@ static String _get_percent_txt(float p_value, float p_total) { return String::num((p_value / p_total) * 100, 1) + "%"; } -String EditorProfiler::_get_time_as_text(Metric &m, float p_time, int p_calls) { +String EditorProfiler::_get_time_as_text(const Metric &m, float p_time, int p_calls) { int dmode = display_mode->get_selected(); @@ -192,18 +192,18 @@ void EditorProfiler::_update_plot() { float highest = 0; for (int i = 0; i < frame_metrics.size(); i++) { - Metric &m = frame_metrics[i]; + const Metric &m = frame_metrics[i]; if (!m.valid) continue; for (Set<StringName>::Element *E = plot_sigs.front(); E; E = E->next()) { - Map<StringName, Metric::Category *>::Element *F = m.category_ptrs.find(E->get()); + const Map<StringName, Metric::Category *>::Element *F = m.category_ptrs.find(E->get()); if (F) { highest = MAX(F->get()->total_time, highest); } - Map<StringName, Metric::Category::Item *>::Element *G = m.item_ptrs.find(E->get()); + const Map<StringName, Metric::Category::Item *>::Element *G = m.item_ptrs.find(E->get()); if (G) { if (use_self) { highest = MAX(G->get()->self, highest); @@ -256,18 +256,18 @@ void EditorProfiler::_update_plot() { } //get - Metric &m = frame_metrics[idx]; + const Metric &m = frame_metrics[idx]; if (m.valid == false) continue; //skip because invalid float value = 0; - Map<StringName, Metric::Category *>::Element *F = m.category_ptrs.find(E->get()); + const Map<StringName, Metric::Category *>::Element *F = m.category_ptrs.find(E->get()); if (F) { value = F->get()->total_time; } - Map<StringName, Metric::Category::Item *>::Element *G = m.item_ptrs.find(E->get()); + const Map<StringName, Metric::Category::Item *>::Element *G = m.item_ptrs.find(E->get()); if (G) { if (use_self) { value = G->get()->self; @@ -375,7 +375,7 @@ void EditorProfiler::_update_frame() { variables->clear(); TreeItem *root = variables->create_item(); - Metric &m = frame_metrics[cursor_metric]; + const Metric &m = frame_metrics[cursor_metric]; int dtime = display_time->get_selected(); @@ -394,7 +394,7 @@ void EditorProfiler::_update_frame() { } for (int j = 0; j < m.categories[i].items.size(); j++) { - Metric::Category::Item &it = m.categories[i].items[j]; + const Metric::Category::Item &it = m.categories[i].items[j]; TreeItem *item = variables->create_item(category); item->set_cell_mode(0, TreeItem::CELL_MODE_CHECK); diff --git a/editor/editor_profiler.h b/editor/editor_profiler.h index cb451475e7..d445ad58aa 100644 --- a/editor/editor_profiler.h +++ b/editor/editor_profiler.h @@ -136,7 +136,7 @@ private: void _activate_pressed(); void _clear_pressed(); - String _get_time_as_text(Metric &m, float p_time, int p_calls); + String _get_time_as_text(const Metric &m, float p_time, int p_calls); void _make_metric_ptrs(Metric &m); void _item_edited(); diff --git a/editor/editor_resource_preview.cpp b/editor/editor_resource_preview.cpp index aa67ea03d7..a9eaad47b7 100644 --- a/editor/editor_resource_preview.cpp +++ b/editor/editor_resource_preview.cpp @@ -46,7 +46,7 @@ bool EditorResourcePreviewGenerator::handles(const String &p_type) const { ERR_EXPLAIN("EditorResourcePreviewGenerator::handles needs to be overridden"); ERR_FAIL_V(false); } -Ref<Texture> EditorResourcePreviewGenerator::generate(const RES &p_from) { +Ref<Texture> EditorResourcePreviewGenerator::generate(const RES &p_from) const { if (get_script_instance() && get_script_instance()->has_method("generate")) { return get_script_instance()->call("generate", p_from); @@ -55,7 +55,7 @@ Ref<Texture> EditorResourcePreviewGenerator::generate(const RES &p_from) { ERR_FAIL_V(Ref<Texture>()); } -Ref<Texture> EditorResourcePreviewGenerator::generate_from_path(const String &p_path) { +Ref<Texture> EditorResourcePreviewGenerator::generate_from_path(const String &p_path) const { if (get_script_instance() && get_script_instance()->has_method("generate_from_path")) { return get_script_instance()->call("generate_from_path", p_path); diff --git a/editor/editor_resource_preview.h b/editor/editor_resource_preview.h index e2276aa11d..74841b1a1e 100644 --- a/editor/editor_resource_preview.h +++ b/editor/editor_resource_preview.h @@ -63,8 +63,8 @@ protected: public: virtual bool handles(const String &p_type) const; - virtual Ref<Texture> generate(const RES &p_from); - virtual Ref<Texture> generate_from_path(const String &p_path); + virtual Ref<Texture> generate(const RES &p_from) const; + virtual Ref<Texture> generate_from_path(const String &p_path) const; EditorResourcePreviewGenerator(); }; diff --git a/editor/editor_settings.cpp b/editor/editor_settings.cpp index c8e97b071f..02e121b5f1 100644 --- a/editor/editor_settings.cpp +++ b/editor/editor_settings.cpp @@ -881,7 +881,7 @@ fail: Vector<String> list = extra_config->get_value("init_projects", "list"); for (int i = 0; i < list.size(); i++) { - list[i] = exe_path + "/" + list[i]; + list.write[i] = exe_path + "/" + list[i]; }; extra_config->set_value("init_projects", "list", list); }; diff --git a/editor/fileserver/editor_file_server.cpp b/editor/fileserver/editor_file_server.cpp index a218070933..b9e0c7d0fa 100644 --- a/editor/fileserver/editor_file_server.cpp +++ b/editor/fileserver/editor_file_server.cpp @@ -78,7 +78,7 @@ void EditorFileServer::_subthread_start(void *s) { _close_client(cd); ERR_FAIL_COND(err != OK); } - passutf8[passlen] = 0; + passutf8.write[passlen] = 0; String s; s.parse_utf8(passutf8.ptr()); if (s != cd->efs->password) { @@ -145,7 +145,7 @@ void EditorFileServer::_subthread_start(void *s) { _close_client(cd); ERR_FAIL_COND(err != OK); } - fileutf8[namelen] = 0; + fileutf8.write[namelen] = 0; String s; s.parse_utf8(fileutf8.ptr()); diff --git a/editor/find_in_files.cpp b/editor/find_in_files.cpp index 004a49e2b4..2be1f1644e 100644 --- a/editor/find_in_files.cpp +++ b/editor/find_in_files.cpp @@ -143,7 +143,7 @@ void FindInFiles::_iterate() { // Scan folders first so we can build a list of files and have progress info later - PoolStringArray &folders_to_scan = _folders_stack[_folders_stack.size() - 1]; + PoolStringArray &folders_to_scan = _folders_stack.write[_folders_stack.size() - 1]; if (folders_to_scan.size() != 0) { // Scan one folder below diff --git a/editor/import/editor_import_collada.cpp b/editor/import/editor_import_collada.cpp index a13f741ee7..22ea5883e8 100644 --- a/editor/import/editor_import_collada.cpp +++ b/editor/import/editor_import_collada.cpp @@ -579,12 +579,12 @@ static void _generate_tangents_and_binormals(const PoolVector<int> &p_indices, c .normalized(); } - tangents[index_arrayr[idx * 3 + 0]] += tangent; - binormals[index_arrayr[idx * 3 + 0]] += binormal; - tangents[index_arrayr[idx * 3 + 1]] += tangent; - binormals[index_arrayr[idx * 3 + 1]] += binormal; - tangents[index_arrayr[idx * 3 + 2]] += tangent; - binormals[index_arrayr[idx * 3 + 2]] += binormal; + tangents.write[index_arrayr[idx * 3 + 0]] += tangent; + binormals.write[index_arrayr[idx * 3 + 0]] += binormal; + tangents.write[index_arrayr[idx * 3 + 1]] += tangent; + binormals.write[index_arrayr[idx * 3 + 1]] += binormal; + tangents.write[index_arrayr[idx * 3 + 2]] += tangent; + binormals.write[index_arrayr[idx * 3 + 2]] += binormal; //print_line(itos(idx)+" tangent: "+tangent); //print_line(itos(idx)+" binormal: "+binormal); @@ -800,7 +800,7 @@ Error ColladaImport::_create_mesh_surfaces(bool p_optimize, Ref<ArrayMesh> &p_me total += weights[i].weight; if (total) for (int i = 0; i < weights.size(); i++) - weights[i].weight /= total; + weights.write[i].weight /= total; if (weights.size() == 0 || total == 0) { //if nothing, add a weight to bone 0 //no weights assigned @@ -987,7 +987,7 @@ Error ColladaImport::_create_mesh_surfaces(bool p_optimize, Ref<ArrayMesh> &p_me vertex_array.resize(vertex_set.size()); for (Set<Collada::Vertex>::Element *F = vertex_set.front(); F; F = F->next()) { - vertex_array[F->get().idx] = F->get(); + vertex_array.write[F->get().idx] = F->get(); } if (has_weights) { @@ -996,9 +996,9 @@ Error ColladaImport::_create_mesh_surfaces(bool p_optimize, Ref<ArrayMesh> &p_me Transform local_xform = p_local_xform; for (int i = 0; i < vertex_array.size(); i++) { - vertex_array[i].vertex = local_xform.xform(vertex_array[i].vertex); - vertex_array[i].normal = local_xform.basis.xform(vertex_array[i].normal).normalized(); - vertex_array[i].tangent.normal = local_xform.basis.xform(vertex_array[i].tangent.normal).normalized(); + vertex_array.write[i].vertex = local_xform.xform(vertex_array[i].vertex); + vertex_array.write[i].normal = local_xform.basis.xform(vertex_array[i].normal).normalized(); + vertex_array.write[i].tangent.normal = local_xform.basis.xform(vertex_array[i].tangent.normal).normalized(); if (local_xform_mirror) { //i shouldn't do this? wtf? //vertex_array[i].normal*=-1.0; @@ -1061,13 +1061,13 @@ Error ColladaImport::_create_mesh_surfaces(bool p_optimize, Ref<ArrayMesh> &p_me //float sum=0.0; for (int l = 0; l < VS::ARRAY_WEIGHTS_SIZE; l++) { if (l < vertex_array[k].weights.size()) { - weights[l] = vertex_array[k].weights[l].weight; - bones[l] = vertex_array[k].weights[l].bone_idx; + weights.write[l] = vertex_array[k].weights[l].weight; + bones.write[l] = vertex_array[k].weights[l].bone_idx; //sum += vertex_array[k].weights[l].weight; } else { - weights[l] = 0; - bones[l] = 0; + weights.write[l] = 0; + bones.write[l] = 0; } } @@ -1286,7 +1286,7 @@ Error ColladaImport::_create_resources(Collada::Node *p_node, bool p_use_compres String str = joint_src->sarray[i]; ERR_FAIL_COND_V(!bone_remap_map.has(str), ERR_INVALID_DATA); - bone_remap[i] = bone_remap_map[str]; + bone_remap.write[i] = bone_remap_map[str]; } } @@ -1506,7 +1506,7 @@ void ColladaImport::_fix_param_animation_tracks() { const Vector<int> &rt = collada.state.referenced_tracks[track_name]; for (int rti = 0; rti < rt.size(); rti++) { - Collada::AnimationTrack *at = &collada.state.animation_tracks[rt[rti]]; + Collada::AnimationTrack *at = &collada.state.animation_tracks.write[rt[rti]]; at->target = E->key(); at->param = "morph/" + collada.state.mesh_name_map[mesh_name]; @@ -1540,7 +1540,7 @@ void ColladaImport::create_animations(bool p_make_tracks_in_all_bones, bool p_im for (int i = 0; i < collada.state.animation_tracks.size(); i++) { - Collada::AnimationTrack &at = collada.state.animation_tracks[i]; + const Collada::AnimationTrack &at = collada.state.animation_tracks[i]; //print_line("CHANNEL: "+at.target+" PARAM: "+at.param); String node; @@ -1698,7 +1698,7 @@ void ColladaImport::create_animation(int p_clip, bool p_make_tracks_in_all_bones if (nm.anim_tracks.size() == 1) { //use snapshot keys from anim track instead, because this was most likely exported baked - Collada::AnimationTrack &at = collada.state.animation_tracks[nm.anim_tracks.front()->get()]; + const Collada::AnimationTrack &at = collada.state.animation_tracks[nm.anim_tracks.front()->get()]; snapshots.clear(); for (int i = 0; i < at.keys.size(); i++) snapshots.push_back(at.keys[i].time); @@ -1723,7 +1723,7 @@ void ColladaImport::create_animation(int p_clip, bool p_make_tracks_in_all_bones found_anim = true; - Collada::AnimationTrack &at = collada.state.animation_tracks[ET->get()]; + const Collada::AnimationTrack &at = collada.state.animation_tracks[ET->get()]; int xform_idx = -1; for (int j = 0; j < cn->xform_list.size(); j++) { @@ -1745,18 +1745,18 @@ void ColladaImport::create_animation(int p_clip, bool p_make_tracks_in_all_bones Vector<float> data = at.get_value_at_time(snapshots[i]); ERR_CONTINUE(data.empty()); - Collada::Node::XForm &xf = cn->xform_list[xform_idx]; + Collada::Node::XForm &xf = cn->xform_list.write[xform_idx]; if (at.component == "ANGLE") { ERR_CONTINUE(data.size() != 1); ERR_CONTINUE(xf.op != Collada::Node::XForm::OP_ROTATE); ERR_CONTINUE(xf.data.size() < 4); - xf.data[3] = data[0]; + xf.data.write[3] = data[0]; } else if (at.component == "X" || at.component == "Y" || at.component == "Z") { int cn = at.component[0] - 'X'; ERR_CONTINUE(cn >= xf.data.size()); ERR_CONTINUE(data.size() > 1); - xf.data[cn] = data[0]; + xf.data.write[cn] = data[0]; } else if (data.size() == xf.data.size()) { xf.data = data; @@ -1862,7 +1862,7 @@ void ColladaImport::create_animation(int p_clip, bool p_make_tracks_in_all_bones continue; } - Collada::AnimationTrack &at = collada.state.animation_tracks[ti]; + const Collada::AnimationTrack &at = collada.state.animation_tracks[ti]; // take snapshots if (!collada.state.scene_map.has(at.target)) @@ -1965,7 +1965,7 @@ Node *EditorSceneImporterCollada::import_scene(const String &p_path, uint32_t p_ if (p_flags & IMPORT_ANIMATION_DETECT_LOOP) { if (name.begins_with("loop") || name.ends_with("loop") || name.begins_with("cycle") || name.ends_with("cycle")) { - state.animations[i]->set_loop(true); + state.animations.write[i]->set_loop(true); } } diff --git a/editor/import/editor_scene_importer_gltf.cpp b/editor/import/editor_scene_importer_gltf.cpp index f2f4328cd2..7cfaa9070f 100644 --- a/editor/import/editor_scene_importer_gltf.cpp +++ b/editor/import/editor_scene_importer_gltf.cpp @@ -651,7 +651,7 @@ Vector<double> EditorSceneImporterGLTF::_decode_accessor(GLTFState &state, int p } else { //fill with zeros, as bufferview is not defined. for (int i = 0; i < (a.count * component_count); i++) { - dst_buffer[i] = 0; + dst_buffer.write[i] = 0; } } @@ -794,7 +794,7 @@ Vector<Quat> EditorSceneImporterGLTF::_decode_accessor_as_quat(GLTFState &state, ret.resize(ret_size); { for (int i = 0; i < ret_size; i++) { - ret[i] = Quat(attribs_ptr[i * 4 + 0], attribs_ptr[i * 4 + 1], attribs_ptr[i * 4 + 2], attribs_ptr[i * 4 + 3]); + ret.write[i] = Quat(attribs_ptr[i * 4 + 0], attribs_ptr[i * 4 + 1], attribs_ptr[i * 4 + 2], attribs_ptr[i * 4 + 3]); } } return ret; @@ -808,8 +808,8 @@ Vector<Transform2D> EditorSceneImporterGLTF::_decode_accessor_as_xform2d(GLTFSta ERR_FAIL_COND_V(attribs.size() % 4 != 0, ret); ret.resize(attribs.size() / 4); for (int i = 0; i < ret.size(); i++) { - ret[i][0] = Vector2(attribs[i * 4 + 0], attribs[i * 4 + 1]); - ret[i][1] = Vector2(attribs[i * 4 + 2], attribs[i * 4 + 3]); + ret.write[i][0] = Vector2(attribs[i * 4 + 0], attribs[i * 4 + 1]); + ret.write[i][1] = Vector2(attribs[i * 4 + 2], attribs[i * 4 + 3]); } return ret; } @@ -823,9 +823,9 @@ Vector<Basis> EditorSceneImporterGLTF::_decode_accessor_as_basis(GLTFState &stat ERR_FAIL_COND_V(attribs.size() % 9 != 0, ret); ret.resize(attribs.size() / 9); for (int i = 0; i < ret.size(); i++) { - ret[i].set_axis(0, Vector3(attribs[i * 9 + 0], attribs[i * 9 + 1], attribs[i * 9 + 2])); - ret[i].set_axis(1, Vector3(attribs[i * 9 + 3], attribs[i * 9 + 4], attribs[i * 9 + 5])); - ret[i].set_axis(2, Vector3(attribs[i * 9 + 6], attribs[i * 9 + 7], attribs[i * 9 + 8])); + ret.write[i].set_axis(0, Vector3(attribs[i * 9 + 0], attribs[i * 9 + 1], attribs[i * 9 + 2])); + ret.write[i].set_axis(1, Vector3(attribs[i * 9 + 3], attribs[i * 9 + 4], attribs[i * 9 + 5])); + ret.write[i].set_axis(2, Vector3(attribs[i * 9 + 6], attribs[i * 9 + 7], attribs[i * 9 + 8])); } return ret; } @@ -838,10 +838,10 @@ Vector<Transform> EditorSceneImporterGLTF::_decode_accessor_as_xform(GLTFState & ERR_FAIL_COND_V(attribs.size() % 16 != 0, ret); ret.resize(attribs.size() / 16); for (int i = 0; i < ret.size(); i++) { - ret[i].basis.set_axis(0, Vector3(attribs[i * 16 + 0], attribs[i * 16 + 1], attribs[i * 16 + 2])); - ret[i].basis.set_axis(1, Vector3(attribs[i * 16 + 4], attribs[i * 16 + 5], attribs[i * 16 + 6])); - ret[i].basis.set_axis(2, Vector3(attribs[i * 16 + 8], attribs[i * 16 + 9], attribs[i * 16 + 10])); - ret[i].set_origin(Vector3(attribs[i * 16 + 12], attribs[i * 16 + 13], attribs[i * 16 + 14])); + ret.write[i].basis.set_axis(0, Vector3(attribs[i * 16 + 0], attribs[i * 16 + 1], attribs[i * 16 + 2])); + ret.write[i].basis.set_axis(1, Vector3(attribs[i * 16 + 4], attribs[i * 16 + 5], attribs[i * 16 + 6])); + ret.write[i].basis.set_axis(2, Vector3(attribs[i * 16 + 8], attribs[i * 16 + 9], attribs[i * 16 + 10])); + ret.write[i].set_origin(Vector3(attribs[i * 16 + 12], attribs[i * 16 + 13], attribs[i * 16 + 14])); } return ret; } @@ -1085,7 +1085,7 @@ Error EditorSceneImporterGLTF::_parse_meshes(GLTFState &state) { ERR_FAIL_COND_V(mesh.mesh->get_blend_shape_count() != weights.size(), ERR_PARSE_ERROR); mesh.blend_weights.resize(weights.size()); for (int j = 0; j < weights.size(); j++) { - mesh.blend_weights[j] = weights[j]; + mesh.blend_weights.write[j] = weights[j]; } } @@ -1139,7 +1139,7 @@ Error EditorSceneImporterGLTF::_parse_images(GLTFState &state, const String &p_b ERR_FAIL_INDEX_V(bvi, state.buffer_views.size(), ERR_PARAMETER_RANGE_ERROR); - GLTFBufferView &bv = state.buffer_views[bvi]; + const GLTFBufferView &bv = state.buffer_views[bvi]; int bi = bv.buffer; ERR_FAIL_INDEX_V(bi, state.buffers.size(), ERR_PARAMETER_RANGE_ERROR); @@ -1596,7 +1596,7 @@ Error EditorSceneImporterGLTF::_parse_animations(GLTFState &state) { PoolVector<float> weights = _decode_accessor_as_floats(state, output, false); ERR_FAIL_INDEX_V(state.nodes[node]->mesh, state.meshes.size(), ERR_PARSE_ERROR); - GLTFMesh *mesh = &state.meshes[state.nodes[node]->mesh]; + const GLTFMesh *mesh = &state.meshes[state.nodes[node]->mesh]; ERR_FAIL_COND_V(mesh->blend_weights.size() == 0, ERR_PARSE_ERROR); int wc = mesh->blend_weights.size(); @@ -1611,11 +1611,11 @@ Error EditorSceneImporterGLTF::_parse_animations(GLTFState &state) { Vector<float> wdata; wdata.resize(wlen); for (int l = 0; l < wlen; l++) { - wdata[l] = r[l * wc + k]; + wdata.write[l] = r[l * wc + k]; } cf.values = wdata; - track->weight_tracks[k] = cf; + track->weight_tracks.write[k] = cf; } } else { WARN_PRINTS("Invalid path: " + path); @@ -1657,7 +1657,7 @@ void EditorSceneImporterGLTF::_generate_node(GLTFState &state, int p_node, Node if (n->mesh >= 0) { ERR_FAIL_INDEX(n->mesh, state.meshes.size()); MeshInstance *mi = memnew(MeshInstance); - GLTFMesh &mesh = state.meshes[n->mesh]; + GLTFMesh &mesh = state.meshes.write[n->mesh]; mi->set_mesh(mesh.mesh); if (mesh.mesh->get_name() == "") { mesh.mesh->set_name(n->name); @@ -1750,7 +1750,7 @@ void EditorSceneImporterGLTF::_generate_bone(GLTFState &state, int p_node, Vecto s->set_bone_rest(bone_index, state.skins[skin].bones[n->joints[i].bone].inverse_bind.affine_inverse()); n->godot_nodes.push_back(s); - n->joints[i].godot_bone_index = bone_index; + n->joints.write[i].godot_bone_index = bone_index; } for (int i = 0; i < n->children.size(); i++) { diff --git a/editor/import/resource_importer_csv_translation.cpp b/editor/import/resource_importer_csv_translation.cpp index ec0500361d..cf850eef03 100644 --- a/editor/import/resource_importer_csv_translation.cpp +++ b/editor/import/resource_importer_csv_translation.cpp @@ -119,7 +119,7 @@ Error ResourceImporterCSVTranslation::import(const String &p_source_file, const if (key != "") { for (int i = 1; i < line.size(); i++) { - translations[i - 1]->add_message(key, line[i]); + translations.write[i - 1]->add_message(key, line[i]); } } diff --git a/editor/import/resource_importer_scene.cpp b/editor/import/resource_importer_scene.cpp index a5ad34f377..b5e3466b12 100644 --- a/editor/import/resource_importer_scene.cpp +++ b/editor/import/resource_importer_scene.cpp @@ -750,7 +750,7 @@ void ResourceImporterScene::_filter_tracks(Node *scene, const String &p_text) { Vector<String> strings = p_text.split("\n"); for (int i = 0; i < strings.size(); i++) { - strings[i] = strings[i].strip_edges(); + strings.write[i] = strings[i].strip_edges(); } List<StringName> anim_names; diff --git a/editor/import/resource_importer_wav.cpp b/editor/import/resource_importer_wav.cpp index debdeb1c4a..fa641871a9 100644 --- a/editor/import/resource_importer_wav.cpp +++ b/editor/import/resource_importer_wav.cpp @@ -215,19 +215,19 @@ Error ResourceImporterWAV::import(const String &p_source_file, const String &p_s for (int i = 0; i < frames * format_channels; i++) { // 8 bit samples are UNSIGNED - data[i] = int8_t(file->get_8() - 128) / 128.f; + data.write[i] = int8_t(file->get_8() - 128) / 128.f; } } else if (format_bits == 32 && compression_code == 3) { for (int i = 0; i < frames * format_channels; i++) { //32 bit IEEE Float - data[i] = file->get_float(); + data.write[i] = file->get_float(); } } else if (format_bits == 16) { for (int i = 0; i < frames * format_channels; i++) { //16 bit SIGNED - data[i] = int16_t(file->get_16()) / 32768.f; + data.write[i] = int16_t(file->get_16()) / 32768.f; } } else { for (int i = 0; i < frames * format_channels; i++) { @@ -241,7 +241,7 @@ Error ResourceImporterWAV::import(const String &p_source_file, const String &p_s } s <<= (32 - format_bits); - data[i] = (int32_t(s) >> 16) / 32768.f; + data.write[i] = (int32_t(s) >> 16) / 32768.f; } } @@ -335,7 +335,7 @@ Error ResourceImporterWAV::import(const String &p_source_file, const String &p_s float res = (a0 * mu * mu2 + a1 * mu2 + a2 * mu + a3); - new_data[i * format_channels + c] = res; + new_data.write[i * format_channels + c] = res; // update position and always keep fractional part within ]0...1] // in order to avoid 32bit floating point precision errors @@ -374,7 +374,7 @@ Error ResourceImporterWAV::import(const String &p_source_file, const String &p_s float mult = 1.0 / max; for (int i = 0; i < data.size(); i++) { - data[i] *= mult; + data.write[i] *= mult; } } } @@ -408,7 +408,7 @@ Error ResourceImporterWAV::import(const String &p_source_file, const String &p_s Vector<float> new_data; new_data.resize((last - first + 1) * format_channels); for (int i = first * format_channels; i < (last + 1) * format_channels; i++) { - new_data[i - first * format_channels] = data[i]; + new_data.write[i - first * format_channels] = data[i]; } data = new_data; @@ -433,7 +433,7 @@ Error ResourceImporterWAV::import(const String &p_source_file, const String &p_s Vector<float> new_data; new_data.resize(data.size() / 2); for (int i = 0; i < frames; i++) { - new_data[i] = (data[i * 2 + 0] + data[i * 2 + 1]) / 2.0; + new_data.write[i] = (data[i * 2 + 0] + data[i * 2 + 1]) / 2.0; } data = new_data; @@ -465,8 +465,8 @@ Error ResourceImporterWAV::import(const String &p_source_file, const String &p_s right.resize(tframes); for (int i = 0; i < tframes; i++) { - left[i] = data[i * 2 + 0]; - right[i] = data[i * 2 + 1]; + left.write[i] = data[i * 2 + 0]; + right.write[i] = data[i * 2 + 1]; } PoolVector<uint8_t> bleft; diff --git a/editor/plugins/abstract_polygon_2d_editor.cpp b/editor/plugins/abstract_polygon_2d_editor.cpp index 5052b69e24..2d341cdd93 100644 --- a/editor/plugins/abstract_polygon_2d_editor.cpp +++ b/editor/plugins/abstract_polygon_2d_editor.cpp @@ -345,7 +345,7 @@ bool AbstractPolygon2DEditor::forward_gui_input(const Ref<InputEvent> &p_event) Vector<Vector2> vertices = _get_polygon(edited_point.polygon); ERR_FAIL_INDEX_V(edited_point.vertex, vertices.size(), false); - vertices[edited_point.vertex] = edited_point.pos - _get_offset(edited_point.polygon); + vertices.write[edited_point.vertex] = edited_point.pos - _get_offset(edited_point.polygon); undo_redo->create_action(TTR("Edit Poly")); _action_set_polygon(edited_point.polygon, pre_move_edit, vertices); @@ -445,7 +445,7 @@ bool AbstractPolygon2DEditor::forward_gui_input(const Ref<InputEvent> &p_event) Vector<Vector2> vertices = _get_polygon(edited_point.polygon); ERR_FAIL_INDEX_V(edited_point.vertex, vertices.size(), false); - vertices[edited_point.vertex] = cpoint - _get_offset(edited_point.polygon); + vertices.write[edited_point.vertex] = cpoint - _get_offset(edited_point.polygon); _set_polygon(edited_point.polygon, vertices); } diff --git a/editor/plugins/animation_blend_space_2d_editor.cpp b/editor/plugins/animation_blend_space_2d_editor.cpp index 8d17062248..27df60f87a 100644 --- a/editor/plugins/animation_blend_space_2d_editor.cpp +++ b/editor/plugins/animation_blend_space_2d_editor.cpp @@ -414,7 +414,7 @@ void AnimationNodeBlendSpace2DEditor::_blend_space_draw() { point = (point - blend_space->get_min_space()) / (blend_space->get_max_space() - blend_space->get_min_space()); point *= s; point.y = s.height - point.y; - points[j] = point; + points.write[j] = point; } for (int j = 0; j < 3; j++) { diff --git a/editor/plugins/animation_player_editor_plugin.cpp b/editor/plugins/animation_player_editor_plugin.cpp index 23eeef9f20..9ab5436de8 100644 --- a/editor/plugins/animation_player_editor_plugin.cpp +++ b/editor/plugins/animation_player_editor_plugin.cpp @@ -1333,7 +1333,7 @@ void AnimationPlayerEditor::_allocate_onion_layers() { bool is_present = onion.differences_only && i == captures - 1; // Each capture is a viewport with a canvas item attached that renders a full-size rect with the contents of the main viewport - onion.captures[i] = VS::get_singleton()->viewport_create(); + onion.captures.write[i] = VS::get_singleton()->viewport_create(); VS::get_singleton()->viewport_set_usage(onion.captures[i], VS::VIEWPORT_USAGE_2D); VS::get_singleton()->viewport_set_size(onion.captures[i], capture_size.width, capture_size.height); VS::get_singleton()->viewport_set_update_mode(onion.captures[i], VS::VIEWPORT_UPDATE_ALWAYS); @@ -1473,7 +1473,7 @@ void AnimationPlayerEditor::_prepare_onion_layers_2() { float pos = cpos + step_off * anim->get_step(); bool valid = anim->has_loop() || (pos >= 0 && pos <= anim->get_length()); - onion.captures_valid[cidx] = valid; + onion.captures_valid.write[cidx] = valid; if (valid) { player->seek(pos, true); get_tree()->flush_transform_notifications(); // Needed for transforms of Spatials diff --git a/editor/plugins/animation_state_machine_editor.cpp b/editor/plugins/animation_state_machine_editor.cpp index 04bd5f0cec..ee450333c8 100644 --- a/editor/plugins/animation_state_machine_editor.cpp +++ b/editor/plugins/animation_state_machine_editor.cpp @@ -679,7 +679,7 @@ void AnimationNodeStateMachineEditor::_state_machine_draw() { Ref<StyleBox> sb = name == selected_node ? style_selected : style; int strsize = font->get_string_size(name).width; - NodeRect &nr = node_rects[i]; + NodeRect &nr = node_rects.write[i]; Vector2 offset = nr.node.position; int h = nr.node.size.height; @@ -771,7 +771,7 @@ void AnimationNodeStateMachineEditor::_state_machine_pos_draw() { if (idx == -1) return; - NodeRect &nr = node_rects[idx]; + const NodeRect &nr = node_rects[idx]; Vector2 from; from.x = nr.play.position.x; diff --git a/editor/plugins/asset_library_editor_plugin.cpp b/editor/plugins/asset_library_editor_plugin.cpp index 505dd4ab76..e98dfceb90 100644 --- a/editor/plugins/asset_library_editor_plugin.cpp +++ b/editor/plugins/asset_library_editor_plugin.cpp @@ -197,7 +197,7 @@ void EditorAssetLibraryItemDescription::set_image(int p_type, int p_index, const for (int i = 0; i < preview_images.size(); i++) { if (preview_images[i].id == p_index) { - preview_images[i].image = p_image; + preview_images.write[i].image = p_image; if (preview_images[i].button->is_pressed()) { _preview_click(p_index); } diff --git a/editor/plugins/audio_stream_editor_plugin.cpp b/editor/plugins/audio_stream_editor_plugin.cpp index ddb03d0250..454a5d72f2 100644 --- a/editor/plugins/audio_stream_editor_plugin.cpp +++ b/editor/plugins/audio_stream_editor_plugin.cpp @@ -81,8 +81,8 @@ void AudioStreamEditor::_draw_preview() { float min = preview->get_min(ofs, ofs_n) * 0.5 + 0.5; int idx = i; - lines[idx * 2 + 0] = Vector2(i + 1, rect.position.y + min * rect.size.y); - lines[idx * 2 + 1] = Vector2(i + 1, rect.position.y + max * rect.size.y); + lines.write[idx * 2 + 0] = Vector2(i + 1, rect.position.y + min * rect.size.y); + lines.write[idx * 2 + 1] = Vector2(i + 1, rect.position.y + max * rect.size.y); } Vector<Color> color; diff --git a/editor/plugins/canvas_item_editor_plugin.cpp b/editor/plugins/canvas_item_editor_plugin.cpp index 1d20c63969..eed6b5a95c 100644 --- a/editor/plugins/canvas_item_editor_plugin.cpp +++ b/editor/plugins/canvas_item_editor_plugin.cpp @@ -533,7 +533,7 @@ void CanvasItemEditor::_get_canvas_items_at_pos(const Point2 &p_pos, Vector<_Sel r_items.remove(i); i--; } else { - r_items[i].item = canvas_item; + r_items.write[i].item = canvas_item; } } } diff --git a/editor/plugins/collision_polygon_editor_plugin.cpp b/editor/plugins/collision_polygon_editor_plugin.cpp index e837359d0c..5109379add 100644 --- a/editor/plugins/collision_polygon_editor_plugin.cpp +++ b/editor/plugins/collision_polygon_editor_plugin.cpp @@ -276,7 +276,7 @@ bool Polygon3DEditor::forward_spatial_gui_input(Camera *p_camera, const Ref<Inpu //apply ERR_FAIL_INDEX_V(edited_point, poly.size(), false); - poly[edited_point] = edited_point_pos; + poly.write[edited_point] = edited_point_pos; undo_redo->create_action(TTR("Edit Poly")); undo_redo->add_do_method(node, "set_polygon", poly); undo_redo->add_undo_method(node, "set_polygon", pre_move_edit); diff --git a/editor/plugins/collision_shape_2d_editor_plugin.cpp b/editor/plugins/collision_shape_2d_editor_plugin.cpp index b003664dca..9e052bb027 100644 --- a/editor/plugins/collision_shape_2d_editor_plugin.cpp +++ b/editor/plugins/collision_shape_2d_editor_plugin.cpp @@ -446,8 +446,8 @@ void CollisionShape2DEditor::forward_draw_over_viewport(Control *p_overlay) { float radius = shape->get_radius(); float height = shape->get_height() / 2; - handles[0] = Point2(radius, -height); - handles[1] = Point2(0, -(height + radius)); + handles.write[0] = Point2(radius, -height); + handles.write[1] = Point2(0, -(height + radius)); p_overlay->draw_texture(h, gt.xform(handles[0]) - size); p_overlay->draw_texture(h, gt.xform(handles[1]) - size); @@ -458,7 +458,7 @@ void CollisionShape2DEditor::forward_draw_over_viewport(Control *p_overlay) { Ref<CircleShape2D> shape = node->get_shape(); handles.resize(1); - handles[0] = Point2(shape->get_radius(), 0); + handles.write[0] = Point2(shape->get_radius(), 0); p_overlay->draw_texture(h, gt.xform(handles[0]) - size); @@ -476,8 +476,8 @@ void CollisionShape2DEditor::forward_draw_over_viewport(Control *p_overlay) { Ref<LineShape2D> shape = node->get_shape(); handles.resize(2); - handles[0] = shape->get_normal() * shape->get_d(); - handles[1] = shape->get_normal() * (shape->get_d() + 30.0); + handles.write[0] = shape->get_normal() * shape->get_d(); + handles.write[1] = shape->get_normal() * (shape->get_d() + 30.0); p_overlay->draw_texture(h, gt.xform(handles[0]) - size); p_overlay->draw_texture(h, gt.xform(handles[1]) - size); @@ -488,7 +488,7 @@ void CollisionShape2DEditor::forward_draw_over_viewport(Control *p_overlay) { Ref<RayShape2D> shape = node->get_shape(); handles.resize(1); - handles[0] = Point2(0, shape->get_length()); + handles.write[0] = Point2(0, shape->get_length()); p_overlay->draw_texture(h, gt.xform(handles[0]) - size); @@ -499,8 +499,8 @@ void CollisionShape2DEditor::forward_draw_over_viewport(Control *p_overlay) { handles.resize(2); Vector2 ext = shape->get_extents(); - handles[0] = Point2(ext.x, 0); - handles[1] = Point2(0, -ext.y); + handles.write[0] = Point2(ext.x, 0); + handles.write[1] = Point2(0, -ext.y); p_overlay->draw_texture(h, gt.xform(handles[0]) - size); p_overlay->draw_texture(h, gt.xform(handles[1]) - size); @@ -511,8 +511,8 @@ void CollisionShape2DEditor::forward_draw_over_viewport(Control *p_overlay) { Ref<SegmentShape2D> shape = node->get_shape(); handles.resize(2); - handles[0] = shape->get_a(); - handles[1] = shape->get_b(); + handles.write[0] = shape->get_a(); + handles.write[1] = shape->get_b(); p_overlay->draw_texture(h, gt.xform(handles[0]) - size); p_overlay->draw_texture(h, gt.xform(handles[1]) - size); diff --git a/editor/plugins/light_occluder_2d_editor_plugin.cpp b/editor/plugins/light_occluder_2d_editor_plugin.cpp index a3be10dc33..3351e5918f 100644 --- a/editor/plugins/light_occluder_2d_editor_plugin.cpp +++ b/editor/plugins/light_occluder_2d_editor_plugin.cpp @@ -255,7 +255,7 @@ bool LightOccluder2DEditor::forward_gui_input(const Ref<InputEvent> &p_event) { //apply ERR_FAIL_INDEX_V(edited_point, poly.size(), false); - poly[edited_point] = edited_point_pos; + poly.write[edited_point] = edited_point_pos; undo_redo->create_action(TTR("Edit Poly")); undo_redo->add_do_method(node->get_occluder_polygon().ptr(), "set_polygon", poly); undo_redo->add_undo_method(node->get_occluder_polygon().ptr(), "set_polygon", pre_move_edit); diff --git a/editor/plugins/particles_2d_editor_plugin.cpp b/editor/plugins/particles_2d_editor_plugin.cpp index 6d11079759..c2b17189ef 100644 --- a/editor/plugins/particles_2d_editor_plugin.cpp +++ b/editor/plugins/particles_2d_editor_plugin.cpp @@ -165,12 +165,12 @@ void Particles2DEditorPlugin::_generate_emission_mask() { if (emode == EMISSION_MODE_SOLID) { if (capture_colors) { - valid_colors[vpc * 4 + 0] = r[(j * s.width + i) * 4 + 0]; - valid_colors[vpc * 4 + 1] = r[(j * s.width + i) * 4 + 1]; - valid_colors[vpc * 4 + 2] = r[(j * s.width + i) * 4 + 2]; - valid_colors[vpc * 4 + 3] = r[(j * s.width + i) * 4 + 3]; + valid_colors.write[vpc * 4 + 0] = r[(j * s.width + i) * 4 + 0]; + valid_colors.write[vpc * 4 + 1] = r[(j * s.width + i) * 4 + 1]; + valid_colors.write[vpc * 4 + 2] = r[(j * s.width + i) * 4 + 2]; + valid_colors.write[vpc * 4 + 3] = r[(j * s.width + i) * 4 + 3]; } - valid_positions[vpc++] = Point2(i, j); + valid_positions.write[vpc++] = Point2(i, j); } else { @@ -189,7 +189,7 @@ void Particles2DEditorPlugin::_generate_emission_mask() { } if (on_border) { - valid_positions[vpc] = Point2(i, j); + valid_positions.write[vpc] = Point2(i, j); if (emode == EMISSION_MODE_BORDER_DIRECTED) { Vector2 normal; @@ -206,14 +206,14 @@ void Particles2DEditorPlugin::_generate_emission_mask() { } normal.normalize(); - valid_normals[vpc] = normal; + valid_normals.write[vpc] = normal; } if (capture_colors) { - valid_colors[vpc * 4 + 0] = r[(j * s.width + i) * 4 + 0]; - valid_colors[vpc * 4 + 1] = r[(j * s.width + i) * 4 + 1]; - valid_colors[vpc * 4 + 2] = r[(j * s.width + i) * 4 + 2]; - valid_colors[vpc * 4 + 3] = r[(j * s.width + i) * 4 + 3]; + valid_colors.write[vpc * 4 + 0] = r[(j * s.width + i) * 4 + 0]; + valid_colors.write[vpc * 4 + 1] = r[(j * s.width + i) * 4 + 1]; + valid_colors.write[vpc * 4 + 2] = r[(j * s.width + i) * 4 + 2]; + valid_colors.write[vpc * 4 + 3] = r[(j * s.width + i) * 4 + 3]; } vpc++; diff --git a/editor/plugins/script_editor_plugin.cpp b/editor/plugins/script_editor_plugin.cpp index 94d1b96b91..3f28cfd858 100644 --- a/editor/plugins/script_editor_plugin.cpp +++ b/editor/plugins/script_editor_plugin.cpp @@ -342,11 +342,11 @@ void ScriptEditor::_save_history() { if (Object::cast_to<ScriptEditorBase>(n)) { - history[history_pos].state = Object::cast_to<ScriptEditorBase>(n)->get_edit_state(); + history.write[history_pos].state = Object::cast_to<ScriptEditorBase>(n)->get_edit_state(); } if (Object::cast_to<EditorHelp>(n)) { - history[history_pos].state = Object::cast_to<EditorHelp>(n)->get_scroll(); + history.write[history_pos].state = Object::cast_to<EditorHelp>(n)->get_scroll(); } } @@ -373,11 +373,11 @@ void ScriptEditor::_go_to_tab(int p_idx) { if (Object::cast_to<ScriptEditorBase>(n)) { - history[history_pos].state = Object::cast_to<ScriptEditorBase>(n)->get_edit_state(); + history.write[history_pos].state = Object::cast_to<ScriptEditorBase>(n)->get_edit_state(); } if (Object::cast_to<EditorHelp>(n)) { - history[history_pos].state = Object::cast_to<EditorHelp>(n)->get_scroll(); + history.write[history_pos].state = Object::cast_to<EditorHelp>(n)->get_scroll(); } } @@ -2612,11 +2612,11 @@ void ScriptEditor::_update_history_pos(int p_new_pos) { if (Object::cast_to<ScriptEditorBase>(n)) { - history[history_pos].state = Object::cast_to<ScriptEditorBase>(n)->get_edit_state(); + history.write[history_pos].state = Object::cast_to<ScriptEditorBase>(n)->get_edit_state(); } if (Object::cast_to<EditorHelp>(n)) { - history[history_pos].state = Object::cast_to<EditorHelp>(n)->get_scroll(); + history.write[history_pos].state = Object::cast_to<EditorHelp>(n)->get_scroll(); } history_pos = p_new_pos; diff --git a/editor/plugins/skeleton_editor_plugin.cpp b/editor/plugins/skeleton_editor_plugin.cpp index 40a696119e..fe7d1df50c 100644 --- a/editor/plugins/skeleton_editor_plugin.cpp +++ b/editor/plugins/skeleton_editor_plugin.cpp @@ -68,16 +68,16 @@ void SkeletonEditor::create_physical_skeleton() { if (parent < 0) { - bones_infos[bone_id].relative_rest = skeleton->get_bone_rest(bone_id); + bones_infos.write[bone_id].relative_rest = skeleton->get_bone_rest(bone_id); } else { - bones_infos[bone_id].relative_rest = bones_infos[parent].relative_rest * skeleton->get_bone_rest(bone_id); + bones_infos.write[bone_id].relative_rest = bones_infos[parent].relative_rest * skeleton->get_bone_rest(bone_id); /// create physical bone on parent if (!bones_infos[parent].physical_bone) { - bones_infos[parent].physical_bone = create_physical_bone(parent, bone_id, bones_infos); + bones_infos.write[parent].physical_bone = create_physical_bone(parent, bone_id, bones_infos); ur->create_action(TTR("Create physical bones")); ur->add_do_method(skeleton, "add_child", bones_infos[parent].physical_bone); diff --git a/editor/plugins/spatial_editor_plugin.cpp b/editor/plugins/spatial_editor_plugin.cpp index f0c874a150..4ac6636bc8 100644 --- a/editor/plugins/spatial_editor_plugin.cpp +++ b/editor/plugins/spatial_editor_plugin.cpp @@ -5009,7 +5009,7 @@ SpatialEditor::SpatialEditor(EditorNode *p_editor) { tool_button[TOOL_MODE_SELECT]->set_toggle_mode(true); tool_button[TOOL_MODE_SELECT]->set_flat(true); tool_button[TOOL_MODE_SELECT]->set_pressed(true); - button_binds[0] = MENU_TOOL_SELECT; + button_binds.write[0] = MENU_TOOL_SELECT; tool_button[TOOL_MODE_SELECT]->connect("pressed", this, "_menu_item_pressed", button_binds); tool_button[TOOL_MODE_SELECT]->set_tooltip(TTR("Select Mode (Q)") + "\n" + keycode_get_string(KEY_MASK_CMD) + TTR("Drag: Rotate\nAlt+Drag: Move\nAlt+RMB: Depth list selection")); @@ -5017,7 +5017,7 @@ SpatialEditor::SpatialEditor(EditorNode *p_editor) { hbc_menu->add_child(tool_button[TOOL_MODE_MOVE]); tool_button[TOOL_MODE_MOVE]->set_toggle_mode(true); tool_button[TOOL_MODE_MOVE]->set_flat(true); - button_binds[0] = MENU_TOOL_MOVE; + button_binds.write[0] = MENU_TOOL_MOVE; tool_button[TOOL_MODE_MOVE]->connect("pressed", this, "_menu_item_pressed", button_binds); tool_button[TOOL_MODE_MOVE]->set_tooltip(TTR("Move Mode (W)")); @@ -5025,7 +5025,7 @@ SpatialEditor::SpatialEditor(EditorNode *p_editor) { hbc_menu->add_child(tool_button[TOOL_MODE_ROTATE]); tool_button[TOOL_MODE_ROTATE]->set_toggle_mode(true); tool_button[TOOL_MODE_ROTATE]->set_flat(true); - button_binds[0] = MENU_TOOL_ROTATE; + button_binds.write[0] = MENU_TOOL_ROTATE; tool_button[TOOL_MODE_ROTATE]->connect("pressed", this, "_menu_item_pressed", button_binds); tool_button[TOOL_MODE_ROTATE]->set_tooltip(TTR("Rotate Mode (E)")); @@ -5033,7 +5033,7 @@ SpatialEditor::SpatialEditor(EditorNode *p_editor) { hbc_menu->add_child(tool_button[TOOL_MODE_SCALE]); tool_button[TOOL_MODE_SCALE]->set_toggle_mode(true); tool_button[TOOL_MODE_SCALE]->set_flat(true); - button_binds[0] = MENU_TOOL_SCALE; + button_binds.write[0] = MENU_TOOL_SCALE; tool_button[TOOL_MODE_SCALE]->connect("pressed", this, "_menu_item_pressed", button_binds); tool_button[TOOL_MODE_SCALE]->set_tooltip(TTR("Scale Mode (R)")); @@ -5041,19 +5041,19 @@ SpatialEditor::SpatialEditor(EditorNode *p_editor) { hbc_menu->add_child(tool_button[TOOL_MODE_LIST_SELECT]); tool_button[TOOL_MODE_LIST_SELECT]->set_toggle_mode(true); tool_button[TOOL_MODE_LIST_SELECT]->set_flat(true); - button_binds[0] = MENU_TOOL_LIST_SELECT; + button_binds.write[0] = MENU_TOOL_LIST_SELECT; tool_button[TOOL_MODE_LIST_SELECT]->connect("pressed", this, "_menu_item_pressed", button_binds); tool_button[TOOL_MODE_LIST_SELECT]->set_tooltip(TTR("Show a list of all objects at the position clicked\n(same as Alt+RMB in select mode).")); tool_button[TOOL_LOCK_SELECTED] = memnew(ToolButton); hbc_menu->add_child(tool_button[TOOL_LOCK_SELECTED]); - button_binds[0] = MENU_LOCK_SELECTED; + button_binds.write[0] = MENU_LOCK_SELECTED; tool_button[TOOL_LOCK_SELECTED]->connect("pressed", this, "_menu_item_pressed", button_binds); tool_button[TOOL_LOCK_SELECTED]->set_tooltip(TTR("Lock the selected object in place (can't be moved).")); tool_button[TOOL_UNLOCK_SELECTED] = memnew(ToolButton); hbc_menu->add_child(tool_button[TOOL_UNLOCK_SELECTED]); - button_binds[0] = MENU_UNLOCK_SELECTED; + button_binds.write[0] = MENU_UNLOCK_SELECTED; tool_button[TOOL_UNLOCK_SELECTED]->connect("pressed", this, "_menu_item_pressed", button_binds); tool_button[TOOL_UNLOCK_SELECTED]->set_tooltip(TTR("Unlock the selected object (can be moved).")); @@ -5064,7 +5064,7 @@ SpatialEditor::SpatialEditor(EditorNode *p_editor) { hbc_menu->add_child(tool_option_button[TOOL_OPT_LOCAL_COORDS]); tool_option_button[TOOL_OPT_LOCAL_COORDS]->set_toggle_mode(true); tool_option_button[TOOL_OPT_LOCAL_COORDS]->set_flat(true); - button_binds[0] = MENU_TOOL_LOCAL_COORDS; + button_binds.write[0] = MENU_TOOL_LOCAL_COORDS; tool_option_button[TOOL_OPT_LOCAL_COORDS]->connect("toggled", this, "_menu_item_toggled", button_binds); ED_SHORTCUT("spatial_editor/local_coords", TTR("Local Coords"), KEY_T); sct = ED_GET_SHORTCUT("spatial_editor/local_coords").ptr()->get_as_text(); @@ -5074,7 +5074,7 @@ SpatialEditor::SpatialEditor(EditorNode *p_editor) { hbc_menu->add_child(tool_option_button[TOOL_OPT_USE_SNAP]); tool_option_button[TOOL_OPT_USE_SNAP]->set_toggle_mode(true); tool_option_button[TOOL_OPT_USE_SNAP]->set_flat(true); - button_binds[0] = MENU_TOOL_USE_SNAP; + button_binds.write[0] = MENU_TOOL_USE_SNAP; tool_option_button[TOOL_OPT_USE_SNAP]->connect("toggled", this, "_menu_item_toggled", button_binds); ED_SHORTCUT("spatial_editor/snap", TTR("Snap"), KEY_Y); sct = ED_GET_SHORTCUT("spatial_editor/snap").ptr()->get_as_text(); diff --git a/editor/plugins/sprite_editor_plugin.cpp b/editor/plugins/sprite_editor_plugin.cpp index 66673cca00..9bf1178b58 100644 --- a/editor/plugins/sprite_editor_plugin.cpp +++ b/editor/plugins/sprite_editor_plugin.cpp @@ -169,7 +169,7 @@ void SpriteEditor::_update_mesh_data() { Size2 img_size = Vector2(image->get_width(), image->get_height()); for (int j = 0; j < lines.size(); j++) { - lines[j] = expand(lines[j], rect, epsilon); + lines.write[j] = expand(lines[j], rect, epsilon); int index_ofs = computed_vertices.size(); diff --git a/editor/plugins/tile_map_editor_plugin.cpp b/editor/plugins/tile_map_editor_plugin.cpp index 484da3b4f3..435ef229c5 100644 --- a/editor/plugins/tile_map_editor_plugin.cpp +++ b/editor/plugins/tile_map_editor_plugin.cpp @@ -196,7 +196,7 @@ Vector<int> TileMapEditor::get_selected_tiles() const { } for (int i = items.size() - 1; i >= 0; i--) { - items[i] = palette->get_item_metadata(items[i]); + items.write[i] = palette->get_item_metadata(items[i]); } return items; } @@ -983,7 +983,7 @@ bool TileMapEditor::forward_gui_input(const Ref<InputEvent> &p_event) { ids.push_back(0); for (List<TileData>::Element *E = copydata.front(); E; E = E->next()) { - ids[0] = E->get().cell; + ids.write[0] = E->get().cell; _set_cell(E->get().pos + ofs, ids, E->get().flip_h, E->get().flip_v, E->get().transpose); } _finish_undo(); @@ -1006,7 +1006,7 @@ bool TileMapEditor::forward_gui_input(const Ref<InputEvent> &p_event) { } for (List<TileData>::Element *E = copydata.front(); E; E = E->next()) { - ids[0] = E->get().cell; + ids.write[0] = E->get().cell; _set_cell(E->get().pos + ofs, ids, E->get().flip_h, E->get().flip_v, E->get().transpose); } _finish_undo(); @@ -1228,7 +1228,7 @@ bool TileMapEditor::forward_gui_input(const Ref<InputEvent> &p_event) { for (Map<Point2i, CellOp>::Element *E = paint_undo.front(); E; E = E->next()) { - tmp_cell[0] = E->get().idx; + tmp_cell.write[0] = E->get().idx; _set_cell(E->key(), tmp_cell, E->get().xf, E->get().yf, E->get().tr); } } @@ -1265,7 +1265,7 @@ bool TileMapEditor::forward_gui_input(const Ref<InputEvent> &p_event) { for (Map<Point2i, CellOp>::Element *E = paint_undo.front(); E; E = E->next()) { - tmp_cell[0] = E->get().idx; + tmp_cell.write[0] = E->get().idx; _set_cell(E->key(), tmp_cell, E->get().xf, E->get().yf, E->get().tr); } } @@ -1750,7 +1750,7 @@ TileMapEditor::TileMapEditor(EditorNode *p_editor) { bucket_cache_visited = 0; invalid_cell.resize(1); - invalid_cell[0] = TileMap::INVALID_CELL; + invalid_cell.write[0] = TileMap::INVALID_CELL; ED_SHORTCUT("tile_map_editor/erase_selection", TTR("Erase Selection"), KEY_DELETE); ED_SHORTCUT("tile_map_editor/find_tile", TTR("Find Tile"), KEY_MASK_CMD + KEY_F); diff --git a/editor/plugins/visual_shader_editor_plugin.cpp b/editor/plugins/visual_shader_editor_plugin.cpp index b9b8b07a2e..9218fed907 100644 --- a/editor/plugins/visual_shader_editor_plugin.cpp +++ b/editor/plugins/visual_shader_editor_plugin.cpp @@ -190,7 +190,7 @@ void VisualShaderEditor::_update_graph() { } for (int i = 0; i < plugins.size(); i++) { - custom_editor = plugins[i]->create_editor(vsnode); + custom_editor = plugins.write[i]->create_editor(vsnode); if (custom_editor) { break; } diff --git a/editor/project_manager.cpp b/editor/project_manager.cpp index af7c4bb379..95d39953cf 100644 --- a/editor/project_manager.cpp +++ b/editor/project_manager.cpp @@ -1781,8 +1781,8 @@ ProjectManager::ProjectManager() { vb->add_constant_override("separation", 15 * EDSCALE); String cp; - cp.push_back(0xA9); - cp.push_back(0); + cp += 0xA9; + cp += '0'; OS::get_singleton()->set_window_title(VERSION_NAME + String(" - ") + TTR("Project Manager") + " - " + cp + " 2007-2018 Juan Linietsky, Ariel Manzur & Godot Contributors"); HBoxContainer *top_hb = memnew(HBoxContainer); diff --git a/editor/project_settings_editor.cpp b/editor/project_settings_editor.cpp index e6ae2d64e7..2b2e03ce38 100644 --- a/editor/project_settings_editor.cpp +++ b/editor/project_settings_editor.cpp @@ -1462,7 +1462,7 @@ void ProjectSettingsEditor::_update_translations() { t->set_editable(0, true); t->set_tooltip(0, l); t->set_checked(0, l_filter.has(l)); - translation_filter_treeitems[i] = t; + translation_filter_treeitems.write[i] = t; } } else { for (int i = 0; i < s; i++) { @@ -1502,7 +1502,7 @@ void ProjectSettingsEditor::_update_translations() { if (langnames.length() > 0) langnames += ","; langnames += names[i]; - translation_locales_idxs_remap[l_idx] = i; + translation_locales_idxs_remap.write[l_idx] = i; l_idx++; } } diff --git a/editor/property_editor.cpp b/editor/property_editor.cpp index 576227344b..b370a711e3 100644 --- a/editor/property_editor.cpp +++ b/editor/property_editor.cpp @@ -90,7 +90,7 @@ bool EditorResourceConversionPlugin::handles(const Ref<Resource> &p_resource) co return false; } -Ref<Resource> EditorResourceConversionPlugin::convert(const Ref<Resource> &p_resource) { +Ref<Resource> EditorResourceConversionPlugin::convert(const Ref<Resource> &p_resource) const { if (get_script_instance()) return get_script_instance()->call("_convert", p_resource); diff --git a/editor/property_editor.h b/editor/property_editor.h index 56743822d2..7d8fa22f3f 100644 --- a/editor/property_editor.h +++ b/editor/property_editor.h @@ -64,7 +64,7 @@ protected: public: virtual String converts_to() const; virtual bool handles(const Ref<Resource> &p_resource) const; - virtual Ref<Resource> convert(const Ref<Resource> &p_resource); + virtual Ref<Resource> convert(const Ref<Resource> &p_resource) const; }; class CustomPropertyEditor : public Popup { diff --git a/editor/quick_open.cpp b/editor/quick_open.cpp index 26dd931321..907bb50f7e 100644 --- a/editor/quick_open.cpp +++ b/editor/quick_open.cpp @@ -195,7 +195,7 @@ Vector<Pair<String, Ref<Texture> > > EditorQuickOpen::_sort_fs(Vector<Pair<Strin Vector<float> scores; scores.resize(list.size()); for (int i = 0; i < list.size(); i++) - scores[i] = _path_cmp(search_text, list[i].first); + scores.write[i] = _path_cmp(search_text, list[i].first); while (list.size() > 0) { diff --git a/editor/script_editor_debugger.cpp b/editor/script_editor_debugger.cpp index 9ce0e973f7..e483fde4bc 100644 --- a/editor/script_editor_debugger.cpp +++ b/editor/script_editor_debugger.cpp @@ -658,7 +658,7 @@ void ScriptEditorDebugger::_parse_message(const String &p_msg, const Array &p_da Vector<float> p; p.resize(arr.size()); for (int i = 0; i < arr.size(); i++) { - p[i] = arr[i]; + p.write[i] = arr[i]; if (i < perf_items.size()) { float v = p[i]; @@ -693,7 +693,7 @@ void ScriptEditorDebugger::_parse_message(const String &p_msg, const Array &p_da perf_items[i]->set_text(1, vs); perf_items[i]->set_tooltip(1, tt); if (p[i] > perf_max[i]) - perf_max[i] = p[i]; + perf_max.write[i] = p[i]; } } perf_history.push_front(p); @@ -807,7 +807,7 @@ void ScriptEditorDebugger::_parse_message(const String &p_msg, const Array &p_da item.signature = "categ::" + name + "::" + item.name; item.name = item.name.capitalize(); c.total_time += item.total; - c.items[i / 2] = item; + c.items.write[i / 2] = item; } metric.categories.push_back(c); } @@ -844,7 +844,7 @@ void ScriptEditorDebugger::_parse_message(const String &p_msg, const Array &p_da item.calls = calls; item.self = self; item.total = total; - funcs.items[i] = item; + funcs.items.write[i] = item; } metric.categories.push_back(funcs); @@ -1193,7 +1193,7 @@ void ScriptEditorDebugger::start() { perf_history.clear(); for (int i = 0; i < Performance::MONITOR_MAX; i++) { - perf_max[i] = 0; + perf_max.write[i] = 0; } int remote_port = (int)EditorSettings::get_singleton()->get("network/debug/remote_port"); @@ -2076,7 +2076,7 @@ ScriptEditorDebugger::ScriptEditorDebugger(EditorNode *p_editor) { it->set_selectable(1, false); it->set_text(0, name.capitalize()); perf_items.push_back(it); - perf_max[i] = 0; + perf_max.write[i] = 0; } } diff --git a/editor/spatial_editor_gizmos.cpp b/editor/spatial_editor_gizmos.cpp index 35544f711b..c450c0fd4c 100644 --- a/editor/spatial_editor_gizmos.cpp +++ b/editor/spatial_editor_gizmos.cpp @@ -229,7 +229,7 @@ void EditorSpatialGizmo::add_collision_segments(const Vector<Vector3> &p_lines) collision_segments.resize(from + p_lines.size()); for (int i = 0; i < p_lines.size(); i++) { - collision_segments[from + i] = p_lines[i]; + collision_segments.write[from + i] = p_lines[i]; } } @@ -296,14 +296,14 @@ void EditorSpatialGizmo::add_handles(const Vector<Vector3> &p_handles, bool p_bi int chs = handles.size(); handles.resize(chs + p_handles.size()); for (int i = 0; i < p_handles.size(); i++) { - handles[i + chs] = p_handles[i]; + handles.write[i + chs] = p_handles[i]; } } else { int chs = secondary_handles.size(); secondary_handles.resize(chs + p_handles.size()); for (int i = 0; i < p_handles.size(); i++) { - secondary_handles[i + chs] = p_handles[i]; + secondary_handles.write[i + chs] = p_handles[i]; } } } @@ -597,7 +597,7 @@ void EditorSpatialGizmo::create() { for (int i = 0; i < instances.size(); i++) { - instances[i].create_instance(spatial_node); + instances.write[i].create_instance(spatial_node); } transform(); @@ -621,7 +621,7 @@ void EditorSpatialGizmo::free() { if (instances[i].instance.is_valid()) VS::get_singleton()->free(instances[i].instance); - instances[i].instance = RID(); + instances.write[i].instance = RID(); } valid = false; @@ -1124,8 +1124,8 @@ void AudioStreamPlayer3DSpatialGizmo::redraw() { Vector3 from(Math::sin(a) * radius, Math::cos(a) * radius, ofs); Vector3 to(Math::sin(an) * radius, Math::cos(an) * radius, ofs); - points[i * 2 + 0] = from; - points[i * 2 + 1] = to; + points.write[i * 2 + 0] = from; + points.write[i * 2 + 1] = to; } for (int i = 0; i < 4; i++) { @@ -1134,8 +1134,8 @@ void AudioStreamPlayer3DSpatialGizmo::redraw() { Vector3 from(Math::sin(a) * radius, Math::cos(a) * radius, ofs); - points[200 + i * 2 + 0] = from; - points[200 + i * 2 + 1] = Vector3(); + points.write[200 + i * 2 + 0] = from; + points.write[200 + i * 2 + 1] = Vector3(); } add_lines(points, material); @@ -1441,11 +1441,11 @@ void SkeletonSpatialGizmo::redraw() { weights.resize(4); for (int i = 0; i < 4; i++) { - bones[i] = 0; - weights[i] = 0; + bones.write[i] = 0; + weights.write[i] = 0; } - weights[0] = 1; + weights.write[0] = 1; AABB aabb; @@ -1457,7 +1457,7 @@ void SkeletonSpatialGizmo::redraw() { int parent = skel->get_bone_parent(i); if (parent >= 0) { - grests[i] = grests[parent] * skel->get_bone_rest(i); + grests.write[i] = grests[parent] * skel->get_bone_rest(i); Vector3 v0 = grests[parent].origin; Vector3 v1 = grests[i].origin; @@ -1480,7 +1480,7 @@ void SkeletonSpatialGizmo::redraw() { int pointidx = 0; for (int j = 0; j < 3; j++) { - bones[0] = parent; + bones.write[0] = parent; surface_tool->add_bones(bones); surface_tool->add_weights(weights); surface_tool->add_color(rootcolor); @@ -1508,7 +1508,7 @@ void SkeletonSpatialGizmo::redraw() { Vector3 point = v0 + d * dist * 0.2; point += axis * dist * 0.1; - bones[0] = parent; + bones.write[0] = parent; surface_tool->add_bones(bones); surface_tool->add_weights(weights); surface_tool->add_color(bonecolor); @@ -1518,12 +1518,12 @@ void SkeletonSpatialGizmo::redraw() { surface_tool->add_color(bonecolor); surface_tool->add_vertex(point); - bones[0] = parent; + bones.write[0] = parent; surface_tool->add_bones(bones); surface_tool->add_weights(weights); surface_tool->add_color(bonecolor); surface_tool->add_vertex(point); - bones[0] = i; + bones.write[0] = i; surface_tool->add_bones(bones); surface_tool->add_weights(weights); surface_tool->add_color(bonecolor); @@ -1535,7 +1535,7 @@ void SkeletonSpatialGizmo::redraw() { SWAP(points[1], points[2]); for (int j = 0; j < 4; j++) { - bones[0] = parent; + bones.write[0] = parent; surface_tool->add_bones(bones); surface_tool->add_weights(weights); surface_tool->add_color(bonecolor); @@ -1560,8 +1560,8 @@ void SkeletonSpatialGizmo::redraw() { */ } else { - grests[i] = skel->get_bone_rest(i); - bones[0] = i; + grests.write[i] = skel->get_bone_rest(i); + bones.write[0] = i; } /* Transform t = grests[i]; @@ -2542,8 +2542,8 @@ void CollisionShapeSpatialGizmo::redraw() { Vector<Vector3> points; points.resize(md.edges.size() * 2); for (int i = 0; i < md.edges.size(); i++) { - points[i * 2 + 0] = md.vertices[md.edges[i].a]; - points[i * 2 + 1] = md.vertices[md.edges[i].b]; + points.write[i * 2 + 0] = md.vertices[md.edges[i].a]; + points.write[i * 2 + 1] = md.vertices[md.edges[i].b]; } add_lines(points, material); |