fix anchoring for textured case

This commit is contained in:
Adrian Mariano
2025-06-21 00:28:40 -04:00
parent 77b87040dc
commit cc169e0e23

View File

@@ -861,23 +861,21 @@ function linear_sweep(
assert(is_vector(shift, 2), str(shift)) assert(is_vector(shift, 2), str(shift))
assert(is_bool(caps) || is_bool_list(caps,2), "\ncaps must be boolean or a list of two booleans.") assert(is_bool(caps) || is_bool_list(caps,2), "\ncaps must be boolean or a list of two booleans.")
let( let(
h = one_defined([h, height,l,length],"h,height,l,length",dflt=1) h = one_defined([h, height,l,length],"h,height,l,length",dflt=1),
) regions = region_parts(region),
!is_undef(texture)? _textured_linear_sweep( vnf = !is_undef(texture)?
_textured_linear_sweep(
region, h=h, caps=caps, region, h=h, caps=caps,
texture=texture, tex_size=tex_size, texture=texture, tex_size=tex_size,
counts=tex_reps, inset=tex_inset, counts=tex_reps, inset=tex_inset,
rot=tex_rot, tex_scale=tex_depth, rot=tex_rot, tex_scale=tex_depth,
twist=twist, scale=scale, shift=shift, twist=twist, scale=scale, shift=shift,
style=style, samples=tex_samples, style=style, samples=tex_samples)
anchor=anchor, spin=spin, orient=orient : let(
) :
let(
caps = is_bool(caps) ? [caps,caps] : caps, caps = is_bool(caps) ? [caps,caps] : caps,
anchor = center==true? "origin" : anchor = center==true? "origin" :
center == false? "original_base" : center == false? "original_base" :
default(anchor, "original_base"), default(anchor, "original_base"),
regions = region_parts(region),
slices = default(slices, max(1,ceil(abs(twist)/5))), slices = default(slices, max(1,ceil(abs(twist)/5))),
scale = is_num(scale)? [scale,scale] : point2d(scale), scale = is_num(scale)? [scale,scale] : point2d(scale),
topmat = move(shift) * scale(scale) * rot(-twist), topmat = move(shift) * scale(scale) * rot(-twist),
@@ -914,7 +912,9 @@ function linear_sweep(
) vnf_vertex_array(verts, caps=false, col_wrap=true, style=style), ) vnf_vertex_array(verts, caps=false, col_wrap=true, style=style),
if (caps[0]) for (rgn = regions) vnf_from_region(rgn, down(h/2), reverse=true), if (caps[0]) for (rgn = regions) vnf_from_region(rgn, down(h/2), reverse=true),
if (caps[1]) for (rgn = trgns) vnf_from_region(rgn, up(h/2), reverse=false) if (caps[1]) for (rgn = trgns) vnf_from_region(rgn, up(h/2), reverse=false)
]), ])
)
vnf,
regparts = flatten(regions), regparts = flatten(regions),
sizes = [0,each cumsum([for(entry=regparts) len(entry)])], sizes = [0,each cumsum([for(entry=regparts) len(entry)])],
ganchors = [ ganchors = [