Skip to content

Commit 970343b

Browse files
dansheerinfrenchdog
authored andcommitted
Replace pxr namespace with PXR_NS to allow building against custom USD builds.
1 parent 52ca5d5 commit 970343b

33 files changed

+984
-984
lines changed

maya_plugin/test/testUsdTranslation.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ TEST(UsdTranslationTests, addStageToCache) {
3737

3838
// On windows we need to cast to long int, otheriwse its a warning as error
3939
ASSERT_TRUE(
40-
pxr::UsdUtilsStageCache::Get().Find(pxr::UsdStageCache::Id::FromLongInt(
40+
PXR_NS::UsdUtilsStageCache::Get().Find(PXR_NS::UsdStageCache::Id::FromLongInt(
4141
static_cast<long int>(cacheId))) ==
4242
const_cast<BifrostUsd::Stage&>(*stage).getStagePtr());
4343

@@ -56,8 +56,8 @@ TEST(UsdTranslationTests, portRemoved) {
5656
translator->portRemoved("somestage", "someproxy");
5757

5858
// On windows we need to cast to long int, otheriwse its a warning as error
59-
ASSERT_FALSE(pxr::UsdUtilsStageCache::Get().Find(
60-
pxr::UsdStageCache::Id::FromLongInt(static_cast<long int>(cacheId))));
59+
ASSERT_FALSE(PXR_NS::UsdUtilsStageCache::Get().Find(
60+
PXR_NS::UsdStageCache::Id::FromLongInt(static_cast<long int>(cacheId))));
6161

6262
delete translator;
6363
}

src/BifrostUsd/Attribute.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@
1919

2020
#include <Amino/Cpp/ClassDefine.h>
2121

22-
/// \todo BIFROST-6874 remove pxr::Work_EnsureDetachedTaskProgress();
22+
/// \todo BIFROST-6874 remove PXR_NS::Work_EnsureDetachedTaskProgress();
2323
#include <pxr/base/work/detachedTask.h>
2424

2525
namespace BifrostUsd {
26-
Attribute::Attribute(pxr::UsdAttribute attribute, Amino::Ptr<Prim> prim)
26+
Attribute::Attribute(PXR_NS::UsdAttribute attribute, Amino::Ptr<Prim> prim)
2727
: pxr_attribute(std::move(attribute)), prim_ptr(std::move(prim)) {
2828
assert((prim_ptr != nullptr) == (pxr_attribute.IsValid()));
2929
}
@@ -37,13 +37,13 @@ Amino::Ptr<BifrostUsd::Attribute> Amino::createDefaultClass() {
3737
// Destructor of USD instances are lauching threads. This result in
3838
// a deadlock on windows when unloading the library (which destroys the
3939
// default constructed object held in static variables).
40-
/// \todo BIFROST-6874 remove pxr::Work_EnsureDetachedTaskProgress();
41-
pxr::Work_EnsureDetachedTaskProgress();
40+
/// \todo BIFROST-6874 remove PXR_NS::Work_EnsureDetachedTaskProgress();
41+
PXR_NS::Work_EnsureDetachedTaskProgress();
4242
auto stage = Amino::newClassPtr<BifrostUsd::Stage>();
4343
auto pxr_prim = stage->get().GetPseudoRoot();
4444
auto prim = Amino::newClassPtr<BifrostUsd::Prim>(pxr_prim, stage);
4545
auto pxr_attr =
46-
pxr_prim.CreateAttribute(pxr::TfToken(""), pxr::SdfValueTypeName());
46+
pxr_prim.CreateAttribute(PXR_NS::TfToken(""), PXR_NS::SdfValueTypeName());
4747
return Amino::newClassPtr<BifrostUsd::Attribute>(pxr_attr, prim);
4848
}
4949
AMINO_DEFINE_DEFAULT_CLASS(BifrostUsd::Attribute);

src/BifrostUsd/Layer.cpp

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020

2121
#include <Amino/Cpp/ClassDefine.h>
2222

23-
/// \todo BIFROST-6874 remove pxr::Work_EnsureDetachedTaskProgress();
23+
/// \todo BIFROST-6874 remove PXR_NS::Work_EnsureDetachedTaskProgress();
2424
#include <pxr/base/work/detachedTask.h>
2525

2626
// Note: To silence warnings coming from USD library
@@ -100,16 +100,16 @@ Amino::String getFilenameWithValidUsdFileFormat(const Amino::String& filename =
100100
BifrostUsd::Layer const s_invalidLayer{BifrostUsd::Layer::Invalid{}};
101101

102102
struct Sublayer {
103-
pxr::SdfLayerRefPtr sublayer;
103+
PXR_NS::SdfLayerRefPtr sublayer;
104104
Amino::String sublayerPath;
105105
};
106106

107-
Amino::Array<Sublayer> getSublayers(const pxr::SdfLayerRefPtr layer) {
107+
Amino::Array<Sublayer> getSublayers(const PXR_NS::SdfLayerRefPtr layer) {
108108
Amino::Array<Sublayer> layers;
109109
if (layer) {
110110
auto subLayerPaths = layer->GetSubLayerPaths();
111111
for (size_t i = 0; i < subLayerPaths.size(); ++i) {
112-
auto sublayer = pxr::SdfLayer::FindOrOpenRelativeToLayer(
112+
auto sublayer = PXR_NS::SdfLayer::FindOrOpenRelativeToLayer(
113113
layer, subLayerPaths[i]);
114114
std::string sublayerPath = subLayerPaths[i];
115115
if (sublayer) {
@@ -128,7 +128,7 @@ Layer::Layer(Layer::Invalid) { assert(!isValid()); }
128128

129129
Layer::Layer(const Amino::String& tag) {
130130
m_tag = getTagWithValidUsdFileFormat(tag);
131-
m_layer = pxr::SdfLayer::CreateAnonymous(m_tag.c_str());
131+
m_layer = PXR_NS::SdfLayer::CreateAnonymous(m_tag.c_str());
132132
}
133133

134134
Layer::Layer(const Amino::String& filePath,
@@ -151,10 +151,10 @@ Layer::Layer(const Amino::String& filePath,
151151

152152
// Temporary Stage that will help in loading relative files and give us
153153
// access to the sublayers
154-
auto stage = pxr::UsdStage::Open(m_originalFilePath.c_str());
154+
auto stage = PXR_NS::UsdStage::Open(m_originalFilePath.c_str());
155155
if (stage) {
156156
if (isEditable) {
157-
m_layer = pxr::SdfLayer::CreateAnonymous(m_tag.c_str());
157+
m_layer = PXR_NS::SdfLayer::CreateAnonymous(m_tag.c_str());
158158
m_layer->TransferContent(stage->GetRootLayer());
159159
auto sublayers = getSublayers(stage->GetRootLayer());
160160
// Clear the sublayerPaths
@@ -180,7 +180,7 @@ Layer::Layer(const Amino::String& filePath,
180180
}
181181
}
182182

183-
Layer::Layer(const pxr::SdfLayerRefPtr layer,
183+
Layer::Layer(const PXR_NS::SdfLayerRefPtr layer,
184184
const bool isEditable,
185185
const Amino::String& originalFilePath) {
186186
auto validOriginalPath = originalFilePath.empty() ? "" :
@@ -203,7 +203,7 @@ Layer::Layer(const pxr::SdfLayerRefPtr layer,
203203
}
204204
auto sublayers = getSublayers(layer);
205205
if (isEditable) {
206-
m_layer = pxr::SdfLayer::CreateAnonymous(m_tag.c_str());
206+
m_layer = PXR_NS::SdfLayer::CreateAnonymous(m_tag.c_str());
207207
m_layer->TransferContent(layer);
208208
// Clear the sublayerPaths
209209
m_layer->SetSubLayerPaths(std::vector<std::string>());
@@ -239,7 +239,7 @@ Layer::Layer(const Layer& other, const Amino::String& savefilePath)
239239
}
240240

241241
if (other.m_layer->PermissionToEdit()) {
242-
m_layer = pxr::SdfLayer::CreateAnonymous(m_tag.c_str());
242+
m_layer = PXR_NS::SdfLayer::CreateAnonymous(m_tag.c_str());
243243
m_layer->TransferContent(other.m_layer);
244244

245245
// Replace sublayers coming from the other layer by the one created by
@@ -375,7 +375,7 @@ bool Layer::exportToFile(const Amino::String& filePath,
375375
return false;
376376
}
377377

378-
auto outLayer = pxr::SdfLayer::CreateNew(outFilePath);
378+
auto outLayer = PXR_NS::SdfLayer::CreateNew(outFilePath);
379379
if (!outLayer) {
380380
return false;
381381
}
@@ -411,7 +411,7 @@ bool Layer::exportToFile(const Amino::String& filePath,
411411
}
412412

413413
Amino::String Layer::exportToString(bool exportSubLayers) const {
414-
auto outLayer = pxr::SdfLayer::CreateAnonymous(
414+
auto outLayer = PXR_NS::SdfLayer::CreateAnonymous(
415415
getTagWithValidUsdFileFormat().c_str());
416416
outLayer->TransferContent(m_layer);
417417

@@ -473,8 +473,8 @@ Amino::Ptr<BifrostUsd::Layer> Amino::createDefaultClass() {
473473
// Destructor of USD instances are lauching threads. This result in
474474
// a deadlock on windows when unloading the library (which destroys the
475475
// default constructed object held in static variables).
476-
/// \todo BIFROST-6874 remove pxr::Work_EnsureDetachedTaskProgress();
477-
pxr::Work_EnsureDetachedTaskProgress();
476+
/// \todo BIFROST-6874 remove PXR_NS::Work_EnsureDetachedTaskProgress();
477+
PXR_NS::Work_EnsureDetachedTaskProgress();
478478
return Amino::newClassPtr<BifrostUsd::Layer>(
479479
BifrostUsd::Layer::Invalid{});
480480
}

src/BifrostUsd/Prim.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@
1919

2020
// #include <core/logger.h>
2121

22-
/// \todo BIFROST-6874 remove pxr::Work_EnsureDetachedTaskProgress();
22+
/// \todo BIFROST-6874 remove PXR_NS::Work_EnsureDetachedTaskProgress();
2323
#include <pxr/base/work/detachedTask.h>
2424

2525
namespace BifrostUsd {
26-
Prim::Prim(pxr::UsdPrim prim, Amino::Ptr<Stage> stage)
26+
Prim::Prim(PXR_NS::UsdPrim prim, Amino::Ptr<Stage> stage)
2727
: pxr_prim(std::move(prim)), stage_ptr(std::move(stage)) {
2828
assert((stage_ptr != nullptr) == (pxr_prim.IsValid()));
2929
}
@@ -37,8 +37,8 @@ Amino::Ptr<BifrostUsd::Prim> Amino::createDefaultClass() {
3737
// Destructor of USD instances are lauching threads. This result in
3838
// a deadlock on windows when unloading the library (which destroys the
3939
// default constructed object held in static variables).
40-
/// \todo BIFROST-6874 remove pxr::Work_EnsureDetachedTaskProgress();
41-
pxr::Work_EnsureDetachedTaskProgress();
40+
/// \todo BIFROST-6874 remove PXR_NS::Work_EnsureDetachedTaskProgress();
41+
PXR_NS::Work_EnsureDetachedTaskProgress();
4242
auto stage = Amino::newClassPtr<BifrostUsd::Stage>();
4343
auto pxr_prim = stage->get().GetPseudoRoot();
4444
return Amino::newClassPtr<BifrostUsd::Prim>(pxr_prim, stage);

src/BifrostUsd/Stage.cpp

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ BIFUSD_WARNING_DISABLE_MSC(4800)
3333
#include <pxr/usd/usd/prim.h>
3434
#include <pxr/usd/usd/stage.h>
3535

36-
/// \todo BIFROST-6874 remove pxr::Work_EnsureDetachedTaskProgress();
36+
/// \todo BIFROST-6874 remove PXR_NS::Work_EnsureDetachedTaskProgress();
3737
#include <pxr/base/work/detachedTask.h>
3838

3939
BIFUSD_WARNING_POP
@@ -42,11 +42,11 @@ BIFUSD_WARNING_POP
4242

4343
namespace {
4444

45-
pxr::UsdStage::InitialLoadSet GetPxrInitialLoadSet(
45+
PXR_NS::UsdStage::InitialLoadSet GetPxrInitialLoadSet(
4646
BifrostUsd::InitialLoadSet load) {
4747
return load == BifrostUsd::InitialLoadSet::LoadAll
48-
? pxr::UsdStage::InitialLoadSet::LoadAll
49-
: pxr::UsdStage::InitialLoadSet::LoadNone;
48+
? PXR_NS::UsdStage::InitialLoadSet::LoadAll
49+
: PXR_NS::UsdStage::InitialLoadSet::LoadNone;
5050
}
5151

5252
} // namespace
@@ -55,36 +55,36 @@ namespace BifrostUsd {
5555

5656
Stage::Stage()
5757
: m_rootLayer(Amino::newClassPtr<Layer>()),
58-
m_stage(pxr::UsdStage::Open(m_rootLayer->m_layer)) {}
58+
m_stage(PXR_NS::UsdStage::Open(m_rootLayer->m_layer)) {}
5959

6060
Stage::Stage(Invalid) { assert(!isValid()); }
6161

6262
Stage::Stage(const Layer& rootLayer, const InitialLoadSet load)
6363
: m_rootLayer(Amino::newClassPtr<Layer>(rootLayer)),
6464
m_stage(
65-
pxr::UsdStage::Open(m_rootLayer->m_layer, GetPxrInitialLoadSet(load)))
65+
PXR_NS::UsdStage::Open(m_rootLayer->m_layer, GetPxrInitialLoadSet(load)))
6666

6767
{}
6868

6969
Stage::Stage(const Layer& rootLayer,
70-
const pxr::UsdStagePopulationMask& mask,
70+
const PXR_NS::UsdStagePopulationMask& mask,
7171
const InitialLoadSet load)
7272
: m_rootLayer(Amino::newClassPtr<Layer>(rootLayer)),
73-
m_stage(pxr::UsdStage::OpenMasked(
73+
m_stage(PXR_NS::UsdStage::OpenMasked(
7474
m_rootLayer->m_layer, mask, GetPxrInitialLoadSet(load)))
7575

7676
{}
7777

7878
Stage::Stage(const Amino::String& filePath, const InitialLoadSet load)
7979
: m_rootLayer(Amino::newClassPtr<Layer>(filePath, "")),
80-
m_stage(pxr::UsdStage::Open(m_rootLayer->m_layer,
80+
m_stage(PXR_NS::UsdStage::Open(m_rootLayer->m_layer,
8181
GetPxrInitialLoadSet(load))) {}
8282

8383
Stage::Stage(const Amino::String& filePath,
84-
const pxr::UsdStagePopulationMask& mask,
84+
const PXR_NS::UsdStagePopulationMask& mask,
8585
const InitialLoadSet load)
8686
: m_rootLayer(Amino::newClassPtr<Layer>(filePath, "")),
87-
m_stage(pxr::UsdStage::OpenMasked(
87+
m_stage(PXR_NS::UsdStage::OpenMasked(
8888
m_rootLayer->m_layer, mask, GetPxrInitialLoadSet(load))) {}
8989

9090
Stage::Stage(const Stage& other) : Stage(*other.m_rootLayer) {
@@ -101,7 +101,7 @@ Stage::Stage(const Stage& other) : Stage(*other.m_rootLayer) {
101101

102102
Stage& Stage::operator=(const Stage& other) {
103103
m_rootLayer = Amino::newClassPtr<Layer>(*other.m_rootLayer);
104-
m_stage = pxr::UsdStage::Open(m_rootLayer->m_layer);
104+
m_stage = PXR_NS::UsdStage::Open(m_rootLayer->m_layer);
105105

106106
// The newly created UsdStage has the root layer as its default EditTarget.
107107
// We can't just copy the m_editLayerIndex, but must set the desired
@@ -148,7 +148,7 @@ bool Stage::setEditLayerIndex(const int layerIndex,
148148
const size_t numLayers = subLayerPaths.size();
149149
if (static_cast<size_t>(layerIndex) < numLayers) {
150150
// Find the sublayer
151-
auto layer = pxr::SdfLayer::FindOrOpen(subLayerPaths[layerIndex]);
151+
auto layer = PXR_NS::SdfLayer::FindOrOpen(subLayerPaths[layerIndex]);
152152
if (layer) {
153153
m_stage->SetEditTarget(layer);
154154
m_editLayerIndex = layerIndex;
@@ -166,11 +166,11 @@ bool Stage::setEditLayerIndex(const int layerIndex,
166166
return false;
167167
}
168168

169-
pxr::UsdVariantSet Stage::getLastModifedVariantSet() const {
170-
pxr::UsdPrim variant_prim;
169+
PXR_NS::UsdVariantSet Stage::getLastModifedVariantSet() const {
170+
PXR_NS::UsdPrim variant_prim;
171171
if (this->hasLastModifiedVariantSetPrim()) {
172172
variant_prim = m_stage->GetPrimAtPath(
173-
pxr::SdfPath(this->last_modified_variant_set_prim.c_str()));
173+
PXR_NS::SdfPath(this->last_modified_variant_set_prim.c_str()));
174174
}
175175
return variant_prim.GetVariantSet(
176176
this->last_modified_variant_set_name.c_str());
@@ -189,8 +189,8 @@ Amino::Ptr<BifrostUsd::Stage> Amino::createDefaultClass() {
189189
// Destructor of USD instances are lauching threads. This result in
190190
// a deadlock on windows when unloading the library (which destroys the
191191
// default constructed object held in static variables).
192-
/// \todo BIFROST-6874 remove pxr::Work_EnsureDetachedTaskProgress();
193-
pxr::Work_EnsureDetachedTaskProgress();
192+
/// \todo BIFROST-6874 remove PXR_NS::Work_EnsureDetachedTaskProgress();
193+
PXR_NS::Work_EnsureDetachedTaskProgress();
194194
return Amino::newClassPtr<BifrostUsd::Stage>();
195195
}
196196
AMINO_DEFINE_DEFAULT_CLASS(BifrostUsd::Stage);

src/BifrostUsd/StageCache.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ bool StageCache::addStageToCache(const Amino::Ptr<BifrostUsd::Stage>& stage,
3636
if (stage) {
3737
auto usdStagePtr =
3838
const_cast<Stage&>(*stage).getStagePtr();
39-
auto id = pxr::UsdUtilsStageCache::Get().Insert(usdStagePtr);
39+
auto id = PXR_NS::UsdUtilsStageCache::Get().Insert(usdStagePtr);
4040

4141
if (id && id.IsValid()) {
4242
// Note: on the USD side, this is implemented as a long int
@@ -54,11 +54,11 @@ bool StageCache::removeStageFromCache(int64_t id) {
5454
// Which is platform dependent. We interface ith a 64 bit int.
5555
// So we cast.
5656
assert(id <= std::numeric_limits<int>::max());
57-
return pxr::UsdUtilsStageCache::Get().Erase(
58-
pxr::UsdStageCache::Id::FromLongInt(static_cast<int>(id)));
57+
return PXR_NS::UsdUtilsStageCache::Get().Erase(
58+
PXR_NS::UsdStageCache::Id::FromLongInt(static_cast<int>(id)));
5959
#else
60-
return pxr::UsdUtilsStageCache::Get().Erase(
61-
pxr::UsdStageCache::Id::FromLongInt(id));
60+
return PXR_NS::UsdUtilsStageCache::Get().Erase(
61+
PXR_NS::UsdStageCache::Id::FromLongInt(id));
6262
#endif
6363
}
6464

src/BifrostUsd/include/Attribute.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ class AMINO_ANNOTATE("Amino::Class") USD_DECL Attribute {
5151
public:
5252
#ifndef DISABLE_PXR_HEADERS
5353
Attribute() = default;
54-
Attribute(pxr::UsdAttribute attribute, Amino::Ptr<Prim> prim);
54+
Attribute(PXR_NS::UsdAttribute attribute, Amino::Ptr<Prim> prim);
5555

5656
Attribute(const Attribute&) = default;
5757
Attribute(Attribute &&) noexcept = default;
@@ -67,11 +67,11 @@ class AMINO_ANNOTATE("Amino::Class") USD_DECL Attribute {
6767
return prim_ptr != nullptr;
6868
}
6969

70-
pxr::UsdAttribute const* operator->() const { return &pxr_attribute; }
70+
PXR_NS::UsdAttribute const* operator->() const { return &pxr_attribute; }
7171
Amino::Ptr<Prim> const& getPrim() const { return prim_ptr; }
7272

7373
private:
74-
pxr::UsdAttribute pxr_attribute;
74+
PXR_NS::UsdAttribute pxr_attribute;
7575

7676
// We need to keep a pointer to the prims since attributes can only exist on
7777
// prims and if we don't then Bifrost will cleanup the prims if they are

src/BifrostUsd/include/Layer.h

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ class AMINO_ANNOTATE("Amino::Class") USD_DECL Layer {
6464
const Amino::String& savefilePath = "",
6565
const bool isEditable = true);
6666

67-
explicit Layer(const pxr::SdfLayerRefPtr layer,
67+
explicit Layer(const PXR_NS::SdfLayerRefPtr layer,
6868
const bool isEditable = true,
6969
const Amino::String& originalFilePath = "");
7070

@@ -90,25 +90,25 @@ class AMINO_ANNOTATE("Amino::Class") USD_DECL Layer {
9090
bool isValid() const { return m_layer != nullptr; }
9191
explicit operator bool() const { return isValid(); }
9292

93-
/// \brief Accessors to the underlying pxr::SdfLayer.
93+
/// \brief Accessors to the underlying PXR_NS::SdfLayer.
9494
///
9595
/// These accessor should be used instead of getting the underlying
96-
/// pxr::SdfLayerRefPtr directly, because they propagate constness to the
97-
/// pxr::SdfLayer pointer.
96+
/// PXR_NS::SdfLayerRefPtr directly, because they propagate constness to the
97+
/// PXR_NS::SdfLayer pointer.
9898
///
9999
/// This helps avoiding unintentionally creating side effects in other
100100
/// pointers to the same \ref BifrostUsd::Layer.
101101
/// \{
102-
pxr::SdfLayer& get() { return *m_layer; }
103-
pxr::SdfLayer& operator*() { return *m_layer; }
104-
pxr::SdfLayer* operator->() { return m_layer.operator->(); }
105-
pxr::SdfLayer const& get() const { return *m_layer; }
106-
pxr::SdfLayer const& operator*() const { return *m_layer; }
107-
pxr::SdfLayer const* operator->() const { return m_layer.operator->(); }
102+
PXR_NS::SdfLayer& get() { return *m_layer; }
103+
PXR_NS::SdfLayer& operator*() { return *m_layer; }
104+
PXR_NS::SdfLayer* operator->() { return m_layer.operator->(); }
105+
PXR_NS::SdfLayer const& get() const { return *m_layer; }
106+
PXR_NS::SdfLayer const& operator*() const { return *m_layer; }
107+
PXR_NS::SdfLayer const* operator->() const { return m_layer.operator->(); }
108108
/// \}
109109

110110
// This function is purposefully non-const. Be careful with it.
111-
pxr::SdfLayerRefPtr getLayerPtr() { return m_layer; }
111+
PXR_NS::SdfLayerRefPtr getLayerPtr() { return m_layer; }
112112

113113
void setFilePath(const Amino::String& filePath);
114114
const Amino::String& getFilePath() const;
@@ -221,7 +221,7 @@ class AMINO_ANNOTATE("Amino::Class") USD_DECL Layer {
221221
friend Stage;
222222

223223
/// The underlying anonymous sdf layer.
224-
pxr::SdfLayerRefPtr m_layer;
224+
PXR_NS::SdfLayerRefPtr m_layer;
225225

226226
/// The file path where to save this Layer.
227227
/// Can be an empty string, which will disable file export if no other

0 commit comments

Comments
 (0)