diff options
author | Rémi Verschelde <rverschelde@gmail.com> | 2024-02-09 18:09:11 +0100 |
---|---|---|
committer | Rémi Verschelde <rverschelde@gmail.com> | 2024-02-09 18:09:11 +0100 |
commit | d00dc8facfc343037b29e2eb6e828251e788df24 (patch) | |
tree | 79e480aca28088bb93451e165ce429374d97e421 /modules/gltf | |
parent | d87dd6e7797088b57f9636e07d57fc67e0471e24 (diff) | |
parent | 684752e75bdeb58727c2d9b0ff0265d7fcd47de0 (diff) | |
download | redot-engine-d00dc8facfc343037b29e2eb6e828251e788df24.tar.gz |
Merge pull request #87371 from AThousandShips/size_err_check
Replace error checks against `size` with `is_empty`
Diffstat (limited to 'modules/gltf')
-rw-r--r-- | modules/gltf/gltf_document.cpp | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/modules/gltf/gltf_document.cpp b/modules/gltf/gltf_document.cpp index 1f819b96ba..ff2f290e4f 100644 --- a/modules/gltf/gltf_document.cpp +++ b/modules/gltf/gltf_document.cpp @@ -250,7 +250,7 @@ Error GLTFDocument::_serialize_gltf_extensions(Ref<GLTFState> p_state) const { } Error GLTFDocument::_serialize_scenes(Ref<GLTFState> p_state) { - ERR_FAIL_COND_V_MSG(p_state->root_nodes.size() == 0, ERR_INVALID_DATA, "GLTF export: The scene must have at least one root node."); + ERR_FAIL_COND_V_MSG(p_state->root_nodes.is_empty(), ERR_INVALID_DATA, "GLTF export: The scene must have at least one root node."); // Godot only supports one scene per glTF file. Array scenes; Dictionary scene_dict; @@ -806,7 +806,7 @@ Error GLTFDocument::_parse_buffers(Ref<GLTFState> p_state, const String &p_base_ uri = uri.uri_decode(); uri = p_base_path.path_join(uri).replace("\\", "/"); // Fix for Windows. buffer_data = FileAccess::get_file_as_bytes(uri); - ERR_FAIL_COND_V_MSG(buffer.size() == 0, ERR_PARSE_ERROR, "glTF: Couldn't load binary file as an array: " + uri); + ERR_FAIL_COND_V_MSG(buffer.is_empty(), ERR_PARSE_ERROR, "glTF: Couldn't load binary file as an array: " + uri); } ERR_FAIL_COND_V(!buffer.has("byteLength"), ERR_PARSE_ERROR); @@ -1544,7 +1544,7 @@ GLTFAccessorIndex GLTFDocument::_encode_accessor_as_ints(Ref<GLTFState> p_state, } } - ERR_FAIL_COND_V(attribs.size() == 0, -1); + ERR_FAIL_COND_V(attribs.is_empty(), -1); Ref<GLTFAccessor> accessor; accessor.instantiate(); @@ -1903,7 +1903,7 @@ GLTFAccessorIndex GLTFDocument::_encode_accessor_as_floats(Ref<GLTFState> p_stat _calc_accessor_min_max(i, element_count, type_max, attribs, type_min); } - ERR_FAIL_COND_V(!attribs.size(), -1); + ERR_FAIL_COND_V(attribs.is_empty(), -1); Ref<GLTFAccessor> accessor; accessor.instantiate(); @@ -2221,7 +2221,7 @@ Error GLTFDocument::_serialize_meshes(Ref<GLTFState> p_state) { Dictionary attributes; { Vector<Vector3> a = array[Mesh::ARRAY_VERTEX]; - ERR_FAIL_COND_V(!a.size(), ERR_INVALID_DATA); + ERR_FAIL_COND_V(a.is_empty(), ERR_INVALID_DATA); attributes["POSITION"] = _encode_accessor_as_vec3(p_state, a, true); vertex_num = a.size(); } @@ -2788,7 +2788,7 @@ Error GLTFDocument::_parse_meshes(Ref<GLTFState> p_state) { } else if (primitive == Mesh::PRIMITIVE_TRIANGLES) { //generate indices because they need to be swapped for CW/CCW const Vector<Vector3> &vertices = array[Mesh::ARRAY_VERTEX]; - ERR_FAIL_COND_V(vertices.size() == 0, ERR_PARSE_ERROR); + ERR_FAIL_COND_V(vertices.is_empty(), ERR_PARSE_ERROR); Vector<int> indices; const int vs = vertices.size(); indices.resize(vs); @@ -2919,7 +2919,7 @@ Error GLTFDocument::_parse_meshes(Ref<GLTFState> p_state) { if (t.has("TANGENT")) { const Vector<Vector3> tangents_v3 = _decode_accessor_as_vec3(p_state, t["TANGENT"], true); const Vector<float> src_tangents = array[Mesh::ARRAY_TANGENT]; - ERR_FAIL_COND_V(src_tangents.size() == 0, ERR_PARSE_ERROR); + ERR_FAIL_COND_V(src_tangents.is_empty(), ERR_PARSE_ERROR); Vector<float> tangents_v4; @@ -4414,7 +4414,7 @@ Error GLTFDocument::_verify_skin(Ref<GLTFState> p_state, Ref<GLTFSkin> p_skin) { out_roots.sort(); - ERR_FAIL_COND_V(out_roots.size() == 0, FAILED); + ERR_FAIL_COND_V(out_roots.is_empty(), FAILED); // Make sure the roots are the exact same (they better be) ERR_FAIL_COND_V(out_roots.size() != p_skin->roots.size(), FAILED); @@ -6104,7 +6104,7 @@ struct SceneFormatImporterGLTFInterpolate<Quaternion> { template <class T> T GLTFDocument::_interpolate_track(const Vector<real_t> &p_times, const Vector<T> &p_values, const float p_time, const GLTFAnimation::Interpolation p_interp) { - ERR_FAIL_COND_V(!p_values.size(), T()); + ERR_FAIL_COND_V(p_values.is_empty(), T()); if (p_times.size() != (p_values.size() / (p_interp == GLTFAnimation::INTERP_CUBIC_SPLINE ? 3 : 1))) { ERR_PRINT_ONCE("The interpolated values are not corresponding to its times."); return p_values[0]; |