Skip to content

Commit

Permalink
USDShader : Fixed default preset values on IntPlugs that are intended…
Browse files Browse the repository at this point in the history
… to be enum indexes instead of string values.
  • Loading branch information
boberfly committed Oct 9, 2024
1 parent 28d115d commit e88fd8a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
1 change: 1 addition & 0 deletions Changes.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ Fixes
-----

- ShaderView : Fixed crash caused by a SceneCreator returning `None`.
- USDShader : Fixed default preset values on IntPlugs that are intended to be enum indexes instead of string values.

1.4.14.0 (relative to 1.4.13.0)
========
Expand Down
9 changes: 7 additions & 2 deletions python/GafferUSDUI/USDShaderUI.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,12 +190,17 @@ def __presetValues( plug ) :
property = __primProperty( plug )
if property :
allowedTokens = property.GetMetadata( "allowedTokens" )
return IECore.StringVectorData( allowedTokens ) if allowedTokens else None
if allowedTokens and isinstance( plug, Gaffer.IntPlug ) :
return IECore.IntVectorData( [ i for i in range( len( allowedTokens ) ) ] )
else :
return IECore.StringVectorData( allowedTokens ) if allowedTokens else None

property = __sdrProperty( plug )
options = property.GetOptions()
if options :
if len( options ) > 1 and all( o[1] == "" for o in options ) :
if isinstance( plug, Gaffer.IntPlug ) :
return IECore.IntVectorData( [ i for i in range( len( options ) ) ] )
elif len( options ) > 1 and all( o[1] == "" for o in options ) :
# USD's `_CreateSdrShaderProperty` method in `shaderDefUtils.cpp`
# always uses an empty string for the option value when converting
# from `allowedTokens`. Ignore that, and use the names as the values
Expand Down

0 comments on commit e88fd8a

Please sign in to comment.