-
Notifications
You must be signed in to change notification settings - Fork 202
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #210 from Autodesk/ufe_bbox_support_dev
Ufe bbox support dev
- Loading branch information
Showing
19 changed files
with
756 additions
and
28 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// | ||
// 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. | ||
// | ||
#pragma once | ||
|
||
// Make sure ufe.h is included, if it hasn't been already. | ||
#include <ufe/ufe.h> | ||
|
||
// UFE v1 has no UFE_V2 macro. | ||
#if !defined(UFE_V2_FEATURES_AVAILABLE) && !defined(UFE_V2) | ||
#define UFE_V2(...) | ||
#endif | ||
|
||
#if !defined(UFE_V3_FEATURES_AVAILABLE) && !defined(UFE_V3) | ||
#define UFE_V3(...) | ||
#endif |
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,73 @@ | ||
// =========================================================================== | ||
// Copyright 2019 Autodesk, Inc. All rights reserved. | ||
// | ||
// Use of this software is subject to the terms of the Autodesk license | ||
// agreement provided at the time of installation or download, or which | ||
// otherwise accompanies this software in either electronic or hard copy form. | ||
// =========================================================================== | ||
|
||
#include "UsdObject3d.h" | ||
#include "Utils.h" | ||
|
||
#include "ufe/types.h" | ||
|
||
#include "pxr/usd/usdGeom/bboxCache.h" | ||
#include "pxr/usd/usd/timeCode.h" | ||
|
||
namespace { | ||
Ufe::Vector3d toVector3d(const GfVec3d& v) | ||
{ | ||
return Ufe::Vector3d(v[0], v[1], v[2]); | ||
} | ||
|
||
} | ||
|
||
MAYAUSD_NS_DEF { | ||
namespace ufe { | ||
|
||
UsdObject3d::UsdObject3d(const UsdSceneItem::Ptr& item) | ||
: Ufe::Object3d(), fItem(item), fPrim(item->prim()) {} | ||
|
||
UsdObject3d::~UsdObject3d() {} | ||
|
||
/*static*/ | ||
UsdObject3d::Ptr UsdObject3d::create(const UsdSceneItem::Ptr& item) | ||
{ | ||
return std::make_shared<UsdObject3d>(item); | ||
} | ||
|
||
//------------------------------------------------------------------------------ | ||
// Ufe::Object3d overrides | ||
//------------------------------------------------------------------------------ | ||
|
||
Ufe::SceneItem::Ptr UsdObject3d::sceneItem() const | ||
{ | ||
return fItem; | ||
} | ||
|
||
Ufe::BBox3d UsdObject3d::boundingBox() const | ||
{ | ||
// Use USD to compute the bounding box. This is strictly speaking | ||
// incorrect, as a USD node may eventually have a Maya child, given the | ||
// full generality of UFE paths. However, as of 24-Oct-2019, this does not | ||
// exist. To support this use case, | ||
// UsdGeomBoundable::ComputeExtentFromPlugins() allows a plugin to register | ||
// an extent computation; this should be explored. | ||
// | ||
// UsdGeomImageable::ComputeLocalBound() just calls UsdGeomBBoxCache, so do | ||
// this here as well. | ||
// | ||
// Would be nice to know if the object extents are animated or not, so | ||
// we can bypass time computation and simply use UsdTimeCode::Default() | ||
// as the time. | ||
TfTokenVector purposes{UsdGeomTokens->default_}; | ||
UsdGeomBBoxCache bboxCache(getTime(sceneItem()->path()), purposes); | ||
auto bbox = bboxCache.ComputeLocalBound(fPrim); | ||
auto range = bbox.GetRange(); | ||
auto min = range.GetMin(); | ||
auto max = range.GetMax(); | ||
return Ufe::BBox3d(toVector3d(min), toVector3d(max)); | ||
} | ||
|
||
} // namespace ufe | ||
} // namespace MayaUsd |
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,50 @@ | ||
// =========================================================================== | ||
// Copyright 2019 Autodesk, Inc. All rights reserved. | ||
// | ||
// Use of this software is subject to the terms of the Autodesk license | ||
// agreement provided at the time of installation or download, or which | ||
// otherwise accompanies this software in either electronic or hard copy form. | ||
// =========================================================================== | ||
#pragma once | ||
|
||
#include "../base/api.h" | ||
#include "UsdSceneItem.h" | ||
|
||
#include "ufe/object3d.h" | ||
|
||
MAYAUSD_NS_DEF { | ||
namespace ufe { | ||
|
||
//! \brief USD run-time 3D object interface | ||
/*! | ||
This class implements the Object3d interface for USD prims. | ||
*/ | ||
class MAYAUSD_CORE_PUBLIC UsdObject3d : public Ufe::Object3d | ||
{ | ||
public: | ||
using Ptr = std::shared_ptr<UsdObject3d>; | ||
|
||
UsdObject3d(const UsdSceneItem::Ptr& item); | ||
~UsdObject3d() override; | ||
|
||
// Delete the copy/move constructors assignment operators. | ||
UsdObject3d(const UsdObject3d&) = delete; | ||
UsdObject3d& operator=(const UsdObject3d&) = delete; | ||
UsdObject3d(UsdObject3d&&) = delete; | ||
UsdObject3d& operator=(UsdObject3d&&) = delete; | ||
|
||
//! Create a UsdObject3d. | ||
static UsdObject3d::Ptr create(const UsdSceneItem::Ptr& item); | ||
|
||
// Ufe::Object3d overrides | ||
Ufe::SceneItem::Ptr sceneItem() const override; | ||
Ufe::BBox3d boundingBox() const override; | ||
|
||
private: | ||
UsdSceneItem::Ptr fItem; | ||
UsdPrim fPrim; | ||
|
||
}; // UsdObject3d | ||
|
||
} // namespace ufe | ||
} // namespace MayaUsd |
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,39 @@ | ||
// =========================================================================== | ||
// Copyright 2019 Autodesk, Inc. All rights reserved. | ||
// | ||
// Use of this software is subject to the terms of the Autodesk license | ||
// agreement provided at the time of installation or download, or which | ||
// otherwise accompanies this software in either electronic or hard copy form. | ||
// =========================================================================== | ||
|
||
#include "UsdObject3dHandler.h" | ||
#include "UsdSceneItem.h" | ||
|
||
MAYAUSD_NS_DEF { | ||
namespace ufe { | ||
|
||
UsdObject3dHandler::UsdObject3dHandler() : Ufe::Object3dHandler() {} | ||
|
||
UsdObject3dHandler::~UsdObject3dHandler() {} | ||
|
||
/*static*/ | ||
UsdObject3dHandler::Ptr UsdObject3dHandler::create() | ||
{ | ||
return std::make_shared<UsdObject3dHandler>(); | ||
} | ||
|
||
//------------------------------------------------------------------------------ | ||
// UsdObject3dHandler overrides | ||
//------------------------------------------------------------------------------ | ||
|
||
Ufe::Object3d::Ptr UsdObject3dHandler::object3d(const Ufe::SceneItem::Ptr& item) const | ||
{ | ||
UsdSceneItem::Ptr usdItem = std::dynamic_pointer_cast<UsdSceneItem>(item); | ||
#if !defined(NDEBUG) | ||
assert(usdItem); | ||
#endif | ||
return UsdObject3d::create(usdItem); | ||
} | ||
|
||
} // namespace ufe | ||
} // namespace MayaUsd |
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,46 @@ | ||
// =========================================================================== | ||
// Copyright 2019 Autodesk, Inc. All rights reserved. | ||
// | ||
// Use of this software is subject to the terms of the Autodesk license | ||
// agreement provided at the time of installation or download, or which | ||
// otherwise accompanies this software in either electronic or hard copy form. | ||
// =========================================================================== | ||
#pragma once | ||
|
||
#include "../base/api.h" | ||
|
||
#include "UsdObject3d.h" | ||
|
||
#include "ufe/object3dHandler.h" | ||
|
||
MAYAUSD_NS_DEF { | ||
namespace ufe { | ||
|
||
//! \brief USD run-time 3D object handler. | ||
/*! | ||
Factory object for Object3d interfaces. | ||
*/ | ||
class MAYAUSD_CORE_PUBLIC UsdObject3dHandler : public Ufe::Object3dHandler | ||
{ | ||
public: | ||
typedef std::shared_ptr<UsdObject3dHandler> Ptr; | ||
|
||
UsdObject3dHandler(); | ||
~UsdObject3dHandler() override; | ||
|
||
// Delete the copy/move constructors assignment operators. | ||
UsdObject3dHandler(const UsdObject3dHandler&) = delete; | ||
UsdObject3dHandler& operator=(const UsdObject3dHandler&) = delete; | ||
UsdObject3dHandler(UsdObject3dHandler&&) = delete; | ||
UsdObject3dHandler& operator=(UsdObject3dHandler&&) = delete; | ||
|
||
//! Create a UsdObject3dHandler. | ||
static UsdObject3dHandler::Ptr create(); | ||
|
||
// UsdObject3dHandler overrides | ||
Ufe::Object3d::Ptr object3d(const Ufe::SceneItem::Ptr& item) const override; | ||
|
||
}; // UsdObject3dHandler | ||
|
||
} // namespace ufe | ||
} // namespace MayaUsd |
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
Oops, something went wrong.