style cleanup
This commit is contained in:
@@ -27,7 +27,7 @@
|
||||
|
||||
/***/
|
||||
|
||||
typedef unsigned char byte;
|
||||
typedef unsigned char byte;
|
||||
|
||||
/***/
|
||||
|
||||
@@ -50,10 +50,13 @@ typedef struct _EHash {
|
||||
CCGAllocatorHDL allocator;
|
||||
} EHash;
|
||||
|
||||
#define EHASH_alloc(eh, nb) ((eh)->allocatorIFC.alloc((eh)->allocator, nb))
|
||||
#define EHASH_free(eh, ptr) ((eh)->allocatorIFC.free((eh)->allocator, ptr))
|
||||
#define EHASH_alloc(eh, nb) ((eh)->allocatorIFC.alloc((eh)->allocator, nb))
|
||||
#define EHASH_free(eh, ptr) ((eh)->allocatorIFC.free((eh)->allocator, ptr))
|
||||
|
||||
#define EHASH_hash(eh, item) (((uintptr_t) (item))%((unsigned int) (eh)->curSize))
|
||||
#define EHASH_hash(eh, item) (((uintptr_t) (item)) % ((unsigned int) (eh)->curSize))
|
||||
|
||||
static void ccgSubSurf__sync(CCGSubSurf *ss);
|
||||
static int _edge_isBoundary(const CCGEdge *e);
|
||||
|
||||
static EHash *_ehash_new(int estimatedNumEntries, CCGAllocatorIFC *allocatorIFC, CCGAllocatorHDL allocator)
|
||||
{
|
||||
@@ -107,7 +110,7 @@ static void _ehash_insert(EHash *eh, EHEntry *entry)
|
||||
memset(eh->buckets, 0, eh->curSize * sizeof(*eh->buckets));
|
||||
|
||||
while (numBuckets--) {
|
||||
for (entry = oldBuckets[numBuckets]; entry;) {
|
||||
for (entry = oldBuckets[numBuckets]; entry; ) {
|
||||
EHEntry *next = entry->next;
|
||||
|
||||
hash = EHASH_hash(eh, entry->key);
|
||||
@@ -125,12 +128,12 @@ static void _ehash_insert(EHash *eh, EHEntry *entry)
|
||||
static void *_ehash_lookupWithPrev(EHash *eh, void *key, void ***prevp_r)
|
||||
{
|
||||
int hash = EHASH_hash(eh, key);
|
||||
void **prevp = (void**) &eh->buckets[hash];
|
||||
void **prevp = (void **) &eh->buckets[hash];
|
||||
EHEntry *entry;
|
||||
|
||||
for (; (entry = *prevp); prevp = (void**) &entry->next) {
|
||||
for (; (entry = *prevp); prevp = (void **) &entry->next) {
|
||||
if (entry->key == key) {
|
||||
*prevp_r = (void**) prevp;
|
||||
*prevp_r = (void **) prevp;
|
||||
return entry;
|
||||
}
|
||||
}
|
||||
@@ -279,7 +282,7 @@ static int VertDataEqual(const float *a, const float *b)
|
||||
#define VertDataCopy(av, bv) { float *_a = (float *)av, *_b = (float *) bv; _a[0] = _b[0]; _a[1] = _b[1]; _a[2] = _b[2]; }
|
||||
#define VertDataAdd(av, bv) { float *_a = (float *)av, *_b = (float *) bv; _a[0] += _b[0]; _a[1] += _b[1]; _a[2] += _b[2]; }
|
||||
#define VertDataSub(av, bv) { float *_a = (float *)av, *_b = (float *) bv; _a[0] -= _b[0]; _a[1] -= _b[1]; _a[2] -= _b[2]; }
|
||||
#define VertDataMulN(av, n) { float *_a = (float *)av; _a[0]*=n; _a[1]*=n; _a[2] *=n; }
|
||||
#define VertDataMulN(av, n) { float *_a = (float *)av; _a[0] *= n; _a[1] *= n; _a[2] *= n; }
|
||||
#define VertDataAvg4(tv, av, bv, cv, dv) \
|
||||
{ \
|
||||
float *_t = (float *) tv, *_a = (float *) av, *_b = (float *) bv, *_c = (float *) cv, *_d = (float *) dv; \
|
||||
@@ -291,9 +294,6 @@ static int VertDataEqual(const float *a, const float *b)
|
||||
#define NormCopy(av, bv) { float *_a = (float *) av, *_b = (float *) bv; _a[0] = _b[0]; _a[1] = _b[1]; _a[2] = _b[2]; }
|
||||
#define NormAdd(av, bv) { float *_a = (float *) av, *_b = (float *) bv; _a[0] += _b[0]; _a[1] += _b[1]; _a[2] += _b[2]; }
|
||||
|
||||
|
||||
static int _edge_isBoundary(const CCGEdge *e);
|
||||
|
||||
/***/
|
||||
|
||||
enum {
|
||||
@@ -309,8 +309,8 @@ enum {
|
||||
} /*FaceFlags*/;
|
||||
|
||||
struct CCGVert {
|
||||
CCGVert *next; /* EHData.next */
|
||||
CCGVertHDL vHDL; /* EHData.key */
|
||||
CCGVert *next; /* EHData.next */
|
||||
CCGVertHDL vHDL; /* EHData.key */
|
||||
|
||||
short numEdges, numFaces, flags, pad;
|
||||
|
||||
@@ -322,17 +322,17 @@ struct CCGVert {
|
||||
|
||||
static CCG_INLINE byte *VERT_getLevelData(CCGVert *v)
|
||||
{
|
||||
return (byte*)(&(v)[1]);
|
||||
return (byte *)(&(v)[1]);
|
||||
}
|
||||
|
||||
struct CCGEdge {
|
||||
CCGEdge *next; /* EHData.next */
|
||||
CCGEdgeHDL eHDL; /* EHData.key */
|
||||
CCGEdge *next; /* EHData.next */
|
||||
CCGEdgeHDL eHDL; /* EHData.key */
|
||||
|
||||
short numFaces, flags;
|
||||
float crease;
|
||||
|
||||
CCGVert *v0,*v1;
|
||||
CCGVert *v0, *v1;
|
||||
CCGFace **faces;
|
||||
|
||||
// byte *levelData;
|
||||
@@ -341,12 +341,12 @@ struct CCGEdge {
|
||||
|
||||
static CCG_INLINE byte *EDGE_getLevelData(CCGEdge *e)
|
||||
{
|
||||
return (byte*)(&(e)[1]);
|
||||
return (byte *)(&(e)[1]);
|
||||
}
|
||||
|
||||
struct CCGFace {
|
||||
CCGFace *next; /* EHData.next */
|
||||
CCGFaceHDL fHDL; /* EHData.key */
|
||||
CCGFace *next; /* EHData.next */
|
||||
CCGFaceHDL fHDL; /* EHData.key */
|
||||
|
||||
short numVerts, flags, pad1, pad2;
|
||||
|
||||
@@ -359,17 +359,17 @@ struct CCGFace {
|
||||
|
||||
static CCG_INLINE CCGVert **FACE_getVerts(CCGFace *f)
|
||||
{
|
||||
return (CCGVert**)(&f[1]);
|
||||
return (CCGVert **)(&f[1]);
|
||||
}
|
||||
|
||||
static CCG_INLINE CCGEdge **FACE_getEdges(CCGFace *f)
|
||||
{
|
||||
return (CCGEdge**)(&(FACE_getVerts(f)[f->numVerts]));
|
||||
return (CCGEdge **)(&(FACE_getVerts(f)[f->numVerts]));
|
||||
}
|
||||
|
||||
static CCG_INLINE byte *FACE_getCenterData(CCGFace *f)
|
||||
{
|
||||
return (byte*)(&(FACE_getEdges(f)[(f)->numVerts]));
|
||||
return (byte *)(&(FACE_getEdges(f)[(f)->numVerts]));
|
||||
}
|
||||
|
||||
typedef enum {
|
||||
@@ -381,9 +381,9 @@ typedef enum {
|
||||
} SyncState;
|
||||
|
||||
struct CCGSubSurf {
|
||||
EHash *vMap; /* map of CCGVertHDL -> Vert */
|
||||
EHash *eMap; /* map of CCGEdgeHDL -> Edge */
|
||||
EHash *fMap; /* map of CCGFaceHDL -> Face */
|
||||
EHash *vMap; /* map of CCGVertHDL -> Vert */
|
||||
EHash *eMap; /* map of CCGEdgeHDL -> Edge */
|
||||
EHash *fMap; /* map of CCGFaceHDL -> Face */
|
||||
|
||||
CCGMeshIFC meshIFC;
|
||||
|
||||
@@ -398,18 +398,18 @@ struct CCGSubSurf {
|
||||
|
||||
void *q, *r;
|
||||
|
||||
// data for calc vert normals
|
||||
/* data for calc vert normals */
|
||||
int calcVertNormals;
|
||||
int normalDataOffset;
|
||||
|
||||
// data for age'ing (to debug sync)
|
||||
/* data for age'ing (to debug sync) */
|
||||
int currentAge;
|
||||
int useAgeCounts;
|
||||
int vertUserAgeOffset;
|
||||
int edgeUserAgeOffset;
|
||||
int faceUserAgeOffset;
|
||||
|
||||
// data used during syncing
|
||||
/* data used during syncing */
|
||||
SyncState syncState;
|
||||
|
||||
EHash *oldVMap, *oldEMap, *oldFMap;
|
||||
@@ -418,9 +418,9 @@ struct CCGSubSurf {
|
||||
CCGEdge **tempEdges;
|
||||
};
|
||||
|
||||
#define CCGSUBSURF_alloc(ss, nb) ((ss)->allocatorIFC.alloc((ss)->allocator, nb))
|
||||
#define CCGSUBSURF_realloc(ss, ptr, nb, ob) ((ss)->allocatorIFC.realloc((ss)->allocator, ptr, nb, ob))
|
||||
#define CCGSUBSURF_free(ss, ptr) ((ss)->allocatorIFC.free((ss)->allocator, ptr))
|
||||
#define CCGSUBSURF_alloc(ss, nb) ((ss)->allocatorIFC.alloc((ss)->allocator, nb))
|
||||
#define CCGSUBSURF_realloc(ss, ptr, nb, ob) ((ss)->allocatorIFC.realloc((ss)->allocator, ptr, nb, ob))
|
||||
#define CCGSUBSURF_free(ss, ptr) ((ss)->allocatorIFC.free((ss)->allocator, ptr))
|
||||
|
||||
/***/
|
||||
|
||||
@@ -428,9 +428,9 @@ static CCGVert *_vert_new(CCGVertHDL vHDL, CCGSubSurf *ss)
|
||||
{
|
||||
int num_vert_data = ss->subdivLevels + 1;
|
||||
CCGVert *v = CCGSUBSURF_alloc(ss,
|
||||
sizeof(CCGVert) +
|
||||
ss->meshIFC.vertDataSize * num_vert_data +
|
||||
ss->meshIFC.vertUserSize);
|
||||
sizeof(CCGVert) +
|
||||
ss->meshIFC.vertDataSize * num_vert_data +
|
||||
ss->meshIFC.vertUserSize);
|
||||
byte *userData;
|
||||
|
||||
v->vHDL = vHDL;
|
||||
@@ -441,7 +441,7 @@ static CCGVert *_vert_new(CCGVertHDL vHDL, CCGSubSurf *ss)
|
||||
|
||||
userData = ccgSubSurf_getVertUserData(ss, v);
|
||||
memset(userData, 0, ss->meshIFC.vertUserSize);
|
||||
if (ss->useAgeCounts) *((int*) &userData[ss->vertUserAgeOffset]) = ss->currentAge;
|
||||
if (ss->useAgeCounts) *((int *) &userData[ss->vertUserAgeOffset]) = ss->currentAge;
|
||||
|
||||
return v;
|
||||
}
|
||||
@@ -541,7 +541,7 @@ static CCGEdge *_edge_new(CCGEdgeHDL eHDL, CCGVert *v0, CCGVert *v1, float creas
|
||||
|
||||
userData = ccgSubSurf_getEdgeUserData(ss, e);
|
||||
memset(userData, 0, ss->meshIFC.edgeUserSize);
|
||||
if (ss->useAgeCounts) *((int*) &userData[ss->edgeUserAgeOffset]) = ss->currentAge;
|
||||
if (ss->useAgeCounts) *((int *) &userData[ss->edgeUserAgeOffset]) = ss->currentAge;
|
||||
|
||||
return e;
|
||||
}
|
||||
@@ -562,7 +562,7 @@ static void _edge_addFace(CCGEdge *e, CCGFace *f, CCGSubSurf *ss)
|
||||
}
|
||||
static int _edge_isBoundary(const CCGEdge *e)
|
||||
{
|
||||
return e->numFaces<2;
|
||||
return e->numFaces < 2;
|
||||
}
|
||||
|
||||
static CCGVert *_edge_getOtherVert(CCGEdge *e, CCGVert *vQ)
|
||||
@@ -626,11 +626,11 @@ static CCGFace *_face_new(CCGFaceHDL fHDL, CCGVert **verts, CCGEdge **edges, int
|
||||
{
|
||||
int maxGridSize = ccg_gridsize(ss->subdivLevels);
|
||||
int num_face_data = (numVerts * maxGridSize +
|
||||
numVerts * maxGridSize * maxGridSize + 1);
|
||||
numVerts * maxGridSize * maxGridSize + 1);
|
||||
CCGFace *f = CCGSUBSURF_alloc(ss,
|
||||
sizeof(CCGFace) +
|
||||
sizeof(CCGVert*) * numVerts +
|
||||
sizeof(CCGEdge*) * numVerts +
|
||||
sizeof(CCGVert *) * numVerts +
|
||||
sizeof(CCGEdge *) * numVerts +
|
||||
ss->meshIFC.vertDataSize * num_face_data +
|
||||
ss->meshIFC.faceUserSize);
|
||||
byte *userData;
|
||||
@@ -649,7 +649,7 @@ static CCGFace *_face_new(CCGFaceHDL fHDL, CCGVert **verts, CCGEdge **edges, int
|
||||
|
||||
userData = ccgSubSurf_getFaceUserData(ss, f);
|
||||
memset(userData, 0, ss->meshIFC.faceUserSize);
|
||||
if (ss->useAgeCounts) *((int*) &userData[ss->faceUserAgeOffset]) = ss->currentAge;
|
||||
if (ss->useAgeCounts) *((int *) &userData[ss->faceUserAgeOffset]) = ss->currentAge;
|
||||
|
||||
return f;
|
||||
}
|
||||
@@ -702,12 +702,12 @@ static CCG_INLINE void *_face_getIFCoEdge(CCGFace *f, CCGEdge *e, int lvl, int e
|
||||
|
||||
eX = eX * spacing;
|
||||
eY = eY * spacing;
|
||||
if (e->v0!=FACE_getVerts(f)[S]) {
|
||||
if (e->v0 != FACE_getVerts(f)[S]) {
|
||||
eX = (maxGridSize * 2 - 1) - 1 - eX;
|
||||
}
|
||||
y = maxGridSize - 1 - eX;
|
||||
x = maxGridSize - 1 - eY;
|
||||
if (x<0) {
|
||||
if (x < 0) {
|
||||
S = (S + f->numVerts - 1) % f->numVerts;
|
||||
cx = y;
|
||||
cy = -x;
|
||||
@@ -733,8 +733,8 @@ static void _face_calcIFNo(CCGFace *f, int lvl, int S, int x, int y, float *no,
|
||||
float *b = _face_getIFCo(f, lvl, S, x + 1, y + 0, levels, dataSize);
|
||||
float *c = _face_getIFCo(f, lvl, S, x + 1, y + 1, levels, dataSize);
|
||||
float *d = _face_getIFCo(f, lvl, S, x + 0, y + 1, levels, dataSize);
|
||||
float a_cX = c[0]-a[0], a_cY = c[1]-a[1], a_cZ = c[2]-a[2];
|
||||
float b_dX = d[0]-b[0], b_dY = d[1]-b[1], b_dZ = d[2]-b[2];
|
||||
float a_cX = c[0] - a[0], a_cY = c[1] - a[1], a_cZ = c[2] - a[2];
|
||||
float b_dX = d[0] - b[0], b_dY = d[1] - b[1], b_dZ = d[2] - b[2];
|
||||
float length;
|
||||
|
||||
no[0] = b_dY * a_cZ - b_dZ * a_cY;
|
||||
@@ -779,7 +779,7 @@ CCGSubSurf *ccgSubSurf_new(CCGMeshIFC *ifc, int subdivLevels, CCGAllocatorIFC *a
|
||||
allocator = NULL;
|
||||
}
|
||||
|
||||
if (subdivLevels<1) {
|
||||
if (subdivLevels < 1) {
|
||||
return NULL;
|
||||
}
|
||||
else {
|
||||
@@ -881,10 +881,10 @@ void ccgSubSurf_getAllowEdgeCreation(CCGSubSurf *ss, int *allowEdgeCreation_r, f
|
||||
|
||||
CCGError ccgSubSurf_setSubdivisionLevels(CCGSubSurf *ss, int subdivisionLevels)
|
||||
{
|
||||
if (subdivisionLevels<=0) {
|
||||
if (subdivisionLevels <= 0) {
|
||||
return eCCGError_InvalidValue;
|
||||
}
|
||||
else if (subdivisionLevels!=ss->subdivLevels) {
|
||||
else if (subdivisionLevels != ss->subdivLevels) {
|
||||
ss->numGrids = 0;
|
||||
ss->subdivLevels = subdivisionLevels;
|
||||
_ehash_free(ss->vMap, (EHEntryFreeFP) _vert_free, ss);
|
||||
@@ -934,7 +934,7 @@ CCGError ccgSubSurf_setUseAgeCounts(CCGSubSurf *ss, int useAgeCounts, int vertUs
|
||||
CCGError ccgSubSurf_setCalcVertexNormals(CCGSubSurf *ss, int useVertNormals, int normalDataOffset)
|
||||
{
|
||||
if (useVertNormals) {
|
||||
if (normalDataOffset<0 || normalDataOffset + 12>ss->meshIFC.vertDataSize) {
|
||||
if (normalDataOffset < 0 || normalDataOffset + 12 > ss->meshIFC.vertDataSize) {
|
||||
return eCCGError_InvalidValue;
|
||||
}
|
||||
else {
|
||||
@@ -954,7 +954,7 @@ CCGError ccgSubSurf_setCalcVertexNormals(CCGSubSurf *ss, int useVertNormals, int
|
||||
|
||||
CCGError ccgSubSurf_initFullSync(CCGSubSurf *ss)
|
||||
{
|
||||
if (ss->syncState!=eSyncState_None) {
|
||||
if (ss->syncState != eSyncState_None) {
|
||||
return eCCGError_InvalidSyncState;
|
||||
}
|
||||
|
||||
@@ -981,7 +981,7 @@ CCGError ccgSubSurf_initFullSync(CCGSubSurf *ss)
|
||||
|
||||
CCGError ccgSubSurf_initPartialSync(CCGSubSurf *ss)
|
||||
{
|
||||
if (ss->syncState!=eSyncState_None) {
|
||||
if (ss->syncState != eSyncState_None) {
|
||||
return eCCGError_InvalidSyncState;
|
||||
}
|
||||
|
||||
@@ -994,7 +994,7 @@ CCGError ccgSubSurf_initPartialSync(CCGSubSurf *ss)
|
||||
|
||||
CCGError ccgSubSurf_syncVertDel(CCGSubSurf *ss, CCGVertHDL vHDL)
|
||||
{
|
||||
if (ss->syncState!=eSyncState_Partial) {
|
||||
if (ss->syncState != eSyncState_Partial) {
|
||||
return eCCGError_InvalidSyncState;
|
||||
}
|
||||
else {
|
||||
@@ -1015,7 +1015,7 @@ CCGError ccgSubSurf_syncVertDel(CCGSubSurf *ss, CCGVertHDL vHDL)
|
||||
|
||||
CCGError ccgSubSurf_syncEdgeDel(CCGSubSurf *ss, CCGEdgeHDL eHDL)
|
||||
{
|
||||
if (ss->syncState!=eSyncState_Partial) {
|
||||
if (ss->syncState != eSyncState_Partial) {
|
||||
return eCCGError_InvalidSyncState;
|
||||
}
|
||||
else {
|
||||
@@ -1036,7 +1036,7 @@ CCGError ccgSubSurf_syncEdgeDel(CCGSubSurf *ss, CCGEdgeHDL eHDL)
|
||||
|
||||
CCGError ccgSubSurf_syncFaceDel(CCGSubSurf *ss, CCGFaceHDL fHDL)
|
||||
{
|
||||
if (ss->syncState!=eSyncState_Partial) {
|
||||
if (ss->syncState != eSyncState_Partial) {
|
||||
return eCCGError_InvalidSyncState;
|
||||
}
|
||||
else {
|
||||
@@ -1059,21 +1059,21 @@ CCGError ccgSubSurf_syncVert(CCGSubSurf *ss, CCGVertHDL vHDL, const void *vertDa
|
||||
{
|
||||
void **prevp;
|
||||
CCGVert *v = NULL;
|
||||
short seamflag = (seam)? Vert_eSeam: 0;
|
||||
short seamflag = (seam) ? Vert_eSeam : 0;
|
||||
|
||||
if (ss->syncState == eSyncState_Partial) {
|
||||
v = _ehash_lookupWithPrev(ss->vMap, vHDL, &prevp);
|
||||
if (!v) {
|
||||
v = _vert_new(vHDL, ss);
|
||||
VertDataCopy(_vert_getCo(v,0,ss->meshIFC.vertDataSize), vertData);
|
||||
_ehash_insert(ss->vMap, (EHEntry*) v);
|
||||
v->flags = Vert_eEffected|seamflag;
|
||||
VertDataCopy(_vert_getCo(v, 0, ss->meshIFC.vertDataSize), vertData);
|
||||
_ehash_insert(ss->vMap, (EHEntry *) v);
|
||||
v->flags = Vert_eEffected | seamflag;
|
||||
}
|
||||
else if (!VertDataEqual(vertData, _vert_getCo(v, 0, ss->meshIFC.vertDataSize)) || ((v->flags & Vert_eSeam) != seamflag)) {
|
||||
int i, j;
|
||||
|
||||
VertDataCopy(_vert_getCo(v,0,ss->meshIFC.vertDataSize), vertData);
|
||||
v->flags = Vert_eEffected|seamflag;
|
||||
VertDataCopy(_vert_getCo(v, 0, ss->meshIFC.vertDataSize), vertData);
|
||||
v->flags = Vert_eEffected | seamflag;
|
||||
|
||||
for (i = 0; i < v->numEdges; i++) {
|
||||
CCGEdge *e = v->edges[i];
|
||||
@@ -1089,26 +1089,26 @@ CCGError ccgSubSurf_syncVert(CCGSubSurf *ss, CCGVertHDL vHDL, const void *vertDa
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (ss->syncState!=eSyncState_Vert) {
|
||||
if (ss->syncState != eSyncState_Vert) {
|
||||
return eCCGError_InvalidSyncState;
|
||||
}
|
||||
|
||||
v = _ehash_lookupWithPrev(ss->oldVMap, vHDL, &prevp);
|
||||
if (!v) {
|
||||
v = _vert_new(vHDL, ss);
|
||||
VertDataCopy(_vert_getCo(v,0,ss->meshIFC.vertDataSize), vertData);
|
||||
_ehash_insert(ss->vMap, (EHEntry*) v);
|
||||
v->flags = Vert_eEffected|seamflag;
|
||||
VertDataCopy(_vert_getCo(v, 0, ss->meshIFC.vertDataSize), vertData);
|
||||
_ehash_insert(ss->vMap, (EHEntry *) v);
|
||||
v->flags = Vert_eEffected | seamflag;
|
||||
}
|
||||
else if (!VertDataEqual(vertData, _vert_getCo(v, 0, ss->meshIFC.vertDataSize)) || ((v->flags & Vert_eSeam) != seamflag)) {
|
||||
*prevp = v->next;
|
||||
_ehash_insert(ss->vMap, (EHEntry*) v);
|
||||
VertDataCopy(_vert_getCo(v,0,ss->meshIFC.vertDataSize), vertData);
|
||||
v->flags = Vert_eEffected|Vert_eChanged|seamflag;
|
||||
_ehash_insert(ss->vMap, (EHEntry *) v);
|
||||
VertDataCopy(_vert_getCo(v, 0, ss->meshIFC.vertDataSize), vertData);
|
||||
v->flags = Vert_eEffected | Vert_eChanged | seamflag;
|
||||
}
|
||||
else {
|
||||
*prevp = v->next;
|
||||
_ehash_insert(ss->vMap, (EHEntry*) v);
|
||||
_ehash_insert(ss->vMap, (EHEntry *) v);
|
||||
v->flags = 0;
|
||||
}
|
||||
}
|
||||
@@ -1124,7 +1124,7 @@ CCGError ccgSubSurf_syncEdge(CCGSubSurf *ss, CCGEdgeHDL eHDL, CCGVertHDL e_vHDL0
|
||||
|
||||
if (ss->syncState == eSyncState_Partial) {
|
||||
e = _ehash_lookupWithPrev(ss->eMap, eHDL, &prevp);
|
||||
if (!e || e->v0->vHDL!=e_vHDL0 || e->v1->vHDL!=e_vHDL1 || crease!=e->crease) {
|
||||
if (!e || e->v0->vHDL != e_vHDL0 || e->v1->vHDL != e_vHDL1 || crease != e->crease) {
|
||||
CCGVert *v0 = _ehash_lookup(ss->vMap, e_vHDL0);
|
||||
CCGVert *v1 = _ehash_lookup(ss->vMap, e_vHDL1);
|
||||
|
||||
@@ -1137,7 +1137,7 @@ CCGError ccgSubSurf_syncEdge(CCGSubSurf *ss, CCGEdgeHDL eHDL, CCGVertHDL e_vHDL0
|
||||
_edge_unlinkMarkAndFree(e, ss);
|
||||
}
|
||||
else {
|
||||
_ehash_insert(ss->eMap, (EHEntry*) eNew);
|
||||
_ehash_insert(ss->eMap, (EHEntry *) eNew);
|
||||
}
|
||||
|
||||
eNew->v0->flags |= Vert_eEffected;
|
||||
@@ -1148,24 +1148,24 @@ CCGError ccgSubSurf_syncEdge(CCGSubSurf *ss, CCGEdgeHDL eHDL, CCGVertHDL e_vHDL0
|
||||
if (ss->syncState == eSyncState_Vert) {
|
||||
ss->syncState = eSyncState_Edge;
|
||||
}
|
||||
else if (ss->syncState!=eSyncState_Edge) {
|
||||
else if (ss->syncState != eSyncState_Edge) {
|
||||
return eCCGError_InvalidSyncState;
|
||||
}
|
||||
|
||||
e = _ehash_lookupWithPrev(ss->oldEMap, eHDL, &prevp);
|
||||
if (!e || e->v0->vHDL!=e_vHDL0 || e->v1->vHDL!=e_vHDL1|| e->crease!=crease) {
|
||||
if (!e || e->v0->vHDL != e_vHDL0 || e->v1->vHDL != e_vHDL1 || e->crease != crease) {
|
||||
CCGVert *v0 = _ehash_lookup(ss->vMap, e_vHDL0);
|
||||
CCGVert *v1 = _ehash_lookup(ss->vMap, e_vHDL1);
|
||||
e = _edge_new(eHDL, v0, v1, crease, ss);
|
||||
_ehash_insert(ss->eMap, (EHEntry*) e);
|
||||
_ehash_insert(ss->eMap, (EHEntry *) e);
|
||||
e->v0->flags |= Vert_eEffected;
|
||||
e->v1->flags |= Vert_eEffected;
|
||||
}
|
||||
else {
|
||||
*prevp = e->next;
|
||||
_ehash_insert(ss->eMap, (EHEntry*) e);
|
||||
_ehash_insert(ss->eMap, (EHEntry *) e);
|
||||
e->flags = 0;
|
||||
if ((e->v0->flags|e->v1->flags)&Vert_eChanged) {
|
||||
if ((e->v0->flags | e->v1->flags) & Vert_eChanged) {
|
||||
e->v0->flags |= Vert_eEffected;
|
||||
e->v1->flags |= Vert_eEffected;
|
||||
}
|
||||
@@ -1199,10 +1199,12 @@ CCGError ccgSubSurf_syncFace(CCGSubSurf *ss, CCGFaceHDL fHDL, int numVerts, CCGV
|
||||
}
|
||||
|
||||
if (f) {
|
||||
if ( f->numVerts!=numVerts ||
|
||||
memcmp(FACE_getVerts(f), ss->tempVerts, sizeof(*ss->tempVerts) * numVerts) ||
|
||||
memcmp(FACE_getEdges(f), ss->tempEdges, sizeof(*ss->tempEdges) * numVerts))
|
||||
if (f->numVerts != numVerts ||
|
||||
memcmp(FACE_getVerts(f), ss->tempVerts, sizeof(*ss->tempVerts) * numVerts) ||
|
||||
memcmp(FACE_getEdges(f), ss->tempEdges, sizeof(*ss->tempEdges) * numVerts))
|
||||
{
|
||||
topologyChanged = 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (!f || topologyChanged) {
|
||||
@@ -1218,7 +1220,7 @@ CCGError ccgSubSurf_syncFace(CCGSubSurf *ss, CCGFaceHDL fHDL, int numVerts, CCGV
|
||||
}
|
||||
else {
|
||||
ss->numGrids += numVerts;
|
||||
_ehash_insert(ss->fMap, (EHEntry*) fNew);
|
||||
_ehash_insert(ss->fMap, (EHEntry *) fNew);
|
||||
}
|
||||
|
||||
for (k = 0; k < numVerts; k++)
|
||||
@@ -1229,7 +1231,7 @@ CCGError ccgSubSurf_syncFace(CCGSubSurf *ss, CCGFaceHDL fHDL, int numVerts, CCGV
|
||||
if (ss->syncState == eSyncState_Vert || ss->syncState == eSyncState_Edge) {
|
||||
ss->syncState = eSyncState_Face;
|
||||
}
|
||||
else if (ss->syncState!=eSyncState_Face) {
|
||||
else if (ss->syncState != eSyncState_Face) {
|
||||
return eCCGError_InvalidSyncState;
|
||||
}
|
||||
|
||||
@@ -1246,8 +1248,8 @@ CCGError ccgSubSurf_syncFace(CCGSubSurf *ss, CCGFaceHDL fHDL, int numVerts, CCGV
|
||||
|
||||
if (!ss->tempEdges[k]) {
|
||||
if (ss->allowEdgeCreation) {
|
||||
CCGEdge *e = ss->tempEdges[k] = _edge_new((CCGEdgeHDL) -1, ss->tempVerts[k], ss->tempVerts[(k + 1) % numVerts], ss->defaultCreaseValue, ss);
|
||||
_ehash_insert(ss->eMap, (EHEntry*) e);
|
||||
CCGEdge *e = ss->tempEdges[k] = _edge_new((CCGEdgeHDL) - 1, ss->tempVerts[k], ss->tempVerts[(k + 1) % numVerts], ss->defaultCreaseValue, ss);
|
||||
_ehash_insert(ss->eMap, (EHEntry *) e);
|
||||
e->v0->flags |= Vert_eEffected;
|
||||
e->v1->flags |= Vert_eEffected;
|
||||
if (ss->meshIFC.edgeUserSize) {
|
||||
@@ -1261,15 +1263,15 @@ CCGError ccgSubSurf_syncFace(CCGSubSurf *ss, CCGFaceHDL fHDL, int numVerts, CCGV
|
||||
}
|
||||
|
||||
if (f) {
|
||||
if ( f->numVerts!=numVerts ||
|
||||
memcmp(FACE_getVerts(f), ss->tempVerts, sizeof(*ss->tempVerts) * numVerts) ||
|
||||
memcmp(FACE_getEdges(f), ss->tempEdges, sizeof(*ss->tempEdges) * numVerts))
|
||||
if (f->numVerts != numVerts ||
|
||||
memcmp(FACE_getVerts(f), ss->tempVerts, sizeof(*ss->tempVerts) * numVerts) ||
|
||||
memcmp(FACE_getEdges(f), ss->tempEdges, sizeof(*ss->tempEdges) * numVerts))
|
||||
topologyChanged = 1;
|
||||
}
|
||||
|
||||
if (!f || topologyChanged) {
|
||||
f = _face_new(fHDL, ss->tempVerts, ss->tempEdges, numVerts, ss);
|
||||
_ehash_insert(ss->fMap, (EHEntry*) f);
|
||||
_ehash_insert(ss->fMap, (EHEntry *) f);
|
||||
ss->numGrids += numVerts;
|
||||
|
||||
for (k = 0; k < numVerts; k++)
|
||||
@@ -1277,7 +1279,7 @@ CCGError ccgSubSurf_syncFace(CCGSubSurf *ss, CCGFaceHDL fHDL, int numVerts, CCGV
|
||||
}
|
||||
else {
|
||||
*prevp = f->next;
|
||||
_ehash_insert(ss->fMap, (EHEntry*) f);
|
||||
_ehash_insert(ss->fMap, (EHEntry *) f);
|
||||
f->flags = 0;
|
||||
ss->numGrids += f->numVerts;
|
||||
|
||||
@@ -1295,7 +1297,6 @@ CCGError ccgSubSurf_syncFace(CCGSubSurf *ss, CCGFaceHDL fHDL, int numVerts, CCGV
|
||||
return eCCGError_None;
|
||||
}
|
||||
|
||||
static void ccgSubSurf__sync(CCGSubSurf *ss);
|
||||
CCGError ccgSubSurf_processSync(CCGSubSurf *ss)
|
||||
{
|
||||
if (ss->syncState == eSyncState_Partial) {
|
||||
@@ -1327,15 +1328,17 @@ CCGError ccgSubSurf_processSync(CCGSubSurf *ss)
|
||||
return eCCGError_None;
|
||||
}
|
||||
|
||||
#define VERT_getNo(e, lvl) _vert_getNo(e, lvl, vertDataSize, normalDataOffset)
|
||||
#define EDGE_getNo(e, lvl, x) _edge_getNo(e, lvl, x, vertDataSize, normalDataOffset)
|
||||
#define FACE_getIFNo(f, lvl, S, x, y) _face_getIFNo(f, lvl, S, x, y, subdivLevels, vertDataSize, normalDataOffset)
|
||||
#define FACE_calcIFNo(f, lvl, S, x, y, no) _face_calcIFNo(f, lvl, S, x, y, no, subdivLevels, vertDataSize)
|
||||
#define FACE_getIENo(f, lvl, S, x) _face_getIENo(f, lvl, S, x, subdivLevels, vertDataSize, normalDataOffset)
|
||||
#define VERT_getNo(e, lvl) _vert_getNo(e, lvl, vertDataSize, normalDataOffset)
|
||||
#define EDGE_getNo(e, lvl, x) _edge_getNo(e, lvl, x, vertDataSize, normalDataOffset)
|
||||
#define FACE_getIFNo(f, lvl, S, x, y) _face_getIFNo(f, lvl, S, x, y, subdivLevels, vertDataSize, normalDataOffset)
|
||||
#define FACE_calcIFNo(f, lvl, S, x, y, no) _face_calcIFNo(f, lvl, S, x, y, no, subdivLevels, vertDataSize)
|
||||
#define FACE_getIENo(f, lvl, S, x) _face_getIENo(f, lvl, S, x, subdivLevels, vertDataSize, normalDataOffset)
|
||||
|
||||
static void ccgSubSurf__calcVertNormals(CCGSubSurf *ss,
|
||||
CCGVert **effectedV, CCGEdge **effectedE, CCGFace **effectedF,
|
||||
int numEffectedV, int numEffectedE, int numEffectedF) {
|
||||
int i,ptrIdx;
|
||||
CCGVert **effectedV, CCGEdge **effectedE, CCGFace **effectedF,
|
||||
int numEffectedV, int numEffectedE, int numEffectedF)
|
||||
{
|
||||
int i, ptrIdx;
|
||||
int subdivLevels = ss->subdivLevels;
|
||||
int lvl = ss->subdivLevels;
|
||||
int edgeSize = ccg_edgesize(lvl);
|
||||
@@ -1345,7 +1348,7 @@ static void ccgSubSurf__calcVertNormals(CCGSubSurf *ss,
|
||||
|
||||
#pragma omp parallel for private(ptrIdx) if (numEffectedF * edgeSize * edgeSize * 4 >= CCG_OMP_LIMIT)
|
||||
for (ptrIdx = 0; ptrIdx < numEffectedF; ptrIdx++) {
|
||||
CCGFace *f = (CCGFace*) effectedF[ptrIdx];
|
||||
CCGFace *f = (CCGFace *) effectedF[ptrIdx];
|
||||
int S, x, y;
|
||||
float no[3];
|
||||
|
||||
@@ -1354,19 +1357,19 @@ static void ccgSubSurf__calcVertNormals(CCGSubSurf *ss,
|
||||
for (x = 0; x < gridSize - 1; x++)
|
||||
NormZero(FACE_getIFNo(f, lvl, S, x, y));
|
||||
|
||||
if (FACE_getEdges(f)[(S - 1+f->numVerts)%f->numVerts]->flags&Edge_eEffected)
|
||||
if (FACE_getEdges(f)[(S - 1 + f->numVerts) % f->numVerts]->flags & Edge_eEffected)
|
||||
for (x = 0; x < gridSize - 1; x++)
|
||||
NormZero(FACE_getIFNo(f, lvl, S, x, gridSize - 1));
|
||||
if (FACE_getEdges(f)[S]->flags&Edge_eEffected)
|
||||
if (FACE_getEdges(f)[S]->flags & Edge_eEffected)
|
||||
for (y = 0; y < gridSize - 1; y++)
|
||||
NormZero(FACE_getIFNo(f, lvl, S, gridSize - 1, y));
|
||||
if (FACE_getVerts(f)[S]->flags&Vert_eEffected)
|
||||
if (FACE_getVerts(f)[S]->flags & Vert_eEffected)
|
||||
NormZero(FACE_getIFNo(f, lvl, S, gridSize - 1, gridSize - 1));
|
||||
}
|
||||
|
||||
for (S = 0; S < f->numVerts; S++) {
|
||||
int yLimit = !(FACE_getEdges(f)[(S - 1 + f->numVerts) % f->numVerts]->flags & Edge_eEffected);
|
||||
int xLimit = !(FACE_getEdges(f)[S]->flags&Edge_eEffected);
|
||||
int xLimit = !(FACE_getEdges(f)[S]->flags & Edge_eEffected);
|
||||
int yLimitNext = xLimit;
|
||||
int xLimitPrev = yLimit;
|
||||
|
||||
@@ -1391,13 +1394,13 @@ static void ccgSubSurf__calcVertNormals(CCGSubSurf *ss,
|
||||
if (x == 0 && y == 0) {
|
||||
int K;
|
||||
|
||||
if (!yLimitNext || 1<gridSize - 1)
|
||||
if (!yLimitNext || 1 < gridSize - 1)
|
||||
NormAdd(FACE_getIFNo(f, lvl, (S + 1) % f->numVerts, 0, 1), no);
|
||||
if (!xLimitPrev || 1<gridSize - 1)
|
||||
if (!xLimitPrev || 1 < gridSize - 1)
|
||||
NormAdd(FACE_getIFNo(f, lvl, (S - 1 + f->numVerts) % f->numVerts, 1, 0), no);
|
||||
|
||||
for (K = 0; K < f->numVerts; K++) {
|
||||
if (K!=S) {
|
||||
if (K != S) {
|
||||
NormAdd(FACE_getIFNo(f, lvl, K, 0, 0), no);
|
||||
}
|
||||
}
|
||||
@@ -1416,22 +1419,22 @@ static void ccgSubSurf__calcVertNormals(CCGSubSurf *ss,
|
||||
}
|
||||
}
|
||||
}
|
||||
// XXX can I reduce the number of normalisations here?
|
||||
/* XXX can I reduce the number of normalisations here? */
|
||||
for (ptrIdx = 0; ptrIdx < numEffectedV; ptrIdx++) {
|
||||
CCGVert *v = (CCGVert*) effectedV[ptrIdx];
|
||||
CCGVert *v = (CCGVert *) effectedV[ptrIdx];
|
||||
float length, *no = _vert_getNo(v, lvl, vertDataSize, normalDataOffset);
|
||||
|
||||
NormZero(no);
|
||||
|
||||
for (i = 0; i < v->numFaces; i++) {
|
||||
CCGFace *f = v->faces[i];
|
||||
NormAdd(no, FACE_getIFNo(f, lvl, _face_getVertIndex(f,v), gridSize - 1, gridSize - 1));
|
||||
NormAdd(no, FACE_getIFNo(f, lvl, _face_getVertIndex(f, v), gridSize - 1, gridSize - 1));
|
||||
}
|
||||
|
||||
length = sqrtf(no[0] * no[0] + no[1] * no[1] + no[2] * no[2]);
|
||||
|
||||
if (length > EPSILON) {
|
||||
float invLength = 1.0f/length;
|
||||
float invLength = 1.0f / length;
|
||||
no[0] *= invLength;
|
||||
no[1] *= invLength;
|
||||
no[2] *= invLength;
|
||||
@@ -1442,11 +1445,11 @@ static void ccgSubSurf__calcVertNormals(CCGSubSurf *ss,
|
||||
|
||||
for (i = 0; i < v->numFaces; i++) {
|
||||
CCGFace *f = v->faces[i];
|
||||
NormCopy(FACE_getIFNo(f, lvl, _face_getVertIndex(f,v), gridSize - 1, gridSize - 1), no);
|
||||
NormCopy(FACE_getIFNo(f, lvl, _face_getVertIndex(f, v), gridSize - 1, gridSize - 1), no);
|
||||
}
|
||||
}
|
||||
for (ptrIdx = 0; ptrIdx < numEffectedE; ptrIdx++) {
|
||||
CCGEdge *e = (CCGEdge*) effectedE[ptrIdx];
|
||||
CCGEdge *e = (CCGEdge *) effectedE[ptrIdx];
|
||||
|
||||
if (e->numFaces) {
|
||||
CCGFace *fLast = e->faces[e->numFaces - 1];
|
||||
@@ -1457,7 +1460,7 @@ static void ccgSubSurf__calcVertNormals(CCGSubSurf *ss,
|
||||
|
||||
for (x = 1; x < edgeSize - 1; x++) {
|
||||
NormAdd(_face_getIFNoEdge(fLast, e, lvl, x, 0, subdivLevels, vertDataSize, normalDataOffset),
|
||||
_face_getIFNoEdge(f, e, lvl, x, 0, subdivLevels, vertDataSize, normalDataOffset));
|
||||
_face_getIFNoEdge(f, e, lvl, x, 0, subdivLevels, vertDataSize, normalDataOffset));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1466,7 +1469,7 @@ static void ccgSubSurf__calcVertNormals(CCGSubSurf *ss,
|
||||
|
||||
for (x = 1; x < edgeSize - 1; x++) {
|
||||
NormCopy(_face_getIFNoEdge(f, e, lvl, x, 0, subdivLevels, vertDataSize, normalDataOffset),
|
||||
_face_getIFNoEdge(fLast, e, lvl, x, 0, subdivLevels, vertDataSize, normalDataOffset));
|
||||
_face_getIFNoEdge(fLast, e, lvl, x, 0, subdivLevels, vertDataSize, normalDataOffset));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1474,7 +1477,7 @@ static void ccgSubSurf__calcVertNormals(CCGSubSurf *ss,
|
||||
|
||||
#pragma omp parallel for private(ptrIdx) if (numEffectedF * edgeSize * edgeSize * 4 >= CCG_OMP_LIMIT)
|
||||
for (ptrIdx = 0; ptrIdx < numEffectedF; ptrIdx++) {
|
||||
CCGFace *f = (CCGFace*) effectedF[ptrIdx];
|
||||
CCGFace *f = (CCGFace *) effectedF[ptrIdx];
|
||||
int S, x, y;
|
||||
|
||||
for (S = 0; S < f->numVerts; S++) {
|
||||
@@ -1489,7 +1492,7 @@ static void ccgSubSurf__calcVertNormals(CCGSubSurf *ss,
|
||||
float length = sqrtf(no[0] * no[0] + no[1] * no[1] + no[2] * no[2]);
|
||||
|
||||
if (length > EPSILON) {
|
||||
float invLength = 1.0f/length;
|
||||
float invLength = 1.0f / length;
|
||||
no[0] *= invLength;
|
||||
no[1] *= invLength;
|
||||
no[2] *= invLength;
|
||||
@@ -1501,16 +1504,16 @@ static void ccgSubSurf__calcVertNormals(CCGSubSurf *ss,
|
||||
}
|
||||
|
||||
VertDataCopy((float *)((byte *)FACE_getCenterData(f) + normalDataOffset),
|
||||
FACE_getIFNo(f, lvl, S, 0, 0));
|
||||
FACE_getIFNo(f, lvl, S, 0, 0));
|
||||
|
||||
for (x = 1; x < gridSize - 1; x++)
|
||||
NormCopy(FACE_getIENo(f, lvl, S, x),
|
||||
FACE_getIFNo(f, lvl, S, x, 0));
|
||||
FACE_getIFNo(f, lvl, S, x, 0));
|
||||
}
|
||||
}
|
||||
|
||||
for (ptrIdx = 0; ptrIdx < numEffectedE; ptrIdx++) {
|
||||
CCGEdge *e = (CCGEdge*) effectedE[ptrIdx];
|
||||
CCGEdge *e = (CCGEdge *) effectedE[ptrIdx];
|
||||
|
||||
if (e->numFaces) {
|
||||
CCGFace *f = e->faces[0];
|
||||
@@ -1518,7 +1521,7 @@ static void ccgSubSurf__calcVertNormals(CCGSubSurf *ss,
|
||||
|
||||
for (x = 0; x < edgeSize; x++)
|
||||
NormCopy(EDGE_getNo(e, lvl, x),
|
||||
_face_getIFNoEdge(f, e, lvl, x, 0, subdivLevels, vertDataSize, normalDataOffset));
|
||||
_face_getIFNoEdge(f, e, lvl, x, 0, subdivLevels, vertDataSize, normalDataOffset));
|
||||
}
|
||||
else {
|
||||
/* set to zero here otherwise the normals are uninitialized memory
|
||||
@@ -1535,10 +1538,10 @@ static void ccgSubSurf__calcVertNormals(CCGSubSurf *ss,
|
||||
}
|
||||
#undef FACE_getIFNo
|
||||
|
||||
#define VERT_getCo(v, lvl) _vert_getCo(v, lvl, vertDataSize)
|
||||
#define EDGE_getCo(e, lvl, x) _edge_getCo(e, lvl, x, vertDataSize)
|
||||
#define FACE_getIECo(f, lvl, S, x) _face_getIECo(f, lvl, S, x, subdivLevels, vertDataSize)
|
||||
#define FACE_getIFCo(f, lvl, S, x, y) _face_getIFCo(f, lvl, S, x, y, subdivLevels, vertDataSize)
|
||||
#define VERT_getCo(v, lvl) _vert_getCo(v, lvl, vertDataSize)
|
||||
#define EDGE_getCo(e, lvl, x) _edge_getCo(e, lvl, x, vertDataSize)
|
||||
#define FACE_getIECo(f, lvl, S, x) _face_getIECo(f, lvl, S, x, subdivLevels, vertDataSize)
|
||||
#define FACE_getIFCo(f, lvl, S, x, y) _face_getIFCo(f, lvl, S, x, y, subdivLevels, vertDataSize)
|
||||
|
||||
static void ccgSubSurf__calcSubdivLevel(CCGSubSurf *ss,
|
||||
CCGVert **effectedV, CCGEdge **effectedE, CCGFace **effectedF,
|
||||
@@ -1554,17 +1557,17 @@ static void ccgSubSurf__calcSubdivLevel(CCGSubSurf *ss,
|
||||
|
||||
#pragma omp parallel for private(ptrIdx) if (numEffectedF * edgeSize * edgeSize * 4 >= CCG_OMP_LIMIT)
|
||||
for (ptrIdx = 0; ptrIdx < numEffectedF; ptrIdx++) {
|
||||
CCGFace *f = (CCGFace*) effectedF[ptrIdx];
|
||||
CCGFace *f = (CCGFace *) effectedF[ptrIdx];
|
||||
int S, x, y;
|
||||
|
||||
/* interior face midpoints
|
||||
* o old interior face points
|
||||
*/
|
||||
/* interior face midpoints
|
||||
* - old interior face points
|
||||
*/
|
||||
for (S = 0; S < f->numVerts; S++) {
|
||||
for (y = 0; y < gridSize - 1; y++) {
|
||||
for (x = 0; x < gridSize - 1; x++) {
|
||||
int fx = 1 + 2*x;
|
||||
int fy = 1 + 2*y;
|
||||
int fx = 1 + 2 * x;
|
||||
int fy = 1 + 2 * y;
|
||||
void *co0 = FACE_getIFCo(f, curLvl, S, x + 0, y + 0);
|
||||
void *co1 = FACE_getIFCo(f, curLvl, S, x + 1, y + 0);
|
||||
void *co2 = FACE_getIFCo(f, curLvl, S, x + 1, y + 1);
|
||||
@@ -1576,10 +1579,10 @@ static void ccgSubSurf__calcSubdivLevel(CCGSubSurf *ss,
|
||||
}
|
||||
}
|
||||
|
||||
/* interior edge midpoints
|
||||
* o old interior edge points
|
||||
* o new interior face midpoints
|
||||
*/
|
||||
/* interior edge midpoints
|
||||
* - old interior edge points
|
||||
* - new interior face midpoints
|
||||
*/
|
||||
for (S = 0; S < f->numVerts; S++) {
|
||||
for (x = 0; x < gridSize - 1; x++) {
|
||||
int fx = x * 2 + 1;
|
||||
@@ -1592,12 +1595,12 @@ static void ccgSubSurf__calcSubdivLevel(CCGSubSurf *ss,
|
||||
VertDataAvg4(co, co0, co1, co2, co3);
|
||||
}
|
||||
|
||||
/* interior face interior edge midpoints
|
||||
* o old interior face points
|
||||
* o new interior face midpoints
|
||||
*/
|
||||
/* interior face interior edge midpoints
|
||||
* - old interior face points
|
||||
* - new interior face midpoints
|
||||
*/
|
||||
|
||||
/* vertical */
|
||||
/* vertical */
|
||||
for (x = 1; x < gridSize - 1; x++) {
|
||||
for (y = 0; y < gridSize - 1; y++) {
|
||||
int fx = x * 2;
|
||||
@@ -1612,7 +1615,7 @@ static void ccgSubSurf__calcSubdivLevel(CCGSubSurf *ss,
|
||||
}
|
||||
}
|
||||
|
||||
/* horizontal */
|
||||
/* horizontal */
|
||||
for (y = 1; y < gridSize - 1; y++) {
|
||||
for (x = 0; x < gridSize - 1; x++) {
|
||||
int fx = x * 2 + 1;
|
||||
@@ -1629,12 +1632,12 @@ static void ccgSubSurf__calcSubdivLevel(CCGSubSurf *ss,
|
||||
}
|
||||
}
|
||||
|
||||
/* exterior edge midpoints
|
||||
* o old exterior edge points
|
||||
* o new interior face midpoints
|
||||
*/
|
||||
/* exterior edge midpoints
|
||||
* - old exterior edge points
|
||||
* - new interior face midpoints
|
||||
*/
|
||||
for (ptrIdx = 0; ptrIdx < numEffectedE; ptrIdx++) {
|
||||
CCGEdge *e = (CCGEdge*) effectedE[ptrIdx];
|
||||
CCGEdge *e = (CCGEdge *) effectedE[ptrIdx];
|
||||
float sharpness = EDGE_getSharpness(e, curLvl);
|
||||
int x, j;
|
||||
|
||||
@@ -1681,13 +1684,13 @@ static void ccgSubSurf__calcSubdivLevel(CCGSubSurf *ss,
|
||||
}
|
||||
}
|
||||
|
||||
/* exterior vertex shift
|
||||
* o old vertex points (shifting)
|
||||
* o old exterior edge points
|
||||
* o new interior face midpoints
|
||||
*/
|
||||
/* exterior vertex shift
|
||||
* - old vertex points (shifting)
|
||||
* - old exterior edge points
|
||||
* - new interior face midpoints
|
||||
*/
|
||||
for (ptrIdx = 0; ptrIdx < numEffectedV; ptrIdx++) {
|
||||
CCGVert *v = (CCGVert*) effectedV[ptrIdx];
|
||||
CCGVert *v = (CCGVert *) effectedV[ptrIdx];
|
||||
void *co = VERT_getCo(v, curLvl);
|
||||
void *nCo = VERT_getCo(v, nextLvl);
|
||||
int sharpCount = 0, allSharp = 1;
|
||||
@@ -1701,7 +1704,7 @@ static void ccgSubSurf__calcSubdivLevel(CCGSubSurf *ss,
|
||||
if (seam && _edge_isBoundary(e))
|
||||
seamEdges++;
|
||||
|
||||
if (sharpness!=0.0f) {
|
||||
if (sharpness != 0.0f) {
|
||||
sharpCount++;
|
||||
avgSharpness += sharpness;
|
||||
}
|
||||
@@ -1737,7 +1740,7 @@ static void ccgSubSurf__calcSubdivLevel(CCGSubSurf *ss,
|
||||
|
||||
VertDataCopy(nCo, co);
|
||||
VertDataMulN(nCo, 0.75f);
|
||||
VertDataMulN(r, 0.25f/numBoundary);
|
||||
VertDataMulN(r, 0.25f / numBoundary);
|
||||
VertDataAdd(nCo, r);
|
||||
}
|
||||
else {
|
||||
@@ -1747,26 +1750,26 @@ static void ccgSubSurf__calcSubdivLevel(CCGSubSurf *ss,
|
||||
VertDataZero(q);
|
||||
for (j = 0; j < v->numFaces; j++) {
|
||||
CCGFace *f = v->faces[j];
|
||||
VertDataAdd(q, FACE_getIFCo(f, nextLvl, _face_getVertIndex(f,v), cornerIdx, cornerIdx));
|
||||
VertDataAdd(q, FACE_getIFCo(f, nextLvl, _face_getVertIndex(f, v), cornerIdx, cornerIdx));
|
||||
numFaces++;
|
||||
}
|
||||
VertDataMulN(q, 1.0f/numFaces);
|
||||
VertDataMulN(q, 1.0f / numFaces);
|
||||
VertDataZero(r);
|
||||
for (j = 0; j < v->numEdges; j++) {
|
||||
CCGEdge *e = v->edges[j];
|
||||
VertDataAdd(r, _edge_getCoVert(e, v, curLvl, 1,vertDataSize));
|
||||
VertDataAdd(r, _edge_getCoVert(e, v, curLvl, 1, vertDataSize));
|
||||
numEdges++;
|
||||
}
|
||||
VertDataMulN(r, 1.0f/numEdges);
|
||||
VertDataMulN(r, 1.0f / numEdges);
|
||||
|
||||
VertDataCopy(nCo, co);
|
||||
VertDataMulN(nCo, numEdges - 2.0f);
|
||||
VertDataAdd(nCo, q);
|
||||
VertDataAdd(nCo, r);
|
||||
VertDataMulN(nCo, 1.0f/numEdges);
|
||||
VertDataMulN(nCo, 1.0f / numEdges);
|
||||
}
|
||||
|
||||
if ((sharpCount>1 && v->numFaces) || seam) {
|
||||
if ((sharpCount > 1 && v->numFaces) || seam) {
|
||||
VertDataZero(q);
|
||||
|
||||
if (seam) {
|
||||
@@ -1788,42 +1791,42 @@ static void ccgSubSurf__calcSubdivLevel(CCGSubSurf *ss,
|
||||
}
|
||||
}
|
||||
|
||||
VertDataMulN(q, (float) 1/sharpCount);
|
||||
VertDataMulN(q, (float) 1 / sharpCount);
|
||||
|
||||
if (sharpCount!=2 || allSharp) {
|
||||
// q = q + (co-q) * avgSharpness
|
||||
if (sharpCount != 2 || allSharp) {
|
||||
/* q = q + (co - q) * avgSharpness */
|
||||
VertDataCopy(r, co);
|
||||
VertDataSub(r, q);
|
||||
VertDataMulN(r, avgSharpness);
|
||||
VertDataAdd(q, r);
|
||||
}
|
||||
|
||||
// r = co*.75 + q*.25
|
||||
/* r = co * 0.75 + q * 0.25 */
|
||||
VertDataCopy(r, co);
|
||||
VertDataMulN(r, .75f);
|
||||
VertDataMulN(q, .25f);
|
||||
VertDataAdd(r, q);
|
||||
|
||||
// nCo = nCo + (r-nCo) * avgSharpness
|
||||
/* nCo = nCo + (r - nCo) * avgSharpness */
|
||||
VertDataSub(r, nCo);
|
||||
VertDataMulN(r, avgSharpness);
|
||||
VertDataAdd(nCo, r);
|
||||
}
|
||||
}
|
||||
|
||||
/* exterior edge interior shift
|
||||
* o old exterior edge midpoints (shifting)
|
||||
* o old exterior edge midpoints
|
||||
* o new interior face midpoints
|
||||
*/
|
||||
/* exterior edge interior shift
|
||||
* - old exterior edge midpoints (shifting)
|
||||
* - old exterior edge midpoints
|
||||
* - new interior face midpoints
|
||||
*/
|
||||
for (ptrIdx = 0; ptrIdx < numEffectedE; ptrIdx++) {
|
||||
CCGEdge *e = (CCGEdge*) effectedE[ptrIdx];
|
||||
CCGEdge *e = (CCGEdge *) effectedE[ptrIdx];
|
||||
float sharpness = EDGE_getSharpness(e, curLvl);
|
||||
int sharpCount = 0;
|
||||
float avgSharpness = 0.0;
|
||||
int x, j;
|
||||
|
||||
if (sharpness!=0.0f) {
|
||||
if (sharpness != 0.0f) {
|
||||
sharpCount = 2;
|
||||
avgSharpness += sharpness;
|
||||
|
||||
@@ -1836,7 +1839,7 @@ static void ccgSubSurf__calcSubdivLevel(CCGSubSurf *ss,
|
||||
avgSharpness = 0;
|
||||
}
|
||||
|
||||
if (_edge_isBoundary(e) && (!e->numFaces || sharpCount<2)) {
|
||||
if (_edge_isBoundary(e) && (!e->numFaces || sharpCount < 2)) {
|
||||
for (x = 1; x < edgeSize - 1; x++) {
|
||||
int fx = x * 2;
|
||||
void *co = EDGE_getCo(e, curLvl, x);
|
||||
@@ -1883,7 +1886,7 @@ static void ccgSubSurf__calcSubdivLevel(CCGSubSurf *ss,
|
||||
VertDataMulN(q, 6.0f);
|
||||
VertDataAdd(q, EDGE_getCo(e, curLvl, x - 1));
|
||||
VertDataAdd(q, EDGE_getCo(e, curLvl, x + 1));
|
||||
VertDataMulN(q, 1/8.0f);
|
||||
VertDataMulN(q, 1 / 8.0f);
|
||||
|
||||
VertDataSub(q, nCo);
|
||||
VertDataMulN(q, avgSharpness);
|
||||
@@ -1905,36 +1908,36 @@ static void ccgSubSurf__calcSubdivLevel(CCGSubSurf *ss,
|
||||
|
||||
#pragma omp for schedule(static)
|
||||
for (ptrIdx = 0; ptrIdx < numEffectedF; ptrIdx++) {
|
||||
CCGFace *f = (CCGFace*) effectedF[ptrIdx];
|
||||
CCGFace *f = (CCGFace *) effectedF[ptrIdx];
|
||||
int S, x, y;
|
||||
|
||||
/* interior center point shift
|
||||
* o old face center point (shifting)
|
||||
* o old interior edge points
|
||||
* o new interior face midpoints
|
||||
*/
|
||||
/* interior center point shift
|
||||
* - old face center point (shifting)
|
||||
* - old interior edge points
|
||||
* - new interior face midpoints
|
||||
*/
|
||||
VertDataZero(q);
|
||||
for (S = 0; S < f->numVerts; S++) {
|
||||
VertDataAdd(q, FACE_getIFCo(f, nextLvl, S, 1, 1));
|
||||
}
|
||||
VertDataMulN(q, 1.0f/f->numVerts);
|
||||
VertDataMulN(q, 1.0f / f->numVerts);
|
||||
VertDataZero(r);
|
||||
for (S = 0; S < f->numVerts; S++) {
|
||||
VertDataAdd(r, FACE_getIECo(f, curLvl, S, 1));
|
||||
}
|
||||
VertDataMulN(r, 1.0f/f->numVerts);
|
||||
VertDataMulN(r, 1.0f / f->numVerts);
|
||||
|
||||
VertDataMulN(FACE_getCenterData(f), f->numVerts - 2.0f);
|
||||
VertDataAdd(FACE_getCenterData(f), q);
|
||||
VertDataAdd(FACE_getCenterData(f), r);
|
||||
VertDataMulN(FACE_getCenterData(f), 1.0f/f->numVerts);
|
||||
VertDataMulN(FACE_getCenterData(f), 1.0f / f->numVerts);
|
||||
|
||||
for (S = 0; S < f->numVerts; S++) {
|
||||
/* interior face shift
|
||||
* o old interior face point (shifting)
|
||||
* o new interior edge midpoints
|
||||
* o new interior face midpoints
|
||||
*/
|
||||
/* interior face shift
|
||||
* - old interior face point (shifting)
|
||||
* - new interior edge midpoints
|
||||
* - new interior face midpoints
|
||||
*/
|
||||
for (x = 1; x < gridSize - 1; x++) {
|
||||
for (y = 1; y < gridSize - 1; y++) {
|
||||
int fx = x * 2;
|
||||
@@ -1961,11 +1964,11 @@ static void ccgSubSurf__calcSubdivLevel(CCGSubSurf *ss,
|
||||
}
|
||||
}
|
||||
|
||||
/* interior edge interior shift
|
||||
* o old interior edge point (shifting)
|
||||
* o new interior edge midpoints
|
||||
* o new interior face midpoints
|
||||
*/
|
||||
/* interior edge interior shift
|
||||
* - old interior edge point (shifting)
|
||||
* - new interior edge midpoints
|
||||
* - new interior face midpoints
|
||||
*/
|
||||
for (x = 1; x < gridSize - 1; x++) {
|
||||
int fx = x * 2;
|
||||
void *co = FACE_getIECo(f, curLvl, S, x);
|
||||
@@ -1974,8 +1977,8 @@ static void ccgSubSurf__calcSubdivLevel(CCGSubSurf *ss,
|
||||
VertDataAvg4(q,
|
||||
FACE_getIFCo(f, nextLvl, (S + 1) % f->numVerts, 1, fx - 1),
|
||||
FACE_getIFCo(f, nextLvl, (S + 1) % f->numVerts, 1, fx + 1),
|
||||
FACE_getIFCo(f, nextLvl, S, fx + 1, + 1),
|
||||
FACE_getIFCo(f, nextLvl, S, fx - 1, + 1));
|
||||
FACE_getIFCo(f, nextLvl, S, fx + 1, +1),
|
||||
FACE_getIFCo(f, nextLvl, S, fx - 1, +1));
|
||||
|
||||
VertDataAvg4(r,
|
||||
FACE_getIECo(f, nextLvl, S, fx - 1),
|
||||
@@ -1998,7 +2001,7 @@ static void ccgSubSurf__calcSubdivLevel(CCGSubSurf *ss,
|
||||
}
|
||||
}
|
||||
|
||||
/* copy down */
|
||||
/* copy down */
|
||||
edgeSize = ccg_edgesize(nextLvl);
|
||||
gridSize = ccg_gridsize(nextLvl);
|
||||
cornerIdx = gridSize - 1;
|
||||
@@ -2030,8 +2033,8 @@ static void ccgSubSurf__calcSubdivLevel(CCGSubSurf *ss,
|
||||
}
|
||||
for (x = 0; x < gridSize - 1; x++) {
|
||||
int eI = gridSize - 1 - x;
|
||||
VertDataCopy(FACE_getIFCo(f, nextLvl, S, cornerIdx, x), _edge_getCoVert(e, FACE_getVerts(f)[S], nextLvl, eI,vertDataSize));
|
||||
VertDataCopy(FACE_getIFCo(f, nextLvl, S, x, cornerIdx), _edge_getCoVert(prevE, FACE_getVerts(f)[S], nextLvl, eI,vertDataSize));
|
||||
VertDataCopy(FACE_getIFCo(f, nextLvl, S, cornerIdx, x), _edge_getCoVert(e, FACE_getVerts(f)[S], nextLvl, eI, vertDataSize));
|
||||
VertDataCopy(FACE_getIFCo(f, nextLvl, S, x, cornerIdx), _edge_getCoVert(prevE, FACE_getVerts(f)[S], nextLvl, eI, vertDataSize));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2055,14 +2058,14 @@ static void ccgSubSurf__sync(CCGSubSurf *ss)
|
||||
effectedF = MEM_mallocN(sizeof(*effectedF) * ss->fMap->numEntries, "CCGSubsurf effectedF");
|
||||
numEffectedV = numEffectedE = numEffectedF = 0;
|
||||
for (i = 0; i < ss->vMap->curSize; i++) {
|
||||
CCGVert *v = (CCGVert*) ss->vMap->buckets[i];
|
||||
CCGVert *v = (CCGVert *) ss->vMap->buckets[i];
|
||||
for (; v; v = v->next) {
|
||||
if (v->flags&Vert_eEffected) {
|
||||
if (v->flags & Vert_eEffected) {
|
||||
effectedV[numEffectedV++] = v;
|
||||
|
||||
for (j = 0; j < v->numEdges; j++) {
|
||||
CCGEdge *e = v->edges[j];
|
||||
if (!(e->flags&Edge_eEffected)) {
|
||||
if (!(e->flags & Edge_eEffected)) {
|
||||
effectedE[numEffectedE++] = e;
|
||||
e->flags |= Edge_eEffected;
|
||||
}
|
||||
@@ -2070,7 +2073,7 @@ static void ccgSubSurf__sync(CCGSubSurf *ss)
|
||||
|
||||
for (j = 0; j < v->numFaces; j++) {
|
||||
CCGFace *f = v->faces[j];
|
||||
if (!(f->flags&Face_eEffected)) {
|
||||
if (!(f->flags & Face_eEffected)) {
|
||||
effectedF[numEffectedF++] = f;
|
||||
f->flags |= Face_eEffected;
|
||||
}
|
||||
@@ -2089,7 +2092,7 @@ static void ccgSubSurf__sync(CCGSubSurf *ss)
|
||||
for (i = 0; i < f->numVerts; i++) {
|
||||
VertDataAdd(co, VERT_getCo(FACE_getVerts(f)[i], curLvl));
|
||||
}
|
||||
VertDataMulN(co, 1.0f/f->numVerts);
|
||||
VertDataMulN(co, 1.0f / f->numVerts);
|
||||
|
||||
f->flags = 0;
|
||||
}
|
||||
@@ -2141,7 +2144,7 @@ static void ccgSubSurf__sync(CCGSubSurf *ss)
|
||||
if (seam && _edge_isBoundary(e))
|
||||
seamEdges++;
|
||||
|
||||
if (sharpness!=0.0f) {
|
||||
if (sharpness != 0.0f) {
|
||||
sharpCount++;
|
||||
avgSharpness += sharpness;
|
||||
}
|
||||
@@ -2176,7 +2179,7 @@ static void ccgSubSurf__sync(CCGSubSurf *ss)
|
||||
}
|
||||
VertDataCopy(nCo, co);
|
||||
VertDataMulN(nCo, 0.75f);
|
||||
VertDataMulN(r, 0.25f/numBoundary);
|
||||
VertDataMulN(r, 0.25f / numBoundary);
|
||||
VertDataAdd(nCo, r);
|
||||
}
|
||||
else {
|
||||
@@ -2188,23 +2191,23 @@ static void ccgSubSurf__sync(CCGSubSurf *ss)
|
||||
VertDataAdd(q, FACE_getCenterData(f));
|
||||
numFaces++;
|
||||
}
|
||||
VertDataMulN(q, 1.0f/numFaces);
|
||||
VertDataMulN(q, 1.0f / numFaces);
|
||||
VertDataZero(r);
|
||||
for (i = 0; i < v->numEdges; i++) {
|
||||
CCGEdge *e = v->edges[i];
|
||||
VertDataAdd(r, VERT_getCo(_edge_getOtherVert(e, v), curLvl));
|
||||
numEdges++;
|
||||
}
|
||||
VertDataMulN(r, 1.0f/numEdges);
|
||||
VertDataMulN(r, 1.0f / numEdges);
|
||||
|
||||
VertDataCopy(nCo, co);
|
||||
VertDataMulN(nCo, numEdges - 2.0f);
|
||||
VertDataAdd(nCo, q);
|
||||
VertDataAdd(nCo, r);
|
||||
VertDataMulN(nCo, 1.0f/numEdges);
|
||||
VertDataMulN(nCo, 1.0f / numEdges);
|
||||
}
|
||||
|
||||
if (sharpCount>1 || seam) {
|
||||
if (sharpCount > 1 || seam) {
|
||||
VertDataZero(q);
|
||||
|
||||
if (seam) {
|
||||
@@ -2229,23 +2232,23 @@ static void ccgSubSurf__sync(CCGSubSurf *ss)
|
||||
}
|
||||
}
|
||||
|
||||
VertDataMulN(q, (float) 1/sharpCount);
|
||||
VertDataMulN(q, (float) 1 / sharpCount);
|
||||
|
||||
if (sharpCount!=2 || allSharp) {
|
||||
// q = q + (co-q) * avgSharpness
|
||||
if (sharpCount != 2 || allSharp) {
|
||||
/* q = q + (co - q) * avgSharpness */
|
||||
VertDataCopy(r, co);
|
||||
VertDataSub(r, q);
|
||||
VertDataMulN(r, avgSharpness);
|
||||
VertDataAdd(q, r);
|
||||
}
|
||||
|
||||
// r = co*.75 + q*.25
|
||||
/* r = co * 0.75 + q * 0.25 */
|
||||
VertDataCopy(r, co);
|
||||
VertDataMulN(r, 0.75f);
|
||||
VertDataMulN(q, 0.25f);
|
||||
VertDataAdd(r, q);
|
||||
|
||||
// nCo = nCo + (r-nCo) * avgSharpness
|
||||
/* nCo = nCo + (r - nCo) * avgSharpness */
|
||||
VertDataSub(r, nCo);
|
||||
VertDataMulN(r, avgSharpness);
|
||||
VertDataAdd(nCo, r);
|
||||
@@ -2258,19 +2261,19 @@ static void ccgSubSurf__sync(CCGSubSurf *ss)
|
||||
for (i = 0; i < numEffectedV; i++) {
|
||||
CCGVert *v = effectedV[i];
|
||||
byte *userData = ccgSubSurf_getVertUserData(ss, v);
|
||||
*((int*) &userData[ss->vertUserAgeOffset]) = ss->currentAge;
|
||||
*((int *) &userData[ss->vertUserAgeOffset]) = ss->currentAge;
|
||||
}
|
||||
|
||||
for (i = 0; i < numEffectedE; i++) {
|
||||
CCGEdge *e = effectedE[i];
|
||||
byte *userData = ccgSubSurf_getEdgeUserData(ss, e);
|
||||
*((int*) &userData[ss->edgeUserAgeOffset]) = ss->currentAge;
|
||||
*((int *) &userData[ss->edgeUserAgeOffset]) = ss->currentAge;
|
||||
}
|
||||
|
||||
for (i = 0; i < numEffectedF; i++) {
|
||||
CCGFace *f = effectedF[i];
|
||||
byte *userData = ccgSubSurf_getFaceUserData(ss, f);
|
||||
*((int*) &userData[ss->faceUserAgeOffset]) = ss->currentAge;
|
||||
*((int *) &userData[ss->faceUserAgeOffset]) = ss->currentAge;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2297,14 +2300,14 @@ static void ccgSubSurf__sync(CCGSubSurf *ss)
|
||||
|
||||
for (curLvl = 1; curLvl < subdivLevels; curLvl++) {
|
||||
ccgSubSurf__calcSubdivLevel(ss,
|
||||
effectedV, effectedE, effectedF,
|
||||
numEffectedV, numEffectedE, numEffectedF, curLvl);
|
||||
effectedV, effectedE, effectedF,
|
||||
numEffectedV, numEffectedE, numEffectedF, curLvl);
|
||||
}
|
||||
|
||||
if (ss->calcVertNormals)
|
||||
ccgSubSurf__calcVertNormals(ss,
|
||||
effectedV, effectedE, effectedF,
|
||||
numEffectedV, numEffectedE, numEffectedF);
|
||||
effectedV, effectedE, effectedF,
|
||||
numEffectedV, numEffectedE, numEffectedF);
|
||||
|
||||
for (ptrIdx = 0; ptrIdx < numEffectedV; ptrIdx++) {
|
||||
CCGVert *v = effectedV[ptrIdx];
|
||||
@@ -2329,7 +2332,7 @@ static void ccgSubSurf__allFaces(CCGSubSurf *ss, CCGFace ***faces, int *numFaces
|
||||
array = MEM_mallocN(sizeof(*array) * ss->fMap->numEntries, "CCGSubsurf allFaces");
|
||||
num = 0;
|
||||
for (i = 0; i < ss->fMap->curSize; i++) {
|
||||
CCGFace *f = (CCGFace*) ss->fMap->buckets[i];
|
||||
CCGFace *f = (CCGFace *) ss->fMap->buckets[i];
|
||||
|
||||
for (; f; f = f->next)
|
||||
array[num++] = f;
|
||||
@@ -2360,7 +2363,7 @@ static void ccgSubSurf__effectedFaceNeighbours(CCGSubSurf *ss, CCGFace **faces,
|
||||
}
|
||||
|
||||
for (i = 0; i < ss->vMap->curSize; i++) {
|
||||
CCGVert *v = (CCGVert*) ss->vMap->buckets[i];
|
||||
CCGVert *v = (CCGVert *) ss->vMap->buckets[i];
|
||||
|
||||
for (; v; v = v->next) {
|
||||
for (j = 0; j < v->numFaces; j++)
|
||||
@@ -2375,7 +2378,7 @@ static void ccgSubSurf__effectedFaceNeighbours(CCGSubSurf *ss, CCGFace **faces,
|
||||
}
|
||||
|
||||
for (i = 0; i < ss->eMap->curSize; i++) {
|
||||
CCGEdge *e = (CCGEdge*) ss->eMap->buckets[i];
|
||||
CCGEdge *e = (CCGEdge *) ss->eMap->buckets[i];
|
||||
|
||||
for (; e; e = e->next) {
|
||||
for (j = 0; j < e->numFaces; j++)
|
||||
@@ -2402,7 +2405,7 @@ CCGError ccgSubSurf_updateFromFaces(CCGSubSurf *ss, int lvl, CCGFace **effectedF
|
||||
int vertDataSize = ss->meshIFC.vertDataSize, freeF;
|
||||
|
||||
subdivLevels = ss->subdivLevels;
|
||||
lvl = (lvl)? lvl: subdivLevels;
|
||||
lvl = (lvl) ? lvl : subdivLevels;
|
||||
gridSize = ccg_gridsize(lvl);
|
||||
cornerIdx = gridSize - 1;
|
||||
|
||||
@@ -2423,8 +2426,8 @@ CCGError ccgSubSurf_updateFromFaces(CCGSubSurf *ss, int lvl, CCGFace **effectedF
|
||||
|
||||
for (x = 0; x < gridSize; x++) {
|
||||
int eI = gridSize - 1 - x;
|
||||
VertDataCopy(_edge_getCoVert(e, FACE_getVerts(f)[S], lvl, eI,vertDataSize), FACE_getIFCo(f, lvl, S, cornerIdx, x));
|
||||
VertDataCopy(_edge_getCoVert(prevE, FACE_getVerts(f)[S], lvl, eI,vertDataSize), FACE_getIFCo(f, lvl, S, x, cornerIdx));
|
||||
VertDataCopy(_edge_getCoVert(e, FACE_getVerts(f)[S], lvl, eI, vertDataSize), FACE_getIFCo(f, lvl, S, cornerIdx, x));
|
||||
VertDataCopy(_edge_getCoVert(prevE, FACE_getVerts(f)[S], lvl, eI, vertDataSize), FACE_getIFCo(f, lvl, S, x, cornerIdx));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2441,7 +2444,7 @@ CCGError ccgSubSurf_updateToFaces(CCGSubSurf *ss, int lvl, CCGFace **effectedF,
|
||||
int vertDataSize = ss->meshIFC.vertDataSize, freeF;
|
||||
|
||||
subdivLevels = ss->subdivLevels;
|
||||
lvl = (lvl)? lvl: subdivLevels;
|
||||
lvl = (lvl) ? lvl : subdivLevels;
|
||||
gridSize = ccg_gridsize(lvl);
|
||||
cornerIdx = gridSize - 1;
|
||||
|
||||
@@ -2457,8 +2460,8 @@ CCGError ccgSubSurf_updateToFaces(CCGSubSurf *ss, int lvl, CCGFace **effectedF,
|
||||
|
||||
for (x = 0; x < gridSize; x++) {
|
||||
int eI = gridSize - 1 - x;
|
||||
VertDataCopy(FACE_getIFCo(f, lvl, S, cornerIdx, x), _edge_getCoVert(e, FACE_getVerts(f)[S], lvl, eI,vertDataSize));
|
||||
VertDataCopy(FACE_getIFCo(f, lvl, S, x, cornerIdx), _edge_getCoVert(prevE, FACE_getVerts(f)[S], lvl, eI,vertDataSize));
|
||||
VertDataCopy(FACE_getIFCo(f, lvl, S, cornerIdx, x), _edge_getCoVert(e, FACE_getVerts(f)[S], lvl, eI, vertDataSize));
|
||||
VertDataCopy(FACE_getIFCo(f, lvl, S, x, cornerIdx), _edge_getCoVert(prevE, FACE_getVerts(f)[S], lvl, eI, vertDataSize));
|
||||
}
|
||||
|
||||
for (x = 1; x < gridSize - 1; x++) {
|
||||
@@ -2487,14 +2490,14 @@ CCGError ccgSubSurf_stitchFaces(CCGSubSurf *ss, int lvl, CCGFace **effectedF, in
|
||||
int vertDataSize = ss->meshIFC.vertDataSize;
|
||||
|
||||
subdivLevels = ss->subdivLevels;
|
||||
lvl = (lvl)? lvl: subdivLevels;
|
||||
lvl = (lvl) ? lvl : subdivLevels;
|
||||
gridSize = ccg_gridsize(lvl);
|
||||
edgeSize = ccg_edgesize(lvl);
|
||||
cornerIdx = gridSize - 1;
|
||||
|
||||
ccgSubSurf__allFaces(ss, &effectedF, &numEffectedF, &freeF);
|
||||
ccgSubSurf__effectedFaceNeighbours(ss, effectedF, numEffectedF,
|
||||
&effectedV, &numEffectedV, &effectedE, &numEffectedE);
|
||||
&effectedV, &numEffectedV, &effectedE, &numEffectedE);
|
||||
|
||||
/* zero */
|
||||
for (i = 0; i < numEffectedV; i++) {
|
||||
@@ -2527,7 +2530,7 @@ CCGError ccgSubSurf_stitchFaces(CCGSubSurf *ss, int lvl, CCGFace **effectedF, in
|
||||
CCGEdge *prevE = FACE_getEdges(f)[prevS];
|
||||
|
||||
VertDataAdd(FACE_getCenterData(f), FACE_getIFCo(f, lvl, S, 0, 0));
|
||||
if (FACE_getVerts(f)[S]->flags&Vert_eEffected)
|
||||
if (FACE_getVerts(f)[S]->flags & Vert_eEffected)
|
||||
VertDataAdd(VERT_getCo(FACE_getVerts(f)[S], lvl), FACE_getIFCo(f, lvl, S, cornerIdx, cornerIdx));
|
||||
|
||||
for (x = 1; x < gridSize - 1; x++) {
|
||||
@@ -2537,11 +2540,11 @@ CCGError ccgSubSurf_stitchFaces(CCGSubSurf *ss, int lvl, CCGFace **effectedF, in
|
||||
|
||||
for (x = 0; x < gridSize - 1; x++) {
|
||||
int eI = gridSize - 1 - x;
|
||||
if (FACE_getEdges(f)[S]->flags&Edge_eEffected)
|
||||
VertDataAdd(_edge_getCoVert(e, FACE_getVerts(f)[S], lvl, eI,vertDataSize), FACE_getIFCo(f, lvl, S, cornerIdx, x));
|
||||
if (FACE_getEdges(f)[prevS]->flags&Edge_eEffected)
|
||||
if (FACE_getEdges(f)[S]->flags & Edge_eEffected)
|
||||
VertDataAdd(_edge_getCoVert(e, FACE_getVerts(f)[S], lvl, eI, vertDataSize), FACE_getIFCo(f, lvl, S, cornerIdx, x));
|
||||
if (FACE_getEdges(f)[prevS]->flags & Edge_eEffected)
|
||||
if (x != 0)
|
||||
VertDataAdd(_edge_getCoVert(prevE, FACE_getVerts(f)[S], lvl, eI,vertDataSize), FACE_getIFCo(f, lvl, S, x, cornerIdx));
|
||||
VertDataAdd(_edge_getCoVert(prevE, FACE_getVerts(f)[S], lvl, eI, vertDataSize), FACE_getIFCo(f, lvl, S, x, cornerIdx));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2550,7 +2553,7 @@ CCGError ccgSubSurf_stitchFaces(CCGSubSurf *ss, int lvl, CCGFace **effectedF, in
|
||||
for (i = 0; i < numEffectedV; i++) {
|
||||
CCGVert *v = effectedV[i];
|
||||
if (v->numFaces)
|
||||
VertDataMulN(VERT_getCo(v, lvl), 1.0f/v->numFaces);
|
||||
VertDataMulN(VERT_getCo(v, lvl), 1.0f / v->numFaces);
|
||||
}
|
||||
|
||||
for (i = 0; i < numEffectedE; i++) {
|
||||
@@ -2561,14 +2564,14 @@ CCGError ccgSubSurf_stitchFaces(CCGSubSurf *ss, int lvl, CCGFace **effectedF, in
|
||||
|
||||
if (e->numFaces)
|
||||
for (x = 1; x < edgeSize - 1; x++)
|
||||
VertDataMulN(EDGE_getCo(e, lvl, x), 1.0f/e->numFaces);
|
||||
VertDataMulN(EDGE_getCo(e, lvl, x), 1.0f / e->numFaces);
|
||||
}
|
||||
|
||||
/* copy */
|
||||
for (i = 0; i < numEffectedF; i++) {
|
||||
CCGFace *f = effectedF[i];
|
||||
|
||||
VertDataMulN(FACE_getCenterData(f), 1.0f/f->numVerts);
|
||||
VertDataMulN(FACE_getCenterData(f), 1.0f / f->numVerts);
|
||||
|
||||
for (S = 0; S < f->numVerts; S++)
|
||||
for (x = 1; x < gridSize - 1; x++)
|
||||
@@ -2589,8 +2592,8 @@ CCGError ccgSubSurf_stitchFaces(CCGSubSurf *ss, int lvl, CCGFace **effectedF, in
|
||||
|
||||
for (x = 0; x < gridSize - 1; x++) {
|
||||
int eI = gridSize - 1 - x;
|
||||
VertDataCopy(FACE_getIFCo(f, lvl, S, cornerIdx, x), _edge_getCoVert(e, FACE_getVerts(f)[S], lvl, eI,vertDataSize));
|
||||
VertDataCopy(FACE_getIFCo(f, lvl, S, x, cornerIdx), _edge_getCoVert(prevE, FACE_getVerts(f)[S], lvl, eI,vertDataSize));
|
||||
VertDataCopy(FACE_getIFCo(f, lvl, S, cornerIdx, x), _edge_getCoVert(e, FACE_getVerts(f)[S], lvl, eI, vertDataSize));
|
||||
VertDataCopy(FACE_getIFCo(f, lvl, S, x, cornerIdx), _edge_getCoVert(prevE, FACE_getVerts(f)[S], lvl, eI, vertDataSize));
|
||||
}
|
||||
|
||||
VertDataCopy(FACE_getIECo(f, lvl, S, 0), FACE_getCenterData(f));
|
||||
@@ -2621,12 +2624,12 @@ CCGError ccgSubSurf_updateNormals(CCGSubSurf *ss, CCGFace **effectedF, int numEf
|
||||
|
||||
ccgSubSurf__allFaces(ss, &effectedF, &numEffectedF, &freeF);
|
||||
ccgSubSurf__effectedFaceNeighbours(ss, effectedF, numEffectedF,
|
||||
&effectedV, &numEffectedV, &effectedE, &numEffectedE);
|
||||
&effectedV, &numEffectedV, &effectedE, &numEffectedE);
|
||||
|
||||
if (ss->calcVertNormals)
|
||||
ccgSubSurf__calcVertNormals(ss,
|
||||
effectedV, effectedE, effectedF,
|
||||
numEffectedV, numEffectedE, numEffectedF);
|
||||
effectedV, effectedE, effectedF,
|
||||
numEffectedV, numEffectedE, numEffectedF);
|
||||
|
||||
for (i = 0; i < numEffectedV; i++)
|
||||
effectedV[i]->flags = 0;
|
||||
@@ -2654,12 +2657,12 @@ CCGError ccgSubSurf_updateLevels(CCGSubSurf *ss, int lvl, CCGFace **effectedF, i
|
||||
|
||||
ccgSubSurf__allFaces(ss, &effectedF, &numEffectedF, &freeF);
|
||||
ccgSubSurf__effectedFaceNeighbours(ss, effectedF, numEffectedF,
|
||||
&effectedV, &numEffectedV, &effectedE, &numEffectedE);
|
||||
&effectedV, &numEffectedV, &effectedE, &numEffectedE);
|
||||
|
||||
for (curLvl = lvl; curLvl < subdivLevels; curLvl++) {
|
||||
ccgSubSurf__calcSubdivLevel(ss,
|
||||
effectedV, effectedE, effectedF,
|
||||
numEffectedV, numEffectedE, numEffectedF, curLvl);
|
||||
effectedV, effectedE, effectedF,
|
||||
numEffectedV, numEffectedE, numEffectedF, curLvl);
|
||||
}
|
||||
|
||||
for (i = 0; i < numEffectedV; i++)
|
||||
@@ -2698,15 +2701,15 @@ int ccgSubSurf_getNumFaces(const CCGSubSurf *ss)
|
||||
|
||||
CCGVert *ccgSubSurf_getVert(CCGSubSurf *ss, CCGVertHDL v)
|
||||
{
|
||||
return (CCGVert*) _ehash_lookup(ss->vMap, v);
|
||||
return (CCGVert *) _ehash_lookup(ss->vMap, v);
|
||||
}
|
||||
CCGEdge *ccgSubSurf_getEdge(CCGSubSurf *ss, CCGEdgeHDL e)
|
||||
{
|
||||
return (CCGEdge*) _ehash_lookup(ss->eMap, e);
|
||||
return (CCGEdge *) _ehash_lookup(ss->eMap, e);
|
||||
}
|
||||
CCGFace *ccgSubSurf_getFace(CCGSubSurf *ss, CCGFaceHDL f)
|
||||
{
|
||||
return (CCGFace*) _ehash_lookup(ss->fMap, f);
|
||||
return (CCGFace *) _ehash_lookup(ss->fMap, f);
|
||||
}
|
||||
|
||||
int ccgSubSurf_getSubdivisionLevels(const CCGSubSurf *ss)
|
||||
@@ -2719,7 +2722,7 @@ int ccgSubSurf_getEdgeSize(const CCGSubSurf *ss)
|
||||
}
|
||||
int ccgSubSurf_getEdgeLevelSize(const CCGSubSurf *ss, int level)
|
||||
{
|
||||
if (level<1 || level > ss->subdivLevels) {
|
||||
if (level < 1 || level > ss->subdivLevels) {
|
||||
return -1;
|
||||
}
|
||||
else {
|
||||
@@ -2732,7 +2735,7 @@ int ccgSubSurf_getGridSize(const CCGSubSurf *ss)
|
||||
}
|
||||
int ccgSubSurf_getGridLevelSize(const CCGSubSurf *ss, int level)
|
||||
{
|
||||
if (level<1 || level > ss->subdivLevels) {
|
||||
if (level < 1 || level > ss->subdivLevels) {
|
||||
return -1;
|
||||
}
|
||||
else {
|
||||
@@ -2750,7 +2753,7 @@ int ccgSubSurf_getVertAge(CCGSubSurf *ss, CCGVert *v)
|
||||
{
|
||||
if (ss->useAgeCounts) {
|
||||
byte *userData = ccgSubSurf_getVertUserData(ss, v);
|
||||
return ss->currentAge - *((int*) &userData[ss->vertUserAgeOffset]);
|
||||
return ss->currentAge - *((int *) &userData[ss->vertUserAgeOffset]);
|
||||
}
|
||||
else {
|
||||
return 0;
|
||||
@@ -2766,7 +2769,7 @@ int ccgSubSurf_getVertNumFaces(CCGVert *v)
|
||||
}
|
||||
CCGFace *ccgSubSurf_getVertFace(CCGVert *v, int index)
|
||||
{
|
||||
if (index<0 || index>=v->numFaces) {
|
||||
if (index < 0 || index >= v->numFaces) {
|
||||
return NULL;
|
||||
}
|
||||
else {
|
||||
@@ -2779,7 +2782,7 @@ int ccgSubSurf_getVertNumEdges(CCGVert *v)
|
||||
}
|
||||
CCGEdge *ccgSubSurf_getVertEdge(CCGVert *v, int index)
|
||||
{
|
||||
if (index<0 || index>=v->numEdges) {
|
||||
if (index < 0 || index >= v->numEdges) {
|
||||
return NULL;
|
||||
}
|
||||
else {
|
||||
@@ -2792,7 +2795,7 @@ void *ccgSubSurf_getVertData(CCGSubSurf *ss, CCGVert *v)
|
||||
}
|
||||
void *ccgSubSurf_getVertLevelData(CCGSubSurf *ss, CCGVert *v, int level)
|
||||
{
|
||||
if (level<0 || level > ss->subdivLevels) {
|
||||
if (level < 0 || level > ss->subdivLevels) {
|
||||
return NULL;
|
||||
}
|
||||
else {
|
||||
@@ -2810,7 +2813,7 @@ int ccgSubSurf_getEdgeAge(CCGSubSurf *ss, CCGEdge *e)
|
||||
{
|
||||
if (ss->useAgeCounts) {
|
||||
byte *userData = ccgSubSurf_getEdgeUserData(ss, e);
|
||||
return ss->currentAge - *((int*) &userData[ss->edgeUserAgeOffset]);
|
||||
return ss->currentAge - *((int *) &userData[ss->edgeUserAgeOffset]);
|
||||
}
|
||||
else {
|
||||
return 0;
|
||||
@@ -2819,7 +2822,7 @@ int ccgSubSurf_getEdgeAge(CCGSubSurf *ss, CCGEdge *e)
|
||||
void *ccgSubSurf_getEdgeUserData(CCGSubSurf *ss, CCGEdge *e)
|
||||
{
|
||||
return (EDGE_getLevelData(e) +
|
||||
ss->meshIFC.vertDataSize * ccg_edgebase(ss->subdivLevels + 1));
|
||||
ss->meshIFC.vertDataSize * ccg_edgebase(ss->subdivLevels + 1));
|
||||
}
|
||||
int ccgSubSurf_getEdgeNumFaces(CCGEdge *e)
|
||||
{
|
||||
@@ -2827,7 +2830,7 @@ int ccgSubSurf_getEdgeNumFaces(CCGEdge *e)
|
||||
}
|
||||
CCGFace *ccgSubSurf_getEdgeFace(CCGEdge *e, int index)
|
||||
{
|
||||
if (index<0 || index>=e->numFaces) {
|
||||
if (index < 0 || index >= e->numFaces) {
|
||||
return NULL;
|
||||
}
|
||||
else {
|
||||
@@ -2852,7 +2855,7 @@ void *ccgSubSurf_getEdgeData(CCGSubSurf *ss, CCGEdge *e, int x)
|
||||
}
|
||||
void *ccgSubSurf_getEdgeLevelData(CCGSubSurf *ss, CCGEdge *e, int x, int level)
|
||||
{
|
||||
if (level<0 || level > ss->subdivLevels) {
|
||||
if (level < 0 || level > ss->subdivLevels) {
|
||||
return NULL;
|
||||
}
|
||||
else {
|
||||
@@ -2874,7 +2877,7 @@ int ccgSubSurf_getFaceAge(CCGSubSurf *ss, CCGFace *f)
|
||||
{
|
||||
if (ss->useAgeCounts) {
|
||||
byte *userData = ccgSubSurf_getFaceUserData(ss, f);
|
||||
return ss->currentAge - *((int*) &userData[ss->faceUserAgeOffset]);
|
||||
return ss->currentAge - *((int *) &userData[ss->faceUserAgeOffset]);
|
||||
}
|
||||
else {
|
||||
return 0;
|
||||
@@ -2891,7 +2894,7 @@ int ccgSubSurf_getFaceNumVerts(CCGFace *f)
|
||||
}
|
||||
CCGVert *ccgSubSurf_getFaceVert(CCGFace *f, int index)
|
||||
{
|
||||
if (index<0 || index>=f->numVerts) {
|
||||
if (index < 0 || index >= f->numVerts) {
|
||||
return NULL;
|
||||
}
|
||||
else {
|
||||
@@ -2900,7 +2903,7 @@ CCGVert *ccgSubSurf_getFaceVert(CCGFace *f, int index)
|
||||
}
|
||||
CCGEdge *ccgSubSurf_getFaceEdge(CCGFace *f, int index)
|
||||
{
|
||||
if (index<0 || index>=f->numVerts) {
|
||||
if (index < 0 || index >= f->numVerts) {
|
||||
return NULL;
|
||||
}
|
||||
else {
|
||||
@@ -2943,66 +2946,66 @@ void *ccgSubSurf_getFaceGridData(CCGSubSurf *ss, CCGFace *f, int gridIndex, int
|
||||
|
||||
CCGVertIterator *ccgSubSurf_getVertIterator(CCGSubSurf *ss)
|
||||
{
|
||||
return (CCGVertIterator*) _ehashIterator_new(ss->vMap);
|
||||
return (CCGVertIterator *) _ehashIterator_new(ss->vMap);
|
||||
}
|
||||
CCGEdgeIterator *ccgSubSurf_getEdgeIterator(CCGSubSurf *ss)
|
||||
{
|
||||
return (CCGEdgeIterator*) _ehashIterator_new(ss->eMap);
|
||||
return (CCGEdgeIterator *) _ehashIterator_new(ss->eMap);
|
||||
}
|
||||
CCGFaceIterator *ccgSubSurf_getFaceIterator(CCGSubSurf *ss)
|
||||
{
|
||||
return (CCGFaceIterator*) _ehashIterator_new(ss->fMap);
|
||||
return (CCGFaceIterator *) _ehashIterator_new(ss->fMap);
|
||||
}
|
||||
|
||||
CCGVert *ccgVertIterator_getCurrent(CCGVertIterator *vi)
|
||||
{
|
||||
return (CCGVert*) _ehashIterator_getCurrent((EHashIterator*) vi);
|
||||
return (CCGVert *) _ehashIterator_getCurrent((EHashIterator *) vi);
|
||||
}
|
||||
int ccgVertIterator_isStopped(CCGVertIterator *vi)
|
||||
{
|
||||
return _ehashIterator_isStopped((EHashIterator*) vi);
|
||||
return _ehashIterator_isStopped((EHashIterator *) vi);
|
||||
}
|
||||
void ccgVertIterator_next(CCGVertIterator *vi)
|
||||
{
|
||||
_ehashIterator_next((EHashIterator*) vi);
|
||||
_ehashIterator_next((EHashIterator *) vi);
|
||||
}
|
||||
void ccgVertIterator_free(CCGVertIterator *vi)
|
||||
{
|
||||
_ehashIterator_free((EHashIterator*) vi);
|
||||
_ehashIterator_free((EHashIterator *) vi);
|
||||
}
|
||||
|
||||
CCGEdge *ccgEdgeIterator_getCurrent(CCGEdgeIterator *vi)
|
||||
{
|
||||
return (CCGEdge*) _ehashIterator_getCurrent((EHashIterator*) vi);
|
||||
return (CCGEdge *) _ehashIterator_getCurrent((EHashIterator *) vi);
|
||||
}
|
||||
int ccgEdgeIterator_isStopped(CCGEdgeIterator *vi)
|
||||
{
|
||||
return _ehashIterator_isStopped((EHashIterator*) vi);
|
||||
return _ehashIterator_isStopped((EHashIterator *) vi);
|
||||
}
|
||||
void ccgEdgeIterator_next(CCGEdgeIterator *vi)
|
||||
{
|
||||
_ehashIterator_next((EHashIterator*) vi);
|
||||
_ehashIterator_next((EHashIterator *) vi);
|
||||
}
|
||||
void ccgEdgeIterator_free(CCGEdgeIterator *vi)
|
||||
{
|
||||
_ehashIterator_free((EHashIterator*) vi);
|
||||
_ehashIterator_free((EHashIterator *) vi);
|
||||
}
|
||||
|
||||
CCGFace *ccgFaceIterator_getCurrent(CCGFaceIterator *vi)
|
||||
{
|
||||
return (CCGFace*) _ehashIterator_getCurrent((EHashIterator*) vi);
|
||||
return (CCGFace *) _ehashIterator_getCurrent((EHashIterator *) vi);
|
||||
}
|
||||
int ccgFaceIterator_isStopped(CCGFaceIterator *vi)
|
||||
{
|
||||
return _ehashIterator_isStopped((EHashIterator*) vi);
|
||||
return _ehashIterator_isStopped((EHashIterator *) vi);
|
||||
}
|
||||
void ccgFaceIterator_next(CCGFaceIterator *vi)
|
||||
{
|
||||
_ehashIterator_next((EHashIterator*) vi);
|
||||
_ehashIterator_next((EHashIterator *) vi);
|
||||
}
|
||||
void ccgFaceIterator_free(CCGFaceIterator *vi)
|
||||
{
|
||||
_ehashIterator_free((EHashIterator*) vi);
|
||||
_ehashIterator_free((EHashIterator *) vi);
|
||||
}
|
||||
|
||||
/*** Extern API final vert/edge/face interface ***/
|
||||
|
||||
@@ -120,7 +120,7 @@ static CCGSubSurf *_getSubSurf(CCGSubSurf *prevSS, int subdivLevels, CCGFlags fl
|
||||
int useAging = !!(flags & CCG_USE_AGING);
|
||||
int useArena = flags & CCG_USE_ARENA;
|
||||
|
||||
/* subdivLevels==0 is not allowed */
|
||||
/* subdivLevels==0 is not allowed */
|
||||
subdivLevels = MAX2(subdivLevels, 1);
|
||||
|
||||
if (prevSS) {
|
||||
@@ -128,7 +128,7 @@ static CCGSubSurf *_getSubSurf(CCGSubSurf *prevSS, int subdivLevels, CCGFlags fl
|
||||
|
||||
ccgSubSurf_getUseAgeCounts(prevSS, &oldUseAging, NULL, NULL, NULL);
|
||||
|
||||
if (oldUseAging!=useAging) {
|
||||
if (oldUseAging != useAging) {
|
||||
ccgSubSurf_free(prevSS);
|
||||
}
|
||||
else {
|
||||
@@ -148,7 +148,7 @@ static CCGSubSurf *_getSubSurf(CCGSubSurf *prevSS, int subdivLevels, CCGFlags fl
|
||||
|
||||
if (useArena) {
|
||||
CCGAllocatorIFC allocatorIFC;
|
||||
CCGAllocatorHDL allocator = BLI_memarena_new((1<<16), "subsurf arena");
|
||||
CCGAllocatorHDL allocator = BLI_memarena_new((1 << 16), "subsurf arena");
|
||||
|
||||
allocatorIFC.alloc = arena_alloc;
|
||||
allocatorIFC.realloc = arena_realloc;
|
||||
@@ -177,81 +177,81 @@ static int getEdgeIndex(CCGSubSurf *ss, CCGEdge *e, int x, int edgeSize)
|
||||
{
|
||||
CCGVert *v0 = ccgSubSurf_getEdgeVert0(e);
|
||||
CCGVert *v1 = ccgSubSurf_getEdgeVert1(e);
|
||||
int v0idx = *((int*) ccgSubSurf_getVertUserData(ss, v0));
|
||||
int v1idx = *((int*) ccgSubSurf_getVertUserData(ss, v1));
|
||||
int edgeBase = *((int*) ccgSubSurf_getEdgeUserData(ss, e));
|
||||
int v0idx = *((int *) ccgSubSurf_getVertUserData(ss, v0));
|
||||
int v1idx = *((int *) ccgSubSurf_getVertUserData(ss, v1));
|
||||
int edgeBase = *((int *) ccgSubSurf_getEdgeUserData(ss, e));
|
||||
|
||||
if (x==0) {
|
||||
if (x == 0) {
|
||||
return v0idx;
|
||||
}
|
||||
else if (x==edgeSize-1) {
|
||||
else if (x == edgeSize - 1) {
|
||||
return v1idx;
|
||||
}
|
||||
else {
|
||||
return edgeBase + x-1;
|
||||
return edgeBase + x - 1;
|
||||
}
|
||||
}
|
||||
|
||||
static int getFaceIndex(CCGSubSurf *ss, CCGFace *f, int S, int x, int y, int edgeSize, int gridSize)
|
||||
{
|
||||
int faceBase = *((int*) ccgSubSurf_getFaceUserData(ss, f));
|
||||
int faceBase = *((int *) ccgSubSurf_getFaceUserData(ss, f));
|
||||
int numVerts = ccgSubSurf_getFaceNumVerts(f);
|
||||
|
||||
if (x==gridSize-1 && y==gridSize-1) {
|
||||
if (x == gridSize - 1 && y == gridSize - 1) {
|
||||
CCGVert *v = ccgSubSurf_getFaceVert(f, S);
|
||||
return *((int*) ccgSubSurf_getVertUserData(ss, v));
|
||||
return *((int *) ccgSubSurf_getVertUserData(ss, v));
|
||||
}
|
||||
else if (x==gridSize-1) {
|
||||
else if (x == gridSize - 1) {
|
||||
CCGVert *v = ccgSubSurf_getFaceVert(f, S);
|
||||
CCGEdge *e = ccgSubSurf_getFaceEdge(f, S);
|
||||
int edgeBase = *((int*) ccgSubSurf_getEdgeUserData(ss, e));
|
||||
if (v==ccgSubSurf_getEdgeVert0(e)) {
|
||||
return edgeBase + (gridSize-1-y)-1;
|
||||
int edgeBase = *((int *) ccgSubSurf_getEdgeUserData(ss, e));
|
||||
if (v == ccgSubSurf_getEdgeVert0(e)) {
|
||||
return edgeBase + (gridSize - 1 - y) - 1;
|
||||
}
|
||||
else {
|
||||
return edgeBase + (edgeSize-2-1)-((gridSize-1-y)-1);
|
||||
return edgeBase + (edgeSize - 2 - 1) - ((gridSize - 1 - y) - 1);
|
||||
}
|
||||
}
|
||||
else if (y==gridSize-1) {
|
||||
else if (y == gridSize - 1) {
|
||||
CCGVert *v = ccgSubSurf_getFaceVert(f, S);
|
||||
CCGEdge *e = ccgSubSurf_getFaceEdge(f, (S+numVerts-1)%numVerts);
|
||||
int edgeBase = *((int*) ccgSubSurf_getEdgeUserData(ss, e));
|
||||
if (v==ccgSubSurf_getEdgeVert0(e)) {
|
||||
return edgeBase + (gridSize-1-x)-1;
|
||||
CCGEdge *e = ccgSubSurf_getFaceEdge(f, (S + numVerts - 1) % numVerts);
|
||||
int edgeBase = *((int *) ccgSubSurf_getEdgeUserData(ss, e));
|
||||
if (v == ccgSubSurf_getEdgeVert0(e)) {
|
||||
return edgeBase + (gridSize - 1 - x) - 1;
|
||||
}
|
||||
else {
|
||||
return edgeBase + (edgeSize-2-1)-((gridSize-1-x)-1);
|
||||
return edgeBase + (edgeSize - 2 - 1) - ((gridSize - 1 - x) - 1);
|
||||
}
|
||||
}
|
||||
else if (x==0 && y==0) {
|
||||
else if (x == 0 && y == 0) {
|
||||
return faceBase;
|
||||
}
|
||||
else if (x==0) {
|
||||
S = (S+numVerts-1)%numVerts;
|
||||
return faceBase + 1 + (gridSize-2)*S + (y-1);
|
||||
else if (x == 0) {
|
||||
S = (S + numVerts - 1) % numVerts;
|
||||
return faceBase + 1 + (gridSize - 2) * S + (y - 1);
|
||||
}
|
||||
else if (y==0) {
|
||||
return faceBase + 1 + (gridSize-2)*S + (x-1);
|
||||
else if (y == 0) {
|
||||
return faceBase + 1 + (gridSize - 2) * S + (x - 1);
|
||||
}
|
||||
else {
|
||||
return faceBase + 1 + (gridSize-2)*numVerts + S*(gridSize-2)*(gridSize-2) + (y-1)*(gridSize-2) + (x-1);
|
||||
return faceBase + 1 + (gridSize - 2) * numVerts + S * (gridSize - 2) * (gridSize - 2) + (y - 1) * (gridSize - 2) + (x - 1);
|
||||
}
|
||||
}
|
||||
|
||||
static void get_face_uv_map_vert(UvVertMap *vmap, struct MPoly *mpoly, struct MLoop *ml, int fi, CCGVertHDL *fverts)
|
||||
{
|
||||
UvMapVert *v, *nv;
|
||||
int j, nverts= mpoly[fi].totloop;
|
||||
int j, nverts = mpoly[fi].totloop;
|
||||
|
||||
for (j=0; j<nverts; j++) {
|
||||
for (nv=v=get_uv_map_vert(vmap, ml[j].v); v; v=v->next) {
|
||||
for (j = 0; j < nverts; j++) {
|
||||
for (nv = v = get_uv_map_vert(vmap, ml[j].v); v; v = v->next) {
|
||||
if (v->separate)
|
||||
nv= v;
|
||||
nv = v;
|
||||
if (v->f == fi)
|
||||
break;
|
||||
}
|
||||
|
||||
fverts[j]= SET_INT_IN_POINTER(mpoly[nv->f].loopstart + nv->tfindex);
|
||||
fverts[j] = SET_INT_IN_POINTER(mpoly[nv->f].loopstart + nv->tfindex);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -266,31 +266,31 @@ static int ss_sync_from_uv(CCGSubSurf *ss, CCGSubSurf *origss, DerivedMesh *dm,
|
||||
UvMapVert *v;
|
||||
UvVertMap *vmap;
|
||||
float limit[2];
|
||||
CCGVertHDL *fverts= NULL;
|
||||
CCGVertHDL *fverts = NULL;
|
||||
BLI_array_declare(fverts);
|
||||
EdgeHash *ehash;
|
||||
float creaseFactor = (float)ccgSubSurf_getSubdivisionLevels(ss);
|
||||
float uv[3]= {0.0f, 0.0f, 0.0f}; /* only first 2 values are written into */
|
||||
float uv[3] = {0.0f, 0.0f, 0.0f}; /* only first 2 values are written into */
|
||||
|
||||
limit[0]= limit[1]= STD_UV_CONNECT_LIMIT;
|
||||
vmap= make_uv_vert_map(mpoly, mloop, mloopuv, totface, totvert, 0, limit);
|
||||
limit[0] = limit[1] = STD_UV_CONNECT_LIMIT;
|
||||
vmap = make_uv_vert_map(mpoly, mloop, mloopuv, totface, totvert, 0, limit);
|
||||
if (!vmap)
|
||||
return 0;
|
||||
|
||||
ccgSubSurf_initFullSync(ss);
|
||||
|
||||
/* create vertices */
|
||||
for (i=0; i<totvert; i++) {
|
||||
for (i = 0; i < totvert; i++) {
|
||||
if (!get_uv_map_vert(vmap, i))
|
||||
continue;
|
||||
|
||||
for (v=get_uv_map_vert(vmap, i)->next; v; v=v->next)
|
||||
for (v = get_uv_map_vert(vmap, i)->next; v; v = v->next)
|
||||
if (v->separate)
|
||||
break;
|
||||
|
||||
seam = (v != NULL) || ((mvert+i)->flag & ME_VERT_MERGED);
|
||||
seam = (v != NULL) || ((mvert + i)->flag & ME_VERT_MERGED);
|
||||
|
||||
for (v=get_uv_map_vert(vmap, i); v; v=v->next) {
|
||||
for (v = get_uv_map_vert(vmap, i); v; v = v->next) {
|
||||
if (v->separate) {
|
||||
CCGVert *ssv;
|
||||
int loopid = mpoly[v->f].loopstart + v->tfindex;
|
||||
@@ -306,35 +306,35 @@ static int ss_sync_from_uv(CCGSubSurf *ss, CCGSubSurf *origss, DerivedMesh *dm,
|
||||
/* create edges */
|
||||
ehash = BLI_edgehash_new();
|
||||
|
||||
for (i=0; i<totface; i++) {
|
||||
MPoly *mp = &((MPoly*) mpoly)[i];
|
||||
int nverts= mp->totloop;
|
||||
CCGFace *origf= ccgSubSurf_getFace(origss, SET_INT_IN_POINTER(i));
|
||||
for (i = 0; i < totface; i++) {
|
||||
MPoly *mp = &((MPoly *) mpoly)[i];
|
||||
int nverts = mp->totloop;
|
||||
CCGFace *origf = ccgSubSurf_getFace(origss, SET_INT_IN_POINTER(i));
|
||||
/* unsigned int *fv = &mp->v1; */
|
||||
MLoop *ml= mloop + mp->loopstart;
|
||||
MLoop *ml = mloop + mp->loopstart;
|
||||
|
||||
BLI_array_empty(fverts);
|
||||
BLI_array_growitems(fverts, nverts);
|
||||
|
||||
get_face_uv_map_vert(vmap, mpoly, ml, i, fverts);
|
||||
|
||||
for (j=0; j<nverts; j++) {
|
||||
for (j = 0; j < nverts; j++) {
|
||||
int v0 = GET_INT_FROM_POINTER(fverts[j]);
|
||||
int v1 = GET_INT_FROM_POINTER(fverts[(j+1)%nverts]);
|
||||
MVert *mv0 = mvert + (ml[ j ]. v);
|
||||
MVert *mv1 = mvert + (ml[ ((j+1)%nverts) ].v);
|
||||
int v1 = GET_INT_FROM_POINTER(fverts[(j + 1) % nverts]);
|
||||
MVert *mv0 = mvert + (ml[j].v);
|
||||
MVert *mv1 = mvert + (ml[((j + 1) % nverts)].v);
|
||||
|
||||
if (!BLI_edgehash_haskey(ehash, v0, v1)) {
|
||||
CCGEdge *e, *orige= ccgSubSurf_getFaceEdge(origf, j);
|
||||
CCGEdgeHDL ehdl= SET_INT_IN_POINTER(mp->loopstart + j);
|
||||
CCGEdge *e, *orige = ccgSubSurf_getFaceEdge(origf, j);
|
||||
CCGEdgeHDL ehdl = SET_INT_IN_POINTER(mp->loopstart + j);
|
||||
float crease;
|
||||
|
||||
if ((mv0->flag&mv1->flag) & ME_VERT_MERGED)
|
||||
if ((mv0->flag & mv1->flag) & ME_VERT_MERGED)
|
||||
crease = creaseFactor;
|
||||
else
|
||||
crease = ccgSubSurf_getEdgeCrease(orige);
|
||||
|
||||
ccgSubSurf_syncEdge(ss, ehdl, fverts[j], fverts[(j+1)%nverts], crease, &e);
|
||||
ccgSubSurf_syncEdge(ss, ehdl, fverts[j], fverts[(j + 1) % nverts], crease, &e);
|
||||
BLI_edgehash_insert(ehash, v0, v1, NULL);
|
||||
}
|
||||
}
|
||||
@@ -343,10 +343,10 @@ static int ss_sync_from_uv(CCGSubSurf *ss, CCGSubSurf *origss, DerivedMesh *dm,
|
||||
BLI_edgehash_free(ehash, NULL);
|
||||
|
||||
/* create faces */
|
||||
for (i=0; i<totface; i++) {
|
||||
for (i = 0; i < totface; i++) {
|
||||
MPoly *mp = &mpoly[i];
|
||||
MLoop *ml= &mloop[mp->loopstart];
|
||||
int nverts= mp->totloop;
|
||||
MLoop *ml = &mloop[mp->loopstart];
|
||||
int nverts = mp->totloop;
|
||||
CCGFace *f;
|
||||
|
||||
BLI_array_empty(fverts);
|
||||
@@ -396,7 +396,7 @@ static void set_subsurf_uv(CCGSubSurf *ss, DerivedMesh *dm, DerivedMesh *result,
|
||||
gridFaces = gridSize - 1;
|
||||
|
||||
/* make a map from original faces to CCGFaces */
|
||||
faceMap = MEM_mallocN(totface*sizeof(*faceMap), "facemapuv");
|
||||
faceMap = MEM_mallocN(totface * sizeof(*faceMap), "facemapuv");
|
||||
|
||||
fi = ccgSubSurf_getFaceIterator(uvss);
|
||||
for (; !ccgFaceIterator_isStopped(fi); ccgFaceIterator_next(fi)) {
|
||||
@@ -406,22 +406,22 @@ static void set_subsurf_uv(CCGSubSurf *ss, DerivedMesh *dm, DerivedMesh *result,
|
||||
ccgFaceIterator_free(fi);
|
||||
|
||||
/* load coordinates from uvss into tface */
|
||||
tf= tface;
|
||||
mluv= mloopuv;
|
||||
tf = tface;
|
||||
mluv = mloopuv;
|
||||
|
||||
for (index = 0; index < totface; index++) {
|
||||
CCGFace *f = faceMap[index];
|
||||
int numVerts = ccgSubSurf_getFaceNumVerts(f);
|
||||
|
||||
for (S=0; S<numVerts; S++) {
|
||||
float (*faceGridData)[3]= ccgSubSurf_getFaceGridDataArray(uvss, f, S);
|
||||
for (S = 0; S < numVerts; S++) {
|
||||
float (*faceGridData)[3] = ccgSubSurf_getFaceGridDataArray(uvss, f, S);
|
||||
|
||||
for (y = 0; y < gridFaces; y++) {
|
||||
for (x = 0; x < gridFaces; x++) {
|
||||
float *a = faceGridData[(y + 0)*gridSize + x + 0];
|
||||
float *b = faceGridData[(y + 0)*gridSize + x + 1];
|
||||
float *c = faceGridData[(y + 1)*gridSize + x + 1];
|
||||
float *d = faceGridData[(y + 1)*gridSize + x + 0];
|
||||
float *a = faceGridData[(y + 0) * gridSize + x + 0];
|
||||
float *b = faceGridData[(y + 0) * gridSize + x + 1];
|
||||
float *c = faceGridData[(y + 1) * gridSize + x + 1];
|
||||
float *d = faceGridData[(y + 1) * gridSize + x + 0];
|
||||
|
||||
if (tf) {
|
||||
copy_v2_v2(tf->uv[0], a);
|
||||
@@ -466,41 +466,41 @@ static float *get_ss_weights(WeightTable *wtable, int gridCuts, int faceLen)
|
||||
float *w, w1, w2, w4, fac, fac2, fx, fy;
|
||||
|
||||
if (wtable->len <= faceLen) {
|
||||
void *tmp = MEM_callocN(sizeof(FaceVertWeightEntry)*(faceLen+1), "weight table alloc 2");
|
||||
void *tmp = MEM_callocN(sizeof(FaceVertWeightEntry) * (faceLen + 1), "weight table alloc 2");
|
||||
|
||||
if (wtable->len) {
|
||||
memcpy(tmp, wtable->weight_table, sizeof(FaceVertWeightEntry)*wtable->len);
|
||||
memcpy(tmp, wtable->weight_table, sizeof(FaceVertWeightEntry) * wtable->len);
|
||||
MEM_freeN(wtable->weight_table);
|
||||
}
|
||||
|
||||
wtable->weight_table = tmp;
|
||||
wtable->len = faceLen+1;
|
||||
wtable->len = faceLen + 1;
|
||||
}
|
||||
|
||||
if (!wtable->weight_table[faceLen].valid) {
|
||||
wtable->weight_table[faceLen].valid = 1;
|
||||
wtable->weight_table[faceLen].w = w = MEM_callocN(sizeof(float)*faceLen*faceLen*(gridCuts+2)*(gridCuts+2), "weight table alloc");
|
||||
wtable->weight_table[faceLen].w = w = MEM_callocN(sizeof(float) * faceLen * faceLen * (gridCuts + 2) * (gridCuts + 2), "weight table alloc");
|
||||
fac = 1.0f / (float)faceLen;
|
||||
|
||||
for (i=0; i<faceLen; i++) {
|
||||
for (x=0; x<gridCuts+2; x++) {
|
||||
for (y=0; y<gridCuts+2; y++) {
|
||||
fx = 0.5f - (float)x / (float)(gridCuts+1) / 2.0f;
|
||||
fy = 0.5f - (float)y / (float)(gridCuts+1) / 2.0f;
|
||||
for (i = 0; i < faceLen; i++) {
|
||||
for (x = 0; x < gridCuts + 2; x++) {
|
||||
for (y = 0; y < gridCuts + 2; y++) {
|
||||
fx = 0.5f - (float)x / (float)(gridCuts + 1) / 2.0f;
|
||||
fy = 0.5f - (float)y / (float)(gridCuts + 1) / 2.0f;
|
||||
|
||||
fac2 = faceLen - 4;
|
||||
w1 = (1.0f - fx) * (1.0f - fy) + (-fac2*fx*fy*fac);
|
||||
w2 = (1.0f - fx + fac2*fx*-fac) * (fy);
|
||||
w4 = (fx) * (1.0f - fy + -fac2*fy*fac);
|
||||
|
||||
fac2 = 1.0f - (w1+w2+w4);
|
||||
fac2 = fac2 / (float)(faceLen-3);
|
||||
for (j=0; j<faceLen; j++)
|
||||
w1 = (1.0f - fx) * (1.0f - fy) + (-fac2 * fx * fy * fac);
|
||||
w2 = (1.0f - fx + fac2 * fx * -fac) * (fy);
|
||||
w4 = (fx) * (1.0f - fy + -fac2 * fy * fac);
|
||||
|
||||
fac2 = 1.0f - (w1 + w2 + w4);
|
||||
fac2 = fac2 / (float)(faceLen - 3);
|
||||
for (j = 0; j < faceLen; j++)
|
||||
w[j] = fac2;
|
||||
|
||||
w[i] = w1;
|
||||
w[(i-1+faceLen)%faceLen] = w2;
|
||||
w[(i+1)%faceLen] = w4;
|
||||
w[(i - 1 + faceLen) % faceLen] = w2;
|
||||
w[(i + 1) % faceLen] = w4;
|
||||
|
||||
w += faceLen;
|
||||
}
|
||||
@@ -515,7 +515,7 @@ static void free_ss_weights(WeightTable *wtable)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i=0; i<wtable->len; i++) {
|
||||
for (i = 0; i < wtable->len; i++) {
|
||||
if (wtable->weight_table[i].valid)
|
||||
MEM_freeN(wtable->weight_table[i].w);
|
||||
}
|
||||
@@ -525,7 +525,7 @@ static void free_ss_weights(WeightTable *wtable)
|
||||
}
|
||||
|
||||
static void ss_sync_from_derivedmesh(CCGSubSurf *ss, DerivedMesh *dm,
|
||||
float (*vertexCos)[3], int useFlatSubdiv)
|
||||
float (*vertexCos)[3], int useFlatSubdiv)
|
||||
{
|
||||
float creaseFactor = (float) ccgSubSurf_getSubdivisionLevels(ss);
|
||||
CCGVertHDL *fVerts = NULL;
|
||||
@@ -559,7 +559,7 @@ static void ss_sync_from_derivedmesh(CCGSubSurf *ss, DerivedMesh *dm,
|
||||
ccgSubSurf_syncVert(ss, SET_INT_IN_POINTER(i), mv->co, 0, &v);
|
||||
}
|
||||
|
||||
((int*)ccgSubSurf_getVertUserData(ss, v))[1] = (index)? *index++: i;
|
||||
((int *)ccgSubSurf_getVertUserData(ss, v))[1] = (index) ? *index++ : i;
|
||||
}
|
||||
|
||||
me = medge;
|
||||
@@ -569,24 +569,24 @@ static void ss_sync_from_derivedmesh(CCGSubSurf *ss, DerivedMesh *dm,
|
||||
float crease;
|
||||
|
||||
crease = useFlatSubdiv ? creaseFactor :
|
||||
me->crease * creaseFactor / 255.0f;
|
||||
me->crease * creaseFactor / 255.0f;
|
||||
|
||||
ccgSubSurf_syncEdge(ss, SET_INT_IN_POINTER(i), SET_INT_IN_POINTER(me->v1),
|
||||
SET_INT_IN_POINTER(me->v2), crease, &e);
|
||||
SET_INT_IN_POINTER(me->v2), crease, &e);
|
||||
|
||||
((int*)ccgSubSurf_getEdgeUserData(ss, e))[1] = (index)? *index++: i;
|
||||
((int *)ccgSubSurf_getEdgeUserData(ss, e))[1] = (index) ? *index++ : i;
|
||||
}
|
||||
|
||||
mp = mpoly;
|
||||
index = DM_get_poly_data_layer(dm, CD_ORIGINDEX);
|
||||
for (i=0; i<dm->numPolyData; i++, mp++) {
|
||||
for (i = 0; i < dm->numPolyData; i++, mp++) {
|
||||
CCGFace *f;
|
||||
|
||||
BLI_array_empty(fVerts);
|
||||
BLI_array_growitems(fVerts, mp->totloop);
|
||||
|
||||
ml = mloop + mp->loopstart;
|
||||
for (j=0; j<mp->totloop; j++, ml++) {
|
||||
for (j = 0; j < mp->totloop; j++, ml++) {
|
||||
fVerts[j] = SET_INT_IN_POINTER(ml->v);
|
||||
}
|
||||
|
||||
@@ -595,7 +595,7 @@ static void ss_sync_from_derivedmesh(CCGSubSurf *ss, DerivedMesh *dm,
|
||||
* other parts of code significantly to handle missing faces.
|
||||
* since this really shouldn't even be possible we just bail.*/
|
||||
if (ccgSubSurf_syncFace(ss, SET_INT_IN_POINTER(i), mp->totloop,
|
||||
fVerts, &f) == eCCGError_InvalidValue) {
|
||||
fVerts, &f) == eCCGError_InvalidValue) {
|
||||
static int hasGivenError = 0;
|
||||
|
||||
if (!hasGivenError) {
|
||||
@@ -608,7 +608,7 @@ static void ss_sync_from_derivedmesh(CCGSubSurf *ss, DerivedMesh *dm,
|
||||
return;
|
||||
}
|
||||
|
||||
((int*)ccgSubSurf_getFaceUserData(ss, f))[1] = (index)? *index++: i;
|
||||
((int *)ccgSubSurf_getFaceUserData(ss, f))[1] = (index) ? *index++ : i;
|
||||
}
|
||||
|
||||
ccgSubSurf_processSync(ss);
|
||||
@@ -620,22 +620,22 @@ static void ss_sync_from_derivedmesh(CCGSubSurf *ss, DerivedMesh *dm,
|
||||
|
||||
static int ccgDM_getVertMapIndex(CCGSubSurf *ss, CCGVert *v)
|
||||
{
|
||||
return ((int*) ccgSubSurf_getVertUserData(ss, v))[1];
|
||||
return ((int *) ccgSubSurf_getVertUserData(ss, v))[1];
|
||||
}
|
||||
|
||||
static int ccgDM_getEdgeMapIndex(CCGSubSurf *ss, CCGEdge *e)
|
||||
{
|
||||
return ((int*) ccgSubSurf_getEdgeUserData(ss, e))[1];
|
||||
return ((int *) ccgSubSurf_getEdgeUserData(ss, e))[1];
|
||||
}
|
||||
|
||||
static int ccgDM_getFaceMapIndex(CCGSubSurf *ss, CCGFace *f)
|
||||
{
|
||||
return ((int*) ccgSubSurf_getFaceUserData(ss, f))[1];
|
||||
return ((int *) ccgSubSurf_getFaceUserData(ss, f))[1];
|
||||
}
|
||||
|
||||
static void ccgDM_getMinMax(DerivedMesh *dm, float min_r[3], float max_r[3])
|
||||
{
|
||||
CCGDerivedMesh *ccgdm = (CCGDerivedMesh*) dm;
|
||||
CCGDerivedMesh *ccgdm = (CCGDerivedMesh *) dm;
|
||||
CCGSubSurf *ss = ccgdm->ss;
|
||||
CCGVertIterator *vi = ccgSubSurf_getVertIterator(ss);
|
||||
CCGEdgeIterator *ei = ccgSubSurf_getEdgeIterator(ss);
|
||||
@@ -657,7 +657,7 @@ static void ccgDM_getMinMax(DerivedMesh *dm, float min_r[3], float max_r[3])
|
||||
CCGEdge *e = ccgEdgeIterator_getCurrent(ei);
|
||||
DMGridData *edgeData = ccgSubSurf_getEdgeDataArray(ss, e);
|
||||
|
||||
for (i=0; i<edgeSize; i++)
|
||||
for (i = 0; i < edgeSize; i++)
|
||||
DO_MINMAX(edgeData[i].co, min_r, max_r);
|
||||
}
|
||||
|
||||
@@ -665,12 +665,12 @@ static void ccgDM_getMinMax(DerivedMesh *dm, float min_r[3], float max_r[3])
|
||||
CCGFace *f = ccgFaceIterator_getCurrent(fi);
|
||||
int S, x, y, numVerts = ccgSubSurf_getFaceNumVerts(f);
|
||||
|
||||
for (S=0; S<numVerts; S++) {
|
||||
for (S = 0; S < numVerts; S++) {
|
||||
DMGridData *faceGridData = ccgSubSurf_getFaceGridDataArray(ss, f, S);
|
||||
|
||||
for (y=0; y<gridSize; y++)
|
||||
for (x=0; x<gridSize; x++)
|
||||
DO_MINMAX(faceGridData[y*gridSize + x].co, min_r, max_r);
|
||||
for (y = 0; y < gridSize; y++)
|
||||
for (x = 0; x < gridSize; x++)
|
||||
DO_MINMAX(faceGridData[y * gridSize + x].co, min_r, max_r);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -681,28 +681,28 @@ static void ccgDM_getMinMax(DerivedMesh *dm, float min_r[3], float max_r[3])
|
||||
|
||||
static int ccgDM_getNumVerts(DerivedMesh *dm)
|
||||
{
|
||||
CCGDerivedMesh *ccgdm = (CCGDerivedMesh*) dm;
|
||||
CCGDerivedMesh *ccgdm = (CCGDerivedMesh *) dm;
|
||||
|
||||
return ccgSubSurf_getNumFinalVerts(ccgdm->ss);
|
||||
}
|
||||
|
||||
static int ccgDM_getNumEdges(DerivedMesh *dm)
|
||||
{
|
||||
CCGDerivedMesh *ccgdm = (CCGDerivedMesh*) dm;
|
||||
CCGDerivedMesh *ccgdm = (CCGDerivedMesh *) dm;
|
||||
|
||||
return ccgSubSurf_getNumFinalEdges(ccgdm->ss);
|
||||
}
|
||||
|
||||
static int ccgDM_getNumTessFaces(DerivedMesh *dm)
|
||||
{
|
||||
CCGDerivedMesh *ccgdm = (CCGDerivedMesh*) dm;
|
||||
CCGDerivedMesh *ccgdm = (CCGDerivedMesh *) dm;
|
||||
|
||||
return ccgSubSurf_getNumFinalFaces(ccgdm->ss);
|
||||
}
|
||||
|
||||
static int ccgDM_getNumLoops(DerivedMesh *dm)
|
||||
{
|
||||
CCGDerivedMesh *ccgdm = (CCGDerivedMesh*) dm;
|
||||
CCGDerivedMesh *ccgdm = (CCGDerivedMesh *) dm;
|
||||
|
||||
/* All subsurf faces are quads */
|
||||
return 4 * ccgSubSurf_getNumFinalFaces(ccgdm->ss);
|
||||
@@ -710,7 +710,7 @@ static int ccgDM_getNumLoops(DerivedMesh *dm)
|
||||
|
||||
static void ccgDM_getFinalVert(DerivedMesh *dm, int vertNum, MVert *mv)
|
||||
{
|
||||
CCGDerivedMesh *ccgdm = (CCGDerivedMesh*) dm;
|
||||
CCGDerivedMesh *ccgdm = (CCGDerivedMesh *) dm;
|
||||
CCGSubSurf *ss = ccgdm->ss;
|
||||
DMGridData *vd;
|
||||
int i;
|
||||
@@ -814,7 +814,7 @@ static void ccgDM_getFinalVertNo(DerivedMesh *dm, int vertNum, float no_r[3])
|
||||
|
||||
static void ccgDM_getFinalEdge(DerivedMesh *dm, int edgeNum, MEdge *med)
|
||||
{
|
||||
CCGDerivedMesh *ccgdm = (CCGDerivedMesh*) dm;
|
||||
CCGDerivedMesh *ccgdm = (CCGDerivedMesh *) dm;
|
||||
CCGSubSurf *ss = ccgdm->ss;
|
||||
int i;
|
||||
|
||||
@@ -833,39 +833,39 @@ static void ccgDM_getFinalEdge(DerivedMesh *dm, int edgeNum, MEdge *med)
|
||||
|
||||
/* code added in bmesh but works correctly without, commenting - campbell */
|
||||
#if 0
|
||||
int lasti, previ;
|
||||
int lasti, previ;
|
||||
i = lastface;
|
||||
lasti = 0;
|
||||
while (1) {
|
||||
previ = i;
|
||||
if (ccgdm->faceMap[i].startEdge >= edgeNum) {
|
||||
i -= fabsf(i - lasti) / 2.0f;
|
||||
}
|
||||
else if (ccgdm->faceMap[i].startEdge < edgeNum) {
|
||||
i += fabsf(i - lasti) / 2.0f;
|
||||
}
|
||||
else {
|
||||
break;
|
||||
}
|
||||
|
||||
if (i < 0) {
|
||||
i = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
if (i > lastface) {
|
||||
i = lastface;
|
||||
lasti = 0;
|
||||
while (1) {
|
||||
previ = i;
|
||||
if (ccgdm->faceMap[i].startEdge >= edgeNum) {
|
||||
i -= fabsf(i-lasti)/2.0f;
|
||||
}
|
||||
else if (ccgdm->faceMap[i].startEdge < edgeNum) {
|
||||
i += fabsf(i-lasti)/2.0f;
|
||||
}
|
||||
else {
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
if (i < 0) {
|
||||
i = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (i > lastface) {
|
||||
i = lastface;
|
||||
break;
|
||||
if (i == lasti)
|
||||
break;
|
||||
|
||||
}
|
||||
lasti = previ;
|
||||
}
|
||||
|
||||
if (i == lasti)
|
||||
break;
|
||||
|
||||
lasti = previ;
|
||||
}
|
||||
|
||||
i = i > 0 ? i - 1 : i;
|
||||
i = i > 0 ? i - 1 : i;
|
||||
#endif
|
||||
|
||||
i = 0;
|
||||
@@ -885,7 +885,7 @@ static void ccgDM_getFinalEdge(DerivedMesh *dm, int edgeNum, MEdge *med)
|
||||
if (offset < gridSideEdges) {
|
||||
x = offset;
|
||||
med->v1 = getFaceIndex(ss, f, grid, x, 0, edgeSize, gridSize);
|
||||
med->v2 = getFaceIndex(ss, f, grid, x+1, 0, edgeSize, gridSize);
|
||||
med->v2 = getFaceIndex(ss, f, grid, x + 1, 0, edgeSize, gridSize);
|
||||
}
|
||||
else {
|
||||
offset -= gridSideEdges;
|
||||
@@ -893,11 +893,11 @@ static void ccgDM_getFinalEdge(DerivedMesh *dm, int edgeNum, MEdge *med)
|
||||
y = (offset / 2) % gridSideEdges;
|
||||
if (offset % 2 == 0) {
|
||||
med->v1 = getFaceIndex(ss, f, grid, x, y, edgeSize, gridSize);
|
||||
med->v2 = getFaceIndex(ss, f, grid, x, y+1, edgeSize, gridSize);
|
||||
med->v2 = getFaceIndex(ss, f, grid, x, y + 1, edgeSize, gridSize);
|
||||
}
|
||||
else {
|
||||
med->v1 = getFaceIndex(ss, f, grid, y, x, edgeSize, gridSize);
|
||||
med->v2 = getFaceIndex(ss, f, grid, y+1, x, edgeSize, gridSize);
|
||||
med->v2 = getFaceIndex(ss, f, grid, y + 1, x, edgeSize, gridSize);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -918,12 +918,11 @@ static void ccgDM_getFinalEdge(DerivedMesh *dm, int edgeNum, MEdge *med)
|
||||
x = edgeNum - ccgdm->edgeMap[i].startEdge;
|
||||
|
||||
med->v1 = getEdgeIndex(ss, e, x, edgeSize);
|
||||
med->v2 = getEdgeIndex(ss, e, x+1, edgeSize);
|
||||
med->v2 = getEdgeIndex(ss, e, x + 1, edgeSize);
|
||||
|
||||
edgeFlag = (ccgdm->edgeFlags)? &ccgdm->edgeFlags[i]: NULL;
|
||||
edgeFlag = (ccgdm->edgeFlags) ? &ccgdm->edgeFlags[i] : NULL;
|
||||
if (edgeFlag)
|
||||
flags |= (*edgeFlag & (ME_SEAM | ME_SHARP))
|
||||
| ME_EDGEDRAW | ME_EDGERENDER;
|
||||
flags |= (*edgeFlag & (ME_SEAM | ME_SHARP)) | ME_EDGEDRAW | ME_EDGERENDER;
|
||||
else
|
||||
flags |= ME_EDGEDRAW | ME_EDGERENDER;
|
||||
|
||||
@@ -933,7 +932,7 @@ static void ccgDM_getFinalEdge(DerivedMesh *dm, int edgeNum, MEdge *med)
|
||||
|
||||
static void ccgDM_getFinalFace(DerivedMesh *dm, int faceNum, MFace *mf)
|
||||
{
|
||||
CCGDerivedMesh *ccgdm = (CCGDerivedMesh*) dm;
|
||||
CCGDerivedMesh *ccgdm = (CCGDerivedMesh *) dm;
|
||||
CCGSubSurf *ss = ccgdm->ss;
|
||||
int gridSize = ccgSubSurf_getGridSize(ss);
|
||||
int edgeSize = ccgSubSurf_getEdgeSize(ss);
|
||||
@@ -963,10 +962,10 @@ static void ccgDM_getFinalFace(DerivedMesh *dm, int faceNum, MFace *mf)
|
||||
y = offset / gridSideEdges;
|
||||
x = offset % gridSideEdges;
|
||||
|
||||
mf->v1 = getFaceIndex(ss, f, grid, x+0, y+0, edgeSize, gridSize);
|
||||
mf->v2 = getFaceIndex(ss, f, grid, x+0, y+1, edgeSize, gridSize);
|
||||
mf->v3 = getFaceIndex(ss, f, grid, x+1, y+1, edgeSize, gridSize);
|
||||
mf->v4 = getFaceIndex(ss, f, grid, x+1, y+0, edgeSize, gridSize);
|
||||
mf->v1 = getFaceIndex(ss, f, grid, x + 0, y + 0, edgeSize, gridSize);
|
||||
mf->v2 = getFaceIndex(ss, f, grid, x + 0, y + 1, edgeSize, gridSize);
|
||||
mf->v3 = getFaceIndex(ss, f, grid, x + 1, y + 1, edgeSize, gridSize);
|
||||
mf->v4 = getFaceIndex(ss, f, grid, x + 1, y + 0, edgeSize, gridSize);
|
||||
|
||||
if (faceFlags) {
|
||||
mf->flag = faceFlags[i].flag;
|
||||
@@ -978,9 +977,9 @@ static void ccgDM_getFinalFace(DerivedMesh *dm, int faceNum, MFace *mf)
|
||||
/* Translate GridHidden into the ME_HIDE flag for MVerts. Assumes
|
||||
vertices are in the order output by ccgDM_copyFinalVertArray. */
|
||||
void subsurf_copy_grid_hidden(DerivedMesh *dm, const MPoly *mpoly,
|
||||
MVert *mvert, const MDisps *mdisps)
|
||||
MVert *mvert, const MDisps *mdisps)
|
||||
{
|
||||
CCGDerivedMesh *ccgdm = (CCGDerivedMesh*)dm;
|
||||
CCGDerivedMesh *ccgdm = (CCGDerivedMesh *)dm;
|
||||
CCGSubSurf *ss = ccgdm->ss;
|
||||
int level = ccgSubSurf_getSubdivisionLevels(ss);
|
||||
int gridSize = ccgSubSurf_getGridSize(ss);
|
||||
@@ -1004,7 +1003,7 @@ void subsurf_copy_grid_hidden(DerivedMesh *dm, const MPoly *mpoly,
|
||||
int vndx, offset;
|
||||
|
||||
vndx = getFaceIndex(ss, f, j, x, y, edgeSize, gridSize);
|
||||
offset = (y*factor) * hidden_gridsize + (x*factor);
|
||||
offset = (y * factor) * hidden_gridsize + (x * factor);
|
||||
if (BLI_BITMAP_GET(md->hidden, offset))
|
||||
mvert[vndx].flag |= ME_HIDE;
|
||||
}
|
||||
@@ -1015,7 +1014,7 @@ void subsurf_copy_grid_hidden(DerivedMesh *dm, const MPoly *mpoly,
|
||||
|
||||
static void ccgDM_copyFinalVertArray(DerivedMesh *dm, MVert *mvert)
|
||||
{
|
||||
CCGDerivedMesh *ccgdm = (CCGDerivedMesh*) dm;
|
||||
CCGDerivedMesh *ccgdm = (CCGDerivedMesh *) dm;
|
||||
CCGSubSurf *ss = ccgdm->ss;
|
||||
DMGridData *vd;
|
||||
int index;
|
||||
@@ -1029,14 +1028,14 @@ static void ccgDM_copyFinalVertArray(DerivedMesh *dm, MVert *mvert)
|
||||
CCGFace *f = ccgdm->faceMap[index].face;
|
||||
int x, y, S, numVerts = ccgSubSurf_getFaceNumVerts(f);
|
||||
|
||||
vd= ccgSubSurf_getFaceCenterData(f);
|
||||
vd = ccgSubSurf_getFaceCenterData(f);
|
||||
copy_v3_v3(mvert[i].co, vd->co);
|
||||
normal_float_to_short_v3(mvert[i].no, vd->no);
|
||||
i++;
|
||||
|
||||
for (S = 0; S < numVerts; S++) {
|
||||
for (x = 1; x < gridSize - 1; x++, i++) {
|
||||
vd= ccgSubSurf_getFaceGridEdgeData(ss, f, S, x);
|
||||
vd = ccgSubSurf_getFaceGridEdgeData(ss, f, S, x);
|
||||
copy_v3_v3(mvert[i].co, vd->co);
|
||||
normal_float_to_short_v3(mvert[i].no, vd->no);
|
||||
}
|
||||
@@ -1045,7 +1044,7 @@ static void ccgDM_copyFinalVertArray(DerivedMesh *dm, MVert *mvert)
|
||||
for (S = 0; S < numVerts; S++) {
|
||||
for (y = 1; y < gridSize - 1; y++) {
|
||||
for (x = 1; x < gridSize - 1; x++, i++) {
|
||||
vd= ccgSubSurf_getFaceGridData(ss, f, S, x, y);
|
||||
vd = ccgSubSurf_getFaceGridData(ss, f, S, x, y);
|
||||
copy_v3_v3(mvert[i].co, vd->co);
|
||||
normal_float_to_short_v3(mvert[i].no, vd->no);
|
||||
}
|
||||
@@ -1059,7 +1058,7 @@ static void ccgDM_copyFinalVertArray(DerivedMesh *dm, MVert *mvert)
|
||||
int x;
|
||||
|
||||
for (x = 1; x < edgeSize - 1; x++, i++) {
|
||||
vd= ccgSubSurf_getEdgeData(ss, e, x);
|
||||
vd = ccgSubSurf_getEdgeData(ss, e, x);
|
||||
copy_v3_v3(mvert[i].co, vd->co);
|
||||
/* This gives errors with -debug-fpe
|
||||
* the normals don't seem to be unit length.
|
||||
@@ -1074,7 +1073,7 @@ static void ccgDM_copyFinalVertArray(DerivedMesh *dm, MVert *mvert)
|
||||
for (index = 0; index < totvert; index++) {
|
||||
CCGVert *v = ccgdm->vertMap[index].vert;
|
||||
|
||||
vd= ccgSubSurf_getVertData(ss, v);
|
||||
vd = ccgSubSurf_getVertData(ss, v);
|
||||
copy_v3_v3(mvert[i].co, vd->co);
|
||||
normal_float_to_short_v3(mvert[i].no, vd->no);
|
||||
i++;
|
||||
@@ -1083,7 +1082,7 @@ static void ccgDM_copyFinalVertArray(DerivedMesh *dm, MVert *mvert)
|
||||
|
||||
static void ccgDM_copyFinalEdgeArray(DerivedMesh *dm, MEdge *medge)
|
||||
{
|
||||
CCGDerivedMesh *ccgdm = (CCGDerivedMesh*) dm;
|
||||
CCGDerivedMesh *ccgdm = (CCGDerivedMesh *) dm;
|
||||
CCGSubSurf *ss = ccgdm->ss;
|
||||
int index;
|
||||
int totedge, totface;
|
||||
@@ -1116,18 +1115,18 @@ static void ccgDM_copyFinalEdgeArray(DerivedMesh *dm, MEdge *medge)
|
||||
if (ccgdm->drawInteriorEdges)
|
||||
med->flag = ME_EDGEDRAW | ME_EDGERENDER;
|
||||
med->v1 = getFaceIndex(ss, f, S, x, y,
|
||||
edgeSize, gridSize);
|
||||
edgeSize, gridSize);
|
||||
med->v2 = getFaceIndex(ss, f, S, x, y + 1,
|
||||
edgeSize, gridSize);
|
||||
edgeSize, gridSize);
|
||||
i++;
|
||||
|
||||
med = &medge[i];
|
||||
if (ccgdm->drawInteriorEdges)
|
||||
med->flag = ME_EDGEDRAW | ME_EDGERENDER;
|
||||
med->v1 = getFaceIndex(ss, f, S, y, x,
|
||||
edgeSize, gridSize);
|
||||
edgeSize, gridSize);
|
||||
med->v2 = getFaceIndex(ss, f, S, y + 1, x,
|
||||
edgeSize, gridSize);
|
||||
edgeSize, gridSize);
|
||||
i++;
|
||||
}
|
||||
}
|
||||
@@ -1146,7 +1145,7 @@ static void ccgDM_copyFinalEdgeArray(DerivedMesh *dm, MEdge *medge)
|
||||
if (edgeFlags) {
|
||||
if (edgeIdx != -1) {
|
||||
flags |= (edgeFlags[index] & (ME_SEAM | ME_SHARP))
|
||||
| ME_EDGEDRAW | ME_EDGERENDER;
|
||||
| ME_EDGEDRAW | ME_EDGERENDER;
|
||||
}
|
||||
}
|
||||
else {
|
||||
@@ -1165,7 +1164,7 @@ static void ccgDM_copyFinalEdgeArray(DerivedMesh *dm, MEdge *medge)
|
||||
|
||||
static void ccgDM_copyFinalFaceArray(DerivedMesh *dm, MFace *mface)
|
||||
{
|
||||
CCGDerivedMesh *ccgdm = (CCGDerivedMesh*) dm;
|
||||
CCGDerivedMesh *ccgdm = (CCGDerivedMesh *) dm;
|
||||
CCGSubSurf *ss = ccgdm->ss;
|
||||
int index;
|
||||
int totface;
|
||||
@@ -1179,21 +1178,21 @@ static void ccgDM_copyFinalFaceArray(DerivedMesh *dm, MFace *mface)
|
||||
CCGFace *f = ccgdm->faceMap[index].face;
|
||||
int x, y, S, numVerts = ccgSubSurf_getFaceNumVerts(f);
|
||||
/* keep types in sync with MFace, avoid many conversions */
|
||||
char flag = (faceFlags)? faceFlags[index].flag: ME_SMOOTH;
|
||||
short mat_nr = (faceFlags)? faceFlags[index].mat_nr: 0;
|
||||
char flag = (faceFlags) ? faceFlags[index].flag : ME_SMOOTH;
|
||||
short mat_nr = (faceFlags) ? faceFlags[index].mat_nr : 0;
|
||||
|
||||
for (S = 0; S < numVerts; S++) {
|
||||
for (y = 0; y < gridSize - 1; y++) {
|
||||
for (x = 0; x < gridSize - 1; x++) {
|
||||
MFace *mf = &mface[i];
|
||||
mf->v1 = getFaceIndex(ss, f, S, x + 0, y + 0,
|
||||
edgeSize, gridSize);
|
||||
edgeSize, gridSize);
|
||||
mf->v2 = getFaceIndex(ss, f, S, x + 0, y + 1,
|
||||
edgeSize, gridSize);
|
||||
edgeSize, gridSize);
|
||||
mf->v3 = getFaceIndex(ss, f, S, x + 1, y + 1,
|
||||
edgeSize, gridSize);
|
||||
edgeSize, gridSize);
|
||||
mf->v4 = getFaceIndex(ss, f, S, x + 1, y + 0,
|
||||
edgeSize, gridSize);
|
||||
edgeSize, gridSize);
|
||||
mf->mat_nr = mat_nr;
|
||||
mf->flag = flag;
|
||||
|
||||
@@ -1206,7 +1205,7 @@ static void ccgDM_copyFinalFaceArray(DerivedMesh *dm, MFace *mface)
|
||||
|
||||
static void ccgDM_copyFinalLoopArray(DerivedMesh *dm, MLoop *mloop)
|
||||
{
|
||||
CCGDerivedMesh *ccgdm = (CCGDerivedMesh*) dm;
|
||||
CCGDerivedMesh *ccgdm = (CCGDerivedMesh *) dm;
|
||||
CCGSubSurf *ss = ccgdm->ss;
|
||||
int index;
|
||||
int totface;
|
||||
@@ -1220,9 +1219,9 @@ static void ccgDM_copyFinalLoopArray(DerivedMesh *dm, MLoop *mloop)
|
||||
MEdge *medge;
|
||||
|
||||
ccgdm->ehash = BLI_edgehash_new();
|
||||
medge = ccgdm->dm.getEdgeArray((DerivedMesh*)ccgdm);
|
||||
medge = ccgdm->dm.getEdgeArray((DerivedMesh *)ccgdm);
|
||||
|
||||
for (i=0; i<ccgdm->dm.numEdgeData; i++) {
|
||||
for (i = 0; i < ccgdm->dm.numEdgeData; i++) {
|
||||
BLI_edgehash_insert(ccgdm->ehash, medge[i].v1, medge[i].v2, SET_INT_IN_POINTER(i));
|
||||
}
|
||||
}
|
||||
@@ -1241,14 +1240,14 @@ static void ccgDM_copyFinalLoopArray(DerivedMesh *dm, MLoop *mloop)
|
||||
int v1, v2, v3, v4;
|
||||
|
||||
v1 = getFaceIndex(ss, f, S, x + 0, y + 0,
|
||||
edgeSize, gridSize);
|
||||
edgeSize, gridSize);
|
||||
|
||||
v2 = getFaceIndex(ss, f, S, x + 0, y + 1,
|
||||
edgeSize, gridSize);
|
||||
edgeSize, gridSize);
|
||||
v3 = getFaceIndex(ss, f, S, x + 1, y + 1,
|
||||
edgeSize, gridSize);
|
||||
edgeSize, gridSize);
|
||||
v4 = getFaceIndex(ss, f, S, x + 1, y + 0,
|
||||
edgeSize, gridSize);
|
||||
edgeSize, gridSize);
|
||||
|
||||
mv->v = v1;
|
||||
mv->e = GET_INT_FROM_POINTER(BLI_edgehash_lookup(ccgdm->ehash, v1, v2));
|
||||
@@ -1273,7 +1272,7 @@ static void ccgDM_copyFinalLoopArray(DerivedMesh *dm, MLoop *mloop)
|
||||
|
||||
static void ccgDM_copyFinalPolyArray(DerivedMesh *dm, MPoly *mpoly)
|
||||
{
|
||||
CCGDerivedMesh *ccgdm = (CCGDerivedMesh*) dm;
|
||||
CCGDerivedMesh *ccgdm = (CCGDerivedMesh *) dm;
|
||||
CCGSubSurf *ss = ccgdm->ss;
|
||||
int index;
|
||||
int totface;
|
||||
@@ -1286,8 +1285,8 @@ static void ccgDM_copyFinalPolyArray(DerivedMesh *dm, MPoly *mpoly)
|
||||
for (index = 0; index < totface; index++) {
|
||||
CCGFace *f = ccgdm->faceMap[index].face;
|
||||
int x, y, S, numVerts = ccgSubSurf_getFaceNumVerts(f);
|
||||
int flag = (faceFlags)? faceFlags[index].flag: ME_SMOOTH;
|
||||
int mat_nr = (faceFlags)? faceFlags[index].mat_nr: 0;
|
||||
int flag = (faceFlags) ? faceFlags[index].flag : ME_SMOOTH;
|
||||
int mat_nr = (faceFlags) ? faceFlags[index].mat_nr : 0;
|
||||
|
||||
for (S = 0; S < numVerts; S++) {
|
||||
for (y = 0; y < gridSize - 1; y++) {
|
||||
@@ -1309,7 +1308,7 @@ static void ccgDM_copyFinalPolyArray(DerivedMesh *dm, MPoly *mpoly)
|
||||
|
||||
static void ccgdm_getVertCos(DerivedMesh *dm, float (*cos)[3])
|
||||
{
|
||||
CCGDerivedMesh *ccgdm = (CCGDerivedMesh*) dm;
|
||||
CCGDerivedMesh *ccgdm = (CCGDerivedMesh *) dm;
|
||||
CCGSubSurf *ss = ccgdm->ss;
|
||||
int edgeSize = ccgSubSurf_getEdgeSize(ss);
|
||||
int gridSize = ccgSubSurf_getGridSize(ss);
|
||||
@@ -1323,7 +1322,7 @@ static void ccgdm_getVertCos(DerivedMesh *dm, float (*cos)[3])
|
||||
int index, totvert, totedge, totface;
|
||||
|
||||
totvert = ccgSubSurf_getNumVerts(ss);
|
||||
vertMap2 = MEM_mallocN(totvert*sizeof(*vertMap2), "vertmap");
|
||||
vertMap2 = MEM_mallocN(totvert * sizeof(*vertMap2), "vertmap");
|
||||
vi = ccgSubSurf_getVertIterator(ss);
|
||||
for (; !ccgVertIterator_isStopped(vi); ccgVertIterator_next(vi)) {
|
||||
CCGVert *v = ccgVertIterator_getCurrent(vi);
|
||||
@@ -1333,16 +1332,16 @@ static void ccgdm_getVertCos(DerivedMesh *dm, float (*cos)[3])
|
||||
ccgVertIterator_free(vi);
|
||||
|
||||
totedge = ccgSubSurf_getNumEdges(ss);
|
||||
edgeMap2 = MEM_mallocN(totedge*sizeof(*edgeMap2), "edgemap");
|
||||
edgeMap2 = MEM_mallocN(totedge * sizeof(*edgeMap2), "edgemap");
|
||||
ei = ccgSubSurf_getEdgeIterator(ss);
|
||||
for (i=0; !ccgEdgeIterator_isStopped(ei); i++,ccgEdgeIterator_next(ei)) {
|
||||
for (i = 0; !ccgEdgeIterator_isStopped(ei); i++, ccgEdgeIterator_next(ei)) {
|
||||
CCGEdge *e = ccgEdgeIterator_getCurrent(ei);
|
||||
|
||||
edgeMap2[GET_INT_FROM_POINTER(ccgSubSurf_getEdgeEdgeHandle(e))] = e;
|
||||
}
|
||||
|
||||
totface = ccgSubSurf_getNumFaces(ss);
|
||||
faceMap2 = MEM_mallocN(totface*sizeof(*faceMap2), "facemap");
|
||||
faceMap2 = MEM_mallocN(totface * sizeof(*faceMap2), "facemap");
|
||||
fi = ccgSubSurf_getFaceIterator(ss);
|
||||
for (; !ccgFaceIterator_isStopped(fi); ccgFaceIterator_next(fi)) {
|
||||
CCGFace *f = ccgFaceIterator_getCurrent(fi);
|
||||
@@ -1352,37 +1351,37 @@ static void ccgdm_getVertCos(DerivedMesh *dm, float (*cos)[3])
|
||||
ccgFaceIterator_free(fi);
|
||||
|
||||
i = 0;
|
||||
for (index=0; index<totface; index++) {
|
||||
for (index = 0; index < totface; index++) {
|
||||
CCGFace *f = faceMap2[index];
|
||||
int x, y, S, numVerts = ccgSubSurf_getFaceNumVerts(f);
|
||||
|
||||
copy_v3_v3(cos[i++], ccgSubSurf_getFaceCenterData(f));
|
||||
|
||||
for (S=0; S<numVerts; S++) {
|
||||
for (x=1; x<gridSize-1; x++) {
|
||||
for (S = 0; S < numVerts; S++) {
|
||||
for (x = 1; x < gridSize - 1; x++) {
|
||||
copy_v3_v3(cos[i++], ccgSubSurf_getFaceGridEdgeData(ss, f, S, x));
|
||||
}
|
||||
}
|
||||
|
||||
for (S=0; S<numVerts; S++) {
|
||||
for (y=1; y<gridSize-1; y++) {
|
||||
for (x=1; x<gridSize-1; x++) {
|
||||
for (S = 0; S < numVerts; S++) {
|
||||
for (y = 1; y < gridSize - 1; y++) {
|
||||
for (x = 1; x < gridSize - 1; x++) {
|
||||
copy_v3_v3(cos[i++], ccgSubSurf_getFaceGridData(ss, f, S, x, y));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (index=0; index<totedge; index++) {
|
||||
CCGEdge *e= edgeMap2[index];
|
||||
for (index = 0; index < totedge; index++) {
|
||||
CCGEdge *e = edgeMap2[index];
|
||||
int x;
|
||||
|
||||
for (x=1; x<edgeSize-1; x++) {
|
||||
for (x = 1; x < edgeSize - 1; x++) {
|
||||
copy_v3_v3(cos[i++], ccgSubSurf_getEdgeData(ss, e, x));
|
||||
}
|
||||
}
|
||||
|
||||
for (index=0; index<totvert; index++) {
|
||||
for (index = 0; index < totvert; index++) {
|
||||
CCGVert *v = vertMap2[index];
|
||||
copy_v3_v3(cos[i++], ccgSubSurf_getVertData(ss, v));
|
||||
}
|
||||
@@ -1393,11 +1392,11 @@ static void ccgdm_getVertCos(DerivedMesh *dm, float (*cos)[3])
|
||||
}
|
||||
|
||||
static void ccgDM_foreachMappedVert(
|
||||
DerivedMesh *dm,
|
||||
void (*func)(void *userData, int index, const float co[3], const float no_f[3], const short no_s[3]),
|
||||
void *userData)
|
||||
DerivedMesh *dm,
|
||||
void (*func)(void *userData, int index, const float co[3], const float no_f[3], const short no_s[3]),
|
||||
void *userData)
|
||||
{
|
||||
CCGDerivedMesh *ccgdm = (CCGDerivedMesh*) dm;
|
||||
CCGDerivedMesh *ccgdm = (CCGDerivedMesh *) dm;
|
||||
CCGVertIterator *vi = ccgSubSurf_getVertIterator(ccgdm->ss);
|
||||
|
||||
for (; !ccgVertIterator_isStopped(vi); ccgVertIterator_next(vi)) {
|
||||
@@ -1405,7 +1404,7 @@ static void ccgDM_foreachMappedVert(
|
||||
DMGridData *vd = ccgSubSurf_getVertData(ccgdm->ss, v);
|
||||
int index = ccgDM_getVertMapIndex(ccgdm->ss, v);
|
||||
|
||||
if (index!=-1)
|
||||
if (index != -1)
|
||||
func(userData, index, vd->co, vd->no, NULL);
|
||||
}
|
||||
|
||||
@@ -1413,11 +1412,11 @@ static void ccgDM_foreachMappedVert(
|
||||
}
|
||||
|
||||
static void ccgDM_foreachMappedEdge(
|
||||
DerivedMesh *dm,
|
||||
void (*func)(void *userData, int index, const float v0co[3], const float v1co[3]),
|
||||
void *userData)
|
||||
DerivedMesh *dm,
|
||||
void (*func)(void *userData, int index, const float v0co[3], const float v1co[3]),
|
||||
void *userData)
|
||||
{
|
||||
CCGDerivedMesh *ccgdm = (CCGDerivedMesh*) dm;
|
||||
CCGDerivedMesh *ccgdm = (CCGDerivedMesh *) dm;
|
||||
CCGSubSurf *ss = ccgdm->ss;
|
||||
CCGEdgeIterator *ei = ccgSubSurf_getEdgeIterator(ss);
|
||||
int i, edgeSize = ccgSubSurf_getEdgeSize(ss);
|
||||
@@ -1427,9 +1426,9 @@ static void ccgDM_foreachMappedEdge(
|
||||
DMGridData *edgeData = ccgSubSurf_getEdgeDataArray(ss, e);
|
||||
int index = ccgDM_getEdgeMapIndex(ss, e);
|
||||
|
||||
if (index!=-1) {
|
||||
for (i=0; i<edgeSize-1; i++)
|
||||
func(userData, index, edgeData[i].co, edgeData[i+1].co);
|
||||
if (index != -1) {
|
||||
for (i = 0; i < edgeSize - 1; i++)
|
||||
func(userData, index, edgeData[i].co, edgeData[i + 1].co);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1438,7 +1437,7 @@ static void ccgDM_foreachMappedEdge(
|
||||
|
||||
static void ccgDM_drawVerts(DerivedMesh *dm)
|
||||
{
|
||||
CCGDerivedMesh *ccgdm = (CCGDerivedMesh*) dm;
|
||||
CCGDerivedMesh *ccgdm = (CCGDerivedMesh *) dm;
|
||||
CCGSubSurf *ss = ccgdm->ss;
|
||||
int edgeSize = ccgSubSurf_getEdgeSize(ss);
|
||||
int gridSize = ccgSubSurf_getGridSize(ss);
|
||||
@@ -1459,7 +1458,7 @@ static void ccgDM_drawVerts(DerivedMesh *dm)
|
||||
CCGEdge *e = ccgEdgeIterator_getCurrent(ei);
|
||||
int x;
|
||||
|
||||
for (x=1; x<edgeSize-1; x++)
|
||||
for (x = 1; x < edgeSize - 1; x++)
|
||||
glVertex3fv(ccgSubSurf_getEdgeData(ss, e, x));
|
||||
}
|
||||
ccgEdgeIterator_free(ei);
|
||||
@@ -1470,12 +1469,12 @@ static void ccgDM_drawVerts(DerivedMesh *dm)
|
||||
int x, y, S, numVerts = ccgSubSurf_getFaceNumVerts(f);
|
||||
|
||||
glVertex3fv(ccgSubSurf_getFaceCenterData(f));
|
||||
for (S=0; S<numVerts; S++)
|
||||
for (x=1; x<gridSize-1; x++)
|
||||
for (S = 0; S < numVerts; S++)
|
||||
for (x = 1; x < gridSize - 1; x++)
|
||||
glVertex3fv(ccgSubSurf_getFaceGridEdgeData(ss, f, S, x));
|
||||
for (S=0; S<numVerts; S++)
|
||||
for (y=1; y<gridSize-1; y++)
|
||||
for (x=1; x<gridSize-1; x++)
|
||||
for (S = 0; S < numVerts; S++)
|
||||
for (y = 1; y < gridSize - 1; y++)
|
||||
for (x = 1; x < gridSize - 1; x++)
|
||||
glVertex3fv(ccgSubSurf_getFaceGridData(ss, f, S, x, y));
|
||||
}
|
||||
ccgFaceIterator_free(fi);
|
||||
@@ -1488,7 +1487,7 @@ static void ccgdm_pbvh_update(CCGDerivedMesh *ccgdm)
|
||||
CCGFace **faces;
|
||||
int totface;
|
||||
|
||||
BLI_pbvh_get_grid_updates(ccgdm->pbvh, 1, (void***)&faces, &totface);
|
||||
BLI_pbvh_get_grid_updates(ccgdm->pbvh, 1, (void ***)&faces, &totface);
|
||||
if (totface) {
|
||||
ccgSubSurf_updateFromFaces(ccgdm->ss, 0, faces, totface);
|
||||
ccgSubSurf_updateNormals(ccgdm->ss, faces, totface);
|
||||
@@ -1499,7 +1498,7 @@ static void ccgdm_pbvh_update(CCGDerivedMesh *ccgdm)
|
||||
|
||||
static void ccgDM_drawEdges(DerivedMesh *dm, int drawLooseEdges, int drawAllEdges)
|
||||
{
|
||||
CCGDerivedMesh *ccgdm = (CCGDerivedMesh*) dm;
|
||||
CCGDerivedMesh *ccgdm = (CCGDerivedMesh *) dm;
|
||||
CCGSubSurf *ss = ccgdm->ss;
|
||||
int i, j, edgeSize = ccgSubSurf_getEdgeSize(ss);
|
||||
int totedge = ccgSubSurf_getNumEdges(ss);
|
||||
@@ -1510,7 +1509,7 @@ static void ccgDM_drawEdges(DerivedMesh *dm, int drawLooseEdges, int drawAllEdge
|
||||
|
||||
ccgSubSurf_getUseAgeCounts(ss, &useAging, NULL, NULL, NULL);
|
||||
|
||||
for (j=0; j< totedge; j++) {
|
||||
for (j = 0; j < totedge; j++) {
|
||||
CCGEdge *e = ccgdm->edgeMap[j].edge;
|
||||
DMGridData *edgeData = ccgSubSurf_getEdgeDataArray(ss, e);
|
||||
|
||||
@@ -1520,20 +1519,20 @@ static void ccgDM_drawEdges(DerivedMesh *dm, int drawLooseEdges, int drawAllEdge
|
||||
if (!drawAllEdges && ccgdm->edgeFlags && !(ccgdm->edgeFlags[j] & ME_EDGEDRAW))
|
||||
continue;
|
||||
|
||||
if (useAging && !(G.f&G_BACKBUFSEL)) {
|
||||
int ageCol = 255-ccgSubSurf_getEdgeAge(ss, e)*4;
|
||||
glColor3ub(0, ageCol>0?ageCol:0, 0);
|
||||
if (useAging && !(G.f & G_BACKBUFSEL)) {
|
||||
int ageCol = 255 - ccgSubSurf_getEdgeAge(ss, e) * 4;
|
||||
glColor3ub(0, ageCol > 0 ? ageCol : 0, 0);
|
||||
}
|
||||
|
||||
glBegin(GL_LINE_STRIP);
|
||||
for (i=0; i<edgeSize-1; i++) {
|
||||
for (i = 0; i < edgeSize - 1; i++) {
|
||||
glVertex3fv(edgeData[i].co);
|
||||
glVertex3fv(edgeData[i+1].co);
|
||||
glVertex3fv(edgeData[i + 1].co);
|
||||
}
|
||||
glEnd();
|
||||
}
|
||||
|
||||
if (useAging && !(G.f&G_BACKBUFSEL)) {
|
||||
if (useAging && !(G.f & G_BACKBUFSEL)) {
|
||||
glColor3ub(0, 0, 0);
|
||||
}
|
||||
|
||||
@@ -1544,23 +1543,23 @@ static void ccgDM_drawEdges(DerivedMesh *dm, int drawLooseEdges, int drawAllEdge
|
||||
CCGFace *f = ccgdm->faceMap[j].face;
|
||||
int S, x, y, numVerts = ccgSubSurf_getFaceNumVerts(f);
|
||||
|
||||
for (S=0; S<numVerts; S++) {
|
||||
for (S = 0; S < numVerts; S++) {
|
||||
DMGridData *faceGridData = ccgSubSurf_getFaceGridDataArray(ss, f, S);
|
||||
|
||||
glBegin(GL_LINE_STRIP);
|
||||
for (x=0; x<gridSize; x++)
|
||||
for (x = 0; x < gridSize; x++)
|
||||
glVertex3fv(faceGridData[x].co);
|
||||
glEnd();
|
||||
for (y=1; y<gridSize-1; y++) {
|
||||
for (y = 1; y < gridSize - 1; y++) {
|
||||
glBegin(GL_LINE_STRIP);
|
||||
for (x=0; x<gridSize; x++)
|
||||
glVertex3fv(faceGridData[y*gridSize + x].co);
|
||||
for (x = 0; x < gridSize; x++)
|
||||
glVertex3fv(faceGridData[y * gridSize + x].co);
|
||||
glEnd();
|
||||
}
|
||||
for (x=1; x<gridSize-1; x++) {
|
||||
for (x = 1; x < gridSize - 1; x++) {
|
||||
glBegin(GL_LINE_STRIP);
|
||||
for (y=0; y<gridSize; y++)
|
||||
glVertex3fv(faceGridData[y*gridSize + x].co);
|
||||
for (y = 0; y < gridSize; y++)
|
||||
glVertex3fv(faceGridData[y * gridSize + x].co);
|
||||
glEnd();
|
||||
}
|
||||
}
|
||||
@@ -1570,20 +1569,20 @@ static void ccgDM_drawEdges(DerivedMesh *dm, int drawLooseEdges, int drawAllEdge
|
||||
|
||||
static void ccgDM_drawLooseEdges(DerivedMesh *dm)
|
||||
{
|
||||
CCGDerivedMesh *ccgdm = (CCGDerivedMesh*) dm;
|
||||
CCGDerivedMesh *ccgdm = (CCGDerivedMesh *) dm;
|
||||
CCGSubSurf *ss = ccgdm->ss;
|
||||
int totedge = ccgSubSurf_getNumEdges(ss);
|
||||
int i, j, edgeSize = ccgSubSurf_getEdgeSize(ss);
|
||||
|
||||
for (j=0; j< totedge; j++) {
|
||||
for (j = 0; j < totedge; j++) {
|
||||
CCGEdge *e = ccgdm->edgeMap[j].edge;
|
||||
DMGridData *edgeData = ccgSubSurf_getEdgeDataArray(ss, e);
|
||||
|
||||
if (!ccgSubSurf_getEdgeNumFaces(e)) {
|
||||
glBegin(GL_LINE_STRIP);
|
||||
for (i=0; i<edgeSize-1; i++) {
|
||||
for (i = 0; i < edgeSize - 1; i++) {
|
||||
glVertex3fv(edgeData[i].co);
|
||||
glVertex3fv(edgeData[i+1].co);
|
||||
glVertex3fv(edgeData[i + 1].co);
|
||||
}
|
||||
glEnd();
|
||||
}
|
||||
@@ -1592,26 +1591,26 @@ static void ccgDM_drawLooseEdges(DerivedMesh *dm)
|
||||
|
||||
static void ccgDM_glNormalFast(float *a, float *b, float *c, float *d)
|
||||
{
|
||||
float a_cX = c[0]-a[0], a_cY = c[1]-a[1], a_cZ = c[2]-a[2];
|
||||
float b_dX = d[0]-b[0], b_dY = d[1]-b[1], b_dZ = d[2]-b[2];
|
||||
float a_cX = c[0] - a[0], a_cY = c[1] - a[1], a_cZ = c[2] - a[2];
|
||||
float b_dX = d[0] - b[0], b_dY = d[1] - b[1], b_dZ = d[2] - b[2];
|
||||
float no[3];
|
||||
|
||||
no[0] = b_dY*a_cZ - b_dZ*a_cY;
|
||||
no[1] = b_dZ*a_cX - b_dX*a_cZ;
|
||||
no[2] = b_dX*a_cY - b_dY*a_cX;
|
||||
no[0] = b_dY * a_cZ - b_dZ * a_cY;
|
||||
no[1] = b_dZ * a_cX - b_dX * a_cZ;
|
||||
no[2] = b_dX * a_cY - b_dY * a_cX;
|
||||
|
||||
/* don't normalize, GL_NORMALIZE is enabled */
|
||||
glNormal3fv(no);
|
||||
}
|
||||
|
||||
/* Only used by non-editmesh types */
|
||||
/* Only used by non-editmesh types */
|
||||
static void ccgDM_drawFacesSolid(DerivedMesh *dm, float (*partial_redraw_planes)[4], int fast, DMSetMaterial setMaterial)
|
||||
{
|
||||
CCGDerivedMesh *ccgdm = (CCGDerivedMesh*) dm;
|
||||
CCGDerivedMesh *ccgdm = (CCGDerivedMesh *) dm;
|
||||
CCGSubSurf *ss = ccgdm->ss;
|
||||
int gridSize = ccgSubSurf_getGridSize(ss);
|
||||
DMFlagMat *faceFlags = ccgdm->faceFlags;
|
||||
int step = (fast)? gridSize-1: 1;
|
||||
int step = (fast) ? gridSize - 1 : 1;
|
||||
int i, totface = ccgSubSurf_getNumFaces(ss);
|
||||
int drawcurrent = 0, matnr = -1, shademodel = -1;
|
||||
|
||||
@@ -1633,19 +1632,19 @@ static void ccgDM_drawFacesSolid(DerivedMesh *dm, float (*partial_redraw_planes)
|
||||
int new_matnr, new_shademodel;
|
||||
|
||||
if (faceFlags) {
|
||||
new_shademodel = (faceFlags[index].flag & ME_SMOOTH)? GL_SMOOTH: GL_FLAT;
|
||||
new_matnr= faceFlags[index].mat_nr;
|
||||
new_shademodel = (faceFlags[index].flag & ME_SMOOTH) ? GL_SMOOTH : GL_FLAT;
|
||||
new_matnr = faceFlags[index].mat_nr;
|
||||
}
|
||||
else {
|
||||
new_shademodel = GL_SMOOTH;
|
||||
new_matnr= 0;
|
||||
new_matnr = 0;
|
||||
}
|
||||
|
||||
if (shademodel != new_shademodel || matnr != new_matnr) {
|
||||
matnr= new_matnr;
|
||||
shademodel= new_shademodel;
|
||||
matnr = new_matnr;
|
||||
shademodel = new_shademodel;
|
||||
|
||||
drawcurrent= setMaterial(matnr+1, NULL);
|
||||
drawcurrent = setMaterial(matnr + 1, NULL);
|
||||
|
||||
glShadeModel(shademodel);
|
||||
}
|
||||
@@ -1653,15 +1652,15 @@ static void ccgDM_drawFacesSolid(DerivedMesh *dm, float (*partial_redraw_planes)
|
||||
if (!drawcurrent)
|
||||
continue;
|
||||
|
||||
for (S=0; S<numVerts; S++) {
|
||||
for (S = 0; S < numVerts; S++) {
|
||||
DMGridData *faceGridData = ccgSubSurf_getFaceGridDataArray(ss, f, S);
|
||||
|
||||
if (shademodel == GL_SMOOTH) {
|
||||
for (y=0; y<gridSize-1; y+=step) {
|
||||
for (y = 0; y < gridSize - 1; y += step) {
|
||||
glBegin(GL_QUAD_STRIP);
|
||||
for (x=0; x<gridSize; x+=step) {
|
||||
DMGridData *a = &faceGridData[(y+0)*gridSize + x];
|
||||
DMGridData *b = &faceGridData[(y+step)*gridSize + x];
|
||||
for (x = 0; x < gridSize; x += step) {
|
||||
DMGridData *a = &faceGridData[(y + 0) * gridSize + x];
|
||||
DMGridData *b = &faceGridData[(y + step) * gridSize + x];
|
||||
|
||||
glNormal3fv(a->no);
|
||||
glVertex3fv(a->co);
|
||||
@@ -1673,12 +1672,12 @@ static void ccgDM_drawFacesSolid(DerivedMesh *dm, float (*partial_redraw_planes)
|
||||
}
|
||||
else {
|
||||
glBegin(GL_QUADS);
|
||||
for (y=0; y<gridSize-1; y+=step) {
|
||||
for (x=0; x<gridSize-1; x+=step) {
|
||||
float *a = faceGridData[(y+0)*gridSize + x].co;
|
||||
float *b = faceGridData[(y+0)*gridSize + x + step].co;
|
||||
float *c = faceGridData[(y+step)*gridSize + x + step].co;
|
||||
float *d = faceGridData[(y+step)*gridSize + x].co;
|
||||
for (y = 0; y < gridSize - 1; y += step) {
|
||||
for (x = 0; x < gridSize - 1; x += step) {
|
||||
float *a = faceGridData[(y + 0) * gridSize + x].co;
|
||||
float *b = faceGridData[(y + 0) * gridSize + x + step].co;
|
||||
float *c = faceGridData[(y + step) * gridSize + x + step].co;
|
||||
float *d = faceGridData[(y + step) * gridSize + x].co;
|
||||
|
||||
ccgDM_glNormalFast(a, b, c, d);
|
||||
|
||||
@@ -1694,16 +1693,16 @@ static void ccgDM_drawFacesSolid(DerivedMesh *dm, float (*partial_redraw_planes)
|
||||
}
|
||||
}
|
||||
|
||||
/* Only used by non-editmesh types */
|
||||
/* Only used by non-editmesh types */
|
||||
static void ccgDM_drawMappedFacesGLSL(DerivedMesh *dm,
|
||||
DMSetMaterial setMaterial,
|
||||
DMSetDrawOptions setDrawOptions,
|
||||
void *userData)
|
||||
DMSetMaterial setMaterial,
|
||||
DMSetDrawOptions setDrawOptions,
|
||||
void *userData)
|
||||
{
|
||||
CCGDerivedMesh *ccgdm = (CCGDerivedMesh*) dm;
|
||||
CCGDerivedMesh *ccgdm = (CCGDerivedMesh *) dm;
|
||||
CCGSubSurf *ss = ccgdm->ss;
|
||||
GPUVertexAttribs gattribs;
|
||||
DMVertexAttribs attribs= {{{NULL}}};
|
||||
DMVertexAttribs attribs = {{{NULL}}};
|
||||
/* MTFace *tf = dm->getTessFaceDataArray(dm, CD_MTFACE); */ /* UNUSED */
|
||||
int gridSize = ccgSubSurf_getGridSize(ss);
|
||||
int gridFaces = gridSize - 1;
|
||||
@@ -1716,25 +1715,25 @@ static void ccgDM_drawMappedFacesGLSL(DerivedMesh *dm,
|
||||
doDraw = 0;
|
||||
matnr = -1;
|
||||
|
||||
#define PASSATTRIB(dx, dy, vert) { \
|
||||
if (attribs.totorco) { \
|
||||
index = getFaceIndex(ss, f, S, x+dx, y+dy, edgeSize, gridSize); \
|
||||
glVertexAttrib3fvARB(attribs.orco.glIndex, attribs.orco.array[index]); \
|
||||
} \
|
||||
for (b = 0; b < attribs.tottface; b++) { \
|
||||
MTFace *tf = &attribs.tface[b].array[a]; \
|
||||
glVertexAttrib2fvARB(attribs.tface[b].glIndex, tf->uv[vert]); \
|
||||
} \
|
||||
for (b = 0; b < attribs.totmcol; b++) { \
|
||||
MCol *cp = &attribs.mcol[b].array[a*4 + vert]; \
|
||||
GLubyte col[4]; \
|
||||
col[0]= cp->b; col[1]= cp->g; col[2]= cp->r; col[3]= cp->a; \
|
||||
glVertexAttrib4ubvARB(attribs.mcol[b].glIndex, col); \
|
||||
} \
|
||||
if (attribs.tottang) { \
|
||||
float *tang = attribs.tang.array[a*4 + vert]; \
|
||||
glVertexAttrib4fvARB(attribs.tang.glIndex, tang); \
|
||||
} \
|
||||
#define PASSATTRIB(dx, dy, vert) { \
|
||||
if (attribs.totorco) { \
|
||||
index = getFaceIndex(ss, f, S, x + dx, y + dy, edgeSize, gridSize); \
|
||||
glVertexAttrib3fvARB(attribs.orco.glIndex, attribs.orco.array[index]); \
|
||||
} \
|
||||
for (b = 0; b < attribs.tottface; b++) { \
|
||||
MTFace *tf = &attribs.tface[b].array[a]; \
|
||||
glVertexAttrib2fvARB(attribs.tface[b].glIndex, tf->uv[vert]); \
|
||||
} \
|
||||
for (b = 0; b < attribs.totmcol; b++) { \
|
||||
MCol *cp = &attribs.mcol[b].array[a * 4 + vert]; \
|
||||
GLubyte col[4]; \
|
||||
col[0] = cp->b; col[1] = cp->g; col[2] = cp->r; col[3] = cp->a; \
|
||||
glVertexAttrib4ubvARB(attribs.mcol[b].glIndex, col); \
|
||||
} \
|
||||
if (attribs.tottang) { \
|
||||
float *tang = attribs.tang.array[a * 4 + vert]; \
|
||||
glVertexAttrib4fvARB(attribs.tang.glIndex, tang); \
|
||||
} \
|
||||
}
|
||||
|
||||
totface = ccgSubSurf_getNumFaces(ss);
|
||||
@@ -1748,11 +1747,11 @@ static void ccgDM_drawMappedFacesGLSL(DerivedMesh *dm,
|
||||
|
||||
if (faceFlags) {
|
||||
drawSmooth = (faceFlags[index].flag & ME_SMOOTH);
|
||||
new_matnr= faceFlags[index].mat_nr + 1;
|
||||
new_matnr = faceFlags[index].mat_nr + 1;
|
||||
}
|
||||
else {
|
||||
drawSmooth = 1;
|
||||
new_matnr= 1;
|
||||
new_matnr = 1;
|
||||
}
|
||||
|
||||
if (new_matnr != matnr) {
|
||||
@@ -1762,22 +1761,23 @@ static void ccgDM_drawMappedFacesGLSL(DerivedMesh *dm,
|
||||
}
|
||||
|
||||
if (!doDraw || (setDrawOptions && (origIndex != ORIGINDEX_NONE) &&
|
||||
(setDrawOptions(userData, origIndex) == DM_DRAW_OPTION_SKIP))) {
|
||||
a += gridFaces*gridFaces*numVerts;
|
||||
(setDrawOptions(userData, origIndex) == DM_DRAW_OPTION_SKIP)))
|
||||
{
|
||||
a += gridFaces * gridFaces * numVerts;
|
||||
continue;
|
||||
}
|
||||
|
||||
glShadeModel(drawSmooth? GL_SMOOTH: GL_FLAT);
|
||||
for (S=0; S<numVerts; S++) {
|
||||
glShadeModel(drawSmooth ? GL_SMOOTH : GL_FLAT);
|
||||
for (S = 0; S < numVerts; S++) {
|
||||
DMGridData *faceGridData = ccgSubSurf_getFaceGridDataArray(ss, f, S);
|
||||
DMGridData *vda, *vdb;
|
||||
|
||||
if (drawSmooth) {
|
||||
for (y=0; y<gridFaces; y++) {
|
||||
for (y = 0; y < gridFaces; y++) {
|
||||
glBegin(GL_QUAD_STRIP);
|
||||
for (x=0; x<gridFaces; x++) {
|
||||
vda = &faceGridData[(y+0)*gridSize + x];
|
||||
vdb = &faceGridData[(y+1)*gridSize + x];
|
||||
for (x = 0; x < gridFaces; x++) {
|
||||
vda = &faceGridData[(y + 0) * gridSize + x];
|
||||
vdb = &faceGridData[(y + 1) * gridSize + x];
|
||||
|
||||
PASSATTRIB(0, 0, 0);
|
||||
glNormal3fv(vda->no);
|
||||
@@ -1787,12 +1787,12 @@ static void ccgDM_drawMappedFacesGLSL(DerivedMesh *dm,
|
||||
glNormal3fv(vdb->no);
|
||||
glVertex3fv(vdb->co);
|
||||
|
||||
if (x != gridFaces-1)
|
||||
if (x != gridFaces - 1)
|
||||
a++;
|
||||
}
|
||||
|
||||
vda = &faceGridData[(y+0)*gridSize + x];
|
||||
vdb = &faceGridData[(y+1)*gridSize + x];
|
||||
vda = &faceGridData[(y + 0) * gridSize + x];
|
||||
vdb = &faceGridData[(y + 1) * gridSize + x];
|
||||
|
||||
PASSATTRIB(0, 0, 3);
|
||||
glNormal3fv(vda->no);
|
||||
@@ -1809,12 +1809,12 @@ static void ccgDM_drawMappedFacesGLSL(DerivedMesh *dm,
|
||||
}
|
||||
else {
|
||||
glBegin(GL_QUADS);
|
||||
for (y=0; y<gridFaces; y++) {
|
||||
for (x=0; x<gridFaces; x++) {
|
||||
float *aco = faceGridData[(y+0)*gridSize + x].co;
|
||||
float *bco = faceGridData[(y+0)*gridSize + x + 1].co;
|
||||
float *cco = faceGridData[(y+1)*gridSize + x + 1].co;
|
||||
float *dco = faceGridData[(y+1)*gridSize + x].co;
|
||||
for (y = 0; y < gridFaces; y++) {
|
||||
for (x = 0; x < gridFaces; x++) {
|
||||
float *aco = faceGridData[(y + 0) * gridSize + x].co;
|
||||
float *bco = faceGridData[(y + 0) * gridSize + x + 1].co;
|
||||
float *cco = faceGridData[(y + 1) * gridSize + x + 1].co;
|
||||
float *dco = faceGridData[(y + 1) * gridSize + x].co;
|
||||
|
||||
ccgDM_glNormalFast(aco, bco, cco, dco);
|
||||
|
||||
@@ -1843,13 +1843,13 @@ static void ccgDM_drawFacesGLSL(DerivedMesh *dm, DMSetMaterial setMaterial)
|
||||
dm->drawMappedFacesGLSL(dm, setMaterial, NULL, NULL);
|
||||
}
|
||||
|
||||
/* Only used by non-editmesh types */
|
||||
/* Only used by non-editmesh types */
|
||||
static void ccgDM_drawMappedFacesMat(DerivedMesh *dm, void (*setMaterial)(void *userData, int, void *attribs), int (*setFace)(void *userData, int index), void *userData)
|
||||
{
|
||||
CCGDerivedMesh *ccgdm = (CCGDerivedMesh*) dm;
|
||||
CCGDerivedMesh *ccgdm = (CCGDerivedMesh *) dm;
|
||||
CCGSubSurf *ss = ccgdm->ss;
|
||||
GPUVertexAttribs gattribs;
|
||||
DMVertexAttribs attribs= {{{NULL}}};
|
||||
DMVertexAttribs attribs = {{{NULL}}};
|
||||
int gridSize = ccgSubSurf_getGridSize(ss);
|
||||
int gridFaces = gridSize - 1;
|
||||
int edgeSize = ccgSubSurf_getEdgeSize(ss);
|
||||
@@ -1860,31 +1860,31 @@ static void ccgDM_drawMappedFacesMat(DerivedMesh *dm, void (*setMaterial)(void *
|
||||
|
||||
matnr = -1;
|
||||
|
||||
#define PASSATTRIB(dx, dy, vert) { \
|
||||
if (attribs.totorco) { \
|
||||
index = getFaceIndex(ss, f, S, x+dx, y+dy, edgeSize, gridSize); \
|
||||
if (attribs.orco.glTexco) \
|
||||
glTexCoord3fv(attribs.orco.array[index]); \
|
||||
else \
|
||||
glVertexAttrib3fvARB(attribs.orco.glIndex, attribs.orco.array[index]); \
|
||||
} \
|
||||
for (b = 0; b < attribs.tottface; b++) { \
|
||||
MTFace *tf = &attribs.tface[b].array[a]; \
|
||||
if (attribs.tface[b].glTexco) \
|
||||
glTexCoord2fv(tf->uv[vert]); \
|
||||
else \
|
||||
glVertexAttrib2fvARB(attribs.tface[b].glIndex, tf->uv[vert]); \
|
||||
} \
|
||||
for (b = 0; b < attribs.totmcol; b++) { \
|
||||
MCol *cp = &attribs.mcol[b].array[a*4 + vert]; \
|
||||
GLubyte col[4]; \
|
||||
col[0]= cp->b; col[1]= cp->g; col[2]= cp->r; col[3]= cp->a; \
|
||||
glVertexAttrib4ubvARB(attribs.mcol[b].glIndex, col); \
|
||||
} \
|
||||
if (attribs.tottang) { \
|
||||
float *tang = attribs.tang.array[a*4 + vert]; \
|
||||
glVertexAttrib4fvARB(attribs.tang.glIndex, tang); \
|
||||
} \
|
||||
#define PASSATTRIB(dx, dy, vert) { \
|
||||
if (attribs.totorco) { \
|
||||
index = getFaceIndex(ss, f, S, x + dx, y + dy, edgeSize, gridSize); \
|
||||
if (attribs.orco.glTexco) \
|
||||
glTexCoord3fv(attribs.orco.array[index]); \
|
||||
else \
|
||||
glVertexAttrib3fvARB(attribs.orco.glIndex, attribs.orco.array[index]); \
|
||||
} \
|
||||
for (b = 0; b < attribs.tottface; b++) { \
|
||||
MTFace *tf = &attribs.tface[b].array[a]; \
|
||||
if (attribs.tface[b].glTexco) \
|
||||
glTexCoord2fv(tf->uv[vert]); \
|
||||
else \
|
||||
glVertexAttrib2fvARB(attribs.tface[b].glIndex, tf->uv[vert]); \
|
||||
} \
|
||||
for (b = 0; b < attribs.totmcol; b++) { \
|
||||
MCol *cp = &attribs.mcol[b].array[a * 4 + vert]; \
|
||||
GLubyte col[4]; \
|
||||
col[0] = cp->b; col[1] = cp->g; col[2] = cp->r; col[3] = cp->a; \
|
||||
glVertexAttrib4ubvARB(attribs.mcol[b].glIndex, col); \
|
||||
} \
|
||||
if (attribs.tottang) { \
|
||||
float *tang = attribs.tang.array[a * 4 + vert]; \
|
||||
glVertexAttrib4fvARB(attribs.tang.glIndex, tang); \
|
||||
} \
|
||||
}
|
||||
|
||||
totface = ccgSubSurf_getNumFaces(ss);
|
||||
@@ -1899,11 +1899,11 @@ static void ccgDM_drawMappedFacesMat(DerivedMesh *dm, void (*setMaterial)(void *
|
||||
/* get flags */
|
||||
if (faceFlags) {
|
||||
drawSmooth = (faceFlags[index].flag & ME_SMOOTH);
|
||||
new_matnr= faceFlags[index].mat_nr + 1;
|
||||
new_matnr = faceFlags[index].mat_nr + 1;
|
||||
}
|
||||
else {
|
||||
drawSmooth = 1;
|
||||
new_matnr= 1;
|
||||
new_matnr = 1;
|
||||
}
|
||||
|
||||
/* material */
|
||||
@@ -1914,22 +1914,22 @@ static void ccgDM_drawMappedFacesMat(DerivedMesh *dm, void (*setMaterial)(void *
|
||||
|
||||
/* face hiding */
|
||||
if ((setFace && (origIndex != ORIGINDEX_NONE) && !setFace(userData, origIndex))) {
|
||||
a += gridFaces*gridFaces*numVerts;
|
||||
a += gridFaces * gridFaces * numVerts;
|
||||
continue;
|
||||
}
|
||||
|
||||
/* draw face*/
|
||||
glShadeModel(drawSmooth? GL_SMOOTH: GL_FLAT);
|
||||
for (S=0; S<numVerts; S++) {
|
||||
glShadeModel(drawSmooth ? GL_SMOOTH : GL_FLAT);
|
||||
for (S = 0; S < numVerts; S++) {
|
||||
DMGridData *faceGridData = ccgSubSurf_getFaceGridDataArray(ss, f, S);
|
||||
DMGridData *vda, *vdb;
|
||||
|
||||
if (drawSmooth) {
|
||||
for (y=0; y<gridFaces; y++) {
|
||||
for (y = 0; y < gridFaces; y++) {
|
||||
glBegin(GL_QUAD_STRIP);
|
||||
for (x=0; x<gridFaces; x++) {
|
||||
vda = &faceGridData[(y+0)*gridSize + x];
|
||||
vdb = &faceGridData[(y+1)*gridSize + x];
|
||||
for (x = 0; x < gridFaces; x++) {
|
||||
vda = &faceGridData[(y + 0) * gridSize + x];
|
||||
vdb = &faceGridData[(y + 1) * gridSize + x];
|
||||
|
||||
PASSATTRIB(0, 0, 0);
|
||||
glNormal3fv(vda->no);
|
||||
@@ -1939,12 +1939,12 @@ static void ccgDM_drawMappedFacesMat(DerivedMesh *dm, void (*setMaterial)(void *
|
||||
glNormal3fv(vdb->no);
|
||||
glVertex3fv(vdb->co);
|
||||
|
||||
if (x != gridFaces-1)
|
||||
if (x != gridFaces - 1)
|
||||
a++;
|
||||
}
|
||||
|
||||
vda = &faceGridData[(y+0)*gridSize + x];
|
||||
vdb = &faceGridData[(y+1)*gridSize + x];
|
||||
vda = &faceGridData[(y + 0) * gridSize + x];
|
||||
vdb = &faceGridData[(y + 1) * gridSize + x];
|
||||
|
||||
PASSATTRIB(0, 0, 3);
|
||||
glNormal3fv(vda->no);
|
||||
@@ -1961,12 +1961,12 @@ static void ccgDM_drawMappedFacesMat(DerivedMesh *dm, void (*setMaterial)(void *
|
||||
}
|
||||
else {
|
||||
glBegin(GL_QUADS);
|
||||
for (y=0; y<gridFaces; y++) {
|
||||
for (x=0; x<gridFaces; x++) {
|
||||
float *aco = faceGridData[(y+0)*gridSize + x].co;
|
||||
float *bco = faceGridData[(y+0)*gridSize + x + 1].co;
|
||||
float *cco = faceGridData[(y+1)*gridSize + x + 1].co;
|
||||
float *dco = faceGridData[(y+1)*gridSize + x].co;
|
||||
for (y = 0; y < gridFaces; y++) {
|
||||
for (x = 0; x < gridFaces; x++) {
|
||||
float *aco = faceGridData[(y + 0) * gridSize + x].co;
|
||||
float *bco = faceGridData[(y + 0) * gridSize + x + 1].co;
|
||||
float *cco = faceGridData[(y + 1) * gridSize + x + 1].co;
|
||||
float *dco = faceGridData[(y + 1) * gridSize + x].co;
|
||||
|
||||
ccgDM_glNormalFast(aco, bco, cco, dco);
|
||||
|
||||
@@ -1991,12 +1991,12 @@ static void ccgDM_drawMappedFacesMat(DerivedMesh *dm, void (*setMaterial)(void *
|
||||
}
|
||||
|
||||
static void ccgDM_drawFacesTex_common(DerivedMesh *dm,
|
||||
DMSetDrawOptionsTex drawParams,
|
||||
DMSetDrawOptions drawParamsMapped,
|
||||
DMCompareDrawOptions compareDrawOptions,
|
||||
void *userData)
|
||||
DMSetDrawOptionsTex drawParams,
|
||||
DMSetDrawOptions drawParamsMapped,
|
||||
DMCompareDrawOptions compareDrawOptions,
|
||||
void *userData)
|
||||
{
|
||||
CCGDerivedMesh *ccgdm = (CCGDerivedMesh*) dm;
|
||||
CCGDerivedMesh *ccgdm = (CCGDerivedMesh *) dm;
|
||||
CCGSubSurf *ss = ccgdm->ss;
|
||||
MCol *mcol = dm->getTessFaceDataArray(dm, CD_PREVIEW_MCOL);
|
||||
MTFace *tf = DM_get_tessface_data_layer(dm, CD_MTFACE);
|
||||
@@ -2021,50 +2021,50 @@ static void ccgDM_drawFacesTex_common(DerivedMesh *dm,
|
||||
int S, x, y, numVerts = ccgSubSurf_getFaceNumVerts(f);
|
||||
int drawSmooth, index = ccgDM_getFaceMapIndex(ss, f);
|
||||
int origIndex = GET_INT_FROM_POINTER(ccgSubSurf_getFaceFaceHandle(f));
|
||||
unsigned char *cp= NULL;
|
||||
unsigned char *cp = NULL;
|
||||
int mat_nr;
|
||||
|
||||
if (faceFlags) {
|
||||
drawSmooth = (faceFlags[origIndex].flag & ME_SMOOTH);
|
||||
mat_nr= faceFlags[origIndex].mat_nr;
|
||||
mat_nr = faceFlags[origIndex].mat_nr;
|
||||
}
|
||||
else {
|
||||
drawSmooth = 1;
|
||||
mat_nr= 0;
|
||||
mat_nr = 0;
|
||||
}
|
||||
|
||||
if (drawParams)
|
||||
draw_option = drawParams(tf, (mcol != NULL), mat_nr);
|
||||
else if (index != ORIGINDEX_NONE)
|
||||
draw_option= (drawParamsMapped)? drawParamsMapped(userData, index): DM_DRAW_OPTION_NORMAL;
|
||||
draw_option = (drawParamsMapped) ? drawParamsMapped(userData, index) : DM_DRAW_OPTION_NORMAL;
|
||||
else
|
||||
draw_option= GPU_enable_material(mat_nr, NULL) ? DM_DRAW_OPTION_NORMAL : DM_DRAW_OPTION_SKIP;
|
||||
draw_option = GPU_enable_material(mat_nr, NULL) ? DM_DRAW_OPTION_NORMAL : DM_DRAW_OPTION_SKIP;
|
||||
|
||||
|
||||
if (draw_option == DM_DRAW_OPTION_SKIP) {
|
||||
if (tf) tf += gridFaces*gridFaces*numVerts;
|
||||
if (mcol) mcol += gridFaces*gridFaces*numVerts*4;
|
||||
if (tf) tf += gridFaces * gridFaces * numVerts;
|
||||
if (mcol) mcol += gridFaces * gridFaces * numVerts * 4;
|
||||
continue;
|
||||
}
|
||||
|
||||
/* flag 1 == use vertex colors */
|
||||
if (mcol) {
|
||||
if (draw_option != DM_DRAW_OPTION_NO_MCOL)
|
||||
cp= (unsigned char*)mcol;
|
||||
mcol += gridFaces*gridFaces*numVerts*4;
|
||||
cp = (unsigned char *)mcol;
|
||||
mcol += gridFaces * gridFaces * numVerts * 4;
|
||||
}
|
||||
|
||||
for (S=0; S<numVerts; S++) {
|
||||
for (S = 0; S < numVerts; S++) {
|
||||
DMGridData *faceGridData = ccgSubSurf_getFaceGridDataArray(ss, f, S);
|
||||
DMGridData *a, *b;
|
||||
|
||||
if (drawSmooth) {
|
||||
glShadeModel(GL_SMOOTH);
|
||||
for (y=0; y<gridFaces; y++) {
|
||||
for (y = 0; y < gridFaces; y++) {
|
||||
glBegin(GL_QUAD_STRIP);
|
||||
for (x=0; x<gridFaces; x++) {
|
||||
a = &faceGridData[(y+0)*gridSize + x];
|
||||
b = &faceGridData[(y+1)*gridSize + x];
|
||||
for (x = 0; x < gridFaces; x++) {
|
||||
a = &faceGridData[(y + 0) * gridSize + x];
|
||||
b = &faceGridData[(y + 1) * gridSize + x];
|
||||
|
||||
if (tf) glTexCoord2fv(tf->uv[0]);
|
||||
if (cp) glColor3ub(cp[3], cp[2], cp[1]);
|
||||
@@ -2076,14 +2076,14 @@ static void ccgDM_drawFacesTex_common(DerivedMesh *dm,
|
||||
glNormal3fv(b->no);
|
||||
glVertex3fv(b->co);
|
||||
|
||||
if (x != gridFaces-1) {
|
||||
if (x != gridFaces - 1) {
|
||||
if (tf) tf++;
|
||||
if (cp) cp += 16;
|
||||
}
|
||||
}
|
||||
|
||||
a = &faceGridData[(y+0)*gridSize + x];
|
||||
b = &faceGridData[(y+1)*gridSize + x];
|
||||
a = &faceGridData[(y + 0) * gridSize + x];
|
||||
b = &faceGridData[(y + 1) * gridSize + x];
|
||||
|
||||
if (tf) glTexCoord2fv(tf->uv[3]);
|
||||
if (cp) glColor3ub(cp[15], cp[14], cp[13]);
|
||||
@@ -2104,12 +2104,12 @@ static void ccgDM_drawFacesTex_common(DerivedMesh *dm,
|
||||
else {
|
||||
glShadeModel(GL_FLAT);
|
||||
glBegin(GL_QUADS);
|
||||
for (y=0; y<gridFaces; y++) {
|
||||
for (x=0; x<gridFaces; x++) {
|
||||
float *a_co = faceGridData[(y+0)*gridSize + x].co;
|
||||
float *b_co = faceGridData[(y+0)*gridSize + x + 1].co;
|
||||
float *c_co = faceGridData[(y+1)*gridSize + x + 1].co;
|
||||
float *d_co = faceGridData[(y+1)*gridSize + x].co;
|
||||
for (y = 0; y < gridFaces; y++) {
|
||||
for (x = 0; x < gridFaces; x++) {
|
||||
float *a_co = faceGridData[(y + 0) * gridSize + x].co;
|
||||
float *b_co = faceGridData[(y + 0) * gridSize + x + 1].co;
|
||||
float *c_co = faceGridData[(y + 1) * gridSize + x + 1].co;
|
||||
float *d_co = faceGridData[(y + 1) * gridSize + x].co;
|
||||
|
||||
ccgDM_glNormalFast(a_co, b_co, c_co, d_co);
|
||||
|
||||
@@ -2140,17 +2140,17 @@ static void ccgDM_drawFacesTex_common(DerivedMesh *dm,
|
||||
}
|
||||
|
||||
static void ccgDM_drawFacesTex(DerivedMesh *dm,
|
||||
DMSetDrawOptionsTex setDrawOptions,
|
||||
DMCompareDrawOptions compareDrawOptions,
|
||||
void *userData)
|
||||
DMSetDrawOptionsTex setDrawOptions,
|
||||
DMCompareDrawOptions compareDrawOptions,
|
||||
void *userData)
|
||||
{
|
||||
ccgDM_drawFacesTex_common(dm, setDrawOptions, NULL, compareDrawOptions, userData);
|
||||
}
|
||||
|
||||
static void ccgDM_drawMappedFacesTex(DerivedMesh *dm,
|
||||
DMSetDrawOptions setDrawOptions,
|
||||
DMCompareDrawOptions compareDrawOptions,
|
||||
void *userData)
|
||||
DMSetDrawOptions setDrawOptions,
|
||||
DMCompareDrawOptions compareDrawOptions,
|
||||
void *userData)
|
||||
{
|
||||
ccgDM_drawFacesTex_common(dm, NULL, setDrawOptions, compareDrawOptions, userData);
|
||||
}
|
||||
@@ -2165,7 +2165,7 @@ static void ccgDM_drawUVEdges(DerivedMesh *dm)
|
||||
if (tf) {
|
||||
glBegin(GL_LINES);
|
||||
for (i = 0; i < dm->numTessFaceData; i++, mf++, tf++) {
|
||||
if (!(mf->flag&ME_HIDE)) {
|
||||
if (!(mf->flag & ME_HIDE)) {
|
||||
glVertex2fv(tf->uv[0]);
|
||||
glVertex2fv(tf->uv[1]);
|
||||
|
||||
@@ -2190,14 +2190,14 @@ static void ccgDM_drawUVEdges(DerivedMesh *dm)
|
||||
}
|
||||
|
||||
static void ccgDM_drawMappedFaces(DerivedMesh *dm,
|
||||
DMSetDrawOptions setDrawOptions,
|
||||
DMSetMaterial setMaterial,
|
||||
DMCompareDrawOptions compareDrawOptions,
|
||||
void *userData, DMDrawFlag flag)
|
||||
DMSetDrawOptions setDrawOptions,
|
||||
DMSetMaterial setMaterial,
|
||||
DMCompareDrawOptions compareDrawOptions,
|
||||
void *userData, DMDrawFlag flag)
|
||||
{
|
||||
CCGDerivedMesh *ccgdm = (CCGDerivedMesh*) dm;
|
||||
CCGDerivedMesh *ccgdm = (CCGDerivedMesh *) dm;
|
||||
CCGSubSurf *ss = ccgdm->ss;
|
||||
MCol *mcol= NULL;
|
||||
MCol *mcol = NULL;
|
||||
int i, gridSize = ccgSubSurf_getGridSize(ss);
|
||||
DMFlagMat *faceFlags = ccgdm->faceFlags;
|
||||
int useColors = flag & DM_DRAW_USE_COLORS;
|
||||
@@ -2218,7 +2218,7 @@ static void ccgDM_drawMappedFaces(DerivedMesh *dm,
|
||||
int S, x, y, numVerts = ccgSubSurf_getFaceNumVerts(f);
|
||||
int drawSmooth, index = ccgDM_getFaceMapIndex(ss, f);
|
||||
int origIndex;
|
||||
unsigned char *cp= NULL;
|
||||
unsigned char *cp = NULL;
|
||||
|
||||
origIndex = GET_INT_FROM_POINTER(ccgSubSurf_getFaceFaceHandle(f));
|
||||
|
||||
@@ -2227,37 +2227,37 @@ static void ccgDM_drawMappedFaces(DerivedMesh *dm,
|
||||
else drawSmooth = 1;
|
||||
|
||||
if (mcol) {
|
||||
cp= (unsigned char*)mcol;
|
||||
mcol += gridFaces*gridFaces*numVerts*4;
|
||||
cp = (unsigned char *)mcol;
|
||||
mcol += gridFaces * gridFaces * numVerts * 4;
|
||||
}
|
||||
|
||||
{
|
||||
DMDrawOption draw_option= DM_DRAW_OPTION_NORMAL;
|
||||
DMDrawOption draw_option = DM_DRAW_OPTION_NORMAL;
|
||||
|
||||
if (index == ORIGINDEX_NONE)
|
||||
draw_option= setMaterial(faceFlags ? faceFlags[origIndex].mat_nr + 1: 1, NULL); /* XXX, no faceFlags no material */
|
||||
draw_option = setMaterial(faceFlags ? faceFlags[origIndex].mat_nr + 1 : 1, NULL); /* XXX, no faceFlags no material */
|
||||
else if (setDrawOptions)
|
||||
draw_option= setDrawOptions(userData, index);
|
||||
draw_option = setDrawOptions(userData, index);
|
||||
|
||||
if (draw_option != DM_DRAW_OPTION_SKIP) {
|
||||
if (draw_option == DM_DRAW_OPTION_STIPPLE) {
|
||||
glEnable(GL_POLYGON_STIPPLE);
|
||||
glPolygonStipple(stipple_quarttone);
|
||||
glEnable(GL_POLYGON_STIPPLE);
|
||||
glPolygonStipple(stipple_quarttone);
|
||||
}
|
||||
|
||||
/* no need to set shading mode to flat because
|
||||
* normals are already used to change shading */
|
||||
glShadeModel(GL_SMOOTH);
|
||||
|
||||
for (S=0; S<numVerts; S++) {
|
||||
for (S = 0; S < numVerts; S++) {
|
||||
DMGridData *faceGridData = ccgSubSurf_getFaceGridDataArray(ss, f, S);
|
||||
if (drawSmooth) {
|
||||
for (y=0; y<gridFaces; y++) {
|
||||
for (y = 0; y < gridFaces; y++) {
|
||||
DMGridData *a, *b;
|
||||
glBegin(GL_QUAD_STRIP);
|
||||
for (x=0; x<gridFaces; x++) {
|
||||
a = &faceGridData[(y+0)*gridSize + x];
|
||||
b = &faceGridData[(y+1)*gridSize + x];
|
||||
for (x = 0; x < gridFaces; x++) {
|
||||
a = &faceGridData[(y + 0) * gridSize + x];
|
||||
b = &faceGridData[(y + 1) * gridSize + x];
|
||||
|
||||
if (cp) glColor3ub(cp[3], cp[2], cp[1]);
|
||||
glNormal3fv(a->no);
|
||||
@@ -2266,13 +2266,13 @@ static void ccgDM_drawMappedFaces(DerivedMesh *dm,
|
||||
glNormal3fv(b->no);
|
||||
glVertex3fv(b->co);
|
||||
|
||||
if (x != gridFaces-1) {
|
||||
if (x != gridFaces - 1) {
|
||||
if (cp) cp += 16;
|
||||
}
|
||||
}
|
||||
|
||||
a = &faceGridData[(y+0)*gridSize + x];
|
||||
b = &faceGridData[(y+1)*gridSize + x];
|
||||
a = &faceGridData[(y + 0) * gridSize + x];
|
||||
b = &faceGridData[(y + 1) * gridSize + x];
|
||||
|
||||
if (cp) glColor3ub(cp[15], cp[14], cp[13]);
|
||||
glNormal3fv(a->no);
|
||||
@@ -2288,12 +2288,12 @@ static void ccgDM_drawMappedFaces(DerivedMesh *dm,
|
||||
}
|
||||
else {
|
||||
glBegin(GL_QUADS);
|
||||
for (y=0; y<gridFaces; y++) {
|
||||
for (x=0; x<gridFaces; x++) {
|
||||
float *a = faceGridData[(y+0)*gridSize + x].co;
|
||||
float *b = faceGridData[(y+0)*gridSize + x + 1].co;
|
||||
float *c = faceGridData[(y+1)*gridSize + x + 1].co;
|
||||
float *d = faceGridData[(y+1)*gridSize + x].co;
|
||||
for (y = 0; y < gridFaces; y++) {
|
||||
for (x = 0; x < gridFaces; x++) {
|
||||
float *a = faceGridData[(y + 0) * gridSize + x].co;
|
||||
float *b = faceGridData[(y + 0) * gridSize + x + 1].co;
|
||||
float *c = faceGridData[(y + 1) * gridSize + x + 1].co;
|
||||
float *d = faceGridData[(y + 1) * gridSize + x].co;
|
||||
|
||||
ccgDM_glNormalFast(a, b, c, d);
|
||||
|
||||
@@ -2320,10 +2320,10 @@ static void ccgDM_drawMappedFaces(DerivedMesh *dm,
|
||||
}
|
||||
|
||||
static void ccgDM_drawMappedEdges(DerivedMesh *dm,
|
||||
DMSetDrawOptions setDrawOptions,
|
||||
void *userData)
|
||||
DMSetDrawOptions setDrawOptions,
|
||||
void *userData)
|
||||
{
|
||||
CCGDerivedMesh *ccgdm = (CCGDerivedMesh*) dm;
|
||||
CCGDerivedMesh *ccgdm = (CCGDerivedMesh *) dm;
|
||||
CCGSubSurf *ss = ccgdm->ss;
|
||||
CCGEdgeIterator *ei = ccgSubSurf_getEdgeIterator(ss);
|
||||
int i, useAging, edgeSize = ccgSubSurf_getEdgeSize(ss);
|
||||
@@ -2336,15 +2336,15 @@ static void ccgDM_drawMappedEdges(DerivedMesh *dm,
|
||||
int index = ccgDM_getEdgeMapIndex(ss, e);
|
||||
|
||||
glBegin(GL_LINE_STRIP);
|
||||
if (index!=-1 && (!setDrawOptions || (setDrawOptions(userData, index) != DM_DRAW_OPTION_SKIP))) {
|
||||
if (useAging && !(G.f&G_BACKBUFSEL)) {
|
||||
int ageCol = 255-ccgSubSurf_getEdgeAge(ss, e)*4;
|
||||
glColor3ub(0, ageCol>0?ageCol:0, 0);
|
||||
if (index != -1 && (!setDrawOptions || (setDrawOptions(userData, index) != DM_DRAW_OPTION_SKIP))) {
|
||||
if (useAging && !(G.f & G_BACKBUFSEL)) {
|
||||
int ageCol = 255 - ccgSubSurf_getEdgeAge(ss, e) * 4;
|
||||
glColor3ub(0, ageCol > 0 ? ageCol : 0, 0);
|
||||
}
|
||||
|
||||
for (i=0; i<edgeSize-1; i++) {
|
||||
for (i = 0; i < edgeSize - 1; i++) {
|
||||
glVertex3fv(edgeData[i].co);
|
||||
glVertex3fv(edgeData[i+1].co);
|
||||
glVertex3fv(edgeData[i + 1].co);
|
||||
}
|
||||
}
|
||||
glEnd();
|
||||
@@ -2354,11 +2354,11 @@ static void ccgDM_drawMappedEdges(DerivedMesh *dm,
|
||||
}
|
||||
|
||||
static void ccgDM_drawMappedEdgesInterp(DerivedMesh *dm,
|
||||
DMSetDrawOptions setDrawOptions,
|
||||
DMSetDrawInterpOptions setDrawInterpOptions,
|
||||
void *userData)
|
||||
DMSetDrawOptions setDrawOptions,
|
||||
DMSetDrawInterpOptions setDrawInterpOptions,
|
||||
void *userData)
|
||||
{
|
||||
CCGDerivedMesh *ccgdm = (CCGDerivedMesh*) dm;
|
||||
CCGDerivedMesh *ccgdm = (CCGDerivedMesh *) dm;
|
||||
CCGSubSurf *ss = ccgdm->ss;
|
||||
CCGEdgeIterator *ei = ccgSubSurf_getEdgeIterator(ss);
|
||||
int i, useAging, edgeSize = ccgSubSurf_getEdgeSize(ss);
|
||||
@@ -2371,13 +2371,13 @@ static void ccgDM_drawMappedEdgesInterp(DerivedMesh *dm,
|
||||
int index = ccgDM_getEdgeMapIndex(ss, e);
|
||||
|
||||
glBegin(GL_LINE_STRIP);
|
||||
if (index!=-1 && (!setDrawOptions || (setDrawOptions(userData, index) != DM_DRAW_OPTION_SKIP))) {
|
||||
for (i=0; i<edgeSize; i++) {
|
||||
setDrawInterpOptions(userData, index, (float) i/(edgeSize-1));
|
||||
if (index != -1 && (!setDrawOptions || (setDrawOptions(userData, index) != DM_DRAW_OPTION_SKIP))) {
|
||||
for (i = 0; i < edgeSize; i++) {
|
||||
setDrawInterpOptions(userData, index, (float) i / (edgeSize - 1));
|
||||
|
||||
if (useAging && !(G.f&G_BACKBUFSEL)) {
|
||||
int ageCol = 255-ccgSubSurf_getEdgeAge(ss, e)*4;
|
||||
glColor3ub(0, ageCol>0?ageCol:0, 0);
|
||||
if (useAging && !(G.f & G_BACKBUFSEL)) {
|
||||
int ageCol = 255 - ccgSubSurf_getEdgeAge(ss, e) * 4;
|
||||
glColor3ub(0, ageCol > 0 ? ageCol : 0, 0);
|
||||
}
|
||||
|
||||
glVertex3fv(edgeData[i].co);
|
||||
@@ -2390,11 +2390,11 @@ static void ccgDM_drawMappedEdgesInterp(DerivedMesh *dm,
|
||||
}
|
||||
|
||||
static void ccgDM_foreachMappedFaceCenter(
|
||||
DerivedMesh *dm,
|
||||
void (*func)(void *userData, int index, const float co[3], const float no[3]),
|
||||
void *userData)
|
||||
DerivedMesh *dm,
|
||||
void (*func)(void *userData, int index, const float co[3], const float no[3]),
|
||||
void *userData)
|
||||
{
|
||||
CCGDerivedMesh *ccgdm = (CCGDerivedMesh*) dm;
|
||||
CCGDerivedMesh *ccgdm = (CCGDerivedMesh *) dm;
|
||||
CCGSubSurf *ss = ccgdm->ss;
|
||||
CCGFaceIterator *fi = ccgSubSurf_getFaceIterator(ss);
|
||||
|
||||
@@ -2402,8 +2402,8 @@ static void ccgDM_foreachMappedFaceCenter(
|
||||
CCGFace *f = ccgFaceIterator_getCurrent(fi);
|
||||
int index = ccgDM_getFaceMapIndex(ss, f);
|
||||
|
||||
if (index!=-1) {
|
||||
/* Face center data normal isn't updated atm. */
|
||||
if (index != -1) {
|
||||
/* Face center data normal isn't updated atm. */
|
||||
DMGridData *vd = ccgSubSurf_getFaceGridData(ss, f, 0, 0, 0);
|
||||
|
||||
func(userData, index, vd->co, vd->no);
|
||||
@@ -2415,14 +2415,14 @@ static void ccgDM_foreachMappedFaceCenter(
|
||||
|
||||
static void ccgDM_release(DerivedMesh *dm)
|
||||
{
|
||||
CCGDerivedMesh *ccgdm = (CCGDerivedMesh*) dm;
|
||||
CCGDerivedMesh *ccgdm = (CCGDerivedMesh *) dm;
|
||||
|
||||
if (DM_release(dm)) {
|
||||
/* Before freeing, need to update the displacement map */
|
||||
if (ccgdm->multires.modified_flags) {
|
||||
/* Check that mmd still exists */
|
||||
if (!ccgdm->multires.local_mmd &&
|
||||
BLI_findindex(&ccgdm->multires.ob->modifiers, ccgdm->multires.mmd) < 0)
|
||||
BLI_findindex(&ccgdm->multires.ob->modifiers, ccgdm->multires.mmd) < 0)
|
||||
ccgdm->multires.mmd = NULL;
|
||||
|
||||
if (ccgdm->multires.mmd) {
|
||||
@@ -2473,23 +2473,23 @@ static void ccg_loops_to_corners(CustomData *fdata, CustomData *ldata,
|
||||
MLoopUV *mloopuv;
|
||||
int i, j;
|
||||
|
||||
for (i=0; i < numTex; i++) {
|
||||
for (i = 0; i < numTex; i++) {
|
||||
texface = CustomData_get_n(fdata, CD_MTFACE, findex, i);
|
||||
texpoly = CustomData_get_n(pdata, CD_MTEXPOLY, polyindex, i);
|
||||
|
||||
ME_MTEXFACE_CPY(texface, texpoly);
|
||||
|
||||
mloopuv = CustomData_get_n(ldata, CD_MLOOPUV, loopstart, i);
|
||||
for (j=0; j<4; j++, mloopuv++) {
|
||||
for (j = 0; j < 4; j++, mloopuv++) {
|
||||
copy_v2_v2(texface->uv[j], mloopuv->uv);
|
||||
}
|
||||
}
|
||||
|
||||
for (i=0; i < numCol; i++) {
|
||||
for (i = 0; i < numCol; i++) {
|
||||
mloopcol = CustomData_get_n(ldata, CD_MLOOPCOL, loopstart, i);
|
||||
mcol = CustomData_get_n(fdata, CD_MCOL, findex, i);
|
||||
|
||||
for (j=0; j<4; j++, mloopcol++) {
|
||||
for (j = 0; j < 4; j++, mloopcol++) {
|
||||
MESH_MLOOPCOL_TO_MCOL(mloopcol, &mcol[j]);
|
||||
}
|
||||
}
|
||||
@@ -2498,7 +2498,7 @@ static void ccg_loops_to_corners(CustomData *fdata, CustomData *ldata,
|
||||
mloopcol = CustomData_get(ldata, loopstart, CD_PREVIEW_MLOOPCOL);
|
||||
mcol = CustomData_get(fdata, findex, CD_PREVIEW_MCOL);
|
||||
|
||||
for (j=0; j<4; j++, mloopcol++) {
|
||||
for (j = 0; j < 4; j++, mloopcol++) {
|
||||
MESH_MLOOPCOL_TO_MCOL(mloopcol, &mcol[j]);
|
||||
}
|
||||
}
|
||||
@@ -2508,7 +2508,7 @@ static void ccg_loops_to_corners(CustomData *fdata, CustomData *ldata,
|
||||
OrigSpaceLoop *lof;
|
||||
|
||||
lof = CustomData_get(ldata, loopstart, CD_ORIGSPACE_MLOOP);
|
||||
for (j=0; j<4; j++, lof++) {
|
||||
for (j = 0; j < 4; j++, lof++) {
|
||||
copy_v2_v2(of->uv[j], lof->uv);
|
||||
}
|
||||
}
|
||||
@@ -2518,8 +2518,8 @@ static void *ccgDM_get_vert_data_layer(DerivedMesh *dm, int type)
|
||||
{
|
||||
if (type == CD_ORIGINDEX) {
|
||||
/* create origindex on demand to save memory */
|
||||
CCGDerivedMesh *ccgdm= (CCGDerivedMesh*)dm;
|
||||
CCGSubSurf *ss= ccgdm->ss;
|
||||
CCGDerivedMesh *ccgdm = (CCGDerivedMesh *)dm;
|
||||
CCGSubSurf *ss = ccgdm->ss;
|
||||
int *origindex;
|
||||
int a, index, totnone, totorig;
|
||||
|
||||
@@ -2530,16 +2530,16 @@ static void *ccgDM_get_vert_data_layer(DerivedMesh *dm, int type)
|
||||
}
|
||||
|
||||
DM_add_vert_layer(dm, CD_ORIGINDEX, CD_CALLOC, NULL);
|
||||
origindex= DM_get_vert_data_layer(dm, CD_ORIGINDEX);
|
||||
origindex = DM_get_vert_data_layer(dm, CD_ORIGINDEX);
|
||||
|
||||
totorig = ccgSubSurf_getNumVerts(ss);
|
||||
totnone= dm->numVertData - totorig;
|
||||
totnone = dm->numVertData - totorig;
|
||||
|
||||
/* original vertices are at the end */
|
||||
for (a=0; a<totnone; a++)
|
||||
origindex[a]= ORIGINDEX_NONE;
|
||||
for (a = 0; a < totnone; a++)
|
||||
origindex[a] = ORIGINDEX_NONE;
|
||||
|
||||
for (index=0; index<totorig; index++, a++) {
|
||||
for (index = 0; index < totorig; index++, a++) {
|
||||
CCGVert *v = ccgdm->vertMap[index].vert;
|
||||
origindex[a] = ccgDM_getVertMapIndex(ccgdm->ss, v);
|
||||
}
|
||||
@@ -2554,11 +2554,11 @@ static void *ccgDM_get_edge_data_layer(DerivedMesh *dm, int type)
|
||||
{
|
||||
if (type == CD_ORIGINDEX) {
|
||||
/* create origindex on demand to save memory */
|
||||
CCGDerivedMesh *ccgdm= (CCGDerivedMesh*)dm;
|
||||
CCGSubSurf *ss= ccgdm->ss;
|
||||
CCGDerivedMesh *ccgdm = (CCGDerivedMesh *)dm;
|
||||
CCGSubSurf *ss = ccgdm->ss;
|
||||
int *origindex;
|
||||
int a, i, index, totnone, totorig, totedge;
|
||||
int edgeSize= ccgSubSurf_getEdgeSize(ss);
|
||||
int edgeSize = ccgSubSurf_getEdgeSize(ss);
|
||||
|
||||
/* Avoid re-creation if the layer exists already */
|
||||
origindex = DM_get_edge_data_layer(dm, CD_ORIGINDEX);
|
||||
@@ -2567,22 +2567,22 @@ static void *ccgDM_get_edge_data_layer(DerivedMesh *dm, int type)
|
||||
}
|
||||
|
||||
DM_add_edge_layer(dm, CD_ORIGINDEX, CD_CALLOC, NULL);
|
||||
origindex= DM_get_edge_data_layer(dm, CD_ORIGINDEX);
|
||||
origindex = DM_get_edge_data_layer(dm, CD_ORIGINDEX);
|
||||
|
||||
totedge= ccgSubSurf_getNumEdges(ss);
|
||||
totorig= totedge*(edgeSize - 1);
|
||||
totnone= dm->numEdgeData - totorig;
|
||||
totedge = ccgSubSurf_getNumEdges(ss);
|
||||
totorig = totedge * (edgeSize - 1);
|
||||
totnone = dm->numEdgeData - totorig;
|
||||
|
||||
/* original edges are at the end */
|
||||
for (a=0; a<totnone; a++)
|
||||
origindex[a]= ORIGINDEX_NONE;
|
||||
for (a = 0; a < totnone; a++)
|
||||
origindex[a] = ORIGINDEX_NONE;
|
||||
|
||||
for (index=0; index<totedge; index++) {
|
||||
CCGEdge *e= ccgdm->edgeMap[index].edge;
|
||||
int mapIndex= ccgDM_getEdgeMapIndex(ss, e);
|
||||
for (index = 0; index < totedge; index++) {
|
||||
CCGEdge *e = ccgdm->edgeMap[index].edge;
|
||||
int mapIndex = ccgDM_getEdgeMapIndex(ss, e);
|
||||
|
||||
for (i = 0; i < edgeSize - 1; i++, a++)
|
||||
origindex[a]= mapIndex;
|
||||
origindex[a] = mapIndex;
|
||||
}
|
||||
|
||||
return origindex;
|
||||
@@ -2595,8 +2595,8 @@ static void *ccgDM_get_tessface_data_layer(DerivedMesh *dm, int type)
|
||||
{
|
||||
if (type == CD_ORIGINDEX) {
|
||||
/* create origindex on demand to save memory */
|
||||
CCGDerivedMesh *ccgdm= (CCGDerivedMesh*)dm;
|
||||
CCGSubSurf *ss= ccgdm->ss;
|
||||
CCGDerivedMesh *ccgdm = (CCGDerivedMesh *)dm;
|
||||
CCGSubSurf *ss = ccgdm->ss;
|
||||
int *origindex;
|
||||
int a, i, index, totface;
|
||||
int gridFaces = ccgSubSurf_getGridSize(ss) - 1;
|
||||
@@ -2608,17 +2608,17 @@ static void *ccgDM_get_tessface_data_layer(DerivedMesh *dm, int type)
|
||||
}
|
||||
|
||||
DM_add_tessface_layer(dm, CD_ORIGINDEX, CD_CALLOC, NULL);
|
||||
origindex= DM_get_tessface_data_layer(dm, CD_ORIGINDEX);
|
||||
origindex = DM_get_tessface_data_layer(dm, CD_ORIGINDEX);
|
||||
|
||||
totface= ccgSubSurf_getNumFaces(ss);
|
||||
totface = ccgSubSurf_getNumFaces(ss);
|
||||
|
||||
for (a=0, index=0; index<totface; index++) {
|
||||
for (a = 0, index = 0; index < totface; index++) {
|
||||
CCGFace *f = ccgdm->faceMap[index].face;
|
||||
int numVerts = ccgSubSurf_getFaceNumVerts(f);
|
||||
int mapIndex = ccgDM_getFaceMapIndex(ss, f);
|
||||
|
||||
for (i=0; i<gridFaces*gridFaces*numVerts; i++, a++)
|
||||
origindex[a]= mapIndex;
|
||||
for (i = 0; i < gridFaces * gridFaces * numVerts; i++, a++)
|
||||
origindex[a] = mapIndex;
|
||||
}
|
||||
|
||||
return origindex;
|
||||
@@ -2659,13 +2659,13 @@ static void *ccgDM_get_tessface_data(DerivedMesh *dm, int index, int type)
|
||||
|
||||
static int ccgDM_getNumGrids(DerivedMesh *dm)
|
||||
{
|
||||
CCGDerivedMesh *ccgdm= (CCGDerivedMesh*)dm;
|
||||
CCGDerivedMesh *ccgdm = (CCGDerivedMesh *)dm;
|
||||
int index, numFaces, numGrids;
|
||||
|
||||
numFaces= ccgSubSurf_getNumFaces(ccgdm->ss);
|
||||
numGrids= 0;
|
||||
numFaces = ccgSubSurf_getNumFaces(ccgdm->ss);
|
||||
numGrids = 0;
|
||||
|
||||
for (index=0; index<numFaces; index++) {
|
||||
for (index = 0; index < numFaces; index++) {
|
||||
CCGFace *f = ccgdm->faceMap[index].face;
|
||||
numGrids += ccgSubSurf_getFaceNumVerts(f);
|
||||
}
|
||||
@@ -2675,7 +2675,7 @@ static int ccgDM_getNumGrids(DerivedMesh *dm)
|
||||
|
||||
static int ccgDM_getGridSize(DerivedMesh *dm)
|
||||
{
|
||||
CCGDerivedMesh *ccgdm= (CCGDerivedMesh*)dm;
|
||||
CCGDerivedMesh *ccgdm = (CCGDerivedMesh *)dm;
|
||||
return ccgSubSurf_getGridSize(ccgdm->ss);
|
||||
}
|
||||
|
||||
@@ -2683,7 +2683,7 @@ static int ccgdm_adjacent_grid(int *gridOffset, CCGFace *f, int S, int offset)
|
||||
{
|
||||
CCGFace *adjf;
|
||||
CCGEdge *e;
|
||||
int i, j= 0, numFaces, fIndex, numEdges= 0;
|
||||
int i, j = 0, numFaces, fIndex, numEdges = 0;
|
||||
|
||||
e = ccgSubSurf_getFaceEdge(f, S);
|
||||
numFaces = ccgSubSurf_getEdgeNumFaces(e);
|
||||
@@ -2710,13 +2710,13 @@ static int ccgdm_adjacent_grid(int *gridOffset, CCGFace *f, int S, int offset)
|
||||
|
||||
fIndex = GET_INT_FROM_POINTER(ccgSubSurf_getFaceFaceHandle(adjf));
|
||||
|
||||
return gridOffset[fIndex] + (j + offset)%numEdges;
|
||||
return gridOffset[fIndex] + (j + offset) % numEdges;
|
||||
}
|
||||
|
||||
static void ccgdm_create_grids(DerivedMesh *dm)
|
||||
{
|
||||
CCGDerivedMesh *ccgdm= (CCGDerivedMesh*)dm;
|
||||
CCGSubSurf *ss= ccgdm->ss;
|
||||
CCGDerivedMesh *ccgdm = (CCGDerivedMesh *)dm;
|
||||
CCGSubSurf *ss = ccgdm->ss;
|
||||
DMGridData **gridData;
|
||||
DMGridAdjacency *gridAdjacency, *adj;
|
||||
DMFlagMat *gridFlagMats;
|
||||
@@ -2732,7 +2732,7 @@ static void ccgdm_create_grids(DerivedMesh *dm)
|
||||
/*gridSize = ccgDM_getGridSize(dm);*/ /*UNUSED*/
|
||||
|
||||
/* compute offset into grid array for each face */
|
||||
gridOffset = MEM_mallocN(sizeof(int)*numFaces, "ccgdm.gridOffset");
|
||||
gridOffset = MEM_mallocN(sizeof(int) * numFaces, "ccgdm.gridOffset");
|
||||
|
||||
for (gIndex = 0, index = 0; index < numFaces; index++) {
|
||||
CCGFace *f = ccgdm->faceMap[index].face;
|
||||
@@ -2743,12 +2743,12 @@ static void ccgdm_create_grids(DerivedMesh *dm)
|
||||
}
|
||||
|
||||
/* compute grid data */
|
||||
gridData = MEM_mallocN(sizeof(DMGridData*)*numGrids, "ccgdm.gridData");
|
||||
gridAdjacency = MEM_mallocN(sizeof(DMGridAdjacency)*numGrids, "ccgdm.gridAdjacency");
|
||||
gridFaces = MEM_mallocN(sizeof(CCGFace*)*numGrids, "ccgdm.gridFaces");
|
||||
gridFlagMats = MEM_mallocN(sizeof(DMFlagMat)*numGrids, "ccgdm.gridFlagMats");
|
||||
gridData = MEM_mallocN(sizeof(DMGridData *) * numGrids, "ccgdm.gridData");
|
||||
gridAdjacency = MEM_mallocN(sizeof(DMGridAdjacency) * numGrids, "ccgdm.gridAdjacency");
|
||||
gridFaces = MEM_mallocN(sizeof(CCGFace *) * numGrids, "ccgdm.gridFaces");
|
||||
gridFlagMats = MEM_mallocN(sizeof(DMFlagMat) * numGrids, "ccgdm.gridFlagMats");
|
||||
|
||||
ccgdm->gridHidden = MEM_callocN(sizeof(BLI_bitmap)*numGrids, "ccgdm.gridHidden");
|
||||
ccgdm->gridHidden = MEM_callocN(sizeof(BLI_bitmap) * numGrids, "ccgdm.gridHidden");
|
||||
|
||||
for (gIndex = 0, index = 0; index < numFaces; index++) {
|
||||
CCGFace *f = ccgdm->faceMap[index].face;
|
||||
@@ -2784,7 +2784,7 @@ static void ccgdm_create_grids(DerivedMesh *dm)
|
||||
|
||||
static DMGridData **ccgDM_getGridData(DerivedMesh *dm)
|
||||
{
|
||||
CCGDerivedMesh *ccgdm= (CCGDerivedMesh*)dm;
|
||||
CCGDerivedMesh *ccgdm = (CCGDerivedMesh *)dm;
|
||||
|
||||
ccgdm_create_grids(dm);
|
||||
return ccgdm->gridData;
|
||||
@@ -2792,7 +2792,7 @@ static DMGridData **ccgDM_getGridData(DerivedMesh *dm)
|
||||
|
||||
static DMGridAdjacency *ccgDM_getGridAdjacency(DerivedMesh *dm)
|
||||
{
|
||||
CCGDerivedMesh *ccgdm= (CCGDerivedMesh*)dm;
|
||||
CCGDerivedMesh *ccgdm = (CCGDerivedMesh *)dm;
|
||||
|
||||
ccgdm_create_grids(dm);
|
||||
return ccgdm->gridAdjacency;
|
||||
@@ -2800,7 +2800,7 @@ static DMGridAdjacency *ccgDM_getGridAdjacency(DerivedMesh *dm)
|
||||
|
||||
static int *ccgDM_getGridOffset(DerivedMesh *dm)
|
||||
{
|
||||
CCGDerivedMesh *ccgdm= (CCGDerivedMesh*)dm;
|
||||
CCGDerivedMesh *ccgdm = (CCGDerivedMesh *)dm;
|
||||
|
||||
ccgdm_create_grids(dm);
|
||||
return ccgdm->gridOffset;
|
||||
@@ -2808,7 +2808,7 @@ static int *ccgDM_getGridOffset(DerivedMesh *dm)
|
||||
|
||||
static DMFlagMat *ccgDM_getGridFlagMats(DerivedMesh *dm)
|
||||
{
|
||||
CCGDerivedMesh *ccgdm= (CCGDerivedMesh*)dm;
|
||||
CCGDerivedMesh *ccgdm = (CCGDerivedMesh *)dm;
|
||||
|
||||
ccgdm_create_grids(dm);
|
||||
return ccgdm->gridFlagMats;
|
||||
@@ -2816,7 +2816,7 @@ static DMFlagMat *ccgDM_getGridFlagMats(DerivedMesh *dm)
|
||||
|
||||
static BLI_bitmap *ccgDM_getGridHidden(DerivedMesh *dm)
|
||||
{
|
||||
CCGDerivedMesh *ccgdm= (CCGDerivedMesh*)dm;
|
||||
CCGDerivedMesh *ccgdm = (CCGDerivedMesh *)dm;
|
||||
|
||||
ccgdm_create_grids(dm);
|
||||
return ccgdm->gridHidden;
|
||||
@@ -2824,10 +2824,10 @@ static BLI_bitmap *ccgDM_getGridHidden(DerivedMesh *dm)
|
||||
|
||||
static const MeshElemMap *ccgDM_getPolyMap(Object *ob, DerivedMesh *dm)
|
||||
{
|
||||
CCGDerivedMesh *ccgdm= (CCGDerivedMesh*)dm;
|
||||
CCGDerivedMesh *ccgdm = (CCGDerivedMesh *)dm;
|
||||
|
||||
if (!ccgdm->multires.mmd && !ccgdm->pmap && ob->type == OB_MESH) {
|
||||
Mesh *me= ob->data;
|
||||
Mesh *me = ob->data;
|
||||
|
||||
create_vert_poly_map(&ccgdm->pmap, &ccgdm->pmap_mem,
|
||||
me->mpoly, me->mloop,
|
||||
@@ -2839,7 +2839,7 @@ static const MeshElemMap *ccgDM_getPolyMap(Object *ob, DerivedMesh *dm)
|
||||
|
||||
static int ccgDM_use_grid_pbvh(CCGDerivedMesh *ccgdm)
|
||||
{
|
||||
MultiresModifierData *mmd= ccgdm->multires.mmd;
|
||||
MultiresModifierData *mmd = ccgdm->multires.mmd;
|
||||
|
||||
/* both of multires and subsurf modifiers are CCG, but
|
||||
* grids should only be used when sculpting on multires */
|
||||
@@ -2851,18 +2851,18 @@ static int ccgDM_use_grid_pbvh(CCGDerivedMesh *ccgdm)
|
||||
|
||||
static struct PBVH *ccgDM_getPBVH(Object *ob, DerivedMesh *dm)
|
||||
{
|
||||
CCGDerivedMesh *ccgdm= (CCGDerivedMesh*)dm;
|
||||
CCGDerivedMesh *ccgdm = (CCGDerivedMesh *)dm;
|
||||
int gridSize, numGrids, grid_pbvh;
|
||||
|
||||
if (!ob) {
|
||||
ccgdm->pbvh= NULL;
|
||||
ccgdm->pbvh = NULL;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (!ob->sculpt)
|
||||
return NULL;
|
||||
|
||||
grid_pbvh= ccgDM_use_grid_pbvh(ccgdm);
|
||||
grid_pbvh = ccgDM_use_grid_pbvh(ccgdm);
|
||||
|
||||
if (ob->sculpt->pbvh) {
|
||||
if (grid_pbvh) {
|
||||
@@ -2871,7 +2871,7 @@ static struct PBVH *ccgDM_getPBVH(Object *ob, DerivedMesh *dm)
|
||||
* when the ccgdm gets remade, the assumption is that the topology
|
||||
* does not change. */
|
||||
ccgdm_create_grids(dm);
|
||||
BLI_pbvh_grids_update(ob->sculpt->pbvh, ccgdm->gridData, ccgdm->gridAdjacency, (void**)ccgdm->gridFaces);
|
||||
BLI_pbvh_grids_update(ob->sculpt->pbvh, ccgdm->gridData, ccgdm->gridAdjacency, (void **)ccgdm->gridFaces);
|
||||
}
|
||||
|
||||
ccgdm->pbvh = ob->sculpt->pbvh;
|
||||
@@ -2889,16 +2889,16 @@ static struct PBVH *ccgDM_getPBVH(Object *ob, DerivedMesh *dm)
|
||||
gridSize = ccgDM_getGridSize(dm);
|
||||
numGrids = ccgDM_getNumGrids(dm);
|
||||
|
||||
ob->sculpt->pbvh= ccgdm->pbvh = BLI_pbvh_new();
|
||||
ob->sculpt->pbvh = ccgdm->pbvh = BLI_pbvh_new();
|
||||
BLI_pbvh_build_grids(ccgdm->pbvh, ccgdm->gridData, ccgdm->gridAdjacency,
|
||||
numGrids, gridSize, (void**)ccgdm->gridFaces, ccgdm->gridFlagMats, ccgdm->gridHidden);
|
||||
numGrids, gridSize, (void **)ccgdm->gridFaces, ccgdm->gridFlagMats, ccgdm->gridHidden);
|
||||
}
|
||||
else if (ob->type == OB_MESH) {
|
||||
Mesh *me= ob->data;
|
||||
ob->sculpt->pbvh= ccgdm->pbvh = BLI_pbvh_new();
|
||||
Mesh *me = ob->data;
|
||||
ob->sculpt->pbvh = ccgdm->pbvh = BLI_pbvh_new();
|
||||
BLI_assert(!(me->mface == NULL && me->mpoly != NULL)); /* BMESH ONLY complain if mpoly is valid but not mface */
|
||||
BLI_pbvh_build_mesh(ccgdm->pbvh, me->mface, me->mvert,
|
||||
me->totface, me->totvert);
|
||||
me->totface, me->totvert);
|
||||
}
|
||||
|
||||
return ccgdm->pbvh;
|
||||
@@ -2915,9 +2915,9 @@ static void ccgDM_calcNormals(DerivedMesh *UNUSED(dm))
|
||||
}
|
||||
|
||||
static CCGDerivedMesh *getCCGDerivedMesh(CCGSubSurf *ss,
|
||||
int drawInteriorEdges,
|
||||
int useSubsurfUv,
|
||||
DerivedMesh *dm)
|
||||
int drawInteriorEdges,
|
||||
int useSubsurfUv,
|
||||
DerivedMesh *dm)
|
||||
{
|
||||
CCGDerivedMesh *ccgdm = MEM_callocN(sizeof(*ccgdm), "ccgdm");
|
||||
CCGVertIterator *vi;
|
||||
@@ -2949,14 +2949,14 @@ static CCGDerivedMesh *getCCGDerivedMesh(CCGSubSurf *ss,
|
||||
MPoly *mpoly = NULL;
|
||||
|
||||
DM_from_template(&ccgdm->dm, dm, DM_TYPE_CCGDM,
|
||||
ccgSubSurf_getNumFinalVerts(ss),
|
||||
ccgSubSurf_getNumFinalEdges(ss),
|
||||
ccgSubSurf_getNumFinalFaces(ss),
|
||||
ccgSubSurf_getNumFinalFaces(ss)*4,
|
||||
ccgSubSurf_getNumFinalFaces(ss));
|
||||
ccgSubSurf_getNumFinalVerts(ss),
|
||||
ccgSubSurf_getNumFinalEdges(ss),
|
||||
ccgSubSurf_getNumFinalFaces(ss),
|
||||
ccgSubSurf_getNumFinalFaces(ss) * 4,
|
||||
ccgSubSurf_getNumFinalFaces(ss));
|
||||
|
||||
CustomData_free_layer_active(&ccgdm->dm.polyData, CD_NORMAL,
|
||||
ccgdm->dm.numPolyData);
|
||||
ccgdm->dm.numPolyData);
|
||||
|
||||
numTex = CustomData_number_of_layers(&ccgdm->dm.loopData, CD_MLOOPUV);
|
||||
numCol = CustomData_number_of_layers(&ccgdm->dm.loopData, CD_MLOOPCOL);
|
||||
@@ -2964,10 +2964,10 @@ static CCGDerivedMesh *getCCGDerivedMesh(CCGSubSurf *ss,
|
||||
hasOrigSpace = CustomData_has_layer(&ccgdm->dm.loopData, CD_ORIGSPACE_MLOOP);
|
||||
|
||||
if (
|
||||
(numTex && CustomData_number_of_layers(&ccgdm->dm.faceData, CD_MTFACE) != numTex) ||
|
||||
(numCol && CustomData_number_of_layers(&ccgdm->dm.faceData, CD_MCOL) != numCol) ||
|
||||
(hasPCol && !CustomData_has_layer(&ccgdm->dm.faceData, CD_PREVIEW_MCOL)) ||
|
||||
(hasOrigSpace && !CustomData_has_layer(&ccgdm->dm.faceData, CD_ORIGSPACE)) )
|
||||
(numTex && CustomData_number_of_layers(&ccgdm->dm.faceData, CD_MTFACE) != numTex) ||
|
||||
(numCol && CustomData_number_of_layers(&ccgdm->dm.faceData, CD_MCOL) != numCol) ||
|
||||
(hasPCol && !CustomData_has_layer(&ccgdm->dm.faceData, CD_PREVIEW_MCOL)) ||
|
||||
(hasOrigSpace && !CustomData_has_layer(&ccgdm->dm.faceData, CD_ORIGSPACE)) )
|
||||
{
|
||||
CustomData_from_bmeshpoly(&ccgdm->dm.faceData,
|
||||
&ccgdm->dm.polyData,
|
||||
@@ -3080,7 +3080,7 @@ static CCGDerivedMesh *getCCGDerivedMesh(CCGSubSurf *ss,
|
||||
}
|
||||
ccgFaceIterator_free(fi);
|
||||
|
||||
ccgdm->reverseFaceMap = MEM_callocN(sizeof(int)*ccgSubSurf_getNumFinalFaces(ss), "reverseFaceMap");
|
||||
ccgdm->reverseFaceMap = MEM_callocN(sizeof(int) * ccgSubSurf_getNumFinalFaces(ss), "reverseFaceMap");
|
||||
|
||||
edgeSize = ccgSubSurf_getEdgeSize(ss);
|
||||
gridSize = ccgSubSurf_getGridSize(ss);
|
||||
@@ -3102,8 +3102,8 @@ static CCGDerivedMesh *getCCGDerivedMesh(CCGSubSurf *ss,
|
||||
base_polyOrigIndex = CustomData_get_layer(&dm->polyData, CD_ORIGINDEX);
|
||||
|
||||
/*CDDM hack*/
|
||||
edgeFlags = ccgdm->edgeFlags = MEM_callocN(sizeof(short)*totedge, "edgeFlags");
|
||||
faceFlags = ccgdm->faceFlags = MEM_callocN(sizeof(DMFlagMat)*totface, "faceFlags");
|
||||
edgeFlags = ccgdm->edgeFlags = MEM_callocN(sizeof(short) * totedge, "edgeFlags");
|
||||
faceFlags = ccgdm->faceFlags = MEM_callocN(sizeof(DMFlagMat) * totface, "faceFlags");
|
||||
|
||||
vertOrigIndex = DM_get_vert_data_layer(&ccgdm->dm, CD_ORIGINDEX);
|
||||
/*edgeOrigIndex = DM_get_edge_data_layer(&ccgdm->dm, CD_ORIGINDEX);*/
|
||||
@@ -3128,7 +3128,7 @@ static CCGDerivedMesh *getCCGDerivedMesh(CCGSubSurf *ss,
|
||||
int numVerts = ccgSubSurf_getFaceNumVerts(f);
|
||||
int numFinalEdges = numVerts * (gridSideEdges + gridInternalEdges);
|
||||
int origIndex = GET_INT_FROM_POINTER(ccgSubSurf_getFaceFaceHandle(f));
|
||||
int g2_wid = gridCuts+2;
|
||||
int g2_wid = gridCuts + 2;
|
||||
float *w2;
|
||||
int s, x, y;
|
||||
|
||||
@@ -3145,7 +3145,7 @@ static CCGDerivedMesh *getCCGDerivedMesh(CCGSubSurf *ss,
|
||||
faceFlags++;
|
||||
|
||||
/* set the face base vert */
|
||||
*((int*)ccgSubSurf_getFaceUserData(ss, f)) = vertNum;
|
||||
*((int *)ccgSubSurf_getFaceUserData(ss, f)) = vertNum;
|
||||
|
||||
BLI_array_empty(loopidx);
|
||||
BLI_array_growitems(loopidx, numVerts);
|
||||
@@ -3175,9 +3175,9 @@ static CCGDerivedMesh *getCCGDerivedMesh(CCGSubSurf *ss,
|
||||
/*interpolate per-vert data*/
|
||||
for (s = 0; s < numVerts; s++) {
|
||||
for (x = 1; x < gridFaces; x++) {
|
||||
w2 = w + s*numVerts*g2_wid*g2_wid + x*numVerts;
|
||||
w2 = w + s * numVerts * g2_wid * g2_wid + x * numVerts;
|
||||
DM_interp_vert_data(dm, &ccgdm->dm, vertidx, w2,
|
||||
numVerts, vertNum);
|
||||
numVerts, vertNum);
|
||||
|
||||
if (vertOrigIndex) {
|
||||
*vertOrigIndex = ORIGINDEX_NONE;
|
||||
@@ -3192,9 +3192,9 @@ static CCGDerivedMesh *getCCGDerivedMesh(CCGSubSurf *ss,
|
||||
for (s = 0; s < numVerts; s++) {
|
||||
for (y = 1; y < gridFaces; y++) {
|
||||
for (x = 1; x < gridFaces; x++) {
|
||||
w2 = w + s*numVerts*g2_wid*g2_wid + (y*g2_wid+x)*numVerts;
|
||||
w2 = w + s * numVerts * g2_wid * g2_wid + (y * g2_wid + x) * numVerts;
|
||||
DM_interp_vert_data(dm, &ccgdm->dm, vertidx, w2,
|
||||
numVerts, vertNum);
|
||||
numVerts, vertNum);
|
||||
|
||||
if (vertOrigIndex) {
|
||||
*vertOrigIndex = ORIGINDEX_NONE;
|
||||
@@ -3209,29 +3209,29 @@ static CCGDerivedMesh *getCCGDerivedMesh(CCGSubSurf *ss,
|
||||
if (has_edge_origindex) {
|
||||
for (i = 0; i < numFinalEdges; ++i)
|
||||
*(int *)DM_get_edge_data(&ccgdm->dm, edgeNum + i,
|
||||
CD_ORIGINDEX) = ORIGINDEX_NONE;
|
||||
CD_ORIGINDEX) = ORIGINDEX_NONE;
|
||||
}
|
||||
|
||||
for (s=0; s<numVerts; s++) {
|
||||
for (s = 0; s < numVerts; s++) {
|
||||
/*interpolate per-face data*/
|
||||
for (y=0; y<gridFaces; y++) {
|
||||
for (x=0; x<gridFaces; x++) {
|
||||
w2 = w + s*numVerts*g2_wid*g2_wid + (y*g2_wid+x)*numVerts;
|
||||
for (y = 0; y < gridFaces; y++) {
|
||||
for (x = 0; x < gridFaces; x++) {
|
||||
w2 = w + s * numVerts * g2_wid * g2_wid + (y * g2_wid + x) * numVerts;
|
||||
CustomData_interp(&dm->loopData, &ccgdm->dm.loopData,
|
||||
loopidx, w2, NULL, numVerts, loopindex2);
|
||||
loopindex2++;
|
||||
|
||||
w2 = w + s*numVerts*g2_wid*g2_wid + ((y+1)*g2_wid+(x))*numVerts;
|
||||
w2 = w + s * numVerts * g2_wid * g2_wid + ((y + 1) * g2_wid + (x)) * numVerts;
|
||||
CustomData_interp(&dm->loopData, &ccgdm->dm.loopData,
|
||||
loopidx, w2, NULL, numVerts, loopindex2);
|
||||
loopindex2++;
|
||||
|
||||
w2 = w + s*numVerts*g2_wid*g2_wid + ((y+1)*g2_wid+(x+1))*numVerts;
|
||||
w2 = w + s * numVerts * g2_wid * g2_wid + ((y + 1) * g2_wid + (x + 1)) * numVerts;
|
||||
CustomData_interp(&dm->loopData, &ccgdm->dm.loopData,
|
||||
loopidx, w2, NULL, numVerts, loopindex2);
|
||||
loopindex2++;
|
||||
|
||||
w2 = w + s*numVerts*g2_wid*g2_wid + ((y)*g2_wid+(x+1))*numVerts;
|
||||
w2 = w + s * numVerts * g2_wid * g2_wid + ((y) * g2_wid + (x + 1)) * numVerts;
|
||||
CustomData_interp(&dm->loopData, &ccgdm->dm.loopData,
|
||||
loopidx, w2, NULL, numVerts, loopindex2);
|
||||
loopindex2++;
|
||||
@@ -3241,7 +3241,7 @@ static CCGDerivedMesh *getCCGDerivedMesh(CCGSubSurf *ss,
|
||||
|
||||
/*generate tessellated face data used for drawing*/
|
||||
ccg_loops_to_corners(&ccgdm->dm.faceData, &ccgdm->dm.loopData,
|
||||
&ccgdm->dm.polyData, loopindex2-4, faceNum, faceNum,
|
||||
&ccgdm->dm.polyData, loopindex2 - 4, faceNum, faceNum,
|
||||
numTex, numCol, hasPCol, hasOrigSpace);
|
||||
|
||||
/*set original index data*/
|
||||
@@ -3288,7 +3288,7 @@ static CCGDerivedMesh *getCCGDerivedMesh(CCGSubSurf *ss,
|
||||
edgeFlags[edgeIdx] = medge[edgeIdx].flag;
|
||||
|
||||
/* set the edge base vert */
|
||||
*((int*)ccgSubSurf_getEdgeUserData(ss, e)) = vertNum;
|
||||
*((int *)ccgSubSurf_getEdgeUserData(ss, e)) = vertNum;
|
||||
|
||||
for (x = 1; x < edgeSize - 1; x++) {
|
||||
float w[2];
|
||||
@@ -3304,8 +3304,7 @@ static CCGDerivedMesh *getCCGDerivedMesh(CCGSubSurf *ss,
|
||||
|
||||
for (i = 0; i < numFinalEdges; ++i) {
|
||||
if (has_edge_origindex) {
|
||||
*(int *)DM_get_edge_data(&ccgdm->dm, edgeNum + i,
|
||||
CD_ORIGINDEX) = mapIndex;
|
||||
*(int *)DM_get_edge_data(&ccgdm->dm, edgeNum + i, CD_ORIGINDEX) = mapIndex;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3318,7 +3317,7 @@ static CCGDerivedMesh *getCCGDerivedMesh(CCGSubSurf *ss,
|
||||
int numlayer = CustomData_number_of_layers(ldata, CD_MLOOPUV);
|
||||
int dmnumlayer = CustomData_number_of_layers(dmldata, CD_MLOOPUV);
|
||||
|
||||
for (i=0; i<numlayer && i<dmnumlayer; i++)
|
||||
for (i = 0; i < numlayer && i < dmnumlayer; i++)
|
||||
set_subsurf_uv(ss, dm, &ccgdm->dm, i);
|
||||
}
|
||||
|
||||
@@ -3332,7 +3331,7 @@ static CCGDerivedMesh *getCCGDerivedMesh(CCGSubSurf *ss,
|
||||
ccgdm->vertMap[index].startVert = vertNum;
|
||||
|
||||
/* set the vert base vert */
|
||||
*((int*) ccgSubSurf_getVertUserData(ss, v)) = vertNum;
|
||||
*((int *) ccgSubSurf_getVertUserData(ss, v)) = vertNum;
|
||||
|
||||
DM_copy_vert_data(dm, &ccgdm->dm, vertIdx, vertNum, 1);
|
||||
|
||||
@@ -3362,10 +3361,10 @@ static CCGDerivedMesh *getCCGDerivedMesh(CCGSubSurf *ss,
|
||||
/***/
|
||||
|
||||
struct DerivedMesh *subsurf_make_derived_from_derived(
|
||||
struct DerivedMesh *dm,
|
||||
struct SubsurfModifierData *smd,
|
||||
int useRenderParams, float (*vertCos)[3],
|
||||
int isFinalCalc, int forEditMode, int inEditMode)
|
||||
struct DerivedMesh *dm,
|
||||
struct SubsurfModifierData *smd,
|
||||
int useRenderParams, float (*vertCos)[3],
|
||||
int isFinalCalc, int forEditMode, int inEditMode)
|
||||
{
|
||||
int useSimple = smd->subdivType == ME_SIMPLE_SUBSURF;
|
||||
CCGFlags useAging = smd->flags & eSubsurfModifierFlag_DebugIncr ? CCG_USE_AGING : 0;
|
||||
@@ -3374,35 +3373,35 @@ struct DerivedMesh *subsurf_make_derived_from_derived(
|
||||
CCGDerivedMesh *result;
|
||||
|
||||
if (forEditMode) {
|
||||
int levels= (smd->modifier.scene)? get_render_subsurf_level(&smd->modifier.scene->r, smd->levels): smd->levels;
|
||||
int levels = (smd->modifier.scene) ? get_render_subsurf_level(&smd->modifier.scene->r, smd->levels) : smd->levels;
|
||||
|
||||
smd->emCache = _getSubSurf(smd->emCache, levels, useAging|CCG_CALC_NORMALS);
|
||||
smd->emCache = _getSubSurf(smd->emCache, levels, useAging | CCG_CALC_NORMALS);
|
||||
ss_sync_from_derivedmesh(smd->emCache, dm, vertCos, useSimple);
|
||||
|
||||
result = getCCGDerivedMesh(smd->emCache,
|
||||
drawInteriorEdges,
|
||||
useSubsurfUv, dm);
|
||||
drawInteriorEdges,
|
||||
useSubsurfUv, dm);
|
||||
}
|
||||
else if (useRenderParams) {
|
||||
/* Do not use cache in render mode. */
|
||||
CCGSubSurf *ss;
|
||||
int levels= (smd->modifier.scene)? get_render_subsurf_level(&smd->modifier.scene->r, smd->renderLevels): smd->renderLevels;
|
||||
int levels = (smd->modifier.scene) ? get_render_subsurf_level(&smd->modifier.scene->r, smd->renderLevels) : smd->renderLevels;
|
||||
|
||||
if (levels == 0)
|
||||
return dm;
|
||||
|
||||
ss = _getSubSurf(NULL, levels, CCG_USE_ARENA|CCG_CALC_NORMALS);
|
||||
ss = _getSubSurf(NULL, levels, CCG_USE_ARENA | CCG_CALC_NORMALS);
|
||||
|
||||
ss_sync_from_derivedmesh(ss, dm, vertCos, useSimple);
|
||||
|
||||
result = getCCGDerivedMesh(ss,
|
||||
drawInteriorEdges, useSubsurfUv, dm);
|
||||
drawInteriorEdges, useSubsurfUv, dm);
|
||||
|
||||
result->freeSS = 1;
|
||||
}
|
||||
else {
|
||||
int useIncremental = (smd->flags & eSubsurfModifierFlag_Incremental);
|
||||
int levels= (smd->modifier.scene)? get_render_subsurf_level(&smd->modifier.scene->r, smd->levels): smd->levels;
|
||||
int levels = (smd->modifier.scene) ? get_render_subsurf_level(&smd->modifier.scene->r, smd->levels) : smd->levels;
|
||||
CCGSubSurf *ss;
|
||||
|
||||
/* It is quite possible there is a much better place to do this. It
|
||||
@@ -3422,13 +3421,13 @@ struct DerivedMesh *subsurf_make_derived_from_derived(
|
||||
}
|
||||
|
||||
if (useIncremental && isFinalCalc) {
|
||||
smd->mCache = ss = _getSubSurf(smd->mCache, levels, useAging|CCG_CALC_NORMALS);
|
||||
smd->mCache = ss = _getSubSurf(smd->mCache, levels, useAging | CCG_CALC_NORMALS);
|
||||
|
||||
ss_sync_from_derivedmesh(ss, dm, vertCos, useSimple);
|
||||
|
||||
result = getCCGDerivedMesh(smd->mCache,
|
||||
drawInteriorEdges,
|
||||
useSubsurfUv, dm);
|
||||
drawInteriorEdges,
|
||||
useSubsurfUv, dm);
|
||||
}
|
||||
else {
|
||||
if (smd->mCache && isFinalCalc) {
|
||||
@@ -3436,7 +3435,7 @@ struct DerivedMesh *subsurf_make_derived_from_derived(
|
||||
smd->mCache = NULL;
|
||||
}
|
||||
|
||||
ss = _getSubSurf(NULL, levels, CCG_USE_ARENA|CCG_CALC_NORMALS);
|
||||
ss = _getSubSurf(NULL, levels, CCG_USE_ARENA | CCG_CALC_NORMALS);
|
||||
ss_sync_from_derivedmesh(ss, dm, vertCos, useSimple);
|
||||
|
||||
result = getCCGDerivedMesh(ss, drawInteriorEdges, useSubsurfUv, dm);
|
||||
@@ -3448,7 +3447,7 @@ struct DerivedMesh *subsurf_make_derived_from_derived(
|
||||
}
|
||||
}
|
||||
|
||||
return (DerivedMesh*)result;
|
||||
return (DerivedMesh *)result;
|
||||
}
|
||||
|
||||
void subsurf_calculate_limit_positions(Mesh *me, float (*positions_r)[3])
|
||||
@@ -3474,14 +3473,14 @@ void subsurf_calculate_limit_positions(Mesh *me, float (*positions_r)[3])
|
||||
float *co;
|
||||
int i;
|
||||
|
||||
edge_sum[0]= edge_sum[1]= edge_sum[2]= 0.0;
|
||||
face_sum[0]= face_sum[1]= face_sum[2]= 0.0;
|
||||
edge_sum[0] = edge_sum[1] = edge_sum[2] = 0.0;
|
||||
face_sum[0] = face_sum[1] = face_sum[2] = 0.0;
|
||||
|
||||
for (i=0; i<N; i++) {
|
||||
for (i = 0; i < N; i++) {
|
||||
CCGEdge *e = ccgSubSurf_getVertEdge(v, i);
|
||||
add_v3_v3v3(edge_sum, edge_sum, ccgSubSurf_getEdgeData(ss, e, 1));
|
||||
}
|
||||
for (i=0; i<numFaces; i++) {
|
||||
for (i = 0; i < numFaces; i++) {
|
||||
CCGFace *f = ccgSubSurf_getVertFace(v, i);
|
||||
add_v3_v3(face_sum, ccgSubSurf_getFaceCenterData(f));
|
||||
}
|
||||
@@ -3489,12 +3488,12 @@ void subsurf_calculate_limit_positions(Mesh *me, float (*positions_r)[3])
|
||||
/* ad-hoc correction for boundary vertices, to at least avoid them
|
||||
* moving completely out of place (brecht) */
|
||||
if (numFaces && numFaces != N)
|
||||
mul_v3_fl(face_sum, (float)N/(float)numFaces);
|
||||
mul_v3_fl(face_sum, (float)N / (float)numFaces);
|
||||
|
||||
co = ccgSubSurf_getVertData(ss, v);
|
||||
positions_r[idx][0] = (co[0]*N*N + edge_sum[0]*4 + face_sum[0])/(N*(N+5));
|
||||
positions_r[idx][1] = (co[1]*N*N + edge_sum[1]*4 + face_sum[1])/(N*(N+5));
|
||||
positions_r[idx][2] = (co[2]*N*N + edge_sum[2]*4 + face_sum[2])/(N*(N+5));
|
||||
positions_r[idx][0] = (co[0] * N * N + edge_sum[0] * 4 + face_sum[0]) / (N * (N + 5));
|
||||
positions_r[idx][1] = (co[1] * N * N + edge_sum[1] * 4 + face_sum[1]) / (N * (N + 5));
|
||||
positions_r[idx][2] = (co[2] * N * N + edge_sum[2] * 4 + face_sum[2]) / (N * (N + 5));
|
||||
}
|
||||
ccgVertIterator_free(vi);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user