ported pitch roof code from old osgearth