Skip to content

Commit

Permalink
polystrips: vertical slice through #1455
Browse files Browse the repository at this point in the history
right now, only considering bmverts that share a face with a selected
bmvert.

right now, selected bmverts are moved with a factor of 1.0, and these
un-selected neighboring bmverts are moved with a constant factor of 0.5.

later, we can determine factor as a falloff based on distance from curve
and size of brush (or some property of edit)
  • Loading branch information
vxlcoder committed Feb 27, 2025
1 parent f98f68d commit 23af344
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions retopoflow/rftool_polystrips/polystrips.py
Original file line number Diff line number Diff line change
Expand Up @@ -307,15 +307,22 @@ def init(self, context, event):
self.curve.tessellate_uniform()
strip_inds = self.strips_indices[self.hovering[0]]
bmfs = [ self.bm.faces[i] for i in strip_inds]
bmvs = { bmv for bmf in bmfs for bmv in bmf.verts }
bmvs = { bmv: 1.0 for bmf in bmfs for bmv in bmf.verts }
# gather neighboring geo
all_bmvs = bmvs | { bmv_other: 0.5 for bmv in bmvs for bmf in bmv.link_faces for bmv_other in bmf.verts if bmv_other not in bmvs }
# all data is local to edit!
data = {}
for bmv in bmvs:
for (bmv, factor) in all_bmvs.items():
t = self.curve.approximate_t_at_point_tessellation(bmv.co)
o = self.curve.eval(t)
z = Vector(self.curve.eval_derivative(t)).normalized()
f = Frame(o, x=self.fwd, z=z)
data[bmv.index] = (t, f.w2l_point(bmv.co), Vector(bmv.co))
data[bmv.index] = (
t,
f.w2l_point(bmv.co),
Vector(bmv.co),
factor,
)
self.grab = {
'mouse': Vector(mouse),
'curve': self.hovering[0],
Expand All @@ -340,7 +347,8 @@ def update(self, context, event):
if event.type in {'ESC', 'RIGHTMOUSE'}:
curve.p0, curve.p1, curve.p2, curve.p3 = self.grab['prev']
for bmv_idx in data:
bm.verts[bmv_idx].co = data[bmv_idx][2]
t, pt_curve_orig, pt_edit_orig, factor = data[bmv_idx]
bm.verts[bmv_idx].co = pt_edit_orig
bmesh.update_edit_mesh(em)
context.area.tag_redraw()
return {'CANCELLED'}
Expand Down Expand Up @@ -373,11 +381,13 @@ def xform(pt0_cur_edit, pt1_cur_edit=None):

for bmv_idx in data:
bmv = bm.verts[bmv_idx]
t, pt, _ = data[bmv_idx]
t, pt_curve_orig, pt_edit_orig, factor = data[bmv_idx]
o = curve.eval(t)
z = Vector(curve.eval_derivative(t)).normalized()
f = Frame(o, x=fwd, z=z)
bmv.co = nearest_point_valid_sources(context, M @ f.l2w_point(pt), world=False)
pt_edit_new = M @ f.l2w_point(pt_curve_orig)
pt_edit_new = pt_edit_orig + (pt_edit_new - pt_edit_orig) * factor
bmv.co = nearest_point_valid_sources(context, pt_edit_new, world=False)

bmesh.update_edit_mesh(em)
context.area.tag_redraw()
Expand Down

0 comments on commit 23af344

Please sign in to comment.