syoyo / tinyusdz

Tiny, dependency-free USDZ/USDA/USDC library written in C++14
Other
453 stars 32 forks source link

Add a cancel / continue callback to control LoadUSDFromFile #167

Open MootoolsSoftware opened 2 weeks ago

MootoolsSoftware commented 2 weeks ago

We are currently implementing an USD parser based on tinyusdz for an application that is displaying thumbnails from these files. As the user might browse to another folder without waiting end of parsing, it must be possible to stop USD reading when this occurs.

When processing large file it would be convenient to add the ability to cancel the usd file parsing. I don't find such possibility and that would be nice to be able to set a callback that returns true or false when the process should stop whould be nice.

syoyo commented 2 weeks ago

TinyUSDZ does not have a feature to cancel the parsing(and progress callback) at the moment.

For a while you can wrap USD Load API with C++ thread/future and set timeout or force kill the thread, but adding a progress callback would be better as you suggests.

Fortunately TinyUSDZ uses hand-written USDA parser and USDC parser, so adding a callback at arbitrary granularity(e.g. per-Prim, per-Property/Attribute) in the parser would be possible, but it would require some amount of work to implement it and also need some time to think about a good logic.

Priority is low unless you contribute or sponsor implementing this feature 🥺 (If you can sponsor it, you may also be interested in sponsoring optimized Ascii parser https://github.com/syoyo/tinyusdz/issues/164 and multi-threaded USD parsing https://github.com/syoyo/tinyusdz/issues/56 )