Hey. So, as far as I knew, the BGE was just going to be slow when you were working on scenes featuring a lot of logic (like particles, for example. It was fast enough for one or two particle systems, but running a lot wasn’t too good for the FPS).
But then, I stumbled on an idea that works exceptionally well. Rather than running logic in every object of a type (like a particle, or even an enemy if you have a lot of them), or even reducing the frequency of that script running, it’s better to loop through a list of said objects and run the logic for them. The overhead that the BGE uses associated with each object’s individual script running is apparently high, and taking out this factor decreased logic over 400% for me (from 36% to 8% in one scene). That is unprecedented. In quicker terms, check out the screenshots.
In the two screenshots below this, the one running at 18 FPS shows a normal scene in which I spawned 1000 objects each running a SIMPLE script that just imports the bge.logic module. The second running at 60 FPS shows a scene in which I spawned 1000 objects that don’t run a script, and the spawner object loops through all objects in the scene TWICE to perform a simple calculation on them. Logic is at around 20% this time. Yeah… You may want to check this one out.
Now, I’m not one who usually puts up screenshots of projects here, especially games that aren’t finished, but I just felt that I had to show what I’ve got so far with this one…
Yes, they’re voxels. I loop through a list of voxels (currently all of them in the scene, not even just the ones near the camera) to figure out if they should be visible or not. It works. Logic’s fairly low (16%, I think), and I’m going to keep working on it. Loop, people! LOOP!
EDIT: So it would seem that maybe my previous test was wrongly set-up, in particular because one scene used GLSL for a rendering-mode, and the other used Multitexture, which skewed the results. As Goran pointed out, he got the same FPS and logic values on both scenes, when they were setup correctly. The correct blend can be downloaded from post #13.