Why do elements need to be continually added to GeometryModel3D property collections which have already been computed for rendering to occur? Why do elements need to be continually added to GeometryModel3D property collections which have already been computed for rendering to occur? wpf wpf

Why do elements need to be continually added to GeometryModel3D property collections which have already been computed for rendering to occur?


It looks like there may be several problems here.

The first that I found was that you're calling comp_mgr.Update() every time you add a particle. This, in turn, calls Update() on every particle. All of that results in an O(n^2) operation which means that for 200 particles (your min), you're running the component update logic 40,000 times. This is definitely what's causing it to be slow.

To eliminate this, I moved the comp_mgr.Update() call out of the while loop. But then I got no points, just like when you uncomment the is_done = true; line.

Interestingly, when I added a second call to comp_mgr.Update(), I got a single point. And with successive calls I got an additional point with each call. This implies that, even with the slower code, you're still only getting 199 points on the 200-point setting.

There seems to be a deeper issue somewhere, but I'm unable to find it. I'll update if I do. Maybe this will lead you or someone else to the answer.

For now, the MainWindow.Generate() method looks like this:

private void Generate(int _total){    const int min = -75;    const int max = 75;    // generate particles    while (current_particles < _total)    {        int rand_x = rng.Next(min, max);        int rand_y = rng.Next(min, max);        comp_manager.AddParticleToComponent(new Point3D(rand_x, rand_y, .0), 1.0);        ++current_particles;    }    Dispatcher.Invoke(() => { comp_manager.Update(); });}

where replicating the Update() call n times results in n-1 points being rendered.