simplify re/le vs rverts/lverts
This commit is contained in:
parent
eea9bc3fd6
commit
de1c0b4814
1 changed files with 10 additions and 13 deletions
|
|
@ -81,17 +81,15 @@ def split(poly, plane, same_only: bool = False):
|
|||
new_vertices = numpy.empty((0, 3), dtype=float)
|
||||
src_pns = target_edge_inds.copy()
|
||||
num_new_vertices = 0
|
||||
re = numpy.empty(0, dtype=int)
|
||||
le = re.copy()
|
||||
rverts = numpy.empty(0, dtype=int)
|
||||
lverts = rverts.copy()
|
||||
else:
|
||||
'''
|
||||
Some edges cross the plane
|
||||
'''
|
||||
right_inds3 = numpy.repeat(right_inds, 3)
|
||||
|
||||
# array of [[clipped vertex (cv0), connected vertex pv00], [cv0, pv01], [cv0, pv02], [cv1, pv10], ...]
|
||||
# which is effectively a list of all edges which touch the right half-plane
|
||||
# remove edges which don't also touch the left half-plane
|
||||
# remove edges which don't also touch the left half-plane
|
||||
rverts = right_inds3[far_vertex_left]
|
||||
lverts = next_vertex[far_vertex_left]
|
||||
if not same_only:
|
||||
|
|
@ -136,10 +134,9 @@ def split(poly, plane, same_only: bool = False):
|
|||
arr = numpy.column_stack((rverts, lverts))
|
||||
target_edge_inds = _get_map_rows(arr, edge_walk_results)
|
||||
|
||||
re, le = rverts, lverts
|
||||
d_right = dists[re][:, None]
|
||||
d_left = dists[le][:, None]
|
||||
new_vertices = (d_right * vertices[le] - d_left * vertices[re]) / (d_right - d_left)
|
||||
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
|
||||
|
|
@ -152,7 +149,7 @@ def split(poly, plane, same_only: bool = False):
|
|||
# use argsort to generate link from target edge to current edge
|
||||
target_order = numpy.argsort(target_edge_inds)
|
||||
new_neighbors_left = numpy.column_stack((
|
||||
ind_map_left[le], # update left vertices based on new indexing
|
||||
ind_map_left[lverts], # update left vertices based on new indexing
|
||||
target_order + num_left, # new vertex indices are same as edge indices + offset
|
||||
target_edge_inds + num_left))
|
||||
|
||||
|
|
@ -160,7 +157,7 @@ def split(poly, plane, same_only: bool = False):
|
|||
|
||||
old_neighbors_left = poly['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[(le, src_pns)] = num_left + numpy.arange(num_new_vertices)
|
||||
old_neighbors_left[(lverts, src_pns)] = num_left + numpy.arange(num_new_vertices)
|
||||
old_neighbors_left = old_neighbors_left[left]
|
||||
|
||||
left_poly = {
|
||||
|
|
@ -175,7 +172,7 @@ def split(poly, plane, same_only: bool = False):
|
|||
ind_map_right[right] = numpy.arange(num_right)
|
||||
|
||||
new_neighbors_right = numpy.column_stack((
|
||||
ind_map_right[re], # update right vertices based on new indexing
|
||||
ind_map_right[rverts], # update right vertices based on new indexing
|
||||
target_edge_inds + num_right, # new vertex indices are same as edge indices + offset
|
||||
target_order + num_right))
|
||||
|
||||
|
|
@ -183,7 +180,7 @@ def split(poly, plane, same_only: bool = False):
|
|||
|
||||
old_neighbors_right = poly['neighbors'].copy()
|
||||
old_neighbors_right[right] = ind_map_right[old_neighbors_right[right]]
|
||||
old_neighbors_right[(re, pinds)] = num_right + numpy.arange(num_new_vertices)
|
||||
old_neighbors_right[(rverts, pinds)] = num_right + numpy.arange(num_new_vertices)
|
||||
old_neighbors_right = old_neighbors_right[right]
|
||||
|
||||
right_poly = {
|
||||
|
|
|
|||
Loading…
Reference in a new issue