I'm putting together some tools to allow artists to easily reload resources when they change on disk. Primarily I'm concerned with USD and texture maps, but I've also been testing with Alembics and references to other Clarisse files. I'm getting some pretty varied results as to whether Clarisse will pick up the updates or not.
I'll touch on both the UI reload methods and the code ones. The UI methods I'm testing are the "Reload Resources" option in the File menu. The "Reload" button in the Attribute Editor on the reference node itself, and the "Reload" and "Reload all" buttons in the Resource View. I will say, up front, that the buttons in the Resource View have not worked to reload any form of resource for me, which makes me wonder if I'm misunderstanding their purpose.
USD
None of the UI methods work to reload a USD. The only piece of code I can produce that will reload a USD is the following:
- Code: Select all
for item in ix.selection:
if item.is_context():
engine = item.get_engine()
engine.unload()
engine.load(True)
Furthermore, if there are two references to the same USD in the scene, even the above code won't work. You need to first unload all references to the USD and then load them again.
Texture Maps
The File menu "Reload Resources" button will reload texture maps. I can't find any way to reload an individual map (I may be missing something), as I said the Resource View "Reload" button doesn't do anything here. If I "Clear" the texture map in the Resource View and then tumble the viewport Clarisse will pull the texture back in and it will be the updated texture.
In the same vein, this code will reload a selected texture map:
- Code: Select all
textures = ix.api.OfObjectVector()
ix.application.get_selection().get_objects(textures)
texture_items = ix.api.OfItemVector()
for item in textures:
if item.is_kindof("Texture"):
texture_items.add(item)
ix.application.unload_resources(texture_items)
As with pressing "Clear" in the Resource View you will need to do something to prompt Clarisse to pull the texture back in. Tumbling the viewport does the trick.
Alembic/Clarisse Files
These seem far more predictable. All the different UI buttons work (except the Resource View) and the following code does the job:
- Code: Select all
for item in ix.selection:
if item.is_context():
engine = item.get_engine()
engine.reload()
So, given all this, I was wondering if this is the expected behaviour? Should USDs be reloadable? Am I doing something wrong? Is there better code to reload a single texture map? If there isn't, is there something I can do through code to prompt Clarisse to reprocess the scene so that users don't have to tumble the viewport in order for the updates to appear? Should the "Reload" buttons in the Resource View reload the resource files, or are they for something else?