LumaPictures / maya-to-hydra-alproxy

This repo is no longer updated. Please see https://github.com/Autodesk/maya-usd

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Ufe selection stops working if USD object set to inactive

pmolodo opened this issue · comments

To reproduce, run this code, then note that you can't click on any ufe objects:

# Ufe selection stops working after item set to inactive

import maya.cmds as cmds
import maya.mel as mel
import pymel.core as pm

def safeLoadPlugin(plugin):
    if not cmds.pluginInfo(plugin, q=1, loaded=1):
        cmds.loadPlugin(plugin)
safeLoadPlugin('AL_USDMayaPlugin')
safeLoadPlugin('maya-ufe-cmd-plugin')
safeLoadPlugin('maya-ufe-usd-plugin')

cmds.file(f=1, new=1)
cmds.AL_usdmaya_ProxyShapeImport(file='/path/to/Kitchen_set/Kitchen_set.usd')
persp = pm.PyNode('persp')
persp.translate.set((55, -780, 525))
persp.rotate.set((52, 0, 0))
persp.getShape().centerOfInterest.set(771)
cmds.refresh()

import maya.cmds as cmds; cmds.loadPlugin("mtoh")
activePanel = cmds.playblast(ae=1)
mel.eval('setRendererAndOverrideInModelPanel $gViewport2 mtohRenderOverride_HdStreamRendererPlugin {};'.format(activePanel))

################

import AL.usdmaya
proxy = AL.usdmaya.ProxyShape.getByName('AL_usdmaya_ProxyShape')
stage = proxy.getUsdStage()
tableTopPath = "/Kitchen_set/Props_grp/DiningTable_grp/KitchenTable_1/Geom/Top"
tableTopPrim = stage.GetPrimAtPath(tableTopPath)
assert tableTopPrim.IsValid()

tableTopPrim.SetActive(False)

I suspect any edit to the usd scene would cause this, not just making something inactive, but haven't confirmed that...

This is caused because mtoh is currently relying on AL's selection callbacks to figure out what is actually selected (it just - potentially - handles drawing of the selected object).

If anything is set inactive, this causes AL to essentially throw out it's renderIndex; however, since AL never receives a draw call, it never actually makes a new renderIndex, and so it's selection calls (which use openGL under the hood) always return nothing.

To fix, we need to implement our OWN selection, and disable AL's selection callback. We want to do this anyway, since having an entire duplicated renderIndex, just for selection, is obviously wasteful.

Have solved this internally, by making it possible to "tell" the AL proxy shape to use "our" renderIndex / engine / taskController for selection. However, that required some changes to both AL and mtoh for this to work. Will update this ticket with branches once I push everything to github.