[Bf-blender-cvs] [f428fe774bf] universal-scene-description: USD import: replace deprecated shape import code.

Michael Kowalski noreply at git.blender.org
Wed Nov 2 19:34:09 CET 2022


Commit: f428fe774bf88bdf56bc86a4df2462739fd482a6
Author: Michael Kowalski
Date:   Wed Nov 2 14:30:00 2022 -0400
Branches: universal-scene-description
https://developer.blender.org/rBf428fe774bf88bdf56bc86a4df2462739fd482a6

USD import: replace deprecated shape import code.

The static functions GetMeshPoints() and GetTopology()
have been removed from the adapter classes in USD 22.11.
In anticipation of this change, the code was updated to
call the corresponding virtual functions instead.
Change authored by Charles Wardlaw.

===================================================================

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 3e6170e51c8..7f32c12029d 100644
--- a/source/blender/io/usd/intern/usd_reader_shape.cc
+++ b/source/blender/io/usd/intern/usd_reader_shape.cc
@@ -65,19 +65,30 @@ void USDShapeReader::read_object_data(Main *bmain, double motionSampleTime)
   USDXformReader::read_object_data(bmain, motionSampleTime);
 }
 
+
 template<typename Adapter>
 void USDShapeReader::read_values(const double motionSampleTime,
                                  pxr::VtVec3fArray &positions,
                                  pxr::VtIntArray &face_indices,
                                  pxr::VtIntArray &face_counts)
 {
-  pxr::VtValue meshPoints = Adapter::GetMeshPoints(prim_, motionSampleTime);
-  positions = meshPoints.template Get<pxr::VtArray<pxr::GfVec3f>>();
-  pxr::HdMeshTopology meshTopologyValue = Adapter::GetMeshTopology().template Get<pxr::HdMeshTopology>();
-  face_counts = meshTopologyValue.GetFaceVertexCounts();
-  face_indices = meshTopologyValue.GetFaceVertexIndices();
+  Adapter adapter;
+  pxr::VtValue points_val = adapter.GetPoints(prim_, motionSampleTime);
+
+  if (points_val.template IsHolding<pxr::VtVec3fArray>()) {
+    positions = points_val.template Get<pxr::VtVec3fArray>();
+  }
+
+  pxr::VtValue topology_val = adapter.GetTopology(prim_, pxr::SdfPath(), motionSampleTime);
+
+  if (topology_val.template IsHolding<pxr::HdMeshTopology>()) {
+    const pxr::HdMeshTopology &topology = topology_val.template Get<pxr::HdMeshTopology>();
+    face_counts = topology.GetFaceVertexCounts();
+    face_indices = topology.GetFaceVertexIndices();
+  }
 }
 
+
 struct Mesh *USDShapeReader::read_mesh(struct Mesh *existing_mesh,
                                        double motionSampleTime,
                                        int /* read_flag */,



More information about the Bf-blender-cvs mailing list