| 1460 | } |
| 1461 | |
| 1462 | void gather_grid(RTCGeometry geom, avector<Vec3fa>& positions, size_t width, size_t height, unsigned int* indices, avector<Vec3fa>& vertices, unsigned int edgey) |
| 1463 | { |
| 1464 | // |
| 1465 | // | <---------- <---------- |
| 1466 | // | /\ | /\ . |
| 1467 | // | edgey | | | |
| 1468 | // | | | | |
| 1469 | // \/ | \/ | |
| 1470 | |
| 1471 | /* gather all rows */ |
| 1472 | size_t y=0; |
| 1473 | for (; y<height; y++) |
| 1474 | { |
| 1475 | /* here edgey points from top/left vertex downwards */ |
| 1476 | unsigned int edgex = edgey; |
| 1477 | |
| 1478 | /* gather all columns */ |
| 1479 | size_t x=0; |
| 1480 | for (; x<width; x++) |
| 1481 | { |
| 1482 | /* here edgex points from left vertex of row downwards */ |
| 1483 | positions[y*(width+1)+x] = vertices[indices[edgex]]; |
| 1484 | |
| 1485 | /* prev -> prev -> opposite moves to the next column (unless we reach the right end) */ |
| 1486 | edgex = rtcGetGeometryPreviousHalfEdge(geom,edgex); |
| 1487 | if (x+1 < width) { |
| 1488 | edgex = rtcGetGeometryPreviousHalfEdge(geom,edgex); |
| 1489 | edgex = rtcGetGeometryOppositeHalfEdge(geom,0,edgex); |
| 1490 | } |
| 1491 | } |
| 1492 | /* load rightmost vertex */ |
| 1493 | positions[y*(width+1)+x] = vertices[indices[edgex]]; |
| 1494 | |
| 1495 | /* next -> opposite -> next moves to next row (unless we reach the bottom) */ |
| 1496 | edgey = rtcGetGeometryNextHalfEdge(geom,edgey); |
| 1497 | if (y+1 < height) { |
| 1498 | edgey = rtcGetGeometryOppositeHalfEdge(geom,0,edgey); |
| 1499 | edgey = rtcGetGeometryNextHalfEdge(geom,edgey); |
| 1500 | } |
| 1501 | } |
| 1502 | |
| 1503 | /* special treatment for last row, edgy points from the bottom/left vertex to the right */ |
| 1504 | unsigned int edgex = edgey; |
| 1505 | for (size_t x=0; x<width; x++) |
| 1506 | { |
| 1507 | positions[y*(width+1)+x] = vertices[indices[edgex]]; |
| 1508 | |
| 1509 | /* next -> opposite -> next moves to the next column (unless we reach the right end) */ |
| 1510 | edgex = rtcGetGeometryNextHalfEdge(geom,edgex); |
| 1511 | if (x+1 < width) { |
| 1512 | edgex = rtcGetGeometryOppositeHalfEdge(geom,0,edgex); |
| 1513 | edgex = rtcGetGeometryNextHalfEdge(geom,edgex); |
| 1514 | } |
| 1515 | } |
| 1516 | /* load rightmost vertex */ |
| 1517 | positions[height*(width+1)+width] = vertices[indices[edgex]]; |
| 1518 | } |
| 1519 |
no test coverage detected