mirror of
https://github.com/BelfrySCAD/BOSL2.git
synced 2025-01-01 09:49:45 +00:00
Fixed attachable() anchors for vnf's with extent=false.
This commit is contained in:
parent
c465a5b746
commit
25841bda73
2 changed files with 14 additions and 23 deletions
|
@ -458,10 +458,9 @@ function find_anchor(anchor, geom) =
|
||||||
eps = 1/2048,
|
eps = 1/2048,
|
||||||
points = vnf[0],
|
points = vnf[0],
|
||||||
faces = vnf[1],
|
faces = vnf[1],
|
||||||
rpts = rot(from=anchor, to=RIGHT, p=move(point3d(-cp), p=points)),
|
rpts = apply(rot(from=anchor, to=RIGHT) * move(point3d(-cp)), points),
|
||||||
hits = [
|
hits = [
|
||||||
for (i = idx(faces)) let(
|
for (face = faces) let(
|
||||||
face = faces[i],
|
|
||||||
verts = select(rpts, face)
|
verts = select(rpts, face)
|
||||||
) if (
|
) if (
|
||||||
max(subindex(verts,0)) >= -eps &&
|
max(subindex(verts,0)) >= -eps &&
|
||||||
|
@ -470,35 +469,27 @@ function find_anchor(anchor, geom) =
|
||||||
min(subindex(verts,1)) <= eps &&
|
min(subindex(verts,1)) <= eps &&
|
||||||
min(subindex(verts,2)) <= eps
|
min(subindex(verts,2)) <= eps
|
||||||
) let(
|
) let(
|
||||||
pt = polygon_line_intersection(
|
poly = select(points, face),
|
||||||
select(points, face),
|
pt = polygon_line_intersection(poly, [cp,cp+anchor], bounded=[true,false], eps=eps)
|
||||||
[CENTER,anchor], eps=eps
|
) if (!is_undef(pt)) let(
|
||||||
)
|
plane = plane_from_polygon(poly),
|
||||||
) if (!is_undef(pt)) [norm(pt), i, pt]
|
n = plane_normal(plane)
|
||||||
|
)
|
||||||
|
[norm(pt-cp), n, pt]
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
assert(len(hits)>0, "Anchor vector does not intersect with the shape. Attachment failed.")
|
assert(len(hits)>0, "Anchor vector does not intersect with the shape. Attachment failed.")
|
||||||
let(
|
let(
|
||||||
furthest = max_index(subindex(hits,0)),
|
furthest = max_index(subindex(hits,0)),
|
||||||
pos = point3d(cp) + hits[furthest][2],
|
|
||||||
dist = hits[furthest][0],
|
dist = hits[furthest][0],
|
||||||
nfaces = [for (hit = hits) if(approx(hit[0],dist,eps=eps)) hit[1]],
|
pos = hits[furthest][2],
|
||||||
n = unit(
|
n = unit(sum([for (hit = hits) if (approx(hit[0],dist,eps=eps)) hit[1]]))
|
||||||
sum([
|
|
||||||
for (i = nfaces) let(
|
|
||||||
faceverts = select(points, faces[i]),
|
|
||||||
faceplane = plane_from_points(faceverts),
|
|
||||||
nrm = plane_normal(faceplane)
|
|
||||||
) nrm
|
|
||||||
]) / len(nfaces),
|
|
||||||
UP
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
[anchor, pos, n, oang]
|
[anchor, pos, n, oang]
|
||||||
) : type == "vnf_extent"? ( //vnf
|
) : type == "vnf_extent"? ( //vnf
|
||||||
let(
|
let(
|
||||||
vnf=geom[1],
|
vnf=geom[1],
|
||||||
rpts = rot(from=anchor, to=RIGHT, p=move(point3d(-cp), p=vnf[0])),
|
rpts = apply(rot(from=anchor, to=RIGHT) * move(point3d(-cp)), vnf[0]),
|
||||||
maxx = max(subindex(rpts,0)),
|
maxx = max(subindex(rpts,0)),
|
||||||
idxs = [for (i = idx(rpts)) if (approx(rpts[i].x, maxx)) i],
|
idxs = [for (i = idx(rpts)) if (approx(rpts[i].x, maxx)) i],
|
||||||
mm = pointlist_bounds(select(rpts,idxs)),
|
mm = pointlist_bounds(select(rpts,idxs)),
|
||||||
|
@ -849,7 +840,7 @@ module attachable(
|
||||||
|
|
||||||
// Module: position()
|
// Module: position()
|
||||||
// Usage:
|
// Usage:
|
||||||
// position(from, [overlap]) ...
|
// position(from) ...
|
||||||
// Description:
|
// Description:
|
||||||
// Attaches children to a parent object at an anchor point.
|
// Attaches children to a parent object at an anchor point.
|
||||||
// Arguments:
|
// Arguments:
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
BOSL_VERSION = [2,0,403];
|
BOSL_VERSION = [2,0,404];
|
||||||
|
|
||||||
|
|
||||||
// Section: BOSL Library Version Functions
|
// Section: BOSL Library Version Functions
|
||||||
|
|
Loading…
Reference in a new issue