Friday, 5 September 2008

Improving Performance/Memory/Rendering

I've added a new kind of scene graph appending mechanism parallel to the normal screen update/render cycle! This needed hell of a lot changes, bug hunting, refactoring. Now it is done in little time slices between the draw of the frames to add a smooth walking experience. While you move in the world the new parts are added/updated/removed. This clears out the small pauses between each step that was present in the game before.

The whole thing is done in class J3DStandingEngine which is mostly reorganized to support iterative calls to different parts like organizing the addition/removal to batches, the actual update part where batch buffers are rebuilt, cleared, and finally locked. The J3DCore class (extension of jME's BaseSimpleGame) in its simpleUpdate function (which is run upon each update before drawing a frame) checks what iterative function must be still called in J3DStandingEngine. Thus gradually the whole appending/updating of the scene graph is being done.

Also a series of changes were made to the GeometryBatchMesh to optimize it further for my needs. Memory consumption is lessen by some of these changes. I've removed its unneeded tmpVertexBuffer, now it is commiting the batch instances vertex buffers directly (saving a lot of temp buffer allocation). Also removed its special AABB bounding box updater, and use the standard bounding volume update mechanism of jME. Yet I'm still hunting for optimizations and bugfixes. :)

All the progress and optimization made possible smooth rendering of much bigger view distances than before, although it can consume much more memory when extreme distances are set.

No comments: