Announcement

Collapse
No announcement yet.

Changing scenes takes a long time

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Changing scenes takes a long time

    Hi all,

    In a WPF application I have a window with 3D content. When the user e.g. wants to create a new project (and in turn close the old one) I'm creating a new scene and I want the old scene to get disposed. Since disposing takes quite a long time (a lot of entities need to be cleaned up) I'm facing the following problem:

    What I do:
    Code:
    MyScene scene = new MyScene();
    ScreenContext screenContext = new ScreenContext(scene);
    WaveServices.ScreenContextManager.To(screenContext );
    The problem now is that the WPF part of the UI is responding again very quickly (after some internal cleanup) but the 3D window is still showing the content of the old scene until the old scene is disposed and this takes quite a long time. The dispose is obviously done in the background, which is very good, but since the 3D UI still shows the old scene and is stuck the application is in an inconsistent state and unusable until the dispose is done.

    If I do the following (not disposing the old scene):
    Code:
    MyScene scene = new MyScene();
    ScreenContext screenContext = new ScreenContext(scene);
    WaveServices.ScreenContextManager.To(screenContext, false);
    the switch to the new scene is done immediately but then I have of course a resource leak because I want the old scene to be cleaned up completely.

    So how can I switch fast and do the cleanup of the Scene in the background?

    Another option would be to not delete the scene and create a new one but to delete all of it's content. But since there are a lot of entities which need to be cleaned up it takes several minutes to do so and the application is not responding meanwhile. Is there a way to release a whole bunch of entities at once or maybe in the background as well? But option 1 (changing scenes) is the preferred one from my perspective.

    Best regards,
    cornholio.
Working...
X