Add check to avoid degenerate planes in BSP tree build

Please merge to release