mirror of
https://github.com/JustinSDK/dotSCAD.git
synced 2025-01-17 14:18:13 +01:00
refactor
This commit is contained in:
parent
59ae93ba5f
commit
37c3a647a5
@ -1,15 +1,12 @@
|
||||
function _tri_subdivide(points, detail) =
|
||||
let(
|
||||
rows = detail + 1,
|
||||
vc = points[2] - points[0],
|
||||
vr = points[1] - points[0],
|
||||
dr = vr / (detail + 1),
|
||||
dc = vc / (detail + 1),
|
||||
rows = detail + 1,
|
||||
dr = (points[2] - points[0]) / rows,
|
||||
dc = (points[1] - points[0]) / rows,
|
||||
pts = [
|
||||
for(ri = [0:rows])
|
||||
let(cols = rows - ri)
|
||||
for(ci = [0:cols])
|
||||
points[0] + ci * dc + ri * dr
|
||||
for(ci = [0:rows - ri])
|
||||
points[0] + ci * dc + ri * dr
|
||||
],
|
||||
ri_base = [for(ri = 0, acc = 0; ri <= rows; ri = ri + 1, acc = acc + rows - ri + 2) acc],
|
||||
idx = function(ci, ri) ci + ri_base[ri],
|
||||
@ -17,7 +14,6 @@ function _tri_subdivide(points, detail) =
|
||||
for(ri = [0:rows - 1])
|
||||
let(cols = rows - ri - 1)
|
||||
for(ci = [0:cols])
|
||||
let(pre = 0)
|
||||
each (ci == cols ?
|
||||
[
|
||||
[idx(ci, ri), idx(ci, ri + 1), idx(ci + 1, ri)]
|
||||
@ -32,17 +28,18 @@ function _tri_subdivide(points, detail) =
|
||||
[pts, faces];
|
||||
|
||||
function _subdivide_project(points, faces, radius, detail) =
|
||||
detail == 0 ? [[for(p = points) p / norm(p) * radius], faces] :
|
||||
let(
|
||||
subdivided_all = [
|
||||
for(face = faces)
|
||||
_tri_subdivide([for(i = face) points[i]], detail)
|
||||
],
|
||||
pts_number_per_tri = len(subdivided_all[0][0]),
|
||||
flatten_points = [
|
||||
for(pts_faces = subdivided_all)
|
||||
for(p = pts_faces[0])
|
||||
p / norm(p) * radius
|
||||
],
|
||||
pts_number_per_tri = len(subdivided_all[0][0]),
|
||||
flatten_faces = [
|
||||
for(i = [0:len(subdivided_all) - 1])
|
||||
let(faces = subdivided_all[i][1])
|
||||
|
Loading…
x
Reference in New Issue
Block a user