forked from bartvdbraak/blender
style cleanup: changes to brace placement / newlines - for/while/if/switch
This commit is contained in:
parent
09dc600839
commit
b340f930ec
@ -63,7 +63,7 @@ public:
|
||||
for (int i = 0; i < m_num_buckets; ++i) {
|
||||
m_buckets[i] = 0;
|
||||
|
||||
for(Entry *entry = map.m_buckets[i]; entry; entry=entry->m_next)
|
||||
for (Entry *entry = map.m_buckets[i]; entry; entry=entry->m_next)
|
||||
insert(entry->m_key, entry->m_value);
|
||||
}
|
||||
}
|
||||
|
@ -241,8 +241,10 @@ inline void GHOST_Rect::wrapPoint(GHOST_TInt32 &x, GHOST_TInt32 &y, GHOST_TInt32
|
||||
GHOST_TInt32 h= getHeight();
|
||||
|
||||
/* highly unlikely but avoid eternal loop */
|
||||
if(w-ofs*2 <= 0 || h-ofs*2 <= 0)
|
||||
if (w-ofs*2 <= 0 || h-ofs*2 <= 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
while(x-ofs < m_l) x+= w-(ofs*2);
|
||||
while(y-ofs < m_t) y+= h-(ofs*2);
|
||||
while(x+ofs > m_r) x-= w-(ofs*2);
|
||||
|
@ -243,7 +243,7 @@ void *MEM_dupallocN(void *vmemh)
|
||||
MemHead *memh= vmemh;
|
||||
memh--;
|
||||
|
||||
if(memh->mmap)
|
||||
if (memh->mmap)
|
||||
newp= MEM_mapallocN(memh->len, "dupli_mapalloc");
|
||||
else
|
||||
newp= MEM_mallocN(memh->len, "dupli_alloc");
|
||||
@ -265,8 +265,8 @@ void *MEM_reallocN(void *vmemh, size_t len)
|
||||
memh--;
|
||||
|
||||
newp= MEM_mallocN(len, memh->name);
|
||||
if(newp) {
|
||||
if(len < memh->len)
|
||||
if (newp) {
|
||||
if (len < memh->len)
|
||||
memcpy(newp, vmemh, len);
|
||||
else
|
||||
memcpy(newp, vmemh, memh->len);
|
||||
@ -311,14 +311,14 @@ void *MEM_mallocN(size_t len, const char *str)
|
||||
|
||||
memh= (MemHead *)malloc(len+sizeof(MemHead)+sizeof(MemTail));
|
||||
|
||||
if(memh) {
|
||||
if (memh) {
|
||||
make_memhead_header(memh, len, str);
|
||||
mem_unlock_thread();
|
||||
if(malloc_debug_memset && len)
|
||||
if (malloc_debug_memset && len)
|
||||
memset(memh+1, 255, len);
|
||||
|
||||
#ifdef DEBUG_MEMCOUNTER
|
||||
if(_mallocn_count==DEBUG_MEMCOUNTER_ERROR_VAL)
|
||||
if (_mallocn_count==DEBUG_MEMCOUNTER_ERROR_VAL)
|
||||
memcount_raise(__func__);
|
||||
memh->_count= _mallocn_count++;
|
||||
#endif
|
||||
@ -339,11 +339,11 @@ void *MEM_callocN(size_t len, const char *str)
|
||||
|
||||
memh= (MemHead *)calloc(len+sizeof(MemHead)+sizeof(MemTail),1);
|
||||
|
||||
if(memh) {
|
||||
if (memh) {
|
||||
make_memhead_header(memh, len, str);
|
||||
mem_unlock_thread();
|
||||
#ifdef DEBUG_MEMCOUNTER
|
||||
if(_mallocn_count==DEBUG_MEMCOUNTER_ERROR_VAL)
|
||||
if (_mallocn_count==DEBUG_MEMCOUNTER_ERROR_VAL)
|
||||
memcount_raise(__func__);
|
||||
memh->_count= _mallocn_count++;
|
||||
#endif
|
||||
@ -366,14 +366,14 @@ void *MEM_mapallocN(size_t len, const char *str)
|
||||
memh= mmap(NULL, len+sizeof(MemHead)+sizeof(MemTail),
|
||||
PROT_READ|PROT_WRITE, MAP_SHARED|MAP_ANON, -1, 0);
|
||||
|
||||
if(memh!=(MemHead *)-1) {
|
||||
if (memh!=(MemHead *)-1) {
|
||||
make_memhead_header(memh, len, str);
|
||||
memh->mmap= 1;
|
||||
mmap_in_use += len;
|
||||
peak_mem = mmap_in_use > peak_mem ? mmap_in_use : peak_mem;
|
||||
mem_unlock_thread();
|
||||
#ifdef DEBUG_MEMCOUNTER
|
||||
if(_mallocn_count==DEBUG_MEMCOUNTER_ERROR_VAL)
|
||||
if (_mallocn_count==DEBUG_MEMCOUNTER_ERROR_VAL)
|
||||
memcount_raise(__func__);
|
||||
memh->_count= _mallocn_count++;
|
||||
#endif
|
||||
@ -406,9 +406,9 @@ static int compare_len(const void *p1, const void *p2)
|
||||
const MemPrintBlock *pb1= (const MemPrintBlock*)p1;
|
||||
const MemPrintBlock *pb2= (const MemPrintBlock*)p2;
|
||||
|
||||
if(pb1->len < pb2->len)
|
||||
if (pb1->len < pb2->len)
|
||||
return 1;
|
||||
else if(pb1->len == pb2->len)
|
||||
else if (pb1->len == pb2->len)
|
||||
return 0;
|
||||
else
|
||||
return -1;
|
||||
@ -431,7 +431,7 @@ void MEM_printmemlist_stats(void)
|
||||
membl = membase->first;
|
||||
if (membl) membl = MEMNEXT(membl);
|
||||
|
||||
while(membl) {
|
||||
while (membl) {
|
||||
pb->name= membl->name;
|
||||
pb->len= membl->len;
|
||||
pb->items= 1;
|
||||
@ -439,18 +439,18 @@ void MEM_printmemlist_stats(void)
|
||||
totpb++;
|
||||
pb++;
|
||||
|
||||
if(membl->next)
|
||||
if (membl->next)
|
||||
membl= MEMNEXT(membl->next);
|
||||
else break;
|
||||
}
|
||||
|
||||
/* sort by name and add together blocks with the same name */
|
||||
qsort(printblock, totpb, sizeof(MemPrintBlock), compare_name);
|
||||
for(a=0, b=0; a<totpb; a++) {
|
||||
if(a == b) {
|
||||
for (a = 0, b=0; a<totpb; a++) {
|
||||
if (a == b) {
|
||||
continue;
|
||||
}
|
||||
else if(strcmp(printblock[a].name, printblock[b].name) == 0) {
|
||||
else if (strcmp(printblock[a].name, printblock[b].name) == 0) {
|
||||
printblock[b].len += printblock[a].len;
|
||||
printblock[b].items++;
|
||||
}
|
||||
@ -465,7 +465,7 @@ void MEM_printmemlist_stats(void)
|
||||
qsort(printblock, totpb, sizeof(MemPrintBlock), compare_len);
|
||||
printf("\ntotal memory len: %.3f MB\n", (double)mem_in_use/(double)(1024*1024));
|
||||
printf(" ITEMS TOTAL-MiB AVERAGE-KiB TYPE\n");
|
||||
for(a=0, pb=printblock; a<totpb; a++, pb++)
|
||||
for (a = 0, pb=printblock; a<totpb; a++, pb++)
|
||||
printf("%6d (%8.3f %8.3f) %s\n", pb->items, (double)pb->len/(double)(1024*1024), (double)pb->len/1024.0/(double)pb->items, pb->name);
|
||||
|
||||
free(printblock);
|
||||
@ -491,7 +491,7 @@ static void MEM_printmemlist_internal( int pydict )
|
||||
print_error("# membase_debug.py\n");
|
||||
print_error("membase = [\\\n");
|
||||
}
|
||||
while(membl) {
|
||||
while (membl) {
|
||||
if (pydict) {
|
||||
fprintf(stderr, "{'len':" SIZET_FORMAT ", 'name':'''%s''', 'pointer':'%p'},\\\n", SIZET_ARG(membl->len), membl->name, (void *)(membl+1));
|
||||
} else {
|
||||
@ -501,7 +501,7 @@ static void MEM_printmemlist_internal( int pydict )
|
||||
print_error("%s len: " SIZET_FORMAT " %p\n", membl->name, SIZET_ARG(membl->len), membl+1);
|
||||
#endif
|
||||
}
|
||||
if(membl->next)
|
||||
if (membl->next)
|
||||
membl= MEMNEXT(membl->next);
|
||||
else break;
|
||||
}
|
||||
@ -536,9 +536,9 @@ void MEM_callbackmemlist(void (*func)(void*)) {
|
||||
membl = membase->first;
|
||||
if (membl) membl = MEMNEXT(membl);
|
||||
|
||||
while(membl) {
|
||||
while (membl) {
|
||||
func(membl+1);
|
||||
if(membl->next)
|
||||
if (membl->next)
|
||||
membl= MEMNEXT(membl->next);
|
||||
else break;
|
||||
}
|
||||
@ -554,13 +554,13 @@ short MEM_testN(void *vmemh) {
|
||||
membl = membase->first;
|
||||
if (membl) membl = MEMNEXT(membl);
|
||||
|
||||
while(membl) {
|
||||
while (membl) {
|
||||
if (vmemh == membl+1) {
|
||||
mem_unlock_thread();
|
||||
return 1;
|
||||
}
|
||||
|
||||
if(membl->next)
|
||||
if (membl->next)
|
||||
membl= MEMNEXT(membl->next);
|
||||
else break;
|
||||
}
|
||||
@ -585,13 +585,13 @@ short MEM_freeN(void *vmemh) /* anders compileertie niet meer */
|
||||
MemHead *memh= vmemh;
|
||||
const char *name;
|
||||
|
||||
if (memh == NULL){
|
||||
if (memh == NULL) {
|
||||
MemorY_ErroR("free","attempt to free NULL pointer");
|
||||
/* print_error(err_stream, "%d\n", (memh+4000)->tag1); */
|
||||
return(-1);
|
||||
}
|
||||
|
||||
if(sizeof(intptr_t)==8) {
|
||||
if (sizeof(intptr_t)==8) {
|
||||
if (((intptr_t) memh) & 0x7) {
|
||||
MemorY_ErroR("free","attempt to free illegal pointer");
|
||||
return(-1);
|
||||
@ -605,7 +605,7 @@ short MEM_freeN(void *vmemh) /* anders compileertie niet meer */
|
||||
}
|
||||
|
||||
memh--;
|
||||
if(memh->tag1 == MEMFREE && memh->tag2 == MEMFREE) {
|
||||
if (memh->tag1 == MEMFREE && memh->tag2 == MEMFREE) {
|
||||
MemorY_ErroR(memh->name,"double free");
|
||||
return(-1);
|
||||
}
|
||||
@ -613,7 +613,7 @@ short MEM_freeN(void *vmemh) /* anders compileertie niet meer */
|
||||
mem_lock_thread();
|
||||
if ((memh->tag1 == MEMTAG1) && (memh->tag2 == MEMTAG2) && ((memh->len & 0x3) == 0)) {
|
||||
memt = (MemTail *)(((char *) memh) + sizeof(MemHead) + memh->len);
|
||||
if (memt->tag3 == MEMTAG3){
|
||||
if (memt->tag3 == MEMTAG3) {
|
||||
|
||||
memh->tag1 = MEMFREE;
|
||||
memh->tag2 = MEMFREE;
|
||||
@ -628,7 +628,7 @@ short MEM_freeN(void *vmemh) /* anders compileertie niet meer */
|
||||
error = 2;
|
||||
MemorY_ErroR(memh->name,"end corrupt");
|
||||
name = check_memlist(memh);
|
||||
if (name != NULL){
|
||||
if (name != NULL) {
|
||||
if (name != memh->name) MemorY_ErroR(name,"is also corrupt");
|
||||
}
|
||||
} else{
|
||||
@ -694,13 +694,13 @@ static void rem_memblock(MemHead *memh)
|
||||
totblock--;
|
||||
mem_in_use -= memh->len;
|
||||
|
||||
if(memh->mmap) {
|
||||
if (memh->mmap) {
|
||||
mmap_in_use -= memh->len;
|
||||
if (munmap(memh, memh->len + sizeof(MemHead) + sizeof(MemTail)))
|
||||
printf("Couldn't unmap memory %s\n", memh->name);
|
||||
}
|
||||
else {
|
||||
if(malloc_debug_memset && memh->len)
|
||||
if (malloc_debug_memset && memh->len)
|
||||
memset(memh+1, 255, memh->len);
|
||||
free(memh);
|
||||
}
|
||||
@ -723,7 +723,7 @@ static const char *check_memlist(MemHead *memh)
|
||||
forw = membase->first;
|
||||
if (forw) forw = MEMNEXT(forw);
|
||||
forwok = NULL;
|
||||
while(forw){
|
||||
while (forw) {
|
||||
if (forw->tag1 != MEMTAG1 || forw->tag2 != MEMTAG2) break;
|
||||
forwok = forw;
|
||||
if (forw->next) forw = MEMNEXT(forw->next);
|
||||
@ -733,7 +733,7 @@ static const char *check_memlist(MemHead *memh)
|
||||
back = (MemHead *) membase->last;
|
||||
if (back) back = MEMNEXT(back);
|
||||
backok = NULL;
|
||||
while(back){
|
||||
while (back) {
|
||||
if (back->tag1 != MEMTAG1 || back->tag2 != MEMTAG2) break;
|
||||
backok = back;
|
||||
if (back->prev) back = MEMNEXT(back->prev);
|
||||
@ -742,13 +742,13 @@ static const char *check_memlist(MemHead *memh)
|
||||
|
||||
if (forw != back) return ("MORE THAN 1 MEMORYBLOCK CORRUPT");
|
||||
|
||||
if (forw == NULL && back == NULL){
|
||||
if (forw == NULL && back == NULL) {
|
||||
/* geen foute headers gevonden dan maar op zoek naar memblock*/
|
||||
|
||||
forw = membase->first;
|
||||
if (forw) forw = MEMNEXT(forw);
|
||||
forwok = NULL;
|
||||
while(forw){
|
||||
while (forw) {
|
||||
if (forw == memh) break;
|
||||
if (forw->tag1 != MEMTAG1 || forw->tag2 != MEMTAG2) break;
|
||||
forwok = forw;
|
||||
@ -760,7 +760,7 @@ static const char *check_memlist(MemHead *memh)
|
||||
back = (MemHead *) membase->last;
|
||||
if (back) back = MEMNEXT(back);
|
||||
backok = NULL;
|
||||
while(back){
|
||||
while (back) {
|
||||
if (back == memh) break;
|
||||
if (back->tag1 != MEMTAG1 || back->tag2 != MEMTAG2) break;
|
||||
backok = back;
|
||||
@ -772,10 +772,10 @@ static const char *check_memlist(MemHead *memh)
|
||||
if (forwok) name = forwok->nextname;
|
||||
else name = "No name found";
|
||||
|
||||
if (forw == memh){
|
||||
if (forw == memh) {
|
||||
/* voor alle zekerheid wordt dit block maar uit de lijst gehaald */
|
||||
if (forwok){
|
||||
if (backok){
|
||||
if (forwok) {
|
||||
if (backok) {
|
||||
forwok->next = (MemHead *)&backok->next;
|
||||
backok->prev = (MemHead *)&forwok->next;
|
||||
forwok->nextname = backok->name;
|
||||
@ -785,7 +785,7 @@ static const char *check_memlist(MemHead *memh)
|
||||
/* membase->last = (struct Link *) &forwok->next; */
|
||||
}
|
||||
} else{
|
||||
if (backok){
|
||||
if (backok) {
|
||||
backok->prev = NULL;
|
||||
membase->first = &backok->next;
|
||||
} else{
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -39,7 +39,7 @@ FILE * ufopen(const char * filename, const char * mode)
|
||||
UTF16_ENCODE(filename);
|
||||
UTF16_ENCODE (mode);
|
||||
|
||||
if(filename_16 && mode_16) {
|
||||
if (filename_16 && mode_16) {
|
||||
f = _wfopen(filename_16, mode_16);
|
||||
}
|
||||
|
||||
@ -81,7 +81,7 @@ int urename(const char *oldname, const char *newname )
|
||||
UTF16_ENCODE(oldname);
|
||||
UTF16_ENCODE (newname);
|
||||
|
||||
if(oldname_16 && newname_16) r = _wrename(oldname_16, newname_16);
|
||||
if (oldname_16 && newname_16) r = _wrename(oldname_16, newname_16);
|
||||
|
||||
UTF16_UN_ENCODE(newname);
|
||||
UTF16_UN_ENCODE(oldname);
|
||||
@ -94,7 +94,7 @@ int umkdir(const char *pathname)
|
||||
BOOL r = 0;
|
||||
UTF16_ENCODE(pathname);
|
||||
|
||||
if(pathname_16) r = CreateDirectoryW(pathname_16, NULL);
|
||||
if (pathname_16) r = CreateDirectoryW(pathname_16, NULL);
|
||||
|
||||
UTF16_UN_ENCODE(pathname);
|
||||
|
||||
@ -123,10 +123,10 @@ int uput_getenv(const char *varname, char * value, size_t buffsize)
|
||||
{
|
||||
int r = 0;
|
||||
wchar_t * str;
|
||||
if(!buffsize) return r;
|
||||
if (!buffsize) return r;
|
||||
|
||||
UTF16_ENCODE(varname);
|
||||
if(varname_16) {
|
||||
if (varname_16) {
|
||||
str = _wgetenv(varname_16);
|
||||
conv_utf_16_to_8(str, value, buffsize);
|
||||
r = 1;
|
||||
@ -143,7 +143,7 @@ int uputenv(const char *name, const char *value)
|
||||
int r = -1;
|
||||
UTF16_ENCODE(name);
|
||||
UTF16_ENCODE(value);
|
||||
if(name_16 && value_16) {
|
||||
if (name_16 && value_16) {
|
||||
r = (SetEnvironmentVariableW(name_16,value_16)!= 0) ? 0 : -1;
|
||||
}
|
||||
UTF16_UN_ENCODE(value);
|
||||
|
@ -106,20 +106,20 @@ void blurbuf(struct ImBuf *ibuf, int nr, Cast *cast)
|
||||
x4= ibuf->x/4;
|
||||
|
||||
/* This doesn't seem to work... paprmh */
|
||||
if(cast->gamma != 1.0) gamwarp(tbuf, cast->gamma);
|
||||
if (cast->gamma != 1.0) gamwarp(tbuf, cast->gamma);
|
||||
|
||||
/* reduce */
|
||||
for(i=0; i<nr; i++) {
|
||||
for (i=0; i<nr; i++) {
|
||||
ttbuf = onehalf(tbuf);
|
||||
if (ttbuf) {
|
||||
freeImBuf(tbuf);
|
||||
tbuf = ttbuf;
|
||||
}
|
||||
if(tbuf->x<4 || tbuf->y<4) break;
|
||||
if (tbuf->x<4 || tbuf->y<4) break;
|
||||
}
|
||||
|
||||
/* enlarge */
|
||||
for(i=0; i<nr; i++) {
|
||||
for (i=0; i<nr; i++) {
|
||||
ttbuf = double_x(tbuf);
|
||||
if (ttbuf) {
|
||||
freeImBuf(tbuf);
|
||||
@ -130,18 +130,18 @@ void blurbuf(struct ImBuf *ibuf, int nr, Cast *cast)
|
||||
freeImBuf(tbuf);
|
||||
tbuf = ttbuf;
|
||||
}
|
||||
if(tbuf->x > x4) {
|
||||
if (tbuf->x > x4) {
|
||||
scaleImBuf(tbuf, ibuf->x, ibuf->y);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* this doesn't seem to work...paprmh*/
|
||||
if(cast->gamma != 1.0) gamwarp(tbuf, 1.0 / cast->gamma);
|
||||
if (cast->gamma != 1.0) gamwarp(tbuf, 1.0 / cast->gamma);
|
||||
|
||||
if(ibuf->rect)memcpy(ibuf->rect, tbuf->rect, 4*ibuf->x*ibuf->y);
|
||||
if (ibuf->rect)memcpy(ibuf->rect, tbuf->rect, 4*ibuf->x*ibuf->y);
|
||||
|
||||
if(ibuf->rect_float)
|
||||
if (ibuf->rect_float)
|
||||
memcpy(ibuf->rect_float, tbuf->rect_float, 4*ibuf->x*ibuf->y*sizeof(float));
|
||||
|
||||
freeImBuf(tbuf);
|
||||
@ -161,13 +161,13 @@ void doblur(struct ImBuf *mbuf, float fac, Cast *cast)
|
||||
|
||||
/* which buffers ? */
|
||||
|
||||
if(fac>7.0) fac= 7.0;
|
||||
if(fac<=1.0) return;
|
||||
if (fac>7.0) fac= 7.0;
|
||||
if (fac<=1.0) return;
|
||||
|
||||
pfac= 2.0;
|
||||
pbuf= dupImBuf(mbuf);
|
||||
n= 1;
|
||||
while(pfac < fac) {
|
||||
while (pfac < fac) {
|
||||
blurbuf(pbuf, n, cast);
|
||||
blurbuf(pbuf, n, cast);
|
||||
|
||||
@ -185,10 +185,10 @@ void doblur(struct ImBuf *mbuf, float fac, Cast *cast)
|
||||
fac= (fac-pfac)/(ifac-pfac);
|
||||
n= mbuf->x*mbuf->y;
|
||||
|
||||
if(cast->show) fac=cast->show-1;
|
||||
if (cast->show) fac=cast->show-1;
|
||||
|
||||
if(mbuf->rect_float){
|
||||
if(fac>=1) {
|
||||
if (mbuf->rect_float){
|
||||
if (fac>=1) {
|
||||
memcpy(mbuf->rect_float, ibuf->rect_float, 4*n*sizeof(float));
|
||||
}
|
||||
else if(fac<=0) {
|
||||
@ -200,7 +200,7 @@ void doblur(struct ImBuf *mbuf, float fac, Cast *cast)
|
||||
irectf= (float *)ibuf->rect_float;
|
||||
prectf= (float *)pbuf->rect_float;
|
||||
mrectf= (float *)mbuf->rect_float;
|
||||
while(n--) {
|
||||
while (n--) {
|
||||
mrectf[0]= irectf[0]*fac+ prectf[0]*infac;
|
||||
mrectf[1]= irectf[1]*fac+ prectf[1]*infac;
|
||||
mrectf[2]= irectf[2]*fac+ prectf[2]*infac;
|
||||
@ -213,10 +213,10 @@ void doblur(struct ImBuf *mbuf, float fac, Cast *cast)
|
||||
}
|
||||
else if(mbuf->rect){
|
||||
b1= (int)fac*255.0;
|
||||
if(b1>255) b1= 255;
|
||||
if (b1>255) b1= 255;
|
||||
b2= 255-b1;
|
||||
|
||||
if(b1==255) {
|
||||
if (b1==255) {
|
||||
memcpy(mbuf->rect, ibuf->rect, 4*n);
|
||||
}
|
||||
else if(b1==0) {
|
||||
@ -226,7 +226,7 @@ void doblur(struct ImBuf *mbuf, float fac, Cast *cast)
|
||||
irect= (char *)ibuf->rect;
|
||||
prect= (char *)pbuf->rect;
|
||||
mrect= (char *)mbuf->rect;
|
||||
while(n--) {
|
||||
while (n--) {
|
||||
mrect[0]= (irect[0]*b1+ prect[0]*b2)>>8;
|
||||
mrect[1]= (irect[1]*b1+ prect[1]*b2)>>8;
|
||||
mrect[2]= (irect[2]*b1+ prect[2]*b2)>>8;
|
||||
@ -247,7 +247,7 @@ void plugin_seq_doit(Cast *cast, float facf0, float facf1, int x, int y, ImBuf *
|
||||
{
|
||||
float bfacf0, bfacf1;
|
||||
|
||||
if(cast->use_ipo==0) {
|
||||
if (cast->use_ipo==0) {
|
||||
bfacf0= bfacf1= cast->blur+1.0;
|
||||
}
|
||||
else {
|
||||
@ -255,8 +255,8 @@ void plugin_seq_doit(Cast *cast, float facf0, float facf1, int x, int y, ImBuf *
|
||||
bfacf1 = (facf1 * 6.0) + 1.0;
|
||||
}
|
||||
|
||||
if(out->rect) memcpy(out->rect, ibuf1->rect, 4*out->x*out->y);
|
||||
if(out->rect_float) memcpy(out->rect_float, ibuf1->rect_float, 4*out->x*out->y*sizeof(float));
|
||||
if (out->rect) memcpy(out->rect, ibuf1->rect, 4*out->x*out->y);
|
||||
if (out->rect_float) memcpy(out->rect_float, ibuf1->rect_float, 4*out->x*out->y*sizeof(float));
|
||||
|
||||
/****************I can't get this field code to work... works ok without...paprmh****************/
|
||||
|
||||
@ -269,13 +269,13 @@ void plugin_seq_doit(Cast *cast, float facf0, float facf1, int x, int y, ImBuf *
|
||||
|
||||
doblur(out, bfacf0, cast); /*fieldA*/
|
||||
|
||||
/* if(out->rect)out->rect += out->x * out->y;
|
||||
if(out->rect_float)out->rect_float += out->x * out->y;
|
||||
/* if (out->rect)out->rect += out->x * out->y;
|
||||
if (out->rect_float)out->rect_float += out->x * out->y;
|
||||
|
||||
doblur(out, bfacf1, cast);*/ /*fieldB*/
|
||||
|
||||
/* if(out->rect)out->rect -= out->x * out->y;
|
||||
if(out->rect_float)out->rect_float -= out->x * out->y;
|
||||
/* if (out->rect)out->rect -= out->x * out->y;
|
||||
if (out->rect_float)out->rect_float -= out->x * out->y;
|
||||
out->flags |= IB_fields;
|
||||
|
||||
interlace(out);*/
|
||||
|
@ -150,7 +150,7 @@ int plugin_tex_doit(int stype, Cast *cast, float *texvec, float *dxt, float *dyt
|
||||
/* always return this value */
|
||||
result[0] = CLAMP (val+cast->offset, 0.0, 1.0) * pow (fabs(sqrt(tv[0]*tv[0]+tv[1]*tv[1]+tv[2]*tv[2])), cast->falloff);
|
||||
|
||||
if(stype==1) {
|
||||
if (stype==1) {
|
||||
/*
|
||||
* this is r, g, b, a:
|
||||
*/
|
||||
@ -161,7 +161,7 @@ int plugin_tex_doit(int stype, Cast *cast, float *texvec, float *dxt, float *dyt
|
||||
|
||||
res |= TEX_RGB;
|
||||
}
|
||||
if(stype==2) {
|
||||
if (stype==2) {
|
||||
/*
|
||||
* This value is the displacement of the actual normal in
|
||||
* the Material calculation.
|
||||
|
@ -124,7 +124,7 @@ float sample_wave(float freq, float coord, float pixsize)
|
||||
float fac, frac, retval;
|
||||
int part1, part2;
|
||||
|
||||
if(pixsize > freq) return 0.5;
|
||||
if (pixsize > freq) return 0.5;
|
||||
|
||||
pixsize/= freq;
|
||||
|
||||
@ -132,19 +132,19 @@ float sample_wave(float freq, float coord, float pixsize)
|
||||
part1= ffloor(fac);
|
||||
frac= fac - part1;
|
||||
|
||||
if(part1 & 1) retval= 0.0;
|
||||
else retval= 1.0;
|
||||
if (part1 & 1) retval= 0.0;
|
||||
else retval = 1.0;
|
||||
|
||||
if(pixsize != 0.0) {
|
||||
if (pixsize != 0.0) {
|
||||
|
||||
/* is coord+pixsize another value? */
|
||||
|
||||
part2= ffloor(fac + pixsize);
|
||||
if(part1==part2) return retval;
|
||||
if (part1==part2) return retval;
|
||||
|
||||
/* antialias */
|
||||
if(retval==1.0) retval= (1.0-frac)/pixsize;
|
||||
else retval= 1.0-(1.0-frac)/pixsize;
|
||||
if (retval == 1.0) retval= (1.0 - frac) / pixsize;
|
||||
else retval= 1.0 - (1.0 - frac) / pixsize;
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
@ -153,23 +153,23 @@ int plugin_tex_doit(int stype, Cast *cast, float *texvec, float *dxt, float *dyt
|
||||
{
|
||||
float xwave, ywave;
|
||||
|
||||
if(stype==1) {
|
||||
if (stype==1) {
|
||||
texvec[0]+= hnoise(cast->noise, texvec[0], texvec[1], texvec[2]);
|
||||
texvec[1]+= hnoise(cast->noise, texvec[1], texvec[2], texvec[0]);
|
||||
}
|
||||
|
||||
if(dxt && dyt) {
|
||||
if (dxt && dyt) {
|
||||
xwave= sample_wave(cast->size, texvec[0], fabs(dxt[0]) + fabs(dyt[0]) );
|
||||
ywave= sample_wave(cast->size, texvec[1], fabs(dxt[1]) + fabs(dyt[1]) );
|
||||
|
||||
if(xwave > ywave) result[0]= xwave-ywave;
|
||||
if (xwave > ywave) result[0]= xwave-ywave;
|
||||
else result[0]= ywave-xwave;
|
||||
}
|
||||
else {
|
||||
xwave= sample_wave(cast->size, texvec[0], 0.0 );
|
||||
ywave= sample_wave(cast->size, texvec[1], 0.0 );
|
||||
|
||||
if(xwave > ywave) result[0]= xwave-ywave;
|
||||
if (xwave > ywave) result[0]= xwave-ywave;
|
||||
else result[0]= ywave-xwave;
|
||||
}
|
||||
|
||||
|
@ -442,7 +442,9 @@ AviError AVI_open_movie (const char *name, AviMovie *movie)
|
||||
|
||||
if (GET_FCC (movie->fp) != FCC("RIFF") ||
|
||||
!(movie->size = GET_FCC (movie->fp)))
|
||||
{
|
||||
return AVI_ERROR_FORMAT;
|
||||
}
|
||||
|
||||
movie->header = (AviMainHeader *) MEM_mallocN (sizeof (AviMainHeader), "movieheader");
|
||||
|
||||
|
@ -46,10 +46,12 @@ void *avi_format_convert (AviMovie *movie, int stream, void *buffer, AviFormat f
|
||||
return buffer;
|
||||
|
||||
if (from != AVI_FORMAT_RGB24 &&
|
||||
to != AVI_FORMAT_RGB24)
|
||||
to != AVI_FORMAT_RGB24)
|
||||
{
|
||||
return avi_format_convert(movie, stream,
|
||||
avi_format_convert (movie, stream, buffer, from, AVI_FORMAT_RGB24, size),
|
||||
AVI_FORMAT_RGB24, to, size);
|
||||
avi_format_convert(movie, stream, buffer, from, AVI_FORMAT_RGB24, size),
|
||||
AVI_FORMAT_RGB24, to, size);
|
||||
}
|
||||
|
||||
switch (to) {
|
||||
case AVI_FORMAT_RGB24:
|
||||
|
@ -1272,7 +1272,9 @@ CCGError ccgSubSurf_syncFace(CCGSubSurf *ss, CCGFaceHDL fHDL, int numVerts, CCGV
|
||||
if (f->numVerts != numVerts ||
|
||||
memcmp(FACE_getVerts(f), ss->tempVerts, sizeof(*ss->tempVerts) * numVerts) ||
|
||||
memcmp(FACE_getEdges(f), ss->tempEdges, sizeof(*ss->tempEdges) * numVerts))
|
||||
{
|
||||
topologyChanged = 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (!f || topologyChanged) {
|
||||
|
@ -2279,8 +2279,10 @@ DerivedMesh *editbmesh_get_derived_cage_and_final(Scene *scene, Object *obedit,
|
||||
* the data we need, rebuild the derived mesh
|
||||
*/
|
||||
if (!em->derivedCage ||
|
||||
(em->lastDataMask & dataMask) != dataMask)
|
||||
(em->lastDataMask & dataMask) != dataMask)
|
||||
{
|
||||
editbmesh_build_data(scene, obedit, em, dataMask);
|
||||
}
|
||||
|
||||
*final_r = em->derivedFinal;
|
||||
return em->derivedCage;
|
||||
@ -2292,8 +2294,10 @@ DerivedMesh *editbmesh_get_derived_cage(Scene *scene, Object *obedit, BMEditMesh
|
||||
* the data we need, rebuild the derived mesh
|
||||
*/
|
||||
if (!em->derivedCage ||
|
||||
(em->lastDataMask & dataMask) != dataMask)
|
||||
(em->lastDataMask & dataMask) != dataMask)
|
||||
{
|
||||
editbmesh_build_data(scene, obedit, em, dataMask);
|
||||
}
|
||||
|
||||
return em->derivedCage;
|
||||
}
|
||||
@ -2701,8 +2705,7 @@ void DM_calc_auto_bump_scale(DerivedMesh *dm)
|
||||
if (nr_tris_to_pile==1 || nr_tris_to_pile==2) {
|
||||
const int indices[] = {offs+0, offs+1, offs+2, offs+0, offs+2, (offs+3)&0x3 };
|
||||
int t;
|
||||
for ( t=0; t<nr_tris_to_pile; t++ )
|
||||
{
|
||||
for ( t=0; t<nr_tris_to_pile; t++ ) {
|
||||
float f2x_area_uv;
|
||||
float * p0 = verts[indices[t*3+0]];
|
||||
float * p1 = verts[indices[t*3+1]];
|
||||
|
@ -1350,9 +1350,11 @@ static void new_particle_duplilist(ListBase *lb, ID *id, Scene *scene, Object *p
|
||||
|
||||
/* some hair paths might be non-existent so they can't be used for duplication */
|
||||
if (hair &&
|
||||
((a < totpart && psys->pathcache[a]->steps < 0) ||
|
||||
(a >= totpart && psys->childcache[a-totpart]->steps < 0)))
|
||||
((a < totpart && psys->pathcache[a]->steps < 0) ||
|
||||
(a >= totpart && psys->childcache[a-totpart]->steps < 0)))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (part->ren_as==PART_DRAW_GR) {
|
||||
/* prevent divide by zero below [#28336] */
|
||||
|
@ -1250,8 +1250,7 @@ static void animsys_evaluate_fcurves (PointerRNA *ptr, ListBase *list, AnimMappe
|
||||
FCurve *fcu;
|
||||
|
||||
/* calculate then execute each curve */
|
||||
for (fcu= list->first; fcu; fcu= fcu->next)
|
||||
{
|
||||
for (fcu= list->first; fcu; fcu= fcu->next) {
|
||||
/* check if this F-Curve doesn't belong to a muted group */
|
||||
if ((fcu->grp == NULL) || (fcu->grp->flag & AGRP_MUTED)==0) {
|
||||
/* check if this curve should be skipped */
|
||||
@ -1274,8 +1273,7 @@ static void animsys_evaluate_drivers (PointerRNA *ptr, AnimData *adt, float ctim
|
||||
/* drivers are stored as F-Curves, but we cannot use the standard code, as we need to check if
|
||||
* the depsgraph requested that this driver be evaluated...
|
||||
*/
|
||||
for (fcu= adt->drivers.first; fcu; fcu= fcu->next)
|
||||
{
|
||||
for (fcu= adt->drivers.first; fcu; fcu= fcu->next) {
|
||||
ChannelDriver *driver= fcu->driver;
|
||||
short ok= 0;
|
||||
|
||||
@ -1351,8 +1349,7 @@ void animsys_evaluate_action_group (PointerRNA *ptr, bAction *act, bActionGroup
|
||||
return;
|
||||
|
||||
/* calculate then execute each curve */
|
||||
for (fcu= agrp->channels.first; (fcu) && (fcu->grp == agrp); fcu= fcu->next)
|
||||
{
|
||||
for (fcu= agrp->channels.first; (fcu) && (fcu->grp == agrp); fcu= fcu->next) {
|
||||
/* check if this curve should be skipped */
|
||||
if ((fcu->flag & (FCURVE_MUTED|FCURVE_DISABLED)) == 0) {
|
||||
calculate_fcurve(fcu, ctime);
|
||||
@ -1968,8 +1965,7 @@ void nladata_flush_channels (ListBase *channels)
|
||||
float value= nec->value;
|
||||
|
||||
/* write values - see animsys_write_rna_setting() to sync the code */
|
||||
switch (RNA_property_type(prop))
|
||||
{
|
||||
switch (RNA_property_type(prop)) {
|
||||
case PROP_BOOLEAN:
|
||||
if (RNA_property_array_length(ptr, prop))
|
||||
RNA_property_boolean_set_index(ptr, prop, array_index, ANIMSYS_FLOAT_AS_BOOL(value));
|
||||
@ -2217,7 +2213,9 @@ void BKE_animsys_evaluate_animdata (Scene *scene, ID *id, AnimData *adt, float c
|
||||
* or be layered on top of existing animation data.
|
||||
* - Drivers should be in the appropriate order to be evaluated without problems...
|
||||
*/
|
||||
if ((recalc & ADT_RECALC_DRIVERS) /*&& (adt->recalc & ADT_RECALC_DRIVERS)*/) // XXX for now, don't check yet, as depsgraph hasn't been updated
|
||||
if ((recalc & ADT_RECALC_DRIVERS)
|
||||
/* XXX for now, don't check yet, as depsgraph hasn't been updated */
|
||||
/* && (adt->recalc & ADT_RECALC_DRIVERS)*/)
|
||||
{
|
||||
animsys_evaluate_drivers(&id_ptr, adt, ctime);
|
||||
}
|
||||
|
@ -1372,7 +1372,7 @@ void armature_mat_pose_to_bone_ex(Object *ob, bPoseChannel *pchan, float inmat[]
|
||||
/* same as object_mat3_to_rot() */
|
||||
void pchan_mat3_to_rot(bPoseChannel *pchan, float mat[][3], short use_compat)
|
||||
{
|
||||
switch(pchan->rotmode) {
|
||||
switch (pchan->rotmode) {
|
||||
case ROT_MODE_QUAT:
|
||||
mat3_to_quat(pchan->quat, mat);
|
||||
break;
|
||||
|
@ -962,7 +962,7 @@ void boid_brain(BoidBrainData *bbd, int p, ParticleData *pa)
|
||||
set_boid_values(&val, bbd->part->boids, pa);
|
||||
|
||||
/* go through rules */
|
||||
switch(state->ruleset_type) {
|
||||
switch (state->ruleset_type) {
|
||||
case eBoidRulesetType_Fuzzy:
|
||||
{
|
||||
for (rule = state->rules.first; rule; rule = rule->next) {
|
||||
@ -1258,7 +1258,7 @@ void boid_body(BoidBrainData *bbd, ParticleData *pa)
|
||||
bpa->ground = boid_find_ground(bbd, pa, ground_co, ground_nor);
|
||||
|
||||
/* change modes, constrain movement & keep track of down vector */
|
||||
switch(bpa->data.mode) {
|
||||
switch (bpa->data.mode) {
|
||||
case eBoidMode_InAir:
|
||||
{
|
||||
float grav[3];
|
||||
@ -1437,7 +1437,7 @@ BoidRule *boid_new_rule(int type)
|
||||
if (type <= 0)
|
||||
return NULL;
|
||||
|
||||
switch(type) {
|
||||
switch (type) {
|
||||
case eBoidRuleType_Goal:
|
||||
case eBoidRuleType_Avoid:
|
||||
rule = MEM_callocN(sizeof(BoidRuleGoalAvoid), "BoidRuleGoalAvoid");
|
||||
|
@ -337,7 +337,7 @@ void brush_reset_sculpt(Brush *br)
|
||||
brush_set_defaults(br);
|
||||
brush_curve_preset(br, CURVE_PRESET_SMOOTH);
|
||||
|
||||
switch(br->sculpt_tool) {
|
||||
switch (br->sculpt_tool) {
|
||||
case SCULPT_TOOL_CLAY:
|
||||
br->flag |= BRUSH_FRONTFACE;
|
||||
break;
|
||||
|
@ -649,8 +649,7 @@ BVHTree* bvhtree_from_mesh_edges(BVHTreeFromMesh *data, DerivedMesh *mesh, float
|
||||
BVHTree *tree = bvhcache_find(&mesh->bvhCache, BVHTREE_FROM_EDGES);
|
||||
|
||||
//Not in cache
|
||||
if (tree == NULL)
|
||||
{
|
||||
if (tree == NULL) {
|
||||
int i;
|
||||
int numEdges= mesh->getNumEdges(mesh);
|
||||
MVert *vert = mesh->getVertDataArray(mesh, CD_MVERT);
|
||||
@ -675,8 +674,7 @@ BVHTree* bvhtree_from_mesh_edges(BVHTreeFromMesh *data, DerivedMesh *mesh, float
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
else {
|
||||
// printf("BVHTree is already build, using cached tree\n");
|
||||
}
|
||||
|
||||
|
@ -191,8 +191,7 @@ static BVHTree *bvhselftree_build_from_cloth (ClothModifierData *clmd, float eps
|
||||
bvhtree = BLI_bvhtree_new(cloth->numverts, epsilon, 4, 6);
|
||||
|
||||
// fill tree
|
||||
for (i = 0; i < cloth->numverts; i++, verts++)
|
||||
{
|
||||
for (i = 0; i < cloth->numverts; i++, verts++) {
|
||||
copy_v3_v3(&co[0*3], verts->xold);
|
||||
|
||||
BLI_bvhtree_insert(bvhtree, i, co, 1);
|
||||
@ -232,8 +231,7 @@ static BVHTree *bvhtree_build_from_cloth (ClothModifierData *clmd, float epsilon
|
||||
bvhtree = BLI_bvhtree_new(cloth->numfaces, epsilon, 4, 26);
|
||||
|
||||
// fill tree
|
||||
for (i = 0; i < cloth->numfaces; i++, mfaces++)
|
||||
{
|
||||
for (i = 0; i < cloth->numfaces; i++, mfaces++) {
|
||||
copy_v3_v3(&co[0*3], verts[mfaces->v1].xold);
|
||||
copy_v3_v3(&co[1*3], verts[mfaces->v2].xold);
|
||||
copy_v3_v3(&co[2*3], verts[mfaces->v3].xold);
|
||||
@ -266,10 +264,8 @@ void bvhtree_update_from_cloth(ClothModifierData *clmd, int moving)
|
||||
mfaces = cloth->mfaces;
|
||||
|
||||
// update vertex position in bvh tree
|
||||
if (verts && mfaces)
|
||||
{
|
||||
for (i = 0; i < cloth->numfaces; i++, mfaces++)
|
||||
{
|
||||
if (verts && mfaces) {
|
||||
for (i = 0; i < cloth->numfaces; i++, mfaces++) {
|
||||
copy_v3_v3(&co[0*3], verts[mfaces->v1].txold);
|
||||
copy_v3_v3(&co[1*3], verts[mfaces->v2].txold);
|
||||
copy_v3_v3(&co[2*3], verts[mfaces->v3].txold);
|
||||
@ -278,8 +274,7 @@ void bvhtree_update_from_cloth(ClothModifierData *clmd, int moving)
|
||||
copy_v3_v3(&co[3*3], verts[mfaces->v4].txold);
|
||||
|
||||
// copy new locations into array
|
||||
if (moving)
|
||||
{
|
||||
if (moving) {
|
||||
// update moving positions
|
||||
copy_v3_v3(&co_moving[0*3], verts[mfaces->v1].tx);
|
||||
copy_v3_v3(&co_moving[1*3], verts[mfaces->v2].tx);
|
||||
@ -319,15 +314,12 @@ void bvhselftree_update_from_cloth(ClothModifierData *clmd, int moving)
|
||||
mfaces = cloth->mfaces;
|
||||
|
||||
// update vertex position in bvh tree
|
||||
if (verts && mfaces)
|
||||
{
|
||||
for (i = 0; i < cloth->numverts; i++, verts++)
|
||||
{
|
||||
if (verts && mfaces) {
|
||||
for (i = 0; i < cloth->numverts; i++, verts++) {
|
||||
copy_v3_v3(&co[0*3], verts->txold);
|
||||
|
||||
// copy new locations into array
|
||||
if (moving)
|
||||
{
|
||||
if (moving) {
|
||||
// update moving positions
|
||||
copy_v3_v3(&co_moving[0*3], verts->tx);
|
||||
|
||||
@ -558,11 +550,9 @@ void cloth_free_modifier(ClothModifierData *clmd )
|
||||
cloth = clmd->clothObject;
|
||||
|
||||
|
||||
if ( cloth )
|
||||
{
|
||||
if ( cloth ) {
|
||||
// If our solver provides a free function, call it
|
||||
if ( solvers [clmd->sim_parms->solver_type].free )
|
||||
{
|
||||
if ( solvers [clmd->sim_parms->solver_type].free ) {
|
||||
solvers [clmd->sim_parms->solver_type].free ( clmd );
|
||||
}
|
||||
|
||||
@ -574,11 +564,9 @@ void cloth_free_modifier(ClothModifierData *clmd )
|
||||
cloth->numverts = 0;
|
||||
|
||||
// Free the springs.
|
||||
if ( cloth->springs != NULL )
|
||||
{
|
||||
if ( cloth->springs != NULL ) {
|
||||
LinkNode *search = cloth->springs;
|
||||
while (search)
|
||||
{
|
||||
while (search) {
|
||||
ClothSpring *spring = search->link;
|
||||
|
||||
MEM_freeN ( spring );
|
||||
@ -628,14 +616,12 @@ void cloth_free_modifier_extern ( ClothModifierData *clmd )
|
||||
|
||||
cloth = clmd->clothObject;
|
||||
|
||||
if ( cloth )
|
||||
{
|
||||
if ( cloth ) {
|
||||
if (G.rt > 0)
|
||||
printf("cloth_free_modifier_extern in\n");
|
||||
|
||||
// If our solver provides a free function, call it
|
||||
if ( solvers [clmd->sim_parms->solver_type].free )
|
||||
{
|
||||
if ( solvers [clmd->sim_parms->solver_type].free ) {
|
||||
solvers [clmd->sim_parms->solver_type].free ( clmd );
|
||||
}
|
||||
|
||||
@ -647,11 +633,9 @@ void cloth_free_modifier_extern ( ClothModifierData *clmd )
|
||||
cloth->numverts = 0;
|
||||
|
||||
// Free the springs.
|
||||
if ( cloth->springs != NULL )
|
||||
{
|
||||
if ( cloth->springs != NULL ) {
|
||||
LinkNode *search = cloth->springs;
|
||||
while (search)
|
||||
{
|
||||
while (search) {
|
||||
ClothSpring *spring = search->link;
|
||||
|
||||
MEM_freeN ( spring );
|
||||
@ -708,8 +692,7 @@ static void cloth_to_object (Object *ob, ClothModifierData *clmd, float (*verte
|
||||
/* inverse matrix is not uptodate... */
|
||||
invert_m4_m4(ob->imat, ob->obmat);
|
||||
|
||||
for (i = 0; i < cloth->numverts; i++)
|
||||
{
|
||||
for (i = 0; i < cloth->numverts; i++) {
|
||||
copy_v3_v3 (vertexCos[i], cloth->verts[i].x);
|
||||
mul_m4_v3(ob->imat, vertexCos[i]); /* cloth is in global coords */
|
||||
}
|
||||
@ -749,17 +732,12 @@ static void cloth_apply_vgroup ( ClothModifierData *clmd, DerivedMesh *dm )
|
||||
|
||||
verts = clothObj->verts;
|
||||
|
||||
if (cloth_uses_vgroup(clmd))
|
||||
{
|
||||
for ( i = 0; i < numverts; i++, verts++ )
|
||||
{
|
||||
if (cloth_uses_vgroup(clmd)) {
|
||||
for ( i = 0; i < numverts; i++, verts++ ) {
|
||||
dvert = dm->getVertData ( dm, i, CD_MDEFORMVERT );
|
||||
if ( dvert )
|
||||
{
|
||||
for ( j = 0; j < dvert->totweight; j++ )
|
||||
{
|
||||
if (( dvert->dw[j].def_nr == (clmd->sim_parms->vgroup_mass-1)) && (clmd->sim_parms->flags & CLOTH_SIMSETTINGS_FLAG_GOAL ))
|
||||
{
|
||||
if ( dvert ) {
|
||||
for ( j = 0; j < dvert->totweight; j++ ) {
|
||||
if (( dvert->dw[j].def_nr == (clmd->sim_parms->vgroup_mass-1)) && (clmd->sim_parms->flags & CLOTH_SIMSETTINGS_FLAG_GOAL )) {
|
||||
verts->goal = dvert->dw [j].weight;
|
||||
/* goalfac= 1.0f; */ /* UNUSED */
|
||||
|
||||
@ -769,22 +747,18 @@ static void cloth_apply_vgroup ( ClothModifierData *clmd, DerivedMesh *dm )
|
||||
*/
|
||||
|
||||
verts->goal = ( float ) pow ( verts->goal , 4.0f );
|
||||
if ( verts->goal >=SOFTGOALSNAP )
|
||||
{
|
||||
if ( verts->goal >=SOFTGOALSNAP ) {
|
||||
verts->flags |= CLOTH_VERT_FLAG_PINNED;
|
||||
}
|
||||
}
|
||||
|
||||
if (clmd->sim_parms->flags & CLOTH_SIMSETTINGS_FLAG_SCALING )
|
||||
{
|
||||
if ( dvert->dw[j].def_nr == (clmd->sim_parms->vgroup_struct-1))
|
||||
{
|
||||
if (clmd->sim_parms->flags & CLOTH_SIMSETTINGS_FLAG_SCALING ) {
|
||||
if ( dvert->dw[j].def_nr == (clmd->sim_parms->vgroup_struct-1)) {
|
||||
verts->struct_stiff = dvert->dw [j].weight;
|
||||
verts->shear_stiff = dvert->dw [j].weight;
|
||||
}
|
||||
|
||||
if ( dvert->dw[j].def_nr == (clmd->sim_parms->vgroup_bend-1))
|
||||
{
|
||||
if ( dvert->dw[j].def_nr == (clmd->sim_parms->vgroup_bend-1)) {
|
||||
verts->bend_stiff = dvert->dw [j].weight;
|
||||
}
|
||||
}
|
||||
@ -812,8 +786,7 @@ static int cloth_from_object(Object *ob, ClothModifierData *clmd, DerivedMesh *d
|
||||
float maxdist = 0;
|
||||
|
||||
// If we have a clothObject, free it.
|
||||
if ( clmd->clothObject != NULL )
|
||||
{
|
||||
if ( clmd->clothObject != NULL ) {
|
||||
cloth_free_modifier ( clmd );
|
||||
if (G.rt > 0)
|
||||
printf("cloth_free_modifier cloth_from_object\n");
|
||||
@ -821,8 +794,7 @@ static int cloth_from_object(Object *ob, ClothModifierData *clmd, DerivedMesh *d
|
||||
|
||||
// Allocate a new cloth object.
|
||||
clmd->clothObject = MEM_callocN ( sizeof ( Cloth ), "cloth" );
|
||||
if ( clmd->clothObject )
|
||||
{
|
||||
if ( clmd->clothObject ) {
|
||||
clmd->clothObject->old_solver_type = 255;
|
||||
// clmd->clothObject->old_collision_type = 255;
|
||||
cloth = clmd->clothObject;
|
||||
@ -851,10 +823,8 @@ static int cloth_from_object(Object *ob, ClothModifierData *clmd, DerivedMesh *d
|
||||
verts = clmd->clothObject->verts;
|
||||
|
||||
// set initial values
|
||||
for ( i = 0; i < dm->getNumVerts(dm); i++, verts++ )
|
||||
{
|
||||
if (first)
|
||||
{
|
||||
for ( i = 0; i < dm->getNumVerts(dm); i++, verts++ ) {
|
||||
if (first) {
|
||||
copy_v3_v3( verts->x, mvert[i].co );
|
||||
|
||||
mul_m4_v3( ob->obmat, verts->x );
|
||||
@ -891,18 +861,15 @@ static int cloth_from_object(Object *ob, ClothModifierData *clmd, DerivedMesh *d
|
||||
// has to be happen before springs are build!
|
||||
cloth_apply_vgroup (clmd, dm);
|
||||
|
||||
if ( !cloth_build_springs ( clmd, dm ) )
|
||||
{
|
||||
if ( !cloth_build_springs ( clmd, dm ) ) {
|
||||
cloth_free_modifier ( clmd );
|
||||
modifier_setError(&(clmd->modifier), "%s", TIP_("Can't build springs."));
|
||||
printf("cloth_free_modifier cloth_build_springs\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
for ( i = 0; i < dm->getNumVerts(dm); i++)
|
||||
{
|
||||
if ((!(cloth->verts[i].flags & CLOTH_VERT_FLAG_PINNED)) && (cloth->verts[i].goal > ALMOST_ZERO))
|
||||
{
|
||||
for ( i = 0; i < dm->getNumVerts(dm); i++) {
|
||||
if ((!(cloth->verts[i].flags & CLOTH_VERT_FLAG_PINNED)) && (cloth->verts[i].goal > ALMOST_ZERO)) {
|
||||
cloth_add_spring (clmd, i, i, 0.0, CLOTH_SPRING_TYPE_GOAL);
|
||||
}
|
||||
}
|
||||
@ -917,8 +884,7 @@ static int cloth_from_object(Object *ob, ClothModifierData *clmd, DerivedMesh *d
|
||||
|
||||
clmd->clothObject->bvhtree = bvhtree_build_from_cloth ( clmd, MAX2(clmd->coll_parms->epsilon, clmd->coll_parms->distance_repel) );
|
||||
|
||||
for (i = 0; i < dm->getNumVerts(dm); i++)
|
||||
{
|
||||
for (i = 0; i < dm->getNumVerts(dm); i++) {
|
||||
maxdist = MAX2(maxdist, clmd->coll_parms->selfepsilon* ( cloth->verts[i].avg_spring_len*2.0f));
|
||||
}
|
||||
|
||||
@ -937,8 +903,7 @@ static void cloth_from_mesh ( ClothModifierData *clmd, DerivedMesh *dm )
|
||||
/* Allocate our vertices. */
|
||||
clmd->clothObject->numverts = numverts;
|
||||
clmd->clothObject->verts = MEM_callocN ( sizeof ( ClothVertex ) * clmd->clothObject->numverts, "clothVertex" );
|
||||
if ( clmd->clothObject->verts == NULL )
|
||||
{
|
||||
if ( clmd->clothObject->verts == NULL ) {
|
||||
cloth_free_modifier ( clmd );
|
||||
modifier_setError(&(clmd->modifier), "%s", TIP_("Out of memory on allocating clmd->clothObject->verts."));
|
||||
printf("cloth_free_modifier clmd->clothObject->verts\n");
|
||||
@ -948,8 +913,7 @@ static void cloth_from_mesh ( ClothModifierData *clmd, DerivedMesh *dm )
|
||||
// save face information
|
||||
clmd->clothObject->numfaces = numfaces;
|
||||
clmd->clothObject->mfaces = MEM_callocN ( sizeof ( MFace ) * clmd->clothObject->numfaces, "clothMFaces" );
|
||||
if ( clmd->clothObject->mfaces == NULL )
|
||||
{
|
||||
if ( clmd->clothObject->mfaces == NULL ) {
|
||||
cloth_free_modifier ( clmd );
|
||||
modifier_setError(&(clmd->modifier), "%s", TIP_("Out of memory on allocating clmd->clothObject->mfaces."));
|
||||
printf("cloth_free_modifier clmd->clothObject->mfaces\n");
|
||||
@ -977,8 +941,7 @@ int cloth_add_spring ( ClothModifierData *clmd, unsigned int indexA, unsigned in
|
||||
Cloth *cloth = clmd->clothObject;
|
||||
ClothSpring *spring = NULL;
|
||||
|
||||
if (cloth)
|
||||
{
|
||||
if (cloth) {
|
||||
// TODO: look if this spring is already there
|
||||
|
||||
spring = ( ClothSpring * ) MEM_callocN ( sizeof ( ClothSpring ), "cloth spring" );
|
||||
@ -1006,11 +969,9 @@ static void cloth_free_errorsprings(Cloth *cloth, EdgeHash *UNUSED(edgehash), Li
|
||||
{
|
||||
unsigned int i = 0;
|
||||
|
||||
if ( cloth->springs != NULL )
|
||||
{
|
||||
if ( cloth->springs != NULL ) {
|
||||
LinkNode *search = cloth->springs;
|
||||
while (search)
|
||||
{
|
||||
while (search) {
|
||||
ClothSpring *spring = search->link;
|
||||
|
||||
MEM_freeN ( spring );
|
||||
@ -1021,10 +982,8 @@ static void cloth_free_errorsprings(Cloth *cloth, EdgeHash *UNUSED(edgehash), Li
|
||||
cloth->springs = NULL;
|
||||
}
|
||||
|
||||
if (edgelist)
|
||||
{
|
||||
for ( i = 0; i < cloth->numverts; i++ )
|
||||
{
|
||||
if (edgelist) {
|
||||
for ( i = 0; i < cloth->numverts; i++ ) {
|
||||
BLI_linklist_free ( edgelist[i],NULL );
|
||||
}
|
||||
|
||||
@ -1062,8 +1021,7 @@ static int cloth_build_springs ( ClothModifierData *clmd, DerivedMesh *dm )
|
||||
if (!edgelist)
|
||||
return 0;
|
||||
|
||||
for ( i = 0; i < numverts; i++ )
|
||||
{
|
||||
for ( i = 0; i < numverts; i++ ) {
|
||||
edgelist[i] = NULL;
|
||||
}
|
||||
|
||||
@ -1074,12 +1032,10 @@ static int cloth_build_springs ( ClothModifierData *clmd, DerivedMesh *dm )
|
||||
edgehash = BLI_edgehash_new();
|
||||
|
||||
// structural springs
|
||||
for ( i = 0; i < numedges; i++ )
|
||||
{
|
||||
for ( i = 0; i < numedges; i++ ) {
|
||||
spring = ( ClothSpring * ) MEM_callocN ( sizeof ( ClothSpring ), "cloth spring" );
|
||||
|
||||
if ( spring )
|
||||
{
|
||||
if ( spring ) {
|
||||
spring->ij = MIN2(medge[i].v1, medge[i].v2);
|
||||
spring->kl = MAX2(medge[i].v2, medge[i].v1);
|
||||
spring->restlen = len_v3v3(cloth->verts[spring->kl].xrest, cloth->verts[spring->ij].xrest);
|
||||
@ -1104,22 +1060,19 @@ static int cloth_build_springs ( ClothModifierData *clmd, DerivedMesh *dm )
|
||||
if (struct_springs > 0)
|
||||
clmd->sim_parms->avg_spring_len /= struct_springs;
|
||||
|
||||
for (i = 0; i < numverts; i++)
|
||||
{
|
||||
for (i = 0; i < numverts; i++) {
|
||||
cloth->verts[i].avg_spring_len = cloth->verts[i].avg_spring_len * 0.49f / ((float)cloth->verts[i].spring_count);
|
||||
}
|
||||
|
||||
// shear springs
|
||||
for ( i = 0; i < numfaces; i++ )
|
||||
{
|
||||
for ( i = 0; i < numfaces; i++ ) {
|
||||
// triangle faces already have shear springs due to structural geometry
|
||||
if ( !mface[i].v4 )
|
||||
continue;
|
||||
|
||||
spring = ( ClothSpring *) MEM_callocN ( sizeof ( ClothSpring ), "cloth spring" );
|
||||
|
||||
if (!spring)
|
||||
{
|
||||
if (!spring) {
|
||||
cloth_free_errorsprings(cloth, edgehash, edgelist);
|
||||
return 0;
|
||||
}
|
||||
@ -1140,8 +1093,7 @@ static int cloth_build_springs ( ClothModifierData *clmd, DerivedMesh *dm )
|
||||
// if ( mface[i].v4 ) --> Quad face
|
||||
spring = ( ClothSpring * ) MEM_callocN ( sizeof ( ClothSpring ), "cloth spring" );
|
||||
|
||||
if (!spring)
|
||||
{
|
||||
if (!spring) {
|
||||
cloth_free_errorsprings(cloth, edgehash, edgelist);
|
||||
return 0;
|
||||
}
|
||||
@ -1162,15 +1114,13 @@ static int cloth_build_springs ( ClothModifierData *clmd, DerivedMesh *dm )
|
||||
if (numfaces) {
|
||||
// bending springs
|
||||
search2 = cloth->springs;
|
||||
for ( i = struct_springs; i < struct_springs+shear_springs; i++ )
|
||||
{
|
||||
for ( i = struct_springs; i < struct_springs+shear_springs; i++ ) {
|
||||
if ( !search2 )
|
||||
break;
|
||||
|
||||
tspring2 = search2->link;
|
||||
search = edgelist[tspring2->kl];
|
||||
while ( search )
|
||||
{
|
||||
while ( search ) {
|
||||
tspring = search->link;
|
||||
index2 = ( ( tspring->ij==tspring2->kl ) ? ( tspring->kl ) : ( tspring->ij ) );
|
||||
|
||||
@ -1181,8 +1131,7 @@ static int cloth_build_springs ( ClothModifierData *clmd, DerivedMesh *dm )
|
||||
{
|
||||
spring = ( ClothSpring * ) MEM_callocN ( sizeof ( ClothSpring ), "cloth spring" );
|
||||
|
||||
if (!spring)
|
||||
{
|
||||
if (!spring) {
|
||||
cloth_free_errorsprings(cloth, edgehash, edgelist);
|
||||
return 0;
|
||||
}
|
||||
@ -1212,16 +1161,14 @@ static int cloth_build_springs ( ClothModifierData *clmd, DerivedMesh *dm )
|
||||
/* of the strands. -jahka */
|
||||
search = cloth->springs;
|
||||
search2 = search->next;
|
||||
while (search && search2)
|
||||
{
|
||||
while (search && search2) {
|
||||
tspring = search->link;
|
||||
tspring2 = search2->link;
|
||||
|
||||
if (tspring->ij == tspring2->kl) {
|
||||
spring = ( ClothSpring * ) MEM_callocN ( sizeof ( ClothSpring ), "cloth spring" );
|
||||
|
||||
if (!spring)
|
||||
{
|
||||
if (!spring) {
|
||||
cloth_free_errorsprings(cloth, edgehash, edgelist);
|
||||
return 0;
|
||||
}
|
||||
@ -1242,13 +1189,12 @@ static int cloth_build_springs ( ClothModifierData *clmd, DerivedMesh *dm )
|
||||
}
|
||||
|
||||
/* insert other near springs in edgehash AFTER bending springs are calculated (for selfcolls) */
|
||||
for ( i = 0; i < numedges; i++ ) // struct springs
|
||||
for (i = 0; i < numedges; i++) { /* struct springs */
|
||||
BLI_edgehash_insert ( edgehash, MIN2(medge[i].v1, medge[i].v2), MAX2(medge[i].v2, medge[i].v1), NULL );
|
||||
|
||||
for ( i = 0; i < numfaces; i++ ) // edge springs
|
||||
{
|
||||
if (mface[i].v4)
|
||||
{
|
||||
}
|
||||
|
||||
for (i = 0; i < numfaces; i++) { /* edge springs */
|
||||
if (mface[i].v4) {
|
||||
BLI_edgehash_insert ( edgehash, MIN2(mface[i].v1, mface[i].v3), MAX2(mface[i].v3, mface[i].v1), NULL );
|
||||
|
||||
BLI_edgehash_insert ( edgehash, MIN2(mface[i].v2, mface[i].v4), MAX2(mface[i].v2, mface[i].v4), NULL );
|
||||
@ -1258,10 +1204,8 @@ static int cloth_build_springs ( ClothModifierData *clmd, DerivedMesh *dm )
|
||||
|
||||
cloth->numsprings = struct_springs + shear_springs + bend_springs;
|
||||
|
||||
if ( edgelist )
|
||||
{
|
||||
for ( i = 0; i < numverts; i++ )
|
||||
{
|
||||
if ( edgelist ) {
|
||||
for ( i = 0; i < numverts; i++ ) {
|
||||
BLI_linklist_free ( edgelist[i],NULL );
|
||||
}
|
||||
|
||||
|
@ -80,8 +80,7 @@ void collision_move_object(CollisionModifierData *collmd, float step, float prev
|
||||
float tv[3] = {0, 0, 0};
|
||||
unsigned int i = 0;
|
||||
|
||||
for ( i = 0; i < collmd->numverts; i++ )
|
||||
{
|
||||
for ( i = 0; i < collmd->numverts; i++ ) {
|
||||
sub_v3_v3v3 ( tv, collmd->xnew[i].co, collmd->x[i].co );
|
||||
VECADDS ( collmd->current_x[i].co, collmd->x[i].co, tv, prevstep );
|
||||
VECADDS ( collmd->current_xnew[i].co, collmd->x[i].co, tv, step );
|
||||
@ -101,8 +100,7 @@ BVHTree *bvhtree_build_from_mvert ( MFace *mfaces, unsigned int numfaces, MVert
|
||||
tree = BLI_bvhtree_new ( numfaces*2, epsilon, 4, 26 );
|
||||
|
||||
// fill tree
|
||||
for ( i = 0; i < numfaces; i++, tface++ )
|
||||
{
|
||||
for ( i = 0; i < numfaces; i++, tface++ ) {
|
||||
copy_v3_v3 ( &co[0*3], x[tface->v1].co );
|
||||
copy_v3_v3 ( &co[1*3], x[tface->v2].co );
|
||||
copy_v3_v3 ( &co[2*3], x[tface->v3].co );
|
||||
@ -128,10 +126,8 @@ void bvhtree_update_from_mvert ( BVHTree * bvhtree, MFace *faces, int numfaces,
|
||||
if ( !bvhtree )
|
||||
return;
|
||||
|
||||
if ( x )
|
||||
{
|
||||
for ( i = 0; i < numfaces; i++, mfaces++ )
|
||||
{
|
||||
if ( x ) {
|
||||
for ( i = 0; i < numfaces; i++, mfaces++ ) {
|
||||
copy_v3_v3 ( &co[0*3], x[mfaces->v1].co );
|
||||
copy_v3_v3 ( &co[1*3], x[mfaces->v2].co );
|
||||
copy_v3_v3 ( &co[2*3], x[mfaces->v3].co );
|
||||
@ -139,8 +135,7 @@ void bvhtree_update_from_mvert ( BVHTree * bvhtree, MFace *faces, int numfaces,
|
||||
copy_v3_v3 ( &co[3*3], x[mfaces->v4].co );
|
||||
|
||||
// copy new locations into array
|
||||
if ( moving && xnew )
|
||||
{
|
||||
if ( moving && xnew ) {
|
||||
// update moving positions
|
||||
copy_v3_v3 ( &co_moving[0*3], xnew[mfaces->v1].co );
|
||||
copy_v3_v3 ( &co_moving[1*3], xnew[mfaces->v2].co );
|
||||
@ -150,8 +145,7 @@ void bvhtree_update_from_mvert ( BVHTree * bvhtree, MFace *faces, int numfaces,
|
||||
|
||||
ret = BLI_bvhtree_update_node ( bvhtree, i, co, co_moving, ( mfaces->v4 ? 4 : 3 ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
else {
|
||||
ret = BLI_bvhtree_update_node ( bvhtree, i, co, NULL, ( mfaces->v4 ? 4 : 3 ) );
|
||||
}
|
||||
|
||||
@ -465,8 +459,7 @@ static void collision_compute_barycentric ( float pv[3], float p1[3], float p2[3
|
||||
|
||||
d = ( a * c - b * b );
|
||||
|
||||
if ( ABS ( d ) < (double)ALMOST_ZERO )
|
||||
{
|
||||
if ( ABS ( d ) < (double)ALMOST_ZERO ) {
|
||||
*w1 = *w2 = *w3 = 1.0 / 3.0;
|
||||
return;
|
||||
}
|
||||
@ -504,8 +497,7 @@ static int cloth_collision_response_static ( ClothModifierData *clmd, CollisionM
|
||||
|
||||
cloth1 = clmd->clothObject;
|
||||
|
||||
for ( ; collpair != collision_end; collpair++ )
|
||||
{
|
||||
for ( ; collpair != collision_end; collpair++ ) {
|
||||
// only handle static collisions here
|
||||
if ( collpair->flag & COLLISION_IN_FUTURE )
|
||||
continue;
|
||||
@ -540,8 +532,7 @@ static int cloth_collision_response_static ( ClothModifierData *clmd, CollisionM
|
||||
// TODO
|
||||
|
||||
// If v_n_mag < 0 the edges are approaching each other.
|
||||
if ( magrelVel > ALMOST_ZERO )
|
||||
{
|
||||
if ( magrelVel > ALMOST_ZERO ) {
|
||||
// Calculate Impulse magnitude to stop all motion in normal direction.
|
||||
float magtangent = 0, repulse = 0, d = 0;
|
||||
double impulse = 0.0;
|
||||
@ -558,8 +549,7 @@ static int cloth_collision_response_static ( ClothModifierData *clmd, CollisionM
|
||||
magtangent = MIN2 ( clmd->coll_parms->friction * 0.01f * magrelVel, sqrtf( dot_v3v3( vrel_t_pre,vrel_t_pre ) ) );
|
||||
|
||||
// Apply friction impulse.
|
||||
if ( magtangent > ALMOST_ZERO )
|
||||
{
|
||||
if ( magtangent > ALMOST_ZERO ) {
|
||||
normalize_v3( vrel_t_pre );
|
||||
|
||||
impulse = magtangent / ( 1.0f + w1*w1 + w2*w2 + w3*w3 ); // 2.0 *
|
||||
@ -587,8 +577,7 @@ static int cloth_collision_response_static ( ClothModifierData *clmd, CollisionM
|
||||
spf = (float)clmd->sim_parms->stepsPerFrame / clmd->sim_parms->timescale;
|
||||
|
||||
d = clmd->coll_parms->epsilon*8.0f/9.0f + epsilon2*8.0f/9.0f - collpair->distance;
|
||||
if ( ( magrelVel < 0.1f*d*spf ) && ( d > ALMOST_ZERO ) )
|
||||
{
|
||||
if ( ( magrelVel < 0.1f*d*spf ) && ( d > ALMOST_ZERO ) ) {
|
||||
repulse = MIN2 ( d*1.0f/spf, 0.1f*d*spf - magrelVel );
|
||||
|
||||
// stay on the safe side and clamp repulse
|
||||
@ -685,10 +674,8 @@ static CollPair* cloth_edge_collision ( ModifierData *md1, ModifierData *md2,
|
||||
face2 = & ( collmd->mfaces[overlap->indexB] );
|
||||
|
||||
// check all 4 possible collisions
|
||||
for ( i = 0; i < 4; i++ )
|
||||
{
|
||||
if ( i == 0 )
|
||||
{
|
||||
for ( i = 0; i < 4; i++ ) {
|
||||
if ( i == 0 ) {
|
||||
// fill faceA
|
||||
ap1 = face1->v1;
|
||||
ap2 = face1->v2;
|
||||
@ -699,10 +686,8 @@ static CollPair* cloth_edge_collision ( ModifierData *md1, ModifierData *md2,
|
||||
bp2 = face2->v2;
|
||||
bp3 = face2->v3;
|
||||
}
|
||||
else if ( i == 1 )
|
||||
{
|
||||
if ( face1->v4 )
|
||||
{
|
||||
else if ( i == 1 ) {
|
||||
if ( face1->v4 ) {
|
||||
// fill faceA
|
||||
ap1 = face1->v1;
|
||||
ap2 = face1->v3;
|
||||
@ -717,10 +702,8 @@ static CollPair* cloth_edge_collision ( ModifierData *md1, ModifierData *md2,
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if ( i == 2 )
|
||||
{
|
||||
if ( face2->v4 )
|
||||
{
|
||||
if ( i == 2 ) {
|
||||
if ( face2->v4 ) {
|
||||
// fill faceA
|
||||
ap1 = face1->v1;
|
||||
ap2 = face1->v2;
|
||||
@ -735,10 +718,8 @@ static CollPair* cloth_edge_collision ( ModifierData *md1, ModifierData *md2,
|
||||
continue;
|
||||
}
|
||||
}
|
||||
else if ( i == 3 )
|
||||
{
|
||||
if ( face1->v4 && face2->v4 )
|
||||
{
|
||||
else if ( i == 3 ) {
|
||||
if ( face1->v4 && face2->v4 ) {
|
||||
// fill faceA
|
||||
ap1 = face1->v1;
|
||||
ap2 = face1->v3;
|
||||
@ -847,8 +828,7 @@ static int cloth_edge_collision_response_moving ( ClothModifierData *clmd, Colli
|
||||
|
||||
cloth1 = clmd->clothObject;
|
||||
|
||||
for ( ; collpair != collision_end; collpair++ )
|
||||
{
|
||||
for ( ; collpair != collision_end; collpair++ ) {
|
||||
if (!(collpair->flag & COLLISION_IS_EDGES))
|
||||
continue;
|
||||
|
||||
@ -865,8 +845,7 @@ static int cloth_edge_collision_response_moving ( ClothModifierData *clmd, Colli
|
||||
magrelVel = dot_v3v3 ( relativeVelocity, collpair->normal );
|
||||
|
||||
// If v_n_mag < 0 the edges are approaching each other.
|
||||
if ( magrelVel > ALMOST_ZERO )
|
||||
{
|
||||
if ( magrelVel > ALMOST_ZERO ) {
|
||||
// Calculate Impulse magnitude to stop all motion in normal direction.
|
||||
float magtangent = 0, repulse = 0, d = 0;
|
||||
double impulse = 0.0;
|
||||
@ -885,8 +864,7 @@ static int cloth_edge_collision_response_moving ( ClothModifierData *clmd, Colli
|
||||
magtangent = MIN2 ( clmd->coll_parms->friction * 0.01 * magrelVel,sqrt ( dot_v3v3 ( vrel_t_pre,vrel_t_pre ) ) );
|
||||
|
||||
// Apply friction impulse.
|
||||
if ( magtangent > ALMOST_ZERO )
|
||||
{
|
||||
if ( magtangent > ALMOST_ZERO ) {
|
||||
normalize_v3( vrel_t_pre );
|
||||
|
||||
impulse = magtangent;
|
||||
@ -906,8 +884,7 @@ static int cloth_edge_collision_response_moving ( ClothModifierData *clmd, Colli
|
||||
spf = (float)clmd->sim_parms->stepsPerFrame / clmd->sim_parms->timescale;
|
||||
|
||||
d = collpair->distance;
|
||||
if ( ( magrelVel < 0.1*d*spf && ( d > ALMOST_ZERO ) ) )
|
||||
{
|
||||
if ( ( magrelVel < 0.1*d*spf && ( d > ALMOST_ZERO ) ) ) {
|
||||
repulse = MIN2 ( d*1.0/spf, 0.1*d*spf - magrelVel );
|
||||
|
||||
// stay on the safe side and clamp repulse
|
||||
@ -949,8 +926,7 @@ static int cloth_collision_response_moving ( ClothModifierData *clmd, CollisionM
|
||||
|
||||
cloth1 = clmd->clothObject;
|
||||
|
||||
for ( ; collpair != collision_end; collpair++ )
|
||||
{
|
||||
for ( ; collpair != collision_end; collpair++ ) {
|
||||
if (collpair->flag & COLLISION_IS_EDGES)
|
||||
continue;
|
||||
|
||||
@ -967,8 +943,7 @@ static int cloth_collision_response_moving ( ClothModifierData *clmd, CollisionM
|
||||
magrelVel = dot_v3v3 ( relativeVelocity, collpair->normal );
|
||||
|
||||
// If v_n_mag < 0 the edges are approaching each other.
|
||||
if ( magrelVel > ALMOST_ZERO )
|
||||
{
|
||||
if ( magrelVel > ALMOST_ZERO ) {
|
||||
// Calculate Impulse magnitude to stop all motion in normal direction.
|
||||
float magtangent = 0, repulse = 0, d = 0;
|
||||
double impulse = 0.0;
|
||||
@ -985,8 +960,7 @@ static int cloth_collision_response_moving ( ClothModifierData *clmd, CollisionM
|
||||
magtangent = MIN2 ( clmd->coll_parms->friction * 0.01 * magrelVel,sqrt ( dot_v3v3 ( vrel_t_pre,vrel_t_pre ) ) );
|
||||
|
||||
// Apply friction impulse.
|
||||
if ( magtangent > ALMOST_ZERO )
|
||||
{
|
||||
if ( magtangent > ALMOST_ZERO ) {
|
||||
normalize_v3( vrel_t_pre );
|
||||
|
||||
impulse = magtangent; // 2.0 *
|
||||
@ -1006,8 +980,7 @@ static int cloth_collision_response_moving ( ClothModifierData *clmd, CollisionM
|
||||
spf = (float)clmd->sim_parms->stepsPerFrame / clmd->sim_parms->timescale;
|
||||
|
||||
d = -collpair->distance;
|
||||
if ( ( magrelVel < 0.1*d*spf ) && ( d > ALMOST_ZERO ) )
|
||||
{
|
||||
if ( ( magrelVel < 0.1*d*spf ) && ( d > ALMOST_ZERO ) ) {
|
||||
repulse = MIN2 ( d*1.0/spf, 0.1*d*spf - magrelVel );
|
||||
|
||||
// stay on the safe side and clamp repulse
|
||||
@ -1034,8 +1007,7 @@ static int cloth_collision_response_moving ( ClothModifierData *clmd, CollisionM
|
||||
magrelVel = dot_v3v3 ( relativeVelocity, collpair->normal );
|
||||
|
||||
// If v_n_mag < 0 the edges are approaching each other.
|
||||
if ( magrelVel > ALMOST_ZERO )
|
||||
{
|
||||
if ( magrelVel > ALMOST_ZERO ) {
|
||||
// Calculate Impulse magnitude to stop all motion in normal direction.
|
||||
float magtangent = 0, repulse = 0, d = 0;
|
||||
double impulse = 0.0;
|
||||
@ -1052,8 +1024,7 @@ static int cloth_collision_response_moving ( ClothModifierData *clmd, CollisionM
|
||||
magtangent = MIN2 ( clmd->coll_parms->friction * 0.01 * magrelVel,sqrt ( dot_v3v3 ( vrel_t_pre,vrel_t_pre ) ) );
|
||||
|
||||
// Apply friction impulse.
|
||||
if ( magtangent > ALMOST_ZERO )
|
||||
{
|
||||
if ( magtangent > ALMOST_ZERO ) {
|
||||
normalize_v3( vrel_t_pre );
|
||||
|
||||
impulse = magtangent; // 2.0 *
|
||||
@ -1072,8 +1043,7 @@ static int cloth_collision_response_moving ( ClothModifierData *clmd, CollisionM
|
||||
spf = (float)clmd->sim_parms->stepsPerFrame / clmd->sim_parms->timescale;
|
||||
|
||||
d = -collpair->distance;
|
||||
if ( ( magrelVel < 0.1*d*spf ) && ( d > ALMOST_ZERO ) )
|
||||
{
|
||||
if ( ( magrelVel < 0.1*d*spf ) && ( d > ALMOST_ZERO ) ) {
|
||||
repulse = MIN2 ( d*1.0/spf, 0.1*d*spf - magrelVel );
|
||||
|
||||
// stay on the safe side and clamp repulse
|
||||
@ -1202,10 +1172,8 @@ static CollPair* cloth_collision ( ModifierData *md1, ModifierData *md2, BVHTree
|
||||
face2 = & ( collmd->mfaces[overlap->indexB] );
|
||||
|
||||
// check all 4 possible collisions
|
||||
for ( i = 0; i < 4; i++ )
|
||||
{
|
||||
if ( i == 0 )
|
||||
{
|
||||
for ( i = 0; i < 4; i++ ) {
|
||||
if ( i == 0 ) {
|
||||
// fill faceA
|
||||
ap1 = face1->v1;
|
||||
ap2 = face1->v2;
|
||||
@ -1216,10 +1184,8 @@ static CollPair* cloth_collision ( ModifierData *md1, ModifierData *md2, BVHTree
|
||||
bp2 = face2->v2;
|
||||
bp3 = face2->v3;
|
||||
}
|
||||
else if ( i == 1 )
|
||||
{
|
||||
if ( face1->v4 )
|
||||
{
|
||||
else if ( i == 1 ) {
|
||||
if ( face1->v4 ) {
|
||||
// fill faceA
|
||||
ap1 = face1->v1;
|
||||
ap2 = face1->v3;
|
||||
@ -1234,10 +1200,8 @@ static CollPair* cloth_collision ( ModifierData *md1, ModifierData *md2, BVHTree
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if ( i == 2 )
|
||||
{
|
||||
if ( face2->v4 )
|
||||
{
|
||||
if ( i == 2 ) {
|
||||
if ( face2->v4 ) {
|
||||
// fill faceA
|
||||
ap1 = face1->v1;
|
||||
ap2 = face1->v2;
|
||||
@ -1252,10 +1216,8 @@ static CollPair* cloth_collision ( ModifierData *md1, ModifierData *md2, BVHTree
|
||||
continue;
|
||||
}
|
||||
}
|
||||
else if ( i == 3 )
|
||||
{
|
||||
if ( face1->v4 && face2->v4 )
|
||||
{
|
||||
else if ( i == 3 ) {
|
||||
if ( face1->v4 && face2->v4 ) {
|
||||
// fill faceA
|
||||
ap1 = face1->v1;
|
||||
ap2 = face1->v3;
|
||||
@ -1417,10 +1379,8 @@ static CollPair* cloth_collision ( ModifierData *md1, ModifierData *md2,
|
||||
face2 = & ( collmd->mfaces[overlap->indexB] );
|
||||
|
||||
// check all 4 possible collisions
|
||||
for ( i = 0; i < 4; i++ )
|
||||
{
|
||||
if ( i == 0 )
|
||||
{
|
||||
for ( i = 0; i < 4; i++ ) {
|
||||
if ( i == 0 ) {
|
||||
// fill faceA
|
||||
collpair->ap1 = face1->v1;
|
||||
collpair->ap2 = face1->v2;
|
||||
@ -1431,10 +1391,8 @@ static CollPair* cloth_collision ( ModifierData *md1, ModifierData *md2,
|
||||
collpair->bp2 = face2->v2;
|
||||
collpair->bp3 = face2->v3;
|
||||
}
|
||||
else if ( i == 1 )
|
||||
{
|
||||
if ( face1->v4 )
|
||||
{
|
||||
else if ( i == 1 ) {
|
||||
if ( face1->v4 ) {
|
||||
// fill faceA
|
||||
collpair->ap1 = face1->v1;
|
||||
collpair->ap2 = face1->v4;
|
||||
@ -1448,10 +1406,8 @@ static CollPair* cloth_collision ( ModifierData *md1, ModifierData *md2,
|
||||
else
|
||||
i++;
|
||||
}
|
||||
if ( i == 2 )
|
||||
{
|
||||
if ( face2->v4 )
|
||||
{
|
||||
if ( i == 2 ) {
|
||||
if ( face2->v4 ) {
|
||||
// fill faceA
|
||||
collpair->ap1 = face1->v1;
|
||||
collpair->ap2 = face1->v2;
|
||||
@ -1465,10 +1421,8 @@ static CollPair* cloth_collision ( ModifierData *md1, ModifierData *md2,
|
||||
else
|
||||
break;
|
||||
}
|
||||
else if ( i == 3 )
|
||||
{
|
||||
if ( face1->v4 && face2->v4 )
|
||||
{
|
||||
else if ( i == 3 ) {
|
||||
if ( face1->v4 && face2->v4 ) {
|
||||
// fill faceA
|
||||
collpair->ap1 = face1->v1;
|
||||
collpair->ap2 = face1->v4;
|
||||
@ -1513,8 +1467,7 @@ static CollPair* cloth_collision ( ModifierData *md1, ModifierData *md2,
|
||||
distance = 2.0 * (double)( epsilon1 + epsilon2 + ALMOST_ZERO );
|
||||
#endif
|
||||
|
||||
if ( distance <= ( epsilon1 + epsilon2 + ALMOST_ZERO ) )
|
||||
{
|
||||
if ( distance <= ( epsilon1 + epsilon2 + ALMOST_ZERO ) ) {
|
||||
normalize_v3_v3( collpair->normal, collpair->vector );
|
||||
|
||||
collpair->distance = distance;
|
||||
@ -2283,14 +2236,12 @@ static void cloth_bvh_objcollisions_nearcheck ( ClothModifierData * clmd, Collis
|
||||
#ifdef WITH_ELTOPO
|
||||
machine_epsilon_offset(clmd->clothObject);
|
||||
|
||||
for ( i = 0; i < numresult; i++ )
|
||||
{
|
||||
for ( i = 0; i < numresult; i++ ) {
|
||||
*collisions_index = cloth_collision ( (ModifierData *)clmd, (ModifierData *)collmd,
|
||||
overlap+i, *collisions_index, dt, tri_visithash, arena );
|
||||
}
|
||||
|
||||
for ( i = 0; i < numresult; i++ )
|
||||
{
|
||||
for ( i = 0; i < numresult; i++ ) {
|
||||
*collisions_index = cloth_edge_collision ( (ModifierData *)clmd, (ModifierData *)collmd,
|
||||
overlap+i, *collisions_index, visithash, arena );
|
||||
}
|
||||
@ -2298,8 +2249,7 @@ static void cloth_bvh_objcollisions_nearcheck ( ClothModifierData * clmd, Collis
|
||||
BLI_ghash_free(tri_visithash, NULL, NULL);
|
||||
BLI_memarena_free(arena);
|
||||
#else /* WITH_ELTOPO */
|
||||
for ( i = 0; i < numresult; i++ )
|
||||
{
|
||||
for ( i = 0; i < numresult; i++ ) {
|
||||
*collisions_index = cloth_collision ( (ModifierData *)clmd, (ModifierData *)collmd,
|
||||
overlap+i, *collisions_index, dt );
|
||||
}
|
||||
@ -2323,12 +2273,10 @@ static int cloth_bvh_objcollisions_resolve ( ClothModifierData * clmd, Collision
|
||||
|
||||
// process all collisions (calculate impulses, TODO: also repulses if distance too short)
|
||||
result = 1;
|
||||
for ( j = 0; j < 5; j++ ) // 5 is just a value that ensures convergence
|
||||
{
|
||||
for ( j = 0; j < 5; j++ ) { /* 5 is just a value that ensures convergence */
|
||||
result = 0;
|
||||
|
||||
if ( collmd->bvhtree )
|
||||
{
|
||||
if ( collmd->bvhtree ) {
|
||||
#ifdef WITH_ELTOPO
|
||||
result += cloth_collision_response_moving(clmd, collmd, collisions, collisions_index);
|
||||
result += cloth_edge_collision_response_moving(clmd, collmd, collisions, collisions_index);
|
||||
@ -2339,14 +2287,11 @@ static int cloth_bvh_objcollisions_resolve ( ClothModifierData * clmd, Collision
|
||||
{
|
||||
#else
|
||||
// apply impulses in parallel
|
||||
if ( result )
|
||||
{
|
||||
if (result) {
|
||||
#endif
|
||||
for ( i = 0; i < numverts; i++ )
|
||||
{
|
||||
for (i = 0; i < numverts; i++) {
|
||||
// calculate "velocities" (just xnew = xold + v; no dt in v)
|
||||
if ( verts[i].impulse_count )
|
||||
{
|
||||
if (verts[i].impulse_count) {
|
||||
VECADDMUL ( verts[i].tv, verts[i].impulse, 1.0f / verts[i].impulse_count );
|
||||
copy_v3_v3 ( verts[i].impulse, tnull );
|
||||
verts[i].impulse_count = 0;
|
||||
@ -2402,8 +2347,7 @@ int cloth_bvh_objcollision (Object *ob, ClothModifierData * clmd, float step, fl
|
||||
collisions_index = MEM_callocN(sizeof(CollPair *) *numcollobj , "CollPair");
|
||||
|
||||
// check all collision objects
|
||||
for (i = 0; i < numcollobj; i++)
|
||||
{
|
||||
for (i = 0; i < numcollobj; i++) {
|
||||
Object *collob= collobjs[i];
|
||||
CollisionModifierData *collmd = (CollisionModifierData*)modifiers_findByType(collob, eModifierType_Collision);
|
||||
BVHTreeOverlap *overlap = NULL;
|
||||
@ -2435,8 +2379,7 @@ int cloth_bvh_objcollision (Object *ob, ClothModifierData * clmd, float step, fl
|
||||
}
|
||||
rounds++;
|
||||
|
||||
for (i = 0; i < numcollobj; i++)
|
||||
{
|
||||
for (i = 0; i < numcollobj; i++) {
|
||||
if ( collisions[i] ) MEM_freeN ( collisions[i] );
|
||||
}
|
||||
|
||||
@ -2449,12 +2392,9 @@ int cloth_bvh_objcollision (Object *ob, ClothModifierData * clmd, float step, fl
|
||||
////////////////////////////////////////////////////////////
|
||||
|
||||
// verts come from clmd
|
||||
for ( i = 0; i < numverts; i++ )
|
||||
{
|
||||
if ( clmd->sim_parms->flags & CLOTH_SIMSETTINGS_FLAG_GOAL )
|
||||
{
|
||||
if ( verts [i].flags & CLOTH_VERT_FLAG_PINNED )
|
||||
{
|
||||
for ( i = 0; i < numverts; i++ ) {
|
||||
if ( clmd->sim_parms->flags & CLOTH_SIMSETTINGS_FLAG_GOAL ) {
|
||||
if ( verts [i].flags & CLOTH_VERT_FLAG_PINNED ) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
@ -2467,10 +2407,8 @@ int cloth_bvh_objcollision (Object *ob, ClothModifierData * clmd, float step, fl
|
||||
////////////////////////////////////////////////////////////
|
||||
// Test on *simple* selfcollisions
|
||||
////////////////////////////////////////////////////////////
|
||||
if ( clmd->coll_parms->flags & CLOTH_COLLSETTINGS_FLAG_SELF )
|
||||
{
|
||||
for (l = 0; l < (unsigned int)clmd->coll_parms->self_loop_count; l++)
|
||||
{
|
||||
if ( clmd->coll_parms->flags & CLOTH_COLLSETTINGS_FLAG_SELF ) {
|
||||
for (l = 0; l < (unsigned int)clmd->coll_parms->self_loop_count; l++) {
|
||||
// TODO: add coll quality rounds again
|
||||
BVHTreeOverlap *overlap = NULL;
|
||||
unsigned int result = 0;
|
||||
@ -2483,14 +2421,12 @@ int cloth_bvh_objcollision (Object *ob, ClothModifierData * clmd, float step, fl
|
||||
|
||||
verts = cloth->verts;
|
||||
|
||||
if ( cloth->bvhselftree )
|
||||
{
|
||||
// search for overlapping collision pairs
|
||||
if ( cloth->bvhselftree ) {
|
||||
// search for overlapping collision pairs
|
||||
overlap = BLI_bvhtree_overlap ( cloth->bvhselftree, cloth->bvhselftree, &result );
|
||||
|
||||
// #pragma omp parallel for private(k, i, j) schedule(static)
|
||||
for ( k = 0; k < result; k++ )
|
||||
{
|
||||
for ( k = 0; k < result; k++ ) {
|
||||
float temp[3];
|
||||
float length = 0;
|
||||
float mindistance;
|
||||
@ -2500,8 +2436,7 @@ int cloth_bvh_objcollision (Object *ob, ClothModifierData * clmd, float step, fl
|
||||
|
||||
mindistance = clmd->coll_parms->selfepsilon* ( cloth->verts[i].avg_spring_len + cloth->verts[j].avg_spring_len );
|
||||
|
||||
if ( clmd->sim_parms->flags & CLOTH_SIMSETTINGS_FLAG_GOAL )
|
||||
{
|
||||
if ( clmd->sim_parms->flags & CLOTH_SIMSETTINGS_FLAG_GOAL ) {
|
||||
if ( ( cloth->verts [i].flags & CLOTH_VERT_FLAG_PINNED ) &&
|
||||
( cloth->verts [j].flags & CLOTH_VERT_FLAG_PINNED ) )
|
||||
{
|
||||
@ -2514,29 +2449,24 @@ int cloth_bvh_objcollision (Object *ob, ClothModifierData * clmd, float step, fl
|
||||
if ( ( ABS ( temp[0] ) > mindistance ) || ( ABS ( temp[1] ) > mindistance ) || ( ABS ( temp[2] ) > mindistance ) ) continue;
|
||||
|
||||
// check for adjacent points (i must be smaller j)
|
||||
if ( BLI_edgehash_haskey ( cloth->edgehash, MIN2(i, j), MAX2(i, j) ) )
|
||||
{
|
||||
if ( BLI_edgehash_haskey ( cloth->edgehash, MIN2(i, j), MAX2(i, j) ) ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
length = normalize_v3( temp );
|
||||
|
||||
if ( length < mindistance )
|
||||
{
|
||||
if ( length < mindistance ) {
|
||||
float correction = mindistance - length;
|
||||
|
||||
if ( cloth->verts [i].flags & CLOTH_VERT_FLAG_PINNED )
|
||||
{
|
||||
if ( cloth->verts [i].flags & CLOTH_VERT_FLAG_PINNED ) {
|
||||
mul_v3_fl( temp, -correction );
|
||||
VECADD ( verts[j].tx, verts[j].tx, temp );
|
||||
}
|
||||
else if ( cloth->verts [j].flags & CLOTH_VERT_FLAG_PINNED )
|
||||
{
|
||||
else if ( cloth->verts [j].flags & CLOTH_VERT_FLAG_PINNED ) {
|
||||
mul_v3_fl( temp, correction );
|
||||
VECADD ( verts[i].tx, verts[i].tx, temp );
|
||||
}
|
||||
else
|
||||
{
|
||||
else {
|
||||
mul_v3_fl( temp, correction * -0.5 );
|
||||
VECADD ( verts[j].tx, verts[j].tx, temp );
|
||||
|
||||
@ -2560,12 +2490,9 @@ int cloth_bvh_objcollision (Object *ob, ClothModifierData * clmd, float step, fl
|
||||
////////////////////////////////////////////////////////////
|
||||
// SELFCOLLISIONS: update velocities
|
||||
////////////////////////////////////////////////////////////
|
||||
if ( ret2 )
|
||||
{
|
||||
for ( i = 0; i < cloth->numverts; i++ )
|
||||
{
|
||||
if ( ! ( verts [i].flags & CLOTH_VERT_FLAG_PINNED ) )
|
||||
{
|
||||
if ( ret2 ) {
|
||||
for ( i = 0; i < cloth->numverts; i++ ) {
|
||||
if ( ! ( verts [i].flags & CLOTH_VERT_FLAG_PINNED ) ) {
|
||||
sub_v3_v3v3 ( verts[i].tv, verts[i].tx, verts[i].txold );
|
||||
}
|
||||
}
|
||||
|
@ -202,7 +202,7 @@ void curvemap_reset(CurveMap *cuma, rctf *clipr, int preset, int slope)
|
||||
if (cuma->curve)
|
||||
MEM_freeN(cuma->curve);
|
||||
|
||||
switch(preset) {
|
||||
switch (preset) {
|
||||
case CURVE_PRESET_LINE: cuma->totpoint= 2; break;
|
||||
case CURVE_PRESET_SHARP: cuma->totpoint= 4; break;
|
||||
case CURVE_PRESET_SMOOTH: cuma->totpoint= 4; break;
|
||||
@ -214,7 +214,7 @@ void curvemap_reset(CurveMap *cuma, rctf *clipr, int preset, int slope)
|
||||
|
||||
cuma->curve= MEM_callocN(cuma->totpoint*sizeof(CurveMapPoint), "curve points");
|
||||
|
||||
switch(preset) {
|
||||
switch (preset) {
|
||||
case CURVE_PRESET_LINE:
|
||||
cuma->curve[0].x= clipr->xmin;
|
||||
cuma->curve[0].y= clipr->ymax;
|
||||
@ -252,10 +252,9 @@ void curvemap_reset(CurveMap *cuma, rctf *clipr, int preset, int slope)
|
||||
case CURVE_PRESET_MID9:
|
||||
{
|
||||
int i;
|
||||
for (i=0; i < cuma->totpoint; i++)
|
||||
{
|
||||
cuma->curve[i].x= i / ((float)cuma->totpoint-1);
|
||||
cuma->curve[i].y= 0.5;
|
||||
for (i = 0; i < cuma->totpoint; i++) {
|
||||
cuma->curve[i].x = i / ((float)cuma->totpoint - 1);
|
||||
cuma->curve[i].y = 0.5;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -3439,8 +3439,7 @@ static void shrinkwrap_get_tarmat (bConstraint *con, bConstraintOb *cob, bConstr
|
||||
{
|
||||
bShrinkwrapConstraint *scon = (bShrinkwrapConstraint *) con->data;
|
||||
|
||||
if ( VALID_CONS_TARGET(ct) && (ct->tar->type == OB_MESH) )
|
||||
{
|
||||
if ( VALID_CONS_TARGET(ct) && (ct->tar->type == OB_MESH) ) {
|
||||
int fail = FALSE;
|
||||
float co[3] = {0.0f, 0.0f, 0.0f};
|
||||
float no[3] = {0.0f, 0.0f, 0.0f};
|
||||
@ -3461,12 +3460,10 @@ static void shrinkwrap_get_tarmat (bConstraint *con, bConstraintOb *cob, bConstr
|
||||
|
||||
unit_m4(ct->matrix);
|
||||
|
||||
if (target != NULL)
|
||||
{
|
||||
if (target != NULL) {
|
||||
space_transform_from_matrixs(&transform, cob->matrix, ct->tar->obmat);
|
||||
|
||||
switch(scon->shrinkType)
|
||||
{
|
||||
switch (scon->shrinkType) {
|
||||
case MOD_SHRINKWRAP_NEAREST_SURFACE:
|
||||
case MOD_SHRINKWRAP_NEAREST_VERTEX:
|
||||
|
||||
@ -3475,8 +3472,7 @@ static void shrinkwrap_get_tarmat (bConstraint *con, bConstraintOb *cob, bConstr
|
||||
else
|
||||
bvhtree_from_mesh_faces(&treeData, target, 0.0, 2, 6);
|
||||
|
||||
if (treeData.tree == NULL)
|
||||
{
|
||||
if (treeData.tree == NULL) {
|
||||
fail = TRUE;
|
||||
break;
|
||||
}
|
||||
@ -3506,14 +3502,12 @@ static void shrinkwrap_get_tarmat (bConstraint *con, bConstraintOb *cob, bConstr
|
||||
|
||||
|
||||
bvhtree_from_mesh_faces(&treeData, target, scon->dist, 4, 6);
|
||||
if (treeData.tree == NULL)
|
||||
{
|
||||
if (treeData.tree == NULL) {
|
||||
fail = TRUE;
|
||||
break;
|
||||
}
|
||||
|
||||
if (normal_projection_project_vertex(0, co, no, &transform, treeData.tree, &hit, treeData.raycast_callback, &treeData) == FALSE)
|
||||
{
|
||||
if (normal_projection_project_vertex(0, co, no, &transform, treeData.tree, &hit, treeData.raycast_callback, &treeData) == FALSE) {
|
||||
fail = TRUE;
|
||||
break;
|
||||
}
|
||||
@ -3542,8 +3536,7 @@ static void shrinkwrap_evaluate (bConstraint *UNUSED(con), bConstraintOb *cob, L
|
||||
bConstraintTarget *ct= targets->first;
|
||||
|
||||
/* only evaluate if there is a target */
|
||||
if (VALID_CONS_TARGET(ct))
|
||||
{
|
||||
if (VALID_CONS_TARGET(ct)) {
|
||||
copy_v3_v3(cob->matrix[3], ct->matrix[3]);
|
||||
}
|
||||
}
|
||||
|
@ -777,7 +777,7 @@ int CTX_data_mode_enum(const bContext *C)
|
||||
Object *obedit= CTX_data_edit_object(C);
|
||||
|
||||
if (obedit) {
|
||||
switch(obedit->type) {
|
||||
switch (obedit->type) {
|
||||
case OB_MESH:
|
||||
return CTX_MODE_EDIT_MESH;
|
||||
case OB_CURVE:
|
||||
|
@ -636,7 +636,7 @@ static void calcknots(float *knots, const short pnts, const short order, const s
|
||||
float k;
|
||||
int a;
|
||||
|
||||
switch(flag & (CU_NURB_ENDPOINT|CU_NURB_BEZIER)) {
|
||||
switch (flag & (CU_NURB_ENDPOINT|CU_NURB_BEZIER)) {
|
||||
case CU_NURB_ENDPOINT:
|
||||
k= 0.0;
|
||||
for (a=1; a <= pnts_order; a++) {
|
||||
@ -2038,7 +2038,7 @@ static void make_bevel_list_3D_tangent(BevList *bl)
|
||||
|
||||
static void make_bevel_list_3D(BevList *bl, int smooth_iter, int twist_mode)
|
||||
{
|
||||
switch(twist_mode) {
|
||||
switch (twist_mode) {
|
||||
case CU_TWIST_TANGENT:
|
||||
make_bevel_list_3D_tangent(bl);
|
||||
break;
|
||||
|
@ -2337,7 +2337,10 @@ int CustomData_layer_has_math(struct CustomData *data, int layer_n)
|
||||
const LayerTypeInfo *typeInfo = layerType_getInfo(data->layers[layer_n].type);
|
||||
|
||||
if (typeInfo->equal && typeInfo->add && typeInfo->multiply &&
|
||||
typeInfo->initminmax && typeInfo->dominmax) return 1;
|
||||
typeInfo->initminmax && typeInfo->dominmax)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -2684,7 +2687,9 @@ int CustomData_verify_versions(struct CustomData *data, int index)
|
||||
|
||||
if (!typeInfo->defaultname && (index > 0) &&
|
||||
data->layers[index-1].type == layer->type)
|
||||
{
|
||||
keeplayer = 0; /* multiple layers of which we only support one */
|
||||
}
|
||||
}
|
||||
|
||||
if (!keeplayer) {
|
||||
|
@ -479,7 +479,7 @@ void flip_side_name(char name[MAX_VGROUP_NAME], const char from_name[MAX_VGROUP_
|
||||
|
||||
/* first case; separator . - _ with extensions r R l L */
|
||||
if (is_char_sep(name[len - 2]) ) {
|
||||
switch(name[len - 1]) {
|
||||
switch (name[len - 1]) {
|
||||
case 'l':
|
||||
prefix[len - 1] = 0;
|
||||
strcpy(replace, "r");
|
||||
@ -500,7 +500,7 @@ void flip_side_name(char name[MAX_VGROUP_NAME], const char from_name[MAX_VGROUP_
|
||||
}
|
||||
/* case; beginning with r R l L , with separator after it */
|
||||
else if (is_char_sep(name[1]) ) {
|
||||
switch(name[0]) {
|
||||
switch (name[0]) {
|
||||
case 'l':
|
||||
strcpy(replace, "r");
|
||||
BLI_strncpy(suffix, name + 1, sizeof(suffix));
|
||||
|
@ -462,7 +462,7 @@ static void build_dag_object(DagForest *dag, DagNode *scenenode, Scene *scene, O
|
||||
if (ob->parent) {
|
||||
node2 = dag_get_node(dag,ob->parent);
|
||||
|
||||
switch(ob->partype) {
|
||||
switch (ob->partype) {
|
||||
case PARSKEL:
|
||||
dag_add_relation(dag,node2,node,DAG_RL_DATA_DATA|DAG_RL_OB_OB, "Parent");
|
||||
break;
|
||||
@ -2245,7 +2245,7 @@ static void dag_object_time_update_flags(Object *ob)
|
||||
Curve *cu;
|
||||
Lattice *lt;
|
||||
|
||||
switch(ob->type) {
|
||||
switch (ob->type) {
|
||||
case OB_MESH:
|
||||
me= ob->data;
|
||||
if (me->key) {
|
||||
|
@ -228,7 +228,7 @@ void count_displist(ListBase *lb, int *totvert, int *totface)
|
||||
dl= lb->first;
|
||||
while (dl) {
|
||||
|
||||
switch(dl->type) {
|
||||
switch (dl->type) {
|
||||
case DL_SURF:
|
||||
*totvert+= dl->nr*dl->parts;
|
||||
*totface+= (dl->nr-1)*(dl->parts-1);
|
||||
|
@ -231,13 +231,22 @@ static int dynamicPaint_surfaceNumOfPoints(DynamicPaintSurface *surface)
|
||||
/* checks whether surface's format/type has realtime preview */
|
||||
int dynamicPaint_surfaceHasColorPreview(DynamicPaintSurface *surface)
|
||||
{
|
||||
if (surface->format == MOD_DPAINT_SURFACE_F_IMAGESEQ) return 0;
|
||||
if (surface->format == MOD_DPAINT_SURFACE_F_IMAGESEQ) {
|
||||
return 0;
|
||||
}
|
||||
else if (surface->format == MOD_DPAINT_SURFACE_F_VERTEX) {
|
||||
if (surface->type == MOD_DPAINT_SURFACE_T_DISPLACE ||
|
||||
surface->type == MOD_DPAINT_SURFACE_T_WAVE) return 0;
|
||||
else return 1;
|
||||
surface->type == MOD_DPAINT_SURFACE_T_WAVE)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
else {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
else {
|
||||
return 1;
|
||||
}
|
||||
else return 1;
|
||||
}
|
||||
|
||||
/* get currently active surface (in user interface) */
|
||||
@ -393,11 +402,15 @@ void dynamicPaintSurface_updateType(struct DynamicPaintSurface *surface)
|
||||
static int surface_totalSamples(DynamicPaintSurface *surface)
|
||||
{
|
||||
if (surface->format == MOD_DPAINT_SURFACE_F_IMAGESEQ &&
|
||||
surface->flags & MOD_DPAINT_ANTIALIAS)
|
||||
return (surface->data->total_points*5);
|
||||
surface->flags & MOD_DPAINT_ANTIALIAS)
|
||||
{
|
||||
return (surface->data->total_points * 5);
|
||||
}
|
||||
if (surface->format == MOD_DPAINT_SURFACE_F_VERTEX &&
|
||||
surface->flags & MOD_DPAINT_ANTIALIAS && surface->data->adj_data)
|
||||
surface->flags & MOD_DPAINT_ANTIALIAS && surface->data->adj_data)
|
||||
{
|
||||
return (surface->data->total_points+surface->data->adj_data->total_targets);
|
||||
}
|
||||
|
||||
return surface->data->total_points;
|
||||
}
|
||||
@ -548,8 +561,7 @@ static int surface_getBrushFlags(DynamicPaintSurface *surface, Scene *scene)
|
||||
else
|
||||
base = scene->base.first;
|
||||
|
||||
while (base || go)
|
||||
{
|
||||
while (base || go) {
|
||||
brushObj = NULL;
|
||||
|
||||
/* select object */
|
||||
@ -559,8 +571,7 @@ static int surface_getBrushFlags(DynamicPaintSurface *surface, Scene *scene)
|
||||
else
|
||||
brushObj = base->object;
|
||||
|
||||
if (!brushObj)
|
||||
{
|
||||
if (!brushObj) {
|
||||
if (surface->brush_group) go = go->next;
|
||||
else base= base->next;
|
||||
continue;
|
||||
@ -572,12 +583,10 @@ static int surface_getBrushFlags(DynamicPaintSurface *surface, Scene *scene)
|
||||
base= base->next;
|
||||
|
||||
md = modifiers_findByType(brushObj, eModifierType_DynamicPaint);
|
||||
if (md && md->mode & (eModifierMode_Realtime | eModifierMode_Render))
|
||||
{
|
||||
if (md && md->mode & (eModifierMode_Realtime | eModifierMode_Render)) {
|
||||
DynamicPaintModifierData *pmd2 = (DynamicPaintModifierData *)md;
|
||||
|
||||
if (pmd2->brush)
|
||||
{
|
||||
if (pmd2->brush) {
|
||||
DynamicPaintBrushSettings *brush = pmd2->brush;
|
||||
|
||||
if (brush->flags & MOD_DPAINT_USES_VELOCITY)
|
||||
@ -888,8 +897,10 @@ void surface_freeUnusedData(DynamicPaintSurface *surface)
|
||||
|
||||
/* free bakedata if not active or surface is baked */
|
||||
if (!(surface->flags & MOD_DPAINT_ACTIVE) ||
|
||||
(surface->pointcache && surface->pointcache->flag & PTCACHE_BAKED))
|
||||
(surface->pointcache && surface->pointcache->flag & PTCACHE_BAKED))
|
||||
{
|
||||
free_bakeData(surface->data);
|
||||
}
|
||||
}
|
||||
|
||||
void dynamicPaint_freeSurfaceData(DynamicPaintSurface *surface)
|
||||
@ -1219,9 +1230,13 @@ static int surface_usesAdjData(DynamicPaintSurface *surface)
|
||||
{
|
||||
if (surface_usesAdjDistance(surface)) return 1;
|
||||
if (surface->format == MOD_DPAINT_SURFACE_F_VERTEX &&
|
||||
surface->flags & MOD_DPAINT_ANTIALIAS) return 1;
|
||||
|
||||
return 0;
|
||||
surface->flags & MOD_DPAINT_ANTIALIAS)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/* initialize surface adjacency data */
|
||||
@ -1294,10 +1309,12 @@ static void dynamicPaint_initAdjacencyData(DynamicPaintSurface *surface, int for
|
||||
/* now check if total number of edges+faces for
|
||||
* each vertex is even, if not -> vertex is on mesh edge */
|
||||
for (i=0; i<sData->total_points; i++) {
|
||||
if ((temp_data[i]%2) ||
|
||||
temp_data[i] < 4)
|
||||
if ((temp_data[i] % 2) ||
|
||||
(temp_data[i] < 4))
|
||||
{
|
||||
ad->flags[i] |= ADJ_ON_MESH_EDGE;
|
||||
|
||||
}
|
||||
|
||||
/* reset temp data */
|
||||
temp_data[i] = 0;
|
||||
}
|
||||
@ -1863,8 +1880,10 @@ static void dynamicPaint_frameUpdate(DynamicPaintModifierData *pmd, Scene *scene
|
||||
|
||||
/* restore canvas derivedmesh if required */
|
||||
if (surface->type == MOD_DPAINT_SURFACE_T_DISPLACE &&
|
||||
surface->flags & MOD_DPAINT_DISP_INCREMENTAL && surface->next)
|
||||
surface->flags & MOD_DPAINT_DISP_INCREMENTAL && surface->next)
|
||||
{
|
||||
canvas_copyDerivedMesh(canvas, dm);
|
||||
}
|
||||
|
||||
BKE_ptcache_validate(cache, surface->current_frame);
|
||||
BKE_ptcache_write(&pid, surface->current_frame);
|
||||
@ -2042,9 +2061,12 @@ static int dynamicPaint_findNeighbourPixel(PaintUVPoint *tempPoints, DerivedMesh
|
||||
//printf("connected UV : %f,%f & %f,%f - %f,%f & %f,%f\n", s_uv1[0], s_uv1[1], s_uv2[0], s_uv2[1], t_uv1[0], t_uv1[1], t_uv2[0], t_uv2[1]);
|
||||
|
||||
if (((s_uv1[0] == t_uv1[0] && s_uv1[1] == t_uv1[1]) &&
|
||||
(s_uv2[0] == t_uv2[0] && s_uv2[1] == t_uv2[1]) ) ||
|
||||
((s_uv2[0] == t_uv1[0] && s_uv2[1] == t_uv1[1]) &&
|
||||
(s_uv1[0] == t_uv2[0] && s_uv1[1] == t_uv2[1]) )) return ((px+neighX[n_index]) + w*(py+neighY[n_index]));
|
||||
(s_uv2[0] == t_uv2[0] && s_uv2[1] == t_uv2[1]) ) ||
|
||||
((s_uv2[0] == t_uv1[0] && s_uv2[1] == t_uv1[1]) &&
|
||||
(s_uv1[0] == t_uv2[0] && s_uv1[1] == t_uv2[1]) ))
|
||||
{
|
||||
return ((px+neighX[n_index]) + w*(py+neighY[n_index]));
|
||||
}
|
||||
|
||||
/*
|
||||
* Find a point that is relatively at same edge position
|
||||
@ -2185,11 +2207,9 @@ int dynamicPaint_createUVSurface(DynamicPaintSurface *surface)
|
||||
*/
|
||||
if (!error) {
|
||||
#pragma omp parallel for schedule(static)
|
||||
for (ty = 0; ty < h; ty++)
|
||||
{
|
||||
for (ty = 0; ty < h; ty++) {
|
||||
int tx;
|
||||
for (tx = 0; tx < w; tx++)
|
||||
{
|
||||
for (tx = 0; tx < w; tx++) {
|
||||
int i, sample;
|
||||
int index = tx+w*ty;
|
||||
PaintUVPoint *tPoint = (&tempPoints[index]);
|
||||
@ -2257,8 +2277,7 @@ int dynamicPaint_createUVSurface(DynamicPaintSurface *surface)
|
||||
|
||||
/* If collision wasn't found but the face is a quad
|
||||
* do another check for the second half */
|
||||
if ((!isInside) && mface[i].v4)
|
||||
{
|
||||
if ((!isInside) && mface[i].v4) {
|
||||
|
||||
/* change d2 to test the other half */
|
||||
sub_v2_v2v2(d2, tface[i].uv[3], tface[i].uv[0]); // uv3 - uv0
|
||||
@ -2330,11 +2349,9 @@ int dynamicPaint_createUVSurface(DynamicPaintSurface *surface)
|
||||
* (To avoid seams on uv island edges)
|
||||
*/
|
||||
#pragma omp parallel for schedule(static)
|
||||
for (ty = 0; ty < h; ty++)
|
||||
{
|
||||
for (ty = 0; ty < h; ty++) {
|
||||
int tx;
|
||||
for (tx = 0; tx < w; tx++)
|
||||
{
|
||||
for (tx = 0; tx < w; tx++) {
|
||||
int index = tx+w*ty;
|
||||
PaintUVPoint *tPoint = (&tempPoints[index]);
|
||||
|
||||
@ -2408,11 +2425,9 @@ int dynamicPaint_createUVSurface(DynamicPaintSurface *surface)
|
||||
* When base loop is over convert found neighbor indexes to real ones
|
||||
* Also count the final number of active surface points
|
||||
*/
|
||||
for (ty = 0; ty < h; ty++)
|
||||
{
|
||||
for (ty = 0; ty < h; ty++) {
|
||||
int tx;
|
||||
for (tx = 0; tx < w; tx++)
|
||||
{
|
||||
for (tx = 0; tx < w; tx++) {
|
||||
int index = tx+w*ty;
|
||||
PaintUVPoint *tPoint = (&tempPoints[index]);
|
||||
|
||||
@ -2440,11 +2455,9 @@ int dynamicPaint_createUVSurface(DynamicPaintSurface *surface)
|
||||
if (sData->adj_data) {
|
||||
PaintAdjData *ed = sData->adj_data;
|
||||
unsigned int n_pos = 0;
|
||||
for (ty = 0; ty < h; ty++)
|
||||
{
|
||||
for (ty = 0; ty < h; ty++) {
|
||||
int tx;
|
||||
for (tx = 0; tx < w; tx++)
|
||||
{
|
||||
for (tx = 0; tx < w; tx++) {
|
||||
int i, index = tx+w*ty;
|
||||
|
||||
if (tempPoints[index].face_index != -1) {
|
||||
@ -2576,8 +2589,7 @@ void dynamicPaint_outputSurfaceImage(DynamicPaintSurface *surface, char* filenam
|
||||
if (ibuf == NULL) {setError(surface->canvas, "Image save failed: Not enough free memory.");return;}
|
||||
|
||||
#pragma omp parallel for schedule(static)
|
||||
for (index = 0; index < sData->total_points; index++)
|
||||
{
|
||||
for (index = 0; index < sData->total_points; index++) {
|
||||
int pos=f_data->uv_p[index].pixel_index*4; /* image buffer position */
|
||||
|
||||
/* Set values of preferred type */
|
||||
@ -2759,8 +2771,7 @@ static void mesh_faces_spherecast_dp(void *userdata, int index, const BVHTreeRay
|
||||
{
|
||||
float dist = bvhtree_ray_tri_intersection(ray, hit->dist, t0, t1, t2);
|
||||
|
||||
if (dist >= 0 && dist < hit->dist)
|
||||
{
|
||||
if (dist >= 0 && dist < hit->dist) {
|
||||
hit->index = index;
|
||||
hit->dist = dist;
|
||||
hit->no[0] = (quad) ? 1.0f : 0.0f;
|
||||
@ -2799,8 +2810,7 @@ static void mesh_faces_nearest_point_dp(void *userdata, int index, const float *
|
||||
int vertex, edge;
|
||||
|
||||
dist = nearest_point_in_tri_surface(t0, t1, t2, co, &vertex, &edge, nearest_tmp);
|
||||
if (dist < nearest->dist)
|
||||
{
|
||||
if (dist < nearest->dist) {
|
||||
nearest->index = index;
|
||||
nearest->dist = dist;
|
||||
copy_v3_v3(nearest->co, nearest_tmp);
|
||||
@ -3188,8 +3198,7 @@ static int dynamicPaint_paintMesh(DynamicPaintSurface *surface,
|
||||
/* check bounding box collision */
|
||||
if (grid && meshBrush_boundsIntersect(&grid->grid_bounds, &mesh_bb, brush, brush_radius))
|
||||
/* Build a bvh tree from transformed vertices */
|
||||
if (bvhtree_from_mesh_faces(&treeData, dm, 0.0f, 4, 8))
|
||||
{
|
||||
if (bvhtree_from_mesh_faces(&treeData, dm, 0.0f, 4, 8)) {
|
||||
int c_index;
|
||||
int total_cells = grid->dim[0]*grid->dim[1]*grid->dim[2];
|
||||
|
||||
@ -3203,8 +3212,7 @@ static int dynamicPaint_paintMesh(DynamicPaintSurface *surface,
|
||||
|
||||
/* loop through cell points and process brush */
|
||||
#pragma omp parallel for schedule(static)
|
||||
for (id = 0; id < grid->s_num[c_index]; id++)
|
||||
{
|
||||
for (id = 0; id < grid->s_num[c_index]; id++) {
|
||||
int index = grid->t_index[grid->s_pos[c_index] + id];
|
||||
int ss, samples = bData->s_num[index];
|
||||
float total_sample = (float)samples;
|
||||
@ -3220,8 +3228,7 @@ static int dynamicPaint_paintMesh(DynamicPaintSurface *surface,
|
||||
total_sample = gaussianTotal;
|
||||
|
||||
/* Supersampling */
|
||||
for (ss=0; ss<samples; ss++)
|
||||
{
|
||||
for (ss=0; ss<samples; ss++) {
|
||||
|
||||
float ray_start[3], ray_dir[3];
|
||||
float sample_factor = 0.0f;
|
||||
@ -3263,8 +3270,7 @@ static int dynamicPaint_paintMesh(DynamicPaintSurface *surface,
|
||||
|
||||
/* Check volume collision */
|
||||
if (brush->collision == MOD_DPAINT_COL_VOLUME || brush->collision == MOD_DPAINT_COL_VOLDIST)
|
||||
if (BLI_bvhtree_ray_cast(treeData.tree, ray_start, ray_dir, 0.0f, &hit, mesh_faces_spherecast_dp, &treeData) != -1)
|
||||
{
|
||||
if (BLI_bvhtree_ray_cast(treeData.tree, ray_start, ray_dir, 0.0f, &hit, mesh_faces_spherecast_dp, &treeData) != -1) {
|
||||
/* We hit a triangle, now check if collision point normal is facing the point */
|
||||
|
||||
/* For optimization sake, hit point normal isn't calculated in ray cast loop */
|
||||
@ -3277,8 +3283,7 @@ static int dynamicPaint_paintMesh(DynamicPaintSurface *surface,
|
||||
|
||||
/* If ray and hit face normal are facing same direction
|
||||
* hit point is inside a closed mesh. */
|
||||
if (dot>=0)
|
||||
{
|
||||
if (dot>=0) {
|
||||
float dist = hit.dist;
|
||||
int f_index = hit.index;
|
||||
|
||||
@ -3342,8 +3347,7 @@ static int dynamicPaint_paintMesh(DynamicPaintSurface *surface,
|
||||
hit.dist = brush_radius;
|
||||
|
||||
/* Do a face normal directional raycast, and use that distance */
|
||||
if (BLI_bvhtree_ray_cast(treeData.tree, ray_start, proj_ray, 0.0f, &hit, mesh_faces_spherecast_dp, &treeData) != -1)
|
||||
{
|
||||
if (BLI_bvhtree_ray_cast(treeData.tree, ray_start, proj_ray, 0.0f, &hit, mesh_faces_spherecast_dp, &treeData) != -1) {
|
||||
proxDist = hit.dist;
|
||||
madd_v3_v3v3fl(hitCo, ray_start, proj_ray, hit.dist); /* Calculate final hit coordinates */
|
||||
hQuad = (hit.no[0] == 1.0f);
|
||||
@ -3446,8 +3450,7 @@ static int dynamicPaint_paintMesh(DynamicPaintSurface *surface,
|
||||
/*
|
||||
* Process hit color and alpha
|
||||
*/
|
||||
if (surface->type == MOD_DPAINT_SURFACE_T_PAINT)
|
||||
{
|
||||
if (surface->type == MOD_DPAINT_SURFACE_T_PAINT) {
|
||||
float sampleColor[3];
|
||||
float alpha_factor = 1.0f;
|
||||
|
||||
@ -3589,8 +3592,7 @@ static int dynamicPaint_paintParticles(DynamicPaintSurface *surface,
|
||||
BLI_begin_threaded_malloc();
|
||||
|
||||
/* only continue if particle bb is close enough to canvas bb */
|
||||
if (boundsIntersectDist(&grid->grid_bounds, &part_bb, range))
|
||||
{
|
||||
if (boundsIntersectDist(&grid->grid_bounds, &part_bb, range)) {
|
||||
int c_index;
|
||||
int total_cells = grid->dim[0]*grid->dim[1]*grid->dim[2];
|
||||
|
||||
@ -3603,13 +3605,14 @@ static int dynamicPaint_paintParticles(DynamicPaintSurface *surface,
|
||||
|
||||
/* check cell bounding box */
|
||||
if (!grid->s_num[c_index] ||
|
||||
!boundsIntersectDist(&grid->bounds[c_index], &part_bb, range))
|
||||
!boundsIntersectDist(&grid->bounds[c_index], &part_bb, range))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
/* loop through cell points */
|
||||
#pragma omp parallel for schedule(static)
|
||||
for (id = 0; id < grid->s_num[c_index]; id++)
|
||||
{
|
||||
for (id = 0; id < grid->s_num[c_index]; id++) {
|
||||
int index = grid->t_index[grid->s_pos[c_index] + id];
|
||||
float disp_intersect = 0.0f;
|
||||
float radius = 0.0f;
|
||||
@ -3714,8 +3717,7 @@ static int dynamicPaint_paintParticles(DynamicPaintSurface *surface,
|
||||
}
|
||||
}
|
||||
|
||||
if (strength > 0.001f)
|
||||
{
|
||||
if (strength > 0.001f) {
|
||||
float paintColor[4] = {0.0f};
|
||||
float depth = 0.0f;
|
||||
|
||||
@ -3781,8 +3783,7 @@ static int dynamicPaint_paintSinglePoint(DynamicPaintSurface *surface, float *po
|
||||
* Loop through every surface point
|
||||
*/
|
||||
#pragma omp parallel for schedule(static)
|
||||
for (index = 0; index < sData->total_points; index++)
|
||||
{
|
||||
for (index = 0; index < sData->total_points; index++) {
|
||||
float distance = len_v3v3(pointCoord, bData->realCoord[bData->s_pos[index]].v);
|
||||
float colorband[4] = {0.0f};
|
||||
float strength;
|
||||
@ -3891,8 +3892,7 @@ static void dynamicPaint_prepareAdjacencyData(DynamicPaintSurface *surface, int
|
||||
if (!bNeighs) return;
|
||||
|
||||
#pragma omp parallel for schedule(static)
|
||||
for (index = 0; index < sData->total_points; index++)
|
||||
{
|
||||
for (index = 0; index < sData->total_points; index++) {
|
||||
int i;
|
||||
int numOfNeighs = adj_data->n_num[index];
|
||||
|
||||
@ -3911,8 +3911,7 @@ static void dynamicPaint_prepareAdjacencyData(DynamicPaintSurface *surface, int
|
||||
|
||||
/* calculate average values (single thread) */
|
||||
bData->average_dist = 0.0f;
|
||||
for (index = 0; index < sData->total_points; index++)
|
||||
{
|
||||
for (index = 0; index < sData->total_points; index++) {
|
||||
int i;
|
||||
int numOfNeighs = adj_data->n_num[index];
|
||||
|
||||
@ -4080,8 +4079,7 @@ static int dynamicPaint_prepareEffectStep(DynamicPaintSurface *surface, Scene *s
|
||||
|
||||
if (*force) {
|
||||
#pragma omp parallel for schedule(static)
|
||||
for (index = 0; index < sData->total_points; index++)
|
||||
{
|
||||
for (index = 0; index < sData->total_points; index++) {
|
||||
float forc[3] = {0};
|
||||
|
||||
/* apply force fields */
|
||||
@ -4121,8 +4119,7 @@ static int dynamicPaint_prepareEffectStep(DynamicPaintSurface *surface, Scene *s
|
||||
}
|
||||
|
||||
/* calculate average values (single thread) */
|
||||
for (index = 0; index < sData->total_points; index++)
|
||||
{
|
||||
for (index = 0; index < sData->total_points; index++) {
|
||||
average_force += (*force)[index*4+3];
|
||||
}
|
||||
average_force /= sData->total_points;
|
||||
@ -4171,8 +4168,7 @@ static void dynamicPaint_doEffectStep(DynamicPaintSurface *surface, float *force
|
||||
memcpy(prevPoint, sData->type_data, sData->total_points*sizeof(struct PaintPoint));
|
||||
|
||||
#pragma omp parallel for schedule(static)
|
||||
for (index = 0; index < sData->total_points; index++)
|
||||
{
|
||||
for (index = 0; index < sData->total_points; index++) {
|
||||
int i;
|
||||
int numOfNeighs = sData->adj_data->n_num[index];
|
||||
PaintPoint *pPoint = &((PaintPoint*)sData->type_data)[index];
|
||||
@ -4214,8 +4210,7 @@ static void dynamicPaint_doEffectStep(DynamicPaintSurface *surface, float *force
|
||||
memcpy(prevPoint, sData->type_data, sData->total_points*sizeof(struct PaintPoint));
|
||||
|
||||
#pragma omp parallel for schedule(static)
|
||||
for (index = 0; index < sData->total_points; index++)
|
||||
{
|
||||
for (index = 0; index < sData->total_points; index++) {
|
||||
int i;
|
||||
int numOfNeighs = sData->adj_data->n_num[index];
|
||||
float totalAlpha = 0.0f;
|
||||
@ -4256,8 +4251,7 @@ static void dynamicPaint_doEffectStep(DynamicPaintSurface *surface, float *force
|
||||
/*
|
||||
* Drip Effect
|
||||
*/
|
||||
if (surface->effect & MOD_DPAINT_EFFECT_DO_DRIP && force)
|
||||
{
|
||||
if (surface->effect & MOD_DPAINT_EFFECT_DO_DRIP && force) {
|
||||
float eff_scale = distance_scale*EFF_MOVEMENT_PER_FRAME*timescale/2.0f;
|
||||
/* Copy current surface to the previous points array to read unmodified values */
|
||||
memcpy(prevPoint, sData->type_data, sData->total_points*sizeof(struct PaintPoint));
|
||||
@ -4335,8 +4329,7 @@ void dynamicPaint_doWaveStep(DynamicPaintSurface *surface, float timescale)
|
||||
if (!prevPoint) return;
|
||||
|
||||
/* calculate average neigh distance (single thread) */
|
||||
for (index = 0; index < sData->total_points; index++)
|
||||
{
|
||||
for (index = 0; index < sData->total_points; index++) {
|
||||
int i;
|
||||
int numOfNeighs = sData->adj_data->n_num[index];
|
||||
|
||||
@ -4435,8 +4428,7 @@ static void dynamicPaint_surfacePreStep(DynamicPaintSurface *surface, float time
|
||||
int index;
|
||||
|
||||
#pragma omp parallel for schedule(static)
|
||||
for (index=0; index<sData->total_points; index++)
|
||||
{
|
||||
for (index=0; index<sData->total_points; index++) {
|
||||
/* Do drying dissolve effects */
|
||||
if (surface->type == MOD_DPAINT_SURFACE_T_PAINT) {
|
||||
PaintPoint *pPoint = &((PaintPoint*)sData->type_data)[index];
|
||||
@ -4651,8 +4643,7 @@ static int dynamicPaint_generateBakeData(DynamicPaintSurface *surface, Scene *sc
|
||||
* Prepare each surface point for a new step
|
||||
*/
|
||||
#pragma omp parallel for schedule(static)
|
||||
for (index=0; index<sData->total_points; index++)
|
||||
{
|
||||
for (index=0; index<sData->total_points; index++) {
|
||||
float prev_point[3] = {0.0f, 0.0f, 0.0f};
|
||||
if (do_velocity_data && !new_bdata) {
|
||||
copy_v3_v3(prev_point, bData->realCoord[bData->s_pos[index]].v);
|
||||
@ -4796,8 +4787,7 @@ static int dynamicPaint_doStep(Scene *scene, Object *ob, DynamicPaintSurface *su
|
||||
else
|
||||
base = scene->base.first;
|
||||
|
||||
while (base || go)
|
||||
{
|
||||
while (base || go) {
|
||||
brushObj = NULL;
|
||||
/* select object */
|
||||
if (surface->brush_group) {
|
||||
@ -4821,12 +4811,10 @@ static int dynamicPaint_doStep(Scene *scene, Object *ob, DynamicPaintSurface *su
|
||||
|
||||
/* check if target has an active dp modifier */
|
||||
md = modifiers_findByType(brushObj, eModifierType_DynamicPaint);
|
||||
if (md && md->mode & (eModifierMode_Realtime | eModifierMode_Render))
|
||||
{
|
||||
if (md && md->mode & (eModifierMode_Realtime | eModifierMode_Render)) {
|
||||
DynamicPaintModifierData *pmd2 = (DynamicPaintModifierData *)md;
|
||||
/* make sure we're dealing with a brush */
|
||||
if (pmd2->brush)
|
||||
{
|
||||
if (pmd2->brush) {
|
||||
DynamicPaintBrushSettings *brush = pmd2->brush;
|
||||
BrushMaterials bMats = {0};
|
||||
|
||||
|
@ -129,7 +129,7 @@ PartDeflect *object_add_collision_fields(int type)
|
||||
pd->f_damp = 1.0f;
|
||||
|
||||
/* set sensible defaults based on type */
|
||||
switch(type) {
|
||||
switch (type) {
|
||||
case PFIELD_VORTEX:
|
||||
pd->shape = PFIELD_SHAPE_PLANE;
|
||||
break;
|
||||
@ -419,8 +419,7 @@ static float eff_calc_visibility(ListBase *colliders, EffectorCache *eff, Effect
|
||||
len = normalize_v3(norm);
|
||||
|
||||
// check all collision objects
|
||||
for (col = colls->first; col; col = col->next)
|
||||
{
|
||||
for (col = colls->first; col; col = col->next) {
|
||||
CollisionModifierData *collmd = col->collmd;
|
||||
|
||||
if (col->ob == eff->ob)
|
||||
@ -506,7 +505,8 @@ float effector_falloff(EffectorCache *eff, EffectorData *efd, EffectedPoint *UNU
|
||||
falloff=0.0f;
|
||||
else if (eff->pd->zdir == PFIELD_Z_NEG && fac > 0.0f)
|
||||
falloff=0.0f;
|
||||
else switch(eff->pd->falloff) {
|
||||
else {
|
||||
switch (eff->pd->falloff) {
|
||||
case PFIELD_FALL_SPHERE:
|
||||
falloff*= falloff_func_dist(eff->pd, efd->distance);
|
||||
break;
|
||||
@ -529,6 +529,7 @@ float effector_falloff(EffectorCache *eff, EffectorData *efd, EffectedPoint *UNU
|
||||
falloff*= falloff_func_rad(eff->pd, r_fac);
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return falloff;
|
||||
@ -835,7 +836,7 @@ static void do_physical_effector(EffectorCache *eff, EffectorData *efd, Effected
|
||||
|
||||
copy_v3_v3(force, efd->vec_to_point);
|
||||
|
||||
switch(pd->forcefield) {
|
||||
switch (pd->forcefield) {
|
||||
case PFIELD_WIND:
|
||||
copy_v3_v3(force, efd->nor);
|
||||
mul_v3_fl(force, strength * efd->falloff);
|
||||
|
@ -1655,8 +1655,7 @@ static float evaluate_driver (ChannelDriver *driver, const float evaltime)
|
||||
{
|
||||
driver->curval= 0.0f;
|
||||
}
|
||||
else
|
||||
{
|
||||
else {
|
||||
/* this evaluates the expression using Python,and returns its result:
|
||||
* - on errors it reports, then returns 0.0f
|
||||
*/
|
||||
|
@ -318,8 +318,7 @@ static void fcm_fn_generator_evaluate (FCurve *UNUSED(fcu), FModifier *fcm, floa
|
||||
/* get function pointer to the func to use:
|
||||
* WARNING: must perform special argument validation hereto guard against crashes
|
||||
*/
|
||||
switch (data->type)
|
||||
{
|
||||
switch (data->type) {
|
||||
/* simple ones */
|
||||
case FCM_GENERATOR_FN_SIN: /* sine wave */
|
||||
fn= sin;
|
||||
|
@ -68,8 +68,7 @@ void free_vfont(struct VFont *vf)
|
||||
if (vf == NULL) return;
|
||||
|
||||
if (vf->data) {
|
||||
while (vf->data->characters.first)
|
||||
{
|
||||
while (vf->data->characters.first) {
|
||||
VChar *che = vf->data->characters.first;
|
||||
|
||||
while (che->nurbsbase.first) {
|
||||
@ -136,8 +135,7 @@ struct TmpFont *vfont_find_tmpfont(VFont *vfont)
|
||||
|
||||
// Try finding the font from font list
|
||||
tmpfnt = ttfdata.first;
|
||||
while (tmpfnt)
|
||||
{
|
||||
while (tmpfnt) {
|
||||
if (tmpfnt->vfont == vfont)
|
||||
break;
|
||||
tmpfnt = tmpfnt->next;
|
||||
@ -280,7 +278,7 @@ VFont *load_vfont(Main *bmain, const char *name)
|
||||
|
||||
static VFont *which_vfont(Curve *cu, CharInfo *info)
|
||||
{
|
||||
switch(info->flag & (CU_CHINFO_BOLD|CU_CHINFO_ITALIC)) {
|
||||
switch (info->flag & (CU_CHINFO_BOLD|CU_CHINFO_ITALIC)) {
|
||||
case CU_CHINFO_BOLD:
|
||||
if (cu->vfontb) return(cu->vfontb); else return(cu->vfont);
|
||||
case CU_CHINFO_ITALIC:
|
||||
@ -397,8 +395,7 @@ static void buildchar(Main *bmain, Curve *cu, unsigned long character, CharInfo
|
||||
nu1 = che->nurbsbase.first;
|
||||
|
||||
// Create the character
|
||||
while (nu1)
|
||||
{
|
||||
while (nu1) {
|
||||
bezt1 = nu1->bezt;
|
||||
if (bezt1) {
|
||||
nu2 =(Nurb*) MEM_mallocN(sizeof(Nurb),"duplichar_nurb");
|
||||
@ -822,10 +819,15 @@ struct chartrans *BKE_text_to_curve(Main *bmain, Scene *scene, Object *ob, int m
|
||||
}
|
||||
}
|
||||
else if ((cu->spacemode==CU_JUSTIFY) && (cu->tb[0].w != 0.0f)) {
|
||||
float curofs= 0.0f;
|
||||
for (i=0; i<=slen; i++) {
|
||||
for (j=i; (mem[j]) && (mem[j]!='\n') &&
|
||||
(mem[j]!='\r') && (chartransdata[j].dobreak==0) && (j<slen); j++);
|
||||
float curofs = 0.0f;
|
||||
for (i = 0; i <= slen; i++) {
|
||||
for (j=i; (mem[j]) && (mem[j]!='\n') &&
|
||||
(mem[j] != '\r') && (chartransdata[j].dobreak == 0) && (j < slen);
|
||||
j++)
|
||||
{
|
||||
/* pass */
|
||||
}
|
||||
|
||||
if ((mem[j]!='\r') && (mem[j]!='\n') &&
|
||||
((chartransdata[j].dobreak!=0))) {
|
||||
if (mem[i]==' ') curofs += (linedata3[ct->linenr]-linedata[ct->linenr])/linedata4[ct->linenr];
|
||||
@ -833,7 +835,7 @@ struct chartrans *BKE_text_to_curve(Main *bmain, Scene *scene, Object *ob, int m
|
||||
}
|
||||
if (mem[i]=='\n' || mem[i]=='\r' || chartransdata[i].dobreak) curofs= 0;
|
||||
ct++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -950,7 +952,7 @@ struct chartrans *BKE_text_to_curve(Main *bmain, Scene *scene, Object *ob, int m
|
||||
if ((mode==FO_CURSUP || mode==FO_PAGEUP) && ct->linenr==0);
|
||||
else if ((mode==FO_CURSDOWN || mode==FO_PAGEDOWN) && ct->linenr==lnr);
|
||||
else {
|
||||
switch(mode) {
|
||||
switch (mode) {
|
||||
case FO_CURSUP: lnr= ct->linenr-1; break;
|
||||
case FO_CURSDOWN: lnr= ct->linenr+1; break;
|
||||
case FO_PAGEUP: lnr= ct->linenr-10; break;
|
||||
|
@ -581,8 +581,7 @@ void IDP_FreeIterBeforeEnd(void *vself)
|
||||
static void IDP_FreeGroup(IDProperty *prop)
|
||||
{
|
||||
IDProperty *loop;
|
||||
for (loop=prop->data.group.first; loop; loop=loop->next)
|
||||
{
|
||||
for (loop=prop->data.group.first; loop; loop=loop->next) {
|
||||
IDP_FreeProperty(loop);
|
||||
}
|
||||
BLI_freelistN(&prop->data.group);
|
||||
|
@ -578,7 +578,7 @@ static ImBuf *add_ibuf_size(unsigned int width, unsigned int height, const char
|
||||
BLI_strncpy(ibuf->name, name, sizeof(ibuf->name));
|
||||
ibuf->userflags |= IB_BITMAPDIRTY;
|
||||
|
||||
switch(uvtestgrid) {
|
||||
switch (uvtestgrid) {
|
||||
case 1:
|
||||
BKE_image_buf_fill_checker(rect, rect_float, width, height);
|
||||
break;
|
||||
@ -929,7 +929,7 @@ char BKE_ftype_to_imtype(const int ftype)
|
||||
|
||||
int BKE_imtype_is_movie(const char imtype)
|
||||
{
|
||||
switch(imtype) {
|
||||
switch (imtype) {
|
||||
case R_IMF_IMTYPE_AVIRAW:
|
||||
case R_IMF_IMTYPE_AVIJPEG:
|
||||
case R_IMF_IMTYPE_AVICODEC:
|
||||
@ -946,7 +946,7 @@ int BKE_imtype_is_movie(const char imtype)
|
||||
|
||||
int BKE_imtype_supports_zbuf(const char imtype)
|
||||
{
|
||||
switch(imtype) {
|
||||
switch (imtype) {
|
||||
case R_IMF_IMTYPE_IRIZ:
|
||||
case R_IMF_IMTYPE_OPENEXR: /* but not R_IMF_IMTYPE_MULTILAYER */
|
||||
return 1;
|
||||
@ -956,7 +956,7 @@ int BKE_imtype_supports_zbuf(const char imtype)
|
||||
|
||||
int BKE_imtype_supports_compress(const char imtype)
|
||||
{
|
||||
switch(imtype) {
|
||||
switch (imtype) {
|
||||
case R_IMF_IMTYPE_PNG:
|
||||
return 1;
|
||||
}
|
||||
@ -965,7 +965,7 @@ int BKE_imtype_supports_compress(const char imtype)
|
||||
|
||||
int BKE_imtype_supports_quality(const char imtype)
|
||||
{
|
||||
switch(imtype) {
|
||||
switch (imtype) {
|
||||
case R_IMF_IMTYPE_JPEG90:
|
||||
case R_IMF_IMTYPE_JP2:
|
||||
case R_IMF_IMTYPE_AVIJPEG:
|
||||
@ -979,7 +979,7 @@ char BKE_imtype_valid_channels(const char imtype)
|
||||
char chan_flag= IMA_CHAN_FLAG_RGB; /* assume all support rgb */
|
||||
|
||||
/* alpha */
|
||||
switch(imtype) {
|
||||
switch (imtype) {
|
||||
case R_IMF_IMTYPE_TARGA:
|
||||
case R_IMF_IMTYPE_IRIS:
|
||||
case R_IMF_IMTYPE_PNG:
|
||||
@ -995,7 +995,7 @@ char BKE_imtype_valid_channels(const char imtype)
|
||||
}
|
||||
|
||||
/* bw */
|
||||
switch(imtype) {
|
||||
switch (imtype) {
|
||||
case R_IMF_IMTYPE_PNG:
|
||||
case R_IMF_IMTYPE_JPEG90:
|
||||
case R_IMF_IMTYPE_TARGA:
|
||||
@ -1110,8 +1110,11 @@ int BKE_add_image_extension(char *string, const char imtype)
|
||||
}
|
||||
#ifdef WITH_TIFF
|
||||
else if (imtype==R_IMF_IMTYPE_TIFF) {
|
||||
if (!BLI_testextensie(string, ".tif") &&
|
||||
!BLI_testextensie(string, ".tiff")) extension= ".tif";
|
||||
if (!BLI_testextensie(string, ".tif") &&
|
||||
!BLI_testextensie(string, ".tiff"))
|
||||
{
|
||||
extension= ".tif";
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#ifdef WITH_OPENEXR
|
||||
@ -1791,7 +1794,7 @@ void BKE_image_signal(Image *ima, ImageUser *iuser, int signal)
|
||||
if (ima==NULL)
|
||||
return;
|
||||
|
||||
switch(signal) {
|
||||
switch (signal) {
|
||||
case IMA_SIGNAL_FREE:
|
||||
image_free_buffers(ima);
|
||||
if (iuser)
|
||||
|
@ -169,12 +169,10 @@ static void checker_board_color_fill(unsigned char *rect, float *rect_float, int
|
||||
hue_step= power_of_2_max_i(width / 8);
|
||||
if (hue_step < 8) hue_step= 8;
|
||||
|
||||
for (y= 0; y < height; y++)
|
||||
{
|
||||
for (y= 0; y < height; y++) {
|
||||
|
||||
val= 0.1 + (y * (0.4 / height)); /* use a number lower then 1.0 else its too bright */
|
||||
for (x= 0; x < width; x++)
|
||||
{
|
||||
for (x= 0; x < width; x++) {
|
||||
hue= (float)((double)(x/hue_step) * 1.0 / width * hue_step);
|
||||
hsv_to_rgb(hue, sat, val, &r, &g, &b);
|
||||
|
||||
@ -291,12 +289,10 @@ static void checker_board_text(unsigned char *rect, float *rect_float, int width
|
||||
|
||||
BLF_buffer(mono, rect_float, rect, width, height, 4);
|
||||
|
||||
for (y= 0; y < height; y+=step)
|
||||
{
|
||||
for (y= 0; y < height; y+=step) {
|
||||
text[1]= '1';
|
||||
|
||||
for (x= 0; x < width; x+=step)
|
||||
{
|
||||
for (x= 0; x < width; x+=step) {
|
||||
/* hard coded offset */
|
||||
pen_x = x + 33;
|
||||
pen_y = y + 44;
|
||||
|
@ -178,8 +178,7 @@ static void print_fvector(float m3[3])
|
||||
DO_INLINE void print_lfvector(float (*fLongVector)[3], unsigned int verts)
|
||||
{
|
||||
unsigned int i = 0;
|
||||
for (i = 0; i < verts; i++)
|
||||
{
|
||||
for (i = 0; i < verts; i++) {
|
||||
print_fvector(fLongVector[i]);
|
||||
}
|
||||
}
|
||||
@ -193,8 +192,7 @@ DO_INLINE lfVector *create_lfvector(unsigned int verts)
|
||||
/* delete long vector */
|
||||
DO_INLINE void del_lfvector(float (*fLongVector)[3])
|
||||
{
|
||||
if (fLongVector != NULL)
|
||||
{
|
||||
if (fLongVector != NULL) {
|
||||
MEM_freeN (fLongVector);
|
||||
// cloth_aligned_free(&MEMORY_BASE, fLongVector);
|
||||
}
|
||||
@ -208,8 +206,7 @@ DO_INLINE void cp_lfvector(float (*to)[3], float (*from)[3], unsigned int verts)
|
||||
DO_INLINE void init_lfvector(float (*fLongVector)[3], float vector[3], unsigned int verts)
|
||||
{
|
||||
unsigned int i = 0;
|
||||
for (i = 0; i < verts; i++)
|
||||
{
|
||||
for (i = 0; i < verts; i++) {
|
||||
copy_v3_v3(fLongVector[i], vector);
|
||||
}
|
||||
}
|
||||
@ -223,8 +220,7 @@ DO_INLINE void mul_lfvectorS(float (*to)[3], float (*fLongVector)[3], float scal
|
||||
{
|
||||
unsigned int i = 0;
|
||||
|
||||
for (i = 0; i < verts; i++)
|
||||
{
|
||||
for (i = 0; i < verts; i++) {
|
||||
mul_fvector_S(to[i], fLongVector[i], scalar);
|
||||
}
|
||||
}
|
||||
@ -233,8 +229,7 @@ DO_INLINE void mul_lfvectorS(float (*to)[3], float (*fLongVector)[3], float scal
|
||||
DO_INLINE void submul_lfvectorS(float (*to)[3], float (*fLongVector)[3], float scalar, unsigned int verts)
|
||||
{
|
||||
unsigned int i = 0;
|
||||
for (i = 0; i < verts; i++)
|
||||
{
|
||||
for (i = 0; i < verts; i++) {
|
||||
VECSUBMUL(to[i], fLongVector[i], scalar);
|
||||
}
|
||||
}
|
||||
@ -258,8 +253,7 @@ DO_INLINE void add_lfvector_lfvector(float (*to)[3], float (*fLongVectorA)[3], f
|
||||
{
|
||||
unsigned int i = 0;
|
||||
|
||||
for (i = 0; i < verts; i++)
|
||||
{
|
||||
for (i = 0; i < verts; i++) {
|
||||
VECADD(to[i], fLongVectorA[i], fLongVectorB[i]);
|
||||
}
|
||||
|
||||
@ -269,8 +263,7 @@ DO_INLINE void add_lfvector_lfvectorS(float (*to)[3], float (*fLongVectorA)[3],
|
||||
{
|
||||
unsigned int i = 0;
|
||||
|
||||
for (i = 0; i < verts; i++)
|
||||
{
|
||||
for (i = 0; i < verts; i++) {
|
||||
VECADDS(to[i], fLongVectorA[i], fLongVectorB[i], bS);
|
||||
|
||||
}
|
||||
@ -280,8 +273,7 @@ DO_INLINE void add_lfvectorS_lfvectorS(float (*to)[3], float (*fLongVectorA)[3],
|
||||
{
|
||||
unsigned int i = 0;
|
||||
|
||||
for (i = 0; i < verts; i++)
|
||||
{
|
||||
for (i = 0; i < verts; i++) {
|
||||
VECADDSS(to[i], fLongVectorA[i], aS, fLongVectorB[i], bS);
|
||||
}
|
||||
}
|
||||
@ -289,8 +281,7 @@ DO_INLINE void add_lfvectorS_lfvectorS(float (*to)[3], float (*fLongVectorA)[3],
|
||||
DO_INLINE void sub_lfvector_lfvectorS(float (*to)[3], float (*fLongVectorA)[3], float (*fLongVectorB)[3], float bS, unsigned int verts)
|
||||
{
|
||||
unsigned int i = 0;
|
||||
for (i = 0; i < verts; i++)
|
||||
{
|
||||
for (i = 0; i < verts; i++) {
|
||||
VECSUBS(to[i], fLongVectorA[i], fLongVectorB[i], bS);
|
||||
}
|
||||
|
||||
@ -300,8 +291,7 @@ DO_INLINE void sub_lfvector_lfvector(float (*to)[3], float (*fLongVectorA)[3], f
|
||||
{
|
||||
unsigned int i = 0;
|
||||
|
||||
for (i = 0; i < verts; i++)
|
||||
{
|
||||
for (i = 0; i < verts; i++) {
|
||||
sub_v3_v3v3(to[i], fLongVectorA[i], fLongVectorB[i]);
|
||||
}
|
||||
|
||||
@ -350,15 +340,12 @@ DO_INLINE void inverse_fmatrix(float to[3][3], float from[3][3])
|
||||
unsigned int i, j;
|
||||
float d;
|
||||
|
||||
if ((d=det_fmatrix(from))==0)
|
||||
{
|
||||
if ((d=det_fmatrix(from)) == 0) {
|
||||
printf("can't build inverse");
|
||||
exit(0);
|
||||
}
|
||||
for (i=0;i<3;i++)
|
||||
{
|
||||
for (j=0;j<3;j++)
|
||||
{
|
||||
for (i=0;i<3;i++) {
|
||||
for (j=0;j<3;j++) {
|
||||
int i1=(i+1)%3;
|
||||
int i2=(i+2)%3;
|
||||
int j1=(j+1)%3;
|
||||
@ -535,8 +522,7 @@ DO_INLINE fmatrix3x3 *create_bfmatrix(unsigned int verts, unsigned int springs)
|
||||
/* delete big matrix */
|
||||
DO_INLINE void del_bfmatrix(fmatrix3x3 *matrix)
|
||||
{
|
||||
if (matrix != NULL)
|
||||
{
|
||||
if (matrix != NULL) {
|
||||
MEM_freeN (matrix);
|
||||
}
|
||||
}
|
||||
@ -554,8 +540,7 @@ DO_INLINE void init_bfmatrix(fmatrix3x3 *matrix, float m3[3][3])
|
||||
{
|
||||
unsigned int i;
|
||||
|
||||
for (i = 0; i < matrix[0].vcount+matrix[0].scount; i++)
|
||||
{
|
||||
for (i = 0; i < matrix[0].vcount+matrix[0].scount; i++) {
|
||||
cp_fmatrix(matrix[i].m, m3);
|
||||
}
|
||||
}
|
||||
@ -567,12 +552,10 @@ DO_INLINE void initdiag_bfmatrix(fmatrix3x3 *matrix, float m3[3][3])
|
||||
unsigned int i,j;
|
||||
float tmatrix[3][3] = {{0,0,0},{0,0,0},{0,0,0}};
|
||||
|
||||
for (i = 0; i < matrix[0].vcount; i++)
|
||||
{
|
||||
for (i = 0; i < matrix[0].vcount; i++) {
|
||||
cp_fmatrix(matrix[i].m, m3);
|
||||
}
|
||||
for (j = matrix[0].vcount; j < matrix[0].vcount+matrix[0].scount; j++)
|
||||
{
|
||||
for (j = matrix[0].vcount; j < matrix[0].vcount+matrix[0].scount; j++) {
|
||||
cp_fmatrix(matrix[j].m, tmatrix);
|
||||
}
|
||||
}
|
||||
@ -581,8 +564,7 @@ DO_INLINE void initdiag_bfmatrix(fmatrix3x3 *matrix, float m3[3][3])
|
||||
DO_INLINE void mul_bfmatrix_S(fmatrix3x3 *matrix, float scalar)
|
||||
{
|
||||
unsigned int i = 0;
|
||||
for (i = 0; i < matrix[0].vcount+matrix[0].scount; i++)
|
||||
{
|
||||
for (i = 0; i < matrix[0].vcount+matrix[0].scount; i++) {
|
||||
mul_fmatrix_S(matrix[i].m, scalar);
|
||||
}
|
||||
}
|
||||
@ -601,15 +583,13 @@ DO_INLINE void mul_bfmatrix_lfvector( float (*to)[3], fmatrix3x3 *from, lfVector
|
||||
{
|
||||
#pragma omp section
|
||||
{
|
||||
for (i = from[0].vcount; i < from[0].vcount+from[0].scount; i++)
|
||||
{
|
||||
for (i = from[0].vcount; i < from[0].vcount+from[0].scount; i++) {
|
||||
muladd_fmatrix_fvector(to[from[i].c], from[i].m, fLongVector[from[i].r]);
|
||||
}
|
||||
}
|
||||
#pragma omp section
|
||||
{
|
||||
for (i = 0; i < from[0].vcount+from[0].scount; i++)
|
||||
{
|
||||
for (i = 0; i < from[0].vcount+from[0].scount; i++) {
|
||||
muladd_fmatrix_fvector(temp[from[i].r], from[i].m, fLongVector[from[i].c]);
|
||||
}
|
||||
}
|
||||
@ -627,8 +607,7 @@ DO_INLINE void mul_prevfmatrix_lfvector( float (*to)[3], fmatrix3x3 *from, lfVec
|
||||
{
|
||||
unsigned int i = 0;
|
||||
|
||||
for (i = 0; i < from[0].vcount; i++)
|
||||
{
|
||||
for (i = 0; i < from[0].vcount; i++) {
|
||||
mul_fmatrix_fvector(to[from[i].r], from[i].m, fLongVector[from[i].c]);
|
||||
}
|
||||
}
|
||||
@ -639,8 +618,7 @@ DO_INLINE void add_bfmatrix_bfmatrix( fmatrix3x3 *to, fmatrix3x3 *from, fmatrix
|
||||
unsigned int i = 0;
|
||||
|
||||
/* process diagonal elements */
|
||||
for (i = 0; i < matrix[0].vcount+matrix[0].scount; i++)
|
||||
{
|
||||
for (i = 0; i < matrix[0].vcount+matrix[0].scount; i++) {
|
||||
add_fmatrix_fmatrix(to[i].m, from[i].m, matrix[i].m);
|
||||
}
|
||||
|
||||
@ -651,8 +629,7 @@ DO_INLINE void addadd_bfmatrix_bfmatrix( fmatrix3x3 *to, fmatrix3x3 *from, fmat
|
||||
unsigned int i = 0;
|
||||
|
||||
/* process diagonal elements */
|
||||
for (i = 0; i < matrix[0].vcount+matrix[0].scount; i++)
|
||||
{
|
||||
for (i = 0; i < matrix[0].vcount+matrix[0].scount; i++) {
|
||||
addadd_fmatrix_fmatrix(to[i].m, from[i].m, matrix[i].m);
|
||||
}
|
||||
|
||||
@ -663,8 +640,7 @@ DO_INLINE void subadd_bfmatrix_bfmatrix( fmatrix3x3 *to, fmatrix3x3 *from, fmat
|
||||
unsigned int i = 0;
|
||||
|
||||
/* process diagonal elements */
|
||||
for (i = 0; i < matrix[0].vcount+matrix[0].scount; i++)
|
||||
{
|
||||
for (i = 0; i < matrix[0].vcount+matrix[0].scount; i++) {
|
||||
subadd_fmatrix_fmatrix(to[i].m, from[i].m, matrix[i].m);
|
||||
}
|
||||
|
||||
@ -675,8 +651,7 @@ DO_INLINE void sub_bfmatrix_bfmatrix( fmatrix3x3 *to, fmatrix3x3 *from, fmatrix
|
||||
unsigned int i = 0;
|
||||
|
||||
/* process diagonal elements */
|
||||
for (i = 0; i < matrix[0].vcount+matrix[0].scount; i++)
|
||||
{
|
||||
for (i = 0; i < matrix[0].vcount+matrix[0].scount; i++) {
|
||||
sub_fmatrix_fmatrix(to[i].m, from[i].m, matrix[i].m);
|
||||
}
|
||||
|
||||
@ -687,8 +662,7 @@ DO_INLINE void sub_bfmatrix_Smatrix( fmatrix3x3 *to, fmatrix3x3 *from, fmatrix3
|
||||
unsigned int i = 0;
|
||||
|
||||
/* process diagonal elements */
|
||||
for (i = 0; i < matrix[0].vcount; i++)
|
||||
{
|
||||
for (i = 0; i < matrix[0].vcount; i++) {
|
||||
sub_fmatrix_fmatrix(to[matrix[i].c].m, from[matrix[i].c].m, matrix[i].m);
|
||||
}
|
||||
|
||||
@ -699,8 +673,7 @@ DO_INLINE void addsub_bfmatrix_bfmatrix( fmatrix3x3 *to, fmatrix3x3 *from, fmat
|
||||
unsigned int i = 0;
|
||||
|
||||
/* process diagonal elements */
|
||||
for (i = 0; i < matrix[0].vcount+matrix[0].scount; i++)
|
||||
{
|
||||
for (i = 0; i < matrix[0].vcount+matrix[0].scount; i++) {
|
||||
addsub_fmatrix_fmatrix(to[i].m, from[i].m, matrix[i].m);
|
||||
}
|
||||
|
||||
@ -713,8 +686,7 @@ DO_INLINE void subadd_bfmatrixS_bfmatrixS( fmatrix3x3 *to, fmatrix3x3 *from, flo
|
||||
unsigned int i = 0;
|
||||
|
||||
/* process diagonal elements */
|
||||
for (i = 0; i < matrix[0].vcount+matrix[0].scount; i++)
|
||||
{
|
||||
for (i = 0; i < matrix[0].vcount+matrix[0].scount; i++) {
|
||||
subadd_fmatrixS_fmatrixS(to[i].m, from[i].m, aS, matrix[i].m, bS);
|
||||
}
|
||||
|
||||
@ -772,12 +744,10 @@ int implicit_init (Object *UNUSED(ob), ClothModifierData *clmd)
|
||||
id->dV = create_lfvector(cloth->numverts);
|
||||
id->z = create_lfvector(cloth->numverts);
|
||||
|
||||
for (i=0;i<cloth->numverts;i++)
|
||||
{
|
||||
for (i=0;i<cloth->numverts;i++) {
|
||||
id->A[i].r = id->A[i].c = id->dFdV[i].r = id->dFdV[i].c = id->dFdX[i].r = id->dFdX[i].c = id->P[i].c = id->P[i].r = id->Pinv[i].c = id->Pinv[i].r = id->bigI[i].c = id->bigI[i].r = id->M[i].r = id->M[i].c = i;
|
||||
|
||||
if (verts [i].flags & CLOTH_VERT_FLAG_PINNED)
|
||||
{
|
||||
if (verts [i].flags & CLOTH_VERT_FLAG_PINNED) {
|
||||
id->S[pinned].pinned = 1;
|
||||
id->S[pinned].c = id->S[pinned].r = i;
|
||||
pinned++;
|
||||
@ -791,8 +761,7 @@ int implicit_init (Object *UNUSED(ob), ClothModifierData *clmd)
|
||||
|
||||
// init springs
|
||||
search = cloth->springs;
|
||||
for (i=0;i<cloth->numsprings;i++)
|
||||
{
|
||||
for (i=0;i<cloth->numsprings;i++) {
|
||||
spring = search->link;
|
||||
|
||||
// dFdV_start[i].r = big_I[i].r = big_zero[i].r =
|
||||
@ -810,8 +779,7 @@ int implicit_init (Object *UNUSED(ob), ClothModifierData *clmd)
|
||||
|
||||
initdiag_bfmatrix(id->bigI, I);
|
||||
|
||||
for (i = 0; i < cloth->numverts; i++)
|
||||
{
|
||||
for (i = 0; i < cloth->numverts; i++) {
|
||||
copy_v3_v3(id->X[i], verts[i].x);
|
||||
}
|
||||
|
||||
@ -823,12 +791,10 @@ int implicit_free (ClothModifierData *clmd)
|
||||
Cloth *cloth;
|
||||
cloth = (Cloth *)clmd->clothObject;
|
||||
|
||||
if (cloth)
|
||||
{
|
||||
if (cloth) {
|
||||
id = cloth->implicit;
|
||||
|
||||
if (id)
|
||||
{
|
||||
if (id) {
|
||||
del_bfmatrix(id->A);
|
||||
del_bfmatrix(id->dFdV);
|
||||
del_bfmatrix(id->dFdX);
|
||||
@ -886,12 +852,10 @@ DO_INLINE float fbstar_jacobi(float length, float L, float kb, float cb)
|
||||
float tempfb = kb * fb(length, L);
|
||||
float fbstar = cb * (length - L);
|
||||
|
||||
if (tempfb < fbstar)
|
||||
{
|
||||
if (tempfb < fbstar) {
|
||||
return cb;
|
||||
}
|
||||
else
|
||||
{
|
||||
else {
|
||||
return kb * fbderiv(length, L);
|
||||
}
|
||||
}
|
||||
@ -900,8 +864,7 @@ DO_INLINE void filter(lfVector *V, fmatrix3x3 *S)
|
||||
{
|
||||
unsigned int i=0;
|
||||
|
||||
for (i=0;i<S[0].vcount;i++)
|
||||
{
|
||||
for (i = 0; i < S[0].vcount; i++) {
|
||||
mul_fvector_fmatrix(V[S[i].r], V[S[i].r], S[i].m);
|
||||
}
|
||||
}
|
||||
@ -936,8 +899,7 @@ static int cg_filtered(lfVector *ldV, fmatrix3x3 *lA, lfVector *lB, lfVector *z
|
||||
s = dot_lfvector(r, r, numverts);
|
||||
starget = s * sqrt(conjgrad_epsilon);
|
||||
|
||||
while (s>starget && conjgrad_loopcount < conjgrad_looplimit)
|
||||
{
|
||||
while (s>starget && conjgrad_loopcount < conjgrad_looplimit) {
|
||||
// Mul(q,A,d); // q = A*d;
|
||||
mul_bfmatrix_lfvector(q, lA, d);
|
||||
|
||||
@ -979,8 +941,7 @@ DO_INLINE void BuildPPinv(fmatrix3x3 *lA, fmatrix3x3 *P, fmatrix3x3 *Pinv)
|
||||
|
||||
// Take only the diagonal blocks of A
|
||||
// #pragma omp parallel for private(i) if (lA[0].vcount > CLOTH_OPENMP_LIMIT)
|
||||
for (i = 0; i<lA[0].vcount; i++)
|
||||
{
|
||||
for (i = 0; i<lA[0].vcount; i++) {
|
||||
// block diagonalizer
|
||||
cp_fmatrix(P[i].m, lA[i].m);
|
||||
inverse_fmatrix(Pinv[i].m, P[i].m);
|
||||
@ -1255,8 +1216,7 @@ DO_INLINE void cloth_calc_spring_force(ClothModifierData *clmd, ClothSpring *s,
|
||||
|
||||
s->flags &= ~CLOTH_SPRING_FLAG_NEEDED;
|
||||
|
||||
if (length > ALMOST_ZERO)
|
||||
{
|
||||
if (length > ALMOST_ZERO) {
|
||||
/*
|
||||
if (length>L)
|
||||
{
|
||||
@ -1270,16 +1230,13 @@ DO_INLINE void cloth_calc_spring_force(ClothModifierData *clmd, ClothSpring *s,
|
||||
*/
|
||||
mul_fvector_S(dir, extent, 1.0f/length);
|
||||
}
|
||||
else
|
||||
{
|
||||
else {
|
||||
mul_fvector_S(dir, extent, 0.0f);
|
||||
}
|
||||
|
||||
// calculate force of structural + shear springs
|
||||
if ((s->type & CLOTH_SPRING_TYPE_STRUCTURAL) || (s->type & CLOTH_SPRING_TYPE_SHEAR))
|
||||
{
|
||||
if (length > L || no_compress)
|
||||
{
|
||||
if ((s->type & CLOTH_SPRING_TYPE_STRUCTURAL) || (s->type & CLOTH_SPRING_TYPE_SHEAR)) {
|
||||
if (length > L || no_compress) {
|
||||
s->flags |= CLOTH_SPRING_FLAG_NEEDED;
|
||||
|
||||
k = clmd->sim_parms->structural;
|
||||
@ -1337,10 +1294,8 @@ DO_INLINE void cloth_calc_spring_force(ClothModifierData *clmd, ClothSpring *s,
|
||||
// dfdx_spring(s->dfdx, dir, length, 0.0, k);
|
||||
// dfdv_damp(s->dfdv, dir, MIN2(1.0, (clmd->sim_parms->goalfrict/100.0)));
|
||||
}
|
||||
else // calculate force of bending springs
|
||||
{
|
||||
if (length < L)
|
||||
{
|
||||
else { /* calculate force of bending springs */
|
||||
if (length < L) {
|
||||
s->flags |= CLOTH_SPRING_FLAG_NEEDED;
|
||||
|
||||
k = clmd->sim_parms->bending;
|
||||
@ -1358,10 +1313,8 @@ DO_INLINE void cloth_calc_spring_force(ClothModifierData *clmd, ClothSpring *s,
|
||||
|
||||
DO_INLINE void cloth_apply_spring_force(ClothModifierData *UNUSED(clmd), ClothSpring *s, lfVector *lF, lfVector *UNUSED(X), lfVector *UNUSED(V), fmatrix3x3 *dFdV, fmatrix3x3 *dFdX)
|
||||
{
|
||||
if (s->flags & CLOTH_SPRING_FLAG_NEEDED)
|
||||
{
|
||||
if (!(s->type & CLOTH_SPRING_TYPE_BENDING))
|
||||
{
|
||||
if (s->flags & CLOTH_SPRING_FLAG_NEEDED) {
|
||||
if (!(s->type & CLOTH_SPRING_TYPE_BENDING)) {
|
||||
sub_fmatrix_fmatrix(dFdV[s->ij].m, dFdV[s->ij].m, s->dfdv);
|
||||
sub_fmatrix_fmatrix(dFdV[s->kl].m, dFdV[s->kl].m, s->dfdv);
|
||||
add_fmatrix_fmatrix(dFdV[s->matrix_index].m, dFdV[s->matrix_index].m, s->dfdv);
|
||||
@ -1486,8 +1439,7 @@ static void hair_velocity_smoothing(ClothModifierData *clmd, lfVector *lF, lfVec
|
||||
}
|
||||
|
||||
/* gather colliders */
|
||||
if (colliders && collfac > 0.0f) for (col = colliders->first; col; col = col->next)
|
||||
{
|
||||
if (colliders && collfac > 0.0f) for (col = colliders->first; col; col = col->next) {
|
||||
MVert *loc0 = col->collmd->x;
|
||||
MVert *loc1 = col->collmd->xnew;
|
||||
float vel[3];
|
||||
@ -1593,8 +1545,7 @@ static void cloth_calc_force(ClothModifierData *clmd, float UNUSED(frame), lfVec
|
||||
/* multiply lF with mass matrix
|
||||
* force = mass * acceleration (in this case: gravity)
|
||||
*/
|
||||
for (i = 0; i < numverts; i++)
|
||||
{
|
||||
for (i = 0; i < numverts; i++) {
|
||||
float temp[3];
|
||||
copy_v3_v3(temp, lF[i]);
|
||||
mul_fmatrix_fvector(lF[i], M[i].m, temp);
|
||||
@ -1603,8 +1554,7 @@ static void cloth_calc_force(ClothModifierData *clmd, float UNUSED(frame), lfVec
|
||||
submul_lfvectorS(lF, lV, spring_air, numverts);
|
||||
|
||||
/* handle external forces like wind */
|
||||
if (effectors)
|
||||
{
|
||||
if (effectors) {
|
||||
// 0 = force, 1 = normalized force
|
||||
winvec = create_lfvector(cloth->numverts);
|
||||
|
||||
@ -1612,14 +1562,12 @@ static void cloth_calc_force(ClothModifierData *clmd, float UNUSED(frame), lfVec
|
||||
printf("winvec: out of memory in implicit.c\n");
|
||||
|
||||
// precalculate wind forces
|
||||
for (i = 0; i < cloth->numverts; i++)
|
||||
{
|
||||
for (i = 0; i < cloth->numverts; i++) {
|
||||
pd_point_from_loc(clmd->scene, (float*)lX[i], (float*)lV[i], i, &epoint);
|
||||
pdDoEffectors(effectors, NULL, clmd->sim_parms->effector_weights, &epoint, winvec[i], NULL);
|
||||
}
|
||||
|
||||
for (i = 0; i < cloth->numfaces; i++)
|
||||
{
|
||||
for (i = 0; i < cloth->numfaces; i++) {
|
||||
float trinormal[3]={0,0,0}; // normalized triangle normal
|
||||
float triunnormal[3]={0,0,0}; // not-normalized-triangle normal
|
||||
float tmp[3]={0,0,0};
|
||||
@ -1650,8 +1598,7 @@ static void cloth_calc_force(ClothModifierData *clmd, float UNUSED(frame), lfVec
|
||||
VECADDS(lF[mfaces[i].v3], lF[mfaces[i].v3], tmp, factor);
|
||||
|
||||
// add wind from v4
|
||||
if (mfaces[i].v4)
|
||||
{
|
||||
if (mfaces[i].v4) {
|
||||
copy_v3_v3(tmp, trinormal);
|
||||
mul_v3_fl(tmp, calculateVertexWindForce(winvec[mfaces[i].v4], triunnormal));
|
||||
VECADDS(lF[mfaces[i].v4], lF[mfaces[i].v4], tmp, factor);
|
||||
@ -1692,8 +1639,7 @@ static void cloth_calc_force(ClothModifierData *clmd, float UNUSED(frame), lfVec
|
||||
|
||||
// calculate spring forces
|
||||
search = cloth->springs;
|
||||
while (search)
|
||||
{
|
||||
while (search) {
|
||||
// only handle active springs
|
||||
// if (((clmd->sim_parms->flags & CSIMSETT_FLAG_TEARING_ENABLED) && !(springs[i].flags & CSPRING_FLAG_DEACTIVATE))|| !(clmd->sim_parms->flags & CSIMSETT_FLAG_TEARING_ENABLED)) {}
|
||||
cloth_calc_spring_force(clmd, search->link, lF, lX, lV, dFdV, dFdX, time);
|
||||
@ -1703,8 +1649,7 @@ static void cloth_calc_force(ClothModifierData *clmd, float UNUSED(frame), lfVec
|
||||
|
||||
// apply spring forces
|
||||
search = cloth->springs;
|
||||
while (search)
|
||||
{
|
||||
while (search) {
|
||||
// only handle active springs
|
||||
// if (((clmd->sim_parms->flags & CSIMSETT_FLAG_TEARING_ENABLED) && !(springs[i].flags & CSPRING_FLAG_DEACTIVATE))|| !(clmd->sim_parms->flags & CSIMSETT_FLAG_TEARING_ENABLED))
|
||||
cloth_apply_spring_force(clmd, search->link, lF, lX, lV, dFdV, dFdX);
|
||||
@ -1836,21 +1781,17 @@ int implicit_solver (Object *ob, float frame, ClothModifierData *clmd, ListBase
|
||||
Implicit_Data *id = cloth->implicit;
|
||||
int do_extra_solve;
|
||||
|
||||
if (clmd->sim_parms->flags & CLOTH_SIMSETTINGS_FLAG_GOAL) /* do goal stuff */
|
||||
{
|
||||
for (i = 0; i < numverts; i++)
|
||||
{
|
||||
if (clmd->sim_parms->flags & CLOTH_SIMSETTINGS_FLAG_GOAL) { /* do goal stuff */
|
||||
for (i = 0; i < numverts; i++) {
|
||||
// update velocities with constrained velocities from pinned verts
|
||||
if (verts [i].flags & CLOTH_VERT_FLAG_PINNED)
|
||||
{
|
||||
if (verts [i].flags & CLOTH_VERT_FLAG_PINNED) {
|
||||
sub_v3_v3v3(id->V[i], verts[i].xconst, verts[i].xold);
|
||||
// mul_v3_fl(id->V[i], clmd->sim_parms->stepsPerFrame);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
while (step < tf)
|
||||
{
|
||||
while (step < tf) {
|
||||
// damping velocity for artistic reasons
|
||||
mul_lfvectorS(id->V, id->V, clmd->sim_parms->vel_damping, numverts);
|
||||
|
||||
@ -1864,13 +1805,10 @@ int implicit_solver (Object *ob, float frame, ClothModifierData *clmd, ListBase
|
||||
add_lfvector_lfvectorS(id->Xnew, id->X, id->Vnew, dt, numverts);
|
||||
|
||||
/* move pinned verts to correct position */
|
||||
for (i = 0; i < numverts; i++)
|
||||
{
|
||||
if (clmd->sim_parms->flags & CLOTH_SIMSETTINGS_FLAG_GOAL)
|
||||
{
|
||||
if (verts [i].flags & CLOTH_VERT_FLAG_PINNED)
|
||||
{
|
||||
float tvect[3] = {.0,.0,.0};
|
||||
for (i = 0; i < numverts; i++) {
|
||||
if (clmd->sim_parms->flags & CLOTH_SIMSETTINGS_FLAG_GOAL) {
|
||||
if (verts[i].flags & CLOTH_VERT_FLAG_PINNED) {
|
||||
float tvect[3] = {0.0f, 0.0f, 0.0f};
|
||||
sub_v3_v3v3(tvect, verts[i].xconst, verts[i].xold);
|
||||
mul_fvector_S(tvect, tvect, step+dt);
|
||||
VECADD(tvect, tvect, verts[i].xold);
|
||||
@ -1881,14 +1819,12 @@ int implicit_solver (Object *ob, float frame, ClothModifierData *clmd, ListBase
|
||||
copy_v3_v3(verts[i].txold, id->X[i]);
|
||||
}
|
||||
|
||||
if (clmd->coll_parms->flags & CLOTH_COLLSETTINGS_FLAG_ENABLED && clmd->clothObject->bvhtree)
|
||||
{
|
||||
if (clmd->coll_parms->flags & CLOTH_COLLSETTINGS_FLAG_ENABLED && clmd->clothObject->bvhtree) {
|
||||
// collisions
|
||||
// itstart();
|
||||
|
||||
// update verts to current positions
|
||||
for (i = 0; i < numverts; i++)
|
||||
{
|
||||
for (i = 0; i < numverts; i++) {
|
||||
copy_v3_v3(verts[i].tx, id->Xnew[i]);
|
||||
|
||||
sub_v3_v3v3(verts[i].tv, verts[i].tx, verts[i].txold);
|
||||
@ -1904,8 +1840,7 @@ int implicit_solver (Object *ob, float frame, ClothModifierData *clmd, ListBase
|
||||
do_extra_solve = cloth_bvh_objcollision(ob, clmd, step/clmd->sim_parms->timescale, dt/clmd->sim_parms->timescale);
|
||||
|
||||
// copy corrected positions back to simulation
|
||||
for (i = 0; i < numverts; i++)
|
||||
{
|
||||
for (i = 0; i < numverts; i++) {
|
||||
// correct velocity again, just to be sure we had to change it due to adaptive collisions
|
||||
sub_v3_v3v3(verts[i].tv, verts[i].tx, id->X[i]);
|
||||
}
|
||||
@ -1913,11 +1848,9 @@ int implicit_solver (Object *ob, float frame, ClothModifierData *clmd, ListBase
|
||||
//if (do_extra_solve)
|
||||
// cloth_calc_helper_forces(ob, clmd, initial_cos, step/clmd->sim_parms->timescale, dt/clmd->sim_parms->timescale);
|
||||
|
||||
for (i = 0; i < numverts; i++)
|
||||
{
|
||||
for (i = 0; i < numverts; i++) {
|
||||
|
||||
if (do_extra_solve)
|
||||
{
|
||||
if (do_extra_solve) {
|
||||
|
||||
if ((clmd->sim_parms->flags & CLOTH_SIMSETTINGS_FLAG_GOAL) && (verts [i].flags & CLOTH_VERT_FLAG_PINNED))
|
||||
continue;
|
||||
@ -1933,8 +1866,7 @@ int implicit_solver (Object *ob, float frame, ClothModifierData *clmd, ListBase
|
||||
|
||||
// if there were collisions, advance the velocity from v_n+1/2 to v_n+1
|
||||
|
||||
if (do_extra_solve)
|
||||
{
|
||||
if (do_extra_solve) {
|
||||
// V = Vnew;
|
||||
cp_lfvector(id->V, id->Vnew, numverts);
|
||||
|
||||
@ -1944,8 +1876,7 @@ int implicit_solver (Object *ob, float frame, ClothModifierData *clmd, ListBase
|
||||
simulate_implicit_euler(id->Vnew, id->X, id->V, id->F, id->dFdV, id->dFdX, dt / 2.0f, id->A, id->B, id->dV, id->S, id->z, id->olddV, id->P, id->Pinv, id->M, id->bigI);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
else {
|
||||
// X = Xnew;
|
||||
cp_lfvector(id->X, id->Xnew, numverts);
|
||||
}
|
||||
@ -1959,16 +1890,13 @@ int implicit_solver (Object *ob, float frame, ClothModifierData *clmd, ListBase
|
||||
step += dt;
|
||||
}
|
||||
|
||||
for (i = 0; i < numverts; i++)
|
||||
{
|
||||
if ((clmd->sim_parms->flags & CLOTH_SIMSETTINGS_FLAG_GOAL) && (verts [i].flags & CLOTH_VERT_FLAG_PINNED))
|
||||
{
|
||||
for (i = 0; i < numverts; i++) {
|
||||
if ((clmd->sim_parms->flags & CLOTH_SIMSETTINGS_FLAG_GOAL) && (verts [i].flags & CLOTH_VERT_FLAG_PINNED)) {
|
||||
copy_v3_v3(verts[i].txold, verts[i].xconst); // TODO: test --> should be .x
|
||||
copy_v3_v3(verts[i].x, verts[i].xconst);
|
||||
copy_v3_v3(verts[i].v, id->V[i]);
|
||||
}
|
||||
else
|
||||
{
|
||||
else {
|
||||
copy_v3_v3(verts[i].txold, id->X[i]);
|
||||
copy_v3_v3(verts[i].x, id->X[i]);
|
||||
copy_v3_v3(verts[i].v, id->V[i]);
|
||||
@ -1987,8 +1915,7 @@ void implicit_set_positions (ClothModifierData *clmd)
|
||||
unsigned int numverts = cloth->numverts, i;
|
||||
Implicit_Data *id = cloth->implicit;
|
||||
|
||||
for (i = 0; i < numverts; i++)
|
||||
{
|
||||
for (i = 0; i < numverts; i++) {
|
||||
copy_v3_v3(id->X[i], verts[i].x);
|
||||
copy_v3_v3(id->V[i], verts[i].v);
|
||||
}
|
||||
|
@ -182,7 +182,7 @@ int id_make_local(ID *id, int test)
|
||||
if (id->flag & LIB_INDIRECT)
|
||||
return 0;
|
||||
|
||||
switch(GS(id->name)) {
|
||||
switch (GS(id->name)) {
|
||||
case ID_SCE:
|
||||
return 0; /* not implemented */
|
||||
case ID_LI:
|
||||
@ -279,7 +279,7 @@ int id_copy(ID *id, ID **newid, int test)
|
||||
/* conventions:
|
||||
* - make shallow copy, only this ID block
|
||||
* - id.us of the new ID is set to 1 */
|
||||
switch(GS(id->name)) {
|
||||
switch (GS(id->name)) {
|
||||
case ID_SCE:
|
||||
return 0; /* can't be copied from here */
|
||||
case ID_LI:
|
||||
@ -368,7 +368,7 @@ int id_unlink(ID *id, int test)
|
||||
Main *mainlib= G.main;
|
||||
ListBase *lb;
|
||||
|
||||
switch(GS(id->name)) {
|
||||
switch (GS(id->name)) {
|
||||
case ID_TXT:
|
||||
if (test) return 1;
|
||||
unlink_text(mainlib, (Text*)id);
|
||||
@ -425,7 +425,7 @@ int id_single_user(bContext *C, ID *id, PointerRNA *ptr, PropertyRNA *prop)
|
||||
|
||||
ListBase *which_libbase(Main *mainlib, short type)
|
||||
{
|
||||
switch( type ) {
|
||||
switch ( type ) {
|
||||
case ID_SCE:
|
||||
return &(mainlib->scene);
|
||||
case ID_LI:
|
||||
@ -589,7 +589,7 @@ static ID *alloc_libblock_notest(short type)
|
||||
{
|
||||
ID *id= NULL;
|
||||
|
||||
switch( type ) {
|
||||
switch ( type ) {
|
||||
case ID_SCE:
|
||||
id= MEM_callocN(sizeof(Scene), "scene");
|
||||
break;
|
||||
@ -796,7 +796,7 @@ void free_libblock(ListBase *lb, void *idv)
|
||||
BPY_id_release(id);
|
||||
#endif
|
||||
|
||||
switch( GS(id->name) ) { /* GetShort from util.h */
|
||||
switch ( GS(id->name) ) { /* GetShort from util.h */
|
||||
case ID_SCE:
|
||||
free_scene((Scene *)id);
|
||||
break;
|
||||
@ -1010,8 +1010,7 @@ static void IDnames_to_dyn_pupstring(DynStr *pupds, ListBase *lb, ID *link, shor
|
||||
BLI_dynstr_append(pupds, numstr);
|
||||
|
||||
/* icon */
|
||||
switch(GS(id->name))
|
||||
{
|
||||
switch (GS(id->name)) {
|
||||
case ID_MA: /* fall through */
|
||||
case ID_TE: /* fall through */
|
||||
case ID_IM: /* fall through */
|
||||
|
@ -493,7 +493,7 @@ short *give_totcolp(Object *ob)
|
||||
/* same as above but for ID's */
|
||||
Material ***give_matarar_id(ID *id)
|
||||
{
|
||||
switch(GS(id->name)) {
|
||||
switch (GS(id->name)) {
|
||||
case ID_ME:
|
||||
return &(((Mesh *)id)->mat);
|
||||
break;
|
||||
@ -509,7 +509,7 @@ Material ***give_matarar_id(ID *id)
|
||||
|
||||
short *give_totcolp_id(ID *id)
|
||||
{
|
||||
switch(GS(id->name)) {
|
||||
switch (GS(id->name)) {
|
||||
case ID_ME:
|
||||
return &(((Mesh *)id)->totcol);
|
||||
break;
|
||||
@ -525,7 +525,7 @@ short *give_totcolp_id(ID *id)
|
||||
|
||||
static void data_delete_material_index_id(ID *id, short index)
|
||||
{
|
||||
switch(GS(id->name)) {
|
||||
switch (GS(id->name)) {
|
||||
case ID_ME:
|
||||
mesh_delete_material_index((Mesh *)id, index);
|
||||
break;
|
||||
|
@ -204,7 +204,7 @@ MetaElem *add_metaball_element(MetaBall *mb, const int type)
|
||||
ml->s= 2.0;
|
||||
ml->flag= MB_SCALE_RAD;
|
||||
|
||||
switch(type) {
|
||||
switch (type) {
|
||||
case MB_BALL:
|
||||
ml->type = MB_BALL;
|
||||
ml->expx= ml->expy= ml->expz= 1.0;
|
||||
@ -853,7 +853,7 @@ void docube(CUBE *cube, PROCESS *p, MetaBall *mb)
|
||||
count++;
|
||||
}
|
||||
if (count>2) {
|
||||
switch(count) {
|
||||
switch (count) {
|
||||
case 3:
|
||||
accum_mballfaces(indexar[2], indexar[1], indexar[0], 0);
|
||||
break;
|
||||
@ -1179,10 +1179,13 @@ int getedge (EDGELIST *table[],
|
||||
k2=t;
|
||||
}
|
||||
q = table[HASH(i1, j1, k1)+HASH(i2, j2, k2)];
|
||||
for (; q != NULL; q = q->next)
|
||||
for (; q != NULL; q = q->next) {
|
||||
if (q->i1 == i1 && q->j1 == j1 && q->k1 == k1 &&
|
||||
q->i2 == i2 && q->j2 == j2 && q->k2 == k2)
|
||||
{
|
||||
return q->vid;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -128,18 +128,22 @@ static int customdata_compare(CustomData *c1, CustomData *c2, Mesh *m1, Mesh *m2
|
||||
CustomDataLayer *l1, *l2;
|
||||
int i, i1=0, i2=0, tot, j;
|
||||
|
||||
for (i=0; i<c1->totlayer; i++) {
|
||||
if (ELEM7(c1->layers[i].type, CD_MVERT, CD_MEDGE, CD_MPOLY,
|
||||
CD_MLOOPUV, CD_MLOOPCOL, CD_MTEXPOLY, CD_MDEFORMVERT))
|
||||
for (i = 0; i < c1->totlayer; i++) {
|
||||
if (ELEM7(c1->layers[i].type, CD_MVERT, CD_MEDGE, CD_MPOLY,
|
||||
CD_MLOOPUV, CD_MLOOPCOL, CD_MTEXPOLY, CD_MDEFORMVERT))
|
||||
{
|
||||
i1++;
|
||||
}
|
||||
}
|
||||
|
||||
for (i=0; i<c2->totlayer; i++) {
|
||||
if (ELEM7(c2->layers[i].type, CD_MVERT, CD_MEDGE, CD_MPOLY,
|
||||
CD_MLOOPUV, CD_MLOOPCOL, CD_MTEXPOLY, CD_MDEFORMVERT))
|
||||
|
||||
for (i = 0; i < c2->totlayer; i++) {
|
||||
if (ELEM7(c2->layers[i].type, CD_MVERT, CD_MEDGE, CD_MPOLY,
|
||||
CD_MLOOPUV, CD_MLOOPCOL, CD_MTEXPOLY, CD_MDEFORMVERT))
|
||||
{
|
||||
i2++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (i1 != i2)
|
||||
return MESHCMP_CDLAYERS_MISMATCH;
|
||||
|
||||
@ -148,12 +152,16 @@ static int customdata_compare(CustomData *c1, CustomData *c2, Mesh *m1, Mesh *m2
|
||||
i1 = 0; i2 = 0;
|
||||
for (i=0; i < tot; i++) {
|
||||
while (i1 < c1->totlayer && !ELEM7(l1->type, CD_MVERT, CD_MEDGE, CD_MPOLY,
|
||||
CD_MLOOPUV, CD_MLOOPCOL, CD_MTEXPOLY, CD_MDEFORMVERT))
|
||||
CD_MLOOPUV, CD_MLOOPCOL, CD_MTEXPOLY, CD_MDEFORMVERT))
|
||||
{
|
||||
i1++, l1++;
|
||||
}
|
||||
|
||||
while (i2 < c2->totlayer && !ELEM7(l2->type, CD_MVERT, CD_MEDGE, CD_MPOLY,
|
||||
CD_MLOOPUV, CD_MLOOPCOL, CD_MTEXPOLY, CD_MDEFORMVERT))
|
||||
while (i2 < c2->totlayer && !ELEM7(l2->type, CD_MVERT, CD_MEDGE, CD_MPOLY,
|
||||
CD_MLOOPUV, CD_MLOOPCOL, CD_MTEXPOLY, CD_MDEFORMVERT))
|
||||
{
|
||||
i2++, l2++;
|
||||
}
|
||||
|
||||
if (l1->type == CD_MVERT) {
|
||||
MVert *v1 = l1->data;
|
||||
@ -3054,10 +3062,13 @@ void mesh_flush_hidden_from_verts(const MVert *mvert,
|
||||
for (i = 0; i < totedge; i++) {
|
||||
MEdge *e = &medge[i];
|
||||
if (mvert[e->v1].flag & ME_HIDE ||
|
||||
mvert[e->v2].flag & ME_HIDE)
|
||||
mvert[e->v2].flag & ME_HIDE)
|
||||
{
|
||||
e->flag |= ME_HIDE;
|
||||
else
|
||||
}
|
||||
else {
|
||||
e->flag &= ~ME_HIDE;
|
||||
}
|
||||
}
|
||||
for (i = 0; i < totpoly; i++) {
|
||||
MPoly *p = &mpoly[i];
|
||||
|
@ -517,7 +517,7 @@ static void real_ibuf_size(MovieClip *clip, MovieClipUser *user, ImBuf *ibuf, in
|
||||
*height = ibuf->y;
|
||||
|
||||
if (clip->flag & MCLIP_USE_PROXY) {
|
||||
switch(user->render_size) {
|
||||
switch (user->render_size) {
|
||||
case MCLIP_PROXY_RENDER_SIZE_25:
|
||||
(*width) *= 4;
|
||||
(*height) *= 4;
|
||||
|
@ -1017,7 +1017,7 @@ static void multiresModifier_disp_run(DerivedMesh *dm, Mesh *me, DerivedMesh *dm
|
||||
|
||||
column_vectors_to_mat3(mat, tx, ty, no);
|
||||
|
||||
switch(op) {
|
||||
switch (op) {
|
||||
case APPLY_DISPLACEMENTS:
|
||||
/* Convert displacement to object space
|
||||
* and add to grid points */
|
||||
|
@ -57,8 +57,7 @@ BLI_INLINE int left(const float* a, const float* b, const float* c)
|
||||
int polyNumVerts(const unsigned short* p, const int vertsPerPoly)
|
||||
{
|
||||
int i, nv = 0;
|
||||
for (i=0; i<vertsPerPoly; i++)
|
||||
{
|
||||
for (i=0; i<vertsPerPoly; i++) {
|
||||
if (p[i]==0xffff)
|
||||
break;
|
||||
nv++;
|
||||
@ -71,8 +70,7 @@ int polyIsConvex(const unsigned short* p, const int vertsPerPoly, const float* v
|
||||
int j, nv = polyNumVerts(p, vertsPerPoly);
|
||||
if (nv<3)
|
||||
return 0;
|
||||
for (j=0; j<nv; j++)
|
||||
{
|
||||
for (j=0; j<nv; j++) {
|
||||
const float* v = &verts[3*p[j]];
|
||||
const float* v_next = &verts[3*p[(j+1)%nv]];
|
||||
const float* v_prev = &verts[3*p[(nv+j-1)%nv]];
|
||||
@ -119,8 +117,7 @@ int buildRawVertIndicesData(DerivedMesh* dm, int *nverts_r, float **verts_r,
|
||||
MFace *faces;
|
||||
|
||||
nverts = dm->getNumVerts(dm);
|
||||
if (nverts>=0xffff)
|
||||
{
|
||||
if (nverts>=0xffff) {
|
||||
printf("Converting navmesh: Error! Too many vertices. Max number of vertices %d\n", 0xffff);
|
||||
return 0;
|
||||
}
|
||||
@ -128,8 +125,7 @@ int buildRawVertIndicesData(DerivedMesh* dm, int *nverts_r, float **verts_r,
|
||||
dm->getVertCos(dm, (float(*)[3])verts);
|
||||
|
||||
//flip coordinates
|
||||
for (vi=0; vi<nverts; vi++)
|
||||
{
|
||||
for (vi=0; vi<nverts; vi++) {
|
||||
SWAP(float, verts[3*vi+1], verts[3*vi+2]);
|
||||
}
|
||||
|
||||
@ -137,8 +133,7 @@ int buildRawVertIndicesData(DerivedMesh* dm, int *nverts_r, float **verts_r,
|
||||
nfaces = dm->getNumTessFaces(dm);
|
||||
faces = dm->getTessFaceArray(dm);
|
||||
ntris = nfaces;
|
||||
for (fi=0; fi<nfaces; fi++)
|
||||
{
|
||||
for (fi=0; fi<nfaces; fi++) {
|
||||
MFace* face = &faces[fi];
|
||||
if (face->v4)
|
||||
ntris++;
|
||||
@ -149,15 +144,13 @@ int buildRawVertIndicesData(DerivedMesh* dm, int *nverts_r, float **verts_r,
|
||||
tris = MEM_callocN(sizeof(unsigned short)*3*ntris, "buildRawVertIndicesData tris");
|
||||
tri = tris;
|
||||
triIdx = 0;
|
||||
for (fi=0; fi<nfaces; fi++)
|
||||
{
|
||||
for (fi=0; fi<nfaces; fi++) {
|
||||
MFace* face = &faces[fi];
|
||||
tri[3*triIdx+0] = (unsigned short) face->v1;
|
||||
tri[3*triIdx+1] = (unsigned short) face->v3;
|
||||
tri[3*triIdx+2] = (unsigned short) face->v2;
|
||||
trisToFacesMap[triIdx++]=fi;
|
||||
if (face->v4)
|
||||
{
|
||||
if (face->v4) {
|
||||
tri[3*triIdx+0] = (unsigned short) face->v1;
|
||||
tri[3*triIdx+1] = (unsigned short) face->v4;
|
||||
tri[3*triIdx+2] = (unsigned short) face->v3;
|
||||
@ -187,8 +180,7 @@ int buildPolygonsByDetailedMeshes(const int vertsPerPoly, const int npolys,
|
||||
unsigned short* newPoly = MEM_callocN(sizeof(unsigned short)*capacity, "buildPolygonsByDetailedMeshes newPoly");
|
||||
memset(newPoly, 0xff, sizeof(unsigned short)*capacity);
|
||||
|
||||
for (polyidx=0; polyidx<npolys; polyidx++)
|
||||
{
|
||||
for (polyidx=0; polyidx<npolys; polyidx++) {
|
||||
size_t i;
|
||||
int j, k;
|
||||
int nv = 0;
|
||||
@ -202,22 +194,18 @@ int buildPolygonsByDetailedMeshes(const int vertsPerPoly, const int npolys,
|
||||
int adjustedNv;
|
||||
int allBorderTraversed;
|
||||
|
||||
for (j=0; j<dtrisNum && btri==-1;j++)
|
||||
{
|
||||
for (j=0; j<dtrisNum && btri==-1;j++) {
|
||||
int curpolytri = dtrisBase+j;
|
||||
for (k=0; k<3; k++)
|
||||
{
|
||||
for (k=0; k<3; k++) {
|
||||
unsigned short neighbortri = dtris[curpolytri*3*2+3+k];
|
||||
if ( neighbortri==0xffff || dtrisToPolysMap[neighbortri]!=polyidx+1)
|
||||
{
|
||||
if ( neighbortri==0xffff || dtrisToPolysMap[neighbortri]!=polyidx+1) {
|
||||
btri = curpolytri;
|
||||
bedge = k;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (btri==-1 || bedge==-1)
|
||||
{
|
||||
if (btri==-1 || bedge==-1) {
|
||||
//can't find triangle with border edge
|
||||
MEM_freeN(traversedTris);
|
||||
MEM_freeN(newPoly);
|
||||
@ -229,13 +217,10 @@ int buildPolygonsByDetailedMeshes(const int vertsPerPoly, const int npolys,
|
||||
tri = btri;
|
||||
edge = (bedge+1)%3;
|
||||
traversedTris[tri-dtrisBase] = 1;
|
||||
while (tri!=btri || edge!=bedge)
|
||||
{
|
||||
while (tri != btri || edge != bedge) {
|
||||
int neighbortri = dtris[tri*3*2+3+edge];
|
||||
if (neighbortri==0xffff || dtrisToPolysMap[neighbortri]!=polyidx+1)
|
||||
{
|
||||
if (nv==capacity)
|
||||
{
|
||||
if (neighbortri==0xffff || dtrisToPolysMap[neighbortri]!=polyidx+1) {
|
||||
if (nv==capacity) {
|
||||
unsigned short* newPolyBig;
|
||||
capacity += vertsPerPoly;
|
||||
newPolyBig = MEM_callocN(sizeof(unsigned short)*capacity, "buildPolygonsByDetailedMeshes newPolyBig");
|
||||
@ -251,16 +236,13 @@ int buildPolygonsByDetailedMeshes(const int vertsPerPoly, const int npolys,
|
||||
else {
|
||||
//move to next tri
|
||||
int twinedge = -1;
|
||||
for (k=0; k<3; k++)
|
||||
{
|
||||
if (dtris[neighbortri*3*2+3+k] == tri)
|
||||
{
|
||||
for (k=0; k<3; k++) {
|
||||
if (dtris[neighbortri*3*2+3+k] == tri) {
|
||||
twinedge = k;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (twinedge==-1)
|
||||
{
|
||||
if (twinedge==-1) {
|
||||
printf("Converting navmesh: Error! Can't find neighbor edge - invalid adjacency info\n");
|
||||
MEM_freeN(traversedTris);
|
||||
goto returnLabel;
|
||||
@ -273,8 +255,7 @@ int buildPolygonsByDetailedMeshes(const int vertsPerPoly, const int npolys,
|
||||
|
||||
adjustedPoly = MEM_callocN(sizeof(unsigned short)*nv, "buildPolygonsByDetailedMeshes adjustedPoly");
|
||||
adjustedNv = 0;
|
||||
for (i=0; i<nv; i++)
|
||||
{
|
||||
for (i=0; i<nv; i++) {
|
||||
unsigned short prev = newPoly[(nv+i-1)%nv];
|
||||
unsigned short cur = newPoly[i];
|
||||
unsigned short next = newPoly[(i+1)%nv];
|
||||
@ -288,17 +269,13 @@ int buildPolygonsByDetailedMeshes(const int vertsPerPoly, const int npolys,
|
||||
nv = adjustedNv;
|
||||
|
||||
allBorderTraversed = 1;
|
||||
for (i=0; i<dtrisNum; i++)
|
||||
{
|
||||
if (traversedTris[i]==0)
|
||||
{
|
||||
for (i=0; i<dtrisNum; i++) {
|
||||
if (traversedTris[i]==0) {
|
||||
//check whether it has border edges
|
||||
int curpolytri = dtrisBase+i;
|
||||
for (k=0; k<3; k++)
|
||||
{
|
||||
for (k=0; k<3; k++) {
|
||||
unsigned short neighbortri = dtris[curpolytri*3*2+3+k];
|
||||
if ( neighbortri==0xffff || dtrisToPolysMap[neighbortri]!=polyidx+1)
|
||||
{
|
||||
if ( neighbortri==0xffff || dtrisToPolysMap[neighbortri]!=polyidx+1) {
|
||||
allBorderTraversed = 0;
|
||||
break;
|
||||
}
|
||||
@ -306,10 +283,8 @@ int buildPolygonsByDetailedMeshes(const int vertsPerPoly, const int npolys,
|
||||
}
|
||||
}
|
||||
|
||||
if (nv<=vertsPerPoly && allBorderTraversed)
|
||||
{
|
||||
for (i=0; i<nv; i++)
|
||||
{
|
||||
if (nv<=vertsPerPoly && allBorderTraversed) {
|
||||
for (i=0; i<nv; i++) {
|
||||
polys[polyidx*vertsPerPoly*2+i] = newPoly[i];
|
||||
}
|
||||
}
|
||||
@ -353,8 +328,7 @@ int buildNavMeshData(const int nverts, const float* verts,
|
||||
unsigned short *dtris, *dmeshes, *polys;
|
||||
int *dtrisToPolysMap, *dtrisToTrisMap;
|
||||
|
||||
if (!recastData)
|
||||
{
|
||||
if (!recastData) {
|
||||
printf("Converting navmesh: Error! Can't find recast custom data\n");
|
||||
return 0;
|
||||
}
|
||||
@ -370,17 +344,14 @@ int buildNavMeshData(const int nverts, const float* verts,
|
||||
|
||||
//search first valid triangle - triangle of convex polygon
|
||||
validTriStart = -1;
|
||||
for (i=0; i< ntris; i++)
|
||||
{
|
||||
if (recastData[trisToFacesMap[trisMapping[i]]]>0)
|
||||
{
|
||||
for (i=0; i< ntris; i++) {
|
||||
if (recastData[trisToFacesMap[trisMapping[i]]]>0) {
|
||||
validTriStart = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (validTriStart<0)
|
||||
{
|
||||
if (validTriStart<0) {
|
||||
printf("Converting navmesh: Error! No valid polygons in mesh\n");
|
||||
MEM_freeN(trisMapping);
|
||||
return 0;
|
||||
@ -396,8 +367,7 @@ int buildNavMeshData(const int nverts, const float* verts,
|
||||
//and reserve memory for adjacency info
|
||||
dtris = MEM_callocN(sizeof(unsigned short)*3*2*ndtris, "buildNavMeshData dtris");
|
||||
memset(dtris, 0xffff, sizeof(unsigned short)*3*2*ndtris);
|
||||
for (i=0; i<ndtris; i++)
|
||||
{
|
||||
for (i=0; i<ndtris; i++) {
|
||||
memcpy(dtris+3*2*i, tris+3*dtrisToTrisMap[i], sizeof(unsigned short)*3);
|
||||
}
|
||||
|
||||
@ -405,11 +375,9 @@ int buildNavMeshData(const int nverts, const float* verts,
|
||||
prevPolyIdx = -1;
|
||||
newPolyIdx = 0;
|
||||
dtrisToPolysMap = MEM_callocN(sizeof(int)*ndtris, "buildNavMeshData dtrisToPolysMap");
|
||||
for (i=0; i<ndtris; i++)
|
||||
{
|
||||
for (i=0; i<ndtris; i++) {
|
||||
curPolyIdx = recastData[trisToFacesMap[dtrisToTrisMap[i]]];
|
||||
if (curPolyIdx!=prevPolyIdx)
|
||||
{
|
||||
if (curPolyIdx!=prevPolyIdx) {
|
||||
newPolyIdx++;
|
||||
prevPolyIdx=curPolyIdx;
|
||||
}
|
||||
@ -426,13 +394,10 @@ int buildNavMeshData(const int nverts, const float* verts,
|
||||
memset(dmeshes, 0, npolys*4*sizeof(unsigned short));
|
||||
dmesh = NULL;
|
||||
prevpolyidx = 0;
|
||||
for (i=0; i<ndtris; i++)
|
||||
{
|
||||
for (i=0; i<ndtris; i++) {
|
||||
int curpolyidx = dtrisToPolysMap[i];
|
||||
if (curpolyidx!=prevpolyidx)
|
||||
{
|
||||
if (curpolyidx!=prevpolyidx+1)
|
||||
{
|
||||
if (curpolyidx!=prevpolyidx) {
|
||||
if (curpolyidx!=prevpolyidx+1) {
|
||||
printf("Converting navmesh: Error! Wrong order of detailed mesh faces\n");
|
||||
return 0;
|
||||
}
|
||||
@ -476,8 +441,7 @@ int buildNavMeshDataByDerivedMesh(DerivedMesh *dm, int *vertsPerPoly,
|
||||
unsigned short *tris=NULL;
|
||||
|
||||
res = buildRawVertIndicesData(dm, nverts, verts, &ntris, &tris, trisToFacesMap, &recastData);
|
||||
if (!res)
|
||||
{
|
||||
if (!res) {
|
||||
printf("Converting navmesh: Error! Can't get vertices and indices from mesh\n");
|
||||
goto exit;
|
||||
}
|
||||
@ -485,8 +449,7 @@ int buildNavMeshDataByDerivedMesh(DerivedMesh *dm, int *vertsPerPoly,
|
||||
res = buildNavMeshData(*nverts, *verts, ntris, tris, recastData, *trisToFacesMap,
|
||||
ndtris, dtris, npolys, dmeshes,polys, vertsPerPoly,
|
||||
dtrisToPolysMap, dtrisToTrisMap);
|
||||
if (!res)
|
||||
{
|
||||
if (!res) {
|
||||
printf("Converting navmesh: Error! Can't get vertices and indices from mesh\n");
|
||||
goto exit;
|
||||
}
|
||||
@ -501,12 +464,10 @@ exit:
|
||||
int polyFindVertex(const unsigned short* p, const int vertsPerPoly, unsigned short vertexIdx)
|
||||
{
|
||||
int i, res = -1;
|
||||
for (i=0; i<vertsPerPoly; i++)
|
||||
{
|
||||
for (i=0; i<vertsPerPoly; i++) {
|
||||
if (p[i]==0xffff)
|
||||
break;
|
||||
if (p[i]==vertexIdx)
|
||||
{
|
||||
if (p[i] == vertexIdx) {
|
||||
res = i;
|
||||
break;
|
||||
}
|
||||
|
@ -357,7 +357,7 @@ NlaStrip *add_nla_soundstrip (Scene *scene, Speaker *speaker)
|
||||
|
||||
strip->end = (float)ceil((double)info.length * FPS);
|
||||
}
|
||||
else
|
||||
else
|
||||
#endif
|
||||
{
|
||||
strip->end = 10.0f;
|
||||
@ -373,7 +373,7 @@ NlaStrip *add_nla_soundstrip (Scene *scene, Speaker *speaker)
|
||||
strip->extendmode = NLASTRIP_EXTEND_NOTHING; /* nothing to extend... */
|
||||
|
||||
/* strip should be referenced as-is */
|
||||
strip->scale= 1.0f;
|
||||
strip->scale = 1.0f;
|
||||
strip->repeat = 1.0f;
|
||||
|
||||
/* return this strip */
|
||||
|
@ -1483,7 +1483,7 @@ void object_rot_to_mat3(Object *ob, float mat[][3])
|
||||
|
||||
void object_mat3_to_rot(Object *ob, float mat[][3], short use_compat)
|
||||
{
|
||||
switch(ob->rotmode) {
|
||||
switch (ob->rotmode) {
|
||||
case ROT_MODE_QUAT:
|
||||
{
|
||||
float dquat[4];
|
||||
@ -2025,7 +2025,7 @@ static void solve_parenting (Scene *scene, Object *ob, Object *par, float obmat[
|
||||
|
||||
if (ob->partype & PARSLOW) copy_m4_m4(slowmat, obmat);
|
||||
|
||||
switch(ob->partype & PARTYPE) {
|
||||
switch (ob->partype & PARTYPE) {
|
||||
case PAROBJECT:
|
||||
ok= 0;
|
||||
if (par->type==OB_CURVE) {
|
||||
@ -2260,7 +2260,7 @@ void minmax_object(Object *ob, float min[3], float max[3])
|
||||
int a;
|
||||
short change= FALSE;
|
||||
|
||||
switch(ob->type) {
|
||||
switch (ob->type) {
|
||||
case OB_CURVE:
|
||||
case OB_FONT:
|
||||
case OB_SURF:
|
||||
@ -2568,7 +2568,7 @@ void object_handle_update(Scene *scene, Object *ob)
|
||||
}
|
||||
|
||||
/* includes all keys and modifiers */
|
||||
switch(ob->type) {
|
||||
switch (ob->type) {
|
||||
case OB_MESH:
|
||||
{
|
||||
#if 0 // XXX, comment for 2.56a release, background wont set 'scene->customdata_mask'
|
||||
@ -2784,8 +2784,7 @@ int ray_hit_boundbox(struct BoundBox *bb, float ray_start[3], float ray_normal[3
|
||||
int result = 0;
|
||||
int i;
|
||||
|
||||
for (i = 0; i < 12 && result == 0; i++)
|
||||
{
|
||||
for (i = 0; i < 12 && result == 0; i++) {
|
||||
float lambda;
|
||||
int v1, v2, v3;
|
||||
v1 = triangle_indexes[i][0];
|
||||
@ -2812,8 +2811,7 @@ 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)
|
||||
|
@ -196,15 +196,13 @@ static float Ph(struct Ocean* o, float kx,float kz )
|
||||
float tmp;
|
||||
float k2 = kx*kx + kz*kz;
|
||||
|
||||
if (k2 == 0.0f)
|
||||
{
|
||||
if (k2 == 0.0f) {
|
||||
return 0.0f; // no DC component
|
||||
}
|
||||
|
||||
// damp out the waves going in the direction opposite the wind
|
||||
tmp = (o->_wx * kx + o->_wz * kz)/sqrtf(k2);
|
||||
if (tmp < 0)
|
||||
{
|
||||
if (tmp < 0) {
|
||||
tmp *= o->_damp_reflections;
|
||||
}
|
||||
|
||||
@ -421,18 +419,15 @@ void BKE_ocean_eval_uv_catrom(struct Ocean *oc, struct OceanResult *ocr, float u
|
||||
frac_z)
|
||||
|
||||
{
|
||||
if (oc->_do_disp_y)
|
||||
{
|
||||
if (oc->_do_disp_y) {
|
||||
ocr->disp[1] = INTERP(oc->_disp_y);
|
||||
}
|
||||
if (oc->_do_normals)
|
||||
{
|
||||
if (oc->_do_normals) {
|
||||
ocr->normal[0] = INTERP(oc->_N_x);
|
||||
ocr->normal[1] = oc->_N_y/*INTERP(oc->_N_y) (MEM01)*/;
|
||||
ocr->normal[2] = INTERP(oc->_N_z);
|
||||
}
|
||||
if (oc->_do_chop)
|
||||
{
|
||||
if (oc->_do_chop) {
|
||||
ocr->disp[0] = INTERP(oc->_disp_x);
|
||||
ocr->disp[2] = INTERP(oc->_disp_z);
|
||||
}
|
||||
@ -441,8 +436,7 @@ void BKE_ocean_eval_uv_catrom(struct Ocean *oc, struct OceanResult *ocr, float u
|
||||
ocr->disp[2] = 0.0;
|
||||
}
|
||||
|
||||
if (oc->_do_jacobian)
|
||||
{
|
||||
if (oc->_do_jacobian) {
|
||||
compute_eigenstuff(ocr, INTERP(oc->_Jxx),INTERP(oc->_Jzz),INTERP(oc->_Jxz));
|
||||
}
|
||||
}
|
||||
@ -474,8 +468,7 @@ void BKE_ocean_eval_ij(struct Ocean *oc, struct OceanResult *ocr, int i,int j)
|
||||
|
||||
ocr->disp[1] = oc->_do_disp_y ? oc->_disp_y[i*oc->_N+j] : 0.0f;
|
||||
|
||||
if (oc->_do_chop)
|
||||
{
|
||||
if (oc->_do_chop) {
|
||||
ocr->disp[0] = oc->_disp_x[i*oc->_N+j];
|
||||
ocr->disp[2] = oc->_disp_z[i*oc->_N+j];
|
||||
}
|
||||
@ -484,8 +477,7 @@ void BKE_ocean_eval_ij(struct Ocean *oc, struct OceanResult *ocr, int i,int j)
|
||||
ocr->disp[2] = 0.0f;
|
||||
}
|
||||
|
||||
if (oc->_do_normals)
|
||||
{
|
||||
if (oc->_do_normals) {
|
||||
ocr->normal[0] = oc->_N_x[i*oc->_N+j];
|
||||
ocr->normal[1] = oc->_N_y/*oc->_N_y[i*oc->_N+j] (MEM01)*/;
|
||||
ocr->normal[2] = oc->_N_z[i*oc->_N+j];
|
||||
@ -493,8 +485,7 @@ void BKE_ocean_eval_ij(struct Ocean *oc, struct OceanResult *ocr, int i,int j)
|
||||
normalize_v3(ocr->normal);
|
||||
}
|
||||
|
||||
if (oc->_do_jacobian)
|
||||
{
|
||||
if (oc->_do_jacobian) {
|
||||
compute_eigenstuff(ocr, oc->_Jxx[i*oc->_N+j],oc->_Jzz[i*oc->_N+j],oc->_Jxz[i*oc->_N+j]);
|
||||
}
|
||||
|
||||
@ -511,12 +502,10 @@ void BKE_simulate_ocean(struct Ocean *o, float t, float scale, float chop_amount
|
||||
|
||||
// compute a new htilda
|
||||
#pragma omp parallel for private(i, j)
|
||||
for (i = 0 ; i < o->_M ; ++i)
|
||||
{
|
||||
for (i = 0 ; i < o->_M ; ++i) {
|
||||
// note the <= _N/2 here, see the fftw doco about
|
||||
// the mechanics of the complex->real fft storage
|
||||
for ( j = 0 ; j <= o->_N / 2 ; ++j)
|
||||
{
|
||||
for ( j = 0 ; j <= o->_N / 2 ; ++j) {
|
||||
fftw_complex exp_param1;
|
||||
fftw_complex exp_param2;
|
||||
fftw_complex conj_param;
|
||||
@ -541,8 +530,7 @@ void BKE_simulate_ocean(struct Ocean *o, float t, float scale, float chop_amount
|
||||
|
||||
#pragma omp section
|
||||
{
|
||||
if (o->_do_disp_y)
|
||||
{
|
||||
if (o->_do_disp_y) {
|
||||
// y displacement
|
||||
fftw_execute(o->_disp_y_plan);
|
||||
}
|
||||
@ -550,13 +538,10 @@ void BKE_simulate_ocean(struct Ocean *o, float t, float scale, float chop_amount
|
||||
|
||||
#pragma omp section
|
||||
{
|
||||
if (o->_do_chop)
|
||||
{
|
||||
if (o->_do_chop) {
|
||||
// x displacement
|
||||
for ( i = 0 ; i < o->_M ; ++i)
|
||||
{
|
||||
for ( j = 0 ; j <= o->_N / 2 ; ++j)
|
||||
{
|
||||
for ( i = 0 ; i < o->_M ; ++i) {
|
||||
for ( j = 0 ; j <= o->_N / 2 ; ++j) {
|
||||
fftw_complex mul_param;
|
||||
fftw_complex minus_i;
|
||||
|
||||
@ -575,13 +560,10 @@ void BKE_simulate_ocean(struct Ocean *o, float t, float scale, float chop_amount
|
||||
|
||||
#pragma omp section
|
||||
{
|
||||
if (o->_do_chop)
|
||||
{
|
||||
if (o->_do_chop) {
|
||||
// z displacement
|
||||
for ( i = 0 ; i < o->_M ; ++i)
|
||||
{
|
||||
for ( j = 0 ; j <= o->_N / 2 ; ++j)
|
||||
{
|
||||
for ( i = 0 ; i < o->_M ; ++i) {
|
||||
for ( j = 0 ; j <= o->_N / 2 ; ++j) {
|
||||
fftw_complex mul_param;
|
||||
fftw_complex minus_i;
|
||||
|
||||
@ -600,13 +582,10 @@ void BKE_simulate_ocean(struct Ocean *o, float t, float scale, float chop_amount
|
||||
|
||||
#pragma omp section
|
||||
{
|
||||
if (o->_do_jacobian)
|
||||
{
|
||||
if (o->_do_jacobian) {
|
||||
// Jxx
|
||||
for ( i = 0 ; i < o->_M ; ++i)
|
||||
{
|
||||
for ( j = 0 ; j <= o->_N / 2 ; ++j)
|
||||
{
|
||||
for ( i = 0 ; i < o->_M ; ++i) {
|
||||
for ( j = 0 ; j <= o->_N / 2 ; ++j) {
|
||||
fftw_complex mul_param;
|
||||
|
||||
//init_complex(mul_param, -scale, 0);
|
||||
@ -620,10 +599,8 @@ void BKE_simulate_ocean(struct Ocean *o, float t, float scale, float chop_amount
|
||||
}
|
||||
fftw_execute(o->_Jxx_plan);
|
||||
|
||||
for ( i = 0 ; i < o->_M ; ++i)
|
||||
{
|
||||
for ( j = 0 ; j < o->_N ; ++j)
|
||||
{
|
||||
for ( i = 0 ; i < o->_M ; ++i) {
|
||||
for ( j = 0 ; j < o->_N ; ++j) {
|
||||
o->_Jxx[i*o->_N+j] += 1.0;
|
||||
}
|
||||
}
|
||||
@ -632,13 +609,10 @@ void BKE_simulate_ocean(struct Ocean *o, float t, float scale, float chop_amount
|
||||
|
||||
#pragma omp section
|
||||
{
|
||||
if (o->_do_jacobian)
|
||||
{
|
||||
if (o->_do_jacobian) {
|
||||
// Jzz
|
||||
for ( i = 0 ; i < o->_M ; ++i)
|
||||
{
|
||||
for ( j = 0 ; j <= o->_N / 2 ; ++j)
|
||||
{
|
||||
for ( i = 0 ; i < o->_M ; ++i) {
|
||||
for ( j = 0 ; j <= o->_N / 2 ; ++j) {
|
||||
fftw_complex mul_param;
|
||||
|
||||
//init_complex(mul_param, -scale, 0);
|
||||
@ -651,10 +625,8 @@ void BKE_simulate_ocean(struct Ocean *o, float t, float scale, float chop_amount
|
||||
}
|
||||
}
|
||||
fftw_execute(o->_Jzz_plan);
|
||||
for ( i = 0 ; i < o->_M ; ++i)
|
||||
{
|
||||
for ( j = 0 ; j < o->_N ; ++j)
|
||||
{
|
||||
for ( i = 0 ; i < o->_M ; ++i) {
|
||||
for ( j = 0 ; j < o->_N ; ++j) {
|
||||
o->_Jzz[i*o->_N+j] += 1.0;
|
||||
}
|
||||
}
|
||||
@ -663,13 +635,10 @@ void BKE_simulate_ocean(struct Ocean *o, float t, float scale, float chop_amount
|
||||
|
||||
#pragma omp section
|
||||
{
|
||||
if (o->_do_jacobian)
|
||||
{
|
||||
if (o->_do_jacobian) {
|
||||
// Jxz
|
||||
for ( i = 0 ; i < o->_M ; ++i)
|
||||
{
|
||||
for ( j = 0 ; j <= o->_N / 2 ; ++j)
|
||||
{
|
||||
for ( i = 0 ; i < o->_M ; ++i) {
|
||||
for ( j = 0 ; j <= o->_N / 2 ; ++j) {
|
||||
fftw_complex mul_param;
|
||||
|
||||
//init_complex(mul_param, -scale, 0);
|
||||
@ -688,12 +657,9 @@ void BKE_simulate_ocean(struct Ocean *o, float t, float scale, float chop_amount
|
||||
#pragma omp section
|
||||
{
|
||||
// fft normals
|
||||
if (o->_do_normals)
|
||||
{
|
||||
for ( i = 0 ; i < o->_M ; ++i)
|
||||
{
|
||||
for ( j = 0 ; j <= o->_N / 2 ; ++j)
|
||||
{
|
||||
if (o->_do_normals) {
|
||||
for ( i = 0 ; i < o->_M ; ++i) {
|
||||
for ( j = 0 ; j <= o->_N / 2 ; ++j) {
|
||||
fftw_complex mul_param;
|
||||
|
||||
init_complex(mul_param, 0.0, -1.0);
|
||||
@ -709,12 +675,9 @@ void BKE_simulate_ocean(struct Ocean *o, float t, float scale, float chop_amount
|
||||
|
||||
#pragma omp section
|
||||
{
|
||||
if (o->_do_normals)
|
||||
{
|
||||
for ( i = 0 ; i < o->_M ; ++i)
|
||||
{
|
||||
for ( j = 0 ; j <= o->_N / 2 ; ++j)
|
||||
{
|
||||
if (o->_do_normals) {
|
||||
for ( i = 0 ; i < o->_M ; ++i) {
|
||||
for ( j = 0 ; j <= o->_N / 2 ; ++j) {
|
||||
fftw_complex mul_param;
|
||||
|
||||
init_complex(mul_param, 0.0, -1.0);
|
||||
@ -757,12 +720,9 @@ static void set_height_normalize_factor(struct Ocean *oc)
|
||||
|
||||
BLI_rw_mutex_lock(&oc->oceanmutex, THREAD_LOCK_READ);
|
||||
|
||||
for (i = 0; i < oc->_M; ++i)
|
||||
{
|
||||
for (j = 0; j < oc->_N; ++j)
|
||||
{
|
||||
if ( max_h < fabsf(oc->_disp_y[i*oc->_N+j]))
|
||||
{
|
||||
for (i = 0; i < oc->_M; ++i) {
|
||||
for (j = 0; j < oc->_N; ++j) {
|
||||
if ( max_h < fabsf(oc->_disp_y[i*oc->_N+j])) {
|
||||
max_h = fabsf(oc->_disp_y[i*oc->_N+j]);
|
||||
}
|
||||
}
|
||||
@ -851,10 +811,8 @@ void BKE_init_ocean(struct Ocean* o, int M,int N, float Lx, float Lz, float V, f
|
||||
/*srand(seed);*/
|
||||
BLI_srand(seed);
|
||||
|
||||
for (i = 0 ; i < o->_M ; ++i)
|
||||
{
|
||||
for (j = 0 ; j < o->_N ; ++j)
|
||||
{
|
||||
for (i = 0 ; i < o->_M ; ++i) {
|
||||
for (j = 0 ; j < o->_N ; ++j) {
|
||||
float r1 = gaussRand();
|
||||
float r2 = gaussRand();
|
||||
|
||||
@ -921,14 +879,12 @@ void BKE_free_ocean_data(struct Ocean *oc)
|
||||
|
||||
BLI_rw_mutex_lock(&oc->oceanmutex, THREAD_LOCK_WRITE);
|
||||
|
||||
if (oc->_do_disp_y)
|
||||
{
|
||||
if (oc->_do_disp_y) {
|
||||
fftw_destroy_plan(oc->_disp_y_plan);
|
||||
MEM_freeN(oc->_disp_y);
|
||||
}
|
||||
|
||||
if (oc->_do_normals)
|
||||
{
|
||||
if (oc->_do_normals) {
|
||||
MEM_freeN(oc->_fft_in_nx);
|
||||
MEM_freeN(oc->_fft_in_nz);
|
||||
fftw_destroy_plan(oc->_N_x_plan);
|
||||
@ -938,8 +894,7 @@ void BKE_free_ocean_data(struct Ocean *oc)
|
||||
MEM_freeN(oc->_N_z);
|
||||
}
|
||||
|
||||
if (oc->_do_chop)
|
||||
{
|
||||
if (oc->_do_chop) {
|
||||
MEM_freeN(oc->_fft_in_x);
|
||||
MEM_freeN(oc->_fft_in_z);
|
||||
fftw_destroy_plan(oc->_disp_x_plan);
|
||||
@ -948,8 +903,7 @@ void BKE_free_ocean_data(struct Ocean *oc)
|
||||
MEM_freeN(oc->_disp_z);
|
||||
}
|
||||
|
||||
if (oc->_do_jacobian)
|
||||
{
|
||||
if (oc->_do_jacobian) {
|
||||
MEM_freeN(oc->_fft_in_jxx);
|
||||
MEM_freeN(oc->_fft_in_jzz);
|
||||
MEM_freeN(oc->_fft_in_jxz);
|
||||
@ -1002,7 +956,7 @@ static void cache_filename(char *string, const char *path, const char *relbase,
|
||||
char cachepath[FILE_MAX];
|
||||
const char *fname;
|
||||
|
||||
switch(type) {
|
||||
switch (type) {
|
||||
case CACHE_TYPE_FOAM:
|
||||
fname= "foam_";
|
||||
break;
|
||||
@ -1043,8 +997,7 @@ void BKE_free_ocean_cache(struct OceanCache *och)
|
||||
if (!och) return;
|
||||
|
||||
if (och->ibufs_disp) {
|
||||
for (i=och->start, f=0; i<=och->end; i++, f++)
|
||||
{
|
||||
for (i=och->start, f=0; i<=och->end; i++, f++) {
|
||||
if (och->ibufs_disp[f]) {
|
||||
IMB_freeImBuf(och->ibufs_disp[f]);
|
||||
}
|
||||
@ -1053,8 +1006,7 @@ void BKE_free_ocean_cache(struct OceanCache *och)
|
||||
}
|
||||
|
||||
if (och->ibufs_foam) {
|
||||
for (i=och->start, f=0; i<=och->end; i++, f++)
|
||||
{
|
||||
for (i=och->start, f=0; i<=och->end; i++, f++) {
|
||||
if (och->ibufs_foam[f]) {
|
||||
IMB_freeImBuf(och->ibufs_foam[f]);
|
||||
}
|
||||
@ -1063,8 +1015,7 @@ void BKE_free_ocean_cache(struct OceanCache *och)
|
||||
}
|
||||
|
||||
if (och->ibufs_norm) {
|
||||
for (i=och->start, f=0; i<=och->end; i++, f++)
|
||||
{
|
||||
for (i=och->start, f=0; i<=och->end; i++, f++) {
|
||||
if (och->ibufs_norm[f]) {
|
||||
IMB_freeImBuf(och->ibufs_norm[f]);
|
||||
}
|
||||
|
@ -72,7 +72,7 @@ int seekPackedFile(PackedFile *pf, int offset, int whence)
|
||||
|
||||
if (pf) {
|
||||
oldseek = pf->seek;
|
||||
switch(whence) {
|
||||
switch (whence) {
|
||||
case SEEK_CUR:
|
||||
seek = oldseek + offset;
|
||||
break;
|
||||
|
@ -59,7 +59,7 @@ Paint *paint_get_active(Scene *sce)
|
||||
ToolSettings *ts = sce->toolsettings;
|
||||
|
||||
if (sce->basact && sce->basact->object) {
|
||||
switch(sce->basact->object->mode) {
|
||||
switch (sce->basact->object->mode) {
|
||||
case OB_MODE_SCULPT:
|
||||
return &ts->sculpt->paint;
|
||||
case OB_MODE_VERTEX_PAINT:
|
||||
|
@ -1572,7 +1572,7 @@ static float psys_interpolate_value_from_verts(DerivedMesh *dm, short from, int
|
||||
if (values==0 || index==-1)
|
||||
return 0.0;
|
||||
|
||||
switch(from) {
|
||||
switch (from) {
|
||||
case PART_FROM_VERT:
|
||||
return values[index];
|
||||
case PART_FROM_FACE:
|
||||
@ -1936,7 +1936,7 @@ static void do_kink(ParticleKey *state, ParticleKey *par, float *par_rot, float
|
||||
copy_v3_v3(result, state->co);
|
||||
sub_v3_v3v3(par_vec, par->co, state->co);
|
||||
|
||||
switch(type) {
|
||||
switch (type) {
|
||||
case PART_KINK_CURL:
|
||||
{
|
||||
negate_v3(par_vec);
|
||||
@ -2846,7 +2846,7 @@ static void cache_key_incremental_rotation(ParticleCacheKey *key0, ParticleCache
|
||||
{
|
||||
float cosangle, angle, tangent[3], normal[3], q[4];
|
||||
|
||||
switch(i) {
|
||||
switch (i) {
|
||||
case 0:
|
||||
/* start from second key */
|
||||
break;
|
||||
@ -3778,7 +3778,7 @@ static void get_cpa_texture(DerivedMesh *dm, ParticleSystem *psys, ParticleSetti
|
||||
if (ELEM(texco, TEXCO_UV, TEXCO_ORCO) && (ELEM(part->from, PART_FROM_FACE, PART_FROM_VOLUME) == 0 || part->distr == PART_DISTR_GRID))
|
||||
texco = TEXCO_GLOB;
|
||||
|
||||
switch(texco) {
|
||||
switch (texco) {
|
||||
case TEXCO_GLOB:
|
||||
copy_v3_v3(texvec, par->state.co);
|
||||
break;
|
||||
@ -3846,7 +3846,7 @@ void psys_get_texture(ParticleSimulationData *sim, ParticleData *pa, ParticleTex
|
||||
if (texco == TEXCO_UV && (ELEM(part->from, PART_FROM_FACE, PART_FROM_VOLUME) == 0 || part->distr == PART_DISTR_GRID))
|
||||
texco = TEXCO_GLOB;
|
||||
|
||||
switch(texco) {
|
||||
switch (texco) {
|
||||
case TEXCO_GLOB:
|
||||
copy_v3_v3(texvec, pa->state.co);
|
||||
break;
|
||||
|
@ -787,7 +787,7 @@ static void distribute_threads_exec(ParticleThread *thread, ParticleData *pa, Ch
|
||||
pa->num = i = ctx->index[p];
|
||||
mface = dm->getTessFaceData(dm,i,CD_MFACE);
|
||||
|
||||
switch(distr) {
|
||||
switch (distr) {
|
||||
case PART_DISTR_JIT:
|
||||
if (ctx->jitlevel == 1) {
|
||||
if (mface->v4)
|
||||
@ -855,13 +855,15 @@ static void distribute_threads_exec(ParticleThread *thread, ParticleData *pa, Ch
|
||||
}
|
||||
if (intersect==0)
|
||||
pa->foffset=0.0;
|
||||
else switch(distr) {
|
||||
case PART_DISTR_JIT:
|
||||
pa->foffset*= ctx->jit[p%(2*ctx->jitlevel)];
|
||||
break;
|
||||
case PART_DISTR_RAND:
|
||||
pa->foffset*=BLI_frand();
|
||||
break;
|
||||
else {
|
||||
switch (distr) {
|
||||
case PART_DISTR_JIT:
|
||||
pa->foffset *= ctx->jit[p % (2 * ctx->jitlevel)];
|
||||
break;
|
||||
case PART_DISTR_RAND:
|
||||
pa->foffset *= BLI_frand();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1575,7 +1577,7 @@ static void initialize_all_particles(ParticleSimulationData *sim)
|
||||
|
||||
static void get_angular_velocity_vector(short avemode, ParticleKey *state, float *vec)
|
||||
{
|
||||
switch(avemode) {
|
||||
switch (avemode) {
|
||||
case PART_AVE_VELOCITY:
|
||||
copy_v3_v3(vec, state->vel);
|
||||
break;
|
||||
@ -1779,7 +1781,7 @@ void psys_get_birth_coordinates(ParticleSimulationData *sim, ParticleData *pa, P
|
||||
|
||||
if (part->rotmode) {
|
||||
/* create vector into which rotation is aligned */
|
||||
switch(part->rotmode) {
|
||||
switch (part->rotmode) {
|
||||
case PART_ROT_NOR:
|
||||
copy_v3_v3(rot_vec, nor);
|
||||
break;
|
||||
@ -2141,7 +2143,7 @@ static void integrate_particle(ParticleSettings *part, ParticleData *pa, float d
|
||||
if (pa->prev_state.time < 0.f && integrator == PART_INT_VERLET)
|
||||
integrator = PART_INT_EULER;
|
||||
|
||||
switch(integrator) {
|
||||
switch (integrator) {
|
||||
case PART_INT_EULER:
|
||||
steps=1;
|
||||
break;
|
||||
@ -2175,7 +2177,7 @@ static void integrate_particle(ParticleSettings *part, ParticleData *pa, float d
|
||||
/* calculate next state */
|
||||
add_v3_v3(states[i].vel, impulse);
|
||||
|
||||
switch(integrator) {
|
||||
switch (integrator) {
|
||||
case PART_INT_EULER:
|
||||
madd_v3_v3v3fl(pa->state.co, states->co, states->vel, dtime);
|
||||
madd_v3_v3v3fl(pa->state.vel, states->vel, acceleration, dtime);
|
||||
@ -2193,7 +2195,7 @@ static void integrate_particle(ParticleSettings *part, ParticleData *pa, float d
|
||||
}
|
||||
break;
|
||||
case PART_INT_RK4:
|
||||
switch(i) {
|
||||
switch (i) {
|
||||
case 0:
|
||||
copy_v3_v3(dx[0], states->vel);
|
||||
mul_v3_fl(dx[0], dtime);
|
||||
@ -2859,7 +2861,7 @@ static float collision_point_distance_with_normal(float p[3], ParticleCollisionE
|
||||
if (fac >= 0.f)
|
||||
collision_interpolate_element(pce, 0.f, fac, col);
|
||||
|
||||
switch(pce->tot) {
|
||||
switch (pce->tot) {
|
||||
case 1:
|
||||
{
|
||||
sub_v3_v3v3(nor, p, pce->x0);
|
||||
@ -2884,7 +2886,7 @@ static void collision_point_on_surface(float p[3], ParticleCollisionElement *pce
|
||||
{
|
||||
collision_interpolate_element(pce, 0.f, fac, col);
|
||||
|
||||
switch(pce->tot) {
|
||||
switch (pce->tot) {
|
||||
case 1:
|
||||
{
|
||||
sub_v3_v3v3(co, p, pce->x0);
|
||||
@ -3833,7 +3835,7 @@ static void dynamics_step(ParticleSimulationData *sim, float cfra)
|
||||
sim->colliders = get_collider_cache(sim->scene, sim->ob, NULL);
|
||||
|
||||
/* initialize physics type specific stuff */
|
||||
switch(part->phystype) {
|
||||
switch (part->phystype) {
|
||||
case PART_PHYS_BOIDS:
|
||||
{
|
||||
ParticleTarget *pt = psys->targets.first;
|
||||
@ -3908,7 +3910,7 @@ static void dynamics_step(ParticleSimulationData *sim, float cfra)
|
||||
pa->state.time = -1.f;
|
||||
}
|
||||
|
||||
switch(part->phystype) {
|
||||
switch (part->phystype) {
|
||||
case PART_PHYS_NEWTON:
|
||||
{
|
||||
LOOP_DYNAMIC_PARTICLES {
|
||||
@ -4499,7 +4501,7 @@ void particle_system_update(Scene *scene, Object *ob, ParticleSystem *psys)
|
||||
/* setup necessary physics type dependent additional data if it doesn't yet exist */
|
||||
psys_prepare_physics(&sim);
|
||||
|
||||
switch(part->type) {
|
||||
switch (part->type) {
|
||||
case PART_HAIR:
|
||||
{
|
||||
/* nothing to do so bail out early */
|
||||
@ -4551,7 +4553,7 @@ void particle_system_update(Scene *scene, Object *ob, ParticleSystem *psys)
|
||||
}
|
||||
default:
|
||||
{
|
||||
switch(part->phystype) {
|
||||
switch (part->phystype) {
|
||||
case PART_PHYS_NO:
|
||||
case PART_PHYS_KEYED:
|
||||
{
|
||||
|
@ -433,7 +433,7 @@ static void ptcache_particle_extra_read(void *psys_v, PTCacheMem *pm, float UNUS
|
||||
PTCacheExtra *extra = pm->extradata.first;
|
||||
|
||||
for (; extra; extra=extra->next) {
|
||||
switch(extra->type) {
|
||||
switch (extra->type) {
|
||||
case BPHYS_EXTRA_FLUID_SPRINGS:
|
||||
{
|
||||
if (psys->fluid_springs)
|
||||
@ -690,14 +690,20 @@ static int ptcache_dynamicpaint_write(PTCacheFile *pf, void *dp_v)
|
||||
/* cache type */
|
||||
ptcache_file_write(pf, &surface->type, 1, sizeof(int));
|
||||
|
||||
if (surface->type == MOD_DPAINT_SURFACE_T_PAINT)
|
||||
in_len = sizeof(PaintPoint)*total_points;
|
||||
if (surface->type == MOD_DPAINT_SURFACE_T_PAINT) {
|
||||
in_len = sizeof(PaintPoint) * total_points;
|
||||
}
|
||||
else if (surface->type == MOD_DPAINT_SURFACE_T_DISPLACE ||
|
||||
surface->type == MOD_DPAINT_SURFACE_T_WEIGHT)
|
||||
in_len = sizeof(float)*total_points;
|
||||
else if (surface->type == MOD_DPAINT_SURFACE_T_WAVE)
|
||||
in_len = sizeof(PaintWavePoint)*total_points;
|
||||
else return 0;
|
||||
surface->type == MOD_DPAINT_SURFACE_T_WEIGHT)
|
||||
{
|
||||
in_len = sizeof(float) * total_points;
|
||||
}
|
||||
else if (surface->type == MOD_DPAINT_SURFACE_T_WAVE) {
|
||||
in_len = sizeof(PaintWavePoint) * total_points;
|
||||
}
|
||||
else {
|
||||
return 0;
|
||||
}
|
||||
|
||||
out = (unsigned char *)MEM_callocN(LZO_OUT_LEN(in_len), "pointcache_lzo_buffer");
|
||||
|
||||
@ -727,14 +733,20 @@ static int ptcache_dynamicpaint_read(PTCacheFile *pf, void *dp_v)
|
||||
return 0;
|
||||
|
||||
/* read surface data */
|
||||
if (surface->type == MOD_DPAINT_SURFACE_T_PAINT)
|
||||
if (surface->type == MOD_DPAINT_SURFACE_T_PAINT) {
|
||||
data_len = sizeof(PaintPoint);
|
||||
}
|
||||
else if (surface->type == MOD_DPAINT_SURFACE_T_DISPLACE ||
|
||||
surface->type == MOD_DPAINT_SURFACE_T_WEIGHT)
|
||||
surface->type == MOD_DPAINT_SURFACE_T_WEIGHT)
|
||||
{
|
||||
data_len = sizeof(float);
|
||||
else if (surface->type == MOD_DPAINT_SURFACE_T_WAVE)
|
||||
}
|
||||
else if (surface->type == MOD_DPAINT_SURFACE_T_WAVE) {
|
||||
data_len = sizeof(PaintWavePoint);
|
||||
else return 0;
|
||||
}
|
||||
else {
|
||||
return 0;
|
||||
}
|
||||
|
||||
ptcache_file_compressed_read(pf, (unsigned char*)surface->data->type_data, data_len*surface->data->total_points);
|
||||
|
||||
@ -989,8 +1001,7 @@ void BKE_ptcache_ids_from_object(ListBase *lb, Object *ob, Scene *scene, int dup
|
||||
}
|
||||
else if (md->type == eModifierType_Smoke) {
|
||||
SmokeModifierData *smd = (SmokeModifierData *)md;
|
||||
if (smd->type & MOD_SMOKE_TYPE_DOMAIN)
|
||||
{
|
||||
if (smd->type & MOD_SMOKE_TYPE_DOMAIN) {
|
||||
pid= MEM_callocN(sizeof(PTCacheID), "PTCacheID");
|
||||
BKE_ptcache_id_from_smoke(pid, ob, (SmokeModifierData*)md);
|
||||
BLI_addtail(lb, pid);
|
||||
@ -998,8 +1009,7 @@ void BKE_ptcache_ids_from_object(ListBase *lb, Object *ob, Scene *scene, int dup
|
||||
}
|
||||
else if (md->type == eModifierType_DynamicPaint) {
|
||||
DynamicPaintModifierData *pmd = (DynamicPaintModifierData *)md;
|
||||
if (pmd->canvas)
|
||||
{
|
||||
if (pmd->canvas) {
|
||||
DynamicPaintSurface *surface = pmd->canvas->surfaces.first;
|
||||
|
||||
for (; surface; surface=surface->next) {
|
||||
@ -1205,8 +1215,7 @@ static int ptcache_file_compressed_read(PTCacheFile *pf, unsigned char *result,
|
||||
r = lzo1x_decompress_safe(in, (lzo_uint)in_len, result, (lzo_uint *)&out_len, NULL);
|
||||
#endif
|
||||
#ifdef WITH_LZMA
|
||||
if (compressed == 2)
|
||||
{
|
||||
if (compressed == 2) {
|
||||
size_t sizeOfIt;
|
||||
size_t leni = in_len, leno = len;
|
||||
ptcache_file_read(pf, &size, 1, sizeof(unsigned int));
|
||||
@ -1270,8 +1279,7 @@ static int ptcache_file_compressed_write(PTCacheFile *pf, unsigned char *in, uns
|
||||
else
|
||||
ptcache_file_write(pf, in, in_len, sizeof(unsigned char));
|
||||
|
||||
if (compressed == 2)
|
||||
{
|
||||
if (compressed == 2) {
|
||||
unsigned int size = sizeOfIt;
|
||||
ptcache_file_write(pf, &sizeOfIt, 1, sizeof(unsigned int));
|
||||
ptcache_file_write(pf, props, size, sizeof(unsigned char));
|
||||
@ -2505,16 +2513,14 @@ int BKE_ptcache_object_reset(Scene *scene, Object *ob, int mode)
|
||||
}
|
||||
if (md->type == eModifierType_Smoke) {
|
||||
SmokeModifierData *smd = (SmokeModifierData *)md;
|
||||
if (smd->type & MOD_SMOKE_TYPE_DOMAIN)
|
||||
{
|
||||
if (smd->type & MOD_SMOKE_TYPE_DOMAIN) {
|
||||
BKE_ptcache_id_from_smoke(&pid, ob, (SmokeModifierData*)md);
|
||||
reset |= BKE_ptcache_id_reset(scene, &pid, mode);
|
||||
}
|
||||
}
|
||||
if (md->type == eModifierType_DynamicPaint) {
|
||||
DynamicPaintModifierData *pmd = (DynamicPaintModifierData *)md;
|
||||
if (pmd->canvas)
|
||||
{
|
||||
if (pmd->canvas) {
|
||||
DynamicPaintSurface *surface = pmd->canvas->surfaces.first;
|
||||
|
||||
for (; surface; surface=surface->next) {
|
||||
@ -2813,8 +2819,7 @@ void BKE_ptcache_bake(PTCacheBaker* baker)
|
||||
PTCacheID *pid2;
|
||||
BKE_ptcache_ids_from_object(&pidlist2, pid->ob, scene, MAX_DUPLI_RECUR);
|
||||
for (pid2=pidlist2.first; pid2; pid2=pid2->next) {
|
||||
if (pid2->type == PTCACHE_TYPE_SMOKE_DOMAIN)
|
||||
{
|
||||
if (pid2->type == PTCACHE_TYPE_SMOKE_DOMAIN) {
|
||||
if (pid2->cache && !(pid2->cache->flag & PTCACHE_BAKED)) {
|
||||
if (bake || pid2->cache->flag & PTCACHE_REDO_NEEDED)
|
||||
BKE_ptcache_id_clear(pid2, PTCACHE_CLEAR_ALL, 0);
|
||||
@ -3246,8 +3251,7 @@ void BKE_ptcache_update_info(PTCacheID *pid)
|
||||
}
|
||||
|
||||
if (cache->flag & PTCACHE_DISK_CACHE) {
|
||||
if (pid->type == PTCACHE_TYPE_SMOKE_DOMAIN)
|
||||
{
|
||||
if (pid->type == PTCACHE_TYPE_SMOKE_DOMAIN) {
|
||||
int totpoint = pid->totpoint(pid->calldata, 0);
|
||||
|
||||
if (cache->totpoint > totpoint)
|
||||
|
@ -99,7 +99,7 @@ void init_property(bProperty *prop)
|
||||
|
||||
prop->data= 0;
|
||||
|
||||
switch(prop->type) {
|
||||
switch (prop->type) {
|
||||
case GPROP_BOOL:
|
||||
case GPROP_INT:
|
||||
case GPROP_FLOAT:
|
||||
@ -206,7 +206,7 @@ int compare_property(bProperty *prop, const char *str)
|
||||
// extern int Gdfra; /* sector.c */
|
||||
float fvalue, ftest;
|
||||
|
||||
switch(prop->type) {
|
||||
switch (prop->type) {
|
||||
case GPROP_BOOL:
|
||||
if (BLI_strcasecmp(str, "true")==0) {
|
||||
if (prop->data==1) return 0;
|
||||
@ -242,7 +242,7 @@ void set_property(bProperty *prop, const char *str)
|
||||
{
|
||||
// extern int Gdfra; /* sector.c */
|
||||
|
||||
switch(prop->type) {
|
||||
switch (prop->type) {
|
||||
case GPROP_BOOL:
|
||||
if (BLI_strcasecmp(str, "true")==0) prop->data= 1;
|
||||
else if (BLI_strcasecmp(str, "false")==0) prop->data= 0;
|
||||
@ -266,7 +266,7 @@ void add_property(bProperty *prop, const char *str)
|
||||
{
|
||||
// extern int Gdfra; /* sector.c */
|
||||
|
||||
switch(prop->type) {
|
||||
switch (prop->type) {
|
||||
case GPROP_BOOL:
|
||||
case GPROP_INT:
|
||||
prop->data+= atoi(str);
|
||||
@ -288,7 +288,7 @@ void set_property_valstr(bProperty *prop, char *str)
|
||||
|
||||
if (str == NULL) return;
|
||||
|
||||
switch(prop->type) {
|
||||
switch (prop->type) {
|
||||
case GPROP_BOOL:
|
||||
case GPROP_INT:
|
||||
sprintf(str, "%d", prop->data);
|
||||
|
@ -43,7 +43,7 @@
|
||||
|
||||
static const char *report_type_str(int type)
|
||||
{
|
||||
switch(type) {
|
||||
switch (type) {
|
||||
case RPT_DEBUG: return "Debug";
|
||||
case RPT_INFO: return "Info";
|
||||
case RPT_OPERATOR: return "Operator";
|
||||
|
@ -110,7 +110,7 @@ void init_sensor(bSensor *sens)
|
||||
sens->data= NULL;
|
||||
sens->pulse = 0;
|
||||
|
||||
switch(sens->type) {
|
||||
switch (sens->type) {
|
||||
case SENS_ALWAYS:
|
||||
sens->pulse = 0;
|
||||
break;
|
||||
@ -272,7 +272,7 @@ void init_controller(bController *cont)
|
||||
if (cont->data) MEM_freeN(cont->data);
|
||||
cont->data= NULL;
|
||||
|
||||
switch(cont->type) {
|
||||
switch (cont->type) {
|
||||
case CONT_EXPRESSION:
|
||||
cont->data= MEM_callocN(sizeof(bExpressionCont), "expcont");
|
||||
break;
|
||||
@ -400,7 +400,7 @@ void init_actuator(bActuator *act)
|
||||
if (act->data) MEM_freeN(act->data);
|
||||
act->data= NULL;
|
||||
|
||||
switch(act->type) {
|
||||
switch (act->type) {
|
||||
case ACT_ACTION:
|
||||
case ACT_SHAPEACTION:
|
||||
act->data= MEM_callocN(sizeof(bActionActuator), "actionact");
|
||||
@ -647,7 +647,7 @@ void sca_remove_ob_poin(Object *obt, Object *ob)
|
||||
|
||||
sens= obt->sensors.first;
|
||||
while (sens) {
|
||||
switch(sens->type) {
|
||||
switch (sens->type) {
|
||||
case SENS_MESSAGE:
|
||||
ms= sens->data;
|
||||
if (ms->fromObject==ob) ms->fromObject= NULL;
|
||||
@ -657,7 +657,7 @@ void sca_remove_ob_poin(Object *obt, Object *ob)
|
||||
|
||||
act= obt->actuators.first;
|
||||
while (act) {
|
||||
switch(act->type) {
|
||||
switch (act->type) {
|
||||
case ACT_CAMERA:
|
||||
ca= act->data;
|
||||
if (ca->ob==ob) ca->ob= NULL;
|
||||
|
@ -2112,7 +2112,7 @@ static void transform_image(int x, int y, struct ImBuf *ibuf1, struct ImBuf *out
|
||||
yt += (yo / 2.0f);
|
||||
|
||||
//interpolate
|
||||
switch(interpolation) {
|
||||
switch (interpolation) {
|
||||
case 0:
|
||||
neareast_interpolation(ibuf1,out, xt,yt,xi,yi);
|
||||
break;
|
||||
|
@ -3099,13 +3099,17 @@ int seqbase_isolated_sel_check(ListBase *seqbase)
|
||||
if ( (seq->seq1 && (seq->seq1->flag & SELECT) == 0) ||
|
||||
(seq->seq2 && (seq->seq2->flag & SELECT) == 0) ||
|
||||
(seq->seq3 && (seq->seq3->flag & SELECT) == 0) )
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if ( (seq->seq1 && (seq->seq1->flag & SELECT)) ||
|
||||
(seq->seq2 && (seq->seq2->flag & SELECT)) ||
|
||||
(seq->seq3 && (seq->seq3->flag & SELECT)) )
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -146,8 +146,7 @@ static void shrinkwrap_calc_nearest_vertex(ShrinkwrapCalcData *calc)
|
||||
|
||||
|
||||
BENCH(bvhtree_from_mesh_verts(&treeData, calc->target, 0.0, 2, 6));
|
||||
if (treeData.tree == NULL)
|
||||
{
|
||||
if (treeData.tree == NULL) {
|
||||
OUT_OF_MEMORY();
|
||||
return;
|
||||
}
|
||||
@ -158,8 +157,7 @@ static void shrinkwrap_calc_nearest_vertex(ShrinkwrapCalcData *calc)
|
||||
#ifndef __APPLE__
|
||||
#pragma omp parallel for default(none) private(i) firstprivate(nearest) shared(treeData,calc) schedule(static)
|
||||
#endif
|
||||
for (i = 0; i<calc->numVerts; ++i)
|
||||
{
|
||||
for (i = 0; i<calc->numVerts; ++i) {
|
||||
float *co = calc->vertexCos[i];
|
||||
float tmp_co[3];
|
||||
float weight = defvert_array_find_weight_safe(calc->dvert, i, calc->vgroup);
|
||||
@ -189,8 +187,7 @@ static void shrinkwrap_calc_nearest_vertex(ShrinkwrapCalcData *calc)
|
||||
|
||||
|
||||
//Found the nearest vertex
|
||||
if (nearest.index != -1)
|
||||
{
|
||||
if (nearest.index != -1) {
|
||||
//Adjusting the vertex weight, so that after interpolating it keeps a certain distance from the nearest position
|
||||
float dist = sasqrt(nearest.dist);
|
||||
if (dist > FLT_EPSILON) weight *= (dist - calc->keepDist)/dist;
|
||||
@ -224,8 +221,7 @@ int normal_projection_project_vertex(char options, const float *vert, const floa
|
||||
memcpy( &hit_tmp, hit, sizeof(hit_tmp) );
|
||||
|
||||
//Apply space transform (TODO readjust dist)
|
||||
if (transf)
|
||||
{
|
||||
if (transf) {
|
||||
copy_v3_v3( tmp_co, vert );
|
||||
space_transform_apply( transf, tmp_co );
|
||||
co = tmp_co;
|
||||
@ -298,8 +294,7 @@ static void shrinkwrap_calc_normal_projection(ShrinkwrapCalcData *calc)
|
||||
|
||||
|
||||
//Prepare data to retrieve the direction in which we should project each vertex
|
||||
if (calc->smd->projAxis == MOD_SHRINKWRAP_PROJECT_OVER_NORMAL)
|
||||
{
|
||||
if (calc->smd->projAxis == MOD_SHRINKWRAP_PROJECT_OVER_NORMAL) {
|
||||
if (calc->vert == NULL) return;
|
||||
}
|
||||
else {
|
||||
@ -316,8 +311,7 @@ static void shrinkwrap_calc_normal_projection(ShrinkwrapCalcData *calc)
|
||||
return;
|
||||
}
|
||||
|
||||
if (calc->smd->auxTarget)
|
||||
{
|
||||
if (calc->smd->auxTarget) {
|
||||
auxMesh = object_get_derived_final(calc->smd->auxTarget);
|
||||
if (!auxMesh)
|
||||
return;
|
||||
@ -332,16 +326,14 @@ static void shrinkwrap_calc_normal_projection(ShrinkwrapCalcData *calc)
|
||||
#ifndef __APPLE__
|
||||
#pragma omp parallel for private(i,hit) schedule(static)
|
||||
#endif
|
||||
for (i = 0; i<calc->numVerts; ++i)
|
||||
{
|
||||
for (i = 0; i<calc->numVerts; ++i) {
|
||||
float *co = calc->vertexCos[i];
|
||||
float tmp_co[3], tmp_no[3];
|
||||
float weight = defvert_array_find_weight_safe(calc->dvert, i, calc->vgroup);
|
||||
|
||||
if (weight == 0.0f) continue;
|
||||
|
||||
if (calc->vert)
|
||||
{
|
||||
if (calc->vert) {
|
||||
/* calc->vert contains verts from derivedMesh */
|
||||
/* this coordinated are deformed by vertexCos only for normal projection (to get correct normals) */
|
||||
/* for other cases calc->varts contains undeformed coordinates and vertexCos should be used */
|
||||
@ -364,8 +356,7 @@ static void shrinkwrap_calc_normal_projection(ShrinkwrapCalcData *calc)
|
||||
hit.dist = 10000.0f; //TODO: we should use FLT_MAX here, but sweepsphere code isn't prepared for that
|
||||
|
||||
//Project over positive direction of axis
|
||||
if (use_normal & MOD_SHRINKWRAP_PROJECT_ALLOW_POS_DIR)
|
||||
{
|
||||
if (use_normal & MOD_SHRINKWRAP_PROJECT_ALLOW_POS_DIR) {
|
||||
|
||||
if (auxData.tree)
|
||||
normal_projection_project_vertex(0, tmp_co, tmp_no, &local2aux, auxData.tree, &hit, auxData.raycast_callback, &auxData);
|
||||
@ -374,8 +365,7 @@ static void shrinkwrap_calc_normal_projection(ShrinkwrapCalcData *calc)
|
||||
}
|
||||
|
||||
//Project over negative direction of axis
|
||||
if (use_normal & MOD_SHRINKWRAP_PROJECT_ALLOW_NEG_DIR && hit.index == -1)
|
||||
{
|
||||
if (use_normal & MOD_SHRINKWRAP_PROJECT_ALLOW_NEG_DIR && hit.index == -1) {
|
||||
float inv_no[3];
|
||||
negate_v3_v3(inv_no, tmp_no);
|
||||
|
||||
@ -386,8 +376,7 @@ static void shrinkwrap_calc_normal_projection(ShrinkwrapCalcData *calc)
|
||||
}
|
||||
|
||||
|
||||
if (hit.index != -1)
|
||||
{
|
||||
if (hit.index != -1) {
|
||||
madd_v3_v3v3fl(hit.co, hit.co, tmp_no, calc->keepDist);
|
||||
interp_v3_v3v3(co, co, hit.co, weight);
|
||||
}
|
||||
@ -414,8 +403,7 @@ static void shrinkwrap_calc_nearest_surface_point(ShrinkwrapCalcData *calc)
|
||||
|
||||
//Create a bvh-tree of the given target
|
||||
BENCH(bvhtree_from_mesh_faces( &treeData, calc->target, 0.0, 2, 6));
|
||||
if (treeData.tree == NULL)
|
||||
{
|
||||
if (treeData.tree == NULL) {
|
||||
OUT_OF_MEMORY();
|
||||
return;
|
||||
}
|
||||
@ -429,8 +417,7 @@ static void shrinkwrap_calc_nearest_surface_point(ShrinkwrapCalcData *calc)
|
||||
#ifndef __APPLE__
|
||||
#pragma omp parallel for default(none) private(i) firstprivate(nearest) shared(calc,treeData) schedule(static)
|
||||
#endif
|
||||
for (i = 0; i<calc->numVerts; ++i)
|
||||
{
|
||||
for (i = 0; i<calc->numVerts; ++i) {
|
||||
float *co = calc->vertexCos[i];
|
||||
float tmp_co[3];
|
||||
float weight = defvert_array_find_weight_safe(calc->dvert, i, calc->vgroup);
|
||||
@ -458,10 +445,8 @@ static void shrinkwrap_calc_nearest_surface_point(ShrinkwrapCalcData *calc)
|
||||
BLI_bvhtree_find_nearest(treeData.tree, tmp_co, &nearest, treeData.nearest_callback, &treeData);
|
||||
|
||||
//Found the nearest vertex
|
||||
if (nearest.index != -1)
|
||||
{
|
||||
if (calc->smd->shrinkOpts & MOD_SHRINKWRAP_KEEP_ABOVE_SURFACE)
|
||||
{
|
||||
if (nearest.index != -1) {
|
||||
if (calc->smd->shrinkOpts & MOD_SHRINKWRAP_KEEP_ABOVE_SURFACE) {
|
||||
//Make the vertex stay on the front side of the face
|
||||
madd_v3_v3v3fl(tmp_co, nearest.co, nearest.no, calc->keepDist);
|
||||
}
|
||||
@ -511,8 +496,7 @@ void shrinkwrapModifier_deform(ShrinkwrapModifierData *smd, Object *ob, DerivedM
|
||||
}
|
||||
|
||||
|
||||
if (smd->target)
|
||||
{
|
||||
if (smd->target) {
|
||||
calc.target = object_get_derived_final(smd->target);
|
||||
|
||||
//TODO there might be several "bugs" on non-uniform scales matrixs
|
||||
@ -528,28 +512,24 @@ void shrinkwrapModifier_deform(ShrinkwrapModifierData *smd, Object *ob, DerivedM
|
||||
|
||||
calc.vgroup = defgroup_name_index(calc.ob, smd->vgroup_name);
|
||||
|
||||
if (dm != NULL && smd->shrinkType == MOD_SHRINKWRAP_PROJECT)
|
||||
{
|
||||
if (dm != NULL && smd->shrinkType == MOD_SHRINKWRAP_PROJECT) {
|
||||
//Setup arrays to get vertexs positions, normals and deform weights
|
||||
calc.vert = dm->getVertDataArray(dm, CD_MVERT);
|
||||
calc.dvert = dm->getVertDataArray(dm, CD_MDEFORMVERT);
|
||||
|
||||
//Using vertexs positions/normals as if a subsurface was applied
|
||||
if (smd->subsurfLevels)
|
||||
{
|
||||
if (smd->subsurfLevels) {
|
||||
SubsurfModifierData ssmd= {{NULL}};
|
||||
ssmd.subdivType = ME_CC_SUBSURF; //catmull clark
|
||||
ssmd.levels = smd->subsurfLevels; //levels
|
||||
|
||||
ss_mesh = subsurf_make_derived_from_derived(dm, &ssmd, FALSE, NULL, 0, 0, (ob->mode & OB_MODE_EDIT));
|
||||
|
||||
if (ss_mesh)
|
||||
{
|
||||
if (ss_mesh) {
|
||||
calc.vert = ss_mesh->getVertDataArray(ss_mesh, CD_MVERT);
|
||||
if (calc.vert)
|
||||
{
|
||||
//TRICKY: this code assumes subsurface will have the transformed original vertices
|
||||
//in their original order at the end of the vert array.
|
||||
if (calc.vert) {
|
||||
/* TRICKY: this code assumes subsurface will have the transformed original vertices
|
||||
* in their original order at the end of the vert array. */
|
||||
calc.vert = calc.vert + ss_mesh->getNumVerts(ss_mesh) - dm->getNumVerts(dm);
|
||||
}
|
||||
}
|
||||
@ -562,8 +542,7 @@ void shrinkwrapModifier_deform(ShrinkwrapModifierData *smd, Object *ob, DerivedM
|
||||
|
||||
//Projecting target defined - lets work!
|
||||
if (calc.target) {
|
||||
switch(smd->shrinkType)
|
||||
{
|
||||
switch (smd->shrinkType) {
|
||||
case MOD_SHRINKWRAP_NEAREST_SURFACE:
|
||||
BENCH(shrinkwrap_calc_nearest_surface_point(&calc));
|
||||
break;
|
||||
|
@ -44,8 +44,7 @@ void freeSketch(SK_Sketch *sketch)
|
||||
{
|
||||
SK_Stroke *stk, *next;
|
||||
|
||||
for (stk = sketch->strokes.first; stk; stk = next)
|
||||
{
|
||||
for (stk = sketch->strokes.first; stk; stk = next) {
|
||||
next = stk->next;
|
||||
|
||||
sk_freeStroke(stk);
|
||||
@ -119,8 +118,7 @@ SK_Stroke* sk_createStroke(void)
|
||||
|
||||
void sk_shrinkStrokeBuffer(SK_Stroke *stk)
|
||||
{
|
||||
if (stk->nb_points < stk->buf_size)
|
||||
{
|
||||
if (stk->nb_points < stk->buf_size) {
|
||||
SK_Point *old_points = stk->points;
|
||||
|
||||
stk->buf_size = stk->nb_points;
|
||||
@ -135,8 +133,7 @@ void sk_shrinkStrokeBuffer(SK_Stroke *stk)
|
||||
|
||||
void sk_growStrokeBuffer(SK_Stroke *stk)
|
||||
{
|
||||
if (stk->nb_points == stk->buf_size)
|
||||
{
|
||||
if (stk->nb_points == stk->buf_size) {
|
||||
SK_Point *old_points = stk->points;
|
||||
|
||||
stk->buf_size *= 2;
|
||||
@ -151,12 +148,10 @@ void sk_growStrokeBuffer(SK_Stroke *stk)
|
||||
|
||||
void sk_growStrokeBufferN(SK_Stroke *stk, int n)
|
||||
{
|
||||
if (stk->nb_points + n > stk->buf_size)
|
||||
{
|
||||
if (stk->nb_points + n > stk->buf_size) {
|
||||
SK_Point *old_points = stk->points;
|
||||
|
||||
while (stk->nb_points + n > stk->buf_size)
|
||||
{
|
||||
while (stk->nb_points + n > stk->buf_size) {
|
||||
stk->buf_size *= 2;
|
||||
}
|
||||
|
||||
@ -202,8 +197,7 @@ void sk_insertStrokePoints(SK_Stroke *stk, SK_Point *pts, int len, int start, in
|
||||
|
||||
sk_growStrokeBufferN(stk, len - size);
|
||||
|
||||
if (len != size)
|
||||
{
|
||||
if (len != size) {
|
||||
int tail_size = stk->nb_points - end + 1;
|
||||
|
||||
memmove(stk->points + start + len, stk->points + end + 1, tail_size * sizeof(SK_Point));
|
||||
@ -218,8 +212,7 @@ void sk_trimStroke(SK_Stroke *stk, int start, int end)
|
||||
{
|
||||
int size = end - start + 1;
|
||||
|
||||
if (start > 0)
|
||||
{
|
||||
if (start > 0) {
|
||||
memmove(stk->points, stk->points + start, size * sizeof(SK_Point));
|
||||
}
|
||||
|
||||
@ -253,8 +246,7 @@ void sk_straightenStroke(SK_Stroke *stk, int start, int end, float p_start[3], f
|
||||
sk_insertStrokePoint(stk, &pt1, start + 1); /* insert after start */
|
||||
sk_insertStrokePoint(stk, &pt2, end + 1); /* insert before end (since end was pushed back already) */
|
||||
|
||||
for (i = 1; i < total; i++)
|
||||
{
|
||||
for (i = 1; i < total; i++) {
|
||||
float delta = (float)i / (float)total;
|
||||
float *p = stk->points[start + 1 + i].p;
|
||||
|
||||
@ -269,30 +261,23 @@ void sk_polygonizeStroke(SK_Stroke *stk, int start, int end)
|
||||
int i;
|
||||
|
||||
/* find first exact points outside of range */
|
||||
for (;start > 0; start--)
|
||||
{
|
||||
if (stk->points[start].type == PT_EXACT)
|
||||
{
|
||||
for (;start > 0; start--) {
|
||||
if (stk->points[start].type == PT_EXACT) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
for (;end < stk->nb_points - 1; end++)
|
||||
{
|
||||
if (stk->points[end].type == PT_EXACT)
|
||||
{
|
||||
for (;end < stk->nb_points - 1; end++) {
|
||||
if (stk->points[end].type == PT_EXACT) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
offset = start + 1;
|
||||
|
||||
for (i = start + 1; i < end; i++)
|
||||
{
|
||||
if (stk->points[i].type == PT_EXACT)
|
||||
{
|
||||
if (offset != i)
|
||||
{
|
||||
for (i = start + 1; i < end; i++) {
|
||||
if (stk->points[i].type == PT_EXACT) {
|
||||
if (offset != i) {
|
||||
memcpy(stk->points + offset, stk->points + i, sizeof(SK_Point));
|
||||
}
|
||||
|
||||
@ -301,8 +286,7 @@ void sk_polygonizeStroke(SK_Stroke *stk, int start, int end)
|
||||
}
|
||||
|
||||
/* some points were removes, move end of array */
|
||||
if (offset < end)
|
||||
{
|
||||
if (offset < end) {
|
||||
int size = stk->nb_points - end;
|
||||
memmove(stk->points + offset, stk->points + end, size * sizeof(SK_Point));
|
||||
stk->nb_points = offset + size;
|
||||
@ -323,8 +307,7 @@ void sk_flattenStroke(SK_Stroke *stk, int start, int end)
|
||||
project_v3_v3v3(normal, distance, normal);
|
||||
limit = normalize_v3(normal);
|
||||
|
||||
for (i = 1; i < total - 1; i++)
|
||||
{
|
||||
for (i = 1; i < total - 1; i++) {
|
||||
float d = limit * i / total;
|
||||
float offset[3];
|
||||
float *p = stk->points[start + i].p;
|
||||
@ -342,8 +325,7 @@ void sk_flattenStroke(SK_Stroke *stk, int start, int end)
|
||||
|
||||
void sk_removeStroke(SK_Sketch *sketch, SK_Stroke *stk)
|
||||
{
|
||||
if (sketch->active_stroke == stk)
|
||||
{
|
||||
if (sketch->active_stroke == stk) {
|
||||
sketch->active_stroke = NULL;
|
||||
}
|
||||
|
||||
@ -358,8 +340,7 @@ void sk_reverseStroke(SK_Stroke *stk)
|
||||
|
||||
sk_allocStrokeBuffer(stk);
|
||||
|
||||
for (i = 0; i < stk->nb_points; i++)
|
||||
{
|
||||
for (i = 0; i < stk->nb_points; i++) {
|
||||
sk_copyPoint(stk->points + i, old_points + stk->nb_points - 1 - i);
|
||||
}
|
||||
|
||||
@ -376,8 +357,7 @@ void sk_filterStroke(SK_Stroke *stk, int start, int end)
|
||||
char work;
|
||||
int i;
|
||||
|
||||
if (start == -1)
|
||||
{
|
||||
if (start == -1) {
|
||||
start = 0;
|
||||
end = stk->nb_points - 1;
|
||||
}
|
||||
@ -386,8 +366,7 @@ void sk_filterStroke(SK_Stroke *stk, int start, int end)
|
||||
stk->nb_points = 0;
|
||||
|
||||
/* adding points before range */
|
||||
for (i = 0; i < start; i++)
|
||||
{
|
||||
for (i = 0; i < start; i++) {
|
||||
sk_appendStrokePoint(stk, old_points + i);
|
||||
}
|
||||
|
||||
@ -398,8 +377,7 @@ void sk_filterStroke(SK_Stroke *stk, int start, int end)
|
||||
work = 1;
|
||||
|
||||
/* while still reducing */
|
||||
while (work)
|
||||
{
|
||||
while (work) {
|
||||
int ls, le;
|
||||
work = 0;
|
||||
|
||||
@ -407,15 +385,13 @@ void sk_filterStroke(SK_Stroke *stk, int start, int end)
|
||||
le = start+1;
|
||||
|
||||
/* while not over interval */
|
||||
while (ls < end)
|
||||
{
|
||||
while (ls < end) {
|
||||
int max_i = 0;
|
||||
short v1[2];
|
||||
float max_dist = 16; /* more than 4 pixels */
|
||||
|
||||
/* find the next marked point */
|
||||
while (marked[le] == 0)
|
||||
{
|
||||
while (marked[le] == 0) {
|
||||
le++;
|
||||
}
|
||||
|
||||
@ -424,8 +400,7 @@ void sk_filterStroke(SK_Stroke *stk, int start, int end)
|
||||
v1[0] = old_points[ls].p2d[1] - old_points[le].p2d[1];
|
||||
|
||||
|
||||
for ( i = ls + 1; i < le; i++ )
|
||||
{
|
||||
for ( i = ls + 1; i < le; i++ ) {
|
||||
float mul;
|
||||
float dist;
|
||||
short v2[2];
|
||||
@ -433,8 +408,7 @@ void sk_filterStroke(SK_Stroke *stk, int start, int end)
|
||||
v2[0] = old_points[i].p2d[0] - old_points[ls].p2d[0];
|
||||
v2[1] = old_points[i].p2d[1] - old_points[ls].p2d[1];
|
||||
|
||||
if (v2[0] == 0 && v2[1] == 0)
|
||||
{
|
||||
if (v2[0] == 0 && v2[1] == 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -442,15 +416,13 @@ void sk_filterStroke(SK_Stroke *stk, int start, int end)
|
||||
|
||||
dist = mul * mul * (v2[0]*v2[0] + v2[1]*v2[1]);
|
||||
|
||||
if (dist > max_dist)
|
||||
{
|
||||
if (dist > max_dist) {
|
||||
max_dist = dist;
|
||||
max_i = i;
|
||||
}
|
||||
}
|
||||
|
||||
if (max_i != 0)
|
||||
{
|
||||
if (max_i != 0) {
|
||||
work = 1;
|
||||
marked[max_i] = 1;
|
||||
}
|
||||
@ -462,10 +434,8 @@ void sk_filterStroke(SK_Stroke *stk, int start, int end)
|
||||
|
||||
|
||||
/* adding points after range */
|
||||
for (i = start; i <= end; i++)
|
||||
{
|
||||
if (marked[i])
|
||||
{
|
||||
for (i = start; i <= end; i++) {
|
||||
if (marked[i]) {
|
||||
sk_appendStrokePoint(stk, old_points + i);
|
||||
}
|
||||
}
|
||||
@ -473,8 +443,7 @@ void sk_filterStroke(SK_Stroke *stk, int start, int end)
|
||||
MEM_freeN(marked);
|
||||
|
||||
/* adding points after range */
|
||||
for (i = end + 1; i < nb_points; i++)
|
||||
{
|
||||
for (i = end + 1; i < nb_points; i++) {
|
||||
sk_appendStrokePoint(stk, old_points + i);
|
||||
}
|
||||
|
||||
@ -490,13 +459,11 @@ void sk_filterLastContinuousStroke(SK_Stroke *stk)
|
||||
|
||||
end = stk->nb_points -1;
|
||||
|
||||
for (start = end - 1; start > 0 && stk->points[start].type == PT_CONTINUOUS; start--)
|
||||
{
|
||||
for (start = end - 1; start > 0 && stk->points[start].type == PT_CONTINUOUS; start--) {
|
||||
/* nothing to do here*/
|
||||
}
|
||||
|
||||
if (end - start > 1)
|
||||
{
|
||||
if (end - start > 1) {
|
||||
sk_filterStroke(stk, start, end);
|
||||
}
|
||||
}
|
||||
@ -505,8 +472,7 @@ SK_Point *sk_lastStrokePoint(SK_Stroke *stk)
|
||||
{
|
||||
SK_Point *pt = NULL;
|
||||
|
||||
if (stk->nb_points > 0)
|
||||
{
|
||||
if (stk->nb_points > 0) {
|
||||
pt = stk->points + (stk->nb_points - 1);
|
||||
}
|
||||
|
||||
@ -520,8 +486,7 @@ void sk_endContinuousStroke(SK_Stroke *stk)
|
||||
|
||||
void sk_updateNextPoint(SK_Sketch *sketch, SK_Stroke *stk)
|
||||
{
|
||||
if (stk)
|
||||
{
|
||||
if (stk) {
|
||||
memcpy(&sketch->next_point, stk->points[stk->nb_points - 1].p, sizeof(SK_Point));
|
||||
}
|
||||
}
|
||||
@ -529,8 +494,7 @@ void sk_updateNextPoint(SK_Sketch *sketch, SK_Stroke *stk)
|
||||
int sk_stroke_filtermval(SK_DrawData *dd)
|
||||
{
|
||||
int retval = 0;
|
||||
if (ABS(dd->mval[0] - dd->previous_mval[0]) + ABS(dd->mval[1] - dd->previous_mval[1]) > U.gp_manhattendist)
|
||||
{
|
||||
if (ABS(dd->mval[0] - dd->previous_mval[0]) + ABS(dd->mval[1] - dd->previous_mval[1]) > U.gp_manhattendist) {
|
||||
retval = 1;
|
||||
}
|
||||
|
||||
@ -551,12 +515,10 @@ void sk_deleteSelectedStrokes(SK_Sketch *sketch)
|
||||
{
|
||||
SK_Stroke *stk, *next;
|
||||
|
||||
for (stk = sketch->strokes.first; stk; stk = next)
|
||||
{
|
||||
for (stk = sketch->strokes.first; stk; stk = next) {
|
||||
next = stk->next;
|
||||
|
||||
if (stk->selected == 1)
|
||||
{
|
||||
if (stk->selected == 1) {
|
||||
sk_removeStroke(sketch, stk);
|
||||
}
|
||||
}
|
||||
@ -566,31 +528,26 @@ void sk_selectAllSketch(SK_Sketch *sketch, int mode)
|
||||
{
|
||||
SK_Stroke *stk = NULL;
|
||||
|
||||
if (mode == -1)
|
||||
{
|
||||
for (stk = sketch->strokes.first; stk; stk = stk->next)
|
||||
{
|
||||
if (mode == -1) {
|
||||
for (stk = sketch->strokes.first; stk; stk = stk->next) {
|
||||
stk->selected = 0;
|
||||
}
|
||||
}
|
||||
else if (mode == 0) {
|
||||
for (stk = sketch->strokes.first; stk; stk = stk->next)
|
||||
{
|
||||
for (stk = sketch->strokes.first; stk; stk = stk->next) {
|
||||
stk->selected = 1;
|
||||
}
|
||||
}
|
||||
else if (mode == 1) {
|
||||
int selected = 1;
|
||||
|
||||
for (stk = sketch->strokes.first; stk; stk = stk->next)
|
||||
{
|
||||
for (stk = sketch->strokes.first; stk; stk = stk->next) {
|
||||
selected &= stk->selected;
|
||||
}
|
||||
|
||||
selected ^= 1;
|
||||
|
||||
for (stk = sketch->strokes.first; stk; stk = stk->next)
|
||||
{
|
||||
for (stk = sketch->strokes.first; stk; stk = stk->next) {
|
||||
stk->selected = selected;
|
||||
}
|
||||
}
|
||||
|
@ -402,7 +402,10 @@ static void ccd_mesh_update(Object *ob,ccd_Mesh *pccd_M)
|
||||
if (!cmd->numverts || !cmd->numfaces) return;
|
||||
|
||||
if ((pccd_M->totvert != cmd->numverts) ||
|
||||
(pccd_M->totface != cmd->numfaces)) return;
|
||||
(pccd_M->totface != cmd->numfaces))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
pccd_M->bbmin[0]=pccd_M->bbmin[1]=pccd_M->bbmin[2]=1e30f;
|
||||
pccd_M->bbmax[0]=pccd_M->bbmax[1]=pccd_M->bbmax[2]=-1e30f;
|
||||
@ -1388,8 +1391,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++) {
|
||||
if (( bf->flag & BFF_INTERSECT) || ( bf->flag & BFF_CLOSEVERT))
|
||||
{
|
||||
if (( bf->flag & BFF_INTERSECT) || ( bf->flag & BFF_CLOSEVERT)) {
|
||||
sb->bpoint[bf->v1].choke2=MAX2(sb->bpoint[bf->v1].choke2,choke);
|
||||
sb->bpoint[bf->v2].choke2=MAX2(sb->bpoint[bf->v2].choke2,choke);
|
||||
sb->bpoint[bf->v3].choke2=MAX2(sb->bpoint[bf->v3].choke2,choke);
|
||||
@ -1935,8 +1937,8 @@ static int sb_detect_vertex_collisionCached(float opco[3], float facenormal[3],
|
||||
}
|
||||
|
||||
}
|
||||
if ((deflected < 2)&& (G.rt != 444)) // we did not hit a face until now
|
||||
{ // see if 'outer' hits an edge
|
||||
if ((deflected < 2)&& (G.rt != 444)) { /* we did not hit a face until now */
|
||||
/* see if 'outer' hits an edge */
|
||||
float dist;
|
||||
|
||||
closest_to_line_segment_v3(ve, opco, nv1, nv2);
|
||||
@ -2831,8 +2833,7 @@ static void softbody_calc_forces(Scene *scene, Object *ob, float forcetime, floa
|
||||
nlEnd(NL_MATRIX);
|
||||
nlEnd(NL_SYSTEM);
|
||||
|
||||
if ((G.rt == 32) && (nl_flags & NLF_BUILD))
|
||||
{
|
||||
if ((G.rt == 32) && (nl_flags & NLF_BUILD)) {
|
||||
printf("####MEE#####\n");
|
||||
nlPrintMatrix();
|
||||
}
|
||||
@ -3230,8 +3231,7 @@ static void springs_from_mesh(Object *ob)
|
||||
float scale =1.0f;
|
||||
|
||||
sb= ob->soft;
|
||||
if (me && sb)
|
||||
{
|
||||
if (me && sb) {
|
||||
/* using bp->origS as a container for spring calcualtions here
|
||||
** will be overwritten sbObjectStep() to receive
|
||||
** actual modifier stack positions
|
||||
@ -3307,8 +3307,7 @@ static void mesh_to_softbody(Scene *scene, Object *ob)
|
||||
this enables per vertex *mass painting*
|
||||
*/
|
||||
|
||||
if (sb->namedVG_Mass[0])
|
||||
{
|
||||
if (sb->namedVG_Mass[0]) {
|
||||
int grp= defgroup_name_index (ob,sb->namedVG_Mass);
|
||||
/* printf("VGN %s %d\n",sb->namedVG_Mass,grp); */
|
||||
if (grp > -1) {
|
||||
@ -3321,8 +3320,7 @@ static void mesh_to_softbody(Scene *scene, Object *ob)
|
||||
/* first set the default */
|
||||
bp->springweight = 1.0f;
|
||||
|
||||
if (sb->namedVG_Spring_K[0])
|
||||
{
|
||||
if (sb->namedVG_Spring_K[0]) {
|
||||
int grp= defgroup_name_index (ob,sb->namedVG_Spring_K);
|
||||
//printf("VGN %s %d\n",sb->namedVG_Spring_K,grp);
|
||||
if (grp > -1) {
|
||||
@ -3639,8 +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);}
|
||||
}
|
||||
@ -3896,7 +3893,7 @@ static void softbody_reset(Object *ob, SoftBody *sb, float (*vertexCos)[3], int
|
||||
SB_estimate_transform(ob,NULL,NULL,NULL);
|
||||
SB_estimate_transform(ob,NULL,NULL,NULL);
|
||||
}
|
||||
switch(ob->type) {
|
||||
switch (ob->type) {
|
||||
case OB_MESH:
|
||||
if (ob->softflag & OB_SB_FACECOLL) mesh_faces_to_scratch(ob);
|
||||
break;
|
||||
@ -3952,8 +3949,7 @@ static void softbody_step(Scene *scene, Object *ob, SoftBody *sb, float dtime)
|
||||
if (sb->solver_ID>0) mid_flags |= MID_PRESERVE;
|
||||
|
||||
forcetime = forcetimemax; /* hope for integrating in one step */
|
||||
while ( (ABS(timedone) < ABS(dtime)) && (loops < 2000) )
|
||||
{
|
||||
while ( (ABS(timedone) < ABS(dtime)) && (loops < 2000) ) {
|
||||
/* set goals in time */
|
||||
interpolate_exciter(ob,200,(int)(200.0f*(timedone/dtime)));
|
||||
|
||||
@ -4021,12 +4017,11 @@ static void softbody_step(Scene *scene, Object *ob, SoftBody *sb, float dtime)
|
||||
}
|
||||
|
||||
}
|
||||
else if (sb->solver_ID == 2)
|
||||
{/* do semi "fake" implicit euler */
|
||||
else if (sb->solver_ID == 2) {
|
||||
/* do semi "fake" implicit euler */
|
||||
//removed
|
||||
}/*SOLVER SELECT*/
|
||||
else if (sb->solver_ID == 4)
|
||||
{
|
||||
else if (sb->solver_ID == 4) {
|
||||
/* do semi "fake" implicit euler */
|
||||
}/*SOLVER SELECT*/
|
||||
else if (sb->solver_ID == 3) {
|
||||
@ -4083,7 +4078,7 @@ void sbObjectStep(Scene *scene, Object *ob, float cfra, float (*vertexCos)[3], i
|
||||
if (sb->bpoint == NULL ||
|
||||
((ob->softflag & OB_SB_EDGES) && !ob->soft->bspring && object_has_edges(ob))) {
|
||||
|
||||
switch(ob->type) {
|
||||
switch (ob->type) {
|
||||
case OB_MESH:
|
||||
mesh_to_softbody(scene, ob);
|
||||
break;
|
||||
|
@ -95,8 +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;
|
||||
}
|
||||
@ -106,22 +105,19 @@ struct bSound* sound_new_file(struct Main *bmain, const char *filename)
|
||||
|
||||
void sound_free(struct bSound* sound)
|
||||
{
|
||||
if (sound->packedfile)
|
||||
{
|
||||
if (sound->packedfile) {
|
||||
freePackedFile(sound->packedfile);
|
||||
sound->packedfile = NULL;
|
||||
}
|
||||
|
||||
#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;
|
||||
}
|
||||
@ -141,10 +137,8 @@ static void sound_sync_callback(void* data, int mode, float time)
|
||||
struct Scene* scene;
|
||||
|
||||
scene = bmain->scene.first;
|
||||
while (scene)
|
||||
{
|
||||
if (scene->audio.flag & AUDIO_SYNC)
|
||||
{
|
||||
while (scene) {
|
||||
if (scene->audio.flag & AUDIO_SYNC) {
|
||||
if (mode)
|
||||
sound_play_scene(scene);
|
||||
else
|
||||
@ -282,8 +276,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);
|
||||
|
||||
free_libblock(&bmain->sound, sound);
|
||||
@ -312,8 +305,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;
|
||||
sound->playback_handle = sound->handle;
|
||||
@ -322,16 +314,13 @@ void sound_delete_cache(struct bSound* sound)
|
||||
|
||||
void sound_load(struct Main *bmain, struct bSound* sound)
|
||||
{
|
||||
if (sound)
|
||||
{
|
||||
if (sound->cache)
|
||||
{
|
||||
if (sound) {
|
||||
if (sound->cache) {
|
||||
AUD_unload(sound->cache);
|
||||
sound->cache = NULL;
|
||||
}
|
||||
|
||||
if (sound->handle)
|
||||
{
|
||||
if (sound->handle) {
|
||||
AUD_unload(sound->handle);
|
||||
sound->handle = NULL;
|
||||
sound->playback_handle = NULL;
|
||||
@ -341,7 +330,7 @@ void sound_load(struct Main *bmain, struct bSound* sound)
|
||||
|
||||
// XXX unused currently
|
||||
#if 0
|
||||
switch(sound->type)
|
||||
switch (sound->type)
|
||||
{
|
||||
case SOUND_TYPE_FILE:
|
||||
#endif
|
||||
@ -376,15 +365,13 @@ void sound_load(struct Main *bmain, struct bSound* sound)
|
||||
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);
|
||||
}
|
||||
|
||||
@ -557,14 +544,12 @@ void sound_play_scene(struct Scene *scene)
|
||||
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);
|
||||
}
|
||||
@ -577,8 +562,7 @@ 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)
|
||||
@ -596,12 +580,10 @@ 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;
|
||||
}
|
||||
@ -616,10 +598,8 @@ void sound_seek_scene(struct Main *bmain, struct Scene *scene)
|
||||
}
|
||||
}
|
||||
|
||||
if (scene->audio.flag & AUDIO_SCRUB && !animation_playing)
|
||||
{
|
||||
if (scene->audio.flag & AUDIO_SYNC)
|
||||
{
|
||||
if (scene->audio.flag & AUDIO_SCRUB && !animation_playing) {
|
||||
if (scene->audio.flag & AUDIO_SYNC) {
|
||||
AUD_seek(scene->sound_scene_handle, CFRA / FPS);
|
||||
AUD_seekSequencer(scene->sound_scene_handle, CFRA / FPS);
|
||||
}
|
||||
@ -648,8 +628,7 @@ 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)
|
||||
return AUD_getSequencerPosition(scene->sound_scene_handle);
|
||||
else
|
||||
@ -668,8 +647,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,8 +661,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,23 +686,16 @@ 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->adt)
|
||||
{
|
||||
for (track = ob->adt->nla_tracks.first; track; track = track->next)
|
||||
{
|
||||
for (strip = track->strips.first; strip; strip = strip->next)
|
||||
{
|
||||
if (strip->type == NLASTRIP_TYPE_SOUND)
|
||||
{
|
||||
if (ob->type == OB_SPEAKER) {
|
||||
if (ob->adt) {
|
||||
for (track = ob->adt->nla_tracks.first; track; track = track->next) {
|
||||
for (strip = track->strips.first; strip; strip = strip->next) {
|
||||
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)
|
||||
AUD_moveSequence(strip->speaker_handle, strip->start / FPS, -1, 0);
|
||||
else {
|
||||
@ -734,15 +704,13 @@ 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,
|
||||
speaker->volume_min, speaker->distance_max,
|
||||
@ -765,13 +733,11 @@ void sound_update_scene(struct Scene* scene)
|
||||
}
|
||||
}
|
||||
|
||||
while ((handle = AUD_getSet(scene->speaker_handles)))
|
||||
{
|
||||
while ((handle = AUD_getSet(scene->speaker_handles))) {
|
||||
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);
|
||||
AUD_setSequencerAnimData(scene->sound_scene, AUD_AP_ORIENTATION, CFRA, quat, 1);
|
||||
|
@ -2423,7 +2423,9 @@ static void ccgDM_release(DerivedMesh *dm)
|
||||
/* Check that mmd still exists */
|
||||
if (!ccgdm->multires.local_mmd &&
|
||||
BLI_findindex(&ccgdm->multires.ob->modifiers, ccgdm->multires.mmd) < 0)
|
||||
{
|
||||
ccgdm->multires.mmd = NULL;
|
||||
}
|
||||
|
||||
if (ccgdm->multires.mmd) {
|
||||
if (ccgdm->multires.modified_flags & MULTIRES_COORDS_MODIFIED)
|
||||
|
@ -1193,9 +1193,11 @@ void txt_order_cursors(Text *text)
|
||||
if (!text->sell) return;
|
||||
|
||||
/* Flip so text->curl is before text->sell */
|
||||
if (txt_get_span(text->curl, text->sell)<0 ||
|
||||
(text->curl==text->sell && text->curc>text->selc))
|
||||
if ((txt_get_span(text->curl, text->sell) < 0) ||
|
||||
(text->curl == text->sell && text->curc > text->selc))
|
||||
{
|
||||
txt_curs_swap(text);
|
||||
}
|
||||
}
|
||||
|
||||
int txt_has_sel(Text *text)
|
||||
@ -2018,7 +2020,7 @@ void txt_do_undo(Text *text)
|
||||
|
||||
undoing= 1;
|
||||
|
||||
switch(op) {
|
||||
switch (op) {
|
||||
case UNDO_CLEFT:
|
||||
txt_move_right(text, 0);
|
||||
break;
|
||||
@ -2245,7 +2247,7 @@ void txt_do_redo(Text *text)
|
||||
|
||||
undoing= 1;
|
||||
|
||||
switch(op) {
|
||||
switch (op) {
|
||||
case UNDO_CLEFT:
|
||||
txt_move_left(text, 0);
|
||||
break;
|
||||
@ -2832,8 +2834,7 @@ void txt_indent(Text *text)
|
||||
}
|
||||
|
||||
num = 0;
|
||||
while (TRUE)
|
||||
{
|
||||
while (TRUE) {
|
||||
tmp= MEM_mallocN(text->curl->len+indentlen+1, "textline_string");
|
||||
|
||||
text->curc = 0;
|
||||
@ -2851,8 +2852,7 @@ void txt_indent(Text *text)
|
||||
txt_make_dirty(text);
|
||||
txt_clean_text(text);
|
||||
|
||||
if (text->curl == text->sell)
|
||||
{
|
||||
if (text->curl == text->sell) {
|
||||
text->selc = text->sell->len;
|
||||
break;
|
||||
}
|
||||
@ -2862,14 +2862,12 @@ void txt_indent(Text *text)
|
||||
}
|
||||
}
|
||||
text->curc = 0;
|
||||
while ( num > 0 )
|
||||
{
|
||||
while ( num > 0 ) {
|
||||
text->curl = text->curl->prev;
|
||||
num--;
|
||||
}
|
||||
|
||||
if (!undoing)
|
||||
{
|
||||
if (!undoing) {
|
||||
txt_undo_add_toop(text, UNDO_INDENT, txt_get_span(text->lines.first, text->curl), text->curc, txt_get_span(text->lines.first, text->sell), text->selc);
|
||||
}
|
||||
}
|
||||
@ -2893,12 +2891,10 @@ void txt_unindent(Text *text)
|
||||
indent = spaceslen;
|
||||
}
|
||||
|
||||
while (TRUE)
|
||||
{
|
||||
while (TRUE) {
|
||||
int i = 0;
|
||||
|
||||
if (BLI_strncasecmp(text->curl->line, remove, indent) == 0)
|
||||
{
|
||||
if (BLI_strncasecmp(text->curl->line, remove, indent) == 0) {
|
||||
while (i< text->curl->len) {
|
||||
text->curl->line[i]= text->curl->line[i+indent];
|
||||
i++;
|
||||
@ -2909,8 +2905,7 @@ void txt_unindent(Text *text)
|
||||
txt_make_dirty(text);
|
||||
txt_clean_text(text);
|
||||
|
||||
if (text->curl == text->sell)
|
||||
{
|
||||
if (text->curl == text->sell) {
|
||||
text->selc = text->sell->len;
|
||||
break;
|
||||
}
|
||||
@ -2921,14 +2916,12 @@ void txt_unindent(Text *text)
|
||||
|
||||
}
|
||||
text->curc = 0;
|
||||
while ( num > 0 )
|
||||
{
|
||||
while ( num > 0 ) {
|
||||
text->curl = text->curl->prev;
|
||||
num--;
|
||||
}
|
||||
|
||||
if (!undoing)
|
||||
{
|
||||
if (!undoing) {
|
||||
txt_undo_add_toop(text, UNDO_UNINDENT, txt_get_span(text->lines.first, text->curl), text->curc, txt_get_span(text->lines.first, text->sell), text->selc);
|
||||
}
|
||||
}
|
||||
@ -2944,8 +2937,7 @@ void txt_comment(Text *text)
|
||||
if (!text->sell) return;// Need to change this need to check if only one line is selected to more then one
|
||||
|
||||
num = 0;
|
||||
while (TRUE)
|
||||
{
|
||||
while (TRUE) {
|
||||
tmp= MEM_mallocN(text->curl->len+2, "textline_string");
|
||||
|
||||
text->curc = 0;
|
||||
@ -2963,8 +2955,7 @@ void txt_comment(Text *text)
|
||||
txt_make_dirty(text);
|
||||
txt_clean_text(text);
|
||||
|
||||
if (text->curl == text->sell)
|
||||
{
|
||||
if (text->curl == text->sell) {
|
||||
text->selc = text->sell->len;
|
||||
break;
|
||||
}
|
||||
@ -2974,14 +2965,12 @@ void txt_comment(Text *text)
|
||||
}
|
||||
}
|
||||
text->curc = 0;
|
||||
while ( num > 0 )
|
||||
{
|
||||
while ( num > 0 ) {
|
||||
text->curl = text->curl->prev;
|
||||
num--;
|
||||
}
|
||||
|
||||
if (!undoing)
|
||||
{
|
||||
if (!undoing) {
|
||||
txt_undo_add_toop(text, UNDO_COMMENT, txt_get_span(text->lines.first, text->curl), text->curc, txt_get_span(text->lines.first, text->sell), text->selc);
|
||||
}
|
||||
}
|
||||
@ -2995,12 +2984,10 @@ void txt_uncomment(Text *text)
|
||||
if (!text->curl) return;
|
||||
if (!text->sell) return;
|
||||
|
||||
while (TRUE)
|
||||
{
|
||||
while (TRUE) {
|
||||
int i = 0;
|
||||
|
||||
if (text->curl->line[i] == remove)
|
||||
{
|
||||
if (text->curl->line[i] == remove) {
|
||||
while (i< text->curl->len) {
|
||||
text->curl->line[i]= text->curl->line[i+1];
|
||||
i++;
|
||||
@ -3012,8 +2999,7 @@ void txt_uncomment(Text *text)
|
||||
txt_make_dirty(text);
|
||||
txt_clean_text(text);
|
||||
|
||||
if (text->curl == text->sell)
|
||||
{
|
||||
if (text->curl == text->sell) {
|
||||
text->selc = text->sell->len;
|
||||
break;
|
||||
}
|
||||
@ -3024,14 +3010,12 @@ void txt_uncomment(Text *text)
|
||||
|
||||
}
|
||||
text->curc = 0;
|
||||
while ( num > 0 )
|
||||
{
|
||||
while ( num > 0 ) {
|
||||
text->curl = text->curl->prev;
|
||||
num--;
|
||||
}
|
||||
|
||||
if (!undoing)
|
||||
{
|
||||
if (!undoing) {
|
||||
txt_undo_add_toop(text, UNDO_UNCOMMENT, txt_get_span(text->lines.first, text->curl), text->curc, txt_get_span(text->lines.first, text->sell), text->selc);
|
||||
}
|
||||
}
|
||||
@ -3047,27 +3031,23 @@ int setcurr_tab_spaces (Text *text, int space)
|
||||
if (!text) return 0;
|
||||
if (!text->curl) return 0;
|
||||
|
||||
while (text->curl->line[i] == indent)
|
||||
{
|
||||
while (text->curl->line[i] == indent) {
|
||||
//we only count those tabs/spaces that are before any text or before the curs;
|
||||
if (i == text->curc)
|
||||
{
|
||||
if (i == text->curc) {
|
||||
return i;
|
||||
}
|
||||
else {
|
||||
i++;
|
||||
}
|
||||
}
|
||||
if (strstr(text->curl->line, word))
|
||||
{
|
||||
if (strstr(text->curl->line, word)) {
|
||||
/* if we find a ':' on this line, then add a tab but not if it is:
|
||||
* 1) in a comment
|
||||
* 2) within an identifier
|
||||
* 3) after the cursor (text->curc), i.e. when creating space before a function def [#25414]
|
||||
*/
|
||||
int a, is_indent = 0;
|
||||
for (a=0; (a < text->curc) && (text->curl->line[a] != '\0'); a++)
|
||||
{
|
||||
for (a=0; (a < text->curc) && (text->curl->line[a] != '\0'); a++) {
|
||||
char ch= text->curl->line[a];
|
||||
if (ch=='#') {
|
||||
break;
|
||||
@ -3084,13 +3064,10 @@ int setcurr_tab_spaces (Text *text, int space)
|
||||
}
|
||||
}
|
||||
|
||||
for (test=0; back_words[test]; test++)
|
||||
{
|
||||
for (test=0; back_words[test]; test++) {
|
||||
/* if there are these key words then remove a tab because we are done with the block */
|
||||
if (strstr(text->curl->line, back_words[test]) && i > 0)
|
||||
{
|
||||
if (strcspn(text->curl->line, back_words[test]) < strcspn(text->curl->line, comm))
|
||||
{
|
||||
if (strstr(text->curl->line, back_words[test]) && i > 0) {
|
||||
if (strcspn(text->curl->line, back_words[test]) < strcspn(text->curl->line, comm)) {
|
||||
i -= space;
|
||||
}
|
||||
}
|
||||
@ -3139,14 +3116,16 @@ TextMarker *txt_find_marker_region(Text *text, TextLine *line, int start, int en
|
||||
for (marker=text->markers.first; marker; marker=next) {
|
||||
next= marker->next;
|
||||
|
||||
if (group && marker->group != group) continue;
|
||||
if (group && marker->group != group) continue;
|
||||
else if ((marker->flags & flags) != flags) continue;
|
||||
else if (marker->lineno < lineno) continue;
|
||||
else if (marker->lineno < lineno) continue;
|
||||
else if (marker->lineno > lineno) break;
|
||||
|
||||
if ((marker->start==marker->end && start<=marker->start && marker->start<=end) ||
|
||||
(marker->start<end && marker->end>start))
|
||||
(marker->start<end && marker->end>start))
|
||||
{
|
||||
return marker;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
@ -663,7 +663,7 @@ void default_tex(Tex *tex)
|
||||
|
||||
void tex_set_type(Tex *tex, int type)
|
||||
{
|
||||
switch(type) {
|
||||
switch (type) {
|
||||
|
||||
case TEX_VOXELDATA:
|
||||
if (tex->vd == NULL)
|
||||
@ -1180,7 +1180,7 @@ Tex *give_current_material_texture(Material *ma)
|
||||
|
||||
int give_active_mtex(ID *id, MTex ***mtex_ar, short *act)
|
||||
{
|
||||
switch(GS(id->name)) {
|
||||
switch (GS(id->name)) {
|
||||
case ID_MA:
|
||||
*mtex_ar= ((Material *)id)->mtex;
|
||||
if (act) *act= (((Material *)id)->texact);
|
||||
@ -1211,7 +1211,7 @@ void set_active_mtex(ID *id, short act)
|
||||
if (act<0) act= 0;
|
||||
else if (act>=MAX_MTEX) act= MAX_MTEX-1;
|
||||
|
||||
switch(GS(id->name)) {
|
||||
switch (GS(id->name)) {
|
||||
case ID_MA:
|
||||
((Material *)id)->texact= act;
|
||||
break;
|
||||
|
@ -120,19 +120,17 @@ static int write_audio_frame(void)
|
||||
audio_time += (double) audio_input_samples / (double) c->sample_rate;
|
||||
|
||||
pkt.size = avcodec_encode_audio(c, audio_output_buffer,
|
||||
audio_outbuf_size,
|
||||
(short*) audio_input_buffer);
|
||||
audio_outbuf_size,
|
||||
(short *)audio_input_buffer);
|
||||
|
||||
if (pkt.size < 0)
|
||||
{
|
||||
if (pkt.size < 0) {
|
||||
// XXX error("Error writing audio packet");
|
||||
return -1;
|
||||
}
|
||||
|
||||
pkt.data = audio_output_buffer;
|
||||
|
||||
if (c->coded_frame && c->coded_frame->pts != AV_NOPTS_VALUE)
|
||||
{
|
||||
if (c->coded_frame && c->coded_frame->pts != AV_NOPTS_VALUE) {
|
||||
pkt.pts = av_rescale_q(c->coded_frame->pts,
|
||||
c->time_base, audio_stream->time_base);
|
||||
fprintf(stderr, "Audio Frame PTS: %d\n", (int)pkt.pts);
|
||||
@ -175,7 +173,7 @@ static AVFrame* alloc_picture(int pix_fmt, int width, int height)
|
||||
* first is always desired guess_format parameter */
|
||||
static const char** get_file_extensions(int format)
|
||||
{
|
||||
switch(format) {
|
||||
switch (format) {
|
||||
case FFMPEG_DV: {
|
||||
static const char * rv[] = { ".dv", NULL };
|
||||
return rv;
|
||||
@ -372,7 +370,7 @@ static void set_ffmpeg_property_option(AVCodecContext* c, IDProperty * prop)
|
||||
*param++ = 0;
|
||||
}
|
||||
|
||||
switch(prop->type) {
|
||||
switch (prop->type) {
|
||||
case IDP_STRING:
|
||||
fprintf(stderr, "%s.\n", IDP_String(prop));
|
||||
av_set_string3(c, prop->name, IDP_String(prop), 1, &rv);
|
||||
@ -717,7 +715,7 @@ static int start_ffmpeg_impl(struct RenderData *rd, int rectx, int recty, Report
|
||||
|
||||
BLI_snprintf(of->filename, sizeof(of->filename), "%s", name);
|
||||
/* set the codec to the user's selection */
|
||||
switch(ffmpeg_type) {
|
||||
switch (ffmpeg_type) {
|
||||
case FFMPEG_AVI:
|
||||
case FFMPEG_MOV:
|
||||
case FFMPEG_MKV:
|
||||
@ -929,8 +927,7 @@ int start_ffmpeg(struct Scene *scene, RenderData *rd, int rectx, int recty, Repo
|
||||
|
||||
success = start_ffmpeg_impl(rd, rectx, recty, reports);
|
||||
#ifdef WITH_AUDASPACE
|
||||
if (audio_stream)
|
||||
{
|
||||
if (audio_stream) {
|
||||
AVCodecContext* c = audio_stream->codec;
|
||||
AUD_DeviceSpecs specs;
|
||||
specs.channels = c->channels;
|
||||
@ -974,8 +971,7 @@ int append_ffmpeg(RenderData *rd, int start_frame, int frame, int *pixels, int r
|
||||
// why is this done before writing the video frame and again at end_ffmpeg?
|
||||
// write_audio_frames(frame / (((double)rd->frs_sec) / rd->frs_sec_base));
|
||||
|
||||
if (video_stream)
|
||||
{
|
||||
if (video_stream) {
|
||||
avframe= generate_video_frame((unsigned char*) pixels, reports);
|
||||
success= (avframe && write_video_frame(rd, frame - start_frame, avframe, reports));
|
||||
|
||||
@ -1172,10 +1168,12 @@ static const AVOption *my_av_find_opt(void *v, const char *name,
|
||||
const AVOption *o= c->option;
|
||||
|
||||
for (;o && o->name; o++) {
|
||||
if (!strcmp(o->name, name) &&
|
||||
(!unit || (o->unit && !strcmp(o->unit, unit))) &&
|
||||
(o->flags & mask) == flags )
|
||||
if (!strcmp(o->name, name) &&
|
||||
(!unit || (o->unit && !strcmp(o->unit, unit))) &&
|
||||
(o->flags & mask) == flags)
|
||||
{
|
||||
return o;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
@ -217,12 +217,10 @@ static void bvh_insertionsort(BVHNode **a, int lo, int hi, int axis)
|
||||
{
|
||||
int i,j;
|
||||
BVHNode *t;
|
||||
for (i=lo; i < hi; i++)
|
||||
{
|
||||
for (i=lo; i < hi; i++) {
|
||||
j=i;
|
||||
t = a[i];
|
||||
while ((j!=lo) && (t->bv[axis] < (a[j-1])->bv[axis]))
|
||||
{
|
||||
while ((j!=lo) && (t->bv[axis] < (a[j-1])->bv[axis])) {
|
||||
a[j] = a[j-1];
|
||||
j--;
|
||||
}
|
||||
@ -233,8 +231,7 @@ static void bvh_insertionsort(BVHNode **a, int lo, int hi, int axis)
|
||||
static int bvh_partition(BVHNode **a, int lo, int hi, BVHNode * x, int axis)
|
||||
{
|
||||
int i=lo, j=hi;
|
||||
while (1)
|
||||
{
|
||||
while (1) {
|
||||
while ((a[i])->bv[axis] < x->bv[axis]) i++;
|
||||
j--;
|
||||
while (x->bv[axis] < (a[j])->bv[axis]) j--;
|
||||
@ -284,22 +281,18 @@ static void bvh_heapsort(BVHNode **a, int lo, int hi, int axis)
|
||||
|
||||
static BVHNode *bvh_medianof3(BVHNode **a, int lo, int mid, int hi, int axis) // returns Sortable
|
||||
{
|
||||
if ((a[mid])->bv[axis] < (a[lo])->bv[axis])
|
||||
{
|
||||
if ((a[mid])->bv[axis] < (a[lo])->bv[axis]) {
|
||||
if ((a[hi])->bv[axis] < (a[mid])->bv[axis])
|
||||
return a[mid];
|
||||
else
|
||||
{
|
||||
else {
|
||||
if ((a[hi])->bv[axis] < (a[lo])->bv[axis])
|
||||
return a[hi];
|
||||
else
|
||||
return a[lo];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((a[hi])->bv[axis] < (a[mid])->bv[axis])
|
||||
{
|
||||
else {
|
||||
if ((a[hi])->bv[axis] < (a[mid])->bv[axis]) {
|
||||
if ((a[hi])->bv[axis] < (a[lo])->bv[axis])
|
||||
return a[lo];
|
||||
else
|
||||
@ -354,8 +347,7 @@ static void sort_along_axis(BVHTree *tree, int start, int end, int axis)
|
||||
static int partition_nth_element(BVHNode **a, int _begin, int _end, int n, int axis)
|
||||
{
|
||||
int begin = _begin, end = _end, cut;
|
||||
while (end-begin > 3)
|
||||
{
|
||||
while (end-begin > 3) {
|
||||
cut = bvh_partition(a, begin, end, bvh_medianof3(a, begin, (begin+end)/2, end-1, axis), axis );
|
||||
if (cut <= n)
|
||||
begin = cut;
|
||||
@ -375,8 +367,7 @@ static void build_skip_links(BVHTree *tree, BVHNode *node, BVHNode *left, BVHNod
|
||||
node->skip[0] = left;
|
||||
node->skip[1] = right;
|
||||
|
||||
for (i = 0; i < node->totnode; i++)
|
||||
{
|
||||
for (i = 0; i < node->totnode; i++) {
|
||||
if (i+1 < node->totnode)
|
||||
build_skip_links(tree, node->children[i], left, node->children[i+1] );
|
||||
else
|
||||
@ -396,20 +387,16 @@ static void create_kdop_hull(BVHTree *tree, BVHNode *node, const float *co, int
|
||||
int i, k;
|
||||
|
||||
// don't init boudings for the moving case
|
||||
if (!moving)
|
||||
{
|
||||
for (i = tree->start_axis; i < tree->stop_axis; i++)
|
||||
{
|
||||
bv[2*i] = FLT_MAX;
|
||||
bv[2*i + 1] = -FLT_MAX;
|
||||
if (!moving) {
|
||||
for (i = tree->start_axis; i < tree->stop_axis; i++) {
|
||||
bv[2 * i] = FLT_MAX;
|
||||
bv[2 * i + 1] = -FLT_MAX;
|
||||
}
|
||||
}
|
||||
|
||||
for (k = 0; k < numpoints; k++)
|
||||
{
|
||||
// for all Axes.
|
||||
for (i = tree->start_axis; i < tree->stop_axis; i++)
|
||||
{
|
||||
for (k = 0; k < numpoints; k++) {
|
||||
/* for all Axes. */
|
||||
for (i = tree->start_axis; i < tree->stop_axis; i++) {
|
||||
newminmax = dot_v3v3(&co[k * 3], KDOP_AXES[i]);
|
||||
if (newminmax < bv[2 * i])
|
||||
bv[2 * i] = newminmax;
|
||||
@ -427,17 +414,14 @@ static void refit_kdop_hull(BVHTree *tree, BVHNode *node, int start, int end)
|
||||
float *bv = node->bv;
|
||||
|
||||
|
||||
for (i = tree->start_axis; i < tree->stop_axis; i++)
|
||||
{
|
||||
for (i = tree->start_axis; i < tree->stop_axis; i++) {
|
||||
bv[2*i] = FLT_MAX;
|
||||
bv[2*i + 1] = -FLT_MAX;
|
||||
}
|
||||
|
||||
for (j = start; j < end; j++)
|
||||
{
|
||||
// for all Axes.
|
||||
for (i = tree->start_axis; i < tree->stop_axis; i++)
|
||||
{
|
||||
for (j = start; j < end; j++) {
|
||||
/* for all Axes. */
|
||||
for (i = tree->start_axis; i < tree->stop_axis; i++) {
|
||||
newmin = tree->nodes[j]->bv[(2 * i)];
|
||||
if ((newmin < bv[(2 * i)]))
|
||||
bv[(2 * i)] = newmin;
|
||||
@ -459,15 +443,13 @@ static char get_largest_axis(float *bv)
|
||||
middle_point[0] = (bv[1]) - (bv[0]); // x axis
|
||||
middle_point[1] = (bv[3]) - (bv[2]); // y axis
|
||||
middle_point[2] = (bv[5]) - (bv[4]); // z axis
|
||||
if (middle_point[0] > middle_point[1])
|
||||
{
|
||||
if (middle_point[0] > middle_point[1]) {
|
||||
if (middle_point[0] > middle_point[2])
|
||||
return 1; // max x axis
|
||||
else
|
||||
return 5; // max z axis
|
||||
}
|
||||
else
|
||||
{
|
||||
else {
|
||||
if (middle_point[1] > middle_point[2])
|
||||
return 3; // max y axis
|
||||
else
|
||||
@ -481,18 +463,14 @@ static void node_join(BVHTree *tree, BVHNode *node)
|
||||
{
|
||||
int i, j;
|
||||
|
||||
for (i = tree->start_axis; i < tree->stop_axis; i++)
|
||||
{
|
||||
for (i = tree->start_axis; i < tree->stop_axis; i++) {
|
||||
node->bv[2*i] = FLT_MAX;
|
||||
node->bv[2*i + 1] = -FLT_MAX;
|
||||
}
|
||||
|
||||
for (i = 0; i < tree->tree_type; i++)
|
||||
{
|
||||
if (node->children[i])
|
||||
{
|
||||
for (j = tree->start_axis; j < tree->stop_axis; j++)
|
||||
{
|
||||
for (i = 0; i < tree->tree_type; i++) {
|
||||
if (node->children[i]) {
|
||||
for (j = tree->start_axis; j < tree->stop_axis; j++) {
|
||||
// update minimum
|
||||
if (node->children[i]->bv[(2 * j)] < node->bv[(2 * j)])
|
||||
node->bv[(2 * j)] = node->children[i]->bv[(2 * j)];
|
||||
@ -619,17 +597,17 @@ static void build_implicit_tree_helper(BVHTree *tree, BVHBuildHelper *data)
|
||||
data->tree_type= tree->tree_type;
|
||||
|
||||
//Calculate the smallest tree_type^n such that tree_type^n >= num_leafs
|
||||
for (
|
||||
data->leafs_per_child[0] = 1;
|
||||
data->leafs_per_child[0] < data->totleafs;
|
||||
data->leafs_per_child[0] *= data->tree_type
|
||||
);
|
||||
for (data->leafs_per_child[0] = 1;
|
||||
data->leafs_per_child[0] < data->totleafs;
|
||||
data->leafs_per_child[0] *= data->tree_type)
|
||||
{
|
||||
/* pass */
|
||||
}
|
||||
|
||||
data->branches_on_level[0] = 1;
|
||||
|
||||
//We could stop the loop first (but I am lazy to find out when)
|
||||
for (depth = 1; depth < 32; depth++)
|
||||
{
|
||||
for (depth = 1; depth < 32; depth++) {
|
||||
data->branches_on_level[depth] = data->branches_on_level[depth-1] * data->tree_type;
|
||||
data->leafs_per_child [depth] = data->leafs_per_child [depth-1] / data->tree_type;
|
||||
}
|
||||
@ -700,8 +678,7 @@ static int implicit_needed_branches(int tree_type, int leafs)
|
||||
static void split_leafs(BVHNode **leafs_array, int *nth, int partitions, int split_axis)
|
||||
{
|
||||
int i;
|
||||
for (i=0; i < partitions-1; i++)
|
||||
{
|
||||
for (i=0; i < partitions-1; i++) {
|
||||
if (nth[i] >= nth[partitions])
|
||||
break;
|
||||
|
||||
@ -742,8 +719,7 @@ static void non_recursive_bvh_div_nodes(BVHTree *tree, BVHNode *branches_array,
|
||||
|
||||
//Most of bvhtree code relies on 1-leaf trees having at least one branch
|
||||
//We handle that special case here
|
||||
if (num_leafs == 1)
|
||||
{
|
||||
if (num_leafs == 1) {
|
||||
BVHNode *root = branches_array+0;
|
||||
refit_kdop_hull(tree, root, 0, num_leafs);
|
||||
root->main_axis = get_largest_axis(root->bv) / 2;
|
||||
@ -758,8 +734,7 @@ static void non_recursive_bvh_div_nodes(BVHTree *tree, BVHNode *branches_array,
|
||||
build_implicit_tree_helper(tree, &data);
|
||||
|
||||
//Loop tree levels (log N) loops
|
||||
for (i=1, depth = 1; i <= num_branches; i = i*tree_type + tree_offset, depth++)
|
||||
{
|
||||
for (i=1, depth = 1; i <= num_branches; i = i*tree_type + tree_offset, depth++) {
|
||||
const int first_of_next_level = i*tree_type + tree_offset;
|
||||
const int end_j = MIN2(first_of_next_level, num_branches + 1); //index of last branch on this level
|
||||
int j;
|
||||
@ -885,22 +860,19 @@ BVHTree *BLI_bvhtree_new(int maxsize, float epsilon, char tree_type, char axis)
|
||||
|
||||
tree->nodes = (BVHNode **)MEM_callocN(sizeof(BVHNode *)*numnodes, "BVHNodes");
|
||||
|
||||
if (!tree->nodes)
|
||||
{
|
||||
if (!tree->nodes) {
|
||||
MEM_freeN(tree);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
tree->nodebv = (float*)MEM_callocN(sizeof(float)* axis * numnodes, "BVHNodeBV");
|
||||
if (!tree->nodebv)
|
||||
{
|
||||
if (!tree->nodebv) {
|
||||
MEM_freeN(tree->nodes);
|
||||
MEM_freeN(tree);
|
||||
}
|
||||
|
||||
tree->nodechild = (BVHNode**)MEM_callocN(sizeof(BVHNode*) * tree_type * numnodes, "BVHNodeBV");
|
||||
if (!tree->nodechild)
|
||||
{
|
||||
if (!tree->nodechild) {
|
||||
MEM_freeN(tree->nodebv);
|
||||
MEM_freeN(tree->nodes);
|
||||
MEM_freeN(tree);
|
||||
@ -908,8 +880,7 @@ BVHTree *BLI_bvhtree_new(int maxsize, float epsilon, char tree_type, char axis)
|
||||
|
||||
tree->nodearray = (BVHNode *)MEM_callocN(sizeof(BVHNode)* numnodes, "BVHNodeArray");
|
||||
|
||||
if (!tree->nodearray)
|
||||
{
|
||||
if (!tree->nodearray) {
|
||||
MEM_freeN(tree->nodechild);
|
||||
MEM_freeN(tree->nodebv);
|
||||
MEM_freeN(tree->nodes);
|
||||
@ -918,8 +889,7 @@ BVHTree *BLI_bvhtree_new(int maxsize, float epsilon, char tree_type, char axis)
|
||||
}
|
||||
|
||||
//link the dynamic bv and child links
|
||||
for (i=0; i< numnodes; i++)
|
||||
{
|
||||
for (i=0; i< numnodes; i++) {
|
||||
tree->nodearray[i].bv = tree->nodebv + i * axis;
|
||||
tree->nodearray[i].children = tree->nodechild + i * tree_type;
|
||||
}
|
||||
@ -931,8 +901,7 @@ BVHTree *BLI_bvhtree_new(int maxsize, float epsilon, char tree_type, char axis)
|
||||
|
||||
void BLI_bvhtree_free(BVHTree *tree)
|
||||
{
|
||||
if (tree)
|
||||
{
|
||||
if (tree) {
|
||||
MEM_freeN(tree->nodes);
|
||||
MEM_freeN(tree->nodearray);
|
||||
MEM_freeN(tree->nodebv);
|
||||
@ -985,8 +954,7 @@ int BLI_bvhtree_insert(BVHTree *tree, int index, const float *co, int numpoints)
|
||||
node->index= index;
|
||||
|
||||
// inflate the bv with some epsilon
|
||||
for (i = tree->start_axis; i < tree->stop_axis; i++)
|
||||
{
|
||||
for (i = tree->start_axis; i < tree->stop_axis; i++) {
|
||||
node->bv[(2 * i)] -= tree->epsilon; // minimum
|
||||
node->bv[(2 * i) + 1] += tree->epsilon; // maximum
|
||||
}
|
||||
@ -1013,8 +981,7 @@ int BLI_bvhtree_update_node(BVHTree *tree, int index, const float *co, const flo
|
||||
create_kdop_hull(tree, node, co_moving, numpoints, 1);
|
||||
|
||||
// inflate the bv with some epsilon
|
||||
for (i = tree->start_axis; i < tree->stop_axis; i++)
|
||||
{
|
||||
for (i = tree->start_axis; i < tree->stop_axis; i++) {
|
||||
node->bv[(2 * i)] -= tree->epsilon; // minimum
|
||||
node->bv[(2 * i) + 1] += tree->epsilon; // maximum
|
||||
}
|
||||
@ -1057,8 +1024,7 @@ static int tree_overlap(BVHNode *node1, BVHNode *node2, int start_axis, int stop
|
||||
bv2 += start_axis<<1;
|
||||
|
||||
// test all axis if min + max overlap
|
||||
for (; bv1 != bv1_end; bv1+=2, bv2+=2)
|
||||
{
|
||||
for (; bv1 != bv1_end; bv1+=2, bv2+=2) {
|
||||
if ((*(bv1) > *(bv2 + 1)) || (*(bv2) > *(bv1 + 1)))
|
||||
return 0;
|
||||
}
|
||||
@ -1070,27 +1036,21 @@ static void traverse(BVHOverlapData *data, BVHNode *node1, BVHNode *node2)
|
||||
{
|
||||
int j;
|
||||
|
||||
if (tree_overlap(node1, node2, data->start_axis, data->stop_axis))
|
||||
{
|
||||
if (tree_overlap(node1, node2, data->start_axis, data->stop_axis)) {
|
||||
// check if node1 is a leaf
|
||||
if (!node1->totnode)
|
||||
{
|
||||
if (!node1->totnode) {
|
||||
// check if node2 is a leaf
|
||||
if (!node2->totnode)
|
||||
{
|
||||
if (!node2->totnode) {
|
||||
|
||||
if (node1 == node2)
|
||||
{
|
||||
if (node1 == node2) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (data->i >= data->max_overlap)
|
||||
{
|
||||
if (data->i >= data->max_overlap) {
|
||||
// try to make alloc'ed memory bigger
|
||||
data->overlap = realloc(data->overlap, sizeof(BVHTreeOverlap)*data->max_overlap*2);
|
||||
|
||||
if (!data->overlap)
|
||||
{
|
||||
if (!data->overlap) {
|
||||
printf("Out of Memory in traverse\n");
|
||||
return;
|
||||
}
|
||||
@ -1103,20 +1063,15 @@ static void traverse(BVHOverlapData *data, BVHNode *node1, BVHNode *node2)
|
||||
|
||||
data->i++;
|
||||
}
|
||||
else
|
||||
{
|
||||
for (j = 0; j < data->tree2->tree_type; j++)
|
||||
{
|
||||
else {
|
||||
for (j = 0; j < data->tree2->tree_type; j++) {
|
||||
if (node2->children[j])
|
||||
traverse(data, node1, node2->children[j]);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
for (j = 0; j < data->tree2->tree_type; j++)
|
||||
{
|
||||
else {
|
||||
for (j = 0; j < data->tree2->tree_type; j++) {
|
||||
if (node1->children[j])
|
||||
traverse(data, node1->children[j], node2);
|
||||
}
|
||||
@ -1142,8 +1097,7 @@ BVHTreeOverlap *BLI_bvhtree_overlap(BVHTree *tree1, BVHTree *tree2, unsigned int
|
||||
|
||||
data = MEM_callocN(sizeof(BVHOverlapData *)* tree1->tree_type, "BVHOverlapData_star");
|
||||
|
||||
for (j = 0; j < tree1->tree_type; j++)
|
||||
{
|
||||
for (j = 0; j < tree1->tree_type; j++) {
|
||||
data[j] = (BVHOverlapData *)MEM_callocN(sizeof(BVHOverlapData), "BVHOverlapData");
|
||||
|
||||
// init BVHOverlapData
|
||||
@ -1157,8 +1111,7 @@ BVHTreeOverlap *BLI_bvhtree_overlap(BVHTree *tree1, BVHTree *tree2, unsigned int
|
||||
}
|
||||
|
||||
#pragma omp parallel for private(j) schedule(static)
|
||||
for (j = 0; j < MIN2(tree1->tree_type, tree1->nodes[tree1->totleaf]->totnode); j++)
|
||||
{
|
||||
for (j = 0; j < MIN2(tree1->tree_type, tree1->nodes[tree1->totleaf]->totnode); j++) {
|
||||
traverse(data[j], tree1->nodes[tree1->totleaf]->children[j], tree2->nodes[tree2->totleaf]);
|
||||
}
|
||||
|
||||
@ -1167,14 +1120,12 @@ BVHTreeOverlap *BLI_bvhtree_overlap(BVHTree *tree1, BVHTree *tree2, unsigned int
|
||||
|
||||
to = overlap = (BVHTreeOverlap *)MEM_callocN(sizeof(BVHTreeOverlap)*total, "BVHTreeOverlap");
|
||||
|
||||
for (j = 0; j < tree1->tree_type; j++)
|
||||
{
|
||||
for (j = 0; j < tree1->tree_type; j++) {
|
||||
memcpy(to, data[j]->overlap, data[j]->i*sizeof(BVHTreeOverlap));
|
||||
to+=data[j]->i;
|
||||
}
|
||||
|
||||
for (j = 0; j < tree1->tree_type; j++)
|
||||
{
|
||||
for (j = 0; j < tree1->tree_type; j++) {
|
||||
free(data[j]->overlap);
|
||||
MEM_freeN(data[j]);
|
||||
}
|
||||
@ -1191,8 +1142,7 @@ static float calc_nearest_point(const float proj[3], BVHNode *node, float *neare
|
||||
const float *bv = node->bv;
|
||||
|
||||
//nearest on AABB hull
|
||||
for (i=0; i != 3; i++, bv += 2)
|
||||
{
|
||||
for (i=0; i != 3; i++, bv += 2) {
|
||||
if (bv[0] > proj[i])
|
||||
nearest[i] = bv[0];
|
||||
else if (bv[1] < proj[i])
|
||||
@ -1235,35 +1185,28 @@ typedef struct NodeDistance
|
||||
// TODO: use a priority queue to reduce the number of nodes looked on
|
||||
static void dfs_find_nearest_dfs(BVHNearestData *data, BVHNode *node)
|
||||
{
|
||||
if (node->totnode == 0)
|
||||
{
|
||||
if (node->totnode == 0) {
|
||||
if (data->callback)
|
||||
data->callback(data->userdata , node->index, data->co, &data->nearest);
|
||||
else
|
||||
{
|
||||
else {
|
||||
data->nearest.index = node->index;
|
||||
data->nearest.dist = calc_nearest_point(data->proj, node, data->nearest.co);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
else {
|
||||
//Better heuristic to pick the closest node to dive on
|
||||
int i;
|
||||
float nearest[3];
|
||||
|
||||
if (data->proj[ node->main_axis ] <= node->children[0]->bv[node->main_axis*2+1])
|
||||
{
|
||||
if (data->proj[ node->main_axis ] <= node->children[0]->bv[node->main_axis*2+1]) {
|
||||
|
||||
for (i=0; i != node->totnode; i++)
|
||||
{
|
||||
for (i=0; i != node->totnode; i++) {
|
||||
if ( calc_nearest_point(data->proj, node->children[i], nearest) >= data->nearest.dist) continue;
|
||||
dfs_find_nearest_dfs(data, node->children[i]);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (i=node->totnode-1; i >= 0 ; i--)
|
||||
{
|
||||
else {
|
||||
for (i=node->totnode-1; i >= 0 ; i--) {
|
||||
if ( calc_nearest_point(data->proj, node->children[i], nearest) >= data->nearest.dist) continue;
|
||||
dfs_find_nearest_dfs(data, node->children[i]);
|
||||
}
|
||||
@ -1381,17 +1324,14 @@ int BLI_bvhtree_find_nearest(BVHTree *tree, const float co[3], BVHTreeNearest *n
|
||||
data.callback = callback;
|
||||
data.userdata = userdata;
|
||||
|
||||
for (i = data.tree->start_axis; i != data.tree->stop_axis; i++)
|
||||
{
|
||||
for (i = data.tree->start_axis; i != data.tree->stop_axis; i++) {
|
||||
data.proj[i] = dot_v3v3(data.co, KDOP_AXES[i]);
|
||||
}
|
||||
|
||||
if (nearest)
|
||||
{
|
||||
if (nearest) {
|
||||
memcpy( &data.nearest , nearest, sizeof(*nearest) );
|
||||
}
|
||||
else
|
||||
{
|
||||
else {
|
||||
data.nearest.index = -1;
|
||||
data.nearest.dist = FLT_MAX;
|
||||
}
|
||||
@ -1401,8 +1341,7 @@ int BLI_bvhtree_find_nearest(BVHTree *tree, const float co[3], BVHTreeNearest *n
|
||||
dfs_find_nearest_begin(&data, root);
|
||||
|
||||
//copy back results
|
||||
if (nearest)
|
||||
{
|
||||
if (nearest) {
|
||||
memcpy(nearest, &data.nearest, sizeof(*nearest));
|
||||
}
|
||||
|
||||
@ -1424,10 +1363,8 @@ static float ray_nearest_hit(BVHRayCastData *data, float *bv)
|
||||
|
||||
float low = 0, upper = data->hit.dist;
|
||||
|
||||
for (i=0; i != 3; i++, bv += 2)
|
||||
{
|
||||
if (data->ray_dot_axis[i] == 0.0f)
|
||||
{
|
||||
for (i=0; i != 3; i++, bv += 2) {
|
||||
if (data->ray_dot_axis[i] == 0.0f) {
|
||||
//axis aligned ray
|
||||
if (data->ray.origin[i] < bv[0] - data->ray.radius ||
|
||||
data->ray.origin[i] > bv[1] + data->ray.radius)
|
||||
@ -1435,18 +1372,15 @@ static float ray_nearest_hit(BVHRayCastData *data, float *bv)
|
||||
return FLT_MAX;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
else {
|
||||
float ll = (bv[0] - data->ray.radius - data->ray.origin[i]) / data->ray_dot_axis[i];
|
||||
float lu = (bv[1] + data->ray.radius - data->ray.origin[i]) / data->ray_dot_axis[i];
|
||||
|
||||
if (data->ray_dot_axis[i] > 0.0f)
|
||||
{
|
||||
if (data->ray_dot_axis[i] > 0.0f) {
|
||||
if (ll > low) low = ll;
|
||||
if (lu < upper) upper = lu;
|
||||
}
|
||||
else
|
||||
{
|
||||
else {
|
||||
if (lu > low) low = lu;
|
||||
if (ll < upper) upper = ll;
|
||||
}
|
||||
@ -1494,31 +1428,25 @@ static void dfs_raycast(BVHRayCastData *data, BVHNode *node)
|
||||
float dist = (data->ray.radius > 0.0f) ? ray_nearest_hit(data, node->bv) : fast_ray_nearest_hit(data, node);
|
||||
if (dist >= data->hit.dist) return;
|
||||
|
||||
if (node->totnode == 0)
|
||||
{
|
||||
if (data->callback)
|
||||
if (node->totnode == 0) {
|
||||
if (data->callback) {
|
||||
data->callback(data->userdata, node->index, &data->ray, &data->hit);
|
||||
else
|
||||
{
|
||||
}
|
||||
else {
|
||||
data->hit.index = node->index;
|
||||
data->hit.dist = dist;
|
||||
madd_v3_v3v3fl(data->hit.co, data->ray.origin, data->ray.direction, dist);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
else {
|
||||
//pick loop direction to dive into the tree (based on ray direction and split axis)
|
||||
if (data->ray_dot_axis[ (int)node->main_axis ] > 0.0f)
|
||||
{
|
||||
for (i=0; i != node->totnode; i++)
|
||||
{
|
||||
if (data->ray_dot_axis[ (int)node->main_axis ] > 0.0f) {
|
||||
for (i=0; i != node->totnode; i++) {
|
||||
dfs_raycast(data, node->children[i]);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (i=node->totnode-1; i >= 0; i--)
|
||||
{
|
||||
else {
|
||||
for (i=node->totnode-1; i >= 0; i--) {
|
||||
dfs_raycast(data, node->children[i]);
|
||||
}
|
||||
}
|
||||
@ -1575,13 +1503,11 @@ int BLI_bvhtree_ray_cast(BVHTree *tree, const float co[3], const float dir[3], f
|
||||
|
||||
normalize_v3(data.ray.direction);
|
||||
|
||||
for (i=0; i<3; i++)
|
||||
{
|
||||
for (i=0; i<3; i++) {
|
||||
data.ray_dot_axis[i] = dot_v3v3(data.ray.direction, KDOP_AXES[i]);
|
||||
data.idot_axis[i] = 1.0f / data.ray_dot_axis[i];
|
||||
|
||||
if (fabsf(data.ray_dot_axis[i]) < FLT_EPSILON)
|
||||
{
|
||||
if (fabsf(data.ray_dot_axis[i]) < FLT_EPSILON) {
|
||||
data.ray_dot_axis[i] = 0.0;
|
||||
}
|
||||
data.index[2*i] = data.idot_axis[i] < 0.0f ? 1 : 0;
|
||||
@ -1593,14 +1519,12 @@ int BLI_bvhtree_ray_cast(BVHTree *tree, const float co[3], const float dir[3], f
|
||||
|
||||
if (hit)
|
||||
memcpy( &data.hit, hit, sizeof(*hit) );
|
||||
else
|
||||
{
|
||||
else {
|
||||
data.hit.index = -1;
|
||||
data.hit.dist = FLT_MAX;
|
||||
}
|
||||
|
||||
if (root)
|
||||
{
|
||||
if (root) {
|
||||
dfs_raycast(&data, root);
|
||||
// iterative_raycast(&data, root);
|
||||
}
|
||||
@ -1635,8 +1559,7 @@ float BLI_bvhtree_bb_raycast(float *bv, const float light_start[3], const float
|
||||
|
||||
dist = ray_nearest_hit(&data, bv);
|
||||
|
||||
if (dist > 0.0f)
|
||||
{
|
||||
if (dist > 0.0f) {
|
||||
madd_v3_v3v3fl(pos, light_start, data.ray.direction, dist);
|
||||
}
|
||||
return dist;
|
||||
@ -1666,8 +1589,7 @@ typedef struct RangeQueryData
|
||||
|
||||
static void dfs_range_query(RangeQueryData *data, BVHNode *node)
|
||||
{
|
||||
if (node->totnode == 0)
|
||||
{
|
||||
if (node->totnode == 0) {
|
||||
#if 0 /*UNUSED*/
|
||||
//Calculate the node min-coords (if the node was a point then this is the point coordinates)
|
||||
float co[3];
|
||||
@ -1676,18 +1598,14 @@ static void dfs_range_query(RangeQueryData *data, BVHNode *node)
|
||||
co[2] = node->bv[4];
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
else {
|
||||
int i;
|
||||
for (i=0; i != node->totnode; i++)
|
||||
{
|
||||
for (i=0; i != node->totnode; i++) {
|
||||
float nearest[3];
|
||||
float dist = calc_nearest_point(data->center, node->children[i], nearest);
|
||||
if (dist < data->radius)
|
||||
{
|
||||
if (dist < data->radius) {
|
||||
//Its a leaf.. call the callback
|
||||
if (node->children[i]->totnode == 0)
|
||||
{
|
||||
if (node->children[i]->totnode == 0) {
|
||||
data->hits++;
|
||||
data->callback(data->userdata, node->children[i]->index, dist);
|
||||
}
|
||||
@ -1711,15 +1629,12 @@ int BLI_bvhtree_range_query(BVHTree *tree, const float co[3], float radius, BVHT
|
||||
data.callback = callback;
|
||||
data.userdata = userdata;
|
||||
|
||||
if (root != NULL)
|
||||
{
|
||||
if (root != NULL) {
|
||||
float nearest[3];
|
||||
float dist = calc_nearest_point(data.center, root, nearest);
|
||||
if (dist < data.radius)
|
||||
{
|
||||
//Its a leaf.. call the callback
|
||||
if (root->totnode == 0)
|
||||
{
|
||||
if (dist < data.radius) {
|
||||
/* Its a leaf.. call the callback */
|
||||
if (root->totnode == 0) {
|
||||
data.hits++;
|
||||
data.callback(data.userdata, root->index, dist);
|
||||
}
|
||||
|
@ -141,8 +141,7 @@ DLRBT_Node *BLI_dlrbTree_search (DLRBT_Tree *tree, DLRBT_Comparator_FP cmp_cb, v
|
||||
return NULL;
|
||||
|
||||
/* iteratively perform this search */
|
||||
while (node && found==0)
|
||||
{
|
||||
while (node && found == 0) {
|
||||
/* check if traverse further or not
|
||||
* NOTE: it is assumed that the values will be unit values only
|
||||
*/
|
||||
@ -183,8 +182,7 @@ DLRBT_Node *BLI_dlrbTree_search_exact (DLRBT_Tree *tree, DLRBT_Comparator_FP cmp
|
||||
return NULL;
|
||||
|
||||
/* iteratively perform this search */
|
||||
while (node && found==0)
|
||||
{
|
||||
while (node && found==0) {
|
||||
/* check if traverse further or not
|
||||
* NOTE: it is assumed that the values will be unit values only
|
||||
*/
|
||||
|
@ -387,7 +387,7 @@ void bpath_traverse_id(Main *bmain, ID *id, BPathVisitor visit_cb, const int fla
|
||||
return;
|
||||
}
|
||||
|
||||
switch(GS(id->name)) {
|
||||
switch (GS(id->name)) {
|
||||
case ID_IM:
|
||||
ima= (Image *)id;
|
||||
if (ima->packedfile == NULL || (flag & BPATH_TRAVERSE_SKIP_PACKED) == 0) {
|
||||
|
@ -85,7 +85,9 @@ char *BLI_dynlib_get_error_as_string(DynamicLibrary *lib)
|
||||
if (FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM|FORMAT_MESSAGE_IGNORE_INSERTS,
|
||||
NULL, err, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
|
||||
buf, sizeof(buf), NULL))
|
||||
{
|
||||
return buf;
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
|
@ -127,17 +127,21 @@ static void freetypechar_to_vchar(FT_Face face, FT_ULong charcode, VFontData *vf
|
||||
npoints[j] = ftoutline.contours[j] - ftoutline.contours[j - 1];
|
||||
}
|
||||
|
||||
// get number of on-curve points for beziertriples (including conic virtual on-points)
|
||||
// get number of on-curve points for beziertriples (including conic virtual on-points)
|
||||
for (j = 0; j < ftoutline.n_contours; j++) {
|
||||
for (k = 0; k < npoints[j]; k++) {
|
||||
if (j > 0) l = k + ftoutline.contours[j - 1] + 1; else l = k;
|
||||
if (ftoutline.tags[l] == FT_Curve_Tag_On)
|
||||
onpoints[j]++;
|
||||
l = (j > 0) ? (k + ftoutline.contours[j - 1] + 1) : k;
|
||||
|
||||
if (k < npoints[j] - 1 )
|
||||
if (ftoutline.tags[l] == FT_Curve_Tag_On)
|
||||
onpoints[j]++;
|
||||
|
||||
if (k < npoints[j] - 1 ) {
|
||||
if ( ftoutline.tags[l] == FT_Curve_Tag_Conic &&
|
||||
ftoutline.tags[l+1] == FT_Curve_Tag_Conic)
|
||||
ftoutline.tags[l+1] == FT_Curve_Tag_Conic)
|
||||
{
|
||||
onpoints[j]++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -398,8 +402,7 @@ static VFontData *objfnt_to_ftvfontdata(PackedFile * pf)
|
||||
}
|
||||
|
||||
// Load characters
|
||||
while (charcode < 256)
|
||||
{
|
||||
while (charcode < 256) {
|
||||
// Generate the font data
|
||||
freetypechar_to_vchar(face, charcode, vfd);
|
||||
|
||||
|
@ -46,13 +46,11 @@ static void flagAxialSymmetry(BNode *root_node, BNode *end_node, BArc *arc, int
|
||||
|
||||
void BLI_freeNode(BGraph *graph, BNode *node)
|
||||
{
|
||||
if (node->arcs)
|
||||
{
|
||||
if (node->arcs) {
|
||||
MEM_freeN(node->arcs);
|
||||
}
|
||||
|
||||
if (graph->free_node)
|
||||
{
|
||||
if (graph->free_node) {
|
||||
graph->free_node(node);
|
||||
}
|
||||
}
|
||||
@ -70,8 +68,7 @@ BNode *BLI_otherNode(BArc *arc, BNode *node)
|
||||
|
||||
void BLI_removeArc(BGraph *graph, BArc *arc)
|
||||
{
|
||||
if (graph->free_arc)
|
||||
{
|
||||
if (graph->free_arc) {
|
||||
graph->free_arc(arc);
|
||||
}
|
||||
|
||||
@ -82,8 +79,7 @@ void BLI_flagNodes(BGraph *graph, int flag)
|
||||
{
|
||||
BNode *node;
|
||||
|
||||
for (node = graph->nodes.first; node; node = node->next)
|
||||
{
|
||||
for (node = graph->nodes.first; node; node = node->next) {
|
||||
node->flag = flag;
|
||||
}
|
||||
}
|
||||
@ -92,8 +88,7 @@ void BLI_flagArcs(BGraph *graph, int flag)
|
||||
{
|
||||
BArc *arc;
|
||||
|
||||
for (arc = graph->arcs.first; arc; arc = arc->next)
|
||||
{
|
||||
for (arc = graph->arcs.first; arc; arc = arc->next) {
|
||||
arc->flag = flag;
|
||||
}
|
||||
}
|
||||
@ -109,10 +104,8 @@ void BLI_buildAdjacencyList(BGraph *graph)
|
||||
BNode *node;
|
||||
BArc *arc;
|
||||
|
||||
for (node = graph->nodes.first; node; node = node->next)
|
||||
{
|
||||
if (node->arcs != NULL)
|
||||
{
|
||||
for (node = graph->nodes.first; node; node = node->next) {
|
||||
if (node->arcs != NULL) {
|
||||
MEM_freeN(node->arcs);
|
||||
}
|
||||
|
||||
@ -122,16 +115,13 @@ void BLI_buildAdjacencyList(BGraph *graph)
|
||||
node->flag = 0;
|
||||
}
|
||||
|
||||
for (arc = graph->arcs.first; arc; arc= arc->next)
|
||||
{
|
||||
for (arc = graph->arcs.first; arc; arc= arc->next) {
|
||||
addArcToNodeAdjacencyList(arc->head, arc);
|
||||
addArcToNodeAdjacencyList(arc->tail, arc);
|
||||
}
|
||||
|
||||
for (node = graph->nodes.first; node; node = node->next)
|
||||
{
|
||||
if (node->degree != node->flag)
|
||||
{
|
||||
for (node = graph->nodes.first; node; node = node->next) {
|
||||
if (node->degree != node->flag) {
|
||||
printf("error in node [%p]. Added only %i arcs out of %i\n", (void *)node, node->flag, node->degree);
|
||||
}
|
||||
}
|
||||
@ -141,8 +131,7 @@ void BLI_rebuildAdjacencyListForNode(BGraph* graph, BNode *node)
|
||||
{
|
||||
BArc *arc;
|
||||
|
||||
if (node->arcs != NULL)
|
||||
{
|
||||
if (node->arcs != NULL) {
|
||||
MEM_freeN(node->arcs);
|
||||
}
|
||||
|
||||
@ -151,20 +140,16 @@ void BLI_rebuildAdjacencyListForNode(BGraph* graph, BNode *node)
|
||||
/* temporary use to indicate the first index available in the lists */
|
||||
node->flag = 0;
|
||||
|
||||
for (arc = graph->arcs.first; arc; arc= arc->next)
|
||||
{
|
||||
if (arc->head == node)
|
||||
{
|
||||
for (arc = graph->arcs.first; arc; arc= arc->next) {
|
||||
if (arc->head == node) {
|
||||
addArcToNodeAdjacencyList(arc->head, arc);
|
||||
}
|
||||
else if (arc->tail == node)
|
||||
{
|
||||
else if (arc->tail == node) {
|
||||
addArcToNodeAdjacencyList(arc->tail, arc);
|
||||
}
|
||||
}
|
||||
|
||||
if (node->degree != node->flag)
|
||||
{
|
||||
if (node->degree != node->flag) {
|
||||
printf("error in node [%p]. Added only %i arcs out of %i\n", (void *)node, node->flag, node->degree);
|
||||
}
|
||||
}
|
||||
@ -173,10 +158,8 @@ void BLI_freeAdjacencyList(BGraph *graph)
|
||||
{
|
||||
BNode *node;
|
||||
|
||||
for (node = graph->nodes.first; node; node = node->next)
|
||||
{
|
||||
if (node->arcs != NULL)
|
||||
{
|
||||
for (node = graph->nodes.first; node; node = node->next) {
|
||||
if (node->arcs != NULL) {
|
||||
MEM_freeN(node->arcs);
|
||||
node->arcs = NULL;
|
||||
}
|
||||
@ -187,10 +170,8 @@ int BLI_hasAdjacencyList(BGraph *graph)
|
||||
{
|
||||
BNode *node;
|
||||
|
||||
for (node = graph->nodes.first; node; node = node->next)
|
||||
{
|
||||
if (node->arcs == NULL)
|
||||
{
|
||||
for (node = graph->nodes.first; node; node = node->next) {
|
||||
if (node->arcs == NULL) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@ -200,28 +181,24 @@ int BLI_hasAdjacencyList(BGraph *graph)
|
||||
|
||||
void BLI_replaceNodeInArc(BGraph *graph, BArc *arc, BNode *node_src, BNode *node_replaced)
|
||||
{
|
||||
if (arc->head == node_replaced)
|
||||
{
|
||||
if (arc->head == node_replaced) {
|
||||
arc->head = node_src;
|
||||
node_src->degree++;
|
||||
}
|
||||
|
||||
if (arc->tail == node_replaced)
|
||||
{
|
||||
if (arc->tail == node_replaced) {
|
||||
arc->tail = node_src;
|
||||
node_src->degree++;
|
||||
}
|
||||
|
||||
if (arc->head == arc->tail)
|
||||
{
|
||||
if (arc->head == arc->tail) {
|
||||
node_src->degree -= 2;
|
||||
|
||||
graph->free_arc(arc);
|
||||
BLI_freelinkN(&graph->arcs, arc);
|
||||
}
|
||||
|
||||
if (node_replaced->degree == 0)
|
||||
{
|
||||
if (node_replaced->degree == 0) {
|
||||
BLI_removeNode(graph, node_replaced);
|
||||
}
|
||||
}
|
||||
@ -230,26 +207,22 @@ void BLI_replaceNode(BGraph *graph, BNode *node_src, BNode *node_replaced)
|
||||
{
|
||||
BArc *arc, *next_arc;
|
||||
|
||||
for (arc = graph->arcs.first; arc; arc = next_arc)
|
||||
{
|
||||
for (arc = graph->arcs.first; arc; arc = next_arc) {
|
||||
next_arc = arc->next;
|
||||
|
||||
if (arc->head == node_replaced)
|
||||
{
|
||||
if (arc->head == node_replaced) {
|
||||
arc->head = node_src;
|
||||
node_replaced->degree--;
|
||||
node_src->degree++;
|
||||
}
|
||||
|
||||
if (arc->tail == node_replaced)
|
||||
{
|
||||
if (arc->tail == node_replaced) {
|
||||
arc->tail = node_src;
|
||||
node_replaced->degree--;
|
||||
node_src->degree++;
|
||||
}
|
||||
|
||||
if (arc->head == arc->tail)
|
||||
{
|
||||
if (arc->head == arc->tail) {
|
||||
node_src->degree -= 2;
|
||||
|
||||
graph->free_arc(arc);
|
||||
@ -257,8 +230,7 @@ void BLI_replaceNode(BGraph *graph, BNode *node_src, BNode *node_replaced)
|
||||
}
|
||||
}
|
||||
|
||||
if (node_replaced->degree == 0)
|
||||
{
|
||||
if (node_replaced->degree == 0) {
|
||||
BLI_removeNode(graph, node_replaced);
|
||||
}
|
||||
}
|
||||
@ -267,12 +239,9 @@ void BLI_removeDoubleNodes(BGraph *graph, float limit)
|
||||
{
|
||||
BNode *node_src, *node_replaced;
|
||||
|
||||
for (node_src = graph->nodes.first; node_src; node_src = node_src->next)
|
||||
{
|
||||
for (node_replaced = graph->nodes.first; node_replaced; node_replaced = node_replaced->next)
|
||||
{
|
||||
if (node_replaced != node_src && len_v3v3(node_replaced->p, node_src->p) <= limit)
|
||||
{
|
||||
for (node_src = graph->nodes.first; node_src; node_src = node_src->next) {
|
||||
for (node_replaced = graph->nodes.first; node_replaced; node_replaced = node_replaced->next) {
|
||||
if (node_replaced != node_src && len_v3v3(node_replaced->p, node_src->p) <= limit) {
|
||||
BLI_replaceNode(graph, node_src, node_replaced);
|
||||
}
|
||||
}
|
||||
@ -285,11 +254,9 @@ BNode * BLI_FindNodeByPosition(BGraph *graph, float *p, float limit)
|
||||
BNode *closest_node = NULL, *node;
|
||||
float min_distance = 0.0f;
|
||||
|
||||
for (node = graph->nodes.first; node; node = node->next)
|
||||
{
|
||||
for (node = graph->nodes.first; node; node = node->next) {
|
||||
float distance = len_v3v3(p, node->p);
|
||||
if (distance <= limit && (closest_node == NULL || distance < min_distance))
|
||||
{
|
||||
if (distance <= limit && (closest_node == NULL || distance < min_distance)) {
|
||||
closest_node = node;
|
||||
min_distance = distance;
|
||||
}
|
||||
@ -301,15 +268,13 @@ BNode * BLI_FindNodeByPosition(BGraph *graph, float *p, float limit)
|
||||
|
||||
static void flagSubgraph(BNode *node, int subgraph)
|
||||
{
|
||||
if (node->subgraph_index == 0)
|
||||
{
|
||||
if (node->subgraph_index == 0) {
|
||||
BArc *arc;
|
||||
int i;
|
||||
|
||||
node->subgraph_index = subgraph;
|
||||
|
||||
for (i = 0; i < node->degree; i++)
|
||||
{
|
||||
for (i = 0; i < node->degree; i++) {
|
||||
arc = node->arcs[i];
|
||||
flagSubgraph(BLI_otherNode(arc, node), subgraph);
|
||||
}
|
||||
@ -321,20 +286,16 @@ int BLI_FlagSubgraphs(BGraph *graph)
|
||||
BNode *node;
|
||||
int subgraph = 0;
|
||||
|
||||
if (BLI_hasAdjacencyList(graph) == 0)
|
||||
{
|
||||
if (BLI_hasAdjacencyList(graph) == 0) {
|
||||
BLI_buildAdjacencyList(graph);
|
||||
}
|
||||
|
||||
for (node = graph->nodes.first; node; node = node->next)
|
||||
{
|
||||
for (node = graph->nodes.first; node; node = node->next) {
|
||||
node->subgraph_index = 0;
|
||||
}
|
||||
|
||||
for (node = graph->nodes.first; node; node = node->next)
|
||||
{
|
||||
if (node->subgraph_index == 0)
|
||||
{
|
||||
for (node = graph->nodes.first; node; node = node->next) {
|
||||
if (node->subgraph_index == 0) {
|
||||
subgraph++;
|
||||
flagSubgraph(node, subgraph);
|
||||
}
|
||||
@ -347,10 +308,8 @@ void BLI_ReflagSubgraph(BGraph *graph, int old_subgraph, int new_subgraph)
|
||||
{
|
||||
BNode *node;
|
||||
|
||||
for (node = graph->nodes.first; node; node = node->next)
|
||||
{
|
||||
if (node->flag == old_subgraph)
|
||||
{
|
||||
for (node = graph->nodes.first; node; node = node->next) {
|
||||
if (node->flag == old_subgraph) {
|
||||
node->flag = new_subgraph;
|
||||
}
|
||||
}
|
||||
@ -362,26 +321,22 @@ static int detectCycle(BNode *node, BArc *src_arc)
|
||||
{
|
||||
int value = 0;
|
||||
|
||||
if (node->flag == 0)
|
||||
{
|
||||
if (node->flag == 0) {
|
||||
int i;
|
||||
|
||||
/* mark node as visited */
|
||||
node->flag = 1;
|
||||
|
||||
for (i = 0; i < node->degree && value == 0; i++)
|
||||
{
|
||||
for (i = 0; i < node->degree && value == 0; i++) {
|
||||
BArc *arc = node->arcs[i];
|
||||
|
||||
/* don't go back on the source arc */
|
||||
if (arc != src_arc)
|
||||
{
|
||||
if (arc != src_arc) {
|
||||
value = detectCycle(BLI_otherNode(arc, node), arc);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
else {
|
||||
value = 1;
|
||||
}
|
||||
|
||||
@ -399,11 +354,9 @@ int BLI_isGraphCyclic(BGraph *graph)
|
||||
BLI_flagNodes(graph, 0);
|
||||
|
||||
/* detectCycles in subgraphs */
|
||||
for (node = graph->nodes.first; node && value == 0; node = node->next)
|
||||
{
|
||||
for (node = graph->nodes.first; node && value == 0; node = node->next) {
|
||||
/* only for nodes in subgraphs that haven't been visited yet */
|
||||
if (node->flag == 0)
|
||||
{
|
||||
if (node->flag == 0) {
|
||||
value = value || detectCycle(node, NULL);
|
||||
}
|
||||
}
|
||||
@ -415,10 +368,8 @@ BArc * BLI_findConnectedArc(BGraph *graph, BArc *arc, BNode *v)
|
||||
{
|
||||
BArc *nextArc;
|
||||
|
||||
for (nextArc = graph->arcs.first; nextArc; nextArc = nextArc->next)
|
||||
{
|
||||
if (arc != nextArc && (nextArc->head == v || nextArc->tail == v))
|
||||
{
|
||||
for (nextArc = graph->arcs.first; nextArc; nextArc = nextArc->next) {
|
||||
if (arc != nextArc && (nextArc->head == v || nextArc->tail == v)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -434,30 +385,24 @@ static int subtreeShape(BNode *node, BArc *rootArc, int include_root)
|
||||
|
||||
node->flag = 1;
|
||||
|
||||
if (include_root)
|
||||
{
|
||||
if (include_root) {
|
||||
BNode *newNode = BLI_otherNode(rootArc, node);
|
||||
return subtreeShape(newNode, rootArc, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
else {
|
||||
/* Base case, no arcs leading away */
|
||||
if (node->arcs == NULL || *(node->arcs) == NULL)
|
||||
{
|
||||
if (node->arcs == NULL || *(node->arcs) == NULL) {
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
else {
|
||||
int i;
|
||||
|
||||
for (i = 0; i < node->degree; i++)
|
||||
{
|
||||
for (i = 0; i < node->degree; i++) {
|
||||
BArc *arc = node->arcs[i];
|
||||
BNode *newNode = BLI_otherNode(arc, node);
|
||||
|
||||
/* stop immediate and cyclic backtracking */
|
||||
if (arc != rootArc && newNode->flag == 0)
|
||||
{
|
||||
if (arc != rootArc && newNode->flag == 0) {
|
||||
depth += subtreeShape(newNode, arc, 0);
|
||||
}
|
||||
}
|
||||
@ -480,13 +425,11 @@ float BLI_subtreeLength(BNode *node)
|
||||
|
||||
node->flag = 0; /* flag node as visited */
|
||||
|
||||
for (i = 0; i < node->degree; i++)
|
||||
{
|
||||
for (i = 0; i < node->degree; i++) {
|
||||
BArc *arc = node->arcs[i];
|
||||
BNode *other_node = BLI_otherNode(arc, node);
|
||||
|
||||
if (other_node->flag != 0)
|
||||
{
|
||||
if (other_node->flag != 0) {
|
||||
float subgraph_length = arc->length + BLI_subtreeLength(other_node);
|
||||
length = MAX2(length, subgraph_length);
|
||||
}
|
||||
@ -503,15 +446,12 @@ void BLI_calcGraphLength(BGraph *graph)
|
||||
|
||||
nb_subgraphs = BLI_FlagSubgraphs(graph);
|
||||
|
||||
for (i = 1; i <= nb_subgraphs; i++)
|
||||
{
|
||||
for (i = 1; i <= nb_subgraphs; i++) {
|
||||
BNode *node;
|
||||
|
||||
for (node = graph->nodes.first; node; node = node->next)
|
||||
{
|
||||
for (node = graph->nodes.first; node; node = node->next) {
|
||||
/* start on an external node of the subgraph */
|
||||
if (node->subgraph_index == i && node->degree == 1)
|
||||
{
|
||||
if (node->subgraph_index == i && node->degree == 1) {
|
||||
float subgraph_length = BLI_subtreeLength(node);
|
||||
length = MAX2(length, subgraph_length);
|
||||
break;
|
||||
@ -542,32 +482,27 @@ static void testRadialSymmetry(BGraph *graph, BNode* root_node, RadialArc* ring,
|
||||
int i;
|
||||
|
||||
/* sort ring by angle */
|
||||
for (i = 0; i < total - 1; i++)
|
||||
{
|
||||
for (i = 0; i < total - 1; i++) {
|
||||
float minAngle = FLT_MAX;
|
||||
int minIndex = -1;
|
||||
int j;
|
||||
|
||||
for (j = i + 1; j < total; j++)
|
||||
{
|
||||
for (j = i + 1; j < total; j++) {
|
||||
float angle = dot_v3v3(ring[i].n, ring[j].n);
|
||||
|
||||
/* map negative values to 1..2 */
|
||||
if (angle < 0)
|
||||
{
|
||||
if (angle < 0) {
|
||||
angle = 1 - angle;
|
||||
}
|
||||
|
||||
if (angle < minAngle)
|
||||
{
|
||||
if (angle < minAngle) {
|
||||
minIndex = j;
|
||||
minAngle = angle;
|
||||
}
|
||||
}
|
||||
|
||||
/* swap if needed */
|
||||
if (minIndex != i + 1)
|
||||
{
|
||||
if (minIndex != i + 1) {
|
||||
RadialArc tmp;
|
||||
tmp = ring[i + 1];
|
||||
ring[i + 1] = ring[minIndex];
|
||||
@ -575,8 +510,7 @@ static void testRadialSymmetry(BGraph *graph, BNode* root_node, RadialArc* ring,
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; i < total && symmetric; i++)
|
||||
{
|
||||
for (i = 0; i < total && symmetric; i++) {
|
||||
BNode *node1, *node2;
|
||||
float tangent[3];
|
||||
float normal[3];
|
||||
@ -593,29 +527,25 @@ static void testRadialSymmetry(BGraph *graph, BNode* root_node, RadialArc* ring,
|
||||
BLI_mirrorAlongAxis(p, root_node->p, normal);
|
||||
|
||||
/* check if it's within limit before continuing */
|
||||
if (len_v3v3(node1->p, p) > limit)
|
||||
{
|
||||
if (len_v3v3(node1->p, p) > limit) {
|
||||
symmetric = 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (symmetric)
|
||||
{
|
||||
if (symmetric) {
|
||||
/* mark node as symmetric physically */
|
||||
copy_v3_v3(root_node->symmetry_axis, axis);
|
||||
root_node->symmetry_flag |= SYM_PHYSICAL;
|
||||
root_node->symmetry_flag |= SYM_RADIAL;
|
||||
|
||||
/* FLAG SYMMETRY GROUP */
|
||||
for (i = 0; i < total; i++)
|
||||
{
|
||||
for (i = 0; i < total; i++) {
|
||||
ring[i].arc->symmetry_group = group;
|
||||
ring[i].arc->symmetry_flag = SYM_SIDE_RADIAL + i;
|
||||
}
|
||||
|
||||
if (graph->radial_symmetry)
|
||||
{
|
||||
if (graph->radial_symmetry) {
|
||||
graph->radial_symmetry(root_node, ring, total);
|
||||
}
|
||||
}
|
||||
@ -634,13 +564,11 @@ static void handleRadialSymmetry(BGraph *graph, BNode *root_node, int depth, flo
|
||||
root_node->symmetry_flag |= SYM_TOPOLOGICAL;
|
||||
|
||||
/* total the number of arcs in the symmetry ring */
|
||||
for (i = 0; i < root_node->degree; i++)
|
||||
{
|
||||
for (i = 0; i < root_node->degree; i++) {
|
||||
BArc *connectedArc = root_node->arcs[i];
|
||||
|
||||
/* depth is store as a negative in flag. symmetry level is positive */
|
||||
if (connectedArc->symmetry_level == -depth)
|
||||
{
|
||||
if (connectedArc->symmetry_level == -depth) {
|
||||
total++;
|
||||
}
|
||||
}
|
||||
@ -649,13 +577,11 @@ static void handleRadialSymmetry(BGraph *graph, BNode *root_node, int depth, flo
|
||||
unit = ring;
|
||||
|
||||
/* fill in the ring */
|
||||
for (unit = ring, i = 0; i < root_node->degree; i++)
|
||||
{
|
||||
for (unit = ring, i = 0; i < root_node->degree; i++) {
|
||||
BArc *connectedArc = root_node->arcs[i];
|
||||
|
||||
/* depth is store as a negative in flag. symmetry level is positive */
|
||||
if (connectedArc->symmetry_level == -depth)
|
||||
{
|
||||
if (connectedArc->symmetry_level == -depth) {
|
||||
BNode *otherNode = BLI_otherNode(connectedArc, root_node);
|
||||
float vec[3];
|
||||
|
||||
@ -676,19 +602,16 @@ static void handleRadialSymmetry(BGraph *graph, BNode *root_node, int depth, flo
|
||||
* using a rather bogus insertion sort
|
||||
* butrings will never get too big to matter
|
||||
* */
|
||||
for (i = 0; i < total; i++)
|
||||
{
|
||||
for (i = 0; i < total; i++) {
|
||||
int j;
|
||||
|
||||
for (j = i - 1; j >= 0; j--)
|
||||
{
|
||||
for (j = i - 1; j >= 0; j--) {
|
||||
BArc *arc1, *arc2;
|
||||
|
||||
arc1 = ring[j].arc;
|
||||
arc2 = ring[j + 1].arc;
|
||||
|
||||
if (arc1->length > arc2->length)
|
||||
{
|
||||
if (arc1->length > arc2->length) {
|
||||
/* swap with smaller */
|
||||
RadialArc tmp;
|
||||
|
||||
@ -696,8 +619,7 @@ static void handleRadialSymmetry(BGraph *graph, BNode *root_node, int depth, flo
|
||||
ring[j + 1] = ring[j];
|
||||
ring[j] = tmp;
|
||||
}
|
||||
else
|
||||
{
|
||||
else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -707,38 +629,32 @@ static void handleRadialSymmetry(BGraph *graph, BNode *root_node, int depth, flo
|
||||
first = 0;
|
||||
group = 0;
|
||||
|
||||
for (i = 1; i < total; i++)
|
||||
{
|
||||
for (i = 1; i < total; i++) {
|
||||
int dispatch = 0;
|
||||
int last = i - 1;
|
||||
|
||||
if (fabsf(ring[first].arc->length - ring[i].arc->length) > limit)
|
||||
{
|
||||
if (fabsf(ring[first].arc->length - ring[i].arc->length) > limit) {
|
||||
dispatch = 1;
|
||||
}
|
||||
|
||||
/* if not dispatching already and on last arc
|
||||
* Dispatch using current arc as last
|
||||
* */
|
||||
if (dispatch == 0 && i == total - 1)
|
||||
{
|
||||
if (dispatch == 0 && i == total - 1) {
|
||||
last = i;
|
||||
dispatch = 1;
|
||||
}
|
||||
|
||||
if (dispatch)
|
||||
{
|
||||
if (dispatch) {
|
||||
int sub_total = last - first + 1;
|
||||
|
||||
group += 1;
|
||||
|
||||
if (sub_total == 1)
|
||||
{
|
||||
if (sub_total == 1) {
|
||||
group -= 1; /* not really a group so decrement */
|
||||
/* NOTHING TO DO */
|
||||
}
|
||||
else if (sub_total == 2)
|
||||
{
|
||||
else if (sub_total == 2) {
|
||||
BArc *arc1, *arc2;
|
||||
BNode *node1, *node2;
|
||||
|
||||
@ -750,14 +666,12 @@ static void handleRadialSymmetry(BGraph *graph, BNode *root_node, int depth, flo
|
||||
|
||||
testAxialSymmetry(graph, root_node, node1, node2, arc1, arc2, axis, limit, group);
|
||||
}
|
||||
else if (sub_total != total) /* allocate a new sub ring if needed */
|
||||
{
|
||||
else if (sub_total != total) /* allocate a new sub ring if needed */ {
|
||||
RadialArc *sub_ring = MEM_callocN(sizeof(RadialArc) * sub_total, "radial symmetry ring");
|
||||
int sub_i;
|
||||
|
||||
/* fill in the sub ring */
|
||||
for (sub_i = 0; sub_i < sub_total; sub_i++)
|
||||
{
|
||||
for (sub_i = 0; sub_i < sub_total; sub_i++) {
|
||||
sub_ring[sub_i] = ring[first + sub_i];
|
||||
}
|
||||
|
||||
@ -765,8 +679,7 @@ static void handleRadialSymmetry(BGraph *graph, BNode *root_node, int depth, flo
|
||||
|
||||
MEM_freeN(sub_ring);
|
||||
}
|
||||
else if (sub_total == total)
|
||||
{
|
||||
else if (sub_total == total) {
|
||||
testRadialSymmetry(graph, root_node, ring, total, axis, limit, group);
|
||||
}
|
||||
|
||||
@ -786,12 +699,10 @@ static void flagAxialSymmetry(BNode *root_node, BNode *end_node, BArc *arc, int
|
||||
|
||||
sub_v3_v3v3(vec, end_node->p, root_node->p);
|
||||
|
||||
if (dot_v3v3(vec, root_node->symmetry_axis) < 0)
|
||||
{
|
||||
if (dot_v3v3(vec, root_node->symmetry_axis) < 0) {
|
||||
arc->symmetry_flag |= SYM_SIDE_NEGATIVE;
|
||||
}
|
||||
else
|
||||
{
|
||||
else {
|
||||
arc->symmetry_flag |= SYM_SIDE_POSITIVE;
|
||||
}
|
||||
}
|
||||
@ -809,16 +720,13 @@ static void testAxialSymmetry(BGraph *graph, BNode* root_node, BNode* node1, BNo
|
||||
|
||||
cross_v3_v3v3(nor, vec, axis);
|
||||
|
||||
if (abs(nor[0]) > abs(nor[1]) && abs(nor[0]) > abs(nor[2]) && nor[0] < 0)
|
||||
{
|
||||
if (abs(nor[0]) > abs(nor[1]) && abs(nor[0]) > abs(nor[2]) && nor[0] < 0) {
|
||||
negate_v3(nor);
|
||||
}
|
||||
else if (abs(nor[1]) > abs(nor[0]) && abs(nor[1]) > abs(nor[2]) && nor[1] < 0)
|
||||
{
|
||||
else if (abs(nor[1]) > abs(nor[0]) && abs(nor[1]) > abs(nor[2]) && nor[1] < 0) {
|
||||
negate_v3(nor);
|
||||
}
|
||||
else if (abs(nor[2]) > abs(nor[1]) && abs(nor[2]) > abs(nor[0]) && nor[2] < 0)
|
||||
{
|
||||
else if (abs(nor[2]) > abs(nor[1]) && abs(nor[2]) > abs(nor[0]) && nor[2] < 0) {
|
||||
negate_v3(nor);
|
||||
}
|
||||
|
||||
@ -827,8 +735,7 @@ static void testAxialSymmetry(BGraph *graph, BNode* root_node, BNode* node1, BNo
|
||||
BLI_mirrorAlongAxis(p, root_node->p, nor);
|
||||
|
||||
/* check if it's within limit before continuing */
|
||||
if (len_v3v3(node1->p, p) <= limit)
|
||||
{
|
||||
if (len_v3v3(node1->p, p) <= limit) {
|
||||
/* mark node as symmetric physically */
|
||||
copy_v3_v3(root_node->symmetry_axis, nor);
|
||||
root_node->symmetry_flag |= SYM_PHYSICAL;
|
||||
@ -838,13 +745,11 @@ static void testAxialSymmetry(BGraph *graph, BNode* root_node, BNode* node1, BNo
|
||||
flagAxialSymmetry(root_node, node1, arc1, group);
|
||||
flagAxialSymmetry(root_node, node2, arc2, group);
|
||||
|
||||
if (graph->axial_symmetry)
|
||||
{
|
||||
if (graph->axial_symmetry) {
|
||||
graph->axial_symmetry(root_node, node1, node2, arc1, arc2);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
else {
|
||||
/* NOT SYMMETRIC */
|
||||
}
|
||||
}
|
||||
@ -858,20 +763,16 @@ static void handleAxialSymmetry(BGraph *graph, BNode *root_node, int depth, floa
|
||||
/* mark topological symmetry */
|
||||
root_node->symmetry_flag |= SYM_TOPOLOGICAL;
|
||||
|
||||
for (i = 0; i < root_node->degree; i++)
|
||||
{
|
||||
for (i = 0; i < root_node->degree; i++) {
|
||||
BArc *connectedArc = root_node->arcs[i];
|
||||
|
||||
/* depth is store as a negative in flag. symmetry level is positive */
|
||||
if (connectedArc->symmetry_level == -depth)
|
||||
{
|
||||
if (arc1 == NULL)
|
||||
{
|
||||
if (connectedArc->symmetry_level == -depth) {
|
||||
if (arc1 == NULL) {
|
||||
arc1 = connectedArc;
|
||||
node1 = BLI_otherNode(arc1, root_node);
|
||||
}
|
||||
else
|
||||
{
|
||||
else {
|
||||
arc2 = connectedArc;
|
||||
node2 = BLI_otherNode(arc2, root_node);
|
||||
break; /* Can stop now, the two arcs have been found */
|
||||
@ -880,8 +781,7 @@ static void handleAxialSymmetry(BGraph *graph, BNode *root_node, int depth, floa
|
||||
}
|
||||
|
||||
/* shouldn't happen, but just to be sure */
|
||||
if (node1 == NULL || node2 == NULL)
|
||||
{
|
||||
if (node1 == NULL || node2 == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -897,18 +797,15 @@ static void markdownSecondarySymmetry(BGraph *graph, BNode *node, int depth, int
|
||||
/* count the number of branches in this symmetry group
|
||||
* and determinate the axis of symmetry
|
||||
* */
|
||||
for (i = 0; i < node->degree; i++)
|
||||
{
|
||||
for (i = 0; i < node->degree; i++) {
|
||||
BArc *connectedArc = node->arcs[i];
|
||||
|
||||
/* depth is store as a negative in flag. symmetry level is positive */
|
||||
if (connectedArc->symmetry_level == -depth)
|
||||
{
|
||||
if (connectedArc->symmetry_level == -depth) {
|
||||
count++;
|
||||
}
|
||||
/* If arc is on the axis */
|
||||
else if (connectedArc->symmetry_level == level)
|
||||
{
|
||||
else if (connectedArc->symmetry_level == level) {
|
||||
add_v3_v3(axis, connectedArc->head->p);
|
||||
sub_v3_v3v3(axis, axis, connectedArc->tail->p);
|
||||
}
|
||||
@ -917,22 +814,18 @@ static void markdownSecondarySymmetry(BGraph *graph, BNode *node, int depth, int
|
||||
normalize_v3(axis);
|
||||
|
||||
/* Split between axial and radial symmetry */
|
||||
if (count == 2)
|
||||
{
|
||||
if (count == 2) {
|
||||
handleAxialSymmetry(graph, node, depth, axis, limit);
|
||||
}
|
||||
else
|
||||
{
|
||||
else {
|
||||
handleRadialSymmetry(graph, node, depth, axis, limit);
|
||||
}
|
||||
|
||||
/* markdown secondary symetries */
|
||||
for (i = 0; i < node->degree; i++)
|
||||
{
|
||||
for (i = 0; i < node->degree; i++) {
|
||||
BArc *connectedArc = node->arcs[i];
|
||||
|
||||
if (connectedArc->symmetry_level == -depth)
|
||||
{
|
||||
if (connectedArc->symmetry_level == -depth) {
|
||||
/* markdown symmetry for branches corresponding to the depth */
|
||||
markdownSymmetryArc(graph, connectedArc, node, level + 1, limit);
|
||||
}
|
||||
@ -944,19 +837,16 @@ static void markdownSymmetryArc(BGraph *graph, BArc *arc, BNode *node, int level
|
||||
int i;
|
||||
|
||||
/* if arc is null, we start straight from a node */
|
||||
if (arc)
|
||||
{
|
||||
if (arc) {
|
||||
arc->symmetry_level = level;
|
||||
|
||||
node = BLI_otherNode(arc, node);
|
||||
}
|
||||
|
||||
for (i = 0; i < node->degree; i++)
|
||||
{
|
||||
for (i = 0; i < node->degree; i++) {
|
||||
BArc *connectedArc = node->arcs[i];
|
||||
|
||||
if (connectedArc != arc)
|
||||
{
|
||||
if (connectedArc != arc) {
|
||||
BNode *connectedNode = BLI_otherNode(connectedArc, node);
|
||||
|
||||
/* symmetry level is positive value, negative values is subtree depth */
|
||||
@ -966,26 +856,22 @@ static void markdownSymmetryArc(BGraph *graph, BArc *arc, BNode *node, int level
|
||||
|
||||
arc = NULL;
|
||||
|
||||
for (i = 0; i < node->degree; i++)
|
||||
{
|
||||
for (i = 0; i < node->degree; i++) {
|
||||
int issymmetryAxis = 0;
|
||||
BArc *connectedArc = node->arcs[i];
|
||||
|
||||
/* only arcs not already marked as symetric */
|
||||
if (connectedArc->symmetry_level < 0)
|
||||
{
|
||||
if (connectedArc->symmetry_level < 0) {
|
||||
int j;
|
||||
|
||||
/* true by default */
|
||||
issymmetryAxis = 1;
|
||||
|
||||
for (j = 0; j < node->degree; j++)
|
||||
{
|
||||
for (j = 0; j < node->degree; j++) {
|
||||
BArc *otherArc = node->arcs[j];
|
||||
|
||||
/* different arc, same depth */
|
||||
if (otherArc != connectedArc && otherArc->symmetry_level == connectedArc->symmetry_level)
|
||||
{
|
||||
if (otherArc != connectedArc && otherArc->symmetry_level == connectedArc->symmetry_level) {
|
||||
/* not on the symmetry axis */
|
||||
issymmetryAxis = 0;
|
||||
break;
|
||||
@ -994,15 +880,12 @@ static void markdownSymmetryArc(BGraph *graph, BArc *arc, BNode *node, int level
|
||||
}
|
||||
|
||||
/* arc could be on the symmetry axis */
|
||||
if (issymmetryAxis == 1)
|
||||
{
|
||||
if (issymmetryAxis == 1) {
|
||||
/* no arc as been marked previously, keep this one */
|
||||
if (arc == NULL)
|
||||
{
|
||||
if (arc == NULL) {
|
||||
arc = connectedArc;
|
||||
}
|
||||
else if (connectedArc->symmetry_level < arc->symmetry_level)
|
||||
{
|
||||
else if (connectedArc->symmetry_level < arc->symmetry_level) {
|
||||
/* go with more complex subtree as symmetry arc */
|
||||
arc = connectedArc;
|
||||
}
|
||||
@ -1010,20 +893,17 @@ static void markdownSymmetryArc(BGraph *graph, BArc *arc, BNode *node, int level
|
||||
}
|
||||
|
||||
/* go down the arc continuing the symmetry axis */
|
||||
if (arc)
|
||||
{
|
||||
if (arc) {
|
||||
markdownSymmetryArc(graph, arc, node, level, limit);
|
||||
}
|
||||
|
||||
|
||||
/* secondary symmetry */
|
||||
for (i = 0; i < node->degree; i++)
|
||||
{
|
||||
for (i = 0; i < node->degree; i++) {
|
||||
BArc *connectedArc = node->arcs[i];
|
||||
|
||||
/* only arcs not already marked as symetric and is not the next arc on the symmetry axis */
|
||||
if (connectedArc->symmetry_level < 0)
|
||||
{
|
||||
if (connectedArc->symmetry_level < 0) {
|
||||
/* subtree depth is store as a negative value in the symmetry */
|
||||
markdownSecondarySymmetry(graph, node, -connectedArc->symmetry_level, level, limit);
|
||||
}
|
||||
@ -1035,13 +915,11 @@ void BLI_markdownSymmetry(BGraph *graph, BNode *root_node, float limit)
|
||||
BNode *node;
|
||||
BArc *arc;
|
||||
|
||||
if (root_node == NULL)
|
||||
{
|
||||
if (root_node == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (BLI_isGraphCyclic(graph))
|
||||
{
|
||||
if (BLI_isGraphCyclic(graph)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -1054,37 +932,29 @@ void BLI_markdownSymmetry(BGraph *graph, BNode *root_node, float limit)
|
||||
node = root_node;
|
||||
|
||||
/* sanity check REMOVE ME */
|
||||
if (node->degree > 0)
|
||||
{
|
||||
if (node->degree > 0) {
|
||||
arc = node->arcs[0];
|
||||
|
||||
if (node->degree == 1)
|
||||
{
|
||||
if (node->degree == 1) {
|
||||
markdownSymmetryArc(graph, arc, node, 1, limit);
|
||||
}
|
||||
else
|
||||
{
|
||||
else {
|
||||
markdownSymmetryArc(graph, NULL, node, 1, limit);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* mark down non-symetric arcs */
|
||||
for (arc = graph->arcs.first; arc; arc = arc->next)
|
||||
{
|
||||
if (arc->symmetry_level < 0)
|
||||
{
|
||||
for (arc = graph->arcs.first; arc; arc = arc->next) {
|
||||
if (arc->symmetry_level < 0) {
|
||||
arc->symmetry_level = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
else {
|
||||
/* mark down nodes with the lowest level symmetry axis */
|
||||
if (arc->head->symmetry_level == 0 || arc->head->symmetry_level > arc->symmetry_level)
|
||||
{
|
||||
if (arc->head->symmetry_level == 0 || arc->head->symmetry_level > arc->symmetry_level) {
|
||||
arc->head->symmetry_level = arc->symmetry_level;
|
||||
}
|
||||
if (arc->tail->symmetry_level == 0 || arc->tail->symmetry_level > arc->symmetry_level)
|
||||
{
|
||||
if (arc->tail->symmetry_level == 0 || arc->tail->symmetry_level > arc->symmetry_level) {
|
||||
arc->tail->symmetry_level = arc->symmetry_level;
|
||||
}
|
||||
}
|
||||
@ -1108,16 +978,13 @@ void* IT_peek(void* arg, int n)
|
||||
{
|
||||
BArcIterator *iter = (BArcIterator*)arg;
|
||||
|
||||
if (iter->index + n < 0)
|
||||
{
|
||||
if (iter->index + n < 0) {
|
||||
return iter->head(iter);
|
||||
}
|
||||
else if (iter->index + n >= iter->length)
|
||||
{
|
||||
else if (iter->index + n >= iter->length) {
|
||||
return iter->tail(iter);
|
||||
}
|
||||
else
|
||||
{
|
||||
else {
|
||||
return iter->peek(iter, n);
|
||||
}
|
||||
}
|
||||
|
@ -184,8 +184,7 @@ void BLI_sortlist(ListBase *listbase, int (*cmp)(void *, void *))
|
||||
|
||||
BLI_remlink(listbase, current);
|
||||
|
||||
while (previous && cmp(previous, current) == 1)
|
||||
{
|
||||
while (previous && cmp(previous, current) == 1) {
|
||||
previous = previous->prev;
|
||||
}
|
||||
|
||||
|
@ -1156,7 +1156,7 @@ char *BLI_get_folder_version(const int id, const int ver, const int do_check)
|
||||
{
|
||||
static char path[FILE_MAX] = "";
|
||||
int ok;
|
||||
switch(id) {
|
||||
switch (id) {
|
||||
case BLENDER_RESOURCE_PATH_USER:
|
||||
ok= get_path_user(path, NULL, NULL, NULL, ver);
|
||||
break;
|
||||
|
@ -1151,7 +1151,7 @@ static void pbvh_update_draw_buffers(PBVH *bvh, PBVHNode **nodes, int totnode)
|
||||
}
|
||||
|
||||
if (node->flag & PBVH_UpdateDrawBuffers) {
|
||||
switch(bvh->type) {
|
||||
switch (bvh->type) {
|
||||
case PBVH_GRIDS:
|
||||
GPU_update_grid_buffers(node->draw_buffers,
|
||||
bvh->grids,
|
||||
@ -1290,7 +1290,9 @@ void BLI_pbvh_get_grid_updates(PBVH *bvh, int clear, void ***gridfaces, int *tot
|
||||
for (hiter = BLI_ghashIterator_new(map), i = 0;
|
||||
!BLI_ghashIterator_isDone(hiter);
|
||||
BLI_ghashIterator_step(hiter), ++i)
|
||||
{
|
||||
faces[i]= BLI_ghashIterator_getKey(hiter);
|
||||
}
|
||||
|
||||
BLI_ghashIterator_free(hiter);
|
||||
|
||||
@ -1345,7 +1347,7 @@ void BLI_pbvh_node_num_verts(PBVH *bvh, PBVHNode *node, int *uniquevert, int *to
|
||||
{
|
||||
int tot;
|
||||
|
||||
switch(bvh->type) {
|
||||
switch (bvh->type) {
|
||||
case PBVH_GRIDS:
|
||||
tot= node->totprim*bvh->gridsize*bvh->gridsize;
|
||||
if (totvert) *totvert= tot;
|
||||
@ -1360,7 +1362,7 @@ void BLI_pbvh_node_num_verts(PBVH *bvh, PBVHNode *node, int *uniquevert, int *to
|
||||
|
||||
void BLI_pbvh_node_get_grids(PBVH *bvh, PBVHNode *node, int **grid_indices, int *totgrid, int *maxgrid, int *gridsize, DMGridData ***griddata, DMGridAdjacency **gridadj)
|
||||
{
|
||||
switch(bvh->type) {
|
||||
switch (bvh->type) {
|
||||
case PBVH_GRIDS:
|
||||
if (grid_indices) *grid_indices= node->prim_indices;
|
||||
if (totgrid) *totgrid= node->totprim;
|
||||
@ -1504,7 +1506,7 @@ int BLI_pbvh_node_raycast(PBVH *bvh, PBVHNode *node, float (*origco)[3],
|
||||
if (node->flag & PBVH_FullyHidden)
|
||||
return 0;
|
||||
|
||||
switch(bvh->type) {
|
||||
switch (bvh->type) {
|
||||
case PBVH_FACES:
|
||||
vert = bvh->verts;
|
||||
faces= node->prim_indices;
|
||||
|
@ -125,7 +125,7 @@ size_t BLI_strescape(char *dst, const char *src, const size_t maxlen)
|
||||
{
|
||||
size_t len= 0;
|
||||
while (len < maxlen) {
|
||||
switch(*src) {
|
||||
switch (*src) {
|
||||
case '\0':
|
||||
goto escape_finish;
|
||||
case '\\':
|
||||
|
@ -168,7 +168,7 @@ static const size_t utf8_skip_data[256] = {
|
||||
size_t utf8_size; \
|
||||
while (*src != '\0' && (utf8_size= utf8_skip_data[*src]) < maxncpy) { \
|
||||
maxncpy -= utf8_size; \
|
||||
switch(utf8_size) { \
|
||||
switch (utf8_size) { \
|
||||
case 6: *dst ++ = *src ++; \
|
||||
case 5: *dst ++ = *src ++; \
|
||||
case 4: *dst ++ = *src ++; \
|
||||
|
@ -156,8 +156,7 @@ LinkNode *BLO_blendhandle_get_previews(BlendHandle *bh, int ofblocktype, int *to
|
||||
for (bhead= blo_firstbhead(fd); bhead; bhead= blo_nextbhead(fd, bhead)) {
|
||||
if (bhead->code==ofblocktype) {
|
||||
char *idname= bhead_id_name(fd, bhead);
|
||||
switch(GS(idname))
|
||||
{
|
||||
switch (GS(idname)) {
|
||||
case ID_MA: /* fall through */
|
||||
case ID_TE: /* fall through */
|
||||
case ID_IM: /* fall through */
|
||||
|
@ -1061,8 +1061,7 @@ void blo_freefiledata(FileData *fd)
|
||||
close(fd->filedes);
|
||||
}
|
||||
|
||||
if (fd->gzfiledes != NULL)
|
||||
{
|
||||
if (fd->gzfiledes != NULL) {
|
||||
gzclose(fd->gzfiledes);
|
||||
}
|
||||
|
||||
@ -2756,9 +2755,9 @@ static void switch_endian_keyblock(Key *key, KeyBlock *kb)
|
||||
cp= key->elemstr;
|
||||
poin= data;
|
||||
|
||||
while ( cp[0] ) { /* cp[0]==amount */
|
||||
while ( cp[0] ) { /* cp[0] == amount */
|
||||
|
||||
switch(cp[1]) { /* cp[1]= type */
|
||||
switch (cp[1]) { /* cp[1] = type */
|
||||
case IPO_FLOAT:
|
||||
case IPO_BPOINT:
|
||||
case IPO_BEZTRIPLE:
|
||||
@ -3442,7 +3441,7 @@ static void lib_link_particlesettings(FileData *fd, Main *main)
|
||||
for (; state; state=state->next) {
|
||||
rule = state->rules.first;
|
||||
for (; rule; rule=rule->next)
|
||||
switch(rule->type) {
|
||||
switch (rule->type) {
|
||||
case eBoidRuleType_Goal:
|
||||
case eBoidRuleType_Avoid:
|
||||
{
|
||||
@ -4235,8 +4234,7 @@ static void lib_link_object(FileData *fd, Main *main)
|
||||
{
|
||||
SmokeModifierData *smd = (SmokeModifierData *)modifiers_findByType(ob, eModifierType_Smoke);
|
||||
|
||||
if (smd && smd->type == MOD_SMOKE_TYPE_DOMAIN && smd->domain)
|
||||
{
|
||||
if (smd && smd->type == MOD_SMOKE_TYPE_DOMAIN && smd->domain) {
|
||||
smd->domain->flags |= MOD_SMOKE_FILE_LOAD; /* flag for refreshing the simulation after loading */
|
||||
}
|
||||
}
|
||||
@ -4359,8 +4357,7 @@ static void direct_link_modifiers(FileData *fd, ListBase *lb)
|
||||
else if (md->type==eModifierType_Smoke) {
|
||||
SmokeModifierData *smd = (SmokeModifierData*) md;
|
||||
|
||||
if (smd->type==MOD_SMOKE_TYPE_DOMAIN)
|
||||
{
|
||||
if (smd->type==MOD_SMOKE_TYPE_DOMAIN) {
|
||||
smd->flow = NULL;
|
||||
smd->coll = NULL;
|
||||
smd->domain = newdataadr(fd, smd->domain);
|
||||
@ -4405,8 +4402,7 @@ static void direct_link_modifiers(FileData *fd, ListBase *lb)
|
||||
smd->flow = NULL;
|
||||
smd->domain = NULL;
|
||||
smd->coll = newdataadr(fd, smd->coll);
|
||||
if (smd->coll)
|
||||
{
|
||||
if (smd->coll) {
|
||||
smd->coll->points = NULL;
|
||||
smd->coll->numpoints = 0;
|
||||
}
|
||||
@ -4418,8 +4414,7 @@ static void direct_link_modifiers(FileData *fd, ListBase *lb)
|
||||
else if (md->type==eModifierType_DynamicPaint) {
|
||||
DynamicPaintModifierData *pmd = (DynamicPaintModifierData*) md;
|
||||
|
||||
if (pmd->canvas)
|
||||
{
|
||||
if (pmd->canvas) {
|
||||
pmd->canvas = newdataadr(fd, pmd->canvas);
|
||||
pmd->canvas->pmd = pmd;
|
||||
pmd->canvas->dm = NULL;
|
||||
@ -4439,8 +4434,7 @@ static void direct_link_modifiers(FileData *fd, ListBase *lb)
|
||||
}
|
||||
}
|
||||
}
|
||||
if (pmd->brush)
|
||||
{
|
||||
if (pmd->brush) {
|
||||
pmd->brush = newdataadr(fd, pmd->brush);
|
||||
pmd->brush->pmd = pmd;
|
||||
pmd->brush->psys = newdataadr(fd, pmd->brush->psys);
|
||||
@ -6089,8 +6083,7 @@ static void direct_link_sound(FileData *fd, bSound *sound)
|
||||
sound->waveform = NULL;
|
||||
|
||||
// versioning stuff, if there was a cache, then we enable caching:
|
||||
if (sound->cache)
|
||||
{
|
||||
if (sound->cache) {
|
||||
sound->flags |= SOUND_FLAGS_CACHING;
|
||||
sound->cache = NULL;
|
||||
}
|
||||
@ -6233,8 +6226,7 @@ static void lib_link_movieclip(FileData *fd, Main *main)
|
||||
|
||||
static const char *dataname(short id_code)
|
||||
{
|
||||
|
||||
switch( id_code ) {
|
||||
switch ( id_code ) {
|
||||
case ID_OB: return "Data from OB";
|
||||
case ID_ME: return "Data from ME";
|
||||
case ID_IP: return "Data from IP";
|
||||
@ -6344,7 +6336,7 @@ static BHead *read_libblock(FileData *fd, Main *main, BHead *bhead, int flag, ID
|
||||
bhead= read_data_into_oldnewmap(fd, bhead, allocname);
|
||||
|
||||
/* init pointers direct data */
|
||||
switch( GS(id->name) ) {
|
||||
switch (GS(id->name)) {
|
||||
case ID_WM:
|
||||
direct_link_windowmanager(fd, (wmWindowManager *)id);
|
||||
break;
|
||||
@ -6922,7 +6914,7 @@ static void area_add_window_regions(ScrArea *sa, SpaceLink *sl, ListBase *lb)
|
||||
|
||||
if (sl) {
|
||||
/* first channels for ipo action nla... */
|
||||
switch(sl->spacetype) {
|
||||
switch (sl->spacetype) {
|
||||
case SPACE_IPO:
|
||||
ar= MEM_callocN(sizeof(ARegion), "area region from do_versions");
|
||||
BLI_addtail(lb, ar);
|
||||
@ -7044,7 +7036,7 @@ static void area_add_window_regions(ScrArea *sa, SpaceLink *sl, ListBase *lb)
|
||||
if (sl) {
|
||||
/* if active spacetype has view2d data, copy that over to main region */
|
||||
/* and we split view3d */
|
||||
switch(sl->spacetype) {
|
||||
switch (sl->spacetype) {
|
||||
case SPACE_VIEW3D:
|
||||
view3d_split_250((View3D *)sl, lb);
|
||||
break;
|
||||
@ -7450,8 +7442,7 @@ static void do_version_constraints_radians_degrees_250(ListBase *lb)
|
||||
static void do_version_old_trackto_to_constraints(Object *ob)
|
||||
{
|
||||
/* create new trackto constraint from the relationship */
|
||||
if (ob->track)
|
||||
{
|
||||
if (ob->track) {
|
||||
bConstraint *con= add_ob_constraint(ob, "AutoTrack", CONSTRAINT_TYPE_TRACKTO);
|
||||
bTrackToConstraint *data = con->data;
|
||||
|
||||
@ -8336,8 +8327,7 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
|
||||
Mesh *me;
|
||||
|
||||
sound = main->sound.first;
|
||||
while (sound)
|
||||
{
|
||||
while (sound) {
|
||||
sound->max_gain = 1.0;
|
||||
sound->min_gain = 0.0;
|
||||
sound->distance = 1.0;
|
||||
@ -9753,17 +9743,16 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
|
||||
if (md->type==eModifierType_Mirror) {
|
||||
MirrorModifierData *mmd = (MirrorModifierData*) md;
|
||||
|
||||
switch(mmd->axis)
|
||||
{
|
||||
case 0:
|
||||
mmd->flag |= MOD_MIR_AXIS_X;
|
||||
break;
|
||||
case 1:
|
||||
mmd->flag |= MOD_MIR_AXIS_Y;
|
||||
break;
|
||||
case 2:
|
||||
mmd->flag |= MOD_MIR_AXIS_Z;
|
||||
break;
|
||||
switch (mmd->axis) {
|
||||
case 0:
|
||||
mmd->flag |= MOD_MIR_AXIS_X;
|
||||
break;
|
||||
case 1:
|
||||
mmd->flag |= MOD_MIR_AXIS_Y;
|
||||
break;
|
||||
case 2:
|
||||
mmd->flag |= MOD_MIR_AXIS_Z;
|
||||
break;
|
||||
}
|
||||
|
||||
mmd->axis = 0;
|
||||
@ -10062,8 +10051,7 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
|
||||
* */
|
||||
{
|
||||
Scene *sce;
|
||||
for (sce=main->scene.first; sce; sce = sce->id.next)
|
||||
{
|
||||
for (sce=main->scene.first; sce; sce = sce->id.next) {
|
||||
if (sce->toolsettings->skgen_subdivisions[0] == sce->toolsettings->skgen_subdivisions[1] ||
|
||||
sce->toolsettings->skgen_subdivisions[0] == sce->toolsettings->skgen_subdivisions[2] ||
|
||||
sce->toolsettings->skgen_subdivisions[1] == sce->toolsettings->skgen_subdivisions[2])
|
||||
@ -10479,13 +10467,11 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
|
||||
}
|
||||
|
||||
// convert fluids to modifier
|
||||
if (main->versionfile < 246 || (main->versionfile == 246 && main->subversionfile < 1))
|
||||
{
|
||||
if (main->versionfile < 246 || (main->versionfile == 246 && main->subversionfile < 1)) {
|
||||
Object *ob;
|
||||
|
||||
for (ob = main->object.first; ob; ob= ob->id.next) {
|
||||
if (ob->fluidsimSettings)
|
||||
{
|
||||
if (ob->fluidsimSettings) {
|
||||
FluidsimModifierData *fluidmd = (FluidsimModifierData *)modifier_new(eModifierType_Fluidsim);
|
||||
BLI_addhead(&ob->modifiers, (ModifierData *)fluidmd);
|
||||
|
||||
@ -10809,10 +10795,8 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
|
||||
bActuator *act;
|
||||
int a;
|
||||
|
||||
for (sound = main->sound.first; sound; sound = sound->id.next)
|
||||
{
|
||||
if (sound->newpackedfile)
|
||||
{
|
||||
for (sound = main->sound.first; sound; sound = sound->id.next) {
|
||||
if (sound->newpackedfile) {
|
||||
sound->packedfile = sound->newpackedfile;
|
||||
sound->newpackedfile = NULL;
|
||||
}
|
||||
@ -10822,8 +10806,7 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
|
||||
for (act= ob->actuators.first; act; act= act->next) {
|
||||
if (act->type == ACT_SOUND) {
|
||||
bSoundActuator *sAct = (bSoundActuator*) act->data;
|
||||
if (sAct->sound)
|
||||
{
|
||||
if (sAct->sound) {
|
||||
sound = newlibadr(fd, lib, sAct->sound);
|
||||
sAct->flag = sound->flags & SOUND_FLAGS_3D ? ACT_SND_3D_SOUND : 0;
|
||||
sAct->pitch = sound->pitch;
|
||||
@ -10846,13 +10829,10 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
|
||||
}
|
||||
}
|
||||
|
||||
for (scene = main->scene.first; scene; scene = scene->id.next)
|
||||
{
|
||||
if (scene->ed && scene->ed->seqbasep)
|
||||
{
|
||||
for (scene = main->scene.first; scene; scene = scene->id.next) {
|
||||
if (scene->ed && scene->ed->seqbasep) {
|
||||
SEQ_BEGIN(scene->ed, seq) {
|
||||
if (seq->type == SEQ_HD_SOUND)
|
||||
{
|
||||
if (seq->type == SEQ_HD_SOUND) {
|
||||
char str[FILE_MAX];
|
||||
BLI_join_dirfile(str, sizeof(str), seq->strip->dir, seq->strip->stripdata->name);
|
||||
BLI_path_abs(str, main->name);
|
||||
@ -11228,8 +11208,7 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
|
||||
if (tex->vd->extend == 0)
|
||||
tex->vd->extend = TEX_CLIP;
|
||||
|
||||
for (sce= main->scene.first; sce; sce= sce->id.next)
|
||||
{
|
||||
for (sce= main->scene.first; sce; sce= sce->id.next) {
|
||||
if (sce->audio.main == 0.0f)
|
||||
sce->audio.main = 1.0f;
|
||||
|
||||
@ -11371,8 +11350,7 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
|
||||
}
|
||||
}
|
||||
|
||||
if (main->versionfile < 250 || (main->versionfile == 250 && main->subversionfile < 8))
|
||||
{
|
||||
if (main->versionfile < 250 || (main->versionfile == 250 && main->subversionfile < 8)) {
|
||||
{
|
||||
Scene *sce= main->scene.first;
|
||||
while (sce) {
|
||||
@ -11494,8 +11472,7 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
|
||||
}
|
||||
}
|
||||
|
||||
if (main->versionfile < 250 || (main->versionfile == 250 && main->subversionfile < 9))
|
||||
{
|
||||
if (main->versionfile < 250 || (main->versionfile == 250 && main->subversionfile < 9)) {
|
||||
Scene *sce;
|
||||
Mesh *me;
|
||||
Object *ob;
|
||||
@ -11521,8 +11498,7 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
|
||||
}
|
||||
}
|
||||
|
||||
if (main->versionfile < 250 || (main->versionfile == 250 && main->subversionfile < 10))
|
||||
{
|
||||
if (main->versionfile < 250 || (main->versionfile == 250 && main->subversionfile < 10)) {
|
||||
Object *ob;
|
||||
|
||||
/* properly initialize hair clothsim data on old files */
|
||||
@ -11539,8 +11515,7 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
|
||||
}
|
||||
|
||||
/* fix bad area setup in subversion 10 */
|
||||
if (main->versionfile == 250 && main->subversionfile == 10)
|
||||
{
|
||||
if (main->versionfile == 250 && main->subversionfile == 10) {
|
||||
/* fix for new view type in sequencer */
|
||||
bScreen *screen;
|
||||
ScrArea *sa;
|
||||
@ -11579,8 +11554,7 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
|
||||
}
|
||||
}
|
||||
|
||||
if (main->versionfile < 250 || (main->versionfile == 250 && main->subversionfile < 11))
|
||||
{
|
||||
if (main->versionfile < 250 || (main->versionfile == 250 && main->subversionfile < 11)) {
|
||||
{
|
||||
/* fix for new view type in sequencer */
|
||||
bScreen *screen;
|
||||
@ -11622,8 +11596,7 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
|
||||
}
|
||||
}
|
||||
|
||||
if (main->versionfile < 250 || (main->versionfile == 250 && main->subversionfile < 12))
|
||||
{
|
||||
if (main->versionfile < 250 || (main->versionfile == 250 && main->subversionfile < 12)) {
|
||||
Scene *sce;
|
||||
Object *ob;
|
||||
Brush *brush;
|
||||
@ -11984,8 +11957,7 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
|
||||
}
|
||||
|
||||
|
||||
if (main->versionfile < 253)
|
||||
{
|
||||
if (main->versionfile < 253) {
|
||||
Object *ob;
|
||||
Scene *scene;
|
||||
bScreen *sc;
|
||||
@ -12196,8 +12168,7 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
|
||||
}
|
||||
}
|
||||
|
||||
if (main->versionfile < 253 || (main->versionfile == 253 && main->subversionfile < 1))
|
||||
{
|
||||
if (main->versionfile < 253 || (main->versionfile == 253 && main->subversionfile < 1)) {
|
||||
Object *ob;
|
||||
|
||||
for (ob = main->object.first; ob; ob = ob->id.next) {
|
||||
@ -12206,8 +12177,7 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
|
||||
if (md->type == eModifierType_Smoke) {
|
||||
SmokeModifierData *smd = (SmokeModifierData *)md;
|
||||
|
||||
if ((smd->type & MOD_SMOKE_TYPE_DOMAIN) && smd->domain)
|
||||
{
|
||||
if ((smd->type & MOD_SMOKE_TYPE_DOMAIN) && smd->domain) {
|
||||
smd->domain->vorticity = 2.0f;
|
||||
smd->domain->time_scale = 1.0f;
|
||||
|
||||
@ -12226,8 +12196,7 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
|
||||
if (md2->type == eModifierType_Smoke) {
|
||||
SmokeModifierData *smd2 = (SmokeModifierData *)md2;
|
||||
|
||||
if ((smd2->type & MOD_SMOKE_TYPE_FLOW) && smd2->flow)
|
||||
{
|
||||
if ((smd2->type & MOD_SMOKE_TYPE_FLOW) && smd2->flow) {
|
||||
smd2->flow->flags |= MOD_SMOKE_FLOW_INITVELOCITY;
|
||||
}
|
||||
}
|
||||
@ -12313,8 +12282,7 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
|
||||
for (act= ob->actuators.first; act; act= act->next) {
|
||||
if (act->type==ACT_STEERING) {
|
||||
bSteeringActuator* stact = act->data;
|
||||
if (stact->facingaxis==0)
|
||||
{
|
||||
if (stact->facingaxis==0) {
|
||||
stact->facingaxis=1;
|
||||
}
|
||||
}
|
||||
@ -12574,8 +12542,7 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
|
||||
Scene *scene;
|
||||
Sequence *seq;
|
||||
|
||||
for (scene=main->scene.first; scene; scene=scene->id.next)
|
||||
{
|
||||
for (scene=main->scene.first; scene; scene=scene->id.next) {
|
||||
scene->r.ffcodecdata.audio_channels = 2;
|
||||
scene->audio.volume = 1.0f;
|
||||
SEQ_BEGIN(scene->ed, seq) {
|
||||
@ -12749,8 +12716,7 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
|
||||
{
|
||||
/* set defaults for obstacle avoidance, recast data */
|
||||
Scene *sce;
|
||||
for (sce = main->scene.first; sce; sce = sce->id.next)
|
||||
{
|
||||
for (sce = main->scene.first; sce; sce = sce->id.next) {
|
||||
if (sce->gm.levelHeight == 0.f)
|
||||
sce->gm.levelHeight = 2.f;
|
||||
|
||||
@ -12930,8 +12896,7 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
|
||||
}
|
||||
}
|
||||
|
||||
if (main->versionfile < 260 || (main->versionfile == 260 && main->subversionfile < 6))
|
||||
{
|
||||
if (main->versionfile < 260 || (main->versionfile == 260 && main->subversionfile < 6)) {
|
||||
Scene *sce;
|
||||
MovieClip *clip;
|
||||
bScreen *sc;
|
||||
@ -12995,8 +12960,7 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
|
||||
}
|
||||
}
|
||||
|
||||
if (main->versionfile < 260 || (main->versionfile == 260 && main->subversionfile < 8))
|
||||
{
|
||||
if (main->versionfile < 260 || (main->versionfile == 260 && main->subversionfile < 8)) {
|
||||
Brush *brush;
|
||||
|
||||
for (brush= main->brush.first; brush; brush= brush->id.next) {
|
||||
@ -13005,8 +12969,7 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
|
||||
}
|
||||
}
|
||||
|
||||
if (main->versionfile < 261 || (main->versionfile == 261 && main->subversionfile < 1))
|
||||
{
|
||||
if (main->versionfile < 261 || (main->versionfile == 261 && main->subversionfile < 1)) {
|
||||
{
|
||||
/* update use flags for node sockets (was only temporary before) */
|
||||
Scene *sce;
|
||||
@ -13107,8 +13070,7 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
|
||||
}
|
||||
}
|
||||
|
||||
if (main->versionfile < 261 || (main->versionfile == 261 && main->subversionfile < 2))
|
||||
{
|
||||
if (main->versionfile < 261 || (main->versionfile == 261 && main->subversionfile < 2)) {
|
||||
{
|
||||
/* convert Camera Actuator values to defines */
|
||||
Object *ob;
|
||||
@ -13142,8 +13104,7 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
|
||||
}
|
||||
}
|
||||
|
||||
if (main->versionfile < 261 || (main->versionfile == 261 && main->subversionfile < 3))
|
||||
{
|
||||
if (main->versionfile < 261 || (main->versionfile == 261 && main->subversionfile < 3)) {
|
||||
{
|
||||
/* convert extended ascii to utf-8 for text editor */
|
||||
Text *text;
|
||||
@ -13169,8 +13130,7 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
|
||||
for (md= ob->modifiers.first; md; md= md->next) {
|
||||
if (md->type == eModifierType_DynamicPaint) {
|
||||
DynamicPaintModifierData *pmd = (DynamicPaintModifierData *)md;
|
||||
if (pmd->canvas)
|
||||
{
|
||||
if (pmd->canvas) {
|
||||
DynamicPaintSurface *surface = pmd->canvas->surfaces.first;
|
||||
for (; surface; surface=surface->next) {
|
||||
surface->color_dry_threshold = 1.0f;
|
||||
@ -13185,8 +13145,7 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
|
||||
}
|
||||
}
|
||||
|
||||
if (main->versionfile < 262)
|
||||
{
|
||||
if (main->versionfile < 262) {
|
||||
Object *ob;
|
||||
for (ob=main->object.first; ob; ob= ob->id.next) {
|
||||
ModifierData *md;
|
||||
@ -13201,8 +13160,7 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
|
||||
}
|
||||
}
|
||||
|
||||
if (main->versionfile < 263)
|
||||
{
|
||||
if (main->versionfile < 263) {
|
||||
/* set fluidsim rate. the version patch for this in 2.62 was wrong, so
|
||||
* try to correct it, if rate is 0.0 that's likely not intentional */
|
||||
Object *ob;
|
||||
@ -13219,8 +13177,7 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
|
||||
}
|
||||
}
|
||||
|
||||
if (main->versionfile < 262 || (main->versionfile == 262 && main->subversionfile < 1))
|
||||
{
|
||||
if (main->versionfile < 262 || (main->versionfile == 262 && main->subversionfile < 1)) {
|
||||
/* update use flags for node sockets (was only temporary before) */
|
||||
Scene *sce;
|
||||
bNodeTree *ntree;
|
||||
@ -13235,8 +13192,7 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
|
||||
}
|
||||
|
||||
/* only swap for pre-release bmesh merge which had MLoopCol red/blue swap */
|
||||
if (main->versionfile == 262 && main->subversionfile == 1)
|
||||
{
|
||||
if (main->versionfile == 262 && main->subversionfile == 1) {
|
||||
{
|
||||
Mesh *me;
|
||||
for (me = main->mesh.first; me; me = me->id.next) {
|
||||
@ -13246,8 +13202,7 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
|
||||
|
||||
}
|
||||
|
||||
if (main->versionfile < 262 || (main->versionfile == 262 && main->subversionfile < 2))
|
||||
{
|
||||
if (main->versionfile < 262 || (main->versionfile == 262 && main->subversionfile < 2)) {
|
||||
{
|
||||
/* Set new idname of keyingsets from their now "label-only" name. */
|
||||
Scene *scene;
|
||||
@ -13261,8 +13216,7 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
|
||||
}
|
||||
}
|
||||
|
||||
if (main->versionfile < 262 || (main->versionfile == 262 && main->subversionfile < 3))
|
||||
{
|
||||
if (main->versionfile < 262 || (main->versionfile == 262 && main->subversionfile < 3)) {
|
||||
Object *ob;
|
||||
ModifierData *md;
|
||||
|
||||
@ -13276,8 +13230,7 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
|
||||
}
|
||||
}
|
||||
|
||||
if (main->versionfile < 262 || (main->versionfile == 262 && main->subversionfile < 4))
|
||||
{
|
||||
if (main->versionfile < 262 || (main->versionfile == 262 && main->subversionfile < 4)) {
|
||||
/* Read Viscosity presets from older files */
|
||||
Object *ob;
|
||||
|
||||
@ -13301,8 +13254,7 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
|
||||
|
||||
|
||||
|
||||
if (main->versionfile < 263)
|
||||
{
|
||||
if (main->versionfile < 263) {
|
||||
/* Default for old files is to save particle rotations to pointcache */
|
||||
ParticleSettings *part;
|
||||
for (part = main->particle.first; part; part = part->id.next)
|
||||
@ -13440,7 +13392,7 @@ BlendFileData *blo_read_file_internal(FileData *fd, const char *filepath)
|
||||
BLI_strncpy(bfd->main->name, filepath, sizeof(bfd->main->name));
|
||||
|
||||
while (bhead) {
|
||||
switch(bhead->code) {
|
||||
switch (bhead->code) {
|
||||
case DATA:
|
||||
case DNA1:
|
||||
case TEST: /* used as preview since 2.5x */
|
||||
@ -14336,7 +14288,7 @@ static void expand_main(FileData *fd, Main *mainvar)
|
||||
while (id) {
|
||||
if (id->flag & LIB_TEST) {
|
||||
|
||||
switch(GS(id->name)) {
|
||||
switch (GS(id->name)) {
|
||||
|
||||
case ID_OB:
|
||||
expand_object(fd, mainvar, (Object *)id);
|
||||
|
@ -837,7 +837,7 @@ static void write_boid_state(WriteData *wd, BoidState *state)
|
||||
writestruct(wd, DATA, "BoidState", 1, state);
|
||||
|
||||
for (; rule; rule=rule->next) {
|
||||
switch(rule->type) {
|
||||
switch (rule->type) {
|
||||
case eBoidRuleType_Goal:
|
||||
case eBoidRuleType_Avoid:
|
||||
writestruct(wd, DATA, "BoidRuleGoalAvoid", 1, rule);
|
||||
@ -1030,7 +1030,7 @@ static void write_sensors(WriteData *wd, ListBase *lb)
|
||||
|
||||
writedata(wd, DATA, sizeof(void *)*sens->totlinks, sens->links);
|
||||
|
||||
switch(sens->type) {
|
||||
switch (sens->type) {
|
||||
case SENS_NEAR:
|
||||
writestruct(wd, DATA, "bNearSensor", 1, sens->data);
|
||||
break;
|
||||
@ -1091,7 +1091,7 @@ static void write_controllers(WriteData *wd, ListBase *lb)
|
||||
|
||||
writedata(wd, DATA, sizeof(void *)*cont->totlinks, cont->links);
|
||||
|
||||
switch(cont->type) {
|
||||
switch (cont->type) {
|
||||
case CONT_EXPRESSION:
|
||||
writestruct(wd, DATA, "bExpressionCont", 1, cont->data);
|
||||
break;
|
||||
@ -1114,7 +1114,7 @@ static void write_actuators(WriteData *wd, ListBase *lb)
|
||||
while (act) {
|
||||
writestruct(wd, DATA, "bActuator", 1, act);
|
||||
|
||||
switch(act->type) {
|
||||
switch (act->type) {
|
||||
case ACT_ACTION:
|
||||
case ACT_SHAPEACTION:
|
||||
writestruct(wd, DATA, "bActionActuator", 1, act->data);
|
||||
@ -1316,10 +1316,8 @@ static void write_modifiers(WriteData *wd, ListBase *modbase)
|
||||
else if (md->type==eModifierType_Smoke) {
|
||||
SmokeModifierData *smd = (SmokeModifierData*) md;
|
||||
|
||||
if (smd->type & MOD_SMOKE_TYPE_DOMAIN)
|
||||
{
|
||||
if (smd->domain)
|
||||
{
|
||||
if (smd->type & MOD_SMOKE_TYPE_DOMAIN) {
|
||||
if (smd->domain) {
|
||||
write_pointcaches(wd, &(smd->domain->ptcaches[0]));
|
||||
|
||||
/* create fake pointcache so that old blender versions can read it */
|
||||
@ -1353,8 +1351,7 @@ static void write_modifiers(WriteData *wd, ListBase *modbase)
|
||||
else if (md->type==eModifierType_DynamicPaint) {
|
||||
DynamicPaintModifierData *pmd = (DynamicPaintModifierData*) md;
|
||||
|
||||
if (pmd->canvas)
|
||||
{
|
||||
if (pmd->canvas) {
|
||||
DynamicPaintSurface *surface;
|
||||
writestruct(wd, DATA, "DynamicPaintCanvasSettings", 1, pmd->canvas);
|
||||
|
||||
@ -1368,8 +1365,7 @@ static void write_modifiers(WriteData *wd, ListBase *modbase)
|
||||
writestruct(wd, DATA, "EffectorWeights", 1, surface->effector_weights);
|
||||
}
|
||||
}
|
||||
if (pmd->brush)
|
||||
{
|
||||
if (pmd->brush) {
|
||||
writestruct(wd, DATA, "DynamicPaintBrushSettings", 1, pmd->brush);
|
||||
writestruct(wd, DATA, "ColorBand", 1, pmd->brush->paint_ramp);
|
||||
writestruct(wd, DATA, "ColorBand", 1, pmd->brush->vel_ramp);
|
||||
@ -2124,7 +2120,7 @@ static void write_scenes(WriteData *wd, ListBase *scebase)
|
||||
|
||||
if (seq->plugin) writestruct(wd, DATA, "PluginSeq", 1, seq->plugin);
|
||||
if (seq->effectdata) {
|
||||
switch(seq->type) {
|
||||
switch (seq->type) {
|
||||
case SEQ_COLOR:
|
||||
writestruct(wd, DATA, "SolidColorVars", 1, seq->effectdata);
|
||||
break;
|
||||
@ -2258,7 +2254,7 @@ static void write_region(WriteData *wd, ARegion *ar, int spacetype)
|
||||
writestruct(wd, DATA, "ARegion", 1, ar);
|
||||
|
||||
if (ar->regiondata) {
|
||||
switch(spacetype) {
|
||||
switch (spacetype) {
|
||||
case SPACE_VIEW3D:
|
||||
if (ar->regiontype==RGN_TYPE_WINDOW) {
|
||||
RegionView3D *rv3d= ar->regiondata;
|
||||
|
@ -226,8 +226,7 @@ void *BMW_state_add(BMWalker *walker)
|
||||
BMwGenericWalker *newstate;
|
||||
newstate = BLI_mempool_alloc(walker->worklist);
|
||||
newstate->depth = walker->depth;
|
||||
switch (walker->order)
|
||||
{
|
||||
switch (walker->order) {
|
||||
case BMW_DEPTH_FIRST:
|
||||
BLI_addhead(&walker->states, newstate);
|
||||
break;
|
||||
|
@ -880,7 +880,7 @@ static void *bmw_EdgeringWalker_step(BMWalker *walker)
|
||||
}
|
||||
/* only walk to manifold edge */
|
||||
if ((l->f->len % 2 == 0) && EDGE_CHECK(l->e) &&
|
||||
!BLI_ghash_haskey(walker->visithash, l->e))
|
||||
!BLI_ghash_haskey(walker->visithash, l->e))
|
||||
|
||||
#else
|
||||
|
||||
|
@ -29,7 +29,7 @@ void forEachObjectInScene(Scene *sce, Functor &f)
|
||||
{
|
||||
Base *base= (Base*) sce->base.first;
|
||||
|
||||
while(base) {
|
||||
while (base) {
|
||||
Object *ob = base->object;
|
||||
|
||||
f(ob);
|
||||
@ -59,13 +59,11 @@ void AnimationExporter::operator() (Object *ob)
|
||||
/* bool isMatAnim = false; */ /* UNUSED */
|
||||
|
||||
//Export transform animations
|
||||
if (ob->adt && ob->adt->action)
|
||||
{
|
||||
if (ob->adt && ob->adt->action) {
|
||||
fcu = (FCurve*)ob->adt->action->curves.first;
|
||||
|
||||
//transform matrix export for bones are temporarily disabled here.
|
||||
if ( ob->type == OB_ARMATURE )
|
||||
{
|
||||
if ( ob->type == OB_ARMATURE ) {
|
||||
bArmature *arm = (bArmature*)ob->data;
|
||||
for (Bone *bone = (Bone*)arm->bonebase.first; bone; bone = bone->next)
|
||||
write_bone_animation_matrix(ob, bone);
|
||||
@ -79,59 +77,63 @@ void AnimationExporter::operator() (Object *ob)
|
||||
transformName = extract_transform_name( fcu->rna_path );
|
||||
|
||||
if ((!strcmp(transformName, "location") || !strcmp(transformName, "scale")) ||
|
||||
(!strcmp(transformName, "rotation_euler") && ob->rotmode == ROT_MODE_EUL)||
|
||||
(!strcmp(transformName, "rotation_quaternion")))
|
||||
(!strcmp(transformName, "rotation_euler") && ob->rotmode == ROT_MODE_EUL)||
|
||||
(!strcmp(transformName, "rotation_quaternion")))
|
||||
{
|
||||
dae_animation(ob ,fcu, transformName, false);
|
||||
}
|
||||
fcu = fcu->next;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//Export Lamp parameter animations
|
||||
if ( (ob->type == OB_LAMP ) && ((Lamp*)ob ->data)->adt && ((Lamp*)ob ->data)->adt->action )
|
||||
{
|
||||
if ( (ob->type == OB_LAMP ) && ((Lamp*)ob ->data)->adt && ((Lamp*)ob ->data)->adt->action ) {
|
||||
fcu = (FCurve*)(((Lamp*)ob ->data)->adt->action->curves.first);
|
||||
while (fcu) {
|
||||
transformName = extract_transform_name( fcu->rna_path );
|
||||
|
||||
if ((!strcmp(transformName, "color")) || (!strcmp(transformName, "spot_size"))|| (!strcmp(transformName, "spot_blend"))||
|
||||
(!strcmp(transformName, "distance")) )
|
||||
dae_animation(ob , fcu, transformName, true );
|
||||
if ((!strcmp(transformName, "color")) || (!strcmp(transformName, "spot_size"))||
|
||||
(!strcmp(transformName, "spot_blend")) || (!strcmp(transformName, "distance")))
|
||||
{
|
||||
dae_animation(ob , fcu, transformName, true);
|
||||
}
|
||||
fcu = fcu->next;
|
||||
}
|
||||
}
|
||||
|
||||
//Export Camera parameter animations
|
||||
if ( (ob->type == OB_CAMERA ) && ((Camera*)ob ->data)->adt && ((Camera*)ob ->data)->adt->action )
|
||||
{
|
||||
if ( (ob->type == OB_CAMERA ) && ((Camera*)ob ->data)->adt && ((Camera*)ob ->data)->adt->action ) {
|
||||
fcu = (FCurve*)(((Camera*)ob ->data)->adt->action->curves.first);
|
||||
while (fcu) {
|
||||
transformName = extract_transform_name( fcu->rna_path );
|
||||
|
||||
if ((!strcmp(transformName, "lens"))||
|
||||
(!strcmp(transformName, "ortho_scale"))||
|
||||
(!strcmp(transformName, "clip_end"))||(!strcmp(transformName, "clip_start")))
|
||||
dae_animation(ob , fcu, transformName, true );
|
||||
(!strcmp(transformName, "ortho_scale"))||
|
||||
(!strcmp(transformName, "clip_end"))||(!strcmp(transformName, "clip_start")))
|
||||
{
|
||||
dae_animation(ob , fcu, transformName, true);
|
||||
}
|
||||
fcu = fcu->next;
|
||||
}
|
||||
}
|
||||
|
||||
//Export Material parameter animations.
|
||||
for (int a = 0; a < ob->totcol; a++)
|
||||
{
|
||||
for (int a = 0; a < ob->totcol; a++) {
|
||||
Material *ma = give_current_material(ob, a+1);
|
||||
if (!ma) continue;
|
||||
if (ma->adt && ma->adt->action)
|
||||
{
|
||||
if (ma->adt && ma->adt->action) {
|
||||
/* isMatAnim = true; */
|
||||
fcu = (FCurve*)ma->adt->action->curves.first;
|
||||
while (fcu) {
|
||||
transformName = extract_transform_name( fcu->rna_path );
|
||||
|
||||
if ((!strcmp(transformName, "specular_hardness"))||(!strcmp(transformName, "specular_color"))
|
||||
||(!strcmp(transformName, "diffuse_color"))||(!strcmp(transformName, "alpha"))||
|
||||
(!strcmp(transformName, "ior")))
|
||||
if ((!strcmp(transformName, "specular_hardness"))||(!strcmp(transformName, "specular_color")) ||
|
||||
(!strcmp(transformName, "diffuse_color"))||(!strcmp(transformName, "alpha")) ||
|
||||
(!strcmp(transformName, "ior")))
|
||||
{
|
||||
dae_animation(ob ,fcu, transformName, true, ma );
|
||||
}
|
||||
fcu = fcu->next;
|
||||
}
|
||||
}
|
||||
@ -148,8 +150,7 @@ float * AnimationExporter::get_eul_source_for_quat(Object *ob )
|
||||
float *eul = (float*)MEM_callocN(sizeof(float) * fcu->totvert * 3, "quat output source values");
|
||||
float temp_quat[4];
|
||||
float temp_eul[3];
|
||||
while(fcu)
|
||||
{
|
||||
while (fcu) {
|
||||
char * transformName = extract_transform_name( fcu->rna_path );
|
||||
|
||||
if ( !strcmp(transformName, "rotation_quaternion") ) {
|
||||
@ -199,8 +200,7 @@ void AnimationExporter::dae_animation(Object* ob, FCurve *fcu, char* transformNa
|
||||
bool has_tangents = false;
|
||||
bool quatRotation = false;
|
||||
|
||||
if ( !strcmp(transformName, "rotation_quaternion") )
|
||||
{
|
||||
if ( !strcmp(transformName, "rotation_quaternion") ) {
|
||||
fprintf(stderr, "quaternion rotation curves are not supported. rotation curve will not be exported\n");
|
||||
quatRotation = true;
|
||||
return;
|
||||
@ -223,23 +223,20 @@ void AnimationExporter::dae_animation(Object* ob, FCurve *fcu, char* transformNa
|
||||
if (fcu->array_index < 3)
|
||||
axis_name = axis_names[fcu->array_index];
|
||||
}
|
||||
|
||||
//no axis name. single parameter.
|
||||
else{
|
||||
else {
|
||||
/* no axis name. single parameter */
|
||||
axis_name = "";
|
||||
}
|
||||
|
||||
std::string ob_name = std::string("null");
|
||||
|
||||
//Create anim Id
|
||||
if (ob->type == OB_ARMATURE)
|
||||
{
|
||||
if (ob->type == OB_ARMATURE) {
|
||||
ob_name = getObjectBoneName( ob , fcu);
|
||||
BLI_snprintf(anim_id, sizeof(anim_id), "%s_%s.%s", (char*)translate_id(ob_name).c_str(),
|
||||
transformName, axis_name);
|
||||
}
|
||||
else
|
||||
{
|
||||
else {
|
||||
if (ma)
|
||||
ob_name = id_name(ob) + "_material";
|
||||
else
|
||||
@ -257,18 +254,17 @@ void AnimationExporter::dae_animation(Object* ob, FCurve *fcu, char* transformNa
|
||||
std::string output_id;
|
||||
|
||||
//quat rotations are skipped for now, because of complications with determining axis.
|
||||
if (quatRotation)
|
||||
{
|
||||
float * eul = get_eul_source_for_quat(ob);
|
||||
float * eul_axis = (float*)MEM_callocN(sizeof(float) * fcu->totvert, "quat output source values");
|
||||
for ( int i = 0 ; i< fcu->totvert ; i++)
|
||||
if (quatRotation) {
|
||||
float *eul = get_eul_source_for_quat(ob);
|
||||
float *eul_axis = (float*)MEM_callocN(sizeof(float) * fcu->totvert, "quat output source values");
|
||||
for (int i = 0 ; i< fcu->totvert ; i++) {
|
||||
eul_axis[i] = eul[i*3 + fcu->array_index];
|
||||
}
|
||||
output_id= create_source_from_array(COLLADASW::InputSemantic::OUTPUT, eul_axis , fcu->totvert, quatRotation, anim_id, axis_name);
|
||||
MEM_freeN(eul);
|
||||
MEM_freeN(eul_axis);
|
||||
}
|
||||
else
|
||||
{
|
||||
else {
|
||||
output_id= create_source_from_fcurve(COLLADASW::InputSemantic::OUTPUT, fcu, anim_id, axis_name);
|
||||
}
|
||||
// create interpolations source
|
||||
@ -307,8 +303,7 @@ void AnimationExporter::dae_animation(Object* ob, FCurve *fcu, char* transformNa
|
||||
if ( !is_param )
|
||||
target = translate_id(ob_name)
|
||||
+ "/" + get_transform_sid(fcu->rna_path, -1, axis_name, true);
|
||||
else
|
||||
{
|
||||
else {
|
||||
if ( ob->type == OB_LAMP )
|
||||
target = get_light_id(ob)
|
||||
+ "/" + get_light_param_sid(fcu->rna_path, -1, axis_name, true);
|
||||
@ -349,8 +344,7 @@ bool AnimationExporter::is_bone_deform_group(Bone * bone)
|
||||
//Check if current bone is deform
|
||||
if ((bone->flag & BONE_NO_DEFORM) == 0 ) return true;
|
||||
//Check child bones
|
||||
else
|
||||
{
|
||||
else {
|
||||
for (Bone *child = (Bone*)bone->childbase.first; child; child = child->next) {
|
||||
//loop through all the children until deform bone is found, and then return
|
||||
is_def = is_bone_deform_group(child);
|
||||
@ -369,8 +363,7 @@ void AnimationExporter::sample_and_write_bone_animation_matrix(Object *ob_arm, B
|
||||
//char prefix[256];
|
||||
|
||||
FCurve* fcu = (FCurve*)ob_arm->adt->action->curves.first;
|
||||
while(fcu)
|
||||
{
|
||||
while (fcu) {
|
||||
std::string bone_name = getObjectBoneName(ob_arm,fcu);
|
||||
int val = BLI_strcasecmp((char*)bone_name.c_str(),bone->name);
|
||||
if (val==0) break;
|
||||
@ -511,7 +504,7 @@ float AnimationExporter::convert_angle(float angle)
|
||||
|
||||
std::string AnimationExporter::get_semantic_suffix(COLLADASW::InputSemantic::Semantics semantic)
|
||||
{
|
||||
switch(semantic) {
|
||||
switch (semantic) {
|
||||
case COLLADASW::InputSemantic::INPUT:
|
||||
return INPUT_SOURCE_ID_SUFFIX;
|
||||
case COLLADASW::InputSemantic::OUTPUT:
|
||||
@ -531,7 +524,7 @@ std::string AnimationExporter::get_semantic_suffix(COLLADASW::InputSemantic::Sem
|
||||
void AnimationExporter::add_source_parameters(COLLADASW::SourceBase::ParameterNameList& param,
|
||||
COLLADASW::InputSemantic::Semantics semantic, bool is_rot, const char *axis, bool transform)
|
||||
{
|
||||
switch(semantic) {
|
||||
switch (semantic) {
|
||||
case COLLADASW::InputSemantic::INPUT:
|
||||
param.push_back("TIME");
|
||||
break;
|
||||
@ -544,8 +537,7 @@ void AnimationExporter::add_source_parameters(COLLADASW::SourceBase::ParameterNa
|
||||
param.push_back(axis);
|
||||
}
|
||||
else
|
||||
if ( transform )
|
||||
{
|
||||
if ( transform ) {
|
||||
param.push_back("TRANSFORM");
|
||||
}
|
||||
else { //assumes if axis isn't specified all axises are added
|
||||
@ -778,8 +770,7 @@ std::string AnimationExporter::create_4x4_source(std::vector<float> &frames , Ob
|
||||
// SECOND_LIFE_COMPATIBILITY
|
||||
// AFAIK animation to second life is via BVH, but no
|
||||
// reason to not have the collada-animation be correct
|
||||
if (export_settings->second_life)
|
||||
{
|
||||
if (export_settings->second_life) {
|
||||
float temp[4][4];
|
||||
copy_m4_m4(temp, bone->arm_mat);
|
||||
temp[3][0] = temp[3][1] = temp[3][2] = 0.0f;
|
||||
@ -787,8 +778,7 @@ std::string AnimationExporter::create_4x4_source(std::vector<float> &frames , Ob
|
||||
|
||||
mult_m4_m4m4(mat, mat, temp);
|
||||
|
||||
if (bone->parent)
|
||||
{
|
||||
if (bone->parent) {
|
||||
copy_m4_m4(temp, bone->parent->arm_mat);
|
||||
temp[3][0] = temp[3][1] = temp[3][2] = 0.0f;
|
||||
|
||||
@ -1128,7 +1118,7 @@ bool AnimationExporter::hasAnimations(Scene *sce)
|
||||
{
|
||||
Base *base= (Base*) sce->base.first;
|
||||
|
||||
while(base) {
|
||||
while (base) {
|
||||
Object *ob = base->object;
|
||||
|
||||
FCurve *fcu = 0;
|
||||
@ -1143,12 +1133,10 @@ bool AnimationExporter::hasAnimations(Scene *sce)
|
||||
fcu = (FCurve*)(((Camera*)ob ->data)->adt->action->curves.first);
|
||||
|
||||
//Check Material Effect parameter animations.
|
||||
for (int a = 0; a < ob->totcol; a++)
|
||||
{
|
||||
for (int a = 0; a < ob->totcol; a++) {
|
||||
Material *ma = give_current_material(ob, a+1);
|
||||
if (!ma) continue;
|
||||
if (ma->adt && ma->adt->action)
|
||||
{
|
||||
if (ma->adt && ma->adt->action) {
|
||||
fcu = (FCurve*)ma->adt->action->curves.first;
|
||||
}
|
||||
}
|
||||
|
@ -138,8 +138,7 @@ void AnimationImporter::animation_to_fcurves(COLLADAFW::AnimationCurve *curve)
|
||||
bez.ipo = BEZT_IPO_CONST;
|
||||
//bez.h1 = bez.h2 = HD_AUTO;
|
||||
}
|
||||
else
|
||||
{
|
||||
else {
|
||||
bez.h1 = bez.h2 = HD_AUTO;
|
||||
bez.ipo = BEZT_IPO_LIN;
|
||||
}
|
||||
@ -789,17 +788,15 @@ void AnimationImporter::translate_Animations ( COLLADAFW::Node * node ,
|
||||
bool is_joint = node->getType() == COLLADAFW::Node::JOINT;
|
||||
COLLADAFW::Node *root = root_map.find(node->getUniqueId()) == root_map.end() ? node : root_map[node->getUniqueId()];
|
||||
Object *ob = is_joint ? armature_importer->get_armature_for_joint(root) : object_map[node->getUniqueId()];
|
||||
if (!ob)
|
||||
{
|
||||
if (!ob) {
|
||||
fprintf(stderr, "cannot find Object for Node with id=\"%s\"\n", node->getOriginalId().c_str());
|
||||
return;
|
||||
}
|
||||
|
||||
bAction * act;
|
||||
|
||||
if ( (animType->transform) != 0 )
|
||||
{
|
||||
const char *bone_name = is_joint ? bc_get_joint_name(node) : NULL;
|
||||
if ( (animType->transform) != 0 ) {
|
||||
/* const char *bone_name = is_joint ? bc_get_joint_name(node) : NULL; */ /* UNUSED */
|
||||
char joint_path[200];
|
||||
|
||||
if ( is_joint )
|
||||
@ -867,8 +864,7 @@ void AnimationImporter::translate_Animations ( COLLADAFW::Node * node ,
|
||||
}
|
||||
}
|
||||
|
||||
if ((animType->light) != 0)
|
||||
{
|
||||
if ((animType->light) != 0) {
|
||||
Lamp * lamp = (Lamp*) ob->data;
|
||||
|
||||
if (!lamp->adt || !lamp->adt->action) act = verify_adt_action((ID*)&lamp->id, 1);
|
||||
@ -880,22 +876,19 @@ void AnimationImporter::translate_Animations ( COLLADAFW::Node * node ,
|
||||
for (unsigned int i = 0; i < nodeLights.getCount(); i++) {
|
||||
const COLLADAFW::Light *light = (COLLADAFW::Light *) FW_object_map[nodeLights[i]->getInstanciatedObjectId()];
|
||||
|
||||
if ((animType->light & LIGHT_COLOR) != 0)
|
||||
{
|
||||
if ((animType->light & LIGHT_COLOR) != 0) {
|
||||
const COLLADAFW::Color *col = &(light->getColor());
|
||||
const COLLADAFW::UniqueId& listid = col->getAnimationList();
|
||||
|
||||
Assign_color_animations(listid, AnimCurves, "color");
|
||||
}
|
||||
if ((animType->light & LIGHT_FOA) != 0 )
|
||||
{
|
||||
if ((animType->light & LIGHT_FOA) != 0 ) {
|
||||
const COLLADAFW::AnimatableFloat *foa = &(light->getFallOffAngle());
|
||||
const COLLADAFW::UniqueId& listid = foa->getAnimationList();
|
||||
|
||||
Assign_float_animations( listid ,AnimCurves, "spot_size");
|
||||
}
|
||||
if ( (animType->light & LIGHT_FOE) != 0 )
|
||||
{
|
||||
if ( (animType->light & LIGHT_FOE) != 0 ) {
|
||||
const COLLADAFW::AnimatableFloat *foe = &(light->getFallOffExponent());
|
||||
const COLLADAFW::UniqueId& listid = foe->getAnimationList();
|
||||
|
||||
@ -905,8 +898,7 @@ void AnimationImporter::translate_Animations ( COLLADAFW::Node * node ,
|
||||
}
|
||||
}
|
||||
|
||||
if ( (animType->camera) != 0)
|
||||
{
|
||||
if ( (animType->camera) != 0) {
|
||||
Camera * camera = (Camera*) ob->data;
|
||||
|
||||
if (!camera->adt || !camera->adt->action) act = verify_adt_action((ID*)&camera->id, 1);
|
||||
@ -918,29 +910,25 @@ void AnimationImporter::translate_Animations ( COLLADAFW::Node * node ,
|
||||
for (unsigned int i = 0; i < nodeCameras.getCount(); i++) {
|
||||
const COLLADAFW::Camera *camera = (COLLADAFW::Camera *) FW_object_map[nodeCameras[i]->getInstanciatedObjectId()];
|
||||
|
||||
if ((animType->camera & CAMERA_XFOV) != 0 )
|
||||
{
|
||||
if ((animType->camera & CAMERA_XFOV) != 0 ) {
|
||||
const COLLADAFW::AnimatableFloat *xfov = &(camera->getXFov());
|
||||
const COLLADAFW::UniqueId& listid = xfov->getAnimationList();
|
||||
Assign_float_animations( listid ,AnimCurves, "lens");
|
||||
}
|
||||
|
||||
else if ((animType->camera & CAMERA_XMAG) != 0 )
|
||||
{
|
||||
else if ((animType->camera & CAMERA_XMAG) != 0 ) {
|
||||
const COLLADAFW::AnimatableFloat *xmag = &(camera->getXMag());
|
||||
const COLLADAFW::UniqueId& listid = xmag->getAnimationList();
|
||||
Assign_float_animations( listid ,AnimCurves, "ortho_scale");
|
||||
}
|
||||
|
||||
if ((animType->camera & CAMERA_ZFAR) != 0 )
|
||||
{
|
||||
if ((animType->camera & CAMERA_ZFAR) != 0 ) {
|
||||
const COLLADAFW::AnimatableFloat *zfar = &(camera->getFarClippingPlane());
|
||||
const COLLADAFW::UniqueId& listid = zfar->getAnimationList();
|
||||
Assign_float_animations( listid ,AnimCurves, "clip_end");
|
||||
}
|
||||
|
||||
if ((animType->camera & CAMERA_ZNEAR) != 0 )
|
||||
{
|
||||
if ((animType->camera & CAMERA_ZNEAR) != 0 ) {
|
||||
const COLLADAFW::AnimatableFloat *znear = &(camera->getNearClippingPlane());
|
||||
const COLLADAFW::UniqueId& listid = znear->getAnimationList();
|
||||
Assign_float_animations( listid ,AnimCurves, "clip_start");
|
||||
@ -1162,12 +1150,10 @@ AnimationImporter::AnimMix* AnimationImporter::get_animation_type ( const COLLAD
|
||||
for (unsigned int i = 0; i < nodeCameras.getCount(); i++) {
|
||||
const COLLADAFW::Camera *camera = (COLLADAFW::Camera *) FW_object_map[nodeCameras[i]->getInstanciatedObjectId()];
|
||||
|
||||
if ( camera->getCameraType() == COLLADAFW::Camera::PERSPECTIVE )
|
||||
{
|
||||
if ( camera->getCameraType() == COLLADAFW::Camera::PERSPECTIVE ) {
|
||||
types->camera = setAnimType(&(camera->getXMag()),(types->camera), CAMERA_XFOV);
|
||||
}
|
||||
else
|
||||
{
|
||||
else {
|
||||
types->camera = setAnimType(&(camera->getXMag()),(types->camera), CAMERA_XMAG);
|
||||
}
|
||||
types->camera = setAnimType(&(camera->getFarClippingPlane()),(types->camera), CAMERA_ZFAR);
|
||||
@ -1641,7 +1627,7 @@ bool AnimationImporter::evaluate_animation(COLLADAFW::Transformation *tm, float
|
||||
|
||||
COLLADABU::Math::Vector3& axis = ((COLLADAFW::Rotate*)tm)->getRotationAxis();
|
||||
|
||||
float ax[3] = {axis[0], axis[1], axis[2]};
|
||||
float ax[3] = {(float)axis[0], (float)axis[1], (float)axis[2]};
|
||||
float angle = evaluate_fcurve(curves[0], fra);
|
||||
axis_angle_to_mat4(mat, ax, angle);
|
||||
|
||||
|
@ -127,7 +127,7 @@ void ArmatureExporter::find_objects_using_armature(Object *ob_arm, std::vector<O
|
||||
objects.clear();
|
||||
|
||||
Base *base= (Base*) sce->base.first;
|
||||
while(base) {
|
||||
while (base) {
|
||||
Object *ob = base->object;
|
||||
|
||||
if (ob->type == OB_MESH && get_assigned_armature(ob) == ob_arm) {
|
||||
@ -191,10 +191,8 @@ void ArmatureExporter::add_bone_node(Bone *bone, Object *ob_arm, Scene* sce,
|
||||
// Write nodes of childobjects, remove written objects from list
|
||||
std::list<Object*>::iterator i = child_objects.begin();
|
||||
|
||||
while( i != child_objects.end() )
|
||||
{
|
||||
if ((*i)->partype == PARBONE && (0 == strcmp((*i)->parsubstr, bone->name)))
|
||||
{
|
||||
while (i != child_objects.end()) {
|
||||
if ((*i)->partype == PARBONE && (0 == strcmp((*i)->parsubstr, bone->name))) {
|
||||
float backup_parinv[4][4];
|
||||
copy_m4_m4(backup_parinv, (*i)->parentinv);
|
||||
|
||||
@ -210,8 +208,7 @@ void ArmatureExporter::add_bone_node(Bone *bone, Object *ob_arm, Scene* sce,
|
||||
// TODO: when such objects are animated as
|
||||
// single matrix the tweak must be applied
|
||||
// to the result.
|
||||
if (export_settings->second_life)
|
||||
{
|
||||
if (export_settings->second_life) {
|
||||
// tweak objects parentinverse to match compatibility
|
||||
float temp[4][4];
|
||||
|
||||
@ -274,8 +271,7 @@ void ArmatureExporter::add_bone_transform(Object *ob_arm, Bone *bone, COLLADASW:
|
||||
}
|
||||
|
||||
// SECOND_LIFE_COMPATIBILITY
|
||||
if (export_settings->second_life)
|
||||
{
|
||||
if (export_settings->second_life) {
|
||||
// Remove rotations vs armature from transform
|
||||
// parent_rest_rot * mat * irest_rot
|
||||
float temp[4][4];
|
||||
@ -285,8 +281,7 @@ void ArmatureExporter::add_bone_transform(Object *ob_arm, Bone *bone, COLLADASW:
|
||||
|
||||
mult_m4_m4m4(mat, mat, temp);
|
||||
|
||||
if (bone->parent)
|
||||
{
|
||||
if (bone->parent) {
|
||||
copy_m4_m4(temp, bone->parent->arm_mat);
|
||||
temp[3][0] = temp[3][1] = temp[3][2] = 0.0f;
|
||||
|
||||
@ -370,25 +365,21 @@ void ArmatureExporter::export_controller(Object* ob, Object *ob_arm)
|
||||
|
||||
for (j = 0; j < vert->totweight; j++) {
|
||||
int joint_index = joint_index_by_def_index[vert->dw[j].def_nr];
|
||||
if (joint_index != -1 && vert->dw[j].weight > 0.0f)
|
||||
{
|
||||
if (joint_index != -1 && vert->dw[j].weight > 0.0f) {
|
||||
jw[joint_index] += vert->dw[j].weight;
|
||||
sumw += vert->dw[j].weight;
|
||||
}
|
||||
}
|
||||
|
||||
if (sumw > 0.0f)
|
||||
{
|
||||
if (sumw > 0.0f) {
|
||||
float invsumw = 1.0f/sumw;
|
||||
vcounts.push_back(jw.size());
|
||||
for (std::map<int, float>::iterator m = jw.begin(); m != jw.end(); ++m)
|
||||
{
|
||||
for (std::map<int, float>::iterator m = jw.begin(); m != jw.end(); ++m) {
|
||||
joints.push_back((*m).first);
|
||||
weights.push_back(invsumw*(*m).second);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
else {
|
||||
vcounts.push_back(0);
|
||||
/*vcounts.push_back(1);
|
||||
joints.push_back(-1);
|
||||
@ -502,16 +493,14 @@ std::string ArmatureExporter::add_inv_bind_mats_source(Object *ob_arm, ListBase
|
||||
float inv_bind_mat[4][4];
|
||||
|
||||
// SECOND_LIFE_COMPATIBILITY
|
||||
if (export_settings->second_life)
|
||||
{
|
||||
if (export_settings->second_life) {
|
||||
// Only translations, no rotation vs armature
|
||||
float temp[4][4];
|
||||
unit_m4(temp);
|
||||
copy_v3_v3(temp[3], pchan->bone->arm_mat[3]);
|
||||
mult_m4_m4m4(world, ob_arm->obmat, temp);
|
||||
}
|
||||
else
|
||||
{
|
||||
else {
|
||||
// make world-space matrix, arm_mat is armature-space
|
||||
mult_m4_m4m4(world, ob_arm->obmat, pchan->bone->arm_mat);
|
||||
}
|
||||
@ -597,8 +586,7 @@ void ArmatureExporter::add_vertex_weights_element(const std::string& weights_sou
|
||||
|
||||
// write deformer index - weight index pairs
|
||||
int weight_index = 0;
|
||||
for (std::list<int>::const_iterator i = joints.begin(); i != joints.end(); ++i)
|
||||
{
|
||||
for (std::list<int>::const_iterator i = joints.begin(); i != joints.end(); ++i) {
|
||||
weightselem.appendValues(*i, weight_index++);
|
||||
}
|
||||
|
||||
|
@ -278,8 +278,7 @@ void ArmatureImporter::add_leaf_bone(float mat[][4], EditBone *bone, COLLADAFW:
|
||||
TagsMap::iterator etit;
|
||||
ExtraTags *et = 0;
|
||||
etit = uid_tags_map.find(node->getUniqueId().toAscii());
|
||||
if (etit != uid_tags_map.end())
|
||||
{
|
||||
if (etit != uid_tags_map.end()) {
|
||||
et = etit->second;
|
||||
//else return;
|
||||
|
||||
|
@ -42,15 +42,14 @@ CamerasExporter::CamerasExporter(COLLADASW::StreamWriter *sw, const ExportSettin
|
||||
template<class Functor>
|
||||
void forEachCameraObjectInScene(Scene *sce, Functor &f, bool export_selected)
|
||||
{
|
||||
Base *base= (Base*) sce->base.first;
|
||||
while(base) {
|
||||
Base *base = (Base*) sce->base.first;
|
||||
while (base) {
|
||||
Object *ob = base->object;
|
||||
|
||||
if (ob->type == OB_CAMERA && ob->data
|
||||
&& !(export_selected && !(ob->flag & SELECT))) {
|
||||
|
||||
if (ob->type == OB_CAMERA && ob->data && !(export_selected && !(ob->flag & SELECT))) {
|
||||
f(ob, sce);
|
||||
}
|
||||
base= base->next;
|
||||
base = base->next;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -175,7 +175,7 @@ void DocumentExporter::exportCurrentScene(Scene *sce)
|
||||
std::string unitname = "meter";
|
||||
float linearmeasure = RNA_float_get(&unit_settings, "scale_length");
|
||||
|
||||
switch(RNA_property_enum_get(&unit_settings, system)) {
|
||||
switch (RNA_property_enum_get(&unit_settings, system)) {
|
||||
case USER_UNIT_NONE:
|
||||
case USER_UNIT_METRIC:
|
||||
if (linearmeasure == 0.001f) {
|
||||
|
@ -106,7 +106,7 @@ DocumentImporter::~DocumentImporter()
|
||||
{
|
||||
TagsMap::iterator etit;
|
||||
etit = uid_tags_map.begin();
|
||||
while(etit!=uid_tags_map.end()) {
|
||||
while (etit!=uid_tags_map.end()) {
|
||||
delete etit->second;
|
||||
etit++;
|
||||
}
|
||||
@ -178,7 +178,7 @@ void DocumentImporter::finish()
|
||||
system = RNA_struct_find_property(&unit_settings, "system");
|
||||
scale = RNA_struct_find_property(&unit_settings, "scale_length");
|
||||
|
||||
switch(unit_converter.isMetricSystem()) {
|
||||
switch (unit_converter.isMetricSystem()) {
|
||||
case UnitConverter::Metric:
|
||||
RNA_property_enum_set(&unit_settings, system, USER_UNIT_METRIC);
|
||||
break;
|
||||
@ -744,8 +744,7 @@ bool DocumentImporter::writeEffect( const COLLADAFW::Effect* effect )
|
||||
|
||||
Material *ma = uid_effect_map[uid];
|
||||
std::map<COLLADAFW::UniqueId, Material*>::iterator iter;
|
||||
for (iter = uid_material_map.begin(); iter != uid_material_map.end() ; iter++ )
|
||||
{
|
||||
for (iter = uid_material_map.begin(); iter != uid_material_map.end() ; iter++ ) {
|
||||
if ( iter->second == ma ) {
|
||||
this->FW_object_map[iter->first] = effect;
|
||||
break;
|
||||
@ -789,7 +788,7 @@ bool DocumentImporter::writeCamera( const COLLADAFW::Camera* camera )
|
||||
cam->clipend = camera->getFarClippingPlane().getValue();
|
||||
|
||||
COLLADAFW::Camera::CameraType type = camera->getCameraType();
|
||||
switch(type) {
|
||||
switch (type) {
|
||||
case COLLADAFW::Camera::ORTHOGRAPHIC:
|
||||
{
|
||||
cam->type = CAM_ORTHO;
|
||||
@ -808,10 +807,10 @@ bool DocumentImporter::writeCamera( const COLLADAFW::Camera* camera )
|
||||
break;
|
||||
}
|
||||
|
||||
switch(camera->getDescriptionType()) {
|
||||
switch (camera->getDescriptionType()) {
|
||||
case COLLADAFW::Camera::ASPECTRATIO_AND_Y:
|
||||
{
|
||||
switch(cam->type) {
|
||||
switch (cam->type) {
|
||||
case CAM_ORTHO:
|
||||
{
|
||||
double ymag = camera->getYMag().getValue();
|
||||
@ -839,7 +838,7 @@ bool DocumentImporter::writeCamera( const COLLADAFW::Camera* camera )
|
||||
case COLLADAFW::Camera::SINGLE_X:
|
||||
case COLLADAFW::Camera::X_AND_Y:
|
||||
{
|
||||
switch(cam->type) {
|
||||
switch (cam->type) {
|
||||
case CAM_ORTHO:
|
||||
cam->ortho_scale = (float)camera->getXMag().getValue();
|
||||
break;
|
||||
@ -856,7 +855,7 @@ bool DocumentImporter::writeCamera( const COLLADAFW::Camera* camera )
|
||||
break;
|
||||
case COLLADAFW::Camera::SINGLE_Y:
|
||||
{
|
||||
switch(cam->type) {
|
||||
switch (cam->type) {
|
||||
case CAM_ORTHO:
|
||||
cam->ortho_scale = (float)camera->getYMag().getValue();
|
||||
break;
|
||||
@ -1030,7 +1029,7 @@ bool DocumentImporter::writeLight( const COLLADAFW::Light* light )
|
||||
lamp->dist = d;
|
||||
|
||||
COLLADAFW::Light::LightType type = light->getLightType();
|
||||
switch(type) {
|
||||
switch (type) {
|
||||
case COLLADAFW::Light::AMBIENT_LIGHT:
|
||||
{
|
||||
lamp->type = LA_HEMI;
|
||||
|
@ -60,11 +60,10 @@ bool EffectsExporter::hasEffects(Scene *sce)
|
||||
{
|
||||
Base *base = (Base *)sce->base.first;
|
||||
|
||||
while(base) {
|
||||
while (base) {
|
||||
Object *ob= base->object;
|
||||
int a;
|
||||
for (a = 0; a < ob->totcol; a++)
|
||||
{
|
||||
for (a = 0; a < ob->totcol; a++) {
|
||||
Material *ma = give_current_material(ob, a+1);
|
||||
|
||||
// no material, but check all of the slots
|
||||
|
@ -49,37 +49,31 @@ bool ErrorHandler::handleError( const COLLADASaxFWL::IError* error )
|
||||
{
|
||||
mError = true;
|
||||
|
||||
if ( error->getErrorClass() == COLLADASaxFWL::IError::ERROR_SAXPARSER )
|
||||
{
|
||||
if ( error->getErrorClass() == COLLADASaxFWL::IError::ERROR_SAXPARSER ) {
|
||||
COLLADASaxFWL::SaxParserError* saxParserError = (COLLADASaxFWL::SaxParserError*) error;
|
||||
const GeneratedSaxParser::ParserError& parserError = saxParserError->getError();
|
||||
|
||||
// Workaround to avoid wrong error
|
||||
if ( parserError.getErrorType() == GeneratedSaxParser::ParserError::ERROR_VALIDATION_MIN_OCCURS_UNMATCHED)
|
||||
{
|
||||
if ( strcmp(parserError.getElement(), "effect") == 0 )
|
||||
{
|
||||
if ( parserError.getErrorType() == GeneratedSaxParser::ParserError::ERROR_VALIDATION_MIN_OCCURS_UNMATCHED) {
|
||||
if ( strcmp(parserError.getElement(), "effect") == 0 ) {
|
||||
mError = false;
|
||||
}
|
||||
}
|
||||
if ( parserError.getErrorType() == GeneratedSaxParser::ParserError::ERROR_VALIDATION_SEQUENCE_PREVIOUS_SIBLING_NOT_PRESENT)
|
||||
{
|
||||
if ( !((strcmp(parserError.getElement(), "extra") == 0)
|
||||
&& (strcmp(parserError.getAdditionalText().c_str(), "sibling: fx_profile_abstract") == 0)))
|
||||
if ( parserError.getErrorType() == GeneratedSaxParser::ParserError::ERROR_VALIDATION_SEQUENCE_PREVIOUS_SIBLING_NOT_PRESENT) {
|
||||
if ( !((strcmp(parserError.getElement(), "extra") == 0) &&
|
||||
(strcmp(parserError.getAdditionalText().c_str(), "sibling: fx_profile_abstract") == 0)))
|
||||
{
|
||||
mError = false;
|
||||
}
|
||||
}
|
||||
|
||||
if ( parserError.getErrorType() == GeneratedSaxParser::ParserError::ERROR_COULD_NOT_OPEN_FILE)
|
||||
{
|
||||
if ( parserError.getErrorType() == GeneratedSaxParser::ParserError::ERROR_COULD_NOT_OPEN_FILE) {
|
||||
std::cout << "Couldn't open file" << std::endl;
|
||||
}
|
||||
|
||||
std::cout << "Schema validation error: " << parserError.getErrorMessage() << std::endl;
|
||||
}
|
||||
else if ( error->getErrorClass() == COLLADASaxFWL::IError::ERROR_SAXFWL )
|
||||
{
|
||||
else if ( error->getErrorClass() == COLLADASaxFWL::IError::ERROR_SAXFWL ) {
|
||||
COLLADASaxFWL::SaxFWLError* saxFWLError = (COLLADASaxFWL::SaxFWLError*) error;
|
||||
std::cout << "Sax FWL Error: " << saxFWLError->getErrorMessage() << std::endl;
|
||||
}
|
||||
|
@ -440,9 +440,9 @@ void GeometryExporter::create_normals(std::vector<Normal> &nor, std::vector<Face
|
||||
*nn = nshar[*vv];
|
||||
else {
|
||||
Normal n = {
|
||||
vert[*vv].no[0]/32767.0,
|
||||
vert[*vv].no[1]/32767.0,
|
||||
vert[*vv].no[2]/32767.0
|
||||
(float)vert[*vv].no[0] / 32767.0f,
|
||||
(float)vert[*vv].no[1] / 32767.0f,
|
||||
(float)vert[*vv].no[2] / 32767.0f
|
||||
};
|
||||
nor.push_back(n);
|
||||
*nn = (unsigned int)nor.size() - 1;
|
||||
|
@ -108,12 +108,13 @@ struct GeometryFunctor {
|
||||
{
|
||||
|
||||
Base *base= (Base*) sce->base.first;
|
||||
while(base) {
|
||||
while (base) {
|
||||
Object *ob = base->object;
|
||||
|
||||
if (ob->type == OB_MESH && ob->data
|
||||
&& !(export_selected && !(ob->flag && SELECT))
|
||||
&& ((sce->lay & ob->lay)!=0)) {
|
||||
if (ob->type == OB_MESH && ob->data &&
|
||||
!(export_selected && !(ob->flag && SELECT)) &&
|
||||
((sce->lay & ob->lay)!=0))
|
||||
{
|
||||
f(ob);
|
||||
}
|
||||
base= base->next;
|
||||
|
@ -48,11 +48,10 @@ bool ImagesExporter::hasImages(Scene *sce)
|
||||
{
|
||||
Base *base = (Base *)sce->base.first;
|
||||
|
||||
while(base) {
|
||||
while (base) {
|
||||
Object *ob= base->object;
|
||||
int a;
|
||||
for (a = 0; a < ob->totcol; a++)
|
||||
{
|
||||
for (a = 0; a < ob->totcol; a++) {
|
||||
Material *ma = give_current_material(ob, a+1);
|
||||
|
||||
// no material, but check all of the slots
|
||||
|
@ -39,11 +39,10 @@ template<class Functor>
|
||||
void forEachLampObjectInScene(Scene *sce, Functor &f, bool export_selected)
|
||||
{
|
||||
Base *base= (Base*) sce->base.first;
|
||||
while(base) {
|
||||
while (base) {
|
||||
Object *ob = base->object;
|
||||
|
||||
if (ob->type == OB_LAMP && ob->data
|
||||
&& !(export_selected && !(ob->flag & SELECT))) {
|
||||
|
||||
if (ob->type == OB_LAMP && ob->data && !(export_selected && !(ob->flag & SELECT))) {
|
||||
f(ob);
|
||||
}
|
||||
base= base->next;
|
||||
|
@ -50,11 +50,10 @@ bool MaterialsExporter::hasMaterials(Scene *sce)
|
||||
{
|
||||
Base *base = (Base *)sce->base.first;
|
||||
|
||||
while(base) {
|
||||
while (base) {
|
||||
Object *ob= base->object;
|
||||
int a;
|
||||
for (a = 0; a < ob->totcol; a++)
|
||||
{
|
||||
for (a = 0; a < ob->totcol; a++) {
|
||||
Material *ma = give_current_material(ob, a+1);
|
||||
|
||||
// no material, but check all of the slots
|
||||
|
@ -68,7 +68,7 @@ public:
|
||||
void operator ()(Object *ob)
|
||||
{
|
||||
int a;
|
||||
for(a = 0; a < ob->totcol; a++) {
|
||||
for (a = 0; a < ob->totcol; a++) {
|
||||
|
||||
Material *ma = give_current_material(ob, a+1);
|
||||
|
||||
|
@ -116,7 +116,7 @@ UVDataWrapper::UVDataWrapper(COLLADAFW::MeshVertexData& vdata) : mVData(&vdata)
|
||||
void WVDataWrapper::print()
|
||||
{
|
||||
fprintf(stderr, "UVs:\n");
|
||||
switch(mVData->getType()) {
|
||||
switch (mVData->getType()) {
|
||||
case COLLADAFW::MeshVertexData::DATA_TYPE_FLOAT:
|
||||
{
|
||||
COLLADAFW::ArrayPrimitiveType<float>* values = mVData->getFloatValues();
|
||||
@ -147,7 +147,7 @@ void UVDataWrapper::getUV(int uv_index, float *uv)
|
||||
int stride = mVData->getStride(0);
|
||||
if (stride==0) stride = 2;
|
||||
|
||||
switch(mVData->getType()) {
|
||||
switch (mVData->getType()) {
|
||||
case COLLADAFW::MeshVertexData::DATA_TYPE_FLOAT:
|
||||
{
|
||||
COLLADAFW::ArrayPrimitiveType<float>* values = mVData->getFloatValues();
|
||||
@ -676,7 +676,7 @@ void MeshImporter::get_vector(float v[3], COLLADAFW::MeshVertexData& arr, int i,
|
||||
{
|
||||
i *= stride;
|
||||
|
||||
switch(arr.getType()) {
|
||||
switch (arr.getType()) {
|
||||
case COLLADAFW::MeshVertexData::DATA_TYPE_FLOAT:
|
||||
{
|
||||
COLLADAFW::ArrayPrimitiveType<float>* values = arr.getFloatValues();
|
||||
@ -797,7 +797,7 @@ MTFace *MeshImporter::assign_material_to_geom(COLLADAFW::MaterialBinding cmateri
|
||||
// what we already have handled.
|
||||
std::multimap<COLLADAFW::UniqueId, COLLADAFW::UniqueId>::iterator it;
|
||||
it=materials_mapped_to_geom.find(*geom_uid);
|
||||
while(it!=materials_mapped_to_geom.end()) {
|
||||
while (it!=materials_mapped_to_geom.end()) {
|
||||
if (it->second == ma_uid && it->first == *geom_uid) return NULL; // do nothing if already found
|
||||
it++;
|
||||
}
|
||||
|
@ -43,12 +43,12 @@ void SceneExporter::exportScene(Scene *sce)
|
||||
void SceneExporter::exportHierarchy(Scene *sce)
|
||||
{
|
||||
Base *base= (Base*) sce->base.first;
|
||||
while(base) {
|
||||
while (base) {
|
||||
Object *ob = base->object;
|
||||
|
||||
if (!ob->parent) {
|
||||
if (sce->lay & ob->lay) {
|
||||
switch(ob->type) {
|
||||
switch (ob->type) {
|
||||
case OB_MESH:
|
||||
case OB_CAMERA:
|
||||
case OB_LAMP:
|
||||
@ -81,12 +81,12 @@ void SceneExporter::writeNodes(Object *ob, Scene *sce)
|
||||
|
||||
// list child objects
|
||||
Base *b = (Base*) sce->base.first;
|
||||
while(b) {
|
||||
while (b) {
|
||||
// cob - child object
|
||||
Object *cob = b->object;
|
||||
|
||||
if (cob->parent == ob) {
|
||||
switch(cob->type) {
|
||||
switch (cob->type) {
|
||||
case OB_MESH:
|
||||
case OB_CAMERA:
|
||||
case OB_LAMP:
|
||||
@ -154,8 +154,7 @@ void SceneExporter::writeNodes(Object *ob, Scene *sce)
|
||||
}
|
||||
}
|
||||
|
||||
for (std::list<Object*>::iterator i= child_objects.begin(); i != child_objects.end(); ++i)
|
||||
{
|
||||
for (std::list<Object*>::iterator i= child_objects.begin(); i != child_objects.end(); ++i) {
|
||||
writeNodes(*i, sce);
|
||||
}
|
||||
|
||||
|
@ -43,7 +43,7 @@ void TransformReader::get_node_mat(float mat[][4], COLLADAFW::Node *node, std::m
|
||||
COLLADAFW::Transformation *tm = node->getTransformations()[i];
|
||||
COLLADAFW::Transformation::TransformationType type = tm->getTransformationType();
|
||||
|
||||
switch(type) {
|
||||
switch (type) {
|
||||
case COLLADAFW::Transformation::TRANSLATE:
|
||||
dae_translate_to_mat4(tm, cur);
|
||||
break;
|
||||
|
@ -95,19 +95,16 @@ void TransformWriter::add_node_transform_ob(COLLADASW::Node& node, Object *ob)
|
||||
*/
|
||||
|
||||
/* Using parentinv should allow use of existing curves */
|
||||
if (ob->parent)
|
||||
{
|
||||
if (ob->parent) {
|
||||
// If parentinv is identity don't add it.
|
||||
bool add_parinv = false;
|
||||
|
||||
for (int i = 0; i < 16; ++i)
|
||||
{
|
||||
for (int i = 0; i < 16; ++i) {
|
||||
float f = (i % 4 == i / 4) ? 1.0f : 0.0f;
|
||||
add_parinv |= (ob->parentinv[i % 4][i / 4] != f);
|
||||
}
|
||||
|
||||
if (add_parinv)
|
||||
{
|
||||
if (add_parinv) {
|
||||
double dmat[4][4];
|
||||
UnitConverter converter;
|
||||
converter.mat4_to_dae_double(dmat, ob->parentinv);
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user