Trying to track down this cage-subdivision bug still
This commit is contained in:
parent
4a4f5a0e50
commit
d26cae0486
352
Scratch.ipynb
352
Scratch.ipynb
File diff suppressed because one or more lines are too long
14
cage.py
14
cage.py
@ -61,7 +61,12 @@ class Cage(object):
|
||||
# I'm sure it has a pattern I can factor out, but I've not tried
|
||||
# yet.
|
||||
cages = [Cage(numpy.array(a), self.splits) for a in arrs]
|
||||
return cages
|
||||
trans_verts = numpy.zeros((2*len(self.verts),3), dtype=self.verts.dtype)
|
||||
for i,(v,m) in enumerate(zip(self.verts, mids)):
|
||||
trans_verts[2*i] = v
|
||||
trans_verts[2*i+1] = m
|
||||
trans_edges = [[7, 0, 1], [1, 2, 3], [3, 4, 5], [5, 6, 7]]
|
||||
return cages, trans_verts, trans_edges
|
||||
def is_fork(self):
|
||||
return False
|
||||
def transform(self, xform):
|
||||
@ -174,6 +179,7 @@ class CageFork(object):
|
||||
return True
|
||||
def transition_from(self, cage):
|
||||
"""Generate a transitional mesh to adapt the given starting Cage"""
|
||||
print("DEBUG: Transition from {} to {}".format(cage.verts, self.verts))
|
||||
vs = numpy.concatenate([cage.verts, self.verts])
|
||||
# Indices 0...offset-1 are from cage, rest are from self.verts
|
||||
offset = cage.verts.shape[0]
|
||||
@ -228,7 +234,7 @@ class CageGen(object):
|
||||
# from them, depth-first:
|
||||
if cage_cur.is_fork():
|
||||
# First, transition the cage properly:
|
||||
|
||||
mesh_trans = cage_cur.transition_from(cage_last)
|
||||
# TODO: Clean up these recursive calls; parameters are ugly.
|
||||
# Some of them also make no sense in certain combinations
|
||||
# (e.g. loop with fork)
|
||||
@ -237,10 +243,6 @@ class CageGen(object):
|
||||
close_first=False, close_last=close_last,
|
||||
join_fn=join_fn)
|
||||
meshes.append(m)
|
||||
# TODO: This has bugs that produce non-manifold geometry.
|
||||
# Whatever the next generator *starts* with, I may need
|
||||
# to subdivide where I *end*: all of their edges must be
|
||||
# shared (not just incident).
|
||||
# A fork can be only the final element, so disregard anything
|
||||
# after one and just quit:
|
||||
break
|
||||
|
||||
21
examples.py
21
examples.py
@ -163,21 +163,24 @@ def ram_horn_branch():
|
||||
elif i == 3:
|
||||
dx, dy = 1, -1
|
||||
return meshutil.Transform().rotate([-dy,dx,0], -numpy.pi/6)
|
||||
# this has to begin with cage_sub, prior to xf_sub(i) being
|
||||
# composed in, because only this lines up with where the last
|
||||
# frame finished
|
||||
subdiv, trans_vs, trans_es = cage1.subdivide_deprecated()
|
||||
gens = [cage.CageGen(itertools.chain(
|
||||
[cage_sub.transform(xf0)],
|
||||
recur(xf_sub(i).compose(xf0), cage_sub, 8)))
|
||||
#[cage_sub.transform(xf0)],
|
||||
recur(xf_sub(i).compose(xf0), cage_sub, 4)))
|
||||
for i,cage_sub in
|
||||
enumerate(cage1.subdivide_deprecated())]
|
||||
yield cage.CageFork(gens)
|
||||
enumerate(subdiv)]
|
||||
yield cage.CageFork(gens, xf0.apply_to(trans_vs), trans_es)
|
||||
# TODO: Figure out why this has a large gap now
|
||||
# I seem to be producing a transition mesh that is degenerate,
|
||||
# which means the starting cage and subdivided cage are lying right
|
||||
# on top of each other. Starting cage looks okay, so subdivided
|
||||
# cage is probably what is wrong.
|
||||
cg = cage.CageGen(itertools.chain(
|
||||
[cage0],
|
||||
recur(meshutil.Transform(), cage0, 8),
|
||||
recur(meshutil.Transform(), cage0, 4),
|
||||
))
|
||||
# TODO: if this is just a list it seems silly to require itertools
|
||||
mesh = cg.to_mesh(count=32, close_first=True, close_last=True)
|
||||
mesh = cg.to_mesh(count=8, close_first=True, close_last=True)
|
||||
return mesh
|
||||
|
||||
def branch_test():
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user