Skip to content

Commit

Permalink
Draw MM native ImagePlanes in background pass.
Browse files Browse the repository at this point in the history
This allows surfaces to be hidden-line wireframe, with an MM ImagePlane
behind it.

Before this change, Maya native ImagePlanes were drawn behind "hidden
line" surfaces, but now both native and MM ImagePlanes work as expected.
  • Loading branch information
david-cattermole committed Jan 2, 2023
1 parent 6f01637 commit 7219f66
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 12 deletions.
3 changes: 3 additions & 0 deletions include/mmSolver/nodeTypeIds.h
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,9 @@

#define MM_IMAGE_PLANE_SHAPE_TYPE_ID 0x0012F187
#define MM_IMAGE_PLANE_SHAPE_TYPE_NAME "mmImagePlaneShape"
#define MM_IMAGE_PLANE_SHAPE_NODE_CLASSIFY \
"auxiliary/camera:geometry/camera:imageplane:drawdb/geometry/mmSolver/" \
"imagePlane"
#define MM_IMAGE_PLANE_SHAPE_DRAW_CLASSIFY "drawdb/geometry/mmSolver/imagePlane"
#define MM_IMAGE_PLANE_SHAPE_DRAW_REGISTRANT_ID "mmImagePlaneShape"
#define MM_IMAGE_PLANE_SHAPE_SELECTION_TYPE_NAME "mmImagePlaneShapeSelection"
Expand Down
2 changes: 1 addition & 1 deletion src/mmSolver/pluginMain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ MStatus initializePlugin(MObject obj) {
const MString markerClassification = MM_MARKER_DRAW_CLASSIFY;
const MString bundleClassification = MM_BUNDLE_DRAW_CLASSIFY;
const MString imagePlaneShapeClassification =
MM_IMAGE_PLANE_SHAPE_DRAW_CLASSIFY;
MM_IMAGE_PLANE_SHAPE_NODE_CLASSIFY;
const MString skyDomeClassification = MM_SKY_DOME_DRAW_CLASSIFY;
const MString lineClassification = MM_LINE_DRAW_CLASSIFY;
REGISTER_LOCATOR_NODE(plugin, mmsolver::MarkerShapeNode::nodeName(),
Expand Down
29 changes: 26 additions & 3 deletions src/mmSolver/render/RenderOverride.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -312,13 +312,35 @@ MStatus RenderOverride::updateRenderOperations() {
m_op_names[kSceneManipulatorPass] = "mmRenderer_SceneRender_Manipulator";
m_op_names[kPresentOp] = "mmRenderer_PresentTarget";

// Draw these objects for transparency.
auto wire_draw_object_types =
~(MHWRender::MFrameContext::kExcludeMeshes |
MHWRender::MFrameContext::kExcludeNurbsCurves |
MHWRender::MFrameContext::kExcludeNurbsSurfaces |
MHWRender::MFrameContext::kExcludeSubdivSurfaces);

// Draw all non-geometry normally.
auto non_wire_draw_object_types =
((~wire_draw_object_types) |
MHWRender::MFrameContext::kExcludeImagePlane |
MHWRender::MFrameContext::kExcludePluginShapes);

// What objects types to draw for depth buffer?
auto depth_draw_object_types =
wire_draw_object_types | MHWRender::MFrameContext::kExcludeImagePlane;

// Draw image planes in the background always.
auto bg_draw_object_types =
~(MHWRender::MFrameContext::kExcludeImagePlane |
MHWRender::MFrameContext::kExcludePluginShapes);

SceneRender *sceneOp = nullptr;

// Depth pass.
sceneOp = new SceneRender(m_op_names[kSceneDepthPass]);
sceneOp->setViewRectangle(rect);
sceneOp->setSceneFilter(MHWRender::MSceneRender::kRenderShadedItems);
sceneOp->setExcludeTypes(MHWRender::MFrameContext::kExcludeImagePlane);
sceneOp->setExcludeTypes(depth_draw_object_types);
sceneOp->setDisplayModeOverride(display_mode_shaded);
// do not override objects to be drawn.
sceneOp->setDoSelectable(false);
Expand All @@ -330,6 +352,7 @@ MStatus RenderOverride::updateRenderOperations() {
sceneOp = new SceneRender(m_op_names[kSceneBackgroundPass]);
sceneOp->setViewRectangle(rect);
sceneOp->setSceneFilter(MHWRender::MSceneRender::kRenderShadedItems);
// sceneOp->setExcludeTypes(bg_draw_object_types);
// override drawn objects to only image planes under cameras.
sceneOp->setDoSelectable(true);
sceneOp->setDoBackground(true);
Expand All @@ -356,7 +379,7 @@ MStatus RenderOverride::updateRenderOperations() {
sceneOp = new SceneRender(m_op_names[kSceneWireframePass]);
sceneOp->setViewRectangle(rect);
sceneOp->setSceneFilter(MHWRender::MSceneRender::kRenderUIItems);
sceneOp->setExcludeTypes(MHWRender::MFrameContext::kExcludeManipulators);
sceneOp->setExcludeTypes(wire_draw_object_types);
sceneOp->setDisplayModeOverride(display_mode_wireframe);
// do not override objects to be drawn.
sceneOp->setDoSelectable(false);
Expand Down Expand Up @@ -389,7 +412,7 @@ MStatus RenderOverride::updateRenderOperations() {
sceneOp = new SceneRender(m_op_names[kSceneManipulatorPass]);
sceneOp->setViewRectangle(rect);
sceneOp->setSceneFilter(MHWRender::MSceneRender::kRenderUIItems);
sceneOp->setExcludeTypes(~MHWRender::MFrameContext::kExcludeManipulators);
sceneOp->setExcludeTypes(non_wire_draw_object_types);
sceneOp->setDoSelectable(false);
sceneOp->setDoBackground(false);
sceneOp->setClearMask(clear_mask_none);
Expand Down
22 changes: 15 additions & 7 deletions src/mmSolver/render/SceneRender.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,11 @@ SceneRender::postEffectsOverride() {
const MSelectionList *SceneRender::objectSetOverride() {
// If m_do_selectable is false and m_do_background is false: do
// not override.
mSelectionList.clear();
if (m_do_selectable && m_do_background) {
m_selection_list.clear();
if (!m_do_selectable && !m_do_background) {
// This is the most common branch, so it is first.
return nullptr;
} else if (m_do_selectable && m_do_background) {
// If m_do_selectable is true and m_do_background is true:
// override drawn objects to only image planes under cameras.
MItDag it;
Expand All @@ -137,24 +140,29 @@ const MSelectionList *SceneRender::objectSetOverride() {
if (path.pathCount() < 2) {
continue;
}
mSelectionList.add(path);
m_selection_list.add(path);
} else if (item.apiType() == MFn::kPluginLocatorNode) {
MDagPath path;
it.getPath(path);
m_selection_list.add(path);
}
}
return &mSelectionList;
return &m_selection_list;
} else if (m_do_selectable && !m_do_background) {
// If m_do_selectable is true and m_do_background is false:
// override drawn objects to all image planes not under cameras.
MItDag it;
it.traverseUnderWorld(false);
for (it.reset(); !it.isDone(); it.next()) {
auto item = it.currentItem();
if (item.hasFn(MFn::kImagePlane)) {
if (item.hasFn(MFn::kImagePlane) ||
(item.apiType() == MFn::kPluginLocatorNode)) {
MDagPath path;
it.getPath(path);
mSelectionList.add(path);
m_selection_list.add(path);
}
}
return &mSelectionList;
return &m_selection_list;
}
return nullptr;
}
Expand Down
3 changes: 2 additions & 1 deletion src/mmSolver/render/SceneRender.h
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,8 @@ class SceneRender : public MHWRender::MSceneRender {
void setDoBackground(const bool value) { m_do_background = value; }

protected:
MSelectionList mSelectionList;
// Objects Set override. Override which objects are drawn.
MSelectionList m_selection_list;

// 3D viewport panel name, if available
MString m_panel_name;
Expand Down

0 comments on commit 7219f66

Please sign in to comment.