Merged changes in the trunk up to revision 41368.
authorTamito Kajiyama <rd6t-kjym@asahi-net.or.jp>
Sun, 30 Oct 2011 02:03:40 +0000 (02:03 +0000)
committerTamito Kajiyama <rd6t-kjym@asahi-net.or.jp>
Sun, 30 Oct 2011 02:03:40 +0000 (02:03 +0000)
Conflicts resolved:
source/blender/blenkernel/intern/library.c
source/blender/blenlib/intern/bpath.c
source/blender/render/intern/source/convertblender.c

74 files changed:
1  2 
doc/python_api/sphinx_doc_gen.py
intern/ghost/GHOST_ISystem.h
intern/ghost/intern/GHOST_System.cpp
intern/ghost/intern/GHOST_System.h
release/scripts/startup/bl_operators/wm.py
release/scripts/startup/bl_ui/properties_particle.py
source/blender/CMakeLists.txt
source/blender/blenkernel/BKE_main.h
source/blender/blenkernel/CMakeLists.txt
source/blender/blenkernel/intern/BME_conversions.c
source/blender/blenkernel/intern/DerivedMesh.c
source/blender/blenkernel/intern/anim_sys.c
source/blender/blenkernel/intern/cdderivedmesh.c
source/blender/blenkernel/intern/group.c
source/blender/blenkernel/intern/idcode.c
source/blender/blenkernel/intern/library.c
source/blender/blenkernel/intern/material.c
source/blender/blenkernel/intern/object.c
source/blender/blenkernel/intern/scene.c
source/blender/blenkernel/intern/subsurf_ccg.c
source/blender/blenlib/BLI_editVert.h
source/blender/blenlib/CMakeLists.txt
source/blender/blenlib/intern/bpath.c
source/blender/blenloader/intern/readfile.c
source/blender/blenloader/intern/writefile.c
source/blender/editors/include/UI_resources.h
source/blender/editors/interface/interface_templates.c
source/blender/editors/interface/resources.c
source/blender/editors/mesh/editface.c
source/blender/editors/mesh/editmesh.c
source/blender/editors/mesh/editmesh_mods.c
source/blender/editors/mesh/editmesh_tools.c
source/blender/editors/mesh/mesh_intern.h
source/blender/editors/mesh/mesh_ops.c
source/blender/editors/render/CMakeLists.txt
source/blender/editors/render/render_intern.h
source/blender/editors/render/render_ops.c
source/blender/editors/render/render_shading.c
source/blender/editors/space_file/filelist.c
source/blender/editors/space_view3d/drawobject.c
source/blender/editors/transform/transform.c
source/blender/editors/transform/transform_orientations.c
source/blender/makesdna/DNA_ID.h
source/blender/makesdna/DNA_material_types.h
source/blender/makesdna/DNA_mesh_types.h
source/blender/makesdna/DNA_meshdata_types.h
source/blender/makesdna/DNA_scene_types.h
source/blender/makesdna/DNA_userdef_types.h
source/blender/makesdna/intern/makesdna.c
source/blender/makesrna/RNA_access.h
source/blender/makesrna/RNA_enum_types.h
source/blender/makesrna/intern/CMakeLists.txt
source/blender/makesrna/intern/makesrna.c
source/blender/makesrna/intern/rna_ID.c
source/blender/makesrna/intern/rna_action.c
source/blender/makesrna/intern/rna_color.c
source/blender/makesrna/intern/rna_internal.h
source/blender/makesrna/intern/rna_main.c
source/blender/makesrna/intern/rna_main_api.c
source/blender/makesrna/intern/rna_mesh.c
source/blender/makesrna/intern/rna_scene.c
source/blender/makesrna/intern/rna_userdef.c
source/blender/python/intern/bpy.c
source/blender/render/CMakeLists.txt
source/blender/render/extern/include/RE_pipeline.h
source/blender/render/intern/include/render_types.h
source/blender/render/intern/source/convertblender.c
source/blender/render/intern/source/pipeline.c
source/blender/render/intern/source/shadeinput.c
source/blender/render/intern/source/shadeoutput.c
source/blenderplayer/bad_level_call_stubs/stubs.c
source/creator/CMakeLists.txt
source/creator/creator.c
source/gameengine/GamePlayer/ghost/GPG_ghost.cpp

Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
index 6363512a36ab9024a1053f3f5c1f7066f9729207,9d8acc44e88138f30ac60fe7652525d227d2015a..6cefa1b2a42cf3ee44e1620c641254f6adc58843
  #include "BKE_gpencil.h"
  #include "BKE_fcurve.h"
  #include "BKE_speaker.h"
+ #include "BKE_utildefines.h"
 +#include "BKE_linestyle.h"
  
  #include "RNA_access.h"
  
Simple merge
Simple merge
index 624b726e27e9ec292731092d8ea2f51ac49c5feb,b7fe7ef5efdd83b6417b00b202037043d2ba1a31..1d7dfbde9345982869739028dab76cbdb25505f6
  
  #include "MEM_guardedalloc.h"
  
- #include "DNA_mesh_types.h"
- #include "DNA_scene_types.h" /* to get the current frame */
+ #include "DNA_brush_types.h"
  #include "DNA_image_types.h"
- #include "DNA_texture_types.h"
- #include "DNA_text_types.h"
- #include "DNA_sound_types.h"
+ #include "DNA_mesh_types.h"
+ #include "DNA_modifier_types.h"
+ #include "DNA_object_fluidsim.h"
+ #include "DNA_object_force.h"
+ #include "DNA_object_types.h"
+ #include "DNA_particle_types.h"
  #include "DNA_sequence_types.h"
+ #include "DNA_sound_types.h"
+ #include "DNA_text_types.h"
+ #include "DNA_texture_types.h"
  #include "DNA_vfont_types.h"
- #include "DNA_windowmanager_types.h"
+ #include "DNA_scene_types.h"
+ #include "DNA_smoke_types.h"
 +#include "DNA_freestyle_types.h"
  
  #include "BLI_blenlib.h"
  #include "BLI_bpath.h"
@@@ -519,500 -358,231 +359,238 @@@ static int rewrite_path_alloc(char **pa
        }
  }
  
- void BLI_bpathIterator_step(struct BPathIterator *bpi)
+ /* Run visitor function 'visit' on all paths contained in 'id'. */
+ void bpath_traverse_id(Main *bmain, ID *id, BPathVisitor visit_cb, const int flag, void *bpath_user_data)
  {
-       while (bpi->type != BPATH_DONE) {
-               
-               if  ((bpi->type) == BPATH_IMAGE) {
-                       /*if (bpi->data)        bpi->data= ((ID *)bpi->data)->next;*/
-                       if (bpi->data)  bpi->data= ima_stepdata__internal((Image *)bpi->data, 1, bpi->flag); /* must skip images that have no path */
-                       else                    bpi->data= ima_stepdata__internal(bpi->bmain->image.first, 0, bpi->flag);
-                       
-                       if (bpi->data) {
-                               /* get the path info from this datatype */
-                               Image *ima= (Image *)bpi->data;
-                               
-                               bpi->_lib= ima->id.lib ? ima->id.lib->filepath : NULL;
-                               bpi->_path= ima->name;
-                               bpi->_name= ima->id.name+2;
-                               bpi->len= sizeof(ima->name);
-                               
-                               /* we are done, advancing to the next item, this type worked fine */
-                               break;
+       Image *ima;
+       const char *absbase= (flag & BPATH_TRAVERSE_ABS) ? (id->lib ? id->lib->filepath : bmain->name) : NULL;
+       if ((flag & BPATH_TRAVERSE_SKIP_LIBRARY) && id->lib) {
+               return;
+       }
  
+       switch(GS(id->name)) {
+       case ID_IM:
+               ima= (Image *)id;
+               if (ima->packedfile == NULL || (flag & BPATH_TRAVERSE_SKIP_PACKED) == 0) {
+                       if (ELEM3(ima->source, IMA_SRC_FILE, IMA_SRC_MOVIE, IMA_SRC_SEQUENCE)) {
+                               rewrite_path_fixed(ima->name, visit_cb, absbase, bpath_user_data);
                        }
-                       else {
-                               bpi_type_step__internal(bpi);
+               }
+               break;
+       case ID_BR:
+               {
+                       Brush *brush= (Brush *)id;
+                       if (brush->icon_filepath[0]) {
+                               rewrite_path_fixed(brush->icon_filepath, visit_cb, absbase, bpath_user_data);
                        }
                }
+               break;
+       case ID_OB:
  
-               if  ((bpi->type) == BPATH_TEXTURE) {
-                       /*if (bpi->data)        bpi->data= ((ID *)bpi->data)->next;*/
-                       if (bpi->data)  bpi->data= tex_stepdata__internal( (Tex *)bpi->data, 1, bpi->flag); /* must skip images that have no path */
-                       else                    bpi->data= tex_stepdata__internal(bpi->bmain->tex.first, 0, bpi->flag);
+ #define BPATH_TRAVERSE_POINTCACHE(ptcaches)                                    \
+       {                                                                          \
+               PointCache *cache;                                                     \
+               for(cache= (ptcaches).first; cache; cache= cache->next) {              \
+                       if(cache->flag & PTCACHE_DISK_CACHE) {                             \
+                               rewrite_path_fixed(cache->path,                                \
+                                                  visit_cb,                                   \
+                                                  absbase,                                    \
+                                                  bpath_user_data);                           \
+                       }                                                                  \
+               }                                                                      \
+       }                                                                          \
  
-                       if (bpi->data) {
-                               /* get the path info from this datatype */
-                               Tex *tex= (Tex *)bpi->data;
  
-                               if(tex->type == TEX_VOXELDATA) {
-                                       bpi->_lib= tex->id.lib ? tex->id.lib->filepath : NULL;
-                                       bpi->_path= tex->vd->source_path;
-                                       bpi->_name= tex->id.name+2;
-                                       bpi->len= sizeof(tex->vd->source_path);
-                               }
-                               else {
-                                       assert(!"Texture has no path, incorrect step 'tex_stepdata__internal'");
-                               }
+               {
+                       Object *ob= (Object *)id;
+                       ModifierData *md;
+                       ParticleSystem *psys;
  
-                               /* we are done, advancing to the next item, this type worked fine */
-                               break;
  
+                       /* do via modifiers instead */
+ #if 0
+                       if (ob->fluidsimSettings) {
+                               rewrite_path_fixed(ob->fluidsimSettings->surfdataPath, visit_cb, absbase, bpath_user_data);
                        }
-                       else {
-                               bpi_type_step__internal(bpi);
-                       }
-               }
-               if  ((bpi->type) == BPATH_TEXT) {
-                       /*if (bpi->data)        bpi->data= ((ID *)bpi->data)->next;*/
-                       if (bpi->data)  bpi->data= text_stepdata__internal((Text *)bpi->data, 1, bpi->flag); /* must skip images that have no path */
-                       else                    bpi->data= text_stepdata__internal(bpi->bmain->text.first, 0, bpi->flag);
-                       if (bpi->data) {
-                               /* get the path info from this datatype */
-                               Text *text= (Text *)bpi->data;
-                               bpi->_lib= text->id.lib ? text->id.lib->filepath : NULL;
-                               bpi->_path= NULL; /* bpi->path= text->name; */ /* get/set functions override. */
-                               bpi->_name= text->id.name+2;
-                               bpi->len= FILE_MAX; /* malloc'd but limit anyway since large paths may mess up other areas */
+ #endif
  
-                               /* we are done, advancing to the next item, this type worked fine */
-                               break;
+                       for (md= ob->modifiers.first; md; md= md->next) {
+                               if (md->type == eModifierType_Fluidsim) {
+                                       FluidsimModifierData *fluidmd= (FluidsimModifierData *)md;
+                                       if (fluidmd->fss) {
+                                               rewrite_path_fixed(fluidmd->fss->surfdataPath, visit_cb, absbase, bpath_user_data);
+                                       }
+                               }
+                               else if (md->type == eModifierType_Smoke) {
+                                       SmokeModifierData *smd= (SmokeModifierData *)md;
+                                       if(smd->type & MOD_SMOKE_TYPE_DOMAIN) {
+                                               BPATH_TRAVERSE_POINTCACHE(smd->domain->ptcaches[0]);
+                                       }
+                               }
+                               else if (md->type==eModifierType_Cloth) {
+                                       ClothModifierData *clmd= (ClothModifierData*) md;
+                                       BPATH_TRAVERSE_POINTCACHE(clmd->ptcaches);
+                               }
+                       }
  
+                       if (ob->soft) {
+                               BPATH_TRAVERSE_POINTCACHE(ob->soft->ptcaches);
                        }
-                       else {
-                               bpi_type_step__internal(bpi);
+                       for (psys= ob->particlesystem.first; psys; psys= psys->next) {
+                               BPATH_TRAVERSE_POINTCACHE(psys->ptcaches);
                        }
                }
-               else if  ((bpi->type) == BPATH_SOUND) {
-                       if (bpi->data)  bpi->data= snd_stepdata__internal((bSound *)bpi->data, 1, bpi->flag); /* must skip images that have no path */
-                       else                    bpi->data= snd_stepdata__internal(bpi->bmain->sound.first, 0, bpi->flag);
-                       if (bpi->data) {
-                               /* get the path info from this datatype */
-                               bSound *snd= (bSound *)bpi->data;
  
-                               bpi->_lib= snd->id.lib ? snd->id.lib->filepath : NULL;
-                               bpi->_path= snd->name;
-                               bpi->_name= snd->id.name+2;
-                               bpi->len= sizeof(snd->name);
+ #undef BPATH_TRAVERSE_POINTCACHE
  
-                               /* we are done, advancing to the next item, this type worked fine */
-                               break;
-                       }
-                       else {
-                               bpi_type_step__internal(bpi);
+               break;
+       case ID_SO:
+               {
+                       bSound *sound= (bSound *)id;
+                       if (sound->packedfile == NULL || (flag & BPATH_TRAVERSE_SKIP_PACKED) == 0) {
+                               rewrite_path_fixed(sound->name, visit_cb, absbase, bpath_user_data);
                        }
                }
-               else if  ((bpi->type) == BPATH_FONT) {
-                       
-                       if (bpi->data)  bpi->data= vf_stepdata__internal((VFont *)bpi->data, 1, bpi->flag);
-                       else                    bpi->data= vf_stepdata__internal(bpi->bmain->vfont.first, 0, bpi->flag);
-                       
-                       if (bpi->data) {
-                               /* get the path info from this datatype */
-                               VFont *vf= (VFont *)bpi->data;
-                               bpi->_lib= vf->id.lib ? vf->id.lib->filepath : NULL;
-                               bpi->_path= vf->name;
-                               bpi->_name= vf->id.name+2;
-                               bpi->len= sizeof(vf->name);
-                               /* we are done, advancing to the next item, this type worked fine */
-                               break;
-                       }
-                       else {
-                               bpi_type_step__internal(bpi);
-                       }
+               break;
+       case ID_TXT:
+               if (((Text*)id)->name) {
+                       rewrite_path_alloc(&((Text *)id)->name, visit_cb, absbase, bpath_user_data);
                }
-               else if  ((bpi->type) == BPATH_LIB) {
-                       if (bpi->data)  bpi->data= ((ID *)bpi->data)->next;
-                       else                    bpi->data= bpi->bmain->library.first;
-                       
-                       if (bpi->data) {
-                               /* get the path info from this datatype */
-                               Library *lib= (Library *)bpi->data;
-                               
-                               bpi->_lib= NULL;
-                               bpi->_path= lib->name;
-                               bpi->_name= NULL;
-                               bpi->len= sizeof(lib->name);
-                               
-                               /* we are done, advancing to the next item, this type worked fine */
-                               break;
-                       }
-                       else {
-                               bpi_type_step__internal(bpi);
+               break;
+       case ID_VF:
+               {
+                       VFont *vf= (VFont *)id;
+                       if (vf->packedfile == NULL || (flag & BPATH_TRAVERSE_SKIP_PACKED) == 0) {
+                               if (strcmp(vf->name, FO_BUILTIN_NAME) != 0) {
+                                       rewrite_path_fixed(((VFont *)id)->name, visit_cb, absbase, bpath_user_data);
+                               }
                        }
                }
-               else if  ((bpi->type) == BPATH_SEQ) {
-                       if (bpi->data)  bpi->data= seq_stepdata__internal( bpi, 1 );
-                       else                    bpi->data= seq_stepdata__internal( bpi, 0 );
-                       if (bpi->data) {
-                               Sequence *seq= (Sequence *)bpi->data;
-                               bpi->_lib= NULL;
-                               bpi->_name= seq->name+2;
-                               bpi->len= seq->plugin ? sizeof(seq->plugin->name) : sizeof(seq->strip->dir) + sizeof(seq->strip->stripdata->name);
-                               break;
+               break;
+       case ID_TE:
+               {
+                       Tex *tex = (Tex *)id;
+                       if (tex->plugin) {
+                               /* FIXME: rewrite_path assumes path length of FILE_MAX, but
+                                          tex->plugin->name is 160. ... is this field even a path? */
+                               //rewrite_path(tex->plugin->name, visit_cb, bpath_user_data);
                        }
-                       else {
-                               bpi_type_step__internal(bpi);
+                       if (tex->type == TEX_VOXELDATA && TEX_VD_IS_SOURCE_PATH(tex->vd->file_format)) {
+                               rewrite_path_fixed(tex->vd->source_path, visit_cb, absbase, bpath_user_data);
                        }
                }
-               else if  ((bpi->type) == BPATH_CDATA) {
-                       if (bpi->data)  bpi->data= cdata_stepdata__internal( bpi->data, 1 );
-                       else                    bpi->data= cdata_stepdata__internal( bpi->bmain->mesh.first, 0 );
-                       if (bpi->data) {
-                               Mesh *me= (Mesh *)bpi->data;
-                               bpi->_lib= me->id.lib ? me->id.lib->filepath : NULL;
-                               bpi->_path= me->fdata.external->filename;
-                               bpi->_name= me->id.name+2;
-                               bpi->len= sizeof(me->fdata.external->filename);
-                               break;
-                       }
-                       else {
-                               bpi_type_step__internal(bpi);
+               break;
+       case ID_SCE:
+               {
+                       Scene *scene= (Scene *)id;
++                      SceneRenderLayer *srl= scene->r.layers.first;
+                       if (scene->ed) {
+                               Sequence *seq;
+                               SEQ_BEGIN(scene->ed, seq) {
+                                       if (SEQ_HAS_PATH(seq)) {
+                                               if (ELEM(seq->type, SEQ_MOVIE, SEQ_SOUND)) {
+                                                       rewrite_path_fixed_dirfile(seq->strip->dir, seq->strip->stripdata->name, visit_cb, absbase, bpath_user_data);
+                                               }
+                                               else if (seq->type == SEQ_IMAGE) {
+                                                       /* might want an option not to loop over all strips */
+                                                       StripElem *se= seq->strip->stripdata;
+                                                       int len= MEM_allocN_len(se) / sizeof(*se);
+                                                       int i;
+                                                       for(i= 0; i < len; i++, se++) {
+                                                               rewrite_path_fixed_dirfile(seq->strip->dir, se->name, visit_cb, absbase, bpath_user_data);
+                                                       }
+                                               }
+                                               else {
+                                                       /* simple case */
+                                                       rewrite_path_fixed(seq->strip->dir, visit_cb, absbase, bpath_user_data);
+                                               }
+                                       }
+                                       else if (seq->plugin) {
+                                               rewrite_path_fixed(seq->plugin->name, visit_cb, absbase, bpath_user_data);
+                                       }
+                               }
+                               SEQ_END
                        }
-               } else if  ((bpi->type) == BPATH_FRS_MODULE) {
-                       if (bpi->data)  bpi->data= frs_module_stepdata__internal( bpi, 1 );
-                       else                    bpi->data= frs_module_stepdata__internal( bpi, 0 );
-                       if (bpi->data) {
-                               FreestyleModuleConfig *module= (FreestyleModuleConfig *)bpi->data;
-                               bpi->_lib= NULL;
-                               bpi->_path= module->module_path;
-                               bpi->_name= NULL;
-                               bpi->len= sizeof(module->module_path);
-                               break;
-                       } else {
-                               bpi_type_step__internal(bpi);
++                      for(; srl; srl= srl->next) {
++                              FreestyleModuleConfig* module= srl->freestyleConfig.modules.first;
++                              for (; module; module= module->next) {
++                                      rewrite_path_fixed(module->module_path, visit_cb, absbase, bpath_user_data);
++                              }
 +                      }
                }
-       }
- }
- int BLI_bpathIterator_isDone( struct BPathIterator *bpi)
- {
-       return bpi->type==BPATH_DONE;
- }
- /* include the path argument */
- static void bpath_as_report(struct BPathIterator *bpi, const char *message, ReportList *reports)
- {
-       const char *prefix;
-       const char *name;
-       char path_expanded[FILE_MAXDIR*2];
-       
-       if(reports==NULL)
-               return;
-       switch(BLI_bpathIterator_getType(bpi)) {
-       case BPATH_IMAGE:
-               prefix= "Image";
-               break;
-       case BPATH_TEXTURE:
-               prefix= "Texture";
-               break;
-       case BPATH_TEXT:
-               prefix= "Text";
-               break;
-       case BPATH_SOUND:
-               prefix= "Sound";
                break;
-       case BPATH_FONT:
-               prefix= "Font";
-               break;
-       case BPATH_LIB:
-               prefix= "Library";
-               break;
-       case BPATH_SEQ:
-               prefix= "Sequence";
-               break;
-       case BPATH_CDATA:
-               prefix= "Mesh Data";
+       case ID_ME:
+               {
+                       Mesh *me= (Mesh *)id;
+                       if (me->fdata.external) {
+                               rewrite_path_fixed(me->fdata.external->filename, visit_cb, absbase, bpath_user_data);
+                       }
+               }
                break;
-       case BPATH_FRS_MODULE:
-               prefix= "Freestyle Module";
+       case ID_LI:
+               {
+                       Library *lib= (Library *)id;
+                       if(rewrite_path_fixed(lib->name, visit_cb, absbase, bpath_user_data)) {
+                               BKE_library_filepath_set(lib, lib->name);
+                       }
+               }
                break;
        default:
-               prefix= "Unknown";
+               /* Nothing to do for other IDs that don't contain file paths. */
                break;
        }
-       
-       name= BLI_bpathIterator_getName(bpi);
-       BLI_bpathIterator_getPathExpanded(bpi, path_expanded);
-       if(reports) {
-               if (name)       BKE_reportf(reports, RPT_WARNING, "%s \"%s\", \"%s\": %s", prefix, name, path_expanded, message);
-               else            BKE_reportf(reports, RPT_WARNING, "%s \"%s\": %s", prefix, path_expanded, message);
-       }
  }
  
- /* high level function */
- void checkMissingFiles(Main *bmain, ReportList *reports)
+ void bpath_traverse_id_list(Main *bmain, ListBase *lb, BPathVisitor visit_cb, const int flag, void *bpath_user_data)
  {
-       struct BPathIterator *bpi;
-       
-       /* be sure there is low chance of the path being too short */
-       char filepath_expanded[FILE_MAXDIR*2]; 
-       
-       BLI_bpathIterator_init(&bpi, bmain, bmain->name, 0);
-       while (!BLI_bpathIterator_isDone(bpi)) {
-               BLI_bpathIterator_getPathExpanded(bpi, filepath_expanded);
-               
-               if (!BLI_exists(filepath_expanded))
-                       bpath_as_report(bpi, "file not found", reports);
-               BLI_bpathIterator_step(bpi);
+       ID *id;
+       for(id= lb->first; id; id= id->next) {
+               bpath_traverse_id(bmain, id, visit_cb, flag, bpath_user_data);
        }
-       BLI_bpathIterator_free(bpi);
  }
  
- /* dont log any errors at the moment, should probably do this */
- void makeFilesRelative(Main *bmain, const char *basedir, ReportList *reports)
+ void bpath_traverse_main(Main *bmain, BPathVisitor visit_cb, const int flag, void *bpath_user_data)
  {
-       int tot= 0, changed= 0, failed= 0, linked= 0;
-       struct BPathIterator *bpi;
-       char filepath[FILE_MAX];
-       const char *libpath;
-       
-       /* be sure there is low chance of the path being too short */
-       char filepath_relative[(FILE_MAXDIR * 2) + FILE_MAXFILE];
-       if(basedir[0] == '\0') {
-               printf("makeFilesRelative: basedir='', this is a bug\n");
-               return;
-       }
-       BLI_bpathIterator_init(&bpi, bmain, basedir, 0);
-       while (!BLI_bpathIterator_isDone(bpi)) {
-               BLI_bpathIterator_getPath(bpi, filepath);
-               libpath= BLI_bpathIterator_getLib(bpi);
-               
-               if(strncmp(filepath, "//", 2)) {
-                       if (libpath) { /* cant make relative if we are library - TODO, LOG THIS */
-                               linked++;
-                       }
-                       else { /* local data, use the blend files path */
-                               BLI_strncpy(filepath_relative, filepath, sizeof(filepath_relative));
-                               /* Important BLI_cleanup_dir runs before the path is made relative
-                                * because it wont work for paths that start with "//../" */ 
-                               BLI_cleanup_file(bpi->base_path, filepath_relative); /* fix any /foo/../foo/ */
-                               BLI_path_rel(filepath_relative, bpi->base_path);
-                               /* be safe and check the length */
-                               if (BLI_bpathIterator_getPathMaxLen(bpi) <= strlen(filepath_relative)) {
-                                       bpath_as_report(bpi, "couldn't make path relative (too long)", reports);
-                                       failed++;
-                               }
-                               else {
-                                       if(strncmp(filepath_relative, "//", 2)==0) {
-                                               BLI_bpathIterator_setPath(bpi, filepath_relative);
-                                               changed++;
-                                       }
-                                       else {
-                                               bpath_as_report(bpi, "couldn't make path relative", reports);
-                                               failed++;
-                                       }
-                               }
-                       }
-               }
-               BLI_bpathIterator_step(bpi);
-               tot++;
-       }
-       BLI_bpathIterator_free(bpi);
-       if(reports)
-               BKE_reportf(reports, failed ? RPT_ERROR : RPT_INFO, "Total files %i|Changed %i|Failed %i|Linked %i", tot, changed, failed, linked);
+       ListBase *lbarray[MAX_LIBARRAY];
+       int a= set_listbasepointers(bmain, lbarray);
+       while(a--) bpath_traverse_id_list(bmain, lbarray[a], visit_cb, flag, bpath_user_data);
  }
  
- /* dont log any errors at the moment, should probably do this -
-  * Verry similar to makeFilesRelative - keep in sync! */
void makeFilesAbsolute(Main *bmain, const char *basedir, ReportList *reports)
+ /* Rewrites a relative path to be relative to the main file - unless the path is
+    absolute, in which case it is not altered. */
int bpath_relocate_visitor(void *pathbase_v, char *path_dst, const char *path_src)
  {
-       int tot= 0, changed= 0, failed= 0, linked= 0;
-       struct BPathIterator *bpi;
-       char filepath[FILE_MAX];
-       const char *libpath;
-       
        /* be sure there is low chance of the path being too short */
-       char filepath_absolute[(FILE_MAXDIR * 2) + FILE_MAXFILE];
-       if(basedir[0] == '\0') {
-               printf("makeFilesAbsolute: basedir='', this is a bug\n");
-               return;
+       char filepath[(FILE_MAXDIR * 2) + FILE_MAXFILE];
+       const char *base_new= ((char **)pathbase_v)[0];
+       const char *base_old= ((char **)pathbase_v)[1];
+       if (strncmp(base_old, "//", 2) == 0) {
+               printf("%s: error, old base path '%s' is not absolute.\n",
+                      __func__, base_old);
+               return FALSE;
        }
  
-       BLI_bpathIterator_init(&bpi, bmain, basedir, 0);
-       while (!BLI_bpathIterator_isDone(bpi)) {
-               BLI_bpathIterator_getPath(bpi, filepath);
-               libpath= BLI_bpathIterator_getLib(bpi);
-               
-               if(strncmp(filepath, "//", 2)==0) {
-                       if (libpath) { /* cant make absolute if we are library - TODO, LOG THIS */
-                               linked++;
-                       }
-                       else { /* get the expanded path and check it is relative or too long */
-                               BLI_bpathIterator_getPathExpanded(bpi, filepath_absolute);
-                               BLI_cleanup_file(bpi->base_path, filepath_absolute); /* fix any /foo/../foo/ */
-                               /* to be safe, check the length */
-                               if (BLI_bpathIterator_getPathMaxLen(bpi) <= strlen(filepath_absolute)) {
-                                       bpath_as_report(bpi, "couldn't make absolute (too long)", reports);
-                                       failed++;
-                               }
-                               else {
-                                       if(strncmp(filepath_absolute, "//", 2)) {
-                                               BLI_bpathIterator_setPath(bpi, filepath_absolute);
-                                               changed++;
-                                       }
-                                       else {
-                                               bpath_as_report(bpi, "couldn't make absolute", reports);
-                                               failed++;
-                                       }
-                               }
-                       }
-               }
-               BLI_bpathIterator_step(bpi);
-               tot++;
+       /* Make referenced file absolute. This would be a side-effect of
+          BLI_cleanup_file, but we do it explicitely so we know if it changed. */
+       BLI_strncpy(filepath, path_src, FILE_MAX);
+       if (BLI_path_abs(filepath, base_old)) {
+               /* Path was relative and is now absolute. Remap.
+                * Important BLI_cleanup_dir runs before the path is made relative
+                * because it wont work for paths that start with "//../" */
+               BLI_cleanup_file(base_new, filepath);
+               BLI_path_rel(filepath, base_new);
+               BLI_strncpy(path_dst, filepath, FILE_MAX);
+               return TRUE;
        }
-       BLI_bpathIterator_free(bpi);
-       if(reports)
-               BKE_reportf(reports, failed ? RPT_ERROR : RPT_INFO, "Total files %i|Changed %i|Failed %i|Linked %i", tot, changed, failed, linked);
- }
- /* find this file recursively, use the biggest file so thumbnails dont get used by mistake
-  - dir: subdir to search
-  - filename: set this filename
-  - filesize: filesize for the file
- */
- #define MAX_RECUR 16
- static int findFileRecursive(char *filename_new, const char *dirname, const char *filename, int *filesize, int *recur_depth)
- {
-       /* file searching stuff */
-       DIR *dir;
-       struct dirent *de;
-       struct stat status;
-       char path[FILE_MAX];
-       int size;
-       
-       dir= opendir(dirname);
-       
-       if (dir==NULL)
-               return 0;
-       
-       if (*filesize == -1)
-               *filesize= 0; /* dir opened fine */
-       
-       while ((de= readdir(dir)) != NULL) {
-               
-               if (strcmp(".", de->d_name)==0 || strcmp("..", de->d_name)==0)
-                       continue;
-               
-               BLI_join_dirfile(path, sizeof(path), dirname, de->d_name);
-               
-               if (stat(path, &status) != 0)
-                       continue; /* cant stat, dont bother with this file, could print debug info here */
-               
-               if (S_ISREG(status.st_mode)) { /* is file */
-                       if (strncmp(filename, de->d_name, FILE_MAX)==0) { /* name matches */
-                               /* open the file to read its size */
-                               size= status.st_size;
-                               if ((size > 0) && (size > *filesize)) { /* find the biggest file */
-                                       *filesize= size;
-                                       BLI_strncpy(filename_new, path, FILE_MAX);
-                               }
-                       }
-               }
-               else if (S_ISDIR(status.st_mode)) { /* is subdir */
-                       if (*recur_depth <= MAX_RECUR) {
-                               (*recur_depth)++;
-                               findFileRecursive(filename_new, path, filename, filesize, recur_depth);
-                               (*recur_depth)--;
-                       }
-               }
-       }
-       closedir(dir);
-       return 1;
- }
- /* high level function - call from fileselector */
- void findMissingFiles(Main *bmain, const char *str)
- {
-       struct BPathIterator *bpi;
-       
-       /* be sure there is low chance of the path being too short */
-       char filepath_expanded[FILE_MAXDIR*2]; 
-       char filepath[FILE_MAX];
-       const char *libpath;
-       int filesize, recur_depth;
-       
-       char dirname[FILE_MAX], filename_new[FILE_MAX];
-       
-       //XXX waitcursor( 1 );
-       
-       BLI_split_dir_part(str, dirname, sizeof(dirname));
-       
-       BLI_bpathIterator_init(&bpi, bmain, bmain->name, 0);
-       
-       while (!BLI_bpathIterator_isDone(bpi)) {
-               BLI_bpathIterator_getPath(bpi, filepath);
-               libpath= BLI_bpathIterator_getLib(bpi);
-               
-               /* Check if esc was pressed because searching files can be slow */
-               /*XXX if (blender_test_break()) {
-                       break;
-               }*/
-               
-               if (libpath==NULL) {
-                       
-                       BLI_bpathIterator_getPathExpanded(bpi, filepath_expanded);
-                       
-                       if (!BLI_exists(filepath_expanded)) {
-                               /* can the dir be opened? */
-                               filesize= -1;
-                               recur_depth= 0;
-                               
-                               findFileRecursive(filename_new, dirname, BLI_path_basename(filepath), &filesize, &recur_depth);
-                               if (filesize == -1) { /* could not open dir */
-                                       printf("Could not open dir \"%s\"\n", dirname);
-                                       return;
-                               }
-                               
-                               if (filesize > 0) {
-                                       
-                                       if (BLI_bpathIterator_getPathMaxLen(bpi) < strlen(filename_new)) { 
-                                               printf("cannot set path \"%s\" too long!", filename_new);
-                                       }
-                                       else {
-                                               /* copy the found path into the old one */
-                                               if (G.relbase_valid)
-                                                       BLI_path_rel(filename_new, bpi->base_path);
-                                               
-                                               BLI_bpathIterator_setPath(bpi, filename_new);
-                                       }
-                               }
-                       }
-               }
-               BLI_bpathIterator_step(bpi);
+       else {
+               /* Path was not relative to begin with. */
+               return FALSE;
        }
-       BLI_bpathIterator_free(bpi);
-       
-       //XXX waitcursor( 0 );
  }
Simple merge
Simple merge
Simple merge
Simple merge
index 5c49f230ee6c57e1f8acead8090be6bb64a06b99,5968a6e64f82cb9aa679af8de21d1b878ca66ecc..cd37cfa99bc965d9ffecaf012a356cb5b3020db1
@@@ -3435,13 -3403,13 +3431,15 @@@ static void init_render_mesh(Render *re
                                                
                                                if( mface->mat_nr==a1 ) {
                                                        float len;
-                                                       v1= mface->v1;
 +                                                      int edge_mark= 0;
 +                                                              
+                                                       int reverse_verts = negative_scale!=0 && do_autosmooth==0;
+                                                       int rev_tab[] = {reverse_verts==0 ? 0 : 2, 1, reverse_verts==0 ? 2 : 0, 3};
+                                                       v1= reverse_verts==0 ? mface->v1 : mface->v3;
                                                        v2= mface->v2;
-                                                       v3= mface->v3;
+                                                       v3= reverse_verts==0 ? mface->v3 : mface->v1;
                                                        v4= mface->v4;
 -                                                      flag= mface->flag & ME_SMOOTH;
 +                                                      flag= mface->flag & (ME_SMOOTH | ME_FREESTYLE_FACE);
  
                                                        vlr= RE_findOrAddVlak(obr, obr->totvlak++);
                                                        vlr->v1= RE_findOrAddVert(obr, vertofs+v1);
Simple merge
Simple merge