-
Notifications
You must be signed in to change notification settings - Fork 201
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- renamed usd utility functions related to "usd" and "sdf" operations - moved usd utility functions from mayaUsd\ufe\Utils.h to usd\utils\util.h under MayaUsdUtils namespace. - cleaned up variable names according to c++ guideline.
- Loading branch information
Hamed Sabri
committed
Apr 30, 2020
1 parent
c9100f7
commit 54166d2
Showing
8 changed files
with
160 additions
and
94 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
// | ||
// Copyright 2020 Autodesk | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
// | ||
|
||
#include "util.h" | ||
|
||
#include <pxr/usd/sdf/layer.h> | ||
#include <pxr/usd/usd/prim.h> | ||
#include <pxr/usd/usd/stage.h> | ||
|
||
PXR_NAMESPACE_USING_DIRECTIVE | ||
|
||
namespace MayaUsdUtils { | ||
|
||
SdfLayerHandle | ||
defPrimSpecLayer(const UsdPrim& prim) | ||
{ | ||
// Iterate over the layer stack, starting at the highest-priority layer. | ||
// The source layer is the one in which there exists a def primSpec, not | ||
// an over. | ||
|
||
SdfLayerHandle defLayer; | ||
auto layerStack = prim.GetStage()->GetLayerStack(); | ||
|
||
for (auto layer : layerStack) { | ||
auto primSpec = layer->GetPrimAtPath(prim.GetPath()); | ||
if (primSpec && (primSpec->GetSpecifier() == SdfSpecifierDef)) { | ||
defLayer = layer; | ||
break; | ||
} | ||
} | ||
return defLayer; | ||
} | ||
|
||
bool | ||
MayaUsdUtils::doesLayerHavePrimSpec(const UsdPrim& prim) | ||
{ | ||
auto editTarget = prim.GetStage()->GetEditTarget(); | ||
auto layer = editTarget.GetLayer(); | ||
auto primSpec = layer->GetPrimAtPath(prim.GetPath()); | ||
|
||
// to know whether the target layer contains any opinions that | ||
// affect a particular prim, there must be a primSpec for that prim | ||
if (!primSpec) { | ||
return false; | ||
} | ||
|
||
return true; | ||
} | ||
|
||
SdfLayerHandle | ||
MayaUsdUtils::strongestLayerWithPrimSpec(const UsdPrim& prim) | ||
{ | ||
SdfLayerHandle targetLayer; | ||
auto layerStack = prim.GetStage()->GetLayerStack(); | ||
for (auto layer : layerStack) | ||
{ | ||
// to know whether the target layer contains any opinions that | ||
// affect a particular prim, there must be a primSpec for that prim | ||
auto primSpec = layer->GetPrimAtPath(prim.GetPath()); | ||
if (primSpec) { | ||
targetLayer = layer; | ||
break; | ||
} | ||
} | ||
return targetLayer; | ||
} | ||
|
||
} // MayaUsdUtils |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
// | ||
// Copyright 2020 Autodesk | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
// | ||
|
||
#ifndef MAYAUSDUTILS_UTIL_H | ||
#define MAYAUSDUTILS_UTIL_H | ||
|
||
#include <mayaUsdUtils/Api.h> | ||
|
||
#include <mayaUsdUtils/ForwardDeclares.h> | ||
|
||
PXR_NAMESPACE_USING_DIRECTIVE | ||
|
||
namespace MayaUsdUtils { | ||
|
||
//! Return the highest-priority layer where the prim has a def primSpec. | ||
MAYA_USD_UTILS_PUBLIC | ||
SdfLayerHandle defPrimSpecLayer(const UsdPrim&); | ||
|
||
//! Check if a layer has any opinions that affects a particular prim | ||
MAYA_USD_UTILS_PUBLIC | ||
bool doesLayerHavePrimSpec(const UsdPrim&); | ||
|
||
//! Return the layer that has any opinions on a particular prim | ||
MAYA_USD_UTILS_PUBLIC | ||
SdfLayerHandle strongestLayerWithPrimSpec(const UsdPrim&); | ||
|
||
} // namespace MayaUsdUtils | ||
|
||
#endif // MAYAUSDUTILS_UTIL_H |