Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Kowalski <makowalski@nvidia.com>2022-11-01 18:55:58 +0300
committerMichael Kowalski <makowalski@nvidia.com>2022-11-01 18:55:58 +0300
commitbcc2656299ad72b224c5f2644518759561c31045 (patch)
tree048665c7f0fd43a4e7dd8c4a9e6f38e99f85e810
parent99e5024e97f1c34697885b1a93935e72c019da5c (diff)
USD IO: replace deprecated primvars API.
Updated the code to use the UsdGeomPrimvarsAPI class to read and write mesh primvars instead of the now deprecated primvars accessors in UsdGeomImageable. This will be required to build with USD 22.11 in the future, where the deprecated functions have been removed.
-rw-r--r--source/blender/io/usd/intern/usd_reader_mesh.cc15
-rw-r--r--source/blender/io/usd/intern/usd_writer_mesh.cc5
2 files changed, 15 insertions, 5 deletions
diff --git a/source/blender/io/usd/intern/usd_reader_mesh.cc b/source/blender/io/usd/intern/usd_reader_mesh.cc
index 01db6baeb5c..8138f38fcad 100644
--- a/source/blender/io/usd/intern/usd_reader_mesh.cc
+++ b/source/blender/io/usd/intern/usd_reader_mesh.cc
@@ -33,6 +33,7 @@
#include <pxr/base/vt/value.h>
#include <pxr/usd/sdf/types.h>
#include <pxr/usd/usdGeom/mesh.h>
+#include <pxr/usd/usdGeom/primvarsAPI.h>
#include <pxr/usd/usdGeom/subset.h>
#include <pxr/usd/usdShade/materialBindingAPI.h>
@@ -287,11 +288,13 @@ bool USDMeshReader::topology_changed(const Mesh *existing_mesh, const double mot
mesh_prim_.GetFaceVertexCountsAttr().Get(&face_counts_, motionSampleTime);
mesh_prim_.GetPointsAttr().Get(&positions_, motionSampleTime);
+ pxr::UsdGeomPrimvarsAPI primvarsAPI(mesh_prim_);
+
/* TODO(makowalski): Reading normals probably doesn't belong in this function,
* as this is not required to determine if the topology has changed. */
/* If 'normals' and 'primvars:normals' are both specified, the latter has precedence. */
- pxr::UsdGeomPrimvar primvar = mesh_prim_.GetPrimvar(usdtokens::normalsPrimvar);
+ pxr::UsdGeomPrimvar primvar = primvarsAPI.GetPrimvar(usdtokens::normalsPrimvar);
if (primvar.HasValue()) {
primvar.ComputeFlattened(&normals_, motionSampleTime);
normal_interpolation_ = primvar.GetInterpolation();
@@ -355,6 +358,8 @@ void USDMeshReader::read_uvs(Mesh *mesh, const double motionSampleTime, const bo
std::vector<UVSample> uv_primvars(ldata->totlayer);
+ pxr::UsdGeomPrimvarsAPI primvarsAPI(mesh_prim_);
+
if (has_uvs_) {
for (int layer_idx = 0; layer_idx < ldata->totlayer; layer_idx++) {
const CustomDataLayer *layer = &ldata->layers[layer_idx];
@@ -385,11 +390,11 @@ void USDMeshReader::read_uvs(Mesh *mesh, const double motionSampleTime, const bo
}
/* Early out if mesh doesn't have primvar. */
- if (!mesh_prim_.HasPrimvar(uv_token)) {
+ if (!primvarsAPI.HasPrimvar(uv_token)) {
continue;
}
- if (pxr::UsdGeomPrimvar uv_primvar = mesh_prim_.GetPrimvar(uv_token)) {
+ if (pxr::UsdGeomPrimvar uv_primvar = primvarsAPI.GetPrimvar(uv_token)) {
uv_primvar.ComputeFlattened(&uv_primvars[layer_idx].uvs, motionSampleTime);
uv_primvars[layer_idx].interpolation = uv_primvar.GetInterpolation();
}
@@ -835,12 +840,14 @@ Mesh *USDMeshReader::read_mesh(Mesh *existing_mesh,
is_left_handed_ = true;
}
+ pxr::UsdGeomPrimvarsAPI primvarsAPI(mesh_prim_);
+
std::vector<pxr::TfToken> uv_tokens;
/* Currently we only handle UV primvars. */
if (read_flag & MOD_MESHSEQ_READ_UV) {
- std::vector<pxr::UsdGeomPrimvar> primvars = mesh_prim_.GetPrimvars();
+ std::vector<pxr::UsdGeomPrimvar> primvars = primvarsAPI.GetPrimvars();
for (pxr::UsdGeomPrimvar p : primvars) {
diff --git a/source/blender/io/usd/intern/usd_writer_mesh.cc b/source/blender/io/usd/intern/usd_writer_mesh.cc
index e949bafe517..e7d79e888e4 100644
--- a/source/blender/io/usd/intern/usd_writer_mesh.cc
+++ b/source/blender/io/usd/intern/usd_writer_mesh.cc
@@ -4,6 +4,7 @@
#include "usd_hierarchy_iterator.h"
#include <pxr/usd/usdGeom/mesh.h>
+#include <pxr/usd/usdGeom/primvarsAPI.h>
#include <pxr/usd/usdShade/material.h>
#include <pxr/usd/usdShade/materialBindingAPI.h>
@@ -107,6 +108,8 @@ void USDGenericMeshWriter::write_uv_maps(const Mesh *mesh, pxr::UsdGeomMesh usd_
{
pxr::UsdTimeCode timecode = get_export_time_code();
+ pxr::UsdGeomPrimvarsAPI primvarsAPI(usd_mesh.GetPrim());
+
const CustomData *ldata = &mesh->ldata;
for (int layer_idx = 0; layer_idx < ldata->totlayer; layer_idx++) {
const CustomDataLayer *layer = &ldata->layers[layer_idx];
@@ -119,7 +122,7 @@ void USDGenericMeshWriter::write_uv_maps(const Mesh *mesh, pxr::UsdGeomMesh usd_
* for texture coordinates by naming the UV Map as such, without having to guess which UV Map
* is the "standard" one. */
pxr::TfToken primvar_name(pxr::TfMakeValidIdentifier(layer->name));
- pxr::UsdGeomPrimvar uv_coords_primvar = usd_mesh.CreatePrimvar(
+ pxr::UsdGeomPrimvar uv_coords_primvar = primvarsAPI.CreatePrimvar(
primvar_name, pxr::SdfValueTypeNames->TexCoord2fArray, pxr::UsdGeomTokens->faceVarying);
MLoopUV *mloopuv = static_cast<MLoopUV *>(layer->data);