Close CageFork properly
This commit is contained in:
parent
43971714cb
commit
46abe2ece7
@ -5,7 +5,10 @@
|
||||
behind this.
|
||||
|
||||
## Annoying/boring
|
||||
- Make branching properly close the final boundaries.
|
||||
- Fix non-manifold bug at branch. (The edges must be *shared*. It is
|
||||
not sufficient that the subdivided edges both lie incident on some
|
||||
other edge and cover it completely. You must subdivide that larger
|
||||
edge, and thus the triangle it lies on.)
|
||||
- https://en.wikipedia.org/wiki/Polygon_triangulation - do this to
|
||||
fix my wave example!
|
||||
- http://www.polygontriangulation.com/2018/07/triangulation-algorithm.html
|
||||
|
||||
5
cage.py
5
cage.py
@ -109,7 +109,8 @@ class CageGen(object):
|
||||
# We stop recursing here, so close things off if needed:
|
||||
if close_last:
|
||||
for poly in cage_last.polys():
|
||||
meshes.append(meshutil.close_boundary_simple(poly))
|
||||
meshes.append(meshutil.close_boundary_simple(poly, reverse=True))
|
||||
# TODO: Fix the winding order hack here.
|
||||
break
|
||||
# If it's a fork, then recursively generate all the geometry
|
||||
# from them, depth-first:
|
||||
@ -119,7 +120,7 @@ class CageGen(object):
|
||||
# (e.g. loop with fork)
|
||||
for gen in cage_cur.gens:
|
||||
m = gen.to_mesh(count=count - i, flip_order=flip_order, loop=loop,
|
||||
close_first=False, close_last=False,
|
||||
close_first=False, close_last=close_last,
|
||||
join_fn=join_fn)
|
||||
# TODO: How do I handle closing with CageFork?
|
||||
meshes.append(m)
|
||||
|
||||
10
meshutil.py
10
meshutil.py
@ -241,13 +241,17 @@ def join_boundary_optim(bound1, bound2):
|
||||
i = numpy.argmin(errs)
|
||||
return join_boundary_simple(bound1, numpy.roll(bound2, i, axis=0))
|
||||
|
||||
def close_boundary_simple(bound):
|
||||
def close_boundary_simple(bound, reverse=False):
|
||||
# This will fail for any non-convex boundary!
|
||||
centroid = numpy.mean(bound, axis=0)
|
||||
vs = numpy.concatenate([bound, centroid[numpy.newaxis,:]])
|
||||
n = bound.shape[0]
|
||||
# note that n is new the index of the centroid
|
||||
fs = numpy.zeros((n+1, 3), dtype=int)
|
||||
for i in range(n):
|
||||
fs[i] = [i, n, (i+1) % n]
|
||||
if reverse:
|
||||
for i in range(n):
|
||||
fs[i] = [(i+1) % n, n, i]
|
||||
else:
|
||||
for i in range(n):
|
||||
fs[i] = [i, n, (i+1) % n]
|
||||
return FaceVertexMesh(vs, fs)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user