|
45 | 45 |
|
46 | 46 | # Selection highlighting mode support. |
47 | 47 | # |
48 | | -# The mode is a defaultRenderGlobals enum attribute, and its entries depend on |
49 | | -# the USD version: on USD > 24.11 it is |
50 | | -# {"Outline Selection", "Legacy Selection"}, while on USD <= 24.11 only |
51 | | -# {"Legacy Selection"} is offered, because 24.11's HgiGL cannot support the |
52 | | -# outline compute shader (see renderGlobals.cpp). The enum indices therefore |
53 | | -# differ between USD versions, so the index is resolved by name rather than |
| 48 | +# The mode is a defaultRenderGlobals enum attribute, and its entries depend on the |
| 49 | +# configuration: usually it is {"Outline Selection", "Legacy Selection"}, but only |
| 50 | +# {"Legacy Selection"} is offered on USD <= 24.11, because 24.11's HgiGL cannot |
| 51 | +# support the outline compute shader, and on macOS, where outline selection |
| 52 | +# highlighting is unsupported (see renderGlobals.cpp). The enum indices therefore |
| 53 | +# differ between configurations, so the index is resolved by name rather than |
54 | 54 | # hardcoded. |
55 | 55 | SELECTION_HIGHLIGHT_MODE_NAME = "mayaHydraSelectionHighlightMode" |
56 | 56 | SELECTION_HIGHLIGHT_MODE_NODE = "defaultRenderGlobals" |
@@ -99,16 +99,31 @@ class MayaHydraBaseTestCase(unittest.TestCase, ImageDiffingTestCase): |
99 | 99 | # mayaUsdPlugin looged as HYDRA-1896, we should remove this when HYDRA-1896 is fixed |
100 | 100 | _pluginsCantUnload = ['mayaHydraFlowViewportAPILocator', 'mtoa', 'modelingToolkit', 'mayaUsdPlugin'] |
101 | 101 |
|
| 102 | + @classmethod |
| 103 | + def outlineSelectionHighlightSupported(cls): |
| 104 | + '''Whether the outline mode is offered at all in this configuration. |
| 105 | +
|
| 106 | + Mirrors the MAYAHYDRA_NO_OUTLINE_SELECTION_HIGHLIGHT gate in |
| 107 | + lib/mayaHydra/mayaPlugin/renderGlobals.cpp. |
| 108 | + ''' |
| 109 | + if platform.system() == "Darwin": |
| 110 | + return False |
| 111 | + return Usd.GetVersion() > (0, 24, 11) |
| 112 | + |
102 | 113 | @classmethod |
103 | 114 | def selectionHighlightMode(cls): |
104 | 115 | '''Return the selection highlighting mode this run should use. |
105 | 116 |
|
106 | | - Taken from the MAYAHYDRA_SELECTION_HIGHLIGHT_MODE environment variable, |
107 | | - defaulting to outline, which is what the plugin ships as its default. |
| 117 | + Taken from the MAYAHYDRA_SELECTION_HIGHLIGHT_MODE environment variable. |
| 118 | + With no variable set, this is outline, the mode the plugin ships as its |
| 119 | + default, except where outline is not offered at all - see |
| 120 | + outlineSelectionHighlightSupported(). |
108 | 121 | ''' |
109 | 122 | mode = os.environ.get(SELECTION_HIGHLIGHT_MODE_ENV_VAR, '').strip().lower() |
110 | 123 | if not mode: |
111 | | - return SELECTION_HIGHLIGHT_MODE_OUTLINE |
| 124 | + return (SELECTION_HIGHLIGHT_MODE_OUTLINE |
| 125 | + if cls.outlineSelectionHighlightSupported() |
| 126 | + else SELECTION_HIGHLIGHT_MODE_LEGACY) |
112 | 127 | if mode not in SELECTION_HIGHLIGHT_MODE_ENUM_NAMES: |
113 | 128 | raise ValueError( |
114 | 129 | "Unknown {} value {!r}; expected one of {}.".format( |
@@ -416,13 +431,15 @@ def applySelectionHighlightMode(self): |
416 | 431 | listEnum=True)[0].split(':') |
417 | 432 |
|
418 | 433 | if wantedEnumName not in enumNames: |
419 | | - # On USD <= 24.11 only "Legacy Selection" is offered, so an outline |
420 | | - # run cannot be honoured. Skipping avoids silently comparing outline |
| 434 | + # Where outline is not offered - USD <= 24.11, or macOS - only |
| 435 | + # "Legacy Selection" exists, so an explicitly requested outline run |
| 436 | + # cannot be honoured. Skipping avoids silently comparing outline |
421 | 437 | # reference images against a legacy render. |
422 | 438 | self.skipTest( |
423 | 439 | "Selection highlighting mode {!r} ({!r}) is not available on " |
424 | | - "USD {}; available modes: {}.".format( |
425 | | - mode, wantedEnumName, str(self._usdVersion), enumNames)) |
| 440 | + "{} with USD {}; available modes: {}.".format( |
| 441 | + mode, wantedEnumName, platform.system(), |
| 442 | + str(self._usdVersion), enumNames)) |
426 | 443 |
|
427 | 444 | wantedIndex = enumNames.index(wantedEnumName) |
428 | 445 | if cmds.getAttr(SELECTION_HIGHLIGHT_MODE_ATTR) == wantedIndex: |
|
0 commit comments