added TFGrid class and moved a lot of terrain code there in preparation for water.