818 const int coarse_face_index)
823 const int ptex_face_inner_resolution = ptex_face_resolution - 2;
824 const int num_inner_vertices_per_ptex = (ptex_face_resolution - 1) * (ptex_face_resolution - 2);
825 const int num_subdiv_vertices_per_coarse_edge = resolution - 2;
828 const int start_vertex_index = center_vertex_index + 1;
831 for (
int corner = 0; corner < coarse_face.
size(); corner++) {
832 const int start_ptex_face_vertex_index = start_vertex_index +
833 corner * num_inner_vertices_per_ptex;
839 start_ptex_face_vertex_index,
840 ptex_face_inner_resolution + 1);
841 for (
int row = 0; row < ptex_face_inner_resolution - 1; row++) {
842 const int start_row_vertex_index = start_ptex_face_vertex_index +
843 row * (ptex_face_inner_resolution + 1);
849 start_row_vertex_index,
850 ptex_face_inner_resolution + 1);
855 start_row_vertex_index +
856 ptex_face_inner_resolution + 1,
857 ptex_face_inner_resolution + 1);
861 for (
int corner = 0; corner < coarse_face.
size(); corner++) {
862 const int next_corner = (corner + 1) % coarse_face.
size();
863 int current_patch_vertex_index = start_vertex_index + corner * num_inner_vertices_per_ptex +
864 ptex_face_inner_resolution;
865 int next_path_vertex_index = start_vertex_index + next_corner * num_inner_vertices_per_ptex +
866 num_inner_vertices_per_ptex - ptex_face_resolution + 1;
867 for (
int row = 0; row < ptex_face_inner_resolution; row++, subdiv_edge_index++) {
868 const int v1 = current_patch_vertex_index;
869 const int v2 = next_path_vertex_index;
872 current_patch_vertex_index += ptex_face_inner_resolution + 1;
873 next_path_vertex_index += 1;
877 if (ptex_face_resolution >= 3) {
878 for (
int corner = 0; corner < coarse_face.
size(); corner++, subdiv_edge_index++) {
879 const int current_patch_end_vertex_index = start_vertex_index +
880 corner * num_inner_vertices_per_ptex +
881 num_inner_vertices_per_ptex - 1;
882 const int v1 = center_vertex_index;
883 const int v2 = current_patch_end_vertex_index;
889 int prev_corner = coarse_face.
size() - 1;
890 for (
int corner = 0; corner < coarse_face.
size(); corner++) {
897 coarse_edge_i * num_subdiv_vertices_per_coarse_edge;
898 const bool flip = (coarse_edge[1] == coarse_vert);
899 int side_start_index;
900 if (ptex_face_resolution >= 3) {
901 side_start_index = start_vertex_index + num_inner_vertices_per_ptex * corner;
904 side_start_index = center_vertex_index;
906 for (
int i = 0; i < ptex_face_resolution - 1; i++, subdiv_edge_index++) {
907 const int v1 = (flip) ? (start_edge_vertex + (resolution - i - 3)) :
908 (start_edge_vertex + i);
909 const int v2 = side_start_index + i;
914 if (ptex_face_resolution >= 3) {
917 coarse_prev_edge * num_subdiv_vertices_per_coarse_edge;
918 const bool flip = (coarse_edge[1] == coarse_vert);
919 int side_start_index = start_vertex_index + num_inner_vertices_per_ptex * corner;
920 for (
int i = 0; i < ptex_face_resolution - 2; i++, subdiv_edge_index++) {
921 const int v1 = (flip) ? (start_edge_vertex + (resolution - i - 3)) :
922 (start_edge_vertex + i);
923 const int v2 = side_start_index + (ptex_face_inner_resolution + 1) * i;
928 prev_corner = corner;
1078 const int coarse_face_index)
1084 const int ptex_inner_resolution = ptex_resolution - 2;
1085 const int num_subdiv_edges_per_coarse_edge = resolution - 1;
1086 const int num_subdiv_vertices_per_coarse_edge = resolution - 2;
1087 const float inv_ptex_resolution_1 = 1.0f /
float(ptex_resolution - 1);
1093 const int start_loop_index = 4 * start_face_index;
1094 const float du = inv_ptex_resolution_1;
1095 const float dv = inv_ptex_resolution_1;
1097 int subdiv_loop_index = start_loop_index;
1099 for (
int y = 1; y < ptex_resolution - 2; y++) {
1100 const float v = y * inv_ptex_resolution_1;
1101 const int inner_y = y - 1;
1102 for (
int x = 1; x < ptex_resolution - 2; x++, subdiv_loop_index += 4) {
1103 const int inner_x = x - 1;
1104 const float u = x * inv_ptex_resolution_1;
1106 const int v0 = start_vertex_index + (inner_y * ptex_inner_resolution + inner_x);
1107 const int v1 = v0 + 1;
1108 const int v2 = v0 + ptex_inner_resolution + 1;
1109 const int v3 = v0 + ptex_inner_resolution;
1111 const int e0 = start_edge_index + (inner_y * (2 * ptex_inner_resolution - 1) + inner_x);
1112 const int e1 = e0 + ptex_inner_resolution;
1113 const int e2 = e0 + (2 * ptex_inner_resolution - 1);
1114 const int e3 = e0 + ptex_inner_resolution - 1;
1138 int prev_corner_index = coarse_face.
size() - 1;
1139 for (
int corner = 0; corner < coarse_face.
size(); corner++) {
1148 coarse_edge_i * num_subdiv_vertices_per_coarse_edge;
1149 const bool flip = (coarse_edge[1] == coarse_vert);
1150 int side_start_index = start_vertex_index;
1151 int side_stride = 0;
1154 int e2_offset, e2_stride;
1155 float u,
v, delta_u, delta_v;
1156 if (coase_prev_vert == prev_coarse_edge[0]) {
1158 num_subdiv_vertices_per_coarse_edge - 1;
1160 num_subdiv_edges_per_coarse_edge - 1;
1176 else if (corner == 1) {
1177 side_start_index += resolution - 3;
1178 side_stride = resolution - 2;
1179 e2_offset = 2 * num_subdiv_edges_per_coarse_edge - 4;
1180 e2_stride = 2 * num_subdiv_edges_per_coarse_edge - 3;
1186 else if (corner == 2) {
1187 side_start_index += num_subdiv_vertices_per_coarse_edge *
1188 num_subdiv_vertices_per_coarse_edge -
1198 else if (corner == 3) {
1199 side_start_index += num_subdiv_vertices_per_coarse_edge *
1200 (num_subdiv_vertices_per_coarse_edge - 1);
1201 side_stride = -(resolution - 2);
1203 (2 * num_subdiv_edges_per_coarse_edge - 3);
1204 e2_stride = -(2 * num_subdiv_edges_per_coarse_edge - 3);
1210 for (
int i = 0; i < resolution - 2; i++, subdiv_loop_index += 4) {
1213 v1 = start_edge_vertex + (resolution - i - 3);
1216 v1 = start_edge_vertex + i;
1218 const int v2 = side_start_index + side_stride * i;
1222 num_subdiv_edges_per_coarse_edge - i - 1;
1228 corner * num_subdiv_vertices_per_coarse_edge + i;
1232 ((corner - 1 + coarse_face.
size()) % coarse_face.
size()) *
1233 num_subdiv_vertices_per_coarse_edge +
1234 num_subdiv_vertices_per_coarse_edge - 1;
1237 e2 = start_edge_index + e2_offset + e2_stride * (i - 1);
1240 const float loop_u = u + delta_u * i;
1241 const float loop_v =
v + delta_v * i;
1266 prev_corner_index = corner;
1272 const int coarse_face_index)
1278 const int ptex_face_inner_resolution = ptex_face_resolution - 2;
1279 const float inv_ptex_resolution_1 = 1.0f /
float(ptex_face_resolution - 1);
1280 const int num_inner_vertices_per_ptex = (ptex_face_resolution - 1) * (ptex_face_resolution - 2);
1282 ptex_face_inner_resolution + 1);
1283 const int num_subdiv_vertices_per_coarse_edge = resolution - 2;
1284 const int num_subdiv_edges_per_coarse_edge = resolution - 1;
1288 const int start_vertex_index = center_vertex_index + 1;
1289 const int start_inner_vertex_index = center_vertex_index + 1;
1292 const int start_loop_index = 4 * start_face_index;
1293 const float du = inv_ptex_resolution_1;
1294 const float dv = inv_ptex_resolution_1;
1296 int subdiv_loop_index = start_loop_index;
1297 for (
int corner = 0; corner < coarse_face.
size(); corner++) {
1298 const int corner_vertex_index = start_vertex_index + corner * num_inner_vertices_per_ptex;
1299 const int corner_edge_index = start_edge_index + corner * num_inner_edges_per_ptex_face;
1300 for (
int y = 1; y < ptex_face_inner_resolution; y++) {
1301 const float v = y * inv_ptex_resolution_1;
1302 const int inner_y = y - 1;
1303 for (
int x = 1; x < ptex_face_inner_resolution + 1; x++, subdiv_loop_index += 4) {
1304 const int inner_x = x - 1;
1305 const float u = x * inv_ptex_resolution_1;
1307 const int v0 = corner_vertex_index +
1308 (inner_y * (ptex_face_inner_resolution + 1) + inner_x);
1309 const int v1 = v0 + 1;
1310 const int v2 = v0 + ptex_face_inner_resolution + 2;
1311 const int v3 = v0 + ptex_face_inner_resolution + 1;
1313 const int e0 = corner_edge_index +
1314 (inner_y * (2 * ptex_face_inner_resolution + 1) + inner_x);
1315 const int e1 = e0 + ptex_face_inner_resolution + 1;
1316 const int e2 = e0 + (2 * ptex_face_inner_resolution + 1);
1317 const int e3 = e0 + ptex_face_inner_resolution;
1321 ptex_face_index + corner,
1341 for (
int corner = 0; corner < coarse_face.
size(); corner++) {
1342 const int next_corner = (corner + 1) % coarse_face.
size();
1343 const int corner_edge_index = start_edge_index + corner * num_inner_edges_per_ptex_face;
1344 const int next_corner_edge_index = start_edge_index +
1345 next_corner * num_inner_edges_per_ptex_face;
1346 int current_patch_vertex_index = start_inner_vertex_index +
1347 corner * num_inner_vertices_per_ptex +
1348 ptex_face_inner_resolution;
1349 int next_path_vertex_index = start_inner_vertex_index +
1350 next_corner * num_inner_vertices_per_ptex +
1351 num_inner_vertices_per_ptex - ptex_face_resolution + 1;
1352 int v0 = current_patch_vertex_index;
1353 int v1 = next_path_vertex_index;
1354 current_patch_vertex_index += ptex_face_inner_resolution + 1;
1355 next_path_vertex_index += 1;
1356 int e0 = start_edge_index + coarse_face.
size() * num_inner_edges_per_ptex_face +
1357 corner * (ptex_face_resolution - 2);
1358 int e1 = next_corner_edge_index + num_inner_edges_per_ptex_face - ptex_face_resolution + 2;
1359 int e3 = corner_edge_index + 2 * ptex_face_resolution - 4;
1360 for (
int row = 1; row < ptex_face_inner_resolution; row++, subdiv_loop_index += 4) {
1361 const int v2 = next_path_vertex_index;
1362 const int v3 = current_patch_vertex_index;
1363 const int e2 = e0 + 1;
1364 const float u = row * du;
1365 const float v = 1.0f - dv;
1369 ptex_face_index + next_corner,
1385 current_patch_vertex_index += ptex_face_inner_resolution + 1;
1386 next_path_vertex_index += 1;
1391 e3 += 2 * ptex_face_resolution - 3;
1395 if (ptex_face_resolution >= 3) {
1396 const int start_center_edge_index = start_edge_index + (num_inner_edges_per_ptex_face +
1397 ptex_face_inner_resolution) *
1399 const int start_boundary_edge = start_edge_index +
1400 coarse_face.
size() * num_inner_edges_per_ptex_face +
1401 ptex_face_inner_resolution - 1;
1402 for (
int corner = 0, prev_corner = coarse_face.
size() - 1; corner < coarse_face.
size();
1403 prev_corner = corner, corner++, subdiv_loop_index += 4)
1405 const int corner_edge_index = start_edge_index + corner * num_inner_edges_per_ptex_face;
1406 const int current_patch_end_vertex_index = start_vertex_index +
1407 corner * num_inner_vertices_per_ptex +
1408 num_inner_vertices_per_ptex - 1;
1409 const int prev_current_patch_end_vertex_index = start_vertex_index +
1410 prev_corner * num_inner_vertices_per_ptex +
1411 num_inner_vertices_per_ptex - 1;
1412 const int v0 = center_vertex_index;
1413 const int v1 = prev_current_patch_end_vertex_index;
1414 const int v2 = current_patch_end_vertex_index - 1;
1415 const int v3 = current_patch_end_vertex_index;
1416 const int e0 = start_center_edge_index + prev_corner;
1417 const int e1 = start_boundary_edge + prev_corner * (ptex_face_inner_resolution);
1418 const int e2 = corner_edge_index + num_inner_edges_per_ptex_face - 1;
1419 const int e3 = start_center_edge_index + corner;
1420 const float u = 1.0f - du;
1421 const float v = 1.0f - dv;
1425 ptex_face_index + corner,
1444 for (
int prev_corner = coarse_face.
size() - 1, corner = 0; corner < coarse_face.
size();
1445 prev_corner = corner, corner++)
1454 const bool flip = (coarse_edge[1] == coarse_vert);
1456 coarse_edge_i * num_subdiv_vertices_per_coarse_edge;
1457 const int corner_vertex_index = start_vertex_index + corner * num_inner_vertices_per_ptex;
1458 const int corner_edge_index = start_edge_index + corner * num_inner_edges_per_ptex_face;
1462 if (coase_prev_vert == prev_coarse_edge[0]) {
1464 num_subdiv_vertices_per_coarse_edge - 1;
1466 num_subdiv_edges_per_coarse_edge - 1;
1472 for (
int i = 0; i <= ptex_face_inner_resolution; i++, subdiv_loop_index += 4) {
1475 v1 = start_edge_vertex + (resolution - i - 3);
1478 v1 = start_edge_vertex + i;
1481 if (ptex_face_inner_resolution >= 1) {
1482 v2 = corner_vertex_index + i;
1485 v2 = center_vertex_index;
1490 num_subdiv_edges_per_coarse_edge - i - 1;
1495 int e1 = start_edge_index + corner * (2 * ptex_face_inner_resolution + 1);
1496 if (ptex_face_resolution >= 3) {
1497 e1 += coarse_face.
size() *
1498 (num_inner_edges_per_ptex_face + ptex_face_inner_resolution + 1) +
1502 if (i == 0 && ptex_face_resolution >= 3) {
1503 e2 = start_edge_index +
1504 coarse_face.
size() *
1505 (num_inner_edges_per_ptex_face + ptex_face_inner_resolution + 1) +
1506 corner * (2 * ptex_face_inner_resolution + 1) + ptex_face_inner_resolution + 1;
1508 else if (i == 0 && ptex_face_resolution < 3) {
1509 e2 = start_edge_index + prev_corner * (2 * ptex_face_inner_resolution + 1);
1512 e2 = corner_edge_index + i - 1;
1514 const float u = du * i;
1515 const float v = 0.0f;
1519 ptex_face_index + corner,
1540 const bool flip_prev = (prev_coarse_edge[1] == coarse_vert);
1541 v0 = corner_vertex_index;
1542 if (coase_prev_vert == prev_coarse_edge[0]) {
1544 num_subdiv_vertices_per_coarse_edge - 1;
1549 e3 = start_edge_index +
1550 coarse_face.
size() * (num_inner_edges_per_ptex_face + ptex_face_inner_resolution + 1) +
1551 corner * (2 * ptex_face_inner_resolution + 1) + ptex_face_inner_resolution + 1;
1552 for (
int i = 0; i <= ptex_face_inner_resolution - 1; i++, subdiv_loop_index += 4) {
1555 if (i == ptex_face_inner_resolution - 1) {
1556 v1 = start_vertex_index + prev_corner * num_inner_vertices_per_ptex +
1557 ptex_face_inner_resolution;
1558 e1 = start_edge_index +
1559 coarse_face.
size() *
1560 (num_inner_edges_per_ptex_face + ptex_face_inner_resolution + 1) +
1561 prev_corner * (2 * ptex_face_inner_resolution + 1) + ptex_face_inner_resolution;
1562 e0 = start_edge_index + coarse_face.
size() * num_inner_edges_per_ptex_face +
1563 prev_corner * ptex_face_inner_resolution;
1566 v1 = v0 + ptex_face_inner_resolution + 1;
1567 e0 = corner_edge_index + ptex_face_inner_resolution +
1568 i * (2 * ptex_face_inner_resolution + 1);
1571 int v2 = flip_prev ? v3 - 1 : v3 + 1;
1575 num_subdiv_edges_per_coarse_edge - 2 - i;
1581 const float u = 0.0f;
1582 const float v = du * (i + 1);
1586 ptex_face_index + corner,