summaryrefslogtreecommitdiff
path: root/editor/import
diff options
context:
space:
mode:
Diffstat (limited to 'editor/import')
-rw-r--r--editor/import/editor_import_collada.cpp50
-rw-r--r--editor/import/editor_scene_importer_gltf.cpp36
-rw-r--r--editor/import/resource_importer_csv_translation.cpp2
-rw-r--r--editor/import/resource_importer_scene.cpp2
-rw-r--r--editor/import/resource_importer_wav.cpp20
5 files changed, 55 insertions, 55 deletions
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;