Search Results

Tuesday, March 1, 2011

Massive Logic Speed Increase in BGE

Hey. So while I was messing around with a game project that I'd been working on that required many objects running logic (and so slowing down the game), I found out a faster method of running logic.

I found that 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 increased logic 400% for me (from 36% to 8% in one scene). That is unprecedented.

In the screen shot shown here, rather than run logic on each individual voxel (cube), the game keeps track of them and checks the distance from the camera to each of them. Logic is at 16%, and I'm feeling good about it. You can download the test of Loop Logic Vs. Each Logic here. Click here to visit the BlenderArtists page for more information on this.

EDIT: So as it was pointed out to me, it would appear that my test blend file was skewed, as I had GLSL set as the rendering mode for one scene, and Multitexture for the other. Clumsy me. As Goran pointed out to me on the BlenderArtists forum, it would appear that loop and each logic are about the same, which is very interesting.

No comments:

Post a Comment