mirror of https://github.com/AxioDL/metaforce.git
MAPA fixes
This commit is contained in:
parent
e1d952dd88
commit
b25db30c2a
|
@ -4,6 +4,22 @@ from mathutils import Vector
|
|||
VertPool = hmdl.HMDLMesh.VertPool
|
||||
strip_next_loop = hmdl.HMDLMesh.strip_next_loop
|
||||
|
||||
def recursive_faces_islands(list_out, rem_list, face):
|
||||
if face not in rem_list:
|
||||
return []
|
||||
|
||||
list_out.append(face)
|
||||
rem_list.remove(face)
|
||||
next_faces = []
|
||||
for e in face.edges:
|
||||
if not e.is_contiguous or e.seam:
|
||||
continue
|
||||
for f in e.link_faces:
|
||||
if f == face:
|
||||
continue
|
||||
next_faces.append(f)
|
||||
return next_faces
|
||||
|
||||
def cook(writebuf, mesh_obj):
|
||||
if mesh_obj.type != 'MESH':
|
||||
raise RuntimeError("%s is not a mesh" % mesh_obj.name)
|
||||
|
@ -43,12 +59,31 @@ def cook(writebuf, mesh_obj):
|
|||
vert_pool.write_out_map(writebuf)
|
||||
|
||||
# Create map surfaces and borders
|
||||
island_faces = list(bm_master.faces)
|
||||
#prev_loop_emit = None
|
||||
loop_ranges = []
|
||||
faces_rem = list(bm_master.faces)
|
||||
loop_iter = 0
|
||||
while len(island_faces):
|
||||
loop_ranges = []
|
||||
while len(faces_rem):
|
||||
island_faces = []
|
||||
faces = [faces_rem[0]]
|
||||
while len(faces):
|
||||
next_faces = []
|
||||
ret_faces = None
|
||||
for f in faces:
|
||||
ret_faces = recursive_faces_islands(island_faces, faces_rem, f)
|
||||
if ret_faces == False:
|
||||
break
|
||||
next_faces.extend(ret_faces)
|
||||
if ret_faces == False:
|
||||
break
|
||||
faces = next_faces
|
||||
|
||||
# island_faces now holds one island (map edge delimited)
|
||||
prev_loop_emit = None
|
||||
loop_set = set()
|
||||
edge_set = set()
|
||||
out_count = 0
|
||||
loop_count = 0
|
||||
while len(island_faces):
|
||||
sel_lists_local = []
|
||||
restore_out_count = out_count
|
||||
for start_face in island_faces:
|
||||
|
@ -88,16 +123,22 @@ def cook(writebuf, mesh_obj):
|
|||
out_count = sl[2]
|
||||
island_faces = max_island_faces
|
||||
|
||||
loop_set = set()
|
||||
edge_set = set()
|
||||
loop_count = len(max_sl)
|
||||
if prev_loop_emit:
|
||||
vert_pool.loop_out_map(writebuf, prev_loop_emit)
|
||||
vert_pool.loop_out_map(writebuf, max_sl[0])
|
||||
loop_count += 2
|
||||
loop_set.add(prev_loop_emit)
|
||||
loop_set.add(max_sl[0])
|
||||
loop_count += len(max_sl)
|
||||
for loop in max_sl:
|
||||
vert_pool.loop_out_map(writebuf, loop)
|
||||
prev_loop_emit = loop
|
||||
loop_set.add(loop)
|
||||
for edge in loop.face.edges:
|
||||
if edge.seam:
|
||||
edge_set.add(edge)
|
||||
|
||||
# Create island surface with edges
|
||||
if len(edge_set):
|
||||
trace_edge = edge_set.pop()
|
||||
else:
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit a99bddc90524b9ca532b0cf8865b493b3002fd67
|
||||
Subproject commit 98bf80a9b9f5afd38bf9491954ea359d7ad4b122
|
Loading…
Reference in New Issue