My main triple A task today has been finding and solving the performance spike we see when in high combat. After some VTuning, it was apparent that 25% of the main thread cycles was dedicated to doing a triangle intersection test, which in turn comes from the functionality which casts a ray between the enemy and the player to determine if the player can be seen or hit with a bullet. In play, my framer rate can go from 90 fps down to 25 fps when five characters are running around shooting me, so not ideal.
The good news is that I added some code (and ate 8MB of valuable system memory) to add what I called a 'skipgrid' which remembers the position of the enemy and the destination of the ray and stores what the hit value was. The next time the intersection command is called, I can do a quick look-up to see if this ray was done before, and instantly return the result. I also added code to limit the engine to a maximum of five intersect tests per cycle so this part of the engine does not swallow up other resources. I am sure there will be some after effects of this optimization, but the new frame rates are much improved. In a high combat scenario with five aggressors, there is little to no frame rate drop during the fighting. You do see a drop when you shoot the shotgun, but that's because it has five ray casts being sent out all at once. Most weapons would not exhibit this 'blip' but I will see what testing feedback results first to see if anyone notices this amongst all the other things going on.
I am writing my blog early today as I have a meeting with the accountants tomorrow, part of my 'Managing Director' hat. I need time to assemble some paperwork and get my head out of code and into facts and figures. They may appear to be in the same mental ballpark, but games coding is much more fun!
Not right now though, it's still full steam ahead and after a nice cup of tea I will be looking closer at the occluder system. If you recall, this is the CPU based system of detecting which objects are being completely hidden by closer objects and removing them from the render scene. You may also recall that switching it on actually caused the frame rate to drop, not increase, so I will be making an assault on that code and finding out the whys and wherefores.
In other news I have my artist back from the land of the ConKit, which means I can start some work on the pistol grip animations, LOD levels for even faster scene renders and other nice graphic tweaks :)