-
Notifications
You must be signed in to change notification settings - Fork 202
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
EMSUSD-1910 - Make USD camera invisible when the parents turn invisible #4110
base: dev
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,6 +18,8 @@ | |
#include <mayaUsd/ufe/Utils.h> | ||
#include <mayaUsd/utils/util.h> | ||
|
||
#include <pxr/usd/usdGeom/camera.h> | ||
|
||
namespace MAYAUSD_NS_DEF { | ||
namespace ufe { | ||
|
||
|
@@ -52,5 +54,33 @@ MayaUsdObject3d::adjustAlignedBBox(const Ufe::BBox3d& bbox, const PXR_NS::UsdTim | |
return UsdUfe::combineUfeBBox(bbox, pulledBBox); | ||
} | ||
|
||
#ifndef UFE_CAMERA_HAS_VISIBILITY | ||
bool MayaUsdObject3d::visibility() const | ||
{ | ||
PXR_NS::TfToken visibilityToken; | ||
auto visAttr = PXR_NS::UsdGeomImageable(prim()).GetVisibilityAttr(); | ||
visAttr.Get(&visibilityToken); | ||
|
||
// Check if the prim is a camera | ||
// if its a camera, then we need to check if the camera's parents are visible | ||
if (prim().IsA<PXR_NS::UsdGeomCamera>() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Will not break 3dsmax, but i still find it a bit iffy that now the behavior varies per object type. Makes the API inconsistant / contract unclear There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also awkward because now setVisiblity and getVisibility will not be symmetrical, you will set the authored attr but return the resolved visibility There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @deboisj Do you have another suggestion on how we can accomplish this task to hide cameras in the 3d viewport when they are hidden because their parent is hidden? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am not sure - how do you handle this for lights? Isnt it the same problem? In max - we have a mechanism to get the resolved visibility and maintain / update a cache for that - but i guess in your case that would have to be done in maya which sounds impractical Could you "hide" it by giving it no gizmo / render item? Do you control anything VS how the camera gizmo is displayed? If maya thought it was visible, but in the end nothing displays, that's probably closest to how the rest of things work in maya-usd - because everything else currently reports "visible' and may actually be "invisible", i.e. in the outliner it would not be color coded insivible There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Actually said something wrong above, the setter calls "make invisible/visible". So there is already a level of asymmetry with the getter |
||
&& (visibilityToken == PXR_NS::UsdGeomTokens->inherited)) { | ||
// get the parent of the camera | ||
Ufe::Path parentPath = sceneItem()->path().pop(); | ||
while (!parentPath.empty()) { | ||
// check if the parent is visible | ||
auto parentItem = Ufe::Hierarchy::createItem(parentPath); | ||
auto parentObject3d = Ufe::Object3d::object3d(parentItem); | ||
if (!parentObject3d->visibility()) { | ||
return false; | ||
} | ||
parentPath = parentPath.pop(); | ||
} | ||
} | ||
|
||
return visibilityToken != PXR_NS::UsdGeomTokens->invisible; | ||
} | ||
#endif // UFE_CAMERA_HAS_VISIBILITY | ||
|
||
} // namespace ufe | ||
} // namespace MAYAUSD_NS_DEF |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,6 +15,8 @@ | |
// | ||
#include "UsdObject3d.h" | ||
|
||
#include "pxr/usd/usdGeom/camera.h" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. is this needed? |
||
|
||
#include <usdUfe/ufe/UsdUndoVisibleCommand.h> | ||
#include <usdUfe/ufe/Utils.h> | ||
#include <usdUfe/utils/editRouter.h> | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you put a comment here stating that when the camera has the visibility method it will be used and this method is used in the older Maya case.