How to fill ngon with quads?

Using knife project I have created a custom mesh for a modular Unity asset so it works for my use case. I now have a n-gon that creates a really ugly topology in Unity:

I would like create quads from my ngon. It should be simple but I can not find a way to do that. The knife tool does not snap to vertices initially. Once you start the first cut it seems to snap to vertices but then I would have to start cutting again to start at any other existing vertex.

If I right-click a edge I get teh Knife topology tool which lets me snap on a vertex. I ended up with this topology, not too bad for a noob?

• I was going to suggest using Knife with the C constrain option to keep cuts parallel to X and Y. .. but, hey.. now @batFINGER has given you a button to push.... forget it :) Commented Dec 20, 2020 at 12:59
• I ended up using C constraint. Trick was to get knife to snap to the first vertex, you get that with the knif topology tool. Commented Dec 20, 2020 at 13:32

Bisect with boundary edges.

Based on the rectangular nature of the corners of given mesh.

Sample result, far from optimized as some edges above could be dissolved.

A script to create a plane from all the boundary edges. The plane coord is edge center, the plane normal is nominated up direction (Z axis) crossed with edge direction.

Script, run in edit mode. Note in hindsight should limit this to selected ngons, and edges. For test sake make the ngon its own object, place in edit mode.

import bpy
import bmesh
from mathutils import Vector

ob = bpy.context.edit_object
me = ob.data

bm = bmesh.from_edit_mesh(me)

up = Vector((0, 0, 1))
def as_plane(e):
return (
(e.verts[0].co + e.verts[1].co) / 2,
up.cross(e.verts[1].co - e.verts[0].co).normalized(),
)

planes = [as_plane(e) for e in bm.edges if e.is_boundary]

while planes:
plane_co,  plane_no = planes.pop()
if plane_no.length < 1e-4:
continue
bmesh.ops.bisect_plane(
bm,
geom=bm.edges[:] + bm.faces[:],
plane_co=plane_co,
plane_no=plane_no,
)

bmesh.ops.remove_doubles(
bm,
dist=1e-4,
)

bmesh.update_edit_mesh(me)

• That is so elegant (Sweetie) ! Commented Dec 20, 2020 at 12:59