diff options
Diffstat (limited to 'source/blender/io/stl/importer')
-rw-r--r-- | source/blender/io/stl/importer/stl_import.cc | 3 | ||||
-rw-r--r-- | source/blender/io/stl/importer/stl_import_ascii_reader.cc | 2 | ||||
-rw-r--r-- | source/blender/io/stl/importer/stl_import_mesh.cc | 25 |
3 files changed, 15 insertions, 15 deletions
diff --git a/source/blender/io/stl/importer/stl_import.cc b/source/blender/io/stl/importer/stl_import.cc index 097d14b038c..e5fde6658ab 100644 --- a/source/blender/io/stl/importer/stl_import.cc +++ b/source/blender/io/stl/importer/stl_import.cc @@ -99,11 +99,12 @@ void importer_main(Main *bmain, BKE_mesh_validate(mesh, verbose_validate, false); } - BKE_view_layer_base_deselect_all(view_layer); + BKE_view_layer_base_deselect_all(scene, view_layer); LayerCollection *lc = BKE_layer_collection_get_active(view_layer); Object *obj = BKE_object_add_only_object(bmain, OB_MESH, ob_name); BKE_mesh_assign_object(bmain, obj, mesh); BKE_collection_object_add(bmain, lc->collection, obj); + BKE_view_layer_synced_ensure(scene, view_layer); Base *base = BKE_view_layer_base_find(view_layer, obj); BKE_view_layer_base_select_and_set_active(view_layer, base); diff --git a/source/blender/io/stl/importer/stl_import_ascii_reader.cc b/source/blender/io/stl/importer/stl_import_ascii_reader.cc index 2edb3c6a114..6a976a2fd2c 100644 --- a/source/blender/io/stl/importer/stl_import_ascii_reader.cc +++ b/source/blender/io/stl/importer/stl_import_ascii_reader.cc @@ -97,7 +97,7 @@ class StringBuffer { start++; } fast_float::from_chars_result res = fast_float::from_chars(start, end, out); - if (res.ec == std::errc::invalid_argument || res.ec == std::errc::result_out_of_range) { + if (ELEM(res.ec, std::errc::invalid_argument, std::errc::result_out_of_range)) { out = 0.0f; } start = const_cast<char *>(res.ptr); diff --git a/source/blender/io/stl/importer/stl_import_mesh.cc b/source/blender/io/stl/importer/stl_import_mesh.cc index b9ed441f0d9..de993cd2f27 100644 --- a/source/blender/io/stl/importer/stl_import_mesh.cc +++ b/source/blender/io/stl/importer/stl_import_mesh.cc @@ -76,27 +76,26 @@ Mesh *STLMeshHelper::to_mesh(Main *bmain, char *mesh_name) id_us_min(&mesh->id); mesh->totvert = verts_.size(); - mesh->mvert = static_cast<MVert *>( - CustomData_add_layer(&mesh->vdata, CD_MVERT, CD_CALLOC, nullptr, mesh->totvert)); + CustomData_add_layer(&mesh->vdata, CD_MVERT, CD_SET_DEFAULT, nullptr, mesh->totvert); + MutableSpan<MVert> verts = mesh->verts_for_write(); for (int i = 0; i < mesh->totvert; i++) { - copy_v3_v3(mesh->mvert[i].co, verts_[i]); + copy_v3_v3(verts[i].co, verts_[i]); } mesh->totpoly = tris_.size(); mesh->totloop = tris_.size() * 3; - mesh->mpoly = static_cast<MPoly *>( - CustomData_add_layer(&mesh->pdata, CD_MPOLY, CD_CALLOC, nullptr, mesh->totpoly)); - mesh->mloop = static_cast<MLoop *>( - CustomData_add_layer(&mesh->ldata, CD_MLOOP, CD_CALLOC, nullptr, mesh->totloop)); - + CustomData_add_layer(&mesh->pdata, CD_MPOLY, CD_SET_DEFAULT, nullptr, mesh->totpoly); + CustomData_add_layer(&mesh->ldata, CD_MLOOP, CD_SET_DEFAULT, nullptr, mesh->totloop); + MutableSpan<MPoly> polys = mesh->polys_for_write(); + MutableSpan<MLoop> loops = mesh->loops_for_write(); threading::parallel_for(tris_.index_range(), 2048, [&](IndexRange tris_range) { for (const int i : tris_range) { - mesh->mpoly[i].loopstart = 3 * i; - mesh->mpoly[i].totloop = 3; + polys[i].loopstart = 3 * i; + polys[i].totloop = 3; - mesh->mloop[3 * i].v = tris_[i].v1; - mesh->mloop[3 * i + 1].v = tris_[i].v2; - mesh->mloop[3 * i + 2].v = tris_[i].v3; + loops[3 * i].v = tris_[i].v1; + loops[3 * i + 1].v = tris_[i].v2; + loops[3 * i + 2].v = tris_[i].v3; } }); |