Skip to content

Commit

Permalink
update based on review
Browse files Browse the repository at this point in the history
  • Loading branch information
lilike-adsk committed Nov 28, 2024
1 parent f5920f4 commit 8c6183e
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 29 deletions.
2 changes: 2 additions & 0 deletions lib/mayaHydra/hydraExtensions/adapters/adapter.h
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,8 @@ class MayaHydraAdapter
MAYAHYDRALIB_API
virtual GfVec4f GetDisplayColor() const { return {1.f,1.f,1.f,1.f}; }

virtual bool WantBeLighted() const { return false; }

protected:
SdfPath _id;
std::vector<MCallbackId> _callbacks;
Expand Down
2 changes: 2 additions & 0 deletions lib/mayaHydra/hydraExtensions/adapters/dagAdapter.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ class MayaHydraDagAdapter : public MayaHydraAdapter
MAYAHYDRALIB_API
VtValue GetInstancePrimvar(const TfToken& key);

bool WantBeLighted() const override {return (MFnDependencyNode(_dagPath.node()).typeName().asChar() == TfToken("mesh")); }

protected:
MAYAHYDRALIB_API
void _AddHierarchyChangedCallbacks(MDagPath& dag);
Expand Down
13 changes: 13 additions & 0 deletions lib/mayaHydra/hydraExtensions/adapters/renderItemAdapter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -575,6 +575,19 @@ HdCullStyle MayaHydraRenderItemAdapter::GetCullStyle() const
#endif
}

bool MayaHydraRenderItemAdapter::WantBeLighted() const
{
// Special case to recognize the Arnold skydome light
if ((_isArnoldSkyDomeLightTriangleShape)) {
return false; // Don't light the sky dome light shape
}

return (
MHWRender::MGeometry::Primitive::kLines != _primitive
&& MHWRender::MGeometry::Primitive::kLineStrip != _primitive
&& MHWRender::MGeometry::Primitive::kPoints != _primitive);
}

///////////////////////////////////////////////////////////////////////
// TF_REGISTRY
///////////////////////////////////////////////////////////////////////
Expand Down
2 changes: 2 additions & 0 deletions lib/mayaHydra/hydraExtensions/adapters/renderItemAdapter.h
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,8 @@ class MayaHydraRenderItemAdapter : public MayaHydraAdapter
MAYAHYDRALIB_API
virtual TfToken GetRenderTag() const override;

bool WantBeLighted() const override;

MAYAHYDRALIB_API
SdfPath& GetMaterial() { return _material; }

Expand Down
33 changes: 4 additions & 29 deletions lib/mayaHydra/hydraExtensions/sceneIndex/mayaHydraSceneIndex.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -235,25 +235,6 @@ namespace {
return sdfDagPath.AppendPath(inPath);
}

///Returns false if this object should not be lighted, true if it should be lighted
template<class T> bool shouldBeLighted(const T& src);
//Template specialization for MDagPath
template<> inline bool shouldBeLighted<MDagPath>(const MDagPath& dag) {
return (MFnDependencyNode(dag.node()).typeName().asChar() == TfToken("mesh"));
}
//Template specialization for MRenderItem
template<> inline bool shouldBeLighted<MRenderItem>(const MRenderItem& ri) {

//Special case to recognize the Arnold skydome light
if (isRenderItem_aiSkyDomeLightTriangleShape(ri)) {
return false;//Don't light the sky dome light shape
}

return (MHWRender::MGeometry::Primitive::kLines != ri.primitive()
&& MHWRender::MGeometry::Primitive::kLineStrip != ri.primitive()
&& MHWRender::MGeometry::Primitive::kPoints != ri.primitive());
}

template<class T>
SdfPath GetMayaPrimPath(const T& src)
{
Expand Down Expand Up @@ -1424,19 +1405,13 @@ void MayaHydraSceneIndex::_RemoveRenderItem(const MayaHydraRenderItemAdapterPtr&

void MayaHydraSceneIndex::GetLightedPrimPaths(SdfPathVector& lightedPrimPaths)
{
_MapAdapter<MayaHydraRenderItemAdapter>(
[&](MayaHydraRenderItemAdapter* a) {
if (a->GetPrimitive() == MHWRender::MGeometry::Primitive::kTriangles) {
lightedPrimPaths.emplace_back(a->GetID());
}
},
_renderItemsAdapters);
_MapAdapter<MayaHydraDagAdapter>(
[&](MayaHydraDagAdapter* a) {
if (a->HasType(HdPrimTypeTokens->mesh)) {
_MapAdapter<MayaHydraAdapter>(
[&](MayaHydraAdapter* a) {
if (a->WantBeLighted()) {
lightedPrimPaths.emplace_back(a->GetID());
}
},
_renderItemsAdapters,
_shapeAdapters);
}

Expand Down

0 comments on commit 8c6183e

Please sign in to comment.