| 2163 | } |
| 2164 | |
| 2165 | static void fillCellQuadrics(Quadric* cell_quadrics, const unsigned int* indices, size_t index_count, const Vector3* vertex_positions, const unsigned int* vertex_cells) |
| 2166 | { |
| 2167 | for (size_t i = 0; i < index_count; i += 3) |
| 2168 | { |
| 2169 | unsigned int i0 = indices[i + 0]; |
| 2170 | unsigned int i1 = indices[i + 1]; |
| 2171 | unsigned int i2 = indices[i + 2]; |
| 2172 | |
| 2173 | unsigned int c0 = vertex_cells[i0]; |
| 2174 | unsigned int c1 = vertex_cells[i1]; |
| 2175 | unsigned int c2 = vertex_cells[i2]; |
| 2176 | |
| 2177 | int single_cell = (c0 == c1) & (c0 == c2); |
| 2178 | |
| 2179 | Quadric Q; |
| 2180 | quadricFromTriangle(Q, vertex_positions[i0], vertex_positions[i1], vertex_positions[i2], single_cell ? 3.f : 1.f); |
| 2181 | |
| 2182 | if (single_cell) |
| 2183 | { |
| 2184 | quadricAdd(cell_quadrics[c0], Q); |
| 2185 | } |
| 2186 | else |
| 2187 | { |
| 2188 | quadricAdd(cell_quadrics[c0], Q); |
| 2189 | quadricAdd(cell_quadrics[c1], Q); |
| 2190 | quadricAdd(cell_quadrics[c2], Q); |
| 2191 | } |
| 2192 | } |
| 2193 | } |
| 2194 | |
| 2195 | static void fillCellReservoirs(Reservoir* cell_reservoirs, size_t cell_count, const Vector3* vertex_positions, const float* vertex_colors, size_t vertex_colors_stride, size_t vertex_count, const unsigned int* vertex_cells) |
| 2196 | { |
no test coverage detected