Skip to content

Commit

Permalink
Replace boost::optional with std::optional in usdGeom
Browse files Browse the repository at this point in the history
  • Loading branch information
nvmkuruc committed Sep 18, 2023
1 parent 6988a51 commit f1de83e
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 19 deletions.
8 changes: 4 additions & 4 deletions pxr/usd/usdGeom/bboxCache.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@
#include "pxr/base/tf/hashmap.h"
#include "pxr/base/work/dispatcher.h"

#include <boost/optional.hpp>
#include <boost/shared_array.hpp>
#include <optional>

PXR_NAMESPACE_OPEN_SCOPE

Expand Down Expand Up @@ -371,13 +371,13 @@ class UsdGeomBBoxCache
/// Return the base time if set, otherwise GetTime(). Use HasBaseTime() to
/// observe if a base time has been set.
UsdTimeCode GetBaseTime() const {
return _baseTime.get_value_or(GetTime());
return _baseTime.value_or(GetTime());
}

/// Clear this cache's baseTime if one has been set. After calling this,
/// the cache will use its time as the baseTime value.
void ClearBaseTime() {
_baseTime = boost::none;
_baseTime = std::nullopt;
}

/// Return true if this cache has a baseTime that's been explicitly set,
Expand Down Expand Up @@ -571,7 +571,7 @@ class UsdGeomBBoxCache

WorkDispatcher _dispatcher;
UsdTimeCode _time;
boost::optional<UsdTimeCode> _baseTime;
std::optional<UsdTimeCode> _baseTime;
TfTokenVector _includedPurposes;
UsdGeomXformCache _ctmCache;
_PrimBBoxHashMap _bboxCache;
Expand Down
30 changes: 15 additions & 15 deletions pxr/usd/usdGeom/camera.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -398,22 +398,22 @@ PXR_NAMESPACE_CLOSE_SCOPE
PXR_NAMESPACE_OPEN_SCOPE

template<class T>
static boost::optional<T> _GetValue(const UsdPrim &prim,
const TfToken &name,
const UsdTimeCode &time)
static std::optional<T> _GetValue(const UsdPrim &prim,
const TfToken &name,
const UsdTimeCode &time)
{
const UsdAttribute attr = prim.GetAttribute(name);
if (!attr) {
TF_WARN("%s attribute on prim %s missing.",
name.GetText(), prim.GetPath().GetText());
return boost::none;
return std::nullopt;
}

T value;
if (!attr.Get(&value, time)) {
TF_WARN("Failed to extract value from attribute %s at <%s>.",
name.GetText(), attr.GetPath().GetText());
return boost::none;
return std::nullopt;
}

return value;
Expand Down Expand Up @@ -488,55 +488,55 @@ UsdGeomCamera::GetCamera(const UsdTimeCode &time) const
camera.SetTransform(
ComputeLocalToWorldTransform(time));

if (const boost::optional<TfToken> projection = _GetValue<TfToken>(
if (const std::optional<TfToken> projection = _GetValue<TfToken>(
GetPrim(), UsdGeomTokens->projection, time)) {
camera.SetProjection(_TokenToProjection(*projection));
}

if (const boost::optional<float> horizontalAperture = _GetValue<float>(
if (const std::optional<float> horizontalAperture = _GetValue<float>(
GetPrim(), UsdGeomTokens->horizontalAperture, time)) {
camera.SetHorizontalAperture(*horizontalAperture);
}

if (const boost::optional<float> verticalAperture = _GetValue<float>(
if (const std::optional<float> verticalAperture = _GetValue<float>(
GetPrim(), UsdGeomTokens->verticalAperture, time)) {
camera.SetVerticalAperture(*verticalAperture);
}

if (const boost::optional<float> horizontalApertureOffset =
if (const std::optional<float> horizontalApertureOffset =
_GetValue<float>(
GetPrim(), UsdGeomTokens->horizontalApertureOffset, time)) {
camera.SetHorizontalApertureOffset(*horizontalApertureOffset);
}

if (const boost::optional<float> verticalApertureOffset = _GetValue<float>(
if (const std::optional<float> verticalApertureOffset = _GetValue<float>(
GetPrim(), UsdGeomTokens->verticalApertureOffset, time)) {
camera.SetVerticalApertureOffset(*verticalApertureOffset);
}

if (const boost::optional<float> focalLength = _GetValue<float>(
if (const std::optional<float> focalLength = _GetValue<float>(
GetPrim(), UsdGeomTokens->focalLength, time)) {
camera.SetFocalLength(*focalLength);
}

if (const boost::optional<GfVec2f> clippingRange = _GetValue<GfVec2f>(
if (const std::optional<GfVec2f> clippingRange = _GetValue<GfVec2f>(
GetPrim(), UsdGeomTokens->clippingRange, time)) {
camera.SetClippingRange(_Vec2fToRange1f(*clippingRange));
}

if (const boost::optional<VtArray<GfVec4f> > clippingPlanes =
if (const std::optional<VtArray<GfVec4f> > clippingPlanes =
_GetValue<VtArray<GfVec4f> >(
GetPrim(), UsdGeomTokens->clippingPlanes, time)) {

camera.SetClippingPlanes(_VtArrayVec4fToVector(*clippingPlanes));
}

if (const boost::optional<float> fStop = _GetValue<float>(
if (const std::optional<float> fStop = _GetValue<float>(
GetPrim(), UsdGeomTokens->fStop, time)) {
camera.SetFStop(*fStop);
}

if (const boost::optional<float> focusDistance = _GetValue<float>(
if (const std::optional<float> focusDistance = _GetValue<float>(
GetPrim(), UsdGeomTokens->focusDistance, time)) {
camera.SetFocusDistance(*focusDistance);
}
Expand Down

0 comments on commit f1de83e

Please sign in to comment.