briochie / wow.unity

A collection of assets to make working with wow.export easier in Unity.
MIT License
18 stars 8 forks source link

Separate import into steps and other changes #27

Open davidrios opened 2 weeks ago

davidrios commented 2 weeks ago

Hello, sorry for the mega PR, it ended up just happening 😅

The basic idea of this PR is to separate the import into distinct steps, because there're a few issues with processing order that can't be solved with the standard import flow. There are flexibility gains as well, which will be described shortly.

I'll also put some speed numbers from my machine on an export set that I'm testing which has around 19k files total and 30 map tiles. Unity doesn't use more than 1 thread, so these should be roughly representative in general. These are the implemented steps:

  1. The standard processing that Unity does automatically when one adds files to the Assets folder. This now only does some minimal required processing, so its speed is pretty much entirely dependent on Unity, it's the same even without the plugin installed. It takes around 4 minutes here.
  2. This is the processing of WMOs and M2s and it's available via a button in a newly implemented wow.unity window. One clicks it and it goes through all available wow assets and do the post-processing. It first processes the raw models, creating materials, etc, and after that populates the WMOs with doodads. Its implementation has some quirks for performance reasons, but it ended up being pretty fast, it takes around 1:30 minutes here to process ~700 objs and ~900 materials. This button can be clicked as many times as one likes, it won't reprocess stuff that is already processed, so subsequent clicks run very fast. It has the added flexibility that it won't mess up stuff that was already changed, for example if one has customized some models and later decides to add additional exported models/tiles, it'll only process the newly added things. It also uses a cancellable progress bar, so it's safe to stop and start it again at any time. I've implemented a popup that reminds the user to execute this step after the automatic Unity import just in case.
  3. This step creates and sets up the materials for the terrain. To do it one needs to select the desired tiles from the Project window, they'll show up in the wow.unity window, then one clicks the Setup Terrain button. It provides the flexibility to process as many or few tiles as desired. It's also cancellable and idempotent like asset processing. The implementation is as well optimized as I could get it, but I think it's not too bad at around 7 minutes to process 30 tiles and create materials for over 7.5k chunks. The implementation lives in the new ADTUtility module
  4. The final step is placing doodads in the map tile prefabs. It works the same, select the tiles in the Project window and click Place Doodads. It's pretty fast, takes less than a minute for 30 tiles, unless the other assets haven't been processed yet, which it'll do automatically given that they need to exist to be able to be placed. This could easily be changed to place the doodads in a prefab instanced in the scene instead as well.

Other notables changes:

briochie commented 2 weeks ago

Hey @davidrios no problem - thank you for making this! I don't have time to dive into these changes right away, but I do want to take a look and play around with it. I appreciate you circling back on this.

Once I get a chance to mess with it I will give you any feedback I have. :)