Blender V5.3
bmo_primitive.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2023 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
10
11#include <algorithm>
12#include <cmath>
13
14#include "MEM_guardedalloc.h"
15
16#include "BLI_array.hh"
17#include "BLI_math_base_safe.hh"
18#include "BLI_math_matrix_c.hh"
20#include "BLI_math_vector_c.hh"
21
22#include "BKE_customdata.hh"
23
24#include "bmesh.hh"
26
27namespace blender {
28
29/* ************************ primitives ******************* */
30
31static const float icovert[12][3] = {
32 {0.0f, 0.0f, -200.0f},
33 {144.72f, -105.144f, -89.443f},
34 {-55.277f, -170.128, -89.443f},
35 {-178.885f, 0.0f, -89.443f},
36 {-55.277f, 170.128f, -89.443f},
37 {144.72f, 105.144f, -89.443f},
38 {55.277f, -170.128f, 89.443f},
39 {-144.72f, -105.144f, 89.443f},
40 {-144.72f, 105.144f, 89.443f},
41 {55.277f, 170.128f, 89.443f},
42 {178.885f, 0.0f, 89.443f},
43 {0.0f, 0.0f, 200.0f},
44};
45
46static const short icoface[20][3] = {
47 {0, 1, 2}, {1, 0, 5}, {0, 2, 3}, {0, 3, 4}, {0, 4, 5}, {1, 5, 10}, {2, 1, 6},
48 {3, 2, 7}, {4, 3, 8}, {5, 4, 9}, {1, 10, 6}, {2, 6, 7}, {3, 7, 8}, {4, 8, 9},
49 {5, 9, 10}, {6, 10, 11}, {7, 6, 11}, {8, 7, 11}, {9, 8, 11}, {10, 9, 11},
50};
51
52static const float icouvs[60][2] = {
53 {0.181819f, 0.000000f}, {0.272728f, 0.157461f}, {0.090910f, 0.157461f}, {0.272728f, 0.157461f},
54 {0.363637f, 0.000000f}, {0.454546f, 0.157461f}, {0.909091f, 0.000000f}, {1.000000f, 0.157461f},
55 {0.818182f, 0.157461f}, {0.727273f, 0.000000f}, {0.818182f, 0.157461f}, {0.636364f, 0.157461f},
56 {0.545455f, 0.000000f}, {0.636364f, 0.157461f}, {0.454546f, 0.157461f}, {0.272728f, 0.157461f},
57 {0.454546f, 0.157461f}, {0.363637f, 0.314921f}, {0.090910f, 0.157461f}, {0.272728f, 0.157461f},
58 {0.181819f, 0.314921f}, {0.818182f, 0.157461f}, {1.000000f, 0.157461f}, {0.909091f, 0.314921f},
59 {0.636364f, 0.157461f}, {0.818182f, 0.157461f}, {0.727273f, 0.314921f}, {0.454546f, 0.157461f},
60 {0.636364f, 0.157461f}, {0.545455f, 0.314921f}, {0.272728f, 0.157461f}, {0.363637f, 0.314921f},
61 {0.181819f, 0.314921f}, {0.090910f, 0.157461f}, {0.181819f, 0.314921f}, {0.000000f, 0.314921f},
62 {0.818182f, 0.157461f}, {0.909091f, 0.314921f}, {0.727273f, 0.314921f}, {0.636364f, 0.157461f},
63 {0.727273f, 0.314921f}, {0.545455f, 0.314921f}, {0.454546f, 0.157461f}, {0.545455f, 0.314921f},
64 {0.363637f, 0.314921f}, {0.181819f, 0.314921f}, {0.363637f, 0.314921f}, {0.272728f, 0.472382f},
65 {0.000000f, 0.314921f}, {0.181819f, 0.314921f}, {0.090910f, 0.472382f}, {0.727273f, 0.314921f},
66 {0.909091f, 0.314921f}, {0.818182f, 0.472382f}, {0.545455f, 0.314921f}, {0.727273f, 0.314921f},
67 {0.636364f, 0.472382f}, {0.363637f, 0.314921f}, {0.545455f, 0.314921f}, {0.454546f, 0.472382f},
68};
69
70static const int monkeyo = 4;
71static const int monkeynv = 271;
72static const int monkeynf = 250;
73static const signed char monkeyv[271][3] = {
74 {-71, 21, 98}, {-63, 12, 88}, {-57, 7, 74}, {-82, -3, 79}, {-82, 4, 92},
75 {-82, 17, 100}, {-92, 21, 102}, {-101, 12, 95}, {-107, 7, 83}, {-117, 31, 84},
76 {-109, 31, 95}, {-96, 31, 102}, {-92, 42, 102}, {-101, 50, 95}, {-107, 56, 83},
77 {-82, 66, 79}, {-82, 58, 92}, {-82, 46, 100}, {-71, 42, 98}, {-63, 50, 88},
78 {-57, 56, 74}, {-47, 31, 72}, {-55, 31, 86}, {-67, 31, 97}, {-66, 31, 99},
79 {-70, 43, 100}, {-82, 48, 103}, {-93, 43, 105}, {-98, 31, 105}, {-93, 20, 105},
80 {-82, 31, 106}, {-82, 15, 103}, {-70, 20, 100}, {-127, 55, 95}, {-127, 45, 105},
81 {-127, -87, 94}, {-127, -41, 100}, {-127, -24, 102}, {-127, -99, 92}, {-127, 52, 77},
82 {-127, 73, 73}, {-127, 115, -70}, {-127, 72, -109}, {-127, 9, -106}, {-127, -49, -45},
83 {-101, -24, 72}, {-87, -56, 73}, {-82, -89, 73}, {-80, -114, 68}, {-85, -121, 67},
84 {-104, -124, 71}, {-127, -126, 74}, {-71, -18, 68}, {-46, -5, 69}, {-21, 19, 57},
85 {-17, 55, 76}, {-36, 62, 80}, {-64, 77, 88}, {-86, 97, 94}, {-107, 92, 97},
86 {-119, 63, 96}, {-106, 53, 99}, {-111, 39, 98}, {-101, 12, 95}, {-79, 2, 90},
87 {-64, 8, 86}, {-47, 24, 83}, {-45, 38, 83}, {-50, 48, 85}, {-72, 56, 92},
88 {-95, 60, 97}, {-127, -98, 94}, {-113, -92, 94}, {-112, -107, 91}, {-119, -113, 89},
89 {-127, -114, 88}, {-127, -25, 96}, {-127, -18, 95}, {-114, -19, 95}, {-111, -29, 96},
90 {-116, -37, 95}, {-76, -6, 86}, {-48, 7, 80}, {-34, 26, 77}, {-32, 48, 84},
91 {-39, 53, 93}, {-71, 70, 102}, {-87, 82, 107}, {-101, 79, 109}, {-114, 55, 108},
92 {-111, -13, 104}, {-100, -57, 91}, {-95, -90, 88}, {-93, -105, 85}, {-97, -117, 81},
93 {-106, -119, 81}, {-127, -121, 82}, {-127, 6, 93}, {-127, 27, 98}, {-85, 61, 95},
94 {-106, 18, 96}, {-110, 27, 97}, {-112, -88, 94}, {-117, -57, 96}, {-127, -57, 96},
95 {-127, -42, 95}, {-115, -35, 100}, {-110, -29, 102}, {-113, -17, 100}, {-122, -16, 100},
96 {-127, -26, 106}, {-121, -19, 104}, {-115, -20, 104}, {-113, -29, 106}, {-117, -32, 103},
97 {-127, -37, 103}, {-94, -40, 71}, {-106, -31, 91}, {-104, -40, 91}, {-97, -32, 71},
98 {-127, -112, 88}, {-121, -111, 88}, {-115, -105, 91}, {-115, -95, 93}, {-127, -100, 84},
99 {-115, -96, 85}, {-115, -104, 82}, {-121, -109, 81}, {-127, -110, 81}, {-105, 28, 100},
100 {-103, 20, 99}, {-84, 55, 97}, {-92, 54, 99}, {-73, 51, 99}, {-55, 45, 89},
101 {-52, 37, 88}, {-53, 25, 87}, {-66, 13, 92}, {-79, 8, 95}, {-98, 14, 100},
102 {-104, 38, 100}, {-100, 48, 100}, {-97, 46, 97}, {-102, 38, 97}, {-96, 16, 97},
103 {-79, 11, 93}, {-68, 15, 90}, {-57, 27, 86}, {-56, 36, 86}, {-59, 43, 87},
104 {-74, 50, 96}, {-91, 51, 98}, {-84, 52, 96}, {-101, 22, 96}, {-102, 29, 96},
105 {-113, 59, 78}, {-102, 85, 79}, {-84, 88, 76}, {-65, 71, 71}, {-40, 58, 63},
106 {-25, 52, 59}, {-28, 21, 48}, {-50, 0, 53}, {-71, -12, 60}, {-127, 115, 37},
107 {-127, 126, -10}, {-127, -25, -86}, {-127, -59, 24}, {-127, -125, 59}, {-127, -103, 44},
108 {-127, -73, 41}, {-127, -62, 36}, {-18, 30, 7}, {-17, 41, -6}, {-28, 34, -56},
109 {-68, 56, -90}, {-33, -6, 9}, {-51, -16, -21}, {-45, -1, -55}, {-84, 7, -85},
110 {-97, -45, 52}, {-104, -53, 33}, {-90, -91, 49}, {-95, -64, 50}, {-85, -117, 51},
111 {-109, -97, 47}, {-111, -69, 46}, {-106, -121, 56}, {-99, -36, 55}, {-100, -29, 60},
112 {-101, -22, 64}, {-100, -50, 21}, {-89, -40, -34}, {-83, -19, -69}, {-69, 111, -49},
113 {-69, 119, -9}, {-69, 109, 30}, {-68, 67, 55}, {-34, 52, 43}, {-46, 58, 36},
114 {-45, 90, 7}, {-25, 72, 16}, {-25, 79, -15}, {-45, 96, -25}, {-45, 87, -57},
115 {-25, 69, -46}, {-48, 42, -75}, {-65, 3, -70}, {-22, 42, -26}, {-75, -22, 19},
116 {-72, -25, -27}, {-13, 52, -30}, {-28, -18, -16}, {6, -13, -42}, {37, 7, -55},
117 {46, 41, -54}, {31, 65, -54}, {4, 61, -40}, {3, 53, -37}, {25, 56, -50},
118 {35, 37, -52}, {28, 10, -52}, {5, -5, -39}, {-21, -9, -17}, {-9, 46, -28},
119 {-6, 39, -37}, {-14, -3, -27}, {6, 0, -47}, {25, 12, -57}, {31, 32, -57},
120 {23, 46, -56}, {4, 44, -46}, {-19, 37, -27}, {-20, 22, -35}, {-30, 12, -35},
121 {-22, 11, -35}, {-19, 2, -35}, {-23, -2, -35}, {-34, 0, -9}, {-35, -3, -22},
122 {-35, 5, -24}, {-25, 26, -27}, {-13, 31, -34}, {-13, 30, -41}, {-23, -2, -41},
123 {-18, 2, -41}, {-21, 10, -41}, {-29, 12, -41}, {-19, 22, -41}, {6, 42, -53},
124 {25, 44, -62}, {34, 31, -63}, {28, 11, -62}, {7, 0, -54}, {-14, -2, -34},
125 {-5, 37, -44}, {-13, 14, -42}, {-7, 8, -43}, {1, 16, -47}, {-4, 22, -45},
126 {3, 30, -48}, {8, 24, -49}, {15, 27, -50}, {12, 35, -50}, {4, 56, -62},
127 {33, 60, -70}, {48, 38, -64}, {41, 7, -68}, {6, -11, -63}, {-26, -16, -42},
128 {-17, 49, -49},
129};
130
131static signed char monkeyf[250][4] = {
132 {27, 4, 5, 26}, {25, 4, 5, 24}, {3, 6, 5, 4},
133 {1, 6, 5, 2}, {5, 6, 7, 4}, {3, 6, 7, 2},
134 {5, 8, 7, 6}, {3, 8, 7, 4}, {7, 8, 9, 6},
135 {5, 8, 9, 4}, {7, 10, 9, 8}, {5, 10, 9, 6},
136 {9, 10, 11, 8}, {7, 10, 11, 6}, {9, 12, 11, 10},
137 {7, 12, 11, 8}, {11, 6, 13, 12}, {5, 4, 13, 12},
138 {3, -2, 13, 12}, {-3, -4, 13, 12}, {-5, -10, 13, 12},
139 {-11, -12, 14, 12}, {-13, -18, 14, 13}, {-19, 4, 5, 13},
140 {10, 12, 4, 4}, {10, 11, 9, 9}, {8, 7, 9, 9},
141 {7, 5, 6, 6}, {6, 3, 4, 4}, {5, 1, 2, 2},
142 {4, -1, 0, 0}, {3, -3, -2, -2}, {22, 67, 68, 23},
143 {20, 65, 66, 21}, {18, 63, 64, 19}, {16, 61, 62, 17},
144 {14, 59, 60, 15}, {12, 19, 48, 57}, {18, 19, 48, 47},
145 {18, 19, 48, 47}, {18, 19, 48, 47}, {18, 19, 48, 47},
146 {18, 19, 48, 47}, {18, 19, 48, 47}, {18, 19, 48, 47},
147 {18, 19, 48, 47}, {18, -9, -8, 47}, {18, 27, 45, 46},
148 {26, 55, 43, 44}, {24, 41, 42, 54}, {22, 39, 40, 23},
149 {20, 37, 38, 21}, {18, 35, 36, 19}, {16, 33, 34, 17},
150 {14, 31, 32, 15}, {12, 39, 30, 13}, {11, 48, 45, 38},
151 {8, 36, -19, 9}, {8, -20, 44, 47}, {42, 45, 46, 43},
152 {18, 19, 40, 39}, {16, 17, 38, 37}, {14, 15, 36, 35},
153 {32, 44, 43, 33}, {12, 33, 32, 42}, {19, 44, 43, 42},
154 {40, 41, 42, -27}, {8, 9, 39, -28}, {15, 43, 42, 16},
155 {13, 43, 42, 14}, {11, 43, 42, 12}, {9, -30, 42, 10},
156 {37, 12, 38, -32}, {-33, 37, 45, 46}, {-33, 40, 41, 39},
157 {38, 40, 41, 37}, {36, 40, 41, 35}, {34, 40, 41, 33},
158 {36, 39, 38, 37}, {35, 40, 39, 38}, {1, 2, 14, 21},
159 {1, 2, 40, 13}, {1, 2, 40, 39}, {1, 24, 12, 39},
160 {-34, 36, 38, 11}, {35, 38, 36, 37}, {-37, 8, 35, 37},
161 {-11, -12, -45, 40}, {-11, -12, 39, 38}, {-11, -12, 37, 36},
162 {-11, -12, 35, 34}, {33, 34, 40, 41}, {33, 34, 38, 39},
163 {33, 34, 36, 37}, {33, -52, 34, 35}, {33, 37, 36, 34},
164 {33, 35, 34, 34}, {8, 7, 37, 36}, {-32, 7, 35, 46},
165 {-34, -33, 45, 46}, {4, -33, 43, 34}, {-34, -33, 41, 42},
166 {-34, -33, 39, 40}, {-34, -33, 37, 38}, {-34, -33, 35, 36},
167 {-34, -33, 33, 34}, {-34, -33, 31, 32}, {-34, -4, 28, 30},
168 {-5, -34, 28, 27}, {-35, -44, 36, 27}, {26, 35, 36, 45},
169 {24, 25, 44, 45}, {25, 23, 44, 42}, {25, 24, 41, 40},
170 {25, 24, 39, 38}, {25, 24, 37, 36}, {25, 24, 35, 34},
171 {25, 24, 33, 32}, {25, 24, 31, 30}, {15, 24, 29, 38},
172 {25, 24, 27, 26}, {23, 12, 37, 26}, {11, 12, 35, 36},
173 {-86, -59, 36, -80}, {-60, -61, 36, 35}, {-62, -63, 36, 35},
174 {-64, -65, 36, 35}, {-66, -67, 36, 35}, {-68, -69, 36, 35},
175 {-70, -71, 36, 35}, {-72, -73, 36, 35}, {-74, -75, 36, 35},
176 {42, 43, 53, 58}, {40, 41, 57, 56}, {38, 39, 55, 57},
177 {-81, -80, 37, 56}, {-83, -82, 55, 52}, {-85, -84, 51, 49},
178 {-87, -86, 48, 49}, {47, 50, 51, 48}, {46, 48, 51, 49},
179 {43, 46, 49, 44}, {-92, -91, 45, 42}, {-23, 49, 50, -20},
180 {-94, 40, 48, -24}, {-96, -22, 48, 49}, {-97, 48, 21, -90},
181 {-100, 36, 50, 23}, {22, 49, 48, -100}, {-101, 47, 46, 22},
182 {21, 45, 35, 25}, {33, 34, 44, 41}, {13, 14, 28, 24},
183 {-107, 26, 30, -106}, {14, 46, 45, 15}, {14, 44, 43, -110},
184 {-111, 42, 23, -110}, {6, 7, 45, 46}, {45, 44, 47, 46},
185 {45, 46, 47, 48}, {47, 46, 49, 48}, {17, 49, 47, 48},
186 {17, 36, 46, 48}, {35, 36, 44, 45}, {35, 36, 40, 43},
187 {35, 36, 38, 39}, {-4, -3, 37, 35}, {-123, 34, 33, 1},
188 {-9, -8, -7, -6}, {-10, -7, 32, -125}, {-127, -11, -126, -126},
189 {-7, -6, 5, 31}, {4, 5, 33, 30}, {4, 39, 33, 32},
190 {4, 35, 32, 38}, {20, 21, 39, 38}, {4, 37, 38, 5},
191 {-11, -10, 36, 3}, {-11, 15, 14, 35}, {13, 16, 34, 34},
192 {-13, 14, 13, 13}, {-3, 1, 30, 29}, {-3, 28, 29, 1},
193 {-2, 31, 28, -1}, {12, 13, 27, 30}, {-2, 26, 12, 12},
194 {35, 29, 42, 36}, {34, 35, 36, 33}, {32, 35, 36, 31},
195 {30, 35, 36, 29}, {28, 35, 36, 27}, {26, 35, 36, 25},
196 {34, 39, 38, 35}, {32, 39, 38, 33}, {30, 39, 38, 31},
197 {28, 39, 38, 29}, {26, 39, 38, 27}, {25, 31, 32, 38},
198 {-18, -17, 45, 44}, {-18, 17, 28, 44}, {-24, -20, 42, -23},
199 {11, 35, 27, 14}, {25, 28, 39, 41}, {37, 41, 40, 38},
200 {34, 40, 36, 35}, {32, 40, 39, 33}, {30, 39, 31, 40},
201 {21, 29, 39, 22}, {-31, 37, 28, 4}, {-32, 33, 35, 36},
202 {32, 33, 34, 34}, {18, 35, 36, 48}, {34, 25, 40, 35},
203 {24, 25, 38, 39}, {24, 25, 36, 37}, {24, 25, 34, 35},
204 {24, 25, 32, 33}, {24, 13, 41, 31}, {17, 11, 41, 35},
205 {15, 16, 34, 35}, {13, 14, 34, 35}, {11, 12, 34, 35},
206 {9, 10, 34, 35}, {7, 8, 34, 35}, {26, 25, 37, 36},
207 {35, 36, 37, 38}, {37, 36, 39, 38}, {37, 38, 39, 40},
208 {25, 31, 36, 39}, {18, 34, 35, 30}, {17, 22, 30, 33},
209 {19, 29, 21, 20}, {16, 26, 29, 17}, {24, 29, 28, 25},
210 {22, 31, 28, 23}, {20, 31, 30, 21}, {18, 31, 30, 19},
211 {16, 30, 17, 17}, {-21, -22, 35, 34}, {-21, -22, 33, 32},
212 {-21, -22, 31, 30}, {-21, -22, 29, 28}, {-21, -22, 27, 26},
213 {-28, -22, 25, 31}, {24, 28, 29, 30}, {23, 24, 26, 27},
214 {23, 24, 25, 25}, {-69, -35, -32, 27}, {-70, 26, 25, -66},
215 {-68, -67, 24, -33},
216};
217
218static const float monkeyuvs[] = {
219 0.843250f, 0.588863f, 0.833697f, 0.611927f, 0.794218f, 0.611927f, 0.815334f, 0.560948f,
220 0.866314f, 0.937441f, 0.866314f, 0.897962f, 0.889378f, 0.888409f, 0.917293f, 0.916324f,
221 0.815334f, 0.560948f, 0.794218f, 0.611927f, 0.746541f, 0.611927f, 0.781622f, 0.527235f,
222 0.866314f, 0.985118f, 0.866314f, 0.937441f, 0.917293f, 0.916324f, 0.951006f, 0.950037f,
223 0.794218f, 0.611927f, 0.815334f, 0.662907f, 0.781622f, 0.696619f, 0.746541f, 0.611927f,
224 0.781622f, 0.950037f, 0.815334f, 0.916325f, 0.866314f, 0.937441f, 0.866314f, 0.985118f,
225 0.833697f, 0.611927f, 0.843250f, 0.634991f, 0.815334f, 0.662907f, 0.794218f, 0.611927f,
226 0.815334f, 0.916325f, 0.843250f, 0.888409f, 0.866314f, 0.897962f, 0.866314f, 0.937441f,
227 0.843250f, 0.634991f, 0.866314f, 0.644544f, 0.866314f, 0.684023f, 0.815334f, 0.662907f,
228 0.794218f, 0.865345f, 0.833697f, 0.865345f, 0.843250f, 0.888409f, 0.815334f, 0.916325f,
229 0.815334f, 0.662907f, 0.866314f, 0.684023f, 0.866314f, 0.731700f, 0.781622f, 0.696619f,
230 0.746541f, 0.865345f, 0.794218f, 0.865345f, 0.815334f, 0.916325f, 0.781622f, 0.950037f,
231 0.866314f, 0.684023f, 0.917293f, 0.662907f, 0.951006f, 0.696619f, 0.866314f, 0.731700f,
232 0.781622f, 0.780653f, 0.815334f, 0.814366f, 0.794218f, 0.865345f, 0.746541f, 0.865345f,
233 0.866314f, 0.644544f, 0.889378f, 0.634991f, 0.917293f, 0.662907f, 0.866314f, 0.684023f,
234 0.815334f, 0.814366f, 0.843250f, 0.842281f, 0.833697f, 0.865345f, 0.794218f, 0.865345f,
235 0.889378f, 0.634991f, 0.898931f, 0.611927f, 0.938410f, 0.611927f, 0.917293f, 0.662907f,
236 0.866314f, 0.793249f, 0.866314f, 0.832728f, 0.843250f, 0.842281f, 0.815334f, 0.814366f,
237 0.917293f, 0.662907f, 0.938410f, 0.611927f, 0.986087f, 0.611927f, 0.951006f, 0.696619f,
238 0.866314f, 0.745572f, 0.866314f, 0.793249f, 0.815334f, 0.814366f, 0.781622f, 0.780653f,
239 0.938410f, 0.611927f, 0.917294f, 0.560947f, 0.951006f, 0.527235f, 0.986087f, 0.611927f,
240 0.951006f, 0.780653f, 0.917294f, 0.814365f, 0.866314f, 0.793249f, 0.866314f, 0.745572f,
241 0.898931f, 0.611927f, 0.889378f, 0.588863f, 0.917294f, 0.560947f, 0.938410f, 0.611927f,
242 0.917294f, 0.814365f, 0.889378f, 0.842281f, 0.866314f, 0.832728f, 0.866314f, 0.793249f,
243 0.889378f, 0.588863f, 0.866314f, 0.579310f, 0.866314f, 0.539831f, 0.917294f, 0.560947f,
244 0.938410f, 0.865345f, 0.898931f, 0.865345f, 0.889378f, 0.842281f, 0.917294f, 0.814365f,
245 0.917294f, 0.560947f, 0.866314f, 0.539831f, 0.866314f, 0.492154f, 0.951006f, 0.527235f,
246 0.986087f, 0.865345f, 0.938410f, 0.865345f, 0.917294f, 0.814365f, 0.951006f, 0.780653f,
247 0.866314f, 0.539831f, 0.815334f, 0.560948f, 0.781622f, 0.527235f, 0.866314f, 0.492154f,
248 0.951006f, 0.950037f, 0.917293f, 0.916324f, 0.938410f, 0.865345f, 0.986087f, 0.865345f,
249 0.866314f, 0.579310f, 0.843250f, 0.588863f, 0.815334f, 0.560948f, 0.866314f, 0.539831f,
250 0.917293f, 0.916324f, 0.889378f, 0.888409f, 0.898931f, 0.865345f, 0.938410f, 0.865345f,
251 0.843250f, 0.588863f, 0.866314f, 0.579310f, 0.866314f, 0.585461f, 0.847600f, 0.593213f,
252 0.892780f, 0.865345f, 0.898931f, 0.865345f, 0.889378f, 0.888409f, 0.885028f, 0.884059f,
253 0.866314f, 0.579310f, 0.889378f, 0.588863f, 0.885028f, 0.593213f, 0.866314f, 0.585461f,
254 0.885028f, 0.846631f, 0.889378f, 0.842281f, 0.898931f, 0.865345f, 0.892780f, 0.865345f,
255 0.889378f, 0.588863f, 0.898931f, 0.611927f, 0.892780f, 0.611927f, 0.885028f, 0.593213f,
256 0.866314f, 0.838879f, 0.866314f, 0.832728f, 0.889378f, 0.842281f, 0.885028f, 0.846631f,
257 0.898931f, 0.611927f, 0.889378f, 0.634991f, 0.885028f, 0.630641f, 0.892780f, 0.611927f,
258 0.847600f, 0.846631f, 0.843250f, 0.842281f, 0.866314f, 0.832728f, 0.866314f, 0.838879f,
259 0.889378f, 0.634991f, 0.866314f, 0.644544f, 0.866314f, 0.638393f, 0.885028f, 0.630641f,
260 0.839848f, 0.865345f, 0.833697f, 0.865345f, 0.843250f, 0.842281f, 0.847600f, 0.846631f,
261 0.866314f, 0.644544f, 0.843250f, 0.634991f, 0.847600f, 0.630641f, 0.866314f, 0.638393f,
262 0.847600f, 0.884059f, 0.843250f, 0.888409f, 0.833697f, 0.865345f, 0.839848f, 0.865345f,
263 0.843250f, 0.634991f, 0.833697f, 0.611927f, 0.839848f, 0.611927f, 0.847600f, 0.630641f,
264 0.866314f, 0.891811f, 0.866314f, 0.897962f, 0.843250f, 0.888409f, 0.847600f, 0.884059f,
265 0.833697f, 0.611927f, 0.843250f, 0.588863f, 0.847600f, 0.593213f, 0.839848f, 0.611927f,
266 0.885028f, 0.884059f, 0.889378f, 0.888409f, 0.866314f, 0.897962f, 0.866314f, 0.891811f,
267 0.866314f, 0.611927f, 0.839848f, 0.611927f, 0.847600f, 0.593213f, 0.885028f, 0.884059f,
268 0.866314f, 0.891811f, 0.866314f, 0.865345f, 0.847600f, 0.630641f, 0.839848f, 0.611927f,
269 0.866314f, 0.611927f, 0.866314f, 0.865345f, 0.866314f, 0.891811f, 0.847600f, 0.884059f,
270 0.866314f, 0.611927f, 0.866314f, 0.638393f, 0.847600f, 0.630641f, 0.847600f, 0.884059f,
271 0.839848f, 0.865345f, 0.866314f, 0.865345f, 0.866314f, 0.611927f, 0.885028f, 0.630641f,
272 0.866314f, 0.638393f, 0.839848f, 0.865345f, 0.847600f, 0.846631f, 0.866314f, 0.865345f,
273 0.866314f, 0.611927f, 0.892780f, 0.611927f, 0.885028f, 0.630641f, 0.847600f, 0.846631f,
274 0.866314f, 0.838879f, 0.866314f, 0.865345f, 0.866314f, 0.611927f, 0.885028f, 0.593213f,
275 0.892780f, 0.611927f, 0.866314f, 0.838879f, 0.885028f, 0.846631f, 0.866314f, 0.865345f,
276 0.866314f, 0.611927f, 0.866314f, 0.585461f, 0.885028f, 0.593213f, 0.885028f, 0.846631f,
277 0.892780f, 0.865345f, 0.866314f, 0.865345f, 0.866314f, 0.611927f, 0.847600f, 0.593213f,
278 0.866314f, 0.585461f, 0.892780f, 0.865345f, 0.885028f, 0.884059f, 0.866314f, 0.865345f,
279 0.520711f, 0.060503f, 0.517028f, 0.068490f, 0.500000f, 0.064527f, 0.500000f, 0.054411f,
280 0.500000f, 0.064527f, 0.482972f, 0.068490f, 0.479289f, 0.060503f, 0.500000f, 0.054411f,
281 0.530457f, 0.065062f, 0.522612f, 0.070678f, 0.517028f, 0.068490f, 0.520711f, 0.060503f,
282 0.482972f, 0.068490f, 0.477388f, 0.070678f, 0.469543f, 0.065062f, 0.479289f, 0.060503f,
283 0.532878f, 0.067822f, 0.526301f, 0.079422f, 0.522612f, 0.070678f, 0.530457f, 0.065062f,
284 0.477388f, 0.070678f, 0.473699f, 0.079422f, 0.467122f, 0.067822f, 0.469543f, 0.065062f,
285 0.544695f, 0.083023f, 0.529228f, 0.091098f, 0.526301f, 0.079422f, 0.532878f, 0.067822f,
286 0.473699f, 0.079422f, 0.470772f, 0.091098f, 0.455305f, 0.083023f, 0.467122f, 0.067822f,
287 0.565647f, 0.115495f, 0.537536f, 0.127779f, 0.529228f, 0.091098f, 0.544695f, 0.083023f,
288 0.470772f, 0.091098f, 0.462464f, 0.127779f, 0.434353f, 0.115495f, 0.455305f, 0.083023f,
289 0.586916f, 0.172042f, 0.626605f, 0.208159f, 0.600470f, 0.238288f, 0.535885f, 0.215568f,
290 0.399530f, 0.238288f, 0.373395f, 0.208159f, 0.413084f, 0.172042f, 0.464115f, 0.215568f,
291 0.626605f, 0.208159f, 0.650908f, 0.240294f, 0.636962f, 0.261221f, 0.600470f, 0.238288f,
292 0.363038f, 0.261221f, 0.349092f, 0.240294f, 0.373395f, 0.208159f, 0.399530f, 0.238288f,
293 0.650908f, 0.240294f, 0.689501f, 0.268805f, 0.655896f, 0.284413f, 0.636962f, 0.261221f,
294 0.344104f, 0.284413f, 0.310499f, 0.268805f, 0.349092f, 0.240294f, 0.363038f, 0.261221f,
295 0.689501f, 0.268805f, 0.684517f, 0.317795f, 0.659507f, 0.313152f, 0.655896f, 0.284413f,
296 0.340493f, 0.313152f, 0.315483f, 0.317795f, 0.310499f, 0.268805f, 0.344104f, 0.284413f,
297 0.684517f, 0.317795f, 0.671357f, 0.334694f, 0.649107f, 0.322437f, 0.659507f, 0.313152f,
298 0.350893f, 0.322437f, 0.328643f, 0.334694f, 0.315483f, 0.317795f, 0.340493f, 0.313152f,
299 0.671357f, 0.334694f, 0.636775f, 0.370732f, 0.613636f, 0.353108f, 0.649107f, 0.322437f,
300 0.386364f, 0.353108f, 0.363225f, 0.370732f, 0.328643f, 0.334694f, 0.350893f, 0.322437f,
301 0.636775f, 0.370732f, 0.602261f, 0.395588f, 0.594178f, 0.371277f, 0.613636f, 0.353108f,
302 0.405822f, 0.371277f, 0.397739f, 0.395588f, 0.363225f, 0.370732f, 0.386364f, 0.353108f,
303 0.602261f, 0.395588f, 0.581044f, 0.398468f, 0.577351f, 0.373341f, 0.594178f, 0.371277f,
304 0.422649f, 0.373341f, 0.418956f, 0.398468f, 0.397739f, 0.395588f, 0.405822f, 0.371277f,
305 0.581044f, 0.398468f, 0.532016f, 0.387365f, 0.539817f, 0.354339f, 0.577351f, 0.373341f,
306 0.460183f, 0.354339f, 0.467984f, 0.387365f, 0.418956f, 0.398468f, 0.422649f, 0.373341f,
307 0.532016f, 0.387365f, 0.500000f, 0.382860f, 0.500000f, 0.340417f, 0.539817f, 0.354339f,
308 0.500000f, 0.340417f, 0.500000f, 0.382860f, 0.467984f, 0.387365f, 0.460183f, 0.354339f,
309 0.559135f, 0.334326f, 0.579057f, 0.335646f, 0.577351f, 0.373341f, 0.539817f, 0.354339f,
310 0.422649f, 0.373341f, 0.420943f, 0.335646f, 0.440865f, 0.334326f, 0.460183f, 0.354339f,
311 0.579057f, 0.335646f, 0.592090f, 0.332885f, 0.594178f, 0.371277f, 0.577351f, 0.373341f,
312 0.405822f, 0.371277f, 0.407910f, 0.332885f, 0.420943f, 0.335646f, 0.422649f, 0.373341f,
313 0.606163f, 0.325516f, 0.613636f, 0.353108f, 0.594178f, 0.371277f, 0.592090f, 0.332885f,
314 0.405822f, 0.371277f, 0.386364f, 0.353108f, 0.393837f, 0.325516f, 0.407910f, 0.332885f,
315 0.628251f, 0.311636f, 0.649107f, 0.322437f, 0.613636f, 0.353108f, 0.606163f, 0.325516f,
316 0.386364f, 0.353108f, 0.350893f, 0.322437f, 0.371749f, 0.311636f, 0.393837f, 0.325516f,
317 0.635551f, 0.300507f, 0.659507f, 0.313152f, 0.649107f, 0.322437f, 0.628251f, 0.311636f,
318 0.350893f, 0.322437f, 0.340493f, 0.313152f, 0.364449f, 0.300507f, 0.371749f, 0.311636f,
319 0.631484f, 0.283889f, 0.655896f, 0.284413f, 0.659507f, 0.313152f, 0.635551f, 0.300507f,
320 0.340493f, 0.313152f, 0.344104f, 0.284413f, 0.368516f, 0.283889f, 0.364449f, 0.300507f,
321 0.611331f, 0.264411f, 0.636962f, 0.261221f, 0.655896f, 0.284413f, 0.631484f, 0.283889f,
322 0.344104f, 0.284413f, 0.363038f, 0.261221f, 0.388669f, 0.264411f, 0.368516f, 0.283889f,
323 0.592372f, 0.254897f, 0.600470f, 0.238288f, 0.636962f, 0.261221f, 0.611331f, 0.264411f,
324 0.363038f, 0.261221f, 0.399530f, 0.238288f, 0.407628f, 0.254897f, 0.388669f, 0.264411f,
325 0.559669f, 0.267717f, 0.535885f, 0.215568f, 0.600470f, 0.238288f, 0.592372f, 0.254897f,
326 0.399530f, 0.238288f, 0.464115f, 0.215568f, 0.440331f, 0.267717f, 0.407628f, 0.254897f,
327 0.559669f, 0.267717f, 0.550878f, 0.277832f, 0.500000f, 0.252445f, 0.535885f, 0.215568f,
328 0.500000f, 0.252445f, 0.449122f, 0.277832f, 0.440331f, 0.267717f, 0.464115f, 0.215568f,
329 0.559135f, 0.334326f, 0.539817f, 0.354339f, 0.500000f, 0.340417f, 0.544001f, 0.314523f,
330 0.500000f, 0.340417f, 0.460183f, 0.354339f, 0.440865f, 0.334326f, 0.455999f, 0.314523f,
331 0.544001f, 0.314523f, 0.500000f, 0.340417f, 0.500000f, 0.295691f, 0.543637f, 0.293371f,
332 0.500000f, 0.295691f, 0.500000f, 0.340417f, 0.455999f, 0.314523f, 0.456363f, 0.293371f,
333 0.500000f, 0.252445f, 0.550878f, 0.277832f, 0.543637f, 0.293371f, 0.500000f, 0.295691f,
334 0.456363f, 0.293371f, 0.449122f, 0.277832f, 0.500000f, 0.252445f, 0.500000f, 0.295691f,
335 0.506819f, 0.075382f, 0.500000f, 0.073497f, 0.500000f, 0.064527f, 0.517028f, 0.068490f,
336 0.500000f, 0.064527f, 0.500000f, 0.073497f, 0.493181f, 0.075382f, 0.482972f, 0.068490f,
337 0.511782f, 0.080633f, 0.506819f, 0.075382f, 0.517028f, 0.068490f, 0.522612f, 0.070678f,
338 0.482972f, 0.068490f, 0.493181f, 0.075382f, 0.488218f, 0.080633f, 0.477388f, 0.070678f,
339 0.512172f, 0.093457f, 0.511782f, 0.080633f, 0.522612f, 0.070678f, 0.526301f, 0.079422f,
340 0.477388f, 0.070678f, 0.488218f, 0.080633f, 0.487828f, 0.093457f, 0.473699f, 0.079422f,
341 0.537536f, 0.127779f, 0.514257f, 0.133422f, 0.513874f, 0.097191f, 0.529228f, 0.091098f,
342 0.486126f, 0.097191f, 0.485743f, 0.133422f, 0.462464f, 0.127779f, 0.470772f, 0.091098f,
343 0.512172f, 0.093457f, 0.526301f, 0.079422f, 0.529228f, 0.091098f, 0.513874f, 0.097191f,
344 0.470772f, 0.091098f, 0.473699f, 0.079422f, 0.487828f, 0.093457f, 0.486126f, 0.097191f,
345 0.520226f, 0.164615f, 0.500000f, 0.157864f, 0.500000f, 0.134352f, 0.514257f, 0.133422f,
346 0.500000f, 0.134352f, 0.500000f, 0.157864f, 0.479774f, 0.164615f, 0.485743f, 0.133422f,
347 0.513874f, 0.097191f, 0.514257f, 0.133422f, 0.500000f, 0.134352f, 0.500000f, 0.100063f,
348 0.500000f, 0.134352f, 0.485743f, 0.133422f, 0.486126f, 0.097191f, 0.500000f, 0.100063f,
349 0.500000f, 0.091346f, 0.512172f, 0.093457f, 0.513874f, 0.097191f, 0.500000f, 0.100063f,
350 0.486126f, 0.097191f, 0.487828f, 0.093457f, 0.500000f, 0.091346f, 0.500000f, 0.100063f,
351 0.530258f, 0.180239f, 0.521901f, 0.181560f, 0.517666f, 0.172353f, 0.520226f, 0.164615f,
352 0.482334f, 0.172353f, 0.478099f, 0.181560f, 0.469742f, 0.180239f, 0.479774f, 0.164615f,
353 0.523673f, 0.198817f, 0.518957f, 0.194728f, 0.521901f, 0.181560f, 0.530258f, 0.180239f,
354 0.478099f, 0.181560f, 0.481043f, 0.194728f, 0.476327f, 0.198817f, 0.469742f, 0.180239f,
355 0.500000f, 0.203867f, 0.508211f, 0.197295f, 0.518957f, 0.194728f, 0.523673f, 0.198817f,
356 0.481043f, 0.194728f, 0.491789f, 0.197295f, 0.500000f, 0.203867f, 0.476327f, 0.198817f,
357 0.500000f, 0.197278f, 0.500000f, 0.192167f, 0.508211f, 0.197295f, 0.500000f, 0.203867f,
358 0.491789f, 0.197295f, 0.500000f, 0.192167f, 0.500000f, 0.197278f, 0.500000f, 0.203867f,
359 0.500000f, 0.157864f, 0.520226f, 0.164615f, 0.517666f, 0.172353f, 0.500000f, 0.165170f,
360 0.482334f, 0.172353f, 0.479774f, 0.164615f, 0.500000f, 0.157864f, 0.500000f, 0.165170f,
361 0.500000f, 0.165170f, 0.517666f, 0.172353f, 0.513538f, 0.176949f, 0.500000f, 0.171718f,
362 0.486462f, 0.176949f, 0.482334f, 0.172353f, 0.500000f, 0.165170f, 0.500000f, 0.171718f,
363 0.500000f, 0.192167f, 0.500000f, 0.186182f, 0.508818f, 0.192407f, 0.508211f, 0.197295f,
364 0.491182f, 0.192407f, 0.500000f, 0.186182f, 0.500000f, 0.192167f, 0.491789f, 0.197295f,
365 0.508211f, 0.197295f, 0.508818f, 0.192407f, 0.515232f, 0.190709f, 0.518957f, 0.194728f,
366 0.484768f, 0.190709f, 0.491182f, 0.192407f, 0.491789f, 0.197295f, 0.481043f, 0.194728f,
367 0.518957f, 0.194728f, 0.515232f, 0.190709f, 0.516908f, 0.181873f, 0.521901f, 0.181560f,
368 0.483092f, 0.181873f, 0.484768f, 0.190709f, 0.481043f, 0.194728f, 0.478099f, 0.181560f,
369 0.521901f, 0.181560f, 0.516908f, 0.181873f, 0.513538f, 0.176949f, 0.517666f, 0.172353f,
370 0.486462f, 0.176949f, 0.483092f, 0.181873f, 0.478099f, 0.181560f, 0.482334f, 0.172353f,
371 0.500000f, 0.186182f, 0.516908f, 0.181873f, 0.515232f, 0.190709f, 0.508818f, 0.192407f,
372 0.484768f, 0.190709f, 0.483092f, 0.181873f, 0.500000f, 0.186182f, 0.491182f, 0.192407f,
373 0.500000f, 0.186182f, 0.500000f, 0.171718f, 0.513538f, 0.176949f, 0.516908f, 0.181873f,
374 0.486462f, 0.176949f, 0.500000f, 0.171718f, 0.500000f, 0.186182f, 0.483092f, 0.181873f,
375 0.500000f, 0.203867f, 0.523673f, 0.198817f, 0.535885f, 0.215568f, 0.500000f, 0.252445f,
376 0.464115f, 0.215568f, 0.476327f, 0.198817f, 0.500000f, 0.203867f, 0.500000f, 0.252445f,
377 0.523673f, 0.198817f, 0.530258f, 0.180239f, 0.544209f, 0.172814f, 0.535885f, 0.215568f,
378 0.455791f, 0.172814f, 0.469742f, 0.180239f, 0.476327f, 0.198817f, 0.464115f, 0.215568f,
379 0.530258f, 0.180239f, 0.520226f, 0.164615f, 0.541327f, 0.154899f, 0.544209f, 0.172814f,
380 0.458673f, 0.154899f, 0.479774f, 0.164615f, 0.469742f, 0.180239f, 0.455791f, 0.172814f,
381 0.520226f, 0.164615f, 0.514257f, 0.133422f, 0.537536f, 0.127779f, 0.541327f, 0.154899f,
382 0.462464f, 0.127779f, 0.485743f, 0.133422f, 0.479774f, 0.164615f, 0.458673f, 0.154899f,
383 0.565647f, 0.115495f, 0.578661f, 0.139176f, 0.541327f, 0.154899f, 0.537536f, 0.127779f,
384 0.458673f, 0.154899f, 0.421339f, 0.139176f, 0.434353f, 0.115495f, 0.462464f, 0.127779f,
385 0.578661f, 0.139176f, 0.583245f, 0.154155f, 0.544209f, 0.172814f, 0.541327f, 0.154899f,
386 0.455791f, 0.172814f, 0.416755f, 0.154155f, 0.421339f, 0.139176f, 0.458673f, 0.154899f,
387 0.586916f, 0.172042f, 0.535885f, 0.215568f, 0.544209f, 0.172814f, 0.583245f, 0.154155f,
388 0.455791f, 0.172814f, 0.464115f, 0.215568f, 0.413084f, 0.172042f, 0.416755f, 0.154155f,
389 0.512172f, 0.093457f, 0.500000f, 0.091346f, 0.500000f, 0.089977f, 0.509911f, 0.090724f,
390 0.500000f, 0.089977f, 0.500000f, 0.091346f, 0.487828f, 0.093457f, 0.490089f, 0.090724f,
391 0.511782f, 0.080633f, 0.512172f, 0.093457f, 0.509911f, 0.090724f, 0.509713f, 0.082236f,
392 0.490089f, 0.090724f, 0.487828f, 0.093457f, 0.488218f, 0.080633f, 0.490287f, 0.082236f,
393 0.506819f, 0.075382f, 0.511782f, 0.080633f, 0.509713f, 0.082236f, 0.505196f, 0.077083f,
394 0.490287f, 0.082236f, 0.488218f, 0.080633f, 0.493181f, 0.075382f, 0.494804f, 0.077083f,
395 0.500000f, 0.073497f, 0.506819f, 0.075382f, 0.505196f, 0.077083f, 0.500000f, 0.075473f,
396 0.494804f, 0.077083f, 0.493181f, 0.075382f, 0.500000f, 0.073497f, 0.500000f, 0.075473f,
397 0.500000f, 0.075473f, 0.505196f, 0.077083f, 0.503445f, 0.080840f, 0.500000f, 0.080320f,
398 0.496555f, 0.080840f, 0.494804f, 0.077083f, 0.500000f, 0.075473f, 0.500000f, 0.080320f,
399 0.505196f, 0.077083f, 0.509713f, 0.082236f, 0.506660f, 0.083289f, 0.503445f, 0.080840f,
400 0.493340f, 0.083289f, 0.490287f, 0.082236f, 0.494804f, 0.077083f, 0.496555f, 0.080840f,
401 0.509713f, 0.082236f, 0.509911f, 0.090724f, 0.506822f, 0.086791f, 0.506660f, 0.083289f,
402 0.493178f, 0.086791f, 0.490089f, 0.090724f, 0.490287f, 0.082236f, 0.493340f, 0.083289f,
403 0.509911f, 0.090724f, 0.500000f, 0.089977f, 0.500000f, 0.085637f, 0.506822f, 0.086791f,
404 0.500000f, 0.085637f, 0.500000f, 0.089977f, 0.490089f, 0.090724f, 0.493178f, 0.086791f,
405 0.500000f, 0.085637f, 0.500000f, 0.080320f, 0.503445f, 0.080840f, 0.506822f, 0.086791f,
406 0.496555f, 0.080840f, 0.500000f, 0.080320f, 0.500000f, 0.085637f, 0.493178f, 0.086791f,
407 0.506822f, 0.086791f, 0.503445f, 0.080840f, 0.506660f, 0.083289f, 0.493340f, 0.083289f,
408 0.496555f, 0.080840f, 0.493178f, 0.086791f, 0.543637f, 0.293371f, 0.550878f, 0.277832f,
409 0.562361f, 0.284338f, 0.559190f, 0.294882f, 0.437639f, 0.284338f, 0.449122f, 0.277832f,
410 0.456363f, 0.293371f, 0.440810f, 0.294882f, 0.544001f, 0.314523f, 0.543637f, 0.293371f,
411 0.559190f, 0.294882f, 0.563180f, 0.307151f, 0.440810f, 0.294882f, 0.456363f, 0.293371f,
412 0.455999f, 0.314523f, 0.436820f, 0.307151f, 0.559135f, 0.334326f, 0.544001f, 0.314523f,
413 0.563180f, 0.307151f, 0.570458f, 0.318697f, 0.436820f, 0.307151f, 0.455999f, 0.314523f,
414 0.440865f, 0.334326f, 0.429542f, 0.318697f, 0.550878f, 0.277832f, 0.559669f, 0.267717f,
415 0.569243f, 0.278245f, 0.562361f, 0.284338f, 0.430757f, 0.278245f, 0.440331f, 0.267717f,
416 0.449122f, 0.277832f, 0.437639f, 0.284338f, 0.559669f, 0.267717f, 0.592372f, 0.254897f,
417 0.589914f, 0.271772f, 0.569243f, 0.278245f, 0.410086f, 0.271772f, 0.407628f, 0.254897f,
418 0.440331f, 0.267717f, 0.430757f, 0.278245f, 0.592372f, 0.254897f, 0.611331f, 0.264411f,
419 0.602190f, 0.277180f, 0.589914f, 0.271772f, 0.397810f, 0.277180f, 0.388669f, 0.264411f,
420 0.407628f, 0.254897f, 0.410086f, 0.271772f, 0.611331f, 0.264411f, 0.631484f, 0.283889f,
421 0.617110f, 0.287175f, 0.602190f, 0.277180f, 0.382890f, 0.287175f, 0.368516f, 0.283889f,
422 0.388669f, 0.264411f, 0.397810f, 0.277180f, 0.631484f, 0.283889f, 0.635551f, 0.300507f,
423 0.618074f, 0.299197f, 0.617110f, 0.287175f, 0.381926f, 0.299197f, 0.364449f, 0.300507f,
424 0.368516f, 0.283889f, 0.382890f, 0.287175f, 0.635551f, 0.300507f, 0.628251f, 0.311636f,
425 0.615871f, 0.307438f, 0.618074f, 0.299197f, 0.384129f, 0.307438f, 0.371749f, 0.311636f,
426 0.364449f, 0.300507f, 0.381926f, 0.299197f, 0.628251f, 0.311636f, 0.606163f, 0.325516f,
427 0.598424f, 0.313725f, 0.615871f, 0.307438f, 0.401576f, 0.313725f, 0.393837f, 0.325516f,
428 0.371749f, 0.311636f, 0.384129f, 0.307438f, 0.606163f, 0.325516f, 0.592090f, 0.332885f,
429 0.590828f, 0.319797f, 0.598424f, 0.313725f, 0.409172f, 0.319797f, 0.407910f, 0.332885f,
430 0.393837f, 0.325516f, 0.401576f, 0.313725f, 0.592090f, 0.332885f, 0.579057f, 0.335646f,
431 0.582130f, 0.320991f, 0.590828f, 0.319797f, 0.417870f, 0.320991f, 0.420943f, 0.335646f,
432 0.407910f, 0.332885f, 0.409172f, 0.319797f, 0.579057f, 0.335646f, 0.559135f, 0.334326f,
433 0.570458f, 0.318697f, 0.582130f, 0.320991f, 0.429542f, 0.318697f, 0.440865f, 0.334326f,
434 0.420943f, 0.335646f, 0.417870f, 0.320991f, 0.582130f, 0.320991f, 0.570458f, 0.318697f,
435 0.578615f, 0.309394f, 0.583998f, 0.312892f, 0.421385f, 0.309394f, 0.429542f, 0.318697f,
436 0.417870f, 0.320991f, 0.416002f, 0.312892f, 0.590828f, 0.319797f, 0.582130f, 0.320991f,
437 0.583998f, 0.312892f, 0.589656f, 0.312336f, 0.416002f, 0.312892f, 0.417870f, 0.320991f,
438 0.409172f, 0.319797f, 0.410344f, 0.312336f, 0.598424f, 0.313725f, 0.590828f, 0.319797f,
439 0.589656f, 0.312336f, 0.596347f, 0.309249f, 0.410344f, 0.312336f, 0.409172f, 0.319797f,
440 0.401576f, 0.313725f, 0.403653f, 0.309249f, 0.615871f, 0.307438f, 0.598424f, 0.313725f,
441 0.596347f, 0.309249f, 0.606014f, 0.302517f, 0.403653f, 0.309249f, 0.401576f, 0.313725f,
442 0.384129f, 0.307438f, 0.393986f, 0.302517f, 0.618074f, 0.299197f, 0.615871f, 0.307438f,
443 0.606014f, 0.302517f, 0.607735f, 0.297520f, 0.393986f, 0.302517f, 0.384129f, 0.307438f,
444 0.381926f, 0.299197f, 0.392265f, 0.297520f, 0.617110f, 0.287175f, 0.618074f, 0.299197f,
445 0.607735f, 0.297520f, 0.606985f, 0.291216f, 0.392265f, 0.297520f, 0.381926f, 0.299197f,
446 0.382890f, 0.287175f, 0.393015f, 0.291216f, 0.602190f, 0.277180f, 0.617110f, 0.287175f,
447 0.606985f, 0.291216f, 0.598275f, 0.283083f, 0.393015f, 0.291216f, 0.382890f, 0.287175f,
448 0.397810f, 0.277180f, 0.401725f, 0.283083f, 0.589914f, 0.271772f, 0.602190f, 0.277180f,
449 0.598275f, 0.283083f, 0.589866f, 0.280167f, 0.401725f, 0.283083f, 0.397810f, 0.277180f,
450 0.410086f, 0.271772f, 0.410134f, 0.280167f, 0.569243f, 0.278245f, 0.589914f, 0.271772f,
451 0.589866f, 0.280167f, 0.576352f, 0.284624f, 0.410134f, 0.280167f, 0.410086f, 0.271772f,
452 0.430757f, 0.278245f, 0.423648f, 0.284624f, 0.562361f, 0.284338f, 0.569243f, 0.278245f,
453 0.576352f, 0.284624f, 0.572831f, 0.289915f, 0.423648f, 0.284624f, 0.430757f, 0.278245f,
454 0.437639f, 0.284338f, 0.427169f, 0.289915f, 0.570458f, 0.318697f, 0.563180f, 0.307151f,
455 0.573307f, 0.303342f, 0.578615f, 0.309394f, 0.426693f, 0.303342f, 0.436820f, 0.307151f,
456 0.429542f, 0.318697f, 0.421385f, 0.309394f, 0.563180f, 0.307151f, 0.559190f, 0.294882f,
457 0.572447f, 0.295716f, 0.573307f, 0.303342f, 0.427553f, 0.295716f, 0.440810f, 0.294882f,
458 0.436820f, 0.307151f, 0.426693f, 0.303342f, 0.559190f, 0.294882f, 0.562361f, 0.284338f,
459 0.572831f, 0.289915f, 0.572447f, 0.295716f, 0.427169f, 0.289915f, 0.437639f, 0.284338f,
460 0.440810f, 0.294882f, 0.427553f, 0.295716f, 0.500000f, 0.382860f, 0.532016f, 0.387365f,
461 0.529647f, 0.428636f, 0.500000f, 0.428636f, 0.470353f, 0.428636f, 0.467984f, 0.387365f,
462 0.500000f, 0.382860f, 0.500000f, 0.428636f, 0.532016f, 0.387365f, 0.581044f, 0.398468f,
463 0.584616f, 0.428636f, 0.529647f, 0.428636f, 0.415384f, 0.428636f, 0.418956f, 0.398468f,
464 0.467984f, 0.387365f, 0.470353f, 0.428636f, 0.581044f, 0.398468f, 0.602261f, 0.395588f,
465 0.622301f, 0.417889f, 0.584616f, 0.428636f, 0.377699f, 0.417889f, 0.397739f, 0.395588f,
466 0.418956f, 0.398468f, 0.415384f, 0.428636f, 0.602261f, 0.395588f, 0.636775f, 0.370732f,
467 0.666214f, 0.388954f, 0.622301f, 0.417889f, 0.333786f, 0.388954f, 0.363225f, 0.370732f,
468 0.397739f, 0.395588f, 0.377699f, 0.417889f, 0.636775f, 0.370732f, 0.671357f, 0.334694f,
469 0.701481f, 0.344467f, 0.666214f, 0.388954f, 0.298519f, 0.344467f, 0.328643f, 0.334694f,
470 0.363225f, 0.370732f, 0.333786f, 0.388954f, 0.671357f, 0.334694f, 0.684517f, 0.317795f,
471 0.712163f, 0.315527f, 0.701481f, 0.344467f, 0.287837f, 0.315527f, 0.315483f, 0.317795f,
472 0.328643f, 0.334694f, 0.298519f, 0.344467f, 0.684517f, 0.317795f, 0.689501f, 0.268805f,
473 0.704305f, 0.260225f, 0.712163f, 0.315527f, 0.295695f, 0.260225f, 0.310499f, 0.268805f,
474 0.315483f, 0.317795f, 0.287837f, 0.315527f, 0.689501f, 0.268805f, 0.650908f, 0.240294f,
475 0.672947f, 0.224880f, 0.704305f, 0.260225f, 0.327053f, 0.224880f, 0.349092f, 0.240294f,
476 0.310499f, 0.268805f, 0.295695f, 0.260225f, 0.650908f, 0.240294f, 0.626605f, 0.208159f,
477 0.640497f, 0.198841f, 0.672947f, 0.224880f, 0.359503f, 0.198841f, 0.373395f, 0.208159f,
478 0.349092f, 0.240294f, 0.327053f, 0.224880f, 0.603553f, 0.023452f, 0.625128f, 0.029461f,
479 0.635753f, 0.082198f, 0.598617f, 0.056841f, 0.364247f, 0.082198f, 0.374872f, 0.029461f,
480 0.396447f, 0.023452f, 0.401383f, 0.056841f, 0.546781f, 0.009442f, 0.603553f, 0.023452f,
481 0.598617f, 0.056841f, 0.556354f, 0.040906f, 0.401383f, 0.056841f, 0.396447f, 0.023452f,
482 0.453219f, 0.009442f, 0.443646f, 0.040906f, 0.500000f, 0.033223f, 0.546781f, 0.009442f,
483 0.556354f, 0.040906f, 0.527159f, 0.049514f, 0.443646f, 0.040906f, 0.453219f, 0.009442f,
484 0.500000f, 0.033223f, 0.472841f, 0.049514f, 0.520711f, 0.060503f, 0.500000f, 0.054411f,
485 0.500000f, 0.033223f, 0.527159f, 0.049514f, 0.500000f, 0.033223f, 0.500000f, 0.054411f,
486 0.479289f, 0.060503f, 0.472841f, 0.049514f, 0.530457f, 0.065062f, 0.520711f, 0.060503f,
487 0.527159f, 0.049514f, 0.537222f, 0.060794f, 0.472841f, 0.049514f, 0.479289f, 0.060503f,
488 0.469543f, 0.065062f, 0.462778f, 0.060794f, 0.532878f, 0.067822f, 0.530457f, 0.065062f,
489 0.537222f, 0.060794f, 0.558499f, 0.065137f, 0.462778f, 0.060794f, 0.469543f, 0.065062f,
490 0.467122f, 0.067822f, 0.441501f, 0.065137f, 0.544695f, 0.083023f, 0.532878f, 0.067822f,
491 0.558499f, 0.065137f, 0.588127f, 0.085177f, 0.441501f, 0.065137f, 0.467122f, 0.067822f,
492 0.455305f, 0.083023f, 0.411873f, 0.085177f, 0.558499f, 0.065137f, 0.556354f, 0.040906f,
493 0.598617f, 0.056841f, 0.588127f, 0.085177f, 0.401383f, 0.056841f, 0.443646f, 0.040906f,
494 0.441501f, 0.065137f, 0.411873f, 0.085177f, 0.558499f, 0.065137f, 0.537222f, 0.060794f,
495 0.527159f, 0.049514f, 0.556354f, 0.040906f, 0.472841f, 0.049514f, 0.462778f, 0.060794f,
496 0.441501f, 0.065137f, 0.443646f, 0.040906f, 0.607239f, 0.113940f, 0.588127f, 0.085177f,
497 0.598617f, 0.056841f, 0.635753f, 0.082198f, 0.401383f, 0.056841f, 0.411873f, 0.085177f,
498 0.392761f, 0.113940f, 0.364247f, 0.082198f, 0.565647f, 0.115495f, 0.544695f, 0.083023f,
499 0.588127f, 0.085177f, 0.607239f, 0.113940f, 0.411873f, 0.085177f, 0.455305f, 0.083023f,
500 0.434353f, 0.115495f, 0.392761f, 0.113940f, 0.578661f, 0.139176f, 0.612663f, 0.133675f,
501 0.605467f, 0.151503f, 0.583245f, 0.154155f, 0.394533f, 0.151503f, 0.387337f, 0.133675f,
502 0.421339f, 0.139176f, 0.416755f, 0.154155f, 0.565647f, 0.115495f, 0.607239f, 0.113940f,
503 0.612663f, 0.133675f, 0.578661f, 0.139176f, 0.387337f, 0.133675f, 0.392761f, 0.113940f,
504 0.434353f, 0.115495f, 0.421339f, 0.139176f, 0.586916f, 0.172042f, 0.583245f, 0.154155f,
505 0.605467f, 0.151503f, 0.600708f, 0.162985f, 0.394533f, 0.151503f, 0.416755f, 0.154155f,
506 0.413084f, 0.172042f, 0.399292f, 0.162985f, 0.586916f, 0.172042f, 0.600708f, 0.162985f,
507 0.640497f, 0.198841f, 0.626605f, 0.208159f, 0.359503f, 0.198841f, 0.399292f, 0.162985f,
508 0.413084f, 0.172042f, 0.373395f, 0.208159f, 0.922374f, 0.064228f, 0.859647f, 0.117994f,
509 0.823287f, 0.101559f, 0.861342f, 0.027230f, 0.176713f, 0.101559f, 0.140353f, 0.117994f,
510 0.077626f, 0.064228f, 0.138658f, 0.027230f, 0.861342f, 0.027230f, 0.823287f, 0.101559f,
511 0.765863f, 0.087001f, 0.774604f, 0.010837f, 0.234137f, 0.087001f, 0.176713f, 0.101559f,
512 0.138658f, 0.027230f, 0.225396f, 0.010837f, 0.774604f, 0.010837f, 0.765863f, 0.087001f,
513 0.661952f, 0.087561f, 0.647010f, 0.028716f, 0.338048f, 0.087561f, 0.234137f, 0.087001f,
514 0.225396f, 0.010837f, 0.352990f, 0.028716f, 0.647010f, 0.028716f, 0.661952f, 0.087561f,
515 0.635753f, 0.082198f, 0.625128f, 0.029461f, 0.364247f, 0.082198f, 0.338048f, 0.087561f,
516 0.352990f, 0.028716f, 0.374872f, 0.029461f, 0.607239f, 0.113940f, 0.635753f, 0.082198f,
517 0.661952f, 0.087561f, 0.612663f, 0.133675f, 0.338048f, 0.087561f, 0.364247f, 0.082198f,
518 0.392761f, 0.113940f, 0.387337f, 0.133675f, 0.704305f, 0.260225f, 0.672947f, 0.224880f,
519 0.743592f, 0.198572f, 0.766410f, 0.233065f, 0.256408f, 0.198572f, 0.327053f, 0.224880f,
520 0.295695f, 0.260225f, 0.233590f, 0.233065f, 0.987633f, 0.154243f, 0.889478f, 0.177602f,
521 0.859647f, 0.117994f, 0.922374f, 0.064228f, 0.140353f, 0.117994f, 0.110522f, 0.177602f,
522 0.012367f, 0.154243f, 0.077626f, 0.064228f, 0.899807f, 0.420886f, 0.844317f, 0.347370f,
523 0.881169f, 0.309153f, 0.958963f, 0.357385f, 0.118831f, 0.309153f, 0.155683f, 0.347370f,
524 0.100193f, 0.420886f, 0.041037f, 0.357385f, 0.958963f, 0.357385f, 0.881169f, 0.309153f,
525 0.903302f, 0.261367f, 0.999860f, 0.253531f, 0.096698f, 0.261367f, 0.118831f, 0.309153f,
526 0.041037f, 0.357385f, 0.000140f, 0.253531f, 0.999860f, 0.253531f, 0.903302f, 0.261367f,
527 0.889478f, 0.177602f, 0.987633f, 0.154243f, 0.110522f, 0.177602f, 0.096698f, 0.261367f,
528 0.000140f, 0.253531f, 0.012367f, 0.154243f, 0.724763f, 0.340212f, 0.712163f, 0.315527f,
529 0.744725f, 0.304629f, 0.766113f, 0.319494f, 0.255275f, 0.304629f, 0.287837f, 0.315527f,
530 0.275237f, 0.340212f, 0.233887f, 0.319494f, 0.766113f, 0.319494f, 0.744725f, 0.304629f,
531 0.793427f, 0.280495f, 0.826663f, 0.297810f, 0.206573f, 0.280495f, 0.255275f, 0.304629f,
532 0.233887f, 0.319494f, 0.173337f, 0.297810f, 0.826663f, 0.297810f, 0.793427f, 0.280495f,
533 0.823620f, 0.254612f, 0.855331f, 0.267956f, 0.176380f, 0.254612f, 0.206573f, 0.280495f,
534 0.173337f, 0.297810f, 0.144669f, 0.267956f, 0.855331f, 0.267956f, 0.823620f, 0.254612f,
535 0.835860f, 0.225225f, 0.868309f, 0.233525f, 0.164140f, 0.225225f, 0.176380f, 0.254612f,
536 0.144669f, 0.267956f, 0.131691f, 0.233525f, 0.813499f, 0.190705f, 0.851288f, 0.181145f,
537 0.868309f, 0.233525f, 0.835860f, 0.225225f, 0.131691f, 0.233525f, 0.148712f, 0.181145f,
538 0.186501f, 0.190705f, 0.164140f, 0.225225f, 0.889478f, 0.177602f, 0.903302f, 0.261367f,
539 0.868309f, 0.233525f, 0.851288f, 0.181145f, 0.131691f, 0.233525f, 0.096698f, 0.261367f,
540 0.110522f, 0.177602f, 0.148712f, 0.181145f, 0.903302f, 0.261367f, 0.881169f, 0.309153f,
541 0.855331f, 0.267956f, 0.868309f, 0.233525f, 0.144669f, 0.267956f, 0.118831f, 0.309153f,
542 0.096698f, 0.261367f, 0.131691f, 0.233525f, 0.881169f, 0.309153f, 0.844317f, 0.347370f,
543 0.826663f, 0.297810f, 0.855331f, 0.267956f, 0.173337f, 0.297810f, 0.155683f, 0.347370f,
544 0.118831f, 0.309153f, 0.144669f, 0.267956f, 0.844317f, 0.347370f, 0.772263f, 0.374010f,
545 0.766113f, 0.319494f, 0.826663f, 0.297810f, 0.233887f, 0.319494f, 0.227737f, 0.374010f,
546 0.155683f, 0.347370f, 0.173337f, 0.297810f, 0.744519f, 0.390057f, 0.724763f, 0.340212f,
547 0.766113f, 0.319494f, 0.772263f, 0.374010f, 0.233887f, 0.319494f, 0.275237f, 0.340212f,
548 0.255481f, 0.390057f, 0.227737f, 0.374010f, 0.824765f, 0.470987f, 0.772263f, 0.374010f,
549 0.844317f, 0.347370f, 0.899807f, 0.420886f, 0.155683f, 0.347370f, 0.227737f, 0.374010f,
550 0.175235f, 0.470987f, 0.100193f, 0.420886f, 0.792141f, 0.464714f, 0.742181f, 0.461543f,
551 0.726855f, 0.432574f, 0.744519f, 0.390057f, 0.273145f, 0.432574f, 0.257819f, 0.461543f,
552 0.207859f, 0.464714f, 0.255481f, 0.390057f, 0.792141f, 0.464714f, 0.744519f, 0.390057f,
553 0.772263f, 0.374010f, 0.824765f, 0.470987f, 0.227737f, 0.374010f, 0.255481f, 0.390057f,
554 0.207859f, 0.464714f, 0.175235f, 0.470987f, 0.795638f, 0.489991f, 0.792141f, 0.464714f,
555 0.824765f, 0.470987f, 0.175235f, 0.470987f, 0.207859f, 0.464714f, 0.204362f, 0.489991f,
556 0.712163f, 0.315527f, 0.704305f, 0.260225f, 0.766410f, 0.233065f, 0.744725f, 0.304629f,
557 0.233590f, 0.233065f, 0.295695f, 0.260225f, 0.287837f, 0.315527f, 0.255275f, 0.304629f,
558 0.766410f, 0.233065f, 0.786137f, 0.227788f, 0.793427f, 0.280495f, 0.744725f, 0.304629f,
559 0.206573f, 0.280495f, 0.213863f, 0.227788f, 0.233590f, 0.233065f, 0.255275f, 0.304629f,
560 0.786137f, 0.227788f, 0.802950f, 0.203415f, 0.823620f, 0.254612f, 0.793427f, 0.280495f,
561 0.176380f, 0.254612f, 0.197050f, 0.203415f, 0.213863f, 0.227788f, 0.206573f, 0.280495f,
562 0.813499f, 0.190705f, 0.835860f, 0.225225f, 0.823620f, 0.254612f, 0.802950f, 0.203415f,
563 0.176380f, 0.254612f, 0.164140f, 0.225225f, 0.186501f, 0.190705f, 0.197050f, 0.203415f,
564 0.661952f, 0.087561f, 0.765863f, 0.087001f, 0.769334f, 0.128771f, 0.691484f, 0.146686f,
565 0.230666f, 0.128771f, 0.234137f, 0.087001f, 0.338048f, 0.087561f, 0.308516f, 0.146686f,
566 0.743592f, 0.198572f, 0.691484f, 0.146686f, 0.769334f, 0.128771f, 0.780113f, 0.169386f,
567 0.230666f, 0.128771f, 0.308516f, 0.146686f, 0.256408f, 0.198572f, 0.219887f, 0.169386f,
568 0.672947f, 0.224880f, 0.640497f, 0.198841f, 0.691484f, 0.146686f, 0.743592f, 0.198572f,
569 0.308516f, 0.146686f, 0.359503f, 0.198841f, 0.327053f, 0.224880f, 0.256408f, 0.198572f,
570 0.640497f, 0.198841f, 0.605467f, 0.151503f, 0.612663f, 0.133675f, 0.691484f, 0.146686f,
571 0.387337f, 0.133675f, 0.394533f, 0.151503f, 0.359503f, 0.198841f, 0.308516f, 0.146686f,
572 0.612663f, 0.133675f, 0.661952f, 0.087561f, 0.691484f, 0.146686f, 0.308516f, 0.146686f,
573 0.338048f, 0.087561f, 0.387337f, 0.133675f, 0.640497f, 0.198841f, 0.600708f, 0.162985f,
574 0.605467f, 0.151503f, 0.394533f, 0.151503f, 0.399292f, 0.162985f, 0.359503f, 0.198841f,
575 0.813499f, 0.190705f, 0.803789f, 0.171181f, 0.830917f, 0.139518f, 0.851288f, 0.181145f,
576 0.169083f, 0.139518f, 0.196211f, 0.171181f, 0.186501f, 0.190705f, 0.148712f, 0.181145f,
577 0.889478f, 0.177602f, 0.851288f, 0.181145f, 0.830917f, 0.139518f, 0.859647f, 0.117994f,
578 0.169083f, 0.139518f, 0.148712f, 0.181145f, 0.110522f, 0.177602f, 0.140353f, 0.117994f,
579 0.780113f, 0.169386f, 0.769334f, 0.128771f, 0.830917f, 0.139518f, 0.803789f, 0.171181f,
580 0.169083f, 0.139518f, 0.230666f, 0.128771f, 0.219887f, 0.169386f, 0.196211f, 0.171181f,
581 0.765863f, 0.087001f, 0.823287f, 0.101559f, 0.830917f, 0.139518f, 0.769334f, 0.128771f,
582 0.169083f, 0.139518f, 0.176713f, 0.101559f, 0.234137f, 0.087001f, 0.230666f, 0.128771f,
583 0.859647f, 0.117994f, 0.830917f, 0.139518f, 0.823287f, 0.101559f, 0.176713f, 0.101559f,
584 0.169083f, 0.139518f, 0.140353f, 0.117994f, 0.574628f, 0.959188f, 0.464516f, 0.959188f,
585 0.477326f, 0.891852f, 0.545439f, 0.884582f, 0.272900f, 0.891852f, 0.285710f, 0.959188f,
586 0.175598f, 0.959188f, 0.204787f, 0.884582f, 0.574628f, 0.959188f, 0.545439f, 0.884582f,
587 0.605134f, 0.846978f, 0.715894f, 0.897069f, 0.145092f, 0.846978f, 0.204787f, 0.884582f,
588 0.175598f, 0.959188f, 0.034332f, 0.897069f, 0.715894f, 0.897069f, 0.605134f, 0.846978f,
589 0.605360f, 0.784410f, 0.683874f, 0.757011f, 0.144866f, 0.784410f, 0.145092f, 0.846978f,
590 0.034332f, 0.897069f, 0.066352f, 0.757011f, 0.683874f, 0.757011f, 0.605360f, 0.784410f,
591 0.574835f, 0.744212f, 0.617867f, 0.719156f, 0.175391f, 0.744212f, 0.144866f, 0.784410f,
592 0.066352f, 0.757011f, 0.132359f, 0.719156f, 0.617867f, 0.719156f, 0.574835f, 0.744212f,
593 0.534996f, 0.712528f, 0.568728f, 0.682132f, 0.215230f, 0.712528f, 0.175391f, 0.744212f,
594 0.132359f, 0.719156f, 0.181498f, 0.682132f, 0.568728f, 0.682132f, 0.534996f, 0.712528f,
595 0.483006f, 0.686791f, 0.508539f, 0.641024f, 0.267220f, 0.686791f, 0.215230f, 0.712528f,
596 0.181498f, 0.682132f, 0.241687f, 0.641024f, 0.534996f, 0.712528f, 0.513415f, 0.736977f,
597 0.478880f, 0.719593f, 0.483006f, 0.686791f, 0.271346f, 0.719593f, 0.236811f, 0.736977f,
598 0.215230f, 0.712528f, 0.267220f, 0.686791f, 0.574835f, 0.744212f, 0.541117f, 0.760754f,
599 0.513415f, 0.736977f, 0.534996f, 0.712528f, 0.236811f, 0.736977f, 0.209109f, 0.760754f,
600 0.175391f, 0.744212f, 0.215230f, 0.712528f, 0.605360f, 0.784410f, 0.557599f, 0.789442f,
601 0.541117f, 0.760754f, 0.574835f, 0.744212f, 0.209109f, 0.760754f, 0.192627f, 0.789442f,
602 0.144866f, 0.784410f, 0.175391f, 0.744212f, 0.605134f, 0.846978f, 0.553841f, 0.821849f,
603 0.557599f, 0.789442f, 0.605360f, 0.784410f, 0.192627f, 0.789442f, 0.196385f, 0.821849f,
604 0.145092f, 0.846978f, 0.144866f, 0.784410f, 0.545439f, 0.884582f, 0.524671f, 0.842380f,
605 0.553841f, 0.821849f, 0.605134f, 0.846978f, 0.196385f, 0.821849f, 0.225555f, 0.842380f,
606 0.204787f, 0.884582f, 0.145092f, 0.846978f, 0.545439f, 0.884582f, 0.477326f, 0.891852f,
607 0.485193f, 0.845321f, 0.524671f, 0.842380f, 0.265033f, 0.845321f, 0.272900f, 0.891852f,
608 0.204787f, 0.884582f, 0.225555f, 0.842380f, 0.743592f, 0.198572f, 0.780113f, 0.169386f,
609 0.786150f, 0.181127f, 0.770208f, 0.191225f, 0.213850f, 0.181127f, 0.219887f, 0.169386f,
610 0.256408f, 0.198572f, 0.229792f, 0.191225f, 0.408153f, 0.587507f, 0.508539f, 0.641024f,
611 0.483006f, 0.686791f, 0.409610f, 0.674022f, 0.267220f, 0.686791f, 0.241687f, 0.641024f,
612 0.342073f, 0.587507f, 0.340616f, 0.674022f, 0.766410f, 0.233065f, 0.743592f, 0.198572f,
613 0.770208f, 0.191225f, 0.786137f, 0.227788f, 0.229792f, 0.191225f, 0.256408f, 0.198572f,
614 0.233590f, 0.233065f, 0.213863f, 0.227788f, 0.400301f, 0.910556f, 0.414155f, 0.878318f,
615 0.477326f, 0.891852f, 0.464516f, 0.959188f, 0.272900f, 0.891852f, 0.336071f, 0.878318f,
616 0.349925f, 0.910556f, 0.285710f, 0.959188f, 0.483006f, 0.686791f, 0.478880f, 0.719593f,
617 0.443630f, 0.713731f, 0.409610f, 0.674022f, 0.306596f, 0.713731f, 0.271346f, 0.719593f,
618 0.267220f, 0.686791f, 0.340616f, 0.674022f, 0.429725f, 0.728622f, 0.392812f, 0.710774f,
619 0.409610f, 0.674022f, 0.443630f, 0.713731f, 0.340616f, 0.674022f, 0.357414f, 0.710774f,
620 0.320501f, 0.728622f, 0.306596f, 0.713731f, 0.422979f, 0.754609f, 0.392812f, 0.710774f,
621 0.429725f, 0.728622f, 0.432640f, 0.746527f, 0.320501f, 0.728622f, 0.357414f, 0.710774f,
622 0.327247f, 0.754609f, 0.317586f, 0.746527f, 0.427719f, 0.796173f, 0.391578f, 0.815187f,
623 0.392812f, 0.710774f, 0.422979f, 0.754609f, 0.357414f, 0.710774f, 0.358648f, 0.815187f,
624 0.322507f, 0.796173f, 0.327247f, 0.754609f, 0.414155f, 0.878318f, 0.391578f, 0.815187f,
625 0.427719f, 0.796173f, 0.448277f, 0.830976f, 0.322507f, 0.796173f, 0.358648f, 0.815187f,
626 0.336071f, 0.878318f, 0.301949f, 0.830976f, 0.477326f, 0.891852f, 0.414155f, 0.878318f,
627 0.448277f, 0.830976f, 0.485193f, 0.845321f, 0.301949f, 0.830976f, 0.336071f, 0.878318f,
628 0.272900f, 0.891852f, 0.265033f, 0.845321f, 0.786137f, 0.227788f, 0.797710f, 0.195652f,
629 0.802580f, 0.199758f, 0.802950f, 0.203415f, 0.197420f, 0.199758f, 0.202290f, 0.195652f,
630 0.213863f, 0.227788f, 0.197050f, 0.203415f, 0.786137f, 0.227788f, 0.770208f, 0.191225f,
631 0.789609f, 0.184671f, 0.797710f, 0.195652f, 0.210391f, 0.184671f, 0.229792f, 0.191225f,
632 0.213863f, 0.227788f, 0.202290f, 0.195652f, 0.770208f, 0.191225f, 0.786150f, 0.181127f,
633 0.789609f, 0.184671f, 0.210391f, 0.184671f, 0.213850f, 0.181127f, 0.229792f, 0.191225f,
634 0.485193f, 0.845321f, 0.448277f, 0.830976f, 0.466042f, 0.804091f, 0.490498f, 0.816075f,
635 0.284184f, 0.804091f, 0.301949f, 0.830976f, 0.265033f, 0.845321f, 0.259728f, 0.816075f,
636 0.448277f, 0.830976f, 0.427719f, 0.796173f, 0.448042f, 0.783921f, 0.466042f, 0.804091f,
637 0.302184f, 0.783921f, 0.322507f, 0.796173f, 0.301949f, 0.830976f, 0.284184f, 0.804091f,
638 0.427719f, 0.796173f, 0.422979f, 0.754609f, 0.438745f, 0.764960f, 0.448042f, 0.783921f,
639 0.311481f, 0.764960f, 0.327247f, 0.754609f, 0.322507f, 0.796173f, 0.302184f, 0.783921f,
640 0.422979f, 0.754609f, 0.432640f, 0.746527f, 0.445216f, 0.756351f, 0.438745f, 0.764960f,
641 0.305010f, 0.756351f, 0.317586f, 0.746527f, 0.327247f, 0.754609f, 0.311481f, 0.764960f,
642 0.432640f, 0.746527f, 0.429725f, 0.728622f, 0.449819f, 0.743458f, 0.445216f, 0.756351f,
643 0.300407f, 0.743458f, 0.320501f, 0.728622f, 0.317586f, 0.746527f, 0.305010f, 0.756351f,
644 0.429725f, 0.728622f, 0.443630f, 0.713731f, 0.456307f, 0.732687f, 0.449819f, 0.743458f,
645 0.293919f, 0.732687f, 0.306596f, 0.713731f, 0.320501f, 0.728622f, 0.300407f, 0.743458f,
646 0.443630f, 0.713731f, 0.478880f, 0.719593f, 0.475471f, 0.740871f, 0.456307f, 0.732687f,
647 0.274755f, 0.740871f, 0.271346f, 0.719593f, 0.306596f, 0.713731f, 0.293919f, 0.732687f,
648 0.524671f, 0.842380f, 0.485193f, 0.845321f, 0.490498f, 0.816075f, 0.514211f, 0.817769f,
649 0.259728f, 0.816075f, 0.265033f, 0.845321f, 0.225555f, 0.842380f, 0.236015f, 0.817769f,
650 0.553841f, 0.821849f, 0.524671f, 0.842380f, 0.514211f, 0.817769f, 0.527961f, 0.808598f,
651 0.236015f, 0.817769f, 0.225555f, 0.842380f, 0.196385f, 0.821849f, 0.222265f, 0.808598f,
652 0.557599f, 0.789442f, 0.553841f, 0.821849f, 0.527961f, 0.808598f, 0.530079f, 0.790754f,
653 0.222265f, 0.808598f, 0.196385f, 0.821849f, 0.192627f, 0.789442f, 0.220147f, 0.790754f,
654 0.541117f, 0.760754f, 0.557599f, 0.789442f, 0.530079f, 0.790754f, 0.518620f, 0.772385f,
655 0.220147f, 0.790754f, 0.192627f, 0.789442f, 0.209109f, 0.760754f, 0.231606f, 0.772385f,
656 0.513415f, 0.736977f, 0.541117f, 0.760754f, 0.518620f, 0.772385f, 0.498668f, 0.755033f,
657 0.231606f, 0.772385f, 0.209109f, 0.760754f, 0.236811f, 0.736977f, 0.251558f, 0.755033f,
658 0.478880f, 0.719593f, 0.513415f, 0.736977f, 0.498668f, 0.755033f, 0.475471f, 0.740871f,
659 0.251558f, 0.755033f, 0.236811f, 0.736977f, 0.271346f, 0.719593f, 0.274755f, 0.740871f,
660 0.445216f, 0.756351f, 0.449819f, 0.743458f, 0.468029f, 0.756171f, 0.459660f, 0.770459f,
661 0.282197f, 0.756171f, 0.300407f, 0.743458f, 0.305010f, 0.756351f, 0.290566f, 0.770459f,
662 0.459660f, 0.770459f, 0.468029f, 0.756171f, 0.487167f, 0.769899f, 0.477354f, 0.785393f,
663 0.263059f, 0.769899f, 0.282197f, 0.756171f, 0.290566f, 0.770459f, 0.272872f, 0.785393f,
664 0.477354f, 0.785393f, 0.487167f, 0.769899f, 0.504617f, 0.782999f, 0.496545f, 0.797122f,
665 0.245609f, 0.782999f, 0.263059f, 0.769899f, 0.272872f, 0.785393f, 0.253681f, 0.797122f,
666 0.496545f, 0.797122f, 0.504617f, 0.782999f, 0.516137f, 0.792591f, 0.513713f, 0.804019f,
667 0.234089f, 0.792591f, 0.245609f, 0.782999f, 0.253681f, 0.797122f, 0.236513f, 0.804019f,
668 0.514211f, 0.817769f, 0.490498f, 0.816075f, 0.496545f, 0.797122f, 0.513713f, 0.804019f,
669 0.253681f, 0.797122f, 0.259728f, 0.816075f, 0.236015f, 0.817769f, 0.236513f, 0.804019f,
670 0.466042f, 0.804091f, 0.477354f, 0.785393f, 0.496545f, 0.797122f, 0.490498f, 0.816075f,
671 0.253681f, 0.797122f, 0.272872f, 0.785393f, 0.284184f, 0.804091f, 0.259728f, 0.816075f,
672 0.466042f, 0.804091f, 0.448042f, 0.783921f, 0.459660f, 0.770459f, 0.477354f, 0.785393f,
673 0.290566f, 0.770459f, 0.302184f, 0.783921f, 0.284184f, 0.804091f, 0.272872f, 0.785393f,
674 0.445216f, 0.756351f, 0.459660f, 0.770459f, 0.448042f, 0.783921f, 0.438745f, 0.764960f,
675 0.302184f, 0.783921f, 0.290566f, 0.770459f, 0.305010f, 0.756351f, 0.311481f, 0.764960f,
676 0.456307f, 0.732687f, 0.475471f, 0.740871f, 0.468029f, 0.756171f, 0.449819f, 0.743458f,
677 0.282197f, 0.756171f, 0.274755f, 0.740871f, 0.293919f, 0.732687f, 0.300407f, 0.743458f,
678 0.498668f, 0.755033f, 0.487167f, 0.769899f, 0.468029f, 0.756171f, 0.475471f, 0.740871f,
679 0.282197f, 0.756171f, 0.263059f, 0.769899f, 0.251558f, 0.755033f, 0.274755f, 0.740871f,
680 0.518620f, 0.772385f, 0.504617f, 0.782999f, 0.487167f, 0.769899f, 0.498668f, 0.755033f,
681 0.263059f, 0.769899f, 0.245609f, 0.782999f, 0.231606f, 0.772385f, 0.251558f, 0.755033f,
682 0.530079f, 0.790754f, 0.516137f, 0.792591f, 0.504617f, 0.782999f, 0.518620f, 0.772385f,
683 0.245609f, 0.782999f, 0.234089f, 0.792591f, 0.220147f, 0.790754f, 0.231606f, 0.772385f,
684 0.527961f, 0.808598f, 0.513713f, 0.804019f, 0.516137f, 0.792591f, 0.530079f, 0.790754f,
685 0.234089f, 0.792591f, 0.236513f, 0.804019f, 0.222265f, 0.808598f, 0.220147f, 0.790754f,
686 0.514211f, 0.817769f, 0.513713f, 0.804019f, 0.527961f, 0.808598f, 0.222265f, 0.808598f,
687 0.236513f, 0.804019f, 0.236015f, 0.817769f, 0.568728f, 0.682132f, 0.508539f, 0.641024f,
688 0.574269f, 0.607668f, 0.613510f, 0.655816f, 0.175957f, 0.607668f, 0.241687f, 0.641024f,
689 0.181498f, 0.682132f, 0.136716f, 0.655816f, 0.617867f, 0.719156f, 0.568728f, 0.682132f,
690 0.613510f, 0.655816f, 0.644031f, 0.693270f, 0.136716f, 0.655816f, 0.181498f, 0.682132f,
691 0.132359f, 0.719156f, 0.106195f, 0.693270f, 0.683874f, 0.757011f, 0.617867f, 0.719156f,
692 0.644031f, 0.693270f, 0.668163f, 0.712097f, 0.106195f, 0.693270f, 0.132359f, 0.719156f,
693 0.066352f, 0.757011f, 0.082063f, 0.712097f, 0.727131f, 0.698475f, 0.683874f, 0.757011f,
694 0.668163f, 0.712097f, 0.676584f, 0.686010f, 0.082063f, 0.712097f, 0.066352f, 0.757011f,
695 0.023095f, 0.698475f, 0.073642f, 0.686010f, 0.729804f, 0.624370f, 0.727131f, 0.698475f,
696 0.676584f, 0.686010f, 0.667013f, 0.640198f, 0.073642f, 0.686010f, 0.023095f, 0.698475f,
697 0.020422f, 0.624370f, 0.083213f, 0.640198f, 0.721292f, 0.572934f, 0.729804f, 0.624370f,
698 0.667013f, 0.640198f, 0.648152f, 0.594596f, 0.083213f, 0.640198f, 0.020422f, 0.624370f,
699 0.028934f, 0.572934f, 0.102074f, 0.594596f, 0.667013f, 0.640198f, 0.613510f, 0.655816f,
700 0.574269f, 0.607668f, 0.648152f, 0.594596f, 0.175957f, 0.607668f, 0.136716f, 0.655816f,
701 0.083213f, 0.640198f, 0.102074f, 0.594596f, 0.667013f, 0.640198f, 0.676584f, 0.686010f,
702 0.644031f, 0.693270f, 0.613510f, 0.655816f, 0.106195f, 0.693270f, 0.073642f, 0.686010f,
703 0.083213f, 0.640198f, 0.136716f, 0.655816f, 0.676584f, 0.686010f, 0.668163f, 0.712097f,
704 0.644031f, 0.693270f, 0.106195f, 0.693270f, 0.082063f, 0.712097f, 0.073642f, 0.686010f,
705 0.630034f, 0.557583f, 0.717709f, 0.538143f, 0.721292f, 0.572934f, 0.648152f, 0.594596f,
706 0.028934f, 0.572934f, 0.032517f, 0.538143f, 0.120192f, 0.557583f, 0.102074f, 0.594596f,
707 0.630034f, 0.557583f, 0.648152f, 0.594596f, 0.574269f, 0.607668f, 0.526877f, 0.539235f,
708 0.175957f, 0.607668f, 0.102074f, 0.594596f, 0.120192f, 0.557583f, 0.223349f, 0.539235f,
709 0.408153f, 0.587507f, 0.526877f, 0.539235f, 0.574269f, 0.607668f, 0.508539f, 0.641024f,
710 0.175957f, 0.607668f, 0.223349f, 0.539235f, 0.342073f, 0.587507f, 0.241687f, 0.641024f,
711};
712
713#define VERT_MARK 1
714
715#define EDGE_ORIG 1
716#define EDGE_MARK 2
717
718#define FACE_MARK 1
719#define FACE_NEW 2
720
722{
723 BMOpSlot *slot_verts_out = BMO_slot_get(op->slots_out, "verts.out");
724
725 const float dia = BMO_slot_float_get(op->slots_in, "size");
726 const uint xtot = max_ii(1, BMO_slot_int_get(op->slots_in, "x_segments"));
727 const uint ytot = max_ii(1, BMO_slot_int_get(op->slots_in, "y_segments"));
728 const float xtot_inv2 = 2.0f / (xtot);
729 const float ytot_inv2 = 2.0f / (ytot);
730
731 const int cd_loop_uv_offset = CustomData_get_offset(&bm->ldata, CD_PROP_FLOAT2);
732 const bool calc_uvs = (cd_loop_uv_offset != -1) && BMO_slot_bool_get(op->slots_in, "calc_uvs");
733
734 BMVert **varr;
735 BMVert *vquad[4];
736
737 float mat[4][4];
738 float vec[3], tvec[3];
739
740 uint x, y, i;
741
742 BMO_slot_mat4_get(op->slots_in, "matrix", mat);
743
744 BMO_slot_buffer_alloc(op, op->slots_out, "verts.out", (xtot + 1) * (ytot + 1));
745 varr = reinterpret_cast<BMVert **>(slot_verts_out->data.buf);
746
747 i = 0;
748 vec[2] = 0.0f;
749 for (y = 0; y <= ytot; y++) {
750 vec[1] = ((y * ytot_inv2) - 1.0f) * dia;
751 for (x = 0; x <= xtot; x++) {
752 vec[0] = ((x * xtot_inv2) - 1.0f) * dia;
753 mul_v3_m4v3(tvec, mat, vec);
754 varr[i] = BM_vert_create(bm, tvec, nullptr, BM_CREATE_NOP);
756 i++;
757 }
758 }
759
760#define XY(_x, _y) ((_x) + ((_y) * (xtot + 1)))
761
762 for (y = 1; y <= ytot; y++) {
763 for (x = 1; x <= xtot; x++) {
764 BMFace *f;
765
766 vquad[0] = varr[XY(x - 1, y - 1)];
767 vquad[1] = varr[XY(x, y - 1)];
768 vquad[2] = varr[XY(x, y)];
769 vquad[3] = varr[XY(x - 1, y)];
770
771 f = BM_face_create_verts(bm, vquad, 4, nullptr, BM_CREATE_NOP, true);
772 if (calc_uvs) {
774 }
775 }
776 }
777
778#undef XY
779
780 if (calc_uvs) {
781 BM_mesh_calc_uvs_grid(bm, xtot, ytot, FACE_MARK, cd_loop_uv_offset);
782 }
783}
784
786 const uint x_segments,
787 const uint y_segments,
788 const short oflag,
789 const int cd_loop_uv_offset)
790{
791 BMFace *f;
792 BMIter iter;
793
794 const float dx = 1.0f / float(x_segments);
795 const float dy = 1.0f / float(y_segments);
796
797 uint face_index = 0;
798
799 BLI_assert(cd_loop_uv_offset != -1);
800
801 BM_ITER_MESH (f, &iter, bm, BM_FACES_OF_MESH) {
802 if (!BMO_face_flag_test(bm, f, oflag)) {
803 continue;
804 }
805
806 const uint ix = face_index % x_segments;
807 const uint iy = face_index / x_segments;
808
809 BMIter liter;
810 BMLoop *l;
811 int loop_index;
812
813 BM_ITER_ELEM_INDEX (l, &liter, f, BM_LOOPS_OF_FACE, loop_index) {
814 float *luv = BM_ELEM_CD_GET_FLOAT_P(l, cd_loop_uv_offset);
815
816 switch (loop_index) {
817 case 0: {
818 luv[0] = ix * dx;
819 luv[1] = iy * dy;
820 break;
821 }
822 case 1: {
823 luv[0] = (ix + 1) * dx;
824 luv[1] = iy * dy;
825 break;
826 }
827 case 2: {
828 luv[0] = (ix + 1) * dx;
829 luv[1] = (iy + 1) * dy;
830 break;
831 }
832 case 3: {
833 luv[0] = ix * dx;
834 luv[1] = (iy + 1) * dy;
835 break;
836 }
837 default: {
838 break;
839 }
840 }
841 }
842
843 face_index++;
844 }
845}
846
847/* Rotation order set to match `BM_mesh_calc_uvs_cube`. */
848static const char cube_faces[6][4] = {
849 {0, 1, 3, 2},
850 {2, 3, 7, 6},
851 {6, 7, 5, 4},
852 {4, 5, 1, 0},
853 {2, 6, 4, 0},
854 {7, 3, 1, 5},
855};
856/* The lower left corner of each face of `cube_faces` in the UV layout from
857 * `BM_mesh_calc_uvs_cube`. */
858static const float cube_faces_uv[6][2] = {
859 {0.375f, 0.0f},
860 {0.375f, 0.25f},
861 {0.375f, 0.5f},
862 {0.375f, 0.75f},
863 {0.125f, 0.5f},
864 {0.625f, 0.5f},
865};
866
885 const bool on_face[3],
886 const float angle,
887 const float angle_scale)
888{
889 BLI_assert(on_face[0] || on_face[1] || on_face[2]);
890 BLI_assert(std::abs(angle_scale - (1.0f / std::tan(angle))) < 1e-6f);
891 float3 co_sphere;
892 for (int axis = 0; axis < 3; axis++) {
893 /* An axis on a face maps to itself, take it directly rather than relying on
894 * the warp returning exactly one, so vertices shared between faces stay exact. */
895 co_sphere[axis] = on_face[axis] ? co[axis] : (std::tan(co[axis] * angle) * angle_scale);
896 }
897 return co_sphere;
898}
899
906 const bool on_face[3],
907 const QuadSphereMethod method)
908{
909 switch (method) {
911 /* Around 49.7728 degrees, solved to minimize area distortion,
912 * see #QUADSPHERE_METHOD_EQUI_ANGULAR_EVEN_AREA. */
913 const float angle = 0.8687f;
914 /* `1 / tan(angle)`. */
915 const float angle_scale = 0.845878184f;
916 return quadsphere_co_from_cube_equi_angular(co, on_face, angle, angle_scale);
917 }
919 const float angle = float(M_PI_4);
920 /* `tan(M_PI_4)` is one. */
921 const float angle_scale = 1.0f;
922 return quadsphere_co_from_cube_equi_angular(co, on_face, angle, angle_scale);
923 }
924 }
926 return co;
927}
928
930{
931 BMOpSlot *slot_verts_out = BMO_slot_get(op->slots_out, "verts.out");
932
933 const float rad = BMO_slot_float_get(op->slots_in, "radius");
934 /* Quads along each cube edge. */
935 const int seg = max_ii(1, BMO_slot_int_get(op->slots_in, "segments"));
936 /* Vertices along each cube edge. */
937 const int seg_vert = seg + 1;
938 /* Mapping from the cube onto the sphere. */
939 const QuadSphereMethod method = QuadSphereMethod(BMO_slot_int_get(op->slots_in, "method"));
940 const int cd_loop_uv_offset = CustomData_get_offset(&bm->ldata, CD_PROP_FLOAT2);
941 const bool calc_uvs = (cd_loop_uv_offset != -1) && BMO_slot_bool_get(op->slots_in, "calc_uvs");
942
943 float mat[4][4];
944 BMO_slot_mat4_get(op->slots_in, "matrix", mat);
945
946 /* Vertices are stored as Z layers, only the cube surface is used
947 * so the first & last are full, those between are a ring. */
948 const int layer_full_len = seg_vert * seg_vert;
949 const int layer_ring_len = seg * 4;
950
952 op, op->slots_out, "verts.out", (layer_full_len * 2) + (layer_ring_len * (seg - 1)));
953 BMVert **varr = reinterpret_cast<BMVert **>(slot_verts_out->data.buf);
954
955 /* Vertex index for a grid index, each axis in [0, seg], one at an extreme. */
956 auto vert_index_from_grid_index_fn =
957 [seg, seg_vert, layer_full_len, layer_ring_len](const int3 &grid_index) -> int {
958 if (grid_index.z == 0) {
959 return (grid_index.y * seg_vert) + grid_index.x;
960 }
961 if (grid_index.z == seg) {
962 return layer_full_len + (layer_ring_len * (seg - 1)) + (grid_index.y * seg_vert) +
963 grid_index.x;
964 }
965 /* Walk around the ring, starting at the (0, 0) corner. */
966 int ring_index;
967 if (grid_index.y == 0) {
968 ring_index = grid_index.x;
969 }
970 else if (grid_index.x == seg) {
971 ring_index = seg + grid_index.y;
972 }
973 else if (grid_index.y == seg) {
974 ring_index = (seg * 3) - grid_index.x;
975 }
976 else {
977 BLI_assert(grid_index.x == 0);
978 ring_index = (seg * 4) - grid_index.y;
979 }
980 return layer_full_len + (layer_ring_len * (grid_index.z - 1)) + ring_index;
981 };
982
983 /* Location on the cube for a single axis, in [-1, 1]. */
984 auto cube_co_from_grid_fn = [seg](const int i) { return float((i * 2) - seg) / float(seg); };
985
986 /* Warp for each axis spanning a cube face, shared by every axis & face.
987 * Only the first spanning axis is read, each depends only on itself. */
988 Array<float> wrap_table(seg_vert);
989 {
990 bool on_face[3] = {true, false, false};
991 float3 co = {1.0f, 0.0f, 0.0f};
992 for (int i = 0; i <= seg; i++) {
993 on_face[1] = ELEM(i, 0, seg);
994 co[1] = cube_co_from_grid_fn(i);
995 wrap_table[i] = quadsphere_co_from_cube(co, on_face, method)[1];
996 }
997 }
998
999 /* Direction on the sphere, the caller scales it to the radius. */
1000 auto sphere_co_from_grid_index_fn =
1001 [seg, &wrap_table, &cube_co_from_grid_fn](const int3 &grid_index) -> float3 {
1002 /* The axis on a cube face, maps to itself (exactly -1 or 1). */
1003 const int axis_face = ELEM(grid_index.x, 0, seg) ? 0 : (ELEM(grid_index.y, 0, seg) ? 1 : 2);
1004 BLI_assert(ELEM(grid_index[axis_face], 0, seg));
1005 const int axis_a = (axis_face + 1) % 3;
1006 const int axis_b = (axis_face + 2) % 3;
1007 float3 co_sphere;
1008 co_sphere[axis_face] = cube_co_from_grid_fn(grid_index[axis_face]);
1009 co_sphere[axis_a] = wrap_table[grid_index[axis_a]];
1010 co_sphere[axis_b] = wrap_table[grid_index[axis_b]];
1011 return co_sphere;
1012 };
1013
1014 int v_index = 0;
1015 auto vert_add_fn = [&](const int3 &grid_index) {
1016 BLI_assert(v_index == vert_index_from_grid_index_fn(grid_index));
1017 UNUSED_VARS_NDEBUG(vert_index_from_grid_index_fn);
1018 float3 co = sphere_co_from_grid_index_fn(grid_index);
1019 normalize_v3_length(co, rad);
1020 mul_m4_v3(mat, co);
1021 varr[v_index++] = BM_vert_create(bm, co, nullptr, BM_CREATE_NOP);
1022 };
1023
1024 /* Create vertices in the order `vert_index_from_grid_index_fn` expects. */
1025 for (int z = 0; z <= seg; z++) {
1026 if (ELEM(z, 0, seg)) {
1027 for (int y = 0; y <= seg; y++) {
1028 for (int x = 0; x <= seg; x++) {
1029 vert_add_fn({x, y, z});
1030 }
1031 }
1032 }
1033 else {
1034 for (int x = 0; x <= seg; x++) {
1035 vert_add_fn({x, 0, z});
1036 }
1037 for (int y = 1; y <= seg; y++) {
1038 vert_add_fn({seg, y, z});
1039 }
1040 for (int x = seg - 1; x >= 0; x--) {
1041 vert_add_fn({x, seg, z});
1042 }
1043 for (int y = seg - 1; y >= 1; y--) {
1044 vert_add_fn({0, y, z});
1045 }
1046 }
1047 }
1048 BLI_assert(v_index == slot_verts_out->len);
1049
1050 /* A `cube_faces` vertex as its cube corner, each axis 0 or 1. */
1051 auto corner_from_cube_vert_fn = [](const int cube_vert) -> int3 {
1052 return int3((cube_vert >> 2) & 1, (cube_vert >> 1) & 1, cube_vert & 1);
1053 };
1054
1055 /* Size of a quad in the UV layout, each cube face takes a quarter. */
1056 const float uv_step = 0.25f / float(seg);
1057
1058 /* Create the quads (edges as needed), one grid per cube face. */
1059 for (int f_index = 0; f_index < 6; f_index++) {
1060 const int3 corner = corner_from_cube_vert_fn(cube_faces[f_index][0]);
1061 /* Step one vertex along each axis of the face. */
1062 const int3 step_u = corner_from_cube_vert_fn(cube_faces[f_index][1]) - corner;
1063 const int3 step_v = corner_from_cube_vert_fn(cube_faces[f_index][3]) - corner;
1064 const int3 grid_index_corner = corner * seg;
1065
1066 for (int v = 0; v < seg; v++) {
1067 for (int u = 0; u < seg; u++) {
1068 const int3 grid_index = grid_index_corner + (step_u * u) + (step_v * v);
1069 /* The render split always cuts quads along the same (0-2) diagonal,
1070 * so quads on two of the four corners never get cut through their corner vertex at all.
1071 * Flip those quads vertices to use the other diagonal instead.
1072 * The final result is a more spherical surface when quads are split into triangles.
1073 * See !163500 which shows the difference. */
1074 const bool flip_quad_direction = (((u * 2) + 1) < seg) != (((v * 2) + 1) < seg);
1075 BMVert *vquad[4];
1076 if (!flip_quad_direction) {
1077 vquad[0] = varr[vert_index_from_grid_index_fn(grid_index)];
1078 vquad[1] = varr[vert_index_from_grid_index_fn(grid_index + step_u)];
1079 vquad[2] = varr[vert_index_from_grid_index_fn(grid_index + step_u + step_v)];
1080 vquad[3] = varr[vert_index_from_grid_index_fn(grid_index + step_v)];
1081 }
1082 else {
1083 vquad[0] = varr[vert_index_from_grid_index_fn(grid_index + step_u)];
1084 vquad[1] = varr[vert_index_from_grid_index_fn(grid_index + step_u + step_v)];
1085 vquad[2] = varr[vert_index_from_grid_index_fn(grid_index + step_v)];
1086 vquad[3] = varr[vert_index_from_grid_index_fn(grid_index)];
1087 }
1088 BMFace *f = BM_face_create_verts(bm, vquad, 4, nullptr, BM_CREATE_NOP, true);
1089
1090 if (calc_uvs) {
1091 /* Calculate each corner from its own index so quads share UVs exactly. */
1092 const float uv_min[2] = {
1093 cube_faces_uv[f_index][0] + (uv_step * float(u)),
1094 cube_faces_uv[f_index][1] + (uv_step * float(v)),
1095 };
1096 const float uv_max[2] = {
1097 cube_faces_uv[f_index][0] + (uv_step * float(u + 1)),
1098 cube_faces_uv[f_index][1] + (uv_step * float(v + 1)),
1099 };
1100 const float uvs[4][2] = {
1101 {uv_min[0], uv_min[1]},
1102 {uv_max[0], uv_min[1]},
1103 {uv_max[0], uv_max[1]},
1104 {uv_min[0], uv_max[1]},
1105 };
1107 /* UV's are is in the un-flipped vertex order, shift the read index when necessary. */
1108 if (flip_quad_direction) {
1109 l = l->prev;
1110 }
1111 for (int i = 0; i < 4; i++, l = l->next) {
1112 copy_v2_v2(BM_ELEM_CD_GET_FLOAT_P(l, cd_loop_uv_offset), uvs[i]);
1113 }
1114 }
1115 }
1116 }
1117 }
1118}
1119
1121{
1122 const float rad = BMO_slot_float_get(op->slots_in, "radius");
1123 /* Prevent zero U/V (crashes). If default permanents were supported 3 would make more sense. */
1124 const int seg = std::max(1, BMO_slot_int_get(op->slots_in, "u_segments"));
1125 const int tot = std::max(1, BMO_slot_int_get(op->slots_in, "v_segments"));
1126
1127 const int cd_loop_uv_offset = CustomData_get_offset(&bm->ldata, CD_PROP_FLOAT2);
1128 const bool calc_uvs = (cd_loop_uv_offset != -1) && BMO_slot_bool_get(op->slots_in, "calc_uvs");
1129
1130 BMOperator bmop, prevop;
1131 BMVert *eve, *preveve;
1132 BMEdge *e;
1133 BMIter iter;
1134 const float axis[3] = {0, 0, 1};
1135 float vec[3], mat[4][4], cmat[3][3];
1136 int a;
1137
1138 BMO_slot_mat4_get(op->slots_in, "matrix", mat);
1139
1140 const float phid = float(M_PI) / tot;
1141 // const float phi = 0.25f * float(M_PI); /* UNUSED. */
1142
1143 /* one segment first */
1144 for (a = 0; a <= tot; a++) {
1145 /* Going in this direction, then edge extruding, makes normals face outward */
1146 float sin_phi, cos_phi;
1147 sin_cos_from_fraction(a, 2 * tot, &sin_phi, &cos_phi);
1148
1149 vec[0] = 0.0f;
1150 vec[1] = rad * sin_phi;
1151 vec[2] = rad * cos_phi;
1152 eve = BM_vert_create(bm, vec, nullptr, BM_CREATE_NOP);
1154
1155 if (a != 0) {
1156 e = BM_edge_create(bm, preveve, eve, nullptr, BM_CREATE_NOP);
1158 }
1159
1160 preveve = eve;
1161 }
1162
1163 /* extrude and rotate; negative phi to make normals face outward */
1164 axis_angle_to_mat3(cmat, axis, -(M_PI * 2) / seg);
1165
1166 for (a = 0; a < seg; a++) {
1167 if (a) {
1168 BMO_op_initf(bm, &bmop, op->flag, "extrude_edge_only edges=%S", &prevop, "geom.out");
1169 BMO_op_exec(bm, &bmop);
1170 BMO_op_finish(bm, &prevop);
1171 }
1172 else {
1173 BMO_op_initf(bm, &bmop, op->flag, "extrude_edge_only edges=%fe", EDGE_ORIG);
1174 BMO_op_exec(bm, &bmop);
1175 }
1176
1178 BMO_op_callf(bm, op->flag, "rotate cent=%v matrix=%m3 verts=%S", vec, cmat, &bmop, "geom.out");
1179
1180 prevop = bmop;
1181 }
1182
1183 if (a) {
1184 BMO_op_finish(bm, &bmop);
1185 }
1186
1187 {
1188 float len, len2, vec2[3];
1189
1190 len = 2 * rad * sinf(phid / 2.0f);
1191
1192 /* Length of one segment in shortest parallel. */
1193 vec[0] = rad * sinf(phid);
1194 vec[1] = 0.0f;
1195 vec[2] = rad * cosf(phid);
1196
1197 mul_v3_m3v3(vec2, cmat, vec);
1198 len2 = len_v3v3(vec, vec2);
1199
1200 /* use shortest segment length divided by 3 as merge threshold */
1202 bm, op->flag, "remove_doubles verts=%fv dist=%f", VERT_MARK, min_ff(len, len2) / 3.0f);
1203 }
1204
1205 if (calc_uvs) {
1206 BMFace *f;
1207 BMLoop *l;
1208 BMIter fiter, liter;
1209
1210 /* We cannot tag faces for UVs computing above,
1211 * so we have to do it now, based on all its vertices being tagged. */
1212 BM_ITER_MESH (f, &fiter, bm, BM_FACES_OF_MESH) {
1213 bool valid = true;
1214
1215 BM_ITER_ELEM (l, &liter, f, BM_LOOPS_OF_FACE) {
1216 if (!BMO_vert_flag_test(bm, l->v, VERT_MARK)) {
1217 valid = false;
1218 break;
1219 }
1220 }
1221
1222 if (valid) {
1224 }
1225 }
1226
1227 BM_mesh_calc_uvs_sphere(bm, FACE_MARK, cd_loop_uv_offset);
1228 }
1229
1230 /* Now apply the inverse matrix. */
1231 BM_ITER_MESH (eve, &iter, bm, BM_VERTS_OF_MESH) {
1232 if (BMO_vert_flag_test(bm, eve, VERT_MARK)) {
1233 mul_m4_v3(mat, eve->co);
1234 }
1235 }
1236
1238}
1239
1241{
1242 const float rad = BMO_slot_float_get(op->slots_in, "radius");
1243 const float rad_div = rad / 200.0f;
1244 const int subdiv = BMO_slot_int_get(op->slots_in, "subdivisions");
1245
1246 const int cd_loop_uv_offset = CustomData_get_offset(&bm->ldata, CD_PROP_FLOAT2);
1247 const bool calc_uvs = (cd_loop_uv_offset != -1) && BMO_slot_bool_get(op->slots_in, "calc_uvs");
1248
1249 BMVert *eva[12];
1250 BMVert *v;
1251 BMIter liter;
1252 BMIter viter;
1253 BMLoop *l;
1254 float vec[3], mat[4][4] /* , phi, phid */;
1255 int a;
1256
1257 BMO_slot_mat4_get(op->slots_in, "matrix", mat);
1258
1259 // phid = 2.0f * float(M_PI) / subdiv; /* UNUSED. */
1260 // phi = 0.25f * float(M_PI); /* UNUSED. */
1261
1262 for (a = 0; a < 12; a++) {
1263 vec[0] = rad_div * icovert[a][0];
1264 vec[1] = rad_div * icovert[a][1];
1265 vec[2] = rad_div * icovert[a][2];
1266 eva[a] = BM_vert_create(bm, vec, nullptr, BM_CREATE_NOP);
1267
1269 }
1270
1271 int uvi = 0;
1272 for (a = 0; a < 20; a++) {
1273 BMFace *f;
1274 BMVert *v1, *v2, *v3;
1275
1276 v1 = eva[icoface[a][0]];
1277 v2 = eva[icoface[a][1]];
1278 v3 = eva[icoface[a][2]];
1279
1280 f = BM_face_create_quad_tri(bm, v1, v2, v3, nullptr, nullptr, BM_CREATE_NOP);
1281
1282 BM_ITER_ELEM (l, &liter, f, BM_LOOPS_OF_FACE) {
1284 }
1285
1286 /* Set the UVs here, the iteration order of the faces is not guaranteed,
1287 * so it's best to set the UVs right after the face is created. */
1288 if (calc_uvs) {
1289 int loop_index;
1290 BM_ITER_ELEM_INDEX (l, &liter, f, BM_LOOPS_OF_FACE, loop_index) {
1291 float *luv = BM_ELEM_CD_GET_FLOAT_P(l, cd_loop_uv_offset);
1292 luv[0] = icouvs[uvi][0];
1293 luv[1] = icouvs[uvi][1];
1294 uvi++;
1295 }
1296 }
1297 }
1298
1299 if (subdiv > 1) {
1300 BMOperator bmop;
1301
1303 &bmop,
1304 op->flag,
1305 "subdivide_edges edges=%fe "
1306 "smooth=%f "
1307 "cuts=%i "
1308 "use_grid_fill=%b use_sphere=%b",
1309 EDGE_MARK,
1310 rad,
1311 (1 << (subdiv - 1)) - 1,
1312 true,
1313 true);
1314
1315 BMO_op_exec(bm, &bmop);
1318 BMO_op_finish(bm, &bmop);
1319 }
1320
1321 /* must transform after because of sphere subdivision */
1322 BM_ITER_MESH (v, &viter, bm, BM_VERTS_OF_MESH) {
1324 mul_m4_v3(mat, v->co);
1325 }
1326 }
1327
1329}
1330
1331static void bm_mesh_calc_uvs_sphere_face(BMFace *f, const int cd_loop_uv_offset)
1332{
1333 float *uvs[4];
1334 BMLoop *l;
1335 BMIter iter;
1336 float dx;
1337 int loop_index, loop_index_max_x;
1338
1339 BLI_assert(f->len <= 4);
1340
1341 /* If face has 3 vertices, it's a polar face, in which case we need to
1342 * compute a nearby to determine its latitude. */
1343 float avgx = 0.0f, avgy = 0.0f;
1344 BM_ITER_ELEM_INDEX (l, &iter, f, BM_LOOPS_OF_FACE, loop_index) {
1345 if (f->len == 3) {
1346 avgx += l->v->co[0];
1347 avgy += l->v->co[1];
1348 }
1349 }
1350 avgx /= 3.0f;
1351 avgy /= 3.0f;
1352
1353 BM_ITER_ELEM_INDEX (l, &iter, f, BM_LOOPS_OF_FACE, loop_index) {
1354 float *luv = BM_ELEM_CD_GET_FLOAT_P(l, cd_loop_uv_offset);
1355 float x = l->v->co[0];
1356 float y = l->v->co[1];
1357 float z = l->v->co[2];
1358 float len = len_v3(l->v->co);
1359
1360 /* Use neighboring point to compute angle for poles. */
1361 float theta;
1362 if (f->len == 3 && fabsf(x) < 0.0001f && fabsf(y) < 0.0001f) {
1363 theta = atan2f(avgy, avgx);
1364 }
1365 else {
1366 theta = atan2f(y, x);
1367 }
1368
1369 /* Shift borderline coordinates to the left. */
1370 if (fabsf(theta - float(M_PI)) < 0.0001f) {
1371 theta = -M_PI;
1372 }
1373
1374 float phi = safe_acosf(z / len);
1375 luv[0] = 0.5f + theta / (float(M_PI) * 2);
1376 luv[1] = 1.0f - phi / float(M_PI);
1377
1378 uvs[loop_index] = luv;
1379 }
1380
1381 /* Fix awkwardly-wrapping UVs */
1382 loop_index_max_x = 0;
1383 for (loop_index = 1; loop_index < f->len; loop_index++) {
1384 if (uvs[loop_index][0] > uvs[loop_index_max_x][0]) {
1385 loop_index_max_x = loop_index;
1386 }
1387 }
1388
1389 for (loop_index = 0; loop_index < f->len; loop_index++) {
1390 if (loop_index != loop_index_max_x) {
1391 dx = uvs[loop_index_max_x][0] - uvs[loop_index][0];
1392 if (dx > 0.5f) {
1393 uvs[loop_index][0] += 1.0f;
1394 }
1395 }
1396 }
1397}
1398
1399void BM_mesh_calc_uvs_sphere(BMesh *bm, const short oflag, const int cd_loop_uv_offset)
1400{
1401 BMFace *f;
1402 BMIter iter;
1403
1404 BLI_assert(cd_loop_uv_offset != -1); /* caller is responsible for giving us UVs */
1405
1406 BM_ITER_MESH (f, &iter, bm, BM_FACES_OF_MESH) {
1407 if (!BMO_face_flag_test(bm, f, oflag)) {
1408 continue;
1409 }
1410
1411 bm_mesh_calc_uvs_sphere_face(f, cd_loop_uv_offset);
1412 }
1413
1414 BMIter iter2;
1415 BMLoop *l;
1416 int loop_index;
1417 float minx = 1.0f;
1418
1419 BM_ITER_MESH (f, &iter, bm, BM_FACES_OF_MESH) {
1420 if (!BMO_face_flag_test(bm, f, oflag)) {
1421 continue;
1422 }
1423 BM_ITER_ELEM_INDEX (l, &iter2, f, BM_LOOPS_OF_FACE, loop_index) {
1424 float *luv = BM_ELEM_CD_GET_FLOAT_P(l, cd_loop_uv_offset);
1425 minx = std::min(luv[0], minx);
1426 }
1427 }
1428
1429 BM_ITER_MESH (f, &iter, bm, BM_FACES_OF_MESH) {
1430 if (!BMO_face_flag_test(bm, f, oflag)) {
1431 continue;
1432 }
1433 BM_ITER_ELEM_INDEX (l, &iter2, f, BM_LOOPS_OF_FACE, loop_index) {
1434 float *luv = BM_ELEM_CD_GET_FLOAT_P(l, cd_loop_uv_offset);
1435 luv[0] -= minx;
1436 }
1437 }
1438}
1439
1441{
1443 float mat[4][4];
1444 int i;
1445
1446 BMO_slot_mat4_get(op->slots_in, "matrix", mat);
1447
1448 const int cd_loop_uv_offset = CustomData_get_offset(&bm->ldata, CD_PROP_FLOAT2);
1449 const bool calc_uvs = (cd_loop_uv_offset != -1) && BMO_slot_bool_get(op->slots_in, "calc_uvs");
1450
1451 for (i = 0; i < monkeynv; i++) {
1452 float v[3];
1453
1454 /* rotate to face in the -Y axis */
1455 v[0] = (monkeyv[i][0] + 127) / 128.0;
1456 v[2] = monkeyv[i][1] / 128.0;
1457 v[1] = monkeyv[i][2] / -128.0;
1458
1459 tv[i] = BM_vert_create(bm, v, nullptr, BM_CREATE_NOP);
1461
1462 if (fabsf(v[0] = -v[0]) < 0.001f) {
1463 tv[monkeynv + i] = tv[i];
1464 }
1465 else {
1466 BMVert *eve = BM_vert_create(bm, v, nullptr, BM_CREATE_NOP);
1467 mul_m4_v3(mat, eve->co);
1468 tv[monkeynv + i] = eve;
1469 }
1470
1472
1473 mul_m4_v3(mat, tv[i]->co);
1474 }
1475
1476 int uvi = 0;
1477 for (i = 0; i < monkeynf; i++) {
1479 bm,
1480 tv[monkeyf[i][0] + i - monkeyo],
1481 tv[monkeyf[i][1] + i - monkeyo],
1482 tv[monkeyf[i][2] + i - monkeyo],
1483 (monkeyf[i][3] != monkeyf[i][2]) ? tv[monkeyf[i][3] + i - monkeyo] : nullptr,
1484 nullptr,
1486
1488 bm,
1489 tv[monkeynv + monkeyf[i][2] + i - monkeyo],
1490 tv[monkeynv + monkeyf[i][1] + i - monkeyo],
1491 tv[monkeynv + monkeyf[i][0] + i - monkeyo],
1492 (monkeyf[i][3] != monkeyf[i][2]) ? tv[monkeynv + monkeyf[i][3] + i - monkeyo] : nullptr,
1493 nullptr,
1495
1496 /* Set the UVs here, the iteration order of the faces is not guaranteed,
1497 * so it's best to set the UVs right after the face is created. */
1498 if (calc_uvs) {
1499 BMLoop *l;
1500 BMIter liter;
1501 BM_ITER_ELEM (l, &liter, f_new_a, BM_LOOPS_OF_FACE) {
1502 float *luv = BM_ELEM_CD_GET_FLOAT_P(l, cd_loop_uv_offset);
1503 luv[0] = monkeyuvs[uvi * 2 + 0];
1504 luv[1] = monkeyuvs[uvi * 2 + 1];
1505 uvi++;
1506 }
1507 BM_ITER_ELEM (l, &liter, f_new_b, BM_LOOPS_OF_FACE) {
1508 float *luv = BM_ELEM_CD_GET_FLOAT_P(l, cd_loop_uv_offset);
1509 luv[0] = monkeyuvs[uvi * 2 + 0];
1510 luv[1] = monkeyuvs[uvi * 2 + 1];
1511 uvi++;
1512 }
1513 }
1514 }
1515
1516 MEM_delete(tv);
1517
1519}
1520
1522{
1523 const float radius = BMO_slot_float_get(op->slots_in, "radius");
1524 const int segs = BMO_slot_int_get(op->slots_in, "segments");
1525 const bool cap_ends = BMO_slot_bool_get(op->slots_in, "cap_ends");
1526 const bool cap_tris = BMO_slot_bool_get(op->slots_in, "cap_tris");
1527
1528 const int cd_loop_uv_offset = CustomData_get_offset(&bm->ldata, CD_PROP_FLOAT2);
1529 const bool calc_uvs = (cd_loop_uv_offset != -1) && BMO_slot_bool_get(op->slots_in, "calc_uvs");
1530
1531 BMVert *v1, *lastv1 = nullptr, *cent1, *firstv1 = nullptr;
1532 float vec[3], mat[4][4];
1533 int a;
1534
1535 if (!segs) {
1536 return;
1537 }
1538
1539 BMO_slot_mat4_get(op->slots_in, "matrix", mat);
1540
1541 if (cap_ends) {
1542 zero_v3(vec);
1543 mul_m4_v3(mat, vec);
1544
1545 cent1 = BM_vert_create(bm, vec, nullptr, BM_CREATE_NOP);
1547 }
1548
1549 for (a = 0; a < segs; a++) {
1550 /* Going this way ends up with normal(s) upward */
1551 sin_cos_from_fraction(a, segs, &vec[0], &vec[1]);
1552 vec[0] *= -radius;
1553 vec[1] *= radius;
1554 vec[2] = 0.0f;
1555 mul_m4_v3(mat, vec);
1556 v1 = BM_vert_create(bm, vec, nullptr, BM_CREATE_NOP);
1557
1559
1560 if (lastv1) {
1561 BM_edge_create(bm, v1, lastv1, nullptr, BM_CREATE_NOP);
1562 }
1563
1564 if (a && cap_ends) {
1565 BMFace *f;
1566
1567 f = BM_face_create_quad_tri(bm, cent1, lastv1, v1, nullptr, nullptr, BM_CREATE_NOP);
1569 }
1570
1571 if (!firstv1) {
1572 firstv1 = v1;
1573 }
1574
1575 lastv1 = v1;
1576 }
1577
1578 if (!a) {
1579 return;
1580 }
1581
1582 BM_edge_create(bm, firstv1, lastv1, nullptr, eBMCreateFlag(0));
1583
1584 if (cap_ends) {
1585 BMFace *f;
1586
1587 f = BM_face_create_quad_tri(bm, cent1, v1, firstv1, nullptr, nullptr, BM_CREATE_NOP);
1589
1590 if (calc_uvs) {
1591 BM_mesh_calc_uvs_circle(bm, mat, radius, FACE_NEW, cd_loop_uv_offset);
1592 }
1593 }
1594
1595 if (!cap_tris) {
1596 BMO_op_callf(bm, op->flag, "dissolve_faces faces=%ff", FACE_NEW);
1597 }
1598
1600}
1601
1603 BMesh *bm, float mat[4][4], const float radius, const short oflag, const int cd_loop_uv_offset)
1604{
1605 BMFace *f;
1606 BMLoop *l;
1607 BMIter fiter, liter;
1608
1609 const float uv_scale = 0.5f / radius;
1610 const float uv_center = 0.5f;
1611
1612 float inv_mat[4][4];
1613
1614 BLI_assert(cd_loop_uv_offset != -1); /* caller must ensure we have UVs already */
1615
1616 invert_m4_m4(inv_mat, mat);
1617
1618 BM_ITER_MESH (f, &fiter, bm, BM_FACES_OF_MESH) {
1619 if (!BMO_face_flag_test(bm, f, oflag)) {
1620 continue;
1621 }
1622
1623 BM_ITER_ELEM (l, &liter, f, BM_LOOPS_OF_FACE) {
1624 float *luv = BM_ELEM_CD_GET_FLOAT_P(l, cd_loop_uv_offset);
1625
1626 float uv_vco[3];
1627 copy_v3_v3(uv_vco, l->v->co);
1628 /* transform back into the unit circle flat on the Z-axis */
1629 mul_m4_v3(inv_mat, uv_vco);
1630
1631 /* then just take those coords for UVs */
1632 luv[0] = uv_center + uv_scale * uv_vco[0];
1633 luv[1] = uv_center + uv_scale * uv_vco[1];
1634 }
1635 }
1636}
1637
1639{
1640 BMVert *v1, *v2, *lastv1 = nullptr, *lastv2 = nullptr, *cent1, *cent2, *firstv1, *firstv2;
1641 BMFace *f;
1642 float vec[3], mat[4][4];
1643 const float rad1 = BMO_slot_float_get(op->slots_in, "radius1");
1644 const float rad2 = BMO_slot_float_get(op->slots_in, "radius2");
1645 const float depth_half = 0.5f * BMO_slot_float_get(op->slots_in, "depth");
1646 int segs = BMO_slot_int_get(op->slots_in, "segments");
1647 const bool cap_ends = BMO_slot_bool_get(op->slots_in, "cap_ends");
1648 const bool cap_tris = BMO_slot_bool_get(op->slots_in, "cap_tris");
1649
1650 const int cd_loop_uv_offset = CustomData_get_offset(&bm->ldata, CD_PROP_FLOAT2);
1651 const bool calc_uvs = (cd_loop_uv_offset != -1) && BMO_slot_bool_get(op->slots_in, "calc_uvs");
1652
1653 if (!segs) {
1654 return;
1655 }
1656
1657 BMO_slot_mat4_get(op->slots_in, "matrix", mat);
1658
1659 if (cap_ends) {
1660 vec[0] = vec[1] = 0.0f;
1661 vec[2] = -depth_half;
1662 mul_m4_v3(mat, vec);
1663
1664 cent1 = BM_vert_create(bm, vec, nullptr, BM_CREATE_NOP);
1665
1666 vec[0] = vec[1] = 0.0f;
1667 vec[2] = depth_half;
1668 mul_m4_v3(mat, vec);
1669
1670 cent2 = BM_vert_create(bm, vec, nullptr, BM_CREATE_NOP);
1671
1674 }
1675
1676 const int side_faces_len = segs - 1;
1677 BMFace **side_faces = MEM_new_array_uninitialized<BMFace *>(side_faces_len, __func__);
1678
1679 for (int i = 0; i < segs; i++) {
1680 /* Calculate with higher precision, see: #87779. */
1681 float sin_phi, cos_phi;
1682 sin_cos_from_fraction(i, segs, &sin_phi, &cos_phi);
1683
1684 vec[0] = rad1 * sin_phi;
1685 vec[1] = rad1 * cos_phi;
1686 vec[2] = -depth_half;
1687 mul_m4_v3(mat, vec);
1688 v1 = BM_vert_create(bm, vec, nullptr, BM_CREATE_NOP);
1689
1690 vec[0] = rad2 * sin_phi;
1691 vec[1] = rad2 * cos_phi;
1692 vec[2] = depth_half;
1693 mul_m4_v3(mat, vec);
1694 v2 = BM_vert_create(bm, vec, nullptr, BM_CREATE_NOP);
1695
1698
1699 if (i) {
1700 if (cap_ends) {
1701 f = BM_face_create_quad_tri(bm, cent1, lastv1, v1, nullptr, nullptr, BM_CREATE_NOP);
1702 if (calc_uvs) {
1704 }
1706
1707 f = BM_face_create_quad_tri(bm, cent2, v2, lastv2, nullptr, nullptr, BM_CREATE_NOP);
1708 if (calc_uvs) {
1710 }
1712 }
1713
1714 f = BM_face_create_quad_tri(bm, lastv1, lastv2, v2, v1, nullptr, BM_CREATE_NOP);
1715 if (calc_uvs) {
1717 }
1718 side_faces[i - 1] = f;
1719 }
1720 else {
1721 firstv1 = v1;
1722 firstv2 = v2;
1723 }
1724
1725 lastv1 = v1;
1726 lastv2 = v2;
1727 }
1728
1729 if (cap_ends) {
1730 f = BM_face_create_quad_tri(bm, cent1, v1, firstv1, nullptr, nullptr, BM_CREATE_NOP);
1731 if (calc_uvs) {
1733 }
1735
1736 f = BM_face_create_quad_tri(bm, cent2, firstv2, v2, nullptr, nullptr, BM_CREATE_NOP);
1737 if (calc_uvs) {
1739 }
1741 }
1742
1743 f = BM_face_create_quad_tri(bm, v1, v2, firstv2, firstv1, nullptr, BM_CREATE_NOP);
1744 if (calc_uvs) {
1746 }
1747
1748 if (calc_uvs) {
1749 BM_mesh_calc_uvs_cone(bm, mat, rad2, rad1, segs, cap_ends, FACE_MARK, cd_loop_uv_offset);
1750 }
1751
1752 /* Collapse vertices at the first end. */
1753 if (rad1 == 0.0f) {
1754 if (cap_ends) {
1755 BM_vert_kill(bm, cent1);
1756 }
1757 for (int i = 0; i < side_faces_len; i++) {
1758 f = side_faces[i];
1760 BM_edge_collapse(bm, l->prev->e, l->prev->v, true, true);
1761 }
1762 }
1763
1764 /* Collapse vertices at the second end. */
1765 if (rad2 == 0.0f) {
1766 if (cap_ends) {
1767 BM_vert_kill(bm, cent2);
1768 }
1769 for (int i = 0; i < side_faces_len; i++) {
1770 f = side_faces[i];
1772 BM_edge_collapse(bm, l->next->e, l->next->v, true, true);
1773 }
1774 }
1775
1776 if (!cap_tris) {
1777 BMO_op_callf(bm, op->flag, "dissolve_faces faces=%ff", FACE_NEW);
1778 }
1779
1780 if (side_faces != nullptr) {
1781 MEM_delete(side_faces);
1782 }
1783
1785}
1786
1788 float mat[4][4],
1789 const float radius_top,
1790 const float radius_bottom,
1791 const int segments,
1792 const bool cap_ends,
1793 const short oflag,
1794 const int cd_loop_uv_offset)
1795{
1796 BMFace *f;
1797 BMLoop *l;
1798 BMIter fiter, liter;
1799
1800 const float uv_width = 1.0f / float(segments);
1801 const float uv_height = cap_ends ? 0.5f : 1.0f;
1802
1803 /* Note that all this allows us to handle all cases
1804 * (real cone, truncated cone, with or without ends capped)
1805 * with a single common code. */
1806 const float uv_center_y = cap_ends ? 0.25f : 0.5f;
1807 const float uv_center_x_top = cap_ends ? 0.25f : 0.5f;
1808 const float uv_center_x_bottom = cap_ends ? 0.75f : 0.5f;
1809 const float uv_radius = cap_ends ? 0.24f : 0.5f;
1810
1811 /* Using the opposite's end uv_scale as a fallback allows us to handle 'real cone' case. */
1812 const float uv_scale_top = (radius_top != 0.0f) ?
1813 (uv_radius / radius_top) :
1814 ((radius_bottom != 0.0f) ? (uv_radius / radius_bottom) :
1815 uv_radius);
1816 const float uv_scale_bottom = (radius_bottom != 0.0f) ? (uv_radius / radius_bottom) :
1817 uv_scale_top;
1818
1819 float local_up[3] = {0.0f, 0.0f, 1.0f};
1820
1821 float x, y;
1822 float inv_mat[4][4];
1823 int loop_index;
1824
1825 /* Transform the up-vector like we did the cone itself, without location. */
1826 mul_mat3_m4_v3(mat, local_up);
1827 /* Remove global scaling. */
1828 normalize_v3(local_up);
1829
1830 invert_m4_m4(inv_mat, mat);
1831
1832 BLI_assert(cd_loop_uv_offset != -1); /* caller is responsible for ensuring the mesh has UVs */
1833
1834 x = 1.0f;
1835 y = 1.0f - uv_height;
1836
1837 BM_ITER_MESH (f, &fiter, bm, BM_FACES_OF_MESH) {
1838 if (!BMO_face_flag_test(bm, f, oflag)) {
1839 continue;
1840 }
1841
1842 if (f->len == 4 && radius_top && radius_bottom) {
1843 /* side face - so unwrap it in a rectangle */
1844 BM_ITER_ELEM_INDEX (l, &liter, f, BM_LOOPS_OF_FACE, loop_index) {
1845 float *luv = BM_ELEM_CD_GET_FLOAT_P(l, cd_loop_uv_offset);
1846
1847 switch (loop_index) {
1848 case 0:
1849 /* Continue in the last position */
1850 break;
1851 case 1:
1852 y += uv_height;
1853 break;
1854 case 2:
1855 x -= uv_width;
1856 break;
1857 case 3:
1858 y -= uv_height;
1859 break;
1860 default:
1861 break;
1862 }
1863
1864 luv[0] = x;
1865 luv[1] = y;
1866 }
1867 }
1868 else {
1869 /* Top or bottom face - so unwrap it by transforming
1870 * back to a circle and using the X/Y coords. */
1872
1873 BM_ITER_ELEM (l, &liter, f, BM_LOOPS_OF_FACE) {
1874 float *luv = BM_ELEM_CD_GET_FLOAT_P(l, cd_loop_uv_offset);
1875 float uv_vco[3];
1876
1877 mul_v3_m4v3(uv_vco, inv_mat, l->v->co);
1878
1879 if (dot_v3v3(f->no, local_up) > 0.0f) { /* if this is a top face of the cone */
1880 luv[0] = uv_center_x_top + uv_vco[0] * uv_scale_top;
1881 luv[1] = uv_center_y + uv_vco[1] * uv_scale_top;
1882 }
1883 else {
1884 luv[0] = uv_center_x_bottom + uv_vco[0] * uv_scale_bottom;
1885 luv[1] = uv_center_y + uv_vco[1] * uv_scale_bottom;
1886 }
1887 }
1888 }
1889 }
1890}
1891
1893{
1894 BMVert *verts[8];
1895 float mat[4][4];
1896 float off = BMO_slot_float_get(op->slots_in, "size") / 2.0f;
1897
1898 const int cd_loop_uv_offset = CustomData_get_offset(&bm->ldata, CD_PROP_FLOAT2);
1899 const bool calc_uvs = (cd_loop_uv_offset != -1) && BMO_slot_bool_get(op->slots_in, "calc_uvs");
1900
1901 BMO_slot_mat4_get(op->slots_in, "matrix", mat);
1902
1903 if (!off) {
1904 off = 0.5f;
1905 }
1906 int i = 0;
1907
1908 for (int x = -1; x < 2; x += 2) {
1909 for (int y = -1; y < 2; y += 2) {
1910 for (int z = -1; z < 2; z += 2) {
1911 float vec[3] = {float(x) * off, float(y) * off, float(z) * off};
1912 mul_m4_v3(mat, vec);
1913 verts[i] = BM_vert_create(bm, vec, nullptr, BM_CREATE_NOP);
1914 BMO_vert_flag_enable(bm, verts[i], VERT_MARK);
1915 i++;
1916 }
1917 }
1918 }
1919
1920 for (i = 0; i < ARRAY_SIZE(cube_faces); i++) {
1921 BMFace *f;
1922 BMVert *quad[4] = {
1923 verts[cube_faces[i][0]],
1924 verts[cube_faces[i][1]],
1925 verts[cube_faces[i][2]],
1926 verts[cube_faces[i][3]],
1927 };
1928
1929 f = BM_face_create_verts(bm, quad, 4, nullptr, BM_CREATE_NOP, true);
1930 if (calc_uvs) {
1932 }
1933 }
1934
1935 if (calc_uvs) {
1937 }
1938
1940}
1941
1943{
1944 BMFace *f;
1945 BMLoop *l;
1946 BMIter fiter, liter;
1947 const float width = 0.25f;
1948
1949 const int cd_loop_uv_offset = CustomData_get_offset(&bm->ldata, CD_PROP_FLOAT2);
1950
1951 float x = 0.375f;
1952 float y = 0.0f;
1953
1954 int loop_index;
1955
1956 BLI_assert(cd_loop_uv_offset != -1); /* the caller can ensure that we have UVs */
1957
1958 BM_ITER_MESH (f, &fiter, bm, BM_FACES_OF_MESH) {
1959 if (!BMO_face_flag_test(bm, f, oflag)) {
1960 continue;
1961 }
1962
1963 BM_ITER_ELEM_INDEX (l, &liter, f, BM_LOOPS_OF_FACE, loop_index) {
1964 float *luv = BM_ELEM_CD_GET_FLOAT_P(l, cd_loop_uv_offset);
1965
1966 luv[0] = x;
1967 luv[1] = y;
1968
1969 switch (loop_index) {
1970 case 0:
1971 x += width;
1972 break;
1973 case 1:
1974 y += width;
1975 break;
1976 case 2:
1977 x -= width;
1978 break;
1979 case 3:
1980 y -= width;
1981 break;
1982 default:
1983 break;
1984 }
1985 }
1986
1987 if (y >= 0.75f && x > 0.125f) {
1988 x = 0.125f;
1989 y = 0.5f;
1990 }
1991 else if (x <= 0.125f) {
1992 x = 0.625f;
1993 y = 0.5f;
1994 }
1995 else {
1996 y += 0.25f;
1997 }
1998 }
1999}
2000
2001} // namespace blender
CustomData interface, see also DNA_customdata_types.h.
#define M_PI
#define M_PI_4
Read Blender memory allocation and freeing.
#define BLI_assert_unreachable()
#define UNUSED_VARS_NDEBUG(...)
#define ELEM(...)
#define BM_FACE_FIRST_LOOP(p)
#define BM_ELEM_CD_GET_FLOAT_P(ele, offset)
#define BM_ITER_ELEM(ele, iter, data, itype)
#define BM_ITER_MESH(ele, iter, bm, itype)
#define BM_ITER_ELEM_INDEX(ele, iter, data, itype, indexvar)
#define BMO_edge_flag_enable(bm, e, oflag)
#define BMO_vert_flag_enable(bm, e, oflag)
#define BMO_face_flag_enable(bm, e, oflag)
#define BMO_vert_flag_test(bm, e, oflag)
#define BMO_face_flag_test(bm, e, oflag)
#define FACE_MARK
#define EDGE_MARK
Definition bmo_bridge.cc:28
#define VERT_MARK
#define FACE_NEW
#define XY(_x, _y)
#define EDGE_ORIG
ccl_device float sin_phi(const float3 w)
SIMD_FORCE_INLINE const btScalar & z() const
Return the z value.
Definition btQuadWord.h:117
SIMD_FORCE_INLINE btScalar angle(const btVector3 &v) const
Return the angle between this and another vector.
Definition btVector3.h:356
ccl_device_inline dual1 len(const ccl_private dual< T > &a)
Definition math_dual.h:263
BMesh Iterators.
MINLINE float min_ff(float a, float b)
int CustomData_get_offset(const CustomData *data, eCustomDataType type)
BLI_assert(slot->slot_subtype.map==BMO_OP_SLOT_SUBTYPE_MAP_FLT)
BMFace * BM_face_create_verts(BMesh *bm, BMVert **vert_arr, const int len, const BMFace *f_example, const eBMCreateFlag create_flag, const bool create_edges)
int BMO_slot_int_get(BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_name)
static const float icovert[12][3]
void BM_mesh_calc_uvs_cone(BMesh *bm, float mat[4][4], float radius_top, float radius_bottom, int segments, bool cap_ends, short oflag, int cd_loop_uv_offset)
MINLINE void copy_v3_v3(float r[3], const float a[3])
unsigned int uint
Definition BKE_text.h:55
void * MEM_new_array_uninitialized(size_t len, size_t size, const char *str) ATTR_WARN_UNUSED_RESULT ATTR_ALLOC_SIZE(1
ATTR_WARN_UNUSED_RESULT const BMLoop * l
void BM_vert_kill(BMesh *bm, BMVert *v)
float BMO_slot_float_get(BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_name)
void mul_v3_m4v3(float r[3], const float mat[4][4], const float vec[3])
MINLINE void copy_v2_v2(float r[2], const float a[2])
void BMO_slot_buffer_flag_enable(BMesh *bm, BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_name, char htype, short oflag)
BMO_FLAG_BUFFER.
bool invert_m4_m4(float inverse[4][4], const float mat[4][4])
MINLINE float safe_acosf(float a)
bool BMO_op_initf(BMesh *bm, BMOperator *op, int flag, const char *fmt,...)
void BM_mesh_calc_uvs_grid(BMesh *bm, uint x_segments, uint y_segments, short oflag, int cd_loop_uv_offset)
void axis_angle_to_mat3(float R[3][3], const float axis[3], float angle)
static float3 quadsphere_co_from_cube_equi_angular(const float3 &co, const bool on_face[3], const float angle, const float angle_scale)
static const int monkeyo
MINLINE int max_ii(int a, int b)
void bmo_create_uvsphere_exec(BMesh *bm, BMOperator *op)
ATTR_WARN_UNUSED_RESULT const BMVert * v
BMVert * BM_vert_create(BMesh *bm, const float co[3], const BMVert *v_example, const eBMCreateFlag create_flag)
Main function for creating a new vertex.
void BMO_op_exec(BMesh *bm, BMOperator *op)
BMESH OPSTACK EXEC OP.
void sin_cos_from_fraction(int numerator, int denominator, float *r_sin, float *r_cos)
static const float cube_faces_uv[6][2]
BMVert * BM_edge_collapse(BMesh *bm, BMEdge *e_kill, BMVert *v_kill, const bool do_del, const bool kill_degenerate_faces)
void mul_m4_v3(const float M[4][4], float r[3])
BMFace * BM_face_create_quad_tri(BMesh *bm, BMVert *v1, BMVert *v2, BMVert *v3, BMVert *v4, const BMFace *f_example, const eBMCreateFlag create_flag)
Make Quad/Triangle.
VecBase< int32_t, 3 > int3
@ BM_CREATE_NOP
Definition bmesh_core.hh:34
static const short icoface[20][3]
void BM_face_normal_update(BMFace *f)
void BMO_slot_buffer_from_enabled_flag(BMesh *bm, BMOperator *op, BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_name, char htype, short oflag)
void bmo_create_circle_exec(BMesh *bm, BMOperator *op)
static const int monkeynv
static const signed char monkeyv[271][3]
static void bm_mesh_calc_uvs_sphere_face(BMFace *f, const int cd_loop_uv_offset)
constexpr size_t ARRAY_SIZE(const T(&arg)[N]) noexcept
bool BMO_op_callf(BMesh *bm, int flag, const char *fmt,...)
MINLINE float len_v3(const float a[3]) ATTR_WARN_UNUSED_RESULT
void BMO_slot_mat4_get(BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_name, float r_mat[4][4])
MINLINE void zero_v3(float r[3])
void BM_mesh_calc_uvs_circle(BMesh *bm, float mat[4][4], float radius, short oflag, int cd_loop_uv_offset)
static signed char monkeyf[250][4]
void mul_mat3_m4_v3(const float mat[4][4], float r[3])
void bmo_create_quadsphere_exec(BMesh *bm, BMOperator *op)
BMOpSlot * BMO_slot_get(BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *identifier)
BMESH OPSTACK GET SLOT.
void bmo_create_grid_exec(BMesh *bm, BMOperator *op)
void bmo_create_icosphere_exec(BMesh *bm, BMOperator *op)
MINLINE float normalize_v3(float n[3])
bool BMO_slot_bool_get(BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_name)
ATTR_WARN_UNUSED_RESULT const BMVert * v2
void * BMO_slot_buffer_alloc(BMOperator *op, BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_name, int len)
MINLINE float normalize_v3_length(float n[3], float unit_length)
static const float monkeyuvs[]
static const int monkeynf
void bmo_create_cube_exec(BMesh *bm, BMOperator *op)
static const char cube_faces[6][4]
static float3 quadsphere_co_from_cube(const float3 &co, const bool on_face[3], const QuadSphereMethod method)
void bmo_create_cone_exec(BMesh *bm, BMOperator *op)
VecBase< float, 3 > float3
void BMO_op_finish(BMesh *bm, BMOperator *op)
BMESH OPSTACK FINISH OP.
@ QUADSPHERE_METHOD_EQUI_ANGULAR
@ QUADSPHERE_METHOD_EQUI_ANGULAR_EVEN_AREA
MINLINE float len_v3v3(const float a[3], const float b[3]) ATTR_WARN_UNUSED_RESULT
void bmo_create_monkey_exec(BMesh *bm, BMOperator *op)
ATTR_WARN_UNUSED_RESULT const BMFlagLayer const short oflag
void mul_v3_m3v3(float r[3], const float M[3][3], const float a[3])
void BM_mesh_calc_uvs_sphere(BMesh *bm, short oflag, int cd_loop_uv_offset)
void BM_mesh_calc_uvs_cube(BMesh *bm, short oflag)
MINLINE float dot_v3v3(const float a[3], const float b[3]) ATTR_WARN_UNUSED_RESULT
BMEdge * BM_edge_create(BMesh *bm, BMVert *v1, BMVert *v2, const BMEdge *e_example, const eBMCreateFlag create_flag)
Main function for creating a new edge.
ATTR_WARN_UNUSED_RESULT const BMVert const BMEdge * e
static const float icouvs[60][2]
#define fabsf
#define sinf
#define cosf
#define atan2f
KERNEL_FEATURE_LIGHT_PASSES KERNEL_FEATURE_PATH_GUIDING float
union blender::BMOpSlot::@376352321363166111241172004263244043165250166277 data
struct BMOpSlot slots_in[BMO_OP_MAX_SLOTS]
struct BMOpSlot slots_out[BMO_OP_MAX_SLOTS]