forked from bartvdbraak/blender
style cleanup: blenkernel
This commit is contained in:
parent
1118b3fe3f
commit
ffed654ff2
File diff suppressed because it is too large
Load Diff
@ -95,7 +95,7 @@ Global G;
|
||||
UserDef U;
|
||||
/* ListBase = {NULL, NULL}; */
|
||||
|
||||
char versionstr[48]= "";
|
||||
char versionstr[48] = "";
|
||||
|
||||
/* ********** free ********** */
|
||||
|
||||
@ -104,7 +104,7 @@ void free_blender(void)
|
||||
{
|
||||
/* samples are in a global list..., also sets G.main->sound->sample NULL */
|
||||
free_main(G.main);
|
||||
G.main= NULL;
|
||||
G.main = NULL;
|
||||
|
||||
BKE_spacetypes_free(); /* after free main, it uses space callbacks */
|
||||
|
||||
@ -122,16 +122,16 @@ void initglobals(void)
|
||||
{
|
||||
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, "//");
|
||||
|
||||
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
|
||||
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
|
||||
G.windowstate = G_WINDOWSTATE_USERDEF;
|
||||
@ -158,7 +158,7 @@ static void clear_global(void)
|
||||
|
||||
// free_vertexpaint();
|
||||
|
||||
G.main= NULL;
|
||||
G.main = NULL;
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
@ -188,17 +188,17 @@ static void clean_paths(Main *main)
|
||||
|
||||
static void setup_app_data(bContext *C, BlendFileData *bfd, const char *filepath)
|
||||
{
|
||||
bScreen *curscreen= NULL;
|
||||
Scene *curscene= NULL;
|
||||
bScreen *curscreen = NULL;
|
||||
Scene *curscene = NULL;
|
||||
int recover;
|
||||
char mode;
|
||||
|
||||
/* 'u' = undo save, 'n' = no UI load */
|
||||
if (bfd->main->screen.first==NULL) mode= 'u';
|
||||
else if (G.fileflags & G_FILE_NO_UI) mode= 'n';
|
||||
else mode= 0;
|
||||
if (bfd->main->screen.first == NULL) mode = 'u';
|
||||
else if (G.fileflags & G_FILE_NO_UI) mode = 'n';
|
||||
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 */
|
||||
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);
|
||||
|
||||
/* we re-use current screen */
|
||||
curscreen= CTX_wm_screen(C);
|
||||
curscreen = CTX_wm_screen(C);
|
||||
/* but use new Scene pointer */
|
||||
curscene= bfd->curscene;
|
||||
if (curscene==NULL) curscene= bfd->main->scene.first;
|
||||
curscene = bfd->curscene;
|
||||
if (curscene == NULL) curscene = bfd->main->scene.first;
|
||||
/* 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 */
|
||||
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 */
|
||||
RNA_property_update_cache_free();
|
||||
|
||||
G.main= bfd->main;
|
||||
G.main = bfd->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... */
|
||||
BKE_userdef_free();
|
||||
|
||||
U= *bfd->user;
|
||||
U = *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);
|
||||
}
|
||||
else {
|
||||
G.winpos= bfd->winpos;
|
||||
G.displaymode= bfd->displaymode;
|
||||
G.fileflags= bfd->fileflags;
|
||||
G.winpos = bfd->winpos;
|
||||
G.displaymode = bfd->displaymode;
|
||||
G.fileflags = bfd->fileflags;
|
||||
CTX_wm_manager_set(C, bfd->main->wm.first);
|
||||
CTX_wm_screen_set(C, bfd->curscreen);
|
||||
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 */
|
||||
if (CTX_data_scene(C)==NULL) {
|
||||
if (CTX_data_scene(C) == NULL) {
|
||||
CTX_data_scene_set(C, bfd->main->scene.first);
|
||||
CTX_wm_screen(C)->scene= CTX_data_scene(C);
|
||||
curscene= CTX_data_scene(C);
|
||||
CTX_wm_screen(C)->scene = CTX_data_scene(C);
|
||||
curscene = CTX_data_scene(C);
|
||||
}
|
||||
|
||||
/* special cases, override loaded flags: */
|
||||
if (G.f != bfd->globalf) {
|
||||
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) {
|
||||
//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) {
|
||||
/* 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 */
|
||||
filepath= bfd->filename;
|
||||
filepath = bfd->filename;
|
||||
}
|
||||
#if 0
|
||||
else if (!G.relbase_valid) {
|
||||
/* otherwise, use an empty string as filename, rather than <memory2> */
|
||||
filepath="";
|
||||
filepath = "";
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -348,8 +348,8 @@ void BKE_userdef_free(void)
|
||||
wmKeyMapItem *kmi;
|
||||
wmKeyMapDiffItem *kmdi;
|
||||
|
||||
for (km=U.user_keymaps.first; km; km=km->next) {
|
||||
for (kmdi=km->diff_items.first; kmdi; kmdi=kmdi->next) {
|
||||
for (km = U.user_keymaps.first; km; km = km->next) {
|
||||
for (kmdi = km->diff_items.first; kmdi; kmdi = kmdi->next) {
|
||||
if (kmdi->add_item) {
|
||||
keymap_item_free(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);
|
||||
|
||||
BLI_freelistN(&km->diff_items);
|
||||
@ -377,20 +377,20 @@ void BKE_userdef_free(void)
|
||||
int BKE_read_file(bContext *C, const char *filepath, ReportList *reports)
|
||||
{
|
||||
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);
|
||||
|
||||
bfd= BLO_read_from_file(filepath, reports);
|
||||
bfd = BLO_read_from_file(filepath, reports);
|
||||
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);
|
||||
MEM_freeN(bfd);
|
||||
bfd= NULL;
|
||||
retval= BKE_READ_FILE_FAIL;
|
||||
bfd = NULL;
|
||||
retval = BKE_READ_FILE_FAIL;
|
||||
}
|
||||
else
|
||||
setup_app_data(C, bfd, filepath); // frees BFD
|
||||
@ -398,20 +398,20 @@ int BKE_read_file(bContext *C, const char *filepath, ReportList *reports)
|
||||
else
|
||||
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;
|
||||
|
||||
bfd= BLO_read_from_memory(filebuf, filelength, reports);
|
||||
bfd = BLO_read_from_memory(filebuf, filelength, reports);
|
||||
if (bfd)
|
||||
setup_app_data(C, bfd, "<memory2>");
|
||||
else
|
||||
BKE_reports_prepend(reports, "Loading failed: ");
|
||||
|
||||
return (bfd?1:0);
|
||||
return (bfd ? 1 : 0);
|
||||
}
|
||||
|
||||
/* memfile is the undo buffer */
|
||||
@ -419,13 +419,13 @@ int BKE_read_file_from_memfile(bContext *C, MemFile *memfile, ReportList *report
|
||||
{
|
||||
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)
|
||||
setup_app_data(C, bfd, "<memory1>");
|
||||
else
|
||||
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) )
|
||||
{
|
||||
blender_test_break_cb= func;
|
||||
blender_test_break_cb = func;
|
||||
}
|
||||
|
||||
|
||||
@ -446,7 +446,7 @@ int blender_test_break(void)
|
||||
blender_test_break_cb();
|
||||
}
|
||||
|
||||
return (G.afbreek==1);
|
||||
return (G.afbreek == 1);
|
||||
}
|
||||
|
||||
|
||||
@ -463,31 +463,31 @@ typedef struct UndoElem {
|
||||
uintptr_t undosize;
|
||||
} UndoElem;
|
||||
|
||||
static ListBase undobase={NULL, NULL};
|
||||
static UndoElem *curundo= NULL;
|
||||
static ListBase undobase = {NULL, NULL};
|
||||
static UndoElem *curundo = NULL;
|
||||
|
||||
|
||||
static int read_undosave(bContext *C, UndoElem *uel)
|
||||
{
|
||||
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 */
|
||||
WM_jobs_stop_all(CTX_wm_manager(C));
|
||||
|
||||
BLI_strncpy(mainstr, G.main->name, sizeof(mainstr)); /* temporal store */
|
||||
|
||||
fileflags= G.fileflags;
|
||||
fileflags = G.fileflags;
|
||||
G.fileflags |= G_FILE_NO_UI;
|
||||
|
||||
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
|
||||
success= BKE_read_file_from_memfile(C, &uel->memfile, NULL);
|
||||
success = BKE_read_file_from_memfile(C, &uel->memfile, NULL);
|
||||
|
||||
/* restore */
|
||||
BLI_strncpy(G.main->name, mainstr, sizeof(G.main->name)); /* restore */
|
||||
G.fileflags= fileflags;
|
||||
G.fileflags = fileflags;
|
||||
|
||||
if (success) {
|
||||
/* 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 */;
|
||||
UndoElem *uel;
|
||||
|
||||
if ( (U.uiflag & USER_GLOBALUNDO)==0) return;
|
||||
if ( U.undosteps==0) return;
|
||||
if ( (U.uiflag & USER_GLOBALUNDO) == 0) return;
|
||||
if (U.undosteps == 0) return;
|
||||
|
||||
/* remove all undos after (also when curundo==NULL) */
|
||||
while (undobase.last != curundo) {
|
||||
uel= undobase.last;
|
||||
uel = undobase.last;
|
||||
BLI_remlink(&undobase, uel);
|
||||
BLO_free_memfile(&uel->memfile);
|
||||
MEM_freeN(uel);
|
||||
}
|
||||
|
||||
/* 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_addtail(&undobase, uel);
|
||||
|
||||
/* and limit amount to the maximum */
|
||||
nr= 0;
|
||||
uel= undobase.last;
|
||||
nr = 0;
|
||||
uel = undobase.last;
|
||||
while (uel) {
|
||||
nr++;
|
||||
if (nr==U.undosteps) break;
|
||||
uel= uel->prev;
|
||||
if (nr == U.undosteps) break;
|
||||
uel = uel->prev;
|
||||
}
|
||||
if (uel) {
|
||||
while (undobase.first!=uel) {
|
||||
UndoElem *first= undobase.first;
|
||||
while (undobase.first != uel) {
|
||||
UndoElem *first = undobase.first;
|
||||
BLI_remlink(&undobase, first);
|
||||
/* the merge is because of compression */
|
||||
BLO_merge_memfile(&first->memfile, &first->next->memfile);
|
||||
@ -541,14 +541,14 @@ void BKE_write_undo(bContext *C, const char *name)
|
||||
|
||||
/* disk save version */
|
||||
if (UNDO_DISK) {
|
||||
static int counter= 0;
|
||||
static int counter = 0;
|
||||
char filepath[FILE_MAX];
|
||||
char numstr[32];
|
||||
int fileflags = G.fileflags & ~(G_FILE_HISTORY); /* don't do file history on undo */
|
||||
|
||||
/* calculate current filepath */
|
||||
counter++;
|
||||
counter= counter % U.undosteps;
|
||||
counter = counter % U.undosteps;
|
||||
|
||||
BLI_snprintf(numstr, sizeof(numstr), "%d.blend", counter);
|
||||
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));
|
||||
}
|
||||
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);
|
||||
curundo->undosize= MEM_get_memory_in_use() - memused;
|
||||
curundo->undosize = MEM_get_memory_in_use() - memused;
|
||||
}
|
||||
|
||||
if (U.undomemory != 0) {
|
||||
/* limit to maximum memory (afterwards, we can't know in advance) */
|
||||
totmem= 0;
|
||||
maxmem= ((uintptr_t)U.undomemory)*1024*1024;
|
||||
totmem = 0;
|
||||
maxmem = ((uintptr_t)U.undomemory) * 1024 * 1024;
|
||||
|
||||
/* keep at least two (original + other) */
|
||||
uel= undobase.last;
|
||||
uel = undobase.last;
|
||||
while (uel && uel->prev) {
|
||||
totmem+= uel->undosize;
|
||||
if (totmem>maxmem) break;
|
||||
uel= uel->prev;
|
||||
totmem += uel->undosize;
|
||||
if (totmem > maxmem) break;
|
||||
uel = uel->prev;
|
||||
}
|
||||
|
||||
if (uel) {
|
||||
if (uel->prev && uel->prev->prev)
|
||||
uel= uel->prev;
|
||||
uel = uel->prev;
|
||||
|
||||
while (undobase.first!=uel) {
|
||||
UndoElem *first= undobase.first;
|
||||
while (undobase.first != uel) {
|
||||
UndoElem *first = undobase.first;
|
||||
BLI_remlink(&undobase, first);
|
||||
/* the merge is because of compression */
|
||||
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)
|
||||
{
|
||||
|
||||
if (step==0) {
|
||||
if (step == 0) {
|
||||
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 */
|
||||
if (curundo==NULL || curundo->prev==NULL) ; // XXX error("No undo available");
|
||||
if (curundo == NULL || curundo->prev == NULL) ; // XXX error("No undo available");
|
||||
else {
|
||||
if (G.debug & G_DEBUG) printf("undo %s\n", curundo->name);
|
||||
curundo= curundo->prev;
|
||||
curundo = curundo->prev;
|
||||
read_undosave(C, curundo);
|
||||
}
|
||||
}
|
||||
else {
|
||||
/* 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 {
|
||||
read_undosave(C, curundo->next);
|
||||
curundo= curundo->next;
|
||||
curundo = curundo->next;
|
||||
if (G.debug & G_DEBUG) printf("redo %s\n", curundo->name);
|
||||
}
|
||||
}
|
||||
@ -627,30 +627,30 @@ void BKE_reset_undo(void)
|
||||
{
|
||||
UndoElem *uel;
|
||||
|
||||
uel= undobase.first;
|
||||
uel = undobase.first;
|
||||
while (uel) {
|
||||
BLO_free_memfile(&uel->memfile);
|
||||
uel= uel->next;
|
||||
uel = uel->next;
|
||||
}
|
||||
|
||||
BLI_freelistN(&undobase);
|
||||
curundo= NULL;
|
||||
curundo = NULL;
|
||||
}
|
||||
|
||||
/* based on index nr it does a restore */
|
||||
void BKE_undo_number(bContext *C, int nr)
|
||||
{
|
||||
curundo= BLI_findlink(&undobase, nr);
|
||||
curundo = BLI_findlink(&undobase, nr);
|
||||
BKE_undo_step(C, 0);
|
||||
}
|
||||
|
||||
/* go back to the last occurance of name in stack */
|
||||
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) {
|
||||
curundo= uel->prev;
|
||||
curundo = uel->prev;
|
||||
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)
|
||||
{
|
||||
if (name) {
|
||||
UndoElem *uel= BLI_rfindstring(&undobase, name, offsetof(UndoElem, name));
|
||||
UndoElem *uel = BLI_rfindstring(&undobase, name, offsetof(UndoElem, name));
|
||||
return uel && uel->prev;
|
||||
}
|
||||
|
||||
@ -670,13 +670,13 @@ int BKE_undo_valid(const char *name)
|
||||
/* if active pointer, set it to 1 if true */
|
||||
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 (active && uel==curundo)
|
||||
*active= 1;
|
||||
if (active && uel == curundo)
|
||||
*active = 1;
|
||||
return uel->name;
|
||||
}
|
||||
return NULL;
|
||||
@ -685,23 +685,23 @@ const char *BKE_undo_get_name(int nr, int *active)
|
||||
char *BKE_undo_menu_string(void)
|
||||
{
|
||||
UndoElem *uel;
|
||||
DynStr *ds= BLI_dynstr_new();
|
||||
DynStr *ds = BLI_dynstr_new();
|
||||
char *menu;
|
||||
|
||||
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, uel->name);
|
||||
}
|
||||
|
||||
menu= BLI_dynstr_get_cstring(ds);
|
||||
menu = BLI_dynstr_get_cstring(ds);
|
||||
BLI_dynstr_free(ds);
|
||||
|
||||
return menu;
|
||||
}
|
||||
|
||||
/* saves quit.blend */
|
||||
/* saves quit.blend */
|
||||
void BKE_undo_save_quit(void)
|
||||
{
|
||||
UndoElem *uel;
|
||||
@ -709,16 +709,16 @@ void BKE_undo_save_quit(void)
|
||||
int file;
|
||||
char str[FILE_MAX];
|
||||
|
||||
if ( (U.uiflag & USER_GLOBALUNDO)==0) return;
|
||||
if ( (U.uiflag & USER_GLOBALUNDO) == 0) return;
|
||||
|
||||
uel= curundo;
|
||||
if (uel==NULL) {
|
||||
uel = curundo;
|
||||
if (uel == NULL) {
|
||||
printf("No undo buffer to save recovery file\n");
|
||||
return;
|
||||
}
|
||||
|
||||
/* 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");
|
||||
|
||||
@ -728,10 +728,10 @@ void BKE_undo_save_quit(void)
|
||||
return;
|
||||
}
|
||||
|
||||
chunk= uel->memfile.chunks.first;
|
||||
chunk = uel->memfile.chunks.first;
|
||||
while (chunk) {
|
||||
if ( write(file, chunk->buf, chunk->size) != chunk->size) break;
|
||||
chunk= chunk->next;
|
||||
if (write(file, chunk->buf, chunk->size) != chunk->size) break;
|
||||
chunk = chunk->next;
|
||||
}
|
||||
|
||||
close(file);
|
||||
@ -743,13 +743,13 @@ void BKE_undo_save_quit(void)
|
||||
/* sets curscene */
|
||||
Main *BKE_undo_get_main(Scene **scene)
|
||||
{
|
||||
Main *mainp= NULL;
|
||||
BlendFileData *bfd= BLO_read_from_memfile(G.main, G.main->name, &curundo->memfile, NULL);
|
||||
Main *mainp = NULL;
|
||||
BlendFileData *bfd = BLO_read_from_memfile(G.main, G.main->name, &curundo->memfile, NULL);
|
||||
|
||||
if (bfd) {
|
||||
mainp= bfd->main;
|
||||
mainp = bfd->main;
|
||||
if (scene)
|
||||
*scene= bfd->curscene;
|
||||
*scene = bfd->curscene;
|
||||
|
||||
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);
|
||||
|
||||
A00 = dot_v3v3(e0, e0);
|
||||
A01 = dot_v3v3(e0, e1 );
|
||||
A11 = dot_v3v3(e1, e1 );
|
||||
B0 = dot_v3v3(diff, e0 );
|
||||
B1 = dot_v3v3(diff, e1 );
|
||||
C = dot_v3v3(diff, diff );
|
||||
A01 = dot_v3v3(e0, e1);
|
||||
A11 = dot_v3v3(e1, e1);
|
||||
B0 = dot_v3v3(diff, e0);
|
||||
B1 = dot_v3v3(diff, e1);
|
||||
C = dot_v3v3(diff, diff);
|
||||
Det = fabs(A00 * A11 - A01 * A01);
|
||||
S = A01 * B1 - A11 * B0;
|
||||
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 {
|
||||
if (fabsf(A00) > FLT_EPSILON)
|
||||
S = -B0/A00;
|
||||
S = -B0 / A00;
|
||||
else
|
||||
S = 0.0f;
|
||||
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 */
|
||||
// Minimum at interior lv
|
||||
/* Minimum at interior lv */
|
||||
float invDet;
|
||||
if (fabsf(Det) > FLT_EPSILON)
|
||||
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;
|
||||
S *= invDet;
|
||||
T *= invDet;
|
||||
sqrDist = S * ( A00 * S + A01 * T + 2.0f * B0) +
|
||||
T * ( A01 * S + A11 * T + 2.0f * B1 ) + C;
|
||||
sqrDist = S * (A00 * S + A01 * T + 2.0f * B0) +
|
||||
T * (A01 * S + A11 * T + 2.0f * B1) + C;
|
||||
}
|
||||
}
|
||||
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 */
|
||||
tmp0 = A01 + B0;
|
||||
tmp1 = A11 + B1;
|
||||
if ( tmp1 > tmp0 ) {
|
||||
if (tmp1 > tmp0) {
|
||||
numer = tmp1 - tmp0;
|
||||
denom = A00 - 2.0f * A01 + A11;
|
||||
if ( numer >= denom ) {
|
||||
if (numer >= denom) {
|
||||
S = 1.0f;
|
||||
T = 0.0f;
|
||||
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
|
||||
S = 0.0f;
|
||||
T = 1.0f - S;
|
||||
sqrDist = S * ( A00 * S + A01 * T + 2.0f * B0 ) +
|
||||
T * ( A01 * S + A11 * T + 2.0f * B1 ) + C;
|
||||
sqrDist = S * (A00 * S + A01 * T + 2.0f * B0) +
|
||||
T * (A01 * S + A11 * T + 2.0f * B1) + C;
|
||||
le = 2;
|
||||
}
|
||||
}
|
||||
else {
|
||||
S = 0.0f;
|
||||
if ( tmp1 <= 0.0f ) {
|
||||
if (tmp1 <= 0.0f) {
|
||||
T = 1.0f;
|
||||
sqrDist = A11 + 2.0f * B1 + C;
|
||||
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 */
|
||||
tmp0 = A01 + B1;
|
||||
tmp1 = A00 + B0;
|
||||
if ( tmp1 > tmp0 ) {
|
||||
if (tmp1 > tmp0) {
|
||||
numer = tmp1 - tmp0;
|
||||
denom = A00 - 2.0f * A01 + A11;
|
||||
if ( numer >= denom ) {
|
||||
if (numer >= denom) {
|
||||
T = 1.0f;
|
||||
S = 0.0f;
|
||||
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
|
||||
T = 0.0f;
|
||||
S = 1.0f - T;
|
||||
sqrDist = S * ( A00 * S + A01 * T + 2.0f * B0 ) +
|
||||
T * ( A01 * S + A11 * T + 2.0f * B1 ) + C;
|
||||
sqrDist = S * (A00 * S + A01 * T + 2.0f * B0) +
|
||||
T * (A01 * S + A11 * T + 2.0f * B1) + C;
|
||||
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 */
|
||||
numer = A11 + B1 - A01 - B0;
|
||||
if ( numer <= 0.0f ) {
|
||||
if (numer <= 0.0f) {
|
||||
S = 0.0f;
|
||||
T = 1.0f;
|
||||
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 {
|
||||
denom = A00 - 2.0f * A01 + A11;
|
||||
if ( numer >= denom ) {
|
||||
if (numer >= denom) {
|
||||
S = 1.0f;
|
||||
T = 0.0f;
|
||||
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
|
||||
S = 0.0f;
|
||||
T = 1.0f - S;
|
||||
sqrDist = S * ( A00 * S + A01 * T + 2.0f * B0 ) +
|
||||
T * ( A01 * S + A11 * T + 2.0f * B1 ) + C;
|
||||
sqrDist = S * (A00 * S + A01 * T + 2.0f * B0) +
|
||||
T * (A01 * S + A11 * T + 2.0f * B1) + C;
|
||||
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
|
||||
if ( sqrDist < FLT_EPSILON )
|
||||
if (sqrDist < FLT_EPSILON)
|
||||
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.
|
||||
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;
|
||||
MFace *face = data->face + index;
|
||||
|
||||
float *t0, *t1, *t2, *t3;
|
||||
t0 = vert[ face->v1 ].co;
|
||||
t1 = vert[ face->v2 ].co;
|
||||
t2 = vert[ face->v3 ].co;
|
||||
t3 = face->v4 ? vert[ face->v4].co : NULL;
|
||||
t0 = vert[face->v1].co;
|
||||
t1 = vert[face->v2].co;
|
||||
t2 = vert[face->v3].co;
|
||||
t3 = face->v4 ? vert[face->v4].co : NULL;
|
||||
|
||||
|
||||
do
|
||||
{
|
||||
do {
|
||||
float nearest_tmp[3], dist;
|
||||
int vertex, edge;
|
||||
|
||||
@ -397,7 +396,7 @@ 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.
|
||||
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;
|
||||
MFace *face = data->face + index;
|
||||
|
||||
@ -408,8 +407,7 @@ static void mesh_faces_spherecast(void *userdata, int index, const BVHTreeRay *r
|
||||
t3 = face->v4 ? vert[face->v4].co : NULL;
|
||||
|
||||
|
||||
do
|
||||
{
|
||||
do {
|
||||
float dist;
|
||||
if (data->sphere_radius == 0.0f)
|
||||
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.
|
||||
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;
|
||||
MEdge *edge = data->edge + index;
|
||||
float nearest_tmp[3], dist;
|
||||
|
||||
float *t0, *t1;
|
||||
t0 = vert[ edge->v1 ].co;
|
||||
t1 = vert[ edge->v2 ].co;
|
||||
t0 = vert[edge->v1].co;
|
||||
t1 = vert[edge->v2].co;
|
||||
|
||||
closest_to_line_segment_v3(nearest_tmp, co, t0, t1);
|
||||
dist = len_squared_v3v3(nearest_tmp, co);
|
||||
@ -460,14 +458,14 @@ static void mesh_edges_nearest_point(void *userdata, int index, const float co[3
|
||||
* BVH builders
|
||||
*/
|
||||
// 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);
|
||||
|
||||
//Not in cache
|
||||
if (tree == NULL) {
|
||||
int i;
|
||||
int numVerts= mesh->getNumVerts(mesh);
|
||||
int numVerts = mesh->getNumVerts(mesh);
|
||||
MVert *vert = mesh->getVertDataArray(mesh, CD_MVERT);
|
||||
|
||||
if (vert != NULL) {
|
||||
@ -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.
|
||||
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);
|
||||
|
||||
//Not in cache
|
||||
if (tree == NULL) {
|
||||
int i;
|
||||
int numFaces= mesh->getNumTessFaces(mesh);
|
||||
int numFaces = mesh->getNumTessFaces(mesh);
|
||||
|
||||
/* BMESH specific check that we have tessfaces,
|
||||
* 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 */
|
||||
tree = BLI_bvhtree_new(numFaces, epsilon, tree_type, axis);
|
||||
if (tree != NULL) {
|
||||
BMEditMesh *em= data->em_evil;
|
||||
BMEditMesh *em = data->em_evil;
|
||||
if (em) {
|
||||
/* 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
|
||||
@ -600,11 +598,11 @@ BVHTree* bvhtree_from_mesh_faces(BVHTreeFromMesh *data, DerivedMesh *mesh, float
|
||||
if (vert != NULL && face != NULL) {
|
||||
for (i = 0; i < numFaces; i++) {
|
||||
float co[4][3];
|
||||
copy_v3_v3(co[0], vert[ face[i].v1 ].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[0], vert[face[i].v1].co);
|
||||
copy_v3_v3(co[1], vert[face[i].v2].co);
|
||||
copy_v3_v3(co[2], vert[face[i].v3].co);
|
||||
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);
|
||||
}
|
||||
@ -644,14 +642,14 @@ BVHTree* bvhtree_from_mesh_faces(BVHTreeFromMesh *data, DerivedMesh *mesh, float
|
||||
}
|
||||
|
||||
// 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);
|
||||
|
||||
//Not in cache
|
||||
if (tree == NULL) {
|
||||
int i;
|
||||
int numEdges= mesh->getNumEdges(mesh);
|
||||
int numEdges = mesh->getNumEdges(mesh);
|
||||
MVert *vert = mesh->getVertDataArray(mesh, CD_MVERT);
|
||||
MEdge *edge = mesh->getEdgeDataArray(mesh, CD_MEDGE);
|
||||
|
||||
@ -661,8 +659,8 @@ BVHTree* bvhtree_from_mesh_edges(BVHTreeFromMesh *data, DerivedMesh *mesh, float
|
||||
if (tree != NULL) {
|
||||
for (i = 0; i < numEdges; i++) {
|
||||
float co[4][3];
|
||||
copy_v3_v3(co[0], vert[ edge[i].v1 ].co);
|
||||
copy_v3_v3(co[1], vert[ edge[i].v2 ].co);
|
||||
copy_v3_v3(co[0], vert[edge[i].v1].co);
|
||||
copy_v3_v3(co[1], vert[edge[i].v2].co);
|
||||
|
||||
BLI_bvhtree_insert(tree, i, co[0], 2);
|
||||
}
|
||||
@ -712,8 +710,7 @@ void free_bvhtree_from_mesh(struct BVHTreeFromMesh *data)
|
||||
|
||||
|
||||
/* BVHCache */
|
||||
typedef struct BVHCacheItem
|
||||
{
|
||||
typedef struct BVHCacheItem {
|
||||
int type;
|
||||
BVHTree *tree;
|
||||
|
||||
@ -721,8 +718,8 @@ typedef struct BVHCacheItem
|
||||
|
||||
static void bvhcacheitem_set_if_match(void *_cached, void *_search)
|
||||
{
|
||||
BVHCacheItem * cached = (BVHCacheItem *)_cached;
|
||||
BVHCacheItem * search = (BVHCacheItem *)_search;
|
||||
BVHCacheItem *cached = (BVHCacheItem *)_cached;
|
||||
BVHCacheItem *search = (BVHCacheItem *)_search;
|
||||
|
||||
if (search->type == cached->type) {
|
||||
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;
|
||||
|
||||
C= MEM_callocN(sizeof(bContext), "bContext");
|
||||
C = MEM_callocN(sizeof(bContext), "bContext");
|
||||
|
||||
return C;
|
||||
}
|
||||
|
||||
bContext *CTX_copy(const bContext *C)
|
||||
{
|
||||
bContext *newC= MEM_dupallocN((void*)C);
|
||||
bContext *newC = MEM_dupallocN((void *)C);
|
||||
|
||||
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
|
||||
* we have to copy the context to ensure */
|
||||
ctx= contexts->last;
|
||||
ctx = contexts->last;
|
||||
|
||||
if (!ctx || ctx->used) {
|
||||
if (ctx) {
|
||||
lastctx= ctx;
|
||||
ctx= MEM_dupallocN(lastctx);
|
||||
lastctx = ctx;
|
||||
ctx = MEM_dupallocN(lastctx);
|
||||
BLI_duplicatelist(&ctx->entries, &lastctx->entries);
|
||||
}
|
||||
else
|
||||
ctx= MEM_callocN(sizeof(bContextStore), "bContextStore");
|
||||
ctx = MEM_callocN(sizeof(bContextStore), "bContextStore");
|
||||
|
||||
BLI_addtail(contexts, ctx);
|
||||
}
|
||||
|
||||
entry= MEM_callocN(sizeof(bContextStoreEntry), "bContextStoreEntry");
|
||||
entry = MEM_callocN(sizeof(bContextStoreEntry), "bContextStoreEntry");
|
||||
BLI_strncpy(entry->name, name, sizeof(entry->name));
|
||||
entry->ptr= *ptr;
|
||||
entry->ptr = *ptr;
|
||||
|
||||
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
|
||||
* we have to copy the context to ensure */
|
||||
ctx= contexts->last;
|
||||
ctx = contexts->last;
|
||||
|
||||
if (!ctx || ctx->used) {
|
||||
if (ctx) {
|
||||
lastctx= ctx;
|
||||
ctx= MEM_dupallocN(lastctx);
|
||||
lastctx = ctx;
|
||||
ctx = MEM_dupallocN(lastctx);
|
||||
BLI_duplicatelist(&ctx->entries, &lastctx->entries);
|
||||
}
|
||||
else
|
||||
ctx= MEM_callocN(sizeof(bContextStore), "bContextStore");
|
||||
ctx = MEM_callocN(sizeof(bContextStore), "bContextStore");
|
||||
|
||||
BLI_addtail(contexts, ctx);
|
||||
}
|
||||
|
||||
for (tentry= context->entries.first; tentry; tentry= tentry->next) {
|
||||
entry= MEM_dupallocN(tentry);
|
||||
for (tentry = context->entries.first; tentry; tentry = tentry->next) {
|
||||
entry = MEM_dupallocN(tentry);
|
||||
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)
|
||||
{
|
||||
C->wm.store= store;
|
||||
C->wm.store = store;
|
||||
}
|
||||
|
||||
bContextStore *CTX_store_copy(bContextStore *store)
|
||||
{
|
||||
bContextStore *ctx;
|
||||
|
||||
ctx= MEM_dupallocN(store);
|
||||
ctx = MEM_dupallocN(store);
|
||||
BLI_duplicatelist(&ctx->entries, &store->entries);
|
||||
|
||||
return ctx;
|
||||
@ -195,7 +195,7 @@ void CTX_store_free_list(ListBase *contexts)
|
||||
{
|
||||
bContextStore *ctx;
|
||||
|
||||
while ((ctx= contexts->first)) {
|
||||
while ((ctx = contexts->first)) {
|
||||
BLI_remlink(contexts, 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)
|
||||
{
|
||||
C->data.py_init= value;
|
||||
C->data.py_init = value;
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
C->data.py_context= value;
|
||||
C->data.py_context = value;
|
||||
}
|
||||
|
||||
/* 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)) {
|
||||
memset(&result, 0, sizeof(bContextDataResult));
|
||||
BPY_context_member_get((bContext*)C, member, &result);
|
||||
if(result.ptr.data)
|
||||
BPY_context_member_get((bContext *)C, member, &result);
|
||||
if (result.ptr.data)
|
||||
return result.ptr.data;
|
||||
}
|
||||
#endif
|
||||
@ -251,8 +251,8 @@ static int ctx_data_get(bContext *C, const char *member, bContextDataResult *res
|
||||
bScreen *sc;
|
||||
ScrArea *sa;
|
||||
ARegion *ar;
|
||||
int done= 0, recursion= C->data.recursion;
|
||||
int ret= 0;
|
||||
int done = 0, recursion = C->data.recursion;
|
||||
int ret = 0;
|
||||
|
||||
memset(result, 0, sizeof(bContextDataResult));
|
||||
#ifdef WITH_PYTHON
|
||||
@ -271,42 +271,42 @@ static int ctx_data_get(bContext *C, const char *member, bContextDataResult *res
|
||||
* Values in order of importance
|
||||
* (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;
|
||||
|
||||
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) {
|
||||
result->ptr= entry->ptr;
|
||||
done= 1;
|
||||
result->ptr = entry->ptr;
|
||||
done = 1;
|
||||
}
|
||||
}
|
||||
if (done!=1 && recursion < 2 && (ar=CTX_wm_region(C))) {
|
||||
C->data.recursion= 2;
|
||||
if (done != 1 && recursion < 2 && (ar = CTX_wm_region(C))) {
|
||||
C->data.recursion = 2;
|
||||
if (ar->type && ar->type->context) {
|
||||
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))) {
|
||||
C->data.recursion= 3;
|
||||
if (done != 1 && recursion < 3 && (sa = CTX_wm_area(C))) {
|
||||
C->data.recursion = 3;
|
||||
if (sa->type && sa->type->context) {
|
||||
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))) {
|
||||
bContextDataCallback cb= sc->context;
|
||||
C->data.recursion= 4;
|
||||
if (done != 1 && recursion < 4 && (sc = CTX_wm_screen(C))) {
|
||||
bContextDataCallback cb = sc->context;
|
||||
C->data.recursion = 4;
|
||||
if (cb) {
|
||||
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;
|
||||
}
|
||||
@ -315,7 +315,7 @@ static void *ctx_data_pointer_get(const bContext *C, const char *member)
|
||||
{
|
||||
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 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 (C == NULL) {
|
||||
*pointer= NULL;
|
||||
*pointer = NULL;
|
||||
return 1;
|
||||
}
|
||||
else if (ctx_data_get((bContext*)C, member, &result)==1) {
|
||||
*pointer= result.ptr.data;
|
||||
else if (ctx_data_get((bContext *)C, member, &result) == 1) {
|
||||
*pointer = result.ptr.data;
|
||||
return 1;
|
||||
}
|
||||
else {
|
||||
*pointer= NULL;
|
||||
*pointer = NULL;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@ -344,13 +344,13 @@ static int ctx_data_collection_get(const bContext *C, const char *member, ListBa
|
||||
{
|
||||
bContextDataResult result;
|
||||
|
||||
if (ctx_data_get((bContext*)C, member, &result)==1) {
|
||||
*list= result.list;
|
||||
if (ctx_data_get((bContext *)C, member, &result) == 1) {
|
||||
*list = result.list;
|
||||
return 1;
|
||||
}
|
||||
|
||||
list->first= NULL;
|
||||
list->last= NULL;
|
||||
list->first = NULL;
|
||||
list->last = NULL;
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -359,7 +359,7 @@ PointerRNA CTX_data_pointer_get(const bContext *C, const char *member)
|
||||
{
|
||||
bContextDataResult result;
|
||||
|
||||
if (ctx_data_get((bContext*)C, member, &result)==1)
|
||||
if (ctx_data_get((bContext *)C, member, &result) == 1)
|
||||
return result.ptr;
|
||||
else
|
||||
return PointerRNA_NULL;
|
||||
@ -379,11 +379,11 @@ ListBase CTX_data_collection_get(const bContext *C, const char *member)
|
||||
{
|
||||
bContextDataResult result;
|
||||
|
||||
if (ctx_data_get((bContext*)C, member, &result)==1) {
|
||||
if (ctx_data_get((bContext *)C, member, &result) == 1) {
|
||||
return result.list;
|
||||
}
|
||||
else {
|
||||
ListBase list= {NULL, NULL};
|
||||
ListBase list = {NULL, NULL};
|
||||
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)
|
||||
{
|
||||
bContextDataResult result;
|
||||
int ret= ctx_data_get((bContext*)C, member, &result);
|
||||
int ret = ctx_data_get((bContext *)C, member, &result);
|
||||
|
||||
if (ret==1) {
|
||||
*r_ptr= result.ptr;
|
||||
*r_lb= result.list;
|
||||
*r_type= result.type;
|
||||
if (ret == 1) {
|
||||
*r_ptr = result.ptr;
|
||||
*r_lb = result.list;
|
||||
*r_type = result.type;
|
||||
}
|
||||
else {
|
||||
memset(r_ptr, 0, sizeof(*r_ptr));
|
||||
memset(r_lb, 0, sizeof(*r_lb));
|
||||
*r_type= 0;
|
||||
*r_type = 0;
|
||||
}
|
||||
|
||||
return ret;
|
||||
@ -418,8 +418,8 @@ static void data_dir_add(ListBase *lb, const char *member)
|
||||
if (BLI_findstring(lb, member, offsetof(LinkData, data)))
|
||||
return;
|
||||
|
||||
link= MEM_callocN(sizeof(LinkData), "LinkData");
|
||||
link->data= (void*)member;
|
||||
link = MEM_callocN(sizeof(LinkData), "LinkData");
|
||||
link->data = (void *)member;
|
||||
BLI_addtail(lb, link);
|
||||
}
|
||||
|
||||
@ -437,32 +437,32 @@ ListBase CTX_data_dir_get(const bContext *C)
|
||||
if (C->wm.store) {
|
||||
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);
|
||||
}
|
||||
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));
|
||||
ar->type->context(C, "", &result);
|
||||
|
||||
if (result.dir)
|
||||
for (a=0; result.dir[a]; a++)
|
||||
for (a = 0; result.dir[a]; 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));
|
||||
sa->type->context(C, "", &result);
|
||||
|
||||
if (result.dir)
|
||||
for (a=0; result.dir[a]; a++)
|
||||
for (a = 0; result.dir[a]; a++)
|
||||
data_dir_add(&lb, result.dir[a]);
|
||||
}
|
||||
if ((sc=CTX_wm_screen(C)) && sc->context) {
|
||||
bContextDataCallback cb= sc->context;
|
||||
if ((sc = CTX_wm_screen(C)) && sc->context) {
|
||||
bContextDataCallback cb = sc->context;
|
||||
memset(&result, 0, sizeof(result));
|
||||
cb(C, "", &result);
|
||||
|
||||
if (result.dir)
|
||||
for (a=0; result.dir[a]; a++)
|
||||
for (a = 0; result.dir[a]; a++)
|
||||
data_dir_add(&lb, result.dir[a]);
|
||||
}
|
||||
|
||||
@ -493,7 +493,7 @@ void CTX_data_id_list_add(bContextDataResult *result, ID *id)
|
||||
{
|
||||
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);
|
||||
|
||||
BLI_addtail(&result->list, link);
|
||||
@ -503,18 +503,18 @@ void CTX_data_list_add(bContextDataResult *result, ID *id, StructRNA *type, void
|
||||
{
|
||||
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);
|
||||
|
||||
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;
|
||||
|
||||
if (func(C, &list)) {
|
||||
int tot= BLI_countlist(&list);
|
||||
int tot = BLI_countlist(&list);
|
||||
BLI_freelistN(&list);
|
||||
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)
|
||||
{
|
||||
result->dir= dir;
|
||||
result->dir = dir;
|
||||
}
|
||||
|
||||
void CTX_data_type_set(bContextDataResult *result, short type)
|
||||
{
|
||||
result->type= type;
|
||||
result->type = type;
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
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)
|
||||
@ -575,7 +575,7 @@ ARegion *CTX_wm_region(const bContext *C)
|
||||
void *CTX_wm_region_data(const bContext *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)
|
||||
@ -594,7 +594,7 @@ struct ReportList *CTX_wm_reports(const bContext *C)
|
||||
View3D *CTX_wm_view3d(const bContext *C)
|
||||
{
|
||||
ScrArea *sa = CTX_wm_area(C);
|
||||
if (sa && sa->spacetype==SPACE_VIEW3D)
|
||||
if (sa && sa->spacetype == SPACE_VIEW3D)
|
||||
return sa->spacedata.first;
|
||||
return NULL;
|
||||
}
|
||||
@ -604,7 +604,7 @@ RegionView3D *CTX_wm_region_view3d(const bContext *C)
|
||||
ScrArea *sa = CTX_wm_area(C);
|
||||
ARegion *ar = CTX_wm_region(C);
|
||||
|
||||
if (sa && sa->spacetype==SPACE_VIEW3D)
|
||||
if (sa && sa->spacetype == SPACE_VIEW3D)
|
||||
if (ar)
|
||||
return ar->regiondata;
|
||||
return NULL;
|
||||
@ -613,7 +613,7 @@ RegionView3D *CTX_wm_region_view3d(const bContext *C)
|
||||
struct SpaceText *CTX_wm_space_text(const bContext *C)
|
||||
{
|
||||
ScrArea *sa = CTX_wm_area(C);
|
||||
if (sa && sa->spacetype==SPACE_TEXT)
|
||||
if (sa && sa->spacetype == SPACE_TEXT)
|
||||
return sa->spacedata.first;
|
||||
return NULL;
|
||||
}
|
||||
@ -621,7 +621,7 @@ struct SpaceText *CTX_wm_space_text(const bContext *C)
|
||||
struct SpaceConsole *CTX_wm_space_console(const bContext *C)
|
||||
{
|
||||
ScrArea *sa = CTX_wm_area(C);
|
||||
if (sa && sa->spacetype==SPACE_CONSOLE)
|
||||
if (sa && sa->spacetype == SPACE_CONSOLE)
|
||||
return sa->spacedata.first;
|
||||
return NULL;
|
||||
}
|
||||
@ -629,7 +629,7 @@ struct SpaceConsole *CTX_wm_space_console(const bContext *C)
|
||||
struct SpaceImage *CTX_wm_space_image(const bContext *C)
|
||||
{
|
||||
ScrArea *sa = CTX_wm_area(C);
|
||||
if (sa && sa->spacetype==SPACE_IMAGE)
|
||||
if (sa && sa->spacetype == SPACE_IMAGE)
|
||||
return sa->spacedata.first;
|
||||
return NULL;
|
||||
}
|
||||
@ -637,7 +637,7 @@ struct SpaceImage *CTX_wm_space_image(const bContext *C)
|
||||
struct SpaceButs *CTX_wm_space_buts(const bContext *C)
|
||||
{
|
||||
ScrArea *sa = CTX_wm_area(C);
|
||||
if (sa && sa->spacetype==SPACE_BUTS)
|
||||
if (sa && sa->spacetype == SPACE_BUTS)
|
||||
return sa->spacedata.first;
|
||||
return NULL;
|
||||
}
|
||||
@ -645,7 +645,7 @@ struct SpaceButs *CTX_wm_space_buts(const bContext *C)
|
||||
struct SpaceFile *CTX_wm_space_file(const bContext *C)
|
||||
{
|
||||
ScrArea *sa = CTX_wm_area(C);
|
||||
if (sa && sa->spacetype==SPACE_FILE)
|
||||
if (sa && sa->spacetype == SPACE_FILE)
|
||||
return sa->spacedata.first;
|
||||
return NULL;
|
||||
}
|
||||
@ -653,7 +653,7 @@ struct SpaceFile *CTX_wm_space_file(const bContext *C)
|
||||
struct SpaceSeq *CTX_wm_space_seq(const bContext *C)
|
||||
{
|
||||
ScrArea *sa = CTX_wm_area(C);
|
||||
if (sa && sa->spacetype==SPACE_SEQ)
|
||||
if (sa && sa->spacetype == SPACE_SEQ)
|
||||
return sa->spacedata.first;
|
||||
return NULL;
|
||||
}
|
||||
@ -661,7 +661,7 @@ struct SpaceSeq *CTX_wm_space_seq(const bContext *C)
|
||||
struct SpaceOops *CTX_wm_space_outliner(const bContext *C)
|
||||
{
|
||||
ScrArea *sa = CTX_wm_area(C);
|
||||
if (sa && sa->spacetype==SPACE_OUTLINER)
|
||||
if (sa && sa->spacetype == SPACE_OUTLINER)
|
||||
return sa->spacedata.first;
|
||||
return NULL;
|
||||
}
|
||||
@ -669,7 +669,7 @@ struct SpaceOops *CTX_wm_space_outliner(const bContext *C)
|
||||
struct SpaceNla *CTX_wm_space_nla(const bContext *C)
|
||||
{
|
||||
ScrArea *sa = CTX_wm_area(C);
|
||||
if (sa && sa->spacetype==SPACE_NLA)
|
||||
if (sa && sa->spacetype == SPACE_NLA)
|
||||
return sa->spacedata.first;
|
||||
return NULL;
|
||||
}
|
||||
@ -677,7 +677,7 @@ struct SpaceNla *CTX_wm_space_nla(const bContext *C)
|
||||
struct SpaceTime *CTX_wm_space_time(const bContext *C)
|
||||
{
|
||||
ScrArea *sa = CTX_wm_area(C);
|
||||
if (sa && sa->spacetype==SPACE_TIME)
|
||||
if (sa && sa->spacetype == SPACE_TIME)
|
||||
return sa->spacedata.first;
|
||||
return NULL;
|
||||
}
|
||||
@ -685,7 +685,7 @@ struct SpaceTime *CTX_wm_space_time(const bContext *C)
|
||||
struct SpaceNode *CTX_wm_space_node(const bContext *C)
|
||||
{
|
||||
ScrArea *sa = CTX_wm_area(C);
|
||||
if (sa && sa->spacetype==SPACE_NODE)
|
||||
if (sa && sa->spacetype == SPACE_NODE)
|
||||
return sa->spacedata.first;
|
||||
return NULL;
|
||||
}
|
||||
@ -693,7 +693,7 @@ struct SpaceNode *CTX_wm_space_node(const bContext *C)
|
||||
struct SpaceLogic *CTX_wm_space_logic(const bContext *C)
|
||||
{
|
||||
ScrArea *sa = CTX_wm_area(C);
|
||||
if (sa && sa->spacetype==SPACE_LOGIC)
|
||||
if (sa && sa->spacetype == SPACE_LOGIC)
|
||||
return sa->spacedata.first;
|
||||
return NULL;
|
||||
}
|
||||
@ -701,7 +701,7 @@ struct SpaceLogic *CTX_wm_space_logic(const bContext *C)
|
||||
struct SpaceIpo *CTX_wm_space_graph(const bContext *C)
|
||||
{
|
||||
ScrArea *sa = CTX_wm_area(C);
|
||||
if (sa && sa->spacetype==SPACE_IPO)
|
||||
if (sa && sa->spacetype == SPACE_IPO)
|
||||
return sa->spacedata.first;
|
||||
return NULL;
|
||||
}
|
||||
@ -709,7 +709,7 @@ struct SpaceIpo *CTX_wm_space_graph(const bContext *C)
|
||||
struct SpaceAction *CTX_wm_space_action(const bContext *C)
|
||||
{
|
||||
ScrArea *sa = CTX_wm_area(C);
|
||||
if (sa && sa->spacetype==SPACE_ACTION)
|
||||
if (sa && sa->spacetype == SPACE_ACTION)
|
||||
return sa->spacedata.first;
|
||||
return NULL;
|
||||
}
|
||||
@ -717,7 +717,7 @@ struct SpaceAction *CTX_wm_space_action(const bContext *C)
|
||||
struct SpaceInfo *CTX_wm_space_info(const bContext *C)
|
||||
{
|
||||
ScrArea *sa = CTX_wm_area(C);
|
||||
if (sa && sa->spacetype==SPACE_INFO)
|
||||
if (sa && sa->spacetype == SPACE_INFO)
|
||||
return sa->spacedata.first;
|
||||
return NULL;
|
||||
}
|
||||
@ -725,7 +725,7 @@ struct SpaceInfo *CTX_wm_space_info(const bContext *C)
|
||||
struct SpaceUserPref *CTX_wm_space_userpref(const bContext *C)
|
||||
{
|
||||
ScrArea *sa = CTX_wm_area(C);
|
||||
if (sa && sa->spacetype==SPACE_USERPREF)
|
||||
if (sa && sa->spacetype == SPACE_USERPREF)
|
||||
return sa->spacedata.first;
|
||||
return NULL;
|
||||
}
|
||||
@ -733,58 +733,58 @@ struct SpaceUserPref *CTX_wm_space_userpref(const bContext *C)
|
||||
struct SpaceClip *CTX_wm_space_clip(const bContext *C)
|
||||
{
|
||||
ScrArea *sa = CTX_wm_area(C);
|
||||
if (sa && sa->spacetype==SPACE_CLIP)
|
||||
if (sa && sa->spacetype == SPACE_CLIP)
|
||||
return sa->spacedata.first;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void CTX_wm_manager_set(bContext *C, wmWindowManager *wm)
|
||||
{
|
||||
C->wm.manager= wm;
|
||||
C->wm.window= NULL;
|
||||
C->wm.screen= NULL;
|
||||
C->wm.area= NULL;
|
||||
C->wm.region= NULL;
|
||||
C->wm.manager = wm;
|
||||
C->wm.window = NULL;
|
||||
C->wm.screen = NULL;
|
||||
C->wm.area = NULL;
|
||||
C->wm.region = NULL;
|
||||
}
|
||||
|
||||
void CTX_wm_window_set(bContext *C, wmWindow *win)
|
||||
{
|
||||
C->wm.window= win;
|
||||
C->wm.screen= (win)? win->screen: NULL;
|
||||
C->wm.window = win;
|
||||
C->wm.screen = (win) ? win->screen : NULL;
|
||||
if (C->wm.screen)
|
||||
C->data.scene= C->wm.screen->scene;
|
||||
C->wm.area= NULL;
|
||||
C->wm.region= NULL;
|
||||
C->data.scene = C->wm.screen->scene;
|
||||
C->wm.area = NULL;
|
||||
C->wm.region = NULL;
|
||||
}
|
||||
|
||||
void CTX_wm_screen_set(bContext *C, bScreen *screen)
|
||||
{
|
||||
C->wm.screen= screen;
|
||||
C->wm.screen = screen;
|
||||
if (C->wm.screen)
|
||||
C->data.scene= C->wm.screen->scene;
|
||||
C->wm.area= NULL;
|
||||
C->wm.region= NULL;
|
||||
C->data.scene = C->wm.screen->scene;
|
||||
C->wm.area = NULL;
|
||||
C->wm.region = NULL;
|
||||
}
|
||||
|
||||
void CTX_wm_area_set(bContext *C, ScrArea *area)
|
||||
{
|
||||
C->wm.area= area;
|
||||
C->wm.region= NULL;
|
||||
C->wm.area = area;
|
||||
C->wm.region = NULL;
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
C->wm.menu= menu;
|
||||
C->wm.menu = menu;
|
||||
}
|
||||
|
||||
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)
|
||||
@ -798,7 +798,7 @@ Main *CTX_data_main(const bContext *C)
|
||||
{
|
||||
Main *bmain;
|
||||
|
||||
if (ctx_data_pointer_verify(C, "blend_data", (void*)&bmain))
|
||||
if (ctx_data_pointer_verify(C, "blend_data", (void *)&bmain))
|
||||
return bmain;
|
||||
else
|
||||
return C->data.main;
|
||||
@ -806,14 +806,14 @@ Main *CTX_data_main(const bContext *C)
|
||||
|
||||
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 *scene;
|
||||
|
||||
if (ctx_data_pointer_verify(C, "scene", (void*)&scene))
|
||||
if (ctx_data_pointer_verify(C, "scene", (void *)&scene))
|
||||
return scene;
|
||||
else
|
||||
return C->data.scene;
|
||||
@ -821,7 +821,7 @@ Scene *CTX_data_scene(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) {
|
||||
switch (obedit->type) {
|
||||
@ -884,7 +884,7 @@ const char *CTX_data_mode_string(const bContext *C)
|
||||
|
||||
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)
|
||||
|
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
@ -104,66 +104,66 @@ static FModifierTypeInfo FMI_MODNAME = {
|
||||
* - Factorized form - (y = (C[0][0]*x + C[0][1]) * (C[1][0]*x + C[1][1]) * ... * (C[n][0]*x + C[n][1]))
|
||||
*/
|
||||
|
||||
static void fcm_generator_free (FModifier *fcm)
|
||||
static void fcm_generator_free(FModifier *fcm)
|
||||
{
|
||||
FMod_Generator *data= (FMod_Generator *)fcm->data;
|
||||
FMod_Generator *data = (FMod_Generator *)fcm->data;
|
||||
|
||||
/* free polynomial coefficients array */
|
||||
if (data->coefficients)
|
||||
MEM_freeN(data->coefficients);
|
||||
}
|
||||
|
||||
static void fcm_generator_copy (FModifier *fcm, FModifier *src)
|
||||
static void fcm_generator_copy(FModifier *fcm, FModifier *src)
|
||||
{
|
||||
FMod_Generator *gen= (FMod_Generator *)fcm->data;
|
||||
FMod_Generator *ogen= (FMod_Generator *)src->data;
|
||||
FMod_Generator *gen = (FMod_Generator *)fcm->data;
|
||||
FMod_Generator *ogen = (FMod_Generator *)src->data;
|
||||
|
||||
/* copy coefficients array? */
|
||||
if (ogen->coefficients)
|
||||
gen->coefficients= MEM_dupallocN(ogen->coefficients);
|
||||
gen->coefficients = MEM_dupallocN(ogen->coefficients);
|
||||
}
|
||||
|
||||
static void fcm_generator_new_data (void *mdata)
|
||||
static void fcm_generator_new_data(void *mdata)
|
||||
{
|
||||
FMod_Generator *data= (FMod_Generator *)mdata;
|
||||
FMod_Generator *data = (FMod_Generator *)mdata;
|
||||
float *cp;
|
||||
|
||||
/* set default generator to be linear 0-1 (gradient = 1, y-offset = 0) */
|
||||
data->poly_order= 1;
|
||||
data->arraysize= 2;
|
||||
cp= data->coefficients= MEM_callocN(sizeof(float)*2, "FMod_Generator_Coefs");
|
||||
data->poly_order = 1;
|
||||
data->arraysize = 2;
|
||||
cp = data->coefficients = MEM_callocN(sizeof(float) * 2, "FMod_Generator_Coefs");
|
||||
cp[0] = 0; // y-offset
|
||||
cp[1] = 1; // gradient
|
||||
}
|
||||
|
||||
static void fcm_generator_verify (FModifier *fcm)
|
||||
static void fcm_generator_verify(FModifier *fcm)
|
||||
{
|
||||
FMod_Generator *data= (FMod_Generator *)fcm->data;
|
||||
FMod_Generator *data = (FMod_Generator *)fcm->data;
|
||||
|
||||
/* requirements depend on mode */
|
||||
switch (data->mode) {
|
||||
case FCM_GENERATOR_POLYNOMIAL: /* expanded polynomial expression */
|
||||
{
|
||||
/* arraysize needs to be order+1, so resize if not */
|
||||
if (data->arraysize != (data->poly_order+1)) {
|
||||
if (data->arraysize != (data->poly_order + 1)) {
|
||||
float *nc;
|
||||
|
||||
/* make new coefficients array, and copy over as much data as can fit */
|
||||
nc= MEM_callocN(sizeof(float)*(data->poly_order+1), "FMod_Generator_Coefs");
|
||||
nc = MEM_callocN(sizeof(float) * (data->poly_order + 1), "FMod_Generator_Coefs");
|
||||
|
||||
if (data->coefficients) {
|
||||
if ((int)data->arraysize > (data->poly_order+1))
|
||||
memcpy(nc, data->coefficients, sizeof(float)*(data->poly_order+1));
|
||||
if ((int)data->arraysize > (data->poly_order + 1))
|
||||
memcpy(nc, data->coefficients, sizeof(float) * (data->poly_order + 1));
|
||||
else
|
||||
memcpy(nc, data->coefficients, sizeof(float)*data->arraysize);
|
||||
memcpy(nc, data->coefficients, sizeof(float) * data->arraysize);
|
||||
|
||||
/* free the old data */
|
||||
MEM_freeN(data->coefficients);
|
||||
}
|
||||
|
||||
/* set the new data */
|
||||
data->coefficients= nc;
|
||||
data->arraysize= data->poly_order+1;
|
||||
data->coefficients = nc;
|
||||
data->arraysize = data->poly_order + 1;
|
||||
}
|
||||
}
|
||||
break;
|
||||
@ -175,30 +175,30 @@ static void fcm_generator_verify (FModifier *fcm)
|
||||
float *nc;
|
||||
|
||||
/* make new coefficients array, and copy over as much data as can fit */
|
||||
nc= MEM_callocN(sizeof(float)*(data->poly_order*2), "FMod_Generator_Coefs");
|
||||
nc = MEM_callocN(sizeof(float) * (data->poly_order * 2), "FMod_Generator_Coefs");
|
||||
|
||||
if (data->coefficients) {
|
||||
if (data->arraysize > (unsigned int)(data->poly_order * 2))
|
||||
memcpy(nc, data->coefficients, sizeof(float)*(data->poly_order * 2));
|
||||
memcpy(nc, data->coefficients, sizeof(float) * (data->poly_order * 2));
|
||||
else
|
||||
memcpy(nc, data->coefficients, sizeof(float)*data->arraysize);
|
||||
memcpy(nc, data->coefficients, sizeof(float) * data->arraysize);
|
||||
|
||||
/* free the old data */
|
||||
MEM_freeN(data->coefficients);
|
||||
}
|
||||
|
||||
/* set the new data */
|
||||
data->coefficients= nc;
|
||||
data->arraysize= data->poly_order * 2;
|
||||
data->coefficients = nc;
|
||||
data->arraysize = data->poly_order * 2;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void fcm_generator_evaluate (FCurve *UNUSED(fcu), FModifier *fcm, float *cvalue, float evaltime)
|
||||
static void fcm_generator_evaluate(FCurve *UNUSED(fcu), FModifier *fcm, float *cvalue, float evaltime)
|
||||
{
|
||||
FMod_Generator *data= (FMod_Generator *)fcm->data;
|
||||
FMod_Generator *data = (FMod_Generator *)fcm->data;
|
||||
|
||||
/* behavior depends on mode
|
||||
* NOTE: the data in its default state is fine too
|
||||
@ -207,23 +207,23 @@ static void fcm_generator_evaluate (FCurve *UNUSED(fcu), FModifier *fcm, float *
|
||||
case FCM_GENERATOR_POLYNOMIAL: /* expanded polynomial expression */
|
||||
{
|
||||
/* we overwrite cvalue with the sum of the polynomial */
|
||||
float *powers = MEM_callocN(sizeof(float)*data->arraysize, "Poly Powers");
|
||||
float value= 0.0f;
|
||||
float *powers = MEM_callocN(sizeof(float) * data->arraysize, "Poly Powers");
|
||||
float value = 0.0f;
|
||||
unsigned int i;
|
||||
|
||||
/* for each x^n, precalculate value based on previous one first... this should be
|
||||
* faster that calling pow() for each entry
|
||||
*/
|
||||
for (i=0; i < data->arraysize; i++) {
|
||||
for (i = 0; i < data->arraysize; i++) {
|
||||
/* first entry is x^0 = 1, otherwise, calculate based on previous */
|
||||
if (i)
|
||||
powers[i]= powers[i-1] * evaltime;
|
||||
powers[i] = powers[i - 1] * evaltime;
|
||||
else
|
||||
powers[0]= 1;
|
||||
powers[0] = 1;
|
||||
}
|
||||
|
||||
/* for each coefficient, add to value, which we'll write to *cvalue in one go */
|
||||
for (i=0; i < data->arraysize; i++)
|
||||
for (i = 0; i < data->arraysize; i++)
|
||||
value += data->coefficients[i] * powers[i];
|
||||
|
||||
/* only if something changed, write *cvalue in one go */
|
||||
@ -231,7 +231,7 @@ static void fcm_generator_evaluate (FCurve *UNUSED(fcu), FModifier *fcm, float *
|
||||
if (data->flag & FCM_GENERATOR_ADDITIVE)
|
||||
*cvalue += value;
|
||||
else
|
||||
*cvalue= value;
|
||||
*cvalue = value;
|
||||
}
|
||||
|
||||
/* cleanup */
|
||||
@ -242,19 +242,19 @@ static void fcm_generator_evaluate (FCurve *UNUSED(fcu), FModifier *fcm, float *
|
||||
|
||||
case FCM_GENERATOR_POLYNOMIAL_FACTORISED: /* Factorized polynomial */
|
||||
{
|
||||
float value= 1.0f, *cp=NULL;
|
||||
float value = 1.0f, *cp = NULL;
|
||||
unsigned int i;
|
||||
|
||||
/* for each coefficient pair, solve for that bracket before accumulating in value by multiplying */
|
||||
for (cp=data->coefficients, i=0; (cp) && (i < (unsigned int)data->poly_order); cp+=2, i++)
|
||||
value *= (cp[0]*evaltime + cp[1]);
|
||||
for (cp = data->coefficients, i = 0; (cp) && (i < (unsigned int)data->poly_order); cp += 2, i++)
|
||||
value *= (cp[0] * evaltime + cp[1]);
|
||||
|
||||
/* only if something changed, write *cvalue in one go */
|
||||
if (data->poly_order) {
|
||||
if (data->flag & FCM_GENERATOR_ADDITIVE)
|
||||
*cvalue += value;
|
||||
else
|
||||
*cvalue= value;
|
||||
*cvalue = value;
|
||||
}
|
||||
}
|
||||
break;
|
||||
@ -288,20 +288,20 @@ static FModifierTypeInfo FMI_GENERATOR = {
|
||||
* sin, cos, tan, sinc (normalised sin), natural log, square root
|
||||
*/
|
||||
|
||||
static void fcm_fn_generator_new_data (void *mdata)
|
||||
static void fcm_fn_generator_new_data(void *mdata)
|
||||
{
|
||||
FMod_FunctionGenerator *data= (FMod_FunctionGenerator *)mdata;
|
||||
FMod_FunctionGenerator *data = (FMod_FunctionGenerator *)mdata;
|
||||
|
||||
/* set amplitude and phase multiplier to 1.0f so that something is generated */
|
||||
data->amplitude= 1.0f;
|
||||
data->phase_multiplier= 1.0f;
|
||||
data->amplitude = 1.0f;
|
||||
data->phase_multiplier = 1.0f;
|
||||
}
|
||||
|
||||
/* Unary 'normalised sine' function
|
||||
* y = sin(PI + x) / (PI * x),
|
||||
* except for x = 0 when y = 1.
|
||||
*/
|
||||
static double sinc (double x)
|
||||
static double sinc(double x)
|
||||
{
|
||||
if (fabs(x) < 0.0001)
|
||||
return 1.0;
|
||||
@ -309,10 +309,10 @@ static double sinc (double x)
|
||||
return sin(M_PI * x) / (M_PI * x);
|
||||
}
|
||||
|
||||
static void fcm_fn_generator_evaluate (FCurve *UNUSED(fcu), FModifier *fcm, float *cvalue, float evaltime)
|
||||
static void fcm_fn_generator_evaluate(FCurve *UNUSED(fcu), FModifier *fcm, float *cvalue, float evaltime)
|
||||
{
|
||||
FMod_FunctionGenerator *data= (FMod_FunctionGenerator *)fcm->data;
|
||||
double arg= data->phase_multiplier*evaltime + data->phase_offset;
|
||||
FMod_FunctionGenerator *data = (FMod_FunctionGenerator *)fcm->data;
|
||||
double arg = data->phase_multiplier * evaltime + data->phase_offset;
|
||||
double (*fn)(double v) = NULL;
|
||||
|
||||
/* get function pointer to the func to use:
|
||||
@ -321,13 +321,13 @@ static void fcm_fn_generator_evaluate (FCurve *UNUSED(fcu), FModifier *fcm, floa
|
||||
switch (data->type) {
|
||||
/* simple ones */
|
||||
case FCM_GENERATOR_FN_SIN: /* sine wave */
|
||||
fn= sin;
|
||||
fn = sin;
|
||||
break;
|
||||
case FCM_GENERATOR_FN_COS: /* cosine wave */
|
||||
fn= cos;
|
||||
fn = cos;
|
||||
break;
|
||||
case FCM_GENERATOR_FN_SINC: /* normalised sine wave */
|
||||
fn= sinc;
|
||||
fn = sinc;
|
||||
break;
|
||||
|
||||
/* validation required */
|
||||
@ -339,14 +339,14 @@ static void fcm_fn_generator_evaluate (FCurve *UNUSED(fcu), FModifier *fcm, floa
|
||||
*cvalue = 0.0f; /* no value possible here */
|
||||
}
|
||||
else
|
||||
fn= tan;
|
||||
fn = tan;
|
||||
}
|
||||
break;
|
||||
case FCM_GENERATOR_FN_LN: /* natural log */
|
||||
{
|
||||
/* check that value is greater than 1? */
|
||||
if (arg > 1.0) {
|
||||
fn= log;
|
||||
fn = log;
|
||||
}
|
||||
else {
|
||||
if ((data->flag & FCM_GENERATOR_ADDITIVE) == 0)
|
||||
@ -358,7 +358,7 @@ static void fcm_fn_generator_evaluate (FCurve *UNUSED(fcu), FModifier *fcm, floa
|
||||
{
|
||||
/* no negative numbers */
|
||||
if (arg > 0.0) {
|
||||
fn= sqrt;
|
||||
fn = sqrt;
|
||||
}
|
||||
else {
|
||||
if ((data->flag & FCM_GENERATOR_ADDITIVE) == 0)
|
||||
@ -373,12 +373,12 @@ static void fcm_fn_generator_evaluate (FCurve *UNUSED(fcu), FModifier *fcm, floa
|
||||
|
||||
/* execute function callback to set value if appropriate */
|
||||
if (fn) {
|
||||
float value= (float)(data->amplitude*(float)fn(arg) + data->value_offset);
|
||||
float value = (float)(data->amplitude * (float)fn(arg) + data->value_offset);
|
||||
|
||||
if (data->flag & FCM_GENERATOR_ADDITIVE)
|
||||
*cvalue += value;
|
||||
else
|
||||
*cvalue= value;
|
||||
*cvalue = value;
|
||||
}
|
||||
}
|
||||
|
||||
@ -399,37 +399,37 @@ static FModifierTypeInfo FMI_FN_GENERATOR = {
|
||||
|
||||
/* Envelope F-Curve Modifier --------------------------- */
|
||||
|
||||
static void fcm_envelope_free (FModifier *fcm)
|
||||
static void fcm_envelope_free(FModifier *fcm)
|
||||
{
|
||||
FMod_Envelope *env= (FMod_Envelope *)fcm->data;
|
||||
FMod_Envelope *env = (FMod_Envelope *)fcm->data;
|
||||
|
||||
/* free envelope data array */
|
||||
if (env->data)
|
||||
MEM_freeN(env->data);
|
||||
}
|
||||
|
||||
static void fcm_envelope_copy (FModifier *fcm, FModifier *src)
|
||||
static void fcm_envelope_copy(FModifier *fcm, FModifier *src)
|
||||
{
|
||||
FMod_Envelope *env= (FMod_Envelope *)fcm->data;
|
||||
FMod_Envelope *oenv= (FMod_Envelope *)src->data;
|
||||
FMod_Envelope *env = (FMod_Envelope *)fcm->data;
|
||||
FMod_Envelope *oenv = (FMod_Envelope *)src->data;
|
||||
|
||||
/* copy envelope data array */
|
||||
if (oenv->data)
|
||||
env->data= MEM_dupallocN(oenv->data);
|
||||
env->data = MEM_dupallocN(oenv->data);
|
||||
}
|
||||
|
||||
static void fcm_envelope_new_data (void *mdata)
|
||||
static void fcm_envelope_new_data(void *mdata)
|
||||
{
|
||||
FMod_Envelope *env= (FMod_Envelope *)mdata;
|
||||
FMod_Envelope *env = (FMod_Envelope *)mdata;
|
||||
|
||||
/* set default min/max ranges */
|
||||
env->min= -1.0f;
|
||||
env->max= 1.0f;
|
||||
env->min = -1.0f;
|
||||
env->max = 1.0f;
|
||||
}
|
||||
|
||||
static void fcm_envelope_verify (FModifier *fcm)
|
||||
static void fcm_envelope_verify(FModifier *fcm)
|
||||
{
|
||||
FMod_Envelope *env= (FMod_Envelope *)fcm->data;
|
||||
FMod_Envelope *env = (FMod_Envelope *)fcm->data;
|
||||
|
||||
/* if the are points, perform bubble-sort on them, as user may have changed the order */
|
||||
if (env->data) {
|
||||
@ -437,44 +437,44 @@ static void fcm_envelope_verify (FModifier *fcm)
|
||||
}
|
||||
}
|
||||
|
||||
static void fcm_envelope_evaluate (FCurve *UNUSED(fcu), FModifier *fcm, float *cvalue, float evaltime)
|
||||
static void fcm_envelope_evaluate(FCurve *UNUSED(fcu), FModifier *fcm, float *cvalue, float evaltime)
|
||||
{
|
||||
FMod_Envelope *env= (FMod_Envelope *)fcm->data;
|
||||
FMod_Envelope *env = (FMod_Envelope *)fcm->data;
|
||||
FCM_EnvelopeData *fed, *prevfed, *lastfed;
|
||||
float min=0.0f, max=0.0f, fac=0.0f;
|
||||
float min = 0.0f, max = 0.0f, fac = 0.0f;
|
||||
int a;
|
||||
|
||||
/* get pointers */
|
||||
if (env->data == NULL) return;
|
||||
prevfed= env->data;
|
||||
fed= prevfed + 1;
|
||||
lastfed= prevfed + (env->totvert-1);
|
||||
prevfed = env->data;
|
||||
fed = prevfed + 1;
|
||||
lastfed = prevfed + (env->totvert - 1);
|
||||
|
||||
/* get min/max values for envelope at evaluation time (relative to mid-value) */
|
||||
if (prevfed->time >= evaltime) {
|
||||
/* before or on first sample, so just extend value */
|
||||
min= prevfed->min;
|
||||
max= prevfed->max;
|
||||
min = prevfed->min;
|
||||
max = prevfed->max;
|
||||
}
|
||||
else if (lastfed->time <= evaltime) {
|
||||
/* after or on last sample, so just extend value */
|
||||
min= lastfed->min;
|
||||
max= lastfed->max;
|
||||
min = lastfed->min;
|
||||
max = lastfed->max;
|
||||
}
|
||||
else {
|
||||
/* evaltime occurs somewhere between segments */
|
||||
// TODO: implement binary search for this to make it faster?
|
||||
for (a=0; prevfed && fed && (a < env->totvert-1); a++, prevfed=fed, fed++) {
|
||||
for (a = 0; prevfed && fed && (a < env->totvert - 1); a++, prevfed = fed, fed++) {
|
||||
/* evaltime occurs within the interval defined by these two envelope points */
|
||||
if ((prevfed->time <= evaltime) && (fed->time >= evaltime)) {
|
||||
float afac, bfac, diff;
|
||||
|
||||
diff= fed->time - prevfed->time;
|
||||
afac= (evaltime - prevfed->time) / diff;
|
||||
bfac= (fed->time - evaltime) / diff;
|
||||
diff = fed->time - prevfed->time;
|
||||
afac = (evaltime - prevfed->time) / diff;
|
||||
bfac = (fed->time - evaltime) / diff;
|
||||
|
||||
min= bfac*prevfed->min + afac*fed->min;
|
||||
max= bfac*prevfed->max + afac*fed->max;
|
||||
min = bfac * prevfed->min + afac * fed->min;
|
||||
max = bfac * prevfed->max + afac * fed->max;
|
||||
|
||||
break;
|
||||
}
|
||||
@ -485,8 +485,8 @@ static void fcm_envelope_evaluate (FCurve *UNUSED(fcu), FModifier *fcm, float *c
|
||||
* - fac is the ratio of how the current y-value corresponds to the reference range
|
||||
* - thus, the new value is found by mapping the old range to the new!
|
||||
*/
|
||||
fac= (*cvalue - (env->midval + env->min)) / (env->max - env->min);
|
||||
*cvalue= min + fac*(max - min);
|
||||
fac = (*cvalue - (env->midval + env->min)) / (env->max - env->min);
|
||||
*cvalue = min + fac * (max - min);
|
||||
}
|
||||
|
||||
static FModifierTypeInfo FMI_ENVELOPE = {
|
||||
@ -523,20 +523,20 @@ typedef struct tFCMED_Cycles {
|
||||
float cycyofs; /* y-offset to apply */
|
||||
} tFCMED_Cycles;
|
||||
|
||||
static void fcm_cycles_new_data (void *mdata)
|
||||
static void fcm_cycles_new_data(void *mdata)
|
||||
{
|
||||
FMod_Cycles *data= (FMod_Cycles *)mdata;
|
||||
FMod_Cycles *data = (FMod_Cycles *)mdata;
|
||||
|
||||
/* turn on cycles by default */
|
||||
data->before_mode= data->after_mode= FCM_EXTRAPOLATE_CYCLIC;
|
||||
data->before_mode = data->after_mode = FCM_EXTRAPOLATE_CYCLIC;
|
||||
}
|
||||
|
||||
static float fcm_cycles_time (FCurve *fcu, FModifier *fcm, float UNUSED(cvalue), float evaltime)
|
||||
static float fcm_cycles_time(FCurve *fcu, FModifier *fcm, float UNUSED(cvalue), float evaltime)
|
||||
{
|
||||
FMod_Cycles *data= (FMod_Cycles *)fcm->data;
|
||||
float prevkey[2], lastkey[2], cycyofs=0.0f;
|
||||
short side=0, mode=0;
|
||||
int cycles=0, ofs=0;
|
||||
FMod_Cycles *data = (FMod_Cycles *)fcm->data;
|
||||
float prevkey[2], lastkey[2], cycyofs = 0.0f;
|
||||
short side = 0, mode = 0;
|
||||
int cycles = 0, ofs = 0;
|
||||
|
||||
/* check if modifier is first in stack, otherwise disable ourself... */
|
||||
// FIXME...
|
||||
@ -547,24 +547,24 @@ static float fcm_cycles_time (FCurve *fcu, FModifier *fcm, float UNUSED(cvalue),
|
||||
|
||||
/* calculate new evaltime due to cyclic interpolation */
|
||||
if (fcu && fcu->bezt) {
|
||||
BezTriple *prevbezt= fcu->bezt;
|
||||
BezTriple *lastbezt= prevbezt + fcu->totvert-1;
|
||||
BezTriple *prevbezt = fcu->bezt;
|
||||
BezTriple *lastbezt = prevbezt + fcu->totvert - 1;
|
||||
|
||||
prevkey[0]= prevbezt->vec[1][0];
|
||||
prevkey[1]= prevbezt->vec[1][1];
|
||||
prevkey[0] = prevbezt->vec[1][0];
|
||||
prevkey[1] = prevbezt->vec[1][1];
|
||||
|
||||
lastkey[0]= lastbezt->vec[1][0];
|
||||
lastkey[1]= lastbezt->vec[1][1];
|
||||
lastkey[0] = lastbezt->vec[1][0];
|
||||
lastkey[1] = lastbezt->vec[1][1];
|
||||
}
|
||||
else if (fcu && fcu->fpt) {
|
||||
FPoint *prevfpt= fcu->fpt;
|
||||
FPoint *lastfpt= prevfpt + fcu->totvert-1;
|
||||
FPoint *prevfpt = fcu->fpt;
|
||||
FPoint *lastfpt = prevfpt + fcu->totvert - 1;
|
||||
|
||||
prevkey[0]= prevfpt->vec[0];
|
||||
prevkey[1]= prevfpt->vec[1];
|
||||
prevkey[0] = prevfpt->vec[0];
|
||||
prevkey[1] = prevfpt->vec[1];
|
||||
|
||||
lastkey[0]= lastfpt->vec[0];
|
||||
lastkey[1]= lastfpt->vec[1];
|
||||
lastkey[0] = lastfpt->vec[0];
|
||||
lastkey[1] = lastfpt->vec[1];
|
||||
}
|
||||
else
|
||||
return evaltime;
|
||||
@ -575,18 +575,18 @@ static float fcm_cycles_time (FCurve *fcu, FModifier *fcm, float UNUSED(cvalue),
|
||||
*/
|
||||
if (evaltime < prevkey[0]) {
|
||||
if (data->before_mode) {
|
||||
side= -1;
|
||||
mode= data->before_mode;
|
||||
cycles= data->before_cycles;
|
||||
ofs= prevkey[0];
|
||||
side = -1;
|
||||
mode = data->before_mode;
|
||||
cycles = data->before_cycles;
|
||||
ofs = prevkey[0];
|
||||
}
|
||||
}
|
||||
else if (evaltime > lastkey[0]) {
|
||||
if (data->after_mode) {
|
||||
side= 1;
|
||||
mode= data->after_mode;
|
||||
cycles= data->after_cycles;
|
||||
ofs= lastkey[0];
|
||||
side = 1;
|
||||
mode = data->after_mode;
|
||||
cycles = data->after_cycles;
|
||||
ofs = lastkey[0];
|
||||
}
|
||||
}
|
||||
if ((ELEM(0, side, mode)))
|
||||
@ -594,22 +594,22 @@ static float fcm_cycles_time (FCurve *fcu, FModifier *fcm, float UNUSED(cvalue),
|
||||
|
||||
/* find relative place within a cycle */
|
||||
{
|
||||
float cycdx=0, cycdy=0;
|
||||
float cycle= 0, cyct=0;
|
||||
float cycdx = 0, cycdy = 0;
|
||||
float cycle = 0, cyct = 0;
|
||||
|
||||
/* calculate period and amplitude (total height) of a cycle */
|
||||
cycdx= lastkey[0] - prevkey[0];
|
||||
cycdy= lastkey[1] - prevkey[1];
|
||||
cycdx = lastkey[0] - prevkey[0];
|
||||
cycdy = lastkey[1] - prevkey[1];
|
||||
|
||||
/* check if cycle is infinitely small, to be point of being impossible to use */
|
||||
if (cycdx == 0)
|
||||
return evaltime;
|
||||
|
||||
/* calculate the 'number' of the cycle */
|
||||
cycle= ((float)side * (evaltime - ofs) / cycdx);
|
||||
cycle = ((float)side * (evaltime - ofs) / cycdx);
|
||||
|
||||
/* calculate the time inside the cycle */
|
||||
cyct= fmod(evaltime - ofs, cycdx);
|
||||
cyct = fmod(evaltime - ofs, cycdx);
|
||||
|
||||
/* check that cyclic is still enabled for the specified time */
|
||||
if (cycles == 0) {
|
||||
@ -641,19 +641,19 @@ static float fcm_cycles_time (FCurve *fcu, FModifier *fcm, float UNUSED(cvalue),
|
||||
evaltime = (side == 1 ? prevkey[0] : lastkey[0]);
|
||||
}
|
||||
/* calculate where in the cycle we are (overwrite evaltime to reflect this) */
|
||||
else if ((mode == FCM_EXTRAPOLATE_MIRROR) && ((int)(cycle+1) % 2)) {
|
||||
else if ((mode == FCM_EXTRAPOLATE_MIRROR) && ((int)(cycle + 1) % 2)) {
|
||||
/* when 'mirror' option is used and cycle number is odd, this cycle is played in reverse
|
||||
* - for 'before' extrapolation, we need to flip in a different way, otherwise values past
|
||||
* then end of the curve get referenced (result of fmod will be negative, and with different phase)
|
||||
*/
|
||||
if (side < 0)
|
||||
evaltime= prevkey[0] - cyct;
|
||||
evaltime = prevkey[0] - cyct;
|
||||
else
|
||||
evaltime= lastkey[0] - cyct;
|
||||
evaltime = lastkey[0] - cyct;
|
||||
}
|
||||
else {
|
||||
/* the cycle is played normally... */
|
||||
evaltime= prevkey[0] + cyct;
|
||||
evaltime = prevkey[0] + cyct;
|
||||
}
|
||||
if (evaltime < prevkey[0]) evaltime += cycdx;
|
||||
}
|
||||
@ -663,17 +663,17 @@ static float fcm_cycles_time (FCurve *fcu, FModifier *fcm, float UNUSED(cvalue),
|
||||
tFCMED_Cycles *edata;
|
||||
|
||||
/* for now, this is just a float, but we could get more stuff... */
|
||||
fcm->edata= edata= MEM_callocN(sizeof(tFCMED_Cycles), "tFCMED_Cycles");
|
||||
edata->cycyofs= cycyofs;
|
||||
fcm->edata = edata = MEM_callocN(sizeof(tFCMED_Cycles), "tFCMED_Cycles");
|
||||
edata->cycyofs = cycyofs;
|
||||
}
|
||||
|
||||
/* return the new frame to evaluate */
|
||||
return evaltime;
|
||||
}
|
||||
|
||||
static void fcm_cycles_evaluate (FCurve *UNUSED(fcu), FModifier *fcm, float *cvalue, float UNUSED(evaltime))
|
||||
static void fcm_cycles_evaluate(FCurve *UNUSED(fcu), FModifier *fcm, float *cvalue, float UNUSED(evaltime))
|
||||
{
|
||||
tFCMED_Cycles *edata= (tFCMED_Cycles *)fcm->edata;
|
||||
tFCMED_Cycles *edata = (tFCMED_Cycles *)fcm->edata;
|
||||
|
||||
/* use temp data */
|
||||
if (edata) {
|
||||
@ -682,7 +682,7 @@ static void fcm_cycles_evaluate (FCurve *UNUSED(fcu), FModifier *fcm, float *cva
|
||||
|
||||
/* free temp data */
|
||||
MEM_freeN(edata);
|
||||
fcm->edata= NULL;
|
||||
fcm->edata = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
@ -703,21 +703,21 @@ static FModifierTypeInfo FMI_CYCLES = {
|
||||
|
||||
/* Noise F-Curve Modifier --------------------------- */
|
||||
|
||||
static void fcm_noise_new_data (void *mdata)
|
||||
static void fcm_noise_new_data(void *mdata)
|
||||
{
|
||||
FMod_Noise *data= (FMod_Noise *)mdata;
|
||||
FMod_Noise *data = (FMod_Noise *)mdata;
|
||||
|
||||
/* defaults */
|
||||
data->size= 1.0f;
|
||||
data->strength= 1.0f;
|
||||
data->phase= 1.0f;
|
||||
data->size = 1.0f;
|
||||
data->strength = 1.0f;
|
||||
data->phase = 1.0f;
|
||||
data->depth = 0;
|
||||
data->modification = FCM_NOISE_MODIF_REPLACE;
|
||||
}
|
||||
|
||||
static void fcm_noise_evaluate (FCurve *UNUSED(fcu), FModifier *fcm, float *cvalue, float evaltime)
|
||||
static void fcm_noise_evaluate(FCurve *UNUSED(fcu), FModifier *fcm, float *cvalue, float evaltime)
|
||||
{
|
||||
FMod_Noise *data= (FMod_Noise *)fcm->data;
|
||||
FMod_Noise *data = (FMod_Noise *)fcm->data;
|
||||
float noise;
|
||||
|
||||
/* generate noise using good ol' Blender Noise
|
||||
@ -729,17 +729,17 @@ static void fcm_noise_evaluate (FCurve *UNUSED(fcu), FModifier *fcm, float *cval
|
||||
/* combine the noise with existing motion data */
|
||||
switch (data->modification) {
|
||||
case FCM_NOISE_MODIF_ADD:
|
||||
*cvalue= *cvalue + noise * data->strength;
|
||||
*cvalue = *cvalue + noise * data->strength;
|
||||
break;
|
||||
case FCM_NOISE_MODIF_SUBTRACT:
|
||||
*cvalue= *cvalue - noise * data->strength;
|
||||
*cvalue = *cvalue - noise * data->strength;
|
||||
break;
|
||||
case FCM_NOISE_MODIF_MULTIPLY:
|
||||
*cvalue= *cvalue * noise * data->strength;
|
||||
*cvalue = *cvalue * noise * data->strength;
|
||||
break;
|
||||
case FCM_NOISE_MODIF_REPLACE:
|
||||
default:
|
||||
*cvalue= *cvalue + (noise - 0.5f) * data->strength;
|
||||
*cvalue = *cvalue + (noise - 0.5f) * data->strength;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -781,25 +781,25 @@ static FModifierTypeInfo FMI_FILTER = {
|
||||
|
||||
/* Python F-Curve Modifier --------------------------- */
|
||||
|
||||
static void fcm_python_free (FModifier *fcm)
|
||||
static void fcm_python_free(FModifier *fcm)
|
||||
{
|
||||
FMod_Python *data= (FMod_Python *)fcm->data;
|
||||
FMod_Python *data = (FMod_Python *)fcm->data;
|
||||
|
||||
/* id-properties */
|
||||
IDP_FreeProperty(data->prop);
|
||||
MEM_freeN(data->prop);
|
||||
}
|
||||
|
||||
static void fcm_python_new_data (void *mdata)
|
||||
static void fcm_python_new_data(void *mdata)
|
||||
{
|
||||
FMod_Python *data= (FMod_Python *)mdata;
|
||||
FMod_Python *data = (FMod_Python *)mdata;
|
||||
|
||||
/* everything should be set correctly by calloc, except for the prop->type constant.*/
|
||||
data->prop = MEM_callocN(sizeof(IDProperty), "PyFModifierProps");
|
||||
data->prop->type = IDP_GROUP;
|
||||
}
|
||||
|
||||
static void fcm_python_copy (FModifier *fcm, FModifier *src)
|
||||
static void fcm_python_copy(FModifier *fcm, FModifier *src)
|
||||
{
|
||||
FMod_Python *pymod = (FMod_Python *)fcm->data;
|
||||
FMod_Python *opymod = (FMod_Python *)src->data;
|
||||
@ -807,7 +807,7 @@ static void fcm_python_copy (FModifier *fcm, FModifier *src)
|
||||
pymod->prop = IDP_CopyProperty(opymod->prop);
|
||||
}
|
||||
|
||||
static void fcm_python_evaluate (FCurve *UNUSED(fcu), FModifier *UNUSED(fcm), float *UNUSED(cvalue), float UNUSED(evaltime))
|
||||
static void fcm_python_evaluate(FCurve *UNUSED(fcu), FModifier *UNUSED(fcm), float *UNUSED(cvalue), float UNUSED(evaltime))
|
||||
{
|
||||
#ifdef WITH_PYTHON
|
||||
//FMod_Python *data= (FMod_Python *)fcm->data;
|
||||
@ -836,9 +836,9 @@ static FModifierTypeInfo FMI_PYTHON = {
|
||||
|
||||
/* Limits F-Curve Modifier --------------------------- */
|
||||
|
||||
static float fcm_limits_time (FCurve *UNUSED(fcu), FModifier *fcm, float UNUSED(cvalue), float evaltime)
|
||||
static float fcm_limits_time(FCurve *UNUSED(fcu), FModifier *fcm, float UNUSED(cvalue), float evaltime)
|
||||
{
|
||||
FMod_Limits *data= (FMod_Limits *)fcm->data;
|
||||
FMod_Limits *data = (FMod_Limits *)fcm->data;
|
||||
|
||||
/* check for the time limits */
|
||||
if ((data->flag & FCM_LIMIT_XMIN) && (evaltime < data->rect.xmin))
|
||||
@ -850,15 +850,15 @@ static float fcm_limits_time (FCurve *UNUSED(fcu), FModifier *fcm, float UNUSED(
|
||||
return evaltime;
|
||||
}
|
||||
|
||||
static void fcm_limits_evaluate (FCurve *UNUSED(fcu), FModifier *fcm, float *cvalue, float UNUSED(evaltime))
|
||||
static void fcm_limits_evaluate(FCurve *UNUSED(fcu), FModifier *fcm, float *cvalue, float UNUSED(evaltime))
|
||||
{
|
||||
FMod_Limits *data= (FMod_Limits *)fcm->data;
|
||||
FMod_Limits *data = (FMod_Limits *)fcm->data;
|
||||
|
||||
/* value limits now */
|
||||
if ((data->flag & FCM_LIMIT_YMIN) && (*cvalue < data->rect.ymin))
|
||||
*cvalue= data->rect.ymin;
|
||||
*cvalue = data->rect.ymin;
|
||||
if ((data->flag & FCM_LIMIT_YMAX) && (*cvalue > data->rect.ymax))
|
||||
*cvalue= data->rect.ymax;
|
||||
*cvalue = data->rect.ymax;
|
||||
}
|
||||
|
||||
static FModifierTypeInfo FMI_LIMITS = {
|
||||
@ -878,18 +878,18 @@ static FModifierTypeInfo FMI_LIMITS = {
|
||||
|
||||
/* Stepped F-Curve Modifier --------------------------- */
|
||||
|
||||
static void fcm_stepped_new_data (void *mdata)
|
||||
static void fcm_stepped_new_data(void *mdata)
|
||||
{
|
||||
FMod_Stepped *data= (FMod_Stepped *)mdata;
|
||||
FMod_Stepped *data = (FMod_Stepped *)mdata;
|
||||
|
||||
/* just need to set the step-size to 2-frames by default */
|
||||
// XXX: or would 5 be more normal?
|
||||
data->step_size = 2.0f;
|
||||
}
|
||||
|
||||
static float fcm_stepped_time (FCurve *UNUSED(fcu), FModifier *fcm, float UNUSED(cvalue), float evaltime)
|
||||
static float fcm_stepped_time(FCurve *UNUSED(fcu), FModifier *fcm, float UNUSED(cvalue), float evaltime)
|
||||
{
|
||||
FMod_Stepped *data= (FMod_Stepped *)fcm->data;
|
||||
FMod_Stepped *data = (FMod_Stepped *)fcm->data;
|
||||
int snapblock;
|
||||
|
||||
/* check range clamping to see if we should alter the timing to achieve the desired results */
|
||||
@ -936,27 +936,27 @@ static FModifierTypeInfo FMI_STEPPED = {
|
||||
|
||||
/* These globals only ever get directly accessed in this file */
|
||||
static FModifierTypeInfo *fmodifiersTypeInfo[FMODIFIER_NUM_TYPES];
|
||||
static short FMI_INIT= 1; /* when non-zero, the list needs to be updated */
|
||||
static short FMI_INIT = 1; /* when non-zero, the list needs to be updated */
|
||||
|
||||
/* This function only gets called when FMI_INIT is non-zero */
|
||||
static void fmods_init_typeinfo (void)
|
||||
static void fmods_init_typeinfo(void)
|
||||
{
|
||||
fmodifiersTypeInfo[0]= NULL; /* 'Null' F-Curve Modifier */
|
||||
fmodifiersTypeInfo[1]= &FMI_GENERATOR; /* Generator F-Curve Modifier */
|
||||
fmodifiersTypeInfo[2]= &FMI_FN_GENERATOR; /* Built-In Function Generator F-Curve Modifier */
|
||||
fmodifiersTypeInfo[3]= &FMI_ENVELOPE; /* Envelope F-Curve Modifier */
|
||||
fmodifiersTypeInfo[4]= &FMI_CYCLES; /* Cycles F-Curve Modifier */
|
||||
fmodifiersTypeInfo[5]= &FMI_NOISE; /* Apply-Noise F-Curve Modifier */
|
||||
fmodifiersTypeInfo[6]= NULL/*&FMI_FILTER*/; /* Filter F-Curve Modifier */ // XXX unimplemented
|
||||
fmodifiersTypeInfo[7]= &FMI_PYTHON; /* Custom Python F-Curve Modifier */
|
||||
fmodifiersTypeInfo[8]= &FMI_LIMITS; /* Limits F-Curve Modifier */
|
||||
fmodifiersTypeInfo[9]= &FMI_STEPPED; /* Stepped F-Curve Modifier */
|
||||
fmodifiersTypeInfo[0] = NULL; /* 'Null' F-Curve Modifier */
|
||||
fmodifiersTypeInfo[1] = &FMI_GENERATOR; /* Generator F-Curve Modifier */
|
||||
fmodifiersTypeInfo[2] = &FMI_FN_GENERATOR; /* Built-In Function Generator F-Curve Modifier */
|
||||
fmodifiersTypeInfo[3] = &FMI_ENVELOPE; /* Envelope F-Curve Modifier */
|
||||
fmodifiersTypeInfo[4] = &FMI_CYCLES; /* Cycles F-Curve Modifier */
|
||||
fmodifiersTypeInfo[5] = &FMI_NOISE; /* Apply-Noise F-Curve Modifier */
|
||||
fmodifiersTypeInfo[6] = NULL /*&FMI_FILTER*/; /* Filter F-Curve Modifier */ // XXX unimplemented
|
||||
fmodifiersTypeInfo[7] = &FMI_PYTHON; /* Custom Python F-Curve Modifier */
|
||||
fmodifiersTypeInfo[8] = &FMI_LIMITS; /* Limits F-Curve Modifier */
|
||||
fmodifiersTypeInfo[9] = &FMI_STEPPED; /* Stepped F-Curve Modifier */
|
||||
}
|
||||
|
||||
/* This function should be used for getting the appropriate type-info when only
|
||||
* a F-Curve modifier type is known
|
||||
*/
|
||||
FModifierTypeInfo *get_fmodifier_typeinfo (int type)
|
||||
FModifierTypeInfo *get_fmodifier_typeinfo(int type)
|
||||
{
|
||||
/* initialize the type-info list? */
|
||||
if (FMI_INIT) {
|
||||
@ -966,7 +966,7 @@ FModifierTypeInfo *get_fmodifier_typeinfo (int type)
|
||||
|
||||
/* only return for valid types */
|
||||
if ( (type >= FMODIFIER_TYPE_NULL) &&
|
||||
(type <= FMODIFIER_NUM_TYPES ) )
|
||||
(type <= FMODIFIER_NUM_TYPES) )
|
||||
{
|
||||
/* there shouldn't be any segfaults here... */
|
||||
return fmodifiersTypeInfo[type];
|
||||
@ -981,7 +981,7 @@ FModifierTypeInfo *get_fmodifier_typeinfo (int type)
|
||||
/* This function should always be used to get the appropriate type-info, as it
|
||||
* has checks which prevent segfaults in some weird cases.
|
||||
*/
|
||||
FModifierTypeInfo *fmodifier_get_typeinfo (FModifier *fcm)
|
||||
FModifierTypeInfo *fmodifier_get_typeinfo(FModifier *fcm)
|
||||
{
|
||||
/* only return typeinfo for valid modifiers */
|
||||
if (fcm)
|
||||
@ -993,9 +993,9 @@ FModifierTypeInfo *fmodifier_get_typeinfo (FModifier *fcm)
|
||||
/* API --------------------------- */
|
||||
|
||||
/* Add a new F-Curve Modifier to the given F-Curve of a certain type */
|
||||
FModifier *add_fmodifier (ListBase *modifiers, int type)
|
||||
FModifier *add_fmodifier(ListBase *modifiers, int type)
|
||||
{
|
||||
FModifierTypeInfo *fmi= get_fmodifier_typeinfo(type);
|
||||
FModifierTypeInfo *fmi = get_fmodifier_typeinfo(type);
|
||||
FModifier *fcm;
|
||||
|
||||
/* sanity checks */
|
||||
@ -1011,7 +1011,7 @@ FModifier *add_fmodifier (ListBase *modifiers, int type)
|
||||
}
|
||||
|
||||
/* add modifier itself */
|
||||
fcm= MEM_callocN(sizeof(FModifier), "F-Curve Modifier");
|
||||
fcm = MEM_callocN(sizeof(FModifier), "F-Curve Modifier");
|
||||
fcm->type = type;
|
||||
fcm->flag = FMODIFIER_FLAG_EXPANDED;
|
||||
fcm->influence = 1.0f;
|
||||
@ -1022,7 +1022,7 @@ FModifier *add_fmodifier (ListBase *modifiers, int type)
|
||||
fcm->flag |= FMODIFIER_FLAG_ACTIVE;
|
||||
|
||||
/* add modifier's data */
|
||||
fcm->data= MEM_callocN(fmi->size, fmi->structName);
|
||||
fcm->data = MEM_callocN(fmi->size, fmi->structName);
|
||||
|
||||
/* init custom settings if necessary */
|
||||
if (fmi->new_data)
|
||||
@ -1033,9 +1033,9 @@ FModifier *add_fmodifier (ListBase *modifiers, int type)
|
||||
}
|
||||
|
||||
/* Make a copy of the specified F-Modifier */
|
||||
FModifier *copy_fmodifier (FModifier *src)
|
||||
FModifier *copy_fmodifier(FModifier *src)
|
||||
{
|
||||
FModifierTypeInfo *fmi= fmodifier_get_typeinfo(src);
|
||||
FModifierTypeInfo *fmi = fmodifier_get_typeinfo(src);
|
||||
FModifier *dst;
|
||||
|
||||
/* sanity check */
|
||||
@ -1065,11 +1065,11 @@ void copy_fmodifiers(ListBase *dst, ListBase *src)
|
||||
if (ELEM(NULL, dst, src))
|
||||
return;
|
||||
|
||||
dst->first= dst->last= NULL;
|
||||
dst->first = dst->last = NULL;
|
||||
BLI_duplicatelist(dst, src);
|
||||
|
||||
for (fcm=dst->first, srcfcm=src->first; fcm && srcfcm; srcfcm=srcfcm->next, fcm=fcm->next) {
|
||||
FModifierTypeInfo *fmi= fmodifier_get_typeinfo(fcm);
|
||||
for (fcm = dst->first, srcfcm = src->first; fcm && srcfcm; srcfcm = srcfcm->next, fcm = fcm->next) {
|
||||
FModifierTypeInfo *fmi = fmodifier_get_typeinfo(fcm);
|
||||
|
||||
/* make a new copy of the F-Modifier's data */
|
||||
fcm->data = MEM_dupallocN(fcm->data);
|
||||
@ -1083,7 +1083,7 @@ void copy_fmodifiers(ListBase *dst, ListBase *src)
|
||||
/* Remove and free the given F-Modifier from the given stack */
|
||||
int remove_fmodifier(ListBase *modifiers, FModifier *fcm)
|
||||
{
|
||||
FModifierTypeInfo *fmi= fmodifier_get_typeinfo(fcm);
|
||||
FModifierTypeInfo *fmi = fmodifier_get_typeinfo(fcm);
|
||||
|
||||
/* sanity check */
|
||||
if (fcm == NULL)
|
||||
@ -1121,14 +1121,14 @@ void free_fmodifiers(ListBase *modifiers)
|
||||
return;
|
||||
|
||||
/* free each modifier in order - modifier is unlinked from list and freed */
|
||||
for (fcm= modifiers->first; fcm; fcm= fmn) {
|
||||
fmn= fcm->next;
|
||||
for (fcm = modifiers->first; fcm; fcm = fmn) {
|
||||
fmn = fcm->next;
|
||||
remove_fmodifier(modifiers, fcm);
|
||||
}
|
||||
}
|
||||
|
||||
/* Find the active F-Modifier */
|
||||
FModifier *find_active_fmodifier (ListBase *modifiers)
|
||||
FModifier *find_active_fmodifier(ListBase *modifiers)
|
||||
{
|
||||
FModifier *fcm;
|
||||
|
||||
@ -1137,7 +1137,7 @@ FModifier *find_active_fmodifier (ListBase *modifiers)
|
||||
return NULL;
|
||||
|
||||
/* loop over modifiers until 'active' one is found */
|
||||
for (fcm= modifiers->first; fcm; fcm= fcm->next) {
|
||||
for (fcm = modifiers->first; fcm; fcm = fcm->next) {
|
||||
if (fcm->flag & FMODIFIER_FLAG_ACTIVE)
|
||||
return fcm;
|
||||
}
|
||||
@ -1156,7 +1156,7 @@ void set_active_fmodifier(ListBase *modifiers, FModifier *fcm)
|
||||
return;
|
||||
|
||||
/* deactivate all, and set current one active */
|
||||
for (fm= modifiers->first; fm; fm= fm->next)
|
||||
for (fm = modifiers->first; fm; fm = fm->next)
|
||||
fm->flag &= ~FMODIFIER_FLAG_ACTIVE;
|
||||
|
||||
/* make given modifier active */
|
||||
@ -1181,15 +1181,15 @@ short list_has_suitable_fmodifier(ListBase *modifiers, int mtype, short acttype)
|
||||
return 0;
|
||||
|
||||
/* find the first mdifier fitting these criteria */
|
||||
for (fcm= modifiers->first; fcm; fcm= fcm->next) {
|
||||
FModifierTypeInfo *fmi= fmodifier_get_typeinfo(fcm);
|
||||
short mOk=1, aOk=1; /* by default 1, so that when only one test, won't fail */
|
||||
for (fcm = modifiers->first; fcm; fcm = fcm->next) {
|
||||
FModifierTypeInfo *fmi = fmodifier_get_typeinfo(fcm);
|
||||
short mOk = 1, aOk = 1; /* by default 1, so that when only one test, won't fail */
|
||||
|
||||
/* check if applicable ones are fullfilled */
|
||||
if (mtype)
|
||||
mOk= (fcm->type == mtype);
|
||||
mOk = (fcm->type == mtype);
|
||||
if (acttype > -1)
|
||||
aOk= (fmi->acttype == acttype);
|
||||
aOk = (fmi->acttype == acttype);
|
||||
|
||||
/* if both are ok, we've found a hit */
|
||||
if (mOk && aOk)
|
||||
@ -1203,7 +1203,7 @@ short list_has_suitable_fmodifier(ListBase *modifiers, int mtype, short acttype)
|
||||
/* Evaluation API --------------------------- */
|
||||
|
||||
/* helper function - calculate influence of FModifier */
|
||||
static float eval_fmodifier_influence (FModifier *fcm, float evaltime)
|
||||
static float eval_fmodifier_influence(FModifier *fcm, float evaltime)
|
||||
{
|
||||
float influence;
|
||||
|
||||
@ -1270,8 +1270,8 @@ float evaluate_time_fmodifiers(ListBase *modifiers, FCurve *fcu, float cvalue, f
|
||||
* effect, which should get us the desired effects when using layered time manipulations
|
||||
* (such as multiple 'stepped' modifiers in sequence, causing different stepping rates)
|
||||
*/
|
||||
for (fcm= modifiers->last; fcm; fcm= fcm->prev) {
|
||||
FModifierTypeInfo *fmi= fmodifier_get_typeinfo(fcm);
|
||||
for (fcm = modifiers->last; fcm; fcm = fcm->prev) {
|
||||
FModifierTypeInfo *fmi = fmodifier_get_typeinfo(fcm);
|
||||
|
||||
if (fmi == NULL)
|
||||
continue;
|
||||
@ -1279,12 +1279,12 @@ float evaluate_time_fmodifiers(ListBase *modifiers, FCurve *fcu, float cvalue, f
|
||||
/* if modifier cannot be applied on this frame (whatever scale it is on, it won't affect the results)
|
||||
* hence we shouldn't bother seeing what it would do given the chance
|
||||
*/
|
||||
if ((fcm->flag & FMODIFIER_FLAG_RANGERESTRICT)==0 ||
|
||||
if ((fcm->flag & FMODIFIER_FLAG_RANGERESTRICT) == 0 ||
|
||||
((fcm->sfra <= evaltime) && (fcm->efra >= evaltime)) )
|
||||
{
|
||||
/* only evaluate if there's a callback for this */
|
||||
if (fmi->evaluate_modifier_time) {
|
||||
if ((fcm->flag & (FMODIFIER_FLAG_DISABLED|FMODIFIER_FLAG_MUTED)) == 0) {
|
||||
if ((fcm->flag & (FMODIFIER_FLAG_DISABLED | FMODIFIER_FLAG_MUTED)) == 0) {
|
||||
float influence = eval_fmodifier_influence(fcm, evaltime);
|
||||
float nval = fmi->evaluate_modifier_time(fcu, fcm, cvalue, evaltime);
|
||||
|
||||
@ -1310,18 +1310,18 @@ void evaluate_value_fmodifiers(ListBase *modifiers, FCurve *fcu, float *cvalue,
|
||||
return;
|
||||
|
||||
/* evaluate modifiers */
|
||||
for (fcm= modifiers->first; fcm; fcm= fcm->next) {
|
||||
FModifierTypeInfo *fmi= fmodifier_get_typeinfo(fcm);
|
||||
for (fcm = modifiers->first; fcm; fcm = fcm->next) {
|
||||
FModifierTypeInfo *fmi = fmodifier_get_typeinfo(fcm);
|
||||
|
||||
if (fmi == NULL)
|
||||
continue;
|
||||
|
||||
/* only evaluate if there's a callback for this, and if F-Modifier can be evaluated on this frame */
|
||||
if ((fcm->flag & FMODIFIER_FLAG_RANGERESTRICT)==0 ||
|
||||
if ((fcm->flag & FMODIFIER_FLAG_RANGERESTRICT) == 0 ||
|
||||
((fcm->sfra <= evaltime) && (fcm->efra >= evaltime)) )
|
||||
{
|
||||
if (fmi->evaluate_modifier) {
|
||||
if ((fcm->flag & (FMODIFIER_FLAG_DISABLED|FMODIFIER_FLAG_MUTED)) == 0) {
|
||||
if ((fcm->flag & (FMODIFIER_FLAG_DISABLED | FMODIFIER_FLAG_MUTED)) == 0) {
|
||||
float influence = eval_fmodifier_influence(fcm, evaltime);
|
||||
float nval = *cvalue;
|
||||
|
||||
@ -1350,8 +1350,8 @@ void fcurve_bake_modifiers(FCurve *fcu, int start, int end)
|
||||
}
|
||||
|
||||
/* temporarily, disable driver while we sample, so that they don't influence the outcome */
|
||||
driver= fcu->driver;
|
||||
fcu->driver= NULL;
|
||||
driver = fcu->driver;
|
||||
fcu->driver = NULL;
|
||||
|
||||
/* bake the modifiers, by sampling the curve at each frame */
|
||||
fcurve_store_samples(fcu, NULL, start, end, fcurve_samplingcb_evalcurve);
|
||||
@ -1360,5 +1360,5 @@ void fcurve_bake_modifiers(FCurve *fcu, int start, int end)
|
||||
free_fmodifiers(&fcu->modifiers);
|
||||
|
||||
/* restore driver */
|
||||
fcu->driver= driver;
|
||||
fcu->driver = driver;
|
||||
}
|
||||
|
@ -47,16 +47,16 @@ static char idp_size_table[] = {
|
||||
1, /*strings*/
|
||||
sizeof(int),
|
||||
sizeof(float),
|
||||
sizeof(float)*3, /*Vector type, deprecated*/
|
||||
sizeof(float)*16, /*Matrix type, deprecated*/
|
||||
sizeof(float) * 3, /*Vector type, deprecated*/
|
||||
sizeof(float) * 16, /*Matrix type, deprecated*/
|
||||
0, /*arrays don't have a fixed size*/
|
||||
sizeof(ListBase), /*Group type*/
|
||||
sizeof(void*),
|
||||
sizeof(void *),
|
||||
sizeof(double)
|
||||
};
|
||||
|
||||
/* ------------Property Array Type ----------- */
|
||||
#define GETPROP(prop, i) (((IDProperty*)(prop)->data.pointer)+(i))
|
||||
#define GETPROP(prop, i) (((IDProperty *)(prop)->data.pointer) + (i))
|
||||
|
||||
/* --------- property array type -------------*/
|
||||
|
||||
@ -78,10 +78,10 @@ IDProperty *IDP_CopyIDPArray(IDProperty *array)
|
||||
IDProperty *narray = MEM_mallocN(sizeof(IDProperty), "IDP_CopyIDPArray"), *tmp;
|
||||
int i;
|
||||
|
||||
*narray= *array;
|
||||
*narray = *array;
|
||||
|
||||
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,
|
||||
* which doesn't work here. instead, simply copy the
|
||||
* contents of the new structure into the array cell,
|
||||
@ -100,7 +100,7 @@ void IDP_FreeIDPArray(IDProperty *prop)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i=0; i<prop->len; i++)
|
||||
for (i = 0; i < prop->len; i++)
|
||||
IDP_FreeProperty(GETPROP(prop, i));
|
||||
|
||||
if (prop->data.pointer)
|
||||
@ -124,22 +124,22 @@ IDProperty *IDP_GetIndexArray(IDProperty *prop, int index)
|
||||
|
||||
IDProperty *IDP_AppendArray(IDProperty *prop, IDProperty *item)
|
||||
{
|
||||
IDP_ResizeIDPArray(prop, prop->len+1);
|
||||
IDP_SetIndexArray(prop, prop->len-1, item);
|
||||
IDP_ResizeIDPArray(prop, prop->len + 1);
|
||||
IDP_SetIndexArray(prop, prop->len - 1, item);
|
||||
return item;
|
||||
}
|
||||
|
||||
void IDP_ResizeIDPArray(IDProperty *prop, int newlen)
|
||||
{
|
||||
void *newarr;
|
||||
int newsize=newlen;
|
||||
int newsize = newlen;
|
||||
|
||||
/*first check if the array buffer size has room*/
|
||||
/*if newlen is 200 chars less then totallen, reallocate anyway*/
|
||||
if (newlen <= prop->totallen && prop->totallen - newlen < 200) {
|
||||
int i;
|
||||
|
||||
for (i=newlen; i<prop->len; i++)
|
||||
for (i = newlen; i < prop->len; i++)
|
||||
IDP_FreeProperty(GETPROP(prop, i));
|
||||
|
||||
prop->len = newlen;
|
||||
@ -156,18 +156,18 @@ void IDP_ResizeIDPArray(IDProperty *prop, int newlen)
|
||||
*/
|
||||
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) {
|
||||
/* newlen is bigger*/
|
||||
memcpy(newarr, prop->data.pointer, prop->len*sizeof(IDProperty));
|
||||
memcpy(newarr, prop->data.pointer, prop->len * sizeof(IDProperty));
|
||||
}
|
||||
else {
|
||||
int i;
|
||||
/* newlen is smaller*/
|
||||
for (i=newlen; i<prop->len; i++) {
|
||||
for (i = newlen; i < prop->len; 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)
|
||||
@ -185,21 +185,21 @@ static void idp_resize_group_array(IDProperty *prop, int newlen, void *newarr)
|
||||
|
||||
if (newlen >= prop->len) {
|
||||
/* bigger */
|
||||
IDProperty **array= newarr;
|
||||
IDProperty **array = newarr;
|
||||
IDPropertyTemplate val;
|
||||
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 */
|
||||
array[a]= IDP_New(IDP_GROUP, &val, "IDP_ResizeArray group");
|
||||
array[a] = IDP_New(IDP_GROUP, &val, "IDP_ResizeArray group");
|
||||
}
|
||||
}
|
||||
else {
|
||||
/* smaller */
|
||||
IDProperty **array= prop->data.pointer;
|
||||
IDProperty **array = prop->data.pointer;
|
||||
int a;
|
||||
|
||||
for (a=newlen; a<prop->len; a++) {
|
||||
for (a = newlen; a < prop->len; a++) {
|
||||
IDP_FreeProperty(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 *newarr;
|
||||
int newsize=newlen;
|
||||
int newsize = newlen;
|
||||
|
||||
/*first check if the array buffer size has room*/
|
||||
/*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;
|
||||
|
||||
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) {
|
||||
/* 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);
|
||||
}
|
||||
else {
|
||||
/* newlen is smaller*/
|
||||
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);
|
||||
@ -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");
|
||||
|
||||
BLI_strncpy(newp->name, prop->name, MAX_IDPROP_NAME);
|
||||
@ -268,7 +268,7 @@ void IDP_FreeArray(IDProperty *prop)
|
||||
newp->data.val2 = prop->data.val2;
|
||||
|
||||
return newp;
|
||||
}
|
||||
}
|
||||
|
||||
static IDProperty *IDP_CopyArray(IDProperty *prop)
|
||||
{
|
||||
@ -278,11 +278,11 @@ static IDProperty *IDP_CopyArray(IDProperty *prop)
|
||||
newp->data.pointer = MEM_dupallocN(prop->data.pointer);
|
||||
|
||||
if (prop->type == IDP_GROUP) {
|
||||
IDProperty **array= newp->data.pointer;
|
||||
IDProperty **array = newp->data.pointer;
|
||||
int a;
|
||||
|
||||
for (a=0; a<prop->len; a++)
|
||||
array[a]= IDP_CopyProperty(array[a]);
|
||||
for (a = 0; a < prop->len; a++)
|
||||
array[a] = IDP_CopyProperty(array[a]);
|
||||
}
|
||||
}
|
||||
newp->len = prop->len;
|
||||
@ -295,11 +295,11 @@ static IDProperty *IDP_CopyArray(IDProperty *prop)
|
||||
/*taken from readfile.c*/
|
||||
#define SWITCH_LONGINT(a) { \
|
||||
char s_i, *p_i; \
|
||||
p_i= (char *)&(a); \
|
||||
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[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; }
|
||||
p_i = (char *)& (a); \
|
||||
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[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; }
|
||||
|
||||
|
||||
|
||||
@ -350,7 +350,7 @@ void IDP_AssignString(IDProperty *prop, const char *st, int maxlen)
|
||||
int stlen = strlen(st);
|
||||
|
||||
if (maxlen > 0 && maxlen < stlen)
|
||||
stlen= maxlen;
|
||||
stlen = maxlen;
|
||||
|
||||
if (prop->subtype == IDP_STRING_SUB_BYTE) {
|
||||
IDP_ResizeArray(prop, stlen);
|
||||
@ -396,14 +396,14 @@ void IDP_FreeString(IDProperty *prop)
|
||||
|
||||
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;
|
||||
id_us_plus(id);
|
||||
}
|
||||
|
||||
void IDP_UnlinkID(IDProperty *prop)
|
||||
{
|
||||
((ID*)prop->data.pointer)->us--;
|
||||
((ID *)prop->data.pointer)->us--;
|
||||
}
|
||||
|
||||
/*-------- Group Functions -------*/
|
||||
@ -414,7 +414,7 @@ static IDProperty *IDP_CopyGroup(IDProperty *prop)
|
||||
IDProperty *newp = idp_generic_copy(prop), *link;
|
||||
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));
|
||||
}
|
||||
|
||||
@ -426,22 +426,22 @@ static IDProperty *IDP_CopyGroup(IDProperty *prop)
|
||||
void IDP_SyncGroupValues(IDProperty *dest, IDProperty *src)
|
||||
{
|
||||
IDProperty *other, *prop;
|
||||
for (prop=src->data.group.first; prop; prop=prop->next) {
|
||||
other= BLI_findstring(&dest->data.group, prop->name, offsetof(IDProperty, name));
|
||||
if (other && prop->type==other->type) {
|
||||
for (prop = src->data.group.first; prop; prop = prop->next) {
|
||||
other = BLI_findstring(&dest->data.group, prop->name, offsetof(IDProperty, name));
|
||||
if (other && prop->type == other->type) {
|
||||
switch (prop->type) {
|
||||
case IDP_INT:
|
||||
case IDP_FLOAT:
|
||||
case IDP_DOUBLE:
|
||||
other->data= prop->data;
|
||||
other->data = prop->data;
|
||||
break;
|
||||
case IDP_GROUP:
|
||||
IDP_SyncGroupValues(other, prop);
|
||||
break;
|
||||
default:
|
||||
{
|
||||
IDProperty *tmp= other;
|
||||
IDProperty *copy= IDP_CopyProperty(prop);
|
||||
IDProperty *tmp = other;
|
||||
IDProperty *copy = IDP_CopyProperty(prop);
|
||||
|
||||
BLI_insertlinkafter(&dest->data.group, other, copy);
|
||||
BLI_remlink(&dest->data.group, tmp);
|
||||
@ -460,8 +460,8 @@ void IDP_SyncGroupValues(IDProperty *dest, IDProperty *src)
|
||||
void IDP_ReplaceGroupInGroup(IDProperty *dest, IDProperty *src)
|
||||
{
|
||||
IDProperty *loop, *prop;
|
||||
for (prop=src->data.group.first; prop; prop=prop->next) {
|
||||
for (loop=dest->data.group.first; loop; loop=loop->next) {
|
||||
for (prop = src->data.group.first; prop; prop = prop->next) {
|
||||
for (loop = dest->data.group.first; loop; loop = loop->next) {
|
||||
if (strcmp(loop->name, prop->name) == 0) {
|
||||
IDProperty *copy = IDP_CopyProperty(prop);
|
||||
|
||||
@ -489,7 +489,7 @@ void IDP_ReplaceGroupInGroup(IDProperty *dest, IDProperty *src)
|
||||
void IDP_ReplaceInGroup(IDProperty *group, IDProperty *prop)
|
||||
{
|
||||
IDProperty *loop;
|
||||
if ((loop= IDP_GetPropertyFromGroup(group, prop->name))) {
|
||||
if ((loop = IDP_GetPropertyFromGroup(group, prop->name))) {
|
||||
BLI_insertlink(&group->data.group, loop, prop);
|
||||
|
||||
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 *idprop= IDP_GetPropertyFromGroup(prop, name);
|
||||
IDProperty *idprop = IDP_GetPropertyFromGroup(prop, name);
|
||||
return (idprop && idprop->type == type) ? idprop : NULL;
|
||||
}
|
||||
|
||||
@ -553,20 +553,20 @@ void *IDP_GetGroupIterator(IDProperty *prop)
|
||||
IDPIter *iter = MEM_callocN(sizeof(IDPIter), "IDPIter");
|
||||
iter->next = prop->data.group.first;
|
||||
iter->parent = prop;
|
||||
return (void*) iter;
|
||||
return (void *) iter;
|
||||
}
|
||||
|
||||
IDProperty *IDP_GroupIterNext(void *vself)
|
||||
{
|
||||
IDPIter *self = (IDPIter*) vself;
|
||||
Link *next = (Link*) self->next;
|
||||
IDPIter *self = (IDPIter *) vself;
|
||||
Link *next = (Link *) self->next;
|
||||
if (self->next == NULL) {
|
||||
MEM_freeN(self);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
self->next = next->next;
|
||||
return (void*) next;
|
||||
return (void *) next;
|
||||
}
|
||||
|
||||
void IDP_FreeIterBeforeEnd(void *vself)
|
||||
@ -581,7 +581,7 @@ void IDP_FreeIterBeforeEnd(void *vself)
|
||||
static void IDP_FreeGroup(IDProperty *prop)
|
||||
{
|
||||
IDProperty *loop;
|
||||
for (loop=prop->data.group.first; loop; loop=loop->next) {
|
||||
for (loop = prop->data.group.first; loop; loop = loop->next) {
|
||||
IDP_FreeProperty(loop);
|
||||
}
|
||||
BLI_freelistN(&prop->data.group);
|
||||
@ -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);
|
||||
else if (prop1->type == IDP_ARRAY) {
|
||||
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
|
||||
return 0;
|
||||
}
|
||||
@ -645,8 +645,8 @@ int IDP_EqualsProperties(IDProperty *prop1, IDProperty *prop2)
|
||||
if (BLI_countlist(&prop1->data.group) != BLI_countlist(&prop2->data.group))
|
||||
return 0;
|
||||
|
||||
for (link1=prop1->data.group.first; link1; link1=link1->next) {
|
||||
link2= IDP_GetPropertyFromGroup(prop2, link1->name);
|
||||
for (link1 = prop1->data.group.first; link1; link1 = link1->next) {
|
||||
link2 = IDP_GetPropertyFromGroup(prop2, link1->name);
|
||||
|
||||
if (!IDP_EqualsProperties(link1, link2))
|
||||
return 0;
|
||||
@ -655,14 +655,14 @@ int IDP_EqualsProperties(IDProperty *prop1, IDProperty *prop2)
|
||||
return 1;
|
||||
}
|
||||
else if (prop1->type == IDP_IDPARRAY) {
|
||||
IDProperty *array1= IDP_IDPArray(prop1);
|
||||
IDProperty *array2= IDP_IDPArray(prop2);
|
||||
IDProperty *array1 = IDP_IDPArray(prop1);
|
||||
IDProperty *array2 = IDP_IDPArray(prop2);
|
||||
int i;
|
||||
|
||||
if (prop1->len != prop2->len)
|
||||
return 0;
|
||||
|
||||
for (i=0; i<prop1->len; i++)
|
||||
for (i = 0; i < prop1->len; i++)
|
||||
if (!IDP_EqualsProperties(&array1[i], &array2[i]))
|
||||
return 0;
|
||||
}
|
||||
@ -673,7 +673,7 @@ int IDP_EqualsProperties(IDProperty *prop1, IDProperty *prop2)
|
||||
/* 'val' is never NULL, don't check */
|
||||
IDProperty *IDP_New(const int type, const IDPropertyTemplate *val, const char *name)
|
||||
{
|
||||
IDProperty *prop=NULL;
|
||||
IDProperty *prop = NULL;
|
||||
|
||||
switch (type) {
|
||||
case IDP_INT:
|
||||
@ -682,11 +682,11 @@ IDProperty *IDP_New(const int type, const IDPropertyTemplate *val, const char *n
|
||||
break;
|
||||
case IDP_FLOAT:
|
||||
prop = MEM_callocN(sizeof(IDProperty), "IDProperty float");
|
||||
*(float*)&prop->data.val = val->f;
|
||||
*(float *)&prop->data.val = val->f;
|
||||
break;
|
||||
case IDP_DOUBLE:
|
||||
prop = MEM_callocN(sizeof(IDProperty), "IDProperty float");
|
||||
*(double*)&prop->data.val = val->d;
|
||||
*(double *)&prop->data.val = val->d;
|
||||
break;
|
||||
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->subtype = val->array.type;
|
||||
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;
|
||||
break;
|
||||
}
|
||||
@ -724,7 +724,7 @@ IDProperty *IDP_New(const int type, const IDPropertyTemplate *val, const char *n
|
||||
prop->len = prop->totallen = val->string.len;
|
||||
memcpy(prop->data.pointer, st, val->string.len);
|
||||
}
|
||||
prop->subtype= IDP_STRING_SUB_BYTE;
|
||||
prop->subtype = IDP_STRING_SUB_BYTE;
|
||||
}
|
||||
else {
|
||||
if (st == NULL) {
|
||||
@ -738,7 +738,7 @@ IDProperty *IDP_New(const int type, const IDPropertyTemplate *val, const char *n
|
||||
prop->len = prop->totallen = stlen;
|
||||
memcpy(prop->data.pointer, st, stlen);
|
||||
}
|
||||
prop->subtype= IDP_STRING_SUB_UTF8;
|
||||
prop->subtype = IDP_STRING_SUB_UTF8;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -39,10 +39,10 @@ void BKE_image_buf_fill_color(unsigned char *rect, float *rect_float, int width,
|
||||
|
||||
/* blank image */
|
||||
if (rect_float) {
|
||||
for (y= 0; y<height; y++) {
|
||||
for (x= 0; x<width; x++) {
|
||||
for (y = 0; y < height; y++) {
|
||||
for (x = 0; x < width; x++) {
|
||||
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);
|
||||
|
||||
for (y= 0; y<height; y++) {
|
||||
for (x= 0; x<width; x++) {
|
||||
for (y = 0; y < height; y++) {
|
||||
for (x = 0; x < width; x++) {
|
||||
|
||||
rect[0]= ccol[0];
|
||||
rect[1]= ccol[1];
|
||||
rect[2]= ccol[2];
|
||||
rect[3]= ccol[3];
|
||||
rect+= 4;
|
||||
rect[0] = ccol[0];
|
||||
rect[1] = ccol[1];
|
||||
rect[2] = ccol[2];
|
||||
rect[3] = ccol[3];
|
||||
rect += 4;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -71,56 +71,56 @@ 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
|
||||
* 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;
|
||||
|
||||
unsigned char *rect_orig= rect;
|
||||
float *rect_float_orig= rect_float;
|
||||
unsigned char *rect_orig = rect;
|
||||
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 */
|
||||
for (y= 0; y<height; y++) {
|
||||
dark= powf(-1.0f, floorf(y / checkerwidth));
|
||||
for (y = 0; y < height; y++) {
|
||||
dark = powf(-1.0f, floorf(y / checkerwidth));
|
||||
|
||||
for (x= 0; x<width; x++) {
|
||||
if (x % checkerwidth == 0) dark= -dark;
|
||||
for (x = 0; x < width; x++) {
|
||||
if (x % checkerwidth == 0) dark = -dark;
|
||||
|
||||
if (rect_float) {
|
||||
if (dark > 0) {
|
||||
rect_float[0]= rect_float[1]= rect_float[2]= 0.25f;
|
||||
rect_float[3]= 1.0f;
|
||||
rect_float[0] = rect_float[1] = rect_float[2] = 0.25f;
|
||||
rect_float[3] = 1.0f;
|
||||
}
|
||||
else {
|
||||
rect_float[0]= rect_float[1]= rect_float[2]= 0.58f;
|
||||
rect_float[3]= 1.0f;
|
||||
rect_float[0] = rect_float[1] = rect_float[2] = 0.58f;
|
||||
rect_float[3] = 1.0f;
|
||||
}
|
||||
rect_float+= 4;
|
||||
rect_float += 4;
|
||||
}
|
||||
else {
|
||||
if (dark > 0) {
|
||||
rect[0]= rect[1]= rect[2]= 64;
|
||||
rect[3]= 255;
|
||||
rect[0] = rect[1] = rect[2] = 64;
|
||||
rect[3] = 255;
|
||||
}
|
||||
else {
|
||||
rect[0]= rect[1]= rect[2]= 150;
|
||||
rect[3]= 255;
|
||||
rect[0] = rect[1] = rect[2] = 150;
|
||||
rect[3] = 255;
|
||||
}
|
||||
rect+= 4;
|
||||
rect += 4;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
rect= rect_orig;
|
||||
rect_float= rect_float_orig;
|
||||
rect = rect_orig;
|
||||
rect_float = rect_float_orig;
|
||||
|
||||
/* 2nd pass, colored + */
|
||||
for (y= 0; y<height; y++) {
|
||||
hoffs= 0.125f * floorf(y / checkerwidth);
|
||||
for (y = 0; y < height; y++) {
|
||||
hoffs = 0.125f * floorf(y / checkerwidth);
|
||||
|
||||
for (x= 0; x<width; x++) {
|
||||
h= 0.125f * floorf(x / checkerwidth);
|
||||
for (x = 0; x < width; x++) {
|
||||
h = 0.125f * floorf(x / checkerwidth);
|
||||
|
||||
if ((fabs((x % checkerwidth) - (checkerwidth / 2)) < 4) &&
|
||||
(fabs((y % checkerwidth) - (checkerwidth / 2)) < 4)) {
|
||||
@ -128,27 +128,27 @@ void BKE_image_buf_fill_checker(unsigned char *rect, float *rect_float, int widt
|
||||
if ((fabs((x % 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);
|
||||
|
||||
if (rect) {
|
||||
rect[0]= (char)(r * 255.0f);
|
||||
rect[1]= (char)(g * 255.0f);
|
||||
rect[2]= (char)(b * 255.0f);
|
||||
rect[3]= 255;
|
||||
rect[0] = (char)(r * 255.0f);
|
||||
rect[1] = (char)(g * 255.0f);
|
||||
rect[2] = (char)(b * 255.0f);
|
||||
rect[3] = 255;
|
||||
}
|
||||
|
||||
if (rect_float) {
|
||||
rect_float[0]= r;
|
||||
rect_float[1]= g;
|
||||
rect_float[2]= b;
|
||||
rect_float[3]= 1.0f;
|
||||
rect_float[0] = r;
|
||||
rect_float[1] = g;
|
||||
rect_float[2] = b;
|
||||
rect_float[3] = 1.0f;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (rect_float) rect_float+= 4;
|
||||
if (rect) rect+= 4;
|
||||
if (rect_float) rect_float += 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 */
|
||||
|
||||
#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
|
||||
|
||||
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;
|
||||
float hue, val, sat, r, g, b;
|
||||
|
||||
sat= 1.0;
|
||||
sat = 1.0;
|
||||
|
||||
hue_step= power_of_2_max_i(width / 8);
|
||||
if (hue_step < 8) hue_step= 8;
|
||||
hue_step = power_of_2_max_i(width / 8);
|
||||
if (hue_step < 8) hue_step = 8;
|
||||
|
||||
for (y= 0; y < height; y++) {
|
||||
for (y = 0; y < height; y++) {
|
||||
|
||||
val= 0.1 + (y * (0.4 / height)); /* use a number lower then 1.0 else its too bright */
|
||||
for (x= 0; x < width; x++) {
|
||||
hue= (float)((double)(x/hue_step) * 1.0 / width * hue_step);
|
||||
val = 0.1 + (y * (0.4 / height)); /* use a number lower then 1.0 else its too bright */
|
||||
for (x = 0; x < width; x++) {
|
||||
hue = (float)((double)(x / hue_step) * 1.0 / width * hue_step);
|
||||
hsv_to_rgb(hue, sat, val, &r, &g, &b);
|
||||
|
||||
if (rect) {
|
||||
rect[0]= (char)(r * 255.0f);
|
||||
rect[1]= (char)(g * 255.0f);
|
||||
rect[2]= (char)(b * 255.0f);
|
||||
rect[3]= 255;
|
||||
rect[0] = (char)(r * 255.0f);
|
||||
rect[1] = (char)(g * 255.0f);
|
||||
rect[2] = (char)(b * 255.0f);
|
||||
rect[3] = 255;
|
||||
|
||||
rect += 4;
|
||||
}
|
||||
|
||||
if (rect_float) {
|
||||
rect_float[0]= r;
|
||||
rect_float[1]= g;
|
||||
rect_float[2]= b;
|
||||
rect_float[3]= 1.0f;
|
||||
rect_float[0] = r;
|
||||
rect_float[1] = g;
|
||||
rect_float[2] = b;
|
||||
rect_float[3] = 1.0f;
|
||||
|
||||
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)
|
||||
{
|
||||
int x, y;
|
||||
float blend_half= blend * 0.5f;
|
||||
float blend_half = blend * 0.5f;
|
||||
|
||||
for (y= 0; y < height; y++) {
|
||||
for (x= 0; x < width; x++) {
|
||||
if (((y / size) % 2 == 1 && (x / size) % 2 == 1 ) || ( (y / size) % 2 == 0 && (x / size) % 2 == 0 )) {
|
||||
for (y = 0; y < height; y++) {
|
||||
for (x = 0; x < width; x++) {
|
||||
if (((y / size) % 2 == 1 && (x / size) % 2 == 1) || ( (y / size) % 2 == 0 && (x / size) % 2 == 0)) {
|
||||
if (rect) {
|
||||
rect[0]= (char)BLEND_CHAR(rect[0], blend);
|
||||
rect[1]= (char)BLEND_CHAR(rect[1], blend);
|
||||
rect[2]= (char)BLEND_CHAR(rect[2], blend);
|
||||
rect[3]= 255;
|
||||
rect[0] = (char)BLEND_CHAR(rect[0], blend);
|
||||
rect[1] = (char)BLEND_CHAR(rect[1], blend);
|
||||
rect[2] = (char)BLEND_CHAR(rect[2], blend);
|
||||
rect[3] = 255;
|
||||
|
||||
rect += 4;
|
||||
}
|
||||
if (rect_float) {
|
||||
rect_float[0]= BLEND_FLOAT(rect_float[0], blend);
|
||||
rect_float[1]= BLEND_FLOAT(rect_float[1], blend);
|
||||
rect_float[2]= BLEND_FLOAT(rect_float[2], blend);
|
||||
rect_float[3]= 1.0f;
|
||||
rect_float[0] = BLEND_FLOAT(rect_float[0], blend);
|
||||
rect_float[1] = BLEND_FLOAT(rect_float[1], blend);
|
||||
rect_float[2] = BLEND_FLOAT(rect_float[2], blend);
|
||||
rect_float[3] = 1.0f;
|
||||
|
||||
rect_float += 4;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (rect) {
|
||||
rect[0]= (char)BLEND_CHAR(rect[0], blend_half);
|
||||
rect[1]= (char)BLEND_CHAR(rect[1], blend_half);
|
||||
rect[2]= (char)BLEND_CHAR(rect[2], blend_half);
|
||||
rect[3]= 255;
|
||||
rect[0] = (char)BLEND_CHAR(rect[0], blend_half);
|
||||
rect[1] = (char)BLEND_CHAR(rect[1], blend_half);
|
||||
rect[2] = (char)BLEND_CHAR(rect[2], blend_half);
|
||||
rect[3] = 255;
|
||||
|
||||
rect += 4;
|
||||
}
|
||||
if (rect_float) {
|
||||
rect_float[0]= BLEND_FLOAT(rect_float[0], blend_half);
|
||||
rect_float[1]= BLEND_FLOAT(rect_float[1], blend_half);
|
||||
rect_float[2]= BLEND_FLOAT(rect_float[2], blend_half);
|
||||
rect_float[3]= 1.0f;
|
||||
rect_float[0] = BLEND_FLOAT(rect_float[0], blend_half);
|
||||
rect_float[1] = BLEND_FLOAT(rect_float[1], blend_half);
|
||||
rect_float[2] = BLEND_FLOAT(rect_float[2], blend_half);
|
||||
rect_float[3] = 1.0f;
|
||||
|
||||
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)
|
||||
{
|
||||
int x, y;
|
||||
for (y= 0; y < height; y++) {
|
||||
for (x= 0; x < width; x++) {
|
||||
for (y = 0; y < height; y++) {
|
||||
for (x = 0; x < width; x++) {
|
||||
if (((y % 32) == 0) || ((x % 32) == 0) || x == 0) {
|
||||
if (rect) {
|
||||
rect[0]= BLEND_CHAR(rect[0], blend);
|
||||
rect[1]= BLEND_CHAR(rect[1], blend);
|
||||
rect[2]= BLEND_CHAR(rect[2], blend);
|
||||
rect[3]= 255;
|
||||
rect[0] = BLEND_CHAR(rect[0], blend);
|
||||
rect[1] = BLEND_CHAR(rect[1], blend);
|
||||
rect[2] = BLEND_CHAR(rect[2], blend);
|
||||
rect[3] = 255;
|
||||
|
||||
rect += 4;
|
||||
}
|
||||
if (rect_float) {
|
||||
rect_float[0]= BLEND_FLOAT(rect_float[0], blend);
|
||||
rect_float[1]= BLEND_FLOAT(rect_float[1], blend);
|
||||
rect_float[2]= BLEND_FLOAT(rect_float[2], blend);
|
||||
rect_float[3]= 1.0f;
|
||||
rect_float[0] = BLEND_FLOAT(rect_float[0], blend);
|
||||
rect_float[1] = BLEND_FLOAT(rect_float[1], blend);
|
||||
rect_float[2] = BLEND_FLOAT(rect_float[2], blend);
|
||||
rect_float[3] = 1.0f;
|
||||
|
||||
rect_float += 4;
|
||||
}
|
||||
@ -282,17 +282,17 @@ static void checker_board_text(unsigned char *rect, float *rect_float, int width
|
||||
{
|
||||
int x, y;
|
||||
int pen_x, pen_y;
|
||||
char text[3]= {'A', '1', '\0'};
|
||||
const int mono= blf_mono_font;
|
||||
char text[3] = {'A', '1', '\0'};
|
||||
const int mono = blf_mono_font;
|
||||
|
||||
BLF_size(mono, 54, 72); /* hard coded size! */
|
||||
|
||||
BLF_buffer(mono, rect_float, rect, width, height, 4);
|
||||
|
||||
for (y= 0; y < height; y+=step) {
|
||||
text[1]= '1';
|
||||
for (y = 0; y < height; y += step) {
|
||||
text[1] = '1';
|
||||
|
||||
for (x= 0; x < width; x+=step) {
|
||||
for (x = 0; x < width; x += step) {
|
||||
/* hard coded offset */
|
||||
pen_x = x + 33;
|
||||
pen_y = y + 44;
|
||||
@ -300,22 +300,22 @@ static void checker_board_text(unsigned char *rect, float *rect_float, int width
|
||||
/* terribly crappy outline font! */
|
||||
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_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_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_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_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_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_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_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_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, 32, 0.07f);
|
||||
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);
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -68,12 +68,12 @@
|
||||
|
||||
ModifierTypeInfo *modifierType_getInfo(ModifierType type)
|
||||
{
|
||||
static ModifierTypeInfo *types[NUM_MODIFIER_TYPES]= {NULL};
|
||||
static ModifierTypeInfo *types[NUM_MODIFIER_TYPES] = {NULL};
|
||||
static int types_init = 1;
|
||||
|
||||
if (types_init) {
|
||||
modifier_type_init(types); /* MOD_utils.c */
|
||||
types_init= 0;
|
||||
types_init = 0;
|
||||
}
|
||||
|
||||
/* type unsigned, no need to check < 0 */
|
||||
@ -137,7 +137,7 @@ int modifier_supportsMapping(ModifierData *md)
|
||||
{
|
||||
ModifierTypeInfo *mti = modifierType_getInfo(md->type);
|
||||
|
||||
return (mti->type==eModifierTypeType_OnlyDeform ||
|
||||
return (mti->type == eModifierTypeType_OnlyDeform ||
|
||||
(mti->flags & eModifierTypeFlag_SupportsMapping));
|
||||
}
|
||||
|
||||
@ -158,8 +158,8 @@ ModifierData *modifiers_findByType(Object *ob, ModifierType type)
|
||||
{
|
||||
ModifierData *md = ob->modifiers.first;
|
||||
|
||||
for (; md; md=md->next)
|
||||
if (md->type==type)
|
||||
for (; md; md = md->next)
|
||||
if (md->type == type)
|
||||
break;
|
||||
|
||||
return md;
|
||||
@ -175,7 +175,7 @@ void modifiers_clearErrors(Object *ob)
|
||||
ModifierData *md = ob->modifiers.first;
|
||||
/* int qRedraw = 0; */
|
||||
|
||||
for (; md; md=md->next) {
|
||||
for (; md; md = md->next) {
|
||||
if (md->error) {
|
||||
MEM_freeN(md->error);
|
||||
md->error = NULL;
|
||||
@ -190,7 +190,7 @@ void modifiers_foreachObjectLink(Object *ob, ObjectWalkFunc walk,
|
||||
{
|
||||
ModifierData *md = ob->modifiers.first;
|
||||
|
||||
for (; md; md=md->next) {
|
||||
for (; md; md = md->next) {
|
||||
ModifierTypeInfo *mti = modifierType_getInfo(md->type);
|
||||
|
||||
if (mti->foreachObjectLink)
|
||||
@ -202,7 +202,7 @@ void modifiers_foreachIDLink(Object *ob, IDWalkFunc walk, void *userData)
|
||||
{
|
||||
ModifierData *md = ob->modifiers.first;
|
||||
|
||||
for (; md; md=md->next) {
|
||||
for (; md; md = md->next) {
|
||||
ModifierTypeInfo *mti = modifierType_getInfo(md->type);
|
||||
|
||||
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;
|
||||
|
||||
for (; md; md=md->next) {
|
||||
for (; md; md = md->next) {
|
||||
ModifierTypeInfo *mti = modifierType_getInfo(md->type);
|
||||
|
||||
if (mti->foreachTexLink)
|
||||
@ -240,9 +240,9 @@ int modifier_couldBeCage(struct Scene *scene, ModifierData *md)
|
||||
{
|
||||
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) &&
|
||||
(!mti->isDisabled || !mti->isDisabled(md, 0)) &&
|
||||
modifier_supportsMapping(md));
|
||||
@ -269,7 +269,7 @@ void modifier_setError(ModifierData *md, const char *format, ...)
|
||||
va_start(ap, format);
|
||||
vsnprintf(buffer, sizeof(buffer), format, ap);
|
||||
va_end(ap);
|
||||
buffer[sizeof(buffer) - 1]= '\0';
|
||||
buffer[sizeof(buffer) - 1] = '\0';
|
||||
|
||||
if (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_)
|
||||
{
|
||||
ModifierData *md = (virtual_)? modifiers_getVirtualModifierList(ob): ob->modifiers.first;
|
||||
ModifierData *md = (virtual_) ? modifiers_getVirtualModifierList(ob) : ob->modifiers.first;
|
||||
int i, cageIndex = -1;
|
||||
|
||||
if (lastPossibleCageIndex_r) {
|
||||
/* ensure the value is initialized */
|
||||
*lastPossibleCageIndex_r= -1;
|
||||
*lastPossibleCageIndex_r = -1;
|
||||
}
|
||||
|
||||
/* 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);
|
||||
|
||||
md->scene= scene;
|
||||
md->scene = scene;
|
||||
|
||||
if (!(md->mode & eModifierMode_Realtime)) 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);
|
||||
|
||||
md->scene= scene;
|
||||
md->scene = scene;
|
||||
|
||||
if ((md->mode & required_mode) != required_mode) 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 */
|
||||
BLI_linklist_reverse((LinkNode**)&dataMasks);
|
||||
BLI_linklist_reverse((LinkNode **)&dataMasks);
|
||||
|
||||
return dataMasks;
|
||||
}
|
||||
@ -431,19 +431,19 @@ ModifierData *modifiers_getVirtualModifierList(Object *ob)
|
||||
|
||||
if (init) {
|
||||
md = modifier_new(eModifierType_Armature);
|
||||
amd = *((ArmatureModifierData*) md);
|
||||
amd = *((ArmatureModifierData *) md);
|
||||
modifier_free(md);
|
||||
|
||||
md = modifier_new(eModifierType_Curve);
|
||||
cmd = *((CurveModifierData*) md);
|
||||
cmd = *((CurveModifierData *) md);
|
||||
modifier_free(md);
|
||||
|
||||
md = modifier_new(eModifierType_Lattice);
|
||||
lmd = *((LatticeModifierData*) md);
|
||||
lmd = *((LatticeModifierData *) md);
|
||||
modifier_free(md);
|
||||
|
||||
md = modifier_new(eModifierType_ShapeKey);
|
||||
smd = *((ShapeKeyModifierData*) md);
|
||||
smd = *((ShapeKeyModifierData *) md);
|
||||
modifier_free(md);
|
||||
|
||||
amd.modifier.mode |= eModifierMode_Virtual;
|
||||
@ -457,19 +457,19 @@ ModifierData *modifiers_getVirtualModifierList(Object *ob)
|
||||
md = ob->modifiers.first;
|
||||
|
||||
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.modifier.next = md;
|
||||
amd.deformflag= ((bArmature *)(ob->parent->data))->deformflag;
|
||||
amd.deformflag = ((bArmature *)(ob->parent->data))->deformflag;
|
||||
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.defaxis = ob->trackflag + 1;
|
||||
cmd.modifier.next = md;
|
||||
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.modifier.next = md;
|
||||
md = &lmd.modifier;
|
||||
@ -479,9 +479,9 @@ ModifierData *modifiers_getVirtualModifierList(Object *ob)
|
||||
/* shape key modifier, not yet for curves */
|
||||
if (ELEM(ob->type, OB_MESH, OB_LATTICE) && ob_get_key(ob)) {
|
||||
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
|
||||
smd.modifier.mode &= ~eModifierMode_Editmode|eModifierMode_OnCage;
|
||||
smd.modifier.mode &= ~eModifierMode_Editmode | eModifierMode_OnCage;
|
||||
|
||||
smd.modifier.next = md;
|
||||
md = &smd.modifier;
|
||||
@ -496,12 +496,12 @@ ModifierData *modifiers_getVirtualModifierList(Object *ob)
|
||||
Object *modifiers_isDeformedByArmature(Object *ob)
|
||||
{
|
||||
ModifierData *md = modifiers_getVirtualModifierList(ob);
|
||||
ArmatureModifierData *amd= NULL;
|
||||
ArmatureModifierData *amd = NULL;
|
||||
|
||||
/* return the first selected armature, this lets us use multiple armatures */
|
||||
for (; md; md=md->next) {
|
||||
if (md->type==eModifierType_Armature) {
|
||||
amd = (ArmatureModifierData*) md;
|
||||
for (; md; md = md->next) {
|
||||
if (md->type == eModifierType_Armature) {
|
||||
amd = (ArmatureModifierData *) md;
|
||||
if (amd->object && (amd->object->flag & SELECT))
|
||||
return amd->object;
|
||||
}
|
||||
@ -520,12 +520,12 @@ Object *modifiers_isDeformedByArmature(Object *ob)
|
||||
Object *modifiers_isDeformedByLattice(Object *ob)
|
||||
{
|
||||
ModifierData *md = modifiers_getVirtualModifierList(ob);
|
||||
LatticeModifierData *lmd= NULL;
|
||||
LatticeModifierData *lmd = NULL;
|
||||
|
||||
/* return the first selected lattice, this lets us use multiple lattices */
|
||||
for (; md; md=md->next) {
|
||||
if (md->type==eModifierType_Lattice) {
|
||||
lmd = (LatticeModifierData*) md;
|
||||
for (; md; md = md->next) {
|
||||
if (md->type == eModifierType_Lattice) {
|
||||
lmd = (LatticeModifierData *) md;
|
||||
if (lmd->object && (lmd->object->flag & SELECT))
|
||||
return lmd->object;
|
||||
}
|
||||
@ -543,10 +543,10 @@ int modifiers_usesArmature(Object *ob, bArmature *arm)
|
||||
{
|
||||
ModifierData *md = modifiers_getVirtualModifierList(ob);
|
||||
|
||||
for (; md; md=md->next) {
|
||||
if (md->type==eModifierType_Armature) {
|
||||
ArmatureModifierData *amd = (ArmatureModifierData*) md;
|
||||
if (amd->object && amd->object->data==arm)
|
||||
for (; md; md = md->next) {
|
||||
if (md->type == eModifierType_Armature) {
|
||||
ArmatureModifierData *amd = (ArmatureModifierData *) md;
|
||||
if (amd->object && amd->object->data == arm)
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
@ -556,9 +556,9 @@ int modifiers_usesArmature(Object *ob, bArmature *arm)
|
||||
|
||||
int modifier_isCorrectableDeformed(ModifierData *md)
|
||||
{
|
||||
if (md->type==eModifierType_Armature)
|
||||
if (md->type == eModifierType_Armature)
|
||||
return 1;
|
||||
if (md->type==eModifierType_ShapeKey)
|
||||
if (md->type == eModifierType_ShapeKey)
|
||||
return 1;
|
||||
|
||||
return 0;
|
||||
@ -568,8 +568,8 @@ int modifiers_isCorrectableDeformed(Object *ob)
|
||||
{
|
||||
ModifierData *md = modifiers_getVirtualModifierList(ob);
|
||||
|
||||
for (; md; md=md->next) {
|
||||
if (ob->mode==OB_MODE_EDIT && (md->mode & eModifierMode_Editmode)==0);
|
||||
for (; md; md = md->next) {
|
||||
if (ob->mode == OB_MODE_EDIT && (md->mode & eModifierMode_Editmode) == 0) ;
|
||||
else
|
||||
if (modifier_isCorrectableDeformed(md))
|
||||
return 1;
|
||||
@ -593,10 +593,10 @@ int modifiers_isPreview(Object *ob)
|
||||
|
||||
int modifiers_indexInObject(Object *ob, ModifierData *md_seek)
|
||||
{
|
||||
int i= 0;
|
||||
int i = 0;
|
||||
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 */
|
||||
return i;
|
||||
}
|
||||
@ -604,11 +604,11 @@ int modifiers_indexInObject(Object *ob, ModifierData *md_seek)
|
||||
void modifier_freeTemporaryData(ModifierData *md)
|
||||
{
|
||||
if (md->type == eModifierType_Armature) {
|
||||
ArmatureModifierData *amd= (ArmatureModifierData*)md;
|
||||
ArmatureModifierData *amd = (ArmatureModifierData *)md;
|
||||
|
||||
if (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) {
|
||||
if (md->type == eModifierType_Multires) {
|
||||
MultiresModifierData *mmd = (MultiresModifierData*)md;
|
||||
MultiresModifierData *mmd = (MultiresModifierData *)md;
|
||||
|
||||
multiresModifier_set_levels_from_disps(mmd, ob);
|
||||
}
|
||||
|
@ -82,7 +82,7 @@ static void multiresModifier_disp_run(DerivedMesh *dm, Mesh *me, DerivedMesh *dm
|
||||
void multires_customdata_delete(Mesh *me)
|
||||
{
|
||||
if (me->edit_btmesh) {
|
||||
BMEditMesh *em= me->edit_btmesh;
|
||||
BMEditMesh *em = me->edit_btmesh;
|
||||
/* CustomData_external_remove is used here only to mark layer
|
||||
* as non-external for further free-ing, so zero element count
|
||||
* looks safer than em->totface */
|
||||
@ -181,9 +181,9 @@ static BLI_bitmap multires_mdisps_downsample_hidden(BLI_bitmap old_hidden,
|
||||
for (y = 0; y < new_gridsize; y++) {
|
||||
for (x = 0; x < new_gridsize; x++) {
|
||||
old_value = BLI_BITMAP_GET(old_hidden,
|
||||
factor*y*old_gridsize + x*factor);
|
||||
factor * y * old_gridsize + x * factor);
|
||||
|
||||
BLI_BITMAP_MODIFY(new_hidden, y*new_gridsize + x, old_value);
|
||||
BLI_BITMAP_MODIFY(new_hidden, y * new_gridsize + x, old_value);
|
||||
}
|
||||
}
|
||||
|
||||
@ -274,7 +274,7 @@ static MDisps *multires_mdisps_initialize_hidden(Mesh *me, int level)
|
||||
|
||||
DerivedMesh *get_multires_dm(Scene *scene, MultiresModifierData *mmd, Object *ob)
|
||||
{
|
||||
ModifierData *md= (ModifierData *)mmd;
|
||||
ModifierData *md = (ModifierData *)mmd;
|
||||
ModifierTypeInfo *mti = modifierType_getInfo(md->type);
|
||||
DerivedMesh *tdm = mesh_get_derived_deform(scene, ob, CD_MASK_BAREMESH);
|
||||
DerivedMesh *dm;
|
||||
@ -294,7 +294,7 @@ MultiresModifierData *find_multires_modifier_before(Scene *scene, ModifierData *
|
||||
for (md = lastmd; md; md = md->prev) {
|
||||
if (md->type == eModifierType_Multires) {
|
||||
if (modifier_isEnabled(scene, md, eModifierMode_Realtime))
|
||||
return (MultiresModifierData*)md;
|
||||
return (MultiresModifierData *)md;
|
||||
}
|
||||
}
|
||||
|
||||
@ -307,16 +307,16 @@ MultiresModifierData *find_multires_modifier_before(Scene *scene, ModifierData *
|
||||
MultiresModifierData *get_multires_modifier(Scene *scene, Object *ob, int use_first)
|
||||
{
|
||||
ModifierData *md;
|
||||
MultiresModifierData *mmd= NULL, *firstmmd= NULL;
|
||||
MultiresModifierData *mmd = NULL, *firstmmd = NULL;
|
||||
|
||||
/* find first active multires modifier */
|
||||
for (md = ob->modifiers.first; md; md = md->next) {
|
||||
if (md->type == eModifierType_Multires) {
|
||||
if (!firstmmd)
|
||||
firstmmd= (MultiresModifierData*)md;
|
||||
firstmmd = (MultiresModifierData *)md;
|
||||
|
||||
if (modifier_isEnabled(scene, md, eModifierMode_Realtime)) {
|
||||
mmd= (MultiresModifierData*)md;
|
||||
mmd = (MultiresModifierData *)md;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -334,11 +334,11 @@ MultiresModifierData *get_multires_modifier(Scene *scene, Object *ob, int use_fi
|
||||
static int multires_get_level(Object *ob, MultiresModifierData *mmd, int render)
|
||||
{
|
||||
if (render)
|
||||
return (mmd->modifier.scene)? get_render_subsurf_level(&mmd->modifier.scene->r, mmd->renderlvl): mmd->renderlvl;
|
||||
return (mmd->modifier.scene) ? get_render_subsurf_level(&mmd->modifier.scene->r, mmd->renderlvl) : mmd->renderlvl;
|
||||
else if (ob->mode == OB_MODE_SCULPT)
|
||||
return mmd->sculptlvl;
|
||||
else
|
||||
return (mmd->modifier.scene)? get_render_subsurf_level(&mmd->modifier.scene->r, mmd->lvl): mmd->lvl;
|
||||
return (mmd->modifier.scene) ? get_render_subsurf_level(&mmd->modifier.scene->r, mmd->lvl) : mmd->lvl;
|
||||
}
|
||||
|
||||
static void multires_set_tot_level(Object *ob, MultiresModifierData *mmd, int lvl)
|
||||
@ -354,7 +354,7 @@ static void multires_set_tot_level(Object *ob, MultiresModifierData *mmd, int lv
|
||||
|
||||
static void multires_dm_mark_as_modified(DerivedMesh *dm, MultiresModifiedFlags flags)
|
||||
{
|
||||
CCGDerivedMesh *ccgdm = (CCGDerivedMesh*)dm;
|
||||
CCGDerivedMesh *ccgdm = (CCGDerivedMesh *)dm;
|
||||
ccgdm->multires.modified_flags |= flags;
|
||||
}
|
||||
|
||||
@ -368,13 +368,13 @@ void multires_force_update(Object *ob)
|
||||
{
|
||||
if (ob) {
|
||||
if (ob->derivedFinal) {
|
||||
ob->derivedFinal->needsFree =1;
|
||||
ob->derivedFinal->needsFree = 1;
|
||||
ob->derivedFinal->release(ob->derivedFinal);
|
||||
ob->derivedFinal = NULL;
|
||||
}
|
||||
if (ob->sculpt && ob->sculpt->pbvh) {
|
||||
BLI_pbvh_free(ob->sculpt->pbvh);
|
||||
ob->sculpt->pbvh= NULL;
|
||||
ob->sculpt->pbvh = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -396,7 +396,7 @@ void multires_force_render_update(Object *ob)
|
||||
int multiresModifier_reshapeFromDM(Scene *scene, MultiresModifierData *mmd,
|
||||
Object *ob, DerivedMesh *srcdm)
|
||||
{
|
||||
DerivedMesh *mrdm = get_multires_dm (scene, mmd, ob);
|
||||
DerivedMesh *mrdm = get_multires_dm(scene, mmd, ob);
|
||||
|
||||
if (mrdm && srcdm && mrdm->getNumVerts(mrdm) == srcdm->getNumVerts(srcdm)) {
|
||||
multires_mvert_to_ss(mrdm, srcdm->getVertArray(srcdm));
|
||||
@ -434,20 +434,20 @@ int multiresModifier_reshapeFromDeformMod(Scene *scene, MultiresModifierData *mm
|
||||
|
||||
/* Create DerivedMesh for deformation modifier */
|
||||
dm = get_multires_dm(scene, mmd, ob);
|
||||
numVerts= dm->getNumVerts(dm);
|
||||
deformedVerts= MEM_callocN(sizeof(float)*numVerts*3, "multiresReshape_deformVerts");
|
||||
numVerts = dm->getNumVerts(dm);
|
||||
deformedVerts = MEM_callocN(sizeof(float) * numVerts * 3, "multiresReshape_deformVerts");
|
||||
|
||||
dm->getVertCos(dm, deformedVerts);
|
||||
mti->deformVerts(md, ob, dm, deformedVerts, numVerts, 0, 0);
|
||||
|
||||
ndm= CDDM_copy(dm);
|
||||
ndm = CDDM_copy(dm);
|
||||
CDDM_apply_vert_coords(ndm, deformedVerts);
|
||||
|
||||
MEM_freeN(deformedVerts);
|
||||
dm->release(dm);
|
||||
|
||||
/* Reshaping */
|
||||
result= multiresModifier_reshapeFromDM(scene, mmd, ob, ndm);
|
||||
result = multiresModifier_reshapeFromDM(scene, mmd, ob, ndm);
|
||||
|
||||
/* Cleanup */
|
||||
ndm->release(ndm);
|
||||
@ -460,19 +460,19 @@ static int get_levels_from_disps(Object *ob)
|
||||
{
|
||||
Mesh *me = ob->data;
|
||||
MDisps *mdisp, *md;
|
||||
int i, j, totlvl= 0;
|
||||
int i, j, totlvl = 0;
|
||||
|
||||
mdisp = CustomData_get_layer(&me->ldata, CD_MDISPS);
|
||||
|
||||
for (i = 0; i < me->totpoly; ++i) {
|
||||
md = mdisp + me->mpoly[i].loopstart;
|
||||
|
||||
for (j=0; j<me->mpoly[i].totloop; j++, md++) {
|
||||
for (j = 0; j < me->mpoly[i].totloop; j++, md++) {
|
||||
if (md->totdisp == 0) continue;
|
||||
|
||||
while (1) {
|
||||
int side = (1 << (totlvl-1)) + 1;
|
||||
int lvl_totdisp = side*side;
|
||||
int side = (1 << (totlvl - 1)) + 1;
|
||||
int lvl_totdisp = side * side;
|
||||
if (md->totdisp == lvl_totdisp)
|
||||
break;
|
||||
else if (md->totdisp < lvl_totdisp)
|
||||
@ -510,7 +510,7 @@ void multiresModifier_set_levels_from_disps(MultiresModifierData *mmd, Object *o
|
||||
|
||||
static void multires_set_tot_mdisps(Mesh *me, int lvl)
|
||||
{
|
||||
MDisps *mdisps= CustomData_get_layer(&me->ldata, CD_MDISPS);
|
||||
MDisps *mdisps = CustomData_get_layer(&me->ldata, CD_MDISPS);
|
||||
int i;
|
||||
|
||||
if (mdisps) {
|
||||
@ -554,18 +554,18 @@ static void multires_copy_grid(float (*gridA)[3], float (*gridB)[3], int sizeA,
|
||||
int x, y, j, skip;
|
||||
|
||||
if (sizeA > sizeB) {
|
||||
skip = (sizeA-1)/(sizeB-1);
|
||||
skip = (sizeA - 1) / (sizeB - 1);
|
||||
|
||||
for (j = 0, y = 0; y < sizeB; y++)
|
||||
for (x = 0; x < sizeB; x++, j++)
|
||||
copy_v3_v3(gridA[y*skip*sizeA + x*skip], gridB[j]);
|
||||
copy_v3_v3(gridA[y * skip * sizeA + x * skip], gridB[j]);
|
||||
}
|
||||
else {
|
||||
skip = (sizeB-1)/(sizeA-1);
|
||||
skip = (sizeB - 1) / (sizeA - 1);
|
||||
|
||||
for (j = 0, y = 0; y < sizeA; y++)
|
||||
for (x = 0; x < sizeA; x++, j++)
|
||||
copy_v3_v3(gridA[j], gridB[y*skip*sizeB + x*skip]);
|
||||
copy_v3_v3(gridA[j], gridB[y * skip * sizeB + x * skip]);
|
||||
}
|
||||
}
|
||||
|
||||
@ -574,30 +574,30 @@ static void multires_copy_dm_grid(DMGridData *gridA, DMGridData *gridB, int size
|
||||
int x, y, j, skip;
|
||||
|
||||
if (sizeA > sizeB) {
|
||||
skip = (sizeA-1)/(sizeB-1);
|
||||
skip = (sizeA - 1) / (sizeB - 1);
|
||||
|
||||
for (j = 0, y = 0; y < sizeB; y++)
|
||||
for (x = 0; x < sizeB; x++, j++)
|
||||
copy_v3_v3(gridA[y*skip*sizeA + x*skip].co, gridB[j].co);
|
||||
copy_v3_v3(gridA[y * skip * sizeA + x * skip].co, gridB[j].co);
|
||||
}
|
||||
else {
|
||||
skip = (sizeB-1)/(sizeA-1);
|
||||
skip = (sizeB - 1) / (sizeA - 1);
|
||||
|
||||
for (j = 0, y = 0; y < sizeA; y++)
|
||||
for (x = 0; x < sizeA; x++, j++)
|
||||
copy_v3_v3(gridA[j].co, gridB[y*skip*sizeB + x*skip].co);
|
||||
copy_v3_v3(gridA[j].co, gridB[y * skip * sizeB + x * skip].co);
|
||||
}
|
||||
}
|
||||
|
||||
static void multires_del_higher(MultiresModifierData *mmd, Object *ob, int lvl)
|
||||
{
|
||||
Mesh *me = (Mesh*)ob->data;
|
||||
Mesh *me = (Mesh *)ob->data;
|
||||
int levels = mmd->totlvl - lvl;
|
||||
MDisps *mdisps;
|
||||
|
||||
multires_set_tot_mdisps(me, mmd->totlvl);
|
||||
CustomData_external_read(&me->ldata, &me->id, CD_MASK_MDISPS, me->totloop);
|
||||
mdisps= CustomData_get_layer(&me->ldata, CD_MDISPS);
|
||||
mdisps = CustomData_get_layer(&me->ldata, CD_MDISPS);
|
||||
|
||||
multires_force_update(ob);
|
||||
|
||||
@ -609,8 +609,8 @@ static void multires_del_higher(MultiresModifierData *mmd, Object *ob, int lvl)
|
||||
int i, j;
|
||||
|
||||
for (i = 0; i < me->totpoly; ++i) {
|
||||
for (j=0; j<me->mpoly[i].totloop; j++) {
|
||||
MDisps *mdisp= &mdisps[me->mpoly[i].loopstart+j];
|
||||
for (j = 0; j < me->mpoly[i].totloop; j++) {
|
||||
MDisps *mdisp = &mdisps[me->mpoly[i].loopstart + j];
|
||||
float (*disps)[3], (*ndisps)[3], (*hdisps)[3];
|
||||
int totdisp = multires_grid_tot[lvl];
|
||||
|
||||
@ -629,8 +629,8 @@ static void multires_del_higher(MultiresModifierData *mmd, Object *ob, int lvl)
|
||||
mdisp->hidden = gh;
|
||||
}
|
||||
|
||||
ndisps += nsize*nsize;
|
||||
hdisps += hsize*hsize;
|
||||
ndisps += nsize * nsize;
|
||||
hdisps += hsize * hsize;
|
||||
|
||||
MEM_freeN(mdisp->disps);
|
||||
mdisp->disps = disps;
|
||||
@ -657,7 +657,7 @@ void multiresModifier_del_levels(MultiresModifierData *mmd, Object *ob, int dire
|
||||
|
||||
multires_set_tot_mdisps(me, mmd->totlvl);
|
||||
CustomData_external_read(&me->ldata, &me->id, CD_MASK_MDISPS, me->totloop);
|
||||
mdisps= CustomData_get_layer(&me->ldata, CD_MDISPS);
|
||||
mdisps = CustomData_get_layer(&me->ldata, CD_MDISPS);
|
||||
|
||||
multires_force_update(ob);
|
||||
|
||||
@ -670,7 +670,7 @@ void multiresModifier_del_levels(MultiresModifierData *mmd, Object *ob, int dire
|
||||
|
||||
static DerivedMesh *multires_dm_create_local(Object *ob, DerivedMesh *dm, int lvl, int totlvl, int simple)
|
||||
{
|
||||
MultiresModifierData mmd= {{NULL}};
|
||||
MultiresModifierData mmd = {{NULL}};
|
||||
|
||||
mmd.lvl = lvl;
|
||||
mmd.sculptlvl = lvl;
|
||||
@ -683,7 +683,7 @@ static DerivedMesh *multires_dm_create_local(Object *ob, DerivedMesh *dm, int lv
|
||||
|
||||
static DerivedMesh *subsurf_dm_create_local(Object *ob, DerivedMesh *dm, int lvl, int simple, int optimal, int plain_uv)
|
||||
{
|
||||
SubsurfModifierData smd= {{NULL}};
|
||||
SubsurfModifierData smd = {{NULL}};
|
||||
|
||||
smd.levels = smd.renderLevels = lvl;
|
||||
if (!plain_uv)
|
||||
@ -742,8 +742,8 @@ void multiresModifier_base_apply(MultiresModifierData *mmd, Object *ob)
|
||||
|
||||
cddm = CDDM_from_mesh(me, NULL);
|
||||
pmap = cddm->getPolyMap(ob, cddm);
|
||||
origco = MEM_callocN(sizeof(float)*3*me->totvert, "multires apply base origco");
|
||||
for (i = 0; i < me->totvert ;++i)
|
||||
origco = MEM_callocN(sizeof(float) * 3 * me->totvert, "multires apply base origco");
|
||||
for (i = 0; i < me->totvert; ++i)
|
||||
copy_v3_v3(origco[i], me->mvert[i].co);
|
||||
|
||||
for (i = 0; i < me->totvert; ++i) {
|
||||
@ -833,7 +833,7 @@ static void multires_subdivide(MultiresModifierData *mmd, Object *ob, int totlvl
|
||||
{
|
||||
Mesh *me = ob->data;
|
||||
MDisps *mdisps;
|
||||
int lvl= mmd->totlvl;
|
||||
int lvl = mmd->totlvl;
|
||||
|
||||
if ((totlvl > multires_max_levels) || (me->totpoly == 0))
|
||||
return;
|
||||
@ -867,12 +867,12 @@ static void multires_subdivide(MultiresModifierData *mmd, Object *ob, int totlvl
|
||||
lowGridSize = lowdm->getGridSize(lowdm);
|
||||
lowGridData = lowdm->getGridData(lowdm);
|
||||
|
||||
subGridData = MEM_callocN(sizeof(float*)*numGrids, "subGridData*");
|
||||
subGridData = MEM_callocN(sizeof(float *) * numGrids, "subGridData*");
|
||||
|
||||
for (i = 0; i < numGrids; ++i) {
|
||||
/* backup subsurf grids */
|
||||
subGridData[i] = MEM_callocN(sizeof(DMGridData)*highGridSize*highGridSize, "subGridData");
|
||||
memcpy(subGridData[i], highGridData[i], sizeof(DMGridData)*highGridSize*highGridSize);
|
||||
subGridData[i] = MEM_callocN(sizeof(DMGridData) * highGridSize * highGridSize, "subGridData");
|
||||
memcpy(subGridData[i], highGridData[i], sizeof(DMGridData) * highGridSize * highGridSize);
|
||||
|
||||
/* overwrite with current displaced grids */
|
||||
multires_copy_dm_grid(highGridData[i], lowGridData[i], highGridSize, lowGridSize);
|
||||
@ -882,7 +882,7 @@ static void multires_subdivide(MultiresModifierData *mmd, Object *ob, int totlvl
|
||||
lowdm->release(lowdm);
|
||||
|
||||
/* subsurf higher levels again with displaced data */
|
||||
ss= ((CCGDerivedMesh*)highdm)->ss;
|
||||
ss = ((CCGDerivedMesh *)highdm)->ss;
|
||||
ccgSubSurf_updateFromFaces(ss, lvl, NULL, 0);
|
||||
ccgSubSurf_updateLevels(ss, lvl, NULL, 0);
|
||||
|
||||
@ -908,7 +908,7 @@ static void multires_subdivide(MultiresModifierData *mmd, Object *ob, int totlvl
|
||||
|
||||
void multiresModifier_subdivide(MultiresModifierData *mmd, Object *ob, int updateblock, int simple)
|
||||
{
|
||||
multires_subdivide(mmd, ob, mmd->totlvl+1, updateblock, simple);
|
||||
multires_subdivide(mmd, ob, mmd->totlvl + 1, updateblock, simple);
|
||||
}
|
||||
|
||||
void grid_tangent(int gridSize, int index, int x, int y, int axis, DMGridData **gridData, float t[3])
|
||||
@ -916,28 +916,28 @@ void grid_tangent(int gridSize, int index, int x, int y, int axis, DMGridData **
|
||||
if (axis == 0) {
|
||||
if (x == gridSize - 1) {
|
||||
if (y == gridSize - 1)
|
||||
sub_v3_v3v3(t, gridData[index][x + gridSize*(y - 1)].co, gridData[index][x - 1 + gridSize*(y - 1)].co);
|
||||
sub_v3_v3v3(t, gridData[index][x + gridSize * (y - 1)].co, gridData[index][x - 1 + gridSize * (y - 1)].co);
|
||||
else
|
||||
sub_v3_v3v3(t, gridData[index][x + gridSize*y].co, gridData[index][x - 1 + gridSize*y].co);
|
||||
sub_v3_v3v3(t, gridData[index][x + gridSize * y].co, gridData[index][x - 1 + gridSize * y].co);
|
||||
}
|
||||
else
|
||||
sub_v3_v3v3(t, gridData[index][x + 1 + gridSize*y].co, gridData[index][x + gridSize*y].co);
|
||||
sub_v3_v3v3(t, gridData[index][x + 1 + gridSize * y].co, gridData[index][x + gridSize * y].co);
|
||||
}
|
||||
else if (axis == 1) {
|
||||
if (y == gridSize - 1) {
|
||||
if (x == gridSize - 1)
|
||||
sub_v3_v3v3(t, gridData[index][x - 1 + gridSize*y].co, gridData[index][x - 1 + gridSize*(y - 1)].co);
|
||||
sub_v3_v3v3(t, gridData[index][x - 1 + gridSize * y].co, gridData[index][x - 1 + gridSize * (y - 1)].co);
|
||||
else
|
||||
sub_v3_v3v3(t, gridData[index][x + gridSize*y].co, gridData[index][x + gridSize*(y - 1)].co);
|
||||
sub_v3_v3v3(t, gridData[index][x + gridSize * y].co, gridData[index][x + gridSize * (y - 1)].co);
|
||||
}
|
||||
else
|
||||
sub_v3_v3v3(t, gridData[index][x + gridSize*(y + 1)].co, gridData[index][x + gridSize*y].co);
|
||||
sub_v3_v3v3(t, gridData[index][x + gridSize * (y + 1)].co, gridData[index][x + gridSize * y].co);
|
||||
}
|
||||
}
|
||||
|
||||
static void multiresModifier_disp_run(DerivedMesh *dm, Mesh *me, DerivedMesh *dm2, DispOp op, DMGridData **oldGridData, int totlvl)
|
||||
{
|
||||
CCGDerivedMesh *ccgdm = (CCGDerivedMesh*)dm;
|
||||
CCGDerivedMesh *ccgdm = (CCGDerivedMesh *)dm;
|
||||
DMGridData **gridData, **subGridData;
|
||||
MPoly *mpoly = me->mpoly;
|
||||
MDisps *mdisps = CustomData_get_layer(&me->ldata, CD_MDISPS);
|
||||
@ -968,10 +968,10 @@ static void multiresModifier_disp_run(DerivedMesh *dm, Mesh *me, DerivedMesh *dm
|
||||
gridSize = dm->getGridSize(dm);
|
||||
gridData = dm->getGridData(dm);
|
||||
gridOffset = dm->getGridOffset(dm);
|
||||
subGridData = (oldGridData)? oldGridData: gridData;
|
||||
subGridData = (oldGridData) ? oldGridData : gridData;
|
||||
|
||||
dGridSize = multires_side_tot[totlvl];
|
||||
dSkip = (dGridSize-1)/(gridSize-1);
|
||||
dSkip = (dGridSize - 1) / (gridSize - 1);
|
||||
|
||||
k = 0; /*current loop/mdisp index within the mloop array*/
|
||||
|
||||
@ -982,7 +982,7 @@ static void multiresModifier_disp_run(DerivedMesh *dm, Mesh *me, DerivedMesh *dm
|
||||
int S, x, y, gIndex = gridOffset[i];
|
||||
|
||||
for (S = 0; S < numVerts; ++S, ++gIndex, ++k) {
|
||||
MDisps *mdisp = &mdisps[mpoly[i].loopstart+S];
|
||||
MDisps *mdisp = &mdisps[mpoly[i].loopstart + S];
|
||||
DMGridData *grid = gridData[gIndex];
|
||||
DMGridData *subgrid = subGridData[gIndex];
|
||||
float (*dispgrid)[3] = NULL;
|
||||
@ -998,10 +998,10 @@ static void multiresModifier_disp_run(DerivedMesh *dm, Mesh *me, DerivedMesh *dm
|
||||
|
||||
for (y = 0; y < gridSize; y++) {
|
||||
for (x = 0; x < gridSize; x++) {
|
||||
float *co = grid[x + y*gridSize].co;
|
||||
float *sco = subgrid[x + y*gridSize].co;
|
||||
float *no = subgrid[x + y*gridSize].no;
|
||||
float *data = dispgrid[dGridSize*y*dSkip + x*dSkip];
|
||||
float *co = grid[x + y * gridSize].co;
|
||||
float *sco = subgrid[x + y * gridSize].co;
|
||||
float *no = subgrid[x + y * gridSize].no;
|
||||
float *data = dispgrid[dGridSize * y * dSkip + x * dSkip];
|
||||
float mat[3][3], tx[3], ty[3], disp[3], d[3];
|
||||
|
||||
/* construct tangent space matrix */
|
||||
@ -1052,7 +1052,7 @@ static void multiresModifier_disp_run(DerivedMesh *dm, Mesh *me, DerivedMesh *dm
|
||||
|
||||
void multires_modifier_update_mdisps(struct DerivedMesh *dm)
|
||||
{
|
||||
CCGDerivedMesh *ccgdm= (CCGDerivedMesh*)dm;
|
||||
CCGDerivedMesh *ccgdm = (CCGDerivedMesh *)dm;
|
||||
Object *ob;
|
||||
Mesh *me;
|
||||
MDisps *mdisps;
|
||||
@ -1095,16 +1095,16 @@ void multires_modifier_update_mdisps(struct DerivedMesh *dm)
|
||||
lowGridData = lowdm->getGridData(lowdm);
|
||||
gridData = dm->getGridData(dm);
|
||||
|
||||
subGridData = MEM_callocN(sizeof(DMGridData*)*numGrids, "subGridData*");
|
||||
diffGrid = MEM_callocN(sizeof(DMGridData)*lowGridSize*lowGridSize, "diff");
|
||||
subGridData = MEM_callocN(sizeof(DMGridData *) * numGrids, "subGridData*");
|
||||
diffGrid = MEM_callocN(sizeof(DMGridData) * lowGridSize * lowGridSize, "diff");
|
||||
|
||||
for (i = 0; i < numGrids; ++i) {
|
||||
/* backup subsurf grids */
|
||||
subGridData[i] = MEM_callocN(sizeof(DMGridData)*highGridSize*highGridSize, "subGridData");
|
||||
memcpy(subGridData[i], highGridData[i], sizeof(DMGridData)*highGridSize*highGridSize);
|
||||
subGridData[i] = MEM_callocN(sizeof(DMGridData) * highGridSize * highGridSize, "subGridData");
|
||||
memcpy(subGridData[i], highGridData[i], sizeof(DMGridData) * highGridSize * highGridSize);
|
||||
|
||||
/* write difference of subsurf and displaced low level into high subsurf */
|
||||
for (j = 0; j < lowGridSize*lowGridSize; ++j)
|
||||
for (j = 0; j < lowGridSize * lowGridSize; ++j)
|
||||
sub_v3_v3v3(diffGrid[j].co, gridData[i][j].co, lowGridData[i][j].co);
|
||||
|
||||
multires_copy_dm_grid(highGridData[i], diffGrid, highGridSize, lowGridSize);
|
||||
@ -1115,7 +1115,7 @@ void multires_modifier_update_mdisps(struct DerivedMesh *dm)
|
||||
lowdm->release(lowdm);
|
||||
|
||||
/* subsurf higher levels again with difference of coordinates */
|
||||
ss= ((CCGDerivedMesh*)highdm)->ss;
|
||||
ss = ((CCGDerivedMesh *)highdm)->ss;
|
||||
ccgSubSurf_updateFromFaces(ss, lvl, NULL, 0);
|
||||
ccgSubSurf_updateLevels(ss, lvl, NULL, 0);
|
||||
|
||||
@ -1147,8 +1147,8 @@ void multires_modifier_update_mdisps(struct DerivedMesh *dm)
|
||||
|
||||
void multires_modifier_update_hidden(DerivedMesh *dm)
|
||||
{
|
||||
CCGDerivedMesh *ccgdm= (CCGDerivedMesh*)dm;
|
||||
BLI_bitmap *grid_hidden= ccgdm->gridHidden;
|
||||
CCGDerivedMesh *ccgdm = (CCGDerivedMesh *)dm;
|
||||
BLI_bitmap *grid_hidden = ccgdm->gridHidden;
|
||||
Mesh *me = ccgdm->multires.ob->data;
|
||||
MDisps *mdisps = CustomData_get_layer(&me->ldata, CD_MDISPS);
|
||||
int totlvl = ccgdm->multires.totlvl;
|
||||
@ -1180,7 +1180,7 @@ void multires_modifier_update_hidden(DerivedMesh *dm)
|
||||
void multires_set_space(DerivedMesh *dm, Object *ob, int from, int to)
|
||||
{
|
||||
DerivedMesh *ccgdm = NULL, *subsurf = NULL;
|
||||
DMGridData **gridData, **subGridData=NULL;
|
||||
DMGridData **gridData, **subGridData = NULL;
|
||||
MPoly *mpoly = CustomData_get_layer(&dm->polyData, CD_MPOLY);
|
||||
MDisps *mdisps;
|
||||
MultiresModifierData *mmd = get_multires_modifier(NULL, ob, 1);
|
||||
@ -1206,20 +1206,20 @@ void multires_set_space(DerivedMesh *dm, Object *ob, int from, int to)
|
||||
gridSize = subsurf->getGridSize(subsurf);
|
||||
gridData = subsurf->getGridData(subsurf);
|
||||
|
||||
subGridData = MEM_callocN(sizeof(DMGridData*)*numGrids, "subGridData*");
|
||||
subGridData = MEM_callocN(sizeof(DMGridData *) * numGrids, "subGridData*");
|
||||
|
||||
for (i = 0; i < numGrids; i++) {
|
||||
subGridData[i] = MEM_callocN(sizeof(DMGridData)*gridSize*gridSize, "subGridData");
|
||||
memcpy(subGridData[i], gridData[i], sizeof(DMGridData)*gridSize*gridSize);
|
||||
subGridData[i] = MEM_callocN(sizeof(DMGridData) * gridSize * gridSize, "subGridData");
|
||||
memcpy(subGridData[i], gridData[i], sizeof(DMGridData) * gridSize * gridSize);
|
||||
}
|
||||
|
||||
/*numGrids = ccgdm->dm->getNumGrids((DerivedMesh*)ccgdm);*/ /*UNUSED*/
|
||||
gridSize = ccgdm->getGridSize((DerivedMesh*)ccgdm);
|
||||
gridData = ccgdm->getGridData((DerivedMesh*)ccgdm);
|
||||
gridOffset = ccgdm->getGridOffset((DerivedMesh*)ccgdm);
|
||||
gridSize = ccgdm->getGridSize((DerivedMesh *)ccgdm);
|
||||
gridData = ccgdm->getGridData((DerivedMesh *)ccgdm);
|
||||
gridOffset = ccgdm->getGridOffset((DerivedMesh *)ccgdm);
|
||||
|
||||
dGridSize = multires_side_tot[totlvl];
|
||||
dSkip = (dGridSize-1)/(gridSize-1);
|
||||
dSkip = (dGridSize - 1) / (gridSize - 1);
|
||||
|
||||
k = 0; /*current loop/mdisp index within the mloop array*/
|
||||
|
||||
@ -1230,25 +1230,25 @@ void multires_set_space(DerivedMesh *dm, Object *ob, int from, int to)
|
||||
int S, x, y, gIndex = gridOffset[i];
|
||||
|
||||
for (S = 0; S < numVerts; ++S, ++gIndex, ++k) {
|
||||
MDisps *mdisp = &mdisps[mpoly[i].loopstart+S];
|
||||
MDisps *mdisp = &mdisps[mpoly[i].loopstart + S];
|
||||
/* DMGridData *grid = gridData[gIndex]; */ /* UNUSED */
|
||||
DMGridData *subgrid = subGridData[gIndex];
|
||||
float (*dispgrid)[3] = NULL;
|
||||
|
||||
/* when adding new faces in edit mode, need to allocate disps */
|
||||
if (!mdisp->disps) {
|
||||
mdisp->totdisp = gridSize*gridSize;
|
||||
mdisp->totdisp = gridSize * gridSize;
|
||||
mdisp->level = totlvl;
|
||||
mdisp->disps = MEM_callocN(sizeof(float)*3*mdisp->totdisp, "disp in multires_set_space");
|
||||
mdisp->disps = MEM_callocN(sizeof(float) * 3 * mdisp->totdisp, "disp in multires_set_space");
|
||||
}
|
||||
|
||||
dispgrid = mdisp->disps;
|
||||
|
||||
for (y = 0; y < gridSize; y++) {
|
||||
for (x = 0; x < gridSize; x++) {
|
||||
float *data = dispgrid[dGridSize*y*dSkip + x*dSkip];
|
||||
float *no = subgrid[x + y*gridSize].no;
|
||||
float *co = subgrid[x + y*gridSize].co;
|
||||
float *data = dispgrid[dGridSize * y * dSkip + x * dSkip];
|
||||
float *no = subgrid[x + y * gridSize].no;
|
||||
float *co = subgrid[x + y * gridSize].co;
|
||||
float mat[3][3], tx[3], ty[3], dco[3];
|
||||
|
||||
/* construct tangent space matrix */
|
||||
@ -1308,12 +1308,12 @@ void multires_stitch_grids(Object *ob)
|
||||
{
|
||||
/* utility for smooth brush */
|
||||
if (ob && ob->derivedFinal) {
|
||||
CCGDerivedMesh *ccgdm = (CCGDerivedMesh*)ob->derivedFinal;
|
||||
CCGDerivedMesh *ccgdm = (CCGDerivedMesh *)ob->derivedFinal;
|
||||
CCGFace **faces;
|
||||
int totface;
|
||||
|
||||
if (ccgdm->pbvh) {
|
||||
BLI_pbvh_get_grid_updates(ccgdm->pbvh, 0, (void***)&faces, &totface);
|
||||
BLI_pbvh_get_grid_updates(ccgdm->pbvh, 0, (void ***)&faces, &totface);
|
||||
|
||||
if (totface) {
|
||||
ccgSubSurf_stitchFaces(ccgdm->ss, 0, faces, totface);
|
||||
@ -1327,11 +1327,11 @@ DerivedMesh *multires_dm_create_from_derived(MultiresModifierData *mmd,
|
||||
int local_mmd, DerivedMesh *dm,
|
||||
Object *ob, int useRenderParams)
|
||||
{
|
||||
Mesh *me= ob->data;
|
||||
Mesh *me = ob->data;
|
||||
DerivedMesh *result;
|
||||
CCGDerivedMesh *ccgdm = NULL;
|
||||
DMGridData **gridData, **subGridData;
|
||||
int lvl= multires_get_level(ob, mmd, useRenderParams);
|
||||
int lvl = multires_get_level(ob, mmd, useRenderParams);
|
||||
int i, gridSize, numGrids;
|
||||
|
||||
if (lvl == 0)
|
||||
@ -1342,7 +1342,7 @@ DerivedMesh *multires_dm_create_from_derived(MultiresModifierData *mmd,
|
||||
mmd->flags & eMultiresModifierFlag_PlainUv);
|
||||
|
||||
if (!local_mmd) {
|
||||
ccgdm = (CCGDerivedMesh*)result;
|
||||
ccgdm = (CCGDerivedMesh *)result;
|
||||
|
||||
ccgdm->multires.ob = ob;
|
||||
ccgdm->multires.mmd = mmd;
|
||||
@ -1356,11 +1356,11 @@ DerivedMesh *multires_dm_create_from_derived(MultiresModifierData *mmd,
|
||||
gridSize = result->getGridSize(result);
|
||||
gridData = result->getGridData(result);
|
||||
|
||||
subGridData = MEM_callocN(sizeof(DMGridData*)*numGrids, "subGridData*");
|
||||
subGridData = MEM_callocN(sizeof(DMGridData *) * numGrids, "subGridData*");
|
||||
|
||||
for (i = 0; i < numGrids; i++) {
|
||||
subGridData[i] = MEM_callocN(sizeof(DMGridData)*gridSize*gridSize, "subGridData");
|
||||
memcpy(subGridData[i], gridData[i], sizeof(DMGridData)*gridSize*gridSize);
|
||||
subGridData[i] = MEM_callocN(sizeof(DMGridData) * gridSize * gridSize, "subGridData");
|
||||
memcpy(subGridData[i], gridData[i], sizeof(DMGridData) * gridSize * gridSize);
|
||||
}
|
||||
|
||||
multires_set_tot_mdisps(me, mmd->totlvl);
|
||||
@ -1430,22 +1430,22 @@ void old_mdisps_bilinear(float out[3], float (*disps)[3], const int st, float u,
|
||||
|
||||
static void old_mdisps_rotate(int S, int UNUSED(newside), int oldside, int x, int y, float *u, float *v)
|
||||
{
|
||||
float offset = oldside*0.5f - 0.5f;
|
||||
float offset = oldside * 0.5f - 0.5f;
|
||||
|
||||
if (S == 1) { *u= offset + x; *v = offset - y; }
|
||||
if (S == 2) { *u= offset + y; *v = offset + x; }
|
||||
if (S == 3) { *u= offset - x; *v = offset + y; }
|
||||
if (S == 0) { *u= offset - y; *v = offset - x; }
|
||||
if (S == 1) { *u = offset + x; *v = offset - y; }
|
||||
if (S == 2) { *u = offset + y; *v = offset + x; }
|
||||
if (S == 3) { *u = offset - x; *v = offset + y; }
|
||||
if (S == 0) { *u = offset - y; *v = offset - x; }
|
||||
}
|
||||
|
||||
static void old_mdisps_convert(MFace *mface, MDisps *mdisp)
|
||||
{
|
||||
int newlvl = log(sqrt(mdisp->totdisp)-1)/M_LN2;
|
||||
int oldlvl = newlvl+1;
|
||||
int newlvl = log(sqrt(mdisp->totdisp) - 1) / M_LN2;
|
||||
int oldlvl = newlvl + 1;
|
||||
int oldside = multires_side_tot[oldlvl];
|
||||
int newside = multires_side_tot[newlvl];
|
||||
int nvert = (mface->v4)? 4: 3;
|
||||
int newtotdisp = multires_grid_tot[newlvl]*nvert;
|
||||
int nvert = (mface->v4) ? 4 : 3;
|
||||
int newtotdisp = multires_grid_tot[newlvl] * nvert;
|
||||
int x, y, S;
|
||||
float (*disps)[3], (*out)[3], u = 0.0f, v = 0.0f; /* Quite gcc barking. */
|
||||
|
||||
@ -1458,19 +1458,19 @@ static void old_mdisps_convert(MFace *mface, MDisps *mdisp)
|
||||
old_mdisps_rotate(S, newside, oldside, x, y, &u, &v);
|
||||
old_mdisps_bilinear(*out, mdisp->disps, oldside, u, v);
|
||||
|
||||
if (S == 1) { (*out)[1]= -(*out)[1]; }
|
||||
if (S == 1) { (*out)[1] = -(*out)[1]; }
|
||||
else if (S == 2) { SWAP(float, (*out)[0], (*out)[1]); }
|
||||
else if (S == 3) { (*out)[0]= -(*out)[0]; }
|
||||
else if (S == 0) { SWAP(float, (*out)[0], (*out)[1]); (*out)[0]= -(*out)[0]; (*out)[1]= -(*out)[1]; };
|
||||
else if (S == 3) { (*out)[0] = -(*out)[0]; }
|
||||
else if (S == 0) { SWAP(float, (*out)[0], (*out)[1]); (*out)[0] = -(*out)[0]; (*out)[1] = -(*out)[1]; };
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
MEM_freeN(mdisp->disps);
|
||||
|
||||
mdisp->totdisp= newtotdisp;
|
||||
mdisp->level= newlvl;
|
||||
mdisp->disps= disps;
|
||||
mdisp->totdisp = newtotdisp;
|
||||
mdisp->level = newlvl;
|
||||
mdisp->disps = disps;
|
||||
}
|
||||
|
||||
void multires_load_old_250(Mesh *me)
|
||||
@ -1479,10 +1479,10 @@ void multires_load_old_250(Mesh *me)
|
||||
MFace *mf;
|
||||
int i, j, k;
|
||||
|
||||
mdisps= CustomData_get_layer(&me->fdata, CD_MDISPS);
|
||||
mdisps = CustomData_get_layer(&me->fdata, CD_MDISPS);
|
||||
|
||||
if (mdisps) {
|
||||
for (i=0; i<me->totface; i++)
|
||||
for (i = 0; i < me->totface; i++)
|
||||
if (mdisps[i].totdisp)
|
||||
old_mdisps_convert(&me->mface[i], &mdisps[i]);
|
||||
|
||||
@ -1491,15 +1491,15 @@ void multires_load_old_250(Mesh *me)
|
||||
|
||||
k = 0;
|
||||
mf = me->mface;
|
||||
for (i=0; i<me->totface; i++, mf++) {
|
||||
for (i = 0; i < me->totface; i++, mf++) {
|
||||
int nvert = mf->v4 ? 4 : 3;
|
||||
int totdisp = mdisps[i].totdisp / nvert;
|
||||
|
||||
for (j=0; j < mf->v4 ? 4 : 3; j++, k++) {
|
||||
mdisps2[k].disps = MEM_callocN(sizeof(float)*3*totdisp, "multires disp in conversion");
|
||||
for (j = 0; j < mf->v4 ? 4 : 3; j++, k++) {
|
||||
mdisps2[k].disps = MEM_callocN(sizeof(float) * 3 * totdisp, "multires disp in conversion");
|
||||
mdisps2[k].totdisp = totdisp;
|
||||
mdisps2[k].level = mdisps[i].level;
|
||||
memcpy(mdisps2[k].disps, mdisps[i].disps + totdisp*j, totdisp);
|
||||
memcpy(mdisps2[k].disps, mdisps[i].disps + totdisp * j, totdisp);
|
||||
}
|
||||
|
||||
}
|
||||
@ -1519,7 +1519,7 @@ static void multires_free_level(MultiresLevel *lvl)
|
||||
void multires_free(Multires *mr)
|
||||
{
|
||||
if (mr) {
|
||||
MultiresLevel* lvl= mr->levels.first;
|
||||
MultiresLevel *lvl = mr->levels.first;
|
||||
|
||||
/* Free the first-level data */
|
||||
if (lvl) {
|
||||
@ -1533,7 +1533,7 @@ void multires_free(Multires *mr)
|
||||
|
||||
while (lvl) {
|
||||
multires_free_level(lvl);
|
||||
lvl= lvl->next;
|
||||
lvl = lvl->next;
|
||||
}
|
||||
|
||||
MEM_freeN(mr->verts);
|
||||
@ -1551,12 +1551,12 @@ static void create_old_vert_face_map(ListBase **map, IndexNode **mem, const Mult
|
||||
IndexNode *node = NULL;
|
||||
|
||||
(*map) = MEM_callocN(sizeof(ListBase) * totvert, "vert face map");
|
||||
(*mem) = MEM_callocN(sizeof(IndexNode) * totface*4, "vert face map mem");
|
||||
(*mem) = MEM_callocN(sizeof(IndexNode) * totface * 4, "vert face map mem");
|
||||
node = *mem;
|
||||
|
||||
/* Find the users */
|
||||
for (i = 0; i < totface; ++i) {
|
||||
for (j = 0; j < (mface[i].v[3]?4:3); ++j, ++node) {
|
||||
for (j = 0; j < (mface[i].v[3] ? 4 : 3); ++j, ++node) {
|
||||
node->index = i;
|
||||
BLI_addtail(&(*map)[mface[i].v[j]], node);
|
||||
}
|
||||
@ -1570,7 +1570,7 @@ static void create_old_vert_edge_map(ListBase **map, IndexNode **mem, const Mult
|
||||
IndexNode *node = NULL;
|
||||
|
||||
(*map) = MEM_callocN(sizeof(ListBase) * totvert, "vert edge map");
|
||||
(*mem) = MEM_callocN(sizeof(IndexNode) * totedge*2, "vert edge map mem");
|
||||
(*mem) = MEM_callocN(sizeof(IndexNode) * totedge * 2, "vert edge map mem");
|
||||
node = *mem;
|
||||
|
||||
/* Find the users */
|
||||
@ -1587,10 +1587,10 @@ static MultiresFace *find_old_face(ListBase *map, MultiresFace *faces, int v1, i
|
||||
IndexNode *n1;
|
||||
int v[4], i, j;
|
||||
|
||||
v[0]= v1;
|
||||
v[1]= v2;
|
||||
v[2]= v3;
|
||||
v[3]= v4;
|
||||
v[0] = v1;
|
||||
v[1] = v2;
|
||||
v[2] = v3;
|
||||
v[3] = v4;
|
||||
|
||||
for (n1 = map[v1].first; n1; n1 = n1->next) {
|
||||
int fnd[4] = {0, 0, 0, 0};
|
||||
@ -1673,7 +1673,7 @@ static void multires_load_old_faces(ListBase **fmap, ListBase **emap, MultiresLe
|
||||
|
||||
static void multires_mvert_to_ss(DerivedMesh *dm, MVert *mvert)
|
||||
{
|
||||
CCGDerivedMesh *ccgdm = (CCGDerivedMesh*) dm;
|
||||
CCGDerivedMesh *ccgdm = (CCGDerivedMesh *) dm;
|
||||
CCGSubSurf *ss = ccgdm->ss;
|
||||
DMGridData *vd;
|
||||
int index;
|
||||
@ -1687,13 +1687,13 @@ static void multires_mvert_to_ss(DerivedMesh *dm, MVert *mvert)
|
||||
CCGFace *f = ccgdm->faceMap[index].face;
|
||||
int x, y, S, numVerts = ccgSubSurf_getFaceNumVerts(f);
|
||||
|
||||
vd= ccgSubSurf_getFaceCenterData(f);
|
||||
vd = ccgSubSurf_getFaceCenterData(f);
|
||||
copy_v3_v3(vd->co, mvert[i].co);
|
||||
i++;
|
||||
|
||||
for (S = 0; S < numVerts; S++) {
|
||||
for (x = 1; x < gridSize - 1; x++, i++) {
|
||||
vd= ccgSubSurf_getFaceGridEdgeData(ss, f, S, x);
|
||||
vd = ccgSubSurf_getFaceGridEdgeData(ss, f, S, x);
|
||||
copy_v3_v3(vd->co, mvert[i].co);
|
||||
}
|
||||
}
|
||||
@ -1701,7 +1701,7 @@ static void multires_mvert_to_ss(DerivedMesh *dm, MVert *mvert)
|
||||
for (S = 0; S < numVerts; S++) {
|
||||
for (y = 1; y < gridSize - 1; y++) {
|
||||
for (x = 1; x < gridSize - 1; x++, i++) {
|
||||
vd= ccgSubSurf_getFaceGridData(ss, f, S, x, y);
|
||||
vd = ccgSubSurf_getFaceGridData(ss, f, S, x, y);
|
||||
copy_v3_v3(vd->co, mvert[i].co);
|
||||
}
|
||||
}
|
||||
@ -1714,7 +1714,7 @@ static void multires_mvert_to_ss(DerivedMesh *dm, MVert *mvert)
|
||||
int x;
|
||||
|
||||
for (x = 1; x < edgeSize - 1; x++, i++) {
|
||||
vd= ccgSubSurf_getEdgeData(ss, e, x);
|
||||
vd = ccgSubSurf_getEdgeData(ss, e, x);
|
||||
copy_v3_v3(vd->co, mvert[i].co);
|
||||
}
|
||||
}
|
||||
@ -1723,7 +1723,7 @@ static void multires_mvert_to_ss(DerivedMesh *dm, MVert *mvert)
|
||||
for (index = 0; index < totvert; index++) {
|
||||
CCGVert *v = ccgdm->vertMap[index].vert;
|
||||
|
||||
vd= ccgSubSurf_getVertData(ss, v);
|
||||
vd = ccgSubSurf_getVertData(ss, v);
|
||||
copy_v3_v3(vd->co, mvert[i].co);
|
||||
i++;
|
||||
}
|
||||
@ -1735,7 +1735,7 @@ static void multires_mvert_to_ss(DerivedMesh *dm, MVert *mvert)
|
||||
static void multires_load_old_dm(DerivedMesh *dm, Mesh *me, int totlvl)
|
||||
{
|
||||
MultiresLevel *lvl, *lvl1;
|
||||
Multires *mr= me->mr;
|
||||
Multires *mr = me->mr;
|
||||
MVert *vsrc, *vdst;
|
||||
unsigned int src, dst;
|
||||
int st = multires_side_tot[totlvl - 1] - 1;
|
||||
@ -1834,10 +1834,10 @@ static void multires_load_old_dm(DerivedMesh *dm, Mesh *me, int totlvl)
|
||||
}
|
||||
|
||||
/* calculate vert to edge/face maps for each level (except the last) */
|
||||
fmap = MEM_callocN(sizeof(ListBase*) * (mr->level_count-1), "multires fmap");
|
||||
emap = MEM_callocN(sizeof(ListBase*) * (mr->level_count-1), "multires emap");
|
||||
fmem = MEM_callocN(sizeof(IndexNode*) * (mr->level_count-1), "multires fmem");
|
||||
emem = MEM_callocN(sizeof(IndexNode*) * (mr->level_count-1), "multires emem");
|
||||
fmap = MEM_callocN(sizeof(ListBase *) * (mr->level_count - 1), "multires fmap");
|
||||
emap = MEM_callocN(sizeof(ListBase *) * (mr->level_count - 1), "multires emap");
|
||||
fmem = MEM_callocN(sizeof(IndexNode *) * (mr->level_count - 1), "multires fmem");
|
||||
emem = MEM_callocN(sizeof(IndexNode *) * (mr->level_count - 1), "multires emem");
|
||||
lvl = lvl1;
|
||||
for (i = 0; i < (unsigned int)mr->level_count - 1; ++i) {
|
||||
create_old_vert_face_map(fmap + i, fmem + i, lvl->faces, lvl->totvert, lvl->totface);
|
||||
@ -1920,10 +1920,10 @@ static void multires_load_old_vcols(Mesh *me)
|
||||
|
||||
for (i = 0; i < me->totface; ++i) {
|
||||
for (j = 0; j < 4; ++j) {
|
||||
mcol[i*4 + j].a = colface[i].col[j].a;
|
||||
mcol[i*4 + j].r = colface[i].col[j].r;
|
||||
mcol[i*4 + j].g = colface[i].col[j].g;
|
||||
mcol[i*4 + j].b = colface[i].col[j].b;
|
||||
mcol[i * 4 + j].a = colface[i].col[j].a;
|
||||
mcol[i * 4 + j].r = colface[i].col[j].r;
|
||||
mcol[i * 4 + j].g = colface[i].col[j].g;
|
||||
mcol[i * 4 + j].b = colface[i].col[j].b;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1982,7 +1982,7 @@ void multires_load_old(Object *ob, Mesh *me)
|
||||
md = ob->modifiers.first;
|
||||
while (md && modifierType_getInfo(md->type)->type == eModifierTypeType_OnlyDeform)
|
||||
md = md->next;
|
||||
mmd = (MultiresModifierData*)modifier_new(eModifierType_Multires);
|
||||
mmd = (MultiresModifierData *)modifier_new(eModifierType_Multires);
|
||||
BLI_insertlinkbefore(&ob->modifiers, md, mmd);
|
||||
|
||||
for (i = 0; i < me->mr->level_count - 1; ++i)
|
||||
@ -1992,7 +1992,7 @@ void multires_load_old(Object *ob, Mesh *me)
|
||||
orig = CDDM_from_mesh(me, NULL);
|
||||
dm = multires_dm_create_from_derived(mmd, 0, orig, ob, 0);
|
||||
|
||||
multires_load_old_dm(dm, me, mmd->totlvl+1);
|
||||
multires_load_old_dm(dm, me, mmd->totlvl + 1);
|
||||
|
||||
multires_dm_mark_as_modified(dm, MULTIRES_COORDS_MODIFIED);
|
||||
dm->release(dm);
|
||||
@ -2011,13 +2011,13 @@ void multires_load_old(Object *ob, Mesh *me)
|
||||
|
||||
/* Remove the old multires */
|
||||
multires_free(me->mr);
|
||||
me->mr= NULL;
|
||||
me->mr = NULL;
|
||||
}
|
||||
|
||||
static void multires_sync_levels(Scene *scene, Object *ob, Object *to_ob)
|
||||
{
|
||||
MultiresModifierData *mmd= get_multires_modifier(scene, ob, 1);
|
||||
MultiresModifierData *to_mmd= get_multires_modifier(scene, to_ob, 1);
|
||||
MultiresModifierData *mmd = get_multires_modifier(scene, ob, 1);
|
||||
MultiresModifierData *to_mmd = get_multires_modifier(scene, to_ob, 1);
|
||||
|
||||
if (!mmd) {
|
||||
/* object could have MDISP even when there is no multires modifier
|
||||
@ -2030,77 +2030,77 @@ static void multires_sync_levels(Scene *scene, Object *ob, Object *to_ob)
|
||||
|
||||
if (!mmd || !to_mmd) return;
|
||||
|
||||
if (mmd->totlvl>to_mmd->totlvl) multires_del_higher(mmd, ob, to_mmd->totlvl);
|
||||
if (mmd->totlvl > to_mmd->totlvl) multires_del_higher(mmd, ob, to_mmd->totlvl);
|
||||
else multires_subdivide(mmd, ob, to_mmd->totlvl, 0, mmd->simple);
|
||||
}
|
||||
|
||||
static void multires_apply_smat(Scene *scene, Object *ob, float smat[3][3])
|
||||
{
|
||||
DerivedMesh *dm= NULL, *cddm= NULL, *subdm= NULL;
|
||||
DerivedMesh *dm = NULL, *cddm = NULL, *subdm = NULL;
|
||||
DMGridData **gridData, **subGridData;
|
||||
Mesh *me= (Mesh*)ob->data;
|
||||
MPoly *mpoly= me->mpoly;
|
||||
Mesh *me = (Mesh *)ob->data;
|
||||
MPoly *mpoly = me->mpoly;
|
||||
/* MLoop *mloop = me->mloop; */ /* UNUSED */
|
||||
MDisps *mdisps;
|
||||
int *gridOffset;
|
||||
int i, /*numGrids, */ gridSize, dGridSize, dSkip, totvert;
|
||||
float (*vertCos)[3] = NULL;
|
||||
MultiresModifierData *mmd= get_multires_modifier(scene, ob, 1);
|
||||
MultiresModifierData *mmd = get_multires_modifier(scene, ob, 1);
|
||||
MultiresModifierData high_mmd;
|
||||
|
||||
CustomData_external_read(&me->ldata, &me->id, CD_MASK_MDISPS, me->totloop);
|
||||
mdisps= CustomData_get_layer(&me->ldata, CD_MDISPS);
|
||||
mdisps = CustomData_get_layer(&me->ldata, CD_MDISPS);
|
||||
|
||||
if (!mdisps || !mmd || !mmd->totlvl) return;
|
||||
|
||||
/* we need derived mesh created from highest resolution */
|
||||
high_mmd= *mmd;
|
||||
high_mmd.lvl= high_mmd.totlvl;
|
||||
high_mmd = *mmd;
|
||||
high_mmd.lvl = high_mmd.totlvl;
|
||||
|
||||
/* unscaled multires with applied displacement */
|
||||
subdm= get_multires_dm(scene, &high_mmd, ob);
|
||||
subdm = get_multires_dm(scene, &high_mmd, ob);
|
||||
|
||||
/* prepare scaled CDDM to create ccgDN */
|
||||
cddm= mesh_get_derived_deform(scene, ob, CD_MASK_BAREMESH);
|
||||
cddm = mesh_get_derived_deform(scene, ob, CD_MASK_BAREMESH);
|
||||
|
||||
totvert= cddm->getNumVerts(cddm);
|
||||
vertCos= MEM_mallocN(sizeof(*vertCos) * totvert, "multiresScale vertCos");
|
||||
totvert = cddm->getNumVerts(cddm);
|
||||
vertCos = MEM_mallocN(sizeof(*vertCos) * totvert, "multiresScale vertCos");
|
||||
cddm->getVertCos(cddm, vertCos);
|
||||
for (i=0; i<totvert; i++)
|
||||
for (i = 0; i < totvert; i++)
|
||||
mul_m3_v3(smat, vertCos[i]);
|
||||
CDDM_apply_vert_coords(cddm, vertCos);
|
||||
MEM_freeN(vertCos);
|
||||
|
||||
/* scaled ccgDM for tangent space of object with applied scale */
|
||||
dm= subsurf_dm_create_local(ob, cddm, high_mmd.totlvl, high_mmd.simple, 0, mmd->flags & eMultiresModifierFlag_PlainUv);
|
||||
dm = subsurf_dm_create_local(ob, cddm, high_mmd.totlvl, high_mmd.simple, 0, mmd->flags & eMultiresModifierFlag_PlainUv);
|
||||
cddm->release(cddm);
|
||||
|
||||
/*numGrids= dm->getNumGrids(dm);*/ /*UNUSED*/
|
||||
gridSize= dm->getGridSize(dm);
|
||||
gridData= dm->getGridData(dm);
|
||||
gridOffset= dm->getGridOffset(dm);
|
||||
subGridData= subdm->getGridData(subdm);
|
||||
gridSize = dm->getGridSize(dm);
|
||||
gridData = dm->getGridData(dm);
|
||||
gridOffset = dm->getGridOffset(dm);
|
||||
subGridData = subdm->getGridData(subdm);
|
||||
|
||||
dGridSize= multires_side_tot[high_mmd.totlvl];
|
||||
dSkip= (dGridSize-1)/(gridSize-1);
|
||||
dGridSize = multires_side_tot[high_mmd.totlvl];
|
||||
dSkip = (dGridSize - 1) / (gridSize - 1);
|
||||
|
||||
#pragma omp parallel for private(i) if (me->totface*gridSize*gridSize*4 >= CCG_OMP_LIMIT)
|
||||
for (i = 0; i < me->totpoly; ++i) {
|
||||
const int numVerts= mpoly[i].totloop;
|
||||
MDisps *mdisp= &mdisps[mpoly[i].loopstart];
|
||||
const int numVerts = mpoly[i].totloop;
|
||||
MDisps *mdisp = &mdisps[mpoly[i].loopstart];
|
||||
int S, x, y, gIndex = gridOffset[i];
|
||||
|
||||
for (S = 0; S < numVerts; ++S, ++gIndex, mdisp++) {
|
||||
DMGridData *grid= gridData[gIndex];
|
||||
DMGridData *subgrid= subGridData[gIndex];
|
||||
float (*dispgrid)[3]= mdisp->disps;
|
||||
DMGridData *grid = gridData[gIndex];
|
||||
DMGridData *subgrid = subGridData[gIndex];
|
||||
float (*dispgrid)[3] = mdisp->disps;
|
||||
|
||||
for (y = 0; y < gridSize; y++) {
|
||||
for (x = 0; x < gridSize; x++) {
|
||||
float *co= grid[x + y*gridSize].co;
|
||||
float *sco= subgrid[x + y*gridSize].co;
|
||||
float *no= grid[x + y*gridSize].no;
|
||||
float *data= dispgrid[dGridSize*y*dSkip + x*dSkip];
|
||||
float *co = grid[x + y * gridSize].co;
|
||||
float *sco = subgrid[x + y * gridSize].co;
|
||||
float *no = grid[x + y * gridSize].no;
|
||||
float *data = dispgrid[dGridSize * y * dSkip + x * dSkip];
|
||||
float mat[3][3], tx[3], ty[3], disp[3];
|
||||
|
||||
/* construct tangent space matrix */
|
||||
@ -2130,11 +2130,11 @@ static void multires_apply_smat(Scene *scene, Object *ob, float smat[3][3])
|
||||
|
||||
int multires_mdisp_corners(MDisps *s)
|
||||
{
|
||||
int lvl= 13;
|
||||
int lvl = 13;
|
||||
|
||||
while (lvl > 0) {
|
||||
int side = (1 << (lvl-1)) + 1;
|
||||
if ((s->totdisp % (side*side)) == 0) return s->totdisp / (side*side);
|
||||
int side = (1 << (lvl - 1)) + 1;
|
||||
if ((s->totdisp % (side * side)) == 0) return s->totdisp / (side * side);
|
||||
lvl--;
|
||||
}
|
||||
|
||||
@ -2204,7 +2204,7 @@ void multires_topology_changed(Mesh *me)
|
||||
/* Find per-corner coordinate with given per-face UV coord */
|
||||
int mdisp_rot_face_to_crn(const int corners, const int face_side, const float u, const float v, float *x, float *y)
|
||||
{
|
||||
const float offset = face_side*0.5f - 0.5f;
|
||||
const float offset = face_side * 0.5f - 0.5f;
|
||||
int S = 0;
|
||||
|
||||
if (corners == 4) {
|
||||
@ -2226,7 +2226,7 @@ int mdisp_rot_face_to_crn(const int corners, const int face_side, const float u,
|
||||
*x = v - offset;
|
||||
}
|
||||
else if (S == 3) {
|
||||
*x= offset - u;
|
||||
*x = offset - u;
|
||||
*y = v - offset;
|
||||
}
|
||||
}
|
||||
@ -2235,15 +2235,15 @@ int mdisp_rot_face_to_crn(const int corners, const int face_side, const float u,
|
||||
float w = (face_side - 1) - u - v;
|
||||
float W1, W2;
|
||||
|
||||
if (u >= v && u >= w) {S = 0; W1= w; W2= v;}
|
||||
else if (v >= u && v >= w) {S = 1; W1 = u; W2 = w;}
|
||||
else {S = 2; W1 = v; W2 = u;}
|
||||
if (u >= v && u >= w) {S = 0; W1 = w; W2 = v; }
|
||||
else if (v >= u && v >= w) {S = 1; W1 = u; W2 = w; }
|
||||
else {S = 2; W1 = v; W2 = u; }
|
||||
|
||||
W1 /= (face_side-1);
|
||||
W2 /= (face_side-1);
|
||||
W1 /= (face_side - 1);
|
||||
W2 /= (face_side - 1);
|
||||
|
||||
*x = (1-(2*W1)/(1-W2)) * grid_size;
|
||||
*y = (1-(2*W2)/(1-W1)) * grid_size;
|
||||
*x = (1 - (2 * W1) / (1 - W2)) * grid_size;
|
||||
*y = (1 - (2 * W2) / (1 - W1)) * grid_size;
|
||||
}
|
||||
|
||||
return S;
|
||||
|
@ -133,15 +133,15 @@ int countPackedFiles(Main *bmain)
|
||||
int count = 0;
|
||||
|
||||
// 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)
|
||||
count++;
|
||||
|
||||
for (vf=bmain->vfont.first; vf; vf=vf->id.next)
|
||||
for (vf = bmain->vfont.first; vf; vf = vf->id.next)
|
||||
if (vf->packedfile)
|
||||
count++;
|
||||
|
||||
for (sound=bmain->sound.first; sound; sound=sound->id.next)
|
||||
for (sound = bmain->sound.first; sound; sound = sound->id.next)
|
||||
if (sound->packedfile)
|
||||
count++;
|
||||
|
||||
@ -176,7 +176,7 @@ PackedFile *newPackedFile(ReportList *reports, const char *filename, const char
|
||||
|
||||
/* render result has no filename and can be ignored
|
||||
* any other files with no name can be ignored too */
|
||||
if (filename[0]=='\0')
|
||||
if (filename[0] == '\0')
|
||||
return NULL;
|
||||
|
||||
//XXX waitcursor(1);
|
||||
@ -189,7 +189,7 @@ PackedFile *newPackedFile(ReportList *reports, const char *filename, const char
|
||||
// open the file
|
||||
// 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) {
|
||||
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;
|
||||
bSound *sound;
|
||||
|
||||
for (ima=bmain->image.first; ima; ima=ima->id.next) {
|
||||
if (ima->packedfile == NULL && ima->id.lib==NULL) {
|
||||
if (ima->source==IMA_SRC_FILE) {
|
||||
for (ima = bmain->image.first; ima; ima = ima->id.next) {
|
||||
if (ima->packedfile == NULL && ima->id.lib == NULL) {
|
||||
if (ima->source == IMA_SRC_FILE) {
|
||||
ima->packedfile = newPackedFile(reports, ima->name, ID_BLEND_PATH(bmain, &ima->id));
|
||||
}
|
||||
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)
|
||||
if (vf->packedfile == NULL && vf->id.lib==NULL && strcmp(vf->name, FO_BUILTIN_NAME) != 0)
|
||||
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)
|
||||
vf->packedfile = newPackedFile(reports, vf->name, bmain->name);
|
||||
|
||||
for (sound=bmain->sound.first; sound; sound=sound->id.next)
|
||||
if (sound->packedfile == NULL && sound->id.lib==NULL)
|
||||
for (sound = bmain->sound.first; sound; sound = sound->id.next)
|
||||
if (sound->packedfile == NULL && sound->id.lib == NULL)
|
||||
sound->packedfile = newPackedFile(reports, sound->name, bmain->name);
|
||||
}
|
||||
|
||||
@ -257,12 +257,12 @@ static char *find_new_name(char *name)
|
||||
if (fop_exists(name)) {
|
||||
for (number = 1; number <= 999; number++) {
|
||||
BLI_snprintf(tempname, sizeof(tempname), "%s.%03d", name, number);
|
||||
if (! fop_exists(tempname)) {
|
||||
if (!fop_exists(tempname)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
len= strlen(tempname) + 1;
|
||||
len = strlen(tempname) + 1;
|
||||
newname = MEM_mallocN(len, "find_new_name");
|
||||
memcpy(newname, tempname, len * sizeof(char));
|
||||
return newname;
|
||||
@ -285,7 +285,7 @@ int writePackedFile(ReportList *reports, const char *filename, PackedFile *pf, i
|
||||
if (BLI_exists(name)) {
|
||||
for (number = 1; number <= 999; 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) {
|
||||
remove_tmp = TRUE;
|
||||
}
|
||||
@ -409,7 +409,7 @@ char *unpackFile(ReportList *reports, const char *abs_name, const char *local_na
|
||||
case PF_KEEP:
|
||||
break;
|
||||
case PF_REMOVE:
|
||||
temp= abs_name;
|
||||
temp = abs_name;
|
||||
break;
|
||||
case PF_USE_LOCAL:
|
||||
// if file exists use it
|
||||
@ -441,7 +441,7 @@ char *unpackFile(ReportList *reports, const char *abs_name, const char *local_na
|
||||
}
|
||||
|
||||
if (temp) {
|
||||
newname= BLI_strdup(temp);
|
||||
newname = BLI_strdup(temp);
|
||||
}
|
||||
}
|
||||
|
||||
@ -533,15 +533,15 @@ void unpackAll(Main *bmain, ReportList *reports, int how)
|
||||
VFont *vf;
|
||||
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)
|
||||
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)
|
||||
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)
|
||||
unpackSound(bmain, reports, sound, how);
|
||||
}
|
||||
|
@ -57,7 +57,7 @@ void free_properties(ListBase *lb)
|
||||
{
|
||||
bProperty *prop;
|
||||
|
||||
while ( (prop= lb->first) ) {
|
||||
while ( (prop = lb->first) ) {
|
||||
BLI_remlink(lb, prop);
|
||||
free_property(prop);
|
||||
}
|
||||
@ -67,11 +67,11 @@ bProperty *copy_property(bProperty *prop)
|
||||
{
|
||||
bProperty *propn;
|
||||
|
||||
propn= MEM_dupallocN(prop);
|
||||
propn = MEM_dupallocN(prop);
|
||||
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;
|
||||
}
|
||||
@ -80,11 +80,11 @@ void copy_properties(ListBase *lbn, ListBase *lbo)
|
||||
{
|
||||
bProperty *prop, *propn;
|
||||
free_properties(lbn); /* in case we are copying to an object with props */
|
||||
prop= lbo->first;
|
||||
prop = lbo->first;
|
||||
while (prop) {
|
||||
propn= copy_property(prop);
|
||||
propn = copy_property(prop);
|
||||
BLI_addtail(lbn, propn);
|
||||
prop= prop->next;
|
||||
prop = prop->next;
|
||||
}
|
||||
|
||||
|
||||
@ -95,19 +95,19 @@ void init_property(bProperty *prop)
|
||||
/* also use when property changes type */
|
||||
|
||||
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) {
|
||||
case GPROP_BOOL:
|
||||
case GPROP_INT:
|
||||
case GPROP_FLOAT:
|
||||
case GPROP_TIME:
|
||||
prop->poin= &prop->data;
|
||||
prop->poin = &prop->data;
|
||||
break;
|
||||
case GPROP_STRING:
|
||||
prop->poin= MEM_callocN(MAX_PROPSTRING, "property string");
|
||||
prop->poin = MEM_callocN(MAX_PROPSTRING, "property string");
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -117,8 +117,8 @@ bProperty *new_property(int type)
|
||||
{
|
||||
bProperty *prop;
|
||||
|
||||
prop= MEM_callocN(sizeof(bProperty), "property");
|
||||
prop->type= type;
|
||||
prop = MEM_callocN(sizeof(bProperty), "property");
|
||||
prop->type = type;
|
||||
|
||||
init_property(prop);
|
||||
|
||||
@ -131,8 +131,8 @@ bProperty *new_property(int type)
|
||||
static bProperty *get_property__internal(bProperty *first, bProperty *self, const char *name)
|
||||
{
|
||||
bProperty *p;
|
||||
for (p= first; p; p= p->next) {
|
||||
if (p!=self && (strcmp(p->name, name)==0))
|
||||
for (p = first; p; p = p->next) {
|
||||
if (p != self && (strcmp(p->name, name) == 0))
|
||||
return p;
|
||||
}
|
||||
return NULL;
|
||||
@ -142,10 +142,10 @@ void unique_property(bProperty *first, bProperty *prop, int force)
|
||||
bProperty *p;
|
||||
|
||||
/* set the first if its not set */
|
||||
if (first==NULL) {
|
||||
first= prop;
|
||||
if (first == NULL) {
|
||||
first = prop;
|
||||
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 base_name[sizeof(prop->name)];
|
||||
char num[sizeof(prop->name)];
|
||||
int i= 0;
|
||||
int i = 0;
|
||||
|
||||
/* strip numbers */
|
||||
BLI_strncpy(base_name, prop->name, sizeof(base_name));
|
||||
for (i= strlen(base_name)-1; (i>=0 && isdigit(base_name[i])); i--) {
|
||||
base_name[i]= '\0';
|
||||
for (i = strlen(base_name) - 1; (i >= 0 && isdigit(base_name[i])); i--) {
|
||||
base_name[i] = '\0';
|
||||
}
|
||||
i= 0;
|
||||
i = 0;
|
||||
|
||||
do { /* ensure we have enough chars for the new number in the name */
|
||||
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)
|
||||
{
|
||||
bProperty *prop;
|
||||
prop= get_ob_property(ob, propc->name);
|
||||
prop = get_ob_property(ob, propc->name);
|
||||
if (prop) {
|
||||
free_property(prop);
|
||||
BLI_remlink(&ob->prop, prop);
|
||||
@ -208,12 +208,12 @@ int compare_property(bProperty *prop, const char *str)
|
||||
|
||||
switch (prop->type) {
|
||||
case GPROP_BOOL:
|
||||
if (BLI_strcasecmp(str, "true")==0) {
|
||||
if (prop->data==1) return 0;
|
||||
if (BLI_strcasecmp(str, "true") == 0) {
|
||||
if (prop->data == 1) return 0;
|
||||
else return 1;
|
||||
}
|
||||
else if (BLI_strcasecmp(str, "false")==0) {
|
||||
if (prop->data==0) return 0;
|
||||
else if (BLI_strcasecmp(str, "false") == 0) {
|
||||
if (prop->data == 0) return 0;
|
||||
else return 1;
|
||||
}
|
||||
/* no break, do GPROP_int too! */
|
||||
@ -225,10 +225,10 @@ int compare_property(bProperty *prop, const char *str)
|
||||
case GPROP_TIME:
|
||||
// WARNING: untested for GPROP_TIME
|
||||
// function isn't used currently
|
||||
fvalue= *((float *)&prop->data);
|
||||
ftest= (float)atof(str);
|
||||
if ( fvalue > ftest) return 1;
|
||||
else if ( fvalue < ftest) return -1;
|
||||
fvalue = *((float *)&prop->data);
|
||||
ftest = (float)atof(str);
|
||||
if (fvalue > ftest) return 1;
|
||||
else if (fvalue < ftest) return -1;
|
||||
return 0;
|
||||
|
||||
case GPROP_STRING:
|
||||
@ -244,16 +244,16 @@ void set_property(bProperty *prop, const char *str)
|
||||
|
||||
switch (prop->type) {
|
||||
case GPROP_BOOL:
|
||||
if (BLI_strcasecmp(str, "true")==0) prop->data= 1;
|
||||
else if (BLI_strcasecmp(str, "false")==0) prop->data= 0;
|
||||
else prop->data= (atoi(str)!=0);
|
||||
if (BLI_strcasecmp(str, "true") == 0) prop->data = 1;
|
||||
else if (BLI_strcasecmp(str, "false") == 0) prop->data = 0;
|
||||
else prop->data = (atoi(str) != 0);
|
||||
break;
|
||||
case GPROP_INT:
|
||||
prop->data= atoi(str);
|
||||
prop->data = atoi(str);
|
||||
break;
|
||||
case GPROP_FLOAT:
|
||||
case GPROP_TIME:
|
||||
*((float *)&prop->data)= (float)atof(str);
|
||||
*((float *)&prop->data) = (float)atof(str);
|
||||
break;
|
||||
case GPROP_STRING:
|
||||
strcpy(prop->poin, str); /* TODO - check size? */
|
||||
@ -269,11 +269,11 @@ void add_property(bProperty *prop, const char *str)
|
||||
switch (prop->type) {
|
||||
case GPROP_BOOL:
|
||||
case GPROP_INT:
|
||||
prop->data+= atoi(str);
|
||||
prop->data += atoi(str);
|
||||
break;
|
||||
case GPROP_FLOAT:
|
||||
case GPROP_TIME:
|
||||
*((float *)&prop->data)+= (float)atof(str);
|
||||
*((float *)&prop->data) += (float)atof(str);
|
||||
break;
|
||||
case GPROP_STRING:
|
||||
/* strcpy(prop->poin, str); */
|
||||
|
@ -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) {
|
||||
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);
|
||||
MEM_freeN(vd);
|
||||
}
|
||||
|
||||
struct VoxelData *BKE_add_voxeldata(void)
|
||||
VoxelData *BKE_add_voxeldata(void)
|
||||
{
|
||||
VoxelData *vd;
|
||||
|
||||
vd = MEM_callocN(sizeof(struct VoxelData), "voxeldata");
|
||||
vd = MEM_callocN(sizeof(VoxelData), "voxeldata");
|
||||
vd->dataset = NULL;
|
||||
vd->resol[0] = vd->resol[1] = vd->resol[2] = 1;
|
||||
vd->interp_type = TEX_VD_LINEAR;
|
||||
@ -1525,7 +1525,7 @@ struct VoxelData *BKE_add_voxeldata(void)
|
||||
return vd;
|
||||
}
|
||||
|
||||
struct VoxelData *BKE_copy_voxeldata(struct VoxelData *vd)
|
||||
VoxelData *BKE_copy_voxeldata(VoxelData *vd)
|
||||
{
|
||||
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;
|
||||
|
||||
@ -1548,7 +1548,7 @@ struct OceanTex *BKE_add_oceantex(void)
|
||||
return ot;
|
||||
}
|
||||
|
||||
struct OceanTex *BKE_copy_oceantex(struct OceanTex *ot)
|
||||
OceanTex *BKE_copy_oceantex(struct OceanTex *ot)
|
||||
{
|
||||
OceanTex *otn = MEM_dupallocN(ot);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user