diff --git a/Changes.md b/Changes.md index d9545fc515..8567e1cf3a 100644 --- a/Changes.md +++ b/Changes.md @@ -5,6 +5,11 @@ Features -------- - AttributeEditor, LightEditor, RenderPassEditor : Added drag and drop editing. Edits can be created or updated by dropping a value into a cell. Cells representing a set expression or string array can be modified by holding Shift to append to an existing edit, or Control may be held to remove from an existing edit. +- USD : Added automatic expansion of USD PointInstancers at render time. + - This can be controlled on a per-instancer basis using a `gafferUSD:pointInstancerAdaptor:enabled` boolean attribute. + - Which point cloud primitive variables are promoted to user attributes can be controlled using a `gafferUSD:pointInstancerAdaptor:attributes` string attribute. + - May be disabled entirely with `GafferScene.SceneAlgo.deregisterRenderAdaptor( "USDPointInstancerAdaptor" )`. +- Viewer : Added "Expand USD Instancers" item to the Expansion menu. Defaults to on for all renderers except OpenGL. Fixes ----- diff --git a/startup/GafferScene/usdPointInstancerAdaptor.py b/startup/GafferScene/usdPointInstancerAdaptor.py index 32faa64115..68289bb6ff 100644 --- a/startup/GafferScene/usdPointInstancerAdaptor.py +++ b/startup/GafferScene/usdPointInstancerAdaptor.py @@ -40,10 +40,16 @@ # into actual Instancers. This supports how USD PointInstancers are currently loaded from # USD files. In the future, they may be first class objects, and this will be unnecessary. -try: - import GafferUSD - # Disabled while we work on a solution for automatically remapping prototype paths - # when pointclouds have been reparented in the scene hierarchy. - # GafferScene.SceneAlgo.registerRenderAdaptor( "USDPointInstancerAdaptor", GafferUSD._PointInstancerAdaptor, "SceneView *Render", "*" ) -except ImportError : - pass +# We don't want to create a dependency on GafferUSD - this should silently do nothing if GafferUSD +# isn't available. We also don't want to import GafferUSD right away - that could lead to circular +# import problems. So instead we register this callback that will try to import GafferUSD +def createPointInstancerAdaptor(): + try: + import GafferUSD + return GafferUSD._PointInstancerAdaptor() + except ImportError : + r = GafferScene.SceneProcessor() + r["out"].setInput( r["in"] ) + return r + +GafferScene.SceneAlgo.registerRenderAdaptor( "USDPointInstancerAdaptor", createPointInstancerAdaptor, "SceneView *Render", "*" )