[Bf-blender-cvs] [63e64940f32] usd-importer-T81257-merge: USD import: bug detecting mesh topology change
makowalski
noreply at git.blender.org
Tue Jul 27 03:55:16 CEST 2021
Commit: 63e64940f327565e68ab80388856f49e5e427d00
Author: makowalski
Date: Mon Jul 26 21:42:56 2021 -0400
Branches: usd-importer-T81257-merge
https://developer.blender.org/rB63e64940f327565e68ab80388856f49e5e427d00
USD import: bug detecting mesh topology change
Fixed mesh reader logic detecting topology changes in mesh
sequence animations, which avoids a crash in some cases.
===================================================================
M source/blender/io/usd/intern/usd_reader_mesh.cc
M source/blender/io/usd/intern/usd_reader_mesh.h
===================================================================
diff --git a/source/blender/io/usd/intern/usd_reader_mesh.cc b/source/blender/io/usd/intern/usd_reader_mesh.cc
index c1e0152a808..6fe79249583 100644
--- a/source/blender/io/usd/intern/usd_reader_mesh.cc
+++ b/source/blender/io/usd/intern/usd_reader_mesh.cc
@@ -183,7 +183,6 @@ USDMeshReader::USDMeshReader(const pxr::UsdPrim &prim,
: USDGeomReader(prim, import_params, settings),
mesh_prim_(prim),
is_left_handed_(false),
- last_num_positions_(-1),
has_uvs_(false),
is_time_varying_(false),
is_initial_load_(false)
@@ -242,18 +241,14 @@ bool USDMeshReader::valid() const
return static_cast<bool>(mesh_prim_);
}
-bool USDMeshReader::topology_changed(Mesh * /* existing_mesh */, const double motionSampleTime)
+bool USDMeshReader::topology_changed(Mesh *existing_mesh, const double motionSampleTime)
{
/* TODO(makowalski): Is it the best strategy to cache the mesh
* geometry in this function? This needs to be revisited. */
- pxr::UsdAttribute faceVertCountsAttr = mesh_prim_.GetFaceVertexCountsAttr();
- pxr::UsdAttribute faceVertIndicesAttr = mesh_prim_.GetFaceVertexIndicesAttr();
- pxr::UsdAttribute pointsAttr = mesh_prim_.GetPointsAttr();
- pxr::UsdAttribute normalsAttr = mesh_prim_.GetNormalsAttr();
- faceVertIndicesAttr.Get(&face_indices_, motionSampleTime);
- faceVertCountsAttr.Get(&face_counts_, motionSampleTime);
- pointsAttr.Get(&positions_, motionSampleTime);
+ mesh_prim_.GetFaceVertexIndicesAttr().Get(&face_indices_, motionSampleTime);
+ mesh_prim_.GetFaceVertexCountsAttr().Get(&face_counts_, motionSampleTime);
+ mesh_prim_.GetPointsAttr().Get(&positions_, motionSampleTime);
/* If 'normals' and 'primvars:normals' are both specified, the latter has precedence. */
pxr::UsdGeomPrimvar primvar = mesh_prim_.GetPrimvar(usdtokens::normalsPrimvar);
@@ -266,15 +261,9 @@ bool USDMeshReader::topology_changed(Mesh * /* existing_mesh */, const double mo
normal_interpolation_ = mesh_prim_.GetNormalsInterpolation();
}
- /* TODO(makowalski): Why aren't we comparing positions_.size()
- * against the number of points of the existing_mesh?
- * Why keep track of the last_num_positons_ at all? */
- if (last_num_positions_ != positions_.size()) {
- last_num_positions_ = positions_.size();
- return true;
- }
-
- return false;
+ return positions_.size() != existing_mesh->totvert ||
+ face_counts_.size() != existing_mesh->totpoly ||
+ face_indices_.size() != existing_mesh->totloop;
}
void USDMeshReader::read_mpolys(Mesh *mesh)
diff --git a/source/blender/io/usd/intern/usd_reader_mesh.h b/source/blender/io/usd/intern/usd_reader_mesh.h
index 71c0860454c..43c812fdb89 100644
--- a/source/blender/io/usd/intern/usd_reader_mesh.h
+++ b/source/blender/io/usd/intern/usd_reader_mesh.h
@@ -42,7 +42,6 @@ class USDMeshReader : public USDGeomReader {
pxr::TfToken normal_interpolation_;
pxr::TfToken orientation_;
bool is_left_handed_;
- int last_num_positions_;
bool has_uvs_;
bool is_time_varying_;
More information about the Bf-blender-cvs
mailing list