ApanLoon / EmpyrionStuff

A collection of tools that can be used to work with some of the file formats used in Empyrion Galactic Survival.
MIT License
10 stars 5 forks source link

EPBLab crashes when creating the 3D view for EPBs with a large number of blocks. #54

Closed ApanLoon closed 5 years ago

ApanLoon commented 5 years ago

There is a bottle neck in the BuildModel method - System.Windows.Media.Media3D.GeometryModel3D.set_Material appears to take an disproportionate amount of time. Excessive GC calls happen when this method is executing as well.

ApanLoon commented 5 years ago

Commit 87a6ea4 seems to not crash the UI thread. It loops over all blocks in a BackgroundWorker thread and that schedules creation of 3D models for blocks in batches of 100 at a time by the UI thread. It seems as if the UI thread still won't handle any other events before all 3D models are created.

I am a bit at a loss here, I don't know the best way to do multi-threading, especially not in WPF/MVVM. Do you, @PeteMichaud, know about this sort of thing?

ApanLoon commented 5 years ago

Fantastic. Just as I posted the question, I found an answer that might be correct. Funny how that happens so often.

ApanLoon commented 5 years ago

Fixed by pull request #55