Skip to content

Commit

Permalink
Merge branch 'public_dev' into vlasovi/HYDRA-927
Browse files Browse the repository at this point in the history
# Conflicts:
#	lib/mayaHydra/mayaPlugin/renderOverride.cpp
  • Loading branch information
vlasovi committed Mar 21, 2024
2 parents 7dc2057 + 59b9563 commit 5cf138f
Show file tree
Hide file tree
Showing 34 changed files with 339 additions and 613 deletions.
2 changes: 1 addition & 1 deletion doc/codingGuidelines.md
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ For source files (.cpp) with an associated header file (.h) that resides in the
All included public header files from outside and inside the project should be `#include`’d using angle brackets. For example:
```cpp
#include <pxr/base/tf/stringUtils.h>
#include <mayaHydraLib/mayaHydraSceneProducer.h>
#include <mayaHydraLib/sceneIndex/mayaHydraSceneIndex.h>
```

Private project’s header files should be `#include`'d using double quotes, and a relative path. Private headers may live in the same directory or sub-directories, but they should never be included using "._" or ".._" as part of a relative path. For example:
Expand Down
6 changes: 3 additions & 3 deletions doc/mayaHydraDetails.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ classDiagram
-_renderIndex: HdRenderIndex*
-_fvpSelectionTracker: Fvp::SelectionTrackerSharedPtr
-_selectionSceneIndex: Fvp::SelectionSceneIndexRefPtr
-_mayaHydraSceneProducer: std::unique_ptr<MayaHydraSceneProducer>
-_mayaHydraSceneIndex: std::unique_ptr<MayaHydraSceneIndex>
+Render(const MHWRender::MDrawContext& drawContext, const MHWRender::MDataServerOperation::MViewportScene& scene)
}
```
Expand Down Expand Up @@ -129,8 +129,8 @@ stateDiagram
state InitHydraResources() {
[*] --> HydraResources
HydraResources --> MayaHydraSceneProducer() : RenderDelegate/RenderIndex
MayaHydraSceneProducer() --> Populate() : Creates MayaHydra specific Scene Indices internally
HydraResources --> MayaHydraSceneIndex() : RenderDelegate/RenderIndex
MayaHydraSceneIndex() --> Populate() : Creates MayaHydra specific Scene Indices internally
Populate() --> MayaHydraAdapter : Loop over Maya native nodes
MayaHydraAdapter --> SceneIndexRegistration : Flow Viewport API (WIP) to inject various Scene Indices including USD data and SelectionHighlighting
SceneIndexRegistration --> [*]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,10 @@ install(TARGETS ${TARGET_NAME}
DESTINATION ${CMAKE_INSTALL_PREFIX}/lib/maya)

if(IS_WINDOWS)
install(FILES $<TARGET_PDB_FILE:${TARGET_NAME}>
DESTINATION ${CMAKE_INSTALL_PREFIX}/lib/maya OPTIONAL)
if (NOT CODE_COVERAGE)
install(FILES $<TARGET_PDB_FILE:${TARGET_NAME}>
DESTINATION ${CMAKE_INSTALL_PREFIX}/lib/maya OPTIONAL)
endif()
endif()

set(LIBFILENAME ${CMAKE_SHARED_LIBRARY_PREFIX}${TARGET_NAME}${CMAKE_SHARED_LIBRARY_SUFFIX})
Expand Down
2 changes: 0 additions & 2 deletions lib/mayaHydra/hydraExtensions/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ target_sources(${TARGET_NAME}
mayaUtils.cpp
mhBuildInfo.cpp
mixedUtils.cpp
mayaHydraSceneProducer.cpp
)

set(HEADERS
Expand All @@ -25,7 +24,6 @@ set(HEADERS
mayaHydraLibInterfaceImp.h
mayaUtils.h
mixedUtils.h
mayaHydraSceneProducer.h
)

# -----------------------------------------------------------------------------
Expand Down
10 changes: 5 additions & 5 deletions lib/mayaHydra/hydraExtensions/adapters/adapter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
#include <mayaHydraLib/adapters/adapterDebugCodes.h>
#include <mayaHydraLib/adapters/materialNetworkConverter.h>
#include <mayaHydraLib/adapters/mayaAttrs.h>
#include <mayaHydraLib/mayaHydraSceneProducer.h>
#include <mayaHydraLib/sceneIndex/mayaHydraSceneIndex.h>

#include <pxr/base/tf/type.h>

Expand All @@ -36,7 +36,7 @@ void _preRemoval(MObject& node, void* clientData)
auto* adapter = reinterpret_cast<MayaHydraAdapter*>(clientData);
TF_DEBUG(MAYAHYDRALIB_ADAPTER_CALLBACKS)
.Msg("Pre-removal callback triggered for prim (%s)\n", adapter->GetID().GetText());
adapter->GetSceneProducer()->RemoveAdapter(adapter->GetID());
adapter->GetMayaHydraSceneIndex()->RemoveAdapter(adapter->GetID());
}

void _nameChanged(MObject& node, const MString& str, void* clientData)
Expand All @@ -47,7 +47,7 @@ void _nameChanged(MObject& node, const MString& str, void* clientData)
TF_DEBUG(MAYAHYDRALIB_ADAPTER_CALLBACKS)
.Msg("Name-changed callback triggered for prim (%s)\n", adapter->GetID().GetText());
adapter->RemoveCallbacks();
adapter->GetSceneProducer()->RecreateAdapterOnIdle(adapter->GetID(), adapter->GetNode());
adapter->GetMayaHydraSceneIndex()->RecreateAdapterOnIdle(adapter->GetID(), adapter->GetNode());
}

} // namespace
Expand All @@ -57,9 +57,9 @@ void _nameChanged(MObject& node, const MString& str, void* clientData)
MayaHydraAdapter::MayaHydraAdapter(
const MObject& node,
const SdfPath& id,
MayaHydraSceneProducer* producer)
MayaHydraSceneIndex* mayaHydraSceneIndex)
: _id(id)
, _sceneProducer(producer)
, _mayaHydraSceneIndex(mayaHydraSceneIndex)
, _node(node)
{
}
Expand Down
10 changes: 5 additions & 5 deletions lib/mayaHydra/hydraExtensions/adapters/adapter.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@

PXR_NAMESPACE_OPEN_SCOPE

class MayaHydraSceneProducer;
class MayaHydraSceneIndex;

/**
* \brief MayaHydraAdapter is the base class for all adapters. An adapter is used to translate from
Expand All @@ -55,12 +55,12 @@ class MayaHydraAdapter
{
public:
MAYAHYDRALIB_API
MayaHydraAdapter(const MObject& node, const SdfPath& id, MayaHydraSceneProducer* producer);
MayaHydraAdapter(const MObject& node, const SdfPath& id, MayaHydraSceneIndex* mayaHydraSceneIndex);
MAYAHYDRALIB_API
virtual ~MayaHydraAdapter();

const SdfPath& GetID() const { return _id; }
MayaHydraSceneProducer* GetSceneProducer() const { return _sceneProducer; }
const SdfPath& GetID() const { return _id; }
MayaHydraSceneIndex* GetMayaHydraSceneIndex() const { return _mayaHydraSceneIndex; }
MAYAHYDRALIB_API
void AddCallback(MCallbackId callbackId);
MAYAHYDRALIB_API
Expand Down Expand Up @@ -109,7 +109,7 @@ class MayaHydraAdapter
protected:
SdfPath _id;
std::vector<MCallbackId> _callbacks;
MayaHydraSceneProducer* _sceneProducer;
MayaHydraSceneIndex* _mayaHydraSceneIndex;
MObject _node;

bool _isPopulated = false;
Expand Down
8 changes: 4 additions & 4 deletions lib/mayaHydra/hydraExtensions/adapters/adapterRegistry.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,15 @@ class MayaHydraAdapterRegistry : public TfSingleton<MayaHydraAdapterRegistry>

public:
using ShapeAdapterCreator
= std::function<MayaHydraShapeAdapterPtr(MayaHydraSceneProducer*, const MDagPath&)>;
= std::function<MayaHydraShapeAdapterPtr(MayaHydraSceneIndex*, const MDagPath&)>;
MAYAHYDRALIB_API
static void RegisterShapeAdapter(const TfToken& type, ShapeAdapterCreator creator);

MAYAHYDRALIB_API
static ShapeAdapterCreator GetShapeAdapterCreator(const MDagPath& dag);

using LightAdapterCreator
= std::function<MayaHydraLightAdapterPtr(MayaHydraSceneProducer*, const MDagPath&)>;
= std::function<MayaHydraLightAdapterPtr(MayaHydraSceneIndex*, const MDagPath&)>;
MAYAHYDRALIB_API
static void RegisterLightAdapter(const TfToken& type, LightAdapterCreator creator);

Expand All @@ -63,15 +63,15 @@ class MayaHydraAdapterRegistry : public TfSingleton<MayaHydraAdapterRegistry>
static LightAdapterCreator GetLightAdapterCreator(const MObject& dag);

using MaterialAdapterCreator = std::function<
MayaHydraMaterialAdapterPtr(const SdfPath&, MayaHydraSceneProducer*, const MObject&)>;
MayaHydraMaterialAdapterPtr(const SdfPath&, MayaHydraSceneIndex*, const MObject&)>;
MAYAHYDRALIB_API
static void RegisterMaterialAdapter(const TfToken& type, MaterialAdapterCreator creator);

MAYAHYDRALIB_API
static MaterialAdapterCreator GetMaterialAdapterCreator(const MObject& node);

using CameraAdapterCreator
= std::function<MayaHydraCameraAdapterPtr(MayaHydraSceneProducer*, const MDagPath&)>;
= std::function<MayaHydraCameraAdapterPtr(MayaHydraSceneIndex*, const MDagPath&)>;
MAYAHYDRALIB_API
static void RegisterCameraAdapter(const TfToken& type, CameraAdapterCreator creator);

Expand Down
14 changes: 7 additions & 7 deletions lib/mayaHydra/hydraExtensions/adapters/aiSkydomeLightAdapter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
#include <mayaHydraLib/adapters/lightAdapter.h>
#include <mayaHydraLib/adapters/mayaAttrs.h>
#include <mayaHydraLib/adapters/tokens.h>
#include <mayaHydraLib/mayaHydraSceneProducer.h>
#include <mayaHydraLib/sceneIndex/mayaHydraSceneIndex.h>

#include <pxr/base/tf/type.h>
#include <pxr/imaging/hd/light.h>
Expand All @@ -33,7 +33,7 @@

PXR_NAMESPACE_OPEN_SCOPE

class MayaHydraSceneProducer;
class MayaHydraSceneIndex;

/**
* \brief MayaHydraAiSkyDomeLightAdapter is used to handle the translation from an Arnold skydome
Expand All @@ -59,8 +59,8 @@ class MayaHydraAiSkyDomeLightAdapter : public MayaHydraLightAdapter
bool _colorIsConnected = false;

public:
MayaHydraAiSkyDomeLightAdapter(MayaHydraSceneProducer* producer, const MDagPath& dag)
: MayaHydraLightAdapter(producer, dag)
MayaHydraAiSkyDomeLightAdapter(MayaHydraSceneIndex* mayaHydraSceneIndex, const MDagPath& dag)
: MayaHydraLightAdapter(mayaHydraSceneIndex, dag)
{
//Init static variables if needed
if (! _pTextureManager){
Expand Down Expand Up @@ -185,7 +185,7 @@ class MayaHydraAiSkyDomeLightAdapter : public MayaHydraLightAdapter
if (!_colorIsConnected){
if (!_dummyTextureFullPathFilename.empty()){
// Update Hydra texture resource everytime Domelight color is tweaked.
auto resourceReg = GetSceneProducer()->GetRenderIndex().GetResourceRegistry();
auto resourceReg = GetMayaHydraSceneIndex()->GetRenderIndex().GetResourceRegistry();
if (TF_VERIFY(resourceReg, "Unable to update AikSkyDomelights constant color"))
resourceReg->ReloadResource(TfToken("texture"), _dummyTextureFullPathFilename);
// SdfAssetPath requires both "path" and "resolvedPath"
Expand Down Expand Up @@ -240,8 +240,8 @@ TF_REGISTRY_FUNCTION_WITH_TAG(MayaHydraAdapterRegistry, domeLight)
{
MayaHydraAdapterRegistry::RegisterLightAdapter(
TfToken("aiSkyDomeLight"),
[](MayaHydraSceneProducer* producer, const MDagPath& dag) -> MayaHydraLightAdapterPtr {
return MayaHydraLightAdapterPtr(new MayaHydraAiSkyDomeLightAdapter(producer, dag));
[](MayaHydraSceneIndex* mayaHydraSceneIndex, const MDagPath& dag) -> MayaHydraLightAdapterPtr {
return MayaHydraLightAdapterPtr(new MayaHydraAiSkyDomeLightAdapter(mayaHydraSceneIndex, dag));
});
}

Expand Down
12 changes: 6 additions & 6 deletions lib/mayaHydra/hydraExtensions/adapters/areaLightAdapter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
#include <mayaHydraLib/adapters/adapterDebugCodes.h>
#include <mayaHydraLib/adapters/adapterRegistry.h>
#include <mayaHydraLib/adapters/lightAdapter.h>
#include <mayaHydraLib/mayaHydraSceneProducer.h>
#include <mayaHydraLib/sceneIndex/mayaHydraSceneIndex.h>

#include <pxr/base/tf/type.h>
#include <pxr/imaging/hd/light.h>
Expand All @@ -31,16 +31,16 @@ PXR_NAMESPACE_OPEN_SCOPE
class MayaHydraAreaLightAdapter : public MayaHydraLightAdapter
{
public:
MayaHydraAreaLightAdapter(MayaHydraSceneProducer* producer, const MDagPath& dag)
: MayaHydraLightAdapter(producer, dag)
MayaHydraAreaLightAdapter(MayaHydraSceneIndex* mayaHydraSceneIndex, const MDagPath& dag)
: MayaHydraLightAdapter(mayaHydraSceneIndex, dag)
{
}

void _CalculateLightParams(GlfSimpleLight& light) override { light.SetSpotCutoff(90.0f); }

const TfToken& LightType() const override
{
if (GetSceneProducer()->IsHdSt()) {
if (GetMayaHydraSceneIndex()->IsHdSt()) {
return HdPrimTypeTokens->simpleLight;
} else {
return HdPrimTypeTokens->rectLight;
Expand Down Expand Up @@ -73,8 +73,8 @@ TF_REGISTRY_FUNCTION_WITH_TAG(MayaHydraAdapterRegistry, pointLight)
{
MayaHydraAdapterRegistry::RegisterLightAdapter(
TfToken("areaLight"),
[](MayaHydraSceneProducer* producer, const MDagPath& dag) -> MayaHydraLightAdapterPtr {
return MayaHydraLightAdapterPtr(new MayaHydraAreaLightAdapter(producer, dag));
[](MayaHydraSceneIndex* mayaHydraSceneIndex, const MDagPath& dag) -> MayaHydraLightAdapterPtr {
return MayaHydraLightAdapterPtr(new MayaHydraAreaLightAdapter(mayaHydraSceneIndex, dag));
});
}

Expand Down
26 changes: 13 additions & 13 deletions lib/mayaHydra/hydraExtensions/adapters/cameraAdapter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
#include <mayaHydraLib/adapters/adapterDebugCodes.h>
#include <mayaHydraLib/adapters/adapterRegistry.h>
#include <mayaHydraLib/adapters/mayaAttrs.h>
#include <mayaHydraLib/mayaHydraSceneProducer.h>
#include <mayaHydraLib/sceneIndex/mayaHydraSceneIndex.h>

#include <pxr/base/gf/interval.h>
#include <pxr/imaging/hd/camera.h>
Expand All @@ -40,16 +40,16 @@ TF_REGISTRY_FUNCTION_WITH_TAG(MayaHydraAdapterRegistry, camera)
{
MayaHydraAdapterRegistry::RegisterCameraAdapter(
HdPrimTypeTokens->camera,
[](MayaHydraSceneProducer* producer, const MDagPath& dag) -> MayaHydraCameraAdapterPtr {
return MayaHydraCameraAdapterPtr(new MayaHydraCameraAdapter(producer, dag));
[](MayaHydraSceneIndex* mayaHydraSceneIndex, const MDagPath& dag) -> MayaHydraCameraAdapterPtr {
return MayaHydraCameraAdapterPtr(new MayaHydraCameraAdapter(mayaHydraSceneIndex, dag));
});
}

} // namespace

// MayaHydraCameraAdapter is used to handle the translation from a Maya camera to hydra.
MayaHydraCameraAdapter::MayaHydraCameraAdapter(MayaHydraSceneProducer* producer, const MDagPath& dag)
: MayaHydraShapeAdapter(producer->GetPrimPath(dag, true), producer, dag)
MayaHydraCameraAdapter::MayaHydraCameraAdapter(MayaHydraSceneIndex* mayaHydraSceneIndex, const MDagPath& dag)
: MayaHydraShapeAdapter(mayaHydraSceneIndex->GetPrimPath(dag, true), mayaHydraSceneIndex, dag)
{
}

Expand All @@ -59,23 +59,23 @@ TfToken MayaHydraCameraAdapter::CameraType() { return HdPrimTypeTokens->camera;

bool MayaHydraCameraAdapter::IsSupported() const
{
return GetSceneProducer()->GetRenderIndex().IsSprimTypeSupported(CameraType());
return GetMayaHydraSceneIndex()->GetRenderIndex().IsSprimTypeSupported(CameraType());
}

void MayaHydraCameraAdapter::Populate()
{
if (_isPopulated) {
return;
}
GetSceneProducer()->InsertSprim(this, CameraType(), GetID(), HdCamera::AllDirty);
GetMayaHydraSceneIndex()->InsertPrim(this, CameraType(), GetID());
_isPopulated = true;
}

void MayaHydraCameraAdapter::MarkDirty(HdDirtyBits dirtyBits)
{
if (_isPopulated && dirtyBits != 0) {
dirtyBits = dirtyBits & HdCamera::AllDirty;
GetSceneProducer()->MarkSprimDirty(GetID(), dirtyBits);
GetMayaHydraSceneIndex()->MarkSprimDirty(GetID(), dirtyBits);
}
}

Expand Down Expand Up @@ -120,7 +120,7 @@ void MayaHydraCameraAdapter::RemovePrim()
if (!_isPopulated) {
return;
}
GetSceneProducer()->RemoveSprim(CameraType(), GetID());
GetMayaHydraSceneIndex()->RemovePrim(GetID());
_isPopulated = false;
}

Expand Down Expand Up @@ -195,20 +195,20 @@ VtValue MayaHydraCameraAdapter::GetCameraParamValue(const TfToken& paramName)

if (paramName == HdCameraTokens->shutterOpen) {
// No motion samples, instantaneous shutter
if (!GetSceneProducer()->GetParams().motionSamplesEnabled())
if (!GetMayaHydraSceneIndex()->GetParams().motionSamplesEnabled())
return VtValue(double(0));
return VtValue(double(GetSceneProducer()->GetCurrentTimeSamplingInterval().GetMin()));
return VtValue(double(GetMayaHydraSceneIndex()->GetCurrentTimeSamplingInterval().GetMin()));
}
if (paramName == HdCameraTokens->shutterClose) {
// No motion samples, instantaneous shutter
if (!GetSceneProducer()->GetParams().motionSamplesEnabled())
if (!GetMayaHydraSceneIndex()->GetParams().motionSamplesEnabled())
return VtValue(double(0));
const auto shutterAngle = camera.shutterAngle(&status);
if (hadError(status))
return {};
auto constexpr maxRadians = M_PI * 2.0;
auto shutterClose = std::min(std::max(0.0, shutterAngle), maxRadians) / maxRadians;
auto interval = GetSceneProducer()->GetCurrentTimeSamplingInterval();
auto interval = GetMayaHydraSceneIndex()->GetCurrentTimeSamplingInterval();
return VtValue(double(interval.GetMin() + interval.GetSize() * shutterClose));
}

Expand Down
4 changes: 2 additions & 2 deletions lib/mayaHydra/hydraExtensions/adapters/cameraAdapter.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

PXR_NAMESPACE_OPEN_SCOPE

class MayaHydraSceneProducer;
class MayaHydraSceneIndex;

/**
* \brief MayaHydraCameraAdapter is used to handle the translation from a Maya camera to hydra.
Expand All @@ -32,7 +32,7 @@ class MayaHydraCameraAdapter : public MayaHydraShapeAdapter
{
public:
MAYAHYDRALIB_API
MayaHydraCameraAdapter(MayaHydraSceneProducer* producer, const MDagPath& dag);
MayaHydraCameraAdapter(MayaHydraSceneIndex* mayaHydraSceneIndex, const MDagPath& dag);

MAYAHYDRALIB_API
virtual ~MayaHydraCameraAdapter();
Expand Down
Loading

0 comments on commit 5cf138f

Please sign in to comment.