277
static int VertDataEqual(const float *a, const float *b)
279
return a[0] == b[0] && a[1] == b[1] && a[2] == b[2];
281
#define VertDataZero(av) { float *_a = (float *)av; _a[0] = _a[1] = _a[2] = 0.0f; }
282
#define VertDataCopy(av, bv) { float *_a = (float *)av, *_b = (float *) bv; _a[0] = _b[0]; _a[1] = _b[1]; _a[2] = _b[2]; }
283
#define VertDataAdd(av, bv) { float *_a = (float *)av, *_b = (float *) bv; _a[0] += _b[0]; _a[1] += _b[1]; _a[2] += _b[2]; }
284
#define VertDataSub(av, bv) { float *_a = (float *)av, *_b = (float *) bv; _a[0] -= _b[0]; _a[1] -= _b[1]; _a[2] -= _b[2]; }
285
#define VertDataMulN(av, n) { float *_a = (float *)av; float _n = n; _a[0] *= _n; _a[1] *= _n; _a[2] *= _n; }
286
#define VertDataAvg4(tv, av, bv, cv, dv) \
288
float *_t = (float *) tv, *_a = (float *) av, *_b = (float *) bv, *_c = (float *) cv, *_d = (float *) dv; \
289
_t[0] = (_a[0] + _b[0] + _c[0] + _d[0]) * 0.25f; \
290
_t[1] = (_a[1] + _b[1] + _c[1] + _d[1]) * 0.25f; \
291
_t[2] = (_a[2] + _b[2] + _c[2] + _d[2]) * 0.25f; \
293
#define NormZero(av) { float *_a = (float *) av; _a[0] = _a[1] = _a[2] = 0.0f; }
294
#define NormCopy(av, bv) { float *_a = (float *) av, *_b = (float *) bv; _a[0] = _b[0]; _a[1] = _b[1]; _a[2] = _b[2]; }
295
#define NormAdd(av, bv) { float *_a = (float *) av, *_b = (float *) bv; _a[0] += _b[0]; _a[1] += _b[1]; _a[2] += _b[2]; }
272
#define NormZero(av) { float *_a = (float *) av; _a[0] = _a[1] = _a[2] = 0.0f; } (void)0
273
#define NormCopy(av, bv) { float *_a = (float *) av, *_b = (float *) bv; _a[0] = _b[0]; _a[1] = _b[1]; _a[2] = _b[2]; } (void)0
274
#define NormAdd(av, bv) { float *_a = (float *) av, *_b = (float *) bv; _a[0] += _b[0]; _a[1] += _b[1]; _a[2] += _b[2]; } (void)0
410
static int VertDataEqual(const float a[], const float b[], const CCGSubSurf *ss)
413
for (i = 0; i < ss->meshIFC.numLayers; i++) {
420
static void VertDataZero(float v[], const CCGSubSurf *ss)
422
memset(v, 0, sizeof(float) * ss->meshIFC.numLayers);
425
static void VertDataCopy(float dst[], const float src[], const CCGSubSurf *ss)
428
for (i = 0; i < ss->meshIFC.numLayers; i++)
432
static void VertDataAdd(float a[], const float b[], const CCGSubSurf *ss)
435
for (i = 0; i < ss->meshIFC.numLayers; i++)
439
static void VertDataSub(float a[], const float b[], const CCGSubSurf *ss)
442
for (i = 0; i < ss->meshIFC.numLayers; i++)
446
static void VertDataMulN(float v[], float f, const CCGSubSurf *ss)
449
for (i = 0; i < ss->meshIFC.numLayers; i++)
453
static void VertDataAvg4(float v[],
454
const float a[], const float b[],
455
const float c[], const float d[],
456
const CCGSubSurf *ss)
459
for (i = 0; i < ss->meshIFC.numLayers; i++)
460
v[i] = (a[i] + b[i] + c[i] + d[i]) * 0.25f;
427
465
static CCGVert *_vert_new(CCGVertHDL vHDL, CCGSubSurf *ss)
429
467
int num_vert_data = ss->subdivLevels + 1;
657
static CCG_INLINE void *_face_getIECo(CCGFace *f, int lvl, int S, int x, int levels, int dataSize)
695
BLI_INLINE void *_face_getIECo(CCGFace *f, int lvl, int S, int x, int levels, int dataSize)
659
697
int maxGridSize = ccg_gridsize(levels);
660
698
int spacing = ccg_spacing(levels, lvl);
661
699
byte *gridBase = FACE_getCenterData(f) + dataSize * (1 + S * (maxGridSize + maxGridSize * maxGridSize));
662
700
return &gridBase[dataSize * x * spacing];
664
static CCG_INLINE void *_face_getIENo(CCGFace *f, int lvl, int S, int x, int levels, int dataSize, int normalDataOffset)
702
BLI_INLINE void *_face_getIENo(CCGFace *f, int lvl, int S, int x, int levels, int dataSize, int normalDataOffset)
666
704
int maxGridSize = ccg_gridsize(levels);
667
705
int spacing = ccg_spacing(levels, lvl);
668
706
byte *gridBase = FACE_getCenterData(f) + dataSize * (1 + S * (maxGridSize + maxGridSize * maxGridSize));
669
707
return &gridBase[dataSize * x * spacing + normalDataOffset];
671
static CCG_INLINE void *_face_getIFCo(CCGFace *f, int lvl, int S, int x, int y, int levels, int dataSize)
709
BLI_INLINE void *_face_getIFCo(CCGFace *f, int lvl, int S, int x, int y, int levels, int dataSize)
673
711
int maxGridSize = ccg_gridsize(levels);
674
712
int spacing = ccg_spacing(levels, lvl);
675
713
byte *gridBase = FACE_getCenterData(f) + dataSize * (1 + S * (maxGridSize + maxGridSize * maxGridSize));
676
714
return &gridBase[dataSize * (maxGridSize + (y * maxGridSize + x) * spacing)];
678
static CCG_INLINE float *_face_getIFNo(CCGFace *f, int lvl, int S, int x, int y, int levels, int dataSize, int normalDataOffset)
716
BLI_INLINE float *_face_getIFNo(CCGFace *f, int lvl, int S, int x, int y, int levels, int dataSize, int normalDataOffset)
680
718
int maxGridSize = ccg_gridsize(levels);
681
719
int spacing = ccg_spacing(levels, lvl);
1071
1122
v = _ehash_lookupWithPrev(ss->vMap, vHDL, &prevp);
1073
1124
v = _vert_new(vHDL, ss);
1074
VertDataCopy(_vert_getCo(v, 0, ss->meshIFC.vertDataSize), vertData);
1125
VertDataCopy(_vert_getCo(v, 0, ss->meshIFC.vertDataSize), vertData, ss);
1075
1126
_ehash_insert(ss->vMap, (EHEntry *) v);
1076
1127
v->flags = Vert_eEffected | seamflag;
1078
else if (!VertDataEqual(vertData, _vert_getCo(v, 0, ss->meshIFC.vertDataSize)) || ((v->flags & Vert_eSeam) != seamflag)) {
1129
else if (!VertDataEqual(vertData, _vert_getCo(v, 0, ss->meshIFC.vertDataSize), ss) ||
1130
((v->flags & Vert_eSeam) != seamflag))
1081
VertDataCopy(_vert_getCo(v, 0, ss->meshIFC.vertDataSize), vertData);
1134
VertDataCopy(_vert_getCo(v, 0, ss->meshIFC.vertDataSize), vertData, ss);
1082
1135
v->flags = Vert_eEffected | seamflag;
1084
1137
for (i = 0; i < v->numEdges; i++) {
1102
1155
v = _ehash_lookupWithPrev(ss->oldVMap, vHDL, &prevp);
1104
1157
v = _vert_new(vHDL, ss);
1105
VertDataCopy(_vert_getCo(v, 0, ss->meshIFC.vertDataSize), vertData);
1158
VertDataCopy(_vert_getCo(v, 0, ss->meshIFC.vertDataSize), vertData, ss);
1106
1159
_ehash_insert(ss->vMap, (EHEntry *) v);
1107
1160
v->flags = Vert_eEffected | seamflag;
1109
else if (!VertDataEqual(vertData, _vert_getCo(v, 0, ss->meshIFC.vertDataSize)) || ((v->flags & Vert_eSeam) != seamflag)) {
1162
else if (!VertDataEqual(vertData, _vert_getCo(v, 0, ss->meshIFC.vertDataSize), ss) ||
1163
((v->flags & Vert_eSeam) != seamflag))
1110
1165
*prevp = v->next;
1111
1166
_ehash_insert(ss->vMap, (EHEntry *) v);
1112
VertDataCopy(_vert_getCo(v, 0, ss->meshIFC.vertDataSize), vertData);
1167
VertDataCopy(_vert_getCo(v, 0, ss->meshIFC.vertDataSize), vertData, ss);
1113
1168
v->flags = Vert_eEffected | Vert_eChanged | seamflag;
1334
1391
return eCCGError_None;
1337
#define VERT_getNo(e, lvl) _vert_getNo(e, lvl, vertDataSize, normalDataOffset)
1394
#define VERT_getNo(e, lvl) _vert_getNo(v, lvl, vertDataSize, normalDataOffset)
1338
1395
#define EDGE_getNo(e, lvl, x) _edge_getNo(e, lvl, x, vertDataSize, normalDataOffset)
1339
1396
#define FACE_getIFNo(f, lvl, S, x, y) _face_getIFNo(f, lvl, S, x, y, subdivLevels, vertDataSize, normalDataOffset)
1340
1397
#define FACE_calcIFNo(f, lvl, S, x, y, no) _face_calcIFNo(f, lvl, S, x, y, no, subdivLevels, vertDataSize)
1361
1418
for (S = 0; S < f->numVerts; S++) {
1362
for (y = 0; y < gridSize - 1; y++)
1363
for (x = 0; x < gridSize - 1; x++)
1419
for (y = 0; y < gridSize - 1; y++) {
1420
for (x = 0; x < gridSize - 1; x++) {
1364
1421
NormZero(FACE_getIFNo(f, lvl, S, x, y));
1366
if (FACE_getEdges(f)[(S - 1 + f->numVerts) % f->numVerts]->flags & Edge_eEffected)
1367
for (x = 0; x < gridSize - 1; x++)
1425
if (FACE_getEdges(f)[(S - 1 + f->numVerts) % f->numVerts]->flags & Edge_eEffected) {
1426
for (x = 0; x < gridSize - 1; x++) {
1368
1427
NormZero(FACE_getIFNo(f, lvl, S, x, gridSize - 1));
1369
if (FACE_getEdges(f)[S]->flags & Edge_eEffected)
1370
for (y = 0; y < gridSize - 1; y++)
1430
if (FACE_getEdges(f)[S]->flags & Edge_eEffected) {
1431
for (y = 0; y < gridSize - 1; y++) {
1371
1432
NormZero(FACE_getIFNo(f, lvl, S, gridSize - 1, y));
1372
if (FACE_getVerts(f)[S]->flags & Vert_eEffected)
1435
if (FACE_getVerts(f)[S]->flags & Vert_eEffected) {
1373
1436
NormZero(FACE_getIFNo(f, lvl, S, gridSize - 1, gridSize - 1));
1376
1440
for (S = 0; S < f->numVerts; S++) {
1579
1643
for (x = 0; x < gridSize - 1; x++) {
1580
1644
int fx = 1 + 2 * x;
1581
1645
int fy = 1 + 2 * y;
1582
void *co0 = FACE_getIFCo(f, curLvl, S, x + 0, y + 0);
1583
void *co1 = FACE_getIFCo(f, curLvl, S, x + 1, y + 0);
1584
void *co2 = FACE_getIFCo(f, curLvl, S, x + 1, y + 1);
1585
void *co3 = FACE_getIFCo(f, curLvl, S, x + 0, y + 1);
1586
void *co = FACE_getIFCo(f, nextLvl, S, fx, fy);
1646
const float *co0 = FACE_getIFCo(f, curLvl, S, x + 0, y + 0);
1647
const float *co1 = FACE_getIFCo(f, curLvl, S, x + 1, y + 0);
1648
const float *co2 = FACE_getIFCo(f, curLvl, S, x + 1, y + 1);
1649
const float *co3 = FACE_getIFCo(f, curLvl, S, x + 0, y + 1);
1650
float *co = FACE_getIFCo(f, nextLvl, S, fx, fy);
1588
VertDataAvg4(co, co0, co1, co2, co3);
1652
VertDataAvg4(co, co0, co1, co2, co3, ss);
1597
1661
for (S = 0; S < f->numVerts; S++) {
1598
1662
for (x = 0; x < gridSize - 1; x++) {
1599
1663
int fx = x * 2 + 1;
1600
void *co0 = FACE_getIECo(f, curLvl, S, x + 0);
1601
void *co1 = FACE_getIECo(f, curLvl, S, x + 1);
1602
void *co2 = FACE_getIFCo(f, nextLvl, (S + 1) % f->numVerts, 1, fx);
1603
void *co3 = FACE_getIFCo(f, nextLvl, S, fx, 1);
1604
void *co = FACE_getIECo(f, nextLvl, S, fx);
1664
const float *co0 = FACE_getIECo(f, curLvl, S, x + 0);
1665
const float *co1 = FACE_getIECo(f, curLvl, S, x + 1);
1666
const float *co2 = FACE_getIFCo(f, nextLvl, (S + 1) % f->numVerts, 1, fx);
1667
const float *co3 = FACE_getIFCo(f, nextLvl, S, fx, 1);
1668
float *co = FACE_getIECo(f, nextLvl, S, fx);
1606
VertDataAvg4(co, co0, co1, co2, co3);
1670
VertDataAvg4(co, co0, co1, co2, co3, ss);
1609
1673
/* interior face interior edge midpoints
1616
1680
for (y = 0; y < gridSize - 1; y++) {
1617
1681
int fx = x * 2;
1618
1682
int fy = y * 2 + 1;
1619
void *co0 = FACE_getIFCo(f, curLvl, S, x, y + 0);
1620
void *co1 = FACE_getIFCo(f, curLvl, S, x, y + 1);
1621
void *co2 = FACE_getIFCo(f, nextLvl, S, fx - 1, fy);
1622
void *co3 = FACE_getIFCo(f, nextLvl, S, fx + 1, fy);
1623
void *co = FACE_getIFCo(f, nextLvl, S, fx, fy);
1683
const float *co0 = FACE_getIFCo(f, curLvl, S, x, y + 0);
1684
const float *co1 = FACE_getIFCo(f, curLvl, S, x, y + 1);
1685
const float *co2 = FACE_getIFCo(f, nextLvl, S, fx - 1, fy);
1686
const float *co3 = FACE_getIFCo(f, nextLvl, S, fx + 1, fy);
1687
float *co = FACE_getIFCo(f, nextLvl, S, fx, fy);
1625
VertDataAvg4(co, co0, co1, co2, co3);
1689
VertDataAvg4(co, co0, co1, co2, co3, ss);
1631
1695
for (x = 0; x < gridSize - 1; x++) {
1632
1696
int fx = x * 2 + 1;
1633
1697
int fy = y * 2;
1634
void *co0 = FACE_getIFCo(f, curLvl, S, x + 0, y);
1635
void *co1 = FACE_getIFCo(f, curLvl, S, x + 1, y);
1636
void *co2 = FACE_getIFCo(f, nextLvl, S, fx, fy - 1);
1637
void *co3 = FACE_getIFCo(f, nextLvl, S, fx, fy + 1);
1638
void *co = FACE_getIFCo(f, nextLvl, S, fx, fy);
1698
const float *co0 = FACE_getIFCo(f, curLvl, S, x + 0, y);
1699
const float *co1 = FACE_getIFCo(f, curLvl, S, x + 1, y);
1700
const float *co2 = FACE_getIFCo(f, nextLvl, S, fx, fy - 1);
1701
const float *co3 = FACE_getIFCo(f, nextLvl, S, fx, fy + 1);
1702
float *co = FACE_getIFCo(f, nextLvl, S, fx, fy);
1640
VertDataAvg4(co, co0, co1, co2, co3);
1704
VertDataAvg4(co, co0, co1, co2, co3, ss);
1655
1719
if (_edge_isBoundary(e) || sharpness > 1.0f) {
1656
1720
for (x = 0; x < edgeSize - 1; x++) {
1657
1721
int fx = x * 2 + 1;
1658
void *co0 = EDGE_getCo(e, curLvl, x + 0);
1659
void *co1 = EDGE_getCo(e, curLvl, x + 1);
1660
void *co = EDGE_getCo(e, nextLvl, fx);
1722
const float *co0 = EDGE_getCo(e, curLvl, x + 0);
1723
const float *co1 = EDGE_getCo(e, curLvl, x + 1);
1724
float *co = EDGE_getCo(e, nextLvl, fx);
1662
VertDataCopy(co, co0);
1663
VertDataAdd(co, co1);
1664
VertDataMulN(co, 0.5f);
1726
VertDataCopy(co, co0, ss);
1727
VertDataAdd(co, co1, ss);
1728
VertDataMulN(co, 0.5f, ss);
1668
1732
for (x = 0; x < edgeSize - 1; x++) {
1669
1733
int fx = x * 2 + 1;
1670
void *co0 = EDGE_getCo(e, curLvl, x + 0);
1671
void *co1 = EDGE_getCo(e, curLvl, x + 1);
1672
void *co = EDGE_getCo(e, nextLvl, fx);
1734
const float *co0 = EDGE_getCo(e, curLvl, x + 0);
1735
const float *co1 = EDGE_getCo(e, curLvl, x + 1);
1736
float *co = EDGE_getCo(e, nextLvl, fx);
1673
1737
int numFaces = 0;
1675
VertDataCopy(q, co0);
1676
VertDataAdd(q, co1);
1739
VertDataCopy(q, co0, ss);
1740
VertDataAdd(q, co1, ss);
1678
1742
for (j = 0; j < e->numFaces; j++) {
1679
1743
CCGFace *f = e->faces[j];
1680
1744
const int f_ed_idx = _face_getEdgeIndex(f, e);
1681
VertDataAdd(q, _face_getIFCoEdge(f, e, f_ed_idx, nextLvl, fx, 1, subdivLevels, vertDataSize));
1745
VertDataAdd(q, _face_getIFCoEdge(f, e, f_ed_idx, nextLvl, fx, 1, subdivLevels, vertDataSize), ss);
1685
VertDataMulN(q, 1.0f / (2.0f + numFaces));
1687
VertDataCopy(r, co0);
1688
VertDataAdd(r, co1);
1689
VertDataMulN(r, 0.5f);
1691
VertDataCopy(co, q);
1693
VertDataMulN(r, sharpness);
1749
VertDataMulN(q, 1.0f / (2.0f + numFaces), ss);
1751
VertDataCopy(r, co0, ss);
1752
VertDataAdd(r, co1, ss);
1753
VertDataMulN(r, 0.5f, ss);
1755
VertDataCopy(co, q, ss);
1756
VertDataSub(r, q, ss);
1757
VertDataMulN(r, sharpness, ss);
1758
VertDataAdd(co, r, ss);
1735
1799
if (seamEdges < 2 || seamEdges != v->numEdges)
1739
VertDataCopy(nCo, co);
1802
if (!v->numEdges || ss->meshIFC.simpleSubdiv) {
1803
VertDataCopy(nCo, co, ss);
1741
1805
else if (_vert_isBoundary(v)) {
1742
1806
int numBoundary = 0;
1808
VertDataZero(r, ss);
1745
1809
for (j = 0; j < v->numEdges; j++) {
1746
1810
CCGEdge *e = v->edges[j];
1747
1811
if (_edge_isBoundary(e)) {
1748
VertDataAdd(r, _edge_getCoVert(e, v, curLvl, 1, vertDataSize));
1812
VertDataAdd(r, _edge_getCoVert(e, v, curLvl, 1, vertDataSize), ss);
1753
VertDataCopy(nCo, co);
1754
VertDataMulN(nCo, 0.75f);
1755
VertDataMulN(r, 0.25f / numBoundary);
1756
VertDataAdd(nCo, r);
1817
VertDataCopy(nCo, co, ss);
1818
VertDataMulN(nCo, 0.75f, ss);
1819
VertDataMulN(r, 0.25f / numBoundary, ss);
1820
VertDataAdd(nCo, r, ss);
1759
1823
int cornerIdx = (1 + (1 << (curLvl))) - 2;
1760
1824
int numEdges = 0, numFaces = 0;
1826
VertDataZero(q, ss);
1763
1827
for (j = 0; j < v->numFaces; j++) {
1764
1828
CCGFace *f = v->faces[j];
1765
VertDataAdd(q, FACE_getIFCo(f, nextLvl, _face_getVertIndex(f, v), cornerIdx, cornerIdx));
1829
VertDataAdd(q, FACE_getIFCo(f, nextLvl, _face_getVertIndex(f, v), cornerIdx, cornerIdx), ss);
1768
VertDataMulN(q, 1.0f / numFaces);
1832
VertDataMulN(q, 1.0f / numFaces, ss);
1833
VertDataZero(r, ss);
1770
1834
for (j = 0; j < v->numEdges; j++) {
1771
1835
CCGEdge *e = v->edges[j];
1772
VertDataAdd(r, _edge_getCoVert(e, v, curLvl, 1, vertDataSize));
1836
VertDataAdd(r, _edge_getCoVert(e, v, curLvl, 1, vertDataSize), ss);
1775
VertDataMulN(r, 1.0f / numEdges);
1839
VertDataMulN(r, 1.0f / numEdges, ss);
1777
VertDataCopy(nCo, co);
1778
VertDataMulN(nCo, numEdges - 2.0f);
1779
VertDataAdd(nCo, q);
1780
VertDataAdd(nCo, r);
1781
VertDataMulN(nCo, 1.0f / numEdges);
1841
VertDataCopy(nCo, co, ss);
1842
VertDataMulN(nCo, numEdges - 2.0f, ss);
1843
VertDataAdd(nCo, q, ss);
1844
VertDataAdd(nCo, r, ss);
1845
VertDataMulN(nCo, 1.0f / numEdges, ss);
1784
1848
if ((sharpCount > 1 && v->numFaces) || seam) {
1849
VertDataZero(q, ss);
1788
1852
avgSharpness = 1.0f;
1798
1862
if (_edge_isBoundary(e))
1799
VertDataAdd(q, _edge_getCoVert(e, v, curLvl, 1, vertDataSize));
1863
VertDataAdd(q, _edge_getCoVert(e, v, curLvl, 1, vertDataSize), ss);
1801
1865
else if (sharpness != 0.0f) {
1802
VertDataAdd(q, _edge_getCoVert(e, v, curLvl, 1, vertDataSize));
1866
VertDataAdd(q, _edge_getCoVert(e, v, curLvl, 1, vertDataSize), ss);
1806
VertDataMulN(q, (float) 1 / sharpCount);
1870
VertDataMulN(q, (float) 1 / sharpCount, ss);
1808
1872
if (sharpCount != 2 || allSharp) {
1809
1873
/* q = q + (co - q) * avgSharpness */
1810
VertDataCopy(r, co);
1812
VertDataMulN(r, avgSharpness);
1874
VertDataCopy(r, co, ss);
1875
VertDataSub(r, q, ss);
1876
VertDataMulN(r, avgSharpness, ss);
1877
VertDataAdd(q, r, ss);
1816
1880
/* r = co * 0.75 + q * 0.25 */
1817
VertDataCopy(r, co);
1818
VertDataMulN(r, .75f);
1819
VertDataMulN(q, .25f);
1881
VertDataCopy(r, co, ss);
1882
VertDataMulN(r, 0.75f, ss);
1883
VertDataMulN(q, 0.25f, ss);
1884
VertDataAdd(r, q, ss);
1822
/* nCo = nCo + (r - nCo) * avgSharpness */
1823
VertDataSub(r, nCo);
1824
VertDataMulN(r, avgSharpness);
1825
VertDataAdd(nCo, r);
1886
/* nCo = nCo + (r - nCo) * avgSharpness */
1887
VertDataSub(r, nCo, ss);
1888
VertDataMulN(r, avgSharpness, ss);
1889
VertDataAdd(nCo, r, ss);
1851
1915
avgSharpness = 0;
1854
if (_edge_isBoundary(e) && (!e->numFaces || sharpCount < 2)) {
1918
if (_edge_isBoundary(e)) {
1855
1919
for (x = 1; x < edgeSize - 1; x++) {
1856
1920
int fx = x * 2;
1857
void *co = EDGE_getCo(e, curLvl, x);
1858
void *nCo = EDGE_getCo(e, nextLvl, fx);
1859
VertDataCopy(r, EDGE_getCo(e, curLvl, x - 1));
1860
VertDataAdd(r, EDGE_getCo(e, curLvl, x + 1));
1861
VertDataMulN(r, 0.5f);
1862
VertDataCopy(nCo, co);
1863
VertDataMulN(nCo, 0.75f);
1864
VertDataMulN(r, 0.25f);
1865
VertDataAdd(nCo, r);
1921
const float *co = EDGE_getCo(e, curLvl, x);
1922
float *nCo = EDGE_getCo(e, nextLvl, fx);
1924
/* Average previous level's endpoints */
1925
VertDataCopy(r, EDGE_getCo(e, curLvl, x - 1), ss);
1926
VertDataAdd(r, EDGE_getCo(e, curLvl, x + 1), ss);
1927
VertDataMulN(r, 0.5f, ss);
1929
/* nCo = nCo * 0.75 + r * 0.25 */
1930
VertDataCopy(nCo, co, ss);
1931
VertDataMulN(nCo, 0.75f, ss);
1932
VertDataMulN(r, 0.25f, ss);
1933
VertDataAdd(nCo, r, ss);
1869
1937
for (x = 1; x < edgeSize - 1; x++) {
1870
1938
int fx = x * 2;
1871
void *co = EDGE_getCo(e, curLvl, x);
1872
void *nCo = EDGE_getCo(e, nextLvl, fx);
1939
const float *co = EDGE_getCo(e, curLvl, x);
1940
float *nCo = EDGE_getCo(e, nextLvl, fx);
1873
1941
int numFaces = 0;
1877
VertDataAdd(r, EDGE_getCo(e, curLvl, x - 1));
1878
VertDataAdd(r, EDGE_getCo(e, curLvl, x + 1));
1943
VertDataZero(q, ss);
1944
VertDataZero(r, ss);
1945
VertDataAdd(r, EDGE_getCo(e, curLvl, x - 1), ss);
1946
VertDataAdd(r, EDGE_getCo(e, curLvl, x + 1), ss);
1879
1947
for (j = 0; j < e->numFaces; j++) {
1880
1948
CCGFace *f = e->faces[j];
1881
1949
int f_ed_idx = _face_getEdgeIndex(f, e);
1882
VertDataAdd(q, _face_getIFCoEdge(f, e, f_ed_idx, nextLvl, fx - 1, 1, subdivLevels, vertDataSize));
1883
VertDataAdd(q, _face_getIFCoEdge(f, e, f_ed_idx, nextLvl, fx + 1, 1, subdivLevels, vertDataSize));
1950
VertDataAdd(q, _face_getIFCoEdge(f, e, f_ed_idx, nextLvl, fx - 1, 1, subdivLevels, vertDataSize), ss);
1951
VertDataAdd(q, _face_getIFCoEdge(f, e, f_ed_idx, nextLvl, fx + 1, 1, subdivLevels, vertDataSize), ss);
1885
VertDataAdd(r, _face_getIFCoEdge(f, e, f_ed_idx, curLvl, x, 1, subdivLevels, vertDataSize));
1953
VertDataAdd(r, _face_getIFCoEdge(f, e, f_ed_idx, curLvl, x, 1, subdivLevels, vertDataSize), ss);
1888
VertDataMulN(q, 1.0f / (numFaces * 2.0f));
1889
VertDataMulN(r, 1.0f / (2.0f + numFaces));
1956
VertDataMulN(q, 1.0f / (numFaces * 2.0f), ss);
1957
VertDataMulN(r, 1.0f / (2.0f + numFaces), ss);
1891
VertDataCopy(nCo, co);
1892
VertDataMulN(nCo, (float) numFaces);
1893
VertDataAdd(nCo, q);
1894
VertDataAdd(nCo, r);
1895
VertDataMulN(nCo, 1.0f / (2 + numFaces));
1959
VertDataCopy(nCo, co, ss);
1960
VertDataMulN(nCo, (float) numFaces, ss);
1961
VertDataAdd(nCo, q, ss);
1962
VertDataAdd(nCo, r, ss);
1963
VertDataMulN(nCo, 1.0f / (2 + numFaces), ss);
1897
1965
if (sharpCount == 2) {
1898
VertDataCopy(q, co);
1899
VertDataMulN(q, 6.0f);
1900
VertDataAdd(q, EDGE_getCo(e, curLvl, x - 1));
1901
VertDataAdd(q, EDGE_getCo(e, curLvl, x + 1));
1902
VertDataMulN(q, 1 / 8.0f);
1966
VertDataCopy(q, co, ss);
1967
VertDataMulN(q, 6.0f, ss);
1968
VertDataAdd(q, EDGE_getCo(e, curLvl, x - 1), ss);
1969
VertDataAdd(q, EDGE_getCo(e, curLvl, x + 1), ss);
1970
VertDataMulN(q, 1 / 8.0f, ss);
1904
VertDataSub(q, nCo);
1905
VertDataMulN(q, avgSharpness);
1906
VertDataAdd(nCo, q);
1972
VertDataSub(q, nCo, ss);
1973
VertDataMulN(q, avgSharpness, ss);
1974
VertDataAdd(nCo, q, ss);
1929
1997
* - old interior edge points
1930
1998
* - new interior face midpoints
1933
for (S = 0; S < f->numVerts; S++) {
1934
VertDataAdd(q, FACE_getIFCo(f, nextLvl, S, 1, 1));
1936
VertDataMulN(q, 1.0f / f->numVerts);
1938
for (S = 0; S < f->numVerts; S++) {
1939
VertDataAdd(r, FACE_getIECo(f, curLvl, S, 1));
1941
VertDataMulN(r, 1.0f / f->numVerts);
2000
VertDataZero(q, ss);
2001
for (S = 0; S < f->numVerts; S++) {
2002
VertDataAdd(q, FACE_getIFCo(f, nextLvl, S, 1, 1), ss);
2004
VertDataMulN(q, 1.0f / f->numVerts, ss);
2005
VertDataZero(r, ss);
2006
for (S = 0; S < f->numVerts; S++) {
2007
VertDataAdd(r, FACE_getIECo(f, curLvl, S, 1), ss);
2009
VertDataMulN(r, 1.0f / f->numVerts, ss);
1943
VertDataMulN(FACE_getCenterData(f), f->numVerts - 2.0f);
1944
VertDataAdd(FACE_getCenterData(f), q);
1945
VertDataAdd(FACE_getCenterData(f), r);
1946
VertDataMulN(FACE_getCenterData(f), 1.0f / f->numVerts);
2011
VertDataMulN((float *)FACE_getCenterData(f), f->numVerts - 2.0f, ss);
2012
VertDataAdd((float *)FACE_getCenterData(f), q, ss);
2013
VertDataAdd((float *)FACE_getCenterData(f), r, ss);
2014
VertDataMulN((float *)FACE_getCenterData(f), 1.0f / f->numVerts, ss);
1948
2016
for (S = 0; S < f->numVerts; S++) {
1949
2017
/* interior face shift
1955
2023
for (y = 1; y < gridSize - 1; y++) {
1956
2024
int fx = x * 2;
1957
2025
int fy = y * 2;
1958
void *co = FACE_getIFCo(f, curLvl, S, x, y);
1959
void *nCo = FACE_getIFCo(f, nextLvl, S, fx, fy);
2026
const float *co = FACE_getIFCo(f, curLvl, S, x, y);
2027
float *nCo = FACE_getIFCo(f, nextLvl, S, fx, fy);
1961
2029
VertDataAvg4(q,
1962
2030
FACE_getIFCo(f, nextLvl, S, fx - 1, fy - 1),
1963
2031
FACE_getIFCo(f, nextLvl, S, fx + 1, fy - 1),
1964
2032
FACE_getIFCo(f, nextLvl, S, fx + 1, fy + 1),
1965
FACE_getIFCo(f, nextLvl, S, fx - 1, fy + 1));
2033
FACE_getIFCo(f, nextLvl, S, fx - 1, fy + 1),
1967
2036
VertDataAvg4(r,
1968
2037
FACE_getIFCo(f, nextLvl, S, fx - 1, fy + 0),
1969
2038
FACE_getIFCo(f, nextLvl, S, fx + 1, fy + 0),
1970
2039
FACE_getIFCo(f, nextLvl, S, fx + 0, fy - 1),
1971
FACE_getIFCo(f, nextLvl, S, fx + 0, fy + 1));
2040
FACE_getIFCo(f, nextLvl, S, fx + 0, fy + 1),
1973
VertDataCopy(nCo, co);
1974
VertDataSub(nCo, q);
1975
VertDataMulN(nCo, 0.25f);
1976
VertDataAdd(nCo, r);
2043
VertDataCopy(nCo, co, ss);
2044
VertDataSub(nCo, q, ss);
2045
VertDataMulN(nCo, 0.25f, ss);
2046
VertDataAdd(nCo, r, ss);
1985
2055
for (x = 1; x < gridSize - 1; x++) {
1986
2056
int fx = x * 2;
1987
void *co = FACE_getIECo(f, curLvl, S, x);
1988
void *nCo = FACE_getIECo(f, nextLvl, S, fx);
2057
const float *co = FACE_getIECo(f, curLvl, S, x);
2058
float *nCo = FACE_getIECo(f, nextLvl, S, fx);
1990
2060
VertDataAvg4(q,
1991
2061
FACE_getIFCo(f, nextLvl, (S + 1) % f->numVerts, 1, fx - 1),
1992
2062
FACE_getIFCo(f, nextLvl, (S + 1) % f->numVerts, 1, fx + 1),
1993
2063
FACE_getIFCo(f, nextLvl, S, fx + 1, +1),
1994
FACE_getIFCo(f, nextLvl, S, fx - 1, +1));
2064
FACE_getIFCo(f, nextLvl, S, fx - 1, +1), ss);
1996
2066
VertDataAvg4(r,
1997
2067
FACE_getIECo(f, nextLvl, S, fx - 1),
1998
2068
FACE_getIECo(f, nextLvl, S, fx + 1),
1999
2069
FACE_getIFCo(f, nextLvl, (S + 1) % f->numVerts, 1, fx),
2000
FACE_getIFCo(f, nextLvl, S, fx, 1));
2070
FACE_getIFCo(f, nextLvl, S, fx, 1),
2002
VertDataCopy(nCo, co);
2003
VertDataSub(nCo, q);
2004
VertDataMulN(nCo, 0.25f);
2005
VertDataAdd(nCo, r);
2073
VertDataCopy(nCo, co, ss);
2074
VertDataSub(nCo, q, ss);
2075
VertDataMulN(nCo, 0.25f, ss);
2076
VertDataAdd(nCo, r, ss);
2035
2106
CCGEdge *e = FACE_getEdges(f)[S];
2036
2107
CCGEdge *prevE = FACE_getEdges(f)[(S + f->numVerts - 1) % f->numVerts];
2038
VertDataCopy(FACE_getIFCo(f, nextLvl, S, 0, 0), FACE_getCenterData(f));
2039
VertDataCopy(FACE_getIECo(f, nextLvl, S, 0), FACE_getCenterData(f));
2040
VertDataCopy(FACE_getIFCo(f, nextLvl, S, cornerIdx, cornerIdx), VERT_getCo(FACE_getVerts(f)[S], nextLvl));
2041
VertDataCopy(FACE_getIECo(f, nextLvl, S, cornerIdx), EDGE_getCo(FACE_getEdges(f)[S], nextLvl, cornerIdx));
2109
VertDataCopy(FACE_getIFCo(f, nextLvl, S, 0, 0), (float *)FACE_getCenterData(f), ss);
2110
VertDataCopy(FACE_getIECo(f, nextLvl, S, 0), (float *)FACE_getCenterData(f), ss);
2111
VertDataCopy(FACE_getIFCo(f, nextLvl, S, cornerIdx, cornerIdx), VERT_getCo(FACE_getVerts(f)[S], nextLvl), ss);
2112
VertDataCopy(FACE_getIECo(f, nextLvl, S, cornerIdx), EDGE_getCo(FACE_getEdges(f)[S], nextLvl, cornerIdx), ss);
2042
2113
for (x = 1; x < gridSize - 1; x++) {
2043
void *co = FACE_getIECo(f, nextLvl, S, x);
2044
VertDataCopy(FACE_getIFCo(f, nextLvl, S, x, 0), co);
2045
VertDataCopy(FACE_getIFCo(f, nextLvl, (S + 1) % f->numVerts, 0, x), co);
2114
float *co = FACE_getIECo(f, nextLvl, S, x);
2115
VertDataCopy(FACE_getIFCo(f, nextLvl, S, x, 0), co, ss);
2116
VertDataCopy(FACE_getIFCo(f, nextLvl, (S + 1) % f->numVerts, 0, x), co, ss);
2047
2118
for (x = 0; x < gridSize - 1; x++) {
2048
2119
int eI = gridSize - 1 - x;
2049
VertDataCopy(FACE_getIFCo(f, nextLvl, S, cornerIdx, x), _edge_getCoVert(e, FACE_getVerts(f)[S], nextLvl, eI, vertDataSize));
2050
VertDataCopy(FACE_getIFCo(f, nextLvl, S, x, cornerIdx), _edge_getCoVert(prevE, FACE_getVerts(f)[S], nextLvl, eI, vertDataSize));
2120
VertDataCopy(FACE_getIFCo(f, nextLvl, S, cornerIdx, x), _edge_getCoVert(e, FACE_getVerts(f)[S], nextLvl, eI, vertDataSize), ss);
2121
VertDataCopy(FACE_getIFCo(f, nextLvl, S, x, cornerIdx), _edge_getCoVert(prevE, FACE_getVerts(f)[S], nextLvl, eI, vertDataSize), ss);
2115
2186
float sharpness = EDGE_getSharpness(e, curLvl);
2117
2188
if (_edge_isBoundary(e) || sharpness >= 1.0f) {
2118
VertDataCopy(co, VERT_getCo(e->v0, curLvl));
2119
VertDataAdd(co, VERT_getCo(e->v1, curLvl));
2120
VertDataMulN(co, 0.5f);
2189
VertDataCopy(co, VERT_getCo(e->v0, curLvl), ss);
2190
VertDataAdd(co, VERT_getCo(e->v1, curLvl), ss);
2191
VertDataMulN(co, 0.5f, ss);
2123
2194
int numFaces = 0;
2124
VertDataCopy(q, VERT_getCo(e->v0, curLvl));
2125
VertDataAdd(q, VERT_getCo(e->v1, curLvl));
2195
VertDataCopy(q, VERT_getCo(e->v0, curLvl), ss);
2196
VertDataAdd(q, VERT_getCo(e->v1, curLvl), ss);
2126
2197
for (i = 0; i < e->numFaces; i++) {
2127
2198
CCGFace *f = e->faces[i];
2128
VertDataAdd(q, FACE_getCenterData(f));
2199
VertDataAdd(q, (float *)FACE_getCenterData(f), ss);
2131
VertDataMulN(q, 1.0f / (2.0f + numFaces));
2133
VertDataCopy(r, VERT_getCo(e->v0, curLvl));
2134
VertDataAdd(r, VERT_getCo(e->v1, curLvl));
2135
VertDataMulN(r, 0.5f);
2137
VertDataCopy(co, q);
2139
VertDataMulN(r, sharpness);
2202
VertDataMulN(q, 1.0f / (2.0f + numFaces), ss);
2204
VertDataCopy(r, VERT_getCo(e->v0, curLvl), ss);
2205
VertDataAdd(r, VERT_getCo(e->v1, curLvl), ss);
2206
VertDataMulN(r, 0.5f, ss);
2208
VertDataCopy(co, q, ss);
2209
VertDataSub(r, q, ss);
2210
VertDataMulN(r, sharpness, ss);
2211
VertDataAdd(co, r, ss);
2143
// edge flags cleared later
2214
/* edge flags cleared later */
2145
2216
for (ptrIdx = 0; ptrIdx < numEffectedV; ptrIdx++) {
2146
2217
CCGVert *v = effectedV[ptrIdx];
2176
2247
if (seamEdges < 2 || seamEdges != v->numEdges)
2180
VertDataCopy(nCo, co);
2250
if (!v->numEdges || ss->meshIFC.simpleSubdiv) {
2251
VertDataCopy(nCo, co, ss);
2182
2253
else if (_vert_isBoundary(v)) {
2183
2254
int numBoundary = 0;
2256
VertDataZero(r, ss);
2186
2257
for (i = 0; i < v->numEdges; i++) {
2187
2258
CCGEdge *e = v->edges[i];
2188
2259
if (_edge_isBoundary(e)) {
2189
VertDataAdd(r, VERT_getCo(_edge_getOtherVert(e, v), curLvl));
2260
VertDataAdd(r, VERT_getCo(_edge_getOtherVert(e, v), curLvl), ss);
2193
VertDataCopy(nCo, co);
2194
VertDataMulN(nCo, 0.75f);
2195
VertDataMulN(r, 0.25f / numBoundary);
2196
VertDataAdd(nCo, r);
2264
VertDataCopy(nCo, co, ss);
2265
VertDataMulN(nCo, 0.75f, ss);
2266
VertDataMulN(r, 0.25f / numBoundary, ss);
2267
VertDataAdd(nCo, r, ss);
2199
2270
int numEdges = 0, numFaces = 0;
2272
VertDataZero(q, ss);
2202
2273
for (i = 0; i < v->numFaces; i++) {
2203
2274
CCGFace *f = v->faces[i];
2204
VertDataAdd(q, FACE_getCenterData(f));
2275
VertDataAdd(q, (float *)FACE_getCenterData(f), ss);
2207
VertDataMulN(q, 1.0f / numFaces);
2278
VertDataMulN(q, 1.0f / numFaces, ss);
2279
VertDataZero(r, ss);
2209
2280
for (i = 0; i < v->numEdges; i++) {
2210
2281
CCGEdge *e = v->edges[i];
2211
VertDataAdd(r, VERT_getCo(_edge_getOtherVert(e, v), curLvl));
2282
VertDataAdd(r, VERT_getCo(_edge_getOtherVert(e, v), curLvl), ss);
2214
VertDataMulN(r, 1.0f / numEdges);
2285
VertDataMulN(r, 1.0f / numEdges, ss);
2216
VertDataCopy(nCo, co);
2217
VertDataMulN(nCo, numEdges - 2.0f);
2218
VertDataAdd(nCo, q);
2219
VertDataAdd(nCo, r);
2220
VertDataMulN(nCo, 1.0f / numEdges);
2287
VertDataCopy(nCo, co, ss);
2288
VertDataMulN(nCo, numEdges - 2.0f, ss);
2289
VertDataAdd(nCo, q, ss);
2290
VertDataAdd(nCo, r, ss);
2291
VertDataMulN(nCo, 1.0f / numEdges, ss);
2223
2294
if (sharpCount > 1 || seam) {
2295
VertDataZero(q, ss);
2227
2298
avgSharpness = 1.0f;
2237
2308
if (_edge_isBoundary(e)) {
2238
2309
CCGVert *oV = _edge_getOtherVert(e, v);
2239
VertDataAdd(q, VERT_getCo(oV, curLvl));
2310
VertDataAdd(q, VERT_getCo(oV, curLvl), ss);
2242
2313
else if (sharpness != 0.0f) {
2243
2314
CCGVert *oV = _edge_getOtherVert(e, v);
2244
VertDataAdd(q, VERT_getCo(oV, curLvl));
2315
VertDataAdd(q, VERT_getCo(oV, curLvl), ss);
2248
VertDataMulN(q, (float) 1 / sharpCount);
2319
VertDataMulN(q, (float) 1 / sharpCount, ss);
2250
2321
if (sharpCount != 2 || allSharp) {
2251
2322
/* q = q + (co - q) * avgSharpness */
2252
VertDataCopy(r, co);
2254
VertDataMulN(r, avgSharpness);
2323
VertDataCopy(r, co, ss);
2324
VertDataSub(r, q, ss);
2325
VertDataMulN(r, avgSharpness, ss);
2326
VertDataAdd(q, r, ss);
2258
2329
/* r = co * 0.75 + q * 0.25 */
2259
VertDataCopy(r, co);
2260
VertDataMulN(r, 0.75f);
2261
VertDataMulN(q, 0.25f);
2330
VertDataCopy(r, co, ss);
2331
VertDataMulN(r, 0.75f, ss);
2332
VertDataMulN(q, 0.25f, ss);
2333
VertDataAdd(r, q, ss);
2264
/* nCo = nCo + (r - nCo) * avgSharpness */
2265
VertDataSub(r, nCo);
2266
VertDataMulN(r, avgSharpness);
2267
VertDataAdd(nCo, r);
2335
/* nCo = nCo + (r - nCo) * avgSharpness */
2336
VertDataSub(r, nCo, ss);
2337
VertDataMulN(r, avgSharpness, ss);
2338
VertDataAdd(nCo, r, ss);
2270
// vert flags cleared later
2341
/* vert flags cleared later */
2273
2344
if (ss->useAgeCounts) {
2301
2372
CCGEdge *e = FACE_getEdges(f)[S];
2302
2373
CCGEdge *prevE = FACE_getEdges(f)[(S + f->numVerts - 1) % f->numVerts];
2304
VertDataCopy(FACE_getIFCo(f, nextLvl, S, 0, 0), FACE_getCenterData(f));
2305
VertDataCopy(FACE_getIECo(f, nextLvl, S, 0), FACE_getCenterData(f));
2306
VertDataCopy(FACE_getIFCo(f, nextLvl, S, 1, 1), VERT_getCo(FACE_getVerts(f)[S], nextLvl));
2307
VertDataCopy(FACE_getIECo(f, nextLvl, S, 1), EDGE_getCo(FACE_getEdges(f)[S], nextLvl, 1));
2375
VertDataCopy(FACE_getIFCo(f, nextLvl, S, 0, 0), (float *)FACE_getCenterData(f), ss);
2376
VertDataCopy(FACE_getIECo(f, nextLvl, S, 0), (float *)FACE_getCenterData(f), ss);
2377
VertDataCopy(FACE_getIFCo(f, nextLvl, S, 1, 1), VERT_getCo(FACE_getVerts(f)[S], nextLvl), ss);
2378
VertDataCopy(FACE_getIECo(f, nextLvl, S, 1), EDGE_getCo(FACE_getEdges(f)[S], nextLvl, 1), ss);
2309
VertDataCopy(FACE_getIFCo(f, nextLvl, S, 1, 0), _edge_getCoVert(e, FACE_getVerts(f)[S], nextLvl, 1, vertDataSize));
2310
VertDataCopy(FACE_getIFCo(f, nextLvl, S, 0, 1), _edge_getCoVert(prevE, FACE_getVerts(f)[S], nextLvl, 1, vertDataSize));
2380
VertDataCopy(FACE_getIFCo(f, nextLvl, S, 1, 0), _edge_getCoVert(e, FACE_getVerts(f)[S], nextLvl, 1, vertDataSize), ss);
2381
VertDataCopy(FACE_getIFCo(f, nextLvl, S, 0, 1), _edge_getCoVert(prevE, FACE_getVerts(f)[S], nextLvl, 1, vertDataSize), ss);
2431
2502
CCGEdge *e = FACE_getEdges(f)[S];
2432
2503
CCGEdge *prevE = FACE_getEdges(f)[(S + f->numVerts - 1) % f->numVerts];
2434
VertDataCopy(FACE_getCenterData(f), FACE_getIFCo(f, lvl, S, 0, 0));
2435
VertDataCopy(VERT_getCo(FACE_getVerts(f)[S], lvl), FACE_getIFCo(f, lvl, S, cornerIdx, cornerIdx));
2505
VertDataCopy((float *)FACE_getCenterData(f), FACE_getIFCo(f, lvl, S, 0, 0), ss);
2506
VertDataCopy(VERT_getCo(FACE_getVerts(f)[S], lvl), FACE_getIFCo(f, lvl, S, cornerIdx, cornerIdx), ss);
2437
2508
for (x = 0; x < gridSize; x++)
2438
VertDataCopy(FACE_getIECo(f, lvl, S, x), FACE_getIFCo(f, lvl, S, x, 0));
2509
VertDataCopy(FACE_getIECo(f, lvl, S, x), FACE_getIFCo(f, lvl, S, x, 0), ss);
2440
2511
for (x = 0; x < gridSize; x++) {
2441
2512
int eI = gridSize - 1 - x;
2442
VertDataCopy(_edge_getCoVert(e, FACE_getVerts(f)[S], lvl, eI, vertDataSize), FACE_getIFCo(f, lvl, S, cornerIdx, x));
2443
VertDataCopy(_edge_getCoVert(prevE, FACE_getVerts(f)[S], lvl, eI, vertDataSize), FACE_getIFCo(f, lvl, S, x, cornerIdx));
2513
VertDataCopy(_edge_getCoVert(e, FACE_getVerts(f)[S], lvl, eI, vertDataSize), FACE_getIFCo(f, lvl, S, cornerIdx, x), ss);
2514
VertDataCopy(_edge_getCoVert(prevE, FACE_getVerts(f)[S], lvl, eI, vertDataSize), FACE_getIFCo(f, lvl, S, x, cornerIdx), ss);
2474
2545
for (x = 0; x < gridSize; x++) {
2475
2546
int eI = gridSize - 1 - x;
2476
VertDataCopy(FACE_getIFCo(f, lvl, S, cornerIdx, x), _edge_getCoVert(e, FACE_getVerts(f)[S], lvl, eI, vertDataSize));
2477
VertDataCopy(FACE_getIFCo(f, lvl, S, x, cornerIdx), _edge_getCoVert(prevE, FACE_getVerts(f)[S], lvl, eI, vertDataSize));
2547
VertDataCopy(FACE_getIFCo(f, lvl, S, cornerIdx, x), _edge_getCoVert(e, FACE_getVerts(f)[S], lvl, eI, vertDataSize), ss);
2548
VertDataCopy(FACE_getIFCo(f, lvl, S, x, cornerIdx), _edge_getCoVert(prevE, FACE_getVerts(f)[S], lvl, eI, vertDataSize), ss);
2480
2551
for (x = 1; x < gridSize - 1; x++) {
2481
VertDataCopy(FACE_getIFCo(f, lvl, S, 0, x), FACE_getIECo(f, lvl, prevS, x));
2482
VertDataCopy(FACE_getIFCo(f, lvl, S, x, 0), FACE_getIECo(f, lvl, S, x));
2552
VertDataCopy(FACE_getIFCo(f, lvl, S, 0, x), FACE_getIECo(f, lvl, prevS, x), ss);
2553
VertDataCopy(FACE_getIFCo(f, lvl, S, x, 0), FACE_getIECo(f, lvl, S, x), ss);
2485
VertDataCopy(FACE_getIFCo(f, lvl, S, 0, 0), FACE_getCenterData(f));
2486
VertDataCopy(FACE_getIFCo(f, lvl, S, cornerIdx, cornerIdx), VERT_getCo(FACE_getVerts(f)[S], lvl));
2556
VertDataCopy(FACE_getIFCo(f, lvl, S, 0, 0), (float *)FACE_getCenterData(f), ss);
2557
VertDataCopy(FACE_getIFCo(f, lvl, S, cornerIdx, cornerIdx), VERT_getCo(FACE_getVerts(f)[S], lvl), ss);
2525
2596
if (e->numFaces)
2526
2597
for (x = 0; x < edgeSize; x++)
2527
VertDataZero(EDGE_getCo(e, lvl, x));
2598
VertDataZero(EDGE_getCo(e, lvl, x), ss);
2531
2602
for (i = 0; i < numEffectedF; i++) {
2532
2603
CCGFace *f = effectedF[i];
2534
VertDataZero(FACE_getCenterData(f));
2605
VertDataZero((float *)FACE_getCenterData(f), ss);
2536
2607
for (S = 0; S < f->numVerts; S++)
2537
2608
for (x = 0; x < gridSize; x++)
2538
VertDataZero(FACE_getIECo(f, lvl, S, x));
2609
VertDataZero(FACE_getIECo(f, lvl, S, x), ss);
2540
2611
for (S = 0; S < f->numVerts; S++) {
2541
2612
int prevS = (S + f->numVerts - 1) % f->numVerts;
2542
2613
CCGEdge *e = FACE_getEdges(f)[S];
2543
2614
CCGEdge *prevE = FACE_getEdges(f)[prevS];
2545
VertDataAdd(FACE_getCenterData(f), FACE_getIFCo(f, lvl, S, 0, 0));
2616
VertDataAdd((float *)FACE_getCenterData(f), FACE_getIFCo(f, lvl, S, 0, 0), ss);
2546
2617
if (FACE_getVerts(f)[S]->flags & Vert_eEffected)
2547
VertDataAdd(VERT_getCo(FACE_getVerts(f)[S], lvl), FACE_getIFCo(f, lvl, S, cornerIdx, cornerIdx));
2618
VertDataAdd(VERT_getCo(FACE_getVerts(f)[S], lvl), FACE_getIFCo(f, lvl, S, cornerIdx, cornerIdx), ss);
2549
2620
for (x = 1; x < gridSize - 1; x++) {
2550
VertDataAdd(FACE_getIECo(f, lvl, S, x), FACE_getIFCo(f, lvl, S, x, 0));
2551
VertDataAdd(FACE_getIECo(f, lvl, prevS, x), FACE_getIFCo(f, lvl, S, 0, x));
2621
VertDataAdd(FACE_getIECo(f, lvl, S, x), FACE_getIFCo(f, lvl, S, x, 0), ss);
2622
VertDataAdd(FACE_getIECo(f, lvl, prevS, x), FACE_getIFCo(f, lvl, S, 0, x), ss);
2554
2625
for (x = 0; x < gridSize - 1; x++) {
2555
2626
int eI = gridSize - 1 - x;
2556
2627
if (FACE_getEdges(f)[S]->flags & Edge_eEffected)
2557
VertDataAdd(_edge_getCoVert(e, FACE_getVerts(f)[S], lvl, eI, vertDataSize), FACE_getIFCo(f, lvl, S, cornerIdx, x));
2628
VertDataAdd(_edge_getCoVert(e, FACE_getVerts(f)[S], lvl, eI, vertDataSize), FACE_getIFCo(f, lvl, S, cornerIdx, x), ss);
2558
2629
if (FACE_getEdges(f)[prevS]->flags & Edge_eEffected)
2560
VertDataAdd(_edge_getCoVert(prevE, FACE_getVerts(f)[S], lvl, eI, vertDataSize), FACE_getIFCo(f, lvl, S, x, cornerIdx));
2631
VertDataAdd(_edge_getCoVert(prevE, FACE_getVerts(f)[S], lvl, eI, vertDataSize), FACE_getIFCo(f, lvl, S, x, cornerIdx), ss);
2566
2637
for (i = 0; i < numEffectedV; i++) {
2567
2638
CCGVert *v = effectedV[i];
2568
2639
if (v->numFaces)
2569
VertDataMulN(VERT_getCo(v, lvl), 1.0f / v->numFaces);
2640
VertDataMulN(VERT_getCo(v, lvl), 1.0f / v->numFaces, ss);
2572
2643
for (i = 0; i < numEffectedE; i++) {
2573
2644
CCGEdge *e = effectedE[i];
2575
VertDataCopy(EDGE_getCo(e, lvl, 0), VERT_getCo(e->v0, lvl));
2576
VertDataCopy(EDGE_getCo(e, lvl, edgeSize - 1), VERT_getCo(e->v1, lvl));
2646
VertDataCopy(EDGE_getCo(e, lvl, 0), VERT_getCo(e->v0, lvl), ss);
2647
VertDataCopy(EDGE_getCo(e, lvl, edgeSize - 1), VERT_getCo(e->v1, lvl), ss);
2578
2649
if (e->numFaces)
2579
2650
for (x = 1; x < edgeSize - 1; x++)
2580
VertDataMulN(EDGE_getCo(e, lvl, x), 1.0f / e->numFaces);
2651
VertDataMulN(EDGE_getCo(e, lvl, x), 1.0f / e->numFaces, ss);
2584
2655
for (i = 0; i < numEffectedF; i++) {
2585
2656
CCGFace *f = effectedF[i];
2587
VertDataMulN(FACE_getCenterData(f), 1.0f / f->numVerts);
2658
VertDataMulN((float *)FACE_getCenterData(f), 1.0f / f->numVerts, ss);
2589
2660
for (S = 0; S < f->numVerts; S++)
2590
2661
for (x = 1; x < gridSize - 1; x++)
2591
VertDataMulN(FACE_getIECo(f, lvl, S, x), 0.5f);
2662
VertDataMulN(FACE_getIECo(f, lvl, S, x), 0.5f, ss);
2593
2664
for (S = 0; S < f->numVerts; S++) {
2594
2665
int prevS = (S + f->numVerts - 1) % f->numVerts;
2595
2666
CCGEdge *e = FACE_getEdges(f)[S];
2596
2667
CCGEdge *prevE = FACE_getEdges(f)[prevS];
2598
VertDataCopy(FACE_getIFCo(f, lvl, S, 0, 0), FACE_getCenterData(f));
2599
VertDataCopy(FACE_getIFCo(f, lvl, S, cornerIdx, cornerIdx), VERT_getCo(FACE_getVerts(f)[S], lvl));
2669
VertDataCopy(FACE_getIFCo(f, lvl, S, 0, 0), (float *)FACE_getCenterData(f), ss);
2670
VertDataCopy(FACE_getIFCo(f, lvl, S, cornerIdx, cornerIdx), VERT_getCo(FACE_getVerts(f)[S], lvl), ss);
2601
2672
for (x = 1; x < gridSize - 1; x++) {
2602
VertDataCopy(FACE_getIFCo(f, lvl, S, x, 0), FACE_getIECo(f, lvl, S, x));
2603
VertDataCopy(FACE_getIFCo(f, lvl, S, 0, x), FACE_getIECo(f, lvl, prevS, x));
2673
VertDataCopy(FACE_getIFCo(f, lvl, S, x, 0), FACE_getIECo(f, lvl, S, x), ss);
2674
VertDataCopy(FACE_getIFCo(f, lvl, S, 0, x), FACE_getIECo(f, lvl, prevS, x), ss);
2606
2677
for (x = 0; x < gridSize - 1; x++) {
2607
2678
int eI = gridSize - 1 - x;
2608
VertDataCopy(FACE_getIFCo(f, lvl, S, cornerIdx, x), _edge_getCoVert(e, FACE_getVerts(f)[S], lvl, eI, vertDataSize));
2609
VertDataCopy(FACE_getIFCo(f, lvl, S, x, cornerIdx), _edge_getCoVert(prevE, FACE_getVerts(f)[S], lvl, eI, vertDataSize));
2680
VertDataCopy(FACE_getIFCo(f, lvl, S, cornerIdx, x), _edge_getCoVert(e, FACE_getVerts(f)[S], lvl, eI, vertDataSize), ss);
2681
VertDataCopy(FACE_getIFCo(f, lvl, S, x, cornerIdx), _edge_getCoVert(prevE, FACE_getVerts(f)[S], lvl, eI, vertDataSize), ss);
2612
VertDataCopy(FACE_getIECo(f, lvl, S, 0), FACE_getCenterData(f));
2613
VertDataCopy(FACE_getIECo(f, lvl, S, gridSize - 1), FACE_getIFCo(f, lvl, S, gridSize - 1, 0));
2684
VertDataCopy(FACE_getIECo(f, lvl, S, 0), (float *)FACE_getCenterData(f), ss);
2685
VertDataCopy(FACE_getIECo(f, lvl, S, gridSize - 1), FACE_getIFCo(f, lvl, S, gridSize - 1, 0), ss);