style cleanup: blenkernel

This commit is contained in:
Campbell Barton 2012-05-06 17:22:54 +00:00
parent 1118b3fe3f
commit ffed654ff2
19 changed files with 4438 additions and 4442 deletions

File diff suppressed because it is too large Load Diff

@ -95,7 +95,7 @@ Global G;
UserDef U; UserDef U;
/* ListBase = {NULL, NULL}; */ /* ListBase = {NULL, NULL}; */
char versionstr[48]= ""; char versionstr[48] = "";
/* ********** free ********** */ /* ********** free ********** */
@ -104,9 +104,9 @@ void free_blender(void)
{ {
/* samples are in a global list..., also sets G.main->sound->sample NULL */ /* samples are in a global list..., also sets G.main->sound->sample NULL */
free_main(G.main); free_main(G.main);
G.main= NULL; G.main = NULL;
BKE_spacetypes_free(); /* after free main, it uses space callbacks */ BKE_spacetypes_free(); /* after free main, it uses space callbacks */
IMB_exit(); IMB_exit();
@ -122,18 +122,18 @@ void initglobals(void)
{ {
memset(&G, 0, sizeof(Global)); memset(&G, 0, sizeof(Global));
U.savetime= 1; U.savetime = 1;
G.main= MEM_callocN(sizeof(Main), "initglobals"); G.main = MEM_callocN(sizeof(Main), "initglobals");
strcpy(G.ima, "//"); strcpy(G.ima, "//");
if (BLENDER_SUBVERSION) if (BLENDER_SUBVERSION)
BLI_snprintf(versionstr, sizeof(versionstr), "v%d.%02d.%d", BLENDER_VERSION/100, BLENDER_VERSION%100, BLENDER_SUBVERSION); BLI_snprintf(versionstr, sizeof(versionstr), "v%d.%02d.%d", BLENDER_VERSION / 100, BLENDER_VERSION % 100, BLENDER_SUBVERSION);
else else
BLI_snprintf(versionstr, sizeof(versionstr), "v%d.%02d", BLENDER_VERSION/100, BLENDER_VERSION%100); BLI_snprintf(versionstr, sizeof(versionstr), "v%d.%02d", BLENDER_VERSION / 100, BLENDER_VERSION % 100);
#ifdef _WIN32 // FULLSCREEN #ifdef _WIN32 // FULLSCREEN
G.windowstate = G_WINDOWSTATE_USERDEF; G.windowstate = G_WINDOWSTATE_USERDEF;
#endif #endif
@ -154,11 +154,11 @@ static void clear_global(void)
{ {
// extern short winqueue_break; /* screen.c */ // extern short winqueue_break; /* screen.c */
free_main(G.main); /* free all lib data */ free_main(G.main); /* free all lib data */
// free_vertexpaint(); // free_vertexpaint();
G.main= NULL; G.main = NULL;
} }
static int clean_paths_visit_cb(void *UNUSED(userdata), char *path_dst, const char *path_src) static int clean_paths_visit_cb(void *UNUSED(userdata), char *path_dst, const char *path_src)
@ -175,7 +175,7 @@ static void clean_paths(Main *main)
BLI_bpath_traverse_main(main, clean_paths_visit_cb, BLI_BPATH_TRAVERSE_SKIP_MULTIFILE, NULL); BLI_bpath_traverse_main(main, clean_paths_visit_cb, BLI_BPATH_TRAVERSE_SKIP_MULTIFILE, NULL);
for (scene= main->scene.first; scene; scene= scene->id.next) { for (scene = main->scene.first; scene; scene = scene->id.next) {
BLI_clean(scene->r.pic); BLI_clean(scene->r.pic);
} }
} }
@ -188,17 +188,17 @@ static void clean_paths(Main *main)
static void setup_app_data(bContext *C, BlendFileData *bfd, const char *filepath) static void setup_app_data(bContext *C, BlendFileData *bfd, const char *filepath)
{ {
bScreen *curscreen= NULL; bScreen *curscreen = NULL;
Scene *curscene= NULL; Scene *curscene = NULL;
int recover; int recover;
char mode; char mode;
/* 'u' = undo save, 'n' = no UI load */ /* 'u' = undo save, 'n' = no UI load */
if (bfd->main->screen.first==NULL) mode= 'u'; if (bfd->main->screen.first == NULL) mode = 'u';
else if (G.fileflags & G_FILE_NO_UI) mode= 'n'; else if (G.fileflags & G_FILE_NO_UI) mode = 'n';
else mode= 0; else mode = 0;
recover= (G.fileflags & G_FILE_RECOVER); recover = (G.fileflags & G_FILE_RECOVER);
/* Free all render results, without this stale data gets displayed after loading files */ /* Free all render results, without this stale data gets displayed after loading files */
if (mode != 'u') { if (mode != 'u') {
@ -222,12 +222,12 @@ static void setup_app_data(bContext *C, BlendFileData *bfd, const char *filepath
SWAP(ListBase, G.main->script, bfd->main->script); SWAP(ListBase, G.main->script, bfd->main->script);
/* we re-use current screen */ /* we re-use current screen */
curscreen= CTX_wm_screen(C); curscreen = CTX_wm_screen(C);
/* but use new Scene pointer */ /* but use new Scene pointer */
curscene= bfd->curscene; curscene = bfd->curscene;
if (curscene==NULL) curscene= bfd->main->scene.first; if (curscene == NULL) curscene = bfd->main->scene.first;
/* and we enforce curscene to be in current screen */ /* and we enforce curscene to be in current screen */
if (curscreen) curscreen->scene= curscene; /* can run in bgmode */ if (curscreen) curscreen->scene = curscene; /* can run in bgmode */
/* clear_global will free G.main, here we can still restore pointers */ /* clear_global will free G.main, here we can still restore pointers */
lib_link_screen_restore(bfd->main, curscreen, curscene); lib_link_screen_restore(bfd->main, curscreen, curscene);
@ -240,7 +240,7 @@ static void setup_app_data(bContext *C, BlendFileData *bfd, const char *filepath
/* clear old property update cache, in case some old references are left dangling */ /* clear old property update cache, in case some old references are left dangling */
RNA_property_update_cache_free(); RNA_property_update_cache_free();
G.main= bfd->main; G.main = bfd->main;
CTX_data_main_set(C, G.main); CTX_data_main_set(C, G.main);
@ -251,7 +251,7 @@ static void setup_app_data(bContext *C, BlendFileData *bfd, const char *filepath
/* only here free userdef themes... */ /* only here free userdef themes... */
BKE_userdef_free(); BKE_userdef_free();
U= *bfd->user; U = *bfd->user;
MEM_freeN(bfd->user); MEM_freeN(bfd->user);
} }
@ -261,9 +261,9 @@ static void setup_app_data(bContext *C, BlendFileData *bfd, const char *filepath
CTX_data_scene_set(C, curscene); CTX_data_scene_set(C, curscene);
} }
else { else {
G.winpos= bfd->winpos; G.winpos = bfd->winpos;
G.displaymode= bfd->displaymode; G.displaymode = bfd->displaymode;
G.fileflags= bfd->fileflags; G.fileflags = bfd->fileflags;
CTX_wm_manager_set(C, bfd->main->wm.first); CTX_wm_manager_set(C, bfd->main->wm.first);
CTX_wm_screen_set(C, bfd->curscreen); CTX_wm_screen_set(C, bfd->curscreen);
CTX_data_scene_set(C, bfd->curscreen->scene); CTX_data_scene_set(C, bfd->curscreen->scene);
@ -273,20 +273,20 @@ static void setup_app_data(bContext *C, BlendFileData *bfd, const char *filepath
} }
/* this can happen when active scene was lib-linked, and doesn't exist anymore */ /* this can happen when active scene was lib-linked, and doesn't exist anymore */
if (CTX_data_scene(C)==NULL) { if (CTX_data_scene(C) == NULL) {
CTX_data_scene_set(C, bfd->main->scene.first); CTX_data_scene_set(C, bfd->main->scene.first);
CTX_wm_screen(C)->scene= CTX_data_scene(C); CTX_wm_screen(C)->scene = CTX_data_scene(C);
curscene= CTX_data_scene(C); curscene = CTX_data_scene(C);
} }
/* special cases, override loaded flags: */ /* special cases, override loaded flags: */
if (G.f != bfd->globalf) { if (G.f != bfd->globalf) {
const int flags_keep = (G_SWAP_EXCHANGE | G_SCRIPT_AUTOEXEC | G_SCRIPT_OVERRIDE_PREF); const int flags_keep = (G_SWAP_EXCHANGE | G_SCRIPT_AUTOEXEC | G_SCRIPT_OVERRIDE_PREF);
bfd->globalf= (bfd->globalf & ~flags_keep) | (G.f & flags_keep); bfd->globalf = (bfd->globalf & ~flags_keep) | (G.f & flags_keep);
} }
G.f= bfd->globalf; G.f = bfd->globalf;
if (!G.background) { if (!G.background) {
//setscreen(G.curscreen); //setscreen(G.curscreen);
@ -300,12 +300,12 @@ static void setup_app_data(bContext *C, BlendFileData *bfd, const char *filepath
if (recover && bfd->filename[0] && G.relbase_valid) { if (recover && bfd->filename[0] && G.relbase_valid) {
/* in case of autosave or quit.blend, use original filename instead /* in case of autosave or quit.blend, use original filename instead
* use relbase_valid to make sure the file is saved, else we get <memory2> in the filename */ * use relbase_valid to make sure the file is saved, else we get <memory2> in the filename */
filepath= bfd->filename; filepath = bfd->filename;
} }
#if 0 #if 0
else if (!G.relbase_valid) { else if (!G.relbase_valid) {
/* otherwise, use an empty string as filename, rather than <memory2> */ /* otherwise, use an empty string as filename, rather than <memory2> */
filepath=""; filepath = "";
} }
#endif #endif
@ -324,8 +324,8 @@ static void setup_app_data(bContext *C, BlendFileData *bfd, const char *filepath
static int handle_subversion_warning(Main *main, ReportList *reports) static int handle_subversion_warning(Main *main, ReportList *reports)
{ {
if (main->minversionfile > BLENDER_VERSION || if (main->minversionfile > BLENDER_VERSION ||
(main->minversionfile == BLENDER_VERSION && (main->minversionfile == BLENDER_VERSION &&
main->minsubversionfile > BLENDER_SUBVERSION)) { main->minsubversionfile > BLENDER_SUBVERSION)) {
BKE_reportf(reports, RPT_ERROR, "File written by newer Blender binary: %d.%d , expect loss of data!", main->minversionfile, main->minsubversionfile); BKE_reportf(reports, RPT_ERROR, "File written by newer Blender binary: %d.%d , expect loss of data!", main->minversionfile, main->minsubversionfile);
} }
@ -348,8 +348,8 @@ void BKE_userdef_free(void)
wmKeyMapItem *kmi; wmKeyMapItem *kmi;
wmKeyMapDiffItem *kmdi; wmKeyMapDiffItem *kmdi;
for (km=U.user_keymaps.first; km; km=km->next) { for (km = U.user_keymaps.first; km; km = km->next) {
for (kmdi=km->diff_items.first; kmdi; kmdi=kmdi->next) { for (kmdi = km->diff_items.first; kmdi; kmdi = kmdi->next) {
if (kmdi->add_item) { if (kmdi->add_item) {
keymap_item_free(kmdi->add_item); keymap_item_free(kmdi->add_item);
MEM_freeN(kmdi->add_item); MEM_freeN(kmdi->add_item);
@ -360,7 +360,7 @@ void BKE_userdef_free(void)
} }
} }
for (kmi=km->items.first; kmi; kmi=kmi->next) for (kmi = km->items.first; kmi; kmi = kmi->next)
keymap_item_free(kmi); keymap_item_free(kmi);
BLI_freelistN(&km->diff_items); BLI_freelistN(&km->diff_items);
@ -377,41 +377,41 @@ void BKE_userdef_free(void)
int BKE_read_file(bContext *C, const char *filepath, ReportList *reports) int BKE_read_file(bContext *C, const char *filepath, ReportList *reports)
{ {
BlendFileData *bfd; BlendFileData *bfd;
int retval= BKE_READ_FILE_OK; int retval = BKE_READ_FILE_OK;
if (strstr(filepath, BLENDER_STARTUP_FILE)==NULL) /* don't print user-pref loading */ if (strstr(filepath, BLENDER_STARTUP_FILE) == NULL) /* don't print user-pref loading */
printf("read blend: %s\n", filepath); printf("read blend: %s\n", filepath);
bfd= BLO_read_from_file(filepath, reports); bfd = BLO_read_from_file(filepath, reports);
if (bfd) { if (bfd) {
if (bfd->user) retval= BKE_READ_FILE_OK_USERPREFS; if (bfd->user) retval = BKE_READ_FILE_OK_USERPREFS;
if (0==handle_subversion_warning(bfd->main, reports)) { if (0 == handle_subversion_warning(bfd->main, reports)) {
free_main(bfd->main); free_main(bfd->main);
MEM_freeN(bfd); MEM_freeN(bfd);
bfd= NULL; bfd = NULL;
retval= BKE_READ_FILE_FAIL; retval = BKE_READ_FILE_FAIL;
} }
else else
setup_app_data(C, bfd, filepath); // frees BFD setup_app_data(C, bfd, filepath); // frees BFD
} }
else else
BKE_reports_prependf(reports, "Loading %s failed: ", filepath); BKE_reports_prependf(reports, "Loading %s failed: ", filepath);
return (bfd?retval:BKE_READ_FILE_FAIL); return (bfd ? retval : BKE_READ_FILE_FAIL);
} }
int BKE_read_file_from_memory(bContext *C, char* filebuf, int filelength, ReportList *reports) int BKE_read_file_from_memory(bContext *C, char *filebuf, int filelength, ReportList *reports)
{ {
BlendFileData *bfd; BlendFileData *bfd;
bfd= BLO_read_from_memory(filebuf, filelength, reports); bfd = BLO_read_from_memory(filebuf, filelength, reports);
if (bfd) if (bfd)
setup_app_data(C, bfd, "<memory2>"); setup_app_data(C, bfd, "<memory2>");
else else
BKE_reports_prepend(reports, "Loading failed: "); BKE_reports_prepend(reports, "Loading failed: ");
return (bfd?1:0); return (bfd ? 1 : 0);
} }
/* memfile is the undo buffer */ /* memfile is the undo buffer */
@ -419,13 +419,13 @@ int BKE_read_file_from_memfile(bContext *C, MemFile *memfile, ReportList *report
{ {
BlendFileData *bfd; BlendFileData *bfd;
bfd= BLO_read_from_memfile(CTX_data_main(C), G.main->name, memfile, reports); bfd = BLO_read_from_memfile(CTX_data_main(C), G.main->name, memfile, reports);
if (bfd) if (bfd)
setup_app_data(C, bfd, "<memory1>"); setup_app_data(C, bfd, "<memory1>");
else else
BKE_reports_prepend(reports, "Loading failed: "); BKE_reports_prepend(reports, "Loading failed: ");
return (bfd?1:0); return (bfd ? 1 : 0);
} }
@ -435,7 +435,7 @@ static void (*blender_test_break_cb)(void) = NULL;
void set_blender_test_break_cb(void (*func)(void) ) void set_blender_test_break_cb(void (*func)(void) )
{ {
blender_test_break_cb= func; blender_test_break_cb = func;
} }
@ -446,15 +446,15 @@ int blender_test_break(void)
blender_test_break_cb(); blender_test_break_cb();
} }
return (G.afbreek==1); return (G.afbreek == 1);
} }
/* ***************** GLOBAL UNDO *************** */ /* ***************** GLOBAL UNDO *************** */
#define UNDO_DISK 0 #define UNDO_DISK 0
#define MAXUNDONAME 64 #define MAXUNDONAME 64
typedef struct UndoElem { typedef struct UndoElem {
struct UndoElem *next, *prev; struct UndoElem *next, *prev;
char str[FILE_MAX]; char str[FILE_MAX];
@ -463,31 +463,31 @@ typedef struct UndoElem {
uintptr_t undosize; uintptr_t undosize;
} UndoElem; } UndoElem;
static ListBase undobase={NULL, NULL}; static ListBase undobase = {NULL, NULL};
static UndoElem *curundo= NULL; static UndoElem *curundo = NULL;
static int read_undosave(bContext *C, UndoElem *uel) static int read_undosave(bContext *C, UndoElem *uel)
{ {
char mainstr[sizeof(G.main->name)]; char mainstr[sizeof(G.main->name)];
int success=0, fileflags; int success = 0, fileflags;
/* This is needed so undoing/redoing doesn't crash with threaded previews going */ /* This is needed so undoing/redoing doesn't crash with threaded previews going */
WM_jobs_stop_all(CTX_wm_manager(C)); WM_jobs_stop_all(CTX_wm_manager(C));
BLI_strncpy(mainstr, G.main->name, sizeof(mainstr)); /* temporal store */ BLI_strncpy(mainstr, G.main->name, sizeof(mainstr)); /* temporal store */
fileflags= G.fileflags; fileflags = G.fileflags;
G.fileflags |= G_FILE_NO_UI; G.fileflags |= G_FILE_NO_UI;
if (UNDO_DISK) if (UNDO_DISK)
success= (BKE_read_file(C, uel->str, NULL) != BKE_READ_FILE_FAIL); success = (BKE_read_file(C, uel->str, NULL) != BKE_READ_FILE_FAIL);
else else
success= BKE_read_file_from_memfile(C, &uel->memfile, NULL); success = BKE_read_file_from_memfile(C, &uel->memfile, NULL);
/* restore */ /* restore */
BLI_strncpy(G.main->name, mainstr, sizeof(G.main->name)); /* restore */ BLI_strncpy(G.main->name, mainstr, sizeof(G.main->name)); /* restore */
G.fileflags= fileflags; G.fileflags = fileflags;
if (success) { if (success) {
/* important not to update time here, else non keyed tranforms are lost */ /* important not to update time here, else non keyed tranforms are lost */
@ -504,33 +504,33 @@ void BKE_write_undo(bContext *C, const char *name)
int nr /*, success */ /* UNUSED */; int nr /*, success */ /* UNUSED */;
UndoElem *uel; UndoElem *uel;
if ( (U.uiflag & USER_GLOBALUNDO)==0) return; if ( (U.uiflag & USER_GLOBALUNDO) == 0) return;
if ( U.undosteps==0) return; if (U.undosteps == 0) return;
/* remove all undos after (also when curundo==NULL) */ /* remove all undos after (also when curundo==NULL) */
while (undobase.last != curundo) { while (undobase.last != curundo) {
uel= undobase.last; uel = undobase.last;
BLI_remlink(&undobase, uel); BLI_remlink(&undobase, uel);
BLO_free_memfile(&uel->memfile); BLO_free_memfile(&uel->memfile);
MEM_freeN(uel); MEM_freeN(uel);
} }
/* make new */ /* make new */
curundo= uel= MEM_callocN(sizeof(UndoElem), "undo file"); curundo = uel = MEM_callocN(sizeof(UndoElem), "undo file");
BLI_strncpy(uel->name, name, sizeof(uel->name)); BLI_strncpy(uel->name, name, sizeof(uel->name));
BLI_addtail(&undobase, uel); BLI_addtail(&undobase, uel);
/* and limit amount to the maximum */ /* and limit amount to the maximum */
nr= 0; nr = 0;
uel= undobase.last; uel = undobase.last;
while (uel) { while (uel) {
nr++; nr++;
if (nr==U.undosteps) break; if (nr == U.undosteps) break;
uel= uel->prev; uel = uel->prev;
} }
if (uel) { if (uel) {
while (undobase.first!=uel) { while (undobase.first != uel) {
UndoElem *first= undobase.first; UndoElem *first = undobase.first;
BLI_remlink(&undobase, first); BLI_remlink(&undobase, first);
/* the merge is because of compression */ /* the merge is because of compression */
BLO_merge_memfile(&first->memfile, &first->next->memfile); BLO_merge_memfile(&first->memfile, &first->next->memfile);
@ -541,14 +541,14 @@ void BKE_write_undo(bContext *C, const char *name)
/* disk save version */ /* disk save version */
if (UNDO_DISK) { if (UNDO_DISK) {
static int counter= 0; static int counter = 0;
char filepath[FILE_MAX]; char filepath[FILE_MAX];
char numstr[32]; char numstr[32];
int fileflags = G.fileflags & ~(G_FILE_HISTORY); /* don't do file history on undo */ int fileflags = G.fileflags & ~(G_FILE_HISTORY); /* don't do file history on undo */
/* calculate current filepath */ /* calculate current filepath */
counter++; counter++;
counter= counter % U.undosteps; counter = counter % U.undosteps;
BLI_snprintf(numstr, sizeof(numstr), "%d.blend", counter); BLI_snprintf(numstr, sizeof(numstr), "%d.blend", counter);
BLI_make_file_string("/", filepath, BLI_temporary_dir(), numstr); BLI_make_file_string("/", filepath, BLI_temporary_dir(), numstr);
@ -558,34 +558,34 @@ void BKE_write_undo(bContext *C, const char *name)
BLI_strncpy(curundo->str, filepath, sizeof(curundo->str)); BLI_strncpy(curundo->str, filepath, sizeof(curundo->str));
} }
else { else {
MemFile *prevfile=NULL; MemFile *prevfile = NULL;
if (curundo->prev) prevfile= &(curundo->prev->memfile); if (curundo->prev) prevfile = &(curundo->prev->memfile);
memused= MEM_get_memory_in_use(); memused = MEM_get_memory_in_use();
/* success= */ /* UNUSED */ BLO_write_file_mem(CTX_data_main(C), prevfile, &curundo->memfile, G.fileflags); /* success= */ /* UNUSED */ BLO_write_file_mem(CTX_data_main(C), prevfile, &curundo->memfile, G.fileflags);
curundo->undosize= MEM_get_memory_in_use() - memused; curundo->undosize = MEM_get_memory_in_use() - memused;
} }
if (U.undomemory != 0) { if (U.undomemory != 0) {
/* limit to maximum memory (afterwards, we can't know in advance) */ /* limit to maximum memory (afterwards, we can't know in advance) */
totmem= 0; totmem = 0;
maxmem= ((uintptr_t)U.undomemory)*1024*1024; maxmem = ((uintptr_t)U.undomemory) * 1024 * 1024;
/* keep at least two (original + other) */ /* keep at least two (original + other) */
uel= undobase.last; uel = undobase.last;
while (uel && uel->prev) { while (uel && uel->prev) {
totmem+= uel->undosize; totmem += uel->undosize;
if (totmem>maxmem) break; if (totmem > maxmem) break;
uel= uel->prev; uel = uel->prev;
} }
if (uel) { if (uel) {
if (uel->prev && uel->prev->prev) if (uel->prev && uel->prev->prev)
uel= uel->prev; uel = uel->prev;
while (undobase.first!=uel) { while (undobase.first != uel) {
UndoElem *first= undobase.first; UndoElem *first = undobase.first;
BLI_remlink(&undobase, first); BLI_remlink(&undobase, first);
/* the merge is because of compression */ /* the merge is because of compression */
BLO_merge_memfile(&first->memfile, &first->next->memfile); BLO_merge_memfile(&first->memfile, &first->next->memfile);
@ -599,25 +599,25 @@ void BKE_write_undo(bContext *C, const char *name)
void BKE_undo_step(bContext *C, int step) void BKE_undo_step(bContext *C, int step)
{ {
if (step==0) { if (step == 0) {
read_undosave(C, curundo); read_undosave(C, curundo);
} }
else if (step==1) { else if (step == 1) {
/* curundo should never be NULL, after restart or load file it should call undo_save */ /* curundo should never be NULL, after restart or load file it should call undo_save */
if (curundo==NULL || curundo->prev==NULL) ; // XXX error("No undo available"); if (curundo == NULL || curundo->prev == NULL) ; // XXX error("No undo available");
else { else {
if (G.debug & G_DEBUG) printf("undo %s\n", curundo->name); if (G.debug & G_DEBUG) printf("undo %s\n", curundo->name);
curundo= curundo->prev; curundo = curundo->prev;
read_undosave(C, curundo); read_undosave(C, curundo);
} }
} }
else { else {
/* curundo has to remain current situation! */ /* curundo has to remain current situation! */
if (curundo==NULL || curundo->next==NULL) ; // XXX error("No redo available"); if (curundo == NULL || curundo->next == NULL) ; // XXX error("No redo available");
else { else {
read_undosave(C, curundo->next); read_undosave(C, curundo->next);
curundo= curundo->next; curundo = curundo->next;
if (G.debug & G_DEBUG) printf("redo %s\n", curundo->name); if (G.debug & G_DEBUG) printf("redo %s\n", curundo->name);
} }
} }
@ -627,30 +627,30 @@ void BKE_reset_undo(void)
{ {
UndoElem *uel; UndoElem *uel;
uel= undobase.first; uel = undobase.first;
while (uel) { while (uel) {
BLO_free_memfile(&uel->memfile); BLO_free_memfile(&uel->memfile);
uel= uel->next; uel = uel->next;
} }
BLI_freelistN(&undobase); BLI_freelistN(&undobase);
curundo= NULL; curundo = NULL;
} }
/* based on index nr it does a restore */ /* based on index nr it does a restore */
void BKE_undo_number(bContext *C, int nr) void BKE_undo_number(bContext *C, int nr)
{ {
curundo= BLI_findlink(&undobase, nr); curundo = BLI_findlink(&undobase, nr);
BKE_undo_step(C, 0); BKE_undo_step(C, 0);
} }
/* go back to the last occurance of name in stack */ /* go back to the last occurance of name in stack */
void BKE_undo_name(bContext *C, const char *name) void BKE_undo_name(bContext *C, const char *name)
{ {
UndoElem *uel= BLI_rfindstring(&undobase, name, offsetof(UndoElem, name)); UndoElem *uel = BLI_rfindstring(&undobase, name, offsetof(UndoElem, name));
if (uel && uel->prev) { if (uel && uel->prev) {
curundo= uel->prev; curundo = uel->prev;
BKE_undo_step(C, 0); BKE_undo_step(C, 0);
} }
} }
@ -659,7 +659,7 @@ void BKE_undo_name(bContext *C, const char *name)
int BKE_undo_valid(const char *name) int BKE_undo_valid(const char *name)
{ {
if (name) { if (name) {
UndoElem *uel= BLI_rfindstring(&undobase, name, offsetof(UndoElem, name)); UndoElem *uel = BLI_rfindstring(&undobase, name, offsetof(UndoElem, name));
return uel && uel->prev; return uel && uel->prev;
} }
@ -670,13 +670,13 @@ int BKE_undo_valid(const char *name)
/* if active pointer, set it to 1 if true */ /* if active pointer, set it to 1 if true */
const char *BKE_undo_get_name(int nr, int *active) const char *BKE_undo_get_name(int nr, int *active)
{ {
UndoElem *uel= BLI_findlink(&undobase, nr); UndoElem *uel = BLI_findlink(&undobase, nr);
if (active) *active= 0; if (active) *active = 0;
if (uel) { if (uel) {
if (active && uel==curundo) if (active && uel == curundo)
*active= 1; *active = 1;
return uel->name; return uel->name;
} }
return NULL; return NULL;
@ -685,23 +685,23 @@ const char *BKE_undo_get_name(int nr, int *active)
char *BKE_undo_menu_string(void) char *BKE_undo_menu_string(void)
{ {
UndoElem *uel; UndoElem *uel;
DynStr *ds= BLI_dynstr_new(); DynStr *ds = BLI_dynstr_new();
char *menu; char *menu;
BLI_dynstr_append(ds, "Global Undo History %t"); BLI_dynstr_append(ds, "Global Undo History %t");
for (uel= undobase.first; uel; uel= uel->next) { for (uel = undobase.first; uel; uel = uel->next) {
BLI_dynstr_append(ds, "|"); BLI_dynstr_append(ds, "|");
BLI_dynstr_append(ds, uel->name); BLI_dynstr_append(ds, uel->name);
} }
menu= BLI_dynstr_get_cstring(ds); menu = BLI_dynstr_get_cstring(ds);
BLI_dynstr_free(ds); BLI_dynstr_free(ds);
return menu; return menu;
} }
/* saves quit.blend */ /* saves quit.blend */
void BKE_undo_save_quit(void) void BKE_undo_save_quit(void)
{ {
UndoElem *uel; UndoElem *uel;
@ -709,16 +709,16 @@ void BKE_undo_save_quit(void)
int file; int file;
char str[FILE_MAX]; char str[FILE_MAX];
if ( (U.uiflag & USER_GLOBALUNDO)==0) return; if ( (U.uiflag & USER_GLOBALUNDO) == 0) return;
uel= curundo; uel = curundo;
if (uel==NULL) { if (uel == NULL) {
printf("No undo buffer to save recovery file\n"); printf("No undo buffer to save recovery file\n");
return; return;
} }
/* no undo state to save */ /* no undo state to save */
if (undobase.first==undobase.last) return; if (undobase.first == undobase.last) return;
BLI_make_file_string("/", str, BLI_temporary_dir(), "quit.blend"); BLI_make_file_string("/", str, BLI_temporary_dir(), "quit.blend");
@ -728,28 +728,28 @@ void BKE_undo_save_quit(void)
return; return;
} }
chunk= uel->memfile.chunks.first; chunk = uel->memfile.chunks.first;
while (chunk) { while (chunk) {
if ( write(file, chunk->buf, chunk->size) != chunk->size) break; if (write(file, chunk->buf, chunk->size) != chunk->size) break;
chunk= chunk->next; chunk = chunk->next;
} }
close(file); close(file);
if (chunk) ; //XXX error("Unable to save %s, internal error", str); if (chunk) ; //XXX error("Unable to save %s, internal error", str);
else printf("Saved session recovery to %s\n", str); else printf("Saved session recovery to %s\n", str);
} }
/* sets curscene */ /* sets curscene */
Main *BKE_undo_get_main(Scene **scene) Main *BKE_undo_get_main(Scene **scene)
{ {
Main *mainp= NULL; Main *mainp = NULL;
BlendFileData *bfd= BLO_read_from_memfile(G.main, G.main->name, &curundo->memfile, NULL); BlendFileData *bfd = BLO_read_from_memfile(G.main, G.main->name, &curundo->memfile, NULL);
if (bfd) { if (bfd) {
mainp= bfd->main; mainp = bfd->main;
if (scene) if (scene)
*scene= bfd->curscene; *scene = bfd->curscene;
MEM_freeN(bfd); MEM_freeN(bfd);
} }

@ -101,11 +101,11 @@ float nearest_point_in_tri_surface(const float v0[3], const float v1[3], const f
sub_v3_v3v3(e1, v2, v0); sub_v3_v3v3(e1, v2, v0);
A00 = dot_v3v3(e0, e0); A00 = dot_v3v3(e0, e0);
A01 = dot_v3v3(e0, e1 ); A01 = dot_v3v3(e0, e1);
A11 = dot_v3v3(e1, e1 ); A11 = dot_v3v3(e1, e1);
B0 = dot_v3v3(diff, e0 ); B0 = dot_v3v3(diff, e0);
B1 = dot_v3v3(diff, e1 ); B1 = dot_v3v3(diff, e1);
C = dot_v3v3(diff, diff ); C = dot_v3v3(diff, diff);
Det = fabs(A00 * A11 - A01 * A01); Det = fabs(A00 * A11 - A01 * A01);
S = A01 * B1 - A11 * B0; S = A01 * B1 - A11 * B0;
T = A01 * B0 - A00 * B1; T = A01 * B0 - A00 * B1;
@ -122,7 +122,7 @@ float nearest_point_in_tri_surface(const float v0[3], const float v1[3], const f
} }
else { else {
if (fabsf(A00) > FLT_EPSILON) if (fabsf(A00) > FLT_EPSILON)
S = -B0/A00; S = -B0 / A00;
else else
S = 0.0f; S = 0.0f;
sqrDist = B0 * S + C; sqrDist = B0 * S + C;
@ -195,7 +195,7 @@ float nearest_point_in_tri_surface(const float v0[3], const float v1[3], const f
} }
} }
else { /* Region 0 */ else { /* Region 0 */
// Minimum at interior lv /* Minimum at interior lv */
float invDet; float invDet;
if (fabsf(Det) > FLT_EPSILON) if (fabsf(Det) > FLT_EPSILON)
invDet = 1.0f / Det; invDet = 1.0f / Det;
@ -203,8 +203,8 @@ float nearest_point_in_tri_surface(const float v0[3], const float v1[3], const f
invDet = 0.0f; invDet = 0.0f;
S *= invDet; S *= invDet;
T *= invDet; T *= invDet;
sqrDist = S * ( A00 * S + A01 * T + 2.0f * B0) + sqrDist = S * (A00 * S + A01 * T + 2.0f * B0) +
T * ( A01 * S + A11 * T + 2.0f * B1 ) + C; T * (A01 * S + A11 * T + 2.0f * B1) + C;
} }
} }
else { else {
@ -213,10 +213,10 @@ float nearest_point_in_tri_surface(const float v0[3], const float v1[3], const f
if (S < 0.0f) { /* Region 2 */ if (S < 0.0f) { /* Region 2 */
tmp0 = A01 + B0; tmp0 = A01 + B0;
tmp1 = A11 + B1; tmp1 = A11 + B1;
if ( tmp1 > tmp0 ) { if (tmp1 > tmp0) {
numer = tmp1 - tmp0; numer = tmp1 - tmp0;
denom = A00 - 2.0f * A01 + A11; denom = A00 - 2.0f * A01 + A11;
if ( numer >= denom ) { if (numer >= denom) {
S = 1.0f; S = 1.0f;
T = 0.0f; T = 0.0f;
sqrDist = A00 + 2.0f * B0 + C; sqrDist = A00 + 2.0f * B0 + C;
@ -228,14 +228,14 @@ float nearest_point_in_tri_surface(const float v0[3], const float v1[3], const f
else else
S = 0.0f; S = 0.0f;
T = 1.0f - S; T = 1.0f - S;
sqrDist = S * ( A00 * S + A01 * T + 2.0f * B0 ) + sqrDist = S * (A00 * S + A01 * T + 2.0f * B0) +
T * ( A01 * S + A11 * T + 2.0f * B1 ) + C; T * (A01 * S + A11 * T + 2.0f * B1) + C;
le = 2; le = 2;
} }
} }
else { else {
S = 0.0f; S = 0.0f;
if ( tmp1 <= 0.0f ) { if (tmp1 <= 0.0f) {
T = 1.0f; T = 1.0f;
sqrDist = A11 + 2.0f * B1 + C; sqrDist = A11 + 2.0f * B1 + C;
lv = 2; lv = 2;
@ -258,10 +258,10 @@ float nearest_point_in_tri_surface(const float v0[3], const float v1[3], const f
else if (T < 0.0f) { /* Region 6 */ else if (T < 0.0f) { /* Region 6 */
tmp0 = A01 + B1; tmp0 = A01 + B1;
tmp1 = A00 + B0; tmp1 = A00 + B0;
if ( tmp1 > tmp0 ) { if (tmp1 > tmp0) {
numer = tmp1 - tmp0; numer = tmp1 - tmp0;
denom = A00 - 2.0f * A01 + A11; denom = A00 - 2.0f * A01 + A11;
if ( numer >= denom ) { if (numer >= denom) {
T = 1.0f; T = 1.0f;
S = 0.0f; S = 0.0f;
sqrDist = A11 + 2.0f * B1 + C; sqrDist = A11 + 2.0f * B1 + C;
@ -273,8 +273,8 @@ float nearest_point_in_tri_surface(const float v0[3], const float v1[3], const f
else else
T = 0.0f; T = 0.0f;
S = 1.0f - T; S = 1.0f - T;
sqrDist = S * ( A00 * S + A01 * T + 2.0f * B0 ) + sqrDist = S * (A00 * S + A01 * T + 2.0f * B0) +
T * ( A01 * S + A11 * T + 2.0f * B1 ) + C; T * (A01 * S + A11 * T + 2.0f * B1) + C;
le = 2; le = 2;
} }
} }
@ -302,7 +302,7 @@ float nearest_point_in_tri_surface(const float v0[3], const float v1[3], const f
} }
else { /* Region 1 */ else { /* Region 1 */
numer = A11 + B1 - A01 - B0; numer = A11 + B1 - A01 - B0;
if ( numer <= 0.0f ) { if (numer <= 0.0f) {
S = 0.0f; S = 0.0f;
T = 1.0f; T = 1.0f;
sqrDist = A11 + 2.0f * B1 + C; sqrDist = A11 + 2.0f * B1 + C;
@ -310,7 +310,7 @@ float nearest_point_in_tri_surface(const float v0[3], const float v1[3], const f
} }
else { else {
denom = A00 - 2.0f * A01 + A11; denom = A00 - 2.0f * A01 + A11;
if ( numer >= denom ) { if (numer >= denom) {
S = 1.0f; S = 1.0f;
T = 0.0f; T = 0.0f;
sqrDist = A00 + 2.0f * B0 + C; sqrDist = A00 + 2.0f * B0 + C;
@ -322,8 +322,8 @@ float nearest_point_in_tri_surface(const float v0[3], const float v1[3], const f
else else
S = 0.0f; S = 0.0f;
T = 1.0f - S; T = 1.0f - S;
sqrDist = S * ( A00 * S + A01 * T + 2.0f * B0 ) + sqrDist = S * (A00 * S + A01 * T + 2.0f * B0) +
T * ( A01 * S + A11 * T + 2.0f * B1 ) + C; T * (A01 * S + A11 * T + 2.0f * B1) + C;
le = 2; le = 2;
} }
} }
@ -331,7 +331,7 @@ float nearest_point_in_tri_surface(const float v0[3], const float v1[3], const f
} }
// Account for numerical round-off error // Account for numerical round-off error
if ( sqrDist < FLT_EPSILON ) if (sqrDist < FLT_EPSILON)
sqrDist = 0.0f; sqrDist = 0.0f;
{ {
@ -362,19 +362,18 @@ float nearest_point_in_tri_surface(const float v0[3], const float v1[3], const f
// userdata must be a BVHMeshCallbackUserdata built from the same mesh as the tree. // userdata must be a BVHMeshCallbackUserdata built from the same mesh as the tree.
static void mesh_faces_nearest_point(void *userdata, int index, const float co[3], BVHTreeNearest *nearest) static void mesh_faces_nearest_point(void *userdata, int index, const float co[3], BVHTreeNearest *nearest)
{ {
const BVHTreeFromMesh *data = (BVHTreeFromMesh*) userdata; const BVHTreeFromMesh *data = (BVHTreeFromMesh *) userdata;
MVert *vert = data->vert; MVert *vert = data->vert;
MFace *face = data->face + index; MFace *face = data->face + index;
float *t0, *t1, *t2, *t3; float *t0, *t1, *t2, *t3;
t0 = vert[ face->v1 ].co; t0 = vert[face->v1].co;
t1 = vert[ face->v2 ].co; t1 = vert[face->v2].co;
t2 = vert[ face->v3 ].co; t2 = vert[face->v3].co;
t3 = face->v4 ? vert[ face->v4].co : NULL; t3 = face->v4 ? vert[face->v4].co : NULL;
do do {
{
float nearest_tmp[3], dist; float nearest_tmp[3], dist;
int vertex, edge; int vertex, edge;
@ -397,8 +396,8 @@ static void mesh_faces_nearest_point(void *userdata, int index, const float co[3
// userdata must be a BVHMeshCallbackUserdata built from the same mesh as the tree. // userdata must be a BVHMeshCallbackUserdata built from the same mesh as the tree.
static void mesh_faces_spherecast(void *userdata, int index, const BVHTreeRay *ray, BVHTreeRayHit *hit) static void mesh_faces_spherecast(void *userdata, int index, const BVHTreeRay *ray, BVHTreeRayHit *hit)
{ {
const BVHTreeFromMesh *data = (BVHTreeFromMesh*) userdata; const BVHTreeFromMesh *data = (BVHTreeFromMesh *) userdata;
MVert *vert = data->vert; MVert *vert = data->vert;
MFace *face = data->face + index; MFace *face = data->face + index;
float *t0, *t1, *t2, *t3; float *t0, *t1, *t2, *t3;
@ -408,8 +407,7 @@ static void mesh_faces_spherecast(void *userdata, int index, const BVHTreeRay *r
t3 = face->v4 ? vert[face->v4].co : NULL; t3 = face->v4 ? vert[face->v4].co : NULL;
do do {
{
float dist; float dist;
if (data->sphere_radius == 0.0f) if (data->sphere_radius == 0.0f)
dist = bvhtree_ray_tri_intersection(ray, hit->dist, t0, t1, t2); dist = bvhtree_ray_tri_intersection(ray, hit->dist, t0, t1, t2);
@ -435,14 +433,14 @@ static void mesh_faces_spherecast(void *userdata, int index, const BVHTreeRay *r
// userdata must be a BVHMeshCallbackUserdata built from the same mesh as the tree. // userdata must be a BVHMeshCallbackUserdata built from the same mesh as the tree.
static void mesh_edges_nearest_point(void *userdata, int index, const float co[3], BVHTreeNearest *nearest) static void mesh_edges_nearest_point(void *userdata, int index, const float co[3], BVHTreeNearest *nearest)
{ {
const BVHTreeFromMesh *data = (BVHTreeFromMesh*) userdata; const BVHTreeFromMesh *data = (BVHTreeFromMesh *) userdata;
MVert *vert = data->vert; MVert *vert = data->vert;
MEdge *edge = data->edge + index; MEdge *edge = data->edge + index;
float nearest_tmp[3], dist; float nearest_tmp[3], dist;
float *t0, *t1; float *t0, *t1;
t0 = vert[ edge->v1 ].co; t0 = vert[edge->v1].co;
t1 = vert[ edge->v2 ].co; t1 = vert[edge->v2].co;
closest_to_line_segment_v3(nearest_tmp, co, t0, t1); closest_to_line_segment_v3(nearest_tmp, co, t0, t1);
dist = len_squared_v3v3(nearest_tmp, co); dist = len_squared_v3v3(nearest_tmp, co);
@ -460,15 +458,15 @@ static void mesh_edges_nearest_point(void *userdata, int index, const float co[3
* BVH builders * BVH builders
*/ */
// Builds a bvh tree.. where nodes are the vertexs of the given mesh // Builds a bvh tree.. where nodes are the vertexs of the given mesh
BVHTree* bvhtree_from_mesh_verts(BVHTreeFromMesh *data, DerivedMesh *mesh, float epsilon, int tree_type, int axis) BVHTree *bvhtree_from_mesh_verts(BVHTreeFromMesh *data, DerivedMesh *mesh, float epsilon, int tree_type, int axis)
{ {
BVHTree *tree = bvhcache_find(&mesh->bvhCache, BVHTREE_FROM_VERTICES); BVHTree *tree = bvhcache_find(&mesh->bvhCache, BVHTREE_FROM_VERTICES);
//Not in cache //Not in cache
if (tree == NULL) { if (tree == NULL) {
int i; int i;
int numVerts= mesh->getNumVerts(mesh); int numVerts = mesh->getNumVerts(mesh);
MVert *vert = mesh->getVertDataArray(mesh, CD_MVERT); MVert *vert = mesh->getVertDataArray(mesh, CD_MVERT);
if (vert != NULL) { if (vert != NULL) {
tree = BLI_bvhtree_new(numVerts, epsilon, tree_type, axis); tree = BLI_bvhtree_new(numVerts, epsilon, tree_type, axis);
@ -514,14 +512,14 @@ BVHTree* bvhtree_from_mesh_verts(BVHTreeFromMesh *data, DerivedMesh *mesh, float
} }
// Builds a bvh tree.. where nodes are the faces of the given mesh. // Builds a bvh tree.. where nodes are the faces of the given mesh.
BVHTree* bvhtree_from_mesh_faces(BVHTreeFromMesh *data, DerivedMesh *mesh, float epsilon, int tree_type, int axis) BVHTree *bvhtree_from_mesh_faces(BVHTreeFromMesh *data, DerivedMesh *mesh, float epsilon, int tree_type, int axis)
{ {
BVHTree *tree = bvhcache_find(&mesh->bvhCache, BVHTREE_FROM_FACES); BVHTree *tree = bvhcache_find(&mesh->bvhCache, BVHTREE_FROM_FACES);
//Not in cache //Not in cache
if (tree == NULL) { if (tree == NULL) {
int i; int i;
int numFaces= mesh->getNumTessFaces(mesh); int numFaces = mesh->getNumTessFaces(mesh);
/* BMESH specific check that we have tessfaces, /* BMESH specific check that we have tessfaces,
* we _could_ tessellate here but rather not - campbell * we _could_ tessellate here but rather not - campbell
@ -534,7 +532,7 @@ BVHTree* bvhtree_from_mesh_faces(BVHTreeFromMesh *data, DerivedMesh *mesh, float
/* Create a bvh-tree of the given target */ /* Create a bvh-tree of the given target */
tree = BLI_bvhtree_new(numFaces, epsilon, tree_type, axis); tree = BLI_bvhtree_new(numFaces, epsilon, tree_type, axis);
if (tree != NULL) { if (tree != NULL) {
BMEditMesh *em= data->em_evil; BMEditMesh *em = data->em_evil;
if (em) { if (em) {
/* data->em_evil is only set for snapping, and only for the mesh of the object /* data->em_evil is only set for snapping, and only for the mesh of the object
* which is currently open in edit mode. When set, the bvhtree should not contain * which is currently open in edit mode. When set, the bvhtree should not contain
@ -594,17 +592,17 @@ BVHTree* bvhtree_from_mesh_faces(BVHTreeFromMesh *data, DerivedMesh *mesh, float
} }
} }
else { else {
MVert *vert = mesh->getVertDataArray(mesh, CD_MVERT); MVert *vert = mesh->getVertDataArray(mesh, CD_MVERT);
MFace *face = mesh->getTessFaceDataArray(mesh, CD_MFACE); MFace *face = mesh->getTessFaceDataArray(mesh, CD_MFACE);
if (vert != NULL && face != NULL) { if (vert != NULL && face != NULL) {
for (i = 0; i < numFaces; i++) { for (i = 0; i < numFaces; i++) {
float co[4][3]; float co[4][3];
copy_v3_v3(co[0], vert[ face[i].v1 ].co); copy_v3_v3(co[0], vert[face[i].v1].co);
copy_v3_v3(co[1], vert[ face[i].v2 ].co); copy_v3_v3(co[1], vert[face[i].v2].co);
copy_v3_v3(co[2], vert[ face[i].v3 ].co); copy_v3_v3(co[2], vert[face[i].v3].co);
if (face[i].v4) if (face[i].v4)
copy_v3_v3(co[3], vert[ face[i].v4 ].co); copy_v3_v3(co[3], vert[face[i].v4].co);
BLI_bvhtree_insert(tree, i, co[0], face[i].v4 ? 4 : 3); BLI_bvhtree_insert(tree, i, co[0], face[i].v4 ? 4 : 3);
} }
@ -644,15 +642,15 @@ BVHTree* bvhtree_from_mesh_faces(BVHTreeFromMesh *data, DerivedMesh *mesh, float
} }
// Builds a bvh tree.. where nodes are the faces of the given mesh. // Builds a bvh tree.. where nodes are the faces of the given mesh.
BVHTree* bvhtree_from_mesh_edges(BVHTreeFromMesh *data, DerivedMesh *mesh, float epsilon, int tree_type, int axis) BVHTree *bvhtree_from_mesh_edges(BVHTreeFromMesh *data, DerivedMesh *mesh, float epsilon, int tree_type, int axis)
{ {
BVHTree *tree = bvhcache_find(&mesh->bvhCache, BVHTREE_FROM_EDGES); BVHTree *tree = bvhcache_find(&mesh->bvhCache, BVHTREE_FROM_EDGES);
//Not in cache //Not in cache
if (tree == NULL) { if (tree == NULL) {
int i; int i;
int numEdges= mesh->getNumEdges(mesh); int numEdges = mesh->getNumEdges(mesh);
MVert *vert = mesh->getVertDataArray(mesh, CD_MVERT); MVert *vert = mesh->getVertDataArray(mesh, CD_MVERT);
MEdge *edge = mesh->getEdgeDataArray(mesh, CD_MEDGE); MEdge *edge = mesh->getEdgeDataArray(mesh, CD_MEDGE);
if (vert != NULL && edge != NULL) { if (vert != NULL && edge != NULL) {
@ -661,8 +659,8 @@ BVHTree* bvhtree_from_mesh_edges(BVHTreeFromMesh *data, DerivedMesh *mesh, float
if (tree != NULL) { if (tree != NULL) {
for (i = 0; i < numEdges; i++) { for (i = 0; i < numEdges; i++) {
float co[4][3]; float co[4][3];
copy_v3_v3(co[0], vert[ edge[i].v1 ].co); copy_v3_v3(co[0], vert[edge[i].v1].co);
copy_v3_v3(co[1], vert[ edge[i].v2 ].co); copy_v3_v3(co[1], vert[edge[i].v2].co);
BLI_bvhtree_insert(tree, i, co[0], 2); BLI_bvhtree_insert(tree, i, co[0], 2);
} }
@ -712,8 +710,7 @@ void free_bvhtree_from_mesh(struct BVHTreeFromMesh *data)
/* BVHCache */ /* BVHCache */
typedef struct BVHCacheItem typedef struct BVHCacheItem {
{
int type; int type;
BVHTree *tree; BVHTree *tree;
@ -721,8 +718,8 @@ typedef struct BVHCacheItem
static void bvhcacheitem_set_if_match(void *_cached, void *_search) static void bvhcacheitem_set_if_match(void *_cached, void *_search)
{ {
BVHCacheItem * cached = (BVHCacheItem *)_cached; BVHCacheItem *cached = (BVHCacheItem *)_cached;
BVHCacheItem * search = (BVHCacheItem *)_search; BVHCacheItem *search = (BVHCacheItem *)_search;
if (search->type == cached->type) { if (search->type == cached->type) {
search->tree = cached->tree; search->tree = cached->tree;

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

@ -92,14 +92,14 @@ bContext *CTX_create(void)
{ {
bContext *C; bContext *C;
C= MEM_callocN(sizeof(bContext), "bContext"); C = MEM_callocN(sizeof(bContext), "bContext");
return C; return C;
} }
bContext *CTX_copy(const bContext *C) bContext *CTX_copy(const bContext *C)
{ {
bContext *newC= MEM_dupallocN((void*)C); bContext *newC = MEM_dupallocN((void *)C);
return newC; return newC;
} }
@ -118,23 +118,23 @@ bContextStore *CTX_store_add(ListBase *contexts, const char *name, PointerRNA *p
/* ensure we have a context to put the entry in, if it was already used /* ensure we have a context to put the entry in, if it was already used
* we have to copy the context to ensure */ * we have to copy the context to ensure */
ctx= contexts->last; ctx = contexts->last;
if (!ctx || ctx->used) { if (!ctx || ctx->used) {
if (ctx) { if (ctx) {
lastctx= ctx; lastctx = ctx;
ctx= MEM_dupallocN(lastctx); ctx = MEM_dupallocN(lastctx);
BLI_duplicatelist(&ctx->entries, &lastctx->entries); BLI_duplicatelist(&ctx->entries, &lastctx->entries);
} }
else else
ctx= MEM_callocN(sizeof(bContextStore), "bContextStore"); ctx = MEM_callocN(sizeof(bContextStore), "bContextStore");
BLI_addtail(contexts, ctx); BLI_addtail(contexts, ctx);
} }
entry= MEM_callocN(sizeof(bContextStoreEntry), "bContextStoreEntry"); entry = MEM_callocN(sizeof(bContextStoreEntry), "bContextStoreEntry");
BLI_strncpy(entry->name, name, sizeof(entry->name)); BLI_strncpy(entry->name, name, sizeof(entry->name));
entry->ptr= *ptr; entry->ptr = *ptr;
BLI_addtail(&ctx->entries, entry); BLI_addtail(&ctx->entries, entry);
@ -148,22 +148,22 @@ bContextStore *CTX_store_add_all(ListBase *contexts, bContextStore *context)
/* ensure we have a context to put the entries in, if it was already used /* ensure we have a context to put the entries in, if it was already used
* we have to copy the context to ensure */ * we have to copy the context to ensure */
ctx= contexts->last; ctx = contexts->last;
if (!ctx || ctx->used) { if (!ctx || ctx->used) {
if (ctx) { if (ctx) {
lastctx= ctx; lastctx = ctx;
ctx= MEM_dupallocN(lastctx); ctx = MEM_dupallocN(lastctx);
BLI_duplicatelist(&ctx->entries, &lastctx->entries); BLI_duplicatelist(&ctx->entries, &lastctx->entries);
} }
else else
ctx= MEM_callocN(sizeof(bContextStore), "bContextStore"); ctx = MEM_callocN(sizeof(bContextStore), "bContextStore");
BLI_addtail(contexts, ctx); BLI_addtail(contexts, ctx);
} }
for (tentry= context->entries.first; tentry; tentry= tentry->next) { for (tentry = context->entries.first; tentry; tentry = tentry->next) {
entry= MEM_dupallocN(tentry); entry = MEM_dupallocN(tentry);
BLI_addtail(&ctx->entries, entry); BLI_addtail(&ctx->entries, entry);
} }
@ -172,14 +172,14 @@ bContextStore *CTX_store_add_all(ListBase *contexts, bContextStore *context)
void CTX_store_set(bContext *C, bContextStore *store) void CTX_store_set(bContext *C, bContextStore *store)
{ {
C->wm.store= store; C->wm.store = store;
} }
bContextStore *CTX_store_copy(bContextStore *store) bContextStore *CTX_store_copy(bContextStore *store)
{ {
bContextStore *ctx; bContextStore *ctx;
ctx= MEM_dupallocN(store); ctx = MEM_dupallocN(store);
BLI_duplicatelist(&ctx->entries, &store->entries); BLI_duplicatelist(&ctx->entries, &store->entries);
return ctx; return ctx;
@ -195,7 +195,7 @@ void CTX_store_free_list(ListBase *contexts)
{ {
bContextStore *ctx; bContextStore *ctx;
while ((ctx= contexts->first)) { while ((ctx = contexts->first)) {
BLI_remlink(contexts, ctx); BLI_remlink(contexts, ctx);
CTX_store_free(ctx); CTX_store_free(ctx);
} }
@ -209,7 +209,7 @@ int CTX_py_init_get(bContext *C)
} }
void CTX_py_init_set(bContext *C, int value) void CTX_py_init_set(bContext *C, int value)
{ {
C->data.py_init= value; C->data.py_init = value;
} }
void *CTX_py_dict_get(const bContext *C) void *CTX_py_dict_get(const bContext *C)
@ -218,7 +218,7 @@ void *CTX_py_dict_get(const bContext *C)
} }
void CTX_py_dict_set(bContext *C, void *value) void CTX_py_dict_set(bContext *C, void *value)
{ {
C->data.py_context= value; C->data.py_context = value;
} }
/* data context utility functions */ /* data context utility functions */
@ -237,8 +237,8 @@ static void *ctx_wm_python_context_get(const bContext *C, const char *member, vo
if (C && CTX_py_dict_get(C)) { if (C && CTX_py_dict_get(C)) {
memset(&result, 0, sizeof(bContextDataResult)); memset(&result, 0, sizeof(bContextDataResult));
BPY_context_member_get((bContext*)C, member, &result); BPY_context_member_get((bContext *)C, member, &result);
if(result.ptr.data) if (result.ptr.data)
return result.ptr.data; return result.ptr.data;
} }
#endif #endif
@ -251,8 +251,8 @@ static int ctx_data_get(bContext *C, const char *member, bContextDataResult *res
bScreen *sc; bScreen *sc;
ScrArea *sa; ScrArea *sa;
ARegion *ar; ARegion *ar;
int done= 0, recursion= C->data.recursion; int done = 0, recursion = C->data.recursion;
int ret= 0; int ret = 0;
memset(result, 0, sizeof(bContextDataResult)); memset(result, 0, sizeof(bContextDataResult));
#ifdef WITH_PYTHON #ifdef WITH_PYTHON
@ -271,42 +271,42 @@ static int ctx_data_get(bContext *C, const char *member, bContextDataResult *res
* Values in order of importance * Values in order of importance
* (0, -1, 1) - Where 1 is highest priority * (0, -1, 1) - Where 1 is highest priority
* */ * */
if (done!=1 && recursion < 1 && C->wm.store) { if (done != 1 && recursion < 1 && C->wm.store) {
bContextStoreEntry *entry; bContextStoreEntry *entry;
C->data.recursion= 1; C->data.recursion = 1;
entry= BLI_rfindstring(&C->wm.store->entries, member, offsetof(bContextStoreEntry, name)); entry = BLI_rfindstring(&C->wm.store->entries, member, offsetof(bContextStoreEntry, name));
if (entry) { if (entry) {
result->ptr= entry->ptr; result->ptr = entry->ptr;
done= 1; done = 1;
} }
} }
if (done!=1 && recursion < 2 && (ar=CTX_wm_region(C))) { if (done != 1 && recursion < 2 && (ar = CTX_wm_region(C))) {
C->data.recursion= 2; C->data.recursion = 2;
if (ar->type && ar->type->context) { if (ar->type && ar->type->context) {
ret = ar->type->context(C, member, result); ret = ar->type->context(C, member, result);
if (ret) done= -(-ret | -done); if (ret) done = -(-ret | -done);
} }
} }
if (done!=1 && recursion < 3 && (sa=CTX_wm_area(C))) { if (done != 1 && recursion < 3 && (sa = CTX_wm_area(C))) {
C->data.recursion= 3; C->data.recursion = 3;
if (sa->type && sa->type->context) { if (sa->type && sa->type->context) {
ret = sa->type->context(C, member, result); ret = sa->type->context(C, member, result);
if (ret) done= -(-ret | -done); if (ret) done = -(-ret | -done);
} }
} }
if (done!=1 && recursion < 4 && (sc=CTX_wm_screen(C))) { if (done != 1 && recursion < 4 && (sc = CTX_wm_screen(C))) {
bContextDataCallback cb= sc->context; bContextDataCallback cb = sc->context;
C->data.recursion= 4; C->data.recursion = 4;
if (cb) { if (cb) {
ret = cb(C, member, result); ret = cb(C, member, result);
if (ret) done= -(-ret | -done); if (ret) done = -(-ret | -done);
} }
} }
C->data.recursion= recursion; C->data.recursion = recursion;
return done; return done;
} }
@ -315,7 +315,7 @@ static void *ctx_data_pointer_get(const bContext *C, const char *member)
{ {
bContextDataResult result; bContextDataResult result;
if (C && ctx_data_get((bContext*)C, member, &result)==1) if (C && ctx_data_get((bContext *)C, member, &result) == 1)
return result.ptr.data; return result.ptr.data;
return NULL; return NULL;
@ -327,15 +327,15 @@ static int ctx_data_pointer_verify(const bContext *C, const char *member, void *
/* if context is NULL, pointer must be NULL too and that is a valid return */ /* if context is NULL, pointer must be NULL too and that is a valid return */
if (C == NULL) { if (C == NULL) {
*pointer= NULL; *pointer = NULL;
return 1; return 1;
} }
else if (ctx_data_get((bContext*)C, member, &result)==1) { else if (ctx_data_get((bContext *)C, member, &result) == 1) {
*pointer= result.ptr.data; *pointer = result.ptr.data;
return 1; return 1;
} }
else { else {
*pointer= NULL; *pointer = NULL;
return 0; return 0;
} }
} }
@ -344,13 +344,13 @@ static int ctx_data_collection_get(const bContext *C, const char *member, ListBa
{ {
bContextDataResult result; bContextDataResult result;
if (ctx_data_get((bContext*)C, member, &result)==1) { if (ctx_data_get((bContext *)C, member, &result) == 1) {
*list= result.list; *list = result.list;
return 1; return 1;
} }
list->first= NULL; list->first = NULL;
list->last= NULL; list->last = NULL;
return 0; return 0;
} }
@ -359,7 +359,7 @@ PointerRNA CTX_data_pointer_get(const bContext *C, const char *member)
{ {
bContextDataResult result; bContextDataResult result;
if (ctx_data_get((bContext*)C, member, &result)==1) if (ctx_data_get((bContext *)C, member, &result) == 1)
return result.ptr; return result.ptr;
else else
return PointerRNA_NULL; return PointerRNA_NULL;
@ -379,11 +379,11 @@ ListBase CTX_data_collection_get(const bContext *C, const char *member)
{ {
bContextDataResult result; bContextDataResult result;
if (ctx_data_get((bContext*)C, member, &result)==1) { if (ctx_data_get((bContext *)C, member, &result) == 1) {
return result.list; return result.list;
} }
else { else {
ListBase list= {NULL, NULL}; ListBase list = {NULL, NULL};
return list; return list;
} }
} }
@ -392,17 +392,17 @@ ListBase CTX_data_collection_get(const bContext *C, const char *member)
int CTX_data_get(const bContext *C, const char *member, PointerRNA *r_ptr, ListBase *r_lb, short *r_type) int CTX_data_get(const bContext *C, const char *member, PointerRNA *r_ptr, ListBase *r_lb, short *r_type)
{ {
bContextDataResult result; bContextDataResult result;
int ret= ctx_data_get((bContext*)C, member, &result); int ret = ctx_data_get((bContext *)C, member, &result);
if (ret==1) { if (ret == 1) {
*r_ptr= result.ptr; *r_ptr = result.ptr;
*r_lb= result.list; *r_lb = result.list;
*r_type= result.type; *r_type = result.type;
} }
else { else {
memset(r_ptr, 0, sizeof(*r_ptr)); memset(r_ptr, 0, sizeof(*r_ptr));
memset(r_lb, 0, sizeof(*r_lb)); memset(r_lb, 0, sizeof(*r_lb));
*r_type= 0; *r_type = 0;
} }
return ret; return ret;
@ -418,8 +418,8 @@ static void data_dir_add(ListBase *lb, const char *member)
if (BLI_findstring(lb, member, offsetof(LinkData, data))) if (BLI_findstring(lb, member, offsetof(LinkData, data)))
return; return;
link= MEM_callocN(sizeof(LinkData), "LinkData"); link = MEM_callocN(sizeof(LinkData), "LinkData");
link->data= (void*)member; link->data = (void *)member;
BLI_addtail(lb, link); BLI_addtail(lb, link);
} }
@ -437,32 +437,32 @@ ListBase CTX_data_dir_get(const bContext *C)
if (C->wm.store) { if (C->wm.store) {
bContextStoreEntry *entry; bContextStoreEntry *entry;
for (entry=C->wm.store->entries.first; entry; entry=entry->next) for (entry = C->wm.store->entries.first; entry; entry = entry->next)
data_dir_add(&lb, entry->name); data_dir_add(&lb, entry->name);
} }
if ((ar=CTX_wm_region(C)) && ar->type && ar->type->context) { if ((ar = CTX_wm_region(C)) && ar->type && ar->type->context) {
memset(&result, 0, sizeof(result)); memset(&result, 0, sizeof(result));
ar->type->context(C, "", &result); ar->type->context(C, "", &result);
if (result.dir) if (result.dir)
for (a=0; result.dir[a]; a++) for (a = 0; result.dir[a]; a++)
data_dir_add(&lb, result.dir[a]); data_dir_add(&lb, result.dir[a]);
} }
if ((sa=CTX_wm_area(C)) && sa->type && sa->type->context) { if ((sa = CTX_wm_area(C)) && sa->type && sa->type->context) {
memset(&result, 0, sizeof(result)); memset(&result, 0, sizeof(result));
sa->type->context(C, "", &result); sa->type->context(C, "", &result);
if (result.dir) if (result.dir)
for (a=0; result.dir[a]; a++) for (a = 0; result.dir[a]; a++)
data_dir_add(&lb, result.dir[a]); data_dir_add(&lb, result.dir[a]);
} }
if ((sc=CTX_wm_screen(C)) && sc->context) { if ((sc = CTX_wm_screen(C)) && sc->context) {
bContextDataCallback cb= sc->context; bContextDataCallback cb = sc->context;
memset(&result, 0, sizeof(result)); memset(&result, 0, sizeof(result));
cb(C, "", &result); cb(C, "", &result);
if (result.dir) if (result.dir)
for (a=0; result.dir[a]; a++) for (a = 0; result.dir[a]; a++)
data_dir_add(&lb, result.dir[a]); data_dir_add(&lb, result.dir[a]);
} }
@ -493,7 +493,7 @@ void CTX_data_id_list_add(bContextDataResult *result, ID *id)
{ {
CollectionPointerLink *link; CollectionPointerLink *link;
link= MEM_callocN(sizeof(CollectionPointerLink), "CTX_data_id_list_add"); link = MEM_callocN(sizeof(CollectionPointerLink), "CTX_data_id_list_add");
RNA_id_pointer_create(id, &link->ptr); RNA_id_pointer_create(id, &link->ptr);
BLI_addtail(&result->list, link); BLI_addtail(&result->list, link);
@ -503,18 +503,18 @@ void CTX_data_list_add(bContextDataResult *result, ID *id, StructRNA *type, void
{ {
CollectionPointerLink *link; CollectionPointerLink *link;
link= MEM_callocN(sizeof(CollectionPointerLink), "CTX_data_list_add"); link = MEM_callocN(sizeof(CollectionPointerLink), "CTX_data_list_add");
RNA_pointer_create(id, type, data, &link->ptr); RNA_pointer_create(id, type, data, &link->ptr);
BLI_addtail(&result->list, link); BLI_addtail(&result->list, link);
} }
int ctx_data_list_count(const bContext *C, int (*func)(const bContext*, ListBase*)) int ctx_data_list_count(const bContext *C, int (*func)(const bContext *, ListBase *))
{ {
ListBase list; ListBase list;
if (func(C, &list)) { if (func(C, &list)) {
int tot= BLI_countlist(&list); int tot = BLI_countlist(&list);
BLI_freelistN(&list); BLI_freelistN(&list);
return tot; return tot;
} }
@ -524,12 +524,12 @@ int ctx_data_list_count(const bContext *C, int (*func)(const bContext*, ListBase
void CTX_data_dir_set(bContextDataResult *result, const char **dir) void CTX_data_dir_set(bContextDataResult *result, const char **dir)
{ {
result->dir= dir; result->dir = dir;
} }
void CTX_data_type_set(bContextDataResult *result, short type) void CTX_data_type_set(bContextDataResult *result, short type)
{ {
result->type= type; result->type = type;
} }
short CTX_data_type_get(bContextDataResult *result) short CTX_data_type_get(bContextDataResult *result)
@ -564,7 +564,7 @@ ScrArea *CTX_wm_area(const bContext *C)
SpaceLink *CTX_wm_space_data(const bContext *C) SpaceLink *CTX_wm_space_data(const bContext *C)
{ {
ScrArea *sa = CTX_wm_area(C); ScrArea *sa = CTX_wm_area(C);
return (sa)? sa->spacedata.first: NULL; return (sa) ? sa->spacedata.first : NULL;
} }
ARegion *CTX_wm_region(const bContext *C) ARegion *CTX_wm_region(const bContext *C)
@ -575,7 +575,7 @@ ARegion *CTX_wm_region(const bContext *C)
void *CTX_wm_region_data(const bContext *C) void *CTX_wm_region_data(const bContext *C)
{ {
ARegion *ar = CTX_wm_region(C); ARegion *ar = CTX_wm_region(C);
return (ar)? ar->regiondata: NULL; return (ar) ? ar->regiondata : NULL;
} }
struct ARegion *CTX_wm_menu(const bContext *C) struct ARegion *CTX_wm_menu(const bContext *C)
@ -594,7 +594,7 @@ struct ReportList *CTX_wm_reports(const bContext *C)
View3D *CTX_wm_view3d(const bContext *C) View3D *CTX_wm_view3d(const bContext *C)
{ {
ScrArea *sa = CTX_wm_area(C); ScrArea *sa = CTX_wm_area(C);
if (sa && sa->spacetype==SPACE_VIEW3D) if (sa && sa->spacetype == SPACE_VIEW3D)
return sa->spacedata.first; return sa->spacedata.first;
return NULL; return NULL;
} }
@ -604,7 +604,7 @@ RegionView3D *CTX_wm_region_view3d(const bContext *C)
ScrArea *sa = CTX_wm_area(C); ScrArea *sa = CTX_wm_area(C);
ARegion *ar = CTX_wm_region(C); ARegion *ar = CTX_wm_region(C);
if (sa && sa->spacetype==SPACE_VIEW3D) if (sa && sa->spacetype == SPACE_VIEW3D)
if (ar) if (ar)
return ar->regiondata; return ar->regiondata;
return NULL; return NULL;
@ -613,7 +613,7 @@ RegionView3D *CTX_wm_region_view3d(const bContext *C)
struct SpaceText *CTX_wm_space_text(const bContext *C) struct SpaceText *CTX_wm_space_text(const bContext *C)
{ {
ScrArea *sa = CTX_wm_area(C); ScrArea *sa = CTX_wm_area(C);
if (sa && sa->spacetype==SPACE_TEXT) if (sa && sa->spacetype == SPACE_TEXT)
return sa->spacedata.first; return sa->spacedata.first;
return NULL; return NULL;
} }
@ -621,7 +621,7 @@ struct SpaceText *CTX_wm_space_text(const bContext *C)
struct SpaceConsole *CTX_wm_space_console(const bContext *C) struct SpaceConsole *CTX_wm_space_console(const bContext *C)
{ {
ScrArea *sa = CTX_wm_area(C); ScrArea *sa = CTX_wm_area(C);
if (sa && sa->spacetype==SPACE_CONSOLE) if (sa && sa->spacetype == SPACE_CONSOLE)
return sa->spacedata.first; return sa->spacedata.first;
return NULL; return NULL;
} }
@ -629,7 +629,7 @@ struct SpaceConsole *CTX_wm_space_console(const bContext *C)
struct SpaceImage *CTX_wm_space_image(const bContext *C) struct SpaceImage *CTX_wm_space_image(const bContext *C)
{ {
ScrArea *sa = CTX_wm_area(C); ScrArea *sa = CTX_wm_area(C);
if (sa && sa->spacetype==SPACE_IMAGE) if (sa && sa->spacetype == SPACE_IMAGE)
return sa->spacedata.first; return sa->spacedata.first;
return NULL; return NULL;
} }
@ -637,7 +637,7 @@ struct SpaceImage *CTX_wm_space_image(const bContext *C)
struct SpaceButs *CTX_wm_space_buts(const bContext *C) struct SpaceButs *CTX_wm_space_buts(const bContext *C)
{ {
ScrArea *sa = CTX_wm_area(C); ScrArea *sa = CTX_wm_area(C);
if (sa && sa->spacetype==SPACE_BUTS) if (sa && sa->spacetype == SPACE_BUTS)
return sa->spacedata.first; return sa->spacedata.first;
return NULL; return NULL;
} }
@ -645,7 +645,7 @@ struct SpaceButs *CTX_wm_space_buts(const bContext *C)
struct SpaceFile *CTX_wm_space_file(const bContext *C) struct SpaceFile *CTX_wm_space_file(const bContext *C)
{ {
ScrArea *sa = CTX_wm_area(C); ScrArea *sa = CTX_wm_area(C);
if (sa && sa->spacetype==SPACE_FILE) if (sa && sa->spacetype == SPACE_FILE)
return sa->spacedata.first; return sa->spacedata.first;
return NULL; return NULL;
} }
@ -653,7 +653,7 @@ struct SpaceFile *CTX_wm_space_file(const bContext *C)
struct SpaceSeq *CTX_wm_space_seq(const bContext *C) struct SpaceSeq *CTX_wm_space_seq(const bContext *C)
{ {
ScrArea *sa = CTX_wm_area(C); ScrArea *sa = CTX_wm_area(C);
if (sa && sa->spacetype==SPACE_SEQ) if (sa && sa->spacetype == SPACE_SEQ)
return sa->spacedata.first; return sa->spacedata.first;
return NULL; return NULL;
} }
@ -661,7 +661,7 @@ struct SpaceSeq *CTX_wm_space_seq(const bContext *C)
struct SpaceOops *CTX_wm_space_outliner(const bContext *C) struct SpaceOops *CTX_wm_space_outliner(const bContext *C)
{ {
ScrArea *sa = CTX_wm_area(C); ScrArea *sa = CTX_wm_area(C);
if (sa && sa->spacetype==SPACE_OUTLINER) if (sa && sa->spacetype == SPACE_OUTLINER)
return sa->spacedata.first; return sa->spacedata.first;
return NULL; return NULL;
} }
@ -669,7 +669,7 @@ struct SpaceOops *CTX_wm_space_outliner(const bContext *C)
struct SpaceNla *CTX_wm_space_nla(const bContext *C) struct SpaceNla *CTX_wm_space_nla(const bContext *C)
{ {
ScrArea *sa = CTX_wm_area(C); ScrArea *sa = CTX_wm_area(C);
if (sa && sa->spacetype==SPACE_NLA) if (sa && sa->spacetype == SPACE_NLA)
return sa->spacedata.first; return sa->spacedata.first;
return NULL; return NULL;
} }
@ -677,7 +677,7 @@ struct SpaceNla *CTX_wm_space_nla(const bContext *C)
struct SpaceTime *CTX_wm_space_time(const bContext *C) struct SpaceTime *CTX_wm_space_time(const bContext *C)
{ {
ScrArea *sa = CTX_wm_area(C); ScrArea *sa = CTX_wm_area(C);
if (sa && sa->spacetype==SPACE_TIME) if (sa && sa->spacetype == SPACE_TIME)
return sa->spacedata.first; return sa->spacedata.first;
return NULL; return NULL;
} }
@ -685,7 +685,7 @@ struct SpaceTime *CTX_wm_space_time(const bContext *C)
struct SpaceNode *CTX_wm_space_node(const bContext *C) struct SpaceNode *CTX_wm_space_node(const bContext *C)
{ {
ScrArea *sa = CTX_wm_area(C); ScrArea *sa = CTX_wm_area(C);
if (sa && sa->spacetype==SPACE_NODE) if (sa && sa->spacetype == SPACE_NODE)
return sa->spacedata.first; return sa->spacedata.first;
return NULL; return NULL;
} }
@ -693,7 +693,7 @@ struct SpaceNode *CTX_wm_space_node(const bContext *C)
struct SpaceLogic *CTX_wm_space_logic(const bContext *C) struct SpaceLogic *CTX_wm_space_logic(const bContext *C)
{ {
ScrArea *sa = CTX_wm_area(C); ScrArea *sa = CTX_wm_area(C);
if (sa && sa->spacetype==SPACE_LOGIC) if (sa && sa->spacetype == SPACE_LOGIC)
return sa->spacedata.first; return sa->spacedata.first;
return NULL; return NULL;
} }
@ -701,7 +701,7 @@ struct SpaceLogic *CTX_wm_space_logic(const bContext *C)
struct SpaceIpo *CTX_wm_space_graph(const bContext *C) struct SpaceIpo *CTX_wm_space_graph(const bContext *C)
{ {
ScrArea *sa = CTX_wm_area(C); ScrArea *sa = CTX_wm_area(C);
if (sa && sa->spacetype==SPACE_IPO) if (sa && sa->spacetype == SPACE_IPO)
return sa->spacedata.first; return sa->spacedata.first;
return NULL; return NULL;
} }
@ -709,7 +709,7 @@ struct SpaceIpo *CTX_wm_space_graph(const bContext *C)
struct SpaceAction *CTX_wm_space_action(const bContext *C) struct SpaceAction *CTX_wm_space_action(const bContext *C)
{ {
ScrArea *sa = CTX_wm_area(C); ScrArea *sa = CTX_wm_area(C);
if (sa && sa->spacetype==SPACE_ACTION) if (sa && sa->spacetype == SPACE_ACTION)
return sa->spacedata.first; return sa->spacedata.first;
return NULL; return NULL;
} }
@ -717,7 +717,7 @@ struct SpaceAction *CTX_wm_space_action(const bContext *C)
struct SpaceInfo *CTX_wm_space_info(const bContext *C) struct SpaceInfo *CTX_wm_space_info(const bContext *C)
{ {
ScrArea *sa = CTX_wm_area(C); ScrArea *sa = CTX_wm_area(C);
if (sa && sa->spacetype==SPACE_INFO) if (sa && sa->spacetype == SPACE_INFO)
return sa->spacedata.first; return sa->spacedata.first;
return NULL; return NULL;
} }
@ -725,7 +725,7 @@ struct SpaceInfo *CTX_wm_space_info(const bContext *C)
struct SpaceUserPref *CTX_wm_space_userpref(const bContext *C) struct SpaceUserPref *CTX_wm_space_userpref(const bContext *C)
{ {
ScrArea *sa = CTX_wm_area(C); ScrArea *sa = CTX_wm_area(C);
if (sa && sa->spacetype==SPACE_USERPREF) if (sa && sa->spacetype == SPACE_USERPREF)
return sa->spacedata.first; return sa->spacedata.first;
return NULL; return NULL;
} }
@ -733,58 +733,58 @@ struct SpaceUserPref *CTX_wm_space_userpref(const bContext *C)
struct SpaceClip *CTX_wm_space_clip(const bContext *C) struct SpaceClip *CTX_wm_space_clip(const bContext *C)
{ {
ScrArea *sa = CTX_wm_area(C); ScrArea *sa = CTX_wm_area(C);
if (sa && sa->spacetype==SPACE_CLIP) if (sa && sa->spacetype == SPACE_CLIP)
return sa->spacedata.first; return sa->spacedata.first;
return NULL; return NULL;
} }
void CTX_wm_manager_set(bContext *C, wmWindowManager *wm) void CTX_wm_manager_set(bContext *C, wmWindowManager *wm)
{ {
C->wm.manager= wm; C->wm.manager = wm;
C->wm.window= NULL; C->wm.window = NULL;
C->wm.screen= NULL; C->wm.screen = NULL;
C->wm.area= NULL; C->wm.area = NULL;
C->wm.region= NULL; C->wm.region = NULL;
} }
void CTX_wm_window_set(bContext *C, wmWindow *win) void CTX_wm_window_set(bContext *C, wmWindow *win)
{ {
C->wm.window= win; C->wm.window = win;
C->wm.screen= (win)? win->screen: NULL; C->wm.screen = (win) ? win->screen : NULL;
if (C->wm.screen) if (C->wm.screen)
C->data.scene= C->wm.screen->scene; C->data.scene = C->wm.screen->scene;
C->wm.area= NULL; C->wm.area = NULL;
C->wm.region= NULL; C->wm.region = NULL;
} }
void CTX_wm_screen_set(bContext *C, bScreen *screen) void CTX_wm_screen_set(bContext *C, bScreen *screen)
{ {
C->wm.screen= screen; C->wm.screen = screen;
if (C->wm.screen) if (C->wm.screen)
C->data.scene= C->wm.screen->scene; C->data.scene = C->wm.screen->scene;
C->wm.area= NULL; C->wm.area = NULL;
C->wm.region= NULL; C->wm.region = NULL;
} }
void CTX_wm_area_set(bContext *C, ScrArea *area) void CTX_wm_area_set(bContext *C, ScrArea *area)
{ {
C->wm.area= area; C->wm.area = area;
C->wm.region= NULL; C->wm.region = NULL;
} }
void CTX_wm_region_set(bContext *C, ARegion *region) void CTX_wm_region_set(bContext *C, ARegion *region)
{ {
C->wm.region= region; C->wm.region = region;
} }
void CTX_wm_menu_set(bContext *C, ARegion *menu) void CTX_wm_menu_set(bContext *C, ARegion *menu)
{ {
C->wm.menu= menu; C->wm.menu = menu;
} }
void CTX_wm_operator_poll_msg_set(bContext *C, const char *msg) void CTX_wm_operator_poll_msg_set(bContext *C, const char *msg)
{ {
C->wm.operator_poll_msg= msg; C->wm.operator_poll_msg = msg;
} }
const char *CTX_wm_operator_poll_msg_get(bContext *C) const char *CTX_wm_operator_poll_msg_get(bContext *C)
@ -798,7 +798,7 @@ Main *CTX_data_main(const bContext *C)
{ {
Main *bmain; Main *bmain;
if (ctx_data_pointer_verify(C, "blend_data", (void*)&bmain)) if (ctx_data_pointer_verify(C, "blend_data", (void *)&bmain))
return bmain; return bmain;
else else
return C->data.main; return C->data.main;
@ -806,14 +806,14 @@ Main *CTX_data_main(const bContext *C)
void CTX_data_main_set(bContext *C, Main *bmain) void CTX_data_main_set(bContext *C, Main *bmain)
{ {
C->data.main= bmain; C->data.main = bmain;
} }
Scene *CTX_data_scene(const bContext *C) Scene *CTX_data_scene(const bContext *C)
{ {
Scene *scene; Scene *scene;
if (ctx_data_pointer_verify(C, "scene", (void*)&scene)) if (ctx_data_pointer_verify(C, "scene", (void *)&scene))
return scene; return scene;
else else
return C->data.scene; return C->data.scene;
@ -821,7 +821,7 @@ Scene *CTX_data_scene(const bContext *C)
int CTX_data_mode_enum(const bContext *C) int CTX_data_mode_enum(const bContext *C)
{ {
Object *obedit= CTX_data_edit_object(C); Object *obedit = CTX_data_edit_object(C);
if (obedit) { if (obedit) {
switch (obedit->type) { switch (obedit->type) {
@ -846,7 +846,7 @@ int CTX_data_mode_enum(const bContext *C)
if (ob) { if (ob) {
if (ob->mode & OB_MODE_POSE) return CTX_MODE_POSE; if (ob->mode & OB_MODE_POSE) return CTX_MODE_POSE;
else if (ob->mode & OB_MODE_SCULPT) return CTX_MODE_SCULPT; else if (ob->mode & OB_MODE_SCULPT) return CTX_MODE_SCULPT;
else if (ob->mode & OB_MODE_WEIGHT_PAINT) return CTX_MODE_PAINT_WEIGHT; else if (ob->mode & OB_MODE_WEIGHT_PAINT) return CTX_MODE_PAINT_WEIGHT;
else if (ob->mode & OB_MODE_VERTEX_PAINT) return CTX_MODE_PAINT_VERTEX; else if (ob->mode & OB_MODE_VERTEX_PAINT) return CTX_MODE_PAINT_VERTEX;
else if (ob->mode & OB_MODE_TEXTURE_PAINT) return CTX_MODE_PAINT_TEXTURE; else if (ob->mode & OB_MODE_TEXTURE_PAINT) return CTX_MODE_PAINT_TEXTURE;
@ -884,7 +884,7 @@ const char *CTX_data_mode_string(const bContext *C)
void CTX_data_scene_set(bContext *C, Scene *scene) void CTX_data_scene_set(bContext *C, Scene *scene)
{ {
C->data.scene= scene; C->data.scene = scene;
} }
ToolSettings *CTX_data_tool_settings(const bContext *C) ToolSettings *CTX_data_tool_settings(const bContext *C)

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

@ -47,16 +47,16 @@ static char idp_size_table[] = {
1, /*strings*/ 1, /*strings*/
sizeof(int), sizeof(int),
sizeof(float), sizeof(float),
sizeof(float)*3, /*Vector type, deprecated*/ sizeof(float) * 3, /*Vector type, deprecated*/
sizeof(float)*16, /*Matrix type, deprecated*/ sizeof(float) * 16, /*Matrix type, deprecated*/
0, /*arrays don't have a fixed size*/ 0, /*arrays don't have a fixed size*/
sizeof(ListBase), /*Group type*/ sizeof(ListBase), /*Group type*/
sizeof(void*), sizeof(void *),
sizeof(double) sizeof(double)
}; };
/* ------------Property Array Type ----------- */ /* ------------Property Array Type ----------- */
#define GETPROP(prop, i) (((IDProperty*)(prop)->data.pointer)+(i)) #define GETPROP(prop, i) (((IDProperty *)(prop)->data.pointer) + (i))
/* --------- property array type -------------*/ /* --------- property array type -------------*/
@ -78,10 +78,10 @@ IDProperty *IDP_CopyIDPArray(IDProperty *array)
IDProperty *narray = MEM_mallocN(sizeof(IDProperty), "IDP_CopyIDPArray"), *tmp; IDProperty *narray = MEM_mallocN(sizeof(IDProperty), "IDP_CopyIDPArray"), *tmp;
int i; int i;
*narray= *array; *narray = *array;
narray->data.pointer = MEM_dupallocN(array->data.pointer); narray->data.pointer = MEM_dupallocN(array->data.pointer);
for (i=0; i<narray->len; i++) { for (i = 0; i < narray->len; i++) {
/* ok, the copy functions always allocate a new structure, /* ok, the copy functions always allocate a new structure,
* which doesn't work here. instead, simply copy the * which doesn't work here. instead, simply copy the
* contents of the new structure into the array cell, * contents of the new structure into the array cell,
@ -100,7 +100,7 @@ void IDP_FreeIDPArray(IDProperty *prop)
{ {
int i; int i;
for (i=0; i<prop->len; i++) for (i = 0; i < prop->len; i++)
IDP_FreeProperty(GETPROP(prop, i)); IDP_FreeProperty(GETPROP(prop, i));
if (prop->data.pointer) if (prop->data.pointer)
@ -124,22 +124,22 @@ IDProperty *IDP_GetIndexArray(IDProperty *prop, int index)
IDProperty *IDP_AppendArray(IDProperty *prop, IDProperty *item) IDProperty *IDP_AppendArray(IDProperty *prop, IDProperty *item)
{ {
IDP_ResizeIDPArray(prop, prop->len+1); IDP_ResizeIDPArray(prop, prop->len + 1);
IDP_SetIndexArray(prop, prop->len-1, item); IDP_SetIndexArray(prop, prop->len - 1, item);
return item; return item;
} }
void IDP_ResizeIDPArray(IDProperty *prop, int newlen) void IDP_ResizeIDPArray(IDProperty *prop, int newlen)
{ {
void *newarr; void *newarr;
int newsize=newlen; int newsize = newlen;
/*first check if the array buffer size has room*/ /*first check if the array buffer size has room*/
/*if newlen is 200 chars less then totallen, reallocate anyway*/ /*if newlen is 200 chars less then totallen, reallocate anyway*/
if (newlen <= prop->totallen && prop->totallen - newlen < 200) { if (newlen <= prop->totallen && prop->totallen - newlen < 200) {
int i; int i;
for (i=newlen; i<prop->len; i++) for (i = newlen; i < prop->len; i++)
IDP_FreeProperty(GETPROP(prop, i)); IDP_FreeProperty(GETPROP(prop, i));
prop->len = newlen; prop->len = newlen;
@ -156,18 +156,18 @@ void IDP_ResizeIDPArray(IDProperty *prop, int newlen)
*/ */
newsize = (newsize >> 3) + (newsize < 9 ? 3 : 6) + newsize; newsize = (newsize >> 3) + (newsize < 9 ? 3 : 6) + newsize;
newarr = MEM_callocN(sizeof(IDProperty)*newsize, "idproperty array resized"); newarr = MEM_callocN(sizeof(IDProperty) * newsize, "idproperty array resized");
if (newlen >= prop->len) { if (newlen >= prop->len) {
/* newlen is bigger*/ /* newlen is bigger*/
memcpy(newarr, prop->data.pointer, prop->len*sizeof(IDProperty)); memcpy(newarr, prop->data.pointer, prop->len * sizeof(IDProperty));
} }
else { else {
int i; int i;
/* newlen is smaller*/ /* newlen is smaller*/
for (i=newlen; i<prop->len; i++) { for (i = newlen; i < prop->len; i++) {
IDP_FreeProperty(GETPROP(prop, i)); IDP_FreeProperty(GETPROP(prop, i));
} }
memcpy(newarr, prop->data.pointer, newlen*sizeof(IDProperty)); memcpy(newarr, prop->data.pointer, newlen * sizeof(IDProperty));
} }
if (prop->data.pointer) if (prop->data.pointer)
@ -185,21 +185,21 @@ static void idp_resize_group_array(IDProperty *prop, int newlen, void *newarr)
if (newlen >= prop->len) { if (newlen >= prop->len) {
/* bigger */ /* bigger */
IDProperty **array= newarr; IDProperty **array = newarr;
IDPropertyTemplate val; IDPropertyTemplate val;
int a; int a;
for (a=prop->len; a<newlen; a++) { for (a = prop->len; a < newlen; a++) {
val.i = 0; /* silence MSVC warning about uninitialized var when debugging */ val.i = 0; /* silence MSVC warning about uninitialized var when debugging */
array[a]= IDP_New(IDP_GROUP, &val, "IDP_ResizeArray group"); array[a] = IDP_New(IDP_GROUP, &val, "IDP_ResizeArray group");
} }
} }
else { else {
/* smaller */ /* smaller */
IDProperty **array= prop->data.pointer; IDProperty **array = prop->data.pointer;
int a; int a;
for (a=newlen; a<prop->len; a++) { for (a = newlen; a < prop->len; a++) {
IDP_FreeProperty(array[a]); IDP_FreeProperty(array[a]);
MEM_freeN(array[a]); MEM_freeN(array[a]);
} }
@ -210,7 +210,7 @@ static void idp_resize_group_array(IDProperty *prop, int newlen, void *newarr)
void IDP_ResizeArray(IDProperty *prop, int newlen) void IDP_ResizeArray(IDProperty *prop, int newlen)
{ {
void *newarr; void *newarr;
int newsize=newlen; int newsize = newlen;
/*first check if the array buffer size has room*/ /*first check if the array buffer size has room*/
/*if newlen is 200 chars less then totallen, reallocate anyway*/ /*if newlen is 200 chars less then totallen, reallocate anyway*/
@ -230,16 +230,16 @@ void IDP_ResizeArray(IDProperty *prop, int newlen)
*/ */
newsize = (newsize >> 3) + (newsize < 9 ? 3 : 6) + newsize; newsize = (newsize >> 3) + (newsize < 9 ? 3 : 6) + newsize;
newarr = MEM_callocN(idp_size_table[(int)prop->subtype]*newsize, "idproperty array resized"); newarr = MEM_callocN(idp_size_table[(int)prop->subtype] * newsize, "idproperty array resized");
if (newlen >= prop->len) { if (newlen >= prop->len) {
/* newlen is bigger*/ /* newlen is bigger*/
memcpy(newarr, prop->data.pointer, prop->len*idp_size_table[(int)prop->subtype]); memcpy(newarr, prop->data.pointer, prop->len * idp_size_table[(int)prop->subtype]);
idp_resize_group_array(prop, newlen, newarr); idp_resize_group_array(prop, newlen, newarr);
} }
else { else {
/* newlen is smaller*/ /* newlen is smaller*/
idp_resize_group_array(prop, newlen, newarr); idp_resize_group_array(prop, newlen, newarr);
memcpy(newarr, prop->data.pointer, newlen*idp_size_table[(int)prop->subtype]); memcpy(newarr, prop->data.pointer, newlen * idp_size_table[(int)prop->subtype]);
} }
MEM_freeN(prop->data.pointer); MEM_freeN(prop->data.pointer);
@ -257,8 +257,8 @@ void IDP_FreeArray(IDProperty *prop)
} }
static IDProperty *idp_generic_copy(IDProperty *prop) static IDProperty *idp_generic_copy(IDProperty *prop)
{ {
IDProperty *newp = MEM_callocN(sizeof(IDProperty), "IDProperty array dup"); IDProperty *newp = MEM_callocN(sizeof(IDProperty), "IDProperty array dup");
BLI_strncpy(newp->name, prop->name, MAX_IDPROP_NAME); BLI_strncpy(newp->name, prop->name, MAX_IDPROP_NAME);
@ -268,7 +268,7 @@ void IDP_FreeArray(IDProperty *prop)
newp->data.val2 = prop->data.val2; newp->data.val2 = prop->data.val2;
return newp; return newp;
} }
static IDProperty *IDP_CopyArray(IDProperty *prop) static IDProperty *IDP_CopyArray(IDProperty *prop)
{ {
@ -278,11 +278,11 @@ static IDProperty *IDP_CopyArray(IDProperty *prop)
newp->data.pointer = MEM_dupallocN(prop->data.pointer); newp->data.pointer = MEM_dupallocN(prop->data.pointer);
if (prop->type == IDP_GROUP) { if (prop->type == IDP_GROUP) {
IDProperty **array= newp->data.pointer; IDProperty **array = newp->data.pointer;
int a; int a;
for (a=0; a<prop->len; a++) for (a = 0; a < prop->len; a++)
array[a]= IDP_CopyProperty(array[a]); array[a] = IDP_CopyProperty(array[a]);
} }
} }
newp->len = prop->len; newp->len = prop->len;
@ -294,12 +294,12 @@ static IDProperty *IDP_CopyArray(IDProperty *prop)
/*taken from readfile.c*/ /*taken from readfile.c*/
#define SWITCH_LONGINT(a) { \ #define SWITCH_LONGINT(a) { \
char s_i, *p_i; \ char s_i, *p_i; \
p_i= (char *)&(a); \ p_i = (char *)& (a); \
s_i=p_i[0]; p_i[0]=p_i[7]; p_i[7]=s_i; \ s_i = p_i[0]; p_i[0] = p_i[7]; p_i[7] = s_i; \
s_i=p_i[1]; p_i[1]=p_i[6]; p_i[6]=s_i; \ s_i = p_i[1]; p_i[1] = p_i[6]; p_i[6] = s_i; \
s_i=p_i[2]; p_i[2]=p_i[5]; p_i[5]=s_i; \ s_i = p_i[2]; p_i[2] = p_i[5]; p_i[5] = s_i; \
s_i=p_i[3]; p_i[3]=p_i[4]; p_i[4]=s_i; } s_i = p_i[3]; p_i[3] = p_i[4]; p_i[4] = s_i; }
@ -350,7 +350,7 @@ void IDP_AssignString(IDProperty *prop, const char *st, int maxlen)
int stlen = strlen(st); int stlen = strlen(st);
if (maxlen > 0 && maxlen < stlen) if (maxlen > 0 && maxlen < stlen)
stlen= maxlen; stlen = maxlen;
if (prop->subtype == IDP_STRING_SUB_BYTE) { if (prop->subtype == IDP_STRING_SUB_BYTE) {
IDP_ResizeArray(prop, stlen); IDP_ResizeArray(prop, stlen);
@ -396,14 +396,14 @@ void IDP_FreeString(IDProperty *prop)
void IDP_LinkID(IDProperty *prop, ID *id) void IDP_LinkID(IDProperty *prop, ID *id)
{ {
if (prop->data.pointer) ((ID*)prop->data.pointer)->us--; if (prop->data.pointer) ((ID *)prop->data.pointer)->us--;
prop->data.pointer = id; prop->data.pointer = id;
id_us_plus(id); id_us_plus(id);
} }
void IDP_UnlinkID(IDProperty *prop) void IDP_UnlinkID(IDProperty *prop)
{ {
((ID*)prop->data.pointer)->us--; ((ID *)prop->data.pointer)->us--;
} }
/*-------- Group Functions -------*/ /*-------- Group Functions -------*/
@ -414,7 +414,7 @@ static IDProperty *IDP_CopyGroup(IDProperty *prop)
IDProperty *newp = idp_generic_copy(prop), *link; IDProperty *newp = idp_generic_copy(prop), *link;
newp->len = prop->len; newp->len = prop->len;
for (link=prop->data.group.first; link; link=link->next) { for (link = prop->data.group.first; link; link = link->next) {
BLI_addtail(&newp->data.group, IDP_CopyProperty(link)); BLI_addtail(&newp->data.group, IDP_CopyProperty(link));
} }
@ -426,22 +426,22 @@ static IDProperty *IDP_CopyGroup(IDProperty *prop)
void IDP_SyncGroupValues(IDProperty *dest, IDProperty *src) void IDP_SyncGroupValues(IDProperty *dest, IDProperty *src)
{ {
IDProperty *other, *prop; IDProperty *other, *prop;
for (prop=src->data.group.first; prop; prop=prop->next) { for (prop = src->data.group.first; prop; prop = prop->next) {
other= BLI_findstring(&dest->data.group, prop->name, offsetof(IDProperty, name)); other = BLI_findstring(&dest->data.group, prop->name, offsetof(IDProperty, name));
if (other && prop->type==other->type) { if (other && prop->type == other->type) {
switch (prop->type) { switch (prop->type) {
case IDP_INT: case IDP_INT:
case IDP_FLOAT: case IDP_FLOAT:
case IDP_DOUBLE: case IDP_DOUBLE:
other->data= prop->data; other->data = prop->data;
break; break;
case IDP_GROUP: case IDP_GROUP:
IDP_SyncGroupValues(other, prop); IDP_SyncGroupValues(other, prop);
break; break;
default: default:
{ {
IDProperty *tmp= other; IDProperty *tmp = other;
IDProperty *copy= IDP_CopyProperty(prop); IDProperty *copy = IDP_CopyProperty(prop);
BLI_insertlinkafter(&dest->data.group, other, copy); BLI_insertlinkafter(&dest->data.group, other, copy);
BLI_remlink(&dest->data.group, tmp); BLI_remlink(&dest->data.group, tmp);
@ -460,8 +460,8 @@ void IDP_SyncGroupValues(IDProperty *dest, IDProperty *src)
void IDP_ReplaceGroupInGroup(IDProperty *dest, IDProperty *src) void IDP_ReplaceGroupInGroup(IDProperty *dest, IDProperty *src)
{ {
IDProperty *loop, *prop; IDProperty *loop, *prop;
for (prop=src->data.group.first; prop; prop=prop->next) { for (prop = src->data.group.first; prop; prop = prop->next) {
for (loop=dest->data.group.first; loop; loop=loop->next) { for (loop = dest->data.group.first; loop; loop = loop->next) {
if (strcmp(loop->name, prop->name) == 0) { if (strcmp(loop->name, prop->name) == 0) {
IDProperty *copy = IDP_CopyProperty(prop); IDProperty *copy = IDP_CopyProperty(prop);
@ -489,7 +489,7 @@ void IDP_ReplaceGroupInGroup(IDProperty *dest, IDProperty *src)
void IDP_ReplaceInGroup(IDProperty *group, IDProperty *prop) void IDP_ReplaceInGroup(IDProperty *group, IDProperty *prop)
{ {
IDProperty *loop; IDProperty *loop;
if ((loop= IDP_GetPropertyFromGroup(group, prop->name))) { if ((loop = IDP_GetPropertyFromGroup(group, prop->name))) {
BLI_insertlink(&group->data.group, loop, prop); BLI_insertlink(&group->data.group, loop, prop);
BLI_remlink(&group->data.group, loop); BLI_remlink(&group->data.group, loop);
@ -539,7 +539,7 @@ IDProperty *IDP_GetPropertyFromGroup(IDProperty *prop, const char *name)
IDProperty *IDP_GetPropertyTypeFromGroup(IDProperty *prop, const char *name, const char type) IDProperty *IDP_GetPropertyTypeFromGroup(IDProperty *prop, const char *name, const char type)
{ {
IDProperty *idprop= IDP_GetPropertyFromGroup(prop, name); IDProperty *idprop = IDP_GetPropertyFromGroup(prop, name);
return (idprop && idprop->type == type) ? idprop : NULL; return (idprop && idprop->type == type) ? idprop : NULL;
} }
@ -553,20 +553,20 @@ void *IDP_GetGroupIterator(IDProperty *prop)
IDPIter *iter = MEM_callocN(sizeof(IDPIter), "IDPIter"); IDPIter *iter = MEM_callocN(sizeof(IDPIter), "IDPIter");
iter->next = prop->data.group.first; iter->next = prop->data.group.first;
iter->parent = prop; iter->parent = prop;
return (void*) iter; return (void *) iter;
} }
IDProperty *IDP_GroupIterNext(void *vself) IDProperty *IDP_GroupIterNext(void *vself)
{ {
IDPIter *self = (IDPIter*) vself; IDPIter *self = (IDPIter *) vself;
Link *next = (Link*) self->next; Link *next = (Link *) self->next;
if (self->next == NULL) { if (self->next == NULL) {
MEM_freeN(self); MEM_freeN(self);
return NULL; return NULL;
} }
self->next = next->next; self->next = next->next;
return (void*) next; return (void *) next;
} }
void IDP_FreeIterBeforeEnd(void *vself) void IDP_FreeIterBeforeEnd(void *vself)
@ -581,7 +581,7 @@ void IDP_FreeIterBeforeEnd(void *vself)
static void IDP_FreeGroup(IDProperty *prop) static void IDP_FreeGroup(IDProperty *prop)
{ {
IDProperty *loop; IDProperty *loop;
for (loop=prop->data.group.first; loop; loop=loop->next) { for (loop = prop->data.group.first; loop; loop = loop->next) {
IDP_FreeProperty(loop); IDP_FreeProperty(loop);
} }
BLI_freelistN(&prop->data.group); BLI_freelistN(&prop->data.group);
@ -635,7 +635,7 @@ int IDP_EqualsProperties(IDProperty *prop1, IDProperty *prop2)
return ((prop1->len == prop2->len) && strncmp(IDP_String(prop1), IDP_String(prop2), prop1->len) == 0); return ((prop1->len == prop2->len) && strncmp(IDP_String(prop1), IDP_String(prop2), prop1->len) == 0);
else if (prop1->type == IDP_ARRAY) { else if (prop1->type == IDP_ARRAY) {
if (prop1->len == prop2->len && prop1->subtype == prop2->subtype) if (prop1->len == prop2->len && prop1->subtype == prop2->subtype)
return memcmp(IDP_Array(prop1), IDP_Array(prop2), idp_size_table[(int)prop1->subtype]*prop1->len); return memcmp(IDP_Array(prop1), IDP_Array(prop2), idp_size_table[(int)prop1->subtype] * prop1->len);
else else
return 0; return 0;
} }
@ -645,8 +645,8 @@ int IDP_EqualsProperties(IDProperty *prop1, IDProperty *prop2)
if (BLI_countlist(&prop1->data.group) != BLI_countlist(&prop2->data.group)) if (BLI_countlist(&prop1->data.group) != BLI_countlist(&prop2->data.group))
return 0; return 0;
for (link1=prop1->data.group.first; link1; link1=link1->next) { for (link1 = prop1->data.group.first; link1; link1 = link1->next) {
link2= IDP_GetPropertyFromGroup(prop2, link1->name); link2 = IDP_GetPropertyFromGroup(prop2, link1->name);
if (!IDP_EqualsProperties(link1, link2)) if (!IDP_EqualsProperties(link1, link2))
return 0; return 0;
@ -655,14 +655,14 @@ int IDP_EqualsProperties(IDProperty *prop1, IDProperty *prop2)
return 1; return 1;
} }
else if (prop1->type == IDP_IDPARRAY) { else if (prop1->type == IDP_IDPARRAY) {
IDProperty *array1= IDP_IDPArray(prop1); IDProperty *array1 = IDP_IDPArray(prop1);
IDProperty *array2= IDP_IDPArray(prop2); IDProperty *array2 = IDP_IDPArray(prop2);
int i; int i;
if (prop1->len != prop2->len) if (prop1->len != prop2->len)
return 0; return 0;
for (i=0; i<prop1->len; i++) for (i = 0; i < prop1->len; i++)
if (!IDP_EqualsProperties(&array1[i], &array2[i])) if (!IDP_EqualsProperties(&array1[i], &array2[i]))
return 0; return 0;
} }
@ -673,7 +673,7 @@ int IDP_EqualsProperties(IDProperty *prop1, IDProperty *prop2)
/* 'val' is never NULL, don't check */ /* 'val' is never NULL, don't check */
IDProperty *IDP_New(const int type, const IDPropertyTemplate *val, const char *name) IDProperty *IDP_New(const int type, const IDPropertyTemplate *val, const char *name)
{ {
IDProperty *prop=NULL; IDProperty *prop = NULL;
switch (type) { switch (type) {
case IDP_INT: case IDP_INT:
@ -682,11 +682,11 @@ IDProperty *IDP_New(const int type, const IDPropertyTemplate *val, const char *n
break; break;
case IDP_FLOAT: case IDP_FLOAT:
prop = MEM_callocN(sizeof(IDProperty), "IDProperty float"); prop = MEM_callocN(sizeof(IDProperty), "IDProperty float");
*(float*)&prop->data.val = val->f; *(float *)&prop->data.val = val->f;
break; break;
case IDP_DOUBLE: case IDP_DOUBLE:
prop = MEM_callocN(sizeof(IDProperty), "IDProperty float"); prop = MEM_callocN(sizeof(IDProperty), "IDProperty float");
*(double*)&prop->data.val = val->d; *(double *)&prop->data.val = val->d;
break; break;
case IDP_ARRAY: case IDP_ARRAY:
{ {
@ -699,7 +699,7 @@ IDProperty *IDP_New(const int type, const IDPropertyTemplate *val, const char *n
prop = MEM_callocN(sizeof(IDProperty), "IDProperty array"); prop = MEM_callocN(sizeof(IDProperty), "IDProperty array");
prop->subtype = val->array.type; prop->subtype = val->array.type;
if (val->array.len) if (val->array.len)
prop->data.pointer = MEM_callocN(idp_size_table[val->array.type]*val->array.len, "id property array"); prop->data.pointer = MEM_callocN(idp_size_table[val->array.type] * val->array.len, "id property array");
prop->len = prop->totallen = val->array.len; prop->len = prop->totallen = val->array.len;
break; break;
} }
@ -724,7 +724,7 @@ IDProperty *IDP_New(const int type, const IDPropertyTemplate *val, const char *n
prop->len = prop->totallen = val->string.len; prop->len = prop->totallen = val->string.len;
memcpy(prop->data.pointer, st, val->string.len); memcpy(prop->data.pointer, st, val->string.len);
} }
prop->subtype= IDP_STRING_SUB_BYTE; prop->subtype = IDP_STRING_SUB_BYTE;
} }
else { else {
if (st == NULL) { if (st == NULL) {
@ -738,7 +738,7 @@ IDProperty *IDP_New(const int type, const IDPropertyTemplate *val, const char *n
prop->len = prop->totallen = stlen; prop->len = prop->totallen = stlen;
memcpy(prop->data.pointer, st, stlen); memcpy(prop->data.pointer, st, stlen);
} }
prop->subtype= IDP_STRING_SUB_UTF8; prop->subtype = IDP_STRING_SUB_UTF8;
} }
break; break;
} }

@ -39,10 +39,10 @@ void BKE_image_buf_fill_color(unsigned char *rect, float *rect_float, int width,
/* blank image */ /* blank image */
if (rect_float) { if (rect_float) {
for (y= 0; y<height; y++) { for (y = 0; y < height; y++) {
for (x= 0; x<width; x++) { for (x = 0; x < width; x++) {
copy_v4_v4(rect_float, color); copy_v4_v4(rect_float, color);
rect_float+= 4; rect_float += 4;
} }
} }
} }
@ -52,14 +52,14 @@ void BKE_image_buf_fill_color(unsigned char *rect, float *rect_float, int width,
rgba_float_to_uchar(ccol, color); rgba_float_to_uchar(ccol, color);
for (y= 0; y<height; y++) { for (y = 0; y < height; y++) {
for (x= 0; x<width; x++) { for (x = 0; x < width; x++) {
rect[0]= ccol[0]; rect[0] = ccol[0];
rect[1]= ccol[1]; rect[1] = ccol[1];
rect[2]= ccol[2]; rect[2] = ccol[2];
rect[3]= ccol[3]; rect[3] = ccol[3];
rect+= 4; rect += 4;
} }
} }
} }
@ -71,84 +71,84 @@ void BKE_image_buf_fill_checker(unsigned char *rect, float *rect_float, int widt
/* these two passes could be combined into one, but it's more readable and /* these two passes could be combined into one, but it's more readable and
* easy to tweak like this, speed isn't really that much of an issue in this situation... */ * easy to tweak like this, speed isn't really that much of an issue in this situation... */
int checkerwidth= 32, dark= 1; int checkerwidth = 32, dark = 1;
int x, y; int x, y;
unsigned char *rect_orig= rect; unsigned char *rect_orig = rect;
float *rect_float_orig= rect_float; float *rect_float_orig = rect_float;
float h=0.0, hoffs=0.0, hue=0.0, s=0.9, v=0.9, r, g, b; float h = 0.0, hoffs = 0.0, hue = 0.0, s = 0.9, v = 0.9, r, g, b;
/* checkers */ /* checkers */
for (y= 0; y<height; y++) { for (y = 0; y < height; y++) {
dark= powf(-1.0f, floorf(y / checkerwidth)); dark = powf(-1.0f, floorf(y / checkerwidth));
for (x= 0; x<width; x++) { for (x = 0; x < width; x++) {
if (x % checkerwidth == 0) dark= -dark; if (x % checkerwidth == 0) dark = -dark;
if (rect_float) { if (rect_float) {
if (dark > 0) { if (dark > 0) {
rect_float[0]= rect_float[1]= rect_float[2]= 0.25f; rect_float[0] = rect_float[1] = rect_float[2] = 0.25f;
rect_float[3]= 1.0f; rect_float[3] = 1.0f;
} }
else { else {
rect_float[0]= rect_float[1]= rect_float[2]= 0.58f; rect_float[0] = rect_float[1] = rect_float[2] = 0.58f;
rect_float[3]= 1.0f; rect_float[3] = 1.0f;
} }
rect_float+= 4; rect_float += 4;
} }
else { else {
if (dark > 0) { if (dark > 0) {
rect[0]= rect[1]= rect[2]= 64; rect[0] = rect[1] = rect[2] = 64;
rect[3]= 255; rect[3] = 255;
} }
else { else {
rect[0]= rect[1]= rect[2]= 150; rect[0] = rect[1] = rect[2] = 150;
rect[3]= 255; rect[3] = 255;
} }
rect+= 4; rect += 4;
} }
} }
} }
rect= rect_orig; rect = rect_orig;
rect_float= rect_float_orig; rect_float = rect_float_orig;
/* 2nd pass, colored + */ /* 2nd pass, colored + */
for (y= 0; y<height; y++) { for (y = 0; y < height; y++) {
hoffs= 0.125f * floorf(y / checkerwidth); hoffs = 0.125f * floorf(y / checkerwidth);
for (x= 0; x<width; x++) { for (x = 0; x < width; x++) {
h= 0.125f * floorf(x / checkerwidth); h = 0.125f * floorf(x / checkerwidth);
if ((fabs((x % checkerwidth) - (checkerwidth / 2)) < 4) && if ((fabs((x % checkerwidth) - (checkerwidth / 2)) < 4) &&
(fabs((y % checkerwidth) - (checkerwidth / 2)) < 4)) { (fabs((y % checkerwidth) - (checkerwidth / 2)) < 4)) {
if ((fabs((x % checkerwidth) - (checkerwidth / 2)) < 1) || if ((fabs((x % checkerwidth) - (checkerwidth / 2)) < 1) ||
(fabs((y % checkerwidth) - (checkerwidth / 2)) < 1)) { (fabs((y % checkerwidth) - (checkerwidth / 2)) < 1)) {
hue= fmodf(fabs(h-hoffs), 1.0f); hue = fmodf(fabs(h - hoffs), 1.0f);
hsv_to_rgb(hue, s, v, &r, &g, &b); hsv_to_rgb(hue, s, v, &r, &g, &b);
if (rect) { if (rect) {
rect[0]= (char)(r * 255.0f); rect[0] = (char)(r * 255.0f);
rect[1]= (char)(g * 255.0f); rect[1] = (char)(g * 255.0f);
rect[2]= (char)(b * 255.0f); rect[2] = (char)(b * 255.0f);
rect[3]= 255; rect[3] = 255;
} }
if (rect_float) { if (rect_float) {
rect_float[0]= r; rect_float[0] = r;
rect_float[1]= g; rect_float[1] = g;
rect_float[2]= b; rect_float[2] = b;
rect_float[3]= 1.0f; rect_float[3] = 1.0f;
} }
} }
} }
if (rect_float) rect_float+= 4; if (rect_float) rect_float += 4;
if (rect) rect+= 4; if (rect) rect += 4;
} }
} }
} }
@ -156,7 +156,7 @@ void BKE_image_buf_fill_checker(unsigned char *rect, float *rect_float, int widt
/* Utility functions for BKE_image_buf_fill_checker_color */ /* Utility functions for BKE_image_buf_fill_checker_color */
#define BLEND_FLOAT(real, add) (real+add <= 1.0f) ? (real+add) : 1.0f #define BLEND_FLOAT(real, add) (real + add <= 1.0f) ? (real + add) : 1.0f
#define BLEND_CHAR(real, add) ((real + (char)(add * 255.0f)) <= 255) ? (real + (char)(add * 255.0f)) : 255 #define BLEND_CHAR(real, add) ((real + (char)(add * 255.0f)) <= 255) ? (real + (char)(add * 255.0f)) : 255
static void checker_board_color_fill(unsigned char *rect, float *rect_float, int width, int height) static void checker_board_color_fill(unsigned char *rect, float *rect_float, int width, int height)
@ -164,32 +164,32 @@ static void checker_board_color_fill(unsigned char *rect, float *rect_float, int
int hue_step, y, x; int hue_step, y, x;
float hue, val, sat, r, g, b; float hue, val, sat, r, g, b;
sat= 1.0; sat = 1.0;
hue_step= power_of_2_max_i(width / 8); hue_step = power_of_2_max_i(width / 8);
if (hue_step < 8) hue_step= 8; if (hue_step < 8) hue_step = 8;
for (y= 0; y < height; y++) { for (y = 0; y < height; y++) {
val= 0.1 + (y * (0.4 / height)); /* use a number lower then 1.0 else its too bright */ val = 0.1 + (y * (0.4 / height)); /* use a number lower then 1.0 else its too bright */
for (x= 0; x < width; x++) { for (x = 0; x < width; x++) {
hue= (float)((double)(x/hue_step) * 1.0 / width * hue_step); hue = (float)((double)(x / hue_step) * 1.0 / width * hue_step);
hsv_to_rgb(hue, sat, val, &r, &g, &b); hsv_to_rgb(hue, sat, val, &r, &g, &b);
if (rect) { if (rect) {
rect[0]= (char)(r * 255.0f); rect[0] = (char)(r * 255.0f);
rect[1]= (char)(g * 255.0f); rect[1] = (char)(g * 255.0f);
rect[2]= (char)(b * 255.0f); rect[2] = (char)(b * 255.0f);
rect[3]= 255; rect[3] = 255;
rect += 4; rect += 4;
} }
if (rect_float) { if (rect_float) {
rect_float[0]= r; rect_float[0] = r;
rect_float[1]= g; rect_float[1] = g;
rect_float[2]= b; rect_float[2] = b;
rect_float[3]= 1.0f; rect_float[3] = 1.0f;
rect_float += 4; rect_float += 4;
} }
@ -200,42 +200,42 @@ static void checker_board_color_fill(unsigned char *rect, float *rect_float, int
static void checker_board_color_tint(unsigned char *rect, float *rect_float, int width, int height, int size, float blend) static void checker_board_color_tint(unsigned char *rect, float *rect_float, int width, int height, int size, float blend)
{ {
int x, y; int x, y;
float blend_half= blend * 0.5f; float blend_half = blend * 0.5f;
for (y= 0; y < height; y++) { for (y = 0; y < height; y++) {
for (x= 0; x < width; x++) { for (x = 0; x < width; x++) {
if (((y / size) % 2 == 1 && (x / size) % 2 == 1 ) || ( (y / size) % 2 == 0 && (x / size) % 2 == 0 )) { if (((y / size) % 2 == 1 && (x / size) % 2 == 1) || ( (y / size) % 2 == 0 && (x / size) % 2 == 0)) {
if (rect) { if (rect) {
rect[0]= (char)BLEND_CHAR(rect[0], blend); rect[0] = (char)BLEND_CHAR(rect[0], blend);
rect[1]= (char)BLEND_CHAR(rect[1], blend); rect[1] = (char)BLEND_CHAR(rect[1], blend);
rect[2]= (char)BLEND_CHAR(rect[2], blend); rect[2] = (char)BLEND_CHAR(rect[2], blend);
rect[3]= 255; rect[3] = 255;
rect += 4; rect += 4;
} }
if (rect_float) { if (rect_float) {
rect_float[0]= BLEND_FLOAT(rect_float[0], blend); rect_float[0] = BLEND_FLOAT(rect_float[0], blend);
rect_float[1]= BLEND_FLOAT(rect_float[1], blend); rect_float[1] = BLEND_FLOAT(rect_float[1], blend);
rect_float[2]= BLEND_FLOAT(rect_float[2], blend); rect_float[2] = BLEND_FLOAT(rect_float[2], blend);
rect_float[3]= 1.0f; rect_float[3] = 1.0f;
rect_float += 4; rect_float += 4;
} }
} }
else { else {
if (rect) { if (rect) {
rect[0]= (char)BLEND_CHAR(rect[0], blend_half); rect[0] = (char)BLEND_CHAR(rect[0], blend_half);
rect[1]= (char)BLEND_CHAR(rect[1], blend_half); rect[1] = (char)BLEND_CHAR(rect[1], blend_half);
rect[2]= (char)BLEND_CHAR(rect[2], blend_half); rect[2] = (char)BLEND_CHAR(rect[2], blend_half);
rect[3]= 255; rect[3] = 255;
rect += 4; rect += 4;
} }
if (rect_float) { if (rect_float) {
rect_float[0]= BLEND_FLOAT(rect_float[0], blend_half); rect_float[0] = BLEND_FLOAT(rect_float[0], blend_half);
rect_float[1]= BLEND_FLOAT(rect_float[1], blend_half); rect_float[1] = BLEND_FLOAT(rect_float[1], blend_half);
rect_float[2]= BLEND_FLOAT(rect_float[2], blend_half); rect_float[2] = BLEND_FLOAT(rect_float[2], blend_half);
rect_float[3]= 1.0f; rect_float[3] = 1.0f;
rect_float += 4; rect_float += 4;
} }
@ -248,22 +248,22 @@ static void checker_board_color_tint(unsigned char *rect, float *rect_float, int
static void checker_board_grid_fill(unsigned char *rect, float *rect_float, int width, int height, float blend) static void checker_board_grid_fill(unsigned char *rect, float *rect_float, int width, int height, float blend)
{ {
int x, y; int x, y;
for (y= 0; y < height; y++) { for (y = 0; y < height; y++) {
for (x= 0; x < width; x++) { for (x = 0; x < width; x++) {
if (((y % 32) == 0) || ((x % 32) == 0) || x == 0) { if (((y % 32) == 0) || ((x % 32) == 0) || x == 0) {
if (rect) { if (rect) {
rect[0]= BLEND_CHAR(rect[0], blend); rect[0] = BLEND_CHAR(rect[0], blend);
rect[1]= BLEND_CHAR(rect[1], blend); rect[1] = BLEND_CHAR(rect[1], blend);
rect[2]= BLEND_CHAR(rect[2], blend); rect[2] = BLEND_CHAR(rect[2], blend);
rect[3]= 255; rect[3] = 255;
rect += 4; rect += 4;
} }
if (rect_float) { if (rect_float) {
rect_float[0]= BLEND_FLOAT(rect_float[0], blend); rect_float[0] = BLEND_FLOAT(rect_float[0], blend);
rect_float[1]= BLEND_FLOAT(rect_float[1], blend); rect_float[1] = BLEND_FLOAT(rect_float[1], blend);
rect_float[2]= BLEND_FLOAT(rect_float[2], blend); rect_float[2] = BLEND_FLOAT(rect_float[2], blend);
rect_float[3]= 1.0f; rect_float[3] = 1.0f;
rect_float += 4; rect_float += 4;
} }
@ -282,17 +282,17 @@ static void checker_board_text(unsigned char *rect, float *rect_float, int width
{ {
int x, y; int x, y;
int pen_x, pen_y; int pen_x, pen_y;
char text[3]= {'A', '1', '\0'}; char text[3] = {'A', '1', '\0'};
const int mono= blf_mono_font; const int mono = blf_mono_font;
BLF_size(mono, 54, 72); /* hard coded size! */ BLF_size(mono, 54, 72); /* hard coded size! */
BLF_buffer(mono, rect_float, rect, width, height, 4); BLF_buffer(mono, rect_float, rect, width, height, 4);
for (y= 0; y < height; y+=step) { for (y = 0; y < height; y += step) {
text[1]= '1'; text[1] = '1';
for (x= 0; x < width; x+=step) { for (x = 0; x < width; x += step) {
/* hard coded offset */ /* hard coded offset */
pen_x = x + 33; pen_x = x + 33;
pen_y = y + 44; pen_y = y + 44;
@ -300,22 +300,22 @@ static void checker_board_text(unsigned char *rect, float *rect_float, int width
/* terribly crappy outline font! */ /* terribly crappy outline font! */
BLF_buffer_col(mono, 1.0, 1.0, 1.0, 1.0); BLF_buffer_col(mono, 1.0, 1.0, 1.0, 1.0);
BLF_position(mono, pen_x-outline, pen_y, 0.0); BLF_position(mono, pen_x - outline, pen_y, 0.0);
BLF_draw_buffer(mono, text); BLF_draw_buffer(mono, text);
BLF_position(mono, pen_x+outline, pen_y, 0.0); BLF_position(mono, pen_x + outline, pen_y, 0.0);
BLF_draw_buffer(mono, text); BLF_draw_buffer(mono, text);
BLF_position(mono, pen_x, pen_y-outline, 0.0); BLF_position(mono, pen_x, pen_y - outline, 0.0);
BLF_draw_buffer(mono, text); BLF_draw_buffer(mono, text);
BLF_position(mono, pen_x, pen_y+outline, 0.0); BLF_position(mono, pen_x, pen_y + outline, 0.0);
BLF_draw_buffer(mono, text); BLF_draw_buffer(mono, text);
BLF_position(mono, pen_x-outline, pen_y-outline, 0.0); BLF_position(mono, pen_x - outline, pen_y - outline, 0.0);
BLF_draw_buffer(mono, text); BLF_draw_buffer(mono, text);
BLF_position(mono, pen_x+outline, pen_y+outline, 0.0); BLF_position(mono, pen_x + outline, pen_y + outline, 0.0);
BLF_draw_buffer(mono, text); BLF_draw_buffer(mono, text);
BLF_position(mono, pen_x-outline, pen_y+outline, 0.0); BLF_position(mono, pen_x - outline, pen_y + outline, 0.0);
BLF_draw_buffer(mono, text); BLF_draw_buffer(mono, text);
BLF_position(mono, pen_x+outline, pen_y-outline, 0.0); BLF_position(mono, pen_x + outline, pen_y - outline, 0.0);
BLF_draw_buffer(mono, text); BLF_draw_buffer(mono, text);
BLF_buffer_col(mono, 0.0, 0.0, 0.0, 1.0); BLF_buffer_col(mono, 0.0, 0.0, 0.0, 1.0);
@ -338,7 +338,7 @@ void BKE_image_buf_fill_checker_color(unsigned char *rect, float *rect_float, in
checker_board_color_tint(rect, rect_float, width, height, 4, 0.05f); checker_board_color_tint(rect, rect_float, width, height, 4, 0.05f);
checker_board_color_tint(rect, rect_float, width, height, 32, 0.07f); checker_board_color_tint(rect, rect_float, width, height, 32, 0.07f);
checker_board_color_tint(rect, rect_float, width, height, 128, 0.15f); checker_board_color_tint(rect, rect_float, width, height, 128, 0.15f);
checker_board_grid_fill(rect, rect_float, width, height, 1.0f/4.0f); checker_board_grid_fill(rect, rect_float, width, height, 1.0f / 4.0f);
checker_board_text(rect, rect_float, width, height, 128, 2); checker_board_text(rect, rect_float, width, height, 128, 2);
} }

File diff suppressed because it is too large Load Diff

@ -68,12 +68,12 @@
ModifierTypeInfo *modifierType_getInfo(ModifierType type) ModifierTypeInfo *modifierType_getInfo(ModifierType type)
{ {
static ModifierTypeInfo *types[NUM_MODIFIER_TYPES]= {NULL}; static ModifierTypeInfo *types[NUM_MODIFIER_TYPES] = {NULL};
static int types_init = 1; static int types_init = 1;
if (types_init) { if (types_init) {
modifier_type_init(types); /* MOD_utils.c */ modifier_type_init(types); /* MOD_utils.c */
types_init= 0; types_init = 0;
} }
/* type unsigned, no need to check < 0 */ /* type unsigned, no need to check < 0 */
@ -97,7 +97,7 @@ ModifierData *modifier_new(int type)
md->type = type; md->type = type;
md->mode = eModifierMode_Realtime md->mode = eModifierMode_Realtime
| eModifierMode_Render | eModifierMode_Expanded; | eModifierMode_Render | eModifierMode_Expanded;
if (mti->flags & eModifierTypeFlag_EnableInEditmode) if (mti->flags & eModifierTypeFlag_EnableInEditmode)
md->mode |= eModifierMode_Editmode; md->mode |= eModifierMode_Editmode;
@ -137,8 +137,8 @@ int modifier_supportsMapping(ModifierData *md)
{ {
ModifierTypeInfo *mti = modifierType_getInfo(md->type); ModifierTypeInfo *mti = modifierType_getInfo(md->type);
return (mti->type==eModifierTypeType_OnlyDeform || return (mti->type == eModifierTypeType_OnlyDeform ||
(mti->flags & eModifierTypeFlag_SupportsMapping)); (mti->flags & eModifierTypeFlag_SupportsMapping));
} }
int modifier_isPreview(ModifierData *md) int modifier_isPreview(ModifierData *md)
@ -158,8 +158,8 @@ ModifierData *modifiers_findByType(Object *ob, ModifierType type)
{ {
ModifierData *md = ob->modifiers.first; ModifierData *md = ob->modifiers.first;
for (; md; md=md->next) for (; md; md = md->next)
if (md->type==type) if (md->type == type)
break; break;
return md; return md;
@ -175,7 +175,7 @@ void modifiers_clearErrors(Object *ob)
ModifierData *md = ob->modifiers.first; ModifierData *md = ob->modifiers.first;
/* int qRedraw = 0; */ /* int qRedraw = 0; */
for (; md; md=md->next) { for (; md; md = md->next) {
if (md->error) { if (md->error) {
MEM_freeN(md->error); MEM_freeN(md->error);
md->error = NULL; md->error = NULL;
@ -186,11 +186,11 @@ void modifiers_clearErrors(Object *ob)
} }
void modifiers_foreachObjectLink(Object *ob, ObjectWalkFunc walk, void modifiers_foreachObjectLink(Object *ob, ObjectWalkFunc walk,
void *userData) void *userData)
{ {
ModifierData *md = ob->modifiers.first; ModifierData *md = ob->modifiers.first;
for (; md; md=md->next) { for (; md; md = md->next) {
ModifierTypeInfo *mti = modifierType_getInfo(md->type); ModifierTypeInfo *mti = modifierType_getInfo(md->type);
if (mti->foreachObjectLink) if (mti->foreachObjectLink)
@ -202,7 +202,7 @@ void modifiers_foreachIDLink(Object *ob, IDWalkFunc walk, void *userData)
{ {
ModifierData *md = ob->modifiers.first; ModifierData *md = ob->modifiers.first;
for (; md; md=md->next) { for (; md; md = md->next) {
ModifierTypeInfo *mti = modifierType_getInfo(md->type); ModifierTypeInfo *mti = modifierType_getInfo(md->type);
if (mti->foreachIDLink) mti->foreachIDLink(md, ob, walk, userData); if (mti->foreachIDLink) mti->foreachIDLink(md, ob, walk, userData);
@ -218,7 +218,7 @@ void modifiers_foreachTexLink(Object *ob, TexWalkFunc walk, void *userData)
{ {
ModifierData *md = ob->modifiers.first; ModifierData *md = ob->modifiers.first;
for (; md; md=md->next) { for (; md; md = md->next) {
ModifierTypeInfo *mti = modifierType_getInfo(md->type); ModifierTypeInfo *mti = modifierType_getInfo(md->type);
if (mti->foreachTexLink) if (mti->foreachTexLink)
@ -240,12 +240,12 @@ int modifier_couldBeCage(struct Scene *scene, ModifierData *md)
{ {
ModifierTypeInfo *mti = modifierType_getInfo(md->type); ModifierTypeInfo *mti = modifierType_getInfo(md->type);
md->scene= scene; md->scene = scene;
return ( (md->mode & eModifierMode_Realtime) && return ((md->mode & eModifierMode_Realtime) &&
(md->mode & eModifierMode_Editmode) && (md->mode & eModifierMode_Editmode) &&
(!mti->isDisabled || !mti->isDisabled(md, 0)) && (!mti->isDisabled || !mti->isDisabled(md, 0)) &&
modifier_supportsMapping(md)); modifier_supportsMapping(md));
} }
int modifier_sameTopology(ModifierData *md) int modifier_sameTopology(ModifierData *md)
@ -269,7 +269,7 @@ void modifier_setError(ModifierData *md, const char *format, ...)
va_start(ap, format); va_start(ap, format);
vsnprintf(buffer, sizeof(buffer), format, ap); vsnprintf(buffer, sizeof(buffer), format, ap);
va_end(ap); va_end(ap);
buffer[sizeof(buffer) - 1]= '\0'; buffer[sizeof(buffer) - 1] = '\0';
if (md->error) if (md->error)
MEM_freeN(md->error); MEM_freeN(md->error);
@ -287,19 +287,19 @@ void modifier_setError(ModifierData *md, const char *format, ...)
*/ */
int modifiers_getCageIndex(struct Scene *scene, Object *ob, int *lastPossibleCageIndex_r, int virtual_) int modifiers_getCageIndex(struct Scene *scene, Object *ob, int *lastPossibleCageIndex_r, int virtual_)
{ {
ModifierData *md = (virtual_)? modifiers_getVirtualModifierList(ob): ob->modifiers.first; ModifierData *md = (virtual_) ? modifiers_getVirtualModifierList(ob) : ob->modifiers.first;
int i, cageIndex = -1; int i, cageIndex = -1;
if (lastPossibleCageIndex_r) { if (lastPossibleCageIndex_r) {
/* ensure the value is initialized */ /* ensure the value is initialized */
*lastPossibleCageIndex_r= -1; *lastPossibleCageIndex_r = -1;
} }
/* Find the last modifier acting on the cage. */ /* Find the last modifier acting on the cage. */
for (i=0; md; i++, md=md->next) { for (i = 0; md; i++, md = md->next) {
ModifierTypeInfo *mti = modifierType_getInfo(md->type); ModifierTypeInfo *mti = modifierType_getInfo(md->type);
md->scene= scene; md->scene = scene;
if (!(md->mode & eModifierMode_Realtime)) continue; if (!(md->mode & eModifierMode_Realtime)) continue;
if (!(md->mode & eModifierMode_Editmode)) continue; if (!(md->mode & eModifierMode_Editmode)) continue;
@ -344,7 +344,7 @@ int modifier_isEnabled(struct Scene *scene, ModifierData *md, int required_mode)
{ {
ModifierTypeInfo *mti = modifierType_getInfo(md->type); ModifierTypeInfo *mti = modifierType_getInfo(md->type);
md->scene= scene; md->scene = scene;
if ((md->mode & required_mode) != required_mode) return 0; if ((md->mode & required_mode) != required_mode) return 0;
if (mti->isDisabled && mti->isDisabled(md, required_mode == eModifierMode_Render)) return 0; if (mti->isDisabled && mti->isDisabled(md, required_mode == eModifierMode_Render)) return 0;
@ -396,7 +396,7 @@ CDMaskLink *modifiers_calcDataMasks(struct Scene *scene, Object *ob, ModifierDat
} }
/* reverse the list so it's in the correct order */ /* reverse the list so it's in the correct order */
BLI_linklist_reverse((LinkNode**)&dataMasks); BLI_linklist_reverse((LinkNode **)&dataMasks);
return dataMasks; return dataMasks;
} }
@ -431,19 +431,19 @@ ModifierData *modifiers_getVirtualModifierList(Object *ob)
if (init) { if (init) {
md = modifier_new(eModifierType_Armature); md = modifier_new(eModifierType_Armature);
amd = *((ArmatureModifierData*) md); amd = *((ArmatureModifierData *) md);
modifier_free(md); modifier_free(md);
md = modifier_new(eModifierType_Curve); md = modifier_new(eModifierType_Curve);
cmd = *((CurveModifierData*) md); cmd = *((CurveModifierData *) md);
modifier_free(md); modifier_free(md);
md = modifier_new(eModifierType_Lattice); md = modifier_new(eModifierType_Lattice);
lmd = *((LatticeModifierData*) md); lmd = *((LatticeModifierData *) md);
modifier_free(md); modifier_free(md);
md = modifier_new(eModifierType_ShapeKey); md = modifier_new(eModifierType_ShapeKey);
smd = *((ShapeKeyModifierData*) md); smd = *((ShapeKeyModifierData *) md);
modifier_free(md); modifier_free(md);
amd.modifier.mode |= eModifierMode_Virtual; amd.modifier.mode |= eModifierMode_Virtual;
@ -457,19 +457,19 @@ ModifierData *modifiers_getVirtualModifierList(Object *ob)
md = ob->modifiers.first; md = ob->modifiers.first;
if (ob->parent) { if (ob->parent) {
if (ob->parent->type==OB_ARMATURE && ob->partype==PARSKEL) { if (ob->parent->type == OB_ARMATURE && ob->partype == PARSKEL) {
amd.object = ob->parent; amd.object = ob->parent;
amd.modifier.next = md; amd.modifier.next = md;
amd.deformflag= ((bArmature *)(ob->parent->data))->deformflag; amd.deformflag = ((bArmature *)(ob->parent->data))->deformflag;
md = &amd.modifier; md = &amd.modifier;
} }
else if (ob->parent->type==OB_CURVE && ob->partype==PARSKEL) { else if (ob->parent->type == OB_CURVE && ob->partype == PARSKEL) {
cmd.object = ob->parent; cmd.object = ob->parent;
cmd.defaxis = ob->trackflag + 1; cmd.defaxis = ob->trackflag + 1;
cmd.modifier.next = md; cmd.modifier.next = md;
md = &cmd.modifier; md = &cmd.modifier;
} }
else if (ob->parent->type==OB_LATTICE && ob->partype==PARSKEL) { else if (ob->parent->type == OB_LATTICE && ob->partype == PARSKEL) {
lmd.object = ob->parent; lmd.object = ob->parent;
lmd.modifier.next = md; lmd.modifier.next = md;
md = &lmd.modifier; md = &lmd.modifier;
@ -479,9 +479,9 @@ ModifierData *modifiers_getVirtualModifierList(Object *ob)
/* shape key modifier, not yet for curves */ /* shape key modifier, not yet for curves */
if (ELEM(ob->type, OB_MESH, OB_LATTICE) && ob_get_key(ob)) { if (ELEM(ob->type, OB_MESH, OB_LATTICE) && ob_get_key(ob)) {
if (ob->type == OB_MESH && (ob->shapeflag & OB_SHAPE_EDIT_MODE)) if (ob->type == OB_MESH && (ob->shapeflag & OB_SHAPE_EDIT_MODE))
smd.modifier.mode |= eModifierMode_Editmode|eModifierMode_OnCage; smd.modifier.mode |= eModifierMode_Editmode | eModifierMode_OnCage;
else else
smd.modifier.mode &= ~eModifierMode_Editmode|eModifierMode_OnCage; smd.modifier.mode &= ~eModifierMode_Editmode | eModifierMode_OnCage;
smd.modifier.next = md; smd.modifier.next = md;
md = &smd.modifier; md = &smd.modifier;
@ -496,12 +496,12 @@ ModifierData *modifiers_getVirtualModifierList(Object *ob)
Object *modifiers_isDeformedByArmature(Object *ob) Object *modifiers_isDeformedByArmature(Object *ob)
{ {
ModifierData *md = modifiers_getVirtualModifierList(ob); ModifierData *md = modifiers_getVirtualModifierList(ob);
ArmatureModifierData *amd= NULL; ArmatureModifierData *amd = NULL;
/* return the first selected armature, this lets us use multiple armatures */ /* return the first selected armature, this lets us use multiple armatures */
for (; md; md=md->next) { for (; md; md = md->next) {
if (md->type==eModifierType_Armature) { if (md->type == eModifierType_Armature) {
amd = (ArmatureModifierData*) md; amd = (ArmatureModifierData *) md;
if (amd->object && (amd->object->flag & SELECT)) if (amd->object && (amd->object->flag & SELECT))
return amd->object; return amd->object;
} }
@ -520,12 +520,12 @@ Object *modifiers_isDeformedByArmature(Object *ob)
Object *modifiers_isDeformedByLattice(Object *ob) Object *modifiers_isDeformedByLattice(Object *ob)
{ {
ModifierData *md = modifiers_getVirtualModifierList(ob); ModifierData *md = modifiers_getVirtualModifierList(ob);
LatticeModifierData *lmd= NULL; LatticeModifierData *lmd = NULL;
/* return the first selected lattice, this lets us use multiple lattices */ /* return the first selected lattice, this lets us use multiple lattices */
for (; md; md=md->next) { for (; md; md = md->next) {
if (md->type==eModifierType_Lattice) { if (md->type == eModifierType_Lattice) {
lmd = (LatticeModifierData*) md; lmd = (LatticeModifierData *) md;
if (lmd->object && (lmd->object->flag & SELECT)) if (lmd->object && (lmd->object->flag & SELECT))
return lmd->object; return lmd->object;
} }
@ -543,10 +543,10 @@ int modifiers_usesArmature(Object *ob, bArmature *arm)
{ {
ModifierData *md = modifiers_getVirtualModifierList(ob); ModifierData *md = modifiers_getVirtualModifierList(ob);
for (; md; md=md->next) { for (; md; md = md->next) {
if (md->type==eModifierType_Armature) { if (md->type == eModifierType_Armature) {
ArmatureModifierData *amd = (ArmatureModifierData*) md; ArmatureModifierData *amd = (ArmatureModifierData *) md;
if (amd->object && amd->object->data==arm) if (amd->object && amd->object->data == arm)
return 1; return 1;
} }
} }
@ -556,9 +556,9 @@ int modifiers_usesArmature(Object *ob, bArmature *arm)
int modifier_isCorrectableDeformed(ModifierData *md) int modifier_isCorrectableDeformed(ModifierData *md)
{ {
if (md->type==eModifierType_Armature) if (md->type == eModifierType_Armature)
return 1; return 1;
if (md->type==eModifierType_ShapeKey) if (md->type == eModifierType_ShapeKey)
return 1; return 1;
return 0; return 0;
@ -568,11 +568,11 @@ int modifiers_isCorrectableDeformed(Object *ob)
{ {
ModifierData *md = modifiers_getVirtualModifierList(ob); ModifierData *md = modifiers_getVirtualModifierList(ob);
for (; md; md=md->next) { for (; md; md = md->next) {
if (ob->mode==OB_MODE_EDIT && (md->mode & eModifierMode_Editmode)==0); if (ob->mode == OB_MODE_EDIT && (md->mode & eModifierMode_Editmode) == 0) ;
else else
if (modifier_isCorrectableDeformed(md)) if (modifier_isCorrectableDeformed(md))
return 1; return 1;
} }
return 0; return 0;
} }
@ -593,22 +593,22 @@ int modifiers_isPreview(Object *ob)
int modifiers_indexInObject(Object *ob, ModifierData *md_seek) int modifiers_indexInObject(Object *ob, ModifierData *md_seek)
{ {
int i= 0; int i = 0;
ModifierData *md; ModifierData *md;
for (md=ob->modifiers.first; (md && md_seek!=md); md=md->next, i++); for (md = ob->modifiers.first; (md && md_seek != md); md = md->next, i++) ;
if (!md) return -1; /* modifier isn't in the object */ if (!md) return -1; /* modifier isn't in the object */
return i; return i;
} }
void modifier_freeTemporaryData(ModifierData *md) void modifier_freeTemporaryData(ModifierData *md)
{ {
if (md->type == eModifierType_Armature) { if (md->type == eModifierType_Armature) {
ArmatureModifierData *amd= (ArmatureModifierData*)md; ArmatureModifierData *amd = (ArmatureModifierData *)md;
if (amd->prevCos) { if (amd->prevCos) {
MEM_freeN(amd->prevCos); MEM_freeN(amd->prevCos);
amd->prevCos= NULL; amd->prevCos = NULL;
} }
} }
} }
@ -625,7 +625,7 @@ void test_object_modifiers(Object *ob)
for (md = ob->modifiers.first; md; md = md->next) { for (md = ob->modifiers.first; md; md = md->next) {
if (md->type == eModifierType_Multires) { if (md->type == eModifierType_Multires) {
MultiresModifierData *mmd = (MultiresModifierData*)md; MultiresModifierData *mmd = (MultiresModifierData *)md;
multiresModifier_set_levels_from_disps(mmd, ob); multiresModifier_set_levels_from_disps(mmd, ob);
} }

File diff suppressed because it is too large Load Diff

@ -73,17 +73,17 @@ int seekPackedFile(PackedFile *pf, int offset, int whence)
if (pf) { if (pf) {
oldseek = pf->seek; oldseek = pf->seek;
switch (whence) { switch (whence) {
case SEEK_CUR: case SEEK_CUR:
seek = oldseek + offset; seek = oldseek + offset;
break; break;
case SEEK_END: case SEEK_END:
seek = pf->size + offset; seek = pf->size + offset;
break; break;
case SEEK_SET: case SEEK_SET:
seek = offset; seek = offset;
break; break;
default: default:
oldseek = -1; oldseek = -1;
} }
if (seek < 0) { if (seek < 0) {
seek = 0; seek = 0;
@ -133,15 +133,15 @@ int countPackedFiles(Main *bmain)
int count = 0; int count = 0;
// let's check if there are packed files... // let's check if there are packed files...
for (ima=bmain->image.first; ima; ima=ima->id.next) for (ima = bmain->image.first; ima; ima = ima->id.next)
if (ima->packedfile) if (ima->packedfile)
count++; count++;
for (vf=bmain->vfont.first; vf; vf=vf->id.next) for (vf = bmain->vfont.first; vf; vf = vf->id.next)
if (vf->packedfile) if (vf->packedfile)
count++; count++;
for (sound=bmain->sound.first; sound; sound=sound->id.next) for (sound = bmain->sound.first; sound; sound = sound->id.next)
if (sound->packedfile) if (sound->packedfile)
count++; count++;
@ -176,7 +176,7 @@ PackedFile *newPackedFile(ReportList *reports, const char *filename, const char
/* render result has no filename and can be ignored /* render result has no filename and can be ignored
* any other files with no name can be ignored too */ * any other files with no name can be ignored too */
if (filename[0]=='\0') if (filename[0] == '\0')
return NULL; return NULL;
//XXX waitcursor(1); //XXX waitcursor(1);
@ -189,7 +189,7 @@ PackedFile *newPackedFile(ReportList *reports, const char *filename, const char
// open the file // open the file
// and create a PackedFile structure // and create a PackedFile structure
file= BLI_open(name, O_BINARY|O_RDONLY, 0); file = BLI_open(name, O_BINARY | O_RDONLY, 0);
if (file <= 0) { if (file <= 0) {
BKE_reportf(reports, RPT_ERROR, "Unable to pack file, source path not found: \"%s\"", name); BKE_reportf(reports, RPT_ERROR, "Unable to pack file, source path not found: \"%s\"", name);
} }
@ -222,23 +222,23 @@ void packAll(Main *bmain, ReportList *reports)
VFont *vf; VFont *vf;
bSound *sound; bSound *sound;
for (ima=bmain->image.first; ima; ima=ima->id.next) { for (ima = bmain->image.first; ima; ima = ima->id.next) {
if (ima->packedfile == NULL && ima->id.lib==NULL) { if (ima->packedfile == NULL && ima->id.lib == NULL) {
if (ima->source==IMA_SRC_FILE) { if (ima->source == IMA_SRC_FILE) {
ima->packedfile = newPackedFile(reports, ima->name, ID_BLEND_PATH(bmain, &ima->id)); ima->packedfile = newPackedFile(reports, ima->name, ID_BLEND_PATH(bmain, &ima->id));
} }
else if (ELEM(ima->source, IMA_SRC_SEQUENCE, IMA_SRC_MOVIE)) { else if (ELEM(ima->source, IMA_SRC_SEQUENCE, IMA_SRC_MOVIE)) {
BKE_reportf(reports, RPT_WARNING, "Image '%s' skipped, movies and image sequences not supported.", ima->id.name+2); BKE_reportf(reports, RPT_WARNING, "Image '%s' skipped, movies and image sequences not supported.", ima->id.name + 2);
} }
} }
} }
for (vf=bmain->vfont.first; vf; vf=vf->id.next) for (vf = bmain->vfont.first; vf; vf = vf->id.next)
if (vf->packedfile == NULL && vf->id.lib==NULL && strcmp(vf->name, FO_BUILTIN_NAME) != 0) if (vf->packedfile == NULL && vf->id.lib == NULL && strcmp(vf->name, FO_BUILTIN_NAME) != 0)
vf->packedfile = newPackedFile(reports, vf->name, bmain->name); vf->packedfile = newPackedFile(reports, vf->name, bmain->name);
for (sound=bmain->sound.first; sound; sound=sound->id.next) for (sound = bmain->sound.first; sound; sound = sound->id.next)
if (sound->packedfile == NULL && sound->id.lib==NULL) if (sound->packedfile == NULL && sound->id.lib == NULL)
sound->packedfile = newPackedFile(reports, sound->name, bmain->name); sound->packedfile = newPackedFile(reports, sound->name, bmain->name);
} }
@ -257,12 +257,12 @@ static char *find_new_name(char *name)
if (fop_exists(name)) { if (fop_exists(name)) {
for (number = 1; number <= 999; number++) { for (number = 1; number <= 999; number++) {
BLI_snprintf(tempname, sizeof(tempname), "%s.%03d", name, number); BLI_snprintf(tempname, sizeof(tempname), "%s.%03d", name, number);
if (! fop_exists(tempname)) { if (!fop_exists(tempname)) {
break; break;
} }
} }
} }
len= strlen(tempname) + 1; len = strlen(tempname) + 1;
newname = MEM_mallocN(len, "find_new_name"); newname = MEM_mallocN(len, "find_new_name");
memcpy(newname, tempname, len * sizeof(char)); memcpy(newname, tempname, len * sizeof(char));
return newname; return newname;
@ -275,7 +275,7 @@ int writePackedFile(ReportList *reports, const char *filename, PackedFile *pf, i
int ret_value = RET_OK; int ret_value = RET_OK;
char name[FILE_MAX]; char name[FILE_MAX];
char tempname[FILE_MAX]; char tempname[FILE_MAX];
/* void *data; */ /* void *data; */
if (guimode) {} //XXX waitcursor(1); if (guimode) {} //XXX waitcursor(1);
@ -285,7 +285,7 @@ int writePackedFile(ReportList *reports, const char *filename, PackedFile *pf, i
if (BLI_exists(name)) { if (BLI_exists(name)) {
for (number = 1; number <= 999; number++) { for (number = 1; number <= 999; number++) {
BLI_snprintf(tempname, sizeof(tempname), "%s.%03d_", name, number); BLI_snprintf(tempname, sizeof(tempname), "%s.%03d_", name, number);
if (! BLI_exists(tempname)) { if (!BLI_exists(tempname)) {
if (BLI_copy(name, tempname) == RET_OK) { if (BLI_copy(name, tempname) == RET_OK) {
remove_tmp = TRUE; remove_tmp = TRUE;
} }
@ -409,7 +409,7 @@ char *unpackFile(ReportList *reports, const char *abs_name, const char *local_na
case PF_KEEP: case PF_KEEP:
break; break;
case PF_REMOVE: case PF_REMOVE:
temp= abs_name; temp = abs_name;
break; break;
case PF_USE_LOCAL: case PF_USE_LOCAL:
// if file exists use it // if file exists use it
@ -417,7 +417,7 @@ char *unpackFile(ReportList *reports, const char *abs_name, const char *local_na
temp = local_name; temp = local_name;
break; break;
} }
// else fall through and create it // else fall through and create it
case PF_WRITE_LOCAL: case PF_WRITE_LOCAL:
if (writePackedFile(reports, local_name, pf, 1) == RET_OK) { if (writePackedFile(reports, local_name, pf, 1) == RET_OK) {
temp = local_name; temp = local_name;
@ -429,7 +429,7 @@ char *unpackFile(ReportList *reports, const char *abs_name, const char *local_na
temp = abs_name; temp = abs_name;
break; break;
} }
// else fall through and create it // else fall through and create it
case PF_WRITE_ORIGINAL: case PF_WRITE_ORIGINAL:
if (writePackedFile(reports, abs_name, pf, 1) == RET_OK) { if (writePackedFile(reports, abs_name, pf, 1) == RET_OK) {
temp = abs_name; temp = abs_name;
@ -441,7 +441,7 @@ char *unpackFile(ReportList *reports, const char *abs_name, const char *local_na
} }
if (temp) { if (temp) {
newname= BLI_strdup(temp); newname = BLI_strdup(temp);
} }
} }
@ -533,15 +533,15 @@ void unpackAll(Main *bmain, ReportList *reports, int how)
VFont *vf; VFont *vf;
bSound *sound; bSound *sound;
for (ima=bmain->image.first; ima; ima=ima->id.next) for (ima = bmain->image.first; ima; ima = ima->id.next)
if (ima->packedfile) if (ima->packedfile)
unpackImage(reports, ima, how); unpackImage(reports, ima, how);
for (vf=bmain->vfont.first; vf; vf=vf->id.next) for (vf = bmain->vfont.first; vf; vf = vf->id.next)
if (vf->packedfile) if (vf->packedfile)
unpackVFont(reports, vf, how); unpackVFont(reports, vf, how);
for (sound=bmain->sound.first; sound; sound=sound->id.next) for (sound = bmain->sound.first; sound; sound = sound->id.next)
if (sound->packedfile) if (sound->packedfile)
unpackSound(bmain, reports, sound, how); unpackSound(bmain, reports, sound, how);
} }

@ -57,7 +57,7 @@ void free_properties(ListBase *lb)
{ {
bProperty *prop; bProperty *prop;
while ( (prop= lb->first) ) { while ( (prop = lb->first) ) {
BLI_remlink(lb, prop); BLI_remlink(lb, prop);
free_property(prop); free_property(prop);
} }
@ -67,11 +67,11 @@ bProperty *copy_property(bProperty *prop)
{ {
bProperty *propn; bProperty *propn;
propn= MEM_dupallocN(prop); propn = MEM_dupallocN(prop);
if (prop->poin && prop->poin != &prop->data) { if (prop->poin && prop->poin != &prop->data) {
propn->poin= MEM_dupallocN(prop->poin); propn->poin = MEM_dupallocN(prop->poin);
} }
else propn->poin= &propn->data; else propn->poin = &propn->data;
return propn; return propn;
} }
@ -80,11 +80,11 @@ void copy_properties(ListBase *lbn, ListBase *lbo)
{ {
bProperty *prop, *propn; bProperty *prop, *propn;
free_properties(lbn); /* in case we are copying to an object with props */ free_properties(lbn); /* in case we are copying to an object with props */
prop= lbo->first; prop = lbo->first;
while (prop) { while (prop) {
propn= copy_property(prop); propn = copy_property(prop);
BLI_addtail(lbn, propn); BLI_addtail(lbn, propn);
prop= prop->next; prop = prop->next;
} }
@ -95,20 +95,20 @@ void init_property(bProperty *prop)
/* also use when property changes type */ /* also use when property changes type */
if (prop->poin && prop->poin != &prop->data) MEM_freeN(prop->poin); if (prop->poin && prop->poin != &prop->data) MEM_freeN(prop->poin);
prop->poin= NULL; prop->poin = NULL;
prop->data= 0; prop->data = 0;
switch (prop->type) { switch (prop->type) {
case GPROP_BOOL: case GPROP_BOOL:
case GPROP_INT: case GPROP_INT:
case GPROP_FLOAT: case GPROP_FLOAT:
case GPROP_TIME: case GPROP_TIME:
prop->poin= &prop->data; prop->poin = &prop->data;
break; break;
case GPROP_STRING: case GPROP_STRING:
prop->poin= MEM_callocN(MAX_PROPSTRING, "property string"); prop->poin = MEM_callocN(MAX_PROPSTRING, "property string");
break; break;
} }
} }
@ -117,8 +117,8 @@ bProperty *new_property(int type)
{ {
bProperty *prop; bProperty *prop;
prop= MEM_callocN(sizeof(bProperty), "property"); prop = MEM_callocN(sizeof(bProperty), "property");
prop->type= type; prop->type = type;
init_property(prop); init_property(prop);
@ -131,8 +131,8 @@ bProperty *new_property(int type)
static bProperty *get_property__internal(bProperty *first, bProperty *self, const char *name) static bProperty *get_property__internal(bProperty *first, bProperty *self, const char *name)
{ {
bProperty *p; bProperty *p;
for (p= first; p; p= p->next) { for (p = first; p; p = p->next) {
if (p!=self && (strcmp(p->name, name)==0)) if (p != self && (strcmp(p->name, name) == 0))
return p; return p;
} }
return NULL; return NULL;
@ -142,10 +142,10 @@ void unique_property(bProperty *first, bProperty *prop, int force)
bProperty *p; bProperty *p;
/* set the first if its not set */ /* set the first if its not set */
if (first==NULL) { if (first == NULL) {
first= prop; first = prop;
while (first->prev) { while (first->prev) {
first= first->prev; first = first->prev;
} }
} }
@ -162,14 +162,14 @@ void unique_property(bProperty *first, bProperty *prop, int force)
char new_name[sizeof(prop->name)]; char new_name[sizeof(prop->name)];
char base_name[sizeof(prop->name)]; char base_name[sizeof(prop->name)];
char num[sizeof(prop->name)]; char num[sizeof(prop->name)];
int i= 0; int i = 0;
/* strip numbers */ /* strip numbers */
BLI_strncpy(base_name, prop->name, sizeof(base_name)); BLI_strncpy(base_name, prop->name, sizeof(base_name));
for (i= strlen(base_name)-1; (i>=0 && isdigit(base_name[i])); i--) { for (i = strlen(base_name) - 1; (i >= 0 && isdigit(base_name[i])); i--) {
base_name[i]= '\0'; base_name[i] = '\0';
} }
i= 0; i = 0;
do { /* ensure we have enough chars for the new number in the name */ do { /* ensure we have enough chars for the new number in the name */
BLI_snprintf(num, sizeof(num), "%d", i++); BLI_snprintf(num, sizeof(num), "%d", i++);
@ -190,7 +190,7 @@ bProperty *get_ob_property(Object *ob, const char *name)
void set_ob_property(Object *ob, bProperty *propc) void set_ob_property(Object *ob, bProperty *propc)
{ {
bProperty *prop; bProperty *prop;
prop= get_ob_property(ob, propc->name); prop = get_ob_property(ob, propc->name);
if (prop) { if (prop) {
free_property(prop); free_property(prop);
BLI_remlink(&ob->prop, prop); BLI_remlink(&ob->prop, prop);
@ -207,32 +207,32 @@ int compare_property(bProperty *prop, const char *str)
float fvalue, ftest; float fvalue, ftest;
switch (prop->type) { switch (prop->type) {
case GPROP_BOOL: case GPROP_BOOL:
if (BLI_strcasecmp(str, "true")==0) { if (BLI_strcasecmp(str, "true") == 0) {
if (prop->data==1) return 0; if (prop->data == 1) return 0;
else return 1; else return 1;
} }
else if (BLI_strcasecmp(str, "false")==0) { else if (BLI_strcasecmp(str, "false") == 0) {
if (prop->data==0) return 0; if (prop->data == 0) return 0;
else return 1; else return 1;
} }
/* no break, do GPROP_int too! */ /* no break, do GPROP_int too! */
case GPROP_INT: case GPROP_INT:
return prop->data - atoi(str); return prop->data - atoi(str);
case GPROP_FLOAT: case GPROP_FLOAT:
case GPROP_TIME: case GPROP_TIME:
// WARNING: untested for GPROP_TIME // WARNING: untested for GPROP_TIME
// function isn't used currently // function isn't used currently
fvalue= *((float *)&prop->data); fvalue = *((float *)&prop->data);
ftest= (float)atof(str); ftest = (float)atof(str);
if ( fvalue > ftest) return 1; if (fvalue > ftest) return 1;
else if ( fvalue < ftest) return -1; else if (fvalue < ftest) return -1;
return 0; return 0;
case GPROP_STRING: case GPROP_STRING:
return strcmp(prop->poin, str); return strcmp(prop->poin, str);
} }
return 0; return 0;
@ -243,21 +243,21 @@ void set_property(bProperty *prop, const char *str)
// extern int Gdfra; /* sector.c */ // extern int Gdfra; /* sector.c */
switch (prop->type) { switch (prop->type) {
case GPROP_BOOL: case GPROP_BOOL:
if (BLI_strcasecmp(str, "true")==0) prop->data= 1; if (BLI_strcasecmp(str, "true") == 0) prop->data = 1;
else if (BLI_strcasecmp(str, "false")==0) prop->data= 0; else if (BLI_strcasecmp(str, "false") == 0) prop->data = 0;
else prop->data= (atoi(str)!=0); else prop->data = (atoi(str) != 0);
break; break;
case GPROP_INT: case GPROP_INT:
prop->data= atoi(str); prop->data = atoi(str);
break; break;
case GPROP_FLOAT: case GPROP_FLOAT:
case GPROP_TIME: case GPROP_TIME:
*((float *)&prop->data)= (float)atof(str); *((float *)&prop->data) = (float)atof(str);
break; break;
case GPROP_STRING: case GPROP_STRING:
strcpy(prop->poin, str); /* TODO - check size? */ strcpy(prop->poin, str); /* TODO - check size? */
break; break;
} }
} }
@ -267,17 +267,17 @@ void add_property(bProperty *prop, const char *str)
// extern int Gdfra; /* sector.c */ // extern int Gdfra; /* sector.c */
switch (prop->type) { switch (prop->type) {
case GPROP_BOOL: case GPROP_BOOL:
case GPROP_INT: case GPROP_INT:
prop->data+= atoi(str); prop->data += atoi(str);
break; break;
case GPROP_FLOAT: case GPROP_FLOAT:
case GPROP_TIME: case GPROP_TIME:
*((float *)&prop->data)+= (float)atof(str); *((float *)&prop->data) += (float)atof(str);
break; break;
case GPROP_STRING: case GPROP_STRING:
/* strcpy(prop->poin, str); */ /* strcpy(prop->poin, str); */
break; break;
} }
} }
@ -289,17 +289,17 @@ void set_property_valstr(bProperty *prop, char *str)
if (str == NULL) return; if (str == NULL) return;
switch (prop->type) { switch (prop->type) {
case GPROP_BOOL: case GPROP_BOOL:
case GPROP_INT: case GPROP_INT:
sprintf(str, "%d", prop->data); sprintf(str, "%d", prop->data);
break; break;
case GPROP_FLOAT: case GPROP_FLOAT:
case GPROP_TIME: case GPROP_TIME:
sprintf(str, "%f", *((float *)&prop->data)); sprintf(str, "%f", *((float *)&prop->data));
break; break;
case GPROP_STRING: case GPROP_STRING:
BLI_strncpy(str, prop->poin, MAX_PROPSTRING); BLI_strncpy(str, prop->poin, MAX_PROPSTRING);
break; break;
} }
} }

@ -1492,7 +1492,7 @@ void BKE_free_pointdensity(PointDensity *pd)
/* ------------------------------------------------------------------------- */ /* ------------------------------------------------------------------------- */
void BKE_free_voxeldatadata(struct VoxelData *vd) void BKE_free_voxeldatadata(VoxelData *vd)
{ {
if (vd->dataset) { if (vd->dataset) {
MEM_freeN(vd->dataset); MEM_freeN(vd->dataset);
@ -1501,17 +1501,17 @@ void BKE_free_voxeldatadata(struct VoxelData *vd)
} }
void BKE_free_voxeldata(struct VoxelData *vd) void BKE_free_voxeldata(VoxelData *vd)
{ {
BKE_free_voxeldatadata(vd); BKE_free_voxeldatadata(vd);
MEM_freeN(vd); MEM_freeN(vd);
} }
struct VoxelData *BKE_add_voxeldata(void) VoxelData *BKE_add_voxeldata(void)
{ {
VoxelData *vd; VoxelData *vd;
vd = MEM_callocN(sizeof(struct VoxelData), "voxeldata"); vd = MEM_callocN(sizeof(VoxelData), "voxeldata");
vd->dataset = NULL; vd->dataset = NULL;
vd->resol[0] = vd->resol[1] = vd->resol[2] = 1; vd->resol[0] = vd->resol[1] = vd->resol[2] = 1;
vd->interp_type = TEX_VD_LINEAR; vd->interp_type = TEX_VD_LINEAR;
@ -1525,7 +1525,7 @@ struct VoxelData *BKE_add_voxeldata(void)
return vd; return vd;
} }
struct VoxelData *BKE_copy_voxeldata(struct VoxelData *vd) VoxelData *BKE_copy_voxeldata(VoxelData *vd)
{ {
VoxelData *vdn; VoxelData *vdn;
@ -1537,7 +1537,7 @@ struct VoxelData *BKE_copy_voxeldata(struct VoxelData *vd)
/* ------------------------------------------------------------------------- */ /* ------------------------------------------------------------------------- */
struct OceanTex *BKE_add_oceantex(void) OceanTex *BKE_add_oceantex(void)
{ {
OceanTex *ot; OceanTex *ot;
@ -1548,7 +1548,7 @@ struct OceanTex *BKE_add_oceantex(void)
return ot; return ot;
} }
struct OceanTex *BKE_copy_oceantex(struct OceanTex *ot) OceanTex *BKE_copy_oceantex(struct OceanTex *ot)
{ {
OceanTex *otn = MEM_dupallocN(ot); OceanTex *otn = MEM_dupallocN(ot);