Closed progfz closed 1 year ago
Yea that makes sense. I currently don't think there is a strong reason to run before the lod and socket imports, and I am not opposed to moving it to run after as long as it always is added to the in execution queue after every asset import. If you want to open a PR, I think this would be an easy thing to change
Will submit a PR later then. Wanted to get confirmation first that it's not some deliberate architectural decision.
Finally, got some time to work on this. Will open a PR at this weekend or next weekend, depending on when I'll get enough time to run proper tests in a clean environment not polluted by my changes to pipeline.
For now I'd like to ask if it's ok to rename "import_asset" function in "ingest.py" to "import_asset_file" and create a new "import_asset" function and move there some code from "assets" and original "import_asset" functions? This way all logic responsible for import process of a single asset with be consolidated in one function, making future changes to it more straightforward.
Yea that should be fine, just be mindful that any function that has the @track_progress decorator gets queued separately. This isn't a huge deal with the import sockets method, since it is almost instant, but I would like to keep each lod import as a separate point in the execution queue, since those could potentially be big files, and we still want the ability to interrupt the execution queue with ESC in between these tasks. Renaming should be fine, I can post comments on the PR as well
Currently there is post_import callback in extensions API but it's called before sockets and lods are imported and there is no callback that is called after that but before next asset in current batch. Meaning that currently there is no proper place for code that should be executed after all default post-import operations on specific asset are completed.
Personally, I moved code responsible for importing lods and sockets into import_asset function in ingest.py so it's executed before post-import callback instead of being executed after a call to import_asset. This move seems the most logical to me as fcurves import is already placed there and not outside import_asset. It works fine for my pipeline but I'm not sure if there were any reasons for original implementation.
Alternatively, post_import callback could be split into two, one being called directly after native import operation and another being called after all default post-import actions are performed. I did not choose this path myself as it's more work than it's worth for my needs.
For context, in my project I was implementing a pipeline that automatically performs certain operations on all imported models with specific metadata and thus I had to resolve compatibility issues caused by Send to Unreal pipeline. I ended up creating a delegate that is called from blender through python API after it's safe to perform operations with newly imported asset on Unreal end. In theory, I could use post_operation callback instead and just keep references to affected assets on Unreal end and then process them all after "safe to proceed" delegate is called but it's more error-prone implementation compared to per-asset call to a delegate.