[Bf-blender-cvs] [3fdfa0782da] usd-importer-T81257-merge: USD Import: remove UsdPrimReader stage member.
makowalski
noreply at git.blender.org
Thu Mar 11 21:29:05 CET 2021
Commit: 3fdfa0782da55683e2cc617efafb5e7ff21ba7fa
Author: makowalski
Date: Thu Mar 11 15:14:06 2021 -0500
Branches: usd-importer-T81257-merge
https://developer.blender.org/rB3fdfa0782da55683e2cc617efafb5e7ff21ba7fa
USD Import: remove UsdPrimReader stage member.
The UsdPrimReader class doesn't need a stage pointer as a
member because the stage can implicitly be accessed
through the prim itself, as long as the prim is valid.
I removed the UsdPrimReader::stage_ member and updated the
relevant constructors and function calls. Also, updated
the various readers to construct schemas directly from
the contained prim, e.g., pxr::UsdLuxRectLight rect_light(prim_)
===================================================================
M source/blender/io/usd/intern/usd_capi.cc
M source/blender/io/usd/intern/usd_reader_camera.cc
M source/blender/io/usd/intern/usd_reader_camera.h
M source/blender/io/usd/intern/usd_reader_curve.cc
M source/blender/io/usd/intern/usd_reader_curve.h
M source/blender/io/usd/intern/usd_reader_geom.h
M source/blender/io/usd/intern/usd_reader_instance.cc
M source/blender/io/usd/intern/usd_reader_instance.h
M source/blender/io/usd/intern/usd_reader_light.cc
M source/blender/io/usd/intern/usd_reader_light.h
M source/blender/io/usd/intern/usd_reader_mesh.cc
M source/blender/io/usd/intern/usd_reader_mesh.h
M source/blender/io/usd/intern/usd_reader_nurbs.cc
M source/blender/io/usd/intern/usd_reader_nurbs.h
M source/blender/io/usd/intern/usd_reader_prim.cc
M source/blender/io/usd/intern/usd_reader_prim.h
M source/blender/io/usd/intern/usd_reader_stage.cc
M source/blender/io/usd/intern/usd_reader_volume.cc
M source/blender/io/usd/intern/usd_reader_volume.h
M source/blender/io/usd/intern/usd_reader_xform.h
M source/blender/io/usd/intern/usd_util.cc
M source/blender/io/usd/intern/usd_util.h
===================================================================
diff --git a/source/blender/io/usd/intern/usd_capi.cc b/source/blender/io/usd/intern/usd_capi.cc
index ba0bc9bb886..25ecbff01b4 100644
--- a/source/blender/io/usd/intern/usd_capi.cc
+++ b/source/blender/io/usd/intern/usd_capi.cc
@@ -889,7 +889,7 @@ CacheReader *CacheReader_open_usd_object(USDStageHandle *handle,
}
// TODO: The handle does not have the proper import params or settings
- USDPrimReader *usd_reader = create_fake_reader(archive, prim);
+ USDPrimReader *usd_reader = create_reader(archive, prim);
if (usd_reader == NULL) {
/* This object is not supported */
diff --git a/source/blender/io/usd/intern/usd_reader_camera.cc b/source/blender/io/usd/intern/usd_reader_camera.cc
index 6c28763424f..a967976cbf2 100644
--- a/source/blender/io/usd/intern/usd_reader_camera.cc
+++ b/source/blender/io/usd/intern/usd_reader_camera.cc
@@ -60,7 +60,11 @@ void USDCameraReader::read_object_data(Main *bmain, double motionSampleTime)
{
Camera *bcam = (Camera *)object_->data;
- pxr::UsdGeomCamera cam_prim = pxr::UsdGeomCamera::Get(stage_, prim_.GetPath());
+ pxr::UsdGeomCamera cam_prim(prim_);
+
+ if (!cam_prim) {
+ return;
+ }
pxr::VtValue val;
cam_prim.GetFocalLengthAttr().Get(&val, motionSampleTime);
diff --git a/source/blender/io/usd/intern/usd_reader_camera.h b/source/blender/io/usd/intern/usd_reader_camera.h
index 31d4db656a1..c5a7b1d5561 100644
--- a/source/blender/io/usd/intern/usd_reader_camera.h
+++ b/source/blender/io/usd/intern/usd_reader_camera.h
@@ -23,11 +23,10 @@ namespace blender::io::usd {
class USDCameraReader : public USDXformReader {
public:
- USDCameraReader(pxr::UsdStageRefPtr stage,
- const pxr::UsdPrim &object,
+ USDCameraReader(const pxr::UsdPrim &object,
const USDImportParams &import_params,
ImportSettings &settings)
- : USDXformReader(stage, object, import_params, settings)
+ : USDXformReader(object, import_params, settings)
{
}
diff --git a/source/blender/io/usd/intern/usd_reader_curve.cc b/source/blender/io/usd/intern/usd_reader_curve.cc
index f2572021b7e..1bc8568d64d 100644
--- a/source/blender/io/usd/intern/usd_reader_curve.cc
+++ b/source/blender/io/usd/intern/usd_reader_curve.cc
@@ -85,7 +85,11 @@ void USDCurvesReader::read_object_data(Main *bmain, double motionSampleTime)
void USDCurvesReader::read_curve_sample(Curve *cu, double motionSampleTime)
{
- curve_prim_ = pxr::UsdGeomBasisCurves::Get(stage_, prim_.GetPath());
+ curve_prim_ = pxr::UsdGeomBasisCurves(prim_);
+
+ if (!curve_prim_) {
+ return;
+ }
pxr::UsdAttribute widthsAttr = curve_prim_.GetWidthsAttr();
pxr::UsdAttribute vertexAttr = curve_prim_.GetCurveVertexCountsAttr();
@@ -199,7 +203,9 @@ Mesh *USDCurvesReader::read_mesh(struct Mesh *existing_mesh,
float vel_scale,
const char **err_str)
{
- pxr::UsdGeomCurves curve_prim_ = pxr::UsdGeomCurves::Get(stage_, prim_.GetPath());
+ // TODO(makowalski): here and elsewhere, move curve_prim_ initialization to
+ // the constructor.
+ pxr::UsdGeomCurves curve_prim_(prim_);
pxr::UsdAttribute widthsAttr = curve_prim_.GetWidthsAttr();
pxr::UsdAttribute vertexAttr = curve_prim_.GetCurveVertexCountsAttr();
diff --git a/source/blender/io/usd/intern/usd_reader_curve.h b/source/blender/io/usd/intern/usd_reader_curve.h
index a74562e9f5a..a54d15ea8a6 100644
--- a/source/blender/io/usd/intern/usd_reader_curve.h
+++ b/source/blender/io/usd/intern/usd_reader_curve.h
@@ -30,11 +30,10 @@ class USDCurvesReader : public USDGeomReader {
Curve *curve_;
public:
- USDCurvesReader(pxr::UsdStageRefPtr stage,
- const pxr::UsdPrim &object,
+ USDCurvesReader(const pxr::UsdPrim &object,
const USDImportParams &import_params,
ImportSettings &settings)
- : USDGeomReader(stage, object, import_params, settings)
+ : USDGeomReader(object, import_params, settings)
{
}
diff --git a/source/blender/io/usd/intern/usd_reader_geom.h b/source/blender/io/usd/intern/usd_reader_geom.h
index 7cb35959d7c..dd5796c697d 100644
--- a/source/blender/io/usd/intern/usd_reader_geom.h
+++ b/source/blender/io/usd/intern/usd_reader_geom.h
@@ -25,11 +25,10 @@ namespace blender::io::usd {
class USDGeomReader : public USDXformReader {
public:
- USDGeomReader(pxr::UsdStageRefPtr stage,
- const pxr::UsdPrim &object,
+ USDGeomReader(const pxr::UsdPrim &object,
const USDImportParams &import_params,
ImportSettings &settings)
- : USDXformReader(stage, object, import_params, settings)
+ : USDXformReader(object, import_params, settings)
{
}
diff --git a/source/blender/io/usd/intern/usd_reader_instance.cc b/source/blender/io/usd/intern/usd_reader_instance.cc
index 23b9aba58b0..b4dc88dfad6 100644
--- a/source/blender/io/usd/intern/usd_reader_instance.cc
+++ b/source/blender/io/usd/intern/usd_reader_instance.cc
@@ -26,11 +26,10 @@
namespace blender::io::usd {
-USDInstanceReader::USDInstanceReader(pxr::UsdStageRefPtr stage,
- const pxr::UsdPrim &object,
+USDInstanceReader::USDInstanceReader(const pxr::UsdPrim &object,
const USDImportParams &import_params,
ImportSettings &settings)
- : USDXformReader(stage, object, import_params, settings)
+ : USDXformReader(object, import_params, settings)
{
}
diff --git a/source/blender/io/usd/intern/usd_reader_instance.h b/source/blender/io/usd/intern/usd_reader_instance.h
index ab3cef3aa7b..5cc04a04e94 100644
--- a/source/blender/io/usd/intern/usd_reader_instance.h
+++ b/source/blender/io/usd/intern/usd_reader_instance.h
@@ -31,8 +31,7 @@ namespace blender::io::usd {
class USDInstanceReader : public USDXformReader {
public:
- USDInstanceReader(pxr::UsdStageRefPtr stage,
- const pxr::UsdPrim &object,
+ USDInstanceReader(const pxr::UsdPrim &object,
const USDImportParams &import_params,
ImportSettings &settings);
diff --git a/source/blender/io/usd/intern/usd_reader_light.cc b/source/blender/io/usd/intern/usd_reader_light.cc
index 91bee43813f..0112ac53425 100644
--- a/source/blender/io/usd/intern/usd_reader_light.cc
+++ b/source/blender/io/usd/intern/usd_reader_light.cc
@@ -70,7 +70,12 @@ void USDLightReader::read_object_data(Main *bmain, double motionSampleTime)
{
Light *blight = (Light *)object_->data;
- pxr::UsdLuxLight light_prim = pxr::UsdLuxLight::Get(stage_, prim_.GetPath());
+ pxr::UsdLuxLight light_prim(prim_);
+
+ if (!light_prim) {
+ return;
+ }
+
pxr::UsdLuxShapingAPI shapingAPI(light_prim);
// Set light type
@@ -133,7 +138,8 @@ void USDLightReader::read_object_data(Main *bmain, double motionSampleTime)
switch (blight->type) {
case LA_AREA:
if (blight->area_shape == LA_AREA_RECT && prim_.IsA<pxr::UsdLuxRectLight>()) {
- pxr::UsdLuxRectLight rect_light = pxr::UsdLuxRectLight::Get(stage_, prim_.GetPath());
+
+ pxr::UsdLuxRectLight rect_light(prim_);
pxr::VtValue width;
rect_light.GetWidthAttr().Get(&width, motionSampleTime);
@@ -146,7 +152,8 @@ void USDLightReader::read_object_data(Main *bmain, double motionSampleTime)
}
if (blight->area_shape == LA_AREA_DISK && prim_.IsA<pxr::UsdLuxDiskLight>()) {
- pxr::UsdLuxDiskLight disk_light = pxr::UsdLuxDiskLight::Get(stage_, prim_.GetPath());
+
+ pxr::UsdLuxDiskLight disk_light(prim_);
pxr::VtValue radius;
disk_light.GetRadiusAttr().Get(&radius, motionSampleTime);
@@ -156,7 +163,8 @@ void USDLightReader::read_object_data(Main *bmain, double motionSampleTime)
break;
case LA_LOCAL:
if (prim_.IsA<pxr::UsdLuxSphereLight>()) {
- pxr::UsdLuxSphereLight sphere_light = pxr::UsdLuxSphereLight::Get(stage_, prim_.GetPath());
+
+ pxr::UsdLuxSphereLight sphere_light(prim_);
pxr::VtValue radius;
sphere_light.GetRadiusAttr().Get(&radius, motionSampleTime);
@@ -166,7 +174,8 @@ void USDLightReader::read_object_data(Main *bmain, double motionSampleTime)
break;
case LA_SPOT:
if (prim_.IsA<pxr::UsdLuxSphereLight>()) {
- pxr::UsdLuxSphereLight sphere_light = pxr::UsdLuxSphereLight::Get(stage_, prim_.GetPath());
+
+ pxr::UsdLuxSphereLight sphere_light(prim_);
pxr::VtValue radius;
sphere_light.GetRadiusAttr().Get(&radius, motionSampleTime);
@@ -184,8 +193,7 @@ void USDLightReader::read_object_data(Main *bmain, double motionSampleTime)
break;
case LA_SUN:
if (prim_.IsA<pxr::UsdLuxDistantLight>()) {
- pxr::UsdLuxDistantLight distant_light = pxr::UsdLuxDistantLight::Get(stage_,
- prim_.GetPath());
+ pxr::UsdLuxDistantLight distant_light(prim_);
pxr::VtValue angle;
distant_light.GetAngleAttr().Get(&angle, motionSampleTime);
diff --git a/source/blender/io/usd/intern/usd_reader_light.h b/source/blender/io/usd/intern/usd_reader_light.h
index 5f64e4b422b..f721f220e35 100644
--- a/source/blender/io/usd/intern/usd_reader_light.h
+++ b/source/blender/io/usd/intern/usd_reader_light.h
@@ -23,11 +23,10 @@ namespace blender::io::usd {
class USDLightReader : public USDXformReader {
public:
- USDLightReader(pxr::UsdStageRefPtr stage,
- const pxr::UsdPrim &object,
+ USDLightReader(const pxr::UsdPrim &object,
const USDImportParams &import_params,
ImportSettings &settings)
- : USDXformReader(stage, object, import_params, settings)
+ : USDXformReader(object, import_params, settings)
{
}
diff --git a/source/blender/io/usd/intern/usd_reader_mesh.cc b/source/blender/io/usd/intern/usd_reader_mesh.cc
index 26b8de07a65..e6b52775d06 100644
--- a/source/blender/io/usd/intern/usd_reader_mesh.cc
+++ b/source/blender/io/usd/intern/usd_reader_mesh.cc
@@ -185,11 +185,10 @@ static void *add_customdata_cb(Mesh *mesh, const char *name, int data_type)
namespace blender::io::usd {
-
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list