Sunday, April 1, 2012

Better performance and tree felling

I added a stats box to my screen so I can start tracking framerate.  Some of the brute force stuff I was doing in the render loop was causing all sorts of slowdowns.  I improved SOME of them and tweaked some other settings as well. One of the things I had to do early one to get my ray intersection logic to work with Three.js was to triangulate my quads.  Yeah...sounded funny to me too.  Essentially, each of my polygons in my meshes start out as quads (squares).  Triangulating them, subdivides them into triangles.  It makes the normal/intersection calculation more better (or there is simply a bug in the Three.js libraries).  Doing this, however creates more vertices which effects framerate.

I also made code change so that the trees will fall in the direction that the dozer is facing when it hits them. I also slow the dozer down when it 'hits' a tree.  I am having ZERO luck getting the trees to get removed form the scene after they disappear below the ground...I simply have no way to pass the parent object to the Tween.js callbacks upon completion.  Grumble

1 comment: