Add check to avoid degenerate planes in BSP tree build

Please merge to release
(cherry picked from commit de0b181913c771c8a670aa51885e71c9fbdd78a2)