diff --git a/lib/mayaHydra/hydraExtensions/adapters/adapter.h b/lib/mayaHydra/hydraExtensions/adapters/adapter.h index d15c4efc5..c3f1d5990 100644 --- a/lib/mayaHydra/hydraExtensions/adapters/adapter.h +++ b/lib/mayaHydra/hydraExtensions/adapters/adapter.h @@ -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 _callbacks; diff --git a/lib/mayaHydra/hydraExtensions/adapters/dagAdapter.h b/lib/mayaHydra/hydraExtensions/adapters/dagAdapter.h index c381dbac7..81fed0d5d 100644 --- a/lib/mayaHydra/hydraExtensions/adapters/dagAdapter.h +++ b/lib/mayaHydra/hydraExtensions/adapters/dagAdapter.h @@ -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); diff --git a/lib/mayaHydra/hydraExtensions/adapters/renderItemAdapter.cpp b/lib/mayaHydra/hydraExtensions/adapters/renderItemAdapter.cpp index ddc4a76cd..1bfdd561d 100644 --- a/lib/mayaHydra/hydraExtensions/adapters/renderItemAdapter.cpp +++ b/lib/mayaHydra/hydraExtensions/adapters/renderItemAdapter.cpp @@ -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 /////////////////////////////////////////////////////////////////////// diff --git a/lib/mayaHydra/hydraExtensions/adapters/renderItemAdapter.h b/lib/mayaHydra/hydraExtensions/adapters/renderItemAdapter.h index 3a7abbd90..bae81b3f9 100644 --- a/lib/mayaHydra/hydraExtensions/adapters/renderItemAdapter.h +++ b/lib/mayaHydra/hydraExtensions/adapters/renderItemAdapter.h @@ -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; } diff --git a/lib/mayaHydra/hydraExtensions/sceneIndex/mayaHydraSceneIndex.cpp b/lib/mayaHydra/hydraExtensions/sceneIndex/mayaHydraSceneIndex.cpp index 297528b09..f972ad495 100644 --- a/lib/mayaHydra/hydraExtensions/sceneIndex/mayaHydraSceneIndex.cpp +++ b/lib/mayaHydra/hydraExtensions/sceneIndex/mayaHydraSceneIndex.cpp @@ -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 bool shouldBeLighted(const T& src); - //Template specialization for MDagPath - template<> inline bool shouldBeLighted(const MDagPath& dag) { - return (MFnDependencyNode(dag.node()).typeName().asChar() == TfToken("mesh")); - } - //Template specialization for MRenderItem - template<> inline bool shouldBeLighted(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 SdfPath GetMayaPrimPath(const T& src) { @@ -1424,19 +1405,13 @@ void MayaHydraSceneIndex::_RemoveRenderItem(const MayaHydraRenderItemAdapterPtr& void MayaHydraSceneIndex::GetLightedPrimPaths(SdfPathVector& lightedPrimPaths) { - _MapAdapter( - [&](MayaHydraRenderItemAdapter* a) { - if (a->GetPrimitive() == MHWRender::MGeometry::Primitive::kTriangles) { - lightedPrimPaths.emplace_back(a->GetID()); - } - }, - _renderItemsAdapters); - _MapAdapter( - [&](MayaHydraDagAdapter* a) { - if (a->HasType(HdPrimTypeTokens->mesh)) { + _MapAdapter( + [&](MayaHydraAdapter* a) { + if (a->WantBeLighted()) { lightedPrimPaths.emplace_back(a->GetID()); } }, + _renderItemsAdapters, _shapeAdapters); }