Implement terrain collision detection