Skip to content

Commit

Permalink
MAYA-126389: Lanierd/MAYA-126389_NEW (#303)
Browse files Browse the repository at this point in the history
* MAYA-126389 : fix selection color for wireframe display.

(cherry picked from commit 2498a978074c66f41942aa5f26e34c3e52a6f1b2)

* Adding more comments and factorize.

(cherry picked from commit 1491fecdbdf1b62b48f05c8704dca5a66a3f6931)

* Fixed a mistake in init color of kLead.

(cherry picked from commit 658bc3a453395e5d0038807ff8c025f909f67b29)

* MAYA-126389 : Fix wireframe colors for selection highlight.

* MAYA-126389 : Implement suggestions from code review and fix the first letter of the RenderItem name being eaten.

* Remove fix for MAYA-125923 and reopen the JIRA.
  • Loading branch information
lanierd-adsk authored and GitHub Enterprise committed Dec 1, 2022
1 parent 9a838e5 commit a6d2d31
Show file tree
Hide file tree
Showing 8 changed files with 198 additions and 66 deletions.
2 changes: 1 addition & 1 deletion lib/mayaUsd/render/mayaToHydra/renderOverride.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -601,7 +601,7 @@ MStatus MtohRenderOverride::Render(const MHWRender::MDrawContext& drawContext, c
auto sceneDelegate = std::dynamic_pointer_cast<HdMayaSceneDelegate>(it);
if (sceneDelegate)
{
sceneDelegate->HandleCompleteViewportScene(scene);
sceneDelegate->HandleCompleteViewportScene(scene, static_cast<MFrameContext::DisplayStyle>(drawContext.getDisplayStyle()));
sceneDelegate->ScheduleRenderTasks(tasks);
}
}
Expand Down
2 changes: 1 addition & 1 deletion lib/usd/hdMaya/adapters/directionalLightAdapter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ class HdMayaDirectionalLightAdapter : public HdMayaLightAdapter
{
TF_DEBUG(HDMAYA_ADAPTER_GET)
.Msg(
"Called HdMayaSpotLightAdapter::Get(%s) - %s\n",
"Called HdMayaDirectionalLightAdapter::Get(%s) - %s\n",
key.GetText(),
GetDagPath().partialPathName().asChar());

Expand Down
30 changes: 21 additions & 9 deletions lib/usd/hdMaya/adapters/renderItemAdapter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -355,23 +355,35 @@ void HdMayaRenderItemAdapter::_RemoveRprim()
GetDelegate()->RemoveRprim(GetID());
}

void HdMayaRenderItemAdapter::UpdateFromDelta(MRenderItem& ri, unsigned int flags)


void HdMayaRenderItemAdapter::UpdateFromDelta(const UpdateFromDeltaData& data)
{
if (_primitive != MHWRender::MGeometry::Primitive::kTriangles
&& _primitive != MHWRender::MGeometry::Primitive::kLines) {
return;
}

//const bool isNew = flags & MViewportScene::MVS_new; //not used yet
const bool visible = flags & MViewportScene::MVS_visible;
const bool visible = data._flags & MViewportScene::MVS_visible;
const bool matrixChanged = data._flags & MViewportScene::MVS_changedMatrix;
const bool geomChanged = data._flags & MViewportScene::MVS_changedGeometry;
const bool topoChanged = data._flags & MViewportScene::MVS_changedTopo;
const bool visibChanged = data._flags & MViewportScene::MVS_changedVisibility;
const bool effectChanged = data._flags & MViewportScene::MVS_changedEffect;

const bool isLinePrimitive = (MHWRender::MGeometry::Primitive::kLines == _primitive);

const bool matrixChanged = flags & MViewportScene::MVS_changedMatrix;
const bool geomChanged = flags & MViewportScene::MVS_changedGeometry;
const bool topoChanged = flags & MViewportScene::MVS_changedTopo;
const bool visibChanged = flags & MViewportScene::MVS_changedVisibility;
const bool effectChanged = flags & MViewportScene::MVS_changedEffect;
_wireframeColor = data._wireframeColor;
_displayStatus = data._displayStatus;

HdDirtyBits dirtyBits = 0;
//At some point, we will have to handle the dormant color if the user customized the wireframe color of an object
//as we use the same color for all dormant objects
if (isLinePrimitive){
GetDelegate()->UpdateDisplayStatusMaterial(_displayStatus, _wireframeColor);
}

HdDirtyBits dirtyBits = 0;

if (visibChanged)
{
Expand All @@ -394,7 +406,7 @@ void HdMayaRenderItemAdapter::UpdateFromDelta(MRenderItem& ri, unsigned int flag

MGeometry* geom = nullptr;
if (geomChanged | topoChanged) {
geom = ri.geometry();
geom = data._ri.geometry();
}
VtIntArray vertexIndices;
VtIntArray vertexCounts;
Expand Down
27 changes: 25 additions & 2 deletions lib/usd/hdMaya/adapters/renderItemAdapter.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
#include <pxr/imaging/hdx/renderTask.h>

#include <maya/MMatrix.h>
#include <maya/MHWGeometryUtilities.h>

#include <functional>
#include <memory>
Expand Down Expand Up @@ -192,6 +193,12 @@ class HdMayaRenderItemAdapter : public HdMayaAdapter
HDMAYA_API
void SetVisible(bool val) { _visible = val; }

HDMAYA_API
const MColor& GetWireframeColor() const { return _wireframeColor; }

HDMAYA_API
MHWRender::DisplayStatus GetDisplayStatus() const { return _displayStatus; }

// TODO: move transform to common base class with HdMayaDagAdapter
HDMAYA_API
GfMatrix4d GetTransform() { return _transform[0]; }
Expand All @@ -211,8 +218,23 @@ class HdMayaRenderItemAdapter : public HdMayaAdapter
HDMAYA_API
void UpdateTopology(MRenderItem& ri);

//Class used to pass data to the UpdateFromDelta method, so we can extend the parameters in the future if needed.
class UpdateFromDeltaData
{
public:
UpdateFromDeltaData(MRenderItem& ri, unsigned int flags, const MColor& wireframeColor, MHWRender::DisplayStatus displayStatus) :
_ri(ri), _flags(flags), _wireframeColor(wireframeColor), _displayStatus(displayStatus)
{
}

MRenderItem& _ri;
unsigned int _flags;
const MColor& _wireframeColor;
MHWRender::DisplayStatus _displayStatus;
};

HDMAYA_API
void UpdateFromDelta(MRenderItem& ri, unsigned int flags);
void UpdateFromDelta(const UpdateFromDeltaData& data);

HDMAYA_API
virtual std::shared_ptr<HdTopology> GetTopology();
Expand Down Expand Up @@ -252,7 +274,8 @@ class HdMayaRenderItemAdapter : public HdMayaAdapter
GfMatrix4d _transform[2]; // TODO: move transform to common base class with HdMayaDagAdapter
int _fastId = 0;
bool _visible = false;

MColor _wireframeColor = {1.f,1.f,1.f,1.f};
MHWRender::DisplayStatus _displayStatus = MHWRender::DisplayStatus::kNoStatus;
};

PXR_NAMESPACE_CLOSE_SCOPE
Expand Down
17 changes: 7 additions & 10 deletions lib/usd/hdMaya/delegates/delegateCtx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,16 +59,13 @@ SdfPath _GetRenderItemPrimPath(const SdfPath& base, const MRenderItem& ri)
if (ri.InternalObjectId() == 0) return {};
const auto mayaPath = UsdMayaUtil::RenderItemToUsdPath(ri, false, false);
if (mayaPath.IsEmpty()) return {};

const auto* chr = mayaPath.GetText();
if (chr == nullptr) {
return {};
};
std::string s(chr + 1);
if (s.empty()) {
return {};
}
return base.AppendPath(SdfPath(s));

const std::string theString = std::string(mayaPath.GetText());
if (theString.size() < 2){
return {};//Error
}

return base.AppendPath(mayaPath);
}

SdfPath _GetRenderItemShaderPrimPath(const SdfPath& base, const MRenderItem& ri)
Expand Down
3 changes: 3 additions & 0 deletions lib/usd/hdMaya/delegates/delegateCtx.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#include <pxr/usd/sdf/path.h>

#include <maya/MDagPath.h>
#include <maya/MHWGeometryUtilities.h>

PXR_NAMESPACE_OPEN_SCOPE

Expand Down Expand Up @@ -59,6 +60,8 @@ class HdMayaDelegateCtx
virtual void RecreateAdapter(const SdfPath& id, const MObject& obj) { }
virtual void RecreateAdapterOnIdle(const SdfPath& id, const MObject& obj) { }
virtual void RebuildAdapterOnIdle(const SdfPath& id, uint32_t flags) { }
virtual void UpdateDisplayStatusMaterial(MHWRender::DisplayStatus displayStatus, const MColor& wireframecolor) {}

/// \brief Notifies the scene delegate when a material tag changes.
///
/// \param id Id of the Material that changed its tag.
Expand Down
Loading

0 comments on commit a6d2d31

Please sign in to comment.