| 18 | } |
| 19 | |
| 20 | static void subdivide(int depth, int face) |
| 21 | { |
| 22 | if(depth-- <= 0) return; |
| 23 | int idx[6]; |
| 24 | loopi(3) idx[i] = hemiindices[face+i]; |
| 25 | loopi(3) |
| 26 | { |
| 27 | int vert = heminumverts++; |
| 28 | hemiverts[vert] = vec(hemiverts[idx[i]]).add(hemiverts[idx[(i+1)%3]]).normalize(); //push on to unit sphere |
| 29 | idx[3+i] = vert; |
| 30 | hemiindices[face+i] = vert; |
| 31 | } |
| 32 | subdivide(depth, face); |
| 33 | loopi(3) genface(depth, idx[i], idx[3+i], idx[3+(i+2)%3]); |
| 34 | } |
| 35 | |
| 36 | //subdiv version wobble much more nicely than a lat/longitude version |
| 37 | static void inithemisphere(int hres, int depth) |