style cleanup: changes to brace placement / newlines - for/while/if/switch
authorCampbell Barton <ideasman42@gmail.com>
Sat, 28 Apr 2012 06:31:57 +0000 (06:31 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Sat, 28 Apr 2012 06:31:57 +0000 (06:31 +0000)
260 files changed:
intern/container/CTR_Map.h
intern/ghost/GHOST_Rect.h
intern/guardedalloc/intern/mallocn.c
intern/mikktspace/mikktspace.c
intern/utfconv/utf_winfunc.c
release/plugins/sequence/blur.c
release/plugins/texture/clouds2.c
release/plugins/texture/tiles.c
source/blender/avi/intern/avi.c
source/blender/avi/intern/codecs.c
source/blender/blenkernel/intern/CCGSubSurf.c
source/blender/blenkernel/intern/DerivedMesh.c
source/blender/blenkernel/intern/anim.c
source/blender/blenkernel/intern/anim_sys.c
source/blender/blenkernel/intern/armature.c
source/blender/blenkernel/intern/boids.c
source/blender/blenkernel/intern/brush.c
source/blender/blenkernel/intern/bvhutils.c
source/blender/blenkernel/intern/cloth.c
source/blender/blenkernel/intern/collision.c
source/blender/blenkernel/intern/colortools.c
source/blender/blenkernel/intern/constraint.c
source/blender/blenkernel/intern/context.c
source/blender/blenkernel/intern/curve.c
source/blender/blenkernel/intern/customdata.c
source/blender/blenkernel/intern/deform.c
source/blender/blenkernel/intern/depsgraph.c
source/blender/blenkernel/intern/displist.c
source/blender/blenkernel/intern/dynamicpaint.c
source/blender/blenkernel/intern/effect.c
source/blender/blenkernel/intern/fcurve.c
source/blender/blenkernel/intern/fmodifier.c
source/blender/blenkernel/intern/font.c
source/blender/blenkernel/intern/idprop.c
source/blender/blenkernel/intern/image.c
source/blender/blenkernel/intern/image_gen.c
source/blender/blenkernel/intern/implicit.c
source/blender/blenkernel/intern/library.c
source/blender/blenkernel/intern/material.c
source/blender/blenkernel/intern/mball.c
source/blender/blenkernel/intern/mesh.c
source/blender/blenkernel/intern/movieclip.c
source/blender/blenkernel/intern/multires.c
source/blender/blenkernel/intern/navmesh_conversion.c
source/blender/blenkernel/intern/nla.c
source/blender/blenkernel/intern/object.c
source/blender/blenkernel/intern/ocean.c
source/blender/blenkernel/intern/packedFile.c
source/blender/blenkernel/intern/paint.c
source/blender/blenkernel/intern/particle.c
source/blender/blenkernel/intern/particle_system.c
source/blender/blenkernel/intern/pointcache.c
source/blender/blenkernel/intern/property.c
source/blender/blenkernel/intern/report.c
source/blender/blenkernel/intern/sca.c
source/blender/blenkernel/intern/seqeffects.c
source/blender/blenkernel/intern/sequencer.c
source/blender/blenkernel/intern/shrinkwrap.c
source/blender/blenkernel/intern/sketch.c
source/blender/blenkernel/intern/softbody.c
source/blender/blenkernel/intern/sound.c
source/blender/blenkernel/intern/subsurf_ccg.c
source/blender/blenkernel/intern/text.c
source/blender/blenkernel/intern/texture.c
source/blender/blenkernel/intern/writeffmpeg.c
source/blender/blenlib/intern/BLI_kdopbvh.c
source/blender/blenlib/intern/DLRB_tree.c
source/blender/blenlib/intern/bpath.c
source/blender/blenlib/intern/dynlib.c
source/blender/blenlib/intern/freetypefont.c
source/blender/blenlib/intern/graph.c
source/blender/blenlib/intern/listbase.c
source/blender/blenlib/intern/path_util.c
source/blender/blenlib/intern/pbvh.c
source/blender/blenlib/intern/string.c
source/blender/blenlib/intern/string_utf8.c
source/blender/blenloader/intern/readblenentry.c
source/blender/blenloader/intern/readfile.c
source/blender/blenloader/intern/writefile.c
source/blender/bmesh/intern/bmesh_walkers.c
source/blender/bmesh/intern/bmesh_walkers_impl.c
source/blender/collada/AnimationExporter.cpp
source/blender/collada/AnimationImporter.cpp
source/blender/collada/ArmatureExporter.cpp
source/blender/collada/ArmatureImporter.cpp
source/blender/collada/CameraExporter.cpp
source/blender/collada/DocumentExporter.cpp
source/blender/collada/DocumentImporter.cpp
source/blender/collada/EffectExporter.cpp
source/blender/collada/ErrorHandler.cpp
source/blender/collada/GeometryExporter.cpp
source/blender/collada/GeometryExporter.h
source/blender/collada/ImageExporter.cpp
source/blender/collada/LightExporter.cpp
source/blender/collada/MaterialExporter.cpp
source/blender/collada/MaterialExporter.h
source/blender/collada/MeshImporter.cpp
source/blender/collada/SceneExporter.cpp
source/blender/collada/TransformReader.cpp
source/blender/collada/TransformWriter.cpp
source/blender/collada/collada_internal.cpp
source/blender/editors/animation/anim_filter.c
source/blender/editors/animation/anim_markers.c
source/blender/editors/armature/editarmature.c
source/blender/editors/armature/editarmature_generate.c
source/blender/editors/armature/editarmature_retarget.c
source/blender/editors/armature/editarmature_sketch.c
source/blender/editors/armature/poselib.c
source/blender/editors/armature/reeb.c
source/blender/editors/curve/editcurve.c
source/blender/editors/curve/editfont.c
source/blender/editors/interface/interface_handlers.c
source/blender/editors/interface/interface_widgets.c
source/blender/editors/interface/resources.c
source/blender/editors/mesh/editmesh_tools.c
source/blender/editors/mesh/meshtools.c
source/blender/editors/object/object_add.c
source/blender/editors/object/object_bake.c
source/blender/editors/object/object_edit.c
source/blender/editors/object/object_hook.c
source/blender/editors/object/object_relations.c
source/blender/editors/object/object_shapekey.c
source/blender/editors/object/object_vgroup.c
source/blender/editors/physics/dynamicpaint_ops.c
source/blender/editors/physics/particle_edit.c
source/blender/editors/physics/physics_fluid.c
source/blender/editors/screen/area.c
source/blender/editors/screen/glutil.c
source/blender/editors/screen/screen_edit.c
source/blender/editors/screen/screen_ops.c
source/blender/editors/sculpt_paint/paint_cursor.c
source/blender/editors/sculpt_paint/sculpt.c
source/blender/editors/sculpt_paint/sculpt_undo.c
source/blender/editors/sound/sound_ops.c
source/blender/editors/space_action/space_action.c
source/blender/editors/space_buttons/buttons_context.c
source/blender/editors/space_buttons/buttons_header.c
source/blender/editors/space_buttons/space_buttons.c
source/blender/editors/space_clip/clip_graph_ops.c
source/blender/editors/space_clip/clip_ops.c
source/blender/editors/space_clip/space_clip.c
source/blender/editors/space_clip/tracking_ops.c
source/blender/editors/space_file/file_draw.c
source/blender/editors/space_file/file_ops.c
source/blender/editors/space_file/filelist.c
source/blender/editors/space_file/filesel.c
source/blender/editors/space_file/fsmenu.c
source/blender/editors/space_file/space_file.c
source/blender/editors/space_graph/graph_buttons.c
source/blender/editors/space_graph/space_graph.c
source/blender/editors/space_image/space_image.c
source/blender/editors/space_logic/logic_buttons.c
source/blender/editors/space_logic/logic_window.c
source/blender/editors/space_logic/space_logic.c
source/blender/editors/space_nla/nla_buttons.c
source/blender/editors/space_nla/space_nla.c
source/blender/editors/space_node/drawnode.c
source/blender/editors/space_node/node_edit.c
source/blender/editors/space_node/node_templates.c
source/blender/editors/space_node/space_node.c
source/blender/editors/space_outliner/outliner_draw.c
source/blender/editors/space_outliner/outliner_select.c
source/blender/editors/space_outliner/outliner_tools.c
source/blender/editors/space_outliner/space_outliner.c
source/blender/editors/space_sequencer/sequencer_draw.c
source/blender/editors/space_text/text_draw.c
source/blender/editors/space_time/space_time.c
source/blender/editors/space_userpref/space_userpref.c
source/blender/editors/space_view3d/view3d_edit.c
source/blender/editors/transform/transform.c
source/blender/editors/transform/transform_constraints.c
source/blender/editors/transform/transform_conversions.c
source/blender/editors/transform/transform_generics.c
source/blender/editors/transform/transform_input.c
source/blender/editors/transform/transform_manipulator.c
source/blender/editors/transform/transform_ops.c
source/blender/editors/transform/transform_orientations.c
source/blender/editors/transform/transform_snap.c
source/blender/editors/util/numinput.c
source/blender/gpu/intern/gpu_buffers.c
source/blender/gpu/intern/gpu_codegen.c
source/blender/gpu/intern/gpu_draw.c
source/blender/gpu/intern/gpu_extensions.c
source/blender/gpu/intern/gpu_material.c
source/blender/ikplugin/intern/itasc_plugin.cpp
source/blender/imbuf/intern/anim_movie.c
source/blender/imbuf/intern/dds/ColorBlock.cpp
source/blender/imbuf/intern/dds/DirectDrawSurface.cpp
source/blender/imbuf/intern/dds/PixelFormat.h
source/blender/imbuf/intern/jpeg.c
source/blender/imbuf/intern/openexr/openexr_api.cpp
source/blender/imbuf/intern/png.c
source/blender/imbuf/intern/radiance_hdr.c
source/blender/imbuf/intern/targa.c
source/blender/imbuf/intern/thumbs.c
source/blender/imbuf/intern/util.c
source/blender/makesdna/intern/dna_genfile.c
source/blender/makesdna/intern/makesdna.c
source/blender/makesrna/intern/makesrna.c
source/blender/makesrna/intern/rna_access.c
source/blender/makesrna/intern/rna_fcurve.c
source/blender/makesrna/intern/rna_main.c
source/blender/makesrna/intern/rna_wm.c
source/blender/modifiers/intern/MOD_boolean.c
source/blender/modifiers/intern/MOD_cast.c
source/blender/modifiers/intern/MOD_collision.c
source/blender/modifiers/intern/MOD_displace.c
source/blender/modifiers/intern/MOD_explode.c
source/blender/modifiers/intern/MOD_fluidsim_util.c
source/blender/modifiers/intern/MOD_mask.c
source/blender/modifiers/intern/MOD_remesh.c
source/blender/modifiers/intern/MOD_screw.c
source/blender/modifiers/intern/MOD_simpledeform.c
source/blender/modifiers/intern/MOD_util.c
source/blender/modifiers/intern/MOD_warp.c
source/blender/modifiers/intern/MOD_wave.c
source/blender/modifiers/intern/MOD_weightvg_util.c
source/blender/nodes/composite/node_composite_util.c
source/blender/nodes/composite/nodes/node_composite_channelMatte.c
source/blender/nodes/composite/nodes/node_composite_colorSpill.c
source/blender/nodes/composite/nodes/node_composite_filter.c
source/blender/nodes/composite/nodes/node_composite_image.c
source/blender/nodes/composite/nodes/node_composite_levels.c
source/blender/nodes/composite/nodes/node_composite_math.c
source/blender/nodes/composite/nodes/node_composite_rotate.c
source/blender/nodes/composite/nodes/node_composite_sepcombYCCA.c
source/blender/nodes/composite/nodes/node_composite_transform.c
source/blender/nodes/shader/node_shader_util.c
source/blender/nodes/shader/nodes/node_shader_math.c
source/blender/nodes/texture/nodes/node_texture_math.c
source/blender/nodes/texture/nodes/node_texture_output.c
source/blender/quicktime/apple/quicktime_import.c
source/blender/render/intern/raytrace/bvh.h
source/blender/render/intern/raytrace/rayobject.cpp
source/blender/render/intern/raytrace/rayobject_blibvh.cpp
source/blender/render/intern/raytrace/rayobject_hint.h
source/blender/render/intern/raytrace/rayobject_instance.cpp
source/blender/render/intern/raytrace/rayobject_octree.cpp
source/blender/render/intern/raytrace/rayobject_qbvh.cpp
source/blender/render/intern/raytrace/rayobject_rtbuild.cpp
source/blender/render/intern/raytrace/rayobject_svbvh.cpp
source/blender/render/intern/raytrace/rayobject_vbvh.cpp
source/blender/render/intern/raytrace/reorganize.h
source/blender/render/intern/raytrace/svbvh.h
source/blender/render/intern/raytrace/vbvh.h
source/blender/render/intern/source/convertblender.c
source/blender/render/intern/source/initrender.c
source/blender/render/intern/source/pointdensity.c
source/blender/render/intern/source/rayshade.c
source/blender/render/intern/source/render_texture.c
source/blender/render/intern/source/rendercore.c
source/blender/render/intern/source/renderdatabase.c
source/blender/render/intern/source/shadeoutput.c
source/blender/render/intern/source/sunsky.c
source/blender/render/intern/source/volume_precache.c
source/blender/render/intern/source/volumetric.c
source/blender/render/intern/source/voxeldata.c
source/blender/render/intern/source/zbuf.c
source/blender/windowmanager/intern/wm_keymap.c
source/blender/windowmanager/intern/wm_operators.c

index 8b6d843..9557821 100644 (file)
@@ -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);
                }
        }
index bcbcade..30d9d16 100644 (file)
@@ -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);
index 2a6a0df..bb3a1c6 100644 (file)
@@ -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{
index 2036e60..24c77c4 100644 (file)
@@ -193,7 +193,7 @@ static STSpace AvgTSpace(const STSpace * pTS0, const STSpace * pTS1)
        // this if is important. Due to floating point precision
        // averaging when ts0==ts1 will cause a slight difference
        // which results in tangent space splits later on
-       if(pTS0->fMagS==pTS1->fMagS && pTS0->fMagT==pTS1->fMagT &&
+       if (pTS0->fMagS==pTS1->fMagS && pTS0->fMagT==pTS1->fMagT &&
           veq(pTS0->vOs,pTS1->vOs)     && veq(pTS0->vOt, pTS1->vOt))
        {
                ts_res.fMagS = pTS0->fMagS;
@@ -207,8 +207,8 @@ static STSpace AvgTSpace(const STSpace * pTS0, const STSpace * pTS1)
                ts_res.fMagT = 0.5f*(pTS0->fMagT+pTS1->fMagT);
                ts_res.vOs = vadd(pTS0->vOs,pTS1->vOs);
                ts_res.vOt = vadd(pTS0->vOt,pTS1->vOt);
-               if( VNotZero(ts_res.vOs) ) ts_res.vOs = Normalize(ts_res.vOs);
-               if( VNotZero(ts_res.vOt) ) ts_res.vOt = Normalize(ts_res.vOt);
+               if ( VNotZero(ts_res.vOs) ) ts_res.vOs = Normalize(ts_res.vOs);
+               if ( VNotZero(ts_res.vOt) ) ts_res.vOt = Normalize(ts_res.vOt);
        }
 
        return ts_res;
@@ -246,7 +246,7 @@ tbool genTangSpace(const SMikkTSpaceContext * pContext, const float fAngularThre
        const float fThresCos = (float) cos((fAngularThreshold*(float)M_PI)/180.0f);
 
        // verify all call-backs have been set
-       if( pContext->m_pInterface->m_getNumFaces==NULL ||
+       if ( pContext->m_pInterface->m_getNumFaces==NULL ||
                pContext->m_pInterface->m_getNumVerticesOfFace==NULL ||
                pContext->m_pInterface->m_getPosition==NULL ||
                pContext->m_pInterface->m_getNormal==NULL ||
@@ -254,21 +254,21 @@ tbool genTangSpace(const SMikkTSpaceContext * pContext, const float fAngularThre
                return TFALSE;
 
        // count triangles on supported faces
-       for(f=0; f<iNrFaces; f++)
+       for (f=0; f<iNrFaces; f++)
        {
                const int verts = pContext->m_pInterface->m_getNumVerticesOfFace(pContext, f);
-               if(verts==3) ++iNrTrianglesIn;
+               if (verts==3) ++iNrTrianglesIn;
                else if(verts==4) iNrTrianglesIn += 2;
        }
-       if(iNrTrianglesIn<=0) return TFALSE;
+       if (iNrTrianglesIn<=0) return TFALSE;
 
        // allocate memory for an index list
        piTriListIn = (int *) malloc(sizeof(int)*3*iNrTrianglesIn);
        pTriInfos = (STriInfo *) malloc(sizeof(STriInfo)*iNrTrianglesIn);
-       if(piTriListIn==NULL || pTriInfos==NULL)
+       if (piTriListIn==NULL || pTriInfos==NULL)
        {
-               if(piTriListIn!=NULL) free(piTriListIn);
-               if(pTriInfos!=NULL) free(pTriInfos);
+               if (piTriListIn!=NULL) free(piTriListIn);
+               if (pTriInfos!=NULL) free(pTriInfos);
                return TFALSE;
        }
 
@@ -283,7 +283,7 @@ tbool genTangSpace(const SMikkTSpaceContext * pContext, const float fAngularThre
        // Mark all degenerate triangles
        iTotTris = iNrTrianglesIn;
        iDegenTriangles = 0;
-       for(t=0; t<iTotTris; t++)
+       for (t=0; t<iTotTris; t++)
        {
                const int i0 = piTriListIn[t*3+0];
                const int i1 = piTriListIn[t*3+1];
@@ -291,7 +291,7 @@ tbool genTangSpace(const SMikkTSpaceContext * pContext, const float fAngularThre
                const SVec3 p0 = GetPosition(pContext, i0);
                const SVec3 p1 = GetPosition(pContext, i1);
                const SVec3 p2 = GetPosition(pContext, i2);
-               if(veq(p0,p1) || veq(p0,p2) || veq(p1,p2))      // degenerate
+               if (veq(p0,p1) || veq(p0,p2) || veq(p1,p2))     // degenerate
                {
                        pTriInfos[t].iFlag |= MARK_DEGENERATE;
                        ++iDegenTriangles;
@@ -317,10 +317,10 @@ tbool genTangSpace(const SMikkTSpaceContext * pContext, const float fAngularThre
        iNrMaxGroups = iNrTrianglesIn*3;
        pGroups = (SGroup *) malloc(sizeof(SGroup)*iNrMaxGroups);
        piGroupTrianglesBuffer = (int *) malloc(sizeof(int)*iNrTrianglesIn*3);
-       if(pGroups==NULL || piGroupTrianglesBuffer==NULL)
+       if (pGroups==NULL || piGroupTrianglesBuffer==NULL)
        {
-               if(pGroups!=NULL) free(pGroups);
-               if(piGroupTrianglesBuffer!=NULL) free(piGroupTrianglesBuffer);
+               if (pGroups!=NULL) free(pGroups);
+               if (piGroupTrianglesBuffer!=NULL) free(piGroupTrianglesBuffer);
                free(piTriListIn);
                free(pTriInfos);
                return TFALSE;
@@ -333,7 +333,7 @@ tbool genTangSpace(const SMikkTSpaceContext * pContext, const float fAngularThre
        //
 
        psTspace = (STSpace *) malloc(sizeof(STSpace)*iNrTSPaces);
-       if(psTspace==NULL)
+       if (psTspace==NULL)
        {
                free(piTriListIn);
                free(pTriInfos);
@@ -342,7 +342,7 @@ tbool genTangSpace(const SMikkTSpaceContext * pContext, const float fAngularThre
                return TFALSE;
        }
        memset(psTspace, 0, sizeof(STSpace)*iNrTSPaces);
-       for(t=0; t<iNrTSPaces; t++)
+       for (t=0; t<iNrTSPaces; t++)
        {
                psTspace[t].vOs.x=1.0f; psTspace[t].vOs.y=0.0f; psTspace[t].vOs.z=0.0f; psTspace[t].fMagS = 1.0f;
                psTspace[t].vOt.x=0.0f; psTspace[t].vOt.y=1.0f; psTspace[t].vOt.z=0.0f; psTspace[t].fMagT = 1.0f;
@@ -359,7 +359,7 @@ tbool genTangSpace(const SMikkTSpaceContext * pContext, const float fAngularThre
        free(pGroups);
        free(piGroupTrianglesBuffer);
 
-       if(!bRes)       // if an allocation in GenerateTSpaces() failed
+       if (!bRes)      // if an allocation in GenerateTSpaces() failed
        {
                // clean up and return false
                free(pTriInfos); free(piTriListIn); free(psTspace);
@@ -376,10 +376,10 @@ tbool genTangSpace(const SMikkTSpaceContext * pContext, const float fAngularThre
        free(pTriInfos); free(piTriListIn);
 
        index = 0;
-       for(f=0; f<iNrFaces; f++)
+       for (f=0; f<iNrFaces; f++)
        {
                const int verts = pContext->m_pInterface->m_getNumVerticesOfFace(pContext, f);
-               if(verts!=3 && verts!=4) continue;
+               if (verts!=3 && verts!=4) continue;
                
 
                // I've decided to let degenerate triangles and group-with-anythings
@@ -390,28 +390,28 @@ tbool genTangSpace(const SMikkTSpaceContext * pContext, const float fAngularThre
                // (this is already the case for good triangles but not for
                // degenerate ones and those with bGroupWithAnything==true)
                bool bOrient = psTspace[index].bOrient;
-               if(psTspace[index].iCounter == 0)       // tspace was not derived from a group
+               if (psTspace[index].iCounter == 0)      // tspace was not derived from a group
                {
                        // look for a space created in GenerateTSpaces() by iCounter>0
                        bool bNotFound = true;
                        int i=1;
-                       while(i<verts && bNotFound)
+                       while (i<verts && bNotFound)
                        {
-                               if(psTspace[index+i].iCounter > 0) bNotFound=false;
+                               if (psTspace[index+i].iCounter > 0) bNotFound=false;
                                else ++i;
                        }
-                       if(!bNotFound) bOrient = psTspace[index+i].bOrient;
+                       if (!bNotFound) bOrient = psTspace[index+i].bOrient;
                }*/
 
                // set data
-               for(i=0; i<verts; i++)
+               for (i=0; i<verts; i++)
                {
                        const STSpace * pTSpace = &psTspace[index];
                        float tang[] = {pTSpace->vOs.x, pTSpace->vOs.y, pTSpace->vOs.z};
                        float bitang[] = {pTSpace->vOt.x, pTSpace->vOt.y, pTSpace->vOt.z};
-                       if(pContext->m_pInterface->m_setTSpace!=NULL)
+                       if (pContext->m_pInterface->m_setTSpace!=NULL)
                                pContext->m_pInterface->m_setTSpace(pContext, tang, bitang, pTSpace->fMagS, pTSpace->fMagT, pTSpace->bOrient, f, i);
-                       if(pContext->m_pInterface->m_setTSpaceBasic!=NULL)
+                       if (pContext->m_pInterface->m_setTSpaceBasic!=NULL)
                                pContext->m_pInterface->m_setTSpaceBasic(pContext, tang, pTSpace->bOrient==TTRUE ? 1.0f : (-1.0f), f, i);
 
                        ++index;
@@ -464,23 +464,23 @@ static void GenerateSharedVerticesIndexList(int piTriList_in_and_out[], const SM
        int iMaxCount=0;
        SVec3 vMin = GetPosition(pContext, 0), vMax = vMin, vDim;
        float fMin, fMax;
-       for(i=1; i<(iNrTrianglesIn*3); i++)
+       for (i=1; i<(iNrTrianglesIn*3); i++)
        {
                const int index = piTriList_in_and_out[i];
 
                const SVec3 vP = GetPosition(pContext, index);
-               if(vMin.x > vP.x) vMin.x = vP.x;
+               if (vMin.x > vP.x) vMin.x = vP.x;
                else if(vMax.x < vP.x) vMax.x = vP.x;
-               if(vMin.y > vP.y) vMin.y = vP.y;
+               if (vMin.y > vP.y) vMin.y = vP.y;
                else if(vMax.y < vP.y) vMax.y = vP.y;
-               if(vMin.z > vP.z) vMin.z = vP.z;
+               if (vMin.z > vP.z) vMin.z = vP.z;
                else if(vMax.z < vP.z) vMax.z = vP.z;
        }
 
        vDim = vsub(vMax,vMin);
        iChannel = 0;
        fMin = vMin.x; fMax=vMax.x;
-       if(vDim.y>vDim.x && vDim.y>vDim.z)
+       if (vDim.y>vDim.x && vDim.y>vDim.z)
        {
                iChannel=1;
                fMin = vMin.y, fMax=vMax.y;
@@ -497,12 +497,12 @@ static void GenerateSharedVerticesIndexList(int piTriList_in_and_out[], const SM
        piHashOffsets = (int *) malloc(sizeof(int)*g_iCells);
        piHashCount2 = (int *) malloc(sizeof(int)*g_iCells);
 
-       if(piHashTable==NULL || piHashCount==NULL || piHashOffsets==NULL || piHashCount2==NULL)
+       if (piHashTable==NULL || piHashCount==NULL || piHashOffsets==NULL || piHashCount2==NULL)
        {
-               if(piHashTable!=NULL) free(piHashTable);
-               if(piHashCount!=NULL) free(piHashCount);
-               if(piHashOffsets!=NULL) free(piHashOffsets);
-               if(piHashCount2!=NULL) free(piHashCount2);
+               if (piHashTable!=NULL) free(piHashTable);
+               if (piHashCount!=NULL) free(piHashCount);
+               if (piHashOffsets!=NULL) free(piHashOffsets);
+               if (piHashCount2!=NULL) free(piHashCount2);
                GenerateSharedVerticesIndexListSlow(piTriList_in_and_out, pContext, iNrTrianglesIn);
                return;
        }
@@ -510,7 +510,7 @@ static void GenerateSharedVerticesIndexList(int piTriList_in_and_out[], const SM
        memset(piHashCount2, 0, sizeof(int)*g_iCells);
 
        // count amount of elements in each cell unit
-       for(i=0; i<(iNrTrianglesIn*3); i++)
+       for (i=0; i<(iNrTrianglesIn*3); i++)
        {
                const int index = piTriList_in_and_out[i];
                const SVec3 vP = GetPosition(pContext, index);
@@ -521,11 +521,11 @@ static void GenerateSharedVerticesIndexList(int piTriList_in_and_out[], const SM
 
        // evaluate start index of each cell.
        piHashOffsets[0]=0;
-       for(k=1; k<g_iCells; k++)
+       for (k=1; k<g_iCells; k++)
                piHashOffsets[k]=piHashOffsets[k-1]+piHashCount[k-1];
 
        // insert vertices
-       for(i=0; i<(iNrTrianglesIn*3); i++)
+       for (i=0; i<(iNrTrianglesIn*3); i++)
        {
                const int index = piTriList_in_and_out[i];
                const SVec3 vP = GetPosition(pContext, index);
@@ -538,29 +538,29 @@ static void GenerateSharedVerticesIndexList(int piTriList_in_and_out[], const SM
                pTable[piHashCount2[iCell]] = i;        // vertex i has been inserted.
                ++piHashCount2[iCell];
        }
-       for(k=0; k<g_iCells; k++)
+       for (k=0; k<g_iCells; k++)
                assert(piHashCount2[k] == piHashCount[k]);      // verify the count
        free(piHashCount2);
 
        // find maximum amount of entries in any hash entry
        iMaxCount = piHashCount[0];
-       for(k=1; k<g_iCells; k++)
-               if(iMaxCount<piHashCount[k])
+       for (k=1; k<g_iCells; k++)
+               if (iMaxCount<piHashCount[k])
                        iMaxCount=piHashCount[k];
        pTmpVert = (STmpVert *) malloc(sizeof(STmpVert)*iMaxCount);
        
 
        // complete the merge
-       for(k=0; k<g_iCells; k++)
+       for (k=0; k<g_iCells; k++)
        {
                // extract table of cell k and amount of entries in it
                int * pTable = &piHashTable[piHashOffsets[k]];
                const int iEntries = piHashCount[k];
-               if(iEntries < 2) continue;
+               if (iEntries < 2) continue;
 
-               if(pTmpVert!=NULL)
+               if (pTmpVert!=NULL)
                {
-                       for(e=0; e<iEntries; e++)
+                       for (e=0; e<iEntries; e++)
                        {
                                int i = pTable[e];
                                const SVec3 vP = GetPosition(pContext, piTriList_in_and_out[i]);
@@ -573,7 +573,7 @@ static void GenerateSharedVerticesIndexList(int piTriList_in_and_out[], const SM
                        MergeVertsSlow(piTriList_in_and_out, pContext, pTable, iEntries);
        }
 
-       if(pTmpVert!=NULL) { free(pTmpVert); }
+       if (pTmpVert!=NULL) { free(pTmpVert); }
        free(piHashTable);
        free(piHashCount);
        free(piHashOffsets);
@@ -585,11 +585,11 @@ static void MergeVertsFast(int piTriList_in_and_out[], STmpVert pTmpVert[], cons
        int c=0, l=0, channel=0;
        float fvMin[3], fvMax[3];
        float dx=0, dy=0, dz=0, fSep=0;
-       for(c=0; c<3; c++)
+       for (c=0; c<3; c++)
        {       fvMin[c]=pTmpVert[iL_in].vert[c]; fvMax[c]=fvMin[c];    }
-       for(l=(iL_in+1); l<=iR_in; l++)
-               for(c=0; c<3; c++)
-                       if(fvMin[c]>pTmpVert[l].vert[c]) fvMin[c]=pTmpVert[l].vert[c];
+       for (l=(iL_in+1); l<=iR_in; l++)
+               for (c=0; c<3; c++)
+                       if (fvMin[c]>pTmpVert[l].vert[c]) fvMin[c]=pTmpVert[l].vert[c];
                        else if(fvMax[c]<pTmpVert[l].vert[c]) fvMax[c]=pTmpVert[l].vert[c];
 
        dx = fvMax[0]-fvMin[0];
@@ -597,17 +597,17 @@ static void MergeVertsFast(int piTriList_in_and_out[], STmpVert pTmpVert[], cons
        dz = fvMax[2]-fvMin[2];
 
        channel = 0;
-       if(dy>dx && dy>dz) channel=1;
+       if (dy>dx && dy>dz) channel=1;
        else if(dz>dx) channel=2;
 
        fSep = 0.5f*(fvMax[channel]+fvMin[channel]);
 
        // terminate recursion when the separation/average value
        // is no longer strictly between fMin and fMax values.
-       if(fSep>=fvMax[channel] || fSep<=fvMin[channel])
+       if (fSep>=fvMax[channel] || fSep<=fvMin[channel])
        {
                // complete the weld
-               for(l=iL_in; l<=iR_in; l++)
+               for (l=iL_in; l<=iR_in; l++)
                {
                        int i = pTmpVert[l].index;
                        const int index = piTriList_in_and_out[i];
@@ -617,7 +617,7 @@ static void MergeVertsFast(int piTriList_in_and_out[], STmpVert pTmpVert[], cons
 
                        tbool bNotFound = TTRUE;
                        int l2=iL_in, i2rec=-1;
-                       while(l2<l && bNotFound)
+                       while (l2<l && bNotFound)
                        {
                                const int i2 = pTmpVert[l2].index;
                                const int index2 = piTriList_in_and_out[i2];
@@ -627,7 +627,7 @@ static void MergeVertsFast(int piTriList_in_and_out[], STmpVert pTmpVert[], cons
                                i2rec=i2;
 
                                //if(vP==vP2 && vN==vN2 && vT==vT2)
-                               if(vP.x==vP2.x && vP.y==vP2.y && vP.z==vP2.z &&
+                               if (vP.x==vP2.x && vP.y==vP2.y && vP.z==vP2.z &&
                                        vN.x==vN2.x && vN.y==vN2.y && vN.z==vN2.z &&
                                        vT.x==vT2.x && vT.y==vT2.y && vT.z==vT2.z)
                                        bNotFound = TFALSE;
@@ -636,7 +636,7 @@ static void MergeVertsFast(int piTriList_in_and_out[], STmpVert pTmpVert[], cons
                        }
                        
                        // merge if previously found
-                       if(!bNotFound)
+                       if (!bNotFound)
                                piTriList_in_and_out[i] = piTriList_in_and_out[i2rec];
                }
        }
@@ -646,24 +646,24 @@ static void MergeVertsFast(int piTriList_in_and_out[], STmpVert pTmpVert[], cons
                assert((iR_in-iL_in)>0);        // at least 2 entries
 
                // separate (by fSep) all points between iL_in and iR_in in pTmpVert[]
-               while(iL < iR)
+               while (iL < iR)
                {
                        tbool bReadyLeftSwap = TFALSE, bReadyRightSwap = TFALSE;
-                       while((!bReadyLeftSwap) && iL<iR)
+                       while ((!bReadyLeftSwap) && iL<iR)
                        {
                                assert(iL>=iL_in && iL<=iR_in);
                                bReadyLeftSwap = !(pTmpVert[iL].vert[channel]<fSep);
-                               if(!bReadyLeftSwap) ++iL;
+                               if (!bReadyLeftSwap) ++iL;
                        }
-                       while((!bReadyRightSwap) && iL<iR)
+                       while ((!bReadyRightSwap) && iL<iR)
                        {
                                assert(iR>=iL_in && iR<=iR_in);
                                bReadyRightSwap = pTmpVert[iR].vert[channel]<fSep;
-                               if(!bReadyRightSwap) --iR;
+                               if (!bReadyRightSwap) --iR;
                        }
                        assert( (iL<iR) || !(bReadyLeftSwap && bReadyRightSwap) );
 
-                       if(bReadyLeftSwap && bReadyRightSwap)
+                       if (bReadyLeftSwap && bReadyRightSwap)
                        {
                                const STmpVert sTmp = pTmpVert[iL];
                                assert(iL<iR);
@@ -674,17 +674,17 @@ static void MergeVertsFast(int piTriList_in_and_out[], STmpVert pTmpVert[], cons
                }
 
                assert(iL==(iR+1) || (iL==iR));
-               if(iL==iR)
+               if (iL==iR)
                {
                        const tbool bReadyRightSwap = pTmpVert[iR].vert[channel]<fSep;
-                       if(bReadyRightSwap) ++iL;
+                       if (bReadyRightSwap) ++iL;
                        else --iR;
                }
 
                // only need to weld when there is more than 1 instance of the (x,y,z)
-               if(iL_in < iR)
+               if (iL_in < iR)
                        MergeVertsFast(piTriList_in_and_out, pTmpVert, pContext, iL_in, iR);    // weld all left of fSep
-               if(iL < iR_in)
+               if (iL < iR_in)
                        MergeVertsFast(piTriList_in_and_out, pTmpVert, pContext, iL, iR_in);    // weld all right of (or equal to) fSep
        }
 }
@@ -693,7 +693,7 @@ static void MergeVertsSlow(int piTriList_in_and_out[], const SMikkTSpaceContext
 {
        // this can be optimized further using a tree structure or more hashing.
        int e=0;
-       for(e=0; e<iEntries; e++)
+       for (e=0; e<iEntries; e++)
        {
                int i = pTable[e];
                const int index = piTriList_in_and_out[i];
@@ -703,7 +703,7 @@ static void MergeVertsSlow(int piTriList_in_and_out[], const SMikkTSpaceContext
 
                tbool bNotFound = TTRUE;
                int e2=0, i2rec=-1;
-               while(e2<e && bNotFound)
+               while (e2<e && bNotFound)
                {
                        const int i2 = pTable[e2];
                        const int index2 = piTriList_in_and_out[i2];
@@ -712,14 +712,14 @@ static void MergeVertsSlow(int piTriList_in_and_out[], const SMikkTSpaceContext
                        const SVec3 vT2 = GetTexCoord(pContext, index2);
                        i2rec = i2;
 
-                       if(veq(vP,vP2) && veq(vN,vN2) && veq(vT,vT2))
+                       if (veq(vP,vP2) && veq(vN,vN2) && veq(vT,vT2))
                                bNotFound = TFALSE;
                        else
                                ++e2;
                }
                
                // merge if previously found
-               if(!bNotFound)
+               if (!bNotFound)
                        piTriList_in_and_out[i] = piTriList_in_and_out[i2rec];
        }
 }
@@ -727,9 +727,9 @@ static void MergeVertsSlow(int piTriList_in_and_out[], const SMikkTSpaceContext
 static void GenerateSharedVerticesIndexListSlow(int piTriList_in_and_out[], const SMikkTSpaceContext * pContext, const int iNrTrianglesIn)
 {
        int iNumUniqueVerts = 0, t=0, i=0;
-       for(t=0; t<iNrTrianglesIn; t++)
+       for (t=0; t<iNrTrianglesIn; t++)
        {
-               for(i=0; i<3; i++)
+               for (i=0; i<3; i++)
                {
                        const int offs = t*3 + i;
                        const int index = piTriList_in_and_out[offs];
@@ -740,27 +740,27 @@ static void GenerateSharedVerticesIndexListSlow(int piTriList_in_and_out[], cons
 
                        tbool bFound = TFALSE;
                        int t2=0, index2rec=-1;
-                       while(!bFound && t2<=t)
+                       while (!bFound && t2<=t)
                        {
                                int j=0;
-                               while(!bFound && j<3)
+                               while (!bFound && j<3)
                                {
                                        const int index2 = piTriList_in_and_out[t2*3 + j];
                                        const SVec3 vP2 = GetPosition(pContext, index2);
                                        const SVec3 vN2 = GetNormal(pContext, index2);
                                        const SVec3 vT2 = GetTexCoord(pContext, index2);
                                        
-                                       if(veq(vP,vP2) && veq(vN,vN2) && veq(vT,vT2))
+                                       if (veq(vP,vP2) && veq(vN,vN2) && veq(vT,vT2))
                                                bFound = TTRUE;
                                        else
                                                ++j;
                                }
-                               if(!bFound) ++t2;
+                               if (!bFound) ++t2;
                        }
 
                        assert(bFound);
                        // if we found our own
-                       if(index2rec == index) { ++iNumUniqueVerts; }
+                       if (index2rec == index) { ++iNumUniqueVerts; }
 
                        piTriList_in_and_out[offs] = index2rec;
                }
@@ -771,15 +771,15 @@ static int GenerateInitialVerticesIndexList(STriInfo pTriInfos[], int piTriList_
 {
        int iTSpacesOffs = 0, f=0, t=0;
        int iDstTriIndex = 0;
-       for(f=0; f<pContext->m_pInterface->m_getNumFaces(pContext); f++)
+       for (f=0; f<pContext->m_pInterface->m_getNumFaces(pContext); f++)
        {
                const int verts = pContext->m_pInterface->m_getNumVerticesOfFace(pContext, f);
-               if(verts!=3 && verts!=4) continue;
+               if (verts!=3 && verts!=4) continue;
 
                pTriInfos[iDstTriIndex].iOrgFaceNumber = f;
                pTriInfos[iDstTriIndex].iTSpacesOffs = iTSpacesOffs;
 
-               if(verts==3)
+               if (verts==3)
                {
                        unsigned char * pVerts = pTriInfos[iDstTriIndex].vert_num;
                        pVerts[0]=0; pVerts[1]=1; pVerts[2]=2;
@@ -810,7 +810,7 @@ static int GenerateInitialVerticesIndexList(STriInfo pTriInfos[], int piTriList_
                                const float distSQ_02 = LengthSquared(vsub(T2,T0));
                                const float distSQ_13 = LengthSquared(vsub(T3,T1));
                                tbool bQuadDiagIs_02;
-                               if(distSQ_02<distSQ_13)
+                               if (distSQ_02<distSQ_13)
                                        bQuadDiagIs_02 = TTRUE;
                                else if(distSQ_13<distSQ_02)
                                        bQuadDiagIs_02 = TFALSE;
@@ -826,7 +826,7 @@ static int GenerateInitialVerticesIndexList(STriInfo pTriInfos[], int piTriList_
                                        bQuadDiagIs_02 = distSQ_13<distSQ_02 ? TFALSE : TTRUE;
                                }
 
-                               if(bQuadDiagIs_02)
+                               if (bQuadDiagIs_02)
                                {
                                        {
                                                unsigned char * pVerts_A = pTriInfos[iDstTriIndex].vert_num;
@@ -871,7 +871,7 @@ static int GenerateInitialVerticesIndexList(STriInfo pTriInfos[], int piTriList_
                assert(iDstTriIndex<=iNrTrianglesIn);
        }
 
-       for(t=0; t<iNrTrianglesIn; t++)
+       for (t=0; t<iNrTrianglesIn; t++)
                pTriInfos[t].iFlag = 0;
 
        // return total amount of tspaces
@@ -946,8 +946,8 @@ static void InitTriInfo(STriInfo pTriInfos[], const int piTriListIn[], const SMi
        // pTriInfos[f].iFlag is cleared in GenerateInitialVerticesIndexList() which is called before this function.
 
        // generate neighbor info list
-       for(f=0; f<iNrTrianglesIn; f++)
-               for(i=0; i<3; i++)
+       for (f=0; f<iNrTrianglesIn; f++)
+               for (i=0; i<3; i++)
                {
                        pTriInfos[f].FaceNeighbors[i] = -1;
                        pTriInfos[f].AssignedGroup[i] = NULL;
@@ -962,7 +962,7 @@ static void InitTriInfo(STriInfo pTriInfos[], const int piTriListIn[], const SMi
                }
 
        // evaluate first order derivatives
-       for(f=0; f<iNrTrianglesIn; f++)
+       for (f=0; f<iNrTrianglesIn; f++)
        {
                // initial values
                const SVec3 v1 = GetPosition(pContext, piTriListIn[f*3+0]);
@@ -986,47 +986,47 @@ static void InitTriInfo(STriInfo pTriInfos[], const int piTriListIn[], const SMi
 
                pTriInfos[f].iFlag |= (fSignedAreaSTx2>0 ? ORIENT_PRESERVING : 0);
 
-               if( NotZero(fSignedAreaSTx2) )
+               if ( NotZero(fSignedAreaSTx2) )
                {
                        const float fAbsArea = fabsf(fSignedAreaSTx2);
                        const float fLenOs = Length(vOs);
                        const float fLenOt = Length(vOt);
                        const float fS = (pTriInfos[f].iFlag&ORIENT_PRESERVING)==0 ? (-1.0f) : 1.0f;
-                       if( NotZero(fLenOs) ) pTriInfos[f].vOs = vscale(fS/fLenOs, vOs);
-                       if( NotZero(fLenOt) ) pTriInfos[f].vOt = vscale(fS/fLenOt, vOt);
+                       if ( NotZero(fLenOs) ) pTriInfos[f].vOs = vscale(fS/fLenOs, vOs);
+                       if ( NotZero(fLenOt) ) pTriInfos[f].vOt = vscale(fS/fLenOt, vOt);
 
                        // evaluate magnitudes prior to normalization of vOs and vOt
                        pTriInfos[f].fMagS = fLenOs / fAbsArea;
                        pTriInfos[f].fMagT = fLenOt / fAbsArea;
 
                        // if this is a good triangle
-                       if( NotZero(pTriInfos[f].fMagS) && NotZero(pTriInfos[f].fMagT))
+                       if ( NotZero(pTriInfos[f].fMagS) && NotZero(pTriInfos[f].fMagT))
                                pTriInfos[f].iFlag &= (~GROUP_WITH_ANY);
                }
        }
 
        // force otherwise healthy quads to a fixed orientation
-       while(t<(iNrTrianglesIn-1))
+       while (t<(iNrTrianglesIn-1))
        {
                const int iFO_a = pTriInfos[t].iOrgFaceNumber;
                const int iFO_b = pTriInfos[t+1].iOrgFaceNumber;
-               if(iFO_a==iFO_b)        // this is a quad
+               if (iFO_a==iFO_b)       // this is a quad
                {
                        const tbool bIsDeg_a = (pTriInfos[t].iFlag&MARK_DEGENERATE)!=0 ? TTRUE : TFALSE;
                        const tbool bIsDeg_b = (pTriInfos[t+1].iFlag&MARK_DEGENERATE)!=0 ? TTRUE : TFALSE;
                        
                        // bad triangles should already have been removed by
                        // DegenPrologue(), but just in case check bIsDeg_a and bIsDeg_a are false
-                       if((bIsDeg_a||bIsDeg_b)==TFALSE)
+                       if ((bIsDeg_a||bIsDeg_b)==TFALSE)
                        {
                                const tbool bOrientA = (pTriInfos[t].iFlag&ORIENT_PRESERVING)!=0 ? TTRUE : TFALSE;
                                const tbool bOrientB = (pTriInfos[t+1].iFlag&ORIENT_PRESERVING)!=0 ? TTRUE : TFALSE;
                                // if this happens the quad has extremely bad mapping!!
-                               if(bOrientA!=bOrientB)
+                               if (bOrientA!=bOrientB)
                                {
                                        //printf("found quad with bad mapping\n");
                                        tbool bChooseOrientFirstTri = TFALSE;
-                                       if((pTriInfos[t+1].iFlag&GROUP_WITH_ANY)!=0) bChooseOrientFirstTri = TTRUE;
+                                       if ((pTriInfos[t+1].iFlag&GROUP_WITH_ANY)!=0) bChooseOrientFirstTri = TTRUE;
                                        else if( CalcTexArea(pContext, &piTriListIn[t*3+0]) >= CalcTexArea(pContext, &piTriListIn[(t+1)*3+0]) )
                                                bChooseOrientFirstTri = TTRUE;
 
@@ -1048,7 +1048,7 @@ static void InitTriInfo(STriInfo pTriInfos[], const int piTriListIn[], const SMi
        // match up edge pairs
        {
                SEdge * pEdges = (SEdge *) malloc(sizeof(SEdge)*iNrTrianglesIn*3);
-               if(pEdges==NULL)
+               if (pEdges==NULL)
                        BuildNeighborsSlow(pTriInfos, piTriListIn, iNrTrianglesIn);
                else
                {
@@ -1070,12 +1070,12 @@ static int Build4RuleGroups(STriInfo pTriInfos[], SGroup pGroups[], int piGroupT
        const int iNrMaxGroups = iNrTrianglesIn*3;
        int iNrActiveGroups = 0;
        int iOffset = 0, f=0, i=0;
-       for(f=0; f<iNrTrianglesIn; f++)
+       for (f=0; f<iNrTrianglesIn; f++)
        {
-               for(i=0; i<3; i++)
+               for (i=0; i<3; i++)
                {
                        // if not assigned to a group
-                       if((pTriInfos[f].iFlag&GROUP_WITH_ANY)==0 && pTriInfos[f].AssignedGroup[i]==NULL)
+                       if ((pTriInfos[f].iFlag&GROUP_WITH_ANY)==0 && pTriInfos[f].AssignedGroup[i]==NULL)
                        {
                                tbool bOrPre;
                                int neigh_indexL, neigh_indexR;
@@ -1092,7 +1092,7 @@ static int Build4RuleGroups(STriInfo pTriInfos[], SGroup pGroups[], int piGroupT
                                bOrPre = (pTriInfos[f].iFlag&ORIENT_PRESERVING)!=0 ? TTRUE : TFALSE;
                                neigh_indexL = pTriInfos[f].FaceNeighbors[i];
                                neigh_indexR = pTriInfos[f].FaceNeighbors[i>0?(i-1):2];
-                               if(neigh_indexL>=0) // neighbor
+                               if (neigh_indexL>=0) // neighbor
                                {
                                        const tbool bAnswer =
                                                AssignRecur(piTriListIn, pTriInfos, neigh_indexL,
@@ -1102,7 +1102,7 @@ static int Build4RuleGroups(STriInfo pTriInfos[], SGroup pGroups[], int piGroupT
                                        const tbool bDiff = bOrPre!=bOrPre2 ? TTRUE : TFALSE;
                                        assert(bAnswer || bDiff);
                                }
-                               if(neigh_indexR>=0) // neighbor
+                               if (neigh_indexR>=0) // neighbor
                                {
                                        const tbool bAnswer =
                                                AssignRecur(piTriListIn, pTriInfos, neigh_indexR,
@@ -1141,20 +1141,20 @@ static tbool AssignRecur(const int piTriListIn[], STriInfo psTriInfos[],
        const int iVertRep = pGroup->iVertexRepresentitive;
        const int * pVerts = &piTriListIn[3*iMyTriIndex+0];
        int i=-1;
-       if(pVerts[0]==iVertRep) i=0;
+       if (pVerts[0]==iVertRep) i=0;
        else if(pVerts[1]==iVertRep) i=1;
        else if(pVerts[2]==iVertRep) i=2;
        assert(i>=0 && i<3);
 
        // early out
-       if(pMyTriInfo->AssignedGroup[i] == pGroup) return TTRUE;
+       if (pMyTriInfo->AssignedGroup[i] == pGroup) return TTRUE;
        else if(pMyTriInfo->AssignedGroup[i]!=NULL) return TFALSE;
-       if((pMyTriInfo->iFlag&GROUP_WITH_ANY)!=0)
+       if ((pMyTriInfo->iFlag&GROUP_WITH_ANY)!=0)
        {
                // first to group with a group-with-anything triangle
                // determines it's orientation.
                // This is the only existing order dependency in the code!!
-               if( pMyTriInfo->AssignedGroup[0] == NULL &&
+               if ( pMyTriInfo->AssignedGroup[0] == NULL &&
                        pMyTriInfo->AssignedGroup[1] == NULL &&
                        pMyTriInfo->AssignedGroup[2] == NULL )
                {
@@ -1164,7 +1164,7 @@ static tbool AssignRecur(const int piTriListIn[], STriInfo psTriInfos[],
        }
        {
                const tbool bOrient = (pMyTriInfo->iFlag&ORIENT_PRESERVING)!=0 ? TTRUE : TFALSE;
-               if(bOrient != pGroup->bOrientPreservering) return TFALSE;
+               if (bOrient != pGroup->bOrientPreservering) return TFALSE;
        }
 
        AddTriToGroup(pGroup, iMyTriIndex);
@@ -1173,9 +1173,9 @@ static tbool AssignRecur(const int piTriListIn[], STriInfo psTriInfos[],
        {
                const int neigh_indexL = pMyTriInfo->FaceNeighbors[i];
                const int neigh_indexR = pMyTriInfo->FaceNeighbors[i>0?(i-1):2];
-               if(neigh_indexL>=0)
+               if (neigh_indexL>=0)
                        AssignRecur(piTriListIn, psTriInfos, neigh_indexL, pGroup);
-               if(neigh_indexR>=0)
+               if (neigh_indexR>=0)
                        AssignRecur(piTriListIn, psTriInfos, neigh_indexR, pGroup);
        }
 
@@ -1199,39 +1199,39 @@ static tbool GenerateTSpaces(STSpace psTspace[], const STriInfo pTriInfos[], con
        SSubGroup * pUniSubGroups = NULL;
        int * pTmpMembers = NULL;
        int iMaxNrFaces=0, iUniqueTspaces=0, g=0, i=0;
-       for(g=0; g<iNrActiveGroups; g++)
-               if(iMaxNrFaces < pGroups[g].iNrFaces)
+       for (g=0; g<iNrActiveGroups; g++)
+               if (iMaxNrFaces < pGroups[g].iNrFaces)
                        iMaxNrFaces = pGroups[g].iNrFaces;
 
-       if(iMaxNrFaces == 0) return TTRUE;
+       if (iMaxNrFaces == 0) return TTRUE;
 
        // make initial allocations
        pSubGroupTspace = (STSpace *) malloc(sizeof(STSpace)*iMaxNrFaces);
        pUniSubGroups = (SSubGroup *) malloc(sizeof(SSubGroup)*iMaxNrFaces);
        pTmpMembers = (int *) malloc(sizeof(int)*iMaxNrFaces);
-       if(pSubGroupTspace==NULL || pUniSubGroups==NULL || pTmpMembers==NULL)
+       if (pSubGroupTspace==NULL || pUniSubGroups==NULL || pTmpMembers==NULL)
        {
-               if(pSubGroupTspace!=NULL) free(pSubGroupTspace);        
-               if(pUniSubGroups!=NULL) free(pUniSubGroups);    
-               if(pTmpMembers!=NULL) free(pTmpMembers);        
+               if (pSubGroupTspace!=NULL) free(pSubGroupTspace);
+               if (pUniSubGroups!=NULL) free(pUniSubGroups);
+               if (pTmpMembers!=NULL) free(pTmpMembers);
                return TFALSE;
        }
 
 
        iUniqueTspaces = 0;
-       for(g=0; g<iNrActiveGroups; g++)
+       for (g=0; g<iNrActiveGroups; g++)
        {
                const SGroup * pGroup = &pGroups[g];
                int iUniqueSubGroups = 0, s=0;
 
-               for(i=0; i<pGroup->iNrFaces; i++)       // triangles
+               for (i=0; i<pGroup->iNrFaces; i++)      // triangles
                {
                        const int f = pGroup->pFaceIndices[i];  // triangle number
                        int index=-1, iVertIndex=-1, iOF_1=-1, iMembers=0, j=0, l=0;
                        SSubGroup tmp_group;
                        tbool bFound;
                        SVec3 n, vOs, vOt;
-                       if(pTriInfos[f].AssignedGroup[0]==pGroup) index=0;
+                       if (pTriInfos[f].AssignedGroup[0]==pGroup) index=0;
                        else if(pTriInfos[f].AssignedGroup[1]==pGroup) index=1;
                        else if(pTriInfos[f].AssignedGroup[2]==pGroup) index=2;
                        assert(index>=0 && index<3);
@@ -1245,14 +1245,14 @@ static tbool GenerateTSpaces(STSpace psTspace[], const STriInfo pTriInfos[], con
                        // project
                        vOs = vsub(pTriInfos[f].vOs, vscale(vdot(n,pTriInfos[f].vOs), n));
                        vOt = vsub(pTriInfos[f].vOt, vscale(vdot(n,pTriInfos[f].vOt), n));
-                       if( VNotZero(vOs) ) vOs = Normalize(vOs);
-                       if( VNotZero(vOt) ) vOt = Normalize(vOt);
+                       if ( VNotZero(vOs) ) vOs = Normalize(vOs);
+                       if ( VNotZero(vOt) ) vOt = Normalize(vOt);
 
                        // original face number
                        iOF_1 = pTriInfos[f].iOrgFaceNumber;
                        
                        iMembers = 0;
-                       for(j=0; j<pGroup->iNrFaces; j++)
+                       for (j=0; j<pGroup->iNrFaces; j++)
                        {
                                const int t = pGroup->pFaceIndices[j];  // triangle number
                                const int iOF_2 = pTriInfos[t].iOrgFaceNumber;
@@ -1260,8 +1260,8 @@ static tbool GenerateTSpaces(STSpace psTspace[], const STriInfo pTriInfos[], con
                                // project
                                SVec3 vOs2 = vsub(pTriInfos[t].vOs, vscale(vdot(n,pTriInfos[t].vOs), n));
                                SVec3 vOt2 = vsub(pTriInfos[t].vOt, vscale(vdot(n,pTriInfos[t].vOt), n));
-                               if( VNotZero(vOs2) ) vOs2 = Normalize(vOs2);
-                               if( VNotZero(vOt2) ) vOt2 = Normalize(vOt2);
+                               if ( VNotZero(vOs2) ) vOs2 = Normalize(vOs2);
+                               if ( VNotZero(vOt2) ) vOt2 = Normalize(vOt2);
 
                                {
                                        const tbool bAny = ( (pTriInfos[f].iFlag | pTriInfos[t].iFlag) & GROUP_WITH_ANY )!=0 ? TTRUE : TFALSE;
@@ -1272,7 +1272,7 @@ static tbool GenerateTSpaces(STSpace psTspace[], const STriInfo pTriInfos[], con
                                        const float fCosT = vdot(vOt,vOt2);
 
                                        assert(f!=t || bSameOrgFace);   // sanity check
-                                       if(bAny || bSameOrgFace || (fCosS>fThresCos && fCosT>fThresCos))
+                                       if (bAny || bSameOrgFace || (fCosS>fThresCos && fCosT>fThresCos))
                                                pTmpMembers[iMembers++] = t;
                                }
                        }
@@ -1280,7 +1280,7 @@ static tbool GenerateTSpaces(STSpace psTspace[], const STriInfo pTriInfos[], con
                        // sort pTmpMembers
                        tmp_group.iNrFaces = iMembers;
                        tmp_group.pTriMembers = pTmpMembers;
-                       if(iMembers>1)
+                       if (iMembers>1)
                        {
                                unsigned int uSeed = INTERNAL_RND_SORT_SEED;    // could replace with a random seed?
                                QuickSort(pTmpMembers, 0, iMembers-1, uSeed);
@@ -1289,10 +1289,10 @@ static tbool GenerateTSpaces(STSpace psTspace[], const STriInfo pTriInfos[], con
                        // look for an existing match
                        bFound = TFALSE;
                        l=0;
-                       while(l<iUniqueSubGroups && !bFound)
+                       while (l<iUniqueSubGroups && !bFound)
                        {
                                bFound = CompareSubGroups(&tmp_group, &pUniSubGroups[l]);
-                               if(!bFound) ++l;
+                               if (!bFound) ++l;
                        }
                        
                        // assign tangent space index
@@ -1300,15 +1300,15 @@ static tbool GenerateTSpaces(STSpace psTspace[], const STriInfo pTriInfos[], con
                        //piTempTangIndices[f*3+index] = iUniqueTspaces+l;
 
                        // if no match was found we allocate a new subgroup
-                       if(!bFound)
+                       if (!bFound)
                        {
                                // insert new subgroup
                                int * pIndices = (int *) malloc(sizeof(int)*iMembers);
-                               if(pIndices==NULL)
+                               if (pIndices==NULL)
                                {
                                        // clean up and return false
                                        int s=0;
-                                       for(s=0; s<iUniqueSubGroups; s++)
+                                       for (s=0; s<iUniqueSubGroups; s++)
                                                free(pUniSubGroups[s].pTriMembers);
                                        free(pUniSubGroups);
                                        free(pTmpMembers);
@@ -1330,7 +1330,7 @@ static tbool GenerateTSpaces(STSpace psTspace[], const STriInfo pTriInfos[], con
                                STSpace * pTS_out = &psTspace[iOffs+iVert];
                                assert(pTS_out->iCounter<2);
                                assert(((pTriInfos[f].iFlag&ORIENT_PRESERVING)!=0) == pGroup->bOrientPreservering);
-                               if(pTS_out->iCounter==1)
+                               if (pTS_out->iCounter==1)
                                {
                                        *pTS_out = AvgTSpace(pTS_out, &pSubGroupTspace[l]);
                                        pTS_out->iCounter = 2;  // update counter
@@ -1347,7 +1347,7 @@ static tbool GenerateTSpaces(STSpace psTspace[], const STriInfo pTriInfos[], con
                }
 
                // clean up and offset iUniqueTspaces
-               for(s=0; s<iUniqueSubGroups; s++)
+               for (s=0; s<iUniqueSubGroups; s++)
                        free(pUniSubGroups[s].pTriMembers);
                iUniqueTspaces += iUniqueSubGroups;
        }
@@ -1370,17 +1370,17 @@ static STSpace EvalTspace(int face_indices[], const int iFaces, const int piTriL
        res.vOt.x=0.0f; res.vOt.y=0.0f; res.vOt.z=0.0f;
        res.fMagS = 0; res.fMagT = 0;
 
-       for(face=0; face<iFaces; face++)
+       for (face=0; face<iFaces; face++)
        {
                const int f = face_indices[face];
 
                // only valid triangles get to add their contribution
-               if( (pTriInfos[f].iFlag&GROUP_WITH_ANY)==0 )
+               if ( (pTriInfos[f].iFlag&GROUP_WITH_ANY)==0 )
                {
                        SVec3 n, vOs, vOt, p0, p1, p2, v1, v2;
                        float fCos, fAngle, fMagS, fMagT;
                        int i=-1, index=-1, i0=-1, i1=-1, i2=-1;
-                       if(piTriListIn[3*f+0]==iVertexRepresentitive) i=0;
+                       if (piTriListIn[3*f+0]==iVertexRepresentitive) i=0;
                        else if(piTriListIn[3*f+1]==iVertexRepresentitive) i=1;
                        else if(piTriListIn[3*f+2]==iVertexRepresentitive) i=2;
                        assert(i>=0 && i<3);
@@ -1390,8 +1390,8 @@ static STSpace EvalTspace(int face_indices[], const int iFaces, const int piTriL
                        n = GetNormal(pContext, index);
                        vOs = vsub(pTriInfos[f].vOs, vscale(vdot(n,pTriInfos[f].vOs), n));
                        vOt = vsub(pTriInfos[f].vOt, vscale(vdot(n,pTriInfos[f].vOt), n));
-                       if( VNotZero(vOs) ) vOs = Normalize(vOs);
-                       if( VNotZero(vOt) ) vOt = Normalize(vOt);
+                       if ( VNotZero(vOs) ) vOs = Normalize(vOs);
+                       if ( VNotZero(vOt) ) vOt = Normalize(vOt);
 
                        i2 = piTriListIn[3*f + (i<2?(i+1):0)];
                        i1 = piTriListIn[3*f + i];
@@ -1423,9 +1423,9 @@ static STSpace EvalTspace(int face_indices[], const int iFaces, const int piTriL
        }
 
        // normalize
-       if( VNotZero(res.vOs) ) res.vOs = Normalize(res.vOs);
-       if( VNotZero(res.vOt) ) res.vOt = Normalize(res.vOt);
-       if(fAngleSum>0)
+       if ( VNotZero(res.vOs) ) res.vOs = Normalize(res.vOs);
+       if ( VNotZero(res.vOt) ) res.vOt = Normalize(res.vOt);
+       if (fAngleSum>0)
        {
                res.fMagS /= fAngleSum;
                res.fMagT /= fAngleSum;
@@ -1438,11 +1438,11 @@ static tbool CompareSubGroups(const SSubGroup * pg1, const SSubGroup * pg2)
 {
        tbool bStillSame=TTRUE;
        int i=0;
-       if(pg1->iNrFaces!=pg2->iNrFaces) return TFALSE;
-       while(i<pg1->iNrFaces && bStillSame)
+       if (pg1->iNrFaces!=pg2->iNrFaces) return TFALSE;
+       while (i<pg1->iNrFaces && bStillSame)
        {
                bStillSame = pg1->pTriMembers[i]==pg2->pTriMembers[i] ? TTRUE : TFALSE;
-               if(bStillSame) ++i;
+               if (bStillSame) ++i;
        }
        return bStillSame;
 }
@@ -1467,12 +1467,12 @@ static void QuickSort(int* pSortBuffer, int iLeft, int iRight, unsigned int uSee
 
        do
        {
-               while(pSortBuffer[iL] < iMid)
+               while (pSortBuffer[iL] < iMid)
                        ++iL;
-               while(pSortBuffer[iR] > iMid)
+               while (pSortBuffer[iR] > iMid)
                        --iR;
 
-               if(iL <= iR)
+               if (iL <= iR)
                {
                        iTmp = pSortBuffer[iL];
                        pSortBuffer[iL] = pSortBuffer[iR];
@@ -1480,11 +1480,11 @@ static void QuickSort(int* pSortBuffer, int iLeft, int iRight, unsigned int uSee
                        ++iL; --iR;
                }
        }
-       while(iL <= iR);
+       while (iL <= iR);
 
-       if(iLeft < iR)
+       if (iLeft < iR)
                QuickSort(pSortBuffer, iLeft, iR, uSeed);
-       if(iL < iRight)
+       if (iL < iRight)
                QuickSort(pSortBuffer, iL, iRight, uSeed);
 }
 
@@ -1499,8 +1499,8 @@ static void BuildNeighborsFast(STriInfo pTriInfos[], SEdge * pEdges, const int p
        // build array of edges
        unsigned int uSeed = INTERNAL_RND_SORT_SEED;                            // could replace with a random seed?
        int iEntries=0, iCurStartIndex=-1, f=0, i=0;
-       for(f=0; f<iNrTrianglesIn; f++)
-               for(i=0; i<3; i++)
+       for (f=0; f<iNrTrianglesIn; f++)
+               for (i=0; i<3; i++)
                {
                        const int i0 = piTriListIn[f*3+i];
                        const int i1 = piTriListIn[f*3+(i<2?(i+1):0)];
@@ -1517,9 +1517,9 @@ static void BuildNeighborsFast(STriInfo pTriInfos[], SEdge * pEdges, const int p
        // with i0 as msb in the quicksort call above.
        iEntries = iNrTrianglesIn*3;
        iCurStartIndex = 0;
-       for(i=1; i<iEntries; i++)
+       for (i=1; i<iEntries; i++)
        {
-               if(pEdges[iCurStartIndex].i0 != pEdges[i].i0)
+               if (pEdges[iCurStartIndex].i0 != pEdges[i].i0)
                {
                        const int iL = iCurStartIndex;
                        const int iR = i-1;
@@ -1533,9 +1533,9 @@ static void BuildNeighborsFast(STriInfo pTriInfos[], SEdge * pEdges, const int p
        // this step is to remain compliant with BuildNeighborsSlow() when
        // more than 2 triangles use the same edge (such as a butterfly topology).
        iCurStartIndex = 0;
-       for(i=1; i<iEntries; i++)
+       for (i=1; i<iEntries; i++)
        {
-               if(pEdges[iCurStartIndex].i0 != pEdges[i].i0 || pEdges[iCurStartIndex].i1 != pEdges[i].i1)
+               if (pEdges[iCurStartIndex].i0 != pEdges[i].i0 || pEdges[iCurStartIndex].i1 != pEdges[i].i1)
                {
                        const int iL = iCurStartIndex;
                        const int iR = i-1;
@@ -1546,7 +1546,7 @@ static void BuildNeighborsFast(STriInfo pTriInfos[], SEdge * pEdges, const int p
        }
 
        // pair up, adjacent triangles
-       for(i=0; i<iEntries; i++)
+       for (i=0; i<iEntries; i++)
        {
                const int i0=pEdges[i].i0;
                const int i1=pEdges[i].i1;
@@ -1558,12 +1558,12 @@ static void BuildNeighborsFast(STriInfo pTriInfos[], SEdge * pEdges, const int p
                GetEdge(&i0_A, &i1_A, &edgenum_A, &piTriListIn[f*3], i0, i1);   // resolve index ordering and edge_num
                bUnassigned_A = pTriInfos[f].FaceNeighbors[edgenum_A] == -1 ? TTRUE : TFALSE;
 
-               if(bUnassigned_A)
+               if (bUnassigned_A)
                {
                        // get true index ordering
                        int j=i+1, t;
                        tbool bNotFound = TTRUE;
-                       while(j<iEntries && i0==pEdges[j].i0 && i1==pEdges[j].i1 && bNotFound)
+                       while (j<iEntries && i0==pEdges[j].i0 && i1==pEdges[j].i1 && bNotFound)
                        {
                                tbool bUnassigned_B;
                                int i0_B, i1_B;
@@ -1572,13 +1572,13 @@ static void BuildNeighborsFast(STriInfo pTriInfos[], SEdge * pEdges, const int p
                                GetEdge(&i1_B, &i0_B, &edgenum_B, &piTriListIn[t*3], pEdges[j].i0, pEdges[j].i1);       // resolve index ordering and edge_num
                                //assert(!(i0_A==i1_B && i1_A==i0_B));
                                bUnassigned_B =  pTriInfos[t].FaceNeighbors[edgenum_B]==-1 ? TTRUE : TFALSE;
-                               if(i0_A==i0_B && i1_A==i1_B && bUnassigned_B)
+                               if (i0_A==i0_B && i1_A==i1_B && bUnassigned_B)
                                        bNotFound = TFALSE;
                                else
                                        ++j;
                        }
 
-                       if(!bNotFound)
+                       if (!bNotFound)
                        {
                                int t = pEdges[j].f;
                                pTriInfos[f].FaceNeighbors[edgenum_A] = t;
@@ -1592,12 +1592,12 @@ static void BuildNeighborsFast(STriInfo pTriInfos[], SEdge * pEdges, const int p
 static void BuildNeighborsSlow(STriInfo pTriInfos[], const int piTriListIn[], const int iNrTrianglesIn)
 {
        int f=0, i=0;
-       for(f=0; f<iNrTrianglesIn; f++)
+       for (f=0; f<iNrTrianglesIn; f++)
        {
-               for(i=0; i<3; i++)
+               for (i=0; i<3; i++)
                {
                        // if unassigned
-                       if(pTriInfos[f].FaceNeighbors[i] == -1)
+                       if (pTriInfos[f].FaceNeighbors[i] == -1)
                        {
                                const int i0_A = piTriListIn[f*3+i];
                                const int i1_A = piTriListIn[f*3+(i<2?(i+1):0)];
@@ -1605,29 +1605,29 @@ static void BuildNeighborsSlow(STriInfo pTriInfos[], const int piTriListIn[], co
                                // search for a neighbor
                                tbool bFound = TFALSE;
                                int t=0, j=0;
-                               while(!bFound && t<iNrTrianglesIn)
+                               while (!bFound && t<iNrTrianglesIn)
                                {
-                                       if(t!=f)
+                                       if (t!=f)
                                        {
                                                j=0;
-                                               while(!bFound && j<3)
+                                               while (!bFound && j<3)
                                                {
                                                        // in rev order
                                                        const int i1_B = piTriListIn[t*3+j];
                                                        const int i0_B = piTriListIn[t*3+(j<2?(j+1):0)];
                                                        //assert(!(i0_A==i1_B && i1_A==i0_B));
-                                                       if(i0_A==i0_B && i1_A==i1_B)
+                                                       if (i0_A==i0_B && i1_A==i1_B)
                                                                bFound = TTRUE;
                                                        else
                                                                ++j;
                                                }
                                        }
                                        
-                                       if(!bFound) ++t;
+                                       if (!bFound) ++t;
                                }
 
                                // assign neighbors
-                               if(bFound)
+                               if (bFound)
                                {
                                        pTriInfos[f].FaceNeighbors[i] = t;
                                        //assert(pTriInfos[t].FaceNeighbors[j]==-1);
@@ -1646,10 +1646,10 @@ static void QuickSortEdges(SEdge * pSortBuffer, int iLeft, int iRight, const int
        // early out
        SEdge sTmp;
        const int iElems = iRight-iLeft+1;
-       if(iElems<2) return;
+       if (iElems<2) return;
        else if(iElems==2)
        {
-               if(pSortBuffer[iLeft].array[channel] > pSortBuffer[iRight].array[channel])
+               if (pSortBuffer[iLeft].array[channel] > pSortBuffer[iRight].array[channel])
                {
                        sTmp = pSortBuffer[iLeft];
                        pSortBuffer[iLeft] = pSortBuffer[iRight];
@@ -1673,12 +1673,12 @@ static void QuickSortEdges(SEdge * pSortBuffer, int iLeft, int iRight, const int
 
        do
        {
-               while(pSortBuffer[iL].array[channel] < iMid)
+               while (pSortBuffer[iL].array[channel] < iMid)
                        ++iL;
-               while(pSortBuffer[iR].array[channel] > iMid)
+               while (pSortBuffer[iR].array[channel] > iMid)
                        --iR;
 
-               if(iL <= iR)
+               if (iL <= iR)
                {
                        sTmp = pSortBuffer[iL];
                        pSortBuffer[iL] = pSortBuffer[iR];
@@ -1686,11 +1686,11 @@ static void QuickSortEdges(SEdge * pSortBuffer, int iLeft, int iRight, const int
                        ++iL; --iR;
                }
        }
-       while(iL <= iR);
+       while (iL <= iR);
 
-       if(iLeft < iR)
+       if (iLeft < iR)
                QuickSortEdges(pSortBuffer, iLeft, iR, channel, uSeed);
-       if(iL < iRight)
+       if (iL < iRight)
                QuickSortEdges(pSortBuffer, iL, iRight, channel, uSeed);
 }
 
@@ -1700,10 +1700,10 @@ static void GetEdge(int * i0_out, int * i1_out, int * edgenum_out, const int ind
        *edgenum_out = -1;
        
        // test if first index is on the edge
-       if(indices[0]==i0_in || indices[0]==i1_in)
+       if (indices[0]==i0_in || indices[0]==i1_in)
        {
                // test if second index is on the edge
-               if(indices[1]==i0_in || indices[1]==i1_in)
+               if (indices[1]==i0_in || indices[1]==i1_in)
                {
                        edgenum_out[0]=0;       // first edge
                        i0_out[0]=indices[0];
@@ -1736,15 +1736,15 @@ static void DegenPrologue(STriInfo pTriInfos[], int piTriList_out[], const int i
 
        // locate quads with only one good triangle
        int t=0;
-       while(t<(iTotTris-1))
+       while (t<(iTotTris-1))
        {
                const int iFO_a = pTriInfos[t].iOrgFaceNumber;
                const int iFO_b = pTriInfos[t+1].iOrgFaceNumber;
-               if(iFO_a==iFO_b)        // this is a quad
+               if (iFO_a==iFO_b)       // this is a quad
                {
                        const tbool bIsDeg_a = (pTriInfos[t].iFlag&MARK_DEGENERATE)!=0 ? TTRUE : TFALSE;
                        const tbool bIsDeg_b = (pTriInfos[t+1].iFlag&MARK_DEGENERATE)!=0 ? TTRUE : TFALSE;
-                       if((bIsDeg_a^bIsDeg_b)!=0)
+                       if ((bIsDeg_a^bIsDeg_b)!=0)
                        {
                                pTriInfos[t].iFlag |= QUAD_ONE_DEGEN_TRI;
                                pTriInfos[t+1].iFlag |= QUAD_ONE_DEGEN_TRI;
@@ -1760,12 +1760,12 @@ static void DegenPrologue(STriInfo pTriInfos[], int piTriList_out[], const int i
        iNextGoodTriangleSearchIndex = 1;
        t=0;
        bStillFindingGoodOnes = TTRUE;
-       while(t<iNrTrianglesIn && bStillFindingGoodOnes)
+       while (t<iNrTrianglesIn && bStillFindingGoodOnes)
        {
                const tbool bIsGood = (pTriInfos[t].iFlag&MARK_DEGENERATE)==0 ? TTRUE : TFALSE;
-               if(bIsGood)
+               if (bIsGood)
                {
-                       if(iNextGoodTriangleSearchIndex < (t+2))
+                       if (iNextGoodTriangleSearchIndex < (t+2))
                                iNextGoodTriangleSearchIndex = t+2;
                }
                else
@@ -1773,10 +1773,10 @@ static void DegenPrologue(STriInfo pTriInfos[], int piTriList_out[], const int i
                        int t0, t1;
                        // search for the first good triangle.
                        tbool bJustADegenerate = TTRUE;
-                       while(bJustADegenerate && iNextGoodTriangleSearchIndex<iTotTris)
+                       while (bJustADegenerate && iNextGoodTriangleSearchIndex<iTotTris)
                        {
                                const tbool bIsGood = (pTriInfos[iNextGoodTriangleSearchIndex].iFlag&MARK_DEGENERATE)==0 ? TTRUE : TFALSE;
-                               if(bIsGood) bJustADegenerate=TFALSE;
+                               if (bIsGood) bJustADegenerate=TFALSE;
                                else ++iNextGoodTriangleSearchIndex;
                        }
 
@@ -1786,10 +1786,10 @@ static void DegenPrologue(STriInfo pTriInfos[], int piTriList_out[], const int i
                        assert(iNextGoodTriangleSearchIndex > (t+1));
 
                        // swap triangle t0 and t1
-                       if(!bJustADegenerate)
+                       if (!bJustADegenerate)
                        {
                                int i=0;
-                               for(i=0; i<3; i++)
+                               for (i=0; i<3; i++)
                                {
                                        const int index = piTriList_out[t0*3+i];
                                        piTriList_out[t0*3+i] = piTriList_out[t1*3+i];
@@ -1805,7 +1805,7 @@ static void DegenPrologue(STriInfo pTriInfos[], int piTriList_out[], const int i
                                bStillFindingGoodOnes = TFALSE; // this is not supposed to happen
                }
 
-               if(bStillFindingGoodOnes) ++t;
+               if (bStillFindingGoodOnes) ++t;
        }
 
        assert(bStillFindingGoodOnes);  // code will still work.
@@ -1817,28 +1817,28 @@ static void DegenEpilogue(STSpace psTspace[], STriInfo pTriInfos[], int piTriLis
        int t=0, i=0;
        // deal with degenerate triangles
        // punishment for degenerate triangles is O(N^2)
-       for(t=iNrTrianglesIn; t<iTotTris; t++)
+       for (t=iNrTrianglesIn; t<iTotTris; t++)
        {
                // degenerate triangles on a quad with one good triangle are skipped
                // here but processed in the next loop
                const tbool bSkip = (pTriInfos[t].iFlag&QUAD_ONE_DEGEN_TRI)!=0 ? TTRUE : TFALSE;
 
-               if(!bSkip)
+               if (!bSkip)
                {
-                       for(i=0; i<3; i++)
+                       for (i=0; i<3; i++)
                        {
                                const int index1 = piTriListIn[t*3+i];
                                // search through the good triangles
                                tbool bNotFound = TTRUE;
                                int j=0;
-                               while(bNotFound && j<(3*iNrTrianglesIn))
+                               while (bNotFound && j<(3*iNrTrianglesIn))
                                {
                                        const int index2 = piTriListIn[j];
-                                       if(index1==index2) bNotFound=TFALSE;
+                                       if (index1==index2) bNotFound=TFALSE;
                                        else ++j;
                                }
 
-                               if(!bNotFound)
+                               if (!bNotFound)
                                {
                                        const int iTri = j/3;
                                        const int iVert = j%3;
@@ -1855,11 +1855,11 @@ static void DegenEpilogue(STSpace psTspace[], STriInfo pTriInfos[], int piTriLis
        }
 
        // deal with degenerate quads with one good triangle
-       for(t=0; t<iNrTrianglesIn; t++)
+       for (t=0; t<iNrTrianglesIn; t++)
        {
                // this triangle belongs to a quad where the
                // other triangle is degenerate
-               if( (pTriInfos[t].iFlag&QUAD_ONE_DEGEN_TRI)!=0 )
+               if ( (pTriInfos[t].iFlag&QUAD_ONE_DEGEN_TRI)!=0 )
                {
                        SVec3 vDstP;
                        int iOrgF=-1, i=0;
@@ -1867,7 +1867,7 @@ static void DegenEpilogue(STSpace psTspace[], STriInfo pTriInfos[], int piTriLis
                        unsigned char * pV = pTriInfos[t].vert_num;
                        int iFlag = (1<<pV[0]) | (1<<pV[1]) | (1<<pV[2]);
                        int iMissingIndex = 0;
-                       if((iFlag&2)==0) iMissingIndex=1;
+                       if ((iFlag&2)==0) iMissingIndex=1;
                        else if((iFlag&4)==0) iMissingIndex=2;
                        else if((iFlag&8)==0) iMissingIndex=3;
 
@@ -1875,11 +1875,11 @@ static void DegenEpilogue(STSpace psTspace[], STriInfo pTriInfos[], int piTriLis
                        vDstP = GetPosition(pContext, MakeIndex(iOrgF, iMissingIndex));
                        bNotFound = TTRUE;
                        i=0;
-                       while(bNotFound && i<3)
+                       while (bNotFound && i<3)
                        {
                                const int iVert = pV[i];
                                const SVec3 vSrcP = GetPosition(pContext, MakeIndex(iOrgF, iVert));
-                               if(veq(vSrcP, vDstP)==TTRUE)
+                               if (veq(vSrcP, vDstP)==TTRUE)
                                {
                                        const int iOffs = pTriInfos[t].iTSpacesOffs;
                                        psTspace[iOffs+iMissingIndex] = psTspace[iOffs+iVert];
index 2e200ea..68d1d6b 100644 (file)
@@ -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);
index e95c243..b59d7fb 100644 (file)
@@ -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);*/
index fc20f57..8561d11 100644 (file)
@@ -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. 
index 151f64b..11e1ed8 100644 (file)
@@ -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;
        }
 
index 2011ced..637d4be 100644 (file)
@@ -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");
 
index 73af709..2c24417 100644 (file)
@@ -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:
index f571897..53e4a97 100644 (file)
@@ -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) {
index c28958d..511b460 100644 (file)
@@ -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]];
index 1ec9f7d..05171a5 100644 (file)
@@ -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] */
index 75b9ae5..be53e3d 100644 (file)
@@ -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);
        }
index 0f3e27a..931aa2d 100644 (file)
@@ -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;
index a556c99..fbcabcc 100644 (file)
@@ -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");
index e7ba09d..3df6de2 100644 (file)
@@ -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;
index 009b7ca..df80ce6 100644 (file)
@@ -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");
        }
 
index a0c273c..97baaad 100644 (file)
@@ -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 );
                }
        
index 5b03f73..264a251 100644 (file)
@@ -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 );
                                        }
                                }
index 25391a3..2d56315 100644 (file)
@@ -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;
index 0a6e8a1..82a908e 100644 (file)
@@ -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]);
        }
 }
index e9dd4d0..7a5b4ef 100644 (file)
@@ -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:
index 9232fe8..e5b2e5f 100644 (file)
@@ -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;
index 1514716..ee8e57d 100644 (file)
@@ -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) {
index 1232177..3e0c947 100644 (file)
@@ -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));
index aa6d429..246c973 100644 (file)
@@ -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) {
index 01d5d6e..fcd8069 100644 (file)
@@ -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);
index 9ce4d68..31544dd 100644 (file)
@@ -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};
 
index 4f320b4..c275d4e 100644 (file)
@@ -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);
index bb8cfe3..806d795 100644 (file)
@@ -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
                                 */
index ed5cf5e..0b722aa 100644 (file)
@@ -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;
diff --git