Skip to content

Commit

Permalink
GafferScene : Enable "USDPointInstancerAdaptor"
Browse files Browse the repository at this point in the history
  • Loading branch information
danieldresser-ie committed Feb 18, 2025
1 parent 38925a8 commit 18b28a8
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 7 deletions.
5 changes: 5 additions & 0 deletions Changes.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 <kbd>Shift</kbd> to append to an existing edit, or <kbd>Control</kbd> 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
-----
Expand Down
20 changes: 13 additions & 7 deletions startup/GafferScene/usdPointInstancerAdaptor.py
Original file line number Diff line number Diff line change
Expand Up @@ -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", "*" )

0 comments on commit 18b28a8

Please sign in to comment.