minor cleanup
This commit is contained in:
parent
58bbdf84dd
commit
d4fbe3e7e4
1 changed files with 12 additions and 9 deletions
|
|
@ -44,7 +44,7 @@ def split(poly, plane, same_only: bool = False):
|
|||
'''
|
||||
vertices = poly['vertices']
|
||||
neighbors = poly['neighbors']
|
||||
num_start = poly['vertices'].shape[0]
|
||||
num_start = neighbors.shape[0]
|
||||
|
||||
dists = plane[1] + (vertices @ plane[0])
|
||||
left = dists > 0
|
||||
|
|
@ -94,6 +94,13 @@ def split(poly, plane, same_only: bool = False):
|
|||
|
||||
num_new_vertices = rverts.size
|
||||
|
||||
'''
|
||||
figure out new vertex positions
|
||||
'''
|
||||
d_right = dists[rverts][:, None]
|
||||
d_left = dists[lverts][:, None]
|
||||
new_vertices = (d_right * vertices[lverts] - d_left * vertices[rverts]) / (d_right - d_left)
|
||||
|
||||
'''
|
||||
walk to next crossing edge
|
||||
'''
|
||||
|
|
@ -131,10 +138,6 @@ def split(poly, plane, same_only: bool = False):
|
|||
arr = numpy.column_stack((rverts, lverts))
|
||||
target_edge_inds = _get_map_rows(arr, edge_walk_results)
|
||||
|
||||
d_right = dists[rverts][:, None]
|
||||
d_left = dists[lverts][:, None]
|
||||
new_vertices = (d_right * vertices[lverts] - d_left * vertices[rverts]) / (d_right - d_left)
|
||||
|
||||
'''
|
||||
map from old vertex ind to new
|
||||
'''
|
||||
|
|
@ -150,9 +153,9 @@ def split(poly, plane, same_only: bool = False):
|
|||
target_order + num_left, # new vertex indices are same as edge indices + offset
|
||||
target_edge_inds + num_left))
|
||||
|
||||
old_vertices_left = poly['vertices'][left]
|
||||
old_vertices_left = vertices[left]
|
||||
|
||||
old_neighbors_left = poly['neighbors'].copy()
|
||||
old_neighbors_left = neighbors.copy()
|
||||
old_neighbors_left[left] = ind_map_left[old_neighbors_left[left]] # map vertices on left side, wrongly mapping any right-side vertices to 0
|
||||
old_neighbors_left[(lverts, src_pns)] = num_left + numpy.arange(num_new_vertices)
|
||||
old_neighbors_left = old_neighbors_left[left]
|
||||
|
|
@ -173,9 +176,9 @@ def split(poly, plane, same_only: bool = False):
|
|||
target_edge_inds + num_right, # new vertex indices are same as edge indices + offset
|
||||
target_order + num_right))
|
||||
|
||||
old_vertices_right = poly['vertices'][right]
|
||||
old_vertices_right = vertices[right]
|
||||
|
||||
old_neighbors_right = poly['neighbors'].copy()
|
||||
old_neighbors_right = neighbors.copy()
|
||||
old_neighbors_right[right] = ind_map_right[old_neighbors_right[right]]
|
||||
old_neighbors_right[(rverts, rl_edge_inds)] = num_right + numpy.arange(num_new_vertices)
|
||||
old_neighbors_right = old_neighbors_right[right]
|
||||
|
|
|
|||
Loading…
Reference in a new issue