[Bf-blender-cvs] [75064c7024b] universal-scene-description: USD import: crash reading shapes.
Michael Kowalski
noreply at git.blender.org
Mon Oct 24 17:19:09 CEST 2022
Commit: 75064c7024b12b845fc36d4fa3079f005651f7c7
Author: Michael Kowalski
Date: Mon Oct 24 11:17:57 2022 -0400
Branches: universal-scene-description
https://developer.blender.org/rB75064c7024b12b845fc36d4fa3079f005651f7c7
USD import: crash reading shapes.
Updated the mesh reading code when reading shapes,
to fix a crash due to the updated mesh API introduced
in the last merge from master.
===================================================================
M source/blender/io/usd/intern/usd_reader_shape.cc
===================================================================
diff --git a/source/blender/io/usd/intern/usd_reader_shape.cc b/source/blender/io/usd/intern/usd_reader_shape.cc
index 80478b9c9cc..3e6170e51c8 100644
--- a/source/blender/io/usd/intern/usd_reader_shape.cc
+++ b/source/blender/io/usd/intern/usd_reader_shape.cc
@@ -132,15 +132,17 @@ struct Mesh *USDShapeReader::read_mesh(struct Mesh *existing_mesh,
existing_mesh, positions.size(), 0, 0, face_indices.size(), face_counts.size());
}
+ MutableSpan<MVert> verts = active_mesh->verts_for_write();
+
for (int i = 0; i < positions.size(); i++) {
- MVert &mvert = active_mesh->mvert[i];
+ MVert &mvert = verts[i];
mvert.co[0] = positions[i][0];
mvert.co[1] = positions[i][1];
mvert.co[2] = positions[i][2];
}
- MPoly *mpolys = active_mesh->mpoly;
- MLoop *mloops = active_mesh->mloop;
+ MutableSpan<MPoly> polys = active_mesh->polys_for_write();
+ MutableSpan<MLoop> loops = active_mesh->loops_for_write();
int loop_index = 0;
@@ -148,7 +150,7 @@ struct Mesh *USDShapeReader::read_mesh(struct Mesh *existing_mesh,
for (int i = 0; i < face_counts.size(); i++) {
const int face_size = face_counts[i];
- MPoly &poly = mpolys[i];
+ MPoly &poly = polys[i];
poly.loopstart = loop_index;
poly.totloop = face_size;
@@ -156,7 +158,7 @@ struct Mesh *USDShapeReader::read_mesh(struct Mesh *existing_mesh,
poly.flag |= is_cube ? 0 : ME_SMOOTH;
for (int f = 0; f < face_size; ++f, ++loop_index) {
- mloops[loop_index].v = face_indices[loop_index];
+ loops[loop_index].v = face_indices[loop_index];
}
}
}
More information about the Bf-blender-cvs
mailing list