Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--source/blender/blenkernel/intern/CCGSubSurf.c1507
-rw-r--r--source/blender/blenkernel/intern/DerivedMesh.c8
-rw-r--r--source/blender/blenkernel/intern/action.c18
-rw-r--r--source/blender/blenkernel/intern/boids.c20
-rw-r--r--source/blender/blenkernel/intern/brush.c6
-rw-r--r--source/blender/blenkernel/intern/cdderivedmesh.c4
-rw-r--r--source/blender/blenkernel/intern/constraint.c2
-rw-r--r--source/blender/blenkernel/intern/customdata.c7
-rw-r--r--source/blender/blenkernel/intern/lattice.c230
-rw-r--r--source/blender/blenkernel/intern/material.c513
-rw-r--r--source/blender/blenkernel/intern/mball.c396
-rw-r--r--source/blender/blenkernel/intern/mesh.c358
-rw-r--r--source/blender/blenkernel/intern/mesh_validate.c2
-rw-r--r--source/blender/blenkernel/intern/multires.c441
-rw-r--r--source/blender/blenkernel/intern/object.c618
-rw-r--r--source/blender/blenkernel/intern/ocean.c8
-rw-r--r--source/blender/blenkernel/intern/scene.c182
-rw-r--r--source/blender/blenkernel/intern/sequencer.c17
-rw-r--r--source/blender/blenkernel/intern/softbody.c456
-rw-r--r--source/blender/blenkernel/intern/sound.c139
-rw-r--r--source/blender/blenkernel/intern/text.c8
-rw-r--r--source/blender/blenkernel/intern/unit.c82
22 files changed, 2631 insertions, 2391 deletions
diff --git a/source/blender/blenkernel/intern/CCGSubSurf.c b/source/blender/blenkernel/intern/CCGSubSurf.c
index 3ab52a7c17b..8f0d5e2e79c 100644
--- a/source/blender/blenkernel/intern/CCGSubSurf.c
+++ b/source/blender/blenkernel/intern/CCGSubSurf.c
@@ -13,9 +13,9 @@
#include "BLO_sys_types.h" // for intptr_t support
#ifdef _MSC_VER
-#define CCG_INLINE __inline
+# define CCG_INLINE __inline
#else
-#define CCG_INLINE inline
+# define CCG_INLINE inline
#endif
/* copied from BKE_utildefines.h ugh */
@@ -59,22 +59,24 @@ typedef struct _EHash {
#define EHASH_hash(eh, item) (((uintptr_t) (item))%((unsigned int) (eh)->curSize))
-static EHash *_ehash_new(int estimatedNumEntries, CCGAllocatorIFC *allocatorIFC, CCGAllocatorHDL allocator) {
+static EHash *_ehash_new(int estimatedNumEntries, CCGAllocatorIFC *allocatorIFC, CCGAllocatorHDL allocator)
+{
EHash *eh = allocatorIFC->alloc(allocator, sizeof(*eh));
eh->allocatorIFC = *allocatorIFC;
eh->allocator = allocator;
eh->numEntries = 0;
eh->curSizeIdx = 0;
- while (kHashSizes[eh->curSizeIdx]<estimatedNumEntries)
+ while (kHashSizes[eh->curSizeIdx] < estimatedNumEntries)
eh->curSizeIdx++;
eh->curSize = kHashSizes[eh->curSizeIdx];
- eh->buckets = EHASH_alloc(eh, eh->curSize*sizeof(*eh->buckets));
- memset(eh->buckets, 0, eh->curSize*sizeof(*eh->buckets));
+ eh->buckets = EHASH_alloc(eh, eh->curSize * sizeof(*eh->buckets));
+ memset(eh->buckets, 0, eh->curSize * sizeof(*eh->buckets));
return eh;
}
typedef void (*EHEntryFreeFP)(EHEntry *, void *);
-static void _ehash_free(EHash *eh, EHEntryFreeFP freeEntry, void *userData) {
+static void _ehash_free(EHash *eh, EHEntryFreeFP freeEntry, void *userData)
+{
int numBuckets = eh->curSize;
while (numBuckets--) {
@@ -93,19 +95,20 @@ static void _ehash_free(EHash *eh, EHEntryFreeFP freeEntry, void *userData) {
EHASH_free(eh, eh);
}
-static void _ehash_insert(EHash *eh, EHEntry *entry) {
+static void _ehash_insert(EHash *eh, EHEntry *entry)
+{
int numBuckets = eh->curSize;
int hash = EHASH_hash(eh, entry->key);
entry->next = eh->buckets[hash];
eh->buckets[hash] = entry;
eh->numEntries++;
- if (eh->numEntries > (numBuckets*3)) {
+ if (eh->numEntries > (numBuckets * 3)) {
EHEntry **oldBuckets = eh->buckets;
eh->curSize = kHashSizes[++eh->curSizeIdx];
- eh->buckets = EHASH_alloc(eh, eh->curSize*sizeof(*eh->buckets));
- memset(eh->buckets, 0, eh->curSize*sizeof(*eh->buckets));
+ eh->buckets = EHASH_alloc(eh, eh->curSize * sizeof(*eh->buckets));
+ memset(eh->buckets, 0, eh->curSize * sizeof(*eh->buckets));
while (numBuckets--) {
for (entry = oldBuckets[numBuckets]; entry;) {
@@ -123,13 +126,14 @@ static void _ehash_insert(EHash *eh, EHEntry *entry) {
}
}
-static void *_ehash_lookupWithPrev(EHash *eh, void *key, void ***prevp_r) {
+static void *_ehash_lookupWithPrev(EHash *eh, void *key, void ***prevp_r)
+{
int hash = EHASH_hash(eh, key);
void **prevp = (void**) &eh->buckets[hash];
EHEntry *entry;
for (; (entry = *prevp); prevp = (void**) &entry->next) {
- if (entry->key==key) {
+ if (entry->key == key) {
*prevp_r = (void**) prevp;
return entry;
}
@@ -138,12 +142,13 @@ static void *_ehash_lookupWithPrev(EHash *eh, void *key, void ***prevp_r) {
return NULL;
}
-static void *_ehash_lookup(EHash *eh, void *key) {
+static void *_ehash_lookup(EHash *eh, void *key)
+{
int hash = EHASH_hash(eh, key);
EHEntry *entry;
for (entry = eh->buckets[hash]; entry; entry = entry->next)
- if (entry->key==key)
+ if (entry->key == key)
break;
return entry;
@@ -157,55 +162,64 @@ typedef struct _EHashIterator {
EHEntry *curEntry;
} EHashIterator;
-static EHashIterator *_ehashIterator_new(EHash *eh) {
+static EHashIterator *_ehashIterator_new(EHash *eh)
+{
EHashIterator *ehi = EHASH_alloc(eh, sizeof(*ehi));
ehi->eh = eh;
ehi->curEntry = NULL;
ehi->curBucket = -1;
while (!ehi->curEntry) {
ehi->curBucket++;
- if (ehi->curBucket==ehi->eh->curSize)
+ if (ehi->curBucket == ehi->eh->curSize)
break;
ehi->curEntry = ehi->eh->buckets[ehi->curBucket];
}
return ehi;
}
-static void _ehashIterator_free(EHashIterator *ehi) {
+static void _ehashIterator_free(EHashIterator *ehi)
+{
EHASH_free(ehi->eh, ehi);
}
-static void *_ehashIterator_getCurrent(EHashIterator *ehi) {
+static void *_ehashIterator_getCurrent(EHashIterator *ehi)
+{
return ehi->curEntry;
}
-static void _ehashIterator_next(EHashIterator *ehi) {
+static void _ehashIterator_next(EHashIterator *ehi)
+{
if (ehi->curEntry) {
ehi->curEntry = ehi->curEntry->next;
while (!ehi->curEntry) {
ehi->curBucket++;
- if (ehi->curBucket==ehi->eh->curSize)
+ if (ehi->curBucket == ehi->eh->curSize)
break;
ehi->curEntry = ehi->eh->buckets[ehi->curBucket];
}
}
}
-static int _ehashIterator_isStopped(EHashIterator *ehi) {
+static int _ehashIterator_isStopped(EHashIterator *ehi)
+{
return !ehi->curEntry;
}
/***/
-static void *_stdAllocator_alloc(CCGAllocatorHDL UNUSED(a), int numBytes) {
+static void *_stdAllocator_alloc(CCGAllocatorHDL UNUSED(a), int numBytes)
+{
return malloc(numBytes);
}
-static void *_stdAllocator_realloc(CCGAllocatorHDL UNUSED(a), void *ptr, int newSize, int UNUSED(oldSize)) {
+static void *_stdAllocator_realloc(CCGAllocatorHDL UNUSED(a), void *ptr, int newSize, int UNUSED(oldSize))
+{
return realloc(ptr, newSize);
}
-static void _stdAllocator_free(CCGAllocatorHDL UNUSED(a), void *ptr) {
+static void _stdAllocator_free(CCGAllocatorHDL UNUSED(a), void *ptr)
+{
free(ptr);
}
-static CCGAllocatorIFC *_getStandardAllocatorIFC(void) {
+static CCGAllocatorIFC *_getStandardAllocatorIFC(void)
+{
static CCGAllocatorIFC ifc;
ifc.alloc = _stdAllocator_alloc;
@@ -218,24 +232,25 @@ static CCGAllocatorIFC *_getStandardAllocatorIFC(void) {
/***/
-static int VertDataEqual(const float *a, const float *b) {
- return a[0]==b[0] && a[1]==b[1] && a[2]==b[2];
+static int VertDataEqual(const float *a, const float *b)
+{
+ return a[0] == b[0] && a[1] == b[1] && a[2] == b[2];
}
-#define VertDataZero(av) { float *_a = (float*) av; _a[0] = _a[1] = _a[2] = 0.0f; }
-#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 VertDataZero(av) { float *_a = (float *)av; _a[0] = _a[1] = _a[2] = 0.0f; }
+#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 VertDataAvg4(tv, av, bv, cv, dv) \
{ \
- float *_t = (float*) tv, *_a = (float*) av, *_b = (float*) bv, *_c = (float*) cv, *_d = (float*) dv; \
- _t[0] = (_a[0]+_b[0]+_c[0]+_d[0])*.25f; \
- _t[1] = (_a[1]+_b[1]+_c[1]+_d[1])*.25f; \
- _t[2] = (_a[2]+_b[2]+_c[2]+_d[2])*.25f; \
+ float *_t = (float *) tv, *_a = (float *) av, *_b = (float *) bv, *_c = (float *) cv, *_d = (float *) dv; \
+ _t[0] = (_a[0] + _b[0] + _c[0] + _d[0]) * 0.25f; \
+ _t[1] = (_a[1] + _b[1] + _c[1] + _d[1]) * 0.25f; \
+ _t[2] = (_a[2] + _b[2] + _c[2] + _d[2]) * 0.25f; \
}
-#define NormZero(av) { float *_a = (float*) av; _a[0] = _a[1] = _a[2] = 0.0f; }
-#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]; }
+#define NormZero(av) { float *_a = (float *) av; _a[0] = _a[1] = _a[2] = 0.0f; }
+#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);
@@ -243,15 +258,15 @@ static int _edge_isBoundary(const CCGEdge *e);
/***/
enum {
- Vert_eEffected= (1<<0),
- Vert_eChanged= (1<<1),
- Vert_eSeam= (1<<2),
+ Vert_eEffected = (1 << 0),
+ Vert_eChanged = (1 << 1),
+ Vert_eSeam = (1 << 2)
} /*VertFlags*/;
enum {
- Edge_eEffected= (1<<0),
+ Edge_eEffected = (1 << 0)
} /*CCGEdgeFlags*/;
enum {
- Face_eEffected= (1<<0),
+ Face_eEffected = (1 << 0)
} /*FaceFlags*/;
struct _CCGVert {
@@ -265,7 +280,7 @@ struct _CCGVert {
// byte *levelData;
// byte *userData;
};
-#define VERT_getLevelData(v) ((byte*) &(v)[1])
+#define VERT_getLevelData(v) ((byte *) &(v)[1])
struct _CCGEdge {
CCGEdge *next; /* EHData.next */
@@ -280,7 +295,7 @@ struct _CCGEdge {
// byte *levelData;
// byte *userData;
};
-#define EDGE_getLevelData(e) ((byte*) &(e)[1])
+#define EDGE_getLevelData(e) ((byte *) &(e)[1])
struct _CCGFace {
CCGFace *next; /* EHData.next */
@@ -296,14 +311,14 @@ struct _CCGFace {
};
#define FACE_getVerts(f) ((CCGVert**) &(f)[1])
#define FACE_getEdges(f) ((CCGEdge**) &(FACE_getVerts(f)[(f)->numVerts]))
-#define FACE_getCenterData(f) ((byte*) &(FACE_getEdges(f)[(f)->numVerts]))
+#define FACE_getCenterData(f) ((byte *) &(FACE_getEdges(f)[(f)->numVerts]))
typedef enum {
eSyncState_None = 0,
eSyncState_Vert,
eSyncState_Edge,
eSyncState_Face,
- eSyncState_Partial,
+ eSyncState_Partial
} SyncState;
struct _CCGSubSurf {
@@ -350,8 +365,9 @@ struct _CCGSubSurf {
/***/
-static CCGVert *_vert_new(CCGVertHDL vHDL, CCGSubSurf *ss) {
- CCGVert *v = CCGSUBSURF_alloc(ss, sizeof(CCGVert) + ss->meshIFC.vertDataSize * (ss->subdivLevels+1) + ss->meshIFC.vertUserSize);
+static CCGVert *_vert_new(CCGVertHDL vHDL, CCGSubSurf *ss)
+{
+ CCGVert *v = CCGSUBSURF_alloc(ss, sizeof(CCGVert) + ss->meshIFC.vertDataSize * (ss->subdivLevels + 1) + ss->meshIFC.vertUserSize);
byte *userData;
v->vHDL = vHDL;
@@ -366,71 +382,87 @@ static CCGVert *_vert_new(CCGVertHDL vHDL, CCGSubSurf *ss) {
return v;
}
-static void _vert_remEdge(CCGVert *v, CCGEdge *e) {
+static void _vert_remEdge(CCGVert *v, CCGEdge *e)
+{
int i;
- for (i=0; i<v->numEdges; i++) {
- if (v->edges[i]==e) {
+ for (i = 0; i < v->numEdges; i++) {
+ if (v->edges[i] == e) {
v->edges[i] = v->edges[--v->numEdges];
break;
}
}
}
-static void _vert_remFace(CCGVert *v, CCGFace *f) {
+static void _vert_remFace(CCGVert *v, CCGFace *f)
+{
int i;
- for (i=0; i<v->numFaces; i++) {
- if (v->faces[i]==f) {
+ for (i = 0; i < v->numFaces; i++) {
+ if (v->faces[i] == f) {
v->faces[i] = v->faces[--v->numFaces];
break;
}
}
}
-static void _vert_addEdge(CCGVert *v, CCGEdge *e, CCGSubSurf *ss) {
- v->edges = CCGSUBSURF_realloc(ss, v->edges, (v->numEdges+1)*sizeof(*v->edges), v->numEdges*sizeof(*v->edges));
+static void _vert_addEdge(CCGVert *v, CCGEdge *e, CCGSubSurf *ss)
+{
+ v->edges = CCGSUBSURF_realloc(ss, v->edges, (v->numEdges + 1) * sizeof(*v->edges), v->numEdges * sizeof(*v->edges));
v->edges[v->numEdges++] = e;
}
-static void _vert_addFace(CCGVert *v, CCGFace *f, CCGSubSurf *ss) {
- v->faces = CCGSUBSURF_realloc(ss, v->faces, (v->numFaces+1)*sizeof(*v->faces), v->numFaces*sizeof(*v->faces));
+static void _vert_addFace(CCGVert *v, CCGFace *f, CCGSubSurf *ss)
+{
+ v->faces = CCGSUBSURF_realloc(ss, v->faces, (v->numFaces + 1) * sizeof(*v->faces), v->numFaces * sizeof(*v->faces));
v->faces[v->numFaces++] = f;
}
-static CCGEdge *_vert_findEdgeTo(const CCGVert *v, const CCGVert *vQ) {
+static CCGEdge *_vert_findEdgeTo(const CCGVert *v, const CCGVert *vQ)
+{
int i;
- for (i=0; i<v->numEdges; i++) {
- CCGEdge *e = v->edges[v->numEdges-1-i]; // XXX, note reverse
- if ( (e->v0==v && e->v1==vQ) ||
- (e->v1==v && e->v0==vQ))
+ for (i = 0; i < v->numEdges; i++) {
+ CCGEdge *e = v->edges[v->numEdges - 1 - i]; // XXX, note reverse
+ if ((e->v0 == v && e->v1 == vQ) ||
+ (e->v1 == v && e->v0 == vQ))
+ {
return e;
+ }
}
return NULL;
}
-static int _vert_isBoundary(const CCGVert *v) {
+static int _vert_isBoundary(const CCGVert *v)
+{
int i;
- for (i=0; i<v->numEdges; i++)
+ for (i = 0; i < v->numEdges; i++)
if (_edge_isBoundary(v->edges[i]))
return 1;
return 0;
}
-static void *_vert_getCo(CCGVert *v, int lvl, int dataSize) {
- return &VERT_getLevelData(v)[lvl*dataSize];
+static void *_vert_getCo(CCGVert *v, int lvl, int dataSize)
+{
+ return &VERT_getLevelData(v)[lvl * dataSize];
}
-static float *_vert_getNo(CCGVert *v, int lvl, int dataSize, int normalDataOffset) {
- return (float*) &VERT_getLevelData(v)[lvl*dataSize + normalDataOffset];
+static float *_vert_getNo(CCGVert *v, int lvl, int dataSize, int normalDataOffset)
+{
+ return (float *) &VERT_getLevelData(v)[lvl * dataSize + normalDataOffset];
}
-static void _vert_free(CCGVert *v, CCGSubSurf *ss) {
+static void _vert_free(CCGVert *v, CCGSubSurf *ss)
+{
CCGSUBSURF_free(ss, v->edges);
CCGSUBSURF_free(ss, v->faces);
CCGSUBSURF_free(ss, v);
}
-static int VERT_seam(const CCGVert *v) {
+static int VERT_seam(const CCGVert *v)
+{
return ((v->flags & Vert_eSeam) != 0);
}
/***/
-static CCGEdge *_edge_new(CCGEdgeHDL eHDL, CCGVert *v0, CCGVert *v1, float crease, CCGSubSurf *ss) {
- CCGEdge *e = CCGSUBSURF_alloc(ss, sizeof(CCGEdge) + ss->meshIFC.vertDataSize *((ss->subdivLevels+1) + (1<<(ss->subdivLevels+1))-1) + ss->meshIFC.edgeUserSize);
+static CCGEdge *_edge_new(CCGEdgeHDL eHDL, CCGVert *v0, CCGVert *v1, float crease, CCGSubSurf *ss)
+{
+ CCGEdge *e = CCGSUBSURF_alloc(ss,
+ sizeof(CCGEdge) +
+ ss->meshIFC.vertDataSize * ((ss->subdivLevels + 1) + (1 << (ss->subdivLevels + 1)) - 1) +
+ ss->meshIFC.edgeUserSize);
byte *userData;
e->eHDL = eHDL;
@@ -449,53 +481,64 @@ static CCGEdge *_edge_new(CCGEdgeHDL eHDL, CCGVert *v0, CCGVert *v1, float creas
return e;
}
-static void _edge_remFace(CCGEdge *e, CCGFace *f) {
+static void _edge_remFace(CCGEdge *e, CCGFace *f)
+{
int i;
- for (i=0; i<e->numFaces; i++) {
- if (e->faces[i]==f) {
+ for (i = 0; i < e->numFaces; i++) {
+ if (e->faces[i] == f) {
e->faces[i] = e->faces[--e->numFaces];
break;
}
}
}
-static void _edge_addFace(CCGEdge *e, CCGFace *f, CCGSubSurf *ss) {
- e->faces = CCGSUBSURF_realloc(ss, e->faces, (e->numFaces+1)*sizeof(*e->faces), e->numFaces*sizeof(*e->faces));
+static void _edge_addFace(CCGEdge *e, CCGFace *f, CCGSubSurf *ss)
+{
+ e->faces = CCGSUBSURF_realloc(ss, e->faces, (e->numFaces + 1) * sizeof(*e->faces), e->numFaces * sizeof(*e->faces));
e->faces[e->numFaces++] = f;
}
-static int _edge_isBoundary(const CCGEdge *e) {
+static int _edge_isBoundary(const CCGEdge *e)
+{
return e->numFaces<2;
}
-static CCGVert *_edge_getOtherVert(CCGEdge *e, CCGVert *vQ) {
- if (vQ==e->v0) {
+static CCGVert *_edge_getOtherVert(CCGEdge *e, CCGVert *vQ)
+{
+ if (vQ == e->v0) {
return e->v1;
- } else {
+ }
+ else {
return e->v0;
}
}
-static void *_edge_getCo(CCGEdge *e, int lvl, int x, int dataSize) {
- int levelBase = lvl + (1<<lvl) - 1;
- return &EDGE_getLevelData(e)[dataSize*(levelBase + x)];
+static void *_edge_getCo(CCGEdge *e, int lvl, int x, int dataSize)
+{
+ int levelBase = lvl + (1 << lvl) - 1;
+ return &EDGE_getLevelData(e)[dataSize * (levelBase + x)];
}
-static float *_edge_getNo(CCGEdge *e, int lvl, int x, int dataSize, int normalDataOffset) {
- int levelBase = lvl + (1<<lvl) - 1;
- return (float*) &EDGE_getLevelData(e)[dataSize*(levelBase + x) + normalDataOffset];
+static float *_edge_getNo(CCGEdge *e, int lvl, int x, int dataSize, int normalDataOffset)
+{
+ int levelBase = lvl + (1 << lvl) - 1;
+ return (float *) &EDGE_getLevelData(e)[dataSize * (levelBase + x) + normalDataOffset];
}
-static void *_edge_getCoVert(CCGEdge *e, CCGVert *v, int lvl, int x, int dataSize) {
- int levelBase = lvl + (1<<lvl) - 1;
- if (v==e->v0) {
- return &EDGE_getLevelData(e)[dataSize*(levelBase + x)];
- } else {
- return &EDGE_getLevelData(e)[dataSize*(levelBase + (1<<lvl) - x)];
+static void *_edge_getCoVert(CCGEdge *e, CCGVert *v, int lvl, int x, int dataSize)
+{
+ int levelBase = lvl + (1 << lvl) - 1;
+ if (v == e->v0) {
+ return &EDGE_getLevelData(e)[dataSize * (levelBase + x)];
+ }
+ else {
+ return &EDGE_getLevelData(e)[dataSize * (levelBase + (1 << lvl) - x)];
}
}
-static void _edge_free(CCGEdge *e, CCGSubSurf *ss) {
+static void _edge_free(CCGEdge *e, CCGSubSurf *ss)
+{
CCGSUBSURF_free(ss, e->faces);
CCGSUBSURF_free(ss, e);
}
-static void _edge_unlinkMarkAndFree(CCGEdge *e, CCGSubSurf *ss) {
+static void _edge_unlinkMarkAndFree(CCGEdge *e, CCGSubSurf *ss)
+{
_vert_remEdge(e->v0, e);
_vert_remEdge(e->v1, e);
e->v0->flags |= Vert_eEffected;
@@ -503,7 +546,8 @@ static void _edge_unlinkMarkAndFree(CCGEdge *e, CCGSubSurf *ss) {
_edge_free(e, ss);
}
-static float EDGE_getSharpness(CCGEdge *e, int lvl) {
+static float EDGE_getSharpness(CCGEdge *e, int lvl)
+{
if (!lvl)
return e->crease;
else if (!e->crease)
@@ -514,9 +558,15 @@ static float EDGE_getSharpness(CCGEdge *e, int lvl) {
return e->crease - lvl;
}
-static CCGFace *_face_new(CCGFaceHDL fHDL, CCGVert **verts, CCGEdge **edges, int numVerts, CCGSubSurf *ss) {
- int maxGridSize = 1 + (1<<(ss->subdivLevels-1));
- CCGFace *f = CCGSUBSURF_alloc(ss, sizeof(CCGFace) + sizeof(CCGVert*)*numVerts + sizeof(CCGEdge*)*numVerts + ss->meshIFC.vertDataSize *(1 + numVerts*maxGridSize + numVerts*maxGridSize*maxGridSize) + ss->meshIFC.faceUserSize);
+static CCGFace *_face_new(CCGFaceHDL fHDL, CCGVert **verts, CCGEdge **edges, int numVerts, CCGSubSurf *ss)
+{
+ int maxGridSize = 1 + (1 << (ss->subdivLevels - 1));
+ CCGFace *f = CCGSUBSURF_alloc(ss,
+ sizeof(CCGFace) +
+ sizeof(CCGVert*) * numVerts +
+ sizeof(CCGEdge*) * numVerts +
+ ss->meshIFC.vertDataSize * (1 + numVerts * maxGridSize + numVerts * maxGridSize * maxGridSize) +
+ ss->meshIFC.faceUserSize);
byte *userData;
int i;
@@ -524,7 +574,7 @@ static CCGFace *_face_new(CCGFaceHDL fHDL, CCGVert **verts, CCGEdge **edges, int
f->fHDL = fHDL;
f->flags = 0;
- for (i=0; i<numVerts; i++) {
+ for (i = 0; i < numVerts; i++) {
FACE_getVerts(f)[i] = verts[i];
FACE_getEdges(f)[i] = edges[i];
_vert_addFace(verts[i], f, ss);
@@ -538,102 +588,115 @@ static CCGFace *_face_new(CCGFaceHDL fHDL, CCGVert **verts, CCGEdge **edges, int
return f;
}
-static CCG_INLINE void *_face_getIECo(CCGFace *f, int lvl, int S, int x, int levels, int dataSize) {
- int maxGridSize = 1 + (1<<(levels-1));
- int spacing = 1<<(levels-lvl);
- byte *gridBase = FACE_getCenterData(f) + dataSize*(1 + S*(maxGridSize + maxGridSize*maxGridSize));
- return &gridBase[dataSize*x*spacing];
+static CCG_INLINE void *_face_getIECo(CCGFace *f, int lvl, int S, int x, int levels, int dataSize)
+{
+ int maxGridSize = 1 + (1 << (levels - 1));
+ int spacing = 1 << (levels - lvl);
+ byte *gridBase = FACE_getCenterData(f) + dataSize * (1 + S * (maxGridSize + maxGridSize * maxGridSize));
+ return &gridBase[dataSize * x * spacing];
}
-static CCG_INLINE void *_face_getIENo(CCGFace *f, int lvl, int S, int x, int levels, int dataSize, int normalDataOffset) {
- int maxGridSize = 1 + (1<<(levels-1));
- int spacing = 1<<(levels-lvl);
- byte *gridBase = FACE_getCenterData(f) + dataSize*(1 + S*(maxGridSize + maxGridSize*maxGridSize));
- return &gridBase[dataSize*x*spacing + normalDataOffset];
+static CCG_INLINE void *_face_getIENo(CCGFace *f, int lvl, int S, int x, int levels, int dataSize, int normalDataOffset)
+{
+ int maxGridSize = 1 + (1 << (levels - 1));
+ int spacing = 1 << (levels - lvl);
+ byte *gridBase = FACE_getCenterData(f) + dataSize * (1 + S * (maxGridSize + maxGridSize * maxGridSize));
+ return &gridBase[dataSize * x * spacing + normalDataOffset];
}
-static CCG_INLINE void *_face_getIFCo(CCGFace *f, int lvl, int S, int x, int y, int levels, int dataSize) {
- int maxGridSize = 1 + (1<<(levels-1));
- int spacing = 1<<(levels-lvl);
- byte *gridBase = FACE_getCenterData(f) + dataSize*(1 + S*(maxGridSize + maxGridSize*maxGridSize));
- return &gridBase[dataSize*(maxGridSize + (y*maxGridSize + x)*spacing)];
+static CCG_INLINE void *_face_getIFCo(CCGFace *f, int lvl, int S, int x, int y, int levels, int dataSize)
+{
+ int maxGridSize = 1 + (1 << (levels - 1));
+ int spacing = 1 << (levels - lvl);
+ byte *gridBase = FACE_getCenterData(f) + dataSize * (1 + S * (maxGridSize + maxGridSize * maxGridSize));
+ return &gridBase[dataSize * (maxGridSize + (y * maxGridSize + x) * spacing)];
}
-static CCG_INLINE float *_face_getIFNo(CCGFace *f, int lvl, int S, int x, int y, int levels, int dataSize, int normalDataOffset) {
- int maxGridSize = 1 + (1<<(levels-1));
- int spacing = 1<<(levels-lvl);
- byte *gridBase = FACE_getCenterData(f) + dataSize*(1 + S*(maxGridSize + maxGridSize*maxGridSize));
- return (float*) &gridBase[dataSize*(maxGridSize + (y*maxGridSize + x)*spacing) + normalDataOffset];
+static CCG_INLINE float *_face_getIFNo(CCGFace *f, int lvl, int S, int x, int y, int levels, int dataSize, int normalDataOffset)
+{
+ int maxGridSize = 1 + (1 << (levels - 1));
+ int spacing = 1 << (levels - lvl);
+ byte *gridBase = FACE_getCenterData(f) + dataSize * (1 + S * (maxGridSize + maxGridSize * maxGridSize));
+ return (float *) &gridBase[dataSize * (maxGridSize + (y * maxGridSize + x) * spacing) + normalDataOffset];
}
-static int _face_getVertIndex(CCGFace *f, CCGVert *v) {
+static int _face_getVertIndex(CCGFace *f, CCGVert *v)
+{
int i;
- for (i=0; i<f->numVerts; i++)
- if (FACE_getVerts(f)[i]==v)
+ for (i = 0; i < f->numVerts; i++)
+ if (FACE_getVerts(f)[i] == v)
return i;
return -1;
}
-static CCG_INLINE void *_face_getIFCoEdge(CCGFace *f, CCGEdge *e, int lvl, int eX, int eY, int levels, int dataSize) {
- int maxGridSize = 1 + (1<<(levels-1));
- int spacing = 1<<(levels-lvl);
+static CCG_INLINE void *_face_getIFCoEdge(CCGFace *f, CCGEdge *e, int lvl, int eX, int eY, int levels, int dataSize)
+{
+ int maxGridSize = 1 + (1 << (levels - 1));
+ int spacing = 1 << (levels - lvl);
int S, x, y, cx, cy;
- for (S=0; S<f->numVerts; S++)
- if (FACE_getEdges(f)[S]==e)
+ for (S = 0; S < f->numVerts; S++)
+ if (FACE_getEdges(f)[S] == e)
break;
- eX = eX*spacing;
- eY = eY*spacing;
+ eX = eX * spacing;
+ eY = eY * spacing;
if (e->v0!=FACE_getVerts(f)[S]) {
- eX = (maxGridSize*2 - 1)-1 - eX;
+ eX = (maxGridSize * 2 - 1) - 1 - eX;
}
y = maxGridSize - 1 - eX;
x = maxGridSize - 1 - eY;
if (x<0) {
- S = (S+f->numVerts-1)%f->numVerts;
+ S = (S + f->numVerts - 1) % f->numVerts;
cx = y;
cy = -x;
- } else if (y<0) {
- S = (S+1)%f->numVerts;
+ }
+ else if (y < 0) {
+ S = (S + 1) % f->numVerts;
cx = -y;
cy = x;
- } else {
+ }
+ else {
cx = x;
cy = y;
}
return _face_getIFCo(f, levels, S, cx, cy, levels, dataSize);
}
-static float *_face_getIFNoEdge(CCGFace *f, CCGEdge *e, int lvl, int eX, int eY, int levels, int dataSize, int normalDataOffset) {
- return (float*) ((byte*) _face_getIFCoEdge(f, e, lvl, eX, eY, levels, dataSize) + normalDataOffset);
+static float *_face_getIFNoEdge(CCGFace *f, CCGEdge *e, int lvl, int eX, int eY, int levels, int dataSize, int normalDataOffset)
+{
+ return (float *) ((byte *) _face_getIFCoEdge(f, e, lvl, eX, eY, levels, dataSize) + normalDataOffset);
}
-static void _face_calcIFNo(CCGFace *f, int lvl, int S, int x, int y, float *no, int levels, int dataSize) {
- float *a = _face_getIFCo(f, lvl, S, x+0, y+0, levels, dataSize);
- 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);
+static void _face_calcIFNo(CCGFace *f, int lvl, int S, int x, int y, float *no, int levels, int dataSize)
+{
+ float *a = _face_getIFCo(f, lvl, S, x + 0, y + 0, levels, dataSize);
+ 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 length;
- 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;
- length = sqrt(no[0]*no[0] + no[1]*no[1] + no[2]*no[2]);
+ length = sqrt(no[0] * no[0] + no[1] * no[1] + no[2] * no[2]);
- if (length>EPSILON) {
+ if (length > EPSILON) {
float invLength = 1.f/length;
no[0] *= invLength;
no[1] *= invLength;
no[2] *= invLength;
- } else {
+ }
+ else {
NormZero(no);
}
}
-static void _face_free(CCGFace *f, CCGSubSurf *ss) {
+static void _face_free(CCGFace *f, CCGSubSurf *ss)
+{
CCGSUBSURF_free(ss, f);
}
-static void _face_unlinkMarkAndFree(CCGFace *f, CCGSubSurf *ss) {
+static void _face_unlinkMarkAndFree(CCGFace *f, CCGSubSurf *ss)
+{
int j;
- for (j=0; j<f->numVerts; j++) {
+ for (j = 0; j < f->numVerts; j++) {
_vert_remFace(FACE_getVerts(f)[j], f);
_edge_remFace(FACE_getEdges(f)[j], f);
FACE_getVerts(f)[j]->flags |= Vert_eEffected;
@@ -643,7 +706,8 @@ static void _face_unlinkMarkAndFree(CCGFace *f, CCGSubSurf *ss) {
/***/
-CCGSubSurf *ccgSubSurf_new(CCGMeshIFC *ifc, int subdivLevels, CCGAllocatorIFC *allocatorIFC, CCGAllocatorHDL allocator) {
+CCGSubSurf *ccgSubSurf_new(CCGMeshIFC *ifc, int subdivLevels, CCGAllocatorIFC *allocatorIFC, CCGAllocatorHDL allocator)
+{
if (!allocatorIFC) {
allocatorIFC = _getStandardAllocatorIFC();
allocator = NULL;
@@ -651,7 +715,8 @@ CCGSubSurf *ccgSubSurf_new(CCGMeshIFC *ifc, int subdivLevels, CCGAllocatorIFC *a
if (subdivLevels<1) {
return NULL;
- } else {
+ }
+ else {
CCGSubSurf *ss = allocatorIFC->alloc(allocator, sizeof(*ss));
ss->allocatorIFC = *allocatorIFC;
@@ -691,7 +756,8 @@ CCGSubSurf *ccgSubSurf_new(CCGMeshIFC *ifc, int subdivLevels, CCGAllocatorIFC *a
}
}
-void ccgSubSurf_free(CCGSubSurf *ss) {
+void ccgSubSurf_free(CCGSubSurf *ss)
+{
CCGAllocatorIFC allocatorIFC = ss->allocatorIFC;
CCGAllocatorHDL allocator = ss->allocator;
@@ -719,7 +785,8 @@ void ccgSubSurf_free(CCGSubSurf *ss) {
}
}
-CCGError ccgSubSurf_setAllowEdgeCreation(CCGSubSurf *ss, int allowEdgeCreation, float defaultCreaseValue, void *defaultUserData) {
+CCGError ccgSubSurf_setAllowEdgeCreation(CCGSubSurf *ss, int allowEdgeCreation, float defaultCreaseValue, void *defaultUserData)
+{
if (ss->defaultEdgeUserData) {
CCGSUBSURF_free(ss, ss->defaultEdgeUserData);
}
@@ -730,13 +797,15 @@ CCGError ccgSubSurf_setAllowEdgeCreation(CCGSubSurf *ss, int allowEdgeCreation,
if (defaultUserData) {
memcpy(ss->defaultEdgeUserData, defaultUserData, ss->meshIFC.edgeUserSize);
- } else {
+ }
+ else {
memset(ss->defaultEdgeUserData, 0, ss->meshIFC.edgeUserSize);
}
return eCCGError_None;
}
-void ccgSubSurf_getAllowEdgeCreation(CCGSubSurf *ss, int *allowEdgeCreation_r, float *defaultCreaseValue_r, void *defaultUserData_r) {
+void ccgSubSurf_getAllowEdgeCreation(CCGSubSurf *ss, int *allowEdgeCreation_r, float *defaultCreaseValue_r, void *defaultUserData_r)
+{
if (allowEdgeCreation_r) *allowEdgeCreation_r = ss->allowEdgeCreation;
if (ss->allowEdgeCreation) {
if (defaultCreaseValue_r) *defaultCreaseValue_r = ss->defaultCreaseValue;
@@ -744,10 +813,12 @@ void ccgSubSurf_getAllowEdgeCreation(CCGSubSurf *ss, int *allowEdgeCreation_r, f
}
}
-CCGError ccgSubSurf_setSubdivisionLevels(CCGSubSurf *ss, int subdivisionLevels) {
+CCGError ccgSubSurf_setSubdivisionLevels(CCGSubSurf *ss, int subdivisionLevels)
+{
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);
@@ -770,19 +841,23 @@ void ccgSubSurf_getUseAgeCounts(CCGSubSurf *ss, int *useAgeCounts_r, int *vertUs
if (faceUserOffset_r) *faceUserOffset_r = ss->faceUserAgeOffset;
}
-CCGError ccgSubSurf_setUseAgeCounts(CCGSubSurf *ss, int useAgeCounts, int vertUserOffset, int edgeUserOffset, int faceUserOffset) {
+CCGError ccgSubSurf_setUseAgeCounts(CCGSubSurf *ss, int useAgeCounts, int vertUserOffset, int edgeUserOffset, int faceUserOffset)
+{
if (useAgeCounts) {
- if ( (vertUserOffset+4>ss->meshIFC.vertUserSize) ||
- (edgeUserOffset+4>ss->meshIFC.edgeUserSize) ||
- (faceUserOffset+4>ss->meshIFC.faceUserSize)) {
+ if ((vertUserOffset + 4 > ss->meshIFC.vertUserSize) ||
+ (edgeUserOffset + 4 > ss->meshIFC.edgeUserSize) ||
+ (faceUserOffset + 4 > ss->meshIFC.faceUserSize))
+ {
return eCCGError_InvalidValue;
- } else {
+ }
+ else {
ss->useAgeCounts = 1;
ss->vertUserAgeOffset = vertUserOffset;
ss->edgeUserAgeOffset = edgeUserOffset;
ss->faceUserAgeOffset = faceUserOffset;
}
- } else {
+ }
+ else {
ss->useAgeCounts = 0;
ss->vertUserAgeOffset = ss->edgeUserAgeOffset = ss->faceUserAgeOffset = 0;
}
@@ -790,15 +865,18 @@ CCGError ccgSubSurf_setUseAgeCounts(CCGSubSurf *ss, int useAgeCounts, int vertUs
return eCCGError_None;
}
-CCGError ccgSubSurf_setCalcVertexNormals(CCGSubSurf *ss, int useVertNormals, int normalDataOffset) {
+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 {
+ }
+ else {
ss->calcVertNormals = 1;
ss->normalDataOffset = normalDataOffset;
}
- } else {
+ }
+ else {
ss->calcVertNormals = 0;
ss->normalDataOffset = 0;
}
@@ -808,7 +886,8 @@ CCGError ccgSubSurf_setCalcVertexNormals(CCGSubSurf *ss, int useVertNormals, int
/***/
-CCGError ccgSubSurf_initFullSync(CCGSubSurf *ss) {
+CCGError ccgSubSurf_initFullSync(CCGSubSurf *ss)
+{
if (ss->syncState!=eSyncState_None) {
return eCCGError_InvalidSyncState;
}
@@ -826,15 +905,16 @@ CCGError ccgSubSurf_initFullSync(CCGSubSurf *ss) {
ss->numGrids = 0;
ss->lenTempArrays = 12;
- ss->tempVerts = MEM_mallocN(sizeof(*ss->tempVerts)*ss->lenTempArrays, "CCGSubsurf tempVerts");
- ss->tempEdges = MEM_mallocN(sizeof(*ss->tempEdges)*ss->lenTempArrays, "CCGSubsurf tempEdges");
+ ss->tempVerts = MEM_mallocN(sizeof(*ss->tempVerts) * ss->lenTempArrays, "CCGSubsurf tempVerts");
+ ss->tempEdges = MEM_mallocN(sizeof(*ss->tempEdges) * ss->lenTempArrays, "CCGSubsurf tempEdges");
ss->syncState = eSyncState_Vert;
return eCCGError_None;
}
-CCGError ccgSubSurf_initPartialSync(CCGSubSurf *ss) {
+CCGError ccgSubSurf_initPartialSync(CCGSubSurf *ss)
+{
if (ss->syncState!=eSyncState_None) {
return eCCGError_InvalidSyncState;
}
@@ -846,16 +926,19 @@ CCGError ccgSubSurf_initPartialSync(CCGSubSurf *ss) {
return eCCGError_None;
}
-CCGError ccgSubSurf_syncVertDel(CCGSubSurf *ss, CCGVertHDL vHDL) {
+CCGError ccgSubSurf_syncVertDel(CCGSubSurf *ss, CCGVertHDL vHDL)
+{
if (ss->syncState!=eSyncState_Partial) {
return eCCGError_InvalidSyncState;
- } else {
+ }
+ else {
void **prevp;
CCGVert *v = _ehash_lookupWithPrev(ss->vMap, vHDL, &prevp);
if (!v || v->numFaces || v->numEdges) {
return eCCGError_InvalidValue;
- } else {
+ }
+ else {
*prevp = v->next;
_vert_free(v, ss);
}
@@ -864,16 +947,19 @@ CCGError ccgSubSurf_syncVertDel(CCGSubSurf *ss, CCGVertHDL vHDL) {
return eCCGError_None;
}
-CCGError ccgSubSurf_syncEdgeDel(CCGSubSurf *ss, CCGEdgeHDL eHDL) {
+CCGError ccgSubSurf_syncEdgeDel(CCGSubSurf *ss, CCGEdgeHDL eHDL)
+{
if (ss->syncState!=eSyncState_Partial) {
return eCCGError_InvalidSyncState;
- } else {
+ }
+ else {
void **prevp;
CCGEdge *e = _ehash_lookupWithPrev(ss->eMap, eHDL, &prevp);
if (!e || e->numFaces) {
return eCCGError_InvalidValue;
- } else {
+ }
+ else {
*prevp = e->next;
_edge_unlinkMarkAndFree(e, ss);
}
@@ -882,16 +968,19 @@ CCGError ccgSubSurf_syncEdgeDel(CCGSubSurf *ss, CCGEdgeHDL eHDL) {
return eCCGError_None;
}
-CCGError ccgSubSurf_syncFaceDel(CCGSubSurf *ss, CCGFaceHDL fHDL) {
+CCGError ccgSubSurf_syncFaceDel(CCGSubSurf *ss, CCGFaceHDL fHDL)
+{
if (ss->syncState!=eSyncState_Partial) {
return eCCGError_InvalidSyncState;
- } else {
+ }
+ else {
void **prevp;
CCGFace *f = _ehash_lookupWithPrev(ss->fMap, fHDL, &prevp);
if (!f) {
return eCCGError_InvalidValue;
- } else {
+ }
+ else {
*prevp = f->next;
_face_unlinkMarkAndFree(f, ss);
}
@@ -900,37 +989,40 @@ CCGError ccgSubSurf_syncFaceDel(CCGSubSurf *ss, CCGFaceHDL fHDL) {
return eCCGError_None;
}
-CCGError ccgSubSurf_syncVert(CCGSubSurf *ss, CCGVertHDL vHDL, const void *vertData, int seam, CCGVert **v_r) {
+CCGError ccgSubSurf_syncVert(CCGSubSurf *ss, CCGVertHDL vHDL, const void *vertData, int seam, CCGVert **v_r)
+{
void **prevp;
CCGVert *v = NULL;
short seamflag = (seam)? Vert_eSeam: 0;
- if (ss->syncState==eSyncState_Partial) {
+ 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;
- } else if (!VertDataEqual(vertData, _vert_getCo(v, 0, ss->meshIFC.vertDataSize)) || ((v->flags & Vert_eSeam) != 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;
- for (i=0; i<v->numEdges; i++) {
+ for (i = 0; i < v->numEdges; i++) {
CCGEdge *e = v->edges[i];
e->v0->flags |= Vert_eEffected;
e->v1->flags |= Vert_eEffected;
}
- for (i=0; i<v->numFaces; i++) {
+ for (i = 0; i < v->numFaces; i++) {
CCGFace *f = v->faces[i];
- for (j=0; j<f->numVerts; j++) {
+ for (j = 0; j < f->numVerts; j++) {
FACE_getVerts(f)[j]->flags |= Vert_eEffected;
}
}
}
- } else {
+ }
+ else {
if (ss->syncState!=eSyncState_Vert) {
return eCCGError_InvalidSyncState;
}
@@ -941,12 +1033,14 @@ CCGError ccgSubSurf_syncVert(CCGSubSurf *ss, CCGVertHDL vHDL, const void *vertDa
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)) {
+ }
+ 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;
- } else {
+ }
+ else {
*prevp = v->next;
_ehash_insert(ss->vMap, (EHEntry*) v);
v->flags = 0;
@@ -957,11 +1051,12 @@ CCGError ccgSubSurf_syncVert(CCGSubSurf *ss, CCGVertHDL vHDL, const void *vertDa
return eCCGError_None;
}
-CCGError ccgSubSurf_syncEdge(CCGSubSurf *ss, CCGEdgeHDL eHDL, CCGVertHDL e_vHDL0, CCGVertHDL e_vHDL1, float crease, CCGEdge **e_r) {
+CCGError ccgSubSurf_syncEdge(CCGSubSurf *ss, CCGEdgeHDL eHDL, CCGVertHDL e_vHDL0, CCGVertHDL e_vHDL1, float crease, CCGEdge **e_r)
+{
void **prevp;
CCGEdge *e = NULL, *eNew;
- if (ss->syncState==eSyncState_Partial) {
+ 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) {
CCGVert *v0 = _ehash_lookup(ss->vMap, e_vHDL0);
@@ -974,17 +1069,20 @@ CCGError ccgSubSurf_syncEdge(CCGSubSurf *ss, CCGEdgeHDL eHDL, CCGVertHDL e_vHDL0
eNew->next = e->next;
_edge_unlinkMarkAndFree(e, ss);
- } else {
+ }
+ else {
_ehash_insert(ss->eMap, (EHEntry*) eNew);
}
eNew->v0->flags |= Vert_eEffected;
eNew->v1->flags |= Vert_eEffected;
}
- } else {
- if (ss->syncState==eSyncState_Vert) {
+ }
+ else {
+ if (ss->syncState == eSyncState_Vert) {
ss->syncState = eSyncState_Edge;
- } else if (ss->syncState!=eSyncState_Edge) {
+ }
+ else if (ss->syncState!=eSyncState_Edge) {
return eCCGError_InvalidSyncState;
}
@@ -996,7 +1094,8 @@ CCGError ccgSubSurf_syncEdge(CCGSubSurf *ss, CCGEdgeHDL eHDL, CCGVertHDL e_vHDL0
_ehash_insert(ss->eMap, (EHEntry*) e);
e->v0->flags |= Vert_eEffected;
e->v1->flags |= Vert_eEffected;
- } else {
+ }
+ else {
*prevp = e->next;
_ehash_insert(ss->eMap, (EHEntry*) e);
e->flags = 0;
@@ -1011,31 +1110,32 @@ CCGError ccgSubSurf_syncEdge(CCGSubSurf *ss, CCGEdgeHDL eHDL, CCGVertHDL e_vHDL0
return eCCGError_None;
}
-CCGError ccgSubSurf_syncFace(CCGSubSurf *ss, CCGFaceHDL fHDL, int numVerts, CCGVertHDL *vHDLs, CCGFace **f_r) {
+CCGError ccgSubSurf_syncFace(CCGSubSurf *ss, CCGFaceHDL fHDL, int numVerts, CCGVertHDL *vHDLs, CCGFace **f_r)
+{
void **prevp;
CCGFace *f = NULL, *fNew;
int j, k, topologyChanged = 0;
- if (numVerts>ss->lenTempArrays) {
- ss->lenTempArrays = (numVerts<ss->lenTempArrays*2)?ss->lenTempArrays*2:numVerts;
- ss->tempVerts = MEM_reallocN(ss->tempVerts, sizeof(*ss->tempVerts)*ss->lenTempArrays);
- ss->tempEdges = MEM_reallocN(ss->tempEdges, sizeof(*ss->tempEdges)*ss->lenTempArrays);
+ if (numVerts > ss->lenTempArrays) {
+ ss->lenTempArrays = (numVerts < ss->lenTempArrays * 2) ? ss->lenTempArrays * 2 : numVerts;
+ ss->tempVerts = MEM_reallocN(ss->tempVerts, sizeof(*ss->tempVerts) * ss->lenTempArrays);
+ ss->tempEdges = MEM_reallocN(ss->tempEdges, sizeof(*ss->tempEdges) * ss->lenTempArrays);
}
- if (ss->syncState==eSyncState_Partial) {
+ if (ss->syncState == eSyncState_Partial) {
f = _ehash_lookupWithPrev(ss->fMap, fHDL, &prevp);
- for (k=0; k<numVerts; k++) {
+ for (k = 0; k < numVerts; k++) {
ss->tempVerts[k] = _ehash_lookup(ss->vMap, vHDLs[k]);
}
- for (k=0; k<numVerts; k++) {
- ss->tempEdges[k] = _vert_findEdgeTo(ss->tempVerts[k], ss->tempVerts[(k+1)%numVerts]);
+ for (k = 0; k < numVerts; k++) {
+ ss->tempEdges[k] = _vert_findEdgeTo(ss->tempVerts[k], ss->tempVerts[(k + 1) % numVerts]);
}
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))
+ memcmp(FACE_getVerts(f), ss->tempVerts, sizeof(*ss->tempVerts) * numVerts) ||
+ memcmp(FACE_getEdges(f), ss->tempEdges, sizeof(*ss->tempEdges) * numVerts))
topologyChanged = 1;
}
@@ -1049,42 +1149,46 @@ CCGError ccgSubSurf_syncFace(CCGSubSurf *ss, CCGFaceHDL fHDL, int numVerts, CCGV
fNew->next = f->next;
_face_unlinkMarkAndFree(f, ss);
- } else {
+ }
+ else {
ss->numGrids += numVerts;
_ehash_insert(ss->fMap, (EHEntry*) fNew);
}
- for (k=0; k<numVerts; k++)
+ for (k = 0; k < numVerts; k++)
FACE_getVerts(fNew)[k]->flags |= Vert_eEffected;
}
- } else {
- if (ss->syncState==eSyncState_Vert || ss->syncState==eSyncState_Edge) {
+ }
+ else {
+ 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;
}
f = _ehash_lookupWithPrev(ss->oldFMap, fHDL, &prevp);
- for (k=0; k<numVerts; k++) {
+ for (k = 0; k < numVerts; k++) {
ss->tempVerts[k] = _ehash_lookup(ss->vMap, vHDLs[k]);
if (!ss->tempVerts[k])
return eCCGError_InvalidValue;
}
- for (k=0; k<numVerts; k++) {
- ss->tempEdges[k] = _vert_findEdgeTo(ss->tempVerts[k], ss->tempVerts[(k+1)%numVerts]);
+ for (k = 0; k < numVerts; k++) {
+ ss->tempEdges[k] = _vert_findEdgeTo(ss->tempVerts[k], ss->tempVerts[(k + 1) % numVerts]);
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);
+ 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) {
memcpy(ccgSubSurf_getEdgeUserData(ss, e), ss->defaultEdgeUserData, ss->meshIFC.edgeUserSize);
}
- } else {
+ }
+ else {
return eCCGError_InvalidValue;
}
}
@@ -1092,8 +1196,8 @@ 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))
+ memcmp(FACE_getVerts(f), ss->tempVerts, sizeof(*ss->tempVerts) * numVerts) ||
+ memcmp(FACE_getEdges(f), ss->tempEdges, sizeof(*ss->tempEdges) * numVerts))
topologyChanged = 1;
}
@@ -1102,17 +1206,18 @@ CCGError ccgSubSurf_syncFace(CCGSubSurf *ss, CCGFaceHDL fHDL, int numVerts, CCGV
_ehash_insert(ss->fMap, (EHEntry*) f);
ss->numGrids += numVerts;
- for (k=0; k<numVerts; k++)
+ for (k = 0; k < numVerts; k++)
FACE_getVerts(f)[k]->flags |= Vert_eEffected;
- } else {
+ }
+ else {
*prevp = f->next;
_ehash_insert(ss->fMap, (EHEntry*) f);
f->flags = 0;
ss->numGrids += f->numVerts;
- for (j=0; j<f->numVerts; j++) {
- if (FACE_getVerts(f)[j]->flags&Vert_eChanged) {
- for (k=0; k<f->numVerts; k++)
+ for (j = 0; j < f->numVerts; j++) {
+ if (FACE_getVerts(f)[j]->flags & Vert_eChanged) {
+ for (k = 0; k < f->numVerts; k++)
FACE_getVerts(f)[k]->flags |= Vert_eEffected;
break;
}
@@ -1125,12 +1230,14 @@ CCGError ccgSubSurf_syncFace(CCGSubSurf *ss, CCGFaceHDL fHDL, int numVerts, CCGV
}
static void ccgSubSurf__sync(CCGSubSurf *ss);
-CCGError ccgSubSurf_processSync(CCGSubSurf *ss) {
- if (ss->syncState==eSyncState_Partial) {
+CCGError ccgSubSurf_processSync(CCGSubSurf *ss)
+{
+ if (ss->syncState == eSyncState_Partial) {
ss->syncState = eSyncState_None;
ccgSubSurf__sync(ss);
- } else if (ss->syncState) {
+ }
+ else if (ss->syncState) {
_ehash_free(ss->oldFMap, (EHEntryFreeFP) _face_unlinkMarkAndFree, ss);
_ehash_free(ss->oldEMap, (EHEntryFreeFP) _edge_unlinkMarkAndFree, ss);
_ehash_free(ss->oldVMap, (EHEntryFreeFP) _vert_free, ss);
@@ -1146,7 +1253,8 @@ CCGError ccgSubSurf_processSync(CCGSubSurf *ss) {
ss->syncState = eSyncState_None;
ccgSubSurf__sync(ss);
- } else {
+ }
+ else {
return eCCGError_InvalidSyncState;
}
@@ -1164,130 +1272,133 @@ static void ccgSubSurf__calcVertNormals(CCGSubSurf *ss,
int i,ptrIdx;
int subdivLevels = ss->subdivLevels;
int lvl = ss->subdivLevels;
- int edgeSize = 1 + (1<<lvl);
- int gridSize = 1 + (1<<(lvl-1));
+ int edgeSize = 1 + (1 << lvl);
+ int gridSize = 1 + (1 << (lvl - 1));
int normalDataOffset = ss->normalDataOffset;
int vertDataSize = ss->meshIFC.vertDataSize;
- #pragma omp parallel for private(ptrIdx) if(numEffectedF*edgeSize*edgeSize*4 >= CCG_OMP_LIMIT)
- for (ptrIdx=0; ptrIdx<numEffectedF; ptrIdx++) {
+ #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];
int S, x, y;
float no[3];
- for (S=0; S<f->numVerts; S++) {
- for (y=0; y<gridSize-1; y++)
- for (x=0; x<gridSize-1; x++)
+ for (S = 0; S < f->numVerts; S++) {
+ for (y = 0; y < gridSize - 1; y++)
+ 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)
- for (x=0; x<gridSize-1; x++)
- NormZero(FACE_getIFNo(f, lvl, S, x, gridSize-1));
+ 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)
- for (y=0; y<gridSize-1; y++)
- NormZero(FACE_getIFNo(f, lvl, S, gridSize-1, y));
+ for (y = 0; y < gridSize - 1; y++)
+ NormZero(FACE_getIFNo(f, lvl, S, gridSize - 1, y));
if (FACE_getVerts(f)[S]->flags&Vert_eEffected)
- NormZero(FACE_getIFNo(f, lvl, S, gridSize-1, gridSize-1));
+ 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);
+ 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 yLimitNext = xLimit;
int xLimitPrev = yLimit;
- for (y=0; y<gridSize - 1; y++) {
- for (x=0; x<gridSize - 1; x++) {
- int xPlusOk = (!xLimit || x<gridSize-2);
- int yPlusOk = (!yLimit || y<gridSize-2);
+ for (y = 0; y < gridSize - 1; y++) {
+ for (x = 0; x < gridSize - 1; x++) {
+ int xPlusOk = (!xLimit || x < gridSize - 2);
+ int yPlusOk = (!yLimit || y < gridSize - 2);
FACE_calcIFNo(f, lvl, S, x, y, no);
- NormAdd(FACE_getIFNo(f, lvl, S, x+0, y+0), no);
+ NormAdd(FACE_getIFNo(f, lvl, S, x + 0, y + 0), no);
if (xPlusOk)
- NormAdd(FACE_getIFNo(f, lvl, S, x+1, y+0), no);
+ NormAdd(FACE_getIFNo(f, lvl, S, x + 1, y + 0), no);
if (yPlusOk)
- NormAdd(FACE_getIFNo(f, lvl, S, x+0, y+1), no);
+ NormAdd(FACE_getIFNo(f, lvl, S, x + 0, y + 1), no);
if (xPlusOk && yPlusOk) {
- if (x<gridSize-2 || y<gridSize-2 || FACE_getVerts(f)[S]->flags&Vert_eEffected) {
- NormAdd(FACE_getIFNo(f, lvl, S, x+1, y+1), no);
+ if (x < gridSize - 2 || y < gridSize - 2 || FACE_getVerts(f)[S]->flags & Vert_eEffected) {
+ NormAdd(FACE_getIFNo(f, lvl, S, x + 1, y + 1), no);
}
}
- if (x==0 && y==0) {
+ if (x == 0 && y == 0) {
int K;
- if (!yLimitNext || 1<gridSize-1)
- NormAdd(FACE_getIFNo(f, lvl, (S+1)%f->numVerts, 0, 1), no);
- if (!xLimitPrev || 1<gridSize-1)
- NormAdd(FACE_getIFNo(f, lvl, (S-1+f->numVerts)%f->numVerts, 1, 0), no);
+ if (!yLimitNext || 1<gridSize - 1)
+ NormAdd(FACE_getIFNo(f, lvl, (S + 1) % f->numVerts, 0, 1), no);
+ 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++) {
+ for (K = 0; K < f->numVerts; K++) {
if (K!=S) {
NormAdd(FACE_getIFNo(f, lvl, K, 0, 0), no);
}
}
- } else if (y==0) {
- NormAdd(FACE_getIFNo(f, lvl, (S+1)%f->numVerts, 0, x), no);
- if (!yLimitNext || x<gridSize-2)
- NormAdd(FACE_getIFNo(f, lvl, (S+1)%f->numVerts, 0, x+1), no);
- } else if (x==0) {
- NormAdd(FACE_getIFNo(f, lvl, (S-1+f->numVerts)%f->numVerts, y, 0), no);
- if (!xLimitPrev || y<gridSize-2)
- NormAdd(FACE_getIFNo(f, lvl, (S-1+f->numVerts)%f->numVerts, y+1, 0), no);
+ }
+ else if (y == 0) {
+ NormAdd(FACE_getIFNo(f, lvl, (S + 1) % f->numVerts, 0, x), no);
+ if (!yLimitNext || x < gridSize - 2)
+ NormAdd(FACE_getIFNo(f, lvl, (S + 1) % f->numVerts, 0, x + 1), no);
+ }
+ else if (x == 0) {
+ NormAdd(FACE_getIFNo(f, lvl, (S - 1 + f->numVerts) % f->numVerts, y, 0), no);
+ if (!xLimitPrev || y < gridSize - 2)
+ NormAdd(FACE_getIFNo(f, lvl, (S - 1 + f->numVerts) % f->numVerts, y + 1, 0), no);
}
}
}
}
}
// XXX can I reduce the number of normalisations here?
- for (ptrIdx=0; ptrIdx<numEffectedV; ptrIdx++) {
+ for (ptrIdx = 0; ptrIdx < numEffectedV; ptrIdx++) {
CCGVert *v = (CCGVert*) effectedV[ptrIdx];
float length, *no = _vert_getNo(v, lvl, vertDataSize, normalDataOffset);
NormZero(no);
- for (i=0; i<v->numFaces; i++) {
+ 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 = sqrt(no[0]*no[0] + no[1]*no[1] + no[2]*no[2]);
+ length = sqrt(no[0] * no[0] + no[1] * no[1] + no[2] * no[2]);
- if (length>EPSILON) {
+ if (length > EPSILON) {
float invLength = 1.0f/length;
no[0] *= invLength;
no[1] *= invLength;
no[2] *= invLength;
- } else {
+ }
+ else {
NormZero(no);
}
- for (i=0; i<v->numFaces; i++) {
+ 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++) {
+ for (ptrIdx = 0; ptrIdx < numEffectedE; ptrIdx++) {
CCGEdge *e = (CCGEdge*) effectedE[ptrIdx];
if (e->numFaces) {
- CCGFace *fLast = e->faces[e->numFaces-1];
+ CCGFace *fLast = e->faces[e->numFaces - 1];
int x;
- for (i=0; i<e->numFaces-1; i++) {
+ for (i = 0; i < e->numFaces - 1; i++) {
CCGFace *f = e->faces[i];
- for (x=1; x<edgeSize-1; x++) {
+ 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));
}
}
- for (i=0; i<e->numFaces-1; i++) {
+ for (i = 0; i < e->numFaces - 1; i++) {
CCGFace *f = e->faces[i];
- for (x=1; x<edgeSize-1; x++) {
+ 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));
}
@@ -1295,50 +1406,51 @@ 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++) {
+ #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];
int S, x, y;
- for (S=0; S<f->numVerts; S++) {
- NormCopy(FACE_getIFNo(f, lvl, (S+1)%f->numVerts, 0, gridSize-1),
- FACE_getIFNo(f, lvl, S, gridSize-1, 0));
+ for (S = 0; S < f->numVerts; S++) {
+ NormCopy(FACE_getIFNo(f, lvl, (S + 1) % f->numVerts, 0, gridSize - 1),
+ FACE_getIFNo(f, lvl, S, gridSize - 1, 0));
}
- for (S=0; S<f->numVerts; S++) {
- for (y=0; y<gridSize; y++) {
- for (x=0; x<gridSize; x++) {
+ for (S = 0; S < f->numVerts; S++) {
+ for (y = 0; y < gridSize; y++) {
+ for (x = 0; x < gridSize; x++) {
float *no = FACE_getIFNo(f, lvl, S, x, y);
- float length = sqrt(no[0]*no[0] + no[1]*no[1] + no[2]*no[2]);
+ float length = sqrt(no[0] * no[0] + no[1] * no[1] + no[2] * no[2]);
- if (length>EPSILON) {
+ if (length > EPSILON) {
float invLength = 1.0f/length;
no[0] *= invLength;
no[1] *= invLength;
no[2] *= invLength;
- } else {
+ }
+ else {
NormZero(no);
}
}
}
- VertDataCopy((float*)((byte*)FACE_getCenterData(f) + normalDataOffset),
+ VertDataCopy((float *)((byte *)FACE_getCenterData(f) + normalDataOffset),
FACE_getIFNo(f, lvl, S, 0, 0));
- for (x=1; x<gridSize-1; x++)
+ for (x = 1; x < gridSize - 1; x++)
NormCopy(FACE_getIENo(f, lvl, S, x),
FACE_getIFNo(f, lvl, S, x, 0));
}
}
- for (ptrIdx=0; ptrIdx<numEffectedE; ptrIdx++) {
+ for (ptrIdx = 0; ptrIdx < numEffectedE; ptrIdx++) {
CCGEdge *e = (CCGEdge*) effectedE[ptrIdx];
if (e->numFaces) {
CCGFace *f = e->faces[0];
int x;
- for (x=0; x<edgeSize; x++)
+ for (x = 0; x < edgeSize; x++)
NormCopy(EDGE_getNo(e, lvl, x),
_face_getIFNoEdge(f, e, lvl, x, 0, subdivLevels, vertDataSize, normalDataOffset));
}
@@ -1349,7 +1461,7 @@ static void ccgSubSurf__calcVertNormals(CCGSubSurf *ss,
* most likely not used so just zero out. */
int x;
- for (x=0; x<edgeSize; x++) {
+ for (x = 0; x < edgeSize; x++) {
NormZero(EDGE_getNo(e, lvl, x));
}
}
@@ -1361,34 +1473,36 @@ static void ccgSubSurf__calcVertNormals(CCGSubSurf *ss,
#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,
- int numEffectedV, int numEffectedE, int numEffectedF, int curLvl) {
+ CCGVert **effectedV, CCGEdge **effectedE, CCGFace **effectedF,
+ int numEffectedV, int numEffectedE, int numEffectedF, int curLvl)
+{
int subdivLevels = ss->subdivLevels;
- int edgeSize = 1 + (1<<curLvl);
- int gridSize = 1 + (1<<(curLvl-1));
- int nextLvl = curLvl+1;
+ int edgeSize = 1 + (1 << curLvl);
+ int gridSize = 1 + (1 << (curLvl - 1));
+ int nextLvl = curLvl + 1;
int ptrIdx, cornerIdx, i;
int vertDataSize = ss->meshIFC.vertDataSize;
void *q = ss->q, *r = ss->r;
- #pragma omp parallel for private(ptrIdx) if(numEffectedF*edgeSize*edgeSize*4 >= CCG_OMP_LIMIT)
- for (ptrIdx=0; ptrIdx<numEffectedF; ptrIdx++) {
+ #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];
int S, x, y;
/* interior face midpoints
* o 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++) {
+ 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;
- 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);
- void *co3 = FACE_getIFCo(f, curLvl, S, x+0, y+1);
+ 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);
+ void *co3 = FACE_getIFCo(f, curLvl, S, x + 0, y + 1);
void *co = FACE_getIFCo(f, nextLvl, S, fx, fy);
VertDataAvg4(co, co0, co1, co2, co3);
@@ -1400,14 +1514,14 @@ static void ccgSubSurf__calcSubdivLevel(CCGSubSurf *ss,
* o old interior edge points
* o new interior face midpoints
*/
- for (S=0; S<f->numVerts; S++) {
- for (x=0; x<gridSize-1; x++) {
- int fx = x*2 + 1;
- void *co0 = FACE_getIECo(f, curLvl, S, x+0);
- void *co1 = FACE_getIECo(f, curLvl, S, x+1);
- void *co2 = FACE_getIFCo(f, nextLvl, (S+1)%f->numVerts, 1, fx);
+ for (S = 0; S < f->numVerts; S++) {
+ for (x = 0; x < gridSize - 1; x++) {
+ int fx = x * 2 + 1;
+ void *co0 = FACE_getIECo(f, curLvl, S, x + 0);
+ void *co1 = FACE_getIECo(f, curLvl, S, x + 1);
+ void *co2 = FACE_getIFCo(f, nextLvl, (S + 1) % f->numVerts, 1, fx);
void *co3 = FACE_getIFCo(f, nextLvl, S, fx, 1);
- void *co = FACE_getIECo(f, nextLvl, S, fx);
+ void *co = FACE_getIECo(f, nextLvl, S, fx);
VertDataAvg4(co, co0, co1, co2, co3);
}
@@ -1418,30 +1532,30 @@ static void ccgSubSurf__calcSubdivLevel(CCGSubSurf *ss,
*/
/* vertical */
- for (x=1; x<gridSize-1; x++) {
- for (y=0; y<gridSize-1; y++) {
- int fx = x*2;
- int fy = y*2+1;
- void *co0 = FACE_getIFCo(f, curLvl, S, x, y+0);
- void *co1 = FACE_getIFCo(f, curLvl, S, x, y+1);
- void *co2 = FACE_getIFCo(f, nextLvl, S, fx-1, fy);
- void *co3 = FACE_getIFCo(f, nextLvl, S, fx+1, fy);
- void *co = FACE_getIFCo(f, nextLvl, S, fx, fy);
+ for (x = 1; x < gridSize - 1; x++) {
+ for (y = 0; y < gridSize - 1; y++) {
+ int fx = x * 2;
+ int fy = y * 2 + 1;
+ void *co0 = FACE_getIFCo(f, curLvl, S, x, y + 0);
+ void *co1 = FACE_getIFCo(f, curLvl, S, x, y + 1);
+ void *co2 = FACE_getIFCo(f, nextLvl, S, fx - 1, fy);
+ void *co3 = FACE_getIFCo(f, nextLvl, S, fx + 1, fy);
+ void *co = FACE_getIFCo(f, nextLvl, S, fx, fy);
VertDataAvg4(co, co0, co1, co2, co3);
}
}
/* horizontal */
- for (y=1; y<gridSize-1; y++) {
- for (x=0; x<gridSize-1; x++) {
- int fx = x*2+1;
- int fy = y*2;
- void *co0 = FACE_getIFCo(f, curLvl, S, x+0, y);
- void *co1 = FACE_getIFCo(f, curLvl, S, x+1, y);
- void *co2 = FACE_getIFCo(f, nextLvl, S, fx, fy-1);
- void *co3 = FACE_getIFCo(f, nextLvl, S, fx, fy+1);
- void *co = FACE_getIFCo(f, nextLvl, S, fx, fy);
+ for (y = 1; y < gridSize - 1; y++) {
+ for (x = 0; x < gridSize - 1; x++) {
+ int fx = x * 2 + 1;
+ int fy = y * 2;
+ void *co0 = FACE_getIFCo(f, curLvl, S, x + 0, y);
+ void *co1 = FACE_getIFCo(f, curLvl, S, x + 1, y);
+ void *co2 = FACE_getIFCo(f, nextLvl, S, fx, fy - 1);
+ void *co3 = FACE_getIFCo(f, nextLvl, S, fx, fy + 1);
+ void *co = FACE_getIFCo(f, nextLvl, S, fx, fy);
VertDataAvg4(co, co0, co1, co2, co3);
}
@@ -1453,40 +1567,41 @@ static void ccgSubSurf__calcSubdivLevel(CCGSubSurf *ss,
* o old exterior edge points
* o new interior face midpoints
*/
- for (ptrIdx=0; ptrIdx<numEffectedE; ptrIdx++) {
+ for (ptrIdx = 0; ptrIdx < numEffectedE; ptrIdx++) {
CCGEdge *e = (CCGEdge*) effectedE[ptrIdx];
float sharpness = EDGE_getSharpness(e, curLvl);
int x, j;
if (_edge_isBoundary(e) || sharpness > 1.0f) {
- for (x=0; x<edgeSize-1; x++) {
- int fx = x*2 + 1;
- void *co0 = EDGE_getCo(e, curLvl, x+0);
- void *co1 = EDGE_getCo(e, curLvl, x+1);
- void *co = EDGE_getCo(e, nextLvl, fx);
+ for (x = 0; x < edgeSize - 1; x++) {
+ int fx = x * 2 + 1;
+ void *co0 = EDGE_getCo(e, curLvl, x + 0);
+ void *co1 = EDGE_getCo(e, curLvl, x + 1);
+ void *co = EDGE_getCo(e, nextLvl, fx);
VertDataCopy(co, co0);
VertDataAdd(co, co1);
VertDataMulN(co, 0.5f);
}
- } else {
- for (x=0; x<edgeSize-1; x++) {
- int fx = x*2 + 1;
- void *co0 = EDGE_getCo(e, curLvl, x+0);
- void *co1 = EDGE_getCo(e, curLvl, x+1);
- void *co = EDGE_getCo(e, nextLvl, fx);
+ }
+ else {
+ for (x = 0; x < edgeSize - 1; x++) {
+ int fx = x * 2 + 1;
+ void *co0 = EDGE_getCo(e, curLvl, x + 0);
+ void *co1 = EDGE_getCo(e, curLvl, x + 1);
+ void *co = EDGE_getCo(e, nextLvl, fx);
int numFaces = 0;
VertDataCopy(q, co0);
VertDataAdd(q, co1);
- for (j=0; j<e->numFaces; j++) {
+ for (j = 0; j < e->numFaces; j++) {
CCGFace *f = e->faces[j];
VertDataAdd(q, _face_getIFCoEdge(f, e, nextLvl, fx, 1, subdivLevels, vertDataSize));
numFaces++;
}
- VertDataMulN(q, 1.0f/(2.0f+numFaces));
+ VertDataMulN(q, 1.0f / (2.0f + numFaces));
VertDataCopy(r, co0);
VertDataAdd(r, co1);
@@ -1505,7 +1620,7 @@ static void ccgSubSurf__calcSubdivLevel(CCGSubSurf *ss,
* o old exterior edge points
* o new interior face midpoints
*/
- for (ptrIdx=0; ptrIdx<numEffectedV; ptrIdx++) {
+ for (ptrIdx = 0; ptrIdx < numEffectedV; ptrIdx++) {
CCGVert *v = (CCGVert*) effectedV[ptrIdx];
void *co = VERT_getCo(v, curLvl);
void *nCo = VERT_getCo(v, nextLvl);
@@ -1513,7 +1628,7 @@ static void ccgSubSurf__calcSubdivLevel(CCGSubSurf *ss,
float avgSharpness = 0.0;
int j, seam = VERT_seam(v), seamEdges = 0;
- for (j=0; j<v->numEdges; j++) {
+ for (j = 0; j < v->numEdges; j++) {
CCGEdge *e = v->edges[j];
float sharpness = EDGE_getSharpness(e, curLvl);
@@ -1523,12 +1638,13 @@ static void ccgSubSurf__calcSubdivLevel(CCGSubSurf *ss,
if (sharpness!=0.0f) {
sharpCount++;
avgSharpness += sharpness;
- } else {
+ }
+ else {
allSharp = 0;
}
}
- if(sharpCount) {
+ if (sharpCount) {
avgSharpness /= sharpCount;
if (avgSharpness > 1.0f) {
avgSharpness = 1.0f;
@@ -1540,11 +1656,12 @@ static void ccgSubSurf__calcSubdivLevel(CCGSubSurf *ss,
if (!v->numEdges) {
VertDataCopy(nCo, co);
- } else if (_vert_isBoundary(v)) {
+ }
+ else if (_vert_isBoundary(v)) {
int numBoundary = 0;
VertDataZero(r);
- for (j=0; j<v->numEdges; j++) {
+ for (j = 0; j < v->numEdges; j++) {
CCGEdge *e = v->edges[j];
if (_edge_isBoundary(e)) {
VertDataAdd(r, _edge_getCoVert(e, v, curLvl, 1, vertDataSize));
@@ -1556,19 +1673,20 @@ static void ccgSubSurf__calcSubdivLevel(CCGSubSurf *ss,
VertDataMulN(nCo, 0.75f);
VertDataMulN(r, 0.25f/numBoundary);
VertDataAdd(nCo, r);
- } else {
- int cornerIdx = (1 + (1<<(curLvl))) - 2;
+ }
+ else {
+ int cornerIdx = (1 + (1 << (curLvl))) - 2;
int numEdges = 0, numFaces = 0;
VertDataZero(q);
- for (j=0; j<v->numFaces; j++) {
+ for (j = 0; j < v->numFaces; j++) {
CCGFace *f = v->faces[j];
VertDataAdd(q, FACE_getIFCo(f, nextLvl, _face_getVertIndex(f,v), cornerIdx, cornerIdx));
numFaces++;
}
VertDataMulN(q, 1.0f/numFaces);
VertDataZero(r);
- for (j=0; j<v->numEdges; j++) {
+ for (j = 0; j < v->numEdges; j++) {
CCGEdge *e = v->edges[j];
VertDataAdd(r, _edge_getCoVert(e, v, curLvl, 1,vertDataSize));
numEdges++;
@@ -1576,7 +1694,7 @@ static void ccgSubSurf__calcSubdivLevel(CCGSubSurf *ss,
VertDataMulN(r, 1.0f/numEdges);
VertDataCopy(nCo, co);
- VertDataMulN(nCo, numEdges-2.0f);
+ VertDataMulN(nCo, numEdges - 2.0f);
VertDataAdd(nCo, q);
VertDataAdd(nCo, r);
VertDataMulN(nCo, 1.0f/numEdges);
@@ -1591,14 +1709,15 @@ static void ccgSubSurf__calcSubdivLevel(CCGSubSurf *ss,
allSharp = 1;
}
- for (j=0; j<v->numEdges; j++) {
+ for (j = 0; j < v->numEdges; j++) {
CCGEdge *e = v->edges[j];
float sharpness = EDGE_getSharpness(e, curLvl);
if (seam) {
if (_edge_isBoundary(e))
VertDataAdd(q, _edge_getCoVert(e, v, curLvl, 1, vertDataSize));
- } else if (sharpness != 0.0f) {
+ }
+ else if (sharpness != 0.0f) {
VertDataAdd(q, _edge_getCoVert(e, v, curLvl, 1, vertDataSize));
}
}
@@ -1606,7 +1725,7 @@ static void ccgSubSurf__calcSubdivLevel(CCGSubSurf *ss,
VertDataMulN(q, (float) 1/sharpCount);
if (sharpCount!=2 || allSharp) {
- // q = q + (co-q)*avgSharpness
+ // q = q + (co-q) * avgSharpness
VertDataCopy(r, co);
VertDataSub(r, q);
VertDataMulN(r, avgSharpness);
@@ -1619,7 +1738,7 @@ static void ccgSubSurf__calcSubdivLevel(CCGSubSurf *ss,
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);
@@ -1631,7 +1750,7 @@ static void ccgSubSurf__calcSubdivLevel(CCGSubSurf *ss,
* o old exterior edge midpoints
* o new interior face midpoints
*/
- for (ptrIdx=0; ptrIdx<numEffectedE; ptrIdx++) {
+ for (ptrIdx = 0; ptrIdx < numEffectedE; ptrIdx++) {
CCGEdge *e = (CCGEdge*) effectedE[ptrIdx];
float sharpness = EDGE_getSharpness(e, curLvl);
int sharpCount = 0;
@@ -1645,57 +1764,59 @@ static void ccgSubSurf__calcSubdivLevel(CCGSubSurf *ss,
if (avgSharpness > 1.0f) {
avgSharpness = 1.0f;
}
- } else {
+ }
+ else {
sharpCount = 0;
avgSharpness = 0;
}
if (_edge_isBoundary(e) && (!e->numFaces || sharpCount<2)) {
- for (x=1; x<edgeSize-1; x++) {
- int fx = x*2;
+ for (x = 1; x < edgeSize - 1; x++) {
+ int fx = x * 2;
void *co = EDGE_getCo(e, curLvl, x);
void *nCo = EDGE_getCo(e, nextLvl, fx);
- VertDataCopy(r, EDGE_getCo(e, curLvl, x-1));
- VertDataAdd(r, EDGE_getCo(e, curLvl, x+1));
+ VertDataCopy(r, EDGE_getCo(e, curLvl, x - 1));
+ VertDataAdd(r, EDGE_getCo(e, curLvl, x + 1));
VertDataMulN(r, 0.5f);
VertDataCopy(nCo, co);
VertDataMulN(nCo, 0.75f);
VertDataMulN(r, 0.25f);
VertDataAdd(nCo, r);
}
- } else {
- for (x=1; x<edgeSize-1; x++) {
- int fx = x*2;
+ }
+ else {
+ for (x = 1; x < edgeSize - 1; x++) {
+ int fx = x * 2;
void *co = EDGE_getCo(e, curLvl, x);
void *nCo = EDGE_getCo(e, nextLvl, fx);
int numFaces = 0;
VertDataZero(q);
VertDataZero(r);
- VertDataAdd(r, EDGE_getCo(e, curLvl, x-1));
- VertDataAdd(r, EDGE_getCo(e, curLvl, x+1));
- for (j=0; j<e->numFaces; j++) {
+ VertDataAdd(r, EDGE_getCo(e, curLvl, x - 1));
+ VertDataAdd(r, EDGE_getCo(e, curLvl, x + 1));
+ for (j = 0; j < e->numFaces; j++) {
CCGFace *f = e->faces[j];
- VertDataAdd(q, _face_getIFCoEdge(f, e, nextLvl, fx-1, 1, subdivLevels, vertDataSize));
- VertDataAdd(q, _face_getIFCoEdge(f, e, nextLvl, fx+1, 1, subdivLevels, vertDataSize));
+ VertDataAdd(q, _face_getIFCoEdge(f, e, nextLvl, fx - 1, 1, subdivLevels, vertDataSize));
+ VertDataAdd(q, _face_getIFCoEdge(f, e, nextLvl, fx + 1, 1, subdivLevels, vertDataSize));
VertDataAdd(r, _face_getIFCoEdge(f, e, curLvl, x, 1, subdivLevels, vertDataSize));
numFaces++;
}
- VertDataMulN(q, 1.0f/(numFaces*2.0f));
- VertDataMulN(r, 1.0f/(2.0f + numFaces));
+ VertDataMulN(q, 1.0f / (numFaces * 2.0f));
+ VertDataMulN(r, 1.0f / (2.0f + numFaces));
VertDataCopy(nCo, co);
VertDataMulN(nCo, (float) numFaces);
VertDataAdd(nCo, q);
VertDataAdd(nCo, r);
- VertDataMulN(nCo, 1.0f/(2+numFaces));
+ VertDataMulN(nCo, 1.0f / (2 + numFaces));
- if (sharpCount==2) {
+ if (sharpCount == 2) {
VertDataCopy(q, co);
VertDataMulN(q, 6.0f);
- VertDataAdd(q, EDGE_getCo(e, curLvl, x-1));
- VertDataAdd(q, EDGE_getCo(e, curLvl, x+1));
+ VertDataAdd(q, EDGE_getCo(e, curLvl, x - 1));
+ VertDataAdd(q, EDGE_getCo(e, curLvl, x + 1));
VertDataMulN(q, 1/8.0f);
VertDataSub(q, nCo);
@@ -1706,7 +1827,7 @@ static void ccgSubSurf__calcSubdivLevel(CCGSubSurf *ss,
}
}
- #pragma omp parallel private(ptrIdx) if(numEffectedF*edgeSize*edgeSize*4 >= CCG_OMP_LIMIT)
+ #pragma omp parallel private(ptrIdx) if (numEffectedF * edgeSize * edgeSize * 4 >= CCG_OMP_LIMIT)
{
void *q, *r;
@@ -1717,7 +1838,7 @@ static void ccgSubSurf__calcSubdivLevel(CCGSubSurf *ss,
}
#pragma omp for schedule(static)
- for (ptrIdx=0; ptrIdx<numEffectedF; ptrIdx++) {
+ for (ptrIdx = 0; ptrIdx < numEffectedF; ptrIdx++) {
CCGFace *f = (CCGFace*) effectedF[ptrIdx];
int S, x, y;
@@ -1727,43 +1848,45 @@ static void ccgSubSurf__calcSubdivLevel(CCGSubSurf *ss,
* o new interior face midpoints
*/
VertDataZero(q);
- for (S=0; S<f->numVerts; S++) {
+ for (S = 0; S < f->numVerts; S++) {
VertDataAdd(q, FACE_getIFCo(f, nextLvl, S, 1, 1));
}
VertDataMulN(q, 1.0f/f->numVerts);
VertDataZero(r);
- for (S=0; S<f->numVerts; S++) {
+ for (S = 0; S < f->numVerts; S++) {
VertDataAdd(r, FACE_getIECo(f, curLvl, S, 1));
}
VertDataMulN(r, 1.0f/f->numVerts);
- VertDataMulN(FACE_getCenterData(f), f->numVerts-2.0f);
+ 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);
- for (S=0; S<f->numVerts; S++) {
+ 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
*/
- for (x=1; x<gridSize-1; x++) {
- for (y=1; y<gridSize-1; y++) {
- int fx = x*2;
- int fy = y*2;
+ for (x = 1; x < gridSize - 1; x++) {
+ for (y = 1; y < gridSize - 1; y++) {
+ int fx = x * 2;
+ int fy = y * 2;
void *co = FACE_getIFCo(f, curLvl, S, x, y);
void *nCo = FACE_getIFCo(f, nextLvl, S, fx, fy);
- VertDataAvg4(q, FACE_getIFCo(f, nextLvl, S, fx-1, fy-1),
- FACE_getIFCo(f, nextLvl, S, fx+1, fy-1),
- FACE_getIFCo(f, nextLvl, S, fx+1, fy+1),
- FACE_getIFCo(f, nextLvl, S, fx-1, fy+1));
-
- VertDataAvg4(r, FACE_getIFCo(f, nextLvl, S, fx-1, fy+0),
- FACE_getIFCo(f, nextLvl, S, fx+1, fy+0),
- FACE_getIFCo(f, nextLvl, S, fx+0, fy-1),
- FACE_getIFCo(f, nextLvl, S, fx+0, fy+1));
+ VertDataAvg4(q,
+ FACE_getIFCo(f, nextLvl, S, fx - 1, fy - 1),
+ FACE_getIFCo(f, nextLvl, S, fx + 1, fy - 1),
+ FACE_getIFCo(f, nextLvl, S, fx + 1, fy + 1),
+ FACE_getIFCo(f, nextLvl, S, fx - 1, fy + 1));
+
+ VertDataAvg4(r,
+ FACE_getIFCo(f, nextLvl, S, fx - 1, fy + 0),
+ FACE_getIFCo(f, nextLvl, S, fx + 1, fy + 0),
+ FACE_getIFCo(f, nextLvl, S, fx + 0, fy - 1),
+ FACE_getIFCo(f, nextLvl, S, fx + 0, fy + 1));
VertDataCopy(nCo, co);
VertDataSub(nCo, q);
@@ -1777,20 +1900,22 @@ static void ccgSubSurf__calcSubdivLevel(CCGSubSurf *ss,
* o new interior edge midpoints
* o new interior face midpoints
*/
- for (x=1; x<gridSize-1; x++) {
- int fx = x*2;
+ for (x = 1; x < gridSize - 1; x++) {
+ int fx = x * 2;
void *co = FACE_getIECo(f, curLvl, S, x);
void *nCo = FACE_getIECo(f, nextLvl, S, fx);
- 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));
-
- VertDataAvg4(r, FACE_getIECo(f, nextLvl, S, fx-1),
- FACE_getIECo(f, nextLvl, S, fx+1),
- FACE_getIFCo(f, nextLvl, (S+1)%f->numVerts, 1, fx),
- FACE_getIFCo(f, nextLvl, S, fx, 1));
+ 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));
+
+ VertDataAvg4(r,
+ FACE_getIECo(f, nextLvl, S, fx - 1),
+ FACE_getIECo(f, nextLvl, S, fx + 1),
+ FACE_getIFCo(f, nextLvl, (S + 1) % f->numVerts, 1, fx),
+ FACE_getIFCo(f, nextLvl, S, fx, 1));
VertDataCopy(nCo, co);
VertDataSub(nCo, q);
@@ -1808,37 +1933,37 @@ static void ccgSubSurf__calcSubdivLevel(CCGSubSurf *ss,
}
/* copy down */
- edgeSize = 1 + (1<<(nextLvl));
- gridSize = 1 + (1<<((nextLvl)-1));
- cornerIdx = gridSize-1;
+ edgeSize = 1 + (1 << (nextLvl));
+ gridSize = 1 + (1 << ((nextLvl)-1));
+ cornerIdx = gridSize - 1;
- #pragma omp parallel for private(i) if(numEffectedF*edgeSize*edgeSize*4 >= CCG_OMP_LIMIT)
- for (i=0; i<numEffectedE; i++) {
+ #pragma omp parallel for private(i) if (numEffectedF * edgeSize * edgeSize * 4 >= CCG_OMP_LIMIT)
+ for (i = 0; i < numEffectedE; i++) {
CCGEdge *e = effectedE[i];
VertDataCopy(EDGE_getCo(e, nextLvl, 0), VERT_getCo(e->v0, nextLvl));
- VertDataCopy(EDGE_getCo(e, nextLvl, edgeSize-1), VERT_getCo(e->v1, nextLvl));
+ VertDataCopy(EDGE_getCo(e, nextLvl, edgeSize - 1), VERT_getCo(e->v1, nextLvl));
}
- #pragma omp parallel for private(i) if(numEffectedF*edgeSize*edgeSize*4 >= CCG_OMP_LIMIT)
- for (i=0; i<numEffectedF; i++) {
+ #pragma omp parallel for private(i) if (numEffectedF * edgeSize * edgeSize * 4 >= CCG_OMP_LIMIT)
+ for (i = 0; i < numEffectedF; i++) {
CCGFace *f = effectedF[i];
int S, x;
- for (S=0; S<f->numVerts; S++) {
+ for (S = 0; S < f->numVerts; S++) {
CCGEdge *e = FACE_getEdges(f)[S];
- CCGEdge *prevE = FACE_getEdges(f)[(S+f->numVerts-1)%f->numVerts];
+ CCGEdge *prevE = FACE_getEdges(f)[(S + f->numVerts - 1) % f->numVerts];
VertDataCopy(FACE_getIFCo(f, nextLvl, S, 0, 0), FACE_getCenterData(f));
VertDataCopy(FACE_getIECo(f, nextLvl, S, 0), FACE_getCenterData(f));
VertDataCopy(FACE_getIFCo(f, nextLvl, S, cornerIdx, cornerIdx), VERT_getCo(FACE_getVerts(f)[S], nextLvl));
VertDataCopy(FACE_getIECo(f, nextLvl, S, cornerIdx), EDGE_getCo(FACE_getEdges(f)[S], nextLvl, cornerIdx));
- for (x=1; x<gridSize-1; x++) {
+ for (x = 1; x < gridSize - 1; x++) {
void *co = FACE_getIECo(f, nextLvl, S, x);
VertDataCopy(FACE_getIFCo(f, nextLvl, S, x, 0), co);
- VertDataCopy(FACE_getIFCo(f, nextLvl, (S+1)%f->numVerts, 0, x), co);
+ VertDataCopy(FACE_getIFCo(f, nextLvl, (S + 1) % f->numVerts, 0, x), co);
}
- for (x=0; x<gridSize-1; x++) {
- int eI = gridSize-1-x;
+ 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));
}
@@ -1847,7 +1972,8 @@ static void ccgSubSurf__calcSubdivLevel(CCGSubSurf *ss,
}
-static void ccgSubSurf__sync(CCGSubSurf *ss) {
+static void ccgSubSurf__sync(CCGSubSurf *ss)
+{
CCGVert **effectedV;
CCGEdge **effectedE;
CCGFace **effectedF;
@@ -1858,17 +1984,17 @@ static void ccgSubSurf__sync(CCGSubSurf *ss) {
int curLvl, nextLvl;
void *q = ss->q, *r = ss->r;
- effectedV = MEM_mallocN(sizeof(*effectedV)*ss->vMap->numEntries, "CCGSubsurf effectedV");
- effectedE = MEM_mallocN(sizeof(*effectedE)*ss->eMap->numEntries, "CCGSubsurf effectedE");
- effectedF = MEM_mallocN(sizeof(*effectedF)*ss->fMap->numEntries, "CCGSubsurf effectedF");
+ effectedV = MEM_mallocN(sizeof(*effectedV) * ss->vMap->numEntries, "CCGSubsurf effectedV");
+ effectedE = MEM_mallocN(sizeof(*effectedE) * ss->eMap->numEntries, "CCGSubsurf effectedE");
+ effectedF = MEM_mallocN(sizeof(*effectedF) * ss->fMap->numEntries, "CCGSubsurf effectedF");
numEffectedV = numEffectedE = numEffectedF = 0;
- for (i=0; i<ss->vMap->curSize; i++) {
+ for (i = 0; i < ss->vMap->curSize; i++) {
CCGVert *v = (CCGVert*) ss->vMap->buckets[i];
for (; v; v = v->next) {
if (v->flags&Vert_eEffected) {
effectedV[numEffectedV++] = v;
- for (j=0; j<v->numEdges; j++) {
+ for (j = 0; j < v->numEdges; j++) {
CCGEdge *e = v->edges[j];
if (!(e->flags&Edge_eEffected)) {
effectedE[numEffectedE++] = e;
@@ -1876,7 +2002,7 @@ static void ccgSubSurf__sync(CCGSubSurf *ss) {
}
}
- for (j=0; j<v->numFaces; j++) {
+ for (j = 0; j < v->numFaces; j++) {
CCGFace *f = v->faces[j];
if (!(f->flags&Face_eEffected)) {
effectedF[numEffectedF++] = f;
@@ -1888,20 +2014,20 @@ static void ccgSubSurf__sync(CCGSubSurf *ss) {
}
curLvl = 0;
- nextLvl = curLvl+1;
+ nextLvl = curLvl + 1;
- for (ptrIdx=0; ptrIdx<numEffectedF; ptrIdx++) {
+ for (ptrIdx = 0; ptrIdx < numEffectedF; ptrIdx++) {
CCGFace *f = effectedF[ptrIdx];
void *co = FACE_getCenterData(f);
VertDataZero(co);
- for (i=0; i<f->numVerts; i++) {
+ for (i = 0; i < f->numVerts; i++) {
VertDataAdd(co, VERT_getCo(FACE_getVerts(f)[i], curLvl));
}
VertDataMulN(co, 1.0f/f->numVerts);
f->flags = 0;
}
- for (ptrIdx=0; ptrIdx<numEffectedE; ptrIdx++) {
+ for (ptrIdx = 0; ptrIdx < numEffectedE; ptrIdx++) {
CCGEdge *e = effectedE[ptrIdx];
void *co = EDGE_getCo(e, nextLvl, 1);
float sharpness = EDGE_getSharpness(e, curLvl);
@@ -1910,16 +2036,17 @@ static void ccgSubSurf__sync(CCGSubSurf *ss) {
VertDataCopy(co, VERT_getCo(e->v0, curLvl));
VertDataAdd(co, VERT_getCo(e->v1, curLvl));
VertDataMulN(co, 0.5f);
- } else {
+ }
+ else {
int numFaces = 0;
VertDataCopy(q, VERT_getCo(e->v0, curLvl));
VertDataAdd(q, VERT_getCo(e->v1, curLvl));
- for (i=0; i<e->numFaces; i++) {
+ for (i = 0; i < e->numFaces; i++) {
CCGFace *f = e->faces[i];
VertDataAdd(q, FACE_getCenterData(f));
numFaces++;
}
- VertDataMulN(q, 1.0f/(2.0f+numFaces));
+ VertDataMulN(q, 1.0f / (2.0f + numFaces));
VertDataCopy(r, VERT_getCo(e->v0, curLvl));
VertDataAdd(r, VERT_getCo(e->v1, curLvl));
@@ -1933,7 +2060,7 @@ static void ccgSubSurf__sync(CCGSubSurf *ss) {
// edge flags cleared later
}
- for (ptrIdx=0; ptrIdx<numEffectedV; ptrIdx++) {
+ for (ptrIdx = 0; ptrIdx < numEffectedV; ptrIdx++) {
CCGVert *v = effectedV[ptrIdx];
void *co = VERT_getCo(v, curLvl);
void *nCo = VERT_getCo(v, nextLvl);
@@ -1941,7 +2068,7 @@ static void ccgSubSurf__sync(CCGSubSurf *ss) {
float avgSharpness = 0.0;
int seam = VERT_seam(v), seamEdges = 0;
- for (i=0; i<v->numEdges; i++) {
+ for (i = 0; i < v->numEdges; i++) {
CCGEdge *e = v->edges[i];
float sharpness = EDGE_getSharpness(e, curLvl);
@@ -1951,12 +2078,13 @@ static void ccgSubSurf__sync(CCGSubSurf *ss) {
if (sharpness!=0.0f) {
sharpCount++;
avgSharpness += sharpness;
- } else {
+ }
+ else {
allSharp = 0;
}
}
- if(sharpCount) {
+ if (sharpCount) {
avgSharpness /= sharpCount;
if (avgSharpness > 1.0f) {
avgSharpness = 1.0f;
@@ -1968,11 +2096,12 @@ static void ccgSubSurf__sync(CCGSubSurf *ss) {
if (!v->numEdges) {
VertDataCopy(nCo, co);
- } else if (_vert_isBoundary(v)) {
+ }
+ else if (_vert_isBoundary(v)) {
int numBoundary = 0;
VertDataZero(r);
- for (i=0; i<v->numEdges; i++) {
+ for (i = 0; i < v->numEdges; i++) {
CCGEdge *e = v->edges[i];
if (_edge_isBoundary(e)) {
VertDataAdd(r, VERT_getCo(_edge_getOtherVert(e, v), curLvl));
@@ -1983,18 +2112,19 @@ static void ccgSubSurf__sync(CCGSubSurf *ss) {
VertDataMulN(nCo, 0.75f);
VertDataMulN(r, 0.25f/numBoundary);
VertDataAdd(nCo, r);
- } else {
+ }
+ else {
int numEdges = 0, numFaces = 0;
VertDataZero(q);
- for (i=0; i<v->numFaces; i++) {
+ for (i = 0; i < v->numFaces; i++) {
CCGFace *f = v->faces[i];
VertDataAdd(q, FACE_getCenterData(f));
numFaces++;
}
VertDataMulN(q, 1.0f/numFaces);
VertDataZero(r);
- for (i=0; i<v->numEdges; i++) {
+ for (i = 0; i < v->numEdges; i++) {
CCGEdge *e = v->edges[i];
VertDataAdd(r, VERT_getCo(_edge_getOtherVert(e, v), curLvl));
numEdges++;
@@ -2002,7 +2132,7 @@ static void ccgSubSurf__sync(CCGSubSurf *ss) {
VertDataMulN(r, 1.0f/numEdges);
VertDataCopy(nCo, co);
- VertDataMulN(nCo, numEdges-2.0f);
+ VertDataMulN(nCo, numEdges - 2.0f);
VertDataAdd(nCo, q);
VertDataAdd(nCo, r);
VertDataMulN(nCo, 1.0f/numEdges);
@@ -2017,7 +2147,7 @@ static void ccgSubSurf__sync(CCGSubSurf *ss) {
allSharp = 1;
}
- for (i=0; i<v->numEdges; i++) {
+ for (i = 0; i < v->numEdges; i++) {
CCGEdge *e = v->edges[i];
float sharpness = EDGE_getSharpness(e, curLvl);
@@ -2026,7 +2156,8 @@ static void ccgSubSurf__sync(CCGSubSurf *ss) {
CCGVert *oV = _edge_getOtherVert(e, v);
VertDataAdd(q, VERT_getCo(oV, curLvl));
}
- } else if (sharpness != 0.0f) {
+ }
+ else if (sharpness != 0.0f) {
CCGVert *oV = _edge_getOtherVert(e, v);
VertDataAdd(q, VERT_getCo(oV, curLvl));
}
@@ -2035,7 +2166,7 @@ static void ccgSubSurf__sync(CCGSubSurf *ss) {
VertDataMulN(q, (float) 1/sharpCount);
if (sharpCount!=2 || allSharp) {
- // q = q + (co-q)*avgSharpness
+ // q = q + (co-q) * avgSharpness
VertDataCopy(r, co);
VertDataSub(r, q);
VertDataMulN(r, avgSharpness);
@@ -2048,7 +2179,7 @@ static void ccgSubSurf__sync(CCGSubSurf *ss) {
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);
@@ -2058,35 +2189,35 @@ static void ccgSubSurf__sync(CCGSubSurf *ss) {
}
if (ss->useAgeCounts) {
- for (i=0; i<numEffectedV; i++) {
+ for (i = 0; i < numEffectedV; i++) {
CCGVert *v = effectedV[i];
byte *userData = ccgSubSurf_getVertUserData(ss, v);
*((int*) &userData[ss->vertUserAgeOffset]) = ss->currentAge;
}
- for (i=0; i<numEffectedE; i++) {
+ for (i = 0; i < numEffectedE; i++) {
CCGEdge *e = effectedE[i];
byte *userData = ccgSubSurf_getEdgeUserData(ss, e);
*((int*) &userData[ss->edgeUserAgeOffset]) = ss->currentAge;
}
- for (i=0; i<numEffectedF; i++) {
+ for (i = 0; i < numEffectedF; i++) {
CCGFace *f = effectedF[i];
byte *userData = ccgSubSurf_getFaceUserData(ss, f);
*((int*) &userData[ss->faceUserAgeOffset]) = ss->currentAge;
}
}
- for (i=0; i<numEffectedE; i++) {
+ for (i = 0; i < numEffectedE; i++) {
CCGEdge *e = effectedE[i];
VertDataCopy(EDGE_getCo(e, nextLvl, 0), VERT_getCo(e->v0, nextLvl));
VertDataCopy(EDGE_getCo(e, nextLvl, 2), VERT_getCo(e->v1, nextLvl));
}
- for (i=0; i<numEffectedF; i++) {
+ for (i = 0; i < numEffectedF; i++) {
CCGFace *f = effectedF[i];
- for (S=0; S<f->numVerts; S++) {
+ for (S = 0; S < f->numVerts; S++) {
CCGEdge *e = FACE_getEdges(f)[S];
- CCGEdge *prevE = FACE_getEdges(f)[(S+f->numVerts-1)%f->numVerts];
+ CCGEdge *prevE = FACE_getEdges(f)[(S + f->numVerts - 1) % f->numVerts];
VertDataCopy(FACE_getIFCo(f, nextLvl, S, 0, 0), FACE_getCenterData(f));
VertDataCopy(FACE_getIECo(f, nextLvl, S, 0), FACE_getCenterData(f));
@@ -2098,7 +2229,7 @@ static void ccgSubSurf__sync(CCGSubSurf *ss) {
}
}
- for (curLvl=1; curLvl<subdivLevels; curLvl++) {
+ for (curLvl = 1; curLvl < subdivLevels; curLvl++) {
ccgSubSurf__calcSubdivLevel(ss,
effectedV, effectedE, effectedF,
numEffectedV, numEffectedE, numEffectedF, curLvl);
@@ -2109,11 +2240,11 @@ static void ccgSubSurf__sync(CCGSubSurf *ss) {
effectedV, effectedE, effectedF,
numEffectedV, numEffectedE, numEffectedF);
- for (ptrIdx=0; ptrIdx<numEffectedV; ptrIdx++) {
+ for (ptrIdx = 0; ptrIdx < numEffectedV; ptrIdx++) {
CCGVert *v = effectedV[ptrIdx];
v->flags = 0;
}
- for (ptrIdx=0; ptrIdx<numEffectedE; ptrIdx++) {
+ for (ptrIdx = 0; ptrIdx < numEffectedE; ptrIdx++) {
CCGEdge *e = effectedE[ptrIdx];
e->flags = 0;
}
@@ -2128,10 +2259,10 @@ static void ccgSubSurf__allFaces(CCGSubSurf *ss, CCGFace ***faces, int *numFaces
CCGFace **array;
int i, num;
- if(!*faces) {
- array = MEM_mallocN(sizeof(*array)*ss->fMap->numEntries, "CCGSubsurf allFaces");
+ if (!*faces) {
+ array = MEM_mallocN(sizeof(*array) * ss->fMap->numEntries, "CCGSubsurf allFaces");
num = 0;
- for (i=0; i<ss->fMap->curSize; i++) {
+ for (i = 0; i < ss->fMap->curSize; i++) {
CCGFace *f = (CCGFace*) ss->fMap->buckets[i];
for (; f; f = f->next)
@@ -2140,10 +2271,11 @@ static void ccgSubSurf__allFaces(CCGSubSurf *ss, CCGFace ***faces, int *numFaces
*faces = array;
*numFaces = num;
- *freeFaces= 1;
+ *freeFaces = 1;
+ }
+ else {
+ *freeFaces = 0;
}
- else
- *freeFaces= 0;
}
static void ccgSubSurf__effectedFaceNeighbours(CCGSubSurf *ss, CCGFace **faces, int numFaces, CCGVert ***verts, int *numVerts, CCGEdge ***edges, int *numEdges)
@@ -2152,39 +2284,39 @@ static void ccgSubSurf__effectedFaceNeighbours(CCGSubSurf *ss, CCGFace **faces,
CCGEdge **arrayE;
int numV, numE, i, j;
- arrayV = MEM_mallocN(sizeof(*arrayV)*ss->vMap->numEntries, "CCGSubsurf arrayV");
- arrayE = MEM_mallocN(sizeof(*arrayE)*ss->eMap->numEntries, "CCGSubsurf arrayV");
+ arrayV = MEM_mallocN(sizeof(*arrayV) * ss->vMap->numEntries, "CCGSubsurf arrayV");
+ arrayE = MEM_mallocN(sizeof(*arrayE) * ss->eMap->numEntries, "CCGSubsurf arrayV");
numV = numE = 0;
- for (i=0; i<numFaces; i++) {
+ for (i = 0; i < numFaces; i++) {
CCGFace *f = faces[i];
f->flags |= Face_eEffected;
}
- for (i=0; i<ss->vMap->curSize; i++) {
+ for (i = 0; i < ss->vMap->curSize; i++) {
CCGVert *v = (CCGVert*) ss->vMap->buckets[i];
for (; v; v = v->next) {
- for(j=0; j<v->numFaces; j++)
- if(!(v->faces[j]->flags & Face_eEffected))
+ for (j = 0; j < v->numFaces; j++)
+ if (!(v->faces[j]->flags & Face_eEffected))
break;
- if(j == v->numFaces) {
+ if (j == v->numFaces) {
arrayV[numV++] = v;
v->flags |= Vert_eEffected;
}
}
}
- for (i=0; i<ss->eMap->curSize; i++) {
+ for (i = 0; i < ss->eMap->curSize; i++) {
CCGEdge *e = (CCGEdge*) ss->eMap->buckets[i];
for (; e; e = e->next) {
- for(j=0; j<e->numFaces; j++)
- if(!(e->faces[j]->flags & Face_eEffected))
+ for (j = 0; j < e->numFaces; j++)
+ if (!(e->faces[j]->flags & Face_eEffected))
break;
- if(j == e->numFaces) {
+ if (j == e->numFaces) {
e->flags |= Edge_eEffected;
arrayE[numE++] = e;
}
@@ -2205,33 +2337,33 @@ CCGError ccgSubSurf_updateFromFaces(CCGSubSurf *ss, int lvl, CCGFace **effectedF
subdivLevels = ss->subdivLevels;
lvl = (lvl)? lvl: subdivLevels;
- gridSize = 1 + (1<<(lvl-1));
- cornerIdx = gridSize-1;
+ gridSize = 1 + (1 << (lvl - 1));
+ cornerIdx = gridSize - 1;
ccgSubSurf__allFaces(ss, &effectedF, &numEffectedF, &freeF);
- for (i=0; i<numEffectedF; i++) {
+ for (i = 0; i < numEffectedF; i++) {
CCGFace *f = effectedF[i];
- for (S=0; S<f->numVerts; S++) {
+ for (S = 0; S < f->numVerts; S++) {
CCGEdge *e = FACE_getEdges(f)[S];
- CCGEdge *prevE = FACE_getEdges(f)[(S+f->numVerts-1)%f->numVerts];
+ CCGEdge *prevE = FACE_getEdges(f)[(S + f->numVerts - 1) % f->numVerts];
VertDataCopy(FACE_getCenterData(f), FACE_getIFCo(f, lvl, S, 0, 0));
VertDataCopy(VERT_getCo(FACE_getVerts(f)[S], lvl), FACE_getIFCo(f, lvl, S, cornerIdx, cornerIdx));
- for (x=0; x<gridSize; x++)
+ for (x = 0; x < gridSize; x++)
VertDataCopy(FACE_getIECo(f, lvl, S, x), FACE_getIFCo(f, lvl, S, x, 0));
- for (x=0; x<gridSize; x++) {
- int eI = gridSize-1-x;
+ 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));
}
}
}
- if(freeF) MEM_freeN(effectedF);
+ if (freeF) MEM_freeN(effectedF);
return eCCGError_None;
}
@@ -2244,26 +2376,26 @@ CCGError ccgSubSurf_updateToFaces(CCGSubSurf *ss, int lvl, CCGFace **effectedF,
subdivLevels = ss->subdivLevels;
lvl = (lvl)? lvl: subdivLevels;
- gridSize = 1 + (1<<(lvl-1));
- cornerIdx = gridSize-1;
+ gridSize = 1 + (1 << (lvl - 1));
+ cornerIdx = gridSize - 1;
ccgSubSurf__allFaces(ss, &effectedF, &numEffectedF, &freeF);
- for (i=0; i<numEffectedF; i++) {
+ for (i = 0; i < numEffectedF; i++) {
CCGFace *f = effectedF[i];
- for (S=0; S<f->numVerts; S++) {
- int prevS = (S+f->numVerts-1)%f->numVerts;
+ for (S = 0; S < f->numVerts; S++) {
+ int prevS = (S + f->numVerts - 1) % f->numVerts;
CCGEdge *e = FACE_getEdges(f)[S];
CCGEdge *prevE = FACE_getEdges(f)[prevS];
- for (x=0; x<gridSize; x++) {
- int eI = gridSize-1-x;
+ 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));
}
- for (x=1; x<gridSize-1; x++) {
+ for (x = 1; x < gridSize - 1; x++) {
VertDataCopy(FACE_getIFCo(f, lvl, S, 0, x), FACE_getIECo(f, lvl, prevS, x));
VertDataCopy(FACE_getIFCo(f, lvl, S, x, 0), FACE_getIECo(f, lvl, S, x));
}
@@ -2273,7 +2405,7 @@ CCGError ccgSubSurf_updateToFaces(CCGSubSurf *ss, int lvl, CCGFace **effectedF,
}
}
- if(freeF) MEM_freeN(effectedF);
+ if (freeF) MEM_freeN(effectedF);
return eCCGError_None;
}
@@ -2290,41 +2422,41 @@ CCGError ccgSubSurf_stitchFaces(CCGSubSurf *ss, int lvl, CCGFace **effectedF, in
subdivLevels = ss->subdivLevels;
lvl = (lvl)? lvl: subdivLevels;
- gridSize = 1 + (1<<(lvl-1));
- edgeSize = 1 + (1<<lvl);
- cornerIdx = gridSize-1;
+ gridSize = 1 + (1 << (lvl - 1));
+ edgeSize = 1 + (1 << lvl);
+ cornerIdx = gridSize - 1;
ccgSubSurf__allFaces(ss, &effectedF, &numEffectedF, &freeF);
ccgSubSurf__effectedFaceNeighbours(ss, effectedF, numEffectedF,
&effectedV, &numEffectedV, &effectedE, &numEffectedE);
/* zero */
- for (i=0; i<numEffectedV; i++) {
+ for (i = 0; i < numEffectedV; i++) {
CCGVert *v = effectedV[i];
- if(v->numFaces)
+ if (v->numFaces)
VertDataZero(VERT_getCo(v, lvl));
}
- for (i=0; i<numEffectedE; i++) {
+ for (i = 0; i < numEffectedE; i++) {
CCGEdge *e = effectedE[i];
- if(e->numFaces)
- for (x=0; x<edgeSize; x++)
+ if (e->numFaces)
+ for (x = 0; x < edgeSize; x++)
VertDataZero(EDGE_getCo(e, lvl, x));
}
/* add */
- for (i=0; i<numEffectedF; i++) {
+ for (i = 0; i < numEffectedF; i++) {
CCGFace *f = effectedF[i];
VertDataZero(FACE_getCenterData(f));
- for (S=0; S<f->numVerts; S++)
- for (x=0; x<gridSize; x++)
+ for (S = 0; S < f->numVerts; S++)
+ for (x = 0; x < gridSize; x++)
VertDataZero(FACE_getIECo(f, lvl, S, x));
- for (S=0; S<f->numVerts; S++) {
- int prevS = (S+f->numVerts-1)%f->numVerts;
+ for (S = 0; S < f->numVerts; S++) {
+ int prevS = (S + f->numVerts - 1) % f->numVerts;
CCGEdge *e = FACE_getEdges(f)[S];
CCGEdge *prevE = FACE_getEdges(f)[prevS];
@@ -2332,90 +2464,91 @@ CCGError ccgSubSurf_stitchFaces(CCGSubSurf *ss, int lvl, CCGFace **effectedF, in
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++) {
+ for (x = 1; x < gridSize - 1; x++) {
VertDataAdd(FACE_getIECo(f, lvl, S, x), FACE_getIFCo(f, lvl, S, x, 0));
VertDataAdd(FACE_getIECo(f, lvl, prevS, x), FACE_getIFCo(f, lvl, S, 0, x));
}
- for (x=0; x<gridSize-1; x++) {
- int eI = gridSize-1-x;
+ 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(x != 0)
+ if (x != 0)
VertDataAdd(_edge_getCoVert(prevE, FACE_getVerts(f)[S], lvl, eI,vertDataSize), FACE_getIFCo(f, lvl, S, x, cornerIdx));
}
}
}
/* average */
- for (i=0; i<numEffectedV; i++) {
+ for (i = 0; i < numEffectedV; i++) {
CCGVert *v = effectedV[i];
- if(v->numFaces)
+ if (v->numFaces)
VertDataMulN(VERT_getCo(v, lvl), 1.0f/v->numFaces);
}
- for (i=0; i<numEffectedE; i++) {
+ for (i = 0; i < numEffectedE; i++) {
CCGEdge *e = effectedE[i];
VertDataCopy(EDGE_getCo(e, lvl, 0), VERT_getCo(e->v0, lvl));
- VertDataCopy(EDGE_getCo(e, lvl, edgeSize-1), VERT_getCo(e->v1, lvl));
+ VertDataCopy(EDGE_getCo(e, lvl, edgeSize - 1), VERT_getCo(e->v1, lvl));
- if(e->numFaces)
- for (x=1; x<edgeSize-1; x++)
+ if (e->numFaces)
+ for (x = 1; x < edgeSize - 1; x++)
VertDataMulN(EDGE_getCo(e, lvl, x), 1.0f/e->numFaces);
}
/* copy */
- for (i=0; i<numEffectedF; i++) {
+ for (i = 0; i < numEffectedF; i++) {
CCGFace *f = effectedF[i];
VertDataMulN(FACE_getCenterData(f), 1.0f/f->numVerts);
- for (S=0; S<f->numVerts; S++)
- for (x=1; x<gridSize-1; x++)
+ for (S = 0; S < f->numVerts; S++)
+ for (x = 1; x < gridSize - 1; x++)
VertDataMulN(FACE_getIECo(f, lvl, S, x), 0.5f);
- for (S=0; S<f->numVerts; S++) {
- int prevS = (S+f->numVerts-1)%f->numVerts;
+ for (S = 0; S < f->numVerts; S++) {
+ int prevS = (S + f->numVerts - 1) % f->numVerts;
CCGEdge *e = FACE_getEdges(f)[S];
CCGEdge *prevE = FACE_getEdges(f)[prevS];
VertDataCopy(FACE_getIFCo(f, lvl, S, 0, 0), FACE_getCenterData(f));
VertDataCopy(FACE_getIFCo(f, lvl, S, cornerIdx, cornerIdx), VERT_getCo(FACE_getVerts(f)[S], lvl));
- for (x=1; x<gridSize-1; x++) {
+ for (x = 1; x < gridSize - 1; x++) {
VertDataCopy(FACE_getIFCo(f, lvl, S, x, 0), FACE_getIECo(f, lvl, S, x));
VertDataCopy(FACE_getIFCo(f, lvl, S, 0, x), FACE_getIECo(f, lvl, prevS, x));
}
- for (x=0; x<gridSize-1; x++) {
- int eI = gridSize-1-x;
+ 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_getIECo(f, lvl, S, 0), FACE_getCenterData(f));
- VertDataCopy(FACE_getIECo(f, lvl, S, gridSize-1), FACE_getIFCo(f, lvl, S, gridSize-1, 0));
+ VertDataCopy(FACE_getIECo(f, lvl, S, gridSize - 1), FACE_getIFCo(f, lvl, S, gridSize - 1, 0));
}
}
- for (i=0; i<numEffectedV; i++)
+ for (i = 0; i < numEffectedV; i++)
effectedV[i]->flags = 0;
- for (i=0; i<numEffectedE; i++)
+ for (i = 0; i < numEffectedE; i++)
effectedE[i]->flags = 0;
- for (i=0; i<numEffectedF; i++)
+ for (i = 0; i < numEffectedF; i++)
effectedF[i]->flags = 0;
MEM_freeN(effectedE);
MEM_freeN(effectedV);
- if(freeF) MEM_freeN(effectedF);
+ if (freeF) MEM_freeN(effectedF);
return eCCGError_None;
}
/* update normals for specified faces */
-CCGError ccgSubSurf_updateNormals(CCGSubSurf *ss, CCGFace **effectedF, int numEffectedF) {
+CCGError ccgSubSurf_updateNormals(CCGSubSurf *ss, CCGFace **effectedF, int numEffectedF)
+{
CCGVert **effectedV;
CCGEdge **effectedE;
int i, numEffectedV, numEffectedE, freeF;
@@ -2429,16 +2562,16 @@ CCGError ccgSubSurf_updateNormals(CCGSubSurf *ss, CCGFace **effectedF, int numEf
effectedV, effectedE, effectedF,
numEffectedV, numEffectedE, numEffectedF);
- for (i=0; i<numEffectedV; i++)
+ for (i = 0; i < numEffectedV; i++)
effectedV[i]->flags = 0;
- for (i=0; i<numEffectedE; i++)
+ for (i = 0; i < numEffectedE; i++)
effectedE[i]->flags = 0;
- for (i=0; i<numEffectedF; i++)
+ for (i = 0; i < numEffectedF; i++)
effectedF[i]->flags = 0;
MEM_freeN(effectedE);
MEM_freeN(effectedV);
- if(freeF) MEM_freeN(effectedF);
+ if (freeF) MEM_freeN(effectedF);
return eCCGError_None;
}
@@ -2457,22 +2590,22 @@ CCGError ccgSubSurf_updateLevels(CCGSubSurf *ss, int lvl, CCGFace **effectedF, i
ccgSubSurf__effectedFaceNeighbours(ss, effectedF, numEffectedF,
&effectedV, &numEffectedV, &effectedE, &numEffectedE);
- for (curLvl=lvl; curLvl<subdivLevels; curLvl++) {
+ for (curLvl = lvl; curLvl < subdivLevels; curLvl++) {
ccgSubSurf__calcSubdivLevel(ss,
effectedV, effectedE, effectedF,
numEffectedV, numEffectedE, numEffectedF, curLvl);
}
- for (i=0; i<numEffectedV; i++)
+ for (i = 0; i < numEffectedV; i++)
effectedV[i]->flags = 0;
- for (i=0; i<numEffectedE; i++)
+ for (i = 0; i < numEffectedE; i++)
effectedE[i]->flags = 0;
- for (i=0; i<numEffectedF; i++)
+ for (i = 0; i < numEffectedF; i++)
effectedF[i]->flags = 0;
MEM_freeN(effectedE);
MEM_freeN(effectedV);
- if(freeF) MEM_freeN(effectedF);
+ if (freeF) MEM_freeN(effectedF);
return eCCGError_None;
}
@@ -2484,272 +2617,352 @@ CCGError ccgSubSurf_updateLevels(CCGSubSurf *ss, int lvl, CCGFace **effectedF, i
/*** External API accessor functions ***/
-int ccgSubSurf_getNumVerts(const CCGSubSurf *ss) {
+int ccgSubSurf_getNumVerts(const CCGSubSurf *ss)
+{
return ss->vMap->numEntries;
}
-int ccgSubSurf_getNumEdges(const CCGSubSurf *ss) {
+int ccgSubSurf_getNumEdges(const CCGSubSurf *ss)
+{
return ss->eMap->numEntries;
}
-int ccgSubSurf_getNumFaces(const CCGSubSurf *ss) {
+int ccgSubSurf_getNumFaces(const CCGSubSurf *ss)
+{
return ss->fMap->numEntries;
}
-CCGVert *ccgSubSurf_getVert(CCGSubSurf *ss, CCGVertHDL v) {
+CCGVert *ccgSubSurf_getVert(CCGSubSurf *ss, CCGVertHDL v)
+{
return (CCGVert*) _ehash_lookup(ss->vMap, v);
}
-CCGEdge *ccgSubSurf_getEdge(CCGSubSurf *ss, CCGEdgeHDL e) {
+CCGEdge *ccgSubSurf_getEdge(CCGSubSurf *ss, CCGEdgeHDL e)
+{
return (CCGEdge*) _ehash_lookup(ss->eMap, e);
}
-CCGFace *ccgSubSurf_getFace(CCGSubSurf *ss, CCGFaceHDL f) {
+CCGFace *ccgSubSurf_getFace(CCGSubSurf *ss, CCGFaceHDL f)
+{
return (CCGFace*) _ehash_lookup(ss->fMap, f);
}
-int ccgSubSurf_getSubdivisionLevels(const CCGSubSurf *ss) {
+int ccgSubSurf_getSubdivisionLevels(const CCGSubSurf *ss)
+{
return ss->subdivLevels;
}
-int ccgSubSurf_getEdgeSize(const CCGSubSurf *ss) {
+int ccgSubSurf_getEdgeSize(const CCGSubSurf *ss)
+{
return ccgSubSurf_getEdgeLevelSize(ss, ss->subdivLevels);
}
-int ccgSubSurf_getEdgeLevelSize(const CCGSubSurf *ss, int level) {
- if (level<1 || level>ss->subdivLevels) {
+int ccgSubSurf_getEdgeLevelSize(const CCGSubSurf *ss, int level)
+{
+ if (level<1 || level > ss->subdivLevels) {
return -1;
- } else {
- return 1 + (1<<level);
+ }
+ else {
+ return 1 + (1 << level);
}
}
-int ccgSubSurf_getGridSize(const CCGSubSurf *ss) {
+int ccgSubSurf_getGridSize(const CCGSubSurf *ss)
+{
return ccgSubSurf_getGridLevelSize(ss, ss->subdivLevels);
}
-int ccgSubSurf_getGridLevelSize(const CCGSubSurf *ss, int level) {
- if (level<1 || level>ss->subdivLevels) {
+int ccgSubSurf_getGridLevelSize(const CCGSubSurf *ss, int level)
+{
+ if (level<1 || level > ss->subdivLevels) {
return -1;
- } else {
- return 1 + (1<<(level-1));
+ }
+ else {
+ return 1 + (1 << (level - 1));
}
}
/* Vert accessors */
-CCGVertHDL ccgSubSurf_getVertVertHandle(CCGVert *v) {
+CCGVertHDL ccgSubSurf_getVertVertHandle(CCGVert *v)
+{
return v->vHDL;
}
-int ccgSubSurf_getVertAge(CCGSubSurf *ss, CCGVert *v) {
+int ccgSubSurf_getVertAge(CCGSubSurf *ss, CCGVert *v)
+{
if (ss->useAgeCounts) {
byte *userData = ccgSubSurf_getVertUserData(ss, v);
return ss->currentAge - *((int*) &userData[ss->vertUserAgeOffset]);
- } else {
+ }
+ else {
return 0;
}
}
-void *ccgSubSurf_getVertUserData(CCGSubSurf *ss, CCGVert *v) {
- return VERT_getLevelData(v) + ss->meshIFC.vertDataSize*(ss->subdivLevels+1);
+void *ccgSubSurf_getVertUserData(CCGSubSurf *ss, CCGVert *v)
+{
+ return VERT_getLevelData(v) + ss->meshIFC.vertDataSize * (ss->subdivLevels + 1);
}
-int ccgSubSurf_getVertNumFaces(CCGVert *v) {
+int ccgSubSurf_getVertNumFaces(CCGVert *v)
+{
return v->numFaces;
}
-CCGFace *ccgSubSurf_getVertFace(CCGVert *v, int index) {
+CCGFace *ccgSubSurf_getVertFace(CCGVert *v, int index)
+{
if (index<0 || index>=v->numFaces) {
return NULL;
- } else {
+ }
+ else {
return v->faces[index];
}
}
-int ccgSubSurf_getVertNumEdges(CCGVert *v) {
+int ccgSubSurf_getVertNumEdges(CCGVert *v)
+{
return v->numEdges;
}
-CCGEdge *ccgSubSurf_getVertEdge(CCGVert *v, int index) {
+CCGEdge *ccgSubSurf_getVertEdge(CCGVert *v, int index)
+{
if (index<0 || index>=v->numEdges) {
return NULL;
- } else {
+ }
+ else {
return v->edges[index];
}
}
-void *ccgSubSurf_getVertData(CCGSubSurf *ss, CCGVert *v) {
+void *ccgSubSurf_getVertData(CCGSubSurf *ss, CCGVert *v)
+{
return ccgSubSurf_getVertLevelData(ss, v, ss->subdivLevels);
}
-void *ccgSubSurf_getVertLevelData(CCGSubSurf *ss, CCGVert *v, int level) {
- if (level<0 || level>ss->subdivLevels) {
+void *ccgSubSurf_getVertLevelData(CCGSubSurf *ss, CCGVert *v, int level)
+{
+ if (level<0 || level > ss->subdivLevels) {
return NULL;
- } else {
+ }
+ else {
return _vert_getCo(v, level, ss->meshIFC.vertDataSize);
}
}
/* Edge accessors */
-CCGEdgeHDL ccgSubSurf_getEdgeEdgeHandle(CCGEdge *e) {
+CCGEdgeHDL ccgSubSurf_getEdgeEdgeHandle(CCGEdge *e)
+{
return e->eHDL;
}
-int ccgSubSurf_getEdgeAge(CCGSubSurf *ss, CCGEdge *e) {
+int ccgSubSurf_getEdgeAge(CCGSubSurf *ss, CCGEdge *e)
+{
if (ss->useAgeCounts) {
byte *userData = ccgSubSurf_getEdgeUserData(ss, e);
return ss->currentAge - *((int*) &userData[ss->edgeUserAgeOffset]);
- } else {
+ }
+ else {
return 0;
}
}
-void *ccgSubSurf_getEdgeUserData(CCGSubSurf *ss, CCGEdge *e) {
- return EDGE_getLevelData(e) + ss->meshIFC.vertDataSize *((ss->subdivLevels+1) + (1<<(ss->subdivLevels+1))-1);
+void *ccgSubSurf_getEdgeUserData(CCGSubSurf *ss, CCGEdge *e)
+{
+ return EDGE_getLevelData(e) + ss->meshIFC.vertDataSize * ((ss->subdivLevels + 1) + (1 << (ss->subdivLevels + 1)) - 1);
}
-int ccgSubSurf_getEdgeNumFaces(CCGEdge *e) {
+int ccgSubSurf_getEdgeNumFaces(CCGEdge *e)
+{
return e->numFaces;
}
-CCGFace *ccgSubSurf_getEdgeFace(CCGEdge *e, int index) {
+CCGFace *ccgSubSurf_getEdgeFace(CCGEdge *e, int index)
+{
if (index<0 || index>=e->numFaces) {
return NULL;
- } else {
+ }
+ else {
return e->faces[index];
}
}
-CCGVert *ccgSubSurf_getEdgeVert0(CCGEdge *e) {
+CCGVert *ccgSubSurf_getEdgeVert0(CCGEdge *e)
+{
return e->v0;
}
-CCGVert *ccgSubSurf_getEdgeVert1(CCGEdge *e) {
+CCGVert *ccgSubSurf_getEdgeVert1(CCGEdge *e)
+{
return e->v1;
}
-void *ccgSubSurf_getEdgeDataArray(CCGSubSurf *ss, CCGEdge *e) {
+void *ccgSubSurf_getEdgeDataArray(CCGSubSurf *ss, CCGEdge *e)
+{
return ccgSubSurf_getEdgeData(ss, e, 0);
}
-void *ccgSubSurf_getEdgeData(CCGSubSurf *ss, CCGEdge *e, int x) {
+void *ccgSubSurf_getEdgeData(CCGSubSurf *ss, CCGEdge *e, int x)
+{
return ccgSubSurf_getEdgeLevelData(ss, e, x, ss->subdivLevels);
}
-void *ccgSubSurf_getEdgeLevelData(CCGSubSurf *ss, CCGEdge *e, int x, int level) {
- if (level<0 || level>ss->subdivLevels) {
+void *ccgSubSurf_getEdgeLevelData(CCGSubSurf *ss, CCGEdge *e, int x, int level)
+{
+ if (level<0 || level > ss->subdivLevels) {
return NULL;
- } else {
+ }
+ else {
return _edge_getCo(e, level, x, ss->meshIFC.vertDataSize);
}
}
-float ccgSubSurf_getEdgeCrease(CCGEdge *e) {
+float ccgSubSurf_getEdgeCrease(CCGEdge *e)
+{
return e->crease;
}
/* Face accessors */
-CCGFaceHDL ccgSubSurf_getFaceFaceHandle(CCGSubSurf *UNUSED(ss), CCGFace *f) {
+CCGFaceHDL ccgSubSurf_getFaceFaceHandle(CCGSubSurf *UNUSED(ss), CCGFace *f)
+{
return f->fHDL;
}
-int ccgSubSurf_getFaceAge(CCGSubSurf *ss, CCGFace *f) {
+int ccgSubSurf_getFaceAge(CCGSubSurf *ss, CCGFace *f)
+{
if (ss->useAgeCounts) {
byte *userData = ccgSubSurf_getFaceUserData(ss, f);
return ss->currentAge - *((int*) &userData[ss->faceUserAgeOffset]);
- } else {
+ }
+ else {
return 0;
}
}
-void *ccgSubSurf_getFaceUserData(CCGSubSurf *ss, CCGFace *f) {
- int maxGridSize = 1 + (1<<(ss->subdivLevels-1));
- return FACE_getCenterData(f) + ss->meshIFC.vertDataSize *(1 + f->numVerts*maxGridSize + f->numVerts*maxGridSize*maxGridSize);
+void *ccgSubSurf_getFaceUserData(CCGSubSurf *ss, CCGFace *f)
+{
+ int maxGridSize = 1 + (1 << (ss->subdivLevels - 1));
+ return FACE_getCenterData(f) + ss->meshIFC.vertDataSize * (1 + f->numVerts * maxGridSize + f->numVerts * maxGridSize * maxGridSize);
}
-int ccgSubSurf_getFaceNumVerts(CCGFace *f) {
+int ccgSubSurf_getFaceNumVerts(CCGFace *f)
+{
return f->numVerts;
}
-CCGVert *ccgSubSurf_getFaceVert(CCGSubSurf *UNUSED(ss), CCGFace *f, int index) {
+CCGVert *ccgSubSurf_getFaceVert(CCGSubSurf *UNUSED(ss), CCGFace *f, int index)
+{
if (index<0 || index>=f->numVerts) {
return NULL;
- } else {
+ }
+ else {
return FACE_getVerts(f)[index];
}
}
-CCGEdge *ccgSubSurf_getFaceEdge(CCGSubSurf *UNUSED(ss), CCGFace *f, int index) {
+CCGEdge *ccgSubSurf_getFaceEdge(CCGSubSurf *UNUSED(ss), CCGFace *f, int index)
+{
if (index<0 || index>=f->numVerts) {
return NULL;
- } else {
+ }
+ else {
return FACE_getEdges(f)[index];
}
}
-int ccgSubSurf_getFaceEdgeIndex(CCGFace *f, CCGEdge *e) {
+int ccgSubSurf_getFaceEdgeIndex(CCGFace *f, CCGEdge *e)
+{
int i;
- for (i=0; i<f->numVerts; i++)
- if (FACE_getEdges(f)[i]==e)
+ for (i = 0; i < f->numVerts; i++) {
+ if (FACE_getEdges(f)[i] == e) {
return i;
-
+ }
+ }
return -1;
}
-void *ccgSubSurf_getFaceCenterData(CCGFace *f) {
+void *ccgSubSurf_getFaceCenterData(CCGFace *f)
+{
return FACE_getCenterData(f);
}
-void *ccgSubSurf_getFaceGridEdgeDataArray(CCGSubSurf *ss, CCGFace *f, int gridIndex) {
+void *ccgSubSurf_getFaceGridEdgeDataArray(CCGSubSurf *ss, CCGFace *f, int gridIndex)
+{
return ccgSubSurf_getFaceGridEdgeData(ss, f, gridIndex, 0);
}
-void *ccgSubSurf_getFaceGridEdgeData(CCGSubSurf *ss, CCGFace *f, int gridIndex, int x) {
+void *ccgSubSurf_getFaceGridEdgeData(CCGSubSurf *ss, CCGFace *f, int gridIndex, int x)
+{
return _face_getIECo(f, ss->subdivLevels, gridIndex, x, ss->subdivLevels, ss->meshIFC.vertDataSize);
}
-void *ccgSubSurf_getFaceGridDataArray(CCGSubSurf *ss, CCGFace *f, int gridIndex) {
+void *ccgSubSurf_getFaceGridDataArray(CCGSubSurf *ss, CCGFace *f, int gridIndex)
+{
return ccgSubSurf_getFaceGridData(ss, f, gridIndex, 0, 0);
}
-void *ccgSubSurf_getFaceGridData(CCGSubSurf *ss, CCGFace *f, int gridIndex, int x, int y) {
+void *ccgSubSurf_getFaceGridData(CCGSubSurf *ss, CCGFace *f, int gridIndex, int x, int y)
+{
return _face_getIFCo(f, ss->subdivLevels, gridIndex, x, y, ss->subdivLevels, ss->meshIFC.vertDataSize);
}
/*** External API iterator functions ***/
-CCGVertIterator *ccgSubSurf_getVertIterator(CCGSubSurf *ss) {
+CCGVertIterator *ccgSubSurf_getVertIterator(CCGSubSurf *ss)
+{
return (CCGVertIterator*) _ehashIterator_new(ss->vMap);
}
-CCGEdgeIterator *ccgSubSurf_getEdgeIterator(CCGSubSurf *ss) {
+CCGEdgeIterator *ccgSubSurf_getEdgeIterator(CCGSubSurf *ss)
+{
return (CCGEdgeIterator*) _ehashIterator_new(ss->eMap);
}
-CCGFaceIterator *ccgSubSurf_getFaceIterator(CCGSubSurf *ss) {
+CCGFaceIterator *ccgSubSurf_getFaceIterator(CCGSubSurf *ss)
+{
return (CCGFaceIterator*) _ehashIterator_new(ss->fMap);
}
-CCGVert *ccgVertIterator_getCurrent(CCGVertIterator *vi) {
+CCGVert *ccgVertIterator_getCurrent(CCGVertIterator *vi)
+{
return (CCGVert*) _ehashIterator_getCurrent((EHashIterator*) vi);
}
-int ccgVertIterator_isStopped(CCGVertIterator *vi) {
+int ccgVertIterator_isStopped(CCGVertIterator *vi)
+{
return _ehashIterator_isStopped((EHashIterator*) vi);
}
-void ccgVertIterator_next(CCGVertIterator *vi) {
+void ccgVertIterator_next(CCGVertIterator *vi)
+{
_ehashIterator_next((EHashIterator*) vi);
}
-void ccgVertIterator_free(CCGVertIterator *vi) {
+void ccgVertIterator_free(CCGVertIterator *vi)
+{
_ehashIterator_free((EHashIterator*) vi);
}
-CCGEdge *ccgEdgeIterator_getCurrent(CCGEdgeIterator *vi) {
+CCGEdge *ccgEdgeIterator_getCurrent(CCGEdgeIterator *vi)
+{
return (CCGEdge*) _ehashIterator_getCurrent((EHashIterator*) vi);
}
-int ccgEdgeIterator_isStopped(CCGEdgeIterator *vi) {
+int ccgEdgeIterator_isStopped(CCGEdgeIterator *vi)
+{
return _ehashIterator_isStopped((EHashIterator*) vi);
}
-void ccgEdgeIterator_next(CCGEdgeIterator *vi) {
+void ccgEdgeIterator_next(CCGEdgeIterator *vi)
+{
_ehashIterator_next((EHashIterator*) vi);
}
-void ccgEdgeIterator_free(CCGEdgeIterator *vi) {
+void ccgEdgeIterator_free(CCGEdgeIterator *vi)
+{
_ehashIterator_free((EHashIterator*) vi);
}
-CCGFace *ccgFaceIterator_getCurrent(CCGFaceIterator *vi) {
+CCGFace *ccgFaceIterator_getCurrent(CCGFaceIterator *vi)
+{
return (CCGFace*) _ehashIterator_getCurrent((EHashIterator*) vi);
}
-int ccgFaceIterator_isStopped(CCGFaceIterator *vi) {
+int ccgFaceIterator_isStopped(CCGFaceIterator *vi)
+{
return _ehashIterator_isStopped((EHashIterator*) vi);
}
-void ccgFaceIterator_next(CCGFaceIterator *vi) {
+void ccgFaceIterator_next(CCGFaceIterator *vi)
+{
_ehashIterator_next((EHashIterator*) vi);
}
-void ccgFaceIterator_free(CCGFaceIterator *vi) {
+void ccgFaceIterator_free(CCGFaceIterator *vi)
+{
_ehashIterator_free((EHashIterator*) vi);
}
/*** Extern API final vert/edge/face interface ***/
-int ccgSubSurf_getNumFinalVerts(const CCGSubSurf *ss) {
- int edgeSize = 1 + (1<<ss->subdivLevels);
- int gridSize = 1 + (1<<(ss->subdivLevels-1));
- int numFinalVerts = ss->vMap->numEntries + ss->eMap->numEntries*(edgeSize-2) + ss->fMap->numEntries + ss->numGrids*((gridSize-2) + ((gridSize-2)*(gridSize-2)));
+int ccgSubSurf_getNumFinalVerts(const CCGSubSurf *ss)
+{
+ int edgeSize = 1 + (1 << ss->subdivLevels);
+ int gridSize = 1 + (1 << (ss->subdivLevels - 1));
+ int numFinalVerts = (ss->vMap->numEntries +
+ ss->eMap->numEntries * (edgeSize - 2) +
+ ss->fMap->numEntries +
+ ss->numGrids * ((gridSize - 2) + ((gridSize - 2) * (gridSize - 2))));
+
return numFinalVerts;
}
-int ccgSubSurf_getNumFinalEdges(const CCGSubSurf *ss) {
- int edgeSize = 1 + (1<<ss->subdivLevels);
- int gridSize = 1 + (1<<(ss->subdivLevels-1));
- int numFinalEdges = ss->eMap->numEntries*(edgeSize-1) + ss->numGrids*((gridSize-1) + 2*((gridSize-2)*(gridSize-1)));
+int ccgSubSurf_getNumFinalEdges(const CCGSubSurf *ss)
+{
+ int edgeSize = 1 + (1 << ss->subdivLevels);
+ int gridSize = 1 + (1 << (ss->subdivLevels - 1));
+ int numFinalEdges = (ss->eMap->numEntries * (edgeSize - 1) +
+ ss->numGrids * ((gridSize - 1) + 2 * ((gridSize - 2) * (gridSize - 1))));
+
return numFinalEdges;
}
-int ccgSubSurf_getNumFinalFaces(const CCGSubSurf *ss) {
- int gridSize = 1 + (1<<(ss->subdivLevels-1));
- int numFinalFaces = ss->numGrids*((gridSize-1)*(gridSize-1));
+int ccgSubSurf_getNumFinalFaces(const CCGSubSurf *ss)
+{
+ int gridSize = 1 + (1 << (ss->subdivLevels - 1));
+ int numFinalFaces = ss->numGrids * ((gridSize - 1) * (gridSize - 1));
return numFinalFaces;
}
diff --git a/source/blender/blenkernel/intern/DerivedMesh.c b/source/blender/blenkernel/intern/DerivedMesh.c
index ca453cc6703..0a6d8b7c041 100644
--- a/source/blender/blenkernel/intern/DerivedMesh.c
+++ b/source/blender/blenkernel/intern/DerivedMesh.c
@@ -869,22 +869,22 @@ void weight_to_rgb(float r_rgb[3], const float weight)
{
const float blend= ((weight/2.0f)+0.5f);
- if (weight<=0.25f){ // blue->cyan
+ if (weight<=0.25f) { // blue->cyan
r_rgb[0]= 0.0f;
r_rgb[1]= blend*weight*4.0f;
r_rgb[2]= blend;
}
- else if (weight<=0.50f){ // cyan->green
+ else if (weight<=0.50f) { // cyan->green
r_rgb[0]= 0.0f;
r_rgb[1]= blend;
r_rgb[2]= blend*(1.0f-((weight-0.25f)*4.0f));
}
- else if (weight <= 0.75f){ // green->yellow
+ else if (weight <= 0.75f) { // green->yellow
r_rgb[0]= blend * ((weight-0.50f)*4.0f);
r_rgb[1]= blend;
r_rgb[2]= 0.0f;
}
- else if (weight <= 1.0f){ // yellow->red
+ else if (weight <= 1.0f) { // yellow->red
r_rgb[0]= blend;
r_rgb[1]= blend * (1.0f-((weight-0.75f)*4.0f));
r_rgb[2]= 0.0f;
diff --git a/source/blender/blenkernel/intern/action.c b/source/blender/blenkernel/intern/action.c
index 767401a55ef..000d74f110a 100644
--- a/source/blender/blenkernel/intern/action.c
+++ b/source/blender/blenkernel/intern/action.c
@@ -1199,7 +1199,7 @@ static void blend_pose_strides(bPose *dst, bPose *src, float srcweight, short mo
{
float dstweight;
- switch (mode){
+ switch (mode) {
case ACTSTRIPMODE_BLEND:
dstweight = 1.0F - srcweight;
break;
@@ -1489,7 +1489,7 @@ static void do_nla(Scene *scene, Object *ob, int blocktype)
}
/* and now go over all strips */
- for (strip=ob->nlastrips.first; strip; strip=strip->next){
+ for (strip=ob->nlastrips.first; strip; strip=strip->next) {
doit=dostride= 0;
if (strip->act && !(strip->flag & ACTSTRIP_MUTE)) { /* so theres an action */
@@ -1500,7 +1500,7 @@ static void do_nla(Scene *scene, Object *ob, int blocktype)
striptime = (scene_cfra-(strip->start)) / length;
stripframe = (scene_cfra-(strip->start)) ;
- if (striptime>=0.0){
+ if (striptime>=0.0) {
if(blocktype==ID_AR)
rest_pose(tpose);
@@ -1509,14 +1509,14 @@ static void do_nla(Scene *scene, Object *ob, int blocktype)
if (striptime < 1.0f + 0.1f/length) {
/* Handle path */
- if ((strip->flag & ACTSTRIP_USESTRIDE) && (blocktype==ID_AR) && (ob->ipoflag & OB_DISABLE_PATH)==0){
+ if ((strip->flag & ACTSTRIP_USESTRIDE) && (blocktype==ID_AR) && (ob->ipoflag & OB_DISABLE_PATH)==0) {
Object *parent= get_parent_path(ob);
if (parent) {
Curve *cu = parent->data;
float ctime, pdist;
- if (cu->flag & CU_PATH){
+ if (cu->flag & CU_PATH) {
/* Ensure we have a valid path */
if(cu->path==NULL || cu->path->data==NULL) makeDispListCurveTypes(scene, parent, 0);
if(cu->path) {
@@ -1590,7 +1590,7 @@ static void do_nla(Scene *scene, Object *ob, int blocktype)
}
/* Handle extend */
else {
- if (strip->flag & ACTSTRIP_HOLDLASTFRAME){
+ if (strip->flag & ACTSTRIP_HOLDLASTFRAME) {
/* we want the strip to hold on the exact fraction of the repeat value */
frametime = actlength * (strip->repeat-(int)strip->repeat);
@@ -1616,13 +1616,13 @@ static void do_nla(Scene *scene, Object *ob, int blocktype)
}
/* Handle blendin & blendout */
- if (doit){
+ if (doit) {
/* Handle blendin */
- if (strip->blendin>0.0 && stripframe<=strip->blendin && scene_cfra>=strip->start){
+ if (strip->blendin>0.0 && stripframe<=strip->blendin && scene_cfra>=strip->start) {
blendfac = stripframe/strip->blendin;
}
- else if (strip->blendout>0.0 && stripframe>=(length-strip->blendout) && scene_cfra<=strip->end){
+ else if (strip->blendout>0.0 && stripframe>=(length-strip->blendout) && scene_cfra<=strip->end) {
blendfac = (length-stripframe)/(strip->blendout);
}
else
diff --git a/source/blender/blenkernel/intern/boids.c b/source/blender/blenkernel/intern/boids.c
index d454bef3184..f3f4d7c9598 100644
--- a/source/blender/blenkernel/intern/boids.c
+++ b/source/blender/blenkernel/intern/boids.c
@@ -291,7 +291,7 @@ static int rule_avoid_collision(BoidRule *rule, BoidBrainData *bbd, BoidValues *
}
}
}
- if(ptn){ MEM_freeN(ptn); ptn=NULL; }
+ if (ptn) { MEM_freeN(ptn); ptn=NULL; }
/* check boids in other systems */
for(pt=bbd->sim->psys->targets.first; pt; pt=pt->next) {
@@ -337,7 +337,7 @@ static int rule_avoid_collision(BoidRule *rule, BoidBrainData *bbd, BoidValues *
}
}
- if(ptn){ MEM_freeN(ptn); ptn=NULL; }
+ if (ptn) { MEM_freeN(ptn); ptn=NULL; }
}
}
@@ -364,7 +364,7 @@ static int rule_separate(BoidRule *UNUSED(rule), BoidBrainData *bbd, BoidValues
len = ptn[1].dist;
ret = 1;
}
- if(ptn){ MEM_freeN(ptn); ptn=NULL; }
+ if (ptn) { MEM_freeN(ptn); ptn=NULL; }
/* check other boid systems */
for(pt=bbd->sim->psys->targets.first; pt; pt=pt->next) {
@@ -382,7 +382,7 @@ static int rule_separate(BoidRule *UNUSED(rule), BoidBrainData *bbd, BoidValues
ret = 1;
}
- if(ptn){ MEM_freeN(ptn); ptn=NULL; }
+ if (ptn) { MEM_freeN(ptn); ptn=NULL; }
}
}
return ret;
@@ -487,7 +487,7 @@ static int rule_follow_leader(BoidRule *rule, BoidBrainData *bbd, BoidValues *va
float vec2[3], t, t_min = 3.0f;
/* first check we're not blocking any leaders */
- for(i = 0; i< bbd->sim->psys->totpart; i+=n){
+ for(i = 0; i< bbd->sim->psys->totpart; i+=n) {
copy_v3_v3(vec, bbd->sim->psys->particles[i].prev_state.vel);
sub_v3_v3v3(loc, pa->prev_state.co, bbd->sim->psys->particles[i].prev_state.co);
@@ -626,7 +626,7 @@ static int rule_fight(BoidRule *rule, BoidBrainData *bbd, BoidValues *val, Parti
f_strength += bbd->part->boids->strength * health;
- if(ptn){ MEM_freeN(ptn); ptn=NULL; }
+ if (ptn) { MEM_freeN(ptn); ptn=NULL; }
/* add other friendlies and calculate enemy strength and find closest enemy */
for(pt=bbd->sim->psys->targets.first; pt; pt=pt->next) {
@@ -653,7 +653,7 @@ static int rule_fight(BoidRule *rule, BoidBrainData *bbd, BoidValues *val, Parti
else if(pt->mode==PTARGET_MODE_FRIEND)
f_strength += epsys->part->boids->strength * health;
- if(ptn){ MEM_freeN(ptn); ptn=NULL; }
+ if (ptn) { MEM_freeN(ptn); ptn=NULL; }
}
}
/* decide action if enemy presence found */
@@ -779,7 +779,7 @@ static Object *boid_find_ground(BoidBrainData *bbd, ParticleData *pa, float grou
hit.dist = col.original_ray_length = len_v3(ray_dir);
col.pce.inside = 0;
- for(coll = bbd->sim->colliders->first; coll; coll = coll->next){
+ for(coll = bbd->sim->colliders->first; coll; coll = coll->next) {
col.current = coll->ob;
col.md = coll->collmd;
col.fac1 = col.fac2 = 0.f;
@@ -804,7 +804,7 @@ static Object *boid_find_ground(BoidBrainData *bbd, ParticleData *pa, float grou
hit.index = -1;
hit.dist = col.original_ray_length = len_v3(ray_dir);
- for(coll = bbd->sim->colliders->first; coll; coll = coll->next){
+ for(coll = bbd->sim->colliders->first; coll; coll = coll->next) {
col.current = coll->ob;
col.md = coll->collmd;
@@ -1325,7 +1325,7 @@ void boid_body(BoidBrainData *bbd, ParticleData *pa)
boid_climb(boids, pa, ground_co, ground_nor);
}
/* land boid when really near ground */
- else if(pa->state.co[2] <= ground_co[2] + 1.01f * pa->size * boids->height){
+ else if(pa->state.co[2] <= ground_co[2] + 1.01f * pa->size * boids->height) {
pa->state.co[2] = ground_co[2] + pa->size * boids->height;
pa->state.vel[2] = 0.0f;
bpa->data.mode = eBoidMode_OnLand;
diff --git a/source/blender/blenkernel/intern/brush.c b/source/blender/blenkernel/intern/brush.c
index f2514c1030b..f5c39f3e30c 100644
--- a/source/blender/blenkernel/intern/brush.c
+++ b/source/blender/blenkernel/intern/brush.c
@@ -543,7 +543,7 @@ void brush_imbuf_new(const Scene *scene, Brush *brush, short flt, short texfall,
if (flt) {
copy_v3_v3(brush_rgb, brush->rgb);
- if(use_color_correction){
+ if (use_color_correction) {
srgb_to_linearrgb_v3_v3(brush_rgb, brush_rgb);
}
@@ -1048,9 +1048,9 @@ void brush_jitter_pos(const Scene *scene, Brush *brush, float pos[2], float jitt
/* jitter-ed brush gives weird and unpredictable result for this
kinds of stroke, so manyally disable jitter usage (sergey) */
- use_jitter&= (brush->flag & (BRUSH_RESTORE_MESH|BRUSH_ANCHORED)) == 0;
+ use_jitter &= (brush->flag & (BRUSH_RESTORE_MESH|BRUSH_ANCHORED)) == 0;
- if(use_jitter){
+ if (use_jitter) {
float rand_pos[2];
const int radius= brush_size(scene, brush);
const int diameter= 2*radius;
diff --git a/source/blender/blenkernel/intern/cdderivedmesh.c b/source/blender/blenkernel/intern/cdderivedmesh.c
index 9f3c9fc8b78..c1d6165d37e 100644
--- a/source/blender/blenkernel/intern/cdderivedmesh.c
+++ b/source/blender/blenkernel/intern/cdderivedmesh.c
@@ -1846,7 +1846,7 @@ static void loops_to_customdata_corners(BMesh *bm, CustomData *facedata,
MLoopUV *mloopuv;
int i, j, hasWCol = CustomData_has_layer(&bm->ldata, CD_WEIGHT_MLOOPCOL);
- for(i=0; i < numTex; i++){
+ for (i=0; i < numTex; i++) {
texface = CustomData_get_n(facedata, CD_MTFACE, cdindex, i);
texpoly = CustomData_bmesh_get_n(&bm->pdata, f->head.data, CD_MTEXPOLY, i);
@@ -1859,7 +1859,7 @@ static void loops_to_customdata_corners(BMesh *bm, CustomData *facedata,
}
}
- for(i=0; i < numCol; i++){
+ for (i=0; i < numCol; i++) {
mcol = CustomData_get_n(facedata, CD_MCOL, cdindex, i);
for (j=0; j<3; j++) {
diff --git a/source/blender/blenkernel/intern/constraint.c b/source/blender/blenkernel/intern/constraint.c
index e8c6ec8d3ed..e8cd1526880 100644
--- a/source/blender/blenkernel/intern/constraint.c
+++ b/source/blender/blenkernel/intern/constraint.c
@@ -2317,7 +2317,7 @@ static void locktrack_evaluate (bConstraint *con, bConstraintOb *cob, ListBase *
/* Vector object -> target */
sub_v3_v3v3(vec, ct->matrix[3], cob->matrix[3]);
- switch (data->lockflag){
+ switch (data->lockflag) {
case LOCK_X: /* LOCK X */
{
switch (data->trackflag) {
diff --git a/source/blender/blenkernel/intern/customdata.c b/source/blender/blenkernel/intern/customdata.c
index b2aaa651912..01216cef7ef 100644
--- a/source/blender/blenkernel/intern/customdata.c
+++ b/source/blender/blenkernel/intern/customdata.c
@@ -644,16 +644,17 @@ static void layerInterp_mloopcol(void **sources, float *weights,
col.a = col.r = col.g = col.b = 0;
sub_weight = sub_weights;
- for(i = 0; i < count; ++i){
+ for (i = 0; i < count; ++i) {
float weight = weights ? weights[i] : 1;
MLoopCol *src = sources[i];
- if(sub_weights){
+ if (sub_weights) {
col.a += src->a * (*sub_weight) * weight;
col.r += src->r * (*sub_weight) * weight;
col.g += src->g * (*sub_weight) * weight;
col.b += src->b * (*sub_weight) * weight;
sub_weight++;
- } else {
+ }
+ else {
col.a += src->a * weight;
col.r += src->r * weight;
col.g += src->g * weight;
diff --git a/source/blender/blenkernel/intern/lattice.c b/source/blender/blenkernel/intern/lattice.c
index 5e4d8d24d24..79922e47564 100644
--- a/source/blender/blenkernel/intern/lattice.c
+++ b/source/blender/blenkernel/intern/lattice.c
@@ -69,11 +69,11 @@
void calc_lat_fudu(int flag, int res, float *fu, float *du)
{
- if(res==1) {
+ if (res==1) {
*fu= 0.0;
*du= 0.0;
}
- else if(flag & LT_GRID) {
+ else if (flag & LT_GRID) {
*fu= -0.5f*(res-1);
*du= 1.0f;
}
@@ -91,14 +91,14 @@ void resizelattice(Lattice *lt, int uNew, int vNew, int wNew, Object *ltOb)
float *co, (*vertexCos)[3] = NULL;
/* vertex weight groups are just freed all for now */
- if(lt->dvert) {
+ if (lt->dvert) {
free_dverts(lt->dvert, lt->pntsu*lt->pntsv*lt->pntsw);
lt->dvert= NULL;
}
while(uNew*vNew*wNew > 32000) {
- if( uNew>=vNew && uNew>=wNew) uNew--;
- else if( vNew>=uNew && vNew>=wNew) vNew--;
+ if ( uNew>=vNew && uNew>=wNew) uNew--;
+ else if ( vNew>=uNew && vNew>=wNew) vNew--;
else wNew--;
}
@@ -131,9 +131,9 @@ void resizelattice(Lattice *lt, int uNew, int vNew, int wNew, Object *ltOb)
}
co = vertexCos[0];
- for(w=0,wc=fw; w<wNew; w++,wc+=dw) {
- for(v=0,vc=fv; v<vNew; v++,vc+=dv) {
- for(u=0,uc=fu; u<uNew; u++,co+=3,uc+=du) {
+ for (w=0,wc=fw; w<wNew; w++,wc+=dw) {
+ for (v=0,vc=fv; v<vNew; v++,vc+=dv) {
+ for (u=0,uc=fu; u<uNew; u++,co+=3,uc+=du) {
co[0] = uc;
co[1] = vc;
co[2] = wc;
@@ -208,9 +208,9 @@ Lattice *copy_lattice(Lattice *lt)
ltn->def= MEM_dupallocN(lt->def);
ltn->key= copy_key(ltn->key);
- if(ltn->key) ltn->key->from= (ID *)ltn;
+ if (ltn->key) ltn->key->from= (ID *)ltn;
- if(lt->dvert) {
+ if (lt->dvert) {
int tot= lt->pntsu*lt->pntsv*lt->pntsw;
ltn->dvert = MEM_mallocN (sizeof (MDeformVert)*tot, "Lattice MDeformVert");
copy_dverts(ltn->dvert, lt->dvert, tot);
@@ -223,13 +223,13 @@ Lattice *copy_lattice(Lattice *lt)
void free_lattice(Lattice *lt)
{
- if(lt->def) MEM_freeN(lt->def);
- if(lt->dvert) free_dverts(lt->dvert, lt->pntsu*lt->pntsv*lt->pntsw);
- if(lt->editlatt) {
+ if (lt->def) MEM_freeN(lt->def);
+ if (lt->dvert) free_dverts(lt->dvert, lt->pntsu*lt->pntsv*lt->pntsw);
+ if (lt->editlatt) {
Lattice *editlt= lt->editlatt->latt;
- if(editlt->def) MEM_freeN(editlt->def);
- if(editlt->dvert) free_dverts(editlt->dvert, lt->pntsu*lt->pntsv*lt->pntsw);
+ if (editlt->def) MEM_freeN(editlt->def);
+ if (editlt->dvert) free_dverts(editlt->dvert, lt->pntsu*lt->pntsv*lt->pntsw);
MEM_freeN(editlt);
MEM_freeN(lt->editlatt);
@@ -254,32 +254,32 @@ void make_local_lattice(Lattice *lt)
* - mixed: make copy
*/
- if(lt->id.lib==NULL) return;
- if(lt->id.us==1) {
+ if (lt->id.lib==NULL) return;
+ if (lt->id.us==1) {
id_clear_lib_data(bmain, &lt->id);
return;
}
- for(ob= bmain->object.first; ob && ELEM(FALSE, is_lib, is_local); ob= ob->id.next) {
- if(ob->data==lt) {
- if(ob->id.lib) is_lib= TRUE;
+ for (ob= bmain->object.first; ob && ELEM(FALSE, is_lib, is_local); ob= ob->id.next) {
+ if (ob->data==lt) {
+ if (ob->id.lib) is_lib= TRUE;
else is_local= TRUE;
}
}
- if(is_local && is_lib==FALSE) {
+ if (is_local && is_lib==FALSE) {
id_clear_lib_data(bmain, &lt->id);
}
- else if(is_local && is_lib) {
+ else if (is_local && is_lib) {
Lattice *lt_new= copy_lattice(lt);
lt_new->id.us= 0;
/* Remap paths of new ID using old library as base. */
BKE_id_lib_local_paths(bmain, lt->id.lib, &lt_new->id);
- for(ob= bmain->object.first; ob; ob= ob->id.next) {
- if(ob->data==lt) {
- if(ob->id.lib==NULL) {
+ for (ob= bmain->object.first; ob; ob= ob->id.next) {
+ if (ob->data==lt) {
+ if (ob->id.lib==NULL) {
ob->data= lt_new;
lt_new->id.us++;
lt->id.us--;
@@ -300,13 +300,13 @@ void init_latt_deform(Object *oblatt, Object *ob)
float fu, fv, fw;
int u, v, w;
- if(lt->editlatt) lt= lt->editlatt->latt;
+ if (lt->editlatt) lt= lt->editlatt->latt;
bp = lt->def;
fp= lt->latticedata= MEM_mallocN(sizeof(float)*3*lt->pntsu*lt->pntsv*lt->pntsw, "latticedata");
/* for example with a particle system: ob==0 */
- if(ob==NULL) {
+ if (ob==NULL) {
/* in deformspace, calc matrix */
invert_m4_m4(lt->latmat, oblatt->obmat);
@@ -322,9 +322,9 @@ void init_latt_deform(Object *oblatt, Object *ob)
invert_m4_m4(imat, lt->latmat);
}
- for(w=0,fw=lt->fw; w<lt->pntsw; w++,fw+=lt->dw) {
- for(v=0,fv=lt->fv; v<lt->pntsv; v++, fv+=lt->dv) {
- for(u=0,fu=lt->fu; u<lt->pntsu; u++, bp++, co+=3, fp+=3, fu+=lt->du) {
+ for (w=0,fw=lt->fw; w<lt->pntsw; w++,fw+=lt->dw) {
+ for (v=0,fv=lt->fv; v<lt->pntsv; v++, fv+=lt->dv) {
+ for (u=0,fu=lt->fu; u<lt->pntsu; u++, bp++, co+=3, fp+=3, fu+=lt->du) {
if (dl) {
fp[0] = co[0] - fu;
fp[1] = co[1] - fv;
@@ -355,10 +355,10 @@ void calc_latt_deform(Object *ob, float *co, float weight)
MDeformVert *dvert= lattice_get_deform_verts(ob);
- if(lt->editlatt) lt= lt->editlatt->latt;
- if(lt->latticedata==NULL) return;
+ if (lt->editlatt) lt= lt->editlatt->latt;
+ if (lt->latticedata==NULL) return;
- if(lt->vgroup[0] && dvert) {
+ if (lt->vgroup[0] && dvert) {
defgroup_nr= defgroup_name_index(ob, lt->vgroup);
copy_v3_v3(co_prev, co);
}
@@ -368,7 +368,7 @@ void calc_latt_deform(Object *ob, float *co, float weight)
/* u v w coords */
- if(lt->pntsu>1) {
+ if (lt->pntsu>1) {
u= (vec[0]-lt->fu)/lt->du;
ui= (int)floor(u);
u -= ui;
@@ -379,7 +379,7 @@ void calc_latt_deform(Object *ob, float *co, float weight)
ui= 0;
}
- if(lt->pntsv>1) {
+ if (lt->pntsv>1) {
v= (vec[1]-lt->fv)/lt->dv;
vi= (int)floor(v);
v -= vi;
@@ -390,7 +390,7 @@ void calc_latt_deform(Object *ob, float *co, float weight)
vi= 0;
}
- if(lt->pntsw>1) {
+ if (lt->pntsw>1) {
w= (vec[2]-lt->fw)/lt->dw;
wi= (int)floor(w);
w -= wi;
@@ -401,39 +401,39 @@ void calc_latt_deform(Object *ob, float *co, float weight)
wi= 0;
}
- for(ww= wi-1; ww<=wi+2; ww++) {
+ for (ww= wi-1; ww<=wi+2; ww++) {
w= tw[ww-wi+1];
- if(w != 0.0f) {
- if(ww>0) {
- if(ww<lt->pntsw) idx_w= ww*lt->pntsu*lt->pntsv;
+ if (w != 0.0f) {
+ if (ww>0) {
+ if (ww<lt->pntsw) idx_w= ww*lt->pntsu*lt->pntsv;
else idx_w= (lt->pntsw-1)*lt->pntsu*lt->pntsv;
}
else idx_w= 0;
- for(vv= vi-1; vv<=vi+2; vv++) {
+ for (vv= vi-1; vv<=vi+2; vv++) {
v= w*tv[vv-vi+1];
- if(v != 0.0f) {
- if(vv>0) {
- if(vv<lt->pntsv) idx_v= idx_w + vv*lt->pntsu;
+ if (v != 0.0f) {
+ if (vv>0) {
+ if (vv<lt->pntsv) idx_v= idx_w + vv*lt->pntsu;
else idx_v= idx_w + (lt->pntsv-1)*lt->pntsu;
}
else idx_v= idx_w;
- for(uu= ui-1; uu<=ui+2; uu++) {
+ for (uu= ui-1; uu<=ui+2; uu++) {
u= weight*v*tu[uu-ui+1];
- if(u != 0.0f) {
- if(uu>0) {
- if(uu<lt->pntsu) idx_u= idx_v + uu;
+ if (u != 0.0f) {
+ if (uu>0) {
+ if (uu<lt->pntsu) idx_u= idx_v + uu;
else idx_u= idx_v + (lt->pntsu-1);
}
else idx_u= idx_v;
madd_v3_v3fl(co, &lt->latticedata[idx_u * 3], u);
- if(defgroup_nr != -1)
+ if (defgroup_nr != -1)
weight_blend += (u * defvert_find_weight(dvert + idx_u, defgroup_nr));
}
}
@@ -442,7 +442,7 @@ void calc_latt_deform(Object *ob, float *co, float weight)
}
}
- if(defgroup_nr != -1)
+ if (defgroup_nr != -1)
interp_v3_v3v3(co, co_prev, co, weight_blend);
}
@@ -451,9 +451,9 @@ void end_latt_deform(Object *ob)
{
Lattice *lt= ob->data;
- if(lt->editlatt) lt= lt->editlatt->latt;
+ if (lt->editlatt) lt= lt->editlatt->latt;
- if(lt->latticedata)
+ if (lt->latticedata)
MEM_freeN(lt->latticedata);
lt->latticedata= NULL;
}
@@ -490,33 +490,33 @@ static int where_on_path_deform(Object *ob, float ctime, float vec[4], float dir
/* test for cyclic */
bl= cu->bev.first;
if (!bl->nr) return 0;
- if(bl && bl->poly> -1) cycl= 1;
+ if (bl && bl->poly> -1) cycl= 1;
- if(cycl==0) {
+ if (cycl==0) {
ctime1= CLAMPIS(ctime, 0.0f, 1.0f);
}
else ctime1= ctime;
/* vec needs 4 items */
- if(where_on_path(ob, ctime1, vec, dir, quat, radius, NULL)) {
+ if (where_on_path(ob, ctime1, vec, dir, quat, radius, NULL)) {
- if(cycl==0) {
+ if (cycl==0) {
Path *path= cu->path;
float dvec[3];
- if(ctime < 0.0f) {
+ if (ctime < 0.0f) {
sub_v3_v3v3(dvec, path->data[1].vec, path->data[0].vec);
mul_v3_fl(dvec, ctime*(float)path->len);
add_v3_v3(vec, dvec);
- if(quat) copy_qt_qt(quat, path->data[0].quat);
- if(radius) *radius= path->data[0].radius;
+ if (quat) copy_qt_qt(quat, path->data[0].quat);
+ if (radius) *radius= path->data[0].radius;
}
- else if(ctime > 1.0f) {
+ else if (ctime > 1.0f) {
sub_v3_v3v3(dvec, path->data[path->len-1].vec, path->data[path->len-2].vec);
mul_v3_fl(dvec, (ctime-1.0f)*(float)path->len);
add_v3_v3(vec, dvec);
- if(quat) copy_qt_qt(quat, path->data[path->len-1].quat);
- if(radius) *radius= path->data[path->len-1].radius;
+ if (quat) copy_qt_qt(quat, path->data[path->len-1].quat);
+ if (radius) *radius= path->data[path->len-1].radius;
/* weight - not used but could be added */
}
}
@@ -539,31 +539,31 @@ static int calc_curve_deform(Scene *scene, Object *par, float co[3],
const int is_neg_axis = (axis > 2);
/* to be sure, mostly after file load */
- if(cu->path==NULL) {
+ if (cu->path==NULL) {
makeDispListCurveTypes(scene, par, 0);
- if(cu->path==NULL) return 0; // happens on append...
+ if (cu->path==NULL) return 0; // happens on append...
}
/* options */
if (is_neg_axis) {
index = axis - 3;
- if(cu->flag & CU_STRETCH)
+ if (cu->flag & CU_STRETCH)
fac= (-co[index]-cd->dmax[index])/(cd->dmax[index] - cd->dmin[index]);
else
fac= - (co[index]-cd->dmax[index])/(cu->path->totdist);
}
else {
index = axis;
- if(cu->flag & CU_STRETCH)
+ if (cu->flag & CU_STRETCH)
fac= (co[index]-cd->dmin[index])/(cd->dmax[index] - cd->dmin[index]);
else
fac= + (co[index]-cd->dmin[index])/(cu->path->totdist);
}
- if( where_on_path_deform(par, fac, loc, dir, new_quat, &radius)) { /* returns OK */
+ if ( where_on_path_deform(par, fac, loc, dir, new_quat, &radius)) { /* returns OK */
float quat[4], cent[3];
- if(cd->no_rot_axis) { /* set by caller */
+ if (cd->no_rot_axis) { /* set by caller */
/* this is not exactly the same as 2.4x, since the axis is having rotation removed rather than
* changing the axis before calculating the tilt but serves much the same purpose */
@@ -603,7 +603,7 @@ static int calc_curve_deform(Scene *scene, Object *par, float co[3],
/* scale if enabled */
- if(cu->flag & CU_PATH_RADIUS)
+ if (cu->flag & CU_PATH_RADIUS)
mul_v3_fl(cent, radius);
/* local rotation */
@@ -613,7 +613,7 @@ static int calc_curve_deform(Scene *scene, Object *par, float co[3],
/* translation */
add_v3_v3v3(co, cent, loc);
- if(quat_r)
+ if (quat_r)
copy_qt_qt(quat_r, quat);
return 1;
@@ -631,7 +631,7 @@ void curve_deform_verts(Scene *scene, Object *cuOb, Object *target,
int use_vgroups;
const int is_neg_axis = (defaxis > 2);
- if(cuOb->type != OB_CURVE)
+ if (cuOb->type != OB_CURVE)
return;
cu = cuOb->data;
@@ -641,7 +641,7 @@ void curve_deform_verts(Scene *scene, Object *cuOb, Object *target,
init_curve_deform(cuOb, target, &cd);
/* dummy bounds, keep if CU_DEFORM_BOUNDS_OFF is set */
- if(is_neg_axis == FALSE) {
+ if (is_neg_axis == FALSE) {
cd.dmin[0]= cd.dmin[1]= cd.dmin[2]= 0.0f;
cd.dmax[0]= cd.dmax[1]= cd.dmax[2]= 1.0f;
}
@@ -655,32 +655,32 @@ void curve_deform_verts(Scene *scene, Object *cuOb, Object *target,
* we want either a Mesh with no derived data, or derived data with
* deformverts
*/
- if(target && target->type==OB_MESH) {
+ if (target && target->type==OB_MESH) {
/* if there's derived data without deformverts, don't use vgroups */
- if(dm && !dm->getVertData(dm, 0, CD_MDEFORMVERT))
+ if (dm && !dm->getVertData(dm, 0, CD_MDEFORMVERT))
use_vgroups = 0;
else
use_vgroups = 1;
} else
use_vgroups = 0;
- if(vgroup && vgroup[0] && use_vgroups) {
+ if (vgroup && vgroup[0] && use_vgroups) {
Mesh *me= target->data;
int index= defgroup_name_index(target, vgroup);
- if(index != -1 && (me->dvert || dm)) {
+ if (index != -1 && (me->dvert || dm)) {
MDeformVert *dvert = me->dvert;
float vec[3];
float weight;
- if(cu->flag & CU_DEFORM_BOUNDS_OFF) {
+ if (cu->flag & CU_DEFORM_BOUNDS_OFF) {
dvert = me->dvert;
- for(a = 0; a < numVerts; a++, dvert++) {
- if(dm) dvert = dm->getVertData(dm, a, CD_MDEFORMVERT);
+ for (a = 0; a < numVerts; a++, dvert++) {
+ if (dm) dvert = dm->getVertData(dm, a, CD_MDEFORMVERT);
weight= defvert_find_weight(dvert, index);
- if(weight > 0.0f) {
+ if (weight > 0.0f) {
mul_m4_v3(cd.curvespace, vertexCos[a]);
copy_v3_v3(vec, vertexCos[a]);
calc_curve_deform(scene, cuOb, vec, defaxis, &cd, NULL);
@@ -693,22 +693,22 @@ void curve_deform_verts(Scene *scene, Object *cuOb, Object *target,
/* set mesh min/max bounds */
INIT_MINMAX(cd.dmin, cd.dmax);
- for(a = 0; a < numVerts; a++, dvert++) {
- if(dm) dvert = dm->getVertData(dm, a, CD_MDEFORMVERT);
+ for (a = 0; a < numVerts; a++, dvert++) {
+ if (dm) dvert = dm->getVertData(dm, a, CD_MDEFORMVERT);
- if(defvert_find_weight(dvert, index) > 0.0f) {
+ if (defvert_find_weight(dvert, index) > 0.0f) {
mul_m4_v3(cd.curvespace, vertexCos[a]);
DO_MINMAX(vertexCos[a], cd.dmin, cd.dmax);
}
}
dvert = me->dvert;
- for(a = 0; a < numVerts; a++, dvert++) {
- if(dm) dvert = dm->getVertData(dm, a, CD_MDEFORMVERT);
+ for (a = 0; a < numVerts; a++, dvert++) {
+ if (dm) dvert = dm->getVertData(dm, a, CD_MDEFORMVERT);
weight= defvert_find_weight(dvert, index);
- if(weight > 0.0f) {
+ if (weight > 0.0f) {
/* already in 'cd.curvespace', prev for loop */
copy_v3_v3(vec, vertexCos[a]);
calc_curve_deform(scene, cuOb, vec, defaxis, &cd, NULL);
@@ -720,8 +720,8 @@ void curve_deform_verts(Scene *scene, Object *cuOb, Object *target,
}
}
else {
- if(cu->flag & CU_DEFORM_BOUNDS_OFF) {
- for(a = 0; a < numVerts; a++) {
+ if (cu->flag & CU_DEFORM_BOUNDS_OFF) {
+ for (a = 0; a < numVerts; a++) {
mul_m4_v3(cd.curvespace, vertexCos[a]);
calc_curve_deform(scene, cuOb, vertexCos[a], defaxis, &cd, NULL);
mul_m4_v3(cd.objectspace, vertexCos[a]);
@@ -731,12 +731,12 @@ void curve_deform_verts(Scene *scene, Object *cuOb, Object *target,
/* set mesh min max bounds */
INIT_MINMAX(cd.dmin, cd.dmax);
- for(a = 0; a < numVerts; a++) {
+ for (a = 0; a < numVerts; a++) {
mul_m4_v3(cd.curvespace, vertexCos[a]);
DO_MINMAX(vertexCos[a], cd.dmin, cd.dmax);
}
- for(a = 0; a < numVerts; a++) {
+ for (a = 0; a < numVerts; a++) {
/* already in 'cd.curvespace', prev for loop */
calc_curve_deform(scene, cuOb, vertexCos[a], defaxis, &cd, NULL);
mul_m4_v3(cd.objectspace, vertexCos[a]);
@@ -755,7 +755,7 @@ void curve_deform_vector(Scene *scene, Object *cuOb, Object *target,
CurveDeform cd;
float quat[4];
- if(cuOb->type != OB_CURVE) {
+ if (cuOb->type != OB_CURVE) {
unit_m3(mat);
return;
}
@@ -768,7 +768,7 @@ void curve_deform_vector(Scene *scene, Object *cuOb, Object *target,
mul_m4_v3(cd.curvespace, vec);
- if(calc_curve_deform(scene, cuOb, vec, target->trackflag, &cd, quat)) {
+ if (calc_curve_deform(scene, cuOb, vec, target->trackflag, &cd, quat)) {
float qmat[3][3];
quat_to_mat3( qmat,quat);
@@ -787,7 +787,7 @@ void lattice_deform_verts(Object *laOb, Object *target, DerivedMesh *dm,
int a;
int use_vgroups;
- if(laOb->type != OB_LATTICE)
+ if (laOb->type != OB_LATTICE)
return;
init_latt_deform(laOb, target);
@@ -796,34 +796,34 @@ void lattice_deform_verts(Object *laOb, Object *target, DerivedMesh *dm,
* we want either a Mesh with no derived data, or derived data with
* deformverts
*/
- if(target && target->type==OB_MESH) {
+ if (target && target->type==OB_MESH) {
/* if there's derived data without deformverts, don't use vgroups */
- if(dm && !dm->getVertData(dm, 0, CD_MDEFORMVERT))
+ if (dm && !dm->getVertData(dm, 0, CD_MDEFORMVERT))
use_vgroups = 0;
else
use_vgroups = 1;
} else
use_vgroups = 0;
- if(vgroup && vgroup[0] && use_vgroups) {
+ if (vgroup && vgroup[0] && use_vgroups) {
Mesh *me = target->data;
int index = defgroup_name_index(target, vgroup);
float weight;
- if(index >= 0 && (me->dvert || dm)) {
+ if (index >= 0 && (me->dvert || dm)) {
MDeformVert *dvert = me->dvert;
- for(a = 0; a < numVerts; a++, dvert++) {
- if(dm) dvert = dm->getVertData(dm, a, CD_MDEFORMVERT);
+ for (a = 0; a < numVerts; a++, dvert++) {
+ if (dm) dvert = dm->getVertData(dm, a, CD_MDEFORMVERT);
weight= defvert_find_weight(dvert, index);
- if(weight > 0.0f)
+ if (weight > 0.0f)
calc_latt_deform(laOb, vertexCos[a], weight);
}
}
} else {
- for(a = 0; a < numVerts; a++) {
+ for (a = 0; a < numVerts; a++) {
calc_latt_deform(laOb, vertexCos[a], 1.0f);
}
}
@@ -832,7 +832,7 @@ void lattice_deform_verts(Object *laOb, Object *target, DerivedMesh *dm,
int object_deform_mball(Object *ob, ListBase *dispbase)
{
- if(ob->parent && ob->parent->type==OB_LATTICE && ob->partype==PARSKEL) {
+ if (ob->parent && ob->parent->type==OB_LATTICE && ob->partype==PARSKEL) {
DispList *dl;
for (dl=dispbase->first; dl; dl=dl->next) {
@@ -857,19 +857,19 @@ void outside_lattice(Lattice *lt)
int u, v, w;
float fac1, du=0.0, dv=0.0, dw=0.0;
- if(lt->flag & LT_OUTSIDE) {
+ if (lt->flag & LT_OUTSIDE) {
bp= lt->def;
- if(lt->pntsu>1) du= 1.0f/((float)lt->pntsu-1);
- if(lt->pntsv>1) dv= 1.0f/((float)lt->pntsv-1);
- if(lt->pntsw>1) dw= 1.0f/((float)lt->pntsw-1);
+ if (lt->pntsu>1) du= 1.0f/((float)lt->pntsu-1);
+ if (lt->pntsv>1) dv= 1.0f/((float)lt->pntsv-1);
+ if (lt->pntsw>1) dw= 1.0f/((float)lt->pntsw-1);
- for(w=0; w<lt->pntsw; w++) {
+ for (w=0; w<lt->pntsw; w++) {
- for(v=0; v<lt->pntsv; v++) {
+ for (v=0; v<lt->pntsv; v++) {
- for(u=0; u<lt->pntsu; u++, bp++) {
- if(u==0 || v==0 || w==0 || u==lt->pntsu-1 || v==lt->pntsv-1 || w==lt->pntsw-1);
+ for (u=0; u<lt->pntsu; u++, bp++) {
+ if (u==0 || v==0 || w==0 || u==lt->pntsu-1 || v==lt->pntsv-1 || w==lt->pntsw-1);
else {
bp->hide= 1;
@@ -914,9 +914,9 @@ void outside_lattice(Lattice *lt)
else {
bp= lt->def;
- for(w=0; w<lt->pntsw; w++)
- for(v=0; v<lt->pntsv; v++)
- for(u=0; u<lt->pntsu; u++, bp++)
+ for (w=0; w<lt->pntsw; w++)
+ for (v=0; v<lt->pntsv; v++)
+ for (u=0; u<lt->pntsu; u++, bp++)
bp->hide= 0;
}
}
@@ -927,7 +927,7 @@ float (*lattice_getVertexCos(struct Object *ob, int *numVerts_r))[3]
int i, numVerts;
float (*vertexCos)[3];
- if(lt->editlatt) lt= lt->editlatt->latt;
+ if (lt->editlatt) lt= lt->editlatt->latt;
numVerts = *numVerts_r = lt->pntsu*lt->pntsv*lt->pntsw;
vertexCos = MEM_mallocN(sizeof(*vertexCos)*numVerts,"lt_vcos");
@@ -990,6 +990,6 @@ struct MDeformVert* lattice_get_deform_verts(struct Object *oblatt)
{
Lattice *lt = (Lattice*)oblatt->data;
BLI_assert(oblatt->type == OB_LATTICE);
- if(lt->editlatt) lt= lt->editlatt->latt;
+ if (lt->editlatt) lt= lt->editlatt->latt;
return lt->dvert;
}
diff --git a/source/blender/blenkernel/intern/material.c b/source/blender/blenkernel/intern/material.c
index f685d0ec151..43270447dad 100644
--- a/source/blender/blenkernel/intern/material.c
+++ b/source/blender/blenkernel/intern/material.c
@@ -82,29 +82,29 @@ void free_material(Material *ma)
MTex *mtex;
int a;
- for(a=0; a<MAX_MTEX; a++) {
+ for (a=0; a<MAX_MTEX; a++) {
mtex= ma->mtex[a];
- if(mtex && mtex->tex) mtex->tex->id.us--;
- if(mtex) MEM_freeN(mtex);
+ if (mtex && mtex->tex) mtex->tex->id.us--;
+ if (mtex) MEM_freeN(mtex);
}
- if(ma->ramp_col) MEM_freeN(ma->ramp_col);
- if(ma->ramp_spec) MEM_freeN(ma->ramp_spec);
+ if (ma->ramp_col) MEM_freeN(ma->ramp_col);
+ if (ma->ramp_spec) MEM_freeN(ma->ramp_spec);
BKE_free_animdata((ID *)ma);
- if(ma->preview)
+ if (ma->preview)
BKE_previewimg_free(&ma->preview);
BKE_icon_delete((struct ID*)ma);
ma->id.icon_id = 0;
/* is no lib link block, but material extension */
- if(ma->nodetree) {
+ if (ma->nodetree) {
ntreeFreeTree(ma->nodetree);
MEM_freeN(ma->nodetree);
}
- if(ma->gpumaterial.first)
+ if (ma->gpumaterial.first)
GPU_material_free(ma);
}
@@ -220,20 +220,20 @@ Material *copy_material(Material *ma)
id_lib_extern((ID *)man->group);
- for(a=0; a<MAX_MTEX; a++) {
- if(ma->mtex[a]) {
+ for (a=0; a<MAX_MTEX; a++) {
+ if (ma->mtex[a]) {
man->mtex[a]= MEM_mallocN(sizeof(MTex), "copymaterial");
memcpy(man->mtex[a], ma->mtex[a], sizeof(MTex));
id_us_plus((ID *)man->mtex[a]->tex);
}
}
- if(ma->ramp_col) man->ramp_col= MEM_dupallocN(ma->ramp_col);
- if(ma->ramp_spec) man->ramp_spec= MEM_dupallocN(ma->ramp_spec);
+ if (ma->ramp_col) man->ramp_col= MEM_dupallocN(ma->ramp_col);
+ if (ma->ramp_spec) man->ramp_spec= MEM_dupallocN(ma->ramp_spec);
if (ma->preview) man->preview = BKE_previewimg_copy(ma->preview);
- if(ma->nodetree) {
+ if (ma->nodetree) {
man->nodetree= ntreeCopyTree(ma->nodetree); /* 0 == full new tree */
}
@@ -252,19 +252,19 @@ Material *localize_material(Material *ma)
BLI_remlink(&G.main->mat, man);
/* no increment for texture ID users, in previewrender.c it prevents decrement */
- for(a=0; a<MAX_MTEX; a++) {
- if(ma->mtex[a]) {
+ for (a=0; a<MAX_MTEX; a++) {
+ if (ma->mtex[a]) {
man->mtex[a]= MEM_mallocN(sizeof(MTex), "copymaterial");
memcpy(man->mtex[a], ma->mtex[a], sizeof(MTex));
}
}
- if(ma->ramp_col) man->ramp_col= MEM_dupallocN(ma->ramp_col);
- if(ma->ramp_spec) man->ramp_spec= MEM_dupallocN(ma->ramp_spec);
+ if (ma->ramp_col) man->ramp_col= MEM_dupallocN(ma->ramp_col);
+ if (ma->ramp_spec) man->ramp_spec= MEM_dupallocN(ma->ramp_spec);
man->preview = NULL;
- if(ma->nodetree)
+ if (ma->nodetree)
man->nodetree= ntreeLocalize(ma->nodetree);
man->gpumaterial.first= man->gpumaterial.last= NULL;
@@ -275,8 +275,8 @@ Material *localize_material(Material *ma)
static void extern_local_material(Material *ma)
{
int i;
- for(i=0; i < MAX_MTEX; i++) {
- if(ma->mtex[i]) id_lib_extern((ID *)ma->mtex[i]->tex);
+ for (i=0; i < MAX_MTEX; i++) {
+ if (ma->mtex[i]) id_lib_extern((ID *)ma->mtex[i]->tex);
}
}
@@ -294,10 +294,10 @@ void make_local_material(Material *ma)
* - mixed: make copy
*/
- if(ma->id.lib==NULL) return;
+ if (ma->id.lib==NULL) return;
/* One local user; set flag and return. */
- if(ma->id.us==1) {
+ if (ma->id.us==1) {
id_clear_lib_data(bmain, &ma->id);
extern_local_material(ma);
return;
@@ -308,10 +308,10 @@ void make_local_material(Material *ma)
/* test objects */
ob= bmain->object.first;
while(ob) {
- if(ob->mat) {
- for(a=0; a<ob->totcol; a++) {
- if(ob->mat[a]==ma) {
- if(ob->id.lib) is_lib= TRUE;
+ if (ob->mat) {
+ for (a=0; a<ob->totcol; a++) {
+ if (ob->mat[a]==ma) {
+ if (ob->id.lib) is_lib= TRUE;
else is_local= TRUE;
}
}
@@ -321,10 +321,10 @@ void make_local_material(Material *ma)
/* test meshes */
me= bmain->mesh.first;
while(me) {
- if(me->mat) {
- for(a=0; a<me->totcol; a++) {
- if(me->mat[a]==ma) {
- if(me->id.lib) is_lib= TRUE;
+ if (me->mat) {
+ for (a=0; a<me->totcol; a++) {
+ if (me->mat[a]==ma) {
+ if (me->id.lib) is_lib= TRUE;
else is_local= TRUE;
}
}
@@ -334,10 +334,10 @@ void make_local_material(Material *ma)
/* test curves */
cu= bmain->curve.first;
while(cu) {
- if(cu->mat) {
- for(a=0; a<cu->totcol; a++) {
- if(cu->mat[a]==ma) {
- if(cu->id.lib) is_lib= TRUE;
+ if (cu->mat) {
+ for (a=0; a<cu->totcol; a++) {
+ if (cu->mat[a]==ma) {
+ if (cu->id.lib) is_lib= TRUE;
else is_local= TRUE;
}
}
@@ -347,10 +347,10 @@ void make_local_material(Material *ma)
/* test mballs */
mb= bmain->mball.first;
while(mb) {
- if(mb->mat) {
- for(a=0; a<mb->totcol; a++) {
- if(mb->mat[a]==ma) {
- if(mb->id.lib) is_lib= TRUE;
+ if (mb->mat) {
+ for (a=0; a<mb->totcol; a++) {
+ if (mb->mat[a]==ma) {
+ if (mb->id.lib) is_lib= TRUE;
else is_local= TRUE;
}
}
@@ -359,12 +359,12 @@ void make_local_material(Material *ma)
}
/* Only local users. */
- if(is_local && is_lib == FALSE) {
+ if (is_local && is_lib == FALSE) {
id_clear_lib_data(bmain, &ma->id);
extern_local_material(ma);
}
/* Both user and local, so copy. */
- else if(is_local && is_lib) {
+ else if (is_local && is_lib) {
Material *ma_new= copy_material(ma);
ma_new->id.us= 0;
@@ -375,10 +375,10 @@ void make_local_material(Material *ma)
/* do objects */
ob= bmain->object.first;
while(ob) {
- if(ob->mat) {
- for(a=0; a<ob->totcol; a++) {
- if(ob->mat[a]==ma) {
- if(ob->id.lib==NULL) {
+ if (ob->mat) {
+ for (a=0; a<ob->totcol; a++) {
+ if (ob->mat[a]==ma) {
+ if (ob->id.lib==NULL) {
ob->mat[a]= ma_new;
ma_new->id.us++;
ma->id.us--;
@@ -391,10 +391,10 @@ void make_local_material(Material *ma)
/* do meshes */
me= bmain->mesh.first;
while(me) {
- if(me->mat) {
- for(a=0; a<me->totcol; a++) {
- if(me->mat[a]==ma) {
- if(me->id.lib==NULL) {
+ if (me->mat) {
+ for (a=0; a<me->totcol; a++) {
+ if (me->mat[a]==ma) {
+ if (me->id.lib==NULL) {
me->mat[a]= ma_new;
ma_new->id.us++;
ma->id.us--;
@@ -407,10 +407,10 @@ void make_local_material(Material *ma)
/* do curves */
cu= bmain->curve.first;
while(cu) {
- if(cu->mat) {
- for(a=0; a<cu->totcol; a++) {
- if(cu->mat[a]==ma) {
- if(cu->id.lib==NULL) {
+ if (cu->mat) {
+ for (a=0; a<cu->totcol; a++) {
+ if (cu->mat[a]==ma) {
+ if (cu->id.lib==NULL) {
cu->mat[a]= ma_new;
ma_new->id.us++;
ma->id.us--;
@@ -423,10 +423,10 @@ void make_local_material(Material *ma)
/* do mballs */
mb= bmain->mball.first;
while(mb) {
- if(mb->mat) {
- for(a=0; a<mb->totcol; a++) {
- if(mb->mat[a]==ma) {
- if(mb->id.lib==NULL) {
+ if (mb->mat) {
+ for (a=0; a<mb->totcol; a++) {
+ if (mb->mat[a]==ma) {
+ if (mb->id.lib==NULL) {
mb->mat[a]= ma_new;
ma_new->id.us++;
ma->id.us--;
@@ -443,7 +443,7 @@ void make_local_material(Material *ma)
void extern_local_matarar(struct Material **matar, short totcol)
{
short i;
- for(i= 0; i < totcol; i++) {
+ for (i= 0; i < totcol; i++) {
id_lib_extern((ID *)matar[i]);
}
}
@@ -454,7 +454,7 @@ Material ***give_matarar(Object *ob)
Curve *cu;
MetaBall *mb;
- if(ob->type==OB_MESH) {
+ if (ob->type==OB_MESH) {
me= ob->data;
return &(me->mat);
}
@@ -462,7 +462,7 @@ Material ***give_matarar(Object *ob)
cu= ob->data;
return &(cu->mat);
}
- else if(ob->type==OB_MBALL) {
+ else if (ob->type==OB_MBALL) {
mb= ob->data;
return &(mb->mat);
}
@@ -475,7 +475,7 @@ short *give_totcolp(Object *ob)
Curve *cu;
MetaBall *mb;
- if(ob->type==OB_MESH) {
+ if (ob->type==OB_MESH) {
me= ob->data;
return &(me->totcol);
}
@@ -483,7 +483,7 @@ short *give_totcolp(Object *ob)
cu= ob->data;
return &(cu->totcol);
}
- else if(ob->type==OB_MBALL) {
+ else if (ob->type==OB_MBALL) {
mb= ob->data;
return &(mb->totcol);
}
@@ -541,11 +541,11 @@ static void data_delete_material_index_id(ID *id, short index)
void material_append_id(ID *id, Material *ma)
{
Material ***matar;
- if((matar= give_matarar_id(id))) {
+ if ((matar= give_matarar_id(id))) {
short *totcol= give_totcolp_id(id);
Material **mat= MEM_callocN(sizeof(void *) * ((*totcol) + 1), "newmatar");
- if(*totcol) memcpy(mat, *matar, sizeof(void *) * (*totcol));
- if(*matar) MEM_freeN(*matar);
+ if (*totcol) memcpy(mat, *matar, sizeof(void *) * (*totcol));
+ if (*matar) MEM_freeN(*matar);
*matar= mat;
(*matar)[(*totcol)++]= ma;
@@ -560,21 +560,21 @@ Material *material_pop_id(ID *id, int index_i, int remove_material_slot)
short index= (short)index_i;
Material *ret= NULL;
Material ***matar;
- if((matar= give_matarar_id(id))) {
+ if ((matar= give_matarar_id(id))) {
short *totcol= give_totcolp_id(id);
- if(index >= 0 && index < (*totcol)) {
+ if (index >= 0 && index < (*totcol)) {
ret= (*matar)[index];
id_us_min((ID *)ret);
if (remove_material_slot) {
- if(*totcol <= 1) {
+ if (*totcol <= 1) {
*totcol= 0;
MEM_freeN(*matar);
*matar= NULL;
}
else {
Material **mat;
- if(index + 1 != (*totcol))
+ if (index + 1 != (*totcol))
memmove((*matar)+index, (*matar)+(index+1), sizeof(void *) * ((*totcol) - (index + 1)));
(*totcol)--;
@@ -605,32 +605,32 @@ Material *give_current_material(Object *ob, short act)
Material ***matarar, *ma;
short *totcolp;
- if(ob==NULL) return NULL;
+ if (ob==NULL) return NULL;
/* if object cannot have material, totcolp==NULL */
totcolp= give_totcolp(ob);
- if(totcolp==NULL || ob->totcol==0) return NULL;
+ if (totcolp==NULL || ob->totcol==0) return NULL;
- if(act<0) {
+ if (act<0) {
printf("no!\n");
}
- if(act>ob->totcol) act= ob->totcol;
- else if(act<=0) act= 1;
+ if (act>ob->totcol) act= ob->totcol;
+ else if (act<=0) act= 1;
- if(ob->matbits && ob->matbits[act-1]) { /* in object */
+ if (ob->matbits && ob->matbits[act-1]) { /* in object */
ma= ob->mat[act-1];
}
else { /* in data */
/* check for inconsistency */
- if(*totcolp < ob->totcol)
+ if (*totcolp < ob->totcol)
ob->totcol= *totcolp;
- if(act>ob->totcol) act= ob->totcol;
+ if (act>ob->totcol) act= ob->totcol;
matarar= give_matarar(ob);
- if(matarar && *matarar) ma= (*matarar)[act-1];
+ if (matarar && *matarar) ma= (*matarar)[act-1];
else ma= NULL;
}
@@ -641,21 +641,21 @@ Material *give_current_material(Object *ob, short act)
ID *material_from(Object *ob, short act)
{
- if(ob==NULL) return NULL;
+ if (ob==NULL) return NULL;
- if(ob->totcol==0) return ob->data;
- if(act==0) act= 1;
+ if (ob->totcol==0) return ob->data;
+ if (act==0) act= 1;
- if(ob->matbits[act-1]) return (ID *)ob;
+ if (ob->matbits[act-1]) return (ID *)ob;
else return ob->data;
}
Material *give_node_material(Material *ma)
{
- if(ma && ma->use_nodes && ma->nodetree) {
+ if (ma && ma->use_nodes && ma->nodetree) {
bNode *node= nodeGetActiveID(ma->nodetree, ID_MA);
- if(node)
+ if (node)
return (Material *)node->id;
}
@@ -680,18 +680,18 @@ void resize_object_material(Object *ob, const short totcol)
Material **newmatar;
char *newmatbits;
- if(totcol==0) {
- if(ob->totcol) {
+ if (totcol==0) {
+ if (ob->totcol) {
MEM_freeN(ob->mat);
MEM_freeN(ob->matbits);
ob->mat= NULL;
ob->matbits= NULL;
}
}
- else if(ob->totcol<totcol) {
+ else if (ob->totcol<totcol) {
newmatar= MEM_callocN(sizeof(void *)*totcol, "newmatar");
newmatbits= MEM_callocN(sizeof(char)*totcol, "newmatbits");
- if(ob->totcol) {
+ if (ob->totcol) {
memcpy(newmatar, ob->mat, sizeof(void *)*ob->totcol);
memcpy(newmatbits, ob->matbits, sizeof(char)*ob->totcol);
MEM_freeN(ob->mat);
@@ -701,8 +701,8 @@ void resize_object_material(Object *ob, const short totcol)
ob->matbits= newmatbits;
}
ob->totcol= totcol;
- if(ob->totcol && ob->actcol==0) ob->actcol= 1;
- if(ob->actcol>ob->totcol) ob->actcol= ob->totcol;
+ if (ob->totcol && ob->actcol==0) ob->actcol= 1;
+ if (ob->actcol>ob->totcol) ob->actcol= ob->totcol;
}
void test_object_materials(ID *id)
@@ -711,12 +711,12 @@ void test_object_materials(ID *id)
Object *ob;
short *totcol;
- if(id==NULL || (totcol=give_totcolp_id(id))==NULL) {
+ if (id==NULL || (totcol=give_totcolp_id(id))==NULL) {
return;
}
- for(ob= G.main->object.first; ob; ob= ob->id.next) {
- if(ob->data==id) {
+ for (ob= G.main->object.first; ob; ob= ob->id.next) {
+ if (ob->data==id) {
resize_object_material(ob, *totcol);
}
}
@@ -727,24 +727,24 @@ void assign_material_id(ID *id, Material *ma, short act)
Material *mao, **matar, ***matarar;
short *totcolp;
- if(act>MAXMAT) return;
- if(act<1) act= 1;
+ if (act>MAXMAT) return;
+ if (act<1) act= 1;
/* prevent crashing when using accidentally */
BLI_assert(id->lib == NULL);
- if(id->lib) return;
+ if (id->lib) return;
/* test arraylens */
totcolp= give_totcolp_id(id);
matarar= give_matarar_id(id);
- if(totcolp==NULL || matarar==NULL) return;
+ if (totcolp==NULL || matarar==NULL) return;
- if(act > *totcolp) {
+ if (act > *totcolp) {
matar= MEM_callocN(sizeof(void *)*act, "matarray1");
- if(*totcolp) {
+ if (*totcolp) {
memcpy(matar, *matarar, sizeof(void *)*(*totcolp));
MEM_freeN(*matarar);
}
@@ -755,10 +755,10 @@ void assign_material_id(ID *id, Material *ma, short act)
/* in data */
mao= (*matarar)[act-1];
- if(mao) mao->id.us--;
+ if (mao) mao->id.us--;
(*matarar)[act-1]= ma;
- if(ma)
+ if (ma)
id_us_plus((ID *)ma);
test_object_materials(id);
@@ -770,24 +770,24 @@ void assign_material(Object *ob, Material *ma, short act)
char *matbits;
short *totcolp;
- if(act>MAXMAT) return;
- if(act<1) act= 1;
+ if (act>MAXMAT) return;
+ if (act<1) act= 1;
/* prevent crashing when using accidentally */
BLI_assert(ob->id.lib == NULL);
- if(ob->id.lib) return;
+ if (ob->id.lib) return;
/* test arraylens */
totcolp= give_totcolp(ob);
matarar= give_matarar(ob);
- if(totcolp==NULL || matarar==NULL) return;
+ if (totcolp==NULL || matarar==NULL) return;
- if(act > *totcolp) {
+ if (act > *totcolp) {
matar= MEM_callocN(sizeof(void *)*act, "matarray1");
- if(*totcolp) {
+ if (*totcolp) {
memcpy(matar, *matarar, sizeof(void *)*(*totcolp));
MEM_freeN(*matarar);
}
@@ -796,10 +796,10 @@ void assign_material(Object *ob, Material *ma, short act)
*totcolp= act;
}
- if(act > ob->totcol) {
+ if (act > ob->totcol) {
matar= MEM_callocN(sizeof(void *)*act, "matarray2");
matbits= MEM_callocN(sizeof(char)*act, "matbits1");
- if( ob->totcol) {
+ if ( ob->totcol) {
memcpy(matar, ob->mat, sizeof(void *)*( ob->totcol ));
memcpy(matbits, ob->matbits, sizeof(char)*(*totcolp));
MEM_freeN(ob->mat);
@@ -810,7 +810,7 @@ void assign_material(Object *ob, Material *ma, short act)
ob->totcol= act;
/* copy object/mesh linking, or assign based on userpref */
- if(ob->actcol)
+ if (ob->actcol)
ob->matbits[act-1]= ob->matbits[ob->actcol-1];
else
ob->matbits[act-1]= (U.flag & USER_MAT_ON_OB)? 1: 0;
@@ -818,18 +818,18 @@ void assign_material(Object *ob, Material *ma, short act)
/* do it */
- if(ob->matbits[act-1]) { /* in object */
+ if (ob->matbits[act-1]) { /* in object */
mao= ob->mat[act-1];
- if(mao) mao->id.us--;
+ if (mao) mao->id.us--;
ob->mat[act-1]= ma;
}
else { /* in data */
mao= (*matarar)[act-1];
- if(mao) mao->id.us--;
+ if (mao) mao->id.us--;
(*matarar)[act-1]= ma;
}
- if(ma)
+ if (ma)
id_us_plus((ID *)ma);
test_object_materials(ob->data);
}
@@ -843,10 +843,10 @@ void assign_matarar(struct Object *ob, struct Material ***matar, short totcol)
while(object_remove_material_slot(ob)) {};
/* now we have the right number of slots */
- for(i=0; i<totcol; i++)
+ for (i=0; i<totcol; i++)
assign_material(ob, (*matar)[i], i+1);
- if(actcol_orig > ob->totcol)
+ if (actcol_orig > ob->totcol)
actcol_orig= ob->totcol;
ob->actcol= actcol_orig;
@@ -858,25 +858,25 @@ short find_material_index(Object *ob, Material *ma)
Material ***matarar;
short a, *totcolp;
- if(ma==NULL) return 0;
+ if (ma==NULL) return 0;
totcolp= give_totcolp(ob);
matarar= give_matarar(ob);
- if(totcolp==NULL || matarar==NULL) return 0;
+ if (totcolp==NULL || matarar==NULL) return 0;
- for(a=0; a<*totcolp; a++)
- if((*matarar)[a]==ma)
+ for (a=0; a<*totcolp; a++)
+ if ((*matarar)[a]==ma)
break;
- if(a<*totcolp)
+ if (a<*totcolp)
return a+1;
return 0;
}
int object_add_material_slot(Object *ob)
{
- if(ob==NULL) return FALSE;
- if(ob->totcol>=MAXMAT) return FALSE;
+ if (ob==NULL) return FALSE;
+ if (ob->totcol>=MAXMAT) return FALSE;
assign_material(ob, NULL, ob->totcol+1);
ob->actcol= ob->totcol;
@@ -888,51 +888,51 @@ static void do_init_render_material(Material *ma, int r_mode, float *amb)
MTex *mtex;
int a, needuv=0, needtang=0;
- if(ma->flarec==0) ma->flarec= 1;
+ if (ma->flarec==0) ma->flarec= 1;
/* add all texcoflags from mtex, texco and mapto were cleared in advance */
- for(a=0; a<MAX_MTEX; a++) {
+ for (a=0; a<MAX_MTEX; a++) {
/* separate tex switching */
- if(ma->septex & (1<<a)) continue;
+ if (ma->septex & (1<<a)) continue;
mtex= ma->mtex[a];
- if(mtex && mtex->tex && (mtex->tex->type | (mtex->tex->use_nodes && mtex->tex->nodetree) )) {
+ if (mtex && mtex->tex && (mtex->tex->type | (mtex->tex->use_nodes && mtex->tex->nodetree) )) {
ma->texco |= mtex->texco;
ma->mapto |= mtex->mapto;
/* always get derivatives for these textures */
if ELEM3(mtex->tex->type, TEX_IMAGE, TEX_PLUGIN, TEX_ENVMAP) ma->texco |= TEXCO_OSA;
- else if(mtex->texflag & (MTEX_COMPAT_BUMP|MTEX_3TAP_BUMP|MTEX_5TAP_BUMP|MTEX_BICUBIC_BUMP)) ma->texco |= TEXCO_OSA;
+ else if (mtex->texflag & (MTEX_COMPAT_BUMP|MTEX_3TAP_BUMP|MTEX_5TAP_BUMP|MTEX_BICUBIC_BUMP)) ma->texco |= TEXCO_OSA;
- if(ma->texco & (TEXCO_ORCO|TEXCO_REFL|TEXCO_NORM|TEXCO_STRAND|TEXCO_STRESS)) needuv= 1;
- else if(ma->texco & (TEXCO_GLOB|TEXCO_UV|TEXCO_OBJECT|TEXCO_SPEED)) needuv= 1;
- else if(ma->texco & (TEXCO_LAVECTOR|TEXCO_VIEW|TEXCO_STICKY)) needuv= 1;
+ if (ma->texco & (TEXCO_ORCO|TEXCO_REFL|TEXCO_NORM|TEXCO_STRAND|TEXCO_STRESS)) needuv= 1;
+ else if (ma->texco & (TEXCO_GLOB|TEXCO_UV|TEXCO_OBJECT|TEXCO_SPEED)) needuv= 1;
+ else if (ma->texco & (TEXCO_LAVECTOR|TEXCO_VIEW|TEXCO_STICKY)) needuv= 1;
- if((ma->mapto & MAP_NORM) && (mtex->normapspace == MTEX_NSPACE_TANGENT))
+ if ((ma->mapto & MAP_NORM) && (mtex->normapspace == MTEX_NSPACE_TANGENT))
needtang= 1;
}
}
- if(needtang) ma->mode |= MA_NORMAP_TANG;
+ if (needtang) ma->mode |= MA_NORMAP_TANG;
else ma->mode &= ~MA_NORMAP_TANG;
- if(ma->mode & (MA_VERTEXCOL|MA_VERTEXCOLP|MA_FACETEXTURE)) {
+ if (ma->mode & (MA_VERTEXCOL|MA_VERTEXCOLP|MA_FACETEXTURE)) {
needuv= 1;
- if(r_mode & R_OSA) ma->texco |= TEXCO_OSA; /* for texfaces */
+ if (r_mode & R_OSA) ma->texco |= TEXCO_OSA; /* for texfaces */
}
- if(needuv) ma->texco |= NEED_UV;
+ if (needuv) ma->texco |= NEED_UV;
/* since the raytracer doesnt recalc O structs for each ray, we have to preset them all */
- if(r_mode & R_RAYTRACE) {
- if((ma->mode & (MA_RAYMIRROR|MA_SHADOW_TRA)) || ((ma->mode & MA_TRANSP) && (ma->mode & MA_RAYTRANSP))) {
+ if (r_mode & R_RAYTRACE) {
+ if ((ma->mode & (MA_RAYMIRROR|MA_SHADOW_TRA)) || ((ma->mode & MA_TRANSP) && (ma->mode & MA_RAYTRANSP))) {
ma->texco |= NEED_UV|TEXCO_ORCO|TEXCO_REFL|TEXCO_NORM;
- if(r_mode & R_OSA) ma->texco |= TEXCO_OSA;
+ if (r_mode & R_OSA) ma->texco |= TEXCO_OSA;
}
}
- if(amb) {
+ if (amb) {
ma->ambr= ma->amb*amb[0];
ma->ambg= ma->amb*amb[1];
ma->ambb= ma->amb*amb[2];
@@ -941,11 +941,11 @@ static void do_init_render_material(Material *ma, int r_mode, float *amb)
ma->mode_l= ma->mode;
ma->mode_l &= ~MA_SHLESS;
- if(ma->strand_surfnor > 0.0f)
+ if (ma->strand_surfnor > 0.0f)
ma->mode_l |= MA_STR_SURFDIFF;
/* parses the geom+tex nodes */
- if(ma->nodetree && ma->use_nodes)
+ if (ma->nodetree && ma->use_nodes)
ntreeShaderGetTexcoMode(ma->nodetree, r_mode, &ma->texco, &ma->mode_l);
}
@@ -953,17 +953,17 @@ static void init_render_nodetree(bNodeTree *ntree, Material *basemat, int r_mode
{
bNode *node;
- for(node=ntree->nodes.first; node; node= node->next) {
- if(node->id) {
- if(GS(node->id->name)==ID_MA) {
+ for (node=ntree->nodes.first; node; node= node->next) {
+ if (node->id) {
+ if (GS(node->id->name)==ID_MA) {
Material *ma= (Material *)node->id;
- if(ma!=basemat) {
+ if (ma!=basemat) {
do_init_render_material(ma, r_mode, amb);
basemat->texco |= ma->texco;
basemat->mode_l |= ma->mode_l & ~(MA_TRANSP|MA_ZTRANSP|MA_RAYTRANSP);
}
}
- else if(node->type==NODE_GROUP)
+ else if (node->type==NODE_GROUP)
init_render_nodetree((bNodeTree *)node->id, basemat, r_mode, amb);
}
}
@@ -974,7 +974,7 @@ void init_render_material(Material *mat, int r_mode, float *amb)
do_init_render_material(mat, r_mode, amb);
- if(mat->nodetree && mat->use_nodes) {
+ if (mat->nodetree && mat->use_nodes) {
init_render_nodetree(mat->nodetree, mat, r_mode, amb);
if (!mat->nodetree->execdata)
@@ -989,18 +989,18 @@ void init_render_materials(Main *bmain, int r_mode, float *amb)
/* clear these flags before going over materials, to make sure they
* are cleared only once, otherwise node materials contained in other
* node materials can go wrong */
- for(ma= bmain->mat.first; ma; ma= ma->id.next) {
- if(ma->id.us) {
+ for (ma= bmain->mat.first; ma; ma= ma->id.next) {
+ if (ma->id.us) {
ma->texco= 0;
ma->mapto= 0;
}
}
/* two steps, first initialize, then or the flags for layers */
- for(ma= bmain->mat.first; ma; ma= ma->id.next) {
+ for (ma= bmain->mat.first; ma; ma= ma->id.next) {
/* is_used flag comes back in convertblender.c */
ma->flag &= ~MA_IS_USED;
- if(ma->id.us)
+ if (ma->id.us)
init_render_material(ma, r_mode, amb);
}
@@ -1010,7 +1010,7 @@ void init_render_materials(Main *bmain, int r_mode, float *amb)
/* only needed for nodes now */
void end_render_material(Material *mat)
{
- if(mat && mat->nodetree && mat->use_nodes) {
+ if (mat && mat->nodetree && mat->use_nodes) {
if (mat->nodetree->execdata)
ntreeShaderEndExecTree(mat->nodetree->execdata, 1);
}
@@ -1019,8 +1019,8 @@ void end_render_material(Material *mat)
void end_render_materials(Main *bmain)
{
Material *ma;
- for(ma= bmain->mat.first; ma; ma= ma->id.next)
- if(ma->id.us)
+ for (ma= bmain->mat.first; ma; ma= ma->id.next)
+ if (ma->id.us)
end_render_material(ma);
}
@@ -1028,13 +1028,13 @@ static int material_in_nodetree(bNodeTree *ntree, Material *mat)
{
bNode *node;
- for(node=ntree->nodes.first; node; node= node->next) {
- if(node->id && GS(node->id->name)==ID_MA) {
- if(node->id==(ID*)mat)
+ for (node=ntree->nodes.first; node; node= node->next) {
+ if (node->id && GS(node->id->name)==ID_MA) {
+ if (node->id==(ID*)mat)
return 1;
}
- else if(node->type==NODE_GROUP)
- if(material_in_nodetree((bNodeTree*)node->id, mat))
+ else if (node->type==NODE_GROUP)
+ if (material_in_nodetree((bNodeTree*)node->id, mat))
return 1;
}
@@ -1043,9 +1043,9 @@ static int material_in_nodetree(bNodeTree *ntree, Material *mat)
int material_in_material(Material *parmat, Material *mat)
{
- if(parmat==mat)
+ if (parmat==mat)
return 1;
- else if(parmat->nodetree && parmat->use_nodes)
+ else if (parmat->nodetree && parmat->use_nodes)
return material_in_nodetree(parmat->nodetree, mat);
else
return 0;
@@ -1086,15 +1086,15 @@ void automatname(Material *ma)
int nr, r, g, b;
float ref;
- if(ma==NULL) return;
- if(ma->mode & MA_SHLESS) ref= 1.0;
+ if (ma==NULL) return;
+ if (ma->mode & MA_SHLESS) ref= 1.0;
else ref= ma->ref;
r= (int)(4.99f*(ref*ma->r));
g= (int)(4.99f*(ref*ma->g));
b= (int)(4.99f*(ref*ma->b));
nr= r + 5*g + 25*b;
- if(nr>124) nr= 124;
+ if (nr>124) nr= 124;
new_id(&G.main->mat, (ID *)ma, colname_array[nr]);
}
@@ -1127,17 +1127,17 @@ int object_remove_material_slot(Object *ob)
totcolp= give_totcolp(ob);
matarar= give_matarar(ob);
- if(*matarar==NULL) return FALSE;
+ if (*matarar==NULL) return FALSE;
/* we delete the actcol */
mao= (*matarar)[ob->actcol-1];
- if(mao) mao->id.us--;
+ if (mao) mao->id.us--;
- for(a=ob->actcol; a<ob->totcol; a++)
+ for (a=ob->actcol; a<ob->totcol; a++)
(*matarar)[a-1]= (*matarar)[a];
(*totcolp)--;
- if(*totcolp==0) {
+ if (*totcolp==0) {
MEM_freeN(*matarar);
*matarar= NULL;
}
@@ -1146,20 +1146,20 @@ int object_remove_material_slot(Object *ob)
obt= G.main->object.first;
while(obt) {
- if(obt->data==ob->data) {
+ if (obt->data==ob->data) {
/* WATCH IT: do not use actcol from ob or from obt (can become zero) */
mao= obt->mat[actcol-1];
- if(mao) mao->id.us--;
+ if (mao) mao->id.us--;
- for(a=actcol; a<obt->totcol; a++) {
+ for (a=actcol; a<obt->totcol; a++) {
obt->mat[a-1]= obt->mat[a];
obt->matbits[a-1]= obt->matbits[a];
}
obt->totcol--;
- if(obt->actcol > obt->totcol) obt->actcol= obt->totcol;
+ if (obt->actcol > obt->totcol) obt->actcol= obt->totcol;
- if(obt->totcol==0) {
+ if (obt->totcol==0) {
MEM_freeN(obt->mat);
MEM_freeN(obt->matbits);
obt->mat= NULL;
@@ -1206,15 +1206,15 @@ void ramp_blend(int type, float r_col[3], const float fac, const float col[3])
r_col[2] = 1.0f - (facm + fac*(1.0f - col[2])) * (1.0f - r_col[2]);
break;
case MA_RAMP_OVERLAY:
- if(r_col[0] < 0.5f)
+ if (r_col[0] < 0.5f)
r_col[0] *= (facm + 2.0f*fac*col[0]);
else
r_col[0] = 1.0f - (facm + 2.0f*fac*(1.0f - col[0])) * (1.0f - r_col[0]);
- if(r_col[1] < 0.5f)
+ if (r_col[1] < 0.5f)
r_col[1] *= (facm + 2.0f*fac*col[1]);
else
r_col[1] = 1.0f - (facm + 2.0f*fac*(1.0f - col[1])) * (1.0f - r_col[1]);
- if(r_col[2] < 0.5f)
+ if (r_col[2] < 0.5f)
r_col[2] *= (facm + 2.0f*fac*col[2]);
else
r_col[2] = 1.0f - (facm + 2.0f*fac*(1.0f - col[2])) * (1.0f - r_col[2]);
@@ -1225,11 +1225,11 @@ void ramp_blend(int type, float r_col[3], const float fac, const float col[3])
r_col[2] -= fac*col[2];
break;
case MA_RAMP_DIV:
- if(col[0]!=0.0f)
+ if (col[0]!=0.0f)
r_col[0] = facm*(r_col[0]) + fac*(r_col[0])/col[0];
- if(col[1]!=0.0f)
+ if (col[1]!=0.0f)
r_col[1] = facm*(r_col[1]) + fac*(r_col[1])/col[1];
- if(col[2]!=0.0f)
+ if (col[2]!=0.0f)
r_col[2] = facm*(r_col[2]) + fac*(r_col[2])/col[2];
break;
case MA_RAMP_DIFF:
@@ -1239,42 +1239,42 @@ void ramp_blend(int type, float r_col[3], const float fac, const float col[3])
break;
case MA_RAMP_DARK:
tmp=col[0]+((1-col[0])*facm);
- if(tmp < r_col[0]) r_col[0]= tmp;
+ if (tmp < r_col[0]) r_col[0]= tmp;
tmp=col[1]+((1-col[1])*facm);
- if(tmp < r_col[1]) r_col[1]= tmp;
+ if (tmp < r_col[1]) r_col[1]= tmp;
tmp=col[2]+((1-col[2])*facm);
- if(tmp < r_col[2]) r_col[2]= tmp;
+ if (tmp < r_col[2]) r_col[2]= tmp;
break;
case MA_RAMP_LIGHT:
tmp= fac*col[0];
- if(tmp > r_col[0]) r_col[0]= tmp;
+ if (tmp > r_col[0]) r_col[0]= tmp;
tmp= fac*col[1];
- if(tmp > r_col[1]) r_col[1]= tmp;
+ if (tmp > r_col[1]) r_col[1]= tmp;
tmp= fac*col[2];
- if(tmp > r_col[2]) r_col[2]= tmp;
+ if (tmp > r_col[2]) r_col[2]= tmp;
break;
case MA_RAMP_DODGE:
- if(r_col[0] !=0.0f){
+ if (r_col[0] != 0.0f) {
tmp = 1.0f - fac*col[0];
- if(tmp <= 0.0f)
+ if (tmp <= 0.0f)
r_col[0] = 1.0f;
else if ((tmp = (r_col[0]) / tmp)> 1.0f)
r_col[0] = 1.0f;
else
r_col[0] = tmp;
}
- if(r_col[1] !=0.0f){
+ if (r_col[1] != 0.0f) {
tmp = 1.0f - fac*col[1];
- if(tmp <= 0.0f )
+ if (tmp <= 0.0f )
r_col[1] = 1.0f;
else if ((tmp = (r_col[1]) / tmp) > 1.0f )
r_col[1] = 1.0f;
else
r_col[1] = tmp;
}
- if(r_col[2] !=0.0f){
+ if (r_col[2] != 0.0f) {
tmp = 1.0f - fac*col[2];
- if(tmp <= 0.0f)
+ if (tmp <= 0.0f)
r_col[2] = 1.0f;
else if ((tmp = (r_col[2]) / tmp) > 1.0f )
r_col[2] = 1.0f;
@@ -1285,7 +1285,7 @@ void ramp_blend(int type, float r_col[3], const float fac, const float col[3])
case MA_RAMP_BURN:
tmp = facm + fac*col[0];
- if(tmp <= 0.0f)
+ if (tmp <= 0.0f)
r_col[0] = 0.0f;
else if (( tmp = (1.0f - (1.0f - (r_col[0])) / tmp )) < 0.0f)
r_col[0] = 0.0f;
@@ -1295,21 +1295,21 @@ void ramp_blend(int type, float r_col[3], const float fac, const float col[3])
r_col[0] = tmp;
tmp = facm + fac*col[1];
- if(tmp <= 0.0f)
+ if (tmp <= 0.0f)
r_col[1] = 0.0f;
else if (( tmp = (1.0f - (1.0f - (r_col[1])) / tmp )) < 0.0f )
r_col[1] = 0.0f;
- else if(tmp >1.0f)
+ else if (tmp >1.0f)
r_col[1]=1.0f;
else
r_col[1] = tmp;
tmp = facm + fac*col[2];
- if(tmp <= 0.0f)
+ if (tmp <= 0.0f)
r_col[2] = 0.0f;
else if (( tmp = (1.0f - (1.0f - (r_col[2])) / tmp )) < 0.0f )
r_col[2] = 0.0f;
- else if(tmp >1.0f)
+ else if (tmp >1.0f)
r_col[2]= 1.0f;
else
r_col[2] = tmp;
@@ -1320,7 +1320,7 @@ void ramp_blend(int type, float r_col[3], const float fac, const float col[3])
float colH,colS,colV;
float tmpr,tmpg,tmpb;
rgb_to_hsv(col[0],col[1],col[2],&colH,&colS,&colV);
- if(colS!=0 ){
+ if (colS != 0) {
rgb_to_hsv(r_col[0],r_col[1],r_col[2],&rH,&rS,&rV);
hsv_to_rgb( colH , rS, rV, &tmpr, &tmpg, &tmpb);
r_col[0] = facm*(r_col[0]) + fac*tmpr;
@@ -1334,7 +1334,7 @@ void ramp_blend(int type, float r_col[3], const float fac, const float col[3])
float rH,rS,rV;
float colH,colS,colV;
rgb_to_hsv(r_col[0],r_col[1],r_col[2],&rH,&rS,&rV);
- if(rS!=0){
+ if (rS != 0) {
rgb_to_hsv(col[0],col[1],col[2],&colH,&colS,&colV);
hsv_to_rgb( rH, (facm*rS +fac*colS), rV, r_col+0, r_col+1, r_col+2);
}
@@ -1355,7 +1355,7 @@ void ramp_blend(int type, float r_col[3], const float fac, const float col[3])
float colH,colS,colV;
float tmpr,tmpg,tmpb;
rgb_to_hsv(col[0],col[1],col[2],&colH,&colS,&colV);
- if(colS!=0){
+ if (colS != 0) {
rgb_to_hsv(r_col[0],r_col[1],r_col[2],&rH,&rS,&rV);
hsv_to_rgb( colH, colS, rV, &tmpr, &tmpg, &tmpb);
r_col[0] = facm*(r_col[0]) + fac*tmpr;
@@ -1409,20 +1409,20 @@ void free_matcopybuf(void)
{
int a;
- for(a=0; a<MAX_MTEX; a++) {
- if(matcopybuf.mtex[a]) {
+ for (a=0; a<MAX_MTEX; a++) {
+ if (matcopybuf.mtex[a]) {
MEM_freeN(matcopybuf.mtex[a]);
matcopybuf.mtex[a]= NULL;
}
}
- if(matcopybuf.ramp_col) MEM_freeN(matcopybuf.ramp_col);
- if(matcopybuf.ramp_spec) MEM_freeN(matcopybuf.ramp_spec);
+ if (matcopybuf.ramp_col) MEM_freeN(matcopybuf.ramp_col);
+ if (matcopybuf.ramp_spec) MEM_freeN(matcopybuf.ramp_spec);
matcopybuf.ramp_col= NULL;
matcopybuf.ramp_spec= NULL;
- if(matcopybuf.nodetree) {
+ if (matcopybuf.nodetree) {
ntreeFreeTree(matcopybuf.nodetree);
MEM_freeN(matcopybuf.nodetree);
matcopybuf.nodetree= NULL;
@@ -1436,16 +1436,16 @@ void copy_matcopybuf(Material *ma)
int a;
MTex *mtex;
- if(matcopied)
+ if (matcopied)
free_matcopybuf();
memcpy(&matcopybuf, ma, sizeof(Material));
- if(matcopybuf.ramp_col) matcopybuf.ramp_col= MEM_dupallocN(matcopybuf.ramp_col);
- if(matcopybuf.ramp_spec) matcopybuf.ramp_spec= MEM_dupallocN(matcopybuf.ramp_spec);
+ if (matcopybuf.ramp_col) matcopybuf.ramp_col= MEM_dupallocN(matcopybuf.ramp_col);
+ if (matcopybuf.ramp_spec) matcopybuf.ramp_spec= MEM_dupallocN(matcopybuf.ramp_spec);
- for(a=0; a<MAX_MTEX; a++) {
+ for (a=0; a<MAX_MTEX; a++) {
mtex= matcopybuf.mtex[a];
- if(mtex) {
+ if (mtex) {
matcopybuf.mtex[a]= MEM_dupallocN(mtex);
}
}
@@ -1461,18 +1461,18 @@ void paste_matcopybuf(Material *ma)
MTex *mtex;
ID id;
- if(matcopied==0)
+ if (matcopied==0)
return;
/* free current mat */
- if(ma->ramp_col) MEM_freeN(ma->ramp_col);
- if(ma->ramp_spec) MEM_freeN(ma->ramp_spec);
- for(a=0; a<MAX_MTEX; a++) {
+ if (ma->ramp_col) MEM_freeN(ma->ramp_col);
+ if (ma->ramp_spec) MEM_freeN(ma->ramp_spec);
+ for (a=0; a<MAX_MTEX; a++) {
mtex= ma->mtex[a];
- if(mtex && mtex->tex) mtex->tex->id.us--;
- if(mtex) MEM_freeN(mtex);
+ if (mtex && mtex->tex) mtex->tex->id.us--;
+ if (mtex) MEM_freeN(mtex);
}
- if(ma->nodetree) {
+ if (ma->nodetree) {
ntreeFreeTree(ma->nodetree);
MEM_freeN(ma->nodetree);
}
@@ -1483,14 +1483,14 @@ void paste_matcopybuf(Material *ma)
memcpy(ma, &matcopybuf, sizeof(Material));
(ma->id)= id;
- if(matcopybuf.ramp_col) ma->ramp_col= MEM_dupallocN(matcopybuf.ramp_col);
- if(matcopybuf.ramp_spec) ma->ramp_spec= MEM_dupallocN(matcopybuf.ramp_spec);
+ if (matcopybuf.ramp_col) ma->ramp_col= MEM_dupallocN(matcopybuf.ramp_col);
+ if (matcopybuf.ramp_spec) ma->ramp_spec= MEM_dupallocN(matcopybuf.ramp_spec);
- for(a=0; a<MAX_MTEX; a++) {
+ for (a=0; a<MAX_MTEX; a++) {
mtex= ma->mtex[a];
- if(mtex) {
+ if (mtex) {
ma->mtex[a]= MEM_dupallocN(mtex);
- if(mtex->tex) id_us_plus((ID *)mtex->tex);
+ if (mtex->tex) id_us_plus((ID *)mtex->tex);
}
}
@@ -1600,7 +1600,7 @@ static int integer_getdigits(int number)
int i=0;
if (number == 0) return 1;
- while (number != 0){
+ while (number != 0) {
number = (int)(number/10);
i++;
}
@@ -1645,11 +1645,11 @@ static short mesh_addmaterial(Mesh *me, Material *ma)
static void set_facetexture_flags(Material *ma, Image *image)
{
- if(image) {
+ if (image) {
ma->mode |= MA_FACETEXTURE;
/* we could check if the texture has alpha, but then more meshes sharing the same
* material may need it. Let's make it simple. */
- if(BKE_image_has_alpha(image))
+ if (BKE_image_has_alpha(image))
ma->mode |= MA_FACETEXTURE_ALPHA;
}
}
@@ -1667,7 +1667,7 @@ static short convert_tfacenomaterial(Main *main, Mesh *me, MTFace *tf, int flag)
if ((ma= BLI_findstring(&main->mat, idname+2, offsetof(ID, name)+2))) {
mat_nr= mesh_getmaterialnumber(me, ma);
/* assign the material to the mesh */
- if(mat_nr == -1) mat_nr= mesh_addmaterial(me, ma);
+ if (mat_nr == -1) mat_nr= mesh_addmaterial(me, ma);
/* if needed set "Face Textures [Alpha]" Material options */
set_facetexture_flags(ma, tf->tpage);
@@ -1676,7 +1676,7 @@ static short convert_tfacenomaterial(Main *main, Mesh *me, MTFace *tf, int flag)
else {
ma= add_material(idname+2);
- if(ma){
+ if (ma) {
printf("TexFace Convert: Material \"%s\" created.\n", idname+2);
mat_nr= mesh_addmaterial(me, ma);
@@ -1711,10 +1711,10 @@ static void convert_tfacematerial(Main *main, Material *ma)
CustomDataLayer *cdl;
char idname[MAX_ID_NAME];
- for(me=main->mesh.first; me; me=me->id.next){
+ for (me=main->mesh.first; me; me=me->id.next) {
/* check if this mesh uses this material */
- for(a=0;a<me->totcol;a++)
- if(me->mat[a] == ma) break;
+ for (a=0;a<me->totcol;a++)
+ if (me->mat[a] == ma) break;
/* no material found */
if (a == me->totcol) continue;
@@ -1725,8 +1725,8 @@ static void convert_tfacematerial(Main *main, Material *ma)
if (!cdl) continue;
/* loop over all the faces and stop at the ones that use the material*/
- for(a=0, mf=me->mface; a<me->totface; a++, mf++) {
- if(me->mat[mf->mat_nr] != ma) continue;
+ for (a=0, mf=me->mface; a<me->totface; a++, mf++) {
+ if (me->mat[mf->mat_nr] != ma) continue;
/* texface data for this face */
tf = ((MTFace*)cdl->data) + a;
@@ -1739,12 +1739,12 @@ static void convert_tfacematerial(Main *main, Material *ma)
/* material already existent, see if the mesh has it */
mat_nr = mesh_getmaterialnumber(me, mat_new);
/* material is not in the mesh, add it */
- if(mat_nr == -1) mat_nr= mesh_addmaterial(me, mat_new);
+ if (mat_nr == -1) mat_nr= mesh_addmaterial(me, mat_new);
}
/* create a new material */
else {
mat_new=copy_material(ma);
- if(mat_new){
+ if (mat_new) {
/* rename the material*/
strcpy(mat_new->id.name, idname);
id_us_min((ID *)mat_new);
@@ -1763,15 +1763,15 @@ static void convert_tfacematerial(Main *main, Material *ma)
* set "Face Textures [Alpha]" Material options
* actually we need to run it always, because of old behavior
* of using face texture if any texture channel was present (multitex) */
- //if((!mat_new->mtex[0]) && (!mat_new->mtex[0]->tex))
+ //if ((!mat_new->mtex[0]) && (!mat_new->mtex[0]->tex))
set_facetexture_flags(mat_new, tf->tpage);
/* set the material number to the face*/
mf->mat_nr = mat_nr;
}
/* remove material from mesh */
- for(a=0;a<me->totcol;)
- if(me->mat[a] == ma) material_pop_id(&me->id, a, 1);else a++;
+ for (a=0;a<me->totcol;)
+ if (me->mat[a] == ma) material_pop_id(&me->id, a, 1);else a++;
}
}
@@ -1805,7 +1805,7 @@ int do_version_tface(Main *main, int fileload)
*/
/* 1st part: marking mesh materials to update */
- for(me=main->mesh.first; me; me=me->id.next){
+ for (me=main->mesh.first; me; me=me->id.next) {
if (me->id.lib) continue;
/* get the active tface layer */
@@ -1816,7 +1816,7 @@ int do_version_tface(Main *main, int fileload)
nomaterialslots = (me->totcol==0?1:0);
/* loop over all the faces*/
- for(a=0, mf=me->mface; a<me->totface; a++, mf++) {
+ for (a=0, mf=me->mface; a<me->totface; a++, mf++) {
/* texface data for this face */
tf = ((MTFace*)cdl->data) + a;
@@ -1824,12 +1824,12 @@ int do_version_tface(Main *main, int fileload)
if (fileload)
tf->mode &= ~TF_CONVERTED;
else {
- if((tf->mode & TF_CONVERTED)) continue;
+ if ((tf->mode & TF_CONVERTED)) continue;
else tf->mode |= TF_CONVERTED;
}
/* no material slots */
- if(nomaterialslots) {
+ if (nomaterialslots) {
flag = encode_tfaceflag(tf, 1);
/* create/find a new material and assign to the face */
@@ -1841,11 +1841,11 @@ int do_version_tface(Main *main, int fileload)
mf->mat_nr = -1;
}
}
- else if(mf->mat_nr < me->totcol) {
+ else if (mf->mat_nr < me->totcol) {
ma= me->mat[mf->mat_nr];
/* no material create one if necessary */
- if(!ma) {
+ if (!ma) {
/* find a new material and assign to the face */
flag = encode_tfaceflag(tf, 1);
@@ -1860,11 +1860,11 @@ int do_version_tface(Main *main, int fileload)
* at doversion time: direct_link might not have happened on it,
* so ma->mtex is not pointing to valid memory yet.
* later we could, but it's better not */
- else if(ma->id.lib)
+ else if (ma->id.lib)
continue;
/* material already marked as disputed */
- else if(ma->game.flag == MAT_BGE_DISPUTED)
+ else if (ma->game.flag == MAT_BGE_DISPUTED)
continue;
/* found a material */
@@ -1889,20 +1889,21 @@ int do_version_tface(Main *main, int fileload)
* channel which not neccessarly the tf->tpage image. But the game engine
* was enabling it. Now it's required to set "Face Texture [Alpha] in the
* material settings. */
- if(!fileload)
+ if (!fileload)
set_facetexture_flags(ma, tf->tpage);
}
}
}
- else
+ else {
continue;
+ }
}
/* if we didn't have material slot and now we do, we need to
* make sure the materials are correct */
- if(nomaterialslots) {
+ if (nomaterialslots) {
if (me->totcol>0) {
- for(a=0, mf=me->mface; a<me->totface; a++, mf++) {
+ for (a=0, mf=me->mface; a<me->totface; a++, mf++) {
if (mf->mat_nr == -1) {
/* texface data for this face */
tf = ((MTFace*)cdl->data) + a;
@@ -1911,7 +1912,7 @@ int do_version_tface(Main *main, int fileload)
}
}
else {
- for(a=0, mf=me->mface; a<me->totface; a++, mf++) {
+ for (a=0, mf=me->mface; a<me->totface; a++, mf++) {
mf->mat_nr=0;
}
}
@@ -1946,10 +1947,10 @@ int do_version_tface(Main *main, int fileload)
/* material is good make sure all faces using
* this material are set to converted */
if (fileload) {
- for(me=main->mesh.first; me; me=me->id.next){
+ for (me=main->mesh.first; me; me=me->id.next) {
/* check if this mesh uses this material */
- for(a=0;a<me->totcol;a++)
- if(me->mat[a] == ma) break;
+ for (a=0;a<me->totcol;a++)
+ if (me->mat[a] == ma) break;
/* no material found */
if (a == me->totcol) continue;
@@ -1972,9 +1973,11 @@ int do_version_tface(Main *main, int fileload)
}
/* material is not used by faces with texface
* set the default flag - do it only once */
- else
- if (fileload)
- ma->game.flag = GEMAT_BACKCULL;
+ else {
+ if (fileload) {
+ ma->game.flag = GEMAT_BACKCULL;
+ }
+ }
}
return nowarning;
diff --git a/source/blender/blenkernel/intern/mball.c b/source/blender/blenkernel/intern/mball.c
index fe2c10d7091..7f05aaed9b0 100644
--- a/source/blender/blenkernel/intern/mball.c
+++ b/source/blender/blenkernel/intern/mball.c
@@ -78,7 +78,7 @@ void unlink_mball(MetaBall *mb)
int a;
for(a=0; a<mb->totcol; a++) {
- if(mb->mat[a]) mb->mat[a]->id.us--;
+ if (mb->mat[a]) mb->mat[a]->id.us--;
mb->mat[a]= NULL;
}
}
@@ -89,14 +89,14 @@ void free_mball(MetaBall *mb)
{
unlink_mball(mb);
- if(mb->adt) {
+ if (mb->adt) {
BKE_free_animdata((ID *)mb);
mb->adt = NULL;
}
- if(mb->mat) MEM_freeN(mb->mat);
- if(mb->bb) MEM_freeN(mb->bb);
+ if (mb->mat) MEM_freeN(mb->mat);
+ if (mb->bb) MEM_freeN(mb->bb);
BLI_freelistN(&mb->elems);
- if(mb->disp.first) freedisplist(&mb->disp);
+ if (mb->disp.first) freedisplist(&mb->disp);
}
MetaBall *add_mball(const char *name)
@@ -138,7 +138,7 @@ MetaBall *copy_mball(MetaBall *mb)
static void extern_local_mball(MetaBall *mb)
{
- if(mb->mat) {
+ if (mb->mat) {
extern_local_matarar(mb->mat, mb->totcol);
}
}
@@ -154,8 +154,8 @@ void make_local_mball(MetaBall *mb)
* - mixed: make copy
*/
- if(mb->id.lib==NULL) return;
- if(mb->id.us==1) {
+ if (mb->id.lib==NULL) return;
+ if (mb->id.us==1) {
id_clear_lib_data(bmain, &mb->id);
extern_local_mball(mb);
@@ -163,17 +163,17 @@ void make_local_mball(MetaBall *mb)
}
for(ob= G.main->object.first; ob && ELEM(0, is_lib, is_local); ob= ob->id.next) {
- if(ob->data == mb) {
- if(ob->id.lib) is_lib= TRUE;
+ if (ob->data == mb) {
+ if (ob->id.lib) is_lib= TRUE;
else is_local= TRUE;
}
}
- if(is_local && is_lib == FALSE) {
+ if (is_local && is_lib == FALSE) {
id_clear_lib_data(bmain, &mb->id);
extern_local_mball(mb);
}
- else if(is_local && is_lib) {
+ else if (is_local && is_lib) {
MetaBall *mb_new= copy_mball(mb);
mb_new->id.us= 0;
@@ -181,8 +181,8 @@ void make_local_mball(MetaBall *mb)
BKE_id_lib_local_paths(bmain, mb->id.lib, &mb_new->id);
for(ob= G.main->object.first; ob; ob= ob->id.next) {
- if(ob->data == mb) {
- if(ob->id.lib==NULL) {
+ if (ob->data == mb) {
+ if (ob->id.lib==NULL) {
ob->data= mb_new;
mb_new->id.us++;
mb->id.us--;
@@ -253,7 +253,7 @@ void tex_space_mball(Object *ob)
float *data, min[3], max[3] /*, loc[3], size[3] */;
int tot, doit=0;
- if(ob->bb==NULL) ob->bb= MEM_callocN(sizeof(BoundBox), "mb boundbox");
+ if (ob->bb==NULL) ob->bb= MEM_callocN(sizeof(BoundBox), "mb boundbox");
bb= ob->bb;
/* Weird one, this. */
@@ -264,7 +264,7 @@ void tex_space_mball(Object *ob)
dl= ob->disp.first;
while(dl) {
tot= dl->nr;
- if(tot) doit= 1;
+ if (tot) doit= 1;
data= dl->verts;
while(tot--) {
/* Also weird... but longer. From utildefines. */
@@ -274,7 +274,7 @@ void tex_space_mball(Object *ob)
dl= dl->next;
}
- if(!doit) {
+ if (!doit) {
min[0] = min[1] = min[2] = -1.0f;
max[0] = max[1] = max[2] = 1.0f;
}
@@ -348,7 +348,7 @@ int is_basis_mball(Object *ob)
/* just a quick test */
len= strlen(ob->id.name);
- if( isdigit(ob->id.name[len-1]) ) return 0;
+ if ( isdigit(ob->id.name[len-1]) ) return 0;
return 1;
}
@@ -361,7 +361,7 @@ int is_mball_basis_for(Object *ob1, Object *ob2)
BLI_split_name_num(basis1name, &basis1nr, ob1->id.name+2, '.');
BLI_split_name_num(basis2name, &basis2nr, ob2->id.name+2, '.');
- if(!strcmp(basis1name, basis2name)) return is_basis_mball(ob1);
+ if (!strcmp(basis1name, basis2name)) return is_basis_mball(ob1);
else return 0;
}
@@ -383,17 +383,17 @@ void copy_mball_properties(Scene *scene, Object *active_object)
BLI_split_name_num(basisname, &basisnr, active_object->id.name+2, '.');
/* XXX recursion check, see scene.c, just too simple code this next_object() */
- if(F_ERROR==next_object(&sce_iter, 0, NULL, NULL))
+ if (F_ERROR==next_object(&sce_iter, 0, NULL, NULL))
return;
while(next_object(&sce_iter, 1, &base, &ob)) {
if (ob->type==OB_MBALL) {
- if(ob!=active_object){
+ if (ob != active_object) {
BLI_split_name_num(obname, &obnr, ob->id.name+2, '.');
/* Object ob has to be in same "group" ... it means, that it has to have
* same base of its name */
- if(strcmp(obname, basisname)==0){
+ if (strcmp(obname, basisname)==0) {
MetaBall *mb= ob->data;
/* Copy properties from selected/edited metaball */
@@ -429,18 +429,18 @@ Object *find_basis_mball(Scene *scene, Object *basis)
totelem= 0;
/* XXX recursion check, see scene.c, just too simple code this next_object() */
- if(F_ERROR==next_object(&sce_iter, 0, NULL, NULL))
+ if (F_ERROR==next_object(&sce_iter, 0, NULL, NULL))
return NULL;
while(next_object(&sce_iter, 1, &base, &ob)) {
if (ob->type==OB_MBALL) {
- if(ob==bob){
+ if (ob==bob) {
MetaBall *mb= ob->data;
/* if bob object is in edit mode, then dynamic list of all MetaElems
* is stored in editelems */
- if(mb->editelems) ml= mb->editelems->first;
+ if (mb->editelems) ml= mb->editelems->first;
/* if bob object is in object mode */
else ml= mb->elems.first;
}
@@ -449,17 +449,17 @@ Object *find_basis_mball(Scene *scene, Object *basis)
/* object ob has to be in same "group" ... it means, that it has to have
* same base of its name */
- if(strcmp(obname, basisname)==0){
+ if (strcmp(obname, basisname)==0) {
MetaBall *mb= ob->data;
/* if object is in edit mode, then dynamic list of all MetaElems
* is stored in editelems */
- if(mb->editelems) ml= mb->editelems->first;
+ if (mb->editelems) ml= mb->editelems->first;
/* if bob object is in object mode */
else ml= mb->elems.first;
- if(obnr<basisnr){
- if(!(ob->flag & OB_FROMDUPLI)){
+ if (obnr < basisnr) {
+ if (!(ob->flag & OB_FROMDUPLI)) {
basis= ob;
basisnr= obnr;
}
@@ -467,8 +467,8 @@ Object *find_basis_mball(Scene *scene, Object *basis)
}
}
- while(ml){
- if(!(ml->flag & MB_HIDE)) totelem++;
+ while (ml) {
+ if (!(ml->flag & MB_HIDE)) totelem++;
ml= ml->next;
}
}
@@ -524,7 +524,7 @@ Object *find_basis_mball(Scene *scene, Object *basis)
void calc_mballco(MetaElem *ml, float *vec)
{
- if(ml->mat) {
+ if (ml->mat) {
mul_m4_v3((float ( * )[4])ml->mat, vec);
}
}
@@ -542,64 +542,64 @@ float densfunc(MetaElem *ball, float x, float y, float z)
dy= vec[1];
dz= vec[2];
- if(ball->type==MB_BALL) {
+ if (ball->type==MB_BALL) {
}
- else if(ball->type==MB_TUBEX) {
- if( dx > ball->len) dx-= ball->len;
- else if(dx< -ball->len) dx+= ball->len;
+ else if (ball->type==MB_TUBEX) {
+ if ( dx > ball->len) dx-= ball->len;
+ else if (dx< -ball->len) dx+= ball->len;
else dx= 0.0;
}
- else if(ball->type==MB_TUBEY) {
- if( dy > ball->len) dy-= ball->len;
- else if(dy< -ball->len) dy+= ball->len;
+ else if (ball->type==MB_TUBEY) {
+ if ( dy > ball->len) dy-= ball->len;
+ else if (dy< -ball->len) dy+= ball->len;
else dy= 0.0;
}
- else if(ball->type==MB_TUBEZ) {
- if( dz > ball->len) dz-= ball->len;
- else if(dz< -ball->len) dz+= ball->len;
+ else if (ball->type==MB_TUBEZ) {
+ if ( dz > ball->len) dz-= ball->len;
+ else if (dz< -ball->len) dz+= ball->len;
else dz= 0.0;
}
- else if(ball->type==MB_TUBE) {
- if( dx > ball->expx) dx-= ball->expx;
- else if(dx< -ball->expx) dx+= ball->expx;
+ else if (ball->type==MB_TUBE) {
+ if ( dx > ball->expx) dx-= ball->expx;
+ else if (dx< -ball->expx) dx+= ball->expx;
else dx= 0.0;
}
- else if(ball->type==MB_PLANE) {
- if( dx > ball->expx) dx-= ball->expx;
- else if(dx< -ball->expx) dx+= ball->expx;
+ else if (ball->type==MB_PLANE) {
+ if ( dx > ball->expx) dx-= ball->expx;
+ else if (dx< -ball->expx) dx+= ball->expx;
else dx= 0.0;
- if( dy > ball->expy) dy-= ball->expy;
- else if(dy< -ball->expy) dy+= ball->expy;
+ if ( dy > ball->expy) dy-= ball->expy;
+ else if (dy< -ball->expy) dy+= ball->expy;
else dy= 0.0;
}
- else if(ball->type==MB_ELIPSOID) {
+ else if (ball->type==MB_ELIPSOID) {
dx *= 1/ball->expx;
dy *= 1/ball->expy;
dz *= 1/ball->expz;
}
- else if(ball->type==MB_CUBE) {
- if( dx > ball->expx) dx-= ball->expx;
- else if(dx< -ball->expx) dx+= ball->expx;
+ else if (ball->type==MB_CUBE) {
+ if ( dx > ball->expx) dx-= ball->expx;
+ else if (dx< -ball->expx) dx+= ball->expx;
else dx= 0.0;
- if( dy > ball->expy) dy-= ball->expy;
- else if(dy< -ball->expy) dy+= ball->expy;
+ if ( dy > ball->expy) dy-= ball->expy;
+ else if (dy< -ball->expy) dy+= ball->expy;
else dy= 0.0;
- if( dz > ball->expz) dz-= ball->expz;
- else if(dz< -ball->expz) dz+= ball->expz;
+ if ( dz > ball->expz) dz-= ball->expz;
+ else if (dz< -ball->expz) dz+= ball->expz;
else dz= 0.0;
}
dist2= (dx*dx + dy*dy + dz*dz);
- if(ball->flag & MB_NEGATIVE) {
+ if (ball->flag & MB_NEGATIVE) {
dist2= 1.0f-(dist2/ball->rad2);
- if(dist2 < 0.0f) return 0.5f;
+ if (dist2 < 0.0f) return 0.5f;
return 0.5f-ball->s*dist2*dist2*dist2;
}
else {
dist2= 1.0f-(dist2/ball->rad2);
- if(dist2 < 0.0f) return -0.5f;
+ if (dist2 < 0.0f) return -0.5f;
return ball->s*dist2*dist2*dist2 -0.5f;
}
@@ -607,32 +607,32 @@ float densfunc(MetaElem *ball, float x, float y, float z)
octal_node* find_metaball_octal_node(octal_node *node, float x, float y, float z, short depth)
{
- if(!depth) return node;
+ if (!depth) return node;
- if(z < node->z){
- if(y < node->y){
- if(x < node->x){
- if(node->nodes[0])
+ if (z < node->z) {
+ if (y < node->y) {
+ if (x < node->x) {
+ if (node->nodes[0])
return find_metaball_octal_node(node->nodes[0],x,y,z,depth--);
else
return node;
}
else{
- if(node->nodes[1])
+ if (node->nodes[1])
return find_metaball_octal_node(node->nodes[1],x,y,z,depth--);
else
return node;
}
}
else{
- if(x < node->x){
- if(node->nodes[3])
+ if (x < node->x) {
+ if (node->nodes[3])
return find_metaball_octal_node(node->nodes[3],x,y,z,depth--);
else
return node;
}
else{
- if(node->nodes[2])
+ if (node->nodes[2])
return find_metaball_octal_node(node->nodes[2],x,y,z,depth--);
else
return node;
@@ -640,29 +640,29 @@ octal_node* find_metaball_octal_node(octal_node *node, float x, float y, float z
}
}
else{
- if(y < node->y){
- if(x < node->x){
- if(node->nodes[4])
+ if (y < node->y) {
+ if (x < node->x) {
+ if (node->nodes[4])
return find_metaball_octal_node(node->nodes[4],x,y,z,depth--);
else
return node;
}
else{
- if(node->nodes[5])
+ if (node->nodes[5])
return find_metaball_octal_node(node->nodes[5],x,y,z,depth--);
else
return node;
}
}
else{
- if(x < node->x){
- if(node->nodes[7])
+ if (x < node->x) {
+ if (node->nodes[7])
return find_metaball_octal_node(node->nodes[7],x,y,z,depth--);
else
return node;
}
else{
- if(node->nodes[6])
+ if (node->nodes[6])
return find_metaball_octal_node(node->nodes[6],x,y,z,depth--);
else
return node;
@@ -681,12 +681,12 @@ float metaball(float x, float y, float z)
float dens=0;
int a;
- if(totelem > 1){
+ if (totelem > 1) {
node= find_metaball_octal_node(metaball_tree->first, x, y, z, metaball_tree->depth);
- if(node){
+ if (node) {
ml_p= node->elems.first;
- while(ml_p){
+ while(ml_p) {
dens+=densfunc(ml_p->ml, x, y, z);
ml_p= ml_p->next;
}
@@ -718,11 +718,11 @@ void accum_mballfaces(int i1, int i2, int i3, int i4)
int *newi, *cur;
/* static int i=0; I would like to delete altogether, but I don't dare to, yet */
- if(totindex==curindex) {
+ if (totindex==curindex) {
totindex+= 256;
newi= MEM_mallocN(4*sizeof(int)*totindex, "vertindex");
- if(indices) {
+ if (indices) {
memcpy(newi, indices, 4*sizeof(int)*(totindex-256));
MEM_freeN(indices);
}
@@ -736,7 +736,7 @@ void accum_mballfaces(int i1, int i2, int i3, int i4)
cur[0]= i1;
cur[1]= i2;
cur[2]= i3;
- if(i4==0)
+ if (i4==0)
cur[3]= i3;
else
cur[3]= i4;
@@ -757,10 +757,10 @@ void *new_pgn_element(int size)
static ListBase lb= {NULL, NULL};
void *adr;
- if(size>10000 || size==0) {
+ if (size>10000 || size==0) {
printf("incorrect use of new_pgn_element\n");
}
- else if(size== -1) {
+ else if (size== -1) {
cur= lb.first;
while(cur) {
MEM_freeN(cur->data);
@@ -773,8 +773,8 @@ void *new_pgn_element(int size)
size= 4*( (size+3)/4 );
- if(cur) {
- if(size+offs < blocksize) {
+ if (cur) {
+ if (size+offs < blocksize) {
adr= (void *) (cur->data+offs);
offs+= size;
return adr;
@@ -797,7 +797,7 @@ void freepolygonize(PROCESS *p)
new_pgn_element(-1);
- if(p->vertices.ptr) MEM_freeN(p->vertices.ptr);
+ if (p->vertices.ptr) MEM_freeN(p->vertices.ptr);
}
/**** Cubical Polygonization (optional) ****/
@@ -852,23 +852,23 @@ void docube(CUBE *cube, PROCESS *p, MetaBall *mb)
indexar[count] = vertid(c1, c2, p, mb);
count++;
}
- if(count>2) {
+ if (count>2) {
switch(count) {
case 3:
accum_mballfaces(indexar[2], indexar[1], indexar[0], 0);
break;
case 4:
- if(indexar[0]==0) accum_mballfaces(indexar[0], indexar[3], indexar[2], indexar[1]);
+ if (indexar[0]==0) accum_mballfaces(indexar[0], indexar[3], indexar[2], indexar[1]);
else accum_mballfaces(indexar[3], indexar[2], indexar[1], indexar[0]);
break;
case 5:
- if(indexar[0]==0) accum_mballfaces(indexar[0], indexar[3], indexar[2], indexar[1]);
+ if (indexar[0]==0) accum_mballfaces(indexar[0], indexar[3], indexar[2], indexar[1]);
else accum_mballfaces(indexar[3], indexar[2], indexar[1], indexar[0]);
accum_mballfaces(indexar[4], indexar[3], indexar[0], 0);
break;
case 6:
- if(indexar[0]==0) {
+ if (indexar[0]==0) {
accum_mballfaces(indexar[0], indexar[3], indexar[2], indexar[1]);
accum_mballfaces(indexar[0], indexar[5], indexar[4], indexar[3]);
}
@@ -878,7 +878,7 @@ void docube(CUBE *cube, PROCESS *p, MetaBall *mb)
}
break;
case 7:
- if(indexar[0]==0) {
+ if (indexar[0]==0) {
accum_mballfaces(indexar[0], indexar[3], indexar[2], indexar[1]);
accum_mballfaces(indexar[0], indexar[5], indexar[4], indexar[3]);
}
@@ -915,7 +915,7 @@ void testface(int i, int j, int k, CUBE* old, int bit, int c1, int c2, int c3, i
pos = corn1->value > 0.0f ? 1 : 0;
/* test if no surface crossing */
- if( (corn2->value > 0) == pos && (corn3->value > 0) == pos && (corn4->value > 0) == pos) return;
+ if ( (corn2->value > 0) == pos && (corn3->value > 0) == pos && (corn4->value > 0) == pos) return;
/* test if cube out of bounds */
/*if ( abs(i) > p->bounds || abs(j) > p->bounds || abs(k) > p->bounds) return;*/
/* test if already visited (always as last) */
@@ -936,14 +936,14 @@ void testface(int i, int j, int k, CUBE* old, int bit, int c1, int c2, int c3, i
newc.corners[FLIP(c3, bit)] = corn3;
newc.corners[FLIP(c4, bit)] = corn4;
- if(newc.corners[0]==NULL) newc.corners[0] = setcorner(p, i, j, k);
- if(newc.corners[1]==NULL) newc.corners[1] = setcorner(p, i, j, k+1);
- if(newc.corners[2]==NULL) newc.corners[2] = setcorner(p, i, j+1, k);
- if(newc.corners[3]==NULL) newc.corners[3] = setcorner(p, i, j+1, k+1);
- if(newc.corners[4]==NULL) newc.corners[4] = setcorner(p, i+1, j, k);
- if(newc.corners[5]==NULL) newc.corners[5] = setcorner(p, i+1, j, k+1);
- if(newc.corners[6]==NULL) newc.corners[6] = setcorner(p, i+1, j+1, k);
- if(newc.corners[7]==NULL) newc.corners[7] = setcorner(p, i+1, j+1, k+1);
+ if (newc.corners[0]==NULL) newc.corners[0] = setcorner(p, i, j, k);
+ if (newc.corners[1]==NULL) newc.corners[1] = setcorner(p, i, j, k+1);
+ if (newc.corners[2]==NULL) newc.corners[2] = setcorner(p, i, j+1, k);
+ if (newc.corners[3]==NULL) newc.corners[3] = setcorner(p, i, j+1, k+1);
+ if (newc.corners[4]==NULL) newc.corners[4] = setcorner(p, i+1, j, k);
+ if (newc.corners[5]==NULL) newc.corners[5] = setcorner(p, i+1, j, k+1);
+ if (newc.corners[6]==NULL) newc.corners[6] = setcorner(p, i+1, j+1, k);
+ if (newc.corners[7]==NULL) newc.corners[7] = setcorner(p, i+1, j+1, k+1);
p->cubes->cube= newc;
}
@@ -1034,7 +1034,7 @@ void makecubetable (void)
static int isdone= 0;
int i, e, c, done[12], pos[8];
- if(isdone) return;
+ if (isdone) return;
isdone= 1;
for (i = 0; i < 256; i++) {
@@ -1233,7 +1233,7 @@ void vnormal (MB_POINT *point, PROCESS *p, MB_POINT *v)
v->z /= f;
}
- if(FALSE) {
+ if (FALSE) {
MB_POINT temp;
delta *= 2.0f;
@@ -1323,20 +1323,20 @@ void converge (MB_POINT *p1, MB_POINT *p2, float v1, float v2,
/* Approximation by linear interpolation is faster then binary subdivision,
* but it results sometimes (mb->thresh < 0.2) into the strange results */
- if((mb->thresh > 0.2f) && (f==1)){
- if((dy == 0.0f) && (dz == 0.0f)){
+ if ((mb->thresh > 0.2f) && (f==1)) {
+ if ((dy == 0.0f) && (dz == 0.0f)) {
p->x = neg.x - negative*dx/(positive-negative);
p->y = neg.y;
p->z = neg.z;
return;
}
- if((dx == 0.0f) && (dz == 0.0f)){
+ if ((dx == 0.0f) && (dz == 0.0f)) {
p->x = neg.x;
p->y = neg.y - negative*dy/(positive-negative);
p->z = neg.z;
return;
}
- if((dx == 0.0f) && (dy == 0.0f)){
+ if ((dx == 0.0f) && (dy == 0.0f)) {
p->x = neg.x;
p->y = neg.y;
p->z = neg.z - negative*dz/(positive-negative);
@@ -1344,7 +1344,7 @@ void converge (MB_POINT *p1, MB_POINT *p2, float v1, float v2,
}
}
- if((dy == 0.0f) && (dz == 0.0f)){
+ if ((dy == 0.0f) && (dz == 0.0f)) {
p->y = neg.y;
p->z = neg.z;
while (1) {
@@ -1354,7 +1354,7 @@ void converge (MB_POINT *p1, MB_POINT *p2, float v1, float v2,
}
}
- if((dx == 0.0f) && (dz == 0.0f)){
+ if ((dx == 0.0f) && (dz == 0.0f)) {
p->x = neg.x;
p->z = neg.z;
while (1) {
@@ -1364,7 +1364,7 @@ void converge (MB_POINT *p1, MB_POINT *p2, float v1, float v2,
}
}
- if((dx == 0.0f) && (dy == 0.0f)){
+ if ((dx == 0.0f) && (dy == 0.0f)) {
p->x = neg.x;
p->y = neg.y;
while (1) {
@@ -1382,7 +1382,7 @@ void converge (MB_POINT *p1, MB_POINT *p2, float v1, float v2,
if (i++ == RES) return;
- if ((function(p->x, p->y, p->z)) > 0.0f){
+ if ((function(p->x, p->y, p->z)) > 0.0f) {
pos.x = p->x;
pos.y = p->y;
pos.z = p->z;
@@ -1408,7 +1408,7 @@ void add_cube(PROCESS *mbproc, int i, int j, int k, int count)
for(b=j-1; b<j+count; b++)
for(c=k-1; c<k+count; c++) {
/* test if cube has been found before */
- if( setcenter(mbproc->centers, a, b, c)==0 ) {
+ if ( setcenter(mbproc->centers, a, b, c)==0 ) {
/* push cube on stack: */
ncube= (CUBES *) new_pgn_element(sizeof(CUBES));
ncube->next= mbproc->cubes;
@@ -1443,7 +1443,7 @@ void find_first_points(PROCESS *mbproc, MetaBall *mb, int a)
/* Skip, when Stiffness of MetaElement is too small ... MetaElement can't be
* visible alone ... but still can influence others MetaElements :-) */
- if(f > 0.0f) {
+ if (f > 0.0f) {
OUT.x = IN.x = in.x= 0.0;
OUT.y = IN.y = in.y= 0.0;
OUT.z = IN.z = in.z= 0.0;
@@ -1451,7 +1451,7 @@ void find_first_points(PROCESS *mbproc, MetaBall *mb, int a)
calc_mballco(ml, (float *)&in);
in_v = mbproc->function(in.x, in.y, in.z);
- for(i=0;i<3;i++){
+ for(i=0;i<3;i++) {
switch (ml->type) {
case MB_BALL:
OUT.x = out.x= IN.x + index[i]*ml->rad;
@@ -1508,7 +1508,7 @@ void find_first_points(PROCESS *mbproc, MetaBall *mb, int a)
nz = abs((out.z - in.z)/mbproc->size);
MAXN = MAX3(nx,ny,nz);
- if(MAXN!=0.0f) {
+ if (MAXN!=0.0f) {
dx = (out.x - in.x)/MAXN;
dy = (out.y - in.y)/MAXN;
dz = (out.z - in.z)/MAXN;
@@ -1521,7 +1521,7 @@ void find_first_points(PROCESS *mbproc, MetaBall *mb, int a)
/* compute value of implicite function */
tmp_v = mbproc->function(workp.x, workp.y, workp.z);
/* add cube to the stack, when value of implicite function crosses zero value */
- if((tmp_v<0.0f && workp_v>=0.0f)||(tmp_v>0.0f && workp_v<=0.0f)) {
+ if ((tmp_v<0.0f && workp_v>=0.0f)||(tmp_v>0.0f && workp_v<=0.0f)) {
/* indexes of CUBE, which includes "first point" */
c_i= (int)floor(workp.x/mbproc->size);
@@ -1608,14 +1608,14 @@ float init_meta(Scene *scene, Object *ob) /* return totsize */
next_object(&sce_iter, 0, NULL, NULL);
while(next_object(&sce_iter, 1, &base, &bob)) {
- if(bob->type==OB_MBALL) {
+ if (bob->type==OB_MBALL) {
zero_size= 0;
ml= NULL;
- if(bob==ob && (base->flag & OB_FROMDUPLI)==0) {
+ if (bob==ob && (base->flag & OB_FROMDUPLI)==0) {
mb= ob->data;
- if(mb->editelems) ml= mb->editelems->first;
+ if (mb->editelems) ml= mb->editelems->first;
else ml= mb->elems.first;
}
else {
@@ -1623,23 +1623,23 @@ float init_meta(Scene *scene, Object *ob) /* return totsize */
int nr;
BLI_split_name_num(name, &nr, bob->id.name+2, '.');
- if( strcmp(obname, name)==0 ) {
+ if ( strcmp(obname, name)==0 ) {
mb= bob->data;
- if(mb->editelems) ml= mb->editelems->first;
+ if (mb->editelems) ml= mb->editelems->first;
else ml= mb->elems.first;
}
}
/* when metaball object has zero scale, then MetaElem to this MetaBall
* will not be put to mainb array */
- if(bob->size[0]==0.0f || bob->size[1]==0.0f || bob->size[2]==0.0f) {
+ if (bob->size[0]==0.0f || bob->size[1]==0.0f || bob->size[2]==0.0f) {
zero_size= 1;
}
- else if(bob->parent) {
+ else if (bob->parent) {
struct Object *pob=bob->parent;
while(pob) {
- if(pob->size[0]==0.0f || pob->size[1]==0.0f || pob->size[2]==0.0f) {
+ if (pob->size[0]==0.0f || pob->size[1]==0.0f || pob->size[2]==0.0f) {
zero_size= 1;
break;
}
@@ -1657,7 +1657,7 @@ float init_meta(Scene *scene, Object *ob) /* return totsize */
}
else {
while(ml) {
- if(!(ml->flag & MB_HIDE)) {
+ if (!(ml->flag & MB_HIDE)) {
int i;
float temp1[4][4], temp2[4][4], temp3[4][4];
float (*mat)[4] = NULL, (*imat)[4] = NULL;
@@ -1668,7 +1668,7 @@ float init_meta(Scene *scene, Object *ob) /* return totsize */
/* too big stiffness seems only ugly due to linear interpolation
* no need to have possibility for too big stiffness */
- if(ml->s > 10.0f) ml->s = 10.0f;
+ if (ml->s > 10.0f) ml->s = 10.0f;
/* Rotation of MetaElem is stored in quat */
quat_to_mat4( temp3,ml->quat);
@@ -1741,15 +1741,15 @@ float init_meta(Scene *scene, Object *ob) /* return totsize */
mul_m4_v3((float ( * )[4])mat, mainb[a]->bb->vec[i]);
/* find max and min of transformed bb */
- for(i=0; i<8; i++){
+ for(i=0; i<8; i++) {
/* find maximums */
- if(mainb[a]->bb->vec[i][0] > max_x) max_x = mainb[a]->bb->vec[i][0];
- if(mainb[a]->bb->vec[i][1] > max_y) max_y = mainb[a]->bb->vec[i][1];
- if(mainb[a]->bb->vec[i][2] > max_z) max_z = mainb[a]->bb->vec[i][2];
+ if (mainb[a]->bb->vec[i][0] > max_x) max_x = mainb[a]->bb->vec[i][0];
+ if (mainb[a]->bb->vec[i][1] > max_y) max_y = mainb[a]->bb->vec[i][1];
+ if (mainb[a]->bb->vec[i][2] > max_z) max_z = mainb[a]->bb->vec[i][2];
/* find minimums */
- if(mainb[a]->bb->vec[i][0] < min_x) min_x = mainb[a]->bb->vec[i][0];
- if(mainb[a]->bb->vec[i][1] < min_y) min_y = mainb[a]->bb->vec[i][1];
- if(mainb[a]->bb->vec[i][2] < min_z) min_z = mainb[a]->bb->vec[i][2];
+ if (mainb[a]->bb->vec[i][0] < min_x) min_x = mainb[a]->bb->vec[i][0];
+ if (mainb[a]->bb->vec[i][1] < min_y) min_y = mainb[a]->bb->vec[i][1];
+ if (mainb[a]->bb->vec[i][2] < min_z) min_z = mainb[a]->bb->vec[i][2];
}
/* create "new" bb, only point 0 and 6, which are
@@ -1782,11 +1782,11 @@ float init_meta(Scene *scene, Object *ob) /* return totsize */
calc_mballco(mainb[a], vec);
size= fabsf( vec[0] );
- if( size > totsize ) totsize= size;
+ if ( size > totsize ) totsize= size;
size= fabsf( vec[1] );
- if( size > totsize ) totsize= size;
+ if ( size > totsize ) totsize= size;
size= fabsf( vec[2] );
- if( size > totsize ) totsize= size;
+ if ( size > totsize ) totsize= size;
vec[0]= mainb[a]->x - mainb[a]->rad;
vec[1]= mainb[a]->y - mainb[a]->rad;
@@ -1795,11 +1795,11 @@ float init_meta(Scene *scene, Object *ob) /* return totsize */
calc_mballco(mainb[a], vec);
size= fabsf( vec[0] );
- if( size > totsize ) totsize= size;
+ if ( size > totsize ) totsize= size;
size= fabsf( vec[1] );
- if( size > totsize ) totsize= size;
+ if ( size > totsize ) totsize= size;
size= fabsf( vec[2] );
- if( size > totsize ) totsize= size;
+ if ( size > totsize ) totsize= size;
}
for(a=0; a<totelem; a++) {
@@ -1821,7 +1821,7 @@ void fill_metaball_octal_node(octal_node *node, MetaElem *ml, short i)
BLI_addtail(&(node->nodes[i]->elems), ml_p);
node->count++;
- if(ml->flag & MB_NEGATIVE) {
+ if (ml->flag & MB_NEGATIVE) {
node->nodes[i]->neg++;
}
else{
@@ -1852,7 +1852,7 @@ void subdivide_metaball_octal_node(octal_node *node, float size_x, float size_y,
int a,i;
/* create new nodes */
- for(a=0;a<8;a++){
+ for(a=0;a<8;a++) {
node->nodes[a]= MEM_mallocN(sizeof(octal_node),"octal_node");
for(i=0;i<8;i++)
node->nodes[a]->nodes[i]= NULL;
@@ -1933,48 +1933,48 @@ void subdivide_metaball_octal_node(octal_node *node, float size_x, float size_y,
ml_p= node->elems.first;
/* setting up references of MetaElems for new nodes */
- while(ml_p){
+ while(ml_p) {
ml= ml_p->ml;
- if(ml->bb->vec[0][2] < z){
- if(ml->bb->vec[0][1] < y){
+ if (ml->bb->vec[0][2] < z) {
+ if (ml->bb->vec[0][1] < y) {
/* vec[0][0] lies in first octant */
- if(ml->bb->vec[0][0] < x){
+ if (ml->bb->vec[0][0] < x) {
/* ml belongs to the (0)1st node */
fill_metaball_octal_node(node, ml, 0);
/* ml belongs to the (3)4th node */
- if(ml->bb->vec[6][1] >= y){
+ if (ml->bb->vec[6][1] >= y) {
fill_metaball_octal_node(node, ml, 3);
/* ml belongs to the (7)8th node */
- if(ml->bb->vec[6][2] >= z){
+ if (ml->bb->vec[6][2] >= z) {
fill_metaball_octal_node(node, ml, 7);
}
}
/* ml belongs to the (1)2nd node */
- if(ml->bb->vec[6][0] >= x){
+ if (ml->bb->vec[6][0] >= x) {
fill_metaball_octal_node(node, ml, 1);
/* ml belongs to the (5)6th node */
- if(ml->bb->vec[6][2] >= z){
+ if (ml->bb->vec[6][2] >= z) {
fill_metaball_octal_node(node, ml, 5);
}
}
/* ml belongs to the (2)3th node */
- if((ml->bb->vec[6][0] >= x) && (ml->bb->vec[6][1] >= y)){
+ if ((ml->bb->vec[6][0] >= x) && (ml->bb->vec[6][1] >= y)) {
fill_metaball_octal_node(node, ml, 2);
/* ml belong to the (6)7th node */
- if(ml->bb->vec[6][2] >= z){
+ if (ml->bb->vec[6][2] >= z) {
fill_metaball_octal_node(node, ml, 6);
}
}
/* ml belongs to the (4)5th node too */
- if(ml->bb->vec[6][2] >= z){
+ if (ml->bb->vec[6][2] >= z) {
fill_metaball_octal_node(node, ml, 4);
}
@@ -1987,40 +1987,40 @@ void subdivide_metaball_octal_node(octal_node *node, float size_x, float size_y,
fill_metaball_octal_node(node, ml, 1);
/* ml belongs to the (2)3th node */
- if(ml->bb->vec[6][1] >= y){
+ if (ml->bb->vec[6][1] >= y) {
fill_metaball_octal_node(node, ml, 2);
/* ml belongs to the (6)7th node */
- if(ml->bb->vec[6][2] >= z){
+ if (ml->bb->vec[6][2] >= z) {
fill_metaball_octal_node(node, ml, 6);
}
}
/* ml belongs to the (5)6th node */
- if(ml->bb->vec[6][2] >= z){
+ if (ml->bb->vec[6][2] >= z) {
fill_metaball_octal_node(node, ml, 5);
}
}
}
else{
/* vec[0][0] is in the (3)4th octant */
- if(ml->bb->vec[0][0] < x){
+ if (ml->bb->vec[0][0] < x) {
/* ml belongs to the (3)4nd node */
fill_metaball_octal_node(node, ml, 3);
/* ml belongs to the (7)8th node */
- if(ml->bb->vec[6][2] >= z){
+ if (ml->bb->vec[6][2] >= z) {
fill_metaball_octal_node(node, ml, 7);
}
/* ml belongs to the (2)3th node */
- if(ml->bb->vec[6][0] >= x){
+ if (ml->bb->vec[6][0] >= x) {
fill_metaball_octal_node(node, ml, 2);
/* ml belongs to the (6)7th node */
- if(ml->bb->vec[6][2] >= z){
+ if (ml->bb->vec[6][2] >= z) {
fill_metaball_octal_node(node, ml, 6);
}
}
@@ -2029,32 +2029,32 @@ void subdivide_metaball_octal_node(octal_node *node, float size_x, float size_y,
}
/* vec[0][0] is in the (2)3th octant */
- if((ml->bb->vec[0][0] >= x) && (ml->bb->vec[0][1] >= y)){
+ if ((ml->bb->vec[0][0] >= x) && (ml->bb->vec[0][1] >= y)) {
/* ml belongs to the (2)3th node */
fill_metaball_octal_node(node, ml, 2);
/* ml belongs to the (6)7th node */
- if(ml->bb->vec[6][2] >= z){
+ if (ml->bb->vec[6][2] >= z) {
fill_metaball_octal_node(node, ml, 6);
}
}
}
else{
- if(ml->bb->vec[0][1] < y){
+ if (ml->bb->vec[0][1] < y) {
/* vec[0][0] lies in (4)5th octant */
- if(ml->bb->vec[0][0] < x){
+ if (ml->bb->vec[0][0] < x) {
/* ml belongs to the (4)5th node */
fill_metaball_octal_node(node, ml, 4);
- if(ml->bb->vec[6][0] >= x){
+ if (ml->bb->vec[6][0] >= x) {
fill_metaball_octal_node(node, ml, 5);
}
- if(ml->bb->vec[6][1] >= y){
+ if (ml->bb->vec[6][1] >= y) {
fill_metaball_octal_node(node, ml, 7);
}
- if((ml->bb->vec[6][0] >= x) && (ml->bb->vec[6][1] >= y)){
+ if ((ml->bb->vec[6][0] >= x) && (ml->bb->vec[6][1] >= y)) {
fill_metaball_octal_node(node, ml, 6);
}
}
@@ -2062,17 +2062,17 @@ void subdivide_metaball_octal_node(octal_node *node, float size_x, float size_y,
else{
fill_metaball_octal_node(node, ml, 5);
- if(ml->bb->vec[6][1] >= y){
+ if (ml->bb->vec[6][1] >= y) {
fill_metaball_octal_node(node, ml, 6);
}
}
}
else{
/* vec[0][0] lies in (7)8th octant */
- if(ml->bb->vec[0][0] < x){
+ if (ml->bb->vec[0][0] < x) {
fill_metaball_octal_node(node, ml, 7);
- if(ml->bb->vec[6][0] >= x){
+ if (ml->bb->vec[6][0] >= x) {
fill_metaball_octal_node(node, ml, 6);
}
}
@@ -2080,7 +2080,7 @@ void subdivide_metaball_octal_node(octal_node *node, float size_x, float size_y,
}
/* vec[0][0] lies in (6)7th octant */
- if((ml->bb->vec[0][0] >= x) && (ml->bb->vec[0][1] >= y)){
+ if ((ml->bb->vec[0][0] >= x) && (ml->bb->vec[0][1] >= y)) {
fill_metaball_octal_node(node, ml, 6);
}
}
@@ -2092,9 +2092,9 @@ void subdivide_metaball_octal_node(octal_node *node, float size_x, float size_y,
depth--;
- if(depth>0){
- for(a=0;a<8;a++){
- if(node->nodes[a]->count > 0) /* if node is not empty, then it is subdivided */
+ if (depth>0) {
+ for(a=0;a<8;a++) {
+ if (node->nodes[a]->count > 0) /* if node is not empty, then it is subdivided */
subdivide_metaball_octal_node(node->nodes[a], size_x, size_y, size_z, depth);
}
}
@@ -2104,8 +2104,8 @@ void subdivide_metaball_octal_node(octal_node *node, float size_x, float size_y,
void free_metaball_octal_node(octal_node *node)
{
int a;
- for(a=0;a<8;a++){
- if(node->nodes[a]!=NULL) free_metaball_octal_node(node->nodes[a]);
+ for(a=0;a<8;a++) {
+ if (node->nodes[a]!=NULL) free_metaball_octal_node(node->nodes[a]);
}
BLI_freelistN(&node->elems);
MEM_freeN(node);
@@ -2139,19 +2139,19 @@ void init_metaball_octal_tree(int depth)
/* size of octal tree scene */
for(a=0;a<totelem;a++) {
- if(mainb[a]->bb->vec[0][0] < node->x_min) node->x_min= mainb[a]->bb->vec[0][0];
- if(mainb[a]->bb->vec[0][1] < node->y_min) node->y_min= mainb[a]->bb->vec[0][1];
- if(mainb[a]->bb->vec[0][2] < node->z_min) node->z_min= mainb[a]->bb->vec[0][2];
+ if (mainb[a]->bb->vec[0][0] < node->x_min) node->x_min= mainb[a]->bb->vec[0][0];
+ if (mainb[a]->bb->vec[0][1] < node->y_min) node->y_min= mainb[a]->bb->vec[0][1];
+ if (mainb[a]->bb->vec[0][2] < node->z_min) node->z_min= mainb[a]->bb->vec[0][2];
- if(mainb[a]->bb->vec[6][0] > node->x_max) node->x_max= mainb[a]->bb->vec[6][0];
- if(mainb[a]->bb->vec[6][1] > node->y_max) node->y_max= mainb[a]->bb->vec[6][1];
- if(mainb[a]->bb->vec[6][2] > node->z_max) node->z_max= mainb[a]->bb->vec[6][2];
+ if (mainb[a]->bb->vec[6][0] > node->x_max) node->x_max= mainb[a]->bb->vec[6][0];
+ if (mainb[a]->bb->vec[6][1] > node->y_max) node->y_max= mainb[a]->bb->vec[6][1];
+ if (mainb[a]->bb->vec[6][2] > node->z_max) node->z_max= mainb[a]->bb->vec[6][2];
ml_p= MEM_mallocN(sizeof(ml_pointer), "ml_pointer");
ml_p->ml= mainb[a];
BLI_addtail(&node->elems, ml_p);
- if(mainb[a]->flag & MB_NEGATIVE) {
+ if (mainb[a]->flag & MB_NEGATIVE) {
/* number of negative MetaElem in scene */
metaball_tree->neg++;
}
@@ -2180,9 +2180,9 @@ void metaball_polygonize(Scene *scene, Object *ob, ListBase *dispbase)
mb= ob->data;
- if(totelem==0) return;
- if(!(G.rendering) && (mb->flag==MB_UPDATE_NEVER)) return;
- if(G.moving && mb->flag==MB_UPDATE_FAST) return;
+ if (totelem==0) return;
+ if (!(G.rendering) && (mb->flag==MB_UPDATE_NEVER)) return;
+ if (G.moving && mb->flag==MB_UPDATE_FAST) return;
curindex= totindex= 0;
indices= NULL;
@@ -2194,23 +2194,23 @@ void metaball_polygonize(Scene *scene, Object *ob, ListBase *dispbase)
/* initialize all mainb (MetaElems) */
totsize= init_meta(scene, ob);
- if(metaball_tree){
+ if (metaball_tree) {
free_metaball_octal_node(metaball_tree->first);
MEM_freeN(metaball_tree);
metaball_tree= NULL;
}
/* if scene includes more then one MetaElem, then octal tree optimalisation is used */
- if((totelem > 1) && (totelem <= 64)) init_metaball_octal_tree(1);
- if((totelem > 64) && (totelem <= 128)) init_metaball_octal_tree(2);
- if((totelem > 128) && (totelem <= 512)) init_metaball_octal_tree(3);
- if((totelem > 512) && (totelem <= 1024)) init_metaball_octal_tree(4);
- if(totelem > 1024) init_metaball_octal_tree(5);
+ if ((totelem > 1) && (totelem <= 64)) init_metaball_octal_tree(1);
+ if ((totelem > 64) && (totelem <= 128)) init_metaball_octal_tree(2);
+ if ((totelem > 128) && (totelem <= 512)) init_metaball_octal_tree(3);
+ if ((totelem > 512) && (totelem <= 1024)) init_metaball_octal_tree(4);
+ if (totelem > 1024) init_metaball_octal_tree(5);
/* don't polygonize metaballs with too high resolution (base mball to small)
* note: Eps was 0.0001f but this was giving problems for blood animation for durian, using 0.00001f */
- if(metaball_tree) {
- if( ob->size[0] <= 0.00001f * (metaball_tree->first->x_max - metaball_tree->first->x_min) ||
+ if (metaball_tree) {
+ if ( ob->size[0] <= 0.00001f * (metaball_tree->first->x_max - metaball_tree->first->x_min) ||
ob->size[1] <= 0.00001f * (metaball_tree->first->y_max - metaball_tree->first->y_min) ||
ob->size[2] <= 0.00001f * (metaball_tree->first->z_max - metaball_tree->first->z_min))
{
@@ -2228,10 +2228,10 @@ void metaball_polygonize(Scene *scene, Object *ob, ListBase *dispbase)
}
/* width is size per polygonize cube */
- if(G.rendering) width= mb->rendersize;
+ if (G.rendering) width= mb->rendersize;
else {
width= mb->wiresize;
- if(G.moving && mb->flag==MB_UPDATE_HALFRES) width*= 2;
+ if (G.moving && mb->flag==MB_UPDATE_HALFRES) width*= 2;
}
/* nr_cubes is just for safety, minimum is totsize */
nr_cubes= (int)(0.5f+totsize/width);
@@ -2248,13 +2248,13 @@ void metaball_polygonize(Scene *scene, Object *ob, ListBase *dispbase)
MEM_freeN(mainb);
/* free octal tree */
- if(totelem > 1){
+ if (totelem > 1) {
free_metaball_octal_node(metaball_tree->first);
MEM_freeN(metaball_tree);
metaball_tree= NULL;
}
- if(curindex) {
+ if (curindex) {
dl= MEM_callocN(sizeof(DispList), "mbaldisp");
BLI_addtail(dispbase, dl);
dl->type= DL_INDEX4;
diff --git a/source/blender/blenkernel/intern/mesh.c b/source/blender/blenkernel/intern/mesh.c
index eb107e15732..03d4ca0a922 100644
--- a/source/blender/blenkernel/intern/mesh.c
+++ b/source/blender/blenkernel/intern/mesh.c
@@ -377,19 +377,19 @@ void unlink_mesh(Mesh *me)
{
int a;
- if(me==NULL) return;
+ if (me==NULL) return;
- for(a=0; a<me->totcol; a++) {
- if(me->mat[a]) me->mat[a]->id.us--;
+ for (a=0; a<me->totcol; a++) {
+ if (me->mat[a]) me->mat[a]->id.us--;
me->mat[a]= NULL;
}
- if(me->key) {
+ if (me->key) {
me->key->id.us--;
}
me->key= NULL;
- if(me->texcomesh) me->texcomesh= NULL;
+ if (me->texcomesh) me->texcomesh= NULL;
}
/* do not free mesh itself */
@@ -404,16 +404,16 @@ void free_mesh(Mesh *me, int unlink)
CustomData_free(&me->ldata, me->totloop);
CustomData_free(&me->pdata, me->totpoly);
- if(me->adt) {
+ if (me->adt) {
BKE_free_animdata(&me->id);
me->adt= NULL;
}
- if(me->mat) MEM_freeN(me->mat);
+ if (me->mat) MEM_freeN(me->mat);
- if(me->bb) MEM_freeN(me->bb);
- if(me->mselect) MEM_freeN(me->mselect);
- if(me->edit_btmesh) MEM_freeN(me->edit_btmesh);
+ if (me->bb) MEM_freeN(me->bb);
+ if (me->mselect) MEM_freeN(me->mselect);
+ if (me->edit_btmesh) MEM_freeN(me->edit_btmesh);
}
void copy_dverts(MDeformVert *dst, MDeformVert *src, int copycount)
@@ -426,8 +426,8 @@ void copy_dverts(MDeformVert *dst, MDeformVert *src, int copycount)
memcpy (dst, src, copycount * sizeof(MDeformVert));
- for (i=0; i<copycount; i++){
- if (src[i].dw){
+ for (i=0; i<copycount; i++) {
+ if (src[i].dw) {
dst[i].dw = MEM_callocN (sizeof(MDeformWeight)*src[i].totweight, "copy_deformWeight");
memcpy (dst[i].dw, src[i].dw, sizeof (MDeformWeight)*src[i].totweight);
}
@@ -446,7 +446,7 @@ void free_dverts(MDeformVert *dvert, int totvert)
return;
/* Free any special data from the verts */
- for (i=0; i<totvert; i++){
+ for (i=0; i<totvert; i++) {
if (dvert[i].dw) MEM_freeN (dvert[i].dw);
}
MEM_freeN (dvert);
@@ -478,7 +478,7 @@ Mesh *copy_mesh(Mesh *me)
men= copy_libblock(&me->id);
men->mat= MEM_dupallocN(me->mat);
- for(a=0; a<men->totcol; a++) {
+ for (a=0; a<men->totcol; a++) {
id_us_plus((ID *)men->mat[a]);
}
id_us_plus((ID *)men->texcomesh);
@@ -491,22 +491,22 @@ Mesh *copy_mesh(Mesh *me)
mesh_update_customdata_pointers(men, TRUE);
/* ensure indirect linked data becomes lib-extern */
- for(i=0; i<me->fdata.totlayer; i++) {
- if(me->fdata.layers[i].type == CD_MTFACE) {
+ for (i=0; i<me->fdata.totlayer; i++) {
+ if (me->fdata.layers[i].type == CD_MTFACE) {
tface= (MTFace*)me->fdata.layers[i].data;
- for(a=0; a<me->totface; a++, tface++)
- if(tface->tpage)
+ for (a=0; a<me->totface; a++, tface++)
+ if (tface->tpage)
id_lib_extern((ID*)tface->tpage);
}
}
- for(i=0; i<me->pdata.totlayer; i++) {
- if(me->pdata.layers[i].type == CD_MTEXPOLY) {
+ for (i=0; i<me->pdata.totlayer; i++) {
+ if (me->pdata.layers[i].type == CD_MTEXPOLY) {
txface= (MTexPoly*)me->pdata.layers[i].data;
- for(a=0; a<me->totpoly; a++, txface++)
- if(txface->tpage)
+ for (a=0; a<me->totpoly; a++, txface++)
+ if (txface->tpage)
id_lib_extern((ID*)txface->tpage);
}
}
@@ -517,7 +517,7 @@ Mesh *copy_mesh(Mesh *me)
men->bb= MEM_dupallocN(men->bb);
men->key= copy_key(me->key);
- if(men->key) men->key->from= (ID *)men;
+ if (men->key) men->key->from= (ID *)men;
return men;
}
@@ -537,17 +537,17 @@ static void expand_local_mesh(Mesh *me)
{
id_lib_extern((ID *)me->texcomesh);
- if(me->mtface || me->mtpoly) {
+ if (me->mtface || me->mtpoly) {
int a, i;
- for(i=0; i<me->pdata.totlayer; i++) {
- if(me->pdata.layers[i].type == CD_MTEXPOLY) {
+ for (i=0; i<me->pdata.totlayer; i++) {
+ if (me->pdata.layers[i].type == CD_MTEXPOLY) {
MTexPoly *txface= (MTexPoly*)me->fdata.layers[i].data;
- for(a=0; a<me->totpoly; a++, txface++) {
+ for (a=0; a<me->totpoly; a++, txface++) {
/* special case: ima always local immediately */
- if(txface->tpage) {
- if(txface->tpage) {
+ if (txface->tpage) {
+ if (txface->tpage) {
id_lib_extern((ID *)txface->tpage);
}
}
@@ -555,14 +555,14 @@ static void expand_local_mesh(Mesh *me)
}
}
- for(i=0; i<me->fdata.totlayer; i++) {
- if(me->fdata.layers[i].type == CD_MTFACE) {
+ for (i=0; i<me->fdata.totlayer; i++) {
+ if (me->fdata.layers[i].type == CD_MTFACE) {
MTFace *tface= (MTFace*)me->fdata.layers[i].data;
- for(a=0; a<me->totface; a++, tface++) {
+ for (a=0; a<me->totface; a++, tface++) {
/* special case: ima always local immediately */
- if(tface->tpage) {
- if(tface->tpage) {
+ if (tface->tpage) {
+ if (tface->tpage) {
id_lib_extern((ID *)tface->tpage);
}
}
@@ -571,7 +571,7 @@ static void expand_local_mesh(Mesh *me)
}
}
- if(me->mat) {
+ if (me->mat) {
extern_local_matarar(me->mat, me->totcol);
}
}
@@ -587,25 +587,25 @@ void make_local_mesh(Mesh *me)
* - mixed: make copy
*/
- if(me->id.lib==NULL) return;
- if(me->id.us==1) {
+ if (me->id.lib==NULL) return;
+ if (me->id.us==1) {
id_clear_lib_data(bmain, &me->id);
expand_local_mesh(me);
return;
}
- for(ob= bmain->object.first; ob && ELEM(0, is_lib, is_local); ob= ob->id.next) {
- if(me == ob->data) {
- if(ob->id.lib) is_lib= TRUE;
+ for (ob= bmain->object.first; ob && ELEM(0, is_lib, is_local); ob= ob->id.next) {
+ if (me == ob->data) {
+ if (ob->id.lib) is_lib= TRUE;
else is_local= TRUE;
}
}
- if(is_local && is_lib == FALSE) {
+ if (is_local && is_lib == FALSE) {
id_clear_lib_data(bmain, &me->id);
expand_local_mesh(me);
}
- else if(is_local && is_lib) {
+ else if (is_local && is_lib) {
Mesh *me_new= copy_mesh(me);
me_new->id.us= 0;
@@ -613,9 +613,9 @@ void make_local_mesh(Mesh *me)
/* Remap paths of new ID using old library as base. */
BKE_id_lib_local_paths(bmain, me->id.lib, &me_new->id);
- for(ob= bmain->object.first; ob; ob= ob->id.next) {
- if(me == ob->data) {
- if(ob->id.lib==NULL) {
+ for (ob= bmain->object.first; ob; ob= ob->id.next) {
+ if (me == ob->data) {
+ if (ob->id.lib==NULL) {
set_mesh(ob, me_new);
}
}
@@ -629,14 +629,14 @@ void boundbox_mesh(Mesh *me, float *loc, float *size)
float min[3], max[3];
float mloc[3], msize[3];
- if(me->bb==NULL) me->bb= MEM_callocN(sizeof(BoundBox), "boundbox");
+ if (me->bb==NULL) me->bb= MEM_callocN(sizeof(BoundBox), "boundbox");
bb= me->bb;
if (!loc) loc= mloc;
if (!size) size= msize;
INIT_MINMAX(min, max);
- if(!minmax_mesh(me, min, max)) {
+ if (!minmax_mesh(me, min, max)) {
min[0] = min[1] = min[2] = -1.0f;
max[0] = max[1] = max[2] = 1.0f;
}
@@ -659,9 +659,9 @@ void tex_space_mesh(Mesh *me)
if (me->texflag & ME_AUTOSPACE) {
for (a=0; a<3; a++) {
- if(size[a]==0.0f) size[a]= 1.0f;
- else if(size[a]>0.0f && size[a]<0.00001f) size[a]= 0.00001f;
- else if(size[a]<0.0f && size[a]> -0.00001f) size[a]= -0.00001f;
+ if (size[a]==0.0f) size[a]= 1.0f;
+ else if (size[a]>0.0f && size[a]<0.00001f) size[a]= 0.00001f;
+ else if (size[a]<0.0f && size[a]> -0.00001f) size[a]= -0.00001f;
}
copy_v3_v3(me->loc, loc);
@@ -674,7 +674,7 @@ BoundBox *mesh_get_bb(Object *ob)
{
Mesh *me= ob->data;
- if(ob->bb)
+ if (ob->bb)
return ob->bb;
if (!me->bb)
@@ -707,7 +707,7 @@ float *get_mesh_orco_verts(Object *ob)
mvert = tme->mvert;
totvert = MIN2(tme->totvert, me->totvert);
- for(a=0; a<totvert; a++, mvert++) {
+ for (a=0; a<totvert; a++, mvert++) {
copy_v3_v3(vcos[a], mvert->co);
}
@@ -721,14 +721,14 @@ void transform_mesh_orco_verts(Mesh *me, float (*orco)[3], int totvert, int inve
mesh_get_texspace(me->texcomesh?me->texcomesh:me, loc, NULL, size);
- if(invert) {
- for(a=0; a<totvert; a++) {
+ if (invert) {
+ for (a=0; a<totvert; a++) {
float *co = orco[a];
madd_v3_v3v3v3(co, loc, co, size);
}
}
else {
- for(a=0; a<totvert; a++) {
+ for (a=0; a<totvert; a++) {
float *co = orco[a];
co[0] = (co[0]-loc[0])/size[0];
co[1] = (co[1]-loc[1])/size[1];
@@ -738,20 +738,20 @@ void transform_mesh_orco_verts(Mesh *me, float (*orco)[3], int totvert, int inve
}
/* rotates the vertices of a face in case v[2] or v[3] (vertex index) is = 0.
- this is necessary to make the if(mface->v4) check for quads work */
+ this is necessary to make the if (mface->v4) check for quads work */
int test_index_face(MFace *mface, CustomData *fdata, int mfindex, int nr)
{
/* first test if the face is legal */
- if((mface->v3 || nr==4) && mface->v3==mface->v4) {
+ if ((mface->v3 || nr==4) && mface->v3==mface->v4) {
mface->v4= 0;
nr--;
}
- if((mface->v2 || mface->v4) && mface->v2==mface->v3) {
+ if ((mface->v2 || mface->v4) && mface->v2==mface->v3) {
mface->v3= mface->v4;
mface->v4= 0;
nr--;
}
- if(mface->v1==mface->v2) {
+ if (mface->v1==mface->v2) {
mface->v2= mface->v3;
mface->v3= mface->v4;
mface->v4= 0;
@@ -759,8 +759,8 @@ int test_index_face(MFace *mface, CustomData *fdata, int mfindex, int nr)
}
/* check corrupt cases, bowtie geometry, cant handle these because edge data wont exist so just return 0 */
- if(nr==3) {
- if(
+ if (nr==3) {
+ if (
/* real edges */
mface->v1==mface->v2 ||
mface->v2==mface->v3 ||
@@ -769,8 +769,8 @@ int test_index_face(MFace *mface, CustomData *fdata, int mfindex, int nr)
return 0;
}
}
- else if(nr==4) {
- if(
+ else if (nr==4) {
+ if (
/* real edges */
mface->v1==mface->v2 ||
mface->v2==mface->v3 ||
@@ -785,25 +785,25 @@ int test_index_face(MFace *mface, CustomData *fdata, int mfindex, int nr)
}
/* prevent a zero at wrong index location */
- if(nr==3) {
- if(mface->v3==0) {
+ if (nr==3) {
+ if (mface->v3==0) {
static int corner_indices[4] = {1, 2, 0, 3};
SWAP(unsigned int, mface->v1, mface->v2);
SWAP(unsigned int, mface->v2, mface->v3);
- if(fdata)
+ if (fdata)
CustomData_swap(fdata, mfindex, corner_indices);
}
}
- else if(nr==4) {
- if(mface->v3==0 || mface->v4==0) {
+ else if (nr==4) {
+ if (mface->v3==0 || mface->v4==0) {
static int corner_indices[4] = {2, 3, 0, 1};
SWAP(unsigned int, mface->v1, mface->v3);
SWAP(unsigned int, mface->v2, mface->v4);
- if(fdata)
+ if (fdata)
CustomData_swap(fdata, mfindex, corner_indices);
}
}
@@ -814,8 +814,8 @@ int test_index_face(MFace *mface, CustomData *fdata, int mfindex, int nr)
Mesh *get_mesh(Object *ob)
{
- if(ob==NULL) return NULL;
- if(ob->type==OB_MESH) return ob->data;
+ if (ob==NULL) return NULL;
+ if (ob->type==OB_MESH) return ob->data;
else return NULL;
}
@@ -825,9 +825,9 @@ void set_mesh(Object *ob, Mesh *me)
multires_force_update(ob);
- if(ob==NULL) return;
+ if (ob==NULL) return;
- if(ob->type==OB_MESH) {
+ if (ob->type==OB_MESH) {
old= ob->data;
if (old)
old->id.us--;
@@ -852,7 +852,7 @@ static void to_edgesort(struct edgesort *ed,
unsigned int v1, unsigned int v2,
short is_loose, short is_draw)
{
- if(v1<v2) {
+ if (v1<v2) {
ed->v1= v1; ed->v2= v2;
}
else {
@@ -866,10 +866,10 @@ static int vergedgesort(const void *v1, const void *v2)
{
const struct edgesort *x1=v1, *x2=v2;
- if( x1->v1 > x2->v1) return 1;
- else if( x1->v1 < x2->v1) return -1;
- else if( x1->v2 > x2->v2) return 1;
- else if( x1->v2 < x2->v2) return -1;
+ if ( x1->v1 > x2->v1) return 1;
+ else if ( x1->v1 < x2->v1) return -1;
+ else if ( x1->v2 > x2->v2) return 1;
+ else if ( x1->v2 < x2->v2) return -1;
return 0;
}
@@ -911,13 +911,13 @@ static void make_edges_mdata(MVert *UNUSED(allvert), MFace *allface, MLoop *alll
/* we put all edges in array, sort them, and detect doubles that way */
- for(a= totface, mface= allface; a>0; a--, mface++) {
- if(mface->v4) totedge+=4;
- else if(mface->v3) totedge+=3;
+ for (a= totface, mface= allface; a>0; a--, mface++) {
+ if (mface->v4) totedge+=4;
+ else if (mface->v3) totedge+=3;
else totedge+=1;
}
- if(totedge==0) {
+ if (totedge==0) {
/* flag that mesh has edges */
(*alledge)= MEM_callocN(0, "make mesh edges");
(*_totedge) = 0;
@@ -926,14 +926,14 @@ static void make_edges_mdata(MVert *UNUSED(allvert), MFace *allface, MLoop *alll
ed= edsort= MEM_mallocN(totedge*sizeof(struct edgesort), "edgesort");
- for(a= totface, mface= allface; a>0; a--, mface++) {
+ for (a= totface, mface= allface; a>0; a--, mface++) {
to_edgesort(ed++, mface->v1, mface->v2, !mface->v3, mface->edcode & ME_V1V2);
- if(mface->v4) {
+ if (mface->v4) {
to_edgesort(ed++, mface->v2, mface->v3, 0, mface->edcode & ME_V2V3);
to_edgesort(ed++, mface->v3, mface->v4, 0, mface->edcode & ME_V3V4);
to_edgesort(ed++, mface->v4, mface->v1, 0, mface->edcode & ME_V4V1);
}
- else if(mface->v3) {
+ else if (mface->v3) {
to_edgesort(ed++, mface->v2, mface->v3, 0, mface->edcode & ME_V2V3);
to_edgesort(ed++, mface->v3, mface->v1, 0, mface->edcode & ME_V3V1);
}
@@ -942,26 +942,26 @@ static void make_edges_mdata(MVert *UNUSED(allvert), MFace *allface, MLoop *alll
qsort(edsort, totedge, sizeof(struct edgesort), vergedgesort);
/* count final amount */
- for(a=totedge, ed=edsort; a>1; a--, ed++) {
+ for (a=totedge, ed=edsort; a>1; a--, ed++) {
/* edge is unique when it differs from next edge, or is last */
- if(ed->v1 != (ed+1)->v1 || ed->v2 != (ed+1)->v2) final++;
+ if (ed->v1 != (ed+1)->v1 || ed->v2 != (ed+1)->v2) final++;
}
final++;
(*alledge)= medge= MEM_callocN(sizeof (MEdge) * final, "make_edges mdge");
(*_totedge)= final;
- for(a=totedge, ed=edsort; a>1; a--, ed++) {
+ for (a=totedge, ed=edsort; a>1; a--, ed++) {
/* edge is unique when it differs from next edge, or is last */
- if(ed->v1 != (ed+1)->v1 || ed->v2 != (ed+1)->v2) {
+ if (ed->v1 != (ed+1)->v1 || ed->v2 != (ed+1)->v2) {
medge->v1= ed->v1;
medge->v2= ed->v2;
- if(old==0 || ed->is_draw) medge->flag= ME_EDGEDRAW|ME_EDGERENDER;
- if(ed->is_loose) medge->flag|= ME_LOOSEEDGE;
+ if (old==0 || ed->is_draw) medge->flag= ME_EDGEDRAW|ME_EDGERENDER;
+ if (ed->is_loose) medge->flag|= ME_LOOSEEDGE;
/* order is swapped so extruding this edge as a surface wont flip face normals
* with cyclic curves */
- if(ed->v1+1 != ed->v2) {
+ if (ed->v1+1 != ed->v2) {
SWAP(unsigned int, medge->v1, medge->v2);
}
medge++;
@@ -975,7 +975,7 @@ static void make_edges_mdata(MVert *UNUSED(allvert), MFace *allface, MLoop *alll
medge->v1= ed->v1;
medge->v2= ed->v2;
medge->flag= ME_EDGEDRAW;
- if(ed->is_loose) medge->flag|= ME_LOOSEEDGE;
+ if (ed->is_loose) medge->flag|= ME_LOOSEEDGE;
medge->flag |= ME_EDGERENDER;
MEM_freeN(edsort);
@@ -1007,7 +1007,7 @@ void make_edges(Mesh *me, int old)
int totedge=0;
make_edges_mdata(me->mvert, me->mface, me->mloop, me->mpoly, me->totvert, me->totface, me->totloop, me->totpoly, old, &medge, &totedge);
- if(totedge==0) {
+ if (totedge==0) {
/* flag that mesh has edges */
me->medge = medge;
me->totedge = 0;
@@ -1064,9 +1064,9 @@ void mball_to_mesh(ListBase *lb, Mesh *me)
int a, *index;
dl= lb->first;
- if(dl==NULL) return;
+ if (dl==NULL) return;
- if(dl->type==DL_INDEX4) {
+ if (dl->type==DL_INDEX4) {
me->totvert= dl->nr;
me->totface= dl->parts;
@@ -1078,7 +1078,7 @@ void mball_to_mesh(ListBase *lb, Mesh *me)
a= dl->nr;
nors= dl->nors;
verts= dl->verts;
- while(a--) {
+ while (a--) {
copy_v3_v3(mvert->co, verts);
normal_float_to_short_v3(mvert->no, nors);
mvert++;
@@ -1088,7 +1088,7 @@ void mball_to_mesh(ListBase *lb, Mesh *me)
a= dl->parts;
index= dl->index;
- while(a--) {
+ while (a--) {
mface->v1= index[0];
mface->v2= index[1];
mface->v3= index[2];
@@ -1148,25 +1148,25 @@ int nurbs_to_mdata_customdb(Object *ob, ListBase *dispbase, MVert **allvert, int
/* count */
dl= dispbase->first;
- while(dl) {
- if(dl->type==DL_SEGM) {
+ while (dl) {
+ if (dl->type==DL_SEGM) {
totvert+= dl->parts*dl->nr;
totedge+= dl->parts*(dl->nr-1);
}
- else if(dl->type==DL_POLY) {
- if(conv_polys) {
+ else if (dl->type==DL_POLY) {
+ if (conv_polys) {
totvert+= dl->parts*dl->nr;
totedge+= dl->parts*dl->nr;
}
}
- else if(dl->type==DL_SURF) {
+ else if (dl->type==DL_SURF) {
int tot;
totvert+= dl->parts*dl->nr;
tot = (dl->parts-1+((dl->flag & DL_CYCL_V)==2))*(dl->nr-1+(dl->flag & DL_CYCL_U));
totvlak += tot;
totloop += tot * 4;
}
- else if(dl->type==DL_INDEX3) {
+ else if (dl->type==DL_INDEX3) {
int tot;
totvert+= dl->nr;
tot = dl->parts;
@@ -1176,7 +1176,7 @@ int nurbs_to_mdata_customdb(Object *ob, ListBase *dispbase, MVert **allvert, int
dl= dl->next;
}
- if(totvert==0) {
+ if (totvert==0) {
/* error("can't convert"); */
/* Make Sure you check ob->data is a curve */
return -1;
@@ -1191,23 +1191,23 @@ int nurbs_to_mdata_customdb(Object *ob, ListBase *dispbase, MVert **allvert, int
vertcount= 0;
dl= dispbase->first;
- while(dl) {
+ while (dl) {
int smooth= dl->rt & CU_SMOOTH ? 1 : 0;
- if(dl->type==DL_SEGM) {
+ if (dl->type==DL_SEGM) {
startvert= vertcount;
a= dl->parts*dl->nr;
data= dl->verts;
- while(a--) {
+ while (a--) {
copy_v3_v3(mvert->co, data);
data+=3;
vertcount++;
mvert++;
}
- for(a=0; a<dl->parts; a++) {
+ for (a=0; a<dl->parts; a++) {
ofs= a*dl->nr;
- for(b=1; b<dl->nr; b++) {
+ for (b=1; b<dl->nr; b++) {
medge->v1= startvert+ofs+b-1;
medge->v2= startvert+ofs+b;
medge->flag = ME_LOOSEEDGE|ME_EDGERENDER;
@@ -1217,23 +1217,23 @@ int nurbs_to_mdata_customdb(Object *ob, ListBase *dispbase, MVert **allvert, int
}
}
- else if(dl->type==DL_POLY) {
- if(conv_polys) {
+ else if (dl->type==DL_POLY) {
+ if (conv_polys) {
startvert= vertcount;
a= dl->parts*dl->nr;
data= dl->verts;
- while(a--) {
+ while (a--) {
copy_v3_v3(mvert->co, data);
data+=3;
vertcount++;
mvert++;
}
- for(a=0; a<dl->parts; a++) {
+ for (a=0; a<dl->parts; a++) {
ofs= a*dl->nr;
- for(b=0; b<dl->nr; b++) {
+ for (b=0; b<dl->nr; b++) {
medge->v1= startvert+ofs+b;
- if(b==dl->nr-1) medge->v2= startvert+ofs;
+ if (b==dl->nr-1) medge->v2= startvert+ofs;
else medge->v2= startvert+ofs+b+1;
medge->flag = ME_LOOSEEDGE|ME_EDGERENDER;
medge++;
@@ -1241,11 +1241,11 @@ int nurbs_to_mdata_customdb(Object *ob, ListBase *dispbase, MVert **allvert, int
}
}
}
- else if(dl->type==DL_INDEX3) {
+ else if (dl->type==DL_INDEX3) {
startvert= vertcount;
a= dl->nr;
data= dl->verts;
- while(a--) {
+ while (a--) {
copy_v3_v3(mvert->co, data);
data+=3;
vertcount++;
@@ -1254,7 +1254,7 @@ int nurbs_to_mdata_customdb(Object *ob, ListBase *dispbase, MVert **allvert, int
a= dl->parts;
index= dl->index;
- while(a--) {
+ while (a--) {
mloop[0].v = startvert+index[0];
mloop[1].v = startvert+index[2];
mloop[2].v = startvert+index[1];
@@ -1262,7 +1262,7 @@ int nurbs_to_mdata_customdb(Object *ob, ListBase *dispbase, MVert **allvert, int
mpoly->totloop = 3;
mpoly->mat_nr = dl->col;
- if(smooth) mpoly->flag |= ME_SMOOTH;
+ if (smooth) mpoly->flag |= ME_SMOOTH;
mpoly++;
mloop+= 3;
index+= 3;
@@ -1270,22 +1270,22 @@ int nurbs_to_mdata_customdb(Object *ob, ListBase *dispbase, MVert **allvert, int
}
- else if(dl->type==DL_SURF) {
+ else if (dl->type==DL_SURF) {
startvert= vertcount;
a= dl->parts*dl->nr;
data= dl->verts;
- while(a--) {
+ while (a--) {
copy_v3_v3(mvert->co, data);
data+=3;
vertcount++;
mvert++;
}
- for(a=0; a<dl->parts; a++) {
+ for (a=0; a<dl->parts; a++) {
- if( (dl->flag & DL_CYCL_V)==0 && a==dl->parts-1) break;
+ if ( (dl->flag & DL_CYCL_V)==0 && a==dl->parts-1) break;
- if(dl->flag & DL_CYCL_U) { /* p2 -> p1 -> */
+ if (dl->flag & DL_CYCL_U) { /* p2 -> p1 -> */
p1= startvert+ dl->nr*a; /* p4 -> p3 -> */
p2= p1+ dl->nr-1; /* -----> next row */
p3= p1+ dl->nr;
@@ -1299,12 +1299,12 @@ int nurbs_to_mdata_customdb(Object *ob, ListBase *dispbase, MVert **allvert, int
p3= p1+ dl->nr;
b= 1;
}
- if( (dl->flag & DL_CYCL_V) && a==dl->parts-1) {
+ if ( (dl->flag & DL_CYCL_V) && a==dl->parts-1) {
p3-= dl->parts*dl->nr;
p4-= dl->parts*dl->nr;
}
- for(; b<dl->nr; b++) {
+ for (; b<dl->nr; b++) {
mloop[0].v= p1;
mloop[1].v= p3;
mloop[2].v= p4;
@@ -1313,7 +1313,7 @@ int nurbs_to_mdata_customdb(Object *ob, ListBase *dispbase, MVert **allvert, int
mpoly->totloop = 4;
mpoly->mat_nr = dl->col;
- if(smooth) mpoly->flag |= ME_SMOOTH;
+ if (smooth) mpoly->flag |= ME_SMOOTH;
mpoly++;
mloop+= 4;
@@ -1393,7 +1393,7 @@ void nurbs_to_mesh(Object *ob)
cu->mat= NULL;
cu->totcol= 0;
- if(ob->data) {
+ if (ob->data) {
free_libblock(&bmain->curve, ob->data);
}
ob->data= me;
@@ -1401,8 +1401,8 @@ void nurbs_to_mesh(Object *ob)
/* other users */
ob1= bmain->object.first;
- while(ob1) {
- if(ob1->data==cu) {
+ while (ob1) {
+ if (ob1->data==cu) {
ob1->type= OB_MESH;
ob1->data= ob->data;
@@ -1477,7 +1477,7 @@ void mesh_to_curve(Scene *scene, Object *ob)
}
med= medge;
- for(i=0; i<totedge; i++, med++) {
+ for (i=0; i<totedge; i++, med++) {
if (!BLI_edgehash_haskey(eh, med->v1, med->v2)) {
EdgeLink *edl= MEM_callocN(sizeof(EdgeLink), "EdgeLink");
@@ -1490,11 +1490,11 @@ void mesh_to_curve(Scene *scene, Object *ob)
BLI_edgehash_free(eh_edge, NULL);
BLI_edgehash_free(eh, NULL);
- if(edges.first) {
+ if (edges.first) {
Curve *cu = add_curve(ob->id.name+2, OB_CURVE);
cu->flag |= CU_3D;
- while(edges.first) {
+ while (edges.first) {
/* each iteration find a polyline and add this as a nurbs poly spline */
ListBase polyline = {NULL, NULL}; /* store a list of VertLink's */
@@ -1509,35 +1509,35 @@ void mesh_to_curve(Scene *scene, Object *ob)
appendPolyLineVert(&polyline, endVert); totpoly++;
BLI_freelinkN(&edges, edges.last); totedges--;
- while(ok) { /* while connected edges are found... */
+ while (ok) { /* while connected edges are found... */
ok = FALSE;
i= totedges;
- while(i) {
+ while (i) {
EdgeLink *edl;
i-=1;
edl= BLI_findlink(&edges, i);
med= edl->edge;
- if(med->v1==endVert) {
+ if (med->v1==endVert) {
endVert = med->v2;
appendPolyLineVert(&polyline, med->v2); totpoly++;
BLI_freelinkN(&edges, edl); totedges--;
ok= TRUE;
}
- else if(med->v2==endVert) {
+ else if (med->v2==endVert) {
endVert = med->v1;
appendPolyLineVert(&polyline, endVert); totpoly++;
BLI_freelinkN(&edges, edl); totedges--;
ok= TRUE;
}
- else if(med->v1==startVert) {
+ else if (med->v1==startVert) {
startVert = med->v2;
prependPolyLineVert(&polyline, startVert); totpoly++;
BLI_freelinkN(&edges, edl); totedges--;
ok= TRUE;
}
- else if(med->v2==startVert) {
+ else if (med->v2==startVert) {
startVert = med->v1;
prependPolyLineVert(&polyline, startVert); totpoly++;
BLI_freelinkN(&edges, edl); totedges--;
@@ -1547,7 +1547,7 @@ void mesh_to_curve(Scene *scene, Object *ob)
}
/* Now we have a polyline, make into a curve */
- if(startVert==endVert) {
+ if (startVert==endVert) {
BLI_freelinkN(&polyline, polyline.last);
totpoly--;
closed = TRUE;
@@ -1600,7 +1600,7 @@ void mesh_to_curve(Scene *scene, Object *ob)
ob->derivedFinal = NULL;
/* curve object could have got bounding box only in special cases */
- if(ob->bb) {
+ if (ob->bb) {
MEM_freeN(ob->bb);
ob->bb= NULL;
}
@@ -1767,11 +1767,11 @@ void mesh_calc_normals(MVert *mverts, int numVerts, MLoop *mloop, MPoly *mpolys,
BLI_array_free(edgevecbuf);
/* following Mesh convention; we use vertex coordinate itself for normal in this case */
- for(i=0; i<numVerts; i++) {
+ for (i=0; i<numVerts; i++) {
MVert *mv= &mverts[i];
float *no= tnorms[i];
- if(normalize_v3(no) == 0.0f)
+ if (normalize_v3(no) == 0.0f)
normalize_v3_v3(no, mv->co);
normal_float_to_short_v3(mv->no, no);
@@ -1788,13 +1788,13 @@ void mesh_calc_normals_tessface(MVert *mverts, int numVerts, MFace *mfaces, int
float (*fnors)[3]= (faceNors_r)? faceNors_r: MEM_callocN(sizeof(*fnors)*numFaces, "meshnormals");
int i;
- for(i=0; i<numFaces; i++) {
+ for (i=0; i<numFaces; i++) {
MFace *mf= &mfaces[i];
float *f_no= fnors[i];
float *n4 = (mf->v4)? tnorms[mf->v4]: NULL;
float *c4 = (mf->v4)? mverts[mf->v4].co: NULL;
- if(mf->v4)
+ if (mf->v4)
normal_quad_v3(f_no, mverts[mf->v1].co, mverts[mf->v2].co, mverts[mf->v3].co, mverts[mf->v4].co);
else
normal_tri_v3(f_no, mverts[mf->v1].co, mverts[mf->v2].co, mverts[mf->v3].co);
@@ -1804,11 +1804,11 @@ void mesh_calc_normals_tessface(MVert *mverts, int numVerts, MFace *mfaces, int
}
/* following Mesh convention; we use vertex coordinate itself for normal in this case */
- for(i=0; i<numVerts; i++) {
+ for (i=0; i<numVerts; i++) {
MVert *mv= &mverts[i];
float *no= tnorms[i];
- if(normalize_v3(no) == 0.0f)
+ if (normalize_v3(no) == 0.0f)
normalize_v3_v3(no, mv->co);
normal_float_to_short_v3(mv->no, no);
@@ -1816,7 +1816,7 @@ void mesh_calc_normals_tessface(MVert *mverts, int numVerts, MFace *mfaces, int
MEM_freeN(tnorms);
- if(fnors != faceNors_r)
+ if (fnors != faceNors_r)
MEM_freeN(fnors);
}
@@ -1833,7 +1833,7 @@ static void bmesh_corners_to_loops(Mesh *me, int findex, int loopstart, int numT
mf = me->mface + findex;
- for(i=0; i < numTex; i++){
+ for (i=0; i < numTex; i++) {
texface = CustomData_get_n(&me->fdata, CD_MTFACE, findex, i);
texpoly = CustomData_get_n(&me->pdata, CD_MTEXPOLY, findex, i);
@@ -1849,7 +1849,7 @@ static void bmesh_corners_to_loops(Mesh *me, int findex, int loopstart, int numT
}
}
- for(i=0; i < numCol; i++){
+ for (i=0; i < numCol; i++) {
mloopcol = CustomData_get_n(&me->ldata, CD_MLOOPCOL, loopstart, i);
mcol = CustomData_get_n(&me->fdata, CD_MCOL, findex, i);
@@ -1997,11 +1997,11 @@ UvVertMap *make_uv_vert_map(struct MPoly *mpoly, struct MLoop *mloop, struct MLo
/* generate UvMapVert array */
mp= mpoly;
- for(a=0; a<totpoly; a++, mp++)
- if(!selected || (!(mp->flag & ME_HIDE) && (mp->flag & ME_FACE_SEL)))
+ for (a=0; a<totpoly; a++, mp++)
+ if (!selected || (!(mp->flag & ME_HIDE) && (mp->flag & ME_FACE_SEL)))
totuv += mp->totloop;
- if(totuv==0)
+ if (totuv==0)
return NULL;
vmap= (UvVertMap*)MEM_callocN(sizeof(*vmap), "UvVertMap");
@@ -2017,11 +2017,11 @@ UvVertMap *make_uv_vert_map(struct MPoly *mpoly, struct MLoop *mloop, struct MLo
}
mp= mpoly;
- for(a=0; a<totpoly; a++, mp++) {
- if(!selected || (!(mp->flag & ME_HIDE) && (mp->flag & ME_FACE_SEL))) {
+ for (a=0; a<totpoly; a++, mp++) {
+ if (!selected || (!(mp->flag & ME_HIDE) && (mp->flag & ME_FACE_SEL))) {
nverts= mp->totloop;
- for(i=0; i<nverts; i++) {
+ for (i=0; i<nverts; i++) {
buf->tfindex= i;
buf->f= a;
buf->separate = 0;
@@ -2033,12 +2033,12 @@ UvVertMap *make_uv_vert_map(struct MPoly *mpoly, struct MLoop *mloop, struct MLo
}
/* sort individual uvs for each vert */
- for(a=0; a<totvert; a++) {
+ for (a=0; a<totvert; a++) {
UvMapVert *newvlist= NULL, *vlist=vmap->vert[a];
UvMapVert *iterv, *v, *lastv, *next;
float *uv, *uv2, uvdiff[2];
- while(vlist) {
+ while (vlist) {
v= vlist;
vlist= vlist->next;
v->next= newvlist;
@@ -2048,15 +2048,15 @@ UvVertMap *make_uv_vert_map(struct MPoly *mpoly, struct MLoop *mloop, struct MLo
lastv= NULL;
iterv= vlist;
- while(iterv) {
+ while (iterv) {
next= iterv->next;
uv2= mloopuv[mpoly[iterv->f].loopstart + iterv->tfindex].uv;
sub_v2_v2v2(uvdiff, uv2, uv);
- if(fabsf(uv[0]-uv2[0]) < limit[0] && fabsf(uv[1]-uv2[1]) < limit[1]) {
- if(lastv) lastv->next= next;
+ if (fabsf(uv[0]-uv2[0]) < limit[0] && fabsf(uv[1]-uv2[1]) < limit[1]) {
+ if (lastv) lastv->next= next;
else vlist= next;
iterv->next= newvlist;
newvlist= iterv;
@@ -2107,9 +2107,9 @@ void create_vert_poly_map(ListBase **map, IndexNode **mem,
node = *mem;
/* Find the users */
- for(i = 0, mp = mpoly; i < totpoly; ++i, ++mp){
+ for (i = 0, mp = mpoly; i < totpoly; ++i, ++mp) {
ml = &mloop[mp->loopstart];
- for(j = 0; j < mp->totloop; ++j, ++node, ++ml) {
+ for (j = 0; j < mp->totloop; ++j, ++node, ++ml) {
node->index = i;
BLI_addtail(&(*map)[ml->v], node);
}
@@ -2129,8 +2129,8 @@ void create_vert_face_map(ListBase **map, IndexNode **mem, const MFace *mface, c
node = *mem;
/* Find the users */
- for(i = 0; i < totface; ++i){
- for(j = 0; j < (mface[i].v4?4:3); ++j, ++node) {
+ for (i = 0; i < totface; ++i) {
+ for (j = 0; j < (mface[i].v4?4:3); ++j, ++node) {
node->index = i;
BLI_addtail(&(*map)[((unsigned int*)(&mface[i]))[j]], node);
}
@@ -2150,8 +2150,8 @@ void create_vert_edge_map(ListBase **map, IndexNode **mem, const MEdge *medge, c
node = *mem;
/* Find the users */
- for(i = 0; i < totedge; ++i){
- for(j = 0; j < 2; ++j, ++node) {
+ for (i = 0; i < totedge; ++i) {
+ for (j = 0; j < 2; ++j, ++node) {
node->index = i;
BLI_addtail(&(*map)[((unsigned int*)(&medge[i].v1))[j]], node);
}
@@ -2177,7 +2177,7 @@ void mesh_loops_to_mface_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);
@@ -2189,7 +2189,7 @@ void mesh_loops_to_mface_corners(CustomData *fdata, CustomData *ldata,
}
}
- for(i=0; i < numCol; i++){
+ for (i=0; i < numCol; i++) {
mcol = CustomData_get_n(fdata, CD_MCOL, findex, i);
for (j=0; j < mf_len; j++) {
@@ -2636,7 +2636,7 @@ static void mesh_calc_ngon_normal(MPoly *mpoly, MLoop *loopstart,
double n[3] = {0.0, 0.0, 0.0}, l;
int i;
- for(i = 0; i < mpoly->totloop; i++){
+ for (i = 0; i < mpoly->totloop; i++) {
v1 = mvert + loopstart[i].v;
v2 = mvert + loopstart[(i+1)%mpoly->totloop].v;
v3 = mvert + loopstart[(i+2)%mpoly->totloop].v;
@@ -2695,7 +2695,7 @@ void mesh_calc_poly_normal(MPoly *mpoly, MLoop *loopstart,
if (mpoly->totloop > 4) {
mesh_calc_ngon_normal(mpoly, loopstart, mvarray, no);
}
- else if (mpoly->totloop == 3){
+ else if (mpoly->totloop == 3) {
normal_tri_v3(no,
mvarray[loopstart[0].v].co,
mvarray[loopstart[1].v].co,
@@ -2726,7 +2726,7 @@ static void mesh_calc_ngon_normal_coords(MPoly *mpoly, MLoop *loopstart,
double n[3] = {0.0, 0.0, 0.0}, l;
int i;
- for(i = 0; i < mpoly->totloop; i++){
+ for (i = 0; i < mpoly->totloop; i++) {
v1 = (const float *)(vertex_coords + loopstart[i].v);
v2 = (const float *)(vertex_coords + loopstart[(i+1)%mpoly->totloop].v);
v3 = (const float *)(vertex_coords + loopstart[(i+2)%mpoly->totloop].v);
@@ -2773,7 +2773,7 @@ void mesh_calc_poly_normal_coords(MPoly *mpoly, MLoop *loopstart,
if (mpoly->totloop > 4) {
mesh_calc_ngon_normal_coords(mpoly, loopstart, vertex_coords, no);
}
- else if (mpoly->totloop == 3){
+ else if (mpoly->totloop == 3) {
normal_tri_v3(no,
vertex_coords[loopstart[0].v],
vertex_coords[loopstart[1].v],
@@ -2879,7 +2879,7 @@ int minmax_mesh(Mesh *me, float min[3], float max[3])
{
int i= me->totvert;
MVert *mvert;
- for(mvert= me->mvert; i--; mvert++) {
+ for (mvert= me->mvert; i--; mvert++) {
DO_MINMAX(mvert->co, min, max);
}
@@ -2891,11 +2891,11 @@ int mesh_center_median(Mesh *me, float cent[3])
int i= me->totvert;
MVert *mvert;
zero_v3(cent);
- for(mvert= me->mvert; i--; mvert++) {
+ for (mvert= me->mvert; i--; mvert++) {
add_v3_v3(cent, mvert->co);
}
/* otherwise we get NAN for 0 verts */
- if(me->totvert) {
+ if (me->totvert) {
mul_v3_fl(cent, 1.0f/(float)me->totvert);
}
@@ -2906,7 +2906,7 @@ int mesh_center_bounds(Mesh *me, float cent[3])
{
float min[3], max[3];
INIT_MINMAX(min, max);
- if(minmax_mesh(me, min, max)) {
+ if (minmax_mesh(me, min, max)) {
mid_v3_v3v3(cent, min, max);
return 1;
}
@@ -2918,7 +2918,7 @@ void mesh_translate(Mesh *me, float offset[3], int do_keys)
{
int i= me->totvert;
MVert *mvert;
- for(mvert= me->mvert; i--; mvert++) {
+ for (mvert= me->mvert; i--; mvert++) {
add_v3_v3(mvert->co, offset);
}
diff --git a/source/blender/blenkernel/intern/mesh_validate.c b/source/blender/blenkernel/intern/mesh_validate.c
index 92f7f959f8a..0f6fedb0b08 100644
--- a/source/blender/blenkernel/intern/mesh_validate.c
+++ b/source/blender/blenkernel/intern/mesh_validate.c
@@ -208,7 +208,7 @@ int BKE_mesh_validate_arrays( Mesh *me,
remove= do_fixes;
}
- if(remove == FALSE){
+ if(remove == FALSE) {
BLI_edgehash_insert(edge_hash, med->v1, med->v2, SET_INT_IN_POINTER(i));
}
else {
diff --git a/source/blender/blenkernel/intern/multires.c b/source/blender/blenkernel/intern/multires.c
index dbac2e756a5..a0f440c10c0 100644
--- a/source/blender/blenkernel/intern/multires.c
+++ b/source/blender/blenkernel/intern/multires.c
@@ -88,8 +88,8 @@ MultiresModifierData *find_multires_modifier_before(Scene *scene, ModifierData *
{
ModifierData *md;
- for(md = lastmd; md; md = md->prev) {
- if(md->type == eModifierType_Multires) {
+ for (md = lastmd; md; md = md->prev) {
+ if (md->type == eModifierType_Multires) {
if (modifier_isEnabled(scene, md, eModifierMode_Realtime))
return (MultiresModifierData*)md;
}
@@ -107,9 +107,9 @@ MultiresModifierData *get_multires_modifier(Scene *scene, Object *ob, int use_fi
MultiresModifierData *mmd= NULL, *firstmmd= NULL;
/* find first active multires modifier */
- for(md = ob->modifiers.first; md; md = md->next) {
- if(md->type == eModifierType_Multires) {
- if(!firstmmd)
+ for (md = ob->modifiers.first; md; md = md->next) {
+ if (md->type == eModifierType_Multires) {
+ if (!firstmmd)
firstmmd= (MultiresModifierData*)md;
if (modifier_isEnabled(scene, md, eModifierMode_Realtime)) {
@@ -119,7 +119,7 @@ MultiresModifierData *get_multires_modifier(Scene *scene, Object *ob, int use_fi
}
}
- if(!mmd && use_first) {
+ if (!mmd && use_first) {
/* active multires have not been found
try to use first one */
return firstmmd;
@@ -130,9 +130,9 @@ MultiresModifierData *get_multires_modifier(Scene *scene, Object *ob, int use_fi
static int multires_get_level(Object *ob, MultiresModifierData *mmd, int render)
{
- if(render)
+ if (render)
return (mmd->modifier.scene)? get_render_subsurf_level(&mmd->modifier.scene->r, mmd->renderlvl): mmd->renderlvl;
- else if(ob->mode == OB_MODE_SCULPT)
+ else if (ob->mode == OB_MODE_SCULPT)
return mmd->sculptlvl;
else
return (mmd->modifier.scene)? get_render_subsurf_level(&mmd->modifier.scene->r, mmd->lvl): mmd->lvl;
@@ -142,7 +142,7 @@ static void multires_set_tot_level(Object *ob, MultiresModifierData *mmd, int lv
{
mmd->totlvl = lvl;
- if(ob->mode != OB_MODE_SCULPT)
+ if (ob->mode != OB_MODE_SCULPT)
mmd->lvl = CLAMPIS(MAX2(mmd->lvl, lvl), 0, mmd->totlvl);
mmd->sculptlvl = CLAMPIS(MAX2(mmd->sculptlvl, lvl), 0, mmd->totlvl);
@@ -157,19 +157,19 @@ static void multires_dm_mark_as_modified(DerivedMesh *dm)
void multires_mark_as_modified(Object *ob)
{
- if(ob && ob->derivedFinal)
+ if (ob && ob->derivedFinal)
multires_dm_mark_as_modified(ob->derivedFinal);
}
void multires_force_update(Object *ob)
{
- if(ob) {
- if(ob->derivedFinal) {
+ if (ob) {
+ if (ob->derivedFinal) {
ob->derivedFinal->needsFree =1;
ob->derivedFinal->release(ob->derivedFinal);
ob->derivedFinal = NULL;
}
- if(ob->sculpt && ob->sculpt->pbvh) {
+ if (ob->sculpt && ob->sculpt->pbvh) {
BLI_pbvh_free(ob->sculpt->pbvh);
ob->sculpt->pbvh= NULL;
}
@@ -186,7 +186,7 @@ void multires_force_external_reload(Object *ob)
void multires_force_render_update(Object *ob)
{
- if(ob && (ob->mode & OB_MODE_SCULPT) && modifiers_findByType(ob, eModifierType_Multires))
+ if (ob && (ob->mode & OB_MODE_SCULPT) && modifiers_findByType(ob, eModifierType_Multires))
multires_force_update(ob);
}
@@ -195,7 +195,7 @@ int multiresModifier_reshapeFromDM(Scene *scene, MultiresModifierData *mmd,
{
DerivedMesh *mrdm = get_multires_dm (scene, mmd, ob);
- if(mrdm && srcdm && mrdm->getNumVerts(mrdm) == srcdm->getNumVerts(srcdm)) {
+ if (mrdm && srcdm && mrdm->getNumVerts(mrdm) == srcdm->getNumVerts(srcdm)) {
multires_mvert_to_ss(mrdm, srcdm->getVertArray(srcdm));
multires_dm_mark_as_modified(mrdm);
@@ -206,7 +206,7 @@ int multiresModifier_reshapeFromDM(Scene *scene, MultiresModifierData *mmd,
return 1;
}
- if(mrdm) mrdm->release(mrdm);
+ if (mrdm) mrdm->release(mrdm);
return 0;
}
@@ -226,7 +226,7 @@ int multiresModifier_reshapeFromDeformMod(Scene *scene, MultiresModifierData *mm
int numVerts, result;
float (*deformedVerts)[3];
- if(multires_get_level(ob, mmd, 0) == 0)
+ if (multires_get_level(ob, mmd, 0) == 0)
return 0;
/* Create DerivedMesh for deformation modifier */
@@ -261,19 +261,19 @@ static int get_levels_from_disps(Object *ob)
mdisp = CustomData_get_layer(&me->ldata, CD_MDISPS);
- for(i = 0; i < me->totpoly; ++i) {
+ for (i = 0; i < me->totpoly; ++i) {
int S = me->mpoly[i].totloop;
md = mdisp + me->mpoly[i].loopstart;
for (j=0; j<me->mpoly[i].totloop; j++, md++) {
- if(md->totdisp == 0) continue;
+ if (md->totdisp == 0) continue;
- while(1) {
+ while (1) {
int side = (1 << (totlvl-1)) + 1;
int lvl_totdisp = side*side*S;
- if(md->totdisp == lvl_totdisp)
+ if (md->totdisp == lvl_totdisp)
break;
- else if(md->totdisp < lvl_totdisp)
+ else if (md->totdisp < lvl_totdisp)
--totlvl;
else
++totlvl;
@@ -293,12 +293,12 @@ void multiresModifier_set_levels_from_disps(MultiresModifierData *mmd, Object *o
Mesh *me = ob->data;
MDisps *mdisp;
- if(me->edit_btmesh)
+ if (me->edit_btmesh)
mdisp = CustomData_get_layer(&me->edit_btmesh->bm->ldata, CD_MDISPS);
else
mdisp = CustomData_get_layer(&me->ldata, CD_MDISPS);
- if(mdisp) {
+ if (mdisp) {
mmd->totlvl = get_levels_from_disps(ob);
mmd->lvl = MIN2(mmd->sculptlvl, mmd->totlvl);
mmd->sculptlvl = MIN2(mmd->sculptlvl, mmd->totlvl);
@@ -311,8 +311,8 @@ static void multires_set_tot_mdisps(Mesh *me, int lvl)
MDisps *mdisps= CustomData_get_layer(&me->ldata, CD_MDISPS);
int i;
- if(mdisps) {
- for(i = 0; i < me->totloop; i++, mdisps++) {
+ if (mdisps) {
+ for (i = 0; i < me->totloop; i++, mdisps++) {
mdisps->totdisp = multires_grid_tot[lvl];
}
}
@@ -323,11 +323,11 @@ static void multires_reallocate_mdisps(int totloop, MDisps *mdisps, int lvl)
int i;
/* reallocate displacements to be filled in */
- for(i = 0; i < totloop; ++i) {
+ for (i = 0; i < totloop; ++i) {
int totdisp = multires_grid_tot[lvl];
float (*disps)[3] = MEM_callocN(sizeof(float) * 3 * totdisp, "multires disps");
- if(mdisps[i].disps)
+ if (mdisps[i].disps)
MEM_freeN(mdisps[i].disps);
mdisps[i].disps = disps;
@@ -346,18 +346,18 @@ static void multires_copy_grid(float (*gridA)[3], float (*gridB)[3], int sizeA,
{
int x, y, j, skip;
- if(sizeA > sizeB) {
+ if (sizeA > sizeB) {
skip = (sizeA-1)/(sizeB-1);
- for(j = 0, y = 0; y < sizeB; y++)
- for(x = 0; x < sizeB; x++, j++)
+ for (j = 0, y = 0; y < sizeB; y++)
+ for (x = 0; x < sizeB; x++, j++)
copy_v3_v3(gridA[y*skip*sizeA + x*skip], gridB[j]);
}
else {
skip = (sizeB-1)/(sizeA-1);
- for(j = 0, y = 0; y < sizeA; y++)
- for(x = 0; x < sizeA; x++, j++)
+ for (j = 0, y = 0; y < sizeA; y++)
+ for (x = 0; x < sizeA; x++, j++)
copy_v3_v3(gridA[j], gridB[y*skip*sizeB + x*skip]);
}
}
@@ -366,18 +366,18 @@ static void multires_copy_dm_grid(DMGridData *gridA, DMGridData *gridB, int size
{
int x, y, j, skip;
- if(sizeA > sizeB) {
+ if (sizeA > sizeB) {
skip = (sizeA-1)/(sizeB-1);
- for(j = 0, y = 0; y < sizeB; y++)
- for(x = 0; x < sizeB; x++, j++)
+ for (j = 0, y = 0; y < sizeB; y++)
+ for (x = 0; x < sizeB; x++, j++)
copy_v3_v3(gridA[y*skip*sizeA + x*skip].co, gridB[j].co);
}
else {
skip = (sizeB-1)/(sizeA-1);
- for(j = 0, y = 0; y < sizeA; y++)
- for(x = 0; x < sizeA; x++, j++)
+ for (j = 0, y = 0; y < sizeA; y++)
+ for (x = 0; x < sizeA; x++, j++)
copy_v3_v3(gridA[j].co, gridB[y*skip*sizeB + x*skip].co);
}
}
@@ -394,14 +394,14 @@ static void multires_del_higher(MultiresModifierData *mmd, Object *ob, int lvl)
multires_force_update(ob);
- if(mdisps && levels > 0) {
- if(lvl > 0) {
+ if (mdisps && levels > 0) {
+ if (lvl > 0) {
/* MLoop *ml = me->mloop; */ /*UNUSED*/
int nsize = multires_side_tot[lvl];
int hsize = multires_side_tot[mmd->totlvl];
int i, j;
- for(i = 0; i < me->totpoly; ++i) {
+ for (i = 0; i < me->totpoly; ++i) {
for (j=0; j<me->mpoly[i].totloop; j++) {
MDisps *mdisp= &mdisps[me->mpoly[i].loopstart+j];
float (*disps)[3], (*ndisps)[3], (*hdisps)[3];
@@ -446,7 +446,7 @@ void multiresModifier_del_levels(MultiresModifierData *mmd, Object *ob, int dire
multires_force_update(ob);
- if(mdisps && levels > 0 && direction == 1) {
+ if (mdisps && levels > 0 && direction == 1) {
multires_del_higher(mmd, ob, lvl);
}
@@ -471,11 +471,11 @@ static DerivedMesh *subsurf_dm_create_local(Object *ob, DerivedMesh *dm, int lvl
SubsurfModifierData smd= {{NULL}};
smd.levels = smd.renderLevels = lvl;
- if(!plain_uv)
+ if (!plain_uv)
smd.flags |= eSubsurfModifierFlag_SubsurfUv;
- if(simple)
+ if (simple)
smd.subdivType = ME_SIMPLE_SUBSURF;
- if(optimal)
+ if (optimal)
smd.flags |= eSubsurfModifierFlag_ControlEdges;
return subsurf_make_derived_from_derived(dm, &smd, 0, NULL, 0, 0, (ob->mode & OB_MODE_EDIT));
@@ -506,7 +506,7 @@ void multiresModifier_base_apply(MultiresModifierData *mmd, Object *ob)
totlvl = mmd->totlvl;
/* nothing to do */
- if(!totlvl)
+ if (!totlvl)
return;
/* XXX - probably not necessary to regenerate the cddm so much? */
@@ -519,7 +519,7 @@ void multiresModifier_base_apply(MultiresModifierData *mmd, Object *ob)
/* copy the new locations of the base verts into the mesh */
offset = dispdm->getNumVerts(dispdm) - me->totvert;
- for(i = 0; i < me->totvert; ++i) {
+ for (i = 0; i < me->totvert; ++i) {
dispdm->getVertCo(dispdm, offset + i, me->mvert[i].co);
}
@@ -528,28 +528,28 @@ void multiresModifier_base_apply(MultiresModifierData *mmd, Object *ob)
cddm = CDDM_from_mesh(me, NULL);
fmap = cddm->getFaceMap(ob, cddm);
origco = MEM_callocN(sizeof(float)*3*me->totvert, "multires apply base origco");
- for(i = 0; i < me->totvert ;++i)
+ for (i = 0; i < me->totvert ;++i)
copy_v3_v3(origco[i], me->mvert[i].co);
- for(i = 0; i < me->totvert; ++i) {
+ for (i = 0; i < me->totvert; ++i) {
IndexNode *n;
float avg_no[3] = {0,0,0}, center[3] = {0,0,0}, push[3];
float dist;
int tot;
/* don't adjust verts not used by at least one face */
- if(!fmap[i].first)
+ if (!fmap[i].first)
continue;
/* find center */
- for(n = fmap[i].first, tot = 0; n; n = n->next) {
+ for (n = fmap[i].first, tot = 0; n; n = n->next) {
MFace *f = &me->mface[n->index];
int S = f->v4 ? 4 : 3;
/* this double counts, not sure if that's bad or good */
- for(j = 0; j < S; ++j) {
+ for (j = 0; j < S; ++j) {
int vndx = (&f->v1)[j];
- if(vndx != i) {
+ if (vndx != i) {
add_v3_v3(center, origco[vndx]);
++tot;
}
@@ -558,20 +558,20 @@ void multiresModifier_base_apply(MultiresModifierData *mmd, Object *ob)
mul_v3_fl(center, 1.0f / tot);
/* find normal */
- for(n = fmap[i].first; n; n = n->next) {
+ for (n = fmap[i].first; n; n = n->next) {
MFace *f = &me->mface[n->index];
int S = f->v4 ? 4 : 3;
float v[4][3], no[3];
- for(j = 0; j < S; ++j) {
+ for (j = 0; j < S; ++j) {
int vndx = (&f->v1)[j];
- if(vndx == i)
+ if (vndx == i)
copy_v3_v3(v[j], center);
else
copy_v3_v3(v[j], origco[vndx]);
}
- if(S == 4)
+ if (S == 4)
normal_quad_v3(no, v[0], v[1], v[2], v[3]);
else
normal_tri_v3(no, v[0], v[1], v[2]);
@@ -609,16 +609,16 @@ static void multires_subdivide(MultiresModifierData *mmd, Object *ob, int totlvl
MDisps *mdisps;
int lvl= mmd->totlvl;
- if(totlvl > multires_max_levels)
+ if (totlvl > multires_max_levels)
return;
multires_force_update(ob);
mdisps = CustomData_get_layer(&me->ldata, CD_MDISPS);
- if(!mdisps)
+ if (!mdisps)
mdisps = CustomData_add_layer(&me->ldata, CD_MDISPS, CD_DEFAULT, NULL, me->totloop);
- if(mdisps->disps && !updateblock && totlvl > 1) {
+ if (mdisps->disps && !updateblock && totlvl > 1) {
/* upsample */
DerivedMesh *lowdm, *cddm, *highdm;
DMGridData **highGridData, **lowGridData, **subGridData;
@@ -643,7 +643,7 @@ static void multires_subdivide(MultiresModifierData *mmd, Object *ob, int totlvl
subGridData = MEM_callocN(sizeof(float*)*numGrids, "subGridData*");
- for(i = 0; i < numGrids; ++i) {
+ for (i = 0; i < numGrids; ++i) {
/* backup subsurf grids */
subGridData[i] = MEM_callocN(sizeof(DMGridData)*highGridSize*highGridSize, "subGridData");
memcpy(subGridData[i], highGridData[i], sizeof(DMGridData)*highGridSize*highGridSize);
@@ -668,7 +668,7 @@ static void multires_subdivide(MultiresModifierData *mmd, Object *ob, int totlvl
/* free */
highdm->release(highdm);
- for(i = 0; i < numGrids; ++i)
+ for (i = 0; i < numGrids; ++i)
MEM_freeN(subGridData[i]);
MEM_freeN(subGridData);
}
@@ -687,9 +687,9 @@ void multiresModifier_subdivide(MultiresModifierData *mmd, Object *ob, int updat
void grid_tangent(int gridSize, int index, int x, int y, int axis, DMGridData **gridData, float t[3])
{
- if(axis == 0) {
- if(x == gridSize - 1) {
- if(y == gridSize - 1)
+ if (axis == 0) {
+ if (x == gridSize - 1) {
+ if (y == gridSize - 1)
sub_v3_v3v3(t, gridData[index][x + gridSize*(y - 1)].co, gridData[index][x - 1 + gridSize*(y - 1)].co);
else
sub_v3_v3v3(t, gridData[index][x + gridSize*y].co, gridData[index][x - 1 + gridSize*y].co);
@@ -697,9 +697,9 @@ void grid_tangent(int gridSize, int index, int x, int y, int axis, DMGridData **
else
sub_v3_v3v3(t, gridData[index][x + 1 + gridSize*y].co, gridData[index][x + gridSize*y].co);
}
- else if(axis == 1) {
- if(y == gridSize - 1) {
- if(x == gridSize - 1)
+ else if (axis == 1) {
+ if (y == gridSize - 1) {
+ if (x == gridSize - 1)
sub_v3_v3v3(t, gridData[index][x - 1 + gridSize*y].co, gridData[index][x - 1 + gridSize*(y - 1)].co);
else
sub_v3_v3v3(t, gridData[index][x + gridSize*y].co, gridData[index][x + gridSize*(y - 1)].co);
@@ -725,13 +725,14 @@ static void multiresModifier_disp_run(DerivedMesh *dm, Mesh *me, DerivedMesh *dm
mdisps = CustomData_get_layer(&dm2->loopData, CD_MDISPS);
totloop = dm2->numLoopData;
totpoly = dm2->numPolyData;
- } else {
+ }
+ else {
totloop = me->totloop;
totpoly = me->totpoly;
}
- if(!mdisps) {
- if(invert)
+ if (!mdisps) {
+ if (invert)
mdisps = CustomData_add_layer(&me->ldata, CD_MDISPS, CD_DEFAULT, NULL, me->totloop);
else
return;
@@ -748,20 +749,20 @@ static void multiresModifier_disp_run(DerivedMesh *dm, Mesh *me, DerivedMesh *dm
k = 0; /*current loop/mdisp index within the mloop array*/
- #pragma omp parallel for private(i) if(totloop*gridSize*gridSize >= CCG_OMP_LIMIT)
+ #pragma omp parallel for private(i) if (totloop*gridSize*gridSize >= CCG_OMP_LIMIT)
- for(i = 0; i < totpoly; ++i) {
+ for (i = 0; i < totpoly; ++i) {
const int numVerts = mpoly[i].totloop;
int S, x, y, gIndex = gridOffset[i];
- for(S = 0; S < numVerts; ++S, ++gIndex, ++k) {
+ for (S = 0; S < numVerts; ++S, ++gIndex, ++k) {
MDisps *mdisp = &mdisps[mpoly[i].loopstart+S];
DMGridData *grid = gridData[gIndex];
DMGridData *subgrid = subGridData[gIndex];
float (*dispgrid)[3] = NULL;
/* when adding new faces in edit mode, need to allocate disps */
- if(!mdisp->disps)
+ if (!mdisp->disps)
#pragma omp critical
{
multires_reallocate_mdisps(totloop, mdisps, totlvl);
@@ -769,8 +770,8 @@ static void multiresModifier_disp_run(DerivedMesh *dm, Mesh *me, DerivedMesh *dm
dispgrid = mdisp->disps;
- for(y = 0; y < gridSize; y++) {
- for(x = 0; x < gridSize; x++) {
+ for (y = 0; y < gridSize; y++) {
+ for (x = 0; x < gridSize; x++) {
float *co = grid[x + y*gridSize].co;
float *sco = subgrid[x + y*gridSize].co;
float *no = subgrid[x + y*gridSize].no;
@@ -790,12 +791,12 @@ static void multiresModifier_disp_run(DerivedMesh *dm, Mesh *me, DerivedMesh *dm
column_vectors_to_mat3(mat, tx, ty, no);
- if(!invert) {
+ if (!invert) {
/* convert to object space and add */
mul_v3_m3v3(disp, mat, data);
add_v3_v3v3(co, sco, disp);
}
- else if(!add) {
+ else if (!add) {
/* convert difference to tangent space */
sub_v3_v3v3(disp, co, sco);
invert_m3(mat);
@@ -812,7 +813,7 @@ static void multiresModifier_disp_run(DerivedMesh *dm, Mesh *me, DerivedMesh *dm
}
}
- if(!invert) {
+ if (!invert) {
ccgSubSurf_stitchFaces(ccgdm->ss, 0, NULL, 0);
ccgSubSurf_updateNormals(ccgdm->ss, NULL, 0);
}
@@ -833,11 +834,11 @@ static void multiresModifier_update(DerivedMesh *dm)
CustomData_external_read(&me->ldata, &me->id, CD_MASK_MDISPS, me->totloop);
mdisps = CustomData_get_layer(&me->ldata, CD_MDISPS);
- if(mdisps) {
+ if (mdisps) {
int lvl = ccgdm->multires.lvl;
int totlvl = ccgdm->multires.totlvl;
- if(lvl < totlvl) {
+ if (lvl < totlvl) {
Mesh *me = ob->data;
DerivedMesh *lowdm, *cddm, *highdm;
DMGridData **highGridData, **lowGridData, **subGridData, **gridData, *diffGrid;
@@ -866,13 +867,13 @@ static void multiresModifier_update(DerivedMesh *dm)
subGridData = MEM_callocN(sizeof(DMGridData*)*numGrids, "subGridData*");
diffGrid = MEM_callocN(sizeof(DMGridData)*lowGridSize*lowGridSize, "diff");
- for(i = 0; i < numGrids; ++i) {
+ for (i = 0; i < numGrids; ++i) {
/* backup subsurf grids */
subGridData[i] = MEM_callocN(sizeof(DMGridData)*highGridSize*highGridSize, "subGridData");
memcpy(subGridData[i], highGridData[i], sizeof(DMGridData)*highGridSize*highGridSize);
/* write difference of subsurf and displaced low level into high subsurf */
- for(j = 0; j < lowGridSize*lowGridSize; ++j)
+ for (j = 0; j < lowGridSize*lowGridSize; ++j)
sub_v3_v3v3(diffGrid[j].co, gridData[i][j].co, lowGridData[i][j].co);
multires_copy_dm_grid(highGridData[i], diffGrid, highGridSize, lowGridSize);
@@ -892,7 +893,7 @@ static void multiresModifier_update(DerivedMesh *dm)
/* free */
highdm->release(highdm);
- for(i = 0; i < numGrids; ++i)
+ for (i = 0; i < numGrids; ++i)
MEM_freeN(subGridData[i]);
MEM_freeN(subGridData);
}
@@ -929,7 +930,7 @@ void multires_set_space(DerivedMesh *dm, Object *ob, int from, int to)
mdisps = CustomData_get_layer(&dm->loopData, CD_MDISPS);
- if(!mdisps) {
+ if (!mdisps) {
goto cleanup;
}
@@ -945,7 +946,7 @@ void multires_set_space(DerivedMesh *dm, Object *ob, int from, int to)
subGridData = MEM_callocN(sizeof(DMGridData*)*numGrids, "subGridData*");
- for(i = 0; i < numGrids; i++) {
+ for (i = 0; i < numGrids; i++) {
subGridData[i] = MEM_callocN(sizeof(DMGridData)*gridSize*gridSize, "subGridData");
memcpy(subGridData[i], gridData[i], sizeof(DMGridData)*gridSize*gridSize);
}
@@ -960,28 +961,28 @@ void multires_set_space(DerivedMesh *dm, Object *ob, int from, int to)
k = 0; /*current loop/mdisp index within the mloop array*/
- //#pragma omp parallel for private(i) if(dm->numLoopData*gridSize*gridSize >= CCG_OMP_LIMIT)
+ //#pragma omp parallel for private(i) if (dm->numLoopData*gridSize*gridSize >= CCG_OMP_LIMIT)
- for(i = 0; i < dm->numPolyData; ++i) {
+ for (i = 0; i < dm->numPolyData; ++i) {
const int numVerts = mpoly[i].totloop;
int S, x, y, gIndex = gridOffset[i];
- for(S = 0; S < numVerts; ++S, ++gIndex, ++k) {
+ for (S = 0; S < numVerts; ++S, ++gIndex, ++k) {
MDisps *mdisp = &mdisps[mpoly[i].loopstart+S];
/* DMGridData *grid = gridData[gIndex]; */ /* UNUSED */
DMGridData *subgrid = subGridData[gIndex];
float (*dispgrid)[3] = NULL;
/* when adding new faces in edit mode, need to allocate disps */
- if(!mdisp->disps) {
+ if (!mdisp->disps) {
mdisp->totdisp = gridSize*gridSize;
mdisp->disps = MEM_callocN(sizeof(float)*3*mdisp->totdisp, "disp in multires_set_space");
}
dispgrid = mdisp->disps;
- for(y = 0; y < gridSize; y++) {
- for(x = 0; x < gridSize; x++) {
+ for (y = 0; y < gridSize; y++) {
+ for (x = 0; x < gridSize; x++) {
float *data = dispgrid[dGridSize*y*dSkip + x*dSkip];
float *no = subgrid[x + y*gridSize].no;
float *co = subgrid[x + y*gridSize].co;
@@ -999,9 +1000,11 @@ void multires_set_space(DerivedMesh *dm, Object *ob, int from, int to)
if (from == MULTIRES_SPACE_TANGENT) {
mul_v3_m3v3(dco, mat, data);
add_v3_v3(dco, co);
- } else if (from == MULTIRES_SPACE_OBJECT) {
+ }
+ else if (from == MULTIRES_SPACE_OBJECT) {
add_v3_v3v3(dco, co, data);
- } else if (from == MULTIRES_SPACE_ABSOLUTE) {
+ }
+ else if (from == MULTIRES_SPACE_ABSOLUTE) {
copy_v3_v3(dco, data);
}
@@ -1013,10 +1016,12 @@ void multires_set_space(DerivedMesh *dm, Object *ob, int from, int to)
sub_v3_v3(dco, co);
mul_v3_m3v3(data, mat, dco);
- } else if (to == MULTIRES_SPACE_OBJECT) {
+ }
+ else if (to == MULTIRES_SPACE_OBJECT) {
sub_v3_v3(dco, co);
mul_v3_m3v3(data, mat, dco);
- } else if (to == MULTIRES_SPACE_ABSOLUTE) {
+ }
+ else if (to == MULTIRES_SPACE_ABSOLUTE) {
copy_v3_v3(data, dco);
}
}
@@ -1039,15 +1044,15 @@ cleanup:
void multires_stitch_grids(Object *ob)
{
/* utility for smooth brush */
- if(ob && ob->derivedFinal) {
+ if (ob && ob->derivedFinal) {
CCGDerivedMesh *ccgdm = (CCGDerivedMesh*)ob->derivedFinal;
CCGFace **faces;
int totface;
- if(ccgdm->pbvh) {
+ if (ccgdm->pbvh) {
BLI_pbvh_get_grid_updates(ccgdm->pbvh, 0, (void***)&faces, &totface);
- if(totface) {
+ if (totface) {
ccgSubSurf_stitchFaces(ccgdm->ss, 0, faces, totface);
MEM_freeN(faces);
}
@@ -1065,14 +1070,14 @@ DerivedMesh *multires_dm_create_from_derived(MultiresModifierData *mmd, int loca
int lvl= multires_get_level(ob, mmd, useRenderParams);
int i, gridSize, numGrids;
- if(lvl == 0)
+ if (lvl == 0)
return dm;
result = subsurf_dm_create_local(ob, dm, lvl,
mmd->simple, mmd->flags & eMultiresModifierFlag_ControlEdges,
mmd->flags & eMultiresModifierFlag_PlainUv);
- if(!local_mmd) {
+ if (!local_mmd) {
ccgdm = (CCGDerivedMesh*)result;
ccgdm->multires.ob = ob;
@@ -1090,7 +1095,7 @@ DerivedMesh *multires_dm_create_from_derived(MultiresModifierData *mmd, int loca
subGridData = MEM_callocN(sizeof(DMGridData*)*numGrids, "subGridData*");
- for(i = 0; i < numGrids; i++) {
+ for (i = 0; i < numGrids; i++) {
subGridData[i] = MEM_callocN(sizeof(DMGridData)*gridSize*gridSize, "subGridData");
memcpy(subGridData[i], gridData[i], sizeof(DMGridData)*gridSize*gridSize);
}
@@ -1101,7 +1106,7 @@ DerivedMesh *multires_dm_create_from_derived(MultiresModifierData *mmd, int loca
/*run displacement*/
multiresModifier_disp_run(result, ob->data, dm, 0, 0, subGridData, mmd->totlvl);
- for(i = 0; i < numGrids; i++)
+ for (i = 0; i < numGrids; i++)
MEM_freeN(subGridData[i]);
MEM_freeN(subGridData);
@@ -1122,13 +1127,13 @@ void old_mdisps_bilinear(float out[3], float (*disps)[3], const int st, float u,
if (!disps || isnan(u) || isnan(v))
return;
- if(u < 0)
+ if (u < 0)
u = 0;
- else if(u >= st)
+ else if (u >= st)
u = st_max;
- if(v < 0)
+ if (v < 0)
v = 0;
- else if(v >= st)
+ else if (v >= st)
v = st_max;
x = floor(u);
@@ -1136,8 +1141,8 @@ void old_mdisps_bilinear(float out[3], float (*disps)[3], const int st, float u,
x2 = x + 1;
y2 = y + 1;
- if(x2 >= st) x2 = st_max;
- if(y2 >= st) y2 = st_max;
+ if (x2 >= st) x2 = st_max;
+ if (y2 >= st) y2 = st_max;
urat = u - x;
vrat = v - y;
@@ -1160,10 +1165,10 @@ static void old_mdisps_rotate(int S, int UNUSED(newside), int oldside, int x, in
{
float offset = oldside*0.5f - 0.5f;
- if(S == 1) { *u= offset + x; *v = offset - y; }
- if(S == 2) { *u= offset + y; *v = offset + x; }
- if(S == 3) { *u= offset - x; *v = offset + y; }
- if(S == 0) { *u= offset - y; *v = offset - x; }
+ if (S == 1) { *u= offset + x; *v = offset - y; }
+ if (S == 2) { *u= offset + y; *v = offset + x; }
+ if (S == 3) { *u= offset - x; *v = offset + y; }
+ if (S == 0) { *u= offset - y; *v = offset - x; }
}
static void old_mdisps_convert(MFace *mface, MDisps *mdisp)
@@ -1180,16 +1185,16 @@ static void old_mdisps_convert(MFace *mface, MDisps *mdisp)
disps = MEM_callocN(sizeof(float) * 3 * newtotdisp, "multires disps");
out = disps;
- for(S = 0; S < nvert; S++) {
- for(y = 0; y < newside; ++y) {
- for(x = 0; x < newside; ++x, ++out) {
+ for (S = 0; S < nvert; S++) {
+ for (y = 0; y < newside; ++y) {
+ for (x = 0; x < newside; ++x, ++out) {
old_mdisps_rotate(S, newside, oldside, x, y, &u, &v);
old_mdisps_bilinear(*out, mdisp->disps, oldside, u, v);
- if(S == 1) { (*out)[1]= -(*out)[1]; }
- else if(S == 2) { SWAP(float, (*out)[0], (*out)[1]); }
- else if(S == 3) { (*out)[0]= -(*out)[0]; }
- else if(S == 0) { SWAP(float, (*out)[0], (*out)[1]); (*out)[0]= -(*out)[0]; (*out)[1]= -(*out)[1]; };
+ if (S == 1) { (*out)[1]= -(*out)[1]; }
+ else if (S == 2) { SWAP(float, (*out)[0], (*out)[1]); }
+ else if (S == 3) { (*out)[0]= -(*out)[0]; }
+ else if (S == 0) { SWAP(float, (*out)[0], (*out)[1]); (*out)[0]= -(*out)[0]; (*out)[1]= -(*out)[1]; };
}
}
}
@@ -1208,9 +1213,9 @@ void multires_load_old_250(Mesh *me)
mdisps= CustomData_get_layer(&me->fdata, CD_MDISPS);
- if(mdisps) {
- for(i=0; i<me->totface; i++)
- if(mdisps[i].totdisp)
+ if (mdisps) {
+ for (i=0; i<me->totface; i++)
+ if (mdisps[i].totdisp)
old_mdisps_convert(&me->mface[i], &mdisps[i]);
CustomData_add_layer(&me->ldata, CD_MDISPS, CD_CALLOC, NULL, me->totloop);
@@ -1235,29 +1240,29 @@ void multires_load_old_250(Mesh *me)
/* Does not actually free lvl itself */
static void multires_free_level(MultiresLevel *lvl)
{
- if(lvl) {
- if(lvl->faces) MEM_freeN(lvl->faces);
- if(lvl->edges) MEM_freeN(lvl->edges);
- if(lvl->colfaces) MEM_freeN(lvl->colfaces);
+ if (lvl) {
+ if (lvl->faces) MEM_freeN(lvl->faces);
+ if (lvl->edges) MEM_freeN(lvl->edges);
+ if (lvl->colfaces) MEM_freeN(lvl->colfaces);
}
}
void multires_free(Multires *mr)
{
- if(mr) {
+ if (mr) {
MultiresLevel* lvl= mr->levels.first;
/* Free the first-level data */
- if(lvl) {
+ if (lvl) {
CustomData_free(&mr->vdata, lvl->totvert);
CustomData_free(&mr->fdata, lvl->totface);
- if(mr->edge_flags)
+ if (mr->edge_flags)
MEM_freeN(mr->edge_flags);
- if(mr->edge_creases)
+ if (mr->edge_creases)
MEM_freeN(mr->edge_creases);
}
- while(lvl) {
+ while (lvl) {
multires_free_level(lvl);
lvl= lvl->next;
}
@@ -1281,8 +1286,8 @@ static void create_old_vert_face_map(ListBase **map, IndexNode **mem, const Mult
node = *mem;
/* Find the users */
- for(i = 0; i < totface; ++i){
- for(j = 0; j < (mface[i].v[3]?4:3); ++j, ++node) {
+ for (i = 0; i < totface; ++i) {
+ for (j = 0; j < (mface[i].v[3]?4:3); ++j, ++node) {
node->index = i;
BLI_addtail(&(*map)[mface[i].v[j]], node);
}
@@ -1300,8 +1305,8 @@ static void create_old_vert_edge_map(ListBase **map, IndexNode **mem, const Mult
node = *mem;
/* Find the users */
- for(i = 0; i < totedge; ++i){
- for(j = 0; j < 2; ++j, ++node) {
+ for (i = 0; i < totedge; ++i) {
+ for (j = 0; j < 2; ++j, ++node) {
node->index = i;
BLI_addtail(&(*map)[medge[i].v[j]], node);
}
@@ -1318,17 +1323,17 @@ static MultiresFace *find_old_face(ListBase *map, MultiresFace *faces, int v1, i
v[2]= v3;
v[3]= v4;
- for(n1 = map[v1].first; n1; n1 = n1->next) {
+ for (n1 = map[v1].first; n1; n1 = n1->next) {
int fnd[4] = {0, 0, 0, 0};
- for(i = 0; i < 4; ++i) {
- for(j = 0; j < 4; ++j) {
- if(v[i] == faces[n1->index].v[j])
+ for (i = 0; i < 4; ++i) {
+ for (j = 0; j < 4; ++j) {
+ if (v[i] == faces[n1->index].v[j])
fnd[i] = 1;
}
}
- if(fnd[0] && fnd[1] && fnd[2] && fnd[3])
+ if (fnd[0] && fnd[1] && fnd[2] && fnd[3])
return &faces[n1->index];
}
@@ -1339,9 +1344,9 @@ static MultiresEdge *find_old_edge(ListBase *map, MultiresEdge *edges, int v1, i
{
IndexNode *n1, *n2;
- for(n1 = map[v1].first; n1; n1 = n1->next) {
- for(n2 = map[v2].first; n2; n2 = n2->next) {
- if(n1->index == n2->index)
+ for (n1 = map[v1].first; n1; n1 = n1->next) {
+ for (n2 = map[v2].first; n2; n2 = n2->next) {
+ if (n1->index == n2->index)
return &edges[n1->index];
}
}
@@ -1354,7 +1359,7 @@ static void multires_load_old_edges(ListBase **emap, MultiresLevel *lvl, int *vv
int emid = find_old_edge(emap[2], lvl->edges, v1, v2)->mid;
vvmap[dst + mov] = emid;
- if(lvl->next->next) {
+ if (lvl->next->next) {
multires_load_old_edges(emap + 1, lvl->next, vvmap, dst + mov, v1, emid, mov / 2);
multires_load_old_edges(emap + 1, lvl->next, vvmap, dst + mov, v2, emid, -mov / 2);
}
@@ -1366,7 +1371,7 @@ static void multires_load_old_faces(ListBase **fmap, ListBase **emap, MultiresLe
int fmid;
int emid13, emid14, emid23, emid24;
- if(lvl && lvl->next) {
+ if (lvl && lvl->next) {
fmid = find_old_face(fmap[1], lvl->faces, v1, v2, v3, v4)->mid;
vvmap[dst] = fmid;
@@ -1388,7 +1393,7 @@ static void multires_load_old_faces(ListBase **fmap, ListBase **emap, MultiresLe
multires_load_old_faces(fmap + 1, emap + 1, lvl->next, vvmap, dst - st2 * st3 - st3,
v1, fmid, emid13, emid14, st2, st3 / 2);
- if(lvl->next->next) {
+ if (lvl->next->next) {
multires_load_old_edges(emap, lvl->next, vvmap, dst, emid24, fmid, st3);
multires_load_old_edges(emap, lvl->next, vvmap, dst, emid13, fmid, -st3);
multires_load_old_edges(emap, lvl->next, vvmap, dst, emid14, fmid, -st2 * st3);
@@ -1409,7 +1414,7 @@ static void multires_mvert_to_ss(DerivedMesh *dm, MVert *mvert)
int i = 0;
totface = ccgSubSurf_getNumFaces(ss);
- for(index = 0; index < totface; index++) {
+ for (index = 0; index < totface; index++) {
CCGFace *f = ccgdm->faceMap[index].face;
int x, y, S, numVerts = ccgSubSurf_getFaceNumVerts(f);
@@ -1417,16 +1422,16 @@ static void multires_mvert_to_ss(DerivedMesh *dm, MVert *mvert)
copy_v3_v3(vd->co, mvert[i].co);
i++;
- for(S = 0; S < numVerts; S++) {
- for(x = 1; x < gridSize - 1; x++, i++) {
+ for (S = 0; S < numVerts; S++) {
+ for (x = 1; x < gridSize - 1; x++, i++) {
vd= ccgSubSurf_getFaceGridEdgeData(ss, f, S, x);
copy_v3_v3(vd->co, mvert[i].co);
}
}
- for(S = 0; S < numVerts; S++) {
- for(y = 1; y < gridSize - 1; y++) {
- for(x = 1; x < gridSize - 1; x++, i++) {
+ 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);
copy_v3_v3(vd->co, mvert[i].co);
}
@@ -1435,18 +1440,18 @@ static void multires_mvert_to_ss(DerivedMesh *dm, MVert *mvert)
}
totedge = ccgSubSurf_getNumEdges(ss);
- for(index = 0; index < totedge; index++) {
+ for (index = 0; index < totedge; index++) {
CCGEdge *e = ccgdm->edgeMap[index].edge;
int x;
- for(x = 1; x < edgeSize - 1; x++, i++) {
+ for (x = 1; x < edgeSize - 1; x++, i++) {
vd= ccgSubSurf_getEdgeData(ss, e, x);
copy_v3_v3(vd->co, mvert[i].co);
}
}
totvert = ccgSubSurf_getNumVerts(ss);
- for(index = 0; index < totvert; index++) {
+ for (index = 0; index < totvert; index++) {
CCGVert *v = ccgdm->vertMap[index].vert;
vd= ccgSubSurf_getVertData(ss, v);
@@ -1479,24 +1484,24 @@ static void multires_load_old_dm(DerivedMesh *dm, Mesh *me, int totlvl)
lvl1 = mr->levels.first;
/* Load base verts */
- for(i = 0; i < lvl1->totvert; ++i) {
+ for (i = 0; i < lvl1->totvert; ++i) {
vvmap[totvert - lvl1->totvert + i] = src;
++src;
}
/* Original edges */
dst = totvert - lvl1->totvert - extedgelen * lvl1->totedge;
- for(i = 0; i < lvl1->totedge; ++i) {
+ for (i = 0; i < lvl1->totedge; ++i) {
int ldst = dst + extedgelen * i;
int lsrc = src;
lvl = lvl1->next;
- for(j = 2; j <= mr->level_count; ++j) {
+ for (j = 2; j <= mr->level_count; ++j) {
int base = multires_side_tot[totlvl - j + 1] - 2;
int skip = multires_side_tot[totlvl - j + 2] - 1;
int st = multires_side_tot[j - 1] - 1;
- for(x = 0; x < st; ++x)
+ for (x = 0; x < st; ++x)
vvmap[ldst + base + x * skip] = lsrc + st * i + x;
lsrc += lvl->totvert - lvl->prev->totvert;
@@ -1506,7 +1511,7 @@ static void multires_load_old_dm(DerivedMesh *dm, Mesh *me, int totlvl)
/* Center points */
dst = 0;
- for(i = 0; i < lvl1->totface; ++i) {
+ for (i = 0; i < lvl1->totface; ++i) {
int sides = lvl1->faces[i].v[3] ? 4 : 3;
vvmap[dst] = src + lvl1->totedge + i;
@@ -1515,7 +1520,7 @@ static void multires_load_old_dm(DerivedMesh *dm, Mesh *me, int totlvl)
/* The rest is only for level 3 and up */
- if(lvl1->next && lvl1->next->next) {
+ if (lvl1->next && lvl1->next->next) {
ListBase **fmap, **emap;
IndexNode **fmem, **emem;
@@ -1523,13 +1528,13 @@ static void multires_load_old_dm(DerivedMesh *dm, Mesh *me, int totlvl)
tottri = totquad = 0;
crossedgelen = multires_side_tot[totlvl - 1] - 2;
dst = 0;
- for(i = 0; i < lvl1->totface; ++i) {
+ for (i = 0; i < lvl1->totface; ++i) {
int sides = lvl1->faces[i].v[3] ? 4 : 3;
lvl = lvl1->next->next;
++dst;
- for(j = 3; j <= mr->level_count; ++j) {
+ for (j = 3; j <= mr->level_count; ++j) {
int base = multires_side_tot[totlvl - j + 1] - 2;
int skip = multires_side_tot[totlvl - j + 2] - 1;
int st = pow(2, j - 2);
@@ -1542,8 +1547,8 @@ static void multires_load_old_dm(DerivedMesh *dm, Mesh *me, int totlvl)
/* Skip earlier face edge crosses */
lsrc += st2 * (tottri * 3 + totquad * 4);
- for(s = 0; s < sides; ++s) {
- for(x = 0; x < st2; ++x) {
+ for (s = 0; s < sides; ++s) {
+ for (x = 0; x < st2; ++x) {
vvmap[dst + crossedgelen * (s + 1) - base - x * skip - 1] = lsrc;
++lsrc;
}
@@ -1554,7 +1559,7 @@ static void multires_load_old_dm(DerivedMesh *dm, Mesh *me, int totlvl)
dst += sides * (st - 1) * st;
- if(sides == 4) ++totquad;
+ if (sides == 4) ++totquad;
else ++tottri;
}
@@ -1565,7 +1570,7 @@ static void multires_load_old_dm(DerivedMesh *dm, Mesh *me, int totlvl)
fmem = MEM_callocN(sizeof(IndexNode*) * (mr->level_count-1), "multires fmem");
emem = MEM_callocN(sizeof(IndexNode*) * (mr->level_count-1), "multires emem");
lvl = lvl1;
- for(i = 0; i < (unsigned int)mr->level_count - 1; ++i) {
+ for (i = 0; i < (unsigned int)mr->level_count - 1; ++i) {
create_old_vert_face_map(fmap + i, fmem + i, lvl->faces, lvl->totvert, lvl->totface);
create_old_vert_edge_map(emap + i, emem + i, lvl->edges, lvl->totvert, lvl->totedge);
lvl = lvl->next;
@@ -1574,11 +1579,11 @@ static void multires_load_old_dm(DerivedMesh *dm, Mesh *me, int totlvl)
/* Interior face verts */
/* lvl = lvl1->next->next; */ /* UNUSED */
dst = 0;
- for(j = 0; j < lvl1->totface; ++j) {
+ for (j = 0; j < lvl1->totface; ++j) {
int sides = lvl1->faces[j].v[3] ? 4 : 3;
int ldst = dst + 1 + sides * (st - 1);
- for(s = 0; s < sides; ++s) {
+ for (s = 0; s < sides; ++s) {
int st2 = multires_side_tot[totlvl - 1] - 2;
int st3 = multires_side_tot[totlvl - 2] - 2;
int st4 = st3 == 0 ? 1 : (st3 + 1) / 2;
@@ -1602,7 +1607,7 @@ static void multires_load_old_dm(DerivedMesh *dm, Mesh *me, int totlvl)
/*lvl = lvl->next;*/ /*UNUSED*/
- for(i = 0; i < (unsigned int)(mr->level_count - 1); ++i) {
+ for (i = 0; i < (unsigned int)(mr->level_count - 1); ++i) {
MEM_freeN(fmap[i]);
MEM_freeN(fmem[i]);
MEM_freeN(emap[i]);
@@ -1616,7 +1621,7 @@ static void multires_load_old_dm(DerivedMesh *dm, Mesh *me, int totlvl)
}
/* Transfer verts */
- for(i = 0; i < totvert; ++i)
+ for (i = 0; i < totvert; ++i)
copy_v3_v3(vdst[i].co, vsrc[vvmap[i]].co);
MEM_freeN(vvmap);
@@ -1633,19 +1638,19 @@ static void multires_load_old_vcols(Mesh *me)
MCol *mcol;
int i, j;
- if(!(lvl = me->mr->levels.first))
+ if (!(lvl = me->mr->levels.first))
return;
- if(!(colface = lvl->colfaces))
+ if (!(colface = lvl->colfaces))
return;
/* older multires format never supported multiple vcol layers,
so we can assume the active vcol layer is the correct one */
- if(!(mcol = CustomData_get_layer(&me->fdata, CD_MCOL)))
+ if (!(mcol = CustomData_get_layer(&me->fdata, CD_MCOL)))
return;
- for(i = 0; i < me->totface; ++i) {
- for(j = 0; j < 4; ++j) {
+ for (i = 0; i < me->totface; ++i) {
+ for (j = 0; j < 4; ++j) {
mcol[i*4 + j].a = colface[i].col[j].a;
mcol[i*4 + j].r = colface[i].col[j].r;
mcol[i*4 + j].g = colface[i].col[j].g;
@@ -1661,13 +1666,13 @@ static void multires_load_old_face_flags(Mesh *me)
MultiresFace *faces;
int i;
- if(!(lvl = me->mr->levels.first))
+ if (!(lvl = me->mr->levels.first))
return;
- if(!(faces = lvl->faces))
+ if (!(faces = lvl->faces))
return;
- for(i = 0; i < me->totface; ++i)
+ for (i = 0; i < me->totface; ++i)
me->mface[i].flag = faces[i].flag;
}
@@ -1692,11 +1697,11 @@ void multires_load_old(Object *ob, Mesh *me)
me->medge = CustomData_add_layer(&me->edata, CD_MEDGE, CD_CALLOC, NULL, me->totedge);
me->mface = CustomData_add_layer(&me->fdata, CD_MFACE, CD_CALLOC, NULL, me->totface);
memcpy(me->mvert, me->mr->verts, sizeof(MVert) * me->totvert);
- for(i = 0; i < me->totedge; ++i) {
+ for (i = 0; i < me->totedge; ++i) {
me->medge[i].v1 = lvl->edges[i].v[0];
me->medge[i].v2 = lvl->edges[i].v[1];
}
- for(i = 0; i < me->totface; ++i) {
+ for (i = 0; i < me->totface; ++i) {
me->mface[i].v1 = lvl->faces[i].v[0];
me->mface[i].v2 = lvl->faces[i].v[1];
me->mface[i].v3 = lvl->faces[i].v[2];
@@ -1706,12 +1711,12 @@ void multires_load_old(Object *ob, Mesh *me)
/* Add a multires modifier to the object */
md = ob->modifiers.first;
- while(md && modifierType_getInfo(md->type)->type == eModifierTypeType_OnlyDeform)
+ while (md && modifierType_getInfo(md->type)->type == eModifierTypeType_OnlyDeform)
md = md->next;
mmd = (MultiresModifierData*)modifier_new(eModifierType_Multires);
BLI_insertlinkbefore(&ob->modifiers, md, mmd);
- for(i = 0; i < me->mr->level_count - 1; ++i)
+ for (i = 0; i < me->mr->level_count - 1; ++i)
multiresModifier_subdivide(mmd, ob, 1, 0);
mmd->lvl = mmd->totlvl;
@@ -1725,9 +1730,9 @@ void multires_load_old(Object *ob, Mesh *me)
orig->release(orig);
/* Copy the first-level data to the mesh */
- for(i = 0, l = me->mr->vdata.layers; i < me->mr->vdata.totlayer; ++i, ++l)
+ for (i = 0, l = me->mr->vdata.layers; i < me->mr->vdata.totlayer; ++i, ++l)
CustomData_add_layer(&me->vdata, l->type, CD_REFERENCE, l->data, me->totvert);
- for(i = 0, l = me->mr->fdata.layers; i < me->mr->fdata.totlayer; ++i, ++l)
+ for (i = 0, l = me->mr->fdata.layers; i < me->mr->fdata.totlayer; ++i, ++l)
CustomData_add_layer(&me->fdata, l->type, CD_REFERENCE, l->data, me->totface);
memset(&me->mr->vdata, 0, sizeof(CustomData));
memset(&me->mr->fdata, 0, sizeof(CustomData));
@@ -1745,7 +1750,7 @@ static void multires_sync_levels(Scene *scene, Object *ob, Object *to_ob)
MultiresModifierData *mmd= get_multires_modifier(scene, ob, 1);
MultiresModifierData *to_mmd= get_multires_modifier(scene, to_ob, 1);
- if(!mmd) {
+ if (!mmd) {
/* object could have MDISP even when there is no multires modifier
this could lead to troubles due to i've got no idea how mdisp could be
upsampled correct without modifier data.
@@ -1757,9 +1762,9 @@ static void multires_sync_levels(Scene *scene, Object *ob, Object *to_ob)
CustomData_free_layer_active(&me->ldata, CD_MDISPS, me->totloop);
}
- if(!mmd || !to_mmd) return;
+ if (!mmd || !to_mmd) return;
- if(mmd->totlvl>to_mmd->totlvl) multires_del_higher(mmd, ob, to_mmd->totlvl);
+ if (mmd->totlvl>to_mmd->totlvl) multires_del_higher(mmd, ob, to_mmd->totlvl);
else multires_subdivide(mmd, ob, to_mmd->totlvl, 0, mmd->simple);
}
@@ -1780,7 +1785,7 @@ static void multires_apply_smat(Scene *scene, Object *ob, float smat[3][3])
CustomData_external_read(&me->ldata, &me->id, CD_MASK_MDISPS, me->totloop);
mdisps= CustomData_get_layer(&me->ldata, CD_MDISPS);
- if(!mdisps || !mmd || !mmd->totlvl) return;
+ if (!mdisps || !mmd || !mmd->totlvl) return;
/* we need derived mesh created from highest resolution */
high_mmd= *mmd;
@@ -1795,7 +1800,7 @@ static void multires_apply_smat(Scene *scene, Object *ob, float smat[3][3])
totvert= cddm->getNumVerts(cddm);
vertCos= MEM_mallocN(sizeof(*vertCos) * totvert, "multiresScale vertCos");
cddm->getVertCos(cddm, vertCos);
- for(i=0; i<totvert; i++)
+ for (i=0; i<totvert; i++)
mul_m3_v3(smat, vertCos[i]);
CDDM_apply_vert_coords(cddm, vertCos);
MEM_freeN(vertCos);
@@ -1813,19 +1818,19 @@ static void multires_apply_smat(Scene *scene, Object *ob, float smat[3][3])
dGridSize= multires_side_tot[high_mmd.totlvl];
dSkip= (dGridSize-1)/(gridSize-1);
- #pragma omp parallel for private(i) if(me->totface*gridSize*gridSize*4 >= CCG_OMP_LIMIT)
- for(i = 0; i < me->totpoly; ++i) {
+ #pragma omp parallel for private(i) if (me->totface*gridSize*gridSize*4 >= CCG_OMP_LIMIT)
+ for (i = 0; i < me->totpoly; ++i) {
const int numVerts= mpoly[i].totloop;
MDisps *mdisp= &mdisps[mpoly[i].loopstart];
int S, x, y, gIndex = gridOffset[i];
- for(S = 0; S < numVerts; ++S, ++gIndex, mdisp++) {
+ for (S = 0; S < numVerts; ++S, ++gIndex, mdisp++) {
DMGridData *grid= gridData[gIndex];
DMGridData *subgrid= subGridData[gIndex];
float (*dispgrid)[3]= mdisp->disps;
- for(y = 0; y < gridSize; y++) {
- for(x = 0; x < gridSize; x++) {
+ for (y = 0; y < gridSize; y++) {
+ for (x = 0; x < gridSize; x++) {
float *co= grid[x + y*gridSize].co;
float *sco= subgrid[x + y*gridSize].co;
float *no= grid[x + y*gridSize].no;
@@ -1861,7 +1866,7 @@ int multires_mdisp_corners(MDisps *s)
{
int lvl= 13;
- while(lvl > 0) {
+ while (lvl > 0) {
int side = (1 << (lvl-1)) + 1;
if ((s->totdisp % (side*side)) == 0) return s->totdisp / (side*side);
lvl--;
@@ -1903,17 +1908,17 @@ void multires_topology_changed(Scene *scene, Object *ob)
int i, grid= 0, corners;
MultiresModifierData *mmd= get_multires_modifier(scene, ob, 1);
- if(mmd)
+ if (mmd)
multires_set_tot_mdisps(me, mmd->totlvl);
CustomData_external_read(&me->fdata, &me->id, CD_MASK_MDISPS, me->totface);
mdisp= CustomData_get_layer(&me->fdata, CD_MDISPS);
- if(!mdisp) return;
+ if (!mdisp) return;
cur= mdisp;
- for(i = 0; i < me->totface; i++, cur++) {
- if(mdisp->totdisp) {
+ for (i = 0; i < me->totface; i++, cur++) {
+ if (mdisp->totdisp) {
corners= multires_mdisp_corners(mdisp);
grid= mdisp->totdisp / corners;
@@ -1921,12 +1926,12 @@ void multires_topology_changed(Scene *scene, Object *ob)
}
}
- for(i = 0; i < me->totface; i++, mdisp++) {
+ for (i = 0; i < me->totface; i++, mdisp++) {
int nvert= me->mface[i].v4 ? 4 : 3;
/* allocate memory for mdisp, the whole disp layer would be erased otherwise */
- if(!mdisp->totdisp || !mdisp->disps) {
- if(grid) {
+ if (!mdisp->totdisp || !mdisp->disps) {
+ if (grid) {
mdisp->totdisp= nvert*grid;
mdisp->disps= MEM_callocN(mdisp->totdisp*sizeof(float)*3, "mdisp topology");
}
@@ -1936,10 +1941,10 @@ void multires_topology_changed(Scene *scene, Object *ob)
corners= multires_mdisp_corners(mdisp);
- if(corners!=nvert) {
+ if (corners!=nvert) {
mdisp->totdisp= (mdisp->totdisp/corners)*nvert;
- if(mdisp->disps)
+ if (mdisp->disps)
MEM_freeN(mdisp->disps);
mdisp->disps= MEM_callocN(mdisp->totdisp*sizeof(float)*3, "mdisp topology");
@@ -1957,25 +1962,29 @@ int mdisp_rot_face_to_crn(const int corners, const int face_side, const float u,
int S = 0;
if (corners == 4) {
- if(u <= offset && v <= offset) S = 0;
- else if(u > offset && v <= offset) S = 1;
- else if(u > offset && v > offset) S = 2;
- else if(u <= offset && v >= offset) S = 3;
+ if (u <= offset && v <= offset) S = 0;
+ else if (u > offset && v <= offset) S = 1;
+ else if (u > offset && v > offset) S = 2;
+ else if (u <= offset && v >= offset) S = 3;
- if(S == 0) {
+ if (S == 0) {
*y = offset - u;
*x = offset - v;
- } else if(S == 1) {
+ }
+ else if (S == 1) {
*x = u - offset;
*y = offset - v;
- } else if(S == 2) {
+ }
+ else if (S == 2) {
*y = u - offset;
*x = v - offset;
- } else if(S == 3) {
+ }
+ else if (S == 3) {
*x= offset - u;
*y = v - offset;
}
- } else {
+ }
+ else {
int grid_size = offset;
float w = (face_side - 1) - u - v;
float W1, W2;
diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c
index 00aa5d96bab..cd59b74243b 100644
--- a/source/blender/blenkernel/intern/object.c
+++ b/source/blender/blenkernel/intern/object.c
@@ -129,7 +129,7 @@ void copy_baseflags(struct Scene *scene)
{
Base *base= scene->base.first;
- while(base) {
+ while (base) {
base->object->flag= base->flag;
base= base->next;
}
@@ -139,7 +139,7 @@ void copy_objectflags(struct Scene *scene)
{
Base *base= scene->base.first;
- while(base) {
+ while (base) {
base->flag= base->object->flag;
base= base->next;
}
@@ -157,7 +157,7 @@ void update_base_layer(struct Scene *scene, Object *ob)
void object_free_particlesystems(Object *ob)
{
- while(ob->particlesystem.first){
+ while (ob->particlesystem.first) {
ParticleSystem *psys = ob->particlesystem.first;
BLI_remlink(&ob->particlesystem,psys);
@@ -168,7 +168,7 @@ void object_free_particlesystems(Object *ob)
void object_free_softbody(Object *ob)
{
- if(ob->soft) {
+ if (ob->soft) {
sbFree(ob->soft);
ob->soft= NULL;
}
@@ -176,7 +176,7 @@ void object_free_softbody(Object *ob)
void object_free_bulletsoftbody(Object *ob)
{
- if(ob->bsoft) {
+ if (ob->bsoft) {
bsbFree(ob->bsoft);
ob->bsoft= NULL;
}
@@ -207,7 +207,7 @@ void object_link_modifiers(struct Object *ob, struct Object *from)
for (md=from->modifiers.first; md; md=md->next) {
ModifierData *nmd = NULL;
- if(ELEM4(md->type, eModifierType_Hook, eModifierType_Softbody, eModifierType_ParticleInstance, eModifierType_Collision)) continue;
+ if (ELEM4(md->type, eModifierType_Hook, eModifierType_Softbody, eModifierType_ParticleInstance, eModifierType_Collision)) continue;
nmd = modifier_new(md->type);
modifier_copyData(md, nmd);
@@ -224,12 +224,12 @@ void object_link_modifiers(struct Object *ob, struct Object *from)
/* also (ab)used in depsgraph */
void object_free_display(Object *ob)
{
- if(ob->derivedDeform) {
+ if (ob->derivedDeform) {
ob->derivedDeform->needsFree = 1;
ob->derivedDeform->release(ob->derivedDeform);
ob->derivedDeform= NULL;
}
- if(ob->derivedFinal) {
+ if (ob->derivedFinal) {
ob->derivedFinal->needsFree = 1;
ob->derivedFinal->release(ob->derivedFinal);
ob->derivedFinal= NULL;
@@ -240,9 +240,9 @@ void object_free_display(Object *ob)
void free_sculptsession_deformMats(SculptSession *ss)
{
- if(ss->orig_cos) MEM_freeN(ss->orig_cos);
- if(ss->deform_cos) MEM_freeN(ss->deform_cos);
- if(ss->deform_imats) MEM_freeN(ss->deform_imats);
+ if (ss->orig_cos) MEM_freeN(ss->orig_cos);
+ if (ss->deform_cos) MEM_freeN(ss->deform_cos);
+ if (ss->deform_imats) MEM_freeN(ss->deform_imats);
ss->orig_cos = NULL;
ss->deform_cos = NULL;
@@ -251,26 +251,26 @@ void free_sculptsession_deformMats(SculptSession *ss)
void free_sculptsession(Object *ob)
{
- if(ob && ob->sculpt) {
+ if (ob && ob->sculpt) {
SculptSession *ss = ob->sculpt;
DerivedMesh *dm= ob->derivedFinal;
- if(ss->pbvh)
+ if (ss->pbvh)
BLI_pbvh_free(ss->pbvh);
- if(dm && dm->getPBVH)
+ if (dm && dm->getPBVH)
dm->getPBVH(NULL, dm); /* signal to clear */
- if(ss->texcache)
+ if (ss->texcache)
MEM_freeN(ss->texcache);
- if(ss->layer_co)
+ if (ss->layer_co)
MEM_freeN(ss->layer_co);
- if(ss->orig_cos)
+ if (ss->orig_cos)
MEM_freeN(ss->orig_cos);
- if(ss->deform_cos)
+ if (ss->deform_cos)
MEM_freeN(ss->deform_cos);
- if(ss->deform_imats)
+ if (ss->deform_imats)
MEM_freeN(ss->deform_imats);
MEM_freeN(ss);
@@ -288,34 +288,34 @@ void free_object(Object *ob)
object_free_display(ob);
/* disconnect specific data */
- if(ob->data) {
+ if (ob->data) {
ID *id= ob->data;
id->us--;
- if(id->us==0) {
- if(ob->type==OB_MESH) unlink_mesh(ob->data);
- else if(ob->type==OB_CURVE) unlink_curve(ob->data);
- else if(ob->type==OB_MBALL) unlink_mball(ob->data);
+ if (id->us==0) {
+ if (ob->type==OB_MESH) unlink_mesh(ob->data);
+ else if (ob->type==OB_CURVE) unlink_curve(ob->data);
+ else if (ob->type==OB_MBALL) unlink_mball(ob->data);
}
ob->data= NULL;
}
- for(a=0; a<ob->totcol; a++) {
- if(ob->mat[a]) ob->mat[a]->id.us--;
+ for (a=0; a<ob->totcol; a++) {
+ if (ob->mat[a]) ob->mat[a]->id.us--;
}
- if(ob->mat) MEM_freeN(ob->mat);
- if(ob->matbits) MEM_freeN(ob->matbits);
+ if (ob->mat) MEM_freeN(ob->mat);
+ if (ob->matbits) MEM_freeN(ob->matbits);
ob->mat= NULL;
ob->matbits= NULL;
- if(ob->bb) MEM_freeN(ob->bb);
+ if (ob->bb) MEM_freeN(ob->bb);
ob->bb= NULL;
- if(ob->adt) BKE_free_animdata((ID *)ob);
- if(ob->poselib) ob->poselib->id.us--;
- if(ob->gpd) ((ID *)ob->gpd)->us--;
- if(ob->defbase.first)
+ if (ob->adt) BKE_free_animdata((ID *)ob);
+ if (ob->poselib) ob->poselib->id.us--;
+ if (ob->gpd) ((ID *)ob->gpd)->us--;
+ if (ob->defbase.first)
BLI_freelistN(&ob->defbase);
- if(ob->pose)
+ if (ob->pose)
free_pose(ob->pose);
- if(ob->mpath)
+ if (ob->mpath)
animviz_free_motionpath(ob->mpath);
free_properties(&ob->prop);
object_free_modifiers(ob);
@@ -328,13 +328,13 @@ void free_object(Object *ob)
free_partdeflect(ob->pd);
- if(ob->soft) sbFree(ob->soft);
- if(ob->bsoft) bsbFree(ob->bsoft);
- if(ob->gpulamp.first) GPU_lamp_free(ob);
+ if (ob->soft) sbFree(ob->soft);
+ if (ob->bsoft) bsbFree(ob->bsoft);
+ if (ob->gpulamp.first) GPU_lamp_free(ob);
free_sculptsession(ob);
- if(ob->pc_ids.first) BLI_freelistN(&ob->pc_ids);
+ if (ob->pc_ids.first) BLI_freelistN(&ob->pc_ids);
}
static void unlink_object__unlinkModifierLinks(void *userData, Object *ob, Object **obpoin)
@@ -372,17 +372,17 @@ void unlink_object(Object *ob)
/* check all objects: parents en bevels and fields, also from libraries */
// FIXME: need to check all animation blocks (drivers)
obt= bmain->object.first;
- while(obt) {
- if(obt->proxy==ob)
+ while (obt) {
+ if (obt->proxy==ob)
obt->proxy= NULL;
- if(obt->proxy_from==ob) {
+ if (obt->proxy_from==ob) {
obt->proxy_from= NULL;
obt->recalc |= OB_RECALC_OB;
}
- if(obt->proxy_group==ob)
+ if (obt->proxy_group==ob)
obt->proxy_group= NULL;
- if(obt->parent==ob) {
+ if (obt->parent==ob) {
obt->parent= NULL;
obt->recalc |= OB_RECALC_OB|OB_RECALC_DATA|OB_RECALC_TIME;
}
@@ -392,22 +392,22 @@ void unlink_object(Object *ob)
if ELEM(obt->type, OB_CURVE, OB_FONT) {
cu= obt->data;
- if(cu->bevobj==ob) {
+ if (cu->bevobj==ob) {
cu->bevobj= NULL;
obt->recalc |= OB_RECALC_OB|OB_RECALC_DATA|OB_RECALC_TIME;
}
- if(cu->taperobj==ob) {
+ if (cu->taperobj==ob) {
cu->taperobj= NULL;
obt->recalc |= OB_RECALC_OB|OB_RECALC_DATA|OB_RECALC_TIME;
}
- if(cu->textoncurve==ob) {
+ if (cu->textoncurve==ob) {
cu->textoncurve= NULL;
obt->recalc |= OB_RECALC_OB|OB_RECALC_DATA|OB_RECALC_TIME;
}
}
- else if(obt->type==OB_ARMATURE && obt->pose) {
+ else if (obt->type==OB_ARMATURE && obt->pose) {
bPoseChannel *pchan;
- for(pchan= obt->pose->chanbase.first; pchan; pchan= pchan->next) {
+ for (pchan= obt->pose->chanbase.first; pchan; pchan= pchan->next) {
for (con = pchan->constraints.first; con; con=con->next) {
bConstraintTypeInfo *cti= constraint_get_typeinfo(con);
ListBase targets = {NULL, NULL};
@@ -428,12 +428,12 @@ void unlink_object(Object *ob)
cti->flush_constraint_targets(con, &targets, 0);
}
}
- if(pchan->custom==ob)
+ if (pchan->custom==ob)
pchan->custom= NULL;
}
}
- else if(ELEM(OB_MBALL, ob->type, obt->type)) {
- if(is_mball_basis_for(obt, ob))
+ else if (ELEM(OB_MBALL, ob->type, obt->type)) {
+ if (is_mball_basis_for (obt, ob))
obt->recalc|= OB_RECALC_DATA;
}
@@ -461,84 +461,84 @@ void unlink_object(Object *ob)
}
/* object is deflector or field */
- if(ob->pd) {
- if(obt->soft)
+ if (ob->pd) {
+ if (obt->soft)
obt->recalc |= OB_RECALC_DATA;
/* cloth */
- for(md=obt->modifiers.first; md; md=md->next)
- if(md->type == eModifierType_Cloth)
+ for (md=obt->modifiers.first; md; md=md->next)
+ if (md->type == eModifierType_Cloth)
obt->recalc |= OB_RECALC_DATA;
}
/* strips */
#if 0 // XXX old animation system
- for(strip= obt->nlastrips.first; strip; strip= strip->next) {
- if(strip->object==ob)
+ for (strip= obt->nlastrips.first; strip; strip= strip->next) {
+ if (strip->object==ob)
strip->object= NULL;
- if(strip->modifiers.first) {
+ if (strip->modifiers.first) {
bActionModifier *amod;
- for(amod= strip->modifiers.first; amod; amod= amod->next)
- if(amod->ob==ob)
+ for (amod= strip->modifiers.first; amod; amod= amod->next)
+ if (amod->ob==ob)
amod->ob= NULL;
}
}
#endif // XXX old animation system
/* particle systems */
- if(obt->particlesystem.first) {
+ if (obt->particlesystem.first) {
ParticleSystem *tpsys= obt->particlesystem.first;
- for(; tpsys; tpsys=tpsys->next) {
+ for (; tpsys; tpsys=tpsys->next) {
BoidState *state = NULL;
BoidRule *rule = NULL;
ParticleTarget *pt = tpsys->targets.first;
- for(; pt; pt=pt->next) {
- if(pt->ob==ob) {
+ for (; pt; pt=pt->next) {
+ if (pt->ob==ob) {
pt->ob = NULL;
obt->recalc |= OB_RECALC_DATA;
break;
}
}
- if(tpsys->target_ob==ob) {
+ if (tpsys->target_ob==ob) {
tpsys->target_ob= NULL;
obt->recalc |= OB_RECALC_DATA;
}
- if(tpsys->part->dup_ob==ob)
+ if (tpsys->part->dup_ob==ob)
tpsys->part->dup_ob= NULL;
- if(tpsys->part->phystype==PART_PHYS_BOIDS) {
+ if (tpsys->part->phystype==PART_PHYS_BOIDS) {
ParticleData *pa;
BoidParticle *bpa;
int p;
- for(p=0,pa=tpsys->particles; p<tpsys->totpart; p++,pa++) {
+ for (p=0,pa=tpsys->particles; p<tpsys->totpart; p++,pa++) {
bpa = pa->boid;
- if(bpa->ground == ob)
+ if (bpa->ground == ob)
bpa->ground = NULL;
}
}
- if(tpsys->part->boids) {
- for(state = tpsys->part->boids->states.first; state; state=state->next) {
- for(rule = state->rules.first; rule; rule=rule->next) {
- if(rule->type==eBoidRuleType_Avoid) {
+ if (tpsys->part->boids) {
+ for (state = tpsys->part->boids->states.first; state; state=state->next) {
+ for (rule = state->rules.first; rule; rule=rule->next) {
+ if (rule->type==eBoidRuleType_Avoid) {
BoidRuleGoalAvoid *gabr = (BoidRuleGoalAvoid*)rule;
- if(gabr->ob==ob)
+ if (gabr->ob==ob)
gabr->ob= NULL;
}
- else if(rule->type==eBoidRuleType_FollowLeader) {
+ else if (rule->type==eBoidRuleType_FollowLeader) {
BoidRuleFollowLeader *flbr = (BoidRuleFollowLeader*)rule;
- if(flbr->ob==ob)
+ if (flbr->ob==ob)
flbr->ob= NULL;
}
}
}
}
}
- if(ob->pd)
+ if (ob->pd)
obt->recalc |= OB_RECALC_DATA;
}
@@ -547,10 +547,10 @@ void unlink_object(Object *ob)
/* materials */
mat= bmain->mat.first;
- while(mat) {
+ while (mat) {
- for(a=0; a<MAX_MTEX; a++) {
- if(mat->mtex[a] && ob==mat->mtex[a]->object) {
+ for (a=0; a<MAX_MTEX; a++) {
+ if (mat->mtex[a] && ob==mat->mtex[a]->object) {
/* actually, test for lib here... to do */
mat->mtex[a]->object= NULL;
}
@@ -560,18 +560,18 @@ void unlink_object(Object *ob)
}
/* textures */
- for(tex= bmain->tex.first; tex; tex= tex->id.next) {
- if(tex->env && (ob==tex->env->object)) tex->env->object= NULL;
- if(tex->pd && (ob==tex->pd->object)) tex->pd->object= NULL;
- if(tex->vd && (ob==tex->vd->object)) tex->vd->object= NULL;
+ for (tex= bmain->tex.first; tex; tex= tex->id.next) {
+ if (tex->env && (ob==tex->env->object)) tex->env->object= NULL;
+ if (tex->pd && (ob==tex->pd->object)) tex->pd->object= NULL;
+ if (tex->vd && (ob==tex->vd->object)) tex->vd->object= NULL;
}
/* worlds */
wrld= bmain->world.first;
- while(wrld) {
- if(wrld->id.lib==NULL) {
- for(a=0; a<MAX_MTEX; a++) {
- if(wrld->mtex[a] && ob==wrld->mtex[a]->object)
+ while (wrld) {
+ if (wrld->id.lib==NULL) {
+ for (a=0; a<MAX_MTEX; a++) {
+ if (wrld->mtex[a] && ob==wrld->mtex[a]->object)
wrld->mtex[a]->object= NULL;
}
}
@@ -581,26 +581,26 @@ void unlink_object(Object *ob)
/* scenes */
sce= bmain->scene.first;
- while(sce) {
- if(sce->id.lib==NULL) {
- if(sce->camera==ob) sce->camera= NULL;
- if(sce->toolsettings->skgen_template==ob) sce->toolsettings->skgen_template = NULL;
- if(sce->toolsettings->particle.object==ob) sce->toolsettings->particle.object= NULL;
+ while (sce) {
+ if (sce->id.lib==NULL) {
+ if (sce->camera==ob) sce->camera= NULL;
+ if (sce->toolsettings->skgen_template==ob) sce->toolsettings->skgen_template = NULL;
+ if (sce->toolsettings->particle.object==ob) sce->toolsettings->particle.object= NULL;
#ifdef DURIAN_CAMERA_SWITCH
{
TimeMarker *m;
for (m= sce->markers.first; m; m= m->next) {
- if(m->camera==ob)
+ if (m->camera==ob)
m->camera= NULL;
}
}
#endif
- if(sce->ed) {
+ if (sce->ed) {
Sequence *seq;
SEQ_BEGIN(sce->ed, seq)
- if(seq->scene_camera==ob) {
+ if (seq->scene_camera==ob) {
seq->scene_camera= NULL;
}
SEQ_END
@@ -612,21 +612,21 @@ void unlink_object(Object *ob)
/* screens */
sc= bmain->screen.first;
- while(sc) {
+ while (sc) {
ScrArea *sa= sc->areabase.first;
- while(sa) {
+ while (sa) {
SpaceLink *sl;
for (sl= sa->spacedata.first; sl; sl= sl->next) {
- if(sl->spacetype==SPACE_VIEW3D) {
+ if (sl->spacetype==SPACE_VIEW3D) {
View3D *v3d= (View3D*) sl;
found= 0;
- if(v3d->camera==ob) {
+ if (v3d->camera==ob) {
v3d->camera= NULL;
found= 1;
}
- if(v3d->localvd && v3d->localvd->camera==ob ) {
+ if (v3d->localvd && v3d->localvd->camera==ob ) {
v3d->localvd->camera= NULL;
found += 2;
}
@@ -649,21 +649,21 @@ void unlink_object(Object *ob)
}
}
}
- else if(sl->spacetype==SPACE_OUTLINER) {
+ else if (sl->spacetype==SPACE_OUTLINER) {
SpaceOops *so= (SpaceOops *)sl;
- if(so->treestore) {
+ if (so->treestore) {
TreeStoreElem *tselem= so->treestore->data;
int a;
- for(a=0; a<so->treestore->usedelem; a++, tselem++) {
- if(tselem->id==(ID *)ob) tselem->id= NULL;
+ for (a=0; a<so->treestore->usedelem; a++, tselem++) {
+ if (tselem->id==(ID *)ob) tselem->id= NULL;
}
}
}
- else if(sl->spacetype==SPACE_BUTS) {
+ else if (sl->spacetype==SPACE_BUTS) {
SpaceButs *sbuts= (SpaceButs *)sl;
- if(sbuts->pinid==(ID *)ob) {
+ if (sbuts->pinid==(ID *)ob) {
sbuts->flag&= ~SB_PIN_CONTEXT;
sbuts->pinid= NULL;
}
@@ -677,14 +677,14 @@ void unlink_object(Object *ob)
/* groups */
group= bmain->group.first;
- while(group) {
+ while (group) {
rem_from_group(group, ob, NULL, NULL);
group= group->id.next;
}
/* cameras */
camera= bmain->camera.first;
- while(camera) {
+ while (camera) {
if (camera->dof_ob==ob) {
camera->dof_ob = NULL;
}
@@ -696,11 +696,11 @@ int exist_object(Object *obtest)
{
Object *ob;
- if(obtest==NULL) return 0;
+ if (obtest==NULL) return 0;
ob= G.main->object.first;
- while(ob) {
- if(ob==obtest) return 1;
+ while (ob) {
+ if (ob==obtest) return 1;
ob= ob->id.next;
}
return 0;
@@ -785,7 +785,7 @@ Object *add_only_object(int type, const char *name)
ob->empty_drawtype= OB_PLAINAXES;
ob->empty_drawsize= 1.0;
- if(type==OB_CAMERA || type==OB_LAMP || type==OB_SPEAKER) {
+ if (type==OB_CAMERA || type==OB_LAMP || type==OB_SPEAKER) {
ob->trackflag= OB_NEGZ;
ob->upflag= OB_POSY;
}
@@ -865,7 +865,7 @@ SoftBody *copy_softbody(SoftBody *sb)
sbn->pointcache= BKE_ptcache_copy_list(&sbn->ptcaches, &sb->ptcaches);
- if(sb->effector_weights)
+ if (sb->effector_weights)
sbn->effector_weights = MEM_dupallocN(sb->effector_weights);
return sbn;
@@ -892,32 +892,32 @@ static ParticleSystem *copy_particlesystem(ParticleSystem *psys)
psysn->particles= MEM_dupallocN(psys->particles);
psysn->child= MEM_dupallocN(psys->child);
- if(psys->part->type == PART_HAIR) {
- for(p=0, pa=psysn->particles; p<psysn->totpart; p++, pa++)
+ if (psys->part->type == PART_HAIR) {
+ for (p=0, pa=psysn->particles; p<psysn->totpart; p++, pa++)
pa->hair = MEM_dupallocN(pa->hair);
}
- if(psysn->particles && (psysn->particles->keys || psysn->particles->boid)) {
+ if (psysn->particles && (psysn->particles->keys || psysn->particles->boid)) {
ParticleKey *key = psysn->particles->keys;
BoidParticle *boid = psysn->particles->boid;
- if(key)
+ if (key)
key = MEM_dupallocN(key);
- if(boid)
+ if (boid)
boid = MEM_dupallocN(boid);
- for(p=0, pa=psysn->particles; p<psysn->totpart; p++, pa++) {
- if(boid)
+ for (p=0, pa=psysn->particles; p<psysn->totpart; p++, pa++) {
+ if (boid)
pa->boid = boid++;
- if(key) {
+ if (key) {
pa->keys = key;
key += pa->totkey;
}
}
}
- if(psys->clmd) {
+ if (psys->clmd) {
psysn->clmd = (ClothModifierData *)modifier_new(eModifierType_Cloth);
modifier_copyData((ModifierData*)psys->clmd, (ModifierData*)psysn->clmd);
psys->hair_in_dm = psys->hair_out_dm = NULL;
@@ -940,7 +940,7 @@ static ParticleSystem *copy_particlesystem(ParticleSystem *psys)
/* XXX - from reading existing code this seems correct but intended usage of
* pointcache should /w cloth should be added in 'ParticleSystem' - campbell */
- if(psysn->clmd) {
+ if (psysn->clmd) {
psysn->clmd->point_cache= psysn->pointcache;
}
@@ -955,22 +955,22 @@ void copy_object_particlesystems(Object *obn, Object *ob)
ModifierData *md;
obn->particlesystem.first= obn->particlesystem.last= NULL;
- for(psys=ob->particlesystem.first; psys; psys=psys->next) {
+ for (psys=ob->particlesystem.first; psys; psys=psys->next) {
npsys= copy_particlesystem(psys);
BLI_addtail(&obn->particlesystem, npsys);
/* need to update particle modifiers too */
- for(md=obn->modifiers.first; md; md=md->next) {
- if(md->type==eModifierType_ParticleSystem) {
+ for (md=obn->modifiers.first; md; md=md->next) {
+ if (md->type==eModifierType_ParticleSystem) {
ParticleSystemModifierData *psmd= (ParticleSystemModifierData*)md;
- if(psmd->psys==psys)
+ if (psmd->psys==psys)
psmd->psys= npsys;
}
- else if(md->type==eModifierType_DynamicPaint) {
+ else if (md->type==eModifierType_DynamicPaint) {
DynamicPaintModifierData *pmd= (DynamicPaintModifierData*)md;
if (pmd->brush) {
- if(pmd->brush->psys==psys) {
+ if (pmd->brush->psys==psys) {
pmd->brush->psys= npsys;
}
}
@@ -978,7 +978,7 @@ void copy_object_particlesystems(Object *obn, Object *ob)
else if (md->type==eModifierType_Smoke) {
SmokeModifierData *smd = (SmokeModifierData*) md;
- if(smd->type==MOD_SMOKE_TYPE_FLOW) {
+ if (smd->type==MOD_SMOKE_TYPE_FLOW) {
if (smd->flow) {
if (smd->flow->psys == psys)
smd->flow->psys= npsys;
@@ -991,7 +991,7 @@ void copy_object_particlesystems(Object *obn, Object *ob)
void copy_object_softbody(Object *obn, Object *ob)
{
- if(ob->soft)
+ if (ob->soft)
obn->soft= copy_softbody(ob->soft);
}
@@ -1003,7 +1003,7 @@ static void copy_object_pose(Object *obn, Object *ob)
obn->pose= NULL;
copy_pose(&obn->pose, ob->pose, 1); /* 1 = copy constraints */
- for (chan = obn->pose->chanbase.first; chan; chan=chan->next){
+ for (chan = obn->pose->chanbase.first; chan; chan=chan->next) {
bConstraint *con;
chan->flag &= ~(POSE_LOC|POSE_ROT|POSE_SIZE);
@@ -1030,7 +1030,7 @@ static void copy_object_pose(Object *obn, Object *ob)
static int object_pose_context(Object *ob)
{
- if( (ob) &&
+ if ( (ob) &&
(ob->type == OB_ARMATURE) &&
(ob->pose) &&
(ob->mode & OB_MODE_POSE)
@@ -1044,15 +1044,15 @@ static int object_pose_context(Object *ob)
Object *object_pose_armature_get(Object *ob)
{
- if(ob==NULL)
+ if (ob==NULL)
return NULL;
- if(object_pose_context(ob))
+ if (object_pose_context(ob))
return ob;
ob= modifiers_isDeformedByArmature(ob);
- if(object_pose_context(ob))
+ if (object_pose_context(ob))
return ob;
return NULL;
@@ -1077,13 +1077,13 @@ Object *copy_object(Object *ob)
obn= copy_libblock(&ob->id);
- if(ob->totcol) {
+ if (ob->totcol) {
obn->mat= MEM_dupallocN(ob->mat);
obn->matbits= MEM_dupallocN(ob->matbits);
obn->totcol= ob->totcol;
}
- if(ob->bb) obn->bb= MEM_dupallocN(ob->bb);
+ if (ob->bb) obn->bb= MEM_dupallocN(ob->bb);
obn->flag &= ~OB_FROMGROUP;
obn->modifiers.first = obn->modifiers.last= NULL;
@@ -1102,10 +1102,10 @@ Object *copy_object(Object *ob)
copy_controllers(&obn->controllers, &ob->controllers);
copy_actuators(&obn->actuators, &ob->actuators);
- if(ob->pose) {
+ if (ob->pose) {
copy_object_pose(obn, ob);
/* backwards compat... non-armatures can get poses in older files? */
- if(ob->type==OB_ARMATURE)
+ if (ob->type==OB_ARMATURE)
armature_rebuild_pose(obn, obn->data);
}
defgroup_copy_list(&obn->defbase, &ob->defbase);
@@ -1119,15 +1119,15 @@ Object *copy_object(Object *ob)
id_us_plus((ID *)obn->gpd);
id_lib_extern((ID *)obn->dup_group);
- for(a=0; a<obn->totcol; a++) id_us_plus((ID *)obn->mat[a]);
+ for (a=0; a<obn->totcol; a++) id_us_plus((ID *)obn->mat[a]);
obn->disp.first= obn->disp.last= NULL;
- if(ob->pd){
+ if (ob->pd) {
obn->pd= MEM_dupallocN(ob->pd);
- if(obn->pd->tex)
+ if (obn->pd->tex)
id_us_plus(&(obn->pd->tex->id));
- if(obn->pd->rng)
+ if (obn->pd->rng)
obn->pd->rng = MEM_dupallocN(ob->pd->rng);
}
obn->soft= copy_softbody(ob->soft);
@@ -1157,7 +1157,7 @@ static void extern_local_object(Object *ob)
extern_local_matarar(ob->mat, ob->totcol);
- for(psys=ob->particlesystem.first; psys; psys=psys->next)
+ for (psys=ob->particlesystem.first; psys; psys=psys->next)
id_lib_extern((ID *)psys->part);
}
@@ -1173,27 +1173,27 @@ void make_local_object(Object *ob)
* - mixed: make copy
*/
- if(ob->id.lib==NULL) return;
+ if (ob->id.lib==NULL) return;
ob->proxy= ob->proxy_from= NULL;
- if(ob->id.us==1) {
+ if (ob->id.us==1) {
id_clear_lib_data(bmain, &ob->id);
extern_local_object(ob);
}
else {
- for(sce= bmain->scene.first; sce && ELEM(0, is_lib, is_local); sce= sce->id.next) {
- if(object_in_scene(ob, sce)) {
- if(sce->id.lib) is_lib= TRUE;
+ for (sce= bmain->scene.first; sce && ELEM(0, is_lib, is_local); sce= sce->id.next) {
+ if (object_in_scene(ob, sce)) {
+ if (sce->id.lib) is_lib= TRUE;
else is_local= TRUE;
}
}
- if(is_local && is_lib == FALSE) {
+ if (is_local && is_lib == FALSE) {
id_clear_lib_data(bmain, &ob->id);
extern_local_object(ob);
}
- else if(is_local && is_lib) {
+ else if (is_local && is_lib) {
Object *ob_new= copy_object(ob);
ob_new->id.us= 0;
@@ -1202,11 +1202,11 @@ void make_local_object(Object *ob)
BKE_id_lib_local_paths(bmain, ob->id.lib, &ob_new->id);
sce= bmain->scene.first;
- while(sce) {
- if(sce->id.lib==NULL) {
+ while (sce) {
+ if (sce->id.lib==NULL) {
base= sce->base.first;
- while(base) {
- if(base->object==ob) {
+ while (base) {
+ if (base->object==ob) {
base->object= ob_new;
ob_new->id.us++;
ob->id.us--;
@@ -1234,11 +1234,11 @@ int object_is_libdata(Object *ob)
/* Returns true if the Object data is a from an external blend file (libdata) */
int object_data_is_libdata(Object *ob)
{
- if(!ob) return 0;
- if(ob->proxy && (ob->data==NULL || ((ID *)ob->data)->lib==NULL)) return 0;
- if(ob->id.lib) return 1;
- if(ob->data==NULL) return 0;
- if(((ID *)ob->data)->lib) return 1;
+ if (!ob) return 0;
+ if (ob->proxy && (ob->data==NULL || ((ID *)ob->data)->lib==NULL)) return 0;
+ if (ob->id.lib) return 1;
+ if (ob->data==NULL) return 0;
+ if (((ID *)ob->data)->lib) return 1;
return 0;
}
@@ -1253,7 +1253,7 @@ static void armature_set_id_extern(Object *ob)
unsigned int lay= arm->layer_protected;
for (pchan = ob->pose->chanbase.first; pchan; pchan=pchan->next) {
- if(!(pchan->bone->layer & lay))
+ if (!(pchan->bone->layer & lay))
id_lib_extern((ID *)pchan->custom);
}
@@ -1265,7 +1265,7 @@ void object_copy_proxy_drivers(Object *ob, Object *target)
FCurve *fcu;
/* add new animdata block */
- if(!ob->adt)
+ if (!ob->adt)
ob->adt= BKE_id_add_animdata(&ob->id);
/* make a copy of all the drivers (for now), then correct any links that need fixing */
@@ -1280,13 +1280,13 @@ void object_copy_proxy_drivers(Object *ob, Object *target)
/* all drivers */
DRIVER_TARGETS_LOOPER(dvar)
{
- if(dtar->id) {
+ if (dtar->id) {
if ((Object *)dtar->id == target)
dtar->id= (ID *)ob;
else {
/* only on local objects because this causes indirect links a -> b -> c,blend to point directly to a.blend
* when a.blend has a proxy thats linked into c.blend */
- if(ob->id.lib==NULL)
+ if (ob->id.lib==NULL)
id_lib_extern((ID *)dtar->id);
}
}
@@ -1304,7 +1304,7 @@ void object_copy_proxy_drivers(Object *ob, Object *target)
void object_make_proxy(Object *ob, Object *target, Object *gob)
{
/* paranoia checks */
- if(ob->id.lib || target->id.lib==NULL) {
+ if (ob->id.lib || target->id.lib==NULL) {
printf("cannot make proxy\n");
return;
}
@@ -1321,10 +1321,10 @@ void object_make_proxy(Object *ob, Object *target, Object *gob)
*
* - no gob means this is being made from a linked object,
* this is closer to making a copy of the object - in-place. */
- if(gob) {
+ if (gob) {
ob->rotmode= target->rotmode;
mult_m4_m4m4(ob->obmat, gob->obmat, target->obmat);
- if(gob->dup_group) { /* should always be true */
+ if (gob->dup_group) { /* should always be true */
float tvec[3];
copy_v3_v3(tvec, gob->dup_group->dupli_ofs);
mul_mat3_m4_v3(ob->obmat, tvec);
@@ -1351,8 +1351,8 @@ void object_make_proxy(Object *ob, Object *target, Object *gob)
/* copy material and index information */
ob->actcol= ob->totcol= 0;
- if(ob->mat) MEM_freeN(ob->mat);
- if(ob->matbits) MEM_freeN(ob->matbits);
+ if (ob->mat) MEM_freeN(ob->mat);
+ if (ob->matbits) MEM_freeN(ob->matbits);
ob->mat = NULL;
ob->matbits= NULL;
if ((target->totcol) && (target->mat) && OB_TYPE_SUPPORT_MATERIAL(ob->type)) {
@@ -1363,14 +1363,14 @@ void object_make_proxy(Object *ob, Object *target, Object *gob)
ob->mat = MEM_dupallocN(target->mat);
ob->matbits = MEM_dupallocN(target->matbits);
- for(i=0; i<target->totcol; i++) {
+ for (i=0; i<target->totcol; i++) {
/* dont need to run test_object_materials since we know this object is new and not used elsewhere */
id_us_plus((ID *)ob->mat[i]);
}
}
/* type conversions */
- if(target->type == OB_ARMATURE) {
+ if (target->type == OB_ARMATURE) {
copy_object_pose(ob, target); /* data copy, object pointers in constraints */
rest_pose(ob->pose); /* clear all transforms in channels */
armature_rebuild_pose(ob, ob->data); /* set all internal links */
@@ -1383,12 +1383,12 @@ void object_make_proxy(Object *ob, Object *target, Object *gob)
}
/* copy IDProperties */
- if(ob->id.properties) {
+ if (ob->id.properties) {
IDP_FreeProperty(ob->id.properties);
MEM_freeN(ob->id.properties);
ob->id.properties= NULL;
}
- if(target->id.properties) {
+ if (target->id.properties) {
ob->id.properties= IDP_CopyProperty(target->id.properties);
}
@@ -1471,7 +1471,7 @@ void object_mat3_to_rot(Object *ob, float mat[][3], short use_compat)
quat_to_mat3(tmat, quat);
/* end drot correction */
- if(use_compat) mat3_to_compatible_eulO(ob->rot, ob->rot, ob->rotmode, tmat);
+ if (use_compat) mat3_to_compatible_eulO(ob->rot, ob->rot, ob->rotmode, tmat);
else mat3_to_eulO(ob->rot, ob->rotmode, tmat);
}
}
@@ -1547,7 +1547,7 @@ void object_apply_mat4(Object *ob, float mat[][4], const short use_compat, const
{
float rot[3][3];
- if(use_parent && ob->parent) {
+ if (use_parent && ob->parent) {
float rmat[4][4], diff_mat[4][4], imat[4][4];
mult_m4_m4m4(diff_mat, ob->parent->obmat, ob->parentinv);
invert_m4_m4(imat, diff_mat);
@@ -1609,16 +1609,16 @@ static void ob_parcurve(Scene *scene, Object *ob, Object *par, float mat[][4])
unit_m4(mat);
cu= par->data;
- if(cu->path==NULL || cu->path->data==NULL) /* only happens on reload file, but violates depsgraph still... fix! */
+ if (cu->path==NULL || cu->path->data==NULL) /* only happens on reload file, but violates depsgraph still... fix! */
makeDispListCurveTypes(scene, par, 0);
- if(cu->path==NULL) return;
+ if (cu->path==NULL) return;
/* catch exceptions: feature for nla stride editing */
- if(ob->ipoflag & OB_DISABLE_PATH) {
+ if (ob->ipoflag & OB_DISABLE_PATH) {
ctime= 0.0f;
}
/* catch exceptions: curve paths used as a duplicator */
- else if(enable_cu_speed) {
+ else if (enable_cu_speed) {
/* ctime is now a proper var setting of Curve which gets set by Animato like any other var that's animated,
* but this will only work if it actually is animated...
*
@@ -1641,7 +1641,7 @@ static void ob_parcurve(Scene *scene, Object *ob, Object *par, float mat[][4])
}
/* time calculus is correct, now apply distance offset */
- if(cu->flag & CU_OFFS_PATHDIST) {
+ if (cu->flag & CU_OFFS_PATHDIST) {
ctime += timeoffs/cu->path->totdist;
/* restore */
@@ -1650,9 +1650,9 @@ static void ob_parcurve(Scene *scene, Object *ob, Object *par, float mat[][4])
/* vec: 4 items! */
- if( where_on_path(par, ctime, vec, dir, cu->flag & CU_FOLLOW ? quat:NULL, &radius, NULL) ) {
+ if ( where_on_path(par, ctime, vec, dir, cu->flag & CU_FOLLOW ? quat:NULL, &radius, NULL) ) {
- if(cu->flag & CU_FOLLOW) {
+ if (cu->flag & CU_FOLLOW) {
#if 0
float x1, q[4];
vec_to_quat( quat,dir, ob->trackflag, ob->upflag);
@@ -1672,7 +1672,7 @@ static void ob_parcurve(Scene *scene, Object *ob, Object *par, float mat[][4])
quat_to_mat4(mat, quat);
}
- if(cu->flag & CU_PATH_RADIUS) {
+ if (cu->flag & CU_PATH_RADIUS) {
float tmat[4][4], rmat[4][4];
scale_m4_fl(tmat, radius);
mult_m4_m4m4(rmat, tmat, mat);
@@ -1696,7 +1696,7 @@ static void ob_parbone(Object *ob, Object *par, float mat[][4])
/* Make sure the bone is still valid */
pchan= get_pose_channel(par->pose, ob->parsubstr);
- if (!pchan){
+ if (!pchan) {
printf ("Object %s with Bone parent: bone %s doesn't exist\n", ob->id.name+2, ob->parsubstr);
unit_m4(mat);
return;
@@ -1718,21 +1718,21 @@ static void give_parvert(Object *par, int nr, float *vec)
vec[0]=vec[1]=vec[2]= 0.0f;
- if(par->type==OB_MESH) {
+ if (par->type==OB_MESH) {
Mesh *me= par->data;
DerivedMesh *dm;
em = me->edit_btmesh;
#if 0 /* this was bmesh only, better, evaluate why this was needed - campbell*/
- if(em) {
+ if (em) {
BMVert *eve;
BMIter iter;
BM_ITER(eve, &iter, em->bm, BM_VERTS_OF_MESH, NULL) {
int *keyindex = CustomData_bmesh_get(&em->bm->vdata, eve->head.data, CD_SHAPE_KEYINDEX);
- if(keyindex && *keyindex==nr) {
+ if (keyindex && *keyindex==nr) {
copy_v3_v3(vec, eve->co);
break;
}
@@ -1742,17 +1742,17 @@ static void give_parvert(Object *par, int nr, float *vec)
dm = (em)? em->derivedFinal: par->derivedFinal;
- if(dm) {
+ if (dm) {
MVert *mvert= dm->getVertArray(dm);
int *index = (int *)dm->getVertDataArray(dm, CD_ORIGINDEX);
int i, vindex, numVerts = dm->getNumVerts(dm);
/* get the average of all verts with (original index == nr) */
count= 0;
- for(i = 0; i < numVerts; i++) {
+ for (i = 0; i < numVerts; i++) {
vindex= (index)? index[i]: i;
- if(vindex == nr) {
+ if (vindex == nr) {
add_v3_v3(vec, mvert[i].co);
count++;
}
@@ -1760,7 +1760,7 @@ static void give_parvert(Object *par, int nr, float *vec)
if (count==0) {
/* keep as 0,0,0 */
- } else if(count > 0) {
+ } else if (count > 0) {
mul_v3_fl(vec, 1.0f / count);
} else {
/* use first index if its out of range */
@@ -1782,12 +1782,12 @@ static void give_parvert(Object *par, int nr, float *vec)
nu= nurbs->first;
count= 0;
- while(nu && !found) {
- if(nu->type == CU_BEZIER) {
+ while (nu && !found) {
+ if (nu->type == CU_BEZIER) {
bezt= nu->bezt;
a= nu->pntsu;
- while(a--) {
- if(count==nr) {
+ while (a--) {
+ if (count==nr) {
found= 1;
copy_v3_v3(vec, bezt->vec[1]);
break;
@@ -1799,8 +1799,8 @@ static void give_parvert(Object *par, int nr, float *vec)
else {
bp= nu->bp;
a= nu->pntsu*nu->pntsv;
- while(a--) {
- if(count==nr) {
+ while (a--) {
+ if (count==nr) {
found= 1;
memcpy(vec, bp->vec, sizeof(float)*3);
break;
@@ -1813,27 +1813,27 @@ static void give_parvert(Object *par, int nr, float *vec)
}
}
- else if(par->type==OB_LATTICE) {
+ else if (par->type==OB_LATTICE) {
Lattice *latt= par->data;
BPoint *bp;
DispList *dl = find_displist(&par->disp, DL_VERTS);
float *co = dl?dl->verts:NULL;
- if(latt->editlatt) latt= latt->editlatt->latt;
+ if (latt->editlatt) latt= latt->editlatt->latt;
a= latt->pntsu*latt->pntsv*latt->pntsw;
count= 0;
bp= latt->def;
- while(a--) {
- if(count==nr) {
- if(co)
+ while (a--) {
+ if (count==nr) {
+ if (co)
memcpy(vec, co, 3*sizeof(float));
else
memcpy(vec, bp->vec, 3*sizeof(float));
break;
}
count++;
- if(co) co+= 3;
+ if (co) co+= 3;
else bp++;
}
}
@@ -1856,7 +1856,7 @@ static void ob_parvert3(Object *ob, Object *par, float mat[][4])
quat_to_mat3( cmat,q);
copy_m4_m3(mat, cmat);
- if(ob->type==OB_CURVE) {
+ if (ob->type==OB_CURVE) {
copy_v3_v3(mat[3], v1);
}
else {
@@ -1875,12 +1875,12 @@ static int where_is_object_parslow(Object *ob, float obmat[4][4], float slowmat[
// include framerate
fac1= ( 1.0f / (1.0f + fabsf(ob->sf)) );
- if(fac1 >= 1.0f) return 0;
+ if (fac1 >= 1.0f) return 0;
fac2= 1.0f-fac1;
fp1= obmat[0];
fp2= slowmat[0];
- for(a=0; a<16; a++, fp1++, fp2++) {
+ for (a=0; a<16; a++, fp1++, fp2++) {
fp1[0]= fac1*fp1[0] + fac2*fp2[0];
}
@@ -1896,21 +1896,21 @@ void where_is_object_time(Scene *scene, Object *ob, float ctime)
/* this one only calculates direct attached parent and track */
/* is faster, but should keep track of timeoffs */
- if(ob==NULL) return;
+ if (ob==NULL) return;
/* execute drivers only, as animation has already been done */
BKE_animsys_evaluate_animdata(scene, &ob->id, ob->adt, ctime, ADT_RECALC_DRIVERS);
- if(ob->parent) {
+ if (ob->parent) {
Object *par= ob->parent;
/* hurms, code below conflicts with depgraph... (ton) */
/* and even worse, it gives bad effects for NLA stride too (try ctime != par->ctime, with MBlur) */
- if(stime != par->ctime) {
+ if (stime != par->ctime) {
// only for ipo systems?
Object tmp= *par;
- if(par->proxy_from); // was a copied matrix, no where_is! bad...
+ if (par->proxy_from); // was a copied matrix, no where_is! bad...
else where_is_object_time(scene, par, ctime);
solve_parenting(scene, ob, par, ob->obmat, slowmat, 0);
@@ -1923,8 +1923,8 @@ void where_is_object_time(Scene *scene, Object *ob, float ctime)
/* "slow parent" is definitely not threadsafe, and may also give bad results jumping around
* An old-fashioned hack which probably doesn't really cut it anymore
*/
- if(ob->partype & PARSLOW) {
- if(!where_is_object_parslow(ob, ob->obmat, slowmat))
+ if (ob->partype & PARSLOW) {
+ if (!where_is_object_parslow(ob, ob->obmat, slowmat))
return;
}
}
@@ -1945,7 +1945,7 @@ void where_is_object_time(Scene *scene, Object *ob, float ctime)
}
/* set negative scale flag in object */
- if(is_negative_m4(ob->obmat)) ob->transflag |= OB_NEG_SCALE;
+ if (is_negative_m4(ob->obmat)) ob->transflag |= OB_NEG_SCALE;
else ob->transflag &= ~OB_NEG_SCALE;
}
@@ -1957,12 +1957,12 @@ void where_is_object_mat(Scene *scene, Object *ob, float obmat[4][4])
{
float slowmat[4][4] = MAT4_UNITY;
- if(ob->parent) {
+ if (ob->parent) {
Object *par= ob->parent;
solve_parenting(scene, ob, par, obmat, slowmat, 1);
- if(ob->partype & PARSLOW)
+ if (ob->partype & PARSLOW)
where_is_object_parslow(ob, obmat, slowmat);
}
else {
@@ -1980,19 +1980,19 @@ static void solve_parenting (Scene *scene, Object *ob, Object *par, float obmat[
object_to_mat4(ob, locmat);
- if(ob->partype & PARSLOW) copy_m4_m4(slowmat, obmat);
+ if (ob->partype & PARSLOW) copy_m4_m4(slowmat, obmat);
switch(ob->partype & PARTYPE) {
case PAROBJECT:
ok= 0;
- if(par->type==OB_CURVE) {
- if( ((Curve *)par->data)->flag & CU_PATH ) {
+ if (par->type==OB_CURVE) {
+ if ( ((Curve *)par->data)->flag & CU_PATH ) {
ob_parcurve(scene, ob, par, tmat);
ok= 1;
}
}
- if(ok) mul_serie_m4(totmat, par->obmat, tmat,
+ if (ok) mul_serie_m4(totmat, par->obmat, tmat,
NULL, NULL, NULL, NULL, NULL, NULL);
else copy_m4_m4(totmat, par->obmat);
@@ -2005,7 +2005,7 @@ static void solve_parenting (Scene *scene, Object *ob, Object *par, float obmat[
case PARVERT1:
unit_m4(totmat);
- if (simul){
+ if (simul) {
copy_v3_v3(totmat[3], par->obmat[3]);
}
else{
@@ -2039,7 +2039,7 @@ static void solve_parenting (Scene *scene, Object *ob, Object *par, float obmat[
copy_m3_m4(originmat, tmat);
// origin, voor help line
- if( (ob->partype & PARTYPE)==PARSKEL ) {
+ if ( (ob->partype & PARTYPE)==PARSKEL ) {
copy_v3_v3(ob->orig, par->obmat[3]);
}
else {
@@ -2067,17 +2067,17 @@ for a lamp that is the child of another object */
int a;
/* NO TIMEOFFS */
- if(ob->parent) {
+ if (ob->parent) {
par= ob->parent;
solve_parenting(scene, ob, par, ob->obmat, slowmat, 1);
- if(ob->partype & PARSLOW) {
+ if (ob->partype & PARSLOW) {
fac1= (float)(1.0/(1.0+ fabs(ob->sf)));
fac2= 1.0f-fac1;
fp1= ob->obmat[0];
fp2= slowmat[0];
- for(a=0; a<16; a++, fp1++, fp2++) {
+ for (a=0; a<16; a++, fp1++, fp2++) {
fp1[0]= fac1*fp1[0] + fac2*fp2[0];
}
}
@@ -2149,13 +2149,13 @@ BoundBox *object_get_boundbox(Object *ob)
{
BoundBox *bb= NULL;
- if(ob->type==OB_MESH) {
+ if (ob->type==OB_MESH) {
bb = mesh_get_bb(ob);
}
else if (ELEM3(ob->type, OB_CURVE, OB_SURF, OB_FONT)) {
bb= ob->bb ? ob->bb : ( (Curve *)ob->data )->bb;
}
- else if(ob->type==OB_MBALL) {
+ else if (ob->type==OB_MBALL) {
bb= ob->bb;
}
return bb;
@@ -2165,8 +2165,8 @@ BoundBox *object_get_boundbox(Object *ob)
void object_boundbox_flag(Object *ob, int flag, int set)
{
BoundBox *bb= object_get_boundbox(ob);
- if(bb) {
- if(set) bb->flag |= flag;
+ if (bb) {
+ if (set) bb->flag |= flag;
else bb->flag &= ~flag;
}
}
@@ -2223,10 +2223,10 @@ void minmax_object(Object *ob, float min[3], float max[3])
{
Curve *cu= ob->data;
- if(cu->bb==NULL) tex_space_curve(cu);
+ if (cu->bb==NULL) tex_space_curve(cu);
bb= *(cu->bb);
- for(a=0; a<8; a++) {
+ for (a=0; a<8; a++) {
mul_m4_v3(ob->obmat, bb.vec[a]);
DO_MINMAX(bb.vec[a], min, max);
}
@@ -2239,9 +2239,9 @@ void minmax_object(Object *ob, float min[3], float max[3])
BPoint *bp= lt->def;
int u, v, w;
- for(w=0; w<lt->pntsw; w++) {
- for(v=0; v<lt->pntsv; v++) {
- for(u=0; u<lt->pntsu; u++, bp++) {
+ for (w=0; w<lt->pntsw; w++) {
+ for (v=0; v<lt->pntsv; v++) {
+ for (u=0; u<lt->pntsu; u++, bp++) {
mul_v3_m4v3(vec, ob->obmat, bp->vec);
DO_MINMAX(vec, min, max);
}
@@ -2251,9 +2251,9 @@ void minmax_object(Object *ob, float min[3], float max[3])
}
break;
case OB_ARMATURE:
- if(ob->pose) {
+ if (ob->pose) {
bPoseChannel *pchan;
- for(pchan= ob->pose->chanbase.first; pchan; pchan= pchan->next) {
+ for (pchan= ob->pose->chanbase.first; pchan; pchan= pchan->next) {
mul_v3_m4v3(vec, ob->obmat, pchan->pose_head);
DO_MINMAX(vec, min, max);
mul_v3_m4v3(vec, ob->obmat, pchan->pose_tail);
@@ -2266,10 +2266,10 @@ void minmax_object(Object *ob, float min[3], float max[3])
{
Mesh *me= get_mesh(ob);
- if(me) {
+ if (me) {
bb = *mesh_get_bb(ob);
- for(a=0; a<8; a++) {
+ for (a=0; a<8; a++) {
mul_m4_v3(ob->obmat, bb.vec[a]);
DO_MINMAX(bb.vec[a], min, max);
}
@@ -2279,7 +2279,7 @@ void minmax_object(Object *ob, float min[3], float max[3])
break;
}
- if(change == FALSE) {
+ if (change == FALSE) {
DO_MINMAX(ob->obmat[3], min, max);
copy_v3_v3(vec, ob->obmat[3]);
@@ -2302,13 +2302,13 @@ int minmax_object_duplis(Scene *scene, Object *ob, float *min, float *max)
DupliObject *dob;
lb= object_duplilist(scene, ob);
- for(dob= lb->first; dob; dob= dob->next) {
- if(dob->no_draw == 0) {
+ for (dob= lb->first; dob; dob= dob->next) {
+ if (dob->no_draw == 0) {
BoundBox *bb= object_get_boundbox(dob->ob);
- if(bb) {
+ if (bb) {
int i;
- for(i=0; i<8; i++) {
+ for (i=0; i<8; i++) {
float vec[3];
mul_v3_m4v3(vec, dob->mat, bb->vec[i]);
DO_MINMAX(vec, min, max);
@@ -2364,8 +2364,8 @@ void BKE_scene_foreach_display_point(
Base *base;
Object *ob;
- for(base= FIRSTBASE; base; base = base->next) {
- if(BASE_VISIBLE(v3d, base) && (base->flag & flag) == flag) {
+ for (base= FIRSTBASE; base; base = base->next) {
+ if (BASE_VISIBLE(v3d, base) && (base->flag & flag) == flag) {
ob= base->object;
if ((ob->transflag & OB_DUPLI)==0) {
@@ -2376,8 +2376,8 @@ void BKE_scene_foreach_display_point(
DupliObject *dob;
lb= object_duplilist(scene, ob);
- for(dob= lb->first; dob; dob= dob->next) {
- if(dob->no_draw == 0) {
+ for (dob= lb->first; dob; dob= dob->next) {
+ if (dob->no_draw == 0) {
BKE_object_foreach_display_point(dob->ob, dob->mat, func_cb, user_data);
}
}
@@ -2450,8 +2450,8 @@ void object_tfm_restore(Object *ob, void *obtfm_pt)
int BKE_object_parent_loop_check(const Object *par, const Object *ob)
{
/* test if 'ob' is a parent somewhere in par's parents */
- if(par == NULL) return 0;
- if(ob == par) return 1;
+ if (par == NULL) return 0;
+ if (ob == par) return 1;
return BKE_object_parent_loop_check(par->parent, ob);
}
@@ -2464,18 +2464,18 @@ int BKE_object_parent_loop_check(const Object *par, const Object *ob)
/* requires flags to be set! */
void object_handle_update(Scene *scene, Object *ob)
{
- if(ob->recalc & OB_RECALC_ALL) {
+ if (ob->recalc & OB_RECALC_ALL) {
/* speed optimization for animation lookups */
- if(ob->pose)
+ if (ob->pose)
make_pose_channels_hash(ob->pose);
- if(ob->recalc & OB_RECALC_DATA) {
- if(ob->type==OB_ARMATURE) {
+ if (ob->recalc & OB_RECALC_DATA) {
+ if (ob->type==OB_ARMATURE) {
/* this happens for reading old files and to match library armatures
with poses we do it ahead of where_is_object to ensure animation
is evaluated on the rebuilt pose, otherwise we get incorrect poses
on file load */
- if(ob->pose==NULL || (ob->pose->flag & POSE_RECALC))
+ if (ob->pose==NULL || (ob->pose->flag & POSE_RECALC))
armature_rebuild_pose(ob, ob->data);
}
}
@@ -2483,19 +2483,19 @@ void object_handle_update(Scene *scene, Object *ob)
/* XXX new animsys warning: depsgraph tag OB_RECALC_DATA should not skip drivers,
which is only in where_is_object now */
// XXX: should this case be OB_RECALC_OB instead?
- if(ob->recalc & OB_RECALC_ALL) {
+ if (ob->recalc & OB_RECALC_ALL) {
if (G.f & G_DEBUG)
printf("recalcob %s\n", ob->id.name+2);
/* handle proxy copy for target */
- if(ob->id.lib && ob->proxy_from) {
+ if (ob->id.lib && ob->proxy_from) {
// printf("ob proxy copy, lib ob %s proxy %s\n", ob->id.name, ob->proxy_from->id.name);
- if(ob->proxy_from->proxy_group) {/* transform proxy into group space */
+ if (ob->proxy_from->proxy_group) {/* transform proxy into group space */
Object *obg= ob->proxy_from->proxy_group;
invert_m4_m4(obg->imat, obg->obmat);
mult_m4_m4m4(ob->obmat, obg->imat, ob->proxy_from->obmat);
- if(obg->dup_group) { /* should always be true */
+ if (obg->dup_group) { /* should always be true */
add_v3_v3(ob->obmat[3], obg->dup_group->dupli_ofs);
}
}
@@ -2506,7 +2506,7 @@ void object_handle_update(Scene *scene, Object *ob)
where_is_object(scene, ob);
}
- if(ob->recalc & OB_RECALC_DATA) {
+ if (ob->recalc & OB_RECALC_DATA) {
ID *data_id= (ID *)ob->data;
AnimData *adt= BKE_animdata_from_id(data_id);
float ctime= (float)scene->r.cfra; // XXX this is bad...
@@ -2516,7 +2516,7 @@ void object_handle_update(Scene *scene, Object *ob)
if (G.f & G_DEBUG)
printf("recalcdata %s\n", ob->id.name+2);
- if(adt) {
+ if (adt) {
/* evaluate drivers */
// XXX: for mesh types, should we push this to derivedmesh instead?
BKE_animsys_evaluate_animdata(scene, data_id, adt, ctime, ADT_RECALC_DRIVERS);
@@ -2529,7 +2529,7 @@ void object_handle_update(Scene *scene, Object *ob)
#if 0 // XXX, comment for 2.56a release, background wont set 'scene->customdata_mask'
BMEditMesh *em = (ob == scene->obedit)? ((Mesh*)ob->data)->edit_btmesh : NULL;
BLI_assert((scene->customdata_mask & CD_MASK_BAREMESH) == CD_MASK_BAREMESH);
- if(em) {
+ if (em) {
makeDerivedMesh(scene, ob, em, scene->customdata_mask, 0); /* was CD_MASK_BAREMESH */
}
else {
@@ -2539,7 +2539,7 @@ void object_handle_update(Scene *scene, Object *ob)
#else /* ensure CD_MASK_BAREMESH for now */
BMEditMesh *em = (ob == scene->obedit)? ((Mesh*)ob->data)->edit_btmesh : NULL;
uint64_t data_mask= scene->customdata_mask | ob->customdata_mask | CD_MASK_BAREMESH;
- if(em) {
+ if (em) {
makeDerivedMesh(scene, ob, em, data_mask, 0); /* was CD_MASK_BAREMESH */
}
else {
@@ -2551,7 +2551,7 @@ void object_handle_update(Scene *scene, Object *ob)
break;
case OB_ARMATURE:
- if(ob->id.lib && ob->proxy_from) {
+ if (ob->id.lib && ob->proxy_from) {
// printf("pose proxy copy, lib ob %s proxy %s\n", ob->id.name, ob->proxy_from->id.name);
copy_pose_result(ob->pose, ob->proxy_from->pose);
}
@@ -2576,16 +2576,16 @@ void object_handle_update(Scene *scene, Object *ob)
}
- if(ob->particlesystem.first) {
+ if (ob->particlesystem.first) {
ParticleSystem *tpsys, *psys;
DerivedMesh *dm;
ob->transflag &= ~OB_DUPLIPARTS;
psys= ob->particlesystem.first;
- while(psys) {
- if(psys_check_enabled(ob, psys)) {
+ while (psys) {
+ if (psys_check_enabled(ob, psys)) {
/* check use of dupli objects here */
- if(psys->part && (psys->part->draw_as == PART_DRAW_REND || G.rendering) &&
+ if (psys->part && (psys->part->draw_as == PART_DRAW_REND || G.rendering) &&
((psys->part->ren_as == PART_DRAW_OB && psys->part->dup_ob)
|| (psys->part->ren_as == PART_DRAW_GR && psys->part->dup_group)))
ob->transflag |= OB_DUPLIPARTS;
@@ -2593,7 +2593,7 @@ void object_handle_update(Scene *scene, Object *ob)
particle_system_update(scene, ob, psys);
psys= psys->next;
}
- else if(psys->flag & PSYS_DELETE) {
+ else if (psys->flag & PSYS_DELETE) {
tpsys=psys->next;
BLI_remlink(&ob->particlesystem, psys);
psys_free(ob,psys);
@@ -2603,14 +2603,14 @@ void object_handle_update(Scene *scene, Object *ob)
psys= psys->next;
}
- if(G.rendering && ob->transflag & OB_DUPLIPARTS) {
+ if (G.rendering && ob->transflag & OB_DUPLIPARTS) {
/* this is to make sure we get render level duplis in groups:
* the derivedmesh must be created before init_render_mesh,
* since object_duplilist does dupliparticles before that */
dm = mesh_create_derived_render(scene, ob, CD_MASK_BAREMESH|CD_MASK_MTFACE|CD_MASK_MCOL);
dm->release(dm);
- for(psys=ob->particlesystem.first; psys; psys=psys->next)
+ for (psys=ob->particlesystem.first; psys; psys=psys->next)
psys_get_modifier(ob, psys)->flag &= ~eParticleSystemFlag_psys_updated;
}
}
@@ -2618,12 +2618,12 @@ void object_handle_update(Scene *scene, Object *ob)
/* check if quick cache is needed */
BKE_ptcache_ids_from_object(&pidlist, ob, scene, MAX_DUPLI_RECUR);
- for(pid=pidlist.first; pid; pid=pid->next) {
- if((pid->cache->flag & PTCACHE_BAKED)
+ for (pid=pidlist.first; pid; pid=pid->next) {
+ if ((pid->cache->flag & PTCACHE_BAKED)
|| (pid->cache->flag & PTCACHE_QUICK_CACHE)==0)
continue;
- if(pid->cache->flag & PTCACHE_OUTDATED || (pid->cache->flag & PTCACHE_SIMULATION_VALID)==0) {
+ if (pid->cache->flag & PTCACHE_OUTDATED || (pid->cache->flag & PTCACHE_SIMULATION_VALID)==0) {
scene->physics_settings.quick_cache_step =
scene->physics_settings.quick_cache_step ?
MIN2(scene->physics_settings.quick_cache_step, pid->cache->step) :
@@ -2635,7 +2635,7 @@ void object_handle_update(Scene *scene, Object *ob)
}
/* the no-group proxy case, we call update */
- if(ob->proxy && ob->proxy_group==NULL) {
+ if (ob->proxy && ob->proxy_group==NULL) {
/* set pointer in library proxy target, for copying, but restore it */
ob->proxy->proxy_from= ob;
// printf("call update, lib ob %s proxy %s\n", ob->proxy->id.name, ob->id.name);
@@ -2646,7 +2646,7 @@ void object_handle_update(Scene *scene, Object *ob)
}
/* the case when this is a group proxy, object_update is called in group.c */
- if(ob->proxy) {
+ if (ob->proxy) {
ob->proxy->proxy_from= ob;
// printf("set proxy pointer for later group stuff %s\n", ob->id.name);
}
@@ -2656,11 +2656,11 @@ void object_sculpt_modifiers_changed(Object *ob)
{
SculptSession *ss= ob->sculpt;
- if(!ss->cache) {
+ if (!ss->cache) {
/* we free pbvh on changes, except during sculpt since it can't deal with
changing PVBH node organization, we hope topology does not change in
the meantime .. weak */
- if(ss->pbvh) {
+ if (ss->pbvh) {
BLI_pbvh_free(ss->pbvh);
ss->pbvh= NULL;
}
@@ -2672,7 +2672,7 @@ void object_sculpt_modifiers_changed(Object *ob)
BLI_pbvh_search_gather(ss->pbvh, NULL, NULL, &nodes, &totnode);
- for(n = 0; n < totnode; n++)
+ for (n = 0; n < totnode; n++)
BLI_pbvh_node_mark_update(nodes[n]);
MEM_freeN(nodes);
@@ -2750,7 +2750,7 @@ int ray_hit_boundbox(struct BoundBox *bb, float ray_start[3], float ray_normal[3
static int pc_cmp(void *a, void *b)
{
LinkData *ad = a, *bd = b;
- if(GET_INT_FROM_POINTER(ad->data) > GET_INT_FROM_POINTER(bd->data))
+ if (GET_INT_FROM_POINTER(ad->data) > GET_INT_FROM_POINTER(bd->data))
return 1;
else return 0;
}
@@ -2762,11 +2762,11 @@ int object_insert_ptcache(Object *ob)
BLI_sortlist(&ob->pc_ids, pc_cmp);
- for(link=ob->pc_ids.first, i = 0; link; link=link->next, i++)
+ for (link=ob->pc_ids.first, i = 0; link; link=link->next, i++)
{
int index = GET_INT_FROM_POINTER(link->data);
- if(i < index)
+ if (i < index)
break;
}
@@ -2815,13 +2815,13 @@ static KeyBlock *insert_meshkey(Scene *scene, Object *ob, const char *name, int
KeyBlock *kb;
int newkey= 0;
- if(key == NULL) {
+ if (key == NULL) {
key= me->key= add_key((ID *)me);
key->type= KEY_RELATIVE;
newkey= 1;
}
- if(newkey || from_mix==FALSE) {
+ if (newkey || from_mix==FALSE) {
/* create from mesh */
kb= add_keyblock(key, name);
mesh_to_key(me, kb);
@@ -2846,13 +2846,13 @@ static KeyBlock *insert_lattkey(Scene *scene, Object *ob, const char *name, int
KeyBlock *kb;
int newkey= 0;
- if(key==NULL) {
+ if (key==NULL) {
key= lt->key= add_key( (ID *)lt);
key->type= KEY_RELATIVE;
newkey= 1;
}
- if(newkey || from_mix==FALSE) {
+ if (newkey || from_mix==FALSE) {
kb= add_keyblock(key, name);
if (!newkey) {
KeyBlock *basekb= (KeyBlock *)key->block.first;
@@ -2884,13 +2884,13 @@ static KeyBlock *insert_curvekey(Scene *scene, Object *ob, const char *name, int
ListBase *lb= BKE_curve_nurbs(cu);
int newkey= 0;
- if(key==NULL) {
+ if (key==NULL) {
key= cu->key= add_key( (ID *)cu);
key->type = KEY_RELATIVE;
newkey= 1;
}
- if(newkey || from_mix==FALSE) {
+ if (newkey || from_mix==FALSE) {
/* create from curve */
kb= add_keyblock(key, name);
if (!newkey) {
@@ -2917,9 +2917,9 @@ static KeyBlock *insert_curvekey(Scene *scene, Object *ob, const char *name, int
KeyBlock *object_insert_shape_key(Scene *scene, Object *ob, const char *name, int from_mix)
{
- if(ob->type==OB_MESH) return insert_meshkey(scene, ob, name, from_mix);
+ if (ob->type==OB_MESH) return insert_meshkey(scene, ob, name, from_mix);
else if ELEM(ob->type, OB_CURVE, OB_SURF)return insert_curvekey(scene, ob, name, from_mix);
- else if(ob->type==OB_LATTICE) return insert_lattkey(scene, ob, name, from_mix);
+ else if (ob->type==OB_LATTICE) return insert_lattkey(scene, ob, name, from_mix);
else return NULL;
}
@@ -2930,15 +2930,23 @@ int object_is_modified(Scene *scene, Object *ob)
{
int flag= 0;
- if(ob_get_key(ob)) {
+ if (ob_get_key(ob)) {
flag |= eModifierMode_Render;
}
else {
ModifierData *md;
/* cloth */
- for(md=modifiers_getVirtualModifierList(ob); md && (flag != (eModifierMode_Render | eModifierMode_Realtime)); md=md->next) {
- if((flag & eModifierMode_Render) == 0 && modifier_isEnabled(scene, md, eModifierMode_Render)) flag |= eModifierMode_Render;
- if((flag & eModifierMode_Realtime) == 0 && modifier_isEnabled(scene, md, eModifierMode_Realtime)) flag |= eModifierMode_Realtime;
+ for (md=modifiers_getVirtualModifierList(ob);
+ md && (flag != (eModifierMode_Render | eModifierMode_Realtime));
+ md=md->next)
+ {
+ if ((flag & eModifierMode_Render) == 0 && modifier_isEnabled(scene, md, eModifierMode_Render)) {
+ flag |= eModifierMode_Render;
+ }
+
+ if ((flag & eModifierMode_Realtime) == 0 && modifier_isEnabled(scene, md, eModifierMode_Realtime)) {
+ flag |= eModifierMode_Realtime;
+ }
}
}
@@ -2948,24 +2956,24 @@ int object_is_modified(Scene *scene, Object *ob)
static void copy_object__forwardModifierLinks(void *UNUSED(userData), Object *UNUSED(ob), ID **idpoin)
{
/* this is copied from ID_NEW; it might be better to have a macro */
- if(*idpoin && (*idpoin)->newid) *idpoin = (*idpoin)->newid;
+ if (*idpoin && (*idpoin)->newid) *idpoin = (*idpoin)->newid;
}
void object_relink(Object *ob)
{
- if(ob->id.lib)
+ if (ob->id.lib)
return;
relink_constraints(&ob->constraints);
- if (ob->pose){
+ if (ob->pose) {
bPoseChannel *chan;
- for (chan = ob->pose->chanbase.first; chan; chan=chan->next){
+ for (chan = ob->pose->chanbase.first; chan; chan=chan->next) {
relink_constraints(&chan->constraints);
}
}
modifiers_foreachIDLink(ob, copy_object__forwardModifierLinks, NULL);
- if(ob->adt)
+ if (ob->adt)
BKE_relink_animdata(ob->adt);
ID_NEW(ob->parent);
@@ -2979,18 +2987,18 @@ MovieClip *object_get_movieclip(Scene *scene, Object *ob, int use_default)
MovieClip *clip= use_default ? scene->clip : NULL;
bConstraint *con= ob->constraints.first, *scon= NULL;
- while(con){
- if(con->type==CONSTRAINT_TYPE_CAMERASOLVER){
- if(scon==NULL || (scon->flag&CONSTRAINT_OFF))
+ while (con) {
+ if (con->type==CONSTRAINT_TYPE_CAMERASOLVER) {
+ if (scon==NULL || (scon->flag&CONSTRAINT_OFF))
scon= con;
}
con= con->next;
}
- if(scon) {
+ if (scon) {
bCameraSolverConstraint *solver= scon->data;
- if((solver->flag&CAMERASOLVER_ACTIVECLIP)==0)
+ if ((solver->flag&CAMERASOLVER_ACTIVECLIP)==0)
clip= solver->clip;
else
clip= scene->clip;
diff --git a/source/blender/blenkernel/intern/ocean.c b/source/blender/blenkernel/intern/ocean.c
index 15ce2e377b6..f1412981935 100644
--- a/source/blender/blenkernel/intern/ocean.c
+++ b/source/blender/blenkernel/intern/ocean.c
@@ -869,12 +869,12 @@ void BKE_init_ocean(struct Ocean* o, int M,int N, float Lx, float Lz, float V, f
o->_fft_in = (fftw_complex*) MEM_mallocN(o->_M * (1+o->_N/2) * sizeof(fftw_complex), "ocean_fft_in");
o->_htilda = (fftw_complex*) MEM_mallocN(o->_M * (1+o->_N/2) * sizeof(fftw_complex), "ocean_htilda");
- if (o->_do_disp_y){
+ if (o->_do_disp_y) {
o->_disp_y = (double*) MEM_mallocN(o->_M * o->_N * sizeof(double), "ocean_disp_y");
o->_disp_y_plan = fftw_plan_dft_c2r_2d(o->_M,o->_N, o->_fft_in, o->_disp_y, FFTW_ESTIMATE);
}
- if (o->_do_normals){
+ if (o->_do_normals) {
o->_fft_in_nx = (fftw_complex*) MEM_mallocN(o->_M * (1+o->_N/2) * sizeof(fftw_complex), "ocean_fft_in_nx");
o->_fft_in_nz = (fftw_complex*) MEM_mallocN(o->_M * (1+o->_N/2) * sizeof(fftw_complex), "ocean_fft_in_nz");
@@ -886,7 +886,7 @@ void BKE_init_ocean(struct Ocean* o, int M,int N, float Lx, float Lz, float V, f
o->_N_z_plan = fftw_plan_dft_c2r_2d(o->_M,o->_N, o->_fft_in_nz, o->_N_z, FFTW_ESTIMATE);
}
- if (o->_do_chop){
+ if (o->_do_chop) {
o->_fft_in_x = (fftw_complex*) MEM_mallocN(o->_M * (1+o->_N/2) * sizeof(fftw_complex), "ocean_fft_in_x");
o->_fft_in_z = (fftw_complex*) MEM_mallocN(o->_M * (1+o->_N/2) * sizeof(fftw_complex), "ocean_fft_in_z");
@@ -896,7 +896,7 @@ void BKE_init_ocean(struct Ocean* o, int M,int N, float Lx, float Lz, float V, f
o->_disp_x_plan = fftw_plan_dft_c2r_2d(o->_M,o->_N, o->_fft_in_x, o->_disp_x, FFTW_ESTIMATE);
o->_disp_z_plan = fftw_plan_dft_c2r_2d(o->_M,o->_N, o->_fft_in_z, o->_disp_z, FFTW_ESTIMATE);
}
- if (o->_do_jacobian){
+ if (o->_do_jacobian) {
o->_fft_in_jxx = (fftw_complex*) MEM_mallocN(o->_M * (1+o->_N/2) * sizeof(fftw_complex), "ocean_fft_in_jxx");
o->_fft_in_jzz = (fftw_complex*) MEM_mallocN(o->_M * (1+o->_N/2) * sizeof(fftw_complex), "ocean_fft_in_jzz");
o->_fft_in_jxz = (fftw_complex*) MEM_mallocN(o->_M * (1+o->_N/2) * sizeof(fftw_complex), "ocean_fft_in_jxz");
diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c
index c8ec71d512f..e01cd992ad8 100644
--- a/source/blender/blenkernel/intern/scene.c
+++ b/source/blender/blenkernel/intern/scene.c
@@ -86,12 +86,12 @@
void free_avicodecdata(AviCodecData *acd)
{
if (acd) {
- if (acd->lpFormat){
+ if (acd->lpFormat) {
MEM_freeN(acd->lpFormat);
acd->lpFormat = NULL;
acd->cbFormat = 0;
}
- if (acd->lpParms){
+ if (acd->lpParms) {
MEM_freeN(acd->lpParms);
acd->lpParms = NULL;
acd->cbParms = 0;
@@ -102,7 +102,7 @@ void free_avicodecdata(AviCodecData *acd)
void free_qtcodecdata(QuicktimeCodecData *qcd)
{
if (qcd) {
- if (qcd->cdParms){
+ if (qcd->cdParms) {
MEM_freeN(qcd->cdParms);
qcd->cdParms = NULL;
qcd->cdSize = 0;
@@ -116,7 +116,7 @@ Scene *copy_scene(Scene *sce, int type)
ToolSettings *ts;
Base *base, *obase;
- if(type == SCE_COPY_EMPTY) {
+ if (type == SCE_COPY_EMPTY) {
ListBase lb;
scen= add_scene(sce->id.name+2);
@@ -142,22 +142,22 @@ Scene *copy_scene(Scene *sce, int type)
scen->fps_info= NULL;
ts= scen->toolsettings;
- if(ts) {
- if(ts->vpaint) {
+ if (ts) {
+ if (ts->vpaint) {
ts->vpaint= MEM_dupallocN(ts->vpaint);
ts->vpaint->paintcursor= NULL;
ts->vpaint->vpaint_prev= NULL;
ts->vpaint->wpaint_prev= NULL;
copy_paint(&ts->vpaint->paint, &ts->vpaint->paint);
}
- if(ts->wpaint) {
+ if (ts->wpaint) {
ts->wpaint= MEM_dupallocN(ts->wpaint);
ts->wpaint->paintcursor= NULL;
ts->wpaint->vpaint_prev= NULL;
ts->wpaint->wpaint_prev= NULL;
copy_paint(&ts->wpaint->paint, &ts->wpaint->paint);
}
- if(ts->sculpt) {
+ if (ts->sculpt) {
ts->sculpt= MEM_dupallocN(ts->sculpt);
copy_paint(&ts->sculpt->paint, &ts->sculpt->paint);
}
@@ -173,16 +173,16 @@ Scene *copy_scene(Scene *sce, int type)
BLI_duplicatelist(&(scen->r.layers), &(sce->r.layers));
BKE_keyingsets_copy(&(scen->keyingsets), &(sce->keyingsets));
- if(sce->nodetree) {
+ if (sce->nodetree) {
scen->nodetree= ntreeCopyTree(sce->nodetree); /* copies actions */
ntreeSwitchID(scen->nodetree, &sce->id, &scen->id);
}
obase= sce->base.first;
base= scen->base.first;
- while(base) {
+ while (base) {
id_us_plus(&base->object->id);
- if(obase==sce->basact) scen->basact= base;
+ if (obase==sce->basact) scen->basact= base;
obase= obase->next;
base= base->next;
@@ -190,19 +190,19 @@ Scene *copy_scene(Scene *sce, int type)
}
/* make a private copy of the avicodecdata */
- if(sce->r.avicodecdata) {
+ if (sce->r.avicodecdata) {
scen->r.avicodecdata = MEM_dupallocN(sce->r.avicodecdata);
scen->r.avicodecdata->lpFormat = MEM_dupallocN(scen->r.avicodecdata->lpFormat);
scen->r.avicodecdata->lpParms = MEM_dupallocN(scen->r.avicodecdata->lpParms);
}
/* make a private copy of the qtcodecdata */
- if(sce->r.qtcodecdata) {
+ if (sce->r.qtcodecdata) {
scen->r.qtcodecdata = MEM_dupallocN(sce->r.qtcodecdata);
scen->r.qtcodecdata->cdParms = MEM_dupallocN(scen->r.qtcodecdata->cdParms);
}
- if(sce->r.ffcodecdata.properties) { /* intentionally check scen not sce. */
+ if (sce->r.ffcodecdata.properties) { /* intentionally check scen not sce. */
scen->r.ffcodecdata.properties= IDP_CopyProperty(sce->r.ffcodecdata.properties);
}
@@ -210,7 +210,7 @@ Scene *copy_scene(Scene *sce, int type)
* are done outside of blenkernel with ED_objects_single_users! */
/* camera */
- if(type == SCE_COPY_LINK_DATA || type == SCE_COPY_FULL) {
+ if (type == SCE_COPY_LINK_DATA || type == SCE_COPY_FULL) {
ID_NEW(scen->camera);
}
@@ -218,15 +218,15 @@ Scene *copy_scene(Scene *sce, int type)
sound_create_scene(scen);
/* world */
- if(type == SCE_COPY_FULL) {
+ if (type == SCE_COPY_FULL) {
BKE_copy_animdata_id_action((ID *)scen);
- if(scen->world) {
+ if (scen->world) {
id_us_plus((ID *)scen->world);
scen->world= copy_world(scen->world);
BKE_copy_animdata_id_action((ID *)scen->world);
}
- if(sce->ed) {
+ if (sce->ed) {
scen->ed= MEM_callocN( sizeof(Editing), "addseq");
scen->ed->seqbasep= &scen->ed->seqbase;
seqbase_dupli_recursive(sce, scen, &scen->ed->seqbase, &sce->ed->seqbase, SEQ_DUPE_ALL);
@@ -242,13 +242,13 @@ void free_scene(Scene *sce)
Base *base;
base= sce->base.first;
- while(base) {
+ while (base) {
base->object->id.us--;
base= base->next;
}
/* do not free objects! */
- if(sce->gpd) {
+ if (sce->gpd) {
#if 0 // removed since this can be invalid memory when freeing everything
// since the grease pencil data is free'd before the scene.
// since grease pencil data is not (yet?), shared between objects
@@ -284,20 +284,20 @@ void free_scene(Scene *sce)
BLI_freelistN(&sce->transform_spaces);
BLI_freelistN(&sce->r.layers);
- if(sce->toolsettings) {
- if(sce->toolsettings->vpaint) {
+ if (sce->toolsettings) {
+ if (sce->toolsettings->vpaint) {
free_paint(&sce->toolsettings->vpaint->paint);
MEM_freeN(sce->toolsettings->vpaint);
}
- if(sce->toolsettings->wpaint) {
+ if (sce->toolsettings->wpaint) {
free_paint(&sce->toolsettings->wpaint->paint);
MEM_freeN(sce->toolsettings->wpaint);
}
- if(sce->toolsettings->sculpt) {
+ if (sce->toolsettings->sculpt) {
free_paint(&sce->toolsettings->sculpt->paint);
MEM_freeN(sce->toolsettings->sculpt);
}
- if(sce->toolsettings->uvsculpt) {
+ if (sce->toolsettings->uvsculpt) {
free_paint(&sce->toolsettings->uvsculpt->paint);
MEM_freeN(sce->toolsettings->uvsculpt);
}
@@ -312,14 +312,14 @@ void free_scene(Scene *sce)
MEM_freeN(sce->theDag);
}
- if(sce->nodetree) {
+ if (sce->nodetree) {
ntreeFreeTree(sce->nodetree);
MEM_freeN(sce->nodetree);
}
- if(sce->stats)
+ if (sce->stats)
MEM_freeN(sce->stats);
- if(sce->fps_info)
+ if (sce->fps_info)
MEM_freeN(sce->fps_info);
sound_destroy_scene(sce);
@@ -458,7 +458,7 @@ Scene *add_scene(const char *name)
pset->draw_step= 2;
pset->fade_frames= 2;
pset->selectmode= SCE_SELECT_PATH;
- for(a=0; a<PE_TOT_BRUSH; a++) {
+ for (a=0; a<PE_TOT_BRUSH; a++) {
pset->brush[a].strength= 0.5;
pset->brush[a].size= 50;
pset->brush[a].step= 10;
@@ -543,8 +543,8 @@ Base *object_in_scene(Object *ob, Scene *sce)
Base *base;
base= sce->base.first;
- while(base) {
- if(base->object == ob) return base;
+ while (base) {
+ if (base->object == ob) return base;
base= base->next;
}
return NULL;
@@ -563,18 +563,18 @@ void set_scene_bg(Main *bmain, Scene *scene)
scene_check_setscene(bmain, scene);
/* can happen when switching modes in other scenes */
- if(scene->obedit && !(scene->obedit->mode & OB_MODE_EDIT))
+ if (scene->obedit && !(scene->obedit->mode & OB_MODE_EDIT))
scene->obedit= NULL;
/* deselect objects (for dataselect) */
- for(ob= bmain->object.first; ob; ob= ob->id.next)
+ for (ob= bmain->object.first; ob; ob= ob->id.next)
ob->flag &= ~(SELECT|OB_FROMGROUP);
/* group flags again */
- for(group= bmain->group.first; group; group= group->id.next) {
+ for (group= bmain->group.first; group; group= group->id.next) {
go= group->gobject.first;
- while(go) {
- if(go->ob) go->ob->flag |= OB_FROMGROUP;
+ while (go) {
+ if (go->ob) go->ob->flag |= OB_FROMGROUP;
go= go->next;
}
}
@@ -583,12 +583,12 @@ void set_scene_bg(Main *bmain, Scene *scene)
DAG_scene_sort(bmain, scene);
/* ensure dags are built for sets */
- for(sce= scene->set; sce; sce= sce->set)
- if(sce->theDag==NULL)
+ for (sce= scene->set; sce; sce= sce->set)
+ if (sce->theDag==NULL)
DAG_scene_sort(bmain, sce);
/* copy layers and flags from bases to objects */
- for(base= scene->base.first; base; base= base->next) {
+ for (base= scene->base.first; base; base= base->next) {
ob= base->object;
ob->lay= base->lay;
@@ -598,7 +598,7 @@ void set_scene_bg(Main *bmain, Scene *scene)
base->flag |= flag;
/* not too nice... for recovering objects with lost data */
- //if(ob->pose==NULL) base->flag &= ~OB_POSEMODE;
+ //if (ob->pose==NULL) base->flag &= ~OB_POSEMODE;
ob->flag= base->flag;
ob->ctime= -1234567.0; /* force ipo to be calculated later */
@@ -610,7 +610,7 @@ void set_scene_bg(Main *bmain, Scene *scene)
Scene *set_scene_name(Main *bmain, const char *name)
{
Scene *sce= (Scene *)find_id("SC", name);
- if(sce) {
+ if (sce) {
set_scene_bg(bmain, sce);
printf("Scene switch: '%s' in file: '%s'\n", name, G.main->name);
return sce;
@@ -626,8 +626,8 @@ void unlink_scene(Main *bmain, Scene *sce, Scene *newsce)
bScreen *sc;
/* check all sets */
- for(sce1= bmain->scene.first; sce1; sce1= sce1->id.next)
- if(sce1->set == sce)
+ for (sce1= bmain->scene.first; sce1; sce1= sce1->id.next)
+ if (sce1->set == sce)
sce1->set= NULL;
/* check all sequences */
@@ -637,8 +637,8 @@ void unlink_scene(Main *bmain, Scene *sce, Scene *newsce)
clear_scene_in_nodes(bmain, sce);
/* al screens */
- for(sc= bmain->screen.first; sc; sc= sc->id.next)
- if(sc->scene == sce)
+ for (sc= bmain->screen.first; sc; sc= sc->id.next)
+ if (sc->scene == sce)
sc->scene= newsce;
free_libblock(&bmain->scene, sce);
@@ -655,13 +655,13 @@ int next_object(Scene **scene, int val, Base **base, Object **ob)
int run_again=1;
/* init */
- if(val==0) {
+ if (val==0) {
fase= F_START;
dupob= NULL;
/* XXX particle systems with metas+dupligroups call this recursively */
/* see bug #18725 */
- if(in_next_object) {
+ if (in_next_object) {
printf("ERROR: MetaBall generation called recursively, not supported\n");
return F_ERROR;
@@ -671,21 +671,21 @@ int next_object(Scene **scene, int val, Base **base, Object **ob)
in_next_object= 1;
/* run_again is set when a duplilist has been ended */
- while(run_again) {
+ while (run_again) {
run_again= 0;
/* the first base */
- if(fase==F_START) {
+ if (fase==F_START) {
*base= (*scene)->base.first;
- if(*base) {
+ if (*base) {
*ob= (*base)->object;
fase= F_SCENE;
}
else {
/* exception: empty scene */
- while((*scene)->set) {
+ while ((*scene)->set) {
(*scene)= (*scene)->set;
- if((*scene)->base.first) {
+ if ((*scene)->base.first) {
*base= (*scene)->base.first;
*ob= (*base)->object;
fase= F_SCENE;
@@ -695,15 +695,15 @@ int next_object(Scene **scene, int val, Base **base, Object **ob)
}
}
else {
- if(*base && fase!=F_DUPLI) {
+ if (*base && fase!=F_DUPLI) {
*base= (*base)->next;
- if(*base) *ob= (*base)->object;
+ if (*base) *ob= (*base)->object;
else {
- if(fase==F_SCENE) {
+ if (fase==F_SCENE) {
/* (*scene) is finished, now do the set */
- while((*scene)->set) {
+ while ((*scene)->set) {
(*scene)= (*scene)->set;
- if((*scene)->base.first) {
+ if ((*scene)->base.first) {
*base= (*scene)->base.first;
*ob= (*base)->object;
break;
@@ -714,25 +714,25 @@ int next_object(Scene **scene, int val, Base **base, Object **ob)
}
}
- if(*base == NULL) fase= F_START;
+ if (*base == NULL) fase= F_START;
else {
- if(fase!=F_DUPLI) {
- if( (*base)->object->transflag & OB_DUPLI) {
+ if (fase!=F_DUPLI) {
+ if ( (*base)->object->transflag & OB_DUPLI) {
/* groups cannot be duplicated for mballs yet,
this enters eternal loop because of
makeDispListMBall getting called inside of group_duplilist */
- if((*base)->object->dup_group == NULL) {
+ if ((*base)->object->dup_group == NULL) {
duplilist= object_duplilist((*scene), (*base)->object);
dupob= duplilist->first;
- if(!dupob)
+ if (!dupob)
free_object_duplilist(duplilist);
}
}
}
/* handle dupli's */
- if(dupob) {
+ if (dupob) {
copy_m4_m4(dupob->ob->obmat, dupob->mat);
@@ -742,11 +742,11 @@ int next_object(Scene **scene, int val, Base **base, Object **ob)
dupob= dupob->next;
}
- else if(fase==F_DUPLI) {
+ else if (fase==F_DUPLI) {
fase= F_SCENE;
(*base)->flag &= ~OB_FROMDUPLI;
- for(dupob= duplilist->first; dupob; dupob= dupob->next) {
+ for (dupob= duplilist->first; dupob; dupob= dupob->next) {
copy_m4_m4(dupob->ob->obmat, dupob->omat);
}
@@ -758,7 +758,7 @@ int next_object(Scene **scene, int val, Base **base, Object **ob)
}
}
- /* if(ob && *ob) {
+ /* if (ob && *ob) {
printf("Scene: '%s', '%s'\n", (*scene)->id.name+2, (*ob)->id.name+2);
} */
@@ -788,11 +788,11 @@ Object *scene_camera_switch_find(Scene *scene)
Object *camera= NULL;
for (m= scene->markers.first; m; m= m->next) {
- if(m->camera && (m->camera->restrictflag & OB_RESTRICT_RENDER)==0 && (m->frame <= cfra) && (m->frame > frame)) {
+ if (m->camera && (m->camera->restrictflag & OB_RESTRICT_RENDER)==0 && (m->frame <= cfra) && (m->frame > frame)) {
camera= m->camera;
frame= m->frame;
- if(frame == cfra)
+ if (frame == cfra)
break;
}
@@ -805,7 +805,7 @@ int scene_camera_switch_update(Scene *scene)
{
#ifdef DURIAN_CAMERA_SWITCH
Object *camera= scene_camera_switch_find(scene);
- if(camera) {
+ if (camera) {
scene->camera= camera;
return 1;
}
@@ -894,15 +894,15 @@ int scene_check_setscene(Main *bmain, Scene *sce)
Scene *scene;
int a, totscene;
- if(sce->set==NULL) return 1;
+ if (sce->set==NULL) return 1;
totscene= 0;
- for(scene= bmain->scene.first; scene; scene= scene->id.next)
+ for (scene= bmain->scene.first; scene; scene= scene->id.next)
totscene++;
- for(a=0, scene=sce; scene->set; scene=scene->set, a++) {
+ for (a=0, scene=sce; scene->set; scene=scene->set, a++) {
/* more iterations than scenes means we have a cycle */
- if(a > totscene) {
+ if (a > totscene) {
/* the tested scene gets zero'ed, that's typically current scene */
sce->set= NULL;
return 0;
@@ -983,7 +983,7 @@ static void scene_update_tagged_recursive(Main *bmain, Scene *scene, Scene *scen
object_handle_update(scene_parent, ob);
- if(ob->dup_group && (ob->transflag & OB_DUPLIGROUP))
+ if (ob->dup_group && (ob->transflag & OB_DUPLIGROUP))
group_handle_recalc_and_update(scene_parent, ob, ob->dup_group);
/* always update layer, so that animating layers works */
@@ -1051,8 +1051,8 @@ void scene_update_for_newframe(Main *bmain, Scene *sce, unsigned int lay)
/* clear animation overrides */
// XXX TODO...
- for(sce_iter= sce; sce_iter; sce_iter= sce_iter->set) {
- if(sce_iter->theDag==NULL)
+ for (sce_iter= sce; sce_iter; sce_iter= sce_iter->set) {
+ if (sce_iter->theDag==NULL)
DAG_scene_sort(bmain, sce_iter);
}
@@ -1092,7 +1092,7 @@ SceneRenderLayer *scene_add_render_layer(Scene *sce, const char *name)
{
SceneRenderLayer *srl;
- if(!name)
+ if (!name)
name= "RenderLayer";
srl= MEM_callocN(sizeof(SceneRenderLayer), "new render layer");
@@ -1128,14 +1128,14 @@ int scene_remove_render_layer(Main *bmain, Scene *scene, SceneRenderLayer *srl)
scene->r.actlay= 0;
- for(sce = bmain->scene.first; sce; sce = sce->id.next) {
- if(sce->nodetree) {
+ for (sce = bmain->scene.first; sce; sce = sce->id.next) {
+ if (sce->nodetree) {
bNode *node;
- for(node = sce->nodetree->nodes.first; node; node = node->next) {
- if(node->type==CMP_NODE_R_LAYERS && (Scene*)node->id==scene) {
- if(node->custom1==act)
+ for (node = sce->nodetree->nodes.first; node; node = node->next) {
+ if (node->type==CMP_NODE_R_LAYERS && (Scene*)node->id==scene) {
+ if (node->custom1==act)
node->custom1= 0;
- else if(node->custom1>act)
+ else if (node->custom1>act)
node->custom1--;
}
}
@@ -1149,7 +1149,7 @@ int scene_remove_render_layer(Main *bmain, Scene *scene, SceneRenderLayer *srl)
int get_render_subsurf_level(RenderData *r, int lvl)
{
- if(r->mode & R_SIMPLIFY)
+ if (r->mode & R_SIMPLIFY)
return MIN2(r->simplify_subsurf, lvl);
else
return lvl;
@@ -1157,7 +1157,7 @@ int get_render_subsurf_level(RenderData *r, int lvl)
int get_render_child_particle_number(RenderData *r, int num)
{
- if(r->mode & R_SIMPLIFY)
+ if (r->mode & R_SIMPLIFY)
return (int)(r->simplify_particles*num);
else
return num;
@@ -1165,7 +1165,7 @@ int get_render_child_particle_number(RenderData *r, int num)
int get_render_shadow_samples(RenderData *r, int samples)
{
- if((r->mode & R_SIMPLIFY) && samples > 0)
+ if ((r->mode & R_SIMPLIFY) && samples > 0)
return MIN2(r->simplify_shadowsamples, samples);
else
return samples;
@@ -1173,7 +1173,7 @@ int get_render_shadow_samples(RenderData *r, int samples)
float get_render_aosss_error(RenderData *r, float error)
{
- if(r->mode & R_SIMPLIFY)
+ if (r->mode & R_SIMPLIFY)
return ((1.0f-r->simplify_aosss)*10.0f + 1.0f)*error;
else
return error;
@@ -1182,19 +1182,19 @@ float get_render_aosss_error(RenderData *r, float error)
/* helper function for the SETLOOPER macro */
Base *_setlooper_base_step(Scene **sce_iter, Base *base)
{
- if(base && base->next) {
+ if (base && base->next) {
/* common case, step to the next */
return base->next;
}
- else if(base==NULL && (*sce_iter)->base.first) {
+ else if (base==NULL && (*sce_iter)->base.first) {
/* first time looping, return the scenes first base */
return (Base *)(*sce_iter)->base.first;
}
else {
/* reached the end, get the next base in the set */
- while((*sce_iter= (*sce_iter)->set)) {
+ while ((*sce_iter= (*sce_iter)->set)) {
base= (Base *)(*sce_iter)->base.first;
- if(base) {
+ if (base) {
return base;
}
}
diff --git a/source/blender/blenkernel/intern/sequencer.c b/source/blender/blenkernel/intern/sequencer.c
index b2188754503..1c3cc44c585 100644
--- a/source/blender/blenkernel/intern/sequencer.c
+++ b/source/blender/blenkernel/intern/sequencer.c
@@ -2701,14 +2701,17 @@ ImBuf *give_ibuf_seq_threaded(SeqRenderData context, float cfra, int chanshown)
if (!e) {
PrefetchThread *tslot;
- for(tslot = running_threads.first;
- tslot; tslot= tslot->next) {
+ for (tslot = running_threads.first;
+ tslot;
+ tslot= tslot->next)
+ {
if (tslot->current &&
- cfra == tslot->current->cfra &&
- chanshown == tslot->current->chanshown &&
- context.rectx == tslot->current->rectx &&
- context.recty == tslot->current->recty &&
- context.preview_render_size== tslot->current->preview_render_size){
+ cfra == tslot->current->cfra &&
+ chanshown == tslot->current->chanshown &&
+ context.rectx == tslot->current->rectx &&
+ context.recty == tslot->current->recty &&
+ context.preview_render_size== tslot->current->preview_render_size)
+ {
found_something = TRUE;
break;
}
diff --git a/source/blender/blenkernel/intern/softbody.c b/source/blender/blenkernel/intern/softbody.c
index 46a3f776e43..e48a17ac274 100644
--- a/source/blender/blenkernel/intern/softbody.c
+++ b/source/blender/blenkernel/intern/softbody.c
@@ -228,7 +228,7 @@ static float _final_goal(Object *ob,BodyPoint *bp)/*jow_go_for2_5 */
float f = -1999.99f;
if (ob){
SoftBody *sb= ob->soft; /* is supposed to be there */
- if(!(ob->softflag & OB_SB_GOAL)) return (0.0f);
+ if (!(ob->softflag & OB_SB_GOAL)) return (0.0f);
if (sb&&bp){
if (bp->goal < 0.0f) return (0.0f);
f = sb->mingoal + bp->goal*ABS(sb->maxgoal - sb->mingoal);
@@ -292,7 +292,7 @@ static ccd_Mesh *ccd_mesh_make(Object *ob)
{
CollisionModifierData *cmd;
ccd_Mesh *pccd_M = NULL;
- ccdf_minmax *mima =NULL;
+ ccdf_minmax *mima = NULL;
MFace *mface=NULL;
float v[3],hull;
int i;
@@ -319,7 +319,7 @@ static ccd_Mesh *ccd_mesh_make(Object *ob)
pccd_M->mvert = MEM_dupallocN(cmd->xnew);
/* note that xnew coords are already in global space, */
/* determine the ortho BB */
- for(i=0; i < pccd_M->totvert; i++){
+ for (i=0; i < pccd_M->totvert; i++){
/* evaluate limits */
copy_v3_v3(v,pccd_M->mvert[i].co);
pccd_M->bbmin[0] = MIN2(pccd_M->bbmin[0],v[0]-hull);
@@ -341,7 +341,7 @@ static ccd_Mesh *ccd_mesh_make(Object *ob)
/* anyhoo we need to walk the list of faces and find OBB they live in */
- for(i=0; i < pccd_M->totface; i++){
+ for (i=0; i < pccd_M->totface; i++){
mima->minx=mima->miny=mima->minz=1e30f;
mima->maxx=mima->maxy=mima->maxz=-1e30f;
@@ -369,7 +369,7 @@ static ccd_Mesh *ccd_mesh_make(Object *ob)
mima->maxy = MAX2(mima->maxy,v[1]+hull);
mima->maxz = MAX2(mima->maxz,v[2]+hull);
- if(mface->v4){
+ if (mface->v4){
copy_v3_v3(v,pccd_M->mvert[mface->v4].co);
mima->minx = MIN2(mima->minx,v[0]-hull);
mima->miny = MIN2(mima->miny,v[1]-hull);
@@ -389,7 +389,7 @@ static ccd_Mesh *ccd_mesh_make(Object *ob)
static void ccd_mesh_update(Object *ob,ccd_Mesh *pccd_M)
{
CollisionModifierData *cmd;
- ccdf_minmax *mima =NULL;
+ ccdf_minmax *mima = NULL;
MFace *mface=NULL;
float v[3],hull;
int i;
@@ -411,13 +411,13 @@ static void ccd_mesh_update(Object *ob,ccd_Mesh *pccd_M)
hull = MAX2(ob->pd->pdef_sbift,ob->pd->pdef_sboft);
/* rotate current to previous */
- if(pccd_M->mprevvert) MEM_freeN(pccd_M->mprevvert);
+ if (pccd_M->mprevvert) MEM_freeN(pccd_M->mprevvert);
pccd_M->mprevvert = pccd_M->mvert;
/* alloc and copy verts*/
pccd_M->mvert = MEM_dupallocN(cmd->xnew);
/* note that xnew coords are already in global space, */
/* determine the ortho BB */
- for(i=0; i < pccd_M->totvert; i++){
+ for (i=0; i < pccd_M->totvert; i++){
/* evaluate limits */
copy_v3_v3(v,pccd_M->mvert[i].co);
pccd_M->bbmin[0] = MIN2(pccd_M->bbmin[0],v[0]-hull);
@@ -445,7 +445,7 @@ static void ccd_mesh_update(Object *ob,ccd_Mesh *pccd_M)
/* anyhoo we need to walk the list of faces and find OBB they live in */
- for(i=0; i < pccd_M->totface; i++){
+ for (i=0; i < pccd_M->totface; i++){
mima->minx=mima->miny=mima->minz=1e30f;
mima->maxx=mima->maxy=mima->maxz=-1e30f;
@@ -473,7 +473,7 @@ static void ccd_mesh_update(Object *ob,ccd_Mesh *pccd_M)
mima->maxy = MAX2(mima->maxy,v[1]+hull);
mima->maxz = MAX2(mima->maxz,v[2]+hull);
- if(mface->v4){
+ if (mface->v4){
copy_v3_v3(v,pccd_M->mvert[mface->v4].co);
mima->minx = MIN2(mima->minx,v[0]-hull);
mima->miny = MIN2(mima->miny,v[1]-hull);
@@ -508,7 +508,7 @@ static void ccd_mesh_update(Object *ob,ccd_Mesh *pccd_M)
mima->maxy = MAX2(mima->maxy,v[1]+hull);
mima->maxz = MAX2(mima->maxz,v[2]+hull);
- if(mface->v4){
+ if (mface->v4){
copy_v3_v3(v,pccd_M->mprevvert[mface->v4].co);
mima->minx = MIN2(mima->minx,v[0]-hull);
mima->miny = MIN2(mima->miny,v[1]-hull);
@@ -528,7 +528,7 @@ static void ccd_mesh_update(Object *ob,ccd_Mesh *pccd_M)
static void ccd_mesh_free(ccd_Mesh *ccdm)
{
- if(ccdm && (ccdm->savety == CCD_SAVETY )){ /*make sure we're not nuking objects we don't know*/
+ if (ccdm && (ccdm->savety == CCD_SAVETY )){ /*make sure we're not nuking objects we don't know*/
MEM_freeN(ccdm->mface);
MEM_freeN(ccdm->mvert);
if (ccdm->mprevvert) MEM_freeN(ccdm->mprevvert);
@@ -546,16 +546,16 @@ static void ccd_build_deflector_hash(Scene *scene, Object *vertexowner, GHash *h
if (!hash) return;
while (base) {
/*Only proceed for mesh object in same layer */
- if(base->object->type==OB_MESH && (base->lay & vertexowner->lay)) {
+ if (base->object->type==OB_MESH && (base->lay & vertexowner->lay)) {
ob= base->object;
- if((vertexowner) && (ob == vertexowner)) {
+ if ((vertexowner) && (ob == vertexowner)) {
/* if vertexowner is given we don't want to check collision with owner object */
base = base->next;
continue;
}
/*+++ only with deflecting set */
- if(ob->pd && ob->pd->deflect && BLI_ghash_lookup(hash, ob) == NULL) {
+ if (ob->pd && ob->pd->deflect && BLI_ghash_lookup(hash, ob) == NULL) {
ccd_Mesh *ccdmesh = ccd_mesh_make(ob);
BLI_ghash_insert(hash, ob, ccdmesh);
}/*--- only with deflecting set */
@@ -573,16 +573,16 @@ static void ccd_update_deflector_hash(Scene *scene, Object *vertexowner, GHash *
if ((!hash) || (!vertexowner)) return;
while (base) {
/*Only proceed for mesh object in same layer */
- if(base->object->type==OB_MESH && (base->lay & vertexowner->lay)) {
+ if (base->object->type==OB_MESH && (base->lay & vertexowner->lay)) {
ob= base->object;
- if(ob == vertexowner){
+ if (ob == vertexowner){
/* if vertexowner is given we don't want to check collision with owner object */
base = base->next;
continue;
}
/*+++ only with deflecting set */
- if(ob->pd && ob->pd->deflect) {
+ if (ob->pd && ob->pd->deflect) {
ccd_Mesh *ccdmesh = BLI_ghash_lookup(hash,ob);
if (ccdmesh)
ccd_mesh_update(ob,ccdmesh);
@@ -604,9 +604,9 @@ static int count_mesh_quads(Mesh *me)
int a,result = 0;
MFace *mface= me->mface;
- if(mface) {
- for(a=me->totface; a>0; a--, mface++) {
- if(mface->v4) result++;
+ if (mface) {
+ for (a=me->totface; a>0; a--, mface++) {
+ if (mface->v4) result++;
}
}
return result;
@@ -630,7 +630,7 @@ static void add_mesh_quad_diag_springs(Object *ob)
bs_new= MEM_callocN( (ob->soft->totspring + nofquads *2 )*sizeof(BodySpring), "bodyspring");
memcpy(bs_new,ob->soft->bspring,(ob->soft->totspring )*sizeof(BodySpring));
- if(ob->soft->bspring)
+ if (ob->soft->bspring)
MEM_freeN(ob->soft->bspring); /* do this before reassigning the pointer or have a 1st class memory leak */
ob->soft->bspring = bs_new;
@@ -638,16 +638,16 @@ static void add_mesh_quad_diag_springs(Object *ob)
a = 0;
bs = bs_new+ob->soft->totspring;
/*bp= ob->soft->bpoint; */ /*UNUSED*/
- if(mface ) {
- for(a=me->totface; a>0; a--, mface++) {
- if(mface->v4) {
+ if (mface ) {
+ for (a=me->totface; a>0; a--, mface++) {
+ if (mface->v4) {
bs->v1= mface->v1;
bs->v2= mface->v3;
- bs->springtype =SB_STIFFQUAD;
+ bs->springtype = SB_STIFFQUAD;
bs++;
bs->v1= mface->v2;
bs->v2= mface->v4;
- bs->springtype =SB_STIFFQUAD;
+ bs->springtype = SB_STIFFQUAD;
bs++;
}
@@ -671,34 +671,34 @@ static void add_2nd_order_roller(Object *ob,float UNUSED(stiffness), int *counte
/* first run counting second run adding */
*counter = 0;
if (addsprings) bs3 = ob->soft->bspring+ob->soft->totspring;
- for(a=sb->totpoint, bp= sb->bpoint; a>0; a--, bp++) {
+ for (a=sb->totpoint, bp= sb->bpoint; a>0; a--, bp++) {
/*scan for neighborhood*/
bpo = NULL;
v0 = (sb->totpoint-a);
- for(b=bp->nofsprings;b>0;b--){
+ for (b=bp->nofsprings;b>0;b--){
bs = sb->bspring + bp->springs[b-1];
/*nasty thing here that springs have two ends
so here we have to make sure we examine the other */
if (v0 == bs->v1){
- bpo =sb->bpoint+bs->v2;
+ bpo = sb->bpoint+bs->v2;
notthis = bs->v2;
}
else {
if (v0 == bs->v2){
- bpo =sb->bpoint+bs->v1;
+ bpo = sb->bpoint+bs->v1;
notthis = bs->v1;
}
else {printf("oops we should not get here - add_2nd_order_springs");}
}
if (bpo){/* so now we have a 2nd order humpdidump */
- for(c=bpo->nofsprings;c>0;c--){
+ for (c=bpo->nofsprings;c>0;c--){
bs2 = sb->bspring + bpo->springs[c-1];
if ((bs2->v1 != notthis) && (bs2->v1 > v0)){
(*counter)++;/*hit */
if (addsprings){
bs3->v1= v0;
bs3->v2= bs2->v1;
- bs3->springtype =SB_BEND;
+ bs3->springtype = SB_BEND;
bs3++;
}
}
@@ -707,7 +707,7 @@ static void add_2nd_order_roller(Object *ob,float UNUSED(stiffness), int *counte
if (addsprings){
bs3->v1= v0;
bs3->v2= bs2->v2;
- bs3->springtype =SB_BEND;
+ bs3->springtype = SB_BEND;
bs3++;
}
@@ -734,7 +734,7 @@ static void add_2nd_order_springs(Object *ob,float stiffness)
bs_new= MEM_callocN( (ob->soft->totspring + counter )*sizeof(BodySpring), "bodyspring");
memcpy(bs_new,ob->soft->bspring,(ob->soft->totspring )*sizeof(BodySpring));
- if(ob->soft->bspring)
+ if (ob->soft->bspring)
MEM_freeN(ob->soft->bspring);
ob->soft->bspring = bs_new;
@@ -774,14 +774,14 @@ static void build_bps_springlist(Object *ob)
if (sb==NULL) return; /* paranoya check */
- for(a=sb->totpoint, bp= sb->bpoint; a>0; a--, bp++) {
+ for (a=sb->totpoint, bp= sb->bpoint; a>0; a--, bp++) {
/* throw away old list */
if (bp->springs) {
MEM_freeN(bp->springs);
bp->springs=NULL;
}
/* scan for attached inner springs */
- for(b=sb->totspring, bs= sb->bspring; b>0; b--, bs++) {
+ for (b=sb->totspring, bs= sb->bspring; b>0; b--, bs++) {
if (( (sb->totpoint-a) == bs->v1) ){
add_bp_springlist(bp,sb->totspring -b);
}
@@ -802,14 +802,14 @@ static void calculate_collision_balls(Object *ob)
if (sb==NULL) return; /* paranoya check */
- for(a=sb->totpoint, bp= sb->bpoint; a>0; a--, bp++) {
+ for (a=sb->totpoint, bp= sb->bpoint; a>0; a--, bp++) {
bp->colball=0;
akku =0.0f;
akku_count=0;
min = 1e22f;
max = -1e22f;
/* first estimation based on attached */
- for(b=bp->nofsprings;b>0;b--){
+ for (b=bp->nofsprings;b>0;b--){
bs = sb->bspring + bp->springs[b-1];
if (bs->springtype == SB_EDGE){
akku += bs->len;
@@ -847,17 +847,17 @@ static void renew_softbody(Scene *scene, Object *ob, int totpoint, int totspring
SoftBody *sb;
int i;
short softflag;
- if(ob->soft==NULL) ob->soft= sbNew(scene);
+ if (ob->soft==NULL) ob->soft= sbNew(scene);
else free_softbody_intern(ob->soft);
sb= ob->soft;
softflag=ob->softflag;
- if(totpoint) {
+ if (totpoint) {
sb->totpoint= totpoint;
sb->totspring= totspring;
sb->bpoint= MEM_mallocN( totpoint*sizeof(BodyPoint), "bodypoint");
- if(totspring)
+ if (totspring)
sb->bspring= MEM_mallocN( totspring*sizeof(BodySpring), "bodyspring");
/* initialise BodyPoint array */
@@ -868,7 +868,7 @@ static void renew_softbody(Scene *scene, Object *ob, int totpoint, int totspring
/* hum as far as i see this is overridden by _final_goal() now jow_go_for2_5 */
/* sadly breaks compatibility with older versions */
/* but makes goals behave the same for meshes, lattices and curves */
- if(softflag & OB_SB_GOAL) {
+ if (softflag & OB_SB_GOAL) {
bp->goal= sb->defgoal;
}
else {
@@ -894,18 +894,18 @@ static void free_softbody_baked(SoftBody *sb)
SBVertex *key;
int k;
- for(k=0; k<sb->totkey; k++) {
+ for (k=0; k<sb->totkey; k++) {
key= *(sb->keys + k);
- if(key) MEM_freeN(key);
+ if (key) MEM_freeN(key);
}
- if(sb->keys) MEM_freeN(sb->keys);
+ if (sb->keys) MEM_freeN(sb->keys);
sb->keys= NULL;
sb->totkey= 0;
}
static void free_scratch(SoftBody *sb)
{
- if(sb->scratch){
+ if (sb->scratch){
/* todo make sure everything is cleaned up nicly */
if (sb->scratch->colliderhash){
BLI_ghash_free(sb->scratch->colliderhash, NULL,
@@ -927,12 +927,12 @@ static void free_scratch(SoftBody *sb)
/* only frees internal data */
static void free_softbody_intern(SoftBody *sb)
{
- if(sb) {
+ if (sb) {
int a;
BodyPoint *bp;
- if(sb->bpoint){
- for(a=sb->totpoint, bp= sb->bpoint; a>0; a--, bp++) {
+ if (sb->bpoint){
+ for (a=sb->totpoint, bp= sb->bpoint; a>0; a--, bp++) {
/* free spring list */
if (bp->springs != NULL) {
MEM_freeN(bp->springs);
@@ -941,7 +941,7 @@ static void free_softbody_intern(SoftBody *sb)
MEM_freeN(sb->bpoint);
}
- if(sb->bspring) MEM_freeN(sb->bspring);
+ if (sb->bspring) MEM_freeN(sb->bspring);
sb->totpoint= sb->totspring= 0;
sb->bpoint= NULL;
@@ -994,9 +994,9 @@ static int are_there_deflectors(Scene *scene, unsigned int layer)
{
Base *base;
- for(base = scene->base.first; base; base= base->next) {
- if( (base->lay & layer) && base->object->pd) {
- if(base->object->pd->deflect)
+ for (base = scene->base.first; base; base= base->next) {
+ if ( (base->lay & layer) && base->object->pd) {
+ if (base->object->pd->deflect)
return 1;
}
}
@@ -1034,14 +1034,14 @@ static int sb_detect_aabb_collisionCached( float UNUSED(force[3]), unsigned int
ccd_Mesh *ccdm = BLI_ghashIterator_getValue (ihash);
ob = BLI_ghashIterator_getKey (ihash);
/* only with deflecting set */
- if(ob->pd && ob->pd->deflect) {
+ if (ob->pd && ob->pd->deflect) {
#if 0 /* UNUSED */
MFace *mface= NULL;
MVert *mvert= NULL;
MVert *mprevvert= NULL;
ccdf_minmax *mima= NULL;
#endif
- if(ccdm){
+ if (ccdm){
#if 0 /* UNUSED */
mface= ccdm->mface;
mvert= ccdm->mvert;
@@ -1071,7 +1071,7 @@ static int sb_detect_aabb_collisionCached( float UNUSED(force[3]), unsigned int
BLI_ghashIterator_step(ihash);
continue;
}
- } /* if(ob->pd && ob->pd->deflect) */
+ } /* if (ob->pd && ob->pd->deflect) */
BLI_ghashIterator_step(ihash);
} /* while () */
BLI_ghashIterator_free(ihash);
@@ -1112,14 +1112,14 @@ static int sb_detect_face_pointCached(float face_v1[3],float face_v2[3],float fa
ccd_Mesh *ccdm = BLI_ghashIterator_getValue (ihash);
ob = BLI_ghashIterator_getKey (ihash);
/* only with deflecting set */
- if(ob->pd && ob->pd->deflect) {
+ if (ob->pd && ob->pd->deflect) {
MVert *mvert= NULL;
MVert *mprevvert= NULL;
- if(ccdm){
+ if (ccdm){
mvert= ccdm->mvert;
a = ccdm->totvert;
mprevvert= ccdm->mprevvert;
- outerfacethickness =ob->pd->pdef_sboft;
+ outerfacethickness = ob->pd->pdef_sboft;
if ((aabbmax[0] < ccdm->bbmin[0]) ||
(aabbmax[1] < ccdm->bbmin[1]) ||
(aabbmax[2] < ccdm->bbmin[2]) ||
@@ -1144,7 +1144,7 @@ static int sb_detect_face_pointCached(float face_v1[3],float face_v2[3],float fa
if (mvert) {
while(a){
copy_v3_v3(nv1,mvert[a-1].co);
- if(mprevvert){
+ if (mprevvert){
mul_v3_fl(nv1,time);
Vec3PlusStVec(nv1,(1.0f-time),mprevvert[a-1].co);
}
@@ -1171,7 +1171,7 @@ static int sb_detect_face_pointCached(float face_v1[3],float face_v2[3],float fa
a--;
}/* while(a)*/
} /* if (mvert) */
- } /* if(ob->pd && ob->pd->deflect) */
+ } /* if (ob->pd && ob->pd->deflect) */
BLI_ghashIterator_step(ihash);
} /* while () */
BLI_ghashIterator_free(ihash);
@@ -1203,12 +1203,12 @@ static int sb_detect_face_collisionCached(float face_v1[3],float face_v2[3],floa
ccd_Mesh *ccdm = BLI_ghashIterator_getValue (ihash);
ob = BLI_ghashIterator_getKey (ihash);
/* only with deflecting set */
- if(ob->pd && ob->pd->deflect) {
+ if (ob->pd && ob->pd->deflect) {
MFace *mface= NULL;
MVert *mvert= NULL;
MVert *mprevvert= NULL;
ccdf_minmax *mima= NULL;
- if(ccdm){
+ if (ccdm){
mface= ccdm->mface;
mvert= ccdm->mvert;
mprevvert= ccdm->mprevvert;
@@ -1308,7 +1308,7 @@ static int sb_detect_face_collisionCached(float face_v1[3],float face_v2[3],floa
mface++;
mima++;
}/* while a */
- } /* if(ob->pd && ob->pd->deflect) */
+ } /* if (ob->pd && ob->pd->deflect) */
BLI_ghashIterator_step(ihash);
} /* while () */
BLI_ghashIterator_free(ihash);
@@ -1330,7 +1330,7 @@ static void scan_for_ext_face_forces(Object *ob,float timenow)
bf = sb->scratch->bodyface;
- for(a=0; a<sb->scratch->totface; a++, bf++) {
+ for (a=0; a<sb->scratch->totface; a++, bf++) {
bf->ext_force[0]=bf->ext_force[1]=bf->ext_force[2]=0.0f;
/*+++edges intruding*/
bf->flag &= ~BFF_INTERSECT;
@@ -1386,7 +1386,7 @@ static void scan_for_ext_face_forces(Object *ob,float timenow)
/*--- close vertices*/
}
bf = sb->scratch->bodyface;
- for(a=0; a<sb->scratch->totface; a++, bf++) {
+ for (a=0; a<sb->scratch->totface; a++, bf++) {
if (( bf->flag & BFF_INTERSECT) || ( bf->flag & BFF_CLOSEVERT))
{
sb->bpoint[bf->v1].choke2=MAX2(sb->bpoint[bf->v1].choke2,choke);
@@ -1431,12 +1431,12 @@ static int sb_detect_edge_collisionCached(float edge_v1[3],float edge_v2[3],floa
ccd_Mesh *ccdm = BLI_ghashIterator_getValue (ihash);
ob = BLI_ghashIterator_getKey (ihash);
/* only with deflecting set */
- if(ob->pd && ob->pd->deflect) {
+ if (ob->pd && ob->pd->deflect) {
MFace *mface= NULL;
MVert *mvert= NULL;
MVert *mprevvert= NULL;
ccdf_minmax *mima= NULL;
- if(ccdm){
+ if (ccdm){
mface= ccdm->mface;
mvert= ccdm->mvert;
mprevvert= ccdm->mprevvert;
@@ -1547,7 +1547,7 @@ static int sb_detect_edge_collisionCached(float edge_v1[3],float edge_v2[3],floa
mface++;
mima++;
}/* while a */
- } /* if(ob->pd && ob->pd->deflect) */
+ } /* if (ob->pd && ob->pd->deflect) */
BLI_ghashIterator_step(ihash);
} /* while () */
BLI_ghashIterator_free(ihash);
@@ -1562,7 +1562,7 @@ static void _scan_for_ext_spring_forces(Scene *scene, Object *ob, float timenow,
float feedback[3];
if (sb && sb->totspring){
- for(a=ifirst; a<ilast; a++) {
+ for (a=ifirst; a<ilast; a++) {
BodySpring *bs = &sb->bspring[a];
bs->ext_force[0]=bs->ext_force[1]=bs->ext_force[2]=0.0f;
feedback[0]=feedback[1]=feedback[2]=0.0f;
@@ -1584,11 +1584,11 @@ static void _scan_for_ext_spring_forces(Scene *scene, Object *ob, float timenow,
/* +++ springs seeing wind ... n stuff depending on their orientation*/
/* note we don't use sb->mediafrict but use sb->aeroedge for magnitude of effect*/
- if(sb->aeroedge){
+ if (sb->aeroedge){
float vel[3],sp[3],pr[3],force[3];
float f,windfactor = 0.25f;
/*see if we have wind*/
- if(do_effector) {
+ if (do_effector) {
EffectedPoint epoint;
float speed[3]={0.0f,0.0f,0.0f};
float pos[3];
@@ -1656,7 +1656,7 @@ static void sb_sfesf_threads_run(Scene *scene, struct Object *ob, float timenow,
do_effector= pdInitEffectors(scene, ob, NULL, ob->soft->effector_weights);
/* figure the number of threads while preventing pretty pointless threading overhead */
- if(scene->r.mode & R_FIXED_THREADS)
+ if (scene->r.mode & R_FIXED_THREADS)
totthread= scene->r.threads;
else
totthread= BLI_system_thread_count();
@@ -1669,7 +1669,7 @@ static void sb_sfesf_threads_run(Scene *scene, struct Object *ob, float timenow,
memset(sb_threads, 0, sizeof(SB_thread_context)*totthread);
left = totsprings;
dec = totsprings/totthread +1;
- for(i=0; i<totthread; i++) {
+ for (i=0; i<totthread; i++) {
sb_threads[i].scene = scene;
sb_threads[i].ob = ob;
sb_threads[i].forcetime = 0.0; // not used here
@@ -1688,10 +1688,10 @@ static void sb_sfesf_threads_run(Scene *scene, struct Object *ob, float timenow,
sb_threads[i].nr= i;
sb_threads[i].tot= totthread;
}
- if(totthread > 1) {
+ if (totthread > 1) {
BLI_init_threads(&threads, exec_scan_for_ext_spring_forces, totthread);
- for(i=0; i<totthread; i++)
+ for (i=0; i<totthread; i++)
BLI_insert_thread(&threads, &sb_threads[i]);
BLI_end_threads(&threads);
@@ -1760,26 +1760,26 @@ static int sb_detect_vertex_collisionCached(float opco[3], float facenormal[3],
ccd_Mesh *ccdm = BLI_ghashIterator_getValue (ihash);
ob = BLI_ghashIterator_getKey (ihash);
/* only with deflecting set */
- if(ob->pd && ob->pd->deflect) {
+ if (ob->pd && ob->pd->deflect) {
MFace *mface= NULL;
MVert *mvert= NULL;
MVert *mprevvert= NULL;
ccdf_minmax *mima= NULL;
- if(ccdm){
+ if (ccdm){
mface= ccdm->mface;
mvert= ccdm->mvert;
mprevvert= ccdm->mprevvert;
mima= ccdm->mima;
a = ccdm->totface;
- minx =ccdm->bbmin[0];
- miny =ccdm->bbmin[1];
- minz =ccdm->bbmin[2];
+ minx = ccdm->bbmin[0];
+ miny = ccdm->bbmin[1];
+ minz = ccdm->bbmin[2];
- maxx =ccdm->bbmax[0];
- maxy =ccdm->bbmax[1];
- maxz =ccdm->bbmax[2];
+ maxx = ccdm->bbmax[0];
+ maxy = ccdm->bbmax[1];
+ maxz = ccdm->bbmax[2];
if ((opco[0] < minx) ||
(opco[1] < miny) ||
@@ -1801,8 +1801,8 @@ static int sb_detect_vertex_collisionCached(float opco[3], float facenormal[3],
/* do object level stuff */
/* need to have user control for that since it depends on model scale */
- innerfacethickness =-ob->pd->pdef_sbift;
- outerfacethickness =ob->pd->pdef_sboft;
+ innerfacethickness = -ob->pd->pdef_sbift;
+ outerfacethickness = ob->pd->pdef_sboft;
fa = (ff*outerfacethickness-outerfacethickness);
fa *= fa;
fa = 1.0f/fa;
@@ -1991,7 +1991,7 @@ static int sb_detect_vertex_collisionCached(float opco[3], float facenormal[3],
mface++;
mima++;
}/* while a */
- } /* if(ob->pd && ob->pd->deflect) */
+ } /* if (ob->pd && ob->pd->deflect) */
BLI_ghashIterator_step(ihash);
} /* while () */
@@ -2041,16 +2041,16 @@ static void dfdx_spring(int ia, int ic, int op, float dir[3],float L,float len,f
float m,delta_ij;
int i ,j;
if (L < len){
- for(i=0;i<3;i++)
- for(j=0;j<3;j++){
+ for (i=0;i<3;i++)
+ for (j=0;j<3;j++){
delta_ij = (i==j ? (1.0f): (0.0f));
m=factor*(dir[i]*dir[j] + (1-L/len)*(delta_ij - dir[i]*dir[j]));
nlMatrixAdd(ia+i,op+ic+j,m);
}
}
else{
- for(i=0;i<3;i++)
- for(j=0;j<3;j++){
+ for (i=0;i<3;i++)
+ for (j=0;j<3;j++){
m=factor*dir[i]*dir[j];
nlMatrixAdd(ia+i,op+ic+j,m);
}
@@ -2061,13 +2061,13 @@ static void dfdx_spring(int ia, int ic, int op, float dir[3],float L,float len,f
static void dfdx_goal(int ia, int ic, int op, float factor)
{
int i;
- for(i=0;i<3;i++) nlMatrixAdd(ia+i,op+ic+i,factor);
+ for (i=0;i<3;i++) nlMatrixAdd(ia+i,op+ic+i,factor);
}
static void dfdv_goal(int ia, int ic,float factor)
{
int i;
- for(i=0;i<3;i++) nlMatrixAdd(ia+i,ic+i,factor);
+ for (i=0;i<3;i++) nlMatrixAdd(ia+i,ic+i,factor);
}
*/
static void sb_spring_force(Object *ob,int bpi,BodySpring *bs,float iks,float UNUSED(forcetime), int nl_flags)
@@ -2112,7 +2112,7 @@ static void sb_spring_force(Object *ob,int bpi,BodySpring *bs,float iks,float UN
else
iks = 1.0f/(1.0f-sb->inpush)-1.0f ;/* inner spring constants function */
- if(bs->len > 0.0f) /* check for degenerated springs */
+ if (bs->len > 0.0f) /* check for degenerated springs */
forcefactor = iks/bs->len;
else
forcefactor = iks;
@@ -2146,7 +2146,7 @@ static void sb_spring_force(Object *ob,int bpi,BodySpring *bs,float iks,float UN
Vec3PlusStVec(bp1->force,-kd,dir);
/* do jacobian stuff if needed */
- if(nl_flags & NLF_BUILD){
+ if (nl_flags & NLF_BUILD){
//int op =3*sb->totpoint;
//float mvel = -forcetime*kd;
//float mpos = -forcetime*forcefactor;
@@ -2154,7 +2154,7 @@ static void sb_spring_force(Object *ob,int bpi,BodySpring *bs,float iks,float UN
// dfdx_spring(ia,ia,op,dir,bs->len,distance,-mpos);
/* depending on my vel */
// dfdv_goal(ia,ia,mvel); // well that ignores geometie
- if(bp2->goal < SOFTGOALSNAP){ /* ommit this bp when it snaps */
+ if (bp2->goal < SOFTGOALSNAP){ /* ommit this bp when it snaps */
/* depending on other pos */
// dfdx_spring(ia,ic,op,dir,bs->len,distance,mpos);
/* depending on other vel */
@@ -2198,12 +2198,12 @@ static int _softbody_calc_forces_slice_in_a_thread(Scene *scene, Object *ob, flo
bp = &sb->bpoint[ifirst];
- for(bb=number_of_points_here; bb>0; bb--, bp++) {
+ for (bb=number_of_points_here; bb>0; bb--, bp++) {
/* clear forces accumulator */
bp->force[0]= bp->force[1]= bp->force[2]= 0.0;
/* naive ball self collision */
/* needs to be done if goal snaps or not */
- if(do_selfcollision){
+ if (do_selfcollision){
int attached;
BodyPoint *obp;
BodySpring *bs;
@@ -2213,7 +2213,7 @@ static int _softbody_calc_forces_slice_in_a_thread(Scene *scene, Object *ob, flo
float compare;
float bstune = sb->ballstiff;
- for(c=sb->totpoint, obp= sb->bpoint; c>=ifirst+bb; c--, obp++) {
+ for (c=sb->totpoint, obp= sb->bpoint; c>=ifirst+bb; c--, obp++) {
compare = (obp->colball + bp->colball);
sub_v3_v3v3(def, bp->pos, obp->pos);
/* rather check the AABBoxes before ever calulating the real distance */
@@ -2223,7 +2223,7 @@ static int _softbody_calc_forces_slice_in_a_thread(Scene *scene, Object *ob, flo
if (distance < compare ){
/* exclude body points attached with a spring */
attached = 0;
- for(b=obp->nofsprings;b>0;b--){
+ for (b=obp->nofsprings;b>0;b--){
bs = sb->bspring + obp->springs[b-1];
if (( ilast-bb == bs->v2) || ( ilast-bb == bs->v1)){
attached=1;
@@ -2251,12 +2251,12 @@ static int _softbody_calc_forces_slice_in_a_thread(Scene *scene, Object *ob, flo
}
/* naive ball self collision done */
- if(_final_goal(ob,bp) < SOFTGOALSNAP){ /* ommit this bp when it snaps */
+ if (_final_goal(ob,bp) < SOFTGOALSNAP){ /* ommit this bp when it snaps */
float auxvect[3];
float velgoal[3];
/* do goal stuff */
- if(ob->softflag & OB_SB_GOAL) {
+ if (ob->softflag & OB_SB_GOAL) {
/* true elastic goal */
float ks,kd;
sub_v3_v3v3(auxvect,bp->pos,bp->origT);
@@ -2292,7 +2292,7 @@ static int _softbody_calc_forces_slice_in_a_thread(Scene *scene, Object *ob, flo
}
/* particle field & vortex */
- if(do_effector) {
+ if (do_effector) {
EffectedPoint epoint;
float kd;
float force[3]= {0.0f, 0.0f, 0.0f};
@@ -2326,7 +2326,7 @@ static int _softbody_calc_forces_slice_in_a_thread(Scene *scene, Object *ob, flo
bp->choke = 0.0f;
bp->choke2 = 0.0f;
bp->loc_flag &= ~SBF_DOFUZZY;
- if(do_deflector && !(bp->loc_flag & SBF_OUTOFCOLLISION) ) {
+ if (do_deflector && !(bp->loc_flag & SBF_OUTOFCOLLISION) ) {
float cfforce[3],defforce[3] ={0.0f,0.0f,0.0f}, vel[3] = {0.0f,0.0f,0.0f}, facenormal[3], cf = 1.0f,intrusion;
float kd = 1.0f;
@@ -2348,11 +2348,11 @@ static int _softbody_calc_forces_slice_in_a_thread(Scene *scene, Object *ob, flo
/* +++springs */
iks = 1.0f/(1.0f-sb->inspring)-1.0f ;/* inner spring constants function */
- if(ob->softflag & OB_SB_EDGES) {
+ if (ob->softflag & OB_SB_EDGES) {
if (sb->bspring){ /* spring list exists at all ? */
int b;
BodySpring *bs;
- for(b=bp->nofsprings;b>0;b--){
+ for (b=bp->nofsprings;b>0;b--){
bs = sb->bspring + bp->springs[b-1];
if (do_springcollision || do_aero){
add_v3_v3(bp->force, bs->ext_force);
@@ -2386,7 +2386,7 @@ static void sb_cf_threads_run(Scene *scene, Object *ob, float forcetime, float t
int lowpoints =100; /* wild guess .. may increase with better thread management 'above' or even be UI option sb->spawn_cf_threads_nopts */
/* figure the number of threads while preventing pretty pointless threading overhead */
- if(scene->r.mode & R_FIXED_THREADS)
+ if (scene->r.mode & R_FIXED_THREADS)
totthread= scene->r.threads;
else
totthread= BLI_system_thread_count();
@@ -2401,7 +2401,7 @@ static void sb_cf_threads_run(Scene *scene, Object *ob, float forcetime, float t
memset(sb_threads, 0, sizeof(SB_thread_context)*totthread);
left = totpoint;
dec = totpoint/totthread +1;
- for(i=0; i<totthread; i++) {
+ for (i=0; i<totthread; i++) {
sb_threads[i].scene = scene;
sb_threads[i].ob = ob;
sb_threads[i].forcetime = forcetime;
@@ -2422,10 +2422,10 @@ static void sb_cf_threads_run(Scene *scene, Object *ob, float forcetime, float t
}
- if(totthread > 1) {
+ if (totthread > 1) {
BLI_init_threads(&threads, exec_softbody_calc_forces, totthread);
- for(i=0; i<totthread; i++)
+ for (i=0; i<totthread; i++)
BLI_insert_thread(&threads, &sb_threads[i]);
BLI_end_threads(&threads);
@@ -2516,7 +2516,7 @@ static void softbody_calc_forces(Scene *scene, Object *ob, float forcetime, floa
/* jacobian
NLboolean success;
- if(nl_flags){
+ if (nl_flags){
nlBegin(NL_SYSTEM);
nlBegin(NL_MATRIX);
}
@@ -2546,10 +2546,10 @@ static void softbody_calc_forces(Scene *scene, Object *ob, float forcetime, floa
do_deflector = sb_detect_aabb_collisionCached(defforce,ob->lay,ob,timenow);
}
- for(a=sb->totpoint, bp= sb->bpoint; a>0; a--, bp++) {
+ for (a=sb->totpoint, bp= sb->bpoint; a>0; a--, bp++) {
/* clear forces accumulator */
bp->force[0]= bp->force[1]= bp->force[2]= 0.0;
- if(nl_flags & NLF_BUILD){
+ if (nl_flags & NLF_BUILD){
//int ia =3*(sb->totpoint-a);
//int op =3*sb->totpoint;
/* dF/dV = v */
@@ -2572,7 +2572,7 @@ static void softbody_calc_forces(Scene *scene, Object *ob, float forcetime, floa
/* naive ball self collision */
/* needs to be done if goal snaps or not */
- if(do_selfcollision){
+ if (do_selfcollision){
int attached;
BodyPoint *obp;
int c,b;
@@ -2580,7 +2580,7 @@ static void softbody_calc_forces(Scene *scene, Object *ob, float forcetime, floa
float distance;
float compare;
- for(c=sb->totpoint, obp= sb->bpoint; c>=a; c--, obp++) {
+ for (c=sb->totpoint, obp= sb->bpoint; c>=a; c--, obp++) {
//if ((bp->octantflag & obp->octantflag) == 0) continue;
@@ -2595,7 +2595,7 @@ static void softbody_calc_forces(Scene *scene, Object *ob, float forcetime, floa
if (distance < compare ){
/* exclude body points attached with a spring */
attached = 0;
- for(b=obp->nofsprings;b>0;b--){
+ for (b=obp->nofsprings;b>0;b--){
bs = sb->bspring + obp->springs[b-1];
if (( sb->totpoint-a == bs->v2) || ( sb->totpoint-a == bs->v1)){
attached=1;
@@ -2611,7 +2611,7 @@ static void softbody_calc_forces(Scene *scene, Object *ob, float forcetime, floa
Vec3PlusStVec(bp->force,f*(1.0f-sb->balldamp),def);
Vec3PlusStVec(bp->force,sb->balldamp,dvel);
- if(nl_flags & NLF_BUILD){
+ if (nl_flags & NLF_BUILD){
//int ia =3*(sb->totpoint-a);
//int ic =3*(sb->totpoint-c);
//int op =3*sb->totpoint;
@@ -2649,12 +2649,12 @@ static void softbody_calc_forces(Scene *scene, Object *ob, float forcetime, floa
}
/* naive ball self collision done */
- if(_final_goal(ob,bp) < SOFTGOALSNAP){ /* ommit this bp when it snaps */
+ if (_final_goal(ob,bp) < SOFTGOALSNAP){ /* ommit this bp when it snaps */
float auxvect[3];
float velgoal[3];
/* do goal stuff */
- if(ob->softflag & OB_SB_GOAL) {
+ if (ob->softflag & OB_SB_GOAL) {
/* true elastic goal */
sub_v3_v3v3(auxvect,bp->pos,bp->origT);
ks = 1.0f/(1.0f- _final_goal(ob,bp)*sb->goalspring)-1.0f ;
@@ -2662,7 +2662,7 @@ static void softbody_calc_forces(Scene *scene, Object *ob, float forcetime, floa
bp->force[1]+= -ks*(auxvect[1]);
bp->force[2]+= -ks*(auxvect[2]);
- if(nl_flags & NLF_BUILD){
+ if (nl_flags & NLF_BUILD){
//int ia =3*(sb->totpoint-a);
//int op =3*(sb->totpoint);
/* depending on my pos */
@@ -2679,7 +2679,7 @@ static void softbody_calc_forces(Scene *scene, Object *ob, float forcetime, floa
bp->force[0]-= kd * (auxvect[0]);
bp->force[1]-= kd * (auxvect[1]);
bp->force[2]-= kd * (auxvect[2]);
- if(nl_flags & NLF_BUILD){
+ if (nl_flags & NLF_BUILD){
//int ia =3*(sb->totpoint-a);
normalize_v3(auxvect);
/* depending on my vel */
@@ -2701,7 +2701,7 @@ static void softbody_calc_forces(Scene *scene, Object *ob, float forcetime, floa
/* particle field & vortex */
- if(do_effector) {
+ if (do_effector) {
EffectedPoint epoint;
float force[3]= {0.0f, 0.0f, 0.0f};
float speed[3]= {0.0f, 0.0f, 0.0f};
@@ -2729,7 +2729,7 @@ static void softbody_calc_forces(Scene *scene, Object *ob, float forcetime, floa
bp->force[1]-= bp->vec[1]*kd;
bp->force[2]-= bp->vec[2]*kd;
/* friction in media done */
- if(nl_flags & NLF_BUILD){
+ if (nl_flags & NLF_BUILD){
//int ia =3*(sb->totpoint-a);
/* da/dv = */
@@ -2743,13 +2743,13 @@ static void softbody_calc_forces(Scene *scene, Object *ob, float forcetime, floa
bp->choke = 0.0f;
bp->choke2 = 0.0f;
bp->loc_flag &= ~SBF_DOFUZZY;
- if(do_deflector) {
+ if (do_deflector) {
float cfforce[3],defforce[3] ={0.0f,0.0f,0.0f}, vel[3] = {0.0f,0.0f,0.0f}, facenormal[3], cf = 1.0f,intrusion;
kd = 1.0f;
if (sb_deflect_face(ob,bp->pos,facenormal,defforce,&cf,timenow,vel,&intrusion)){
if ((!nl_flags)&&(intrusion < 0.0f)){
- if(G.rt & 0x01){ // 17 we did check for bit 0x10 before
+ if (G.rt & 0x01){ // 17 we did check for bit 0x10 before
/*fixing bug [17428] this forces adaptive step size to tiny steps
in some situations .. keeping G.rt==17 option for old files 'needing' the bug
*/
@@ -2792,9 +2792,9 @@ static void softbody_calc_forces(Scene *scene, Object *ob, float forcetime, floa
/* ---cached collision targets */
/* +++springs */
- if(ob->softflag & OB_SB_EDGES) {
+ if (ob->softflag & OB_SB_EDGES) {
if (sb->bspring){ /* spring list exists at all ? */
- for(b=bp->nofsprings;b>0;b--){
+ for (b=bp->nofsprings;b>0;b--){
bs = sb->bspring + bp->springs[b-1];
if (do_springcollision || do_aero){
add_v3_v3(bp->force, bs->ext_force);
@@ -2818,9 +2818,9 @@ static void softbody_calc_forces(Scene *scene, Object *ob, float forcetime, floa
/* finish matrix and solve */
#if (0) // remove onl linking for now .. still i am not sure .. the jacobian can be useful .. so keep that BM
- if(nl_flags & NLF_SOLVE){
+ if (nl_flags & NLF_SOLVE){
//double sct,sst=PIL_check_seconds_timer();
- for(a=sb->totpoint, bp= sb->bpoint; a>0; a--, bp++) {
+ for (a=sb->totpoint, bp= sb->bpoint; a>0; a--, bp++) {
int iv =3*(sb->totpoint-a);
int ip =3*(2*sb->totpoint-a);
int n;
@@ -2839,12 +2839,12 @@ static void softbody_calc_forces(Scene *scene, Object *ob, float forcetime, floa
success= nlSolveAdvanced(NULL, 1);
// nlPrintMatrix(); /* for debug purpose .. anyhow cropping B vector looks like working */
- if(success){
+ if (success){
float f;
int index =0;
/* for debug purpose .. anyhow cropping B vector looks like working */
if (G.rt ==32)
- for(a=2*sb->totpoint, bp= sb->bpoint; a>0; a--, bp++) {
+ for (a=2*sb->totpoint, bp= sb->bpoint; a>0; a--, bp++) {
f=nlGetVariable(0,index);
printf("(%f ",f);index++;
f=nlGetVariable(0,index);
@@ -2854,7 +2854,7 @@ static void softbody_calc_forces(Scene *scene, Object *ob, float forcetime, floa
}
index =0;
- for(a=sb->totpoint, bp= sb->bpoint; a>0; a--, bp++) {
+ for (a=sb->totpoint, bp= sb->bpoint; a>0; a--, bp++) {
f=nlGetVariable(0,index);
bp->impdv[0] = f; index++;
f=nlGetVariable(0,index);
@@ -2863,7 +2863,7 @@ static void softbody_calc_forces(Scene *scene, Object *ob, float forcetime, floa
bp->impdv[2] = f; index++;
}
/*
- for(a=sb->totpoint, bp= sb->bpoint; a>0; a--, bp++) {
+ for (a=sb->totpoint, bp= sb->bpoint; a>0; a--, bp++) {
f=nlGetVariable(0,index);
bp->impdx[0] = f; index++;
f=nlGetVariable(0,index);
@@ -2875,7 +2875,7 @@ static void softbody_calc_forces(Scene *scene, Object *ob, float forcetime, floa
}
else{
printf("Matrix inversion failed \n");
- for(a=sb->totpoint, bp= sb->bpoint; a>0; a--, bp++) {
+ for (a=sb->totpoint, bp= sb->bpoint; a>0; a--, bp++) {
copy_v3_v3(bp->impdv,bp->force);
}
@@ -2914,16 +2914,16 @@ static void softbody_apply_forces(Object *ob, float forcetime, int mode, float *
else timeovermass = forcetime/0.009999f;
*/
- for(a=sb->totpoint, bp= sb->bpoint; a>0; a--, bp++) {
+ for (a=sb->totpoint, bp= sb->bpoint; a>0; a--, bp++) {
/* now we have individual masses */
/* claim a minimum mass for vertex */
if (_final_mass(ob,bp) > 0.009999f) timeovermass = forcetime/_final_mass(ob,bp);
else timeovermass = forcetime/0.009999f;
- if(_final_goal(ob,bp) < SOFTGOALSNAP){
+ if (_final_goal(ob,bp) < SOFTGOALSNAP){
/* this makes t~ = t */
- if(mid_flags & MID_PRESERVE) copy_v3_v3(dx,bp->vec);
+ if (mid_flags & MID_PRESERVE) copy_v3_v3(dx,bp->vec);
/* so here is (v)' = a(cceleration) = sum(F_springs)/m + gravitation + some friction forces + more forces*/
/* the ( ... )' operator denotes derivate respective time */
@@ -2951,7 +2951,7 @@ static void softbody_apply_forces(Object *ob, float forcetime, int mode, float *
else { add_v3_v3(bp->vec, bp->force); }
/* this makes t~ = t+dt */
- if(!(mid_flags & MID_PRESERVE)) copy_v3_v3(dx,bp->vec);
+ if (!(mid_flags & MID_PRESERVE)) copy_v3_v3(dx,bp->vec);
/* so here is (x)'= v(elocity) */
/* the euler step for location then becomes */
@@ -2964,7 +2964,7 @@ static void softbody_apply_forces(Object *ob, float forcetime, int mode, float *
bp->frozen /=2;
}
else{
- bp->frozen =MIN2(bp->frozen*1.05f,1.0f);
+ bp->frozen = MIN2(bp->frozen*1.05f,1.0f);
}
mul_v3_fl(dx,bp->frozen);
*/
@@ -3031,7 +3031,7 @@ static void softbody_restore_prev_step(Object *ob)
BodyPoint *bp;
int a;
- for(a=sb->totpoint, bp= sb->bpoint; a>0; a--, bp++) {
+ for (a=sb->totpoint, bp= sb->bpoint; a>0; a--, bp++) {
copy_v3_v3(bp->vec, bp->prevvec);
copy_v3_v3(bp->pos, bp->prevpos);
}
@@ -3044,7 +3044,7 @@ static void softbody_store_step(Object *ob)
BodyPoint *bp;
int a;
- for(a=sb->totpoint, bp= sb->bpoint; a>0; a--, bp++) {
+ for (a=sb->totpoint, bp= sb->bpoint; a>0; a--, bp++) {
copy_v3_v3(bp->prevvec,bp->vec);
copy_v3_v3(bp->prevpos,bp->pos);
}
@@ -3059,7 +3059,7 @@ static void softbody_store_state(Object *ob,float *ppos,float *pvel)
int a;
float *pp=ppos,*pv=pvel;
- for(a=sb->totpoint, bp= sb->bpoint; a>0; a--, bp++) {
+ for (a=sb->totpoint, bp= sb->bpoint; a>0; a--, bp++) {
copy_v3_v3(pv, bp->vec);
pv+=3;
@@ -3077,7 +3077,7 @@ static void softbody_retrieve_state(Object *ob,float *ppos,float *pvel)
int a;
float *pp=ppos,*pv=pvel;
- for(a=sb->totpoint, bp= sb->bpoint; a>0; a--, bp++) {
+ for (a=sb->totpoint, bp= sb->bpoint; a>0; a--, bp++) {
copy_v3_v3(bp->vec,pv);
pv+=3;
@@ -3096,7 +3096,7 @@ static void softbody_swap_state(Object *ob,float *ppos,float *pvel)
float *pp=ppos,*pv=pvel;
float temp[3];
- for(a=sb->totpoint, bp= sb->bpoint; a>0; a--, bp++) {
+ for (a=sb->totpoint, bp= sb->bpoint; a>0; a--, bp++) {
copy_v3_v3(temp, bp->vec);
copy_v3_v3(bp->vec,pv);
@@ -3124,7 +3124,7 @@ static void softbody_apply_goalsnap(Object *ob)
BodyPoint *bp;
int a;
- for(a=sb->totpoint, bp= sb->bpoint; a>0; a--, bp++) {
+ for (a=sb->totpoint, bp= sb->bpoint; a>0; a--, bp++) {
if (_final_goal(ob,bp) >= SOFTGOALSNAP){
copy_v3_v3(bp->prevpos,bp->pos);
copy_v3_v3(bp->pos,bp->origT);
@@ -3143,7 +3143,7 @@ static void apply_spring_memory(Object *ob)
if (sb && sb->totspring){
b = sb->plastic;
- for(a=0; a<sb->totspring; a++) {
+ for (a=0; a<sb->totspring; a++) {
bs = &sb->bspring[a];
bp1 =&sb->bpoint[bs->v1];
bp2 =&sb->bpoint[bs->v2];
@@ -3166,7 +3166,7 @@ static void interpolate_exciter(Object *ob, int timescale, int time)
f = (float)time/(float)timescale;
- for(a=sb->totpoint, bp= sb->bpoint; a>0; a--, bp++) {
+ for (a=sb->totpoint, bp= sb->bpoint; a>0; a--, bp++) {
bp->origT[0] = bp->origS[0] + f*(bp->origE[0] - bp->origS[0]);
bp->origT[1] = bp->origS[1] + f*(bp->origE[1] - bp->origS[1]);
bp->origT[2] = bp->origS[2] + f*(bp->origE[2] - bp->origS[2]);
@@ -3197,17 +3197,17 @@ static void get_scalar_from_vertexgroup(Object *ob, int vertID, short groupindex
int i;
/* spot the vert in deform vert list at mesh */
- if(ob->type==OB_MESH) {
+ if (ob->type==OB_MESH) {
Mesh *me= ob->data;
if (me->dvert)
dv = me->dvert + vertID;
}
- else if(ob->type==OB_LATTICE) { /* not yet supported in softbody btw */
+ else if (ob->type==OB_LATTICE) { /* not yet supported in softbody btw */
Lattice *lt= ob->data;
if (lt->dvert)
dv = lt->dvert + vertID;
}
- if(dv) {
+ if (dv) {
/* Lets see if this vert is in the weight group */
for (i=0; i<dv->totweight; i++){
if (dv->dw[i].def_nr == groupindex){
@@ -3235,9 +3235,9 @@ static void springs_from_mesh(Object *ob)
** will be overwritten sbObjectStep() to receive
** actual modifier stack positions
*/
- if(me->totvert) {
+ if (me->totvert) {
bp= ob->soft->bpoint;
- for(a=0; a<me->totvert; a++, bp++) {
+ for (a=0; a<me->totvert; a++, bp++) {
copy_v3_v3(bp->origS, me->mvert[a].co);
mul_m4_v3(ob->obmat, bp->origS);
}
@@ -3248,7 +3248,7 @@ static void springs_from_mesh(Object *ob)
if (sb->springpreload != 0 ){
scale = sb->springpreload / 100.0f;
}
- for(a=0; a<sb->totspring; a++) {
+ for (a=0; a<sb->totspring; a++) {
BodySpring *bs = &sb->bspring[a];
bs->len= scale*len_v3v3(sb->bpoint[bs->v1].origS, sb->bpoint[bs->v2].origS);
}
@@ -3277,14 +3277,14 @@ static void mesh_to_softbody(Scene *scene, Object *ob)
sb= ob->soft;
bp= sb->bpoint;
- for(a=0; a<me->totvert; a++, bp++) {
+ for (a=0; a<me->totvert; a++, bp++) {
/* get scalar values needed *per vertex* from vertex group functions,
so we can *paint* them nicly ..
they are normalized [0.0..1.0] so may be we need amplitude for scale
which can be done by caller but still .. i'd like it to go this way
*/
- if((ob->softflag & OB_SB_GOAL) && sb->vertgroup) { /* even this is a deprecated evil hack */
+ if ((ob->softflag & OB_SB_GOAL) && sb->vertgroup) { /* even this is a deprecated evil hack */
/* I'd like to have it .. if (sb->namedVG_Goal[0]) */
get_scalar_from_vertexgroup(ob, a,(short) (sb->vertgroup-1), &bp->goal);
@@ -3298,7 +3298,7 @@ static void mesh_to_softbody(Scene *scene, Object *ob)
else{
/* in consequence if no group was set .. but we want to animate it laters */
/* logically attach to goal with default first */
- if(ob->softflag & OB_SB_GOAL){bp->goal =sb->defgoal;}
+ if (ob->softflag & OB_SB_GOAL){bp->goal = sb->defgoal;}
}
/* to proove the concept
@@ -3309,7 +3309,7 @@ static void mesh_to_softbody(Scene *scene, Object *ob)
{
int grp= defgroup_name_index (ob,sb->namedVG_Mass);
/* printf("VGN %s %d \n",sb->namedVG_Mass,grp); */
- if(grp > -1){
+ if (grp > -1){
get_scalar_from_vertexgroup(ob, a,(short) (grp), &bp->mass);
/* 2.5 bp->mass = bp->mass * sb->nodemass; */
/* printf("bp->mass %f \n",bp->mass); */
@@ -3323,7 +3323,7 @@ static void mesh_to_softbody(Scene *scene, Object *ob)
{
int grp= defgroup_name_index (ob,sb->namedVG_Spring_K);
//printf("VGN %s %d \n",sb->namedVG_Spring_K,grp);
- if(grp > -1){
+ if (grp > -1){
get_scalar_from_vertexgroup(ob, a,(short) (grp), &bp->springweight);
//printf("bp->springweight %f \n",bp->springweight);
@@ -3335,9 +3335,9 @@ static void mesh_to_softbody(Scene *scene, Object *ob)
/* but we only optionally add body edge springs */
if (ob->softflag & OB_SB_EDGES) {
- if(medge) {
+ if (medge) {
bs= sb->bspring;
- for(a=me->totedge; a>0; a--, medge++, bs++) {
+ for (a=me->totedge; a>0; a--, medge++, bs++) {
bs->v1= medge->v1;
bs->v2= medge->v2;
bs->springtype=SB_EDGE;
@@ -3376,7 +3376,7 @@ static void mesh_faces_to_scratch(Object *ob)
bodyface = sb->scratch->bodyface = MEM_mallocN(sizeof(BodyFace)*me->totface,"SB_body_Faces");
//memcpy(sb->scratch->mface,me->mface,sizeof(MFace)*me->totface);
mface = me->mface;
- for(a=0; a<me->totface; a++, mface++, bodyface++) {
+ for (a=0; a<me->totface; a++, mface++, bodyface++) {
bodyface->v1 = mface->v1;
bodyface->v2 = mface->v2;
bodyface->v3 = mface->v3;
@@ -3398,7 +3398,7 @@ static void reference_to_scratch(Object *ob)
sb->scratch->Ref.ivert = MEM_mallocN(sizeof(ReferenceVert)*sb->totpoint,"SB_Reference");
bp= ob->soft->bpoint;
rp= sb->scratch->Ref.ivert;
- for(a=0; a<sb->totpoint; a++, rp++, bp++) {
+ for (a=0; a<sb->totpoint; a++, rp++, bp++) {
copy_v3_v3(rp->pos,bp->pos);
add_v3_v3(accu_pos, bp->pos);
accu_mass += _final_mass(ob,bp);
@@ -3430,27 +3430,27 @@ static void makelatticesprings(Lattice *lt, BodySpring *bs, int dostiff,Object *
dv= lt->pntsu;
dw= dv*lt->pntsv;
- for(w=0; w<lt->pntsw; w++) {
+ for (w=0; w<lt->pntsw; w++) {
- for(v=0; v<lt->pntsv; v++) {
+ for (v=0; v<lt->pntsv; v++) {
- for(u=0, bpuc=0, bpu=NULL; u<lt->pntsu; u++, bp++, bpc++) {
+ for (u=0, bpuc=0, bpu=NULL; u<lt->pntsu; u++, bp++, bpc++) {
- if(w) {
+ if (w) {
bs->v1 = bpc;
bs->v2 = bpc-dw;
bs->springtype=SB_EDGE;
bs->len= globallen((bp-dw)->vec, bp->vec,ob);
bs++;
}
- if(v) {
+ if (v) {
bs->v1 = bpc;
bs->v2 = bpc-dv;
bs->springtype=SB_EDGE;
bs->len= globallen((bp-dv)->vec, bp->vec,ob);
bs++;
}
- if(u) {
+ if (u) {
bs->v1 = bpuc;
bs->v2 = bpc;
bs->springtype=SB_EDGE;
@@ -3460,15 +3460,15 @@ static void makelatticesprings(Lattice *lt, BodySpring *bs, int dostiff,Object *
if (dostiff) {
- if(w){
- if( v && u ) {
+ if (w){
+ if ( v && u ) {
bs->v1 = bpc;
bs->v2 = bpc-dw-dv-1;
bs->springtype=SB_BEND;
bs->len= globallen((bp-dw-dv-1)->vec, bp->vec,ob);
bs++;
}
- if( (v < lt->pntsv-1) && (u != 0) ) {
+ if ( (v < lt->pntsv-1) && (u != 0) ) {
bs->v1 = bpc;
bs->v2 = bpc-dw+dv-1;
bs->springtype=SB_BEND;
@@ -3477,15 +3477,15 @@ static void makelatticesprings(Lattice *lt, BodySpring *bs, int dostiff,Object *
}
}
- if(w < lt->pntsw -1){
- if( v && u ) {
+ if (w < lt->pntsw -1){
+ if ( v && u ) {
bs->v1 = bpc;
bs->v2 = bpc+dw-dv-1;
bs->springtype=SB_BEND;
bs->len= globallen((bp+dw-dv-1)->vec, bp->vec,ob);
bs++;
}
- if( (v < lt->pntsv-1) && (u != 0) ) {
+ if ( (v < lt->pntsv-1) && (u != 0) ) {
bs->v1 = bpc;
bs->v2 = bpc+dw+dv-1;
bs->springtype=SB_BEND;
@@ -3526,15 +3526,15 @@ static void lattice_to_softbody(Scene *scene, Object *ob)
sb= ob->soft; /* can be created in renew_softbody() */
/* weights from bpoints, same code used as for mesh vertices */
- /* if((ob->softflag & OB_SB_GOAL) && sb->vertgroup) { 2.4x one*/
+ /* if ((ob->softflag & OB_SB_GOAL) && sb->vertgroup) { 2.4x one*/
/* new! take the weights from lattice vertex anyhow */
- if(ob->softflag & OB_SB_GOAL){
+ if (ob->softflag & OB_SB_GOAL){
BodyPoint *bp= sb->bpoint;
BPoint *bpnt= lt->def;
/* jow_go_for2_5 */
int a;
- for(a=0; a<totvert; a++, bp++, bpnt++) {
+ for (a=0; a<totvert; a++, bp++, bpnt++) {
bp->goal= bpnt->weight;
}
}
@@ -3562,7 +3562,7 @@ static void curve_surf_to_softbody(Scene *scene, Object *ob)
totvert= count_curveverts(&cu->nurb);
if (ob->softflag & OB_SB_EDGES){
- if(ob->type==OB_CURVE) {
+ if (ob->type==OB_CURVE) {
totspring= totvert - BLI_countlist(&cu->nurb);
}
}
@@ -3576,19 +3576,19 @@ static void curve_surf_to_softbody(Scene *scene, Object *ob)
bs= sb->bspring;
/* weights from bpoints, same code used as for mesh vertices */
- /* if((ob->softflag & OB_SB_GOAL) && sb->vertgroup) 2.4x hack*/
+ /* if ((ob->softflag & OB_SB_GOAL) && sb->vertgroup) 2.4x hack*/
/* new! take the weights from curve vertex anyhow */
- if(ob->softflag & OB_SB_GOAL)
+ if (ob->softflag & OB_SB_GOAL)
setgoal= 1;
- for(nu= cu->nurb.first; nu; nu= nu->next) {
- if(nu->bezt) {
+ for (nu= cu->nurb.first; nu; nu= nu->next) {
+ if (nu->bezt) {
/* bezier case ; this is nicly said naive; who ever wrote this part, it was not me (JOW) :) */
/* a: never ever make tangent handles (sub) and or (ob)ject to collision */
/* b: rather calculate them using some C2 (C2= continous in second derivate -> no jump in bending ) condition */
/* not too hard to do, but needs some more code to care for; some one may want look at it JOW 2010/06/12*/
- for(bezt=nu->bezt, a=0; a<nu->pntsu; a++, bezt++, bp+=3, curindex+=3) {
- if(setgoal) {
+ for (bezt=nu->bezt, a=0; a<nu->pntsu; a++, bezt++, bp+=3, curindex+=3) {
+ if (setgoal) {
bp->goal= bezt->weight;
/* all three triples */
@@ -3599,8 +3599,8 @@ static void curve_surf_to_softbody(Scene *scene, Object *ob)
(bp+2)->loc_flag |= SBF_OUTOFCOLLISION;
}
- if(totspring) {
- if(a>0) {
+ if (totspring) {
+ if (a>0) {
bs->v1= curindex-3;
bs->v2= curindex;
bs->springtype=SB_HANDLE;
@@ -3622,11 +3622,11 @@ static void curve_surf_to_softbody(Scene *scene, Object *ob)
}
}
else {
- for(bpnt=nu->bp, a=0; a<nu->pntsu*nu->pntsv; a++, bpnt++, bp++, curindex++) {
- if(setgoal) {
+ for (bpnt=nu->bp, a=0; a<nu->pntsu*nu->pntsv; a++, bpnt++, bp++, curindex++) {
+ if (setgoal) {
bp->goal= bpnt->weight;
}
- if(totspring && a>0) {
+ if (totspring && a>0) {
bs->v1= curindex-1;
bs->v2= curindex;
bs->springtype=SB_EDGE;
@@ -3637,7 +3637,7 @@ static void curve_surf_to_softbody(Scene *scene, Object *ob)
}
}
- if(totspring)
+ if (totspring)
{
build_bps_springlist(ob); /* link bps to springs */
if (ob->softflag & OB_SB_SELF) {calculate_collision_balls(ob);}
@@ -3648,16 +3648,16 @@ static void curve_surf_to_softbody(Scene *scene, Object *ob)
static void softbody_to_object(Object *ob, float (*vertexCos)[3], int numVerts, int local)
{
SoftBody *sb= ob->soft;
- if(sb){
+ if (sb){
BodyPoint *bp= sb->bpoint;
int a;
- if(sb->solverflags & SBSO_ESTIMATEIPO){SB_estimate_transform(ob,sb->lcom,sb->lrot,sb->lscale);}
+ if (sb->solverflags & SBSO_ESTIMATEIPO){SB_estimate_transform(ob,sb->lcom,sb->lrot,sb->lscale);}
/* inverse matrix is not uptodate... */
invert_m4_m4(ob->imat, ob->obmat);
- for(a=0; a<numVerts; a++, bp++) {
+ for (a=0; a<numVerts; a++, bp++) {
copy_v3_v3(vertexCos[a], bp->pos);
- if(local==0)
+ if (local==0)
mul_m4_v3(ob->imat, vertexCos[a]); /* softbody is in global coords, baked optionally not */
}
}
@@ -3725,7 +3725,7 @@ SoftBody *sbNew(Scene *scene)
sb->pointcache = BKE_ptcache_add(&sb->ptcaches);
- if(!sb->effector_weights)
+ if (!sb->effector_weights)
sb->effector_weights = BKE_add_effector_weights(NULL);
sb->last_frame= MINFRAME-1;
@@ -3739,7 +3739,7 @@ void sbFree(SoftBody *sb)
free_softbody_intern(sb);
BKE_ptcache_free_list(&sb->ptcaches);
sb->pointcache = NULL;
- if(sb->effector_weights)
+ if (sb->effector_weights)
MEM_freeN(sb->effector_weights);
MEM_freeN(sb);
}
@@ -3759,10 +3759,10 @@ void sbObjectToSoftbody(Object *ob)
static int object_has_edges(Object *ob)
{
- if(ob->type==OB_MESH) {
+ if (ob->type==OB_MESH) {
return ((Mesh*) ob->data)->totedge;
}
- else if(ob->type==OB_LATTICE) {
+ else if (ob->type==OB_LATTICE) {
return 1;
}
else {
@@ -3781,10 +3781,10 @@ static void softbody_update_positions(Object *ob, SoftBody *sb, float (*vertexCo
BodyPoint *bp;
int a;
- if(!sb || !sb->bpoint)
+ if (!sb || !sb->bpoint)
return;
- for(a=0,bp=sb->bpoint; a<numVerts; a++, bp++) {
+ for (a=0,bp=sb->bpoint; a<numVerts; a++, bp++) {
/* store where goals are now */
copy_v3_v3(bp->origS, bp->origE);
/* copy the position of the goals at desired end time */
@@ -3823,13 +3823,13 @@ void SB_estimate_transform(Object *ob,float lloc[3],float lrot[3][3],float lscal
float com[3],rcom[3];
int a;
- if(!ob ||!ob->soft) return; /* why did we get here ? */
+ if (!ob ||!ob->soft) return; /* why did we get here ? */
sb= ob->soft;
- if(!sb || !sb->bpoint) return;
+ if (!sb || !sb->bpoint) return;
opos= MEM_callocN( (sb->totpoint)*3*sizeof(float), "SB_OPOS");
rpos= MEM_callocN( (sb->totpoint)*3*sizeof(float), "SB_RPOS");
/* might filter vertex selection with a vertex group */
- for(a=0, bp=sb->bpoint, rp=sb->scratch->Ref.ivert; a<sb->totpoint; a++, bp++, rp++) {
+ for (a=0, bp=sb->bpoint, rp=sb->scratch->Ref.ivert; a<sb->totpoint; a++, bp++, rp++) {
copy_v3_v3(rpos[a],rp->pos);
copy_v3_v3(opos[a],bp->pos);
}
@@ -3851,7 +3851,7 @@ static void softbody_reset(Object *ob, SoftBody *sb, float (*vertexCos)[3], int
BodyPoint *bp;
int a;
- for(a=0,bp=sb->bpoint; a<numVerts; a++, bp++) {
+ for (a=0,bp=sb->bpoint; a<numVerts; a++, bp++) {
copy_v3_v3(bp->pos, vertexCos[a]);
mul_m4_v3(ob->obmat, bp->pos); /* yep, sofbody is global coords*/
copy_v3_v3(bp->origS, bp->pos);
@@ -3889,7 +3889,7 @@ static void softbody_reset(Object *ob, SoftBody *sb, float (*vertexCos)[3], int
/* copy some info to scratch */
/* we only need that if we want to reconstruct IPO */
- if(1) {
+ if (1) {
reference_to_scratch(ob);
SB_estimate_transform(ob,NULL,NULL,NULL);
SB_estimate_transform(ob,NULL,NULL,NULL);
@@ -3920,11 +3920,11 @@ static void softbody_step(Scene *scene, Object *ob, SoftBody *sb, float dtime)
So we refuse to do so. Since we do not know anything about 'outside' canges
especially colliders we refuse to go more than 10 frames.
*/
- if(dtime < 0 || dtime > 10.5f) return;
+ if (dtime < 0 || dtime > 10.5f) return;
ccd_update_deflector_hash(scene, ob, sb->scratch->colliderhash);
- if(sb->scratch->needstobuildcollider){
+ if (sb->scratch->needstobuildcollider){
if (query_external_colliders(scene, ob)){
ccd_build_deflector_hash(scene, ob, sb->scratch->colliderhash);
}
@@ -3948,9 +3948,9 @@ static void softbody_step(Scene *scene, Object *ob, SoftBody *sb, float dtime)
if (sb->minloops > 0) forcetimemax = dtime / sb->minloops;
if (sb->maxloops > 0) forcetimemin = dtime / sb->maxloops;
- if(sb->solver_ID>0) mid_flags |= MID_PRESERVE;
+ if (sb->solver_ID>0) mid_flags |= MID_PRESERVE;
- forcetime =forcetimemax; /* hope for integrating in one step */
+ forcetime = forcetimemax; /* hope for integrating in one step */
while ( (ABS(timedone) < ABS(dtime)) && (loops < 2000) )
{
/* set goals in time */
@@ -4001,7 +4001,7 @@ static void softbody_step(Scene *scene, Object *ob, SoftBody *sb, float dtime)
forcetime = MAX2(dtime - timedone,newtime);
}
loops++;
- if(sb->solverflags & SBSO_MONITOR ){
+ if (sb->solverflags & SBSO_MONITOR ){
sct=PIL_check_seconds_timer();
if (sct-sst > 0.5f) printf("%3.0f%% \r",100.0f*timedone/dtime);
}
@@ -4013,8 +4013,8 @@ static void softbody_step(Scene *scene, Object *ob, SoftBody *sb, float dtime)
interpolate_exciter(ob, 2, 2);
softbody_apply_goalsnap(ob);
- // if(G.f & G_DEBUG){
- if(sb->solverflags & SBSO_MONITOR ){
+ // if (G.f & G_DEBUG){
+ if (sb->solverflags & SBSO_MONITOR ){
if (loops > HEUNWARNLIMIT) /* monitor high loop counts */
printf("\r needed %d steps/frame",loops);
}
@@ -4036,9 +4036,9 @@ static void softbody_step(Scene *scene, Object *ob, SoftBody *sb, float dtime)
else{
printf("softbody no valid solver ID!");
}/*SOLVER SELECT*/
- if(sb->plastic){ apply_spring_memory(ob);}
+ if (sb->plastic){ apply_spring_memory(ob);}
- if(sb->solverflags & SBSO_MONITOR ){
+ if (sb->solverflags & SBSO_MONITOR ){
sct=PIL_check_seconds_timer();
if ((sct-sst > 0.5f) || (G.f & G_DEBUG)) printf(" solver time %f sec %s \n",sct-sst,ob->id.name);
}
@@ -4064,22 +4064,22 @@ void sbObjectStep(Scene *scene, Object *ob, float cfra, float (*vertexCos)[3], i
/* check for changes in mesh, should only happen in case the mesh
* structure changes during an animation */
- if(sb->bpoint && numVerts != sb->totpoint) {
+ if (sb->bpoint && numVerts != sb->totpoint) {
BKE_ptcache_invalidate(cache);
return;
}
/* clamp frame ranges */
- if(framenr < startframe) {
+ if (framenr < startframe) {
BKE_ptcache_invalidate(cache);
return;
}
- else if(framenr > endframe) {
+ else if (framenr > endframe) {
framenr = endframe;
}
/* verify if we need to create the softbody data */
- if(sb->bpoint == NULL ||
+ if (sb->bpoint == NULL ||
((ob->softflag & OB_SB_EDGES) && !ob->soft->bspring && object_has_edges(ob))) {
switch(ob->type) {
@@ -4103,7 +4103,7 @@ void sbObjectStep(Scene *scene, Object *ob, float cfra, float (*vertexCos)[3], i
}
/* continue physics special case */
- if(BKE_ptcache_get_continue_physics()) {
+ if (BKE_ptcache_get_continue_physics()) {
BKE_ptcache_invalidate(cache);
/* do simulation */
dtime = timescale;
@@ -4115,10 +4115,10 @@ void sbObjectStep(Scene *scene, Object *ob, float cfra, float (*vertexCos)[3], i
}
/* still no points? go away */
- if(sb->totpoint==0) {
+ if (sb->totpoint==0) {
return;
}
- if(framenr == startframe) {
+ if (framenr == startframe) {
BKE_ptcache_id_reset(scene, &pid, PTCACHE_RESET_OUTDATED);
/* first frame, no simulation to do, just set the positions */
@@ -4135,32 +4135,32 @@ void sbObjectStep(Scene *scene, Object *ob, float cfra, float (*vertexCos)[3], i
/* try to read from cache */
cache_result = BKE_ptcache_read(&pid, framenr);
- if(cache_result == PTCACHE_READ_EXACT || cache_result == PTCACHE_READ_INTERPOLATED) {
+ if (cache_result == PTCACHE_READ_EXACT || cache_result == PTCACHE_READ_INTERPOLATED) {
softbody_to_object(ob, vertexCos, numVerts, sb->local);
BKE_ptcache_validate(cache, framenr);
- if(cache_result == PTCACHE_READ_INTERPOLATED && cache->flag & PTCACHE_REDO_NEEDED)
+ if (cache_result == PTCACHE_READ_INTERPOLATED && cache->flag & PTCACHE_REDO_NEEDED)
BKE_ptcache_write(&pid, framenr);
sb->last_frame = framenr;
return;
}
- else if(cache_result==PTCACHE_READ_OLD) {
+ else if (cache_result==PTCACHE_READ_OLD) {
; /* do nothing */
}
- else if(/*ob->id.lib || */(cache->flag & PTCACHE_BAKED)) { /* "library linking & pointcaches" has to be solved properly at some point */
+ else if (/*ob->id.lib || */(cache->flag & PTCACHE_BAKED)) { /* "library linking & pointcaches" has to be solved properly at some point */
/* if baked and nothing in cache, do nothing */
BKE_ptcache_invalidate(cache);
return;
}
- if(framenr!=sb->last_frame+1)
+ if (framenr!=sb->last_frame+1)
return;
/* if on second frame, write cache for first frame */
- if(cache->simframe == startframe && (cache->flag & PTCACHE_OUTDATED || cache->last_exact==0))
+ if (cache->simframe == startframe && (cache->flag & PTCACHE_OUTDATED || cache->last_exact==0))
BKE_ptcache_write(&pid, startframe);
softbody_update_positions(ob, sb, vertexCos, numVerts);
diff --git a/source/blender/blenkernel/intern/sound.c b/source/blender/blenkernel/intern/sound.c
index f5b677203f6..594c7a9a2f3 100644
--- a/source/blender/blenkernel/intern/sound.c
+++ b/source/blender/blenkernel/intern/sound.c
@@ -95,7 +95,7 @@ struct bSound* sound_new_file(struct Main *bmain, const char *filename)
sound_load(bmain, sound);
- if(!sound->playback_handle)
+ if (!sound->playback_handle)
{
free_libblock(&bmain->sound, sound);
sound = NULL;
@@ -113,14 +113,14 @@ void sound_free(struct bSound* sound)
}
#ifdef WITH_AUDASPACE
- if(sound->handle)
+ if (sound->handle)
{
AUD_unload(sound->handle);
sound->handle = NULL;
sound->playback_handle = NULL;
}
- if(sound->cache)
+ if (sound->cache)
{
AUD_unload(sound->cache);
sound->cache = NULL;
@@ -143,13 +143,13 @@ static void sound_sync_callback(void* data, int mode, float time)
scene = bmain->scene.first;
while(scene)
{
- if(scene->audio.flag & AUDIO_SYNC)
+ if (scene->audio.flag & AUDIO_SYNC)
{
- if(mode)
+ if (mode)
sound_play_scene(scene);
else
sound_stop_scene(scene);
- if(scene->sound_scene_handle)
+ if (scene->sound_scene_handle)
AUD_seek(scene->sound_scene_handle, time);
}
scene = scene->id.next;
@@ -192,22 +192,22 @@ void sound_init(struct Main *bmain)
specs.format = U.audioformat;
specs.rate = U.audiorate;
- if(force_device >= 0)
+ if (force_device >= 0)
device = force_device;
- if(buffersize < 128)
+ if (buffersize < 128)
buffersize = AUD_DEFAULT_BUFFER_SIZE;
- if(specs.rate < AUD_RATE_8000)
+ if (specs.rate < AUD_RATE_8000)
specs.rate = AUD_RATE_44100;
- if(specs.format <= AUD_FORMAT_INVALID)
+ if (specs.format <= AUD_FORMAT_INVALID)
specs.format = AUD_FORMAT_S16;
- if(specs.channels <= AUD_CHANNELS_INVALID)
+ if (specs.channels <= AUD_CHANNELS_INVALID)
specs.channels = AUD_CHANNELS_STEREO;
- if(!AUD_init(device, specs, buffersize))
+ if (!AUD_init(device, specs, buffersize))
AUD_init(AUD_NULL_DEVICE, specs, buffersize);
sound_init_main(bmain);
@@ -244,7 +244,7 @@ struct bSound* sound_new_buffer(struct Main *bmain, struct bSound *source)
sound_load(bmain, sound);
- if(!sound->playback_handle)
+ if (!sound->playback_handle)
{
free_libblock(&bmain->sound, sound);
sound = NULL;
@@ -270,7 +270,7 @@ struct bSound* sound_new_limiter(struct Main *bmain, struct bSound *source, floa
sound_load(bmain, sound);
- if(!sound->playback_handle)
+ if (!sound->playback_handle)
{
free_libblock(&bmain->sound, sound);
sound = NULL;
@@ -282,7 +282,7 @@ struct bSound* sound_new_limiter(struct Main *bmain, struct bSound *source, floa
void sound_delete(struct Main *bmain, struct bSound* sound)
{
- if(sound)
+ if (sound)
{
sound_free(sound);
@@ -293,11 +293,11 @@ void sound_delete(struct Main *bmain, struct bSound* sound)
void sound_cache(struct bSound* sound)
{
sound->flags |= SOUND_FLAGS_CACHING;
- if(sound->cache)
+ if (sound->cache)
AUD_unload(sound->cache);
sound->cache = AUD_bufferSound(sound->handle);
- if(sound->cache)
+ if (sound->cache)
sound->playback_handle = sound->cache;
else
sound->playback_handle = sound->handle;
@@ -312,7 +312,7 @@ void sound_cache_notifying(struct Main* main, struct bSound* sound)
void sound_delete_cache(struct bSound* sound)
{
sound->flags &= ~SOUND_FLAGS_CACHING;
- if(sound->cache)
+ if (sound->cache)
{
AUD_unload(sound->cache);
sound->cache = NULL;
@@ -322,15 +322,15 @@ void sound_delete_cache(struct bSound* sound)
void sound_load(struct Main *bmain, struct bSound* sound)
{
- if(sound)
+ if (sound)
{
- if(sound->cache)
+ if (sound->cache)
{
AUD_unload(sound->cache);
sound->cache = NULL;
}
- if(sound->handle)
+ if (sound->handle)
{
AUD_unload(sound->handle);
sound->handle = NULL;
@@ -367,28 +367,28 @@ void sound_load(struct Main *bmain, struct bSound* sound)
break;
}
case SOUND_TYPE_BUFFER:
- if(sound->child_sound && sound->child_sound->handle)
+ if (sound->child_sound && sound->child_sound->handle)
sound->handle = AUD_bufferSound(sound->child_sound->handle);
break;
case SOUND_TYPE_LIMITER:
- if(sound->child_sound && sound->child_sound->handle)
+ if (sound->child_sound && sound->child_sound->handle)
sound->handle = AUD_limitSound(sound->child_sound, sound->start, sound->end);
break;
}
#endif
- if(sound->flags & SOUND_FLAGS_MONO)
+ if (sound->flags & SOUND_FLAGS_MONO)
{
void* handle = AUD_monoSound(sound->handle);
AUD_unload(sound->handle);
sound->handle = handle;
}
- if(sound->flags & SOUND_FLAGS_CACHING)
+ if (sound->flags & SOUND_FLAGS_CACHING)
{
sound->cache = AUD_bufferSound(sound->handle);
}
- if(sound->cache)
+ if (sound->cache)
sound->playback_handle = sound->cache;
else
sound->playback_handle = sound->handle;
@@ -414,25 +414,25 @@ void sound_create_scene(struct Scene *scene)
void sound_destroy_scene(struct Scene *scene)
{
- if(scene->sound_scene_handle)
+ if (scene->sound_scene_handle)
AUD_stop(scene->sound_scene_handle);
- if(scene->sound_scrub_handle)
+ if (scene->sound_scrub_handle)
AUD_stop(scene->sound_scrub_handle);
- if(scene->sound_scene)
+ if (scene->sound_scene)
AUD_destroySequencer(scene->sound_scene);
- if(scene->speaker_handles)
+ if (scene->speaker_handles)
AUD_destroySet(scene->speaker_handles);
}
void sound_mute_scene(struct Scene *scene, int muted)
{
- if(scene->sound_scene)
+ if (scene->sound_scene)
AUD_setSequencerMuted(scene->sound_scene, muted);
}
void sound_update_fps(struct Scene *scene)
{
- if(scene->sound_scene)
+ if (scene->sound_scene)
AUD_setSequencerFPS(scene->sound_scene, FPS);
}
@@ -444,7 +444,7 @@ void sound_update_scene_listener(struct Scene *scene)
void* sound_scene_add_scene_sound(struct Scene *scene, struct Sequence* sequence, int startframe, int endframe, int frameskip)
{
- if(scene != sequence->scene)
+ if (scene != sequence->scene)
return AUD_addSequence(scene->sound_scene, sequence->scene->sound_scene, startframe / FPS, endframe / FPS, frameskip / FPS);
return NULL;
}
@@ -531,18 +531,19 @@ void sound_update_sequencer(struct Main* main, struct bSound* sound)
{
struct Scene* scene;
- for(scene = main->scene.first; scene; scene = scene->id.next)
+ for (scene = main->scene.first; scene; scene = scene->id.next) {
seq_update_sound(scene, sound);
+ }
}
static void sound_start_play_scene(struct Scene *scene)
{
- if(scene->sound_scene_handle)
+ if (scene->sound_scene_handle)
AUD_stop(scene->sound_scene_handle);
AUD_setSequencerDeviceSpecs(scene->sound_scene);
- if((scene->sound_scene_handle = AUD_play(scene->sound_scene, 1)))
+ if ((scene->sound_scene_handle = AUD_play(scene->sound_scene, 1)))
AUD_setLoop(scene->sound_scene_handle, -1);
}
@@ -553,22 +554,22 @@ void sound_play_scene(struct Scene *scene)
status = scene->sound_scene_handle ? AUD_getStatus(scene->sound_scene_handle) : AUD_STATUS_INVALID;
- if(status == AUD_STATUS_INVALID)
+ if (status == AUD_STATUS_INVALID)
sound_start_play_scene(scene);
- if(!scene->sound_scene_handle)
+ if (!scene->sound_scene_handle)
{
AUD_unlock();
return;
}
- if(status != AUD_STATUS_PLAYING)
+ if (status != AUD_STATUS_PLAYING)
{
AUD_seek(scene->sound_scene_handle, CFRA / FPS);
AUD_resume(scene->sound_scene_handle);
}
- if(scene->audio.flag & AUDIO_SYNC)
+ if (scene->audio.flag & AUDIO_SYNC)
AUD_startPlayback();
AUD_unlock();
@@ -576,11 +577,11 @@ void sound_play_scene(struct Scene *scene)
void sound_stop_scene(struct Scene *scene)
{
- if(scene->sound_scene_handle)
+ if (scene->sound_scene_handle)
{
AUD_pause(scene->sound_scene_handle);
- if(scene->audio.flag & AUDIO_SYNC)
+ if (scene->audio.flag & AUDIO_SYNC)
AUD_stopPlayback();
}
}
@@ -595,11 +596,11 @@ void sound_seek_scene(struct Main *bmain, struct Scene *scene)
status = scene->sound_scene_handle ? AUD_getStatus(scene->sound_scene_handle) : AUD_STATUS_INVALID;
- if(status == AUD_STATUS_INVALID)
+ if (status == AUD_STATUS_INVALID)
{
sound_start_play_scene(scene);
- if(!scene->sound_scene_handle)
+ if (!scene->sound_scene_handle)
{
AUD_unlock();
return;
@@ -609,13 +610,15 @@ void sound_seek_scene(struct Main *bmain, struct Scene *scene)
}
animation_playing = 0;
- for(screen=bmain->screen.first; screen; screen=screen->id.next)
- if(screen->animtimer)
+ for (screen=bmain->screen.first; screen; screen=screen->id.next) {
+ if (screen->animtimer) {
animation_playing = 1;
+ }
+ }
- if(scene->audio.flag & AUDIO_SCRUB && !animation_playing)
+ if (scene->audio.flag & AUDIO_SCRUB && !animation_playing)
{
- if(scene->audio.flag & AUDIO_SYNC)
+ if (scene->audio.flag & AUDIO_SYNC)
{
AUD_seek(scene->sound_scene_handle, CFRA / FPS);
AUD_seekSequencer(scene->sound_scene_handle, CFRA / FPS);
@@ -623,22 +626,22 @@ void sound_seek_scene(struct Main *bmain, struct Scene *scene)
else
AUD_seek(scene->sound_scene_handle, CFRA / FPS);
AUD_resume(scene->sound_scene_handle);
- if(scene->sound_scrub_handle && AUD_getStatus(scene->sound_scrub_handle) != AUD_STATUS_INVALID)
+ if (scene->sound_scrub_handle && AUD_getStatus(scene->sound_scrub_handle) != AUD_STATUS_INVALID)
AUD_seek(scene->sound_scrub_handle, 0);
else
{
- if(scene->sound_scrub_handle)
+ if (scene->sound_scrub_handle)
AUD_stop(scene->sound_scrub_handle);
scene->sound_scrub_handle = AUD_pauseAfter(scene->sound_scene_handle, 1 / FPS);
}
}
else
{
- if(scene->audio.flag & AUDIO_SYNC)
+ if (scene->audio.flag & AUDIO_SYNC)
AUD_seekSequencer(scene->sound_scene_handle, CFRA / FPS);
else
{
- if(status == AUD_STATUS_PLAYING)
+ if (status == AUD_STATUS_PLAYING)
AUD_seek(scene->sound_scene_handle, CFRA / FPS);
}
}
@@ -648,9 +651,9 @@ void sound_seek_scene(struct Main *bmain, struct Scene *scene)
float sound_sync_scene(struct Scene *scene)
{
- if(scene->sound_scene_handle)
+ if (scene->sound_scene_handle)
{
- if(scene->audio.flag & AUDIO_SYNC)
+ if (scene->audio.flag & AUDIO_SYNC)
return AUD_getSequencerPosition(scene->sound_scene_handle);
else
return AUD_getPosition(scene->sound_scene_handle);
@@ -660,7 +663,7 @@ float sound_sync_scene(struct Scene *scene)
int sound_scene_playing(struct Scene *scene)
{
- if(scene->audio.flag & AUDIO_SYNC)
+ if (scene->audio.flag & AUDIO_SYNC)
return AUD_doesPlayback();
else
return -1;
@@ -668,7 +671,7 @@ int sound_scene_playing(struct Scene *scene)
void sound_free_waveform(struct bSound* sound)
{
- if(sound->waveform)
+ if (sound->waveform)
{
MEM_freeN(((SoundWaveform*)sound->waveform)->data);
MEM_freeN(sound->waveform);
@@ -683,7 +686,7 @@ void sound_read_waveform(struct bSound* sound)
info = AUD_getInfo(sound->playback_handle);
- if(info.length > 0)
+ if (info.length > 0)
{
SoundWaveform* waveform = MEM_mallocN(sizeof(SoundWaveform), "SoundWaveform");
int length = info.length * SOUND_WAVE_SAMPLES_PER_SECOND;
@@ -709,24 +712,24 @@ void sound_update_scene(struct Scene* scene)
void* handle;
float quat[4];
- for(SETLOOPER(scene, sce_it, base))
+ for (SETLOOPER(scene, sce_it, base))
{
ob = base->object;
- if(ob->type == OB_SPEAKER)
+ if (ob->type == OB_SPEAKER)
{
- if(ob->adt)
+ if (ob->adt)
{
- for(track = ob->adt->nla_tracks.first; track; track = track->next)
+ for (track = ob->adt->nla_tracks.first; track; track = track->next)
{
- for(strip = track->strips.first; strip; strip = strip->next)
+ for (strip = track->strips.first; strip; strip = strip->next)
{
- if(strip->type == NLASTRIP_TYPE_SOUND)
+ if (strip->type == NLASTRIP_TYPE_SOUND)
{
speaker = (Speaker*)ob->data;
- if(AUD_removeSet(scene->speaker_handles, strip->speaker_handle))
+ if (AUD_removeSet(scene->speaker_handles, strip->speaker_handle))
{
- if(speaker->sound)
+ if (speaker->sound)
AUD_moveSequence(strip->speaker_handle, strip->start / FPS, -1, 0);
else
{
@@ -736,14 +739,14 @@ void sound_update_scene(struct Scene* scene)
}
else
{
- if(speaker->sound)
+ if (speaker->sound)
{
strip->speaker_handle = AUD_addSequence(scene->sound_scene, speaker->sound->playback_handle, strip->start / FPS, -1, 0);
AUD_setRelativeSequence(strip->speaker_handle, 0);
}
}
- if(strip->speaker_handle)
+ if (strip->speaker_handle)
{
AUD_addSet(new_set, strip->speaker_handle);
AUD_updateSequenceData(strip->speaker_handle, speaker->volume_max,
@@ -772,7 +775,7 @@ void sound_update_scene(struct Scene* scene)
AUD_removeSequence(scene->sound_scene, handle);
}
- if(scene->camera)
+ if (scene->camera)
{
mat4_to_quat(quat, scene->camera->obmat);
AUD_setSequencerAnimData(scene->sound_scene, AUD_AP_LOCATION, CFRA, scene->camera->obmat[3], 1);
diff --git a/source/blender/blenkernel/intern/text.c b/source/blender/blenkernel/intern/text.c
index ba48db588c4..888d59b78b5 100644
--- a/source/blender/blenkernel/intern/text.c
+++ b/source/blender/blenkernel/intern/text.c
@@ -2061,7 +2061,7 @@ void txt_do_undo(Text *text)
linep= txt_undo_read_uint32(text->undo_buf, &text->undo_pos);
buf= MEM_mallocN(linep+1, "dblock buffer");
- for (i=0; i < linep; i++){
+ for (i=0; i < linep; i++) {
buf[(linep-1)-i]= text->undo_buf[text->undo_pos];
text->undo_pos--;
}
@@ -2097,7 +2097,7 @@ void txt_do_undo(Text *text)
/* txt_backspace_char removes utf8-characters, not bytes */
buf= MEM_mallocN(linep+1, "iblock buffer");
- for (i=0; i < linep; i++){
+ for (i=0; i < linep; i++) {
buf[(linep-1)-i]= text->undo_buf[text->undo_pos];
text->undo_pos--;
}
@@ -2766,7 +2766,7 @@ void txt_indent(Text *text)
if (!text->sell) return;
/* insert spaces rather than tabs */
- if (text->flags & TXT_TABSTOSPACES){
+ if (text->flags & TXT_TABSTOSPACES) {
add = tab_to_spaces;
indentlen = spaceslen;
}
@@ -2827,7 +2827,7 @@ void txt_unindent(Text *text)
if (!text->sell) return;
/* insert spaces rather than tabs */
- if (text->flags & TXT_TABSTOSPACES){
+ if (text->flags & TXT_TABSTOSPACES) {
remove = tab_to_spaces;
indent = spaceslen;
}
diff --git a/source/blender/blenkernel/intern/unit.c b/source/blender/blenkernel/intern/unit.c
index 81c526e45a6..9ab91fce302 100644
--- a/source/blender/blenkernel/intern/unit.c
+++ b/source/blender/blenkernel/intern/unit.c
@@ -294,9 +294,9 @@ static bUnitDef *unit_best_fit(double value, bUnitCollection *usys, bUnitDef *un
bUnitDef *unit;
double value_abs= value>0.0?value:-value;
- for(unit= unit_start ? unit_start:usys->units; unit->name; unit++) {
+ for (unit= unit_start ? unit_start:usys->units; unit->name; unit++) {
- if(suppress && (unit->flag & B_UNIT_DEF_SUPPRESS))
+ if (suppress && (unit->flag & B_UNIT_DEF_SUPPRESS))
continue;
/* scale down scalar so 1cm doesnt convert to 10mm because of float error */
@@ -329,10 +329,10 @@ static int unit_as_string(char *str, int len_max, double value, int prec, bUnitC
double value_conv;
int len, i;
- if(unit) {
+ if (unit) {
/* use unit without finding the best one */
}
- else if(value == 0.0) {
+ else if (value == 0.0) {
/* use the default units since there is no way to convert */
unit= unit_default(usys);
}
@@ -346,7 +346,7 @@ static int unit_as_string(char *str, int len_max, double value, int prec, bUnitC
{
len= BLI_snprintf(str, len_max, "%.*f", prec, value_conv);
- if(len >= len_max)
+ if (len >= len_max)
len= len_max;
}
@@ -361,19 +361,19 @@ static int unit_as_string(char *str, int len_max, double value, int prec, bUnitC
str[i--]= pad;
}
- if(i>0 && str[i]=='.') { /* 10. -> 10 */
+ if (i>0 && str[i]=='.') { /* 10. -> 10 */
str[i--]= pad;
}
/* Now add the suffix */
- if(i<len_max) {
+ if (i<len_max) {
int j=0;
i++;
while(unit->name_short[j] && (i < len_max)) {
str[i++]= unit->name_short[j++];
}
- if(pad) {
+ if (pad) {
/* this loop only runs if so many zeros were removed that
* the unit name only used padded chars,
* In that case add padding for the name. */
@@ -385,7 +385,7 @@ static int unit_as_string(char *str, int len_max, double value, int prec, bUnitC
}
/* terminate no matter whats done with padding above */
- if(i >= len_max)
+ if (i >= len_max)
i= len_max-1;
str[i] = '\0';
@@ -398,22 +398,22 @@ void bUnit_AsString(char *str, int len_max, double value, int prec, int system,
{
bUnitCollection *usys = unit_get_system(system, type);
- if(usys==NULL || usys->units[0].name==NULL)
+ if (usys==NULL || usys->units[0].name==NULL)
usys= &buDummyCollecton;
/* split output makes sense only for length, mass and time */
- if(split && (type==B_UNIT_LENGTH || type==B_UNIT_MASS || type==B_UNIT_TIME)) {
+ if (split && (type==B_UNIT_LENGTH || type==B_UNIT_MASS || type==B_UNIT_TIME)) {
bUnitDef *unit_a, *unit_b;
double value_a, value_b;
unit_dual_convert(value, usys, &unit_a, &unit_b, &value_a, &value_b);
/* check the 2 is a smaller unit */
- if(unit_b > unit_a) {
+ if (unit_b > unit_a) {
int i= unit_as_string(str, len_max, value_a, prec, usys, unit_a, '\0');
/* is there enough space for at least 1 char of the next unit? */
- if(i+2 < len_max) {
+ if (i+2 < len_max) {
str[i++]= ' ';
/* use low precision since this is a smaller unit */
@@ -431,9 +431,9 @@ static const char *unit_find_str(const char *str, const char *substr)
{
const char *str_found;
- if(substr && substr[0] != '\0') {
+ if (substr && substr[0] != '\0') {
str_found= strstr(str, substr);
- if(str_found) {
+ if (str_found) {
/* previous char cannot be a letter */
if (str_found == str || isalpha(*(str_found-1))==0) {
/* next char cannot be alphanum */
@@ -487,7 +487,7 @@ static int unit_scale_str(char *str, int len_max, char *str_tmp,
{
char *str_found;
- if((len_max>0) && (str_found= (char *)unit_find_str(str, replace_str))) {
+ if ((len_max>0) && (str_found= (char *)unit_find_str(str, replace_str))) {
/* XXX - investigate, does not respect len_max properly */
int len, len_num, len_name, len_move, found_ofs;
@@ -500,25 +500,25 @@ static int unit_scale_str(char *str, int len_max, char *str_tmp,
len_move= (len - (found_ofs+len_name)) + 1; /* 1+ to copy the string terminator */
len_num= BLI_snprintf(str_tmp, TEMP_STR_SIZE, "*%g"SEP_STR, unit->scalar/scale_pref); /* # removed later */
- if(len_num > len_max)
+ if (len_num > len_max)
len_num= len_max;
- if(found_ofs+len_num+len_move > len_max) {
+ if (found_ofs+len_num+len_move > len_max) {
/* can't move the whole string, move just as much as will fit */
len_move -= (found_ofs+len_num+len_move) - len_max;
}
- if(len_move>0) {
+ if (len_move>0) {
/* resize the last part of the string */
memmove(str_found+len_num, str_found+len_name, len_move); /* may grow or shrink the string */
}
- if(found_ofs+len_num > len_max) {
+ if (found_ofs+len_num > len_max) {
/* not even the number will fit into the string, only copy part of it */
len_num -= (found_ofs+len_num) - len_max;
}
- if(len_num > 0) {
+ if (len_num > 0) {
/* its possible none of the number could be copied in */
memcpy(str_found, str_tmp, len_num); /* without the string terminator */
}
@@ -574,7 +574,7 @@ int bUnit_ReplaceString(char *str, int len_max, const char *str_prev, double sca
char str_tmp[TEMP_STR_SIZE];
int change= 0;
- if(usys==NULL || usys->units[0].name==NULL) {
+ if (usys==NULL || usys->units[0].name==NULL) {
return 0;
}
@@ -583,13 +583,13 @@ int bUnit_ReplaceString(char *str, int len_max, const char *str_prev, double sca
int i;
char *ch= str;
- for(i=0; (i>=len_max || *ch=='\0'); i++, ch++)
- if((*ch>='A') && (*ch<='Z'))
+ for (i=0; (i>=len_max || *ch=='\0'); i++, ch++)
+ if ((*ch>='A') && (*ch<='Z'))
*ch += ('a'-'A');
}
- for(unit= usys->units; unit->name; unit++) {
+ for (unit= usys->units; unit->name; unit++) {
/* incase there are multiple instances */
while(unit_replace(str, len_max, str_tmp, scale_pref, unit))
change= 1;
@@ -601,11 +601,11 @@ int bUnit_ReplaceString(char *str, int len_max, const char *str_prev, double sca
bUnitCollection *usys_iter;
int system_iter;
- for(system_iter= 0; system_iter<UNIT_SYSTEM_TOT; system_iter++) {
+ for (system_iter= 0; system_iter<UNIT_SYSTEM_TOT; system_iter++) {
if (system_iter != system) {
usys_iter= unit_get_system(system_iter, type);
if (usys_iter) {
- for(unit= usys_iter->units; unit->name; unit++) {
+ for (unit= usys_iter->units; unit->name; unit++) {
int ofs = 0;
/* incase there are multiple instances */
while((ofs=unit_replace(str+ofs, len_max-ofs, str_tmp, scale_pref, unit)))
@@ -617,22 +617,22 @@ int bUnit_ReplaceString(char *str, int len_max, const char *str_prev, double sca
}
unit= NULL;
- if(change==0) {
+ if (change==0) {
/* no units given so infer a unit from the previous string or default */
- if(str_prev) {
+ if (str_prev) {
/* see which units the original value had */
- for(unit= usys->units; unit->name; unit++) {
+ for (unit= usys->units; unit->name; unit++) {
if (unit_find(str_prev, unit))
break;
}
}
- if(unit==NULL || unit->name == NULL)
+ if (unit==NULL || unit->name == NULL)
unit= unit_default(usys);
/* add the unit prefix and re-run, use brackets incase there was an expression given */
- if(BLI_snprintf(str_tmp, sizeof(str_tmp), "(%s)%s", str, unit->name) < sizeof(str_tmp)) {
+ if (BLI_snprintf(str_tmp, sizeof(str_tmp), "(%s)%s", str, unit->name) < sizeof(str_tmp)) {
strncpy(str, str_tmp, len_max);
return bUnit_ReplaceString(str, len_max, NULL, scale_pref, system, type);
}
@@ -657,9 +657,9 @@ int bUnit_ReplaceString(char *str, int len_max, const char *str_prev, double sca
int op_found= 0;
/* any operators after this?*/
- for(ch= str_found+1; *ch!='\0'; ch++) {
+ for (ch= str_found+1; *ch!='\0'; ch++) {
- if(*ch==' ' || *ch=='\t') {
+ if (*ch==' ' || *ch=='\t') {
/* do nothing */
}
else if (ch_is_op(*ch) || *ch==',') { /* found an op, no need to insert a ,*/
@@ -688,11 +688,11 @@ void bUnit_ToUnitAltName(char *str, int len_max, const char *orig_str, int syste
bUnitDef *unit_def= unit_default(usys);
/* find and substitute all units */
- for(unit= usys->units; unit->name; unit++) {
- if(len_max > 0 && (unit->name_alt || unit == unit_def))
+ for (unit= usys->units; unit->name; unit++) {
+ if (len_max > 0 && (unit->name_alt || unit == unit_def))
{
const char *found= unit_find_str(orig_str, unit->name_short);
- if(found) {
+ if (found) {
int offset= (int)(found - orig_str);
int len_name= 0;
@@ -705,7 +705,7 @@ void bUnit_ToUnitAltName(char *str, int len_max, const char *orig_str, int syste
len_max-= offset;
/* print the alt_name */
- if(unit->name_alt)
+ if (unit->name_alt)
len_name= BLI_snprintf(str, len_max, "%s", unit->name_alt);
else
len_name= 0;
@@ -726,11 +726,11 @@ double bUnit_ClosestScalar(double value, int system, int type)
bUnitCollection *usys = unit_get_system(system, type);
bUnitDef *unit;
- if(usys==NULL)
+ if (usys==NULL)
return -1;
unit= unit_best_fit(value, usys, NULL, 1);
- if(unit==NULL)
+ if (unit==NULL)
return -1;
return unit->scalar;
@@ -754,7 +754,7 @@ void bUnit_GetSystem(void **usys_pt, int *len, int system, int type)
bUnitCollection *usys = unit_get_system(system, type);
*usys_pt= usys;
- if(usys==NULL) {
+ if (usys==NULL) {
*len= 0;
return;
}