Skip to content
This repository was archived by the owner on Sep 27, 2023. It is now read-only.

Commit f27fece

Browse files
committed
Geometry Compiler: numeric arrays, bug #48
1 parent 38272ad commit f27fece

File tree

3 files changed

+947
-18
lines changed

3 files changed

+947
-18
lines changed

examples/tests/gdf.curv

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
// Table driven regular polyhedra, based on `ideas/shapes/hg_sdf.glsl`,
2+
// ultimately based on "Generalized Distance Functions", Ergun Akleman:
3+
// http://people.tamu.edu/~ergun/research/implicitmodeling/papers/sm99.pdf
4+
5+
// This program is a test case for using arrays within distance functions.
6+
7+
parametric {
8+
exp /*:: scale_picker*/ = 1;
9+
}
10+
11+
let
12+
GDFVectors = [
13+
normalize[1, 0, 0],
14+
normalize[0, 1, 0],
15+
normalize[0, 0, 1],
16+
17+
normalize[1, 1, 1 ],
18+
normalize[-1, 1, 1],
19+
normalize[1, -1, 1],
20+
normalize[1, 1, -1],
21+
22+
normalize[0, 1, phi+1],
23+
normalize[0, -1, phi+1],
24+
normalize[phi+1, 0, 1],
25+
normalize[-phi-1, 0, 1],
26+
normalize[1, phi+1, 0],
27+
normalize[-1, phi+1, 0],
28+
29+
normalize[0, phi, 1],
30+
normalize[0, -phi, 1],
31+
normalize[1, 0, phi],
32+
normalize[-1, 0, phi],
33+
normalize[phi, 1, 0],
34+
normalize[-phi, 1, 0],
35+
];
36+
37+
xGDF(p, r, e, begin, end) =
38+
do
39+
var d := 0;
40+
for (i in begin..end)
41+
d := d + abs(dot(p, GDFVectors[i]))^e;
42+
in d^(1/e) - r;
43+
44+
GDF(p, r, begin, end) =
45+
do var d := 0;
46+
for (i in begin..end)
47+
d := max(d, abs(dot(p, GDFVectors[i])));
48+
in d - r;
49+
50+
// not an octahedron, not Lipschitz(1)
51+
xOcta(r, e) =
52+
make_shape {
53+
dist p = xGDF(p[[X,Y,Z]], r, e, 3, 6);
54+
is_3d = true;
55+
};
56+
57+
// works as expected
58+
Octa r =
59+
make_shape {
60+
dist p = GDF(p[[X,Y,Z]], r, 3, 6);
61+
circumratio = (1/2*sqrt 2) / (1/6*sqrt 6);
62+
bbox = circumratio * [[-r,-r,-r], [r,r,r]];
63+
is_3d = true;
64+
};
65+
66+
xs = xOcta(2,exp) >> lipschitz 5;
67+
s = Octa 2;
68+
69+
in
70+
s

0 commit comments

Comments
 (0)