1 /* precomputed morton layout indices */
2 const int morton_x [256] =
4 0, 1, 0, 1, 2, 3, 2, 3,
5 0, 1, 0, 1, 2, 3, 2, 3,
6 4, 5, 4, 5, 6, 7, 6, 7,
7 4, 5, 4, 5, 6, 7, 6, 7,
8 0, 1, 0, 1, 2, 3, 2, 3,
9 0, 1, 0, 1, 2, 3, 2, 3,
10 4, 5, 4, 5, 6, 7, 6, 7,
11 4, 5, 4, 5, 6, 7, 6, 7,
12 8, 9, 8, 9, 10, 11, 10, 11,
13 8, 9, 8, 9, 10, 11, 10, 11,
14 12, 13, 12, 13, 14, 15, 14, 15,
15 12, 13, 12, 13, 14, 15, 14, 15,
16 8, 9, 8, 9, 10, 11, 10, 11,
17 8, 9, 8, 9, 10, 11, 10, 11,
18 12, 13, 12, 13, 14, 15, 14, 15,
19 12, 13, 12, 13, 14, 15, 14, 15,
20 0, 1, 0, 1, 2, 3, 2, 3,
21 0, 1, 0, 1, 2, 3, 2, 3,
22 4, 5, 4, 5, 6, 7, 6, 7,
23 4, 5, 4, 5, 6, 7, 6, 7,
24 0, 1, 0, 1, 2, 3, 2, 3,
25 0, 1, 0, 1, 2, 3, 2, 3,
26 4, 5, 4, 5, 6, 7, 6, 7,
27 4, 5, 4, 5, 6, 7, 6, 7,
28 8, 9, 8, 9, 10, 11, 10, 11,
29 8, 9, 8, 9, 10, 11, 10, 11,
30 12, 13, 12, 13, 14, 15, 14, 15,
31 12, 13, 12, 13, 14, 15, 14, 15,
32 8, 9, 8, 9, 10, 11, 10, 11,
33 8, 9, 8, 9, 10, 11, 10, 11,
34 12, 13, 12, 13, 14, 15, 14, 15,
35 12, 13, 12, 13, 14, 15, 14, 15
38 const int morton_y [256] =
40 0, 0, 1, 1, 0, 0, 1, 1,
41 2, 2, 3, 3, 2, 2, 3, 3,
42 0, 0, 1, 1, 0, 0, 1, 1,
43 2, 2, 3, 3, 2, 2, 3, 3,
44 4, 4, 5, 5, 4, 4, 5, 5,
45 6, 6, 7, 7, 6, 6, 7, 7,
46 4, 4, 5, 5, 4, 4, 5, 5,
47 6, 6, 7, 7, 6, 6, 7, 7,
48 0, 0, 1, 1, 0, 0, 1, 1,
49 2, 2, 3, 3, 2, 2, 3, 3,
50 0, 0, 1, 1, 0, 0, 1, 1,
51 2, 2, 3, 3, 2, 2, 3, 3,
52 4, 4, 5, 5, 4, 4, 5, 5,
53 6, 6, 7, 7, 6, 6, 7, 7,
54 4, 4, 5, 5, 4, 4, 5, 5,
55 6, 6, 7, 7, 6, 6, 7, 7,
56 8, 8, 9, 9, 8, 8, 9, 9,
57 10, 10, 11, 11, 10, 10, 11, 11,
58 8, 8, 9, 9, 8, 8, 9, 9,
59 10, 10, 11, 11, 10, 10, 11, 11,
60 12, 12, 13, 13, 12, 12, 13, 13,
61 14, 14, 15, 15, 14, 14, 15, 15,
62 12, 12, 13, 13, 12, 12, 13, 13,
63 14, 14, 15, 15, 14, 14, 15, 15,
64 8, 8, 9, 9, 8, 8, 9, 9,
65 10, 10, 11, 11, 10, 10, 11, 11,
66 8, 8, 9, 9, 8, 8, 9, 9,
67 10, 10, 11, 11, 10, 10, 11, 11,
68 12, 12, 13, 13, 12, 12, 13, 13,
69 14, 14, 15, 15, 14, 14, 15, 15,
70 12, 12, 13, 13, 12, 12, 13, 13,
71 14, 14, 15, 15, 14, 14, 15, 15