From 27b4b45543c0f7690a1978a60591a0b5c0f1adbb Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 18 Aug 2012 16:16:13 +0000 Subject: [PATCH 001/163] utility functions: BLI_findptr, BLI_rfindptr --- use for finding an item in a linked list by a pointer. --- source/blender/blenkernel/intern/anim.c | 6 +-- source/blender/blenkernel/intern/group.c | 22 +++++------ source/blender/blenkernel/intern/scene.c | 17 +++------ source/blender/blenlib/BLI_listbase.h | 2 + source/blender/blenlib/intern/listbase.c | 38 +++++++++++++++++++ source/blender/bmesh/intern/bmesh_marking.c | 27 +++++-------- .../blender/editors/gpencil/gpencil_paint.c | 9 +---- source/blender/editors/interface/resources.c | 4 +- source/blender/editors/object/object_edit.c | 12 +++--- .../blender/editors/object/object_modifier.c | 9 +---- source/blender/editors/object/object_select.c | 8 ++-- .../editors/sculpt_paint/sculpt_undo.c | 11 ++---- 12 files changed, 86 insertions(+), 79 deletions(-) diff --git a/source/blender/blenkernel/intern/anim.c b/source/blender/blenkernel/intern/anim.c index 111ac68b345..33cdede6fce 100644 --- a/source/blender/blenkernel/intern/anim.c +++ b/source/blender/blenkernel/intern/anim.c @@ -1279,9 +1279,9 @@ static void new_particle_duplilist(ListBase *lb, ID *id, Scene *scene, Object *p if (part->dup_group == NULL || part->dup_group->gobject.first == NULL) return; - for (go = part->dup_group->gobject.first; go; go = go->next) - if (go->ob == par) - return; + if (BLI_findptr(&part->dup_group->gobject, par, offsetof(GroupObject, ob))) { + return; + } } /* if we have a hair particle system, use the path cache */ diff --git a/source/blender/blenkernel/intern/group.c b/source/blender/blenkernel/intern/group.c index 89341845615..500df1b7b75 100644 --- a/source/blender/blenkernel/intern/group.c +++ b/source/blender/blenkernel/intern/group.c @@ -161,11 +161,13 @@ static int add_to_group_internal(Group *group, Object *ob) { GroupObject *go; - if (group == NULL || ob == NULL) return 0; + if (group == NULL || ob == NULL) { + return FALSE; + } /* check if the object has been added already */ - for (go = group->gobject.first; go; go = go->next) { - if (go->ob == ob) return 0; + if (BLI_findptr(&group->gobject, ob, offsetof(GroupObject, ob))) { + return FALSE; } go = MEM_callocN(sizeof(GroupObject), "groupobject"); @@ -173,7 +175,7 @@ static int add_to_group_internal(Group *group, Object *ob) go->ob = ob; - return 1; + return TRUE; } int add_to_group(Group *group, Object *object, Scene *scene, Base *base) @@ -239,15 +241,11 @@ int rem_from_group(Group *group, Object *object, Scene *scene, Base *base) int object_in_group(Object *ob, Group *group) { - GroupObject *go; - - if (group == NULL || ob == NULL) return 0; - - for (go = group->gobject.first; go; go = go->next) { - if (go->ob == ob) - return 1; + if (group == NULL || ob == NULL) { + return FALSE; } - return 0; + + return (BLI_findptr(&group->gobject, ob, offsetof(GroupObject, ob)) != NULL); } Group *find_group(Object *ob, Group *group) diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c index 889792ad3f8..d476e90498c 100644 --- a/source/blender/blenkernel/intern/scene.c +++ b/source/blender/blenkernel/intern/scene.c @@ -550,14 +550,7 @@ Scene *BKE_scene_add(const char *name) Base *BKE_scene_base_find(Scene *scene, Object *ob) { - Base *base; - - base = scene->base.first; - while (base) { - if (base->object == ob) return base; - base = base->next; - } - return NULL; + return BLI_findptr(&scene->base, ob, offsetof(Base, object)); } void BKE_scene_set_background(Main *bmain, Scene *scene) @@ -582,10 +575,10 @@ void BKE_scene_set_background(Main *bmain, Scene *scene) /* group flags again */ for (group = bmain->group.first; group; group = group->id.next) { - go = group->gobject.first; - while (go) { - if (go->ob) go->ob->flag |= OB_FROMGROUP; - go = go->next; + for (go = group->gobject.first; go; go = go->next) { + if (go->ob) { + go->ob->flag |= OB_FROMGROUP; + } } } diff --git a/source/blender/blenlib/BLI_listbase.h b/source/blender/blenlib/BLI_listbase.h index abe7eacb1ac..1330a74bea3 100644 --- a/source/blender/blenlib/BLI_listbase.h +++ b/source/blender/blenlib/BLI_listbase.h @@ -48,11 +48,13 @@ int BLI_findstringindex(const struct ListBase *listbase, const char *id, const i void *BLI_findlink(const struct ListBase *listbase, int number); void *BLI_findstring(const struct ListBase *listbase, const char *id, const int offset); void *BLI_findstring_ptr(const struct ListBase *listbase, const char *id, const int offset); +void *BLI_findptr(const struct ListBase *listbase, const void *ptr, const int offset); /* find backwards */ void *BLI_rfindlink(const struct ListBase *listbase, int number); void *BLI_rfindstring(const struct ListBase *listbase, const char *id, const int offset); void *BLI_rfindstring_ptr(const struct ListBase *listbase, const char *id, const int offset); +void *BLI_rfindptr(const struct ListBase *listbase, const void *ptr, const int offset); void BLI_freelistN(struct ListBase *listbase); void BLI_addtail(struct ListBase *listbase, void *vlink); diff --git a/source/blender/blenlib/intern/listbase.c b/source/blender/blenlib/intern/listbase.c index 8fe9a94b466..ad718ed8e11 100644 --- a/source/blender/blenlib/intern/listbase.c +++ b/source/blender/blenlib/intern/listbase.c @@ -439,6 +439,44 @@ void *BLI_rfindstring_ptr(const ListBase *listbase, const char *id, const int of return NULL; } +void *BLI_findptr(const ListBase *listbase, const void *ptr, const int offset) +{ + Link *link = NULL; + const void *ptr_iter; + + if (listbase == NULL) return NULL; + + for (link = listbase->first; link; link = link->next) { + /* exact copy of BLI_findstring(), except for this line */ + ptr_iter = *((const char **)(((const char *)link) + offset)); + + if (ptr == ptr_iter) { + return link; + } + } + + return NULL; +} +/* same as above but find reverse */ +void *BLI_rfindptr(const ListBase *listbase, const void *ptr, const int offset) +{ + Link *link = NULL; + const void *ptr_iter; + + if (listbase == NULL) return NULL; + + for (link = listbase->last; link; link = link->prev) { + /* exact copy of BLI_rfindstring(), except for this line */ + ptr_iter = *((const char **)(((const char *)link) + offset)); + + if (ptr == ptr_iter) { + return link; + } + } + + return NULL; +} + int BLI_findstringindex(const ListBase *listbase, const char *id, const int offset) { Link *link = NULL; diff --git a/source/blender/bmesh/intern/bmesh_marking.c b/source/blender/bmesh/intern/bmesh_marking.c index 8e9a19b54fb..58ccfa79a02 100644 --- a/source/blender/bmesh/intern/bmesh_marking.c +++ b/source/blender/bmesh/intern/bmesh_marking.c @@ -31,6 +31,8 @@ * that should be addressed eventually. */ +#include + #include "MEM_guardedalloc.h" #include "DNA_scene_types.h" @@ -708,28 +710,19 @@ void BM_editselection_plane(BMEditSelection *ese, float r_plane[3]) /* --- macro wrapped funcs --- */ int _bm_select_history_check(BMesh *bm, const BMHeader *ele) { - BMEditSelection *ese; - - for (ese = bm->selected.first; ese; ese = ese->next) { - if (ese->ele == (BMElem *)ele) { - return TRUE; - } - } - - return FALSE; + return (BLI_findptr(&bm->selected, ele, offsetof(BMEditSelection, ele)) != NULL); } int _bm_select_history_remove(BMesh *bm, BMHeader *ele) { - BMEditSelection *ese; - for (ese = bm->selected.first; ese; ese = ese->next) { - if (ese->ele == (BMElem *)ele) { - BLI_freelinkN(&(bm->selected), ese); - return TRUE; - } + BMEditSelection *ese = BLI_findptr(&bm->selected, ele, offsetof(BMEditSelection, ele)); + if (ese) { + BLI_freelinkN(&bm->selected, ese); + return TRUE; + } + else { + return FALSE; } - - return FALSE; } void _bm_select_history_store_notest(BMesh *bm, BMHeader *ele) diff --git a/source/blender/editors/gpencil/gpencil_paint.c b/source/blender/editors/gpencil/gpencil_paint.c index fd98dd83a7d..d98f4891dc5 100644 --- a/source/blender/editors/gpencil/gpencil_paint.c +++ b/source/blender/editors/gpencil/gpencil_paint.c @@ -1667,14 +1667,7 @@ static int gpencil_draw_invoke(bContext *C, wmOperator *op, wmEvent *event) static int gpencil_area_exists(bContext *C, ScrArea *sa_test) { bScreen *sc = CTX_wm_screen(C); - ScrArea *sa; - - for (sa = sc->areabase.first; sa; sa = sa->next) { - if (sa == sa_test) - return 1; - } - - return 0; + return (BLI_findindex(&sc->areabase, sa_test) != -1); } static tGPsdata *gpencil_stroke_begin(bContext *C, wmOperator *op) diff --git a/source/blender/editors/interface/resources.c b/source/blender/editors/interface/resources.c index 0ff81f27f6b..20e4360b791 100644 --- a/source/blender/editors/interface/resources.c +++ b/source/blender/editors/interface/resources.c @@ -643,9 +643,7 @@ void ui_theme_init_default(void) bTheme *btheme; /* we search for the theme with name Default */ - for (btheme = U.themes.first; btheme; btheme = btheme->next) { - if (strcmp("Default", btheme->name) == 0) break; - } + btheme = BLI_findstring(&U.themes, "Default", offsetof(bTheme, name)); if (btheme == NULL) { btheme = MEM_callocN(sizeof(bTheme), "theme"); diff --git a/source/blender/editors/object/object_edit.c b/source/blender/editors/object/object_edit.c index b5e85c3712b..aa885320b37 100644 --- a/source/blender/editors/object/object_edit.c +++ b/source/blender/editors/object/object_edit.c @@ -1720,13 +1720,15 @@ static int game_property_copy_exec(bContext *C, wmOperator *op) CTX_DATA_BEGIN(C, Object *, ob_iter, selected_editable_objects) { if (ob != ob_iter) { - if (type == COPY_PROPERTIES_REPLACE) + if (type == COPY_PROPERTIES_REPLACE) { copy_properties(&ob_iter->prop, &ob->prop); - - /* merge - the default when calling with no argument */ - else - for (prop = ob->prop.first; prop; prop = prop->next) + } + else { + /* merge - the default when calling with no argument */ + for (prop = ob->prop.first; prop; prop = prop->next) { set_ob_property(ob_iter, prop); + } + } } } CTX_DATA_END; diff --git a/source/blender/editors/object/object_modifier.c b/source/blender/editors/object/object_modifier.c index 47f5a285374..d3b099887cc 100644 --- a/source/blender/editors/object/object_modifier.c +++ b/source/blender/editors/object/object_modifier.c @@ -268,17 +268,12 @@ static int object_modifier_safe_to_delete(Main *bmain, Object *ob, static int object_modifier_remove(Main *bmain, Object *ob, ModifierData *md, int *sort_depsgraph) { - ModifierData *obmd; - /* It seems on rapid delete it is possible to * get called twice on same modifier, so make * sure it is in list. */ - for (obmd = ob->modifiers.first; obmd; obmd = obmd->next) - if (obmd == md) - break; - - if (!obmd) + if (BLI_findindex(&ob->modifiers, md) != -1) { return 0; + } /* special cases */ if (md->type == eModifierType_ParticleSystem) { diff --git a/source/blender/editors/object/object_select.c b/source/blender/editors/object/object_select.c index ff7728d4f68..7eb8cc01db9 100644 --- a/source/blender/editors/object/object_select.c +++ b/source/blender/editors/object/object_select.c @@ -988,13 +988,11 @@ static int object_select_same_group_exec(bContext *C, wmOperator *op) RNA_string_get(op->ptr, "group", group_name); - for (group = CTX_data_main(C)->group.first; group; group = group->id.next) { - if (!strcmp(group->id.name, group_name)) - break; - } + group = (Group *)BKE_libblock_find_name(ID_GR, group_name); - if (!group) + if (!group) { return OPERATOR_PASS_THROUGH; + } CTX_DATA_BEGIN (C, Base *, base, visible_bases) { diff --git a/source/blender/editors/sculpt_paint/sculpt_undo.c b/source/blender/editors/sculpt_paint/sculpt_undo.c index f327f67be33..c62dc687c73 100644 --- a/source/blender/editors/sculpt_paint/sculpt_undo.c +++ b/source/blender/editors/sculpt_paint/sculpt_undo.c @@ -32,6 +32,7 @@ * \ingroup edsculpt */ +#include #include "MEM_guardedalloc.h" @@ -379,16 +380,12 @@ static void sculpt_undo_free(ListBase *lb) SculptUndoNode *sculpt_undo_get_node(PBVHNode *node) { ListBase *lb = undo_paint_push_get_list(UNDO_PAINT_MESH); - SculptUndoNode *unode; - if (!lb) + if (!lb) { return NULL; + } - for (unode = lb->first; unode; unode = unode->next) - if (unode->node == node) - return unode; - - return NULL; + return BLI_findptr(lb, node, offsetof(SculptUndoNode, node)); } static void sculpt_undo_alloc_and_store_hidden(PBVH *pbvh, From 63f143a3ccf1a411951730f85efbdd84d2076a12 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 18 Aug 2012 16:53:46 +0000 Subject: [PATCH 002/163] use rctf struct for UI buttons and blocks, easier to read and means we can use BLI_rctf functions. --- source/blender/editors/interface/interface.c | 170 ++++++++------- .../editors/interface/interface_handlers.c | 170 +++++++-------- .../editors/interface/interface_intern.h | 6 +- .../editors/interface/interface_layout.c | 24 +-- .../blender/editors/interface/interface_ops.c | 8 +- .../editors/interface/interface_panel.c | 34 +-- .../editors/interface/interface_regions.c | 199 +++++++++--------- .../editors/space_image/image_buttons.c | 2 +- .../editors/space_logic/logic_buttons.c | 8 +- .../editors/space_node/node_templates.c | 2 +- 10 files changed, 308 insertions(+), 315 deletions(-) diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c index 7b1150669e8..55d78ae1307 100644 --- a/source/blender/editors/interface/interface.c +++ b/source/blender/editors/interface/interface.c @@ -196,19 +196,13 @@ void ui_window_to_region(const ARegion *ar, int *x, int *y) void ui_block_translate(uiBlock *block, int x, int y) { - uiBut *bt; + uiBut *but; - for (bt = block->buttons.first; bt; bt = bt->next) { - bt->x1 += x; - bt->y1 += y; - bt->x2 += x; - bt->y2 += y; + for (but = block->buttons.first; but; but = but->next) { + BLI_rctf_translate(&but->rect, x, y); } - block->minx += x; - block->miny += y; - block->maxx += x; - block->maxy += y; + BLI_rctf_translate(&block->rect, x, y); } static void ui_text_bounds_block(uiBlock *block, float offset) @@ -227,24 +221,24 @@ static void ui_text_bounds_block(uiBlock *block, float offset) if (j > i) i = j; } - if (bt->next && bt->x1 < bt->next->x1) + if (bt->next && bt->rect.xmin < bt->next->rect.xmin) lastcol++; } /* cope with multi collumns */ bt = block->buttons.first; while (bt) { - if (bt->next && bt->x1 < bt->next->x1) { + if (bt->next && bt->rect.xmin < bt->next->rect.xmin) { nextcol = 1; col++; } else nextcol = 0; - bt->x1 = x1addval; - bt->x2 = bt->x1 + i + block->bounds; + bt->rect.xmin = x1addval; + bt->rect.xmax = bt->rect.xmin + i + block->bounds; if (col == lastcol) - bt->x2 = MAX2(bt->x2, offset + block->minbounds); + bt->rect.xmax = MAX2(bt->rect.xmax, offset + block->minbounds); ui_check_but(bt); // clips text again @@ -262,43 +256,43 @@ void ui_bounds_block(uiBlock *block) if (block->buttons.first == NULL) { if (block->panel) { - block->minx = 0.0; block->maxx = block->panel->sizex; - block->miny = 0.0; block->maxy = block->panel->sizey; + block->rect.xmin = 0.0; block->rect.xmax = block->panel->sizex; + block->rect.ymin = 0.0; block->rect.ymax = block->panel->sizey; } } else { - block->minx = block->miny = 10000; - block->maxx = block->maxy = -10000; - + block->rect.xmin = block->rect.ymin = 10000; + block->rect.xmax = block->rect.ymax = -10000; + bt = block->buttons.first; while (bt) { - if (bt->x1 < block->minx) block->minx = bt->x1; - if (bt->y1 < block->miny) block->miny = bt->y1; + if (bt->rect.xmin < block->rect.xmin) block->rect.xmin = bt->rect.xmin; + if (bt->rect.ymin < block->rect.ymin) block->rect.ymin = bt->rect.ymin; - if (bt->x2 > block->maxx) block->maxx = bt->x2; - if (bt->y2 > block->maxy) block->maxy = bt->y2; + if (bt->rect.xmax > block->rect.xmax) block->rect.xmax = bt->rect.xmax; + if (bt->rect.ymax > block->rect.ymax) block->rect.ymax = bt->rect.ymax; bt = bt->next; } - block->minx -= block->bounds; - block->miny -= block->bounds; - block->maxx += block->bounds; - block->maxy += block->bounds; + block->rect.xmin -= block->bounds; + block->rect.ymin -= block->bounds; + block->rect.xmax += block->bounds; + block->rect.ymax += block->bounds; } - block->maxx = block->minx + MAX2(block->maxx - block->minx, block->minbounds); + block->rect.xmax = block->rect.xmin + MAX2(block->rect.xmax - block->rect.xmin, block->minbounds); /* hardcoded exception... but that one is annoying with larger safety */ bt = block->buttons.first; if (bt && strncmp(bt->str, "ERROR", 5) == 0) xof = 10; else xof = 40; - block->safety.xmin = block->minx - xof; - block->safety.ymin = block->miny - xof; - block->safety.xmax = block->maxx + xof; - block->safety.ymax = block->maxy + xof; + block->safety.xmin = block->rect.xmin - xof; + block->safety.ymin = block->rect.ymin - xof; + block->safety.xmax = block->rect.xmax + xof; + block->safety.ymax = block->rect.ymax + xof; } static void ui_centered_bounds_block(const bContext *C, uiBlock *block) @@ -316,13 +310,13 @@ static void ui_centered_bounds_block(const bContext *C, uiBlock *block) ui_bounds_block(block); - width = block->maxx - block->minx; - height = block->maxy - block->miny; + width = block->rect.xmax - block->rect.xmin; + height = block->rect.ymax - block->rect.ymin; startx = (xmax * 0.5f) - (width * 0.5f); starty = (ymax * 0.5f) - (height * 0.5f); - ui_block_translate(block, startx - block->minx, starty - block->miny); + ui_block_translate(block, startx - block->rect.xmin, starty - block->rect.ymin); /* now recompute bounds and safety */ ui_bounds_block(block); @@ -341,14 +335,14 @@ static void ui_popup_bounds_block(const bContext *C, uiBlock *block, int bounds_ wm_window_get_size(window, &xmax, &ymax); - oldwidth = block->maxx - block->minx; - oldheight = block->maxy - block->miny; + oldwidth = block->rect.xmax - block->rect.xmin; + oldheight = block->rect.ymax - block->rect.ymin; /* first we ensure wide enough text bounds */ if (bounds_calc == UI_BLOCK_BOUNDS_POPUP_MENU) { if (block->flag & UI_BLOCK_LOOP) { block->bounds = 50; - ui_text_bounds_block(block, block->minx); + ui_text_bounds_block(block, block->rect.xmin); } } @@ -357,8 +351,8 @@ static void ui_popup_bounds_block(const bContext *C, uiBlock *block, int bounds_ ui_bounds_block(block); /* and we adjust the position to fit within window */ - width = block->maxx - block->minx; - height = block->maxy - block->miny; + width = block->rect.xmax - block->rect.xmin; + height = block->rect.ymax - block->rect.ymin; /* avoid divide by zero below, caused by calling with no UI, but better not crash */ oldwidth = oldwidth > 0 ? oldwidth : MAX2(1, width); @@ -366,8 +360,8 @@ static void ui_popup_bounds_block(const bContext *C, uiBlock *block, int bounds_ /* offset block based on mouse position, user offset is scaled * along in case we resized the block in ui_text_bounds_block */ - startx = window->eventstate->x + block->minx + (block->mx * width) / oldwidth; - starty = window->eventstate->y + block->miny + (block->my * height) / oldheight; + startx = window->eventstate->x + block->rect.xmin + (block->mx * width) / oldwidth; + starty = window->eventstate->y + block->rect.ymin + (block->my * height) / oldheight; if (startx < 10) startx = 10; @@ -386,7 +380,7 @@ static void ui_popup_bounds_block(const bContext *C, uiBlock *block, int bounds_ starty = endy - height; } - ui_block_translate(block, startx - block->minx, starty - block->miny); + ui_block_translate(block, startx - block->rect.xmin, starty - block->rect.ymin); /* now recompute bounds and safety */ ui_bounds_block(block); @@ -436,10 +430,10 @@ void uiCenteredBoundsBlock(uiBlock *block, int addval) void uiExplicitBoundsBlock(uiBlock *block, int minx, int miny, int maxx, int maxy) { - block->minx = minx; - block->miny = miny; - block->maxx = maxx; - block->maxy = maxy; + block->rect.xmin = minx; + block->rect.ymin = miny; + block->rect.xmax = maxx; + block->rect.ymax = maxy; block->dobounds = 0; } @@ -504,10 +498,10 @@ static void ui_draw_linkline(uiLinkLine *line, int highlightActiveLines) if (line->from == NULL || line->to == NULL) return; - rect.xmin = (line->from->x1 + line->from->x2) / 2.0f; - rect.ymin = (line->from->y1 + line->from->y2) / 2.0f; - rect.xmax = (line->to->x1 + line->to->x2) / 2.0f; - rect.ymax = (line->to->y1 + line->to->y2) / 2.0f; + rect.xmin = (line->from->rect.xmin + line->from->rect.xmax) / 2.0f; + rect.ymin = (line->from->rect.ymin + line->from->rect.ymax) / 2.0f; + rect.xmax = (line->to->rect.xmin + line->to->rect.xmax) / 2.0f; + rect.ymax = (line->to->rect.ymin + line->to->rect.ymax) / 2.0f; if (line->flag & UI_SELECT) glColor3ub(100, 100, 100); @@ -653,8 +647,8 @@ static int ui_but_update_from_old_block(const bContext *C, uiBlock *block, uiBut *butpp = oldbut; /* still stuff needs to be copied */ - oldbut->x1 = but->x1; oldbut->y1 = but->y1; - oldbut->x2 = but->x2; oldbut->y2 = but->y2; + oldbut->rect.xmin = but->rect.xmin; oldbut->rect.ymin = but->rect.ymin; + oldbut->rect.xmax = but->rect.xmax; oldbut->rect.ymax = but->rect.ymax; oldbut->context = but->context; /* set by Layout */ /* typically the same pointers, but not on undo/redo */ @@ -764,7 +758,7 @@ static void ui_menu_block_set_keyaccels(uiBlock *block) int tot_missing = 0; /* only do it before bounding */ - if (block->minx != block->maxx) + if (block->rect.xmin != block->rect.xmax) return; for (pass = 0; pass < 2; pass++) { @@ -865,7 +859,7 @@ static void ui_menu_block_set_keymaps(const bContext *C, uiBlock *block) IDProperty *prop_menu_name = NULL; /* only do it before bounding */ - if (block->minx != block->maxx) + if (block->rect.xmin != block->rect.xmax) return; for (but = block->buttons.first; but; but = but->next) { @@ -960,7 +954,7 @@ void uiEndBlock(const bContext *C, uiBlock *block) else if (block->dobounds == UI_BLOCK_BOUNDS_POPUP_CENTER) ui_centered_bounds_block(C, block); else if (block->dobounds) ui_popup_bounds_block(C, block, block->dobounds); - if (block->minx == 0.0f && block->maxx == 0.0f) uiBoundsBlock(block, 0); + if (block->rect.xmin == 0.0f && block->rect.xmax == 0.0f) uiBoundsBlock(block, 0); if (block->flag & UI_BUT_ALIGN) uiBlockEndAlign(block); block->endblock = 1; @@ -993,14 +987,14 @@ static void ui_but_to_pixelrect(rcti *rect, const ARegion *ar, uiBlock *block, u getsizex = ar->winx; getsizey = ar->winy; - gx = (but ? but->x1 : block->minx) + (block->panel ? block->panel->ofsx : 0.0f); - gy = (but ? but->y1 : block->miny) + (block->panel ? block->panel->ofsy : 0.0f); + gx = (but ? but->rect.xmin : block->rect.xmin) + (block->panel ? block->panel->ofsx : 0.0f); + gy = (but ? but->rect.ymin : block->rect.ymin) + (block->panel ? block->panel->ofsy : 0.0f); rect->xmin = floorf(getsizex * (0.5f + 0.5f * (gx * block->winmat[0][0] + gy * block->winmat[1][0] + block->winmat[3][0]))); rect->ymin = floorf(getsizey * (0.5f + 0.5f * (gx * block->winmat[0][1] + gy * block->winmat[1][1] + block->winmat[3][1]))); - gx = (but ? but->x2 : block->maxx) + (block->panel ? block->panel->ofsx : 0.0f); - gy = (but ? but->y2 : block->maxy) + (block->panel ? block->panel->ofsy : 0.0f); + gx = (but ? but->rect.xmax : block->rect.xmax) + (block->panel ? block->panel->ofsx : 0.0f); + gy = (but ? but->rect.ymax : block->rect.ymax) + (block->panel ? block->panel->ofsy : 0.0f); rect->xmax = floorf(getsizex * (0.5f + 0.5f * (gx * block->winmat[0][0] + gy * block->winmat[1][0] + block->winmat[3][0]))); rect->ymax = floorf(getsizey * (0.5f + 0.5f * (gx * block->winmat[0][1] + gy * block->winmat[1][1] + block->winmat[3][1]))); @@ -2221,7 +2215,7 @@ void ui_check_but(uiBut *but) /* safety is 4 to enable small number buttons (like 'users') */ - // okwidth= -4 + (but->x2 - but->x1); // UNUSED + // okwidth= -4 + (but->rect.xmax - but->rect.xmin); // UNUSED /* name: */ switch (but->type) { @@ -2229,7 +2223,7 @@ void ui_check_but(uiBut *but) case MENU: case ICONTEXTROW: - if (but->x2 - but->x1 > 24) { + if (but->rect.xmax - but->rect.xmin > 24) { UI_GET_BUT_VALUE_INIT(but, value); ui_set_name_menu(but, (int)value); } @@ -2373,8 +2367,8 @@ static int buts_are_horiz(uiBut *but1, uiBut *but2) { float dx, dy; - dx = fabs(but1->x2 - but2->x1); - dy = fabs(but1->y1 - but2->y2); + dx = fabs(but1->rect.xmax - but2->rect.xmin); + dy = fabs(but1->rect.ymin - but2->rect.ymax); if (dx > dy) return 0; return 1; @@ -2492,32 +2486,32 @@ static void ui_block_do_align_but(uiBut *first, short nr) if (prev) { /* simple cases */ if (rows == 0) { - but->x1 = (prev->x2 + but->x1) / 2.0f; - prev->x2 = but->x1; + but->rect.xmin = (prev->rect.xmax + but->rect.xmin) / 2.0f; + prev->rect.xmax = but->rect.xmin; } else if (cols == 0) { - but->y2 = (prev->y1 + but->y2) / 2.0f; - prev->y1 = but->y2; + but->rect.ymax = (prev->rect.ymin + but->rect.ymax) / 2.0f; + prev->rect.ymin = but->rect.ymax; } else { if (buts_are_horiz(prev, but)) { - but->x1 = (prev->x2 + but->x1) / 2.0f; - prev->x2 = but->x1; + but->rect.xmin = (prev->rect.xmax + but->rect.xmin) / 2.0f; + prev->rect.xmax = but->rect.xmin; /* copy height too */ - but->y2 = prev->y2; + but->rect.ymax = prev->rect.ymax; } else if (prev->prev && buts_are_horiz(prev->prev, prev) == 0) { /* the previous button is a single one in its row */ - but->y2 = (prev->y1 + but->y2) / 2.0f; - prev->y1 = but->y2; + but->rect.ymax = (prev->rect.ymin + but->rect.ymax) / 2.0f; + prev->rect.ymin = but->rect.ymax; - but->x1 = prev->x1; + but->rect.xmin = prev->rect.xmin; if (next && buts_are_horiz(but, next) == 0) - but->x2 = prev->x2; + but->rect.xmax = prev->rect.xmax; } else { /* the previous button is not a single one in its row */ - but->y2 = prev->y1; + but->rect.ymax = prev->rect.ymin; } } } @@ -2586,10 +2580,10 @@ static uiBut *ui_def_but(uiBlock *block, int type, int retval, const char *str, } memcpy(but->str, str, slen + 1); - but->x1 = x1; - but->y1 = y1; - but->x2 = (x1 + x2); - but->y2 = (y1 + y2); + but->rect.xmin = x1; + but->rect.ymin = y1; + but->rect.xmax = (x1 + x2); + but->rect.ymax = (y1 + y2); but->poin = poin; but->hardmin = but->softmin = min; @@ -3296,8 +3290,8 @@ int uiBlocksGetYMin(ListBase *lb) int min = 0; for (block = lb->first; block; block = block->next) - if (block == lb->first || block->miny < min) - min = block->miny; + if (block == lb->first || block->rect.ymin < min) + min = block->rect.ymin; return min; } @@ -3321,15 +3315,15 @@ void uiBlockFlipOrder(uiBlock *block) for (but = block->buttons.first; but; but = but->next) { if (but->flag & UI_BUT_ALIGN) return; - if (but->y1 < miny) miny = but->y1; - if (but->y2 > maxy) maxy = but->y2; + if (but->rect.ymin < miny) miny = but->rect.ymin; + if (but->rect.ymax > maxy) maxy = but->rect.ymax; } /* mirror trick */ centy = (miny + maxy) / 2.0f; for (but = block->buttons.first; but; but = but->next) { - but->y1 = centy - (but->y1 - centy); - but->y2 = centy - (but->y2 - centy); - SWAP(float, but->y1, but->y2); + but->rect.ymin = centy - (but->rect.ymin - centy); + but->rect.ymax = centy - (but->rect.ymax - centy); + SWAP(float, but->rect.ymin, but->rect.ymax); } /* also flip order in block itself, for example for arrowkey */ diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c index 90f8bb52826..ec41c821c04 100644 --- a/source/blender/editors/interface/interface_handlers.c +++ b/source/blender/editors/interface/interface_handlers.c @@ -686,8 +686,8 @@ static int ui_but_mouse_inside_icon(uiBut *but, ARegion *ar, wmEvent *event) ui_window_to_block(ar, but->block, &x, &y); - rect.xmin = but->x1; rect.xmax = but->x2; - rect.ymin = but->y1; rect.ymax = but->y2; + rect.xmin = but->rect.xmin; rect.xmax = but->rect.xmax; + rect.ymin = but->rect.ymin; rect.ymax = but->rect.ymax; if (but->imb) ; /* use button size itself */ else if (but->flag & UI_ICON_LEFT) { @@ -715,7 +715,7 @@ static int ui_but_start_drag(bContext *C, uiBut *but, uiHandleButtonData *data, drag = WM_event_start_drag(C, but->icon, but->dragtype, but->dragpoin, ui_get_but_val(but)); if (but->imb) - WM_event_drag_image(drag, but->imb, but->imb_scale, but->x2 - but->x1, but->y2 - but->y1); + WM_event_drag_image(drag, but->imb, but->imb_scale, but->rect.xmax - but->rect.xmin, but->rect.ymax - but->rect.ymin); return 1; } @@ -1282,7 +1282,7 @@ static void ui_textedit_set_cursor_pos(uiBut *but, uiHandleButtonData *data, sho { uiStyle *style = UI_GetStyle(); // XXX pass on as arg uiFontStyle *fstyle = &style->widget; - int startx = but->x1; + int startx = but->rect.xmin; char *origstr; uiStyleFontSet(fstyle); @@ -1296,7 +1296,7 @@ static void ui_textedit_set_cursor_pos(uiBut *but, uiHandleButtonData *data, sho /* XXX solve generic */ if (but->type == NUM || but->type == NUMSLI) - startx += (int)(0.5f * (but->y2 - but->y1)); + startx += (int)(0.5f * (but->rect.ymax - but->rect.ymin)); else if (ELEM(but->type, TEX, SEARCH_MENU)) { startx += 5; if (but->flag & UI_HAS_ICON) @@ -2537,11 +2537,11 @@ static int ui_do_but_NUM(bContext *C, uiBlock *block, uiBut *but, uiHandleButton if (data->state == BUTTON_STATE_HIGHLIGHT) { /* XXX hardcoded keymap check.... */ if (event->type == WHEELDOWNMOUSE && event->alt) { - mx = but->x1; + mx = but->rect.xmin; click = 1; } else if (event->type == WHEELUPMOUSE && event->alt) { - mx = but->x2; + mx = but->rect.xmax; click = 1; } else if (event->val == KM_PRESS) { @@ -2611,7 +2611,7 @@ static int ui_do_but_NUM(bContext *C, uiBlock *block, uiBut *but, uiHandleButton softmax = but->softmax; if (!ui_is_but_float(but)) { - if (mx < (but->x1 + (but->x2 - but->x1) / 3 - 3)) { + if (mx < (but->rect.xmin + (but->rect.xmax - but->rect.xmin) / 3 - 3)) { button_activate_state(C, but, BUTTON_STATE_NUM_EDITING); temp = (int)data->value - 1; @@ -2622,7 +2622,7 @@ static int ui_do_but_NUM(bContext *C, uiBlock *block, uiBut *but, uiHandleButton button_activate_state(C, but, BUTTON_STATE_EXIT); } - else if (mx > (but->x1 + (2 * (but->x2 - but->x1) / 3) + 3)) { + else if (mx > (but->rect.xmin + (2 * (but->rect.xmax - but->rect.xmin) / 3) + 3)) { button_activate_state(C, but, BUTTON_STATE_NUM_EDITING); temp = (int)data->value + 1; @@ -2637,7 +2637,7 @@ static int ui_do_but_NUM(bContext *C, uiBlock *block, uiBut *but, uiHandleButton button_activate_state(C, but, BUTTON_STATE_TEXT_EDITING); } else { - if (mx < (but->x1 + (but->x2 - but->x1) / 3 - 3)) { + if (mx < (but->rect.xmin + (but->rect.xmax - but->rect.xmin) / 3 - 3)) { button_activate_state(C, but, BUTTON_STATE_NUM_EDITING); tempf = (float)data->value - 0.01f * but->a1; @@ -2646,7 +2646,7 @@ static int ui_do_but_NUM(bContext *C, uiBlock *block, uiBut *but, uiHandleButton button_activate_state(C, but, BUTTON_STATE_EXIT); } - else if (mx > but->x1 + (2 * ((but->x2 - but->x1) / 3) + 3)) { + else if (mx > but->rect.xmin + (2 * ((but->rect.xmax - but->rect.xmin) / 3) + 3)) { button_activate_state(C, but, BUTTON_STATE_NUM_EDITING); tempf = (float)data->value + 0.01f * but->a1; @@ -2674,14 +2674,14 @@ static int ui_numedit_but_SLI(uiBut *but, uiHandleButtonData *data, const short softmax = but->softmax; softrange = softmax - softmin; - if (but->type == NUMSLI) deler = ((but->x2 - but->x1) - 5.0f * but->aspect); - else if (but->type == HSVSLI) deler = ((but->x2 - but->x1) / 2.0f - 5.0f * but->aspect); + if (but->type == NUMSLI) deler = ((but->rect.xmax - but->rect.xmin) - 5.0f * but->aspect); + else if (but->type == HSVSLI) deler = ((but->rect.xmax - but->rect.xmin) / 2.0f - 5.0f * but->aspect); else if (but->type == SCROLL) { - int horizontal = (but->x2 - but->x1 > but->y2 - but->y1); - float size = (horizontal) ? (but->x2 - but->x1) : -(but->y2 - but->y1); + int horizontal = (but->rect.xmax - but->rect.xmin > but->rect.ymax - but->rect.ymin); + float size = (horizontal) ? (but->rect.xmax - but->rect.xmin) : -(but->rect.ymax - but->rect.ymin); deler = size * (but->softmax - but->softmin) / (but->softmax - but->softmin + but->a1); } - else deler = (but->x2 - but->x1 - 5.0f * but->aspect); + else deler = (but->rect.xmax - but->rect.xmin - 5.0f * but->aspect); f = (float)(mx - data->dragstartx) / deler + data->dragfstart; @@ -2750,11 +2750,11 @@ static int ui_do_but_SLI(bContext *C, uiBlock *block, uiBut *but, uiHandleButton if (data->state == BUTTON_STATE_HIGHLIGHT) { /* XXX hardcoded keymap check.... */ if (event->type == WHEELDOWNMOUSE && event->alt) { - mx = but->x1; + mx = but->rect.xmin; click = 2; } else if (event->type == WHEELUPMOUSE && event->alt) { - mx = but->x2; + mx = but->rect.xmax; click = 2; } else if (event->val == KM_PRESS) { @@ -2764,12 +2764,12 @@ static int ui_do_but_SLI(bContext *C, uiBlock *block, uiBut *but, uiHandleButton } /* alt-click on sides to get "arrows" like in NUM buttons, and match wheel usage above */ else if (event->type == LEFTMOUSE && event->alt) { - int halfpos = (but->x1 + but->x2) / 2; + int halfpos = (but->rect.xmin + but->rect.xmax) / 2; click = 2; if (mx < halfpos) - mx = but->x1; + mx = but->rect.xmin; else - mx = but->x2; + mx = but->rect.xmax; } else if (event->type == LEFTMOUSE) { data->dragstartx = mx; @@ -2831,12 +2831,12 @@ static int ui_do_but_SLI(bContext *C, uiBlock *block, uiBut *but, uiHandleButton #if 0 if (but->type == SLI) { - f = (float)(mx - but->x1) / (but->x2 - but->x1); /* same as below */ + f = (float)(mx - but->rect.xmin) / (but->rect.xmax - but->rect.xmin); /* same as below */ } else #endif { - f = (float)(mx - but->x1) / (but->x2 - but->x1); + f = (float)(mx - but->rect.xmin) / (but->rect.xmax - but->rect.xmin); } f = softmin + f * softrange; @@ -2877,7 +2877,7 @@ static int ui_do_but_SCROLL(bContext *C, uiBlock *block, uiBut *but, uiHandleBut { int mx, my /*, click= 0 */; int retval = WM_UI_HANDLER_CONTINUE; - int horizontal = (but->x2 - but->x1 > but->y2 - but->y1); + int horizontal = (but->rect.xmax - but->rect.xmin > but->rect.ymax - but->rect.ymin); mx = event->x; my = event->y; @@ -3034,7 +3034,7 @@ static int ui_numedit_but_NORMAL(uiBut *but, uiHandleButtonData *data, int mx, i * else we'll get a harmless but annoying jump when first clicking */ fp = data->origvec; - rad = (but->x2 - but->x1); + rad = (but->rect.xmax - but->rect.xmin); radsq = rad * rad; if (fp[2] > 0.0f) { @@ -3142,8 +3142,8 @@ static int ui_numedit_but_HSVCUBE(uiBut *but, uiHandleButtonData *data, int mx, /* relative position within box */ - x = ((float)mx_fl - but->x1) / (but->x2 - but->x1); - y = ((float)my_fl - but->y1) / (but->y2 - but->y1); + x = ((float)mx_fl - but->rect.xmin) / (but->rect.xmax - but->rect.xmin); + y = ((float)my_fl - but->rect.ymin) / (but->rect.ymax - but->rect.ymin); CLAMP(x, 0.0f, 1.0f); CLAMP(y, 0.0f, 1.0f); @@ -3348,8 +3348,8 @@ static int ui_numedit_but_HSVCIRCLE(uiBut *but, uiHandleButtonData *data, float ui_mouse_scale_warp(data, mx, my, &mx_fl, &my_fl, shift); - rect.xmin = but->x1; rect.xmax = but->x2; - rect.ymin = but->y1; rect.ymax = but->y2; + rect.xmin = but->rect.xmin; rect.xmax = but->rect.xmax; + rect.ymin = but->rect.ymin; rect.ymax = but->rect.ymax; ui_get_but_vectorf(but, rgb); copy_v3_v3(hsv, ui_block_hsv_get(but->block)); @@ -3541,7 +3541,7 @@ static int ui_numedit_but_COLORBAND(uiBut *but, uiHandleButtonData *data, int mx if (data->draglastx == mx) return changed; - dx = ((float)(mx - data->draglastx)) / (but->x2 - but->x1); + dx = ((float)(mx - data->draglastx)) / (but->rect.xmax - but->rect.xmin); data->dragcbd->pos += dx; CLAMP(data->dragcbd->pos, 0.0f, 1.0f); @@ -3570,7 +3570,7 @@ static int ui_do_but_COLORBAND(bContext *C, uiBlock *block, uiBut *but, uiHandle if (event->ctrl) { /* insert new key on mouse location */ - float pos = ((float)(mx - but->x1)) / (but->x2 - but->x1); + float pos = ((float)(mx - but->rect.xmin)) / (but->rect.xmax - but->rect.xmin); colorband_element_add(coba, pos); button_activate_state(C, but, BUTTON_STATE_EXIT); } @@ -3582,7 +3582,7 @@ static int ui_do_but_COLORBAND(bContext *C, uiBlock *block, uiBut *but, uiHandle /* activate new key when mouse is close */ for (a = 0, cbd = coba->data; a < coba->tot; a++, cbd++) { - xco = but->x1 + (cbd->pos * (but->x2 - but->x1)); + xco = but->rect.xmin + (cbd->pos * (but->rect.xmax - but->rect.xmin)); xco = ABS(xco - mx); if (a == coba->cur) xco += 5; // selected one disadvantage if (xco < mindist) { @@ -3623,8 +3623,8 @@ static int ui_numedit_but_CURVE(uiBut *but, uiHandleButtonData *data, int snap, float fx, fy, zoomx, zoomy /*, offsx, offsy */ /* UNUSED */; int a, changed = 0; - zoomx = (but->x2 - but->x1) / (cumap->curr.xmax - cumap->curr.xmin); - zoomy = (but->y2 - but->y1) / (cumap->curr.ymax - cumap->curr.ymin); + zoomx = (but->rect.xmax - but->rect.xmin) / (cumap->curr.xmax - cumap->curr.xmin); + zoomy = (but->rect.ymax - but->rect.ymin) / (cumap->curr.ymax - cumap->curr.ymin); /* offsx= cumap->curr.xmin; */ /* offsy= cumap->curr.ymin; */ @@ -3719,14 +3719,14 @@ static int ui_do_but_CURVE(bContext *C, uiBlock *block, uiBut *but, uiHandleButt float dist, mindist = 200.0f; // 14 pixels radius int sel = -1; - zoomx = (but->x2 - but->x1) / (cumap->curr.xmax - cumap->curr.xmin); - zoomy = (but->y2 - but->y1) / (cumap->curr.ymax - cumap->curr.ymin); + zoomx = (but->rect.xmax - but->rect.xmin) / (cumap->curr.xmax - cumap->curr.xmin); + zoomy = (but->rect.ymax - but->rect.ymin) / (cumap->curr.ymax - cumap->curr.ymin); offsx = cumap->curr.xmin; offsy = cumap->curr.ymin; if (event->ctrl) { - fx = ((float)mx - but->x1) / zoomx + offsx; - fy = ((float)my - but->y1) / zoomy + offsy; + fx = ((float)mx - but->rect.xmin) / zoomx + offsx; + fy = ((float)my - but->rect.ymin) / zoomy + offsy; curvemap_insert(cuma, fx, fy); curvemapping_changed(cumap, 0); @@ -3736,8 +3736,8 @@ static int ui_do_but_CURVE(bContext *C, uiBlock *block, uiBut *but, uiHandleButt /* check for selecting of a point */ cmp = cuma->curve; /* ctrl adds point, new malloc */ for (a = 0; a < cuma->totpoint; a++) { - fx = but->x1 + zoomx * (cmp[a].x - offsx); - fy = but->y1 + zoomy * (cmp[a].y - offsy); + fx = but->rect.xmin + zoomx * (cmp[a].x - offsx); + fy = but->rect.ymin + zoomy * (cmp[a].y - offsy); dist = (fx - mx) * (fx - mx) + (fy - my) * (fy - my); if (dist < mindist) { sel = a; @@ -3750,8 +3750,8 @@ static int ui_do_but_CURVE(bContext *C, uiBlock *block, uiBut *but, uiHandleButt /* if the click didn't select anything, check if it's clicked on the * curve itself, and if so, add a point */ - fx = ((float)mx - but->x1) / zoomx + offsx; - fy = ((float)my - but->y1) / zoomy + offsy; + fx = ((float)mx - but->rect.xmin) / zoomx + offsx; + fy = ((float)my - but->rect.ymin) / zoomy + offsy; cmp = cuma->table; @@ -3846,8 +3846,8 @@ static int ui_do_but_CURVE(bContext *C, uiBlock *block, uiBut *but, uiHandleButt static int in_scope_resize_zone(uiBut *but, int UNUSED(x), int y) { - /* bottom corner return (x > but->x2 - SCOPE_RESIZE_PAD) && (y < but->y1 + SCOPE_RESIZE_PAD); */ - return (y < but->y1 + SCOPE_RESIZE_PAD); + /* bottom corner return (x > but->rect.xmax - SCOPE_RESIZE_PAD) && (y < but->rect.ymin + SCOPE_RESIZE_PAD); */ + return (y < but->rect.ymin + SCOPE_RESIZE_PAD); } static int ui_numedit_but_HISTOGRAM(uiBut *but, uiHandleButtonData *data, int mx, int my) @@ -3857,15 +3857,15 @@ static int ui_numedit_but_HISTOGRAM(uiBut *but, uiHandleButtonData *data, int mx int changed = 1; float /* dx, */ dy; /* UNUSED */ - /* rect.xmin = but->x1; rect.xmax = but->x2; */ - /* rect.ymin = but->y1; rect.ymax = but->y2; */ + /* rect.xmin = but->rect.xmin; rect.xmax = but->rect.xmax; */ + /* rect.ymin = but->rect.ymin; rect.ymax = but->rect.ymax; */ /* dx = mx - data->draglastx; */ /* UNUSED */ dy = my - data->draglasty; if (in_scope_resize_zone(but, data->dragstartx, data->dragstarty)) { /* resize histogram widget itself */ - hist->height = (but->y2 - but->y1) + (data->dragstarty - my); + hist->height = (but->rect.ymax - but->rect.ymin) + (data->dragstarty - my); } else { /* scale histogram values (dy / 10 for better control) */ @@ -3941,8 +3941,8 @@ static int ui_numedit_but_WAVEFORM(uiBut *but, uiHandleButtonData *data, int mx, int changed = 1; float /* dx, */ dy /* , yfac=1.f */; /* UNUSED */ - /* rect.xmin = but->x1; rect.xmax = but->x2; */ - /* rect.ymin = but->y1; rect.ymax = but->y2; */ + /* rect.xmin = but->rect.xmin; rect.xmax = but->rect.xmax; */ + /* rect.ymin = but->rect.ymin; rect.ymax = but->rect.ymax; */ /* dx = mx - data->draglastx; */ /* UNUSED */ dy = my - data->draglasty; @@ -3950,7 +3950,7 @@ static int ui_numedit_but_WAVEFORM(uiBut *but, uiHandleButtonData *data, int mx, if (in_scope_resize_zone(but, data->dragstartx, data->dragstarty)) { /* resize waveform widget itself */ - scopes->wavefrm_height = (but->y2 - but->y1) + (data->dragstarty - my); + scopes->wavefrm_height = (but->rect.ymax - but->rect.ymin) + (data->dragstarty - my); } else { /* scale waveform values */ @@ -4025,15 +4025,15 @@ static int ui_numedit_but_VECTORSCOPE(uiBut *but, uiHandleButtonData *data, int int changed = 1; /* float dx, dy; */ - /* rect.xmin = but->x1; rect.xmax = but->x2; */ - /* rect.ymin = but->y1; rect.ymax = but->y2; */ + /* rect.xmin = but->rect.xmin; rect.xmax = but->rect.xmax; */ + /* rect.ymin = but->rect.ymin; rect.ymax = but->rect.ymax; */ /* dx = mx - data->draglastx; */ /* dy = my - data->draglasty; */ if (in_scope_resize_zone(but, data->dragstartx, data->dragstarty)) { /* resize vectorscope widget itself */ - scopes->vecscope_height = (but->y2 - but->y1) + (data->dragstarty - my); + scopes->vecscope_height = (but->rect.ymax - but->rect.ymin) + (data->dragstarty - my); } data->draglastx = mx; @@ -4103,17 +4103,17 @@ static int ui_do_but_CHARTAB(bContext *UNUSED(C), uiBlock *UNUSED(block), uiBut if (data->state == BUTTON_STATE_HIGHLIGHT) { if (ELEM3(event->type, LEFTMOUSE, PADENTER, RETKEY) && event->val == KM_PRESS) { /* Calculate the size of the button */ - width = abs(but->x2 - but->x1); - height = abs(but->y2 - but->y1); + width = abs(but->rect.xmax - but->rect.xmin); + height = abs(but->rect.ymax - but->rect.ymin); butw = floor(width / 12); buth = floor(height / 6); /* Initialize variables */ - sx = but->x1; - ex = but->x1 + butw; - sy = but->y1 + height - buth; - ey = but->y1 + height; + sx = but->rect.xmin; + ex = but->rect.xmin + butw; + sy = but->rect.ymin + height - buth; + ey = but->rect.ymin + height; cs = G.charstart; @@ -4236,7 +4236,7 @@ static int ui_numedit_but_TRACKPREVIEW(bContext *C, uiBut *but, uiHandleButtonDa if (in_scope_resize_zone(but, data->dragstartx, data->dragstarty)) { /* resize preview widget itself */ - scopes->track_preview_height = (but->y2 - but->y1) + (data->dragstarty - my); + scopes->track_preview_height = (but->rect.ymax - but->rect.ymin) + (data->dragstarty - my); } else { if (!scopes->track_locked) { @@ -4244,8 +4244,8 @@ static int ui_numedit_but_TRACKPREVIEW(bContext *C, uiBut *but, uiHandleButtonDa scopes->marker = BKE_tracking_marker_ensure(scopes->track, scopes->framenr); scopes->marker->flag &= ~(MARKER_DISABLED | MARKER_TRACKED); - scopes->marker->pos[0] += -dx * scopes->slide_scale[0] / (but->block->maxx - but->block->minx); - scopes->marker->pos[1] += -dy * scopes->slide_scale[1] / (but->block->maxy - but->block->miny); + scopes->marker->pos[0] += -dx * scopes->slide_scale[0] / (but->block->rect.xmax - but->block->rect.xmin); + scopes->marker->pos[1] += -dy * scopes->slide_scale[1] / (but->block->rect.ymax - but->block->rect.ymin); WM_event_add_notifier(C, NC_MOVIECLIP | NA_EDITED, NULL); } @@ -4921,7 +4921,7 @@ static int ui_do_button(bContext *C, uiBlock *block, uiBut *but, wmEvent *event) static int ui_but_contains_pt(uiBut *but, int mx, int my) { - return ((but->x1 < mx && but->x2 >= mx) && (but->y1 < my && but->y2 >= my)); + return ((but->rect.xmin < mx && but->rect.xmax >= mx) && (but->rect.ymin < my && but->rect.ymax >= my)); } static uiBut *ui_but_find_activated(ARegion *ar) @@ -5092,8 +5092,8 @@ static uiBut *ui_but_find_mouse_over(ARegion *ar, int x, int y) /* CLIP_EVENTS prevents the event from reaching other blocks */ if (block->flag & UI_BLOCK_CLIP_EVENTS) { /* check if mouse is inside block */ - if (block->minx <= mx && block->maxx >= mx && - block->miny <= my && block->maxy >= my) + if (block->rect.xmin <= mx && block->rect.xmax >= mx && + block->rect.ymin <= my && block->rect.ymax >= my) { break; } @@ -5979,17 +5979,17 @@ static int ui_mouse_motion_towards_check(uiBlock *block, uiPopupBlockHandle *men /* verify that we are moving towards one of the edges of the * menu block, in other words, in the triangle formed by the * initial mouse location and two edge points. */ - p1[0] = block->minx - 20; - p1[1] = block->miny - 20; + p1[0] = block->rect.xmin - 20; + p1[1] = block->rect.ymin - 20; - p2[0] = block->maxx + 20; - p2[1] = block->miny - 20; + p2[0] = block->rect.xmax + 20; + p2[1] = block->rect.ymin - 20; - p3[0] = block->maxx + 20; - p3[1] = block->maxy + 20; + p3[0] = block->rect.xmax + 20; + p3[1] = block->rect.ymax + 20; - p4[0] = block->minx - 20; - p4[1] = block->maxy + 20; + p4[0] = block->rect.xmin - 20; + p4[1] = block->rect.ymax + 20; oldp[0] = menu->towardsx; oldp[1] = menu->towardsy; @@ -6019,10 +6019,10 @@ static char ui_menu_scroll_test(uiBlock *block, int my) { if (block->flag & (UI_BLOCK_CLIPTOP | UI_BLOCK_CLIPBOTTOM)) { if (block->flag & UI_BLOCK_CLIPTOP) - if (my > block->maxy - 14) + if (my > block->rect.ymax - 14) return 't'; if (block->flag & UI_BLOCK_CLIPBOTTOM) - if (my < block->miny + 14) + if (my < block->rect.ymin + 14) return 'b'; } return 0; @@ -6053,25 +6053,25 @@ static int ui_menu_scroll(ARegion *ar, uiBlock *block, int my) if (test == 't') { /* bottom button is first button */ - if (b1->y1 < b2->y1) - dy = bnext->y1 - b1->y1; + if (b1->rect.ymin < b2->rect.ymin) + dy = bnext->rect.ymin - b1->rect.ymin; /* bottom button is last button */ else - dy = bprev->y1 - b2->y1; + dy = bprev->rect.ymin - b2->rect.ymin; } else if (test == 'b') { /* bottom button is first button */ - if (b1->y1 < b2->y1) - dy = b1->y1 - bnext->y1; + if (b1->rect.ymin < b2->rect.ymin) + dy = b1->rect.ymin - bnext->rect.ymin; /* bottom button is last button */ else - dy = b2->y1 - bprev->y1; + dy = b2->rect.ymin - bprev->rect.ymin; } if (dy) { for (b1 = block->buttons.first; b1; b1 = b1->next) { - b1->y1 -= dy; - b1->y2 -= dy; + b1->rect.ymin -= dy; + b1->rect.ymax -= dy; } /* set flags again */ ui_popup_block_scrolltest(block); @@ -6104,8 +6104,8 @@ static int ui_handle_menu_event(bContext *C, wmEvent *event, uiPopupBlockHandle /* check if mouse is inside block */ inside = 0; - if (block->minx <= mx && block->maxx >= mx) - if (block->miny <= my && block->maxy >= my) + if (block->rect.xmin <= mx && block->rect.xmax >= mx) + if (block->rect.ymin <= my && block->rect.ymax >= my) inside = 1; /* if there's an active modal button, don't check events or outside, except for search menu */ diff --git a/source/blender/editors/interface/interface_intern.h b/source/blender/editors/interface/interface_intern.h index 95049857d49..13d05ca617c 100644 --- a/source/blender/editors/interface/interface_intern.h +++ b/source/blender/editors/interface/interface_intern.h @@ -158,7 +158,7 @@ struct uiBut { char strdata[UI_MAX_NAME_STR]; char drawstr[UI_MAX_DRAW_STR]; - float x1, y1, x2, y2; + rctf rect; char *poin; float hardmin, hardmax, softmin, softmax; @@ -264,8 +264,8 @@ struct uiBlock { char name[UI_MAX_NAME_STR]; float winmat[4][4]; - - float minx, miny, maxx, maxy; + + rctf rect; float aspect; int puphash; /* popup menu hash for memory */ diff --git a/source/blender/editors/interface/interface_layout.c b/source/blender/editors/interface/interface_layout.c index 10fde402acc..32bad26f2c0 100644 --- a/source/blender/editors/interface/interface_layout.c +++ b/source/blender/editors/interface/interface_layout.c @@ -238,8 +238,8 @@ static void ui_item_size(uiItem *item, int *r_w, int *r_h) if (item->type == ITEM_BUTTON) { uiButtonItem *bitem = (uiButtonItem *)item; - if (r_w) *r_w = bitem->but->x2 - bitem->but->x1; - if (r_h) *r_h = bitem->but->y2 - bitem->but->y1; + if (r_w) *r_w = bitem->but->rect.xmax - bitem->but->rect.xmin; + if (r_h) *r_h = bitem->but->rect.ymax - bitem->but->rect.ymin; } else { uiLayout *litem = (uiLayout *)item; @@ -254,8 +254,8 @@ static void ui_item_offset(uiItem *item, int *r_x, int *r_y) if (item->type == ITEM_BUTTON) { uiButtonItem *bitem = (uiButtonItem *)item; - if (r_x) *r_x = bitem->but->x1; - if (r_y) *r_y = bitem->but->y1; + if (r_x) *r_x = bitem->but->rect.xmin; + if (r_y) *r_y = bitem->but->rect.ymin; } else { if (r_x) *r_x = 0; @@ -268,10 +268,10 @@ static void ui_item_position(uiItem *item, int x, int y, int w, int h) if (item->type == ITEM_BUTTON) { uiButtonItem *bitem = (uiButtonItem *)item; - bitem->but->x1 = x; - bitem->but->y1 = y; - bitem->but->x2 = x + w; - bitem->but->y2 = y + h; + bitem->but->rect.xmin = x; + bitem->but->rect.ymin = y; + bitem->but->rect.xmax = x + w; + bitem->but->rect.ymax = y + h; ui_check_but(bitem->but); /* for strlen */ } @@ -1898,10 +1898,10 @@ static void ui_litem_layout_box(uiLayout *litem) /* roundbox around the sublayout */ but = box->roundbox; - but->x1 = litem->x; - but->y1 = litem->y; - but->x2 = litem->x + litem->w; - but->y2 = litem->y + litem->h; + but->rect.xmin = litem->x; + but->rect.ymin = litem->y; + but->rect.xmax = litem->x + litem->w; + but->rect.ymax = litem->y + litem->h; } /* multi-column layout, automatically flowing to the next */ diff --git a/source/blender/editors/interface/interface_ops.c b/source/blender/editors/interface/interface_ops.c index b3b48cb3a46..98df612a6af 100644 --- a/source/blender/editors/interface/interface_ops.c +++ b/source/blender/editors/interface/interface_ops.c @@ -729,10 +729,10 @@ static int ui_editsource_uibut_match(uiBut *but_a, uiBut *but_b) /* this just needs to be a 'good-enough' comparison so we can know beyond * reasonable doubt that these buttons are the same between redraws. * if this fails it only means edit-source fails - campbell */ - if ((but_a->x1 == but_b->x1) && - (but_a->x2 == but_b->x2) && - (but_a->y1 == but_b->y1) && - (but_a->y2 == but_b->y2) && + if ((but_a->rect.xmin == but_b->rect.xmin) && + (but_a->rect.xmax == but_b->rect.xmax) && + (but_a->rect.ymin == but_b->rect.ymin) && + (but_a->rect.ymax == but_b->rect.ymax) && (but_a->type == but_b->type) && (but_a->rnaprop == but_b->rnaprop) && (but_a->optype == but_b->optype) && diff --git a/source/blender/editors/interface/interface_panel.c b/source/blender/editors/interface/interface_panel.c index d04c1af2769..79aff82fe6f 100644 --- a/source/blender/editors/interface/interface_panel.c +++ b/source/blender/editors/interface/interface_panel.c @@ -315,13 +315,13 @@ static void ui_offset_panel_block(uiBlock *block) ofsy = block->panel->sizey - style->panelspace; for (but = block->buttons.first; but; but = but->next) { - but->y1 += ofsy; - but->y2 += ofsy; + but->rect.ymin += ofsy; + but->rect.ymax += ofsy; } - block->maxx = block->panel->sizex; - block->maxy = block->panel->sizey; - block->minx = block->miny = 0.0; + block->rect.xmax = block->panel->sizex; + block->rect.ymax = block->panel->sizey; + block->rect.xmin = block->rect.ymin = 0.0; } /**************************** drawing *******************************/ @@ -1033,14 +1033,14 @@ static void ui_handle_panel_header(const bContext *C, uiBlock *block, int mx, in else if (event == AKEY) button = 1; else if (block->panel->flag & PNL_CLOSEDX) { - if (my >= block->maxy) button = 1; + if (my >= block->rect.ymax) button = 1; } else if (block->panel->control & UI_PNL_CLOSE) { /* whole of header can be used to collapse panel (except top-right corner) */ - if (mx <= block->maxx - 8 - PNL_ICON) button = 2; - //else if (mx <= block->minx + 10 + 2 * PNL_ICON + 2) button = 1; + if (mx <= block->rect.xmax - 8 - PNL_ICON) button = 2; + //else if (mx <= block->rect.xmin + 10 + 2 * PNL_ICON + 2) button = 1; } - else if (mx <= block->maxx - PNL_ICON - 12) { + else if (mx <= block->rect.xmax - PNL_ICON - 12) { button = 1; } @@ -1078,7 +1078,7 @@ static void ui_handle_panel_header(const bContext *C, uiBlock *block, int mx, in else ED_region_tag_redraw(ar); } - else if (mx <= (block->maxx - PNL_ICON - 12) + PNL_ICON + 2) { + else if (mx <= (block->rect.xmax - PNL_ICON - 12) + PNL_ICON + 2) { panel_activate_state(C, block->panel, PANEL_STATE_DRAG); } } @@ -1109,15 +1109,15 @@ int ui_handler_panel_region(bContext *C, wmEvent *event) if (pa->type && pa->type->flag & PNL_NO_HEADER) // XXX - accessed freed panels when scripts reload, need to fix. continue; - if (block->minx <= mx && block->maxx >= mx) - if (block->miny <= my && block->maxy + PNL_HEADER >= my) + if (block->rect.xmin <= mx && block->rect.xmax >= mx) + if (block->rect.ymin <= my && block->rect.ymax + PNL_HEADER >= my) inside = 1; if (inside && event->val == KM_PRESS) { if (event->type == AKEY && !ELEM4(KM_MOD_FIRST, event->ctrl, event->oskey, event->shift, event->alt)) { if (pa->flag & PNL_CLOSEDY) { - if ((block->maxy <= my) && (block->maxy + PNL_HEADER >= my)) + if ((block->rect.ymax <= my) && (block->rect.ymax + PNL_HEADER >= my)) ui_handle_panel_header(C, block, mx, my, event->type); } else @@ -1134,15 +1134,15 @@ int ui_handler_panel_region(bContext *C, wmEvent *event) if (inside) { /* clicked at panel header? */ if (pa->flag & PNL_CLOSEDX) { - if (block->minx <= mx && block->minx + PNL_HEADER >= mx) + if (block->rect.xmin <= mx && block->rect.xmin + PNL_HEADER >= mx) inside_header = 1; } - else if ((block->maxy <= my) && (block->maxy + PNL_HEADER >= my)) { + else if ((block->rect.ymax <= my) && (block->rect.ymax + PNL_HEADER >= my)) { inside_header = 1; } else if (pa->control & UI_PNL_SCALE) { - if (block->maxx - PNL_HEADER <= mx) - if (block->miny + PNL_HEADER >= my) + if (block->rect.xmax - PNL_HEADER <= mx) + if (block->rect.ymin + PNL_HEADER >= my) inside_scale = 1; } diff --git a/source/blender/editors/interface/interface_regions.c b/source/blender/editors/interface/interface_regions.c index ce4043eea6a..1941dc66967 100644 --- a/source/blender/editors/interface/interface_regions.c +++ b/source/blender/editors/interface/interface_regions.c @@ -685,9 +685,9 @@ ARegion *ui_tooltip_create(bContext *C, ARegion *butregion, uiBut *but) ofsx = (but->block->panel) ? but->block->panel->ofsx : 0; ofsy = (but->block->panel) ? but->block->panel->ofsy : 0; - x1f = (but->x1 + but->x2) * 0.5f + ofsx - (TIP_BORDER_X * aspect); + x1f = (but->rect.xmin + but->rect.xmax) * 0.5f + ofsx - (TIP_BORDER_X * aspect); x2f = x1f + fontw + (TIP_BORDER_X * aspect); - y2f = but->y1 + ofsy - (TIP_BORDER_Y * aspect); + y2f = but->rect.ymin + ofsy - (TIP_BORDER_Y * aspect); y1f = y2f - fonth * aspect - (TIP_BORDER_Y * aspect); #undef TIP_MARGIN_Y @@ -1181,17 +1181,17 @@ ARegion *ui_searchbox_create(bContext *C, ARegion *butregion, uiBut *but) data->bbox.ymax = (ar->winrct.ymax - ar->winrct.ymin) - MENU_SHADOW_BOTTOM; /* check if button is lower half */ - if (but->y2 < (but->block->miny + but->block->maxy) / 2) { - data->bbox.ymin += (but->y2 - but->y1); + if (but->rect.ymax < (but->block->rect.ymin + but->block->rect.ymax) / 2) { + data->bbox.ymin += (but->rect.ymax - but->rect.ymin); } else { - data->bbox.ymax -= (but->y2 - but->y1); + data->bbox.ymax -= (but->rect.ymax - but->rect.ymin); } } else { - x1f = but->x1 - 5; /* align text with button */ - x2f = but->x2 + 5; /* symmetrical */ - y2f = but->y1; + x1f = but->rect.xmin - 5; /* align text with button */ + x2f = but->rect.xmax + 5; /* symmetrical */ + y2f = but->rect.ymin; y1f = y2f - uiSearchBoxhHeight(); ofsx = (but->block->panel) ? but->block->panel->ofsx : 0; @@ -1234,7 +1234,7 @@ ARegion *ui_searchbox_create(bContext *C, ARegion *butregion, uiBut *but) if (y1 < 0) { int newy1; - UI_view2d_to_region_no_clip(&butregion->v2d, 0, but->y2 + ofsy, NULL, &newy1); + UI_view2d_to_region_no_clip(&butregion->v2d, 0, but->rect.ymax + ofsy, NULL, &newy1); newy1 += butregion->winrct.ymin; y2 = y2 - y1 + newy1; @@ -1339,45 +1339,44 @@ static void ui_block_position(wmWindow *window, ARegion *butregion, uiBut *but, short dir1 = 0, dir2 = 0; /* transform to window coordinates, using the source button region/block */ - butrct.xmin = but->x1; butrct.xmax = but->x2; - butrct.ymin = but->y1; butrct.ymax = but->y2; + butrct = but->rect; ui_block_to_window_fl(butregion, but->block, &butrct.xmin, &butrct.ymin); ui_block_to_window_fl(butregion, but->block, &butrct.xmax, &butrct.ymax); /* calc block rect */ - if (block->minx == 0.0f && block->maxx == 0.0f) { + if (block->rect.xmin == 0.0f && block->rect.xmax == 0.0f) { if (block->buttons.first) { - block->minx = block->miny = 10000; - block->maxx = block->maxy = -10000; + block->rect.xmin = block->rect.ymin = 10000; + block->rect.xmax = block->rect.ymax = -10000; bt = block->buttons.first; while (bt) { - if (bt->x1 < block->minx) block->minx = bt->x1; - if (bt->y1 < block->miny) block->miny = bt->y1; + if (bt->rect.xmin < block->rect.xmin) block->rect.xmin = bt->rect.xmin; + if (bt->rect.ymin < block->rect.ymin) block->rect.ymin = bt->rect.ymin; - if (bt->x2 > block->maxx) block->maxx = bt->x2; - if (bt->y2 > block->maxy) block->maxy = bt->y2; + if (bt->rect.xmax > block->rect.xmax) block->rect.xmax = bt->rect.xmax; + if (bt->rect.ymax > block->rect.ymax) block->rect.ymax = bt->rect.ymax; bt = bt->next; } } else { /* we're nice and allow empty blocks too */ - block->minx = block->miny = 0; - block->maxx = block->maxy = 20; + block->rect.xmin = block->rect.ymin = 0; + block->rect.xmax = block->rect.ymax = 20; } } - /* aspect = (float)(block->maxx - block->minx + 4);*/ /*UNUSED*/ - ui_block_to_window_fl(butregion, but->block, &block->minx, &block->miny); - ui_block_to_window_fl(butregion, but->block, &block->maxx, &block->maxy); + /* aspect = (float)(block->rect.xmax - block->rect.xmin + 4);*/ /*UNUSED*/ + ui_block_to_window_fl(butregion, but->block, &block->rect.xmin, &block->rect.ymin); + ui_block_to_window_fl(butregion, but->block, &block->rect.xmax, &block->rect.ymax); - //block->minx -= 2.0; block->miny -= 2.0; - //block->maxx += 2.0; block->maxy += 2.0; + //block->rect.xmin -= 2.0; block->rect.ymin -= 2.0; + //block->rect.xmax += 2.0; block->rect.ymax += 2.0; - xsize = block->maxx - block->minx + 4; // 4 for shadow - ysize = block->maxy - block->miny + 4; + xsize = block->rect.xmax - block->rect.xmin + 4; // 4 for shadow + ysize = block->rect.ymax - block->rect.ymin + 4; /* aspect /= (float)xsize;*/ /*UNUSED*/ { @@ -1431,19 +1430,19 @@ static void ui_block_position(wmWindow *window, ARegion *butregion, uiBut *but, } if (dir1 == UI_LEFT) { - xof = butrct.xmin - block->maxx; - if (dir2 == UI_TOP) yof = butrct.ymin - block->miny - center; - else yof = butrct.ymax - block->maxy + center; + xof = butrct.xmin - block->rect.xmax; + if (dir2 == UI_TOP) yof = butrct.ymin - block->rect.ymin - center; + else yof = butrct.ymax - block->rect.ymax + center; } else if (dir1 == UI_RIGHT) { - xof = butrct.xmax - block->minx; - if (dir2 == UI_TOP) yof = butrct.ymin - block->miny - center; - else yof = butrct.ymax - block->maxy + center; + xof = butrct.xmax - block->rect.xmin; + if (dir2 == UI_TOP) yof = butrct.ymin - block->rect.ymin - center; + else yof = butrct.ymax - block->rect.ymax + center; } else if (dir1 == UI_TOP) { - yof = butrct.ymax - block->miny; - if (dir2 == UI_RIGHT) xof = butrct.xmax - block->maxx; - else xof = butrct.xmin - block->minx; + yof = butrct.ymax - block->rect.ymin; + if (dir2 == UI_RIGHT) xof = butrct.xmax - block->rect.xmax; + else xof = butrct.xmin - block->rect.xmin; // changed direction? if ((dir1 & block->direction) == 0) { if (block->direction & UI_SHIFT_FLIPPED) @@ -1452,9 +1451,9 @@ static void ui_block_position(wmWindow *window, ARegion *butregion, uiBut *but, } } else if (dir1 == UI_DOWN) { - yof = butrct.ymin - block->maxy; - if (dir2 == UI_RIGHT) xof = butrct.xmax - block->maxx; - else xof = butrct.xmin - block->minx; + yof = butrct.ymin - block->rect.ymax; + if (dir2 == UI_RIGHT) xof = butrct.xmax - block->rect.xmax; + else xof = butrct.xmin - block->rect.xmin; // changed direction? if ((dir1 & block->direction) == 0) { if (block->direction & UI_SHIFT_FLIPPED) @@ -1475,7 +1474,7 @@ static void ui_block_position(wmWindow *window, ARegion *butregion, uiBut *but, if (left == 0 && right == 0) { if (dir1 == UI_TOP || dir1 == UI_DOWN) { // align with left size of screen - xof = -block->minx + 5; + xof = -block->rect.xmin + 5; } } @@ -1484,33 +1483,33 @@ static void ui_block_position(wmWindow *window, ARegion *butregion, uiBut *but, yof += block->yofs / block->aspect; #if 0 /* clamp to window bounds, could be made into an option if its ever annoying */ - if ( (offscreen = (block->miny + yof)) < 0) yof -= offscreen; /* bottom */ - else if ((offscreen = (block->maxy + yof) - winy) > 0) yof -= offscreen; /* top */ - if ( (offscreen = (block->minx + xof)) < 0) xof -= offscreen; /* left */ - else if ((offscreen = (block->maxx + xof) - winx) > 0) xof -= offscreen; /* right */ + if ( (offscreen = (block->rect.ymin + yof)) < 0) yof -= offscreen; /* bottom */ + else if ((offscreen = (block->rect.ymax + yof) - winy) > 0) yof -= offscreen; /* top */ + if ( (offscreen = (block->rect.xmin + xof)) < 0) xof -= offscreen; /* left */ + else if ((offscreen = (block->rect.xmax + xof) - winx) > 0) xof -= offscreen; /* right */ #endif } /* apply offset, buttons in window coords */ for (bt = block->buttons.first; bt; bt = bt->next) { - ui_block_to_window_fl(butregion, but->block, &bt->x1, &bt->y1); - ui_block_to_window_fl(butregion, but->block, &bt->x2, &bt->y2); + ui_block_to_window_fl(butregion, but->block, &bt->rect.xmin, &bt->rect.ymin); + ui_block_to_window_fl(butregion, but->block, &bt->rect.xmax, &bt->rect.ymax); - bt->x1 += xof; - bt->x2 += xof; - bt->y1 += yof; - bt->y2 += yof; + bt->rect.xmin += xof; + bt->rect.xmax += xof; + bt->rect.ymin += yof; + bt->rect.ymax += yof; bt->aspect = 1.0; // ui_check_but recalculates drawstring size in pixels ui_check_but(bt); } - block->minx += xof; - block->miny += yof; - block->maxx += xof; - block->maxy += yof; + block->rect.xmin += xof; + block->rect.ymin += yof; + block->rect.xmax += xof; + block->rect.ymax += yof; /* safety calculus */ if (but) { @@ -1520,31 +1519,31 @@ static void ui_block_position(wmWindow *window, ARegion *butregion, uiBut *but, /* when you are outside parent button, safety there should be smaller */ /* parent button to left */ - if (midx < block->minx) block->safety.xmin = block->minx - 3; - else block->safety.xmin = block->minx - 40; + if (midx < block->rect.xmin) block->safety.xmin = block->rect.xmin - 3; + else block->safety.xmin = block->rect.xmin - 40; /* parent button to right */ - if (midx > block->maxx) block->safety.xmax = block->maxx + 3; - else block->safety.xmax = block->maxx + 40; + if (midx > block->rect.xmax) block->safety.xmax = block->rect.xmax + 3; + else block->safety.xmax = block->rect.xmax + 40; /* parent button on bottom */ - if (midy < block->miny) block->safety.ymin = block->miny - 3; - else block->safety.ymin = block->miny - 40; + if (midy < block->rect.ymin) block->safety.ymin = block->rect.ymin - 3; + else block->safety.ymin = block->rect.ymin - 40; /* parent button on top */ - if (midy > block->maxy) block->safety.ymax = block->maxy + 3; - else block->safety.ymax = block->maxy + 40; + if (midy > block->rect.ymax) block->safety.ymax = block->rect.ymax + 3; + else block->safety.ymax = block->rect.ymax + 40; /* exception for switched pulldowns... */ if (dir1 && (dir1 & block->direction) == 0) { - if (dir2 == UI_RIGHT) block->safety.xmax = block->maxx + 3; - if (dir2 == UI_LEFT) block->safety.xmin = block->minx - 3; + if (dir2 == UI_RIGHT) block->safety.xmax = block->rect.xmax + 3; + if (dir2 == UI_LEFT) block->safety.xmin = block->rect.xmin - 3; } block->direction = dir1; } else { - block->safety.xmin = block->minx - 40; - block->safety.ymin = block->miny - 40; - block->safety.xmax = block->maxx + 40; - block->safety.ymax = block->maxy + 40; + block->safety.xmin = block->rect.xmin - 40; + block->safety.ymin = block->rect.ymin - 40; + block->safety.xmax = block->rect.xmax + 40; + block->safety.ymax = block->rect.ymax + 40; } /* keep a list of these, needed for pulldown menus */ @@ -1571,15 +1570,15 @@ static void ui_popup_block_clip(wmWindow *window, uiBlock *block) wm_window_get_size(window, &winx, &winy); - if (block->minx < MENU_SHADOW_SIDE) - block->minx = MENU_SHADOW_SIDE; - if (block->maxx > winx - MENU_SHADOW_SIDE) - block->maxx = winx - MENU_SHADOW_SIDE; + if (block->rect.xmin < MENU_SHADOW_SIDE) + block->rect.xmin = MENU_SHADOW_SIDE; + if (block->rect.xmax > winx - MENU_SHADOW_SIDE) + block->rect.xmax = winx - MENU_SHADOW_SIDE; - if (block->miny < MENU_SHADOW_BOTTOM) - block->miny = MENU_SHADOW_BOTTOM; - if (block->maxy > winy - MENU_TOP) - block->maxy = winy - MENU_TOP; + if (block->rect.ymin < MENU_SHADOW_BOTTOM) + block->rect.ymin = MENU_SHADOW_BOTTOM; + if (block->rect.ymax > winy - MENU_TOP) + block->rect.ymax = winy - MENU_TOP; } void ui_popup_block_scrolltest(uiBlock *block) @@ -1598,25 +1597,25 @@ void ui_popup_block_scrolltest(uiBlock *block) /* mark buttons that are outside boundary and the ones next to it for arrow(s) */ for (bt = block->buttons.first; bt; bt = bt->next) { - if (bt->y1 < block->miny) { + if (bt->rect.ymin < block->rect.ymin) { bt->flag |= UI_SCROLLED; block->flag |= UI_BLOCK_CLIPBOTTOM; /* make space for arrow */ - if (bt->y2 < block->miny + 10) { - if (is_flip && bt->next && bt->next->y1 > bt->y1) + if (bt->rect.ymax < block->rect.ymin + 10) { + if (is_flip && bt->next && bt->next->rect.ymin > bt->rect.ymin) bt->next->flag |= UI_SCROLLED; - else if (!is_flip && bt->prev && bt->prev->y1 > bt->y1) + else if (!is_flip && bt->prev && bt->prev->rect.ymin > bt->rect.ymin) bt->prev->flag |= UI_SCROLLED; } } - if (bt->y2 > block->maxy) { + if (bt->rect.ymax > block->rect.ymax) { bt->flag |= UI_SCROLLED; block->flag |= UI_BLOCK_CLIPTOP; /* make space for arrow */ - if (bt->y1 > block->maxy - 10) { - if (!is_flip && bt->next && bt->next->y2 < bt->y2) + if (bt->rect.ymin > block->rect.ymax - 10) { + if (!is_flip && bt->next && bt->next->rect.ymax < bt->rect.ymax) bt->next->flag |= UI_SCROLLED; - else if (is_flip && bt->prev && bt->prev->y2 < bt->y2) + else if (is_flip && bt->prev && bt->prev->rect.ymax < bt->rect.ymax) bt->prev->flag |= UI_SCROLLED; } } @@ -1694,21 +1693,21 @@ uiPopupBlockHandle *ui_popup_block_create(bContext *C, ARegion *butregion, uiBut /* the block and buttons were positioned in window space as in 2.4x, now * these menu blocks are regions so we bring it back to region space. * additionally we add some padding for the menu shadow or rounded menus */ - ar->winrct.xmin = block->minx - MENU_SHADOW_SIDE; - ar->winrct.xmax = block->maxx + MENU_SHADOW_SIDE; - ar->winrct.ymin = block->miny - MENU_SHADOW_BOTTOM; - ar->winrct.ymax = block->maxy + MENU_TOP; + ar->winrct.xmin = block->rect.xmin - MENU_SHADOW_SIDE; + ar->winrct.xmax = block->rect.xmax + MENU_SHADOW_SIDE; + ar->winrct.ymin = block->rect.ymin - MENU_SHADOW_BOTTOM; + ar->winrct.ymax = block->rect.ymax + MENU_TOP; - block->minx -= ar->winrct.xmin; - block->maxx -= ar->winrct.xmin; - block->miny -= ar->winrct.ymin; - block->maxy -= ar->winrct.ymin; + block->rect.xmin -= ar->winrct.xmin; + block->rect.xmax -= ar->winrct.xmin; + block->rect.ymin -= ar->winrct.ymin; + block->rect.ymax -= ar->winrct.ymin; for (bt = block->buttons.first; bt; bt = bt->next) { - bt->x1 -= ar->winrct.xmin; - bt->x2 -= ar->winrct.xmin; - bt->y1 -= ar->winrct.ymin; - bt->y2 -= ar->winrct.ymin; + bt->rect.xmin -= ar->winrct.xmin; + bt->rect.xmax -= ar->winrct.xmin; + bt->rect.ymin -= ar->winrct.ymin; + bt->rect.ymax -= ar->winrct.ymin; } block->flag |= UI_BLOCK_LOOP; @@ -2371,7 +2370,7 @@ static uiBlock *ui_block_func_POPUP(bContext *C, uiPopupBlockHandle *handle, voi if (pup->but) { /* minimum width to enforece */ - minwidth = pup->but->x2 - pup->but->x1; + minwidth = pup->but->rect.xmax - pup->but->rect.xmin; if (pup->but->type == PULLDOWN || pup->but->menu_create_func) { direction = UI_DOWN; @@ -2413,15 +2412,15 @@ static uiBlock *ui_block_func_POPUP(bContext *C, uiPopupBlockHandle *handle, voi * button, so it doesn't overlap the text too much, also note * the offset is negative because we are inverse moving the * block to be under the mouse */ - offset[0] = -(bt->x1 + 0.8f * (bt->x2 - bt->x1)); - offset[1] = -(bt->y1 + 0.5f * UI_UNIT_Y); + offset[0] = -(bt->rect.xmin + 0.8f * (bt->rect.xmax - bt->rect.xmin)); + offset[1] = -(bt->rect.ymin + 0.5f * UI_UNIT_Y); } else { /* position mouse at 0.8*width of the button and below the tile * on the first item */ offset[0] = 0; for (bt = block->buttons.first; bt; bt = bt->next) - offset[0] = mini(offset[0], -(bt->x1 + 0.8f * (bt->x2 - bt->x1))); + offset[0] = mini(offset[0], -(bt->rect.xmin + 0.8f * (bt->rect.xmax - bt->rect.xmin))); offset[1] = 1.5 * UI_UNIT_Y; } diff --git a/source/blender/editors/space_image/image_buttons.c b/source/blender/editors/space_image/image_buttons.c index 51bd4e16d06..b8ca0deb770 100644 --- a/source/blender/editors/space_image/image_buttons.c +++ b/source/blender/editors/space_image/image_buttons.c @@ -274,7 +274,7 @@ static void preview_cb(ScrArea *sa, struct uiBlock *block) /* while dragging we need to update the rects, otherwise it doesn't end with correct one */ - BLI_rctf_init(&dispf, 15.0f, (block->maxx - block->minx) - 15.0f, 15.0f, (block->maxy - block->miny) - 15.0f); + BLI_rctf_init(&dispf, 15.0f, (block->rect.xmax - block->rect.xmin) - 15.0f, 15.0f, (block->rect.ymax - block->rect.ymin) - 15.0f); ui_graphics_to_window_rct(sa->win, &dispf, disprect); /* correction for gla draw */ diff --git a/source/blender/editors/space_logic/logic_buttons.c b/source/blender/editors/space_logic/logic_buttons.c index 1595889f596..999a8baf34b 100644 --- a/source/blender/editors/space_logic/logic_buttons.c +++ b/source/blender/editors/space_logic/logic_buttons.c @@ -84,10 +84,10 @@ static int cut_links_intersect(uiLinkLine *line, float mcoords[][2], int tot) int i, b; rcti rectlink; - rectlink.xmin = (int) (line->from->x1 + line->from->x2) / 2; - rectlink.ymin = (int) (line->from->y1 + line->from->y2) / 2; - rectlink.xmax = (int) (line->to->x1 + line->to->x2) / 2; - rectlink.ymax = (int) (line->to->y1 + line->to->y2) / 2; + rectlink.xmin = (int) (line->from->rect.xmin + line->from->rect.xmax) / 2; + rectlink.ymin = (int) (line->from->rect.ymin + line->from->rect.ymax) / 2; + rectlink.xmax = (int) (line->to->rect.xmin + line->to->rect.xmax) / 2; + rectlink.ymax = (int) (line->to->rect.ymin + line->to->rect.ymax) / 2; if (ui_link_bezier_points(&rectlink, coord_array, LINK_RESOL)) { for (i=0; ibuttons.last; - bt->x2 = UI_UNIT_X / 2; + bt->rect.xmax = UI_UNIT_X / 2; uiBlockSetEmboss(block, UI_EMBOSS); } From a5b5f5d3fbddf6ef8b42b22209bdb70eca0aeaef Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 18 Aug 2012 18:11:51 +0000 Subject: [PATCH 003/163] code cleanup: use BLI rect functions for interface button and block code. --- source/blender/editors/include/UI_interface.h | 98 +++--- source/blender/editors/interface/interface.c | 279 +++++++++--------- .../editors/interface/interface_handlers.c | 14 +- .../blender/editors/interface/interface_ops.c | 5 +- .../editors/interface/interface_regions.c | 165 +++++------ 5 files changed, 259 insertions(+), 302 deletions(-) diff --git a/source/blender/editors/include/UI_interface.h b/source/blender/editors/include/UI_interface.h index 0b0ad83ab21..f055c89235d 100644 --- a/source/blender/editors/include/UI_interface.h +++ b/source/blender/editors/include/UI_interface.h @@ -456,19 +456,19 @@ uiBut *uiDefBut(uiBlock *block, void *poin, float min, float max, float a1, float a2, const char *tip); -uiBut *uiDefButF(uiBlock *block, int type, int retval, const char *str, int x1, int y1, short x2, short y2, float *poin, float min, float max, float a1, float a2, const char *tip); -uiBut *uiDefButBitF(uiBlock *block, int type, int bit, int retval, const char *str, int x1, int y1, short x2, short y2, float *poin, float min, float max, float a1, float a2, const char *tip); -uiBut *uiDefButI(uiBlock *block, int type, int retval, const char *str, int x1, int y1, short x2, short y2, int *poin, float min, float max, float a1, float a2, const char *tip); -uiBut *uiDefButBitI(uiBlock *block, int type, int bit, int retval, const char *str, int x1, int y1, short x2, short y2, int *poin, float min, float max, float a1, float a2, const char *tip); -uiBut *uiDefButS(uiBlock *block, int type, int retval, const char *str, int x1, int y1, short x2, short y2, short *poin, float min, float max, float a1, float a2, const char *tip); -uiBut *uiDefButBitS(uiBlock *block, int type, int bit, int retval, const char *str, int x1, int y1, short x2, short y2, short *poin, float min, float max, float a1, float a2, const char *tip); -uiBut *uiDefButC(uiBlock *block, int type, int retval, const char *str, int x1, int y1, short x2, short y2, char *poin, float min, float max, float a1, float a2, const char *tip); -uiBut *uiDefButBitC(uiBlock *block, int type, int bit, int retval, const char *str, int x1, int y1, short x2, short y2, char *poin, float min, float max, float a1, float a2, const char *tip); -uiBut *uiDefButR(uiBlock *block, int type, int retval, const char *str, int x1, int y1, short x2, short y2, struct PointerRNA *ptr, const char *propname, int index, float min, float max, float a1, float a2, const char *tip); -uiBut *uiDefButR_prop(uiBlock *block, int type, int retval, const char *str, int x1, int y1, short x2, short y2, struct PointerRNA *ptr, struct PropertyRNA *prop, int index, float min, float max, float a1, float a2, const char *tip); -uiBut *uiDefButO(uiBlock *block, int type, const char *opname, int opcontext, const char *str, int x1, int y1, short x2, short y2, const char *tip); -uiBut *uiDefButO_ptr(uiBlock *block, int type, struct wmOperatorType *ot, int opcontext, const char *str, int x1, int y1, short x2, short y2, const char *tip); -uiBut *uiDefButTextO(uiBlock *block, int type, const char *opname, int opcontext, const char *str, int x1, int y1, short x2, short y2, void *poin, float min, float max, float a1, float a2, const char *tip); +uiBut *uiDefButF(uiBlock *block, int type, int retval, const char *str, int x, int y, short width, short height, float *poin, float min, float max, float a1, float a2, const char *tip); +uiBut *uiDefButBitF(uiBlock *block, int type, int bit, int retval, const char *str, int x, int y, short width, short height, float *poin, float min, float max, float a1, float a2, const char *tip); +uiBut *uiDefButI(uiBlock *block, int type, int retval, const char *str, int x, int y, short width, short height, int *poin, float min, float max, float a1, float a2, const char *tip); +uiBut *uiDefButBitI(uiBlock *block, int type, int bit, int retval, const char *str, int x, int y, short width, short height, int *poin, float min, float max, float a1, float a2, const char *tip); +uiBut *uiDefButS(uiBlock *block, int type, int retval, const char *str, int x, int y, short width, short height, short *poin, float min, float max, float a1, float a2, const char *tip); +uiBut *uiDefButBitS(uiBlock *block, int type, int bit, int retval, const char *str, int x, int y, short width, short height, short *poin, float min, float max, float a1, float a2, const char *tip); +uiBut *uiDefButC(uiBlock *block, int type, int retval, const char *str, int x, int y, short width, short height, char *poin, float min, float max, float a1, float a2, const char *tip); +uiBut *uiDefButBitC(uiBlock *block, int type, int bit, int retval, const char *str, int x, int y, short width, short height, char *poin, float min, float max, float a1, float a2, const char *tip); +uiBut *uiDefButR(uiBlock *block, int type, int retval, const char *str, int x, int y, short width, short height, struct PointerRNA *ptr, const char *propname, int index, float min, float max, float a1, float a2, const char *tip); +uiBut *uiDefButR_prop(uiBlock *block, int type, int retval, const char *str, int x, int y, short width, short height, struct PointerRNA *ptr, struct PropertyRNA *prop, int index, float min, float max, float a1, float a2, const char *tip); +uiBut *uiDefButO(uiBlock *block, int type, const char *opname, int opcontext, const char *str, int x, int y, short width, short height, const char *tip); +uiBut *uiDefButO_ptr(uiBlock *block, int type, struct wmOperatorType *ot, int opcontext, const char *str, int x, int y, short width, short height, const char *tip); +uiBut *uiDefButTextO(uiBlock *block, int type, const char *opname, int opcontext, const char *str, int x, int y, short width, short height, void *poin, float min, float max, float a1, float a2, const char *tip); uiBut *uiDefIconBut(uiBlock *block, int type, int retval, int icon, @@ -477,18 +477,18 @@ uiBut *uiDefIconBut(uiBlock *block, void *poin, float min, float max, float a1, float a2, const char *tip); -uiBut *uiDefIconButF(uiBlock *block, int type, int retval, int icon, int x1, int y1, short x2, short y2, float *poin, float min, float max, float a1, float a2, const char *tip); -uiBut *uiDefIconButBitF(uiBlock *block, int type, int bit, int retval, int icon, int x1, int y1, short x2, short y2, float *poin, float min, float max, float a1, float a2, const char *tip); -uiBut *uiDefIconButI(uiBlock *block, int type, int retval, int icon, int x1, int y1, short x2, short y2, int *poin, float min, float max, float a1, float a2, const char *tip); -uiBut *uiDefIconButBitI(uiBlock *block, int type, int bit, int retval, int icon, int x1, int y1, short x2, short y2, int *poin, float min, float max, float a1, float a2, const char *tip); -uiBut *uiDefIconButS(uiBlock *block, int type, int retval, int icon, int x1, int y1, short x2, short y2, short *poin, float min, float max, float a1, float a2, const char *tip); -uiBut *uiDefIconButBitS(uiBlock *block, int type, int bit, int retval, int icon, int x1, int y1, short x2, short y2, short *poin, float min, float max, float a1, float a2, const char *tip); -uiBut *uiDefIconButC(uiBlock *block, int type, int retval, int icon, int x1, int y1, short x2, short y2, char *poin, float min, float max, float a1, float a2, const char *tip); -uiBut *uiDefIconButBitC(uiBlock *block, int type, int bit, int retval, int icon, int x1, int y1, short x2, short y2, char *poin, float min, float max, float a1, float a2, const char *tip); -uiBut *uiDefIconButR(uiBlock *block, int type, int retval, int icon, int x1, int y1, short x2, short y2, struct PointerRNA *ptr, const char *propname, int index, float min, float max, float a1, float a2, const char *tip); -uiBut *uiDefIconButR_prop(uiBlock *block, int type, int retval, int icon, int x1, int y1, short x2, short y2, struct PointerRNA *ptr, PropertyRNA *prop, int index, float min, float max, float a1, float a2, const char *tip); -uiBut *uiDefIconButO(uiBlock *block, int type, const char *opname, int opcontext, int icon, int x1, int y1, short x2, short y2, const char *tip); -uiBut *uiDefIconButO_ptr(uiBlock *block, int type, struct wmOperatorType *ot, int opcontext, int icon, int x1, int y1, short x2, short y2, const char *tip); +uiBut *uiDefIconButF(uiBlock *block, int type, int retval, int icon, int x, int y, short width, short height, float *poin, float min, float max, float a1, float a2, const char *tip); +uiBut *uiDefIconButBitF(uiBlock *block, int type, int bit, int retval, int icon, int x, int y, short width, short height, float *poin, float min, float max, float a1, float a2, const char *tip); +uiBut *uiDefIconButI(uiBlock *block, int type, int retval, int icon, int x, int y, short width, short height, int *poin, float min, float max, float a1, float a2, const char *tip); +uiBut *uiDefIconButBitI(uiBlock *block, int type, int bit, int retval, int icon, int x, int y, short width, short height, int *poin, float min, float max, float a1, float a2, const char *tip); +uiBut *uiDefIconButS(uiBlock *block, int type, int retval, int icon, int x, int y, short width, short height, short *poin, float min, float max, float a1, float a2, const char *tip); +uiBut *uiDefIconButBitS(uiBlock *block, int type, int bit, int retval, int icon, int x, int y, short width, short height, short *poin, float min, float max, float a1, float a2, const char *tip); +uiBut *uiDefIconButC(uiBlock *block, int type, int retval, int icon, int x, int y, short width, short height, char *poin, float min, float max, float a1, float a2, const char *tip); +uiBut *uiDefIconButBitC(uiBlock *block, int type, int bit, int retval, int icon, int x, int y, short width, short height, char *poin, float min, float max, float a1, float a2, const char *tip); +uiBut *uiDefIconButR(uiBlock *block, int type, int retval, int icon, int x, int y, short width, short height, struct PointerRNA *ptr, const char *propname, int index, float min, float max, float a1, float a2, const char *tip); +uiBut *uiDefIconButR_prop(uiBlock *block, int type, int retval, int icon, int x, int y, short width, short height, struct PointerRNA *ptr, PropertyRNA *prop, int index, float min, float max, float a1, float a2, const char *tip); +uiBut *uiDefIconButO(uiBlock *block, int type, const char *opname, int opcontext, int icon, int x, int y, short width, short height, const char *tip); +uiBut *uiDefIconButO_ptr(uiBlock *block, int type, struct wmOperatorType *ot, int opcontext, int icon, int x, int y, short width, short height, const char *tip); uiBut *uiDefIconTextBut(uiBlock *block, int type, int retval, int icon, const char *str, @@ -497,18 +497,18 @@ uiBut *uiDefIconTextBut(uiBlock *block, void *poin, float min, float max, float a1, float a2, const char *tip); -uiBut *uiDefIconTextButF(uiBlock *block, int type, int retval, int icon, const char *str, int x1, int y1, short x2, short y2, float *poin, float min, float max, float a1, float a2, const char *tip); -uiBut *uiDefIconTextButBitF(uiBlock *block, int type, int bit, int retval, int icon, const char *str, int x1, int y1, short x2, short y2, float *poin, float min, float max, float a1, float a2, const char *tip); -uiBut *uiDefIconTextButI(uiBlock *block, int type, int retval, int icon, const char *str, int x1, int y1, short x2, short y2, int *poin, float min, float max, float a1, float a2, const char *tip); -uiBut *uiDefIconTextButBitI(uiBlock *block, int type, int bit, int retval, int icon, const char *str, int x1, int y1, short x2, short y2, int *poin, float min, float max, float a1, float a2, const char *tip); -uiBut *uiDefIconTextButS(uiBlock *block, int type, int retval, int icon, const char *str, int x1, int y1, short x2, short y2, short *poin, float min, float max, float a1, float a2, const char *tip); -uiBut *uiDefIconTextButBitS(uiBlock *block, int type, int bit, int retval, int icon, const char *str, int x1, int y1, short x2, short y2, short *poin, float min, float max, float a1, float a2, const char *tip); -uiBut *uiDefIconTextButC(uiBlock *block, int type, int retval, int icon, const char *str, int x1, int y1, short x2, short y2, char *poin, float min, float max, float a1, float a2, const char *tip); -uiBut *uiDefIconTextButBitC(uiBlock *block, int type, int bit, int retval, int icon, const char *str, int x1, int y1, short x2, short y2, char *poin, float min, float max, float a1, float a2, const char *tip); -uiBut *uiDefIconTextButR(uiBlock *block, int type, int retval, int icon, const char *str, int x1, int y1, short x2, short y2, struct PointerRNA *ptr, const char *propname, int index, float min, float max, float a1, float a2, const char *tip); -uiBut *uiDefIconTextButR_prop(uiBlock *block, int type, int retval, int icon, const char *str, int x1, int y1, short x2, short y2, struct PointerRNA *ptr, struct PropertyRNA *prop, int index, float min, float max, float a1, float a2, const char *tip); -uiBut *uiDefIconTextButO(uiBlock *block, int type, const char *opname, int opcontext, int icon, const char *str, int x1, int y1, short x2, short y2, const char *tip); -uiBut *uiDefIconTextButO_ptr(uiBlock *block, int type, struct wmOperatorType *ot, int opcontext, int icon, const char *str, int x1, int y1, short x2, short y2, const char *tip); +uiBut *uiDefIconTextButF(uiBlock *block, int type, int retval, int icon, const char *str, int x, int y, short width, short height, float *poin, float min, float max, float a1, float a2, const char *tip); +uiBut *uiDefIconTextButBitF(uiBlock *block, int type, int bit, int retval, int icon, const char *str, int x, int y, short width, short height, float *poin, float min, float max, float a1, float a2, const char *tip); +uiBut *uiDefIconTextButI(uiBlock *block, int type, int retval, int icon, const char *str, int x, int y, short width, short height, int *poin, float min, float max, float a1, float a2, const char *tip); +uiBut *uiDefIconTextButBitI(uiBlock *block, int type, int bit, int retval, int icon, const char *str, int x, int y, short width, short height, int *poin, float min, float max, float a1, float a2, const char *tip); +uiBut *uiDefIconTextButS(uiBlock *block, int type, int retval, int icon, const char *str, int x, int y, short width, short height, short *poin, float min, float max, float a1, float a2, const char *tip); +uiBut *uiDefIconTextButBitS(uiBlock *block, int type, int bit, int retval, int icon, const char *str, int x, int y, short width, short height, short *poin, float min, float max, float a1, float a2, const char *tip); +uiBut *uiDefIconTextButC(uiBlock *block, int type, int retval, int icon, const char *str, int x, int y, short width, short height, char *poin, float min, float max, float a1, float a2, const char *tip); +uiBut *uiDefIconTextButBitC(uiBlock *block, int type, int bit, int retval, int icon, const char *str, int x, int y, short width, short height, char *poin, float min, float max, float a1, float a2, const char *tip); +uiBut *uiDefIconTextButR(uiBlock *block, int type, int retval, int icon, const char *str, int x, int y, short width, short height, struct PointerRNA *ptr, const char *propname, int index, float min, float max, float a1, float a2, const char *tip); +uiBut *uiDefIconTextButR_prop(uiBlock *block, int type, int retval, int icon, const char *str, int x, int y, short width, short height, struct PointerRNA *ptr, struct PropertyRNA *prop, int index, float min, float max, float a1, float a2, const char *tip); +uiBut *uiDefIconTextButO(uiBlock *block, int type, const char *opname, int opcontext, int icon, const char *str, int x, int y, short width, short height, const char *tip); +uiBut *uiDefIconTextButO_ptr(uiBlock *block, int type, struct wmOperatorType *ot, int opcontext, int icon, const char *str, int x, int y, short width, short height, const char *tip); /* for passing inputs to ButO buttons */ struct PointerRNA *uiButGetOperatorPtrRNA(uiBut *but); @@ -573,25 +573,25 @@ typedef void (*uiIDPoinFuncFP)(struct bContext *C, const char *str, struct ID ** typedef void (*uiIDPoinFunc)(struct bContext *C, struct ID *id, int event); uiBut *uiDefIDPoinBut(uiBlock *block, uiIDPoinFuncFP func, short blocktype, int retval, const char *str, - int x1, int y1, short x2, short y2, void *idpp, const char *tip); + int x, int y, short width, short height, void *idpp, const char *tip); int uiIconFromID(struct ID *id); -uiBut *uiDefPulldownBut(uiBlock *block, uiBlockCreateFunc func, void *arg, const char *str, int x1, int y1, short x2, short y2, const char *tip); -uiBut *uiDefMenuBut(uiBlock *block, uiMenuCreateFunc func, void *arg, const char *str, int x1, int y1, short x2, short y2, const char *tip); -uiBut *uiDefIconTextMenuBut(uiBlock *block, uiMenuCreateFunc func, void *arg, int icon, const char *str, int x1, int y1, short x2, short y2, const char *tip); -uiBut *uiDefIconMenuBut(uiBlock *block, uiMenuCreateFunc func, void *arg, int icon, int x1, int y1, short x2, short y2, const char *tip); +uiBut *uiDefPulldownBut(uiBlock *block, uiBlockCreateFunc func, void *arg, const char *str, int x, int y, short width, short height, const char *tip); +uiBut *uiDefMenuBut(uiBlock *block, uiMenuCreateFunc func, void *arg, const char *str, int x, int y, short width, short height, const char *tip); +uiBut *uiDefIconTextMenuBut(uiBlock *block, uiMenuCreateFunc func, void *arg, int icon, const char *str, int x, int y, short width, short height, const char *tip); +uiBut *uiDefIconMenuBut(uiBlock *block, uiMenuCreateFunc func, void *arg, int icon, int x, int y, short width, short height, const char *tip); -uiBut *uiDefBlockBut(uiBlock *block, uiBlockCreateFunc func, void *func_arg1, const char *str, int x1, int y1, short x2, short y2, const char *tip); -uiBut *uiDefBlockButN(uiBlock *block, uiBlockCreateFunc func, void *argN, const char *str, int x1, int y1, short x2, short y2, const char *tip); +uiBut *uiDefBlockBut(uiBlock *block, uiBlockCreateFunc func, void *func_arg1, const char *str, int x, int y, short width, short height, const char *tip); +uiBut *uiDefBlockButN(uiBlock *block, uiBlockCreateFunc func, void *argN, const char *str, int x, int y, short width, short height, const char *tip); -uiBut *uiDefIconBlockBut(uiBlock *block, uiBlockCreateFunc func, void *arg, int retval, int icon, int x1, int y1, short x2, short y2, const char *tip); -uiBut *uiDefIconTextBlockBut(uiBlock *block, uiBlockCreateFunc func, void *arg, int icon, const char *str, int x1, int y1, short x2, short y2, const char *tip); +uiBut *uiDefIconBlockBut(uiBlock *block, uiBlockCreateFunc func, void *arg, int retval, int icon, int x, int y, short width, short height, const char *tip); +uiBut *uiDefIconTextBlockBut(uiBlock *block, uiBlockCreateFunc func, void *arg, int icon, const char *str, int x, int y, short width, short height, const char *tip); -uiBut *uiDefKeyevtButS(uiBlock *block, int retval, const char *str, int x1, int y1, short x2, short y2, short *spoin, const char *tip); -uiBut *uiDefHotKeyevtButS(uiBlock *block, int retval, const char *str, int x1, int y1, short x2, short y2, short *keypoin, short *modkeypoin, const char *tip); +uiBut *uiDefKeyevtButS(uiBlock *block, int retval, const char *str, int x, int y, short width, short height, short *spoin, const char *tip); +uiBut *uiDefHotKeyevtButS(uiBlock *block, int retval, const char *str, int x, int y, short width, short height, short *keypoin, short *modkeypoin, const char *tip); -uiBut *uiDefSearchBut(uiBlock *block, void *arg, int retval, int icon, int maxlen, int x1, int y1, short x2, short y2, float a1, float a2, const char *tip); +uiBut *uiDefSearchBut(uiBlock *block, void *arg, int retval, int icon, int maxlen, int x, int y, short width, short height, float a1, float a2, const char *tip); uiBut *uiDefAutoButR(uiBlock *block, struct PointerRNA *ptr, struct PropertyRNA *prop, int index, const char *name, int icon, int x1, int y1, int x2, int y2); int uiDefAutoButsRNA(uiLayout *layout, struct PointerRNA *ptr, int (*check_prop)(struct PointerRNA *, struct PropertyRNA *), const char label_align); diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c index 55d78ae1307..7185946f4fe 100644 --- a/source/blender/editors/interface/interface.c +++ b/source/blender/editors/interface/interface.c @@ -237,8 +237,9 @@ static void ui_text_bounds_block(uiBlock *block, float offset) bt->rect.xmin = x1addval; bt->rect.xmax = bt->rect.xmin + i + block->bounds; - if (col == lastcol) - bt->rect.xmax = MAX2(bt->rect.xmax, offset + block->minbounds); + if (col == lastcol) { + bt->rect.xmax = maxf(bt->rect.xmax, offset + block->minbounds); + } ui_check_but(bt); // clips text again @@ -262,18 +263,10 @@ void ui_bounds_block(uiBlock *block) } else { - block->rect.xmin = block->rect.ymin = 10000; - block->rect.xmax = block->rect.ymax = -10000; + BLI_rctf_init_minmax(&block->rect); - bt = block->buttons.first; - while (bt) { - if (bt->rect.xmin < block->rect.xmin) block->rect.xmin = bt->rect.xmin; - if (bt->rect.ymin < block->rect.ymin) block->rect.ymin = bt->rect.ymin; - - if (bt->rect.xmax > block->rect.xmax) block->rect.xmax = bt->rect.xmax; - if (bt->rect.ymax > block->rect.ymax) block->rect.ymax = bt->rect.ymax; - - bt = bt->next; + for (bt = block->buttons.first; bt; bt = bt->next) { + BLI_rctf_union(&block->rect, &bt->rect); } block->rect.xmin -= block->bounds; @@ -282,7 +275,7 @@ void ui_bounds_block(uiBlock *block) block->rect.ymax += block->bounds; } - block->rect.xmax = block->rect.xmin + MAX2(block->rect.xmax - block->rect.xmin, block->minbounds); + block->rect.xmax = block->rect.xmin + maxf(block->rect.xmax - block->rect.xmin, block->minbounds); /* hardcoded exception... but that one is annoying with larger safety */ bt = block->buttons.first; @@ -647,8 +640,7 @@ static int ui_but_update_from_old_block(const bContext *C, uiBlock *block, uiBut *butpp = oldbut; /* still stuff needs to be copied */ - oldbut->rect.xmin = but->rect.xmin; oldbut->rect.ymin = but->rect.ymin; - oldbut->rect.xmax = but->rect.xmax; oldbut->rect.ymax = but->rect.ymax; + oldbut->rect = but->rect; oldbut->context = but->context; /* set by Layout */ /* typically the same pointers, but not on undo/redo */ @@ -2543,13 +2535,16 @@ void ui_block_do_align(uiBlock *block) /** * \brief ui_def_but is the function that draws many button types * + * \param x,y The lower left hand corner of the button (X axis) + * \param width,height The size of the button. + * * for float buttons: * - \a a1 Click Step (how much to change the value each click) * - \a a2 Number of decimal point values to display. 0 defaults to 3 (0.000) * 1,2,3, and a maximum of 4, all greater values will be clamped to 4. */ static uiBut *ui_def_but(uiBlock *block, int type, int retval, const char *str, - int x1, int y1, short x2, short y2, + int x, int y, short width, short height, void *poin, float min, float max, float a1, float a2, const char *tip) { uiBut *but; @@ -2580,10 +2575,10 @@ static uiBut *ui_def_but(uiBlock *block, int type, int retval, const char *str, } memcpy(but->str, str, slen + 1); - but->rect.xmin = x1; - but->rect.ymin = y1; - but->rect.xmax = (x1 + x2); - but->rect.ymax = (y1 + y2); + but->rect.xmin = x; + but->rect.ymin = y; + but->rect.xmax = but->rect.xmin + width; + but->rect.ymax = but->rect.ymin + height; but->poin = poin; but->hardmin = but->softmin = min; @@ -2676,7 +2671,7 @@ static uiBut *ui_def_but(uiBlock *block, int type, int retval, const char *str, static uiBut *ui_def_but_rna(uiBlock *block, int type, int retval, const char *str, - int x1, int y1, short x2, short y2, + int x, int y, short width, short height, PointerRNA *ptr, PropertyRNA *prop, int index, float min, float max, float a1, float a2, const char *tip) { @@ -2788,7 +2783,7 @@ static uiBut *ui_def_but_rna(uiBlock *block, int type, int retval, const char *s } /* now create button */ - but = ui_def_but(block, type, retval, str, x1, y1, x2, y2, NULL, min, max, a1, a2, tip); + but = ui_def_but(block, type, retval, str, x, y, width, height, NULL, min, max, a1, a2, tip); but->rnapoin = *ptr; but->rnaprop = prop; @@ -2824,16 +2819,16 @@ static uiBut *ui_def_but_rna(uiBlock *block, int type, int retval, const char *s return but; } -static uiBut *ui_def_but_rna_propname(uiBlock *block, int type, int retval, const char *str, int x1, int y1, short x2, short y2, PointerRNA *ptr, const char *propname, int index, float min, float max, float a1, float a2, const char *tip) +static uiBut *ui_def_but_rna_propname(uiBlock *block, int type, int retval, const char *str, int x, int y, short width, short height, PointerRNA *ptr, const char *propname, int index, float min, float max, float a1, float a2, const char *tip) { PropertyRNA *prop = RNA_struct_find_property(ptr, propname); uiBut *but; if (prop) { - but = ui_def_but_rna(block, type, retval, str, x1, y1, x2, y2, ptr, prop, index, min, max, a1, a2, tip); + but = ui_def_but_rna(block, type, retval, str, x, y, width, height, ptr, prop, index, min, max, a1, a2, tip); } else { - but = ui_def_but(block, type, retval, propname, x1, y1, x2, y2, NULL, min, max, a1, a2, tip); + but = ui_def_but(block, type, retval, propname, x, y, width, height, NULL, min, max, a1, a2, tip); UI_DEF_BUT_RNA_DISABLE(but); } @@ -2841,7 +2836,7 @@ static uiBut *ui_def_but_rna_propname(uiBlock *block, int type, int retval, cons return but; } -static uiBut *ui_def_but_operator_ptr(uiBlock *block, int type, wmOperatorType *ot, int opcontext, const char *str, int x1, int y1, short x2, short y2, const char *tip) +static uiBut *ui_def_but_operator_ptr(uiBlock *block, int type, wmOperatorType *ot, int opcontext, const char *str, int x, int y, short width, short height, const char *tip) { uiBut *but; @@ -2856,7 +2851,7 @@ static uiBut *ui_def_but_operator_ptr(uiBlock *block, int type, wmOperatorType * tip = RNA_struct_ui_description(ot->srna); } - but = ui_def_but(block, type, -1, str, x1, y1, x2, y2, NULL, 0, 0, 0, 0, tip); + but = ui_def_but(block, type, -1, str, x, y, width, height, NULL, 0, 0, 0, 0, tip); but->optype = ot; but->opcontext = opcontext; but->flag &= ~UI_BUT_UNDO; /* no need for ui_but_is_undo(), we never need undo here */ @@ -2871,15 +2866,15 @@ static uiBut *ui_def_but_operator_ptr(uiBlock *block, int type, wmOperatorType * } #if 0 /* UNUSED */ -static uiBut *UNUSED_FUNCTION(ui_def_but_operator) (uiBlock * block, int type, const char *opname, int opcontext, const char *str, int x1, int y1, short x2, short y2, const char *tip) +static uiBut *UNUSED_FUNCTION(ui_def_but_operator) (uiBlock * block, int type, const char *opname, int opcontext, const char *str, int x, int y, short width, short height, const char *tip) { wmOperatorType *ot = WM_operatortype_find(opname, 0); if (str == NULL && ot == NULL) str = opname; - return ui_def_but_operator_ptr(block, type, ot, opcontext, str, x1, y1, x2, y2, tip); + return ui_def_but_operator_ptr(block, type, ot, opcontext, str, x, y, width, height, tip); } #endif -static uiBut *ui_def_but_operator_text(uiBlock *block, int type, const char *opname, int opcontext, const char *str, int x1, int y1, short x2, short y2, void *poin, float min, float max, float a1, float a2, const char *tip) +static uiBut *ui_def_but_operator_text(uiBlock *block, int type, const char *opname, int opcontext, const char *str, int x, int y, short width, short height, void *poin, float min, float max, float a1, float a2, const char *tip) { uiBut *but; wmOperatorType *ot; @@ -2895,7 +2890,7 @@ static uiBut *ui_def_but_operator_text(uiBlock *block, int type, const char *opn tip = ot->description; } - but = ui_def_but(block, type, -1, str, x1, y1, x2, y2, poin, min, max, a1, a2, tip); + but = ui_def_but(block, type, -1, str, x, y, width, height, poin, min, max, a1, a2, tip); but->optype = ot; but->opcontext = opcontext; but->flag &= ~UI_BUT_UNDO; /* no need for ui_but_is_undo(), we never need undo here */ @@ -2909,9 +2904,9 @@ static uiBut *ui_def_but_operator_text(uiBlock *block, int type, const char *opn return but; } -uiBut *uiDefBut(uiBlock *block, int type, int retval, const char *str, int x1, int y1, short x2, short y2, void *poin, float min, float max, float a1, float a2, const char *tip) +uiBut *uiDefBut(uiBlock *block, int type, int retval, const char *str, int x, int y, short width, short height, void *poin, float min, float max, float a1, float a2, const char *tip) { - uiBut *but = ui_def_but(block, type, retval, str, x1, y1, x2, y2, poin, min, max, a1, a2, tip); + uiBut *but = ui_def_but(block, type, retval, str, x, y, width, height, poin, min, max, a1, a2, tip); ui_check_but(but); @@ -3030,241 +3025,241 @@ static void ui_check_but_and_iconize(uiBut *but, int icon) ui_check_but(but); } -static uiBut *uiDefButBit(uiBlock *block, int type, int bit, int retval, const char *str, int x1, int y1, short x2, short y2, void *poin, float min, float max, float a1, float a2, const char *tip) +static uiBut *uiDefButBit(uiBlock *block, int type, int bit, int retval, const char *str, int x, int y, short width, short height, void *poin, float min, float max, float a1, float a2, const char *tip) { int bitIdx = findBitIndex(bit); if (bitIdx == -1) { return NULL; } else { - return uiDefBut(block, type | BIT | bitIdx, retval, str, x1, y1, x2, y2, poin, min, max, a1, a2, tip); + return uiDefBut(block, type | BIT | bitIdx, retval, str, x, y, width, height, poin, min, max, a1, a2, tip); } } -uiBut *uiDefButF(uiBlock *block, int type, int retval, const char *str, int x1, int y1, short x2, short y2, float *poin, float min, float max, float a1, float a2, const char *tip) +uiBut *uiDefButF(uiBlock *block, int type, int retval, const char *str, int x, int y, short width, short height, float *poin, float min, float max, float a1, float a2, const char *tip) { - return uiDefBut(block, type | FLO, retval, str, x1, y1, x2, y2, (void *) poin, min, max, a1, a2, tip); + return uiDefBut(block, type | FLO, retval, str, x, y, width, height, (void *) poin, min, max, a1, a2, tip); } -uiBut *uiDefButBitF(uiBlock *block, int type, int bit, int retval, const char *str, int x1, int y1, short x2, short y2, float *poin, float min, float max, float a1, float a2, const char *tip) +uiBut *uiDefButBitF(uiBlock *block, int type, int bit, int retval, const char *str, int x, int y, short width, short height, float *poin, float min, float max, float a1, float a2, const char *tip) { - return uiDefButBit(block, type | FLO, bit, retval, str, x1, y1, x2, y2, (void *) poin, min, max, a1, a2, tip); + return uiDefButBit(block, type | FLO, bit, retval, str, x, y, width, height, (void *) poin, min, max, a1, a2, tip); } -uiBut *uiDefButI(uiBlock *block, int type, int retval, const char *str, int x1, int y1, short x2, short y2, int *poin, float min, float max, float a1, float a2, const char *tip) +uiBut *uiDefButI(uiBlock *block, int type, int retval, const char *str, int x, int y, short width, short height, int *poin, float min, float max, float a1, float a2, const char *tip) { - return uiDefBut(block, type | INT, retval, str, x1, y1, x2, y2, (void *) poin, min, max, a1, a2, tip); + return uiDefBut(block, type | INT, retval, str, x, y, width, height, (void *) poin, min, max, a1, a2, tip); } -uiBut *uiDefButBitI(uiBlock *block, int type, int bit, int retval, const char *str, int x1, int y1, short x2, short y2, int *poin, float min, float max, float a1, float a2, const char *tip) +uiBut *uiDefButBitI(uiBlock *block, int type, int bit, int retval, const char *str, int x, int y, short width, short height, int *poin, float min, float max, float a1, float a2, const char *tip) { - return uiDefButBit(block, type | INT, bit, retval, str, x1, y1, x2, y2, (void *) poin, min, max, a1, a2, tip); + return uiDefButBit(block, type | INT, bit, retval, str, x, y, width, height, (void *) poin, min, max, a1, a2, tip); } -uiBut *uiDefButS(uiBlock *block, int type, int retval, const char *str, int x1, int y1, short x2, short y2, short *poin, float min, float max, float a1, float a2, const char *tip) +uiBut *uiDefButS(uiBlock *block, int type, int retval, const char *str, int x, int y, short width, short height, short *poin, float min, float max, float a1, float a2, const char *tip) { - return uiDefBut(block, type | SHO, retval, str, x1, y1, x2, y2, (void *) poin, min, max, a1, a2, tip); + return uiDefBut(block, type | SHO, retval, str, x, y, width, height, (void *) poin, min, max, a1, a2, tip); } -uiBut *uiDefButBitS(uiBlock *block, int type, int bit, int retval, const char *str, int x1, int y1, short x2, short y2, short *poin, float min, float max, float a1, float a2, const char *tip) +uiBut *uiDefButBitS(uiBlock *block, int type, int bit, int retval, const char *str, int x, int y, short width, short height, short *poin, float min, float max, float a1, float a2, const char *tip) { - return uiDefButBit(block, type | SHO, bit, retval, str, x1, y1, x2, y2, (void *) poin, min, max, a1, a2, tip); + return uiDefButBit(block, type | SHO, bit, retval, str, x, y, width, height, (void *) poin, min, max, a1, a2, tip); } -uiBut *uiDefButC(uiBlock *block, int type, int retval, const char *str, int x1, int y1, short x2, short y2, char *poin, float min, float max, float a1, float a2, const char *tip) +uiBut *uiDefButC(uiBlock *block, int type, int retval, const char *str, int x, int y, short width, short height, char *poin, float min, float max, float a1, float a2, const char *tip) { - return uiDefBut(block, type | CHA, retval, str, x1, y1, x2, y2, (void *) poin, min, max, a1, a2, tip); + return uiDefBut(block, type | CHA, retval, str, x, y, width, height, (void *) poin, min, max, a1, a2, tip); } -uiBut *uiDefButBitC(uiBlock *block, int type, int bit, int retval, const char *str, int x1, int y1, short x2, short y2, char *poin, float min, float max, float a1, float a2, const char *tip) +uiBut *uiDefButBitC(uiBlock *block, int type, int bit, int retval, const char *str, int x, int y, short width, short height, char *poin, float min, float max, float a1, float a2, const char *tip) { - return uiDefButBit(block, type | CHA, bit, retval, str, x1, y1, x2, y2, (void *) poin, min, max, a1, a2, tip); + return uiDefButBit(block, type | CHA, bit, retval, str, x, y, width, height, (void *) poin, min, max, a1, a2, tip); } -uiBut *uiDefButR(uiBlock *block, int type, int retval, const char *str, int x1, int y1, short x2, short y2, PointerRNA *ptr, const char *propname, int index, float min, float max, float a1, float a2, const char *tip) +uiBut *uiDefButR(uiBlock *block, int type, int retval, const char *str, int x, int y, short width, short height, PointerRNA *ptr, const char *propname, int index, float min, float max, float a1, float a2, const char *tip) { uiBut *but; - but = ui_def_but_rna_propname(block, type, retval, str, x1, y1, x2, y2, ptr, propname, index, min, max, a1, a2, tip); + but = ui_def_but_rna_propname(block, type, retval, str, x, y, width, height, ptr, propname, index, min, max, a1, a2, tip); ui_check_but(but); return but; } -uiBut *uiDefButR_prop(uiBlock *block, int type, int retval, const char *str, int x1, int y1, short x2, short y2, PointerRNA *ptr, PropertyRNA *prop, int index, float min, float max, float a1, float a2, const char *tip) +uiBut *uiDefButR_prop(uiBlock *block, int type, int retval, const char *str, int x, int y, short width, short height, PointerRNA *ptr, PropertyRNA *prop, int index, float min, float max, float a1, float a2, const char *tip) { uiBut *but; - but = ui_def_but_rna(block, type, retval, str, x1, y1, x2, y2, ptr, prop, index, min, max, a1, a2, tip); + but = ui_def_but_rna(block, type, retval, str, x, y, width, height, ptr, prop, index, min, max, a1, a2, tip); ui_check_but(but); return but; } -uiBut *uiDefButO_ptr(uiBlock *block, int type, wmOperatorType *ot, int opcontext, const char *str, int x1, int y1, short x2, short y2, const char *tip) +uiBut *uiDefButO_ptr(uiBlock *block, int type, wmOperatorType *ot, int opcontext, const char *str, int x, int y, short width, short height, const char *tip) { uiBut *but; - but = ui_def_but_operator_ptr(block, type, ot, opcontext, str, x1, y1, x2, y2, tip); + but = ui_def_but_operator_ptr(block, type, ot, opcontext, str, x, y, width, height, tip); ui_check_but(but); return but; } -uiBut *uiDefButO(uiBlock *block, int type, const char *opname, int opcontext, const char *str, int x1, int y1, short x2, short y2, const char *tip) +uiBut *uiDefButO(uiBlock *block, int type, const char *opname, int opcontext, const char *str, int x, int y, short width, short height, const char *tip) { wmOperatorType *ot = WM_operatortype_find(opname, 0); if (str == NULL && ot == NULL) str = opname; - return uiDefButO_ptr(block, type, ot, opcontext, str, x1, y1, x2, y2, tip); + return uiDefButO_ptr(block, type, ot, opcontext, str, x, y, width, height, tip); } -uiBut *uiDefButTextO(uiBlock *block, int type, const char *opname, int opcontext, const char *str, int x1, int y1, short x2, short y2, void *poin, float min, float max, float a1, float a2, const char *tip) +uiBut *uiDefButTextO(uiBlock *block, int type, const char *opname, int opcontext, const char *str, int x, int y, short width, short height, void *poin, float min, float max, float a1, float a2, const char *tip) { - uiBut *but = ui_def_but_operator_text(block, type, opname, opcontext, str, x1, y1, x2, y2, poin, min, max, a1, a2, tip); + uiBut *but = ui_def_but_operator_text(block, type, opname, opcontext, str, x, y, width, height, poin, min, max, a1, a2, tip); ui_check_but(but); return but; } /* if a1==1.0 then a2 is an extra icon blending factor (alpha 0.0 - 1.0) */ -uiBut *uiDefIconBut(uiBlock *block, int type, int retval, int icon, int x1, int y1, short x2, short y2, void *poin, float min, float max, float a1, float a2, const char *tip) +uiBut *uiDefIconBut(uiBlock *block, int type, int retval, int icon, int x, int y, short width, short height, void *poin, float min, float max, float a1, float a2, const char *tip) { - uiBut *but = ui_def_but(block, type, retval, "", x1, y1, x2, y2, poin, min, max, a1, a2, tip); + uiBut *but = ui_def_but(block, type, retval, "", x, y, width, height, poin, min, max, a1, a2, tip); ui_check_but_and_iconize(but, icon); return but; } -static uiBut *uiDefIconButBit(uiBlock *block, int type, int bit, int retval, int icon, int x1, int y1, short x2, short y2, void *poin, float min, float max, float a1, float a2, const char *tip) +static uiBut *uiDefIconButBit(uiBlock *block, int type, int bit, int retval, int icon, int x, int y, short width, short height, void *poin, float min, float max, float a1, float a2, const char *tip) { int bitIdx = findBitIndex(bit); if (bitIdx == -1) { return NULL; } else { - return uiDefIconBut(block, type | BIT | bitIdx, retval, icon, x1, y1, x2, y2, poin, min, max, a1, a2, tip); + return uiDefIconBut(block, type | BIT | bitIdx, retval, icon, x, y, width, height, poin, min, max, a1, a2, tip); } } -uiBut *uiDefIconButF(uiBlock *block, int type, int retval, int icon, int x1, int y1, short x2, short y2, float *poin, float min, float max, float a1, float a2, const char *tip) +uiBut *uiDefIconButF(uiBlock *block, int type, int retval, int icon, int x, int y, short width, short height, float *poin, float min, float max, float a1, float a2, const char *tip) { - return uiDefIconBut(block, type | FLO, retval, icon, x1, y1, x2, y2, (void *) poin, min, max, a1, a2, tip); + return uiDefIconBut(block, type | FLO, retval, icon, x, y, width, height, (void *) poin, min, max, a1, a2, tip); } -uiBut *uiDefIconButBitF(uiBlock *block, int type, int bit, int retval, int icon, int x1, int y1, short x2, short y2, float *poin, float min, float max, float a1, float a2, const char *tip) +uiBut *uiDefIconButBitF(uiBlock *block, int type, int bit, int retval, int icon, int x, int y, short width, short height, float *poin, float min, float max, float a1, float a2, const char *tip) { - return uiDefIconButBit(block, type | FLO, bit, retval, icon, x1, y1, x2, y2, (void *) poin, min, max, a1, a2, tip); + return uiDefIconButBit(block, type | FLO, bit, retval, icon, x, y, width, height, (void *) poin, min, max, a1, a2, tip); } -uiBut *uiDefIconButI(uiBlock *block, int type, int retval, int icon, int x1, int y1, short x2, short y2, int *poin, float min, float max, float a1, float a2, const char *tip) +uiBut *uiDefIconButI(uiBlock *block, int type, int retval, int icon, int x, int y, short width, short height, int *poin, float min, float max, float a1, float a2, const char *tip) { - return uiDefIconBut(block, type | INT, retval, icon, x1, y1, x2, y2, (void *) poin, min, max, a1, a2, tip); + return uiDefIconBut(block, type | INT, retval, icon, x, y, width, height, (void *) poin, min, max, a1, a2, tip); } -uiBut *uiDefIconButBitI(uiBlock *block, int type, int bit, int retval, int icon, int x1, int y1, short x2, short y2, int *poin, float min, float max, float a1, float a2, const char *tip) +uiBut *uiDefIconButBitI(uiBlock *block, int type, int bit, int retval, int icon, int x, int y, short width, short height, int *poin, float min, float max, float a1, float a2, const char *tip) { - return uiDefIconButBit(block, type | INT, bit, retval, icon, x1, y1, x2, y2, (void *) poin, min, max, a1, a2, tip); + return uiDefIconButBit(block, type | INT, bit, retval, icon, x, y, width, height, (void *) poin, min, max, a1, a2, tip); } -uiBut *uiDefIconButS(uiBlock *block, int type, int retval, int icon, int x1, int y1, short x2, short y2, short *poin, float min, float max, float a1, float a2, const char *tip) +uiBut *uiDefIconButS(uiBlock *block, int type, int retval, int icon, int x, int y, short width, short height, short *poin, float min, float max, float a1, float a2, const char *tip) { - return uiDefIconBut(block, type | SHO, retval, icon, x1, y1, x2, y2, (void *) poin, min, max, a1, a2, tip); + return uiDefIconBut(block, type | SHO, retval, icon, x, y, width, height, (void *) poin, min, max, a1, a2, tip); } -uiBut *uiDefIconButBitS(uiBlock *block, int type, int bit, int retval, int icon, int x1, int y1, short x2, short y2, short *poin, float min, float max, float a1, float a2, const char *tip) +uiBut *uiDefIconButBitS(uiBlock *block, int type, int bit, int retval, int icon, int x, int y, short width, short height, short *poin, float min, float max, float a1, float a2, const char *tip) { - return uiDefIconButBit(block, type | SHO, bit, retval, icon, x1, y1, x2, y2, (void *) poin, min, max, a1, a2, tip); + return uiDefIconButBit(block, type | SHO, bit, retval, icon, x, y, width, height, (void *) poin, min, max, a1, a2, tip); } -uiBut *uiDefIconButC(uiBlock *block, int type, int retval, int icon, int x1, int y1, short x2, short y2, char *poin, float min, float max, float a1, float a2, const char *tip) +uiBut *uiDefIconButC(uiBlock *block, int type, int retval, int icon, int x, int y, short width, short height, char *poin, float min, float max, float a1, float a2, const char *tip) { - return uiDefIconBut(block, type | CHA, retval, icon, x1, y1, x2, y2, (void *) poin, min, max, a1, a2, tip); + return uiDefIconBut(block, type | CHA, retval, icon, x, y, width, height, (void *) poin, min, max, a1, a2, tip); } -uiBut *uiDefIconButBitC(uiBlock *block, int type, int bit, int retval, int icon, int x1, int y1, short x2, short y2, char *poin, float min, float max, float a1, float a2, const char *tip) +uiBut *uiDefIconButBitC(uiBlock *block, int type, int bit, int retval, int icon, int x, int y, short width, short height, char *poin, float min, float max, float a1, float a2, const char *tip) { - return uiDefIconButBit(block, type | CHA, bit, retval, icon, x1, y1, x2, y2, (void *) poin, min, max, a1, a2, tip); + return uiDefIconButBit(block, type | CHA, bit, retval, icon, x, y, width, height, (void *) poin, min, max, a1, a2, tip); } -uiBut *uiDefIconButR(uiBlock *block, int type, int retval, int icon, int x1, int y1, short x2, short y2, PointerRNA *ptr, const char *propname, int index, float min, float max, float a1, float a2, const char *tip) +uiBut *uiDefIconButR(uiBlock *block, int type, int retval, int icon, int x, int y, short width, short height, PointerRNA *ptr, const char *propname, int index, float min, float max, float a1, float a2, const char *tip) { uiBut *but; - but = ui_def_but_rna_propname(block, type, retval, "", x1, y1, x2, y2, ptr, propname, index, min, max, a1, a2, tip); + but = ui_def_but_rna_propname(block, type, retval, "", x, y, width, height, ptr, propname, index, min, max, a1, a2, tip); ui_check_but_and_iconize(but, icon); return but; } -uiBut *uiDefIconButR_prop(uiBlock *block, int type, int retval, int icon, int x1, int y1, short x2, short y2, PointerRNA *ptr, PropertyRNA *prop, int index, float min, float max, float a1, float a2, const char *tip) +uiBut *uiDefIconButR_prop(uiBlock *block, int type, int retval, int icon, int x, int y, short width, short height, PointerRNA *ptr, PropertyRNA *prop, int index, float min, float max, float a1, float a2, const char *tip) { uiBut *but; - but = ui_def_but_rna(block, type, retval, "", x1, y1, x2, y2, ptr, prop, index, min, max, a1, a2, tip); + but = ui_def_but_rna(block, type, retval, "", x, y, width, height, ptr, prop, index, min, max, a1, a2, tip); ui_check_but_and_iconize(but, icon); return but; } -uiBut *uiDefIconButO_ptr(uiBlock *block, int type, wmOperatorType *ot, int opcontext, int icon, int x1, int y1, short x2, short y2, const char *tip) +uiBut *uiDefIconButO_ptr(uiBlock *block, int type, wmOperatorType *ot, int opcontext, int icon, int x, int y, short width, short height, const char *tip) { uiBut *but; - but = ui_def_but_operator_ptr(block, type, ot, opcontext, "", x1, y1, x2, y2, tip); + but = ui_def_but_operator_ptr(block, type, ot, opcontext, "", x, y, width, height, tip); ui_check_but_and_iconize(but, icon); return but; } -uiBut *uiDefIconButO(uiBlock *block, int type, const char *opname, int opcontext, int icon, int x1, int y1, short x2, short y2, const char *tip) +uiBut *uiDefIconButO(uiBlock *block, int type, const char *opname, int opcontext, int icon, int x, int y, short width, short height, const char *tip) { wmOperatorType *ot = WM_operatortype_find(opname, 0); - return uiDefIconButO_ptr(block, type, ot, opcontext, icon, x1, y1, x2, y2, tip); + return uiDefIconButO_ptr(block, type, ot, opcontext, icon, x, y, width, height, tip); } /* Button containing both string label and icon */ -uiBut *uiDefIconTextBut(uiBlock *block, int type, int retval, int icon, const char *str, int x1, int y1, short x2, short y2, void *poin, float min, float max, float a1, float a2, const char *tip) +uiBut *uiDefIconTextBut(uiBlock *block, int type, int retval, int icon, const char *str, int x, int y, short width, short height, void *poin, float min, float max, float a1, float a2, const char *tip) { - uiBut *but = ui_def_but(block, type, retval, str, x1, y1, x2, y2, poin, min, max, a1, a2, tip); + uiBut *but = ui_def_but(block, type, retval, str, x, y, width, height, poin, min, max, a1, a2, tip); ui_check_but_and_iconize(but, icon); but->flag |= UI_ICON_LEFT; return but; } -static uiBut *uiDefIconTextButBit(uiBlock *block, int type, int bit, int retval, int icon, const char *str, int x1, int y1, short x2, short y2, void *poin, float min, float max, float a1, float a2, const char *tip) +static uiBut *uiDefIconTextButBit(uiBlock *block, int type, int bit, int retval, int icon, const char *str, int x, int y, short width, short height, void *poin, float min, float max, float a1, float a2, const char *tip) { int bitIdx = findBitIndex(bit); if (bitIdx == -1) { return NULL; } else { - return uiDefIconTextBut(block, type | BIT | bitIdx, retval, icon, str, x1, y1, x2, y2, poin, min, max, a1, a2, tip); + return uiDefIconTextBut(block, type | BIT | bitIdx, retval, icon, str, x, y, width, height, poin, min, max, a1, a2, tip); } } -uiBut *uiDefIconTextButF(uiBlock *block, int type, int retval, int icon, const char *str, int x1, int y1, short x2, short y2, float *poin, float min, float max, float a1, float a2, const char *tip) +uiBut *uiDefIconTextButF(uiBlock *block, int type, int retval, int icon, const char *str, int x, int y, short width, short height, float *poin, float min, float max, float a1, float a2, const char *tip) { - return uiDefIconTextBut(block, type | FLO, retval, icon, str, x1, y1, x2, y2, (void *) poin, min, max, a1, a2, tip); + return uiDefIconTextBut(block, type | FLO, retval, icon, str, x, y, width, height, (void *) poin, min, max, a1, a2, tip); } -uiBut *uiDefIconTextButBitF(uiBlock *block, int type, int bit, int retval, int icon, const char *str, int x1, int y1, short x2, short y2, float *poin, float min, float max, float a1, float a2, const char *tip) +uiBut *uiDefIconTextButBitF(uiBlock *block, int type, int bit, int retval, int icon, const char *str, int x, int y, short width, short height, float *poin, float min, float max, float a1, float a2, const char *tip) { - return uiDefIconTextButBit(block, type | FLO, bit, retval, icon, str, x1, y1, x2, y2, (void *) poin, min, max, a1, a2, tip); + return uiDefIconTextButBit(block, type | FLO, bit, retval, icon, str, x, y, width, height, (void *) poin, min, max, a1, a2, tip); } -uiBut *uiDefIconTextButI(uiBlock *block, int type, int retval, int icon, const char *str, int x1, int y1, short x2, short y2, int *poin, float min, float max, float a1, float a2, const char *tip) +uiBut *uiDefIconTextButI(uiBlock *block, int type, int retval, int icon, const char *str, int x, int y, short width, short height, int *poin, float min, float max, float a1, float a2, const char *tip) { - return uiDefIconTextBut(block, type | INT, retval, icon, str, x1, y1, x2, y2, (void *) poin, min, max, a1, a2, tip); + return uiDefIconTextBut(block, type | INT, retval, icon, str, x, y, width, height, (void *) poin, min, max, a1, a2, tip); } -uiBut *uiDefIconTextButBitI(uiBlock *block, int type, int bit, int retval, int icon, const char *str, int x1, int y1, short x2, short y2, int *poin, float min, float max, float a1, float a2, const char *tip) +uiBut *uiDefIconTextButBitI(uiBlock *block, int type, int bit, int retval, int icon, const char *str, int x, int y, short width, short height, int *poin, float min, float max, float a1, float a2, const char *tip) { - return uiDefIconTextButBit(block, type | INT, bit, retval, icon, str, x1, y1, x2, y2, (void *) poin, min, max, a1, a2, tip); + return uiDefIconTextButBit(block, type | INT, bit, retval, icon, str, x, y, width, height, (void *) poin, min, max, a1, a2, tip); } -uiBut *uiDefIconTextButS(uiBlock *block, int type, int retval, int icon, const char *str, int x1, int y1, short x2, short y2, short *poin, float min, float max, float a1, float a2, const char *tip) +uiBut *uiDefIconTextButS(uiBlock *block, int type, int retval, int icon, const char *str, int x, int y, short width, short height, short *poin, float min, float max, float a1, float a2, const char *tip) { - return uiDefIconTextBut(block, type | SHO, retval, icon, str, x1, y1, x2, y2, (void *) poin, min, max, a1, a2, tip); + return uiDefIconTextBut(block, type | SHO, retval, icon, str, x, y, width, height, (void *) poin, min, max, a1, a2, tip); } -uiBut *uiDefIconTextButBitS(uiBlock *block, int type, int bit, int retval, int icon, const char *str, int x1, int y1, short x2, short y2, short *poin, float min, float max, float a1, float a2, const char *tip) +uiBut *uiDefIconTextButBitS(uiBlock *block, int type, int bit, int retval, int icon, const char *str, int x, int y, short width, short height, short *poin, float min, float max, float a1, float a2, const char *tip) { - return uiDefIconTextButBit(block, type | SHO, bit, retval, icon, str, x1, y1, x2, y2, (void *) poin, min, max, a1, a2, tip); + return uiDefIconTextButBit(block, type | SHO, bit, retval, icon, str, x, y, width, height, (void *) poin, min, max, a1, a2, tip); } -uiBut *uiDefIconTextButC(uiBlock *block, int type, int retval, int icon, const char *str, int x1, int y1, short x2, short y2, char *poin, float min, float max, float a1, float a2, const char *tip) +uiBut *uiDefIconTextButC(uiBlock *block, int type, int retval, int icon, const char *str, int x, int y, short width, short height, char *poin, float min, float max, float a1, float a2, const char *tip) { - return uiDefIconTextBut(block, type | CHA, retval, icon, str, x1, y1, x2, y2, (void *) poin, min, max, a1, a2, tip); + return uiDefIconTextBut(block, type | CHA, retval, icon, str, x, y, width, height, (void *) poin, min, max, a1, a2, tip); } -uiBut *uiDefIconTextButBitC(uiBlock *block, int type, int bit, int retval, int icon, const char *str, int x1, int y1, short x2, short y2, char *poin, float min, float max, float a1, float a2, const char *tip) +uiBut *uiDefIconTextButBitC(uiBlock *block, int type, int bit, int retval, int icon, const char *str, int x, int y, short width, short height, char *poin, float min, float max, float a1, float a2, const char *tip) { - return uiDefIconTextButBit(block, type | CHA, bit, retval, icon, str, x1, y1, x2, y2, (void *) poin, min, max, a1, a2, tip); + return uiDefIconTextButBit(block, type | CHA, bit, retval, icon, str, x, y, width, height, (void *) poin, min, max, a1, a2, tip); } -uiBut *uiDefIconTextButR(uiBlock *block, int type, int retval, int icon, const char *str, int x1, int y1, short x2, short y2, PointerRNA *ptr, const char *propname, int index, float min, float max, float a1, float a2, const char *tip) +uiBut *uiDefIconTextButR(uiBlock *block, int type, int retval, int icon, const char *str, int x, int y, short width, short height, PointerRNA *ptr, const char *propname, int index, float min, float max, float a1, float a2, const char *tip) { uiBut *but; - but = ui_def_but_rna_propname(block, type, retval, str, x1, y1, x2, y2, ptr, propname, index, min, max, a1, a2, tip); + but = ui_def_but_rna_propname(block, type, retval, str, x, y, width, height, ptr, propname, index, min, max, a1, a2, tip); ui_check_but_and_iconize(but, icon); but->flag |= UI_ICON_LEFT; return but; } -uiBut *uiDefIconTextButR_prop(uiBlock *block, int type, int retval, int icon, const char *str, int x1, int y1, short x2, short y2, PointerRNA *ptr, PropertyRNA *prop, int index, float min, float max, float a1, float a2, const char *tip) +uiBut *uiDefIconTextButR_prop(uiBlock *block, int type, int retval, int icon, const char *str, int x, int y, short width, short height, PointerRNA *ptr, PropertyRNA *prop, int index, float min, float max, float a1, float a2, const char *tip) { uiBut *but; - but = ui_def_but_rna(block, type, retval, str, x1, y1, x2, y2, ptr, prop, index, min, max, a1, a2, tip); + but = ui_def_but_rna(block, type, retval, str, x, y, width, height, ptr, prop, index, min, max, a1, a2, tip); ui_check_but_and_iconize(but, icon); but->flag |= UI_ICON_LEFT; return but; } -uiBut *uiDefIconTextButO_ptr(uiBlock *block, int type, wmOperatorType *ot, int opcontext, int icon, const char *str, int x1, int y1, short x2, short y2, const char *tip) +uiBut *uiDefIconTextButO_ptr(uiBlock *block, int type, wmOperatorType *ot, int opcontext, int icon, const char *str, int x, int y, short width, short height, const char *tip) { uiBut *but; - but = ui_def_but_operator_ptr(block, type, ot, opcontext, str, x1, y1, x2, y2, tip); + but = ui_def_but_operator_ptr(block, type, ot, opcontext, str, x, y, width, height, tip); ui_check_but_and_iconize(but, icon); but->flag |= UI_ICON_LEFT; return but; } -uiBut *uiDefIconTextButO(uiBlock *block, int type, const char *opname, int opcontext, int icon, const char *str, int x1, int y1, short x2, short y2, const char *tip) +uiBut *uiDefIconTextButO(uiBlock *block, int type, const char *opname, int opcontext, int icon, const char *str, int x, int y, short width, short height, const char *tip) { wmOperatorType *ot = WM_operatortype_find(opname, 0); - return uiDefIconTextButO_ptr(block, type, ot, opcontext, icon, str, x1, y1, x2, y2, tip); + return uiDefIconTextButO_ptr(block, type, ot, opcontext, icon, str, x, y, width, height, tip); } /* END Button containing both string label and icon */ @@ -3516,9 +3511,9 @@ void uiButSetCompleteFunc(uiBut *but, uiButCompleteFunc func, void *arg) but->autofunc_arg = arg; } -uiBut *uiDefIDPoinBut(uiBlock *block, uiIDPoinFuncFP func, short blocktype, int retval, const char *str, int x1, int y1, short x2, short y2, void *idpp, const char *tip) +uiBut *uiDefIDPoinBut(uiBlock *block, uiIDPoinFuncFP func, short blocktype, int retval, const char *str, int x, int y, short width, short height, void *idpp, const char *tip) { - uiBut *but = ui_def_but(block, IDPOIN, retval, str, x1, y1, x2, y2, NULL, 0.0, 0.0, 0.0, 0.0, tip); + uiBut *but = ui_def_but(block, IDPOIN, retval, str, x, y, width, height, NULL, 0.0, 0.0, 0.0, 0.0, tip); but->idpoin_func = func; but->idpoin_idpp = (ID **) idpp; ui_check_but(but); @@ -3529,17 +3524,17 @@ uiBut *uiDefIDPoinBut(uiBlock *block, uiIDPoinFuncFP func, short blocktype, int return but; } -uiBut *uiDefBlockBut(uiBlock *block, uiBlockCreateFunc func, void *arg, const char *str, int x1, int y1, short x2, short y2, const char *tip) +uiBut *uiDefBlockBut(uiBlock *block, uiBlockCreateFunc func, void *arg, const char *str, int x, int y, short width, short height, const char *tip) { - uiBut *but = ui_def_but(block, BLOCK, 0, str, x1, y1, x2, y2, arg, 0.0, 0.0, 0.0, 0.0, tip); + uiBut *but = ui_def_but(block, BLOCK, 0, str, x, y, width, height, arg, 0.0, 0.0, 0.0, 0.0, tip); but->block_create_func = func; ui_check_but(but); return but; } -uiBut *uiDefBlockButN(uiBlock *block, uiBlockCreateFunc func, void *argN, const char *str, int x1, int y1, short x2, short y2, const char *tip) +uiBut *uiDefBlockButN(uiBlock *block, uiBlockCreateFunc func, void *argN, const char *str, int x, int y, short width, short height, const char *tip) { - uiBut *but = ui_def_but(block, BLOCK, 0, str, x1, y1, x2, y2, NULL, 0.0, 0.0, 0.0, 0.0, tip); + uiBut *but = ui_def_but(block, BLOCK, 0, str, x, y, width, height, NULL, 0.0, 0.0, 0.0, 0.0, tip); but->block_create_func = func; if (but->func_argN) { MEM_freeN(but->func_argN); @@ -3550,25 +3545,25 @@ uiBut *uiDefBlockButN(uiBlock *block, uiBlockCreateFunc func, void *argN, const } -uiBut *uiDefPulldownBut(uiBlock *block, uiBlockCreateFunc func, void *arg, const char *str, int x1, int y1, short x2, short y2, const char *tip) +uiBut *uiDefPulldownBut(uiBlock *block, uiBlockCreateFunc func, void *arg, const char *str, int x, int y, short width, short height, const char *tip) { - uiBut *but = ui_def_but(block, PULLDOWN, 0, str, x1, y1, x2, y2, arg, 0.0, 0.0, 0.0, 0.0, tip); + uiBut *but = ui_def_but(block, PULLDOWN, 0, str, x, y, width, height, arg, 0.0, 0.0, 0.0, 0.0, tip); but->block_create_func = func; ui_check_but(but); return but; } -uiBut *uiDefMenuBut(uiBlock *block, uiMenuCreateFunc func, void *arg, const char *str, int x1, int y1, short x2, short y2, const char *tip) +uiBut *uiDefMenuBut(uiBlock *block, uiMenuCreateFunc func, void *arg, const char *str, int x, int y, short width, short height, const char *tip) { - uiBut *but = ui_def_but(block, PULLDOWN, 0, str, x1, y1, x2, y2, arg, 0.0, 0.0, 0.0, 0.0, tip); + uiBut *but = ui_def_but(block, PULLDOWN, 0, str, x, y, width, height, arg, 0.0, 0.0, 0.0, 0.0, tip); but->menu_create_func = func; ui_check_but(but); return but; } -uiBut *uiDefIconTextMenuBut(uiBlock *block, uiMenuCreateFunc func, void *arg, int icon, const char *str, int x1, int y1, short x2, short y2, const char *tip) +uiBut *uiDefIconTextMenuBut(uiBlock *block, uiMenuCreateFunc func, void *arg, int icon, const char *str, int x, int y, short width, short height, const char *tip) { - uiBut *but = ui_def_but(block, PULLDOWN, 0, str, x1, y1, x2, y2, arg, 0.0, 0.0, 0.0, 0.0, tip); + uiBut *but = ui_def_but(block, PULLDOWN, 0, str, x, y, width, height, arg, 0.0, 0.0, 0.0, 0.0, tip); but->icon = (BIFIconID) icon; but->flag |= UI_HAS_ICON; @@ -3582,9 +3577,9 @@ uiBut *uiDefIconTextMenuBut(uiBlock *block, uiMenuCreateFunc func, void *arg, in return but; } -uiBut *uiDefIconMenuBut(uiBlock *block, uiMenuCreateFunc func, void *arg, int icon, int x1, int y1, short x2, short y2, const char *tip) +uiBut *uiDefIconMenuBut(uiBlock *block, uiMenuCreateFunc func, void *arg, int icon, int x, int y, short width, short height, const char *tip) { - uiBut *but = ui_def_but(block, PULLDOWN, 0, "", x1, y1, x2, y2, arg, 0.0, 0.0, 0.0, 0.0, tip); + uiBut *but = ui_def_but(block, PULLDOWN, 0, "", x, y, width, height, arg, 0.0, 0.0, 0.0, 0.0, tip); but->icon = (BIFIconID) icon; but->flag |= UI_HAS_ICON; @@ -3597,9 +3592,9 @@ uiBut *uiDefIconMenuBut(uiBlock *block, uiMenuCreateFunc func, void *arg, int ic } /* Block button containing both string label and icon */ -uiBut *uiDefIconTextBlockBut(uiBlock *block, uiBlockCreateFunc func, void *arg, int icon, const char *str, int x1, int y1, short x2, short y2, const char *tip) +uiBut *uiDefIconTextBlockBut(uiBlock *block, uiBlockCreateFunc func, void *arg, int icon, const char *str, int x, int y, short width, short height, const char *tip) { - uiBut *but = ui_def_but(block, BLOCK, 0, str, x1, y1, x2, y2, arg, 0.0, 0.0, 0.0, 0.0, tip); + uiBut *but = ui_def_but(block, BLOCK, 0, str, x, y, width, height, arg, 0.0, 0.0, 0.0, 0.0, tip); /* XXX temp, old menu calls pass on icon arrow, which is now UI_ICON_SUBMENU flag */ if (icon != ICON_RIGHTARROW_THIN) { @@ -3616,9 +3611,9 @@ uiBut *uiDefIconTextBlockBut(uiBlock *block, uiBlockCreateFunc func, void *arg, } /* Block button containing icon */ -uiBut *uiDefIconBlockBut(uiBlock *block, uiBlockCreateFunc func, void *arg, int retval, int icon, int x1, int y1, short x2, short y2, const char *tip) +uiBut *uiDefIconBlockBut(uiBlock *block, uiBlockCreateFunc func, void *arg, int retval, int icon, int x, int y, short width, short height, const char *tip) { - uiBut *but = ui_def_but(block, BLOCK, retval, "", x1, y1, x2, y2, arg, 0.0, 0.0, 0.0, 0.0, tip); + uiBut *but = ui_def_but(block, BLOCK, retval, "", x, y, width, height, arg, 0.0, 0.0, 0.0, 0.0, tip); but->icon = (BIFIconID) icon; but->flag |= UI_HAS_ICON; @@ -3631,18 +3626,18 @@ uiBut *uiDefIconBlockBut(uiBlock *block, uiBlockCreateFunc func, void *arg, int return but; } -uiBut *uiDefKeyevtButS(uiBlock *block, int retval, const char *str, int x1, int y1, short x2, short y2, short *spoin, const char *tip) +uiBut *uiDefKeyevtButS(uiBlock *block, int retval, const char *str, int x, int y, short width, short height, short *spoin, const char *tip) { - uiBut *but = ui_def_but(block, KEYEVT | SHO, retval, str, x1, y1, x2, y2, spoin, 0.0, 0.0, 0.0, 0.0, tip); + uiBut *but = ui_def_but(block, KEYEVT | SHO, retval, str, x, y, width, height, spoin, 0.0, 0.0, 0.0, 0.0, tip); ui_check_but(but); return but; } /* short pointers hardcoded */ /* modkeypoin will be set to KM_SHIFT, KM_ALT, KM_CTRL, KM_OSKEY bits */ -uiBut *uiDefHotKeyevtButS(uiBlock *block, int retval, const char *str, int x1, int y1, short x2, short y2, short *keypoin, short *modkeypoin, const char *tip) +uiBut *uiDefHotKeyevtButS(uiBlock *block, int retval, const char *str, int x, int y, short width, short height, short *keypoin, short *modkeypoin, const char *tip) { - uiBut *but = ui_def_but(block, HOTKEYEVT | SHO, retval, str, x1, y1, x2, y2, keypoin, 0.0, 0.0, 0.0, 0.0, tip); + uiBut *but = ui_def_but(block, HOTKEYEVT | SHO, retval, str, x, y, width, height, keypoin, 0.0, 0.0, 0.0, 0.0, tip); but->modifier_key = *modkeypoin; ui_check_but(but); return but; @@ -3651,9 +3646,9 @@ uiBut *uiDefHotKeyevtButS(uiBlock *block, int retval, const char *str, int x1, i /* arg is pointer to string/name, use uiButSetSearchFunc() below to make this work */ /* here a1 and a2, if set, control thumbnail preview rows/cols */ -uiBut *uiDefSearchBut(uiBlock *block, void *arg, int retval, int icon, int maxlen, int x1, int y1, short x2, short y2, float a1, float a2, const char *tip) +uiBut *uiDefSearchBut(uiBlock *block, void *arg, int retval, int icon, int maxlen, int x, int y, short width, short height, float a1, float a2, const char *tip) { - uiBut *but = ui_def_but(block, SEARCH_MENU, retval, "", x1, y1, x2, y2, arg, 0.0, maxlen, a1, a2, tip); + uiBut *but = ui_def_but(block, SEARCH_MENU, retval, "", x, y, width, height, arg, 0.0, maxlen, a1, a2, tip); but->icon = (BIFIconID) icon; but->flag |= UI_HAS_ICON; diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c index ec41c821c04..55249e66521 100644 --- a/source/blender/editors/interface/interface_handlers.c +++ b/source/blender/editors/interface/interface_handlers.c @@ -686,8 +686,7 @@ static int ui_but_mouse_inside_icon(uiBut *but, ARegion *ar, wmEvent *event) ui_window_to_block(ar, but->block, &x, &y); - rect.xmin = but->rect.xmin; rect.xmax = but->rect.xmax; - rect.ymin = but->rect.ymin; rect.ymax = but->rect.ymax; + BLI_rcti_rctf_copy(&rect, &but->rect); if (but->imb) ; /* use button size itself */ else if (but->flag & UI_ICON_LEFT) { @@ -4921,7 +4920,7 @@ static int ui_do_button(bContext *C, uiBlock *block, uiBut *but, wmEvent *event) static int ui_but_contains_pt(uiBut *but, int mx, int my) { - return ((but->rect.xmin < mx && but->rect.xmax >= mx) && (but->rect.ymin < my && but->rect.ymax >= my)); + return BLI_in_rctf(&but->rect, mx, my); } static uiBut *ui_but_find_activated(ARegion *ar) @@ -5092,9 +5091,7 @@ static uiBut *ui_but_find_mouse_over(ARegion *ar, int x, int y) /* CLIP_EVENTS prevents the event from reaching other blocks */ if (block->flag & UI_BLOCK_CLIP_EVENTS) { /* check if mouse is inside block */ - if (block->rect.xmin <= mx && block->rect.xmax >= mx && - block->rect.ymin <= my && block->rect.ymax >= my) - { + if (BLI_in_rctf(&block->rect, mx, my)) { break; } } @@ -6103,10 +6100,7 @@ static int ui_handle_menu_event(bContext *C, wmEvent *event, uiPopupBlockHandle ui_window_to_block(ar, block, &mx, &my); /* check if mouse is inside block */ - inside = 0; - if (block->rect.xmin <= mx && block->rect.xmax >= mx) - if (block->rect.ymin <= my && block->rect.ymax >= my) - inside = 1; + inside = BLI_in_rctf(&block->rect, mx, my); /* if there's an active modal button, don't check events or outside, except for search menu */ but = ui_but_find_activated(ar); diff --git a/source/blender/editors/interface/interface_ops.c b/source/blender/editors/interface/interface_ops.c index 98df612a6af..53ff198b44d 100644 --- a/source/blender/editors/interface/interface_ops.c +++ b/source/blender/editors/interface/interface_ops.c @@ -729,10 +729,7 @@ static int ui_editsource_uibut_match(uiBut *but_a, uiBut *but_b) /* this just needs to be a 'good-enough' comparison so we can know beyond * reasonable doubt that these buttons are the same between redraws. * if this fails it only means edit-source fails - campbell */ - if ((but_a->rect.xmin == but_b->rect.xmin) && - (but_a->rect.xmax == but_b->rect.xmax) && - (but_a->rect.ymin == but_b->rect.ymin) && - (but_a->rect.ymax == but_b->rect.ymax) && + if (BLI_rctf_compare(&but_a->rect, &but_b->rect, FLT_EPSILON) && (but_a->type == but_b->type) && (but_a->rnaprop == but_b->rnaprop) && (but_a->optype == but_b->optype) && diff --git a/source/blender/editors/interface/interface_regions.c b/source/blender/editors/interface/interface_regions.c index 1941dc66967..dcab175c733 100644 --- a/source/blender/editors/interface/interface_regions.c +++ b/source/blender/editors/interface/interface_regions.c @@ -420,8 +420,9 @@ ARegion *ui_tooltip_create(bContext *C, ARegion *butregion, uiBut *but) /* IDProperty *prop;*/ char buf[512]; float fonth, fontw, aspect = but->block->aspect; - float x1f, x2f, y1f, y2f; - int x1, x2, y1, y2, winx, winy, ofsx, ofsy, w, h, a; + int winx, winy, ofsx, ofsy, w, h, a; + rctf rect_fl; + rcti rect_i; const int nbr_info = 6; uiStringInfo but_tip = {BUT_GET_TIP, NULL}; @@ -685,62 +686,59 @@ ARegion *ui_tooltip_create(bContext *C, ARegion *butregion, uiBut *but) ofsx = (but->block->panel) ? but->block->panel->ofsx : 0; ofsy = (but->block->panel) ? but->block->panel->ofsy : 0; - x1f = (but->rect.xmin + but->rect.xmax) * 0.5f + ofsx - (TIP_BORDER_X * aspect); - x2f = x1f + fontw + (TIP_BORDER_X * aspect); - y2f = but->rect.ymin + ofsy - (TIP_BORDER_Y * aspect); - y1f = y2f - fonth * aspect - (TIP_BORDER_Y * aspect); + rect_fl.xmin = (but->rect.xmin + but->rect.xmax) * 0.5f + ofsx - (TIP_BORDER_X * aspect); + rect_fl.xmax = rect_fl.xmin + fontw + (TIP_BORDER_X * aspect); + rect_fl.ymax = but->rect.ymin + ofsy - (TIP_BORDER_Y * aspect); + rect_fl.ymin = rect_fl.ymax - fonth * aspect - (TIP_BORDER_Y * aspect); #undef TIP_MARGIN_Y #undef TIP_BORDER_X #undef TIP_BORDER_Y /* copy to int, gets projected if possible too */ - x1 = x1f; y1 = y1f; x2 = x2f; y2 = y2f; + BLI_rcti_rctf_copy(&rect_i, &rect_fl); if (butregion) { /* XXX temp, region v2ds can be empty still */ if (butregion->v2d.cur.xmin != butregion->v2d.cur.xmax) { - UI_view2d_to_region_no_clip(&butregion->v2d, x1f, y1f, &x1, &y1); - UI_view2d_to_region_no_clip(&butregion->v2d, x2f, y2f, &x2, &y2); + UI_view2d_to_region_no_clip(&butregion->v2d, rect_fl.xmin, rect_fl.ymin, &rect_i.xmin, &rect_i.ymin); + UI_view2d_to_region_no_clip(&butregion->v2d, rect_fl.xmax, rect_fl.ymax, &rect_i.xmax, &rect_i.ymax); } - x1 += butregion->winrct.xmin; - x2 += butregion->winrct.xmin; - y1 += butregion->winrct.ymin; - y2 += butregion->winrct.ymin; + BLI_rcti_translate(&rect_i, butregion->winrct.xmin, butregion->winrct.ymin); } wm_window_get_size(CTX_wm_window(C), &winx, &winy); - if (x2 > winx) { + if (rect_i.xmax > winx) { /* super size */ - if (x2 > winx + x1) { - x2 = winx; - x1 = 0; + if (rect_i.xmax > winx + rect_i.xmin) { + rect_i.xmax = winx; + rect_i.xmin = 0; } else { - x1 -= x2 - winx; - x2 = winx; + rect_i.xmin -= rect_i.xmax - winx; + rect_i.xmax = winx; } } /* ensure at least 5 px above screen bounds * 25 is just a guess to be above the menu item */ - if (y1 < 5) { - y2 += (-y1) + 30; - y1 = 30; + if (rect_i.ymin < 5) { + rect_i.ymax += (-rect_i.ymin) + 30; + rect_i.ymin = 30; } /* widget rect, in region coords */ data->bbox.xmin = MENU_SHADOW_SIDE; - data->bbox.xmax = x2 - x1 + MENU_SHADOW_SIDE; + data->bbox.xmax = rect_i.xmax - rect_i.xmin + MENU_SHADOW_SIDE; data->bbox.ymin = MENU_SHADOW_BOTTOM; - data->bbox.ymax = y2 - y1 + MENU_SHADOW_BOTTOM; + data->bbox.ymax = rect_i.ymax - rect_i.ymin + MENU_SHADOW_BOTTOM; /* region bigger for shadow */ - ar->winrct.xmin = x1 - MENU_SHADOW_SIDE; - ar->winrct.xmax = x2 + MENU_SHADOW_SIDE; - ar->winrct.ymin = y1 - MENU_SHADOW_BOTTOM; - ar->winrct.ymax = y2 + MENU_TOP; + ar->winrct.xmin = rect_i.xmin - MENU_SHADOW_SIDE; + ar->winrct.xmax = rect_i.xmax + MENU_SHADOW_SIDE; + ar->winrct.ymin = rect_i.ymin - MENU_SHADOW_BOTTOM; + ar->winrct.ymax = rect_i.ymax + MENU_TOP; /* adds subwindow */ ED_region_init(C, ar); @@ -1134,8 +1132,10 @@ ARegion *ui_searchbox_create(bContext *C, ARegion *butregion, uiBut *but) ARegion *ar; uiSearchboxData *data; float aspect = but->block->aspect; - float x1f, x2f, y1f, y2f; - int x1, x2, y1, y2, winx, winy, ofsx, ofsy; + rctf rect_fl; + rcti rect_i; + int winx, winy, ofsx, ofsy; + int i; /* create area region */ ar = ui_add_temporary_region(CTX_wm_screen(C)); @@ -1189,69 +1189,65 @@ ARegion *ui_searchbox_create(bContext *C, ARegion *butregion, uiBut *but) } } else { - x1f = but->rect.xmin - 5; /* align text with button */ - x2f = but->rect.xmax + 5; /* symmetrical */ - y2f = but->rect.ymin; - y1f = y2f - uiSearchBoxhHeight(); + rect_fl.xmin = but->rect.xmin - 5; /* align text with button */ + rect_fl.xmax = but->rect.xmax + 5; /* symmetrical */ + rect_fl.ymax = but->rect.ymin; + rect_fl.ymin = rect_fl.ymax - uiSearchBoxhHeight(); ofsx = (but->block->panel) ? but->block->panel->ofsx : 0; ofsy = (but->block->panel) ? but->block->panel->ofsy : 0; - x1f += ofsx; - x2f += ofsx; - y1f += ofsy; - y2f += ofsy; + BLI_rctf_translate(&rect_fl, ofsx, ofsy); /* minimal width */ - if (x2f - x1f < 150) x2f = x1f + 150; // XXX arbitrary + if (rect_fl.xmax - rect_fl.xmin < 150) { + rect_fl.xmax = rect_fl.xmin + 150; /* XXX arbitrary */ + } /* copy to int, gets projected if possible too */ - x1 = x1f; y1 = y1f; x2 = x2f; y2 = y2f; + BLI_rcti_rctf_copy(&rect_i, &rect_fl); if (butregion->v2d.cur.xmin != butregion->v2d.cur.xmax) { - UI_view2d_to_region_no_clip(&butregion->v2d, x1f, y1f, &x1, &y1); - UI_view2d_to_region_no_clip(&butregion->v2d, x2f, y2f, &x2, &y2); + UI_view2d_to_region_no_clip(&butregion->v2d, rect_fl.xmin, rect_fl.ymin, &rect_i.xmin, &rect_i.ymin); + UI_view2d_to_region_no_clip(&butregion->v2d, rect_fl.xmax, rect_fl.ymax, &rect_i.xmax, &rect_i.ymax); } - x1 += butregion->winrct.xmin; - x2 += butregion->winrct.xmin; - y1 += butregion->winrct.ymin; - y2 += butregion->winrct.ymin; + BLI_rcti_translate(&rect_i, butregion->winrct.xmin, butregion->winrct.ymin); wm_window_get_size(CTX_wm_window(C), &winx, &winy); - if (x2 > winx) { + if (rect_i.xmax > winx) { /* super size */ - if (x2 > winx + x1) { - x2 = winx; - x1 = 0; + if (rect_i.xmax > winx + rect_i.xmin) { + rect_i.xmax = winx; + rect_i.xmin = 0; } else { - x1 -= x2 - winx; - x2 = winx; + rect_i.xmin -= rect_i.xmax - winx; + rect_i.xmax = winx; } } - if (y1 < 0) { + if (rect_i.ymin < 0) { int newy1; UI_view2d_to_region_no_clip(&butregion->v2d, 0, but->rect.ymax + ofsy, NULL, &newy1); newy1 += butregion->winrct.ymin; - y2 = y2 - y1 + newy1; - y1 = newy1; + rect_i.ymax = rect_i.ymax - rect_i.ymin + newy1; + rect_i.ymin = newy1; } /* widget rect, in region coords */ data->bbox.xmin = MENU_SHADOW_SIDE; - data->bbox.xmax = x2 - x1 + MENU_SHADOW_SIDE; + data->bbox.xmax = rect_i.xmax - rect_i.xmin + MENU_SHADOW_SIDE; data->bbox.ymin = MENU_SHADOW_BOTTOM; - data->bbox.ymax = y2 - y1 + MENU_SHADOW_BOTTOM; + data->bbox.ymax = rect_i.ymax - rect_i.ymin + MENU_SHADOW_BOTTOM; /* region bigger for shadow */ - ar->winrct.xmin = x1 - MENU_SHADOW_SIDE; - ar->winrct.xmax = x2 + MENU_SHADOW_SIDE; - ar->winrct.ymin = y1 - MENU_SHADOW_BOTTOM; - ar->winrct.ymax = y2; + ar->winrct.xmin = rect_i.xmin - MENU_SHADOW_SIDE; + ar->winrct.xmax = rect_i.xmax + MENU_SHADOW_SIDE; + ar->winrct.ymin = rect_i.ymin - MENU_SHADOW_BOTTOM; + ar->winrct.ymax = rect_i.ymax; } /* adds subwindow */ @@ -1272,8 +1268,8 @@ ARegion *ui_searchbox_create(bContext *C, ARegion *butregion, uiBut *but) data->items.names = MEM_callocN(data->items.maxitem * sizeof(void *), "search names"); data->items.pointers = MEM_callocN(data->items.maxitem * sizeof(void *), "search pointers"); data->items.icons = MEM_callocN(data->items.maxitem * sizeof(int), "search icons"); - for (x1 = 0; x1 < data->items.maxitem; x1++) - data->items.names[x1] = MEM_callocN(but->hardmax + 1, "search pointers"); + for (i = 0; i < data->items.maxitem; i++) + data->items.names[i] = MEM_callocN(but->hardmax + 1, "search pointers"); return ar; } @@ -1347,18 +1343,10 @@ static void ui_block_position(wmWindow *window, ARegion *butregion, uiBut *but, /* calc block rect */ if (block->rect.xmin == 0.0f && block->rect.xmax == 0.0f) { if (block->buttons.first) { - block->rect.xmin = block->rect.ymin = 10000; - block->rect.xmax = block->rect.ymax = -10000; - - bt = block->buttons.first; - while (bt) { - if (bt->rect.xmin < block->rect.xmin) block->rect.xmin = bt->rect.xmin; - if (bt->rect.ymin < block->rect.ymin) block->rect.ymin = bt->rect.ymin; + BLI_rctf_init_minmax(&block->rect); - if (bt->rect.xmax > block->rect.xmax) block->rect.xmax = bt->rect.xmax; - if (bt->rect.ymax > block->rect.ymax) block->rect.ymax = bt->rect.ymax; - - bt = bt->next; + for (bt = block->buttons.first; bt; bt = bt->next) { + BLI_rctf_union(&block->rect, &bt->rect); } } else { @@ -1375,7 +1363,7 @@ static void ui_block_position(wmWindow *window, ARegion *butregion, uiBut *but, //block->rect.xmin -= 2.0; block->rect.ymin -= 2.0; //block->rect.xmax += 2.0; block->rect.ymax += 2.0; - xsize = block->rect.xmax - block->rect.xmin + 4; // 4 for shadow + xsize = block->rect.xmax - block->rect.xmin + 4; /* 4 for shadow */ ysize = block->rect.ymax - block->rect.ymin + 4; /* aspect /= (float)xsize;*/ /*UNUSED*/ @@ -1496,20 +1484,14 @@ static void ui_block_position(wmWindow *window, ARegion *butregion, uiBut *but, ui_block_to_window_fl(butregion, but->block, &bt->rect.xmin, &bt->rect.ymin); ui_block_to_window_fl(butregion, but->block, &bt->rect.xmax, &bt->rect.ymax); - bt->rect.xmin += xof; - bt->rect.xmax += xof; - bt->rect.ymin += yof; - bt->rect.ymax += yof; + BLI_rctf_translate(&bt->rect, xof, yof); - bt->aspect = 1.0; - // ui_check_but recalculates drawstring size in pixels + bt->aspect = 1.0f; + /* ui_check_but recalculates drawstring size in pixels */ ui_check_but(bt); } - block->rect.xmin += xof; - block->rect.ymin += yof; - block->rect.xmax += xof; - block->rect.ymax += yof; + BLI_rctf_translate(&block->rect, xof, yof); /* safety calculus */ if (but) { @@ -1630,7 +1612,6 @@ uiPopupBlockHandle *ui_popup_block_create(bContext *C, ARegion *butregion, uiBut static ARegionType type; ARegion *ar; uiBlock *block; - uiBut *bt; uiPopupBlockHandle *handle; uiSafetyRct *saferct; @@ -1698,17 +1679,7 @@ uiPopupBlockHandle *ui_popup_block_create(bContext *C, ARegion *butregion, uiBut ar->winrct.ymin = block->rect.ymin - MENU_SHADOW_BOTTOM; ar->winrct.ymax = block->rect.ymax + MENU_TOP; - block->rect.xmin -= ar->winrct.xmin; - block->rect.xmax -= ar->winrct.xmin; - block->rect.ymin -= ar->winrct.ymin; - block->rect.ymax -= ar->winrct.ymin; - - for (bt = block->buttons.first; bt; bt = bt->next) { - bt->rect.xmin -= ar->winrct.xmin; - bt->rect.xmax -= ar->winrct.xmin; - bt->rect.ymin -= ar->winrct.ymin; - bt->rect.ymax -= ar->winrct.ymin; - } + ui_block_translate(block, -ar->winrct.xmin, -ar->winrct.ymin); block->flag |= UI_BLOCK_LOOP; From 4301df952ebb308c5cba5599609dffba5278f84c Mon Sep 17 00:00:00 2001 From: Nicholas Bishop Date: Sat, 18 Aug 2012 18:54:05 +0000 Subject: [PATCH 004/163] Fix reversed names in modifier-remove error report --- source/blender/editors/object/object_modifier.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/blender/editors/object/object_modifier.c b/source/blender/editors/object/object_modifier.c index d3b099887cc..b82363abb4a 100644 --- a/source/blender/editors/object/object_modifier.c +++ b/source/blender/editors/object/object_modifier.c @@ -336,7 +336,7 @@ int ED_object_modifier_remove(ReportList *reports, Main *bmain, Scene *scene, Ob ok = object_modifier_remove(bmain, ob, md, &sort_depsgraph); if (!ok) { - BKE_reportf(reports, RPT_ERROR, "Modifier '%s' not in object '%s'", ob->id.name, md->name); + BKE_reportf(reports, RPT_ERROR, "Modifier '%s' not in object '%s'", md->name, ob->id.name); return 0; } From 33fa4364475898481093e6f60793b44d50488963 Mon Sep 17 00:00:00 2001 From: Nicholas Bishop Date: Sat, 18 Aug 2012 19:01:37 +0000 Subject: [PATCH 005/163] Fix incorrect error test when removing a modifier r49989 had the test reversed --- source/blender/editors/object/object_modifier.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/blender/editors/object/object_modifier.c b/source/blender/editors/object/object_modifier.c index b82363abb4a..bbc7a6ace7d 100644 --- a/source/blender/editors/object/object_modifier.c +++ b/source/blender/editors/object/object_modifier.c @@ -271,7 +271,7 @@ static int object_modifier_remove(Main *bmain, Object *ob, ModifierData *md, /* It seems on rapid delete it is possible to * get called twice on same modifier, so make * sure it is in list. */ - if (BLI_findindex(&ob->modifiers, md) != -1) { + if (BLI_findindex(&ob->modifiers, md) == -1) { return 0; } From e30ed91b9011b6eb5fae2932c002f83936c31d9d Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 18 Aug 2012 19:30:27 +0000 Subject: [PATCH 006/163] code cleanup: use BLI math funcs for metaballs, also remove MB_POINT struct and just use float[3] instead. --- source/blender/blenkernel/BKE_mball.h | 4 +- source/blender/blenkernel/intern/mball.c | 372 ++++++++++------------- 2 files changed, 164 insertions(+), 212 deletions(-) diff --git a/source/blender/blenkernel/BKE_mball.h b/source/blender/blenkernel/BKE_mball.h index 356f2c8901c..913e8653b9b 100644 --- a/source/blender/blenkernel/BKE_mball.h +++ b/source/blender/blenkernel/BKE_mball.h @@ -57,8 +57,8 @@ float *BKE_mball_make_orco(struct Object *ob, struct ListBase *dispbase); void BKE_mball_properties_copy(struct Scene *scene, struct Object *active_object); int BKE_mball_minmax(struct MetaBall *mb, float min[3], float max[3]); -int BKE_mball_center_median(struct MetaBall *mb, float cent[3]); -int BKE_mball_center_bounds(struct MetaBall *mb, float cent[3]); +int BKE_mball_center_median(struct MetaBall *mb, float r_cent[3]); +int BKE_mball_center_bounds(struct MetaBall *mb, float r_cent[3]); void BKE_mball_translate(struct MetaBall *mb, float offset[3]); struct MetaElem *BKE_mball_element_add(struct MetaBall *mb, const int type); diff --git a/source/blender/blenkernel/intern/mball.c b/source/blender/blenkernel/intern/mball.c index fa5304b081a..039fb2c22f3 100644 --- a/source/blender/blenkernel/intern/mball.c +++ b/source/blender/blenkernel/intern/mball.c @@ -67,12 +67,9 @@ /* Data types */ -typedef struct point { /* a three-dimensional point */ - float x, y, z; /* its coordinates */ -} MB_POINT; - typedef struct vertex { /* surface vertex */ - MB_POINT position, normal; /* position and surface normal */ + float co[3]; /* position and surface normal */ + float no[3]; } VERTEX; typedef struct vertices { /* list of vertices in polygonization */ @@ -82,7 +79,7 @@ typedef struct vertices { /* list of vertices in polygonization */ typedef struct corner { /* corner of a cube */ int i, j, k; /* (i, j, k) is index within lattice */ - float x, y, z, value; /* location and function value */ + float co[3], value; /* location and function value */ struct corner *next; } CORNER; @@ -159,11 +156,11 @@ struct pgn_elements { }; /* Forward declarations */ -static int vertid(CORNER *c1, CORNER *c2, PROCESS *p, MetaBall *mb); +static int vertid(const CORNER *c1, const CORNER *c2, PROCESS *p, MetaBall *mb); static int setcenter(CENTERLIST *table[], int i, int j, int k); static CORNER *setcorner(PROCESS *p, int i, int j, int k); -static void converge(MB_POINT *p1, MB_POINT *p2, float v1, float v2, - float (*function)(float, float, float), MB_POINT *p, MetaBall *mb, int f); +static void converge(const float p1[3], const float p2[3], float v1, float v2, + float (*function)(float, float, float), float p[3], MetaBall *mb, int f); /* Global variables */ @@ -631,65 +628,59 @@ static void calc_mballco(MetaElem *ml, float vec[3]) static float densfunc(MetaElem *ball, float x, float y, float z) { - float dist2 = 0.0, dx, dy, dz; - float vec[3]; + float dist2; + float dvec[3] = {x, y, z}; - vec[0] = x; - vec[1] = y; - vec[2] = z; - mul_m4_v3((float (*)[4])ball->imat, vec); - dx = vec[0]; - dy = vec[1]; - dz = vec[2]; + mul_m4_v3((float (*)[4])ball->imat, dvec); if (ball->type == MB_BALL) { } else if (ball->type == MB_TUBEX) { - if (dx > ball->len) dx -= ball->len; - else if (dx < -ball->len) dx += ball->len; - else dx = 0.0; + if (dvec[0] > ball->len) dvec[0] -= ball->len; + else if (dvec[0] < -ball->len) dvec[0] += ball->len; + else dvec[0] = 0.0; } else if (ball->type == MB_TUBEY) { - if (dy > ball->len) dy -= ball->len; - else if (dy < -ball->len) dy += ball->len; - else dy = 0.0; + if (dvec[1] > ball->len) dvec[1] -= ball->len; + else if (dvec[1] < -ball->len) dvec[1] += ball->len; + else dvec[1] = 0.0; } else if (ball->type == MB_TUBEZ) { - if (dz > ball->len) dz -= ball->len; - else if (dz < -ball->len) dz += ball->len; - else dz = 0.0; + if (dvec[2] > ball->len) dvec[2] -= ball->len; + else if (dvec[2] < -ball->len) dvec[2] += ball->len; + else dvec[2] = 0.0; } else if (ball->type == MB_TUBE) { - if (dx > ball->expx) dx -= ball->expx; - else if (dx < -ball->expx) dx += ball->expx; - else dx = 0.0; + if (dvec[0] > ball->expx) dvec[0] -= ball->expx; + else if (dvec[0] < -ball->expx) dvec[0] += ball->expx; + else dvec[0] = 0.0; } else if (ball->type == MB_PLANE) { - if (dx > ball->expx) dx -= ball->expx; - else if (dx < -ball->expx) dx += ball->expx; - else dx = 0.0; - if (dy > ball->expy) dy -= ball->expy; - else if (dy < -ball->expy) dy += ball->expy; - else dy = 0.0; + if (dvec[0] > ball->expx) dvec[0] -= ball->expx; + else if (dvec[0] < -ball->expx) dvec[0] += ball->expx; + else dvec[0] = 0.0; + if (dvec[1] > ball->expy) dvec[1] -= ball->expy; + else if (dvec[1] < -ball->expy) dvec[1] += ball->expy; + else dvec[1] = 0.0; } else if (ball->type == MB_ELIPSOID) { - dx *= 1 / ball->expx; - dy *= 1 / ball->expy; - dz *= 1 / ball->expz; + dvec[0] *= 1 / ball->expx; + dvec[1] *= 1 / ball->expy; + dvec[2] *= 1 / ball->expz; } else if (ball->type == MB_CUBE) { - if (dx > ball->expx) dx -= ball->expx; - else if (dx < -ball->expx) dx += ball->expx; - else dx = 0.0; - if (dy > ball->expy) dy -= ball->expy; - else if (dy < -ball->expy) dy += ball->expy; - else dy = 0.0; - if (dz > ball->expz) dz -= ball->expz; - else if (dz < -ball->expz) dz += ball->expz; - else dz = 0.0; + if (dvec[0] > ball->expx) dvec[0] -= ball->expx; + else if (dvec[0] < -ball->expx) dvec[0] += ball->expx; + else dvec[0] = 0.0; + if (dvec[1] > ball->expy) dvec[1] -= ball->expy; + else if (dvec[1] < -ball->expy) dvec[1] += ball->expy; + else dvec[1] = 0.0; + if (dvec[2] > ball->expz) dvec[2] -= ball->expz; + else if (dvec[2] < -ball->expz) dvec[2] += ball->expz; + else dvec[2] = 0.0; } - dist2 = (dx * dx + dy * dy + dz * dz); + dist2 = len_v3(dvec); if (ball->flag & MB_NEGATIVE) { dist2 = 1.0f - (dist2 / ball->rad2); @@ -1074,12 +1065,12 @@ static CORNER *setcorner(PROCESS *p, int i, int j, int k) c = (CORNER *) new_pgn_element(sizeof(CORNER)); c->i = i; - c->x = ((float)i - 0.5f) * p->size; + c->co[0] = ((float)i - 0.5f) * p->size; c->j = j; - c->y = ((float)j - 0.5f) * p->size; + c->co[1] = ((float)j - 0.5f) * p->size; c->k = k; - c->z = ((float)k - 0.5f) * p->size; - c->value = p->function(c->x, c->y, c->z); + c->co[2] = ((float)k - 0.5f) * p->size; + c->value = p->function(c->co[0], c->co[1], c->co[2]); c->next = p->corners[index]; p->corners[index] = c; @@ -1204,7 +1195,7 @@ void BKE_mball_cubeTable_free(void) /* setcenter: set (i, j, k) entry of table[] * return 1 if already set; otherwise, set and return 0 */ -static int setcenter(CENTERLIST *table[], int i, int j, int k) +static int setcenter(CENTERLIST *table[], const int i, const int j, const int k) { int index; CENTERLIST *newc, *l, *q; @@ -1324,72 +1315,46 @@ static void addtovertices(VERTICES *vertices, VERTEX v) /* vnormal: compute unit length surface normal at point */ -static void vnormal(MB_POINT *point, PROCESS *p, MB_POINT *v) +static void vnormal(const float point[3], PROCESS *p, float r_no[3]) { float delta = 0.2f * p->delta; - float f = p->function(point->x, point->y, point->z); + float f = p->function(point[0], point[1], point[2]); - v->x = p->function(point->x + delta, point->y, point->z) - f; - v->y = p->function(point->x, point->y + delta, point->z) - f; - v->z = p->function(point->x, point->y, point->z + delta) - f; - f = sqrtf(v->x * v->x + v->y * v->y + v->z * v->z); - - if (f != 0.0f) { - v->x /= f; - v->y /= f; - v->z /= f; - } + r_no[0] = p->function(point[0] + delta, point[1], point[2]) - f; + r_no[1] = p->function(point[0], point[1] + delta, point[2]) - f; + r_no[2] = p->function(point[0], point[1], point[2] + delta) - f; + f = normalize_v3(r_no); - if (FALSE) { - MB_POINT temp; + if (0) { + float tvec[3]; delta *= 2.0f; - f = p->function(point->x, point->y, point->z); + f = p->function(point[0], point[1], point[2]); - temp.x = p->function(point->x + delta, point->y, point->z) - f; - temp.y = p->function(point->x, point->y + delta, point->z) - f; - temp.z = p->function(point->x, point->y, point->z + delta) - f; - f = sqrtf(temp.x * temp.x + temp.y * temp.y + temp.z * temp.z); + tvec[0] = p->function(point[0] + delta, point[1], point[2]) - f; + tvec[1] = p->function(point[0], point[1] + delta, point[2]) - f; + tvec[2] = p->function(point[0], point[1], point[2] + delta) - f; - if (f != 0.0f) { - temp.x /= f; - temp.y /= f; - temp.z /= f; - - v->x += temp.x; - v->y += temp.y; - v->z += temp.z; - - f = sqrtf(v->x * v->x + v->y * v->y + v->z * v->z); - - if (f != 0.0f) { - v->x /= f; - v->y /= f; - v->z /= f; - } + if (normalize_v3(tvec) != 0.0f) { + add_v3_v3(r_no, tvec); + normalize_v3(r_no); } } - } -static int vertid(CORNER *c1, CORNER *c2, PROCESS *p, MetaBall *mb) +static int vertid(const CORNER *c1, const CORNER *c2, PROCESS *p, MetaBall *mb) { VERTEX v; - MB_POINT a, b; int vid = getedge(p->edges, c1->i, c1->j, c1->k, c2->i, c2->j, c2->k); - if (vid != -1) return vid; /* previously computed */ - a.x = c1->x; - a.y = c1->y; - a.z = c1->z; - b.x = c2->x; - b.y = c2->y; - b.z = c2->z; + if (vid != -1) { + return vid; /* previously computed */ + } - converge(&a, &b, c1->value, c2->value, p->function, &v.position, mb, 1); /* position */ - vnormal(&v.position, p, &v.normal); + converge(c1->co, c2->co, c1->value, c2->value, p->function, v.co, mb, 1); /* position */ + vnormal(v.co, p, v.no); addtovertices(&p->vertices, v); /* save vertex */ vid = p->vertices.count - 1; @@ -1403,101 +1368,95 @@ static int vertid(CORNER *c1, CORNER *c2, PROCESS *p, MetaBall *mb) /* converge: from two points of differing sign, converge to zero crossing */ /* watch it: p1 and p2 are used to calculate */ -static void converge(MB_POINT *p1, MB_POINT *p2, float v1, float v2, - float (*function)(float, float, float), MB_POINT *p, MetaBall *mb, int f) +static void converge(const float p1[3], const float p2[3], float v1, float v2, + float (*function)(float, float, float), float p[3], MetaBall *mb, int f) { int i = 0; - MB_POINT pos, neg; + float pos[3], neg[3]; float positive = 0.0f, negative = 0.0f; - float dx = 0.0f, dy = 0.0f, dz = 0.0f; + float dvec[3]; if (v1 < 0) { - pos = *p2; - neg = *p1; + copy_v3_v3(pos, p2); + copy_v3_v3(neg, p1); positive = v2; negative = v1; } else { - pos = *p1; - neg = *p2; + copy_v3_v3(pos, p1); + copy_v3_v3(neg, p2); positive = v1; negative = v2; } - dx = pos.x - neg.x; - dy = pos.y - neg.y; - dz = pos.z - neg.z; + sub_v3_v3v3(dvec, pos, neg); /* Approximation by linear interpolation is faster then binary subdivision, * but it results sometimes (mb->thresh < 0.2) into the strange results */ if ((mb->thresh > 0.2f) && (f == 1)) { - if ((dy == 0.0f) && (dz == 0.0f)) { - p->x = neg.x - negative * dx / (positive - negative); - p->y = neg.y; - p->z = neg.z; + if ((dvec[1] == 0.0f) && (dvec[2] == 0.0f)) { + p[0] = neg[0] - negative * dvec[0] / (positive - negative); + p[1] = neg[1]; + p[2] = neg[2]; return; } - if ((dx == 0.0f) && (dz == 0.0f)) { - p->x = neg.x; - p->y = neg.y - negative * dy / (positive - negative); - p->z = neg.z; + if ((dvec[0] == 0.0f) && (dvec[2] == 0.0f)) { + p[0] = neg[0]; + p[1] = neg[1] - negative * dvec[1] / (positive - negative); + p[2] = neg[2]; return; } - if ((dx == 0.0f) && (dy == 0.0f)) { - p->x = neg.x; - p->y = neg.y; - p->z = neg.z - negative * dz / (positive - negative); + if ((dvec[0] == 0.0f) && (dvec[1] == 0.0f)) { + p[0] = neg[0]; + p[1] = neg[1]; + p[2] = neg[2] - negative * dvec[2] / (positive - negative); return; } } - if ((dy == 0.0f) && (dz == 0.0f)) { - p->y = neg.y; - p->z = neg.z; + if ((dvec[1] == 0.0f) && (dvec[2] == 0.0f)) { + p[1] = neg[1]; + p[2] = neg[2]; while (1) { if (i++ == RES) return; - p->x = 0.5f * (pos.x + neg.x); - if ((function(p->x, p->y, p->z)) > 0.0f) pos.x = p->x; else neg.x = p->x; + p[0] = 0.5f * (pos[0] + neg[0]); + if ((function(p[0], p[1], p[2])) > 0.0f) pos[0] = p[0]; else neg[0] = p[0]; } } - if ((dx == 0.0f) && (dz == 0.0f)) { - p->x = neg.x; - p->z = neg.z; + if ((dvec[0] == 0.0f) && (dvec[2] == 0.0f)) { + p[0] = neg[0]; + p[2] = neg[2]; while (1) { if (i++ == RES) return; - p->y = 0.5f * (pos.y + neg.y); - if ((function(p->x, p->y, p->z)) > 0.0f) pos.y = p->y; else neg.y = p->y; + p[1] = 0.5f * (pos[1] + neg[1]); + if ((function(p[0], p[1], p[2])) > 0.0f) pos[1] = p[1]; else neg[1] = p[1]; } } - - if ((dx == 0.0f) && (dy == 0.0f)) { - p->x = neg.x; - p->y = neg.y; + + if ((dvec[0] == 0.0f) && (dvec[1] == 0.0f)) { + p[0] = neg[0]; + p[1] = neg[1]; while (1) { if (i++ == RES) return; - p->z = 0.5f * (pos.z + neg.z); - if ((function(p->x, p->y, p->z)) > 0.0f) pos.z = p->z; else neg.z = p->z; + p[2] = 0.5f * (pos[2] + neg[2]); + if ((function(p[0], p[1], p[2])) > 0.0f) pos[2] = p[2]; else neg[2] = p[2]; } } /* This is necessary to find start point */ while (1) { - p->x = 0.5f * (pos.x + neg.x); - p->y = 0.5f * (pos.y + neg.y); - p->z = 0.5f * (pos.z + neg.z); + mid_v3_v3v3(&p[0], pos, neg); - if (i++ == RES) return; - - if ((function(p->x, p->y, p->z)) > 0.0f) { - pos.x = p->x; - pos.y = p->y; - pos.z = p->z; + if (i++ == RES) { + return; + } + + if ((function(p[0], p[1], p[2])) > 0.0f) { + copy_v3_v3(pos, &p[0]); } else { - neg.x = p->x; - neg.y = p->y; - neg.z = p->z; + copy_v3_v3(neg, &p[0]); } } } @@ -1535,105 +1494,100 @@ static void add_cube(PROCESS *mbproc, int i, int j, int k, int count) static void find_first_points(PROCESS *mbproc, MetaBall *mb, int a) { - MB_POINT IN, in, OUT, out; /*point;*/ MetaElem *ml; - int i, j, k, c_i, c_j, c_k; - int index[3] = {1, 0, -1}; float f = 0.0f; - float in_v /*, out_v*/; - MB_POINT workp; - float tmp_v, workp_v, max_len, len, dx, dy, dz, nx, ny, nz, MAXN; ml = mainb[a]; - - f = 1 - (mb->thresh / ml->s); + f = 1.0 - (mb->thresh / ml->s); /* Skip, when Stiffness of MetaElement is too small ... MetaElement can't be * visible alone ... but still can influence others MetaElements :-) */ if (f > 0.0f) { - OUT.x = IN.x = in.x = 0.0; - OUT.y = IN.y = in.y = 0.0; - OUT.z = IN.z = in.z = 0.0; + float IN[3] = {0.0f}, OUT[3] = {0.0f}, in[3] = {0.0f}, out[3]; + int i, j, k, c_i, c_j, c_k; + int index[3] = {1, 0, -1}; + float in_v /*, out_v*/; + float workp[3]; + float dvec[3]; + float tmp_v, workp_v, max_len, len, nx, ny, nz, MAXN; - calc_mballco(ml, (float *)&in); - in_v = mbproc->function(in.x, in.y, in.z); + calc_mballco(ml, in); + in_v = mbproc->function(in[0], in[1], in[2]); for (i = 0; i < 3; i++) { switch (ml->type) { case MB_BALL: - OUT.x = out.x = IN.x + index[i] * ml->rad; + OUT[0] = out[0] = IN[0] + index[i] * ml->rad; break; case MB_TUBE: case MB_PLANE: case MB_ELIPSOID: case MB_CUBE: - OUT.x = out.x = IN.x + index[i] * (ml->expx + ml->rad); + OUT[0] = out[0] = IN[0] + index[i] * (ml->expx + ml->rad); break; } for (j = 0; j < 3; j++) { switch (ml->type) { case MB_BALL: - OUT.y = out.y = IN.y + index[j] * ml->rad; + OUT[1] = out[1] = IN[1] + index[j] * ml->rad; break; case MB_TUBE: case MB_PLANE: case MB_ELIPSOID: case MB_CUBE: - OUT.y = out.y = IN.y + index[j] * (ml->expy + ml->rad); + OUT[1] = out[1] = IN[1] + index[j] * (ml->expy + ml->rad); break; } for (k = 0; k < 3; k++) { - out.x = OUT.x; - out.y = OUT.y; + out[0] = OUT[0]; + out[1] = OUT[1]; switch (ml->type) { case MB_BALL: case MB_TUBE: case MB_PLANE: - out.z = IN.z + index[k] * ml->rad; + out[2] = IN[2] + index[k] * ml->rad; break; case MB_ELIPSOID: case MB_CUBE: - out.z = IN.z + index[k] * (ml->expz + ml->rad); + out[2] = IN[2] + index[k] * (ml->expz + ml->rad); break; } - calc_mballco(ml, (float *)&out); + calc_mballco(ml, out); - /*out_v = mbproc->function(out.x, out.y, out.z);*/ /*UNUSED*/ + /*out_v = mbproc->function(out[0], out[1], out[2]);*/ /*UNUSED*/ /* find "first points" on Implicit Surface of MetaElemnt ml */ - workp.x = in.x; - workp.y = in.y; - workp.z = in.z; + copy_v3_v3(workp, in); workp_v = in_v; - max_len = sqrtf((out.x - in.x) * (out.x - in.x) + (out.y - in.y) * (out.y - in.y) + (out.z - in.z) * (out.z - in.z)); + max_len = len_v3v3(out, in); - nx = abs((out.x - in.x) / mbproc->size); - ny = abs((out.y - in.y) / mbproc->size); - nz = abs((out.z - in.z) / mbproc->size); + nx = abs((out[0] - in[0]) / mbproc->size); + ny = abs((out[1] - in[1]) / mbproc->size); + nz = abs((out[2] - in[2]) / mbproc->size); MAXN = MAX3(nx, ny, nz); if (MAXN != 0.0f) { - dx = (out.x - in.x) / MAXN; - dy = (out.y - in.y) / MAXN; - dz = (out.z - in.z) / MAXN; + dvec[0] = (out[0] - in[0]) / MAXN; + dvec[1] = (out[1] - in[1]) / MAXN; + dvec[2] = (out[2] - in[2]) / MAXN; len = 0.0; while (len <= max_len) { - workp.x += dx; - workp.y += dy; - workp.z += dz; + workp[0] += dvec[0]; + workp[1] += dvec[1]; + workp[2] += dvec[2]; /* compute value of implicite function */ - tmp_v = mbproc->function(workp.x, workp.y, workp.z); + tmp_v = mbproc->function(workp[0], workp[1], workp[2]); /* add cube to the stack, when value of implicite function crosses zero value */ if ((tmp_v < 0.0f && workp_v >= 0.0f) || (tmp_v > 0.0f && workp_v <= 0.0f)) { /* indexes of CUBE, which includes "first point" */ - c_i = (int)floor(workp.x / mbproc->size); - c_j = (int)floor(workp.y / mbproc->size); - c_k = (int)floor(workp.z / mbproc->size); + c_i = (int)floor(workp[0] / mbproc->size); + c_j = (int)floor(workp[1] / mbproc->size); + c_k = (int)floor(workp[2] / mbproc->size); /* add CUBE (with indexes c_i, c_j, c_k) to the stack, * this cube includes found point of Implicit Surface */ @@ -1642,7 +1596,7 @@ static void find_first_points(PROCESS *mbproc, MetaBall *mb, int a) else add_cube(mbproc, c_i, c_j, c_k, 1); } - len = sqrtf((workp.x - in.x) * (workp.x - in.x) + (workp.y - in.y) * (workp.y - in.y) + (workp.z - in.z) * (workp.z - in.z)); + len = len_v3v3(workp, in); workp_v = tmp_v; } @@ -2283,7 +2237,7 @@ void BKE_mball_polygonize(Scene *scene, Object *ob, ListBase *dispbase) MetaBall *mb; DispList *dl; int a, nr_cubes; - float *ve, *no, totsize, width; + float *co, *no, totsize, width; mb = ob->data; @@ -2362,6 +2316,8 @@ void BKE_mball_polygonize(Scene *scene, Object *ob, ListBase *dispbase) } if (curindex) { + VERTEX *ptr = mbproc.vertices.ptr; + dl = MEM_callocN(sizeof(DispList), "mbaldisp"); BLI_addtail(dispbase, dl); dl->type = DL_INDEX4; @@ -2372,17 +2328,12 @@ void BKE_mball_polygonize(Scene *scene, Object *ob, ListBase *dispbase) indices = NULL; a = mbproc.vertices.count; - dl->verts = ve = MEM_mallocN(sizeof(float) * 3 * a, "mballverts"); + dl->verts = co = MEM_mallocN(sizeof(float) * 3 * a, "mballverts"); dl->nors = no = MEM_mallocN(sizeof(float) * 3 * a, "mballnors"); - for (a = 0; a < mbproc.vertices.count; a++, no += 3, ve += 3) { - ve[0] = mbproc.vertices.ptr[a].position.x; - ve[1] = mbproc.vertices.ptr[a].position.y; - ve[2] = mbproc.vertices.ptr[a].position.z; - - no[0] = mbproc.vertices.ptr[a].normal.x; - no[1] = mbproc.vertices.ptr[a].normal.y; - no[2] = mbproc.vertices.ptr[a].normal.z; + for (a = 0; a < mbproc.vertices.count; ptr++, a++, no += 3, co += 3) { + copy_v3_v3(co, ptr->co); + copy_v3_v3(no, ptr->no); } } @@ -2403,29 +2354,30 @@ int BKE_mball_minmax(MetaBall *mb, float min[3], float max[3]) return (mb->elems.first != NULL); } -int BKE_mball_center_median(MetaBall *mb, float cent[3]) +int BKE_mball_center_median(MetaBall *mb, float r_cent[3]) { MetaElem *ml; int total = 0; - zero_v3(cent); + zero_v3(r_cent); for (ml = mb->elems.first; ml; ml = ml->next) { - add_v3_v3(cent, &ml->x); + add_v3_v3(r_cent, &ml->x); } - if (total) - mul_v3_fl(cent, 1.0f / (float)total); + if (total) { + mul_v3_fl(r_cent, 1.0f / (float)total); + } return (total != 0); } -int BKE_mball_center_bounds(MetaBall *mb, float cent[3]) +int BKE_mball_center_bounds(MetaBall *mb, float r_cent[3]) { float min[3], max[3]; if (BKE_mball_minmax(mb, min, max)) { - mid_v3_v3v3(cent, min, max); + mid_v3_v3v3(r_cent, min, max); return 1; } From 12425588f2d33174e4a78873075b185ea51ebc3d Mon Sep 17 00:00:00 2001 From: Nicholas Bishop Date: Sat, 18 Aug 2012 19:54:21 +0000 Subject: [PATCH 007/163] Fix simple subsurf on wire edges Subsurf on wire edges gave smooth results even if set to simple subdiv. Added a field to the CCG meshIFC to flag simple subdivision, then when syncing vertices simply skip moving vertices if in simple-subdiv mode. This change affects two places, the level-1 build in sync and the subdivision up to other levels. Fixes bug [#32268] Simple Subsurf Modifier gives unexpected results on edges without faces projects.blender.org/tracker/index.php?func=detail&aid=32268&group_id=9&atid=498 --- source/blender/blenkernel/intern/CCGSubSurf.c | 9 +++++++-- source/blender/blenkernel/intern/CCGSubSurf.h | 2 ++ .../blender/blenkernel/intern/subsurf_ccg.c | 19 ++++++++++++------- 3 files changed, 21 insertions(+), 9 deletions(-) diff --git a/source/blender/blenkernel/intern/CCGSubSurf.c b/source/blender/blenkernel/intern/CCGSubSurf.c index c456840637a..387d4775ad4 100644 --- a/source/blender/blenkernel/intern/CCGSubSurf.c +++ b/source/blender/blenkernel/intern/CCGSubSurf.c @@ -1798,7 +1798,7 @@ static void ccgSubSurf__calcSubdivLevel(CCGSubSurf *ss, if (seamEdges < 2 || seamEdges != v->numEdges) seam = 0; - if (!v->numEdges) { + if (!v->numEdges || ss->meshIFC.simpleSubdiv) { VertDataCopy(nCo, co, ss); } else if (_vert_isBoundary(v)) { @@ -2246,7 +2246,7 @@ static void ccgSubSurf__sync(CCGSubSurf *ss) if (seamEdges < 2 || seamEdges != v->numEdges) seam = 0; - if (!v->numEdges) { + if (!v->numEdges || ss->meshIFC.simpleSubdiv) { VertDataCopy(nCo, co, ss); } else if (_vert_isBoundary(v)) { @@ -2827,6 +2827,11 @@ int ccgSubSurf_getGridLevelSize(const CCGSubSurf *ss, int level) } } +int ccgSubSurf_getSimpleSubdiv(const CCGSubSurf *ss) +{ + return ss->meshIFC.simpleSubdiv; +} + /* Vert accessors */ CCGVertHDL ccgSubSurf_getVertVertHandle(CCGVert *v) diff --git a/source/blender/blenkernel/intern/CCGSubSurf.h b/source/blender/blenkernel/intern/CCGSubSurf.h index 33b37ac281c..0f96bcf172d 100644 --- a/source/blender/blenkernel/intern/CCGSubSurf.h +++ b/source/blender/blenkernel/intern/CCGSubSurf.h @@ -17,6 +17,7 @@ typedef struct CCGMeshIFC { int vertUserSize, edgeUserSize, faceUserSize; int numLayers; int vertDataSize; + int simpleSubdiv; } CCGMeshIFC; /***/ @@ -91,6 +92,7 @@ int ccgSubSurf_getEdgeSize (const CCGSubSurf *ss); int ccgSubSurf_getEdgeLevelSize (const CCGSubSurf *ss, int level); int ccgSubSurf_getGridSize (const CCGSubSurf *ss); int ccgSubSurf_getGridLevelSize (const CCGSubSurf *ss, int level); +int ccgSubSurf_getSimpleSubdiv (const CCGSubSurf *ss); CCGVert* ccgSubSurf_getVert (CCGSubSurf *ss, CCGVertHDL v); CCGVertHDL ccgSubSurf_getVertVertHandle (CCGVert *v); diff --git a/source/blender/blenkernel/intern/subsurf_ccg.c b/source/blender/blenkernel/intern/subsurf_ccg.c index 5c387e8cee0..b2762d23ef3 100644 --- a/source/blender/blenkernel/intern/subsurf_ccg.c +++ b/source/blender/blenkernel/intern/subsurf_ccg.c @@ -113,7 +113,8 @@ typedef enum { CCG_USE_ARENA = 2, CCG_CALC_NORMALS = 4, /* add an extra four bytes for a mask layer */ - CCG_ALLOC_MASK = 8 + CCG_ALLOC_MASK = 8, + CCG_SIMPLE_SUBDIV = 16 } CCGFlags; static CCGSubSurf *_getSubSurf(CCGSubSurf *prevSS, int subdivLevels, @@ -133,7 +134,10 @@ static CCGSubSurf *_getSubSurf(CCGSubSurf *prevSS, int subdivLevels, ccgSubSurf_getUseAgeCounts(prevSS, &oldUseAging, NULL, NULL, NULL); - if (oldUseAging != useAging) { + if ((oldUseAging != useAging) || + (ccgSubSurf_getSimpleSubdiv(prevSS) != + !!(flags & CCG_SIMPLE_SUBDIV))) + { ccgSubSurf_free(prevSS); } else { @@ -156,6 +160,7 @@ static CCGSubSurf *_getSubSurf(CCGSubSurf *prevSS, int subdivLevels, ifc.vertDataSize += sizeof(float) * 3; if (flags & CCG_ALLOC_MASK) ifc.vertDataSize += sizeof(float); + ifc.simpleSubdiv = !!(flags & CCG_SIMPLE_SUBDIV); if (useArena) { CCGAllocatorIFC allocatorIFC; @@ -3474,7 +3479,7 @@ struct DerivedMesh *subsurf_make_derived_from_derived( float (*vertCos)[3], SubsurfFlags flags) { - int useSimple = smd->subdivType == ME_SIMPLE_SUBSURF; + int useSimple = (smd->subdivType == ME_SIMPLE_SUBSURF) ? CCG_SIMPLE_SUBDIV : 0; CCGFlags useAging = smd->flags & eSubsurfModifierFlag_DebugIncr ? CCG_USE_AGING : 0; int useSubsurfUv = smd->flags & eSubsurfModifierFlag_SubsurfUv; int drawInteriorEdges = !(smd->flags & eSubsurfModifierFlag_ControlEdges); @@ -3483,7 +3488,7 @@ struct DerivedMesh *subsurf_make_derived_from_derived( if (flags & SUBSURF_FOR_EDIT_MODE) { int levels = (smd->modifier.scene) ? get_render_subsurf_level(&smd->modifier.scene->r, smd->levels) : smd->levels; - smd->emCache = _getSubSurf(smd->emCache, levels, 3, useAging | CCG_CALC_NORMALS); + smd->emCache = _getSubSurf(smd->emCache, levels, 3, useSimple | useAging | CCG_CALC_NORMALS); ss_sync_from_derivedmesh(smd->emCache, dm, vertCos, useSimple); result = getCCGDerivedMesh(smd->emCache, @@ -3498,7 +3503,7 @@ struct DerivedMesh *subsurf_make_derived_from_derived( if (levels == 0) return dm; - ss = _getSubSurf(NULL, levels, 3, CCG_USE_ARENA | CCG_CALC_NORMALS); + ss = _getSubSurf(NULL, levels, 3, useSimple | CCG_USE_ARENA | CCG_CALC_NORMALS); ss_sync_from_derivedmesh(ss, dm, vertCos, useSimple); @@ -3529,7 +3534,7 @@ struct DerivedMesh *subsurf_make_derived_from_derived( } if (useIncremental && (flags & SUBSURF_IS_FINAL_CALC)) { - smd->mCache = ss = _getSubSurf(smd->mCache, levels, 3, useAging | CCG_CALC_NORMALS); + smd->mCache = ss = _getSubSurf(smd->mCache, levels, 3, useSimple | useAging | CCG_CALC_NORMALS); ss_sync_from_derivedmesh(ss, dm, vertCos, useSimple); @@ -3538,7 +3543,7 @@ struct DerivedMesh *subsurf_make_derived_from_derived( useSubsurfUv, dm); } else { - CCGFlags ccg_flags = CCG_USE_ARENA | CCG_CALC_NORMALS; + CCGFlags ccg_flags = useSimple | CCG_USE_ARENA | CCG_CALC_NORMALS; if (smd->mCache && (flags & SUBSURF_IS_FINAL_CALC)) { ccgSubSurf_free(smd->mCache); From ab662a1e02299691867c3c4480000d630377ea37 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 18 Aug 2012 20:54:43 +0000 Subject: [PATCH 008/163] fix for own commit r49991, this exposed bad logic in rect copy function. --- source/blender/blenlib/BLI_rect.h | 3 ++- source/blender/blenlib/intern/rct.c | 18 +++++++++++++----- source/blender/editors/interface/interface.c | 5 +---- .../editors/interface/interface_handlers.c | 19 ++++++------------- .../editors/interface/interface_panel.c | 2 +- .../editors/space_view3d/view3d_view.c | 5 +---- 6 files changed, 24 insertions(+), 28 deletions(-) diff --git a/source/blender/blenlib/BLI_rect.h b/source/blender/blenlib/BLI_rect.h index 55ab961cc53..d6579afcd0d 100644 --- a/source/blender/blenlib/BLI_rect.h +++ b/source/blender/blenlib/BLI_rect.h @@ -69,7 +69,8 @@ int BLI_rctf_isect(const struct rctf *src1, const struct rctf *src2, struct rct int BLI_rcti_isect(const struct rcti *src1, const struct rcti *src2, struct rcti *dest); void BLI_rctf_union(struct rctf *rctf1, const struct rctf *rctf2); void BLI_rcti_union(struct rcti *rcti1, const struct rcti *rcti2); -void BLI_rcti_rctf_copy(struct rcti *tar, const struct rctf *src); +void BLI_rcti_rctf_copy(struct rcti *dst, const struct rctf *src); +void BLI_rctf_rcti_copy(struct rctf *dst, const struct rcti *src); void print_rctf(const char *str, const struct rctf *rect); void print_rcti(const char *str, const struct rcti *rect); diff --git a/source/blender/blenlib/intern/rct.c b/source/blender/blenlib/intern/rct.c index e22becddfd6..9c65c26c72b 100644 --- a/source/blender/blenlib/intern/rct.c +++ b/source/blender/blenlib/intern/rct.c @@ -363,12 +363,20 @@ int BLI_rcti_isect(const rcti *src1, const rcti *src2, rcti *dest) } } -void BLI_rcti_rctf_copy(rcti *tar, const rctf *src) +void BLI_rcti_rctf_copy(rcti *dst, const rctf *src) { - tar->xmin = floorf(src->xmin + 0.5f); - tar->xmax = floorf((src->xmax - src->xmin) + 0.5f); - tar->ymin = floorf(src->ymin + 0.5f); - tar->ymax = floorf((src->ymax - src->ymin) + 0.5f); + dst->xmin = floorf(src->xmin + 0.5f); + dst->xmax = dst->xmin + floorf((src->xmax - src->xmin) + 0.5f); + dst->ymin = floorf(src->ymin + 0.5f); + dst->ymax = dst->ymin + floorf((src->ymax - src->ymin) + 0.5f); +} + +void BLI_rctf_rcti_copy(rctf *dst, const rcti *src) +{ + dst->xmin = src->xmin; + dst->xmax = src->xmax; + dst->ymin = src->ymin; + dst->ymax = src->ymax; } void print_rctf(const char *str, const rctf *rect) diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c index 7185946f4fe..e7eb1e3a698 100644 --- a/source/blender/editors/interface/interface.c +++ b/source/blender/editors/interface/interface.c @@ -137,10 +137,7 @@ void ui_block_to_window_rct(const ARegion *ar, uiBlock *block, rctf *graph, rcti ui_block_to_window_fl(ar, block, &tmpr.xmin, &tmpr.ymin); ui_block_to_window_fl(ar, block, &tmpr.xmax, &tmpr.ymax); - winr->xmin = tmpr.xmin; - winr->ymin = tmpr.ymin; - winr->xmax = tmpr.xmax; - winr->ymax = tmpr.ymax; + BLI_rcti_rctf_copy(winr, &tmpr); } void ui_window_to_block_fl(const ARegion *ar, uiBlock *block, float *x, float *y) /* for mouse cursor */ diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c index 55249e66521..5226b2ae9e3 100644 --- a/source/blender/editors/interface/interface_handlers.c +++ b/source/blender/editors/interface/interface_handlers.c @@ -3347,9 +3347,8 @@ static int ui_numedit_but_HSVCIRCLE(uiBut *but, uiHandleButtonData *data, float ui_mouse_scale_warp(data, mx, my, &mx_fl, &my_fl, shift); - rect.xmin = but->rect.xmin; rect.xmax = but->rect.xmax; - rect.ymin = but->rect.ymin; rect.ymax = but->rect.ymax; - + BLI_rcti_rctf_copy(&rect, &but->rect); + ui_get_but_vectorf(but, rgb); copy_v3_v3(hsv, ui_block_hsv_get(but->block)); rgb_to_hsv_compat_v(rgb, hsv); @@ -3856,8 +3855,7 @@ static int ui_numedit_but_HISTOGRAM(uiBut *but, uiHandleButtonData *data, int mx int changed = 1; float /* dx, */ dy; /* UNUSED */ - /* rect.xmin = but->rect.xmin; rect.xmax = but->rect.xmax; */ - /* rect.ymin = but->rect.ymin; rect.ymax = but->rect.ymax; */ + /* BLI_rcti_rctf_copy(&rect, &but->rect); */ /* dx = mx - data->draglastx; */ /* UNUSED */ dy = my - data->draglasty; @@ -3940,8 +3938,7 @@ static int ui_numedit_but_WAVEFORM(uiBut *but, uiHandleButtonData *data, int mx, int changed = 1; float /* dx, */ dy /* , yfac=1.f */; /* UNUSED */ - /* rect.xmin = but->rect.xmin; rect.xmax = but->rect.xmax; */ - /* rect.ymin = but->rect.ymin; rect.ymax = but->rect.ymax; */ + /* BLI_rcti_rctf_copy(&rect, &but->rect); */ /* dx = mx - data->draglastx; */ /* UNUSED */ dy = my - data->draglasty; @@ -4024,8 +4021,7 @@ static int ui_numedit_but_VECTORSCOPE(uiBut *but, uiHandleButtonData *data, int int changed = 1; /* float dx, dy; */ - /* rect.xmin = but->rect.xmin; rect.xmax = but->rect.xmax; */ - /* rect.ymin = but->rect.ymin; rect.ymax = but->rect.ymax; */ + /* BLI_rcti_rctf_copy(&rect, &but->rect); */ /* dx = mx - data->draglastx; */ /* dy = my - data->draglasty; */ @@ -5019,10 +5015,7 @@ static int ui_mouse_inside_region(ARegion *ar, int x, int y) ui_window_to_region(ar, &mx, &my); /* make a copy of the mask rect, and tweak accordingly for hidden scrollbars */ - mask_rct.xmin = v2d->mask.xmin; - mask_rct.xmax = v2d->mask.xmax; - mask_rct.ymin = v2d->mask.ymin; - mask_rct.ymax = v2d->mask.ymax; + mask_rct = v2d->mask; if (v2d->scroll & (V2D_SCROLL_VERTICAL_HIDE | V2D_SCROLL_VERTICAL_FULLR)) { if (v2d->scroll & V2D_SCROLL_LEFT) diff --git a/source/blender/editors/interface/interface_panel.c b/source/blender/editors/interface/interface_panel.c index 79aff82fe6f..501a5cf91b0 100644 --- a/source/blender/editors/interface/interface_panel.c +++ b/source/blender/editors/interface/interface_panel.c @@ -422,7 +422,7 @@ static void ui_draw_panel_scalewidget(rcti *rect) glDisable(GL_BLEND); } -static void ui_draw_panel_dragwidget(rctf *rect) +static void ui_draw_panel_dragwidget(const rctf *rect) { float xmin, xmax, dx; float ymin, ymax, dy; diff --git a/source/blender/editors/space_view3d/view3d_view.c b/source/blender/editors/space_view3d/view3d_view.c index 93d70004b18..fbbf23beca4 100644 --- a/source/blender/editors/space_view3d/view3d_view.c +++ b/source/blender/editors/space_view3d/view3d_view.c @@ -1212,10 +1212,7 @@ short view3d_opengl_select(ViewContext *vc, unsigned int *buffer, unsigned int b rect.ymax = input->ymin + 12; } else { - rect.xmin = input->xmin; - rect.xmax = input->xmax; - rect.ymin = input->ymin; - rect.ymax = input->ymax; + BLI_rctf_rcti_copy(&rect, input); } setwinmatrixview3d(ar, v3d, &rect); From 4120c18c47d111b6988297a3d6d4daaa7624fb43 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 18 Aug 2012 21:12:08 +0000 Subject: [PATCH 009/163] re-enable metaball orientation for manipulator and view axis setting (was disabled since 2.4x) --- .../transform/transform_orientations.c | 30 +++++-------------- 1 file changed, 7 insertions(+), 23 deletions(-) diff --git a/source/blender/editors/transform/transform_orientations.c b/source/blender/editors/transform/transform_orientations.c index b9583fc21e1..237f6b35eb0 100644 --- a/source/blender/editors/transform/transform_orientations.c +++ b/source/blender/editors/transform/transform_orientations.c @@ -33,6 +33,7 @@ #include "DNA_armature_types.h" #include "DNA_curve_types.h" #include "DNA_mesh_types.h" +#include "DNA_meta_types.h" #include "DNA_object_types.h" #include "DNA_scene_types.h" #include "DNA_screen_types.h" @@ -549,8 +550,8 @@ int getTransformOrientation(const bContext *C, float normal[3], float plane[3], Object *ob = OBACT; int result = ORIENTATION_NONE; - normal[0] = normal[1] = normal[2] = 0; - plane[0] = plane[1] = plane[2] = 0; + zero_v3(normal); + zero_v3(plane); if (obedit) { float imat[3][3], mat[3][3]; @@ -743,37 +744,20 @@ int getTransformOrientation(const bContext *C, float normal[3], float plane[3], } } else if (obedit->type == OB_MBALL) { -#if 0 // XXX - /* editmball.c */ - MetaElem *ml, *ml_sel = NULL; - - /* loop and check that only one element is selected */ - for (ml = editelems.first; ml; ml = ml->next) { - if (ml->flag & SELECT) { - if (ml_sel == NULL) { - ml_sel = ml; - } - else { - ml_sel = NULL; - break; - } - } - } + MetaBall *mb = obedit->data; - if (ml_sel) { + if (mb->lastelem) { float mat[4][4]; /* Rotation of MetaElem is stored in quat */ - quat_to_mat4(mat, ml_sel->quat); + quat_to_mat4(mat, mb->lastelem->quat); copy_v3_v3(normal, mat[2]); negate_v3_v3(plane, mat[1]); - result = ORIENTATION_NORMAL; + result = ORIENTATION_FACE; } -#endif - } else if (obedit->type == OB_ARMATURE) { bArmature *arm = obedit->data; From e4a6602a9ac9c7d43a882770f19323b6d5616a4b Mon Sep 17 00:00:00 2001 From: Mitchell Stokes Date: Sat, 18 Aug 2012 23:46:37 +0000 Subject: [PATCH 010/163] Fix for [#32361] "Blenderplayer quad-buffer maximum 100Hz Fps" reported by HG1. Allowing the Blenderplayer to break 100fps by making it less dependent on Ghost's messages. --- .../GamePlayer/ghost/GPG_Application.cpp | 73 +++++++++++++------ .../GamePlayer/ghost/GPG_Application.h | 1 + .../gameengine/GamePlayer/ghost/GPG_ghost.cpp | 2 + 3 files changed, 52 insertions(+), 24 deletions(-) diff --git a/source/gameengine/GamePlayer/ghost/GPG_Application.cpp b/source/gameengine/GamePlayer/ghost/GPG_Application.cpp index eccb83fe80c..21de7011eda 100644 --- a/source/gameengine/GamePlayer/ghost/GPG_Application.cpp +++ b/source/gameengine/GamePlayer/ghost/GPG_Application.cpp @@ -464,31 +464,34 @@ bool GPG_Application::processEvent(GHOST_IEvent* event) handled = false; break; - case GHOST_kEventWindowUpdate: - { - GHOST_IWindow* window = event->getWindow(); - if (!m_system->validWindow(window)) break; - // Update the state of the game engine - if (m_kxsystem && !m_exitRequested) - { - // Proceed to next frame - window->activateDrawingContext(); + // The player now runs as often as it can (repsecting vsync and fixedtime). + // This allows the player to break 100fps, but this code is being left here + // as reference. (see EngineNextFrame) + //case GHOST_kEventWindowUpdate: + // { + // GHOST_IWindow* window = event->getWindow(); + // if (!m_system->validWindow(window)) break; + // // Update the state of the game engine + // if (m_kxsystem && !m_exitRequested) + // { + // // Proceed to next frame + // window->activateDrawingContext(); - // first check if we want to exit - m_exitRequested = m_ketsjiengine->GetExitCode(); - - // kick the engine - bool renderFrame = m_ketsjiengine->NextFrame(); - if (renderFrame) - { - // render the frame - m_ketsjiengine->Render(); - } - } - m_exitString = m_ketsjiengine->GetExitString(); - } - break; - + // // first check if we want to exit + // m_exitRequested = m_ketsjiengine->GetExitCode(); + // + // // kick the engine + // bool renderFrame = m_ketsjiengine->NextFrame(); + // if (renderFrame) + // { + // // render the frame + // m_ketsjiengine->Render(); + // } + // } + // m_exitString = m_ketsjiengine->GetExitString(); + // } + // break; + // case GHOST_kEventWindowSize: { GHOST_IWindow* window = event->getWindow(); @@ -789,6 +792,28 @@ void GPG_Application::stopEngine() m_engineRunning = false; } +void GPG_Application::EngineNextFrame() +{ + // Update the state of the game engine + if (m_kxsystem && !m_exitRequested) + { + // Proceed to next frame + if (m_mainWindow) + m_mainWindow->activateDrawingContext(); + + // first check if we want to exit + m_exitRequested = m_ketsjiengine->GetExitCode(); + + // kick the engine + bool renderFrame = m_ketsjiengine->NextFrame(); + if (renderFrame && m_mainWindow) + { + // render the frame + m_ketsjiengine->Render(); + } + } + m_exitString = m_ketsjiengine->GetExitString(); +} void GPG_Application::exitEngine() { diff --git a/source/gameengine/GamePlayer/ghost/GPG_Application.h b/source/gameengine/GamePlayer/ghost/GPG_Application.h index 51dac5cb3f3..e04fcc2a555 100644 --- a/source/gameengine/GamePlayer/ghost/GPG_Application.h +++ b/source/gameengine/GamePlayer/ghost/GPG_Application.h @@ -77,6 +77,7 @@ public: GlobalSettings* getGlobalSettings(void); bool StartGameEngine(int stereoMode); void StopGameEngine(); + void EngineNextFrame(); protected: bool handleWheel(GHOST_IEvent* event); diff --git a/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp b/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp index 025611972ce..63f2988e259 100644 --- a/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp +++ b/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp @@ -970,6 +970,8 @@ int main(int argc, char** argv) { system->processEvents(false); system->dispatchEvents(); + app.EngineNextFrame(); + if ((exitcode = app.getExitRequested())) { run = false; From 48eb27791bcd0b28b3fad384552009fa4b712d00 Mon Sep 17 00:00:00 2001 From: Dalai Felinto Date: Sun, 19 Aug 2012 03:05:38 +0000 Subject: [PATCH 011/163] The Distance Node in 2.49/2.5/2.6 pre-tiles has a different calculation for RGB and YCC. While RGB calculate the distance in 3d between R,G and B, the YCC only takes Cb and Cr into consideration. This commit makes COM_DistanceMatteOperation inheritable and expose the calculate distance function to be re-implemented for the YCC node operation. Thanks Troy Sobotka for the report over email. Patch incorporates review suggestions by Jeroen Bakker. --- source/blender/compositor/CMakeLists.txt | 6 ++- .../nodes/COM_DistanceMatteNode.cpp | 33 +++++++++++--- ....cpp => COM_DistanceRGBMatteOperation.cpp} | 28 ++++++------ ...tion.h => COM_DistanceRGBMatteOperation.h} | 13 +++--- .../COM_DistanceYCCMatteOperation.cpp | 35 +++++++++++++++ .../COM_DistanceYCCMatteOperation.h | 43 +++++++++++++++++++ 6 files changed, 134 insertions(+), 24 deletions(-) rename source/blender/compositor/operations/{COM_DistanceMatteOperation.cpp => COM_DistanceRGBMatteOperation.cpp} (73%) rename source/blender/compositor/operations/{COM_DistanceMatteOperation.h => COM_DistanceRGBMatteOperation.h} (84%) create mode 100644 source/blender/compositor/operations/COM_DistanceYCCMatteOperation.cpp create mode 100644 source/blender/compositor/operations/COM_DistanceYCCMatteOperation.h diff --git a/source/blender/compositor/CMakeLists.txt b/source/blender/compositor/CMakeLists.txt index 65d46bf515a..c110d4f077e 100644 --- a/source/blender/compositor/CMakeLists.txt +++ b/source/blender/compositor/CMakeLists.txt @@ -473,8 +473,10 @@ set(SRC operations/COM_DifferenceMatteOperation.h operations/COM_LuminanceMatteOperation.cpp operations/COM_LuminanceMatteOperation.h - operations/COM_DistanceMatteOperation.cpp - operations/COM_DistanceMatteOperation.h + operations/COM_DistanceRGBMatteOperation.cpp + operations/COM_DistanceRGBMatteOperation.h + operations/COM_DistanceYCCMatteOperation.cpp + operations/COM_DistanceYCCMatteOperation.h operations/COM_ChromaMatteOperation.cpp operations/COM_ChromaMatteOperation.h operations/COM_ColorMatteOperation.cpp diff --git a/source/blender/compositor/nodes/COM_DistanceMatteNode.cpp b/source/blender/compositor/nodes/COM_DistanceMatteNode.cpp index d6730ef6a00..87e7b9d0788 100644 --- a/source/blender/compositor/nodes/COM_DistanceMatteNode.cpp +++ b/source/blender/compositor/nodes/COM_DistanceMatteNode.cpp @@ -21,8 +21,10 @@ #include "COM_DistanceMatteNode.h" #include "BKE_node.h" -#include "COM_DistanceMatteOperation.h" +#include "COM_DistanceRGBMatteOperation.h" +#include "COM_DistanceYCCMatteOperation.h" #include "COM_SetAlphaOperation.h" +#include "COM_ConvertRGBToYCCOperation.h" DistanceMatteNode::DistanceMatteNode(bNode *editorNode) : Node(editorNode) { @@ -36,12 +38,33 @@ void DistanceMatteNode::convertToOperations(ExecutionSystem *graph, CompositorCo OutputSocket *outputSocketImage = this->getOutputSocket(0); OutputSocket *outputSocketMatte = this->getOutputSocket(1); - DistanceMatteOperation *operation = new DistanceMatteOperation(); + NodeOperation *operation; bNode *editorsnode = getbNode(); - operation->setSettings((NodeChroma *)editorsnode->storage); + NodeChroma *storage = (NodeChroma *)editorsnode->storage; - inputSocketImage->relinkConnections(operation->getInputSocket(0), 0, graph); - inputSocketKey->relinkConnections(operation->getInputSocket(1), 1, graph); + /* work in RGB color space */ + if (storage->channel == 1) { + operation = new DistanceRGBMatteOperation(); + ((DistanceRGBMatteOperation *) operation)->setSettings(storage); + + inputSocketImage->relinkConnections(operation->getInputSocket(0), 0, graph); + inputSocketKey->relinkConnections(operation->getInputSocket(1), 1, graph); + } + /* work in YCbCr color space */ + else { + operation = new DistanceYCCMatteOperation(); + ((DistanceYCCMatteOperation *) operation)->setSettings(storage); + + ConvertRGBToYCCOperation *operationYCCImage = new ConvertRGBToYCCOperation(); + inputSocketImage->relinkConnections(operationYCCImage->getInputSocket(0), 0, graph); + addLink(graph, operationYCCImage->getOutputSocket(), operation->getInputSocket(0)); + graph->addOperation(operationYCCImage); + + ConvertRGBToYCCOperation *operationYCCMatte = new ConvertRGBToYCCOperation(); + inputSocketKey->relinkConnections(operationYCCMatte->getInputSocket(0), 1, graph); + addLink(graph, operationYCCMatte->getOutputSocket(), operation->getInputSocket(1)); + graph->addOperation(operationYCCMatte); + } if (outputSocketMatte->isConnected()) { outputSocketMatte->relinkConnections(operation->getOutputSocket()); diff --git a/source/blender/compositor/operations/COM_DistanceMatteOperation.cpp b/source/blender/compositor/operations/COM_DistanceRGBMatteOperation.cpp similarity index 73% rename from source/blender/compositor/operations/COM_DistanceMatteOperation.cpp rename to source/blender/compositor/operations/COM_DistanceRGBMatteOperation.cpp index b65b5e0f224..df3809ba129 100644 --- a/source/blender/compositor/operations/COM_DistanceMatteOperation.cpp +++ b/source/blender/compositor/operations/COM_DistanceRGBMatteOperation.cpp @@ -19,32 +19,39 @@ * Dalai Felinto */ -#include "COM_DistanceMatteOperation.h" +#include "COM_DistanceRGBMatteOperation.h" #include "BLI_math.h" -DistanceMatteOperation::DistanceMatteOperation() : NodeOperation() +DistanceRGBMatteOperation::DistanceRGBMatteOperation() : NodeOperation() { - addInputSocket(COM_DT_COLOR); - addInputSocket(COM_DT_COLOR); - addOutputSocket(COM_DT_VALUE); + this->addInputSocket(COM_DT_COLOR); + this->addInputSocket(COM_DT_COLOR); + this->addOutputSocket(COM_DT_VALUE); this->m_inputImageProgram = NULL; this->m_inputKeyProgram = NULL; } -void DistanceMatteOperation::initExecution() +void DistanceRGBMatteOperation::initExecution() { this->m_inputImageProgram = this->getInputSocketReader(0); this->m_inputKeyProgram = this->getInputSocketReader(1); } -void DistanceMatteOperation::deinitExecution() +void DistanceRGBMatteOperation::deinitExecution() { this->m_inputImageProgram = NULL; this->m_inputKeyProgram = NULL; } -void DistanceMatteOperation::executePixel(float output[4], float x, float y, PixelSampler sampler) +float DistanceRGBMatteOperation::calculateDistance(float key[4], float image[4]) +{ + return sqrt(pow((key[0] - image[0]), 2) + + pow((key[1] - image[1]), 2) + + pow((key[2] - image[2]), 2)); +} + +void DistanceRGBMatteOperation::executePixel(float output[4], float x, float y, PixelSampler sampler) { float inKey[4]; float inImage[4]; @@ -58,9 +65,7 @@ void DistanceMatteOperation::executePixel(float output[4], float x, float y, Pix this->m_inputKeyProgram->read(inKey, x, y, sampler); this->m_inputImageProgram->read(inImage, x, y, sampler); - distance = sqrt(pow((inKey[0] - inImage[0]), 2) + - pow((inKey[1] - inImage[1]), 2) + - pow((inKey[2] - inImage[2]), 2)); + distance = this->calculateDistance(inKey, inImage); /* store matte(alpha) value in [0] to go with * COM_SetAlphaOperation and the Value output @@ -87,4 +92,3 @@ void DistanceMatteOperation::executePixel(float output[4], float x, float y, Pix output[0] = inImage[3]; } } - diff --git a/source/blender/compositor/operations/COM_DistanceMatteOperation.h b/source/blender/compositor/operations/COM_DistanceRGBMatteOperation.h similarity index 84% rename from source/blender/compositor/operations/COM_DistanceMatteOperation.h rename to source/blender/compositor/operations/COM_DistanceRGBMatteOperation.h index a176e5da888..5a34135b1a4 100644 --- a/source/blender/compositor/operations/COM_DistanceMatteOperation.h +++ b/source/blender/compositor/operations/COM_DistanceRGBMatteOperation.h @@ -19,8 +19,8 @@ * Dalai Felinto */ -#ifndef _COM_DistanceMatteOperation_h -#define _COM_DistanceMatteOperation_h +#ifndef _COM_DistanceRGBMatteOperation_h +#define _COM_DistanceRGBMatteOperation_h #include "COM_MixBaseOperation.h" @@ -28,16 +28,19 @@ * this program converts an input color to an output value. * it assumes we are in sRGB color space. */ -class DistanceMatteOperation : public NodeOperation { -private: +class DistanceRGBMatteOperation : public NodeOperation { +protected: NodeChroma *m_settings; SocketReader *m_inputImageProgram; SocketReader *m_inputKeyProgram; + + virtual float calculateDistance(float key[4], float image[4]); + public: /** * Default constructor */ - DistanceMatteOperation(); + DistanceRGBMatteOperation(); /** * the inner loop of this program diff --git a/source/blender/compositor/operations/COM_DistanceYCCMatteOperation.cpp b/source/blender/compositor/operations/COM_DistanceYCCMatteOperation.cpp new file mode 100644 index 00000000000..32ed7486f5b --- /dev/null +++ b/source/blender/compositor/operations/COM_DistanceYCCMatteOperation.cpp @@ -0,0 +1,35 @@ +/* + * Copyright 2011, Blender Foundation. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Contributor: + * Dalai Felinto + */ + +#include "COM_DistanceYCCMatteOperation.h" +#include "BLI_math.h" + +DistanceYCCMatteOperation::DistanceYCCMatteOperation() : DistanceRGBMatteOperation() +{ + /* pass */ +} + +float DistanceYCCMatteOperation::calculateDistance(float key[4], float image[4]) +{ + return sqrt(pow((key[1] - image[1]), 2) + + pow((key[2] - image[2]), 2)); +} + diff --git a/source/blender/compositor/operations/COM_DistanceYCCMatteOperation.h b/source/blender/compositor/operations/COM_DistanceYCCMatteOperation.h new file mode 100644 index 00000000000..f4866a327f1 --- /dev/null +++ b/source/blender/compositor/operations/COM_DistanceYCCMatteOperation.h @@ -0,0 +1,43 @@ +/* + * Copyright 2011, Blender Foundation. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Contributor: + * Dalai Felinto + */ + +#ifndef _COM_DistanceYCCMatteOperation_h +#define _COM_DistanceYCCMatteOperation_h +#include "COM_MixBaseOperation.h" +#include "COM_DistanceRGBMatteOperation.h" + + +/** + * this program converts an input color to an output value. + * it assumes we are in sRGB color space. + */ +class DistanceYCCMatteOperation : public DistanceRGBMatteOperation { +protected: + virtual float calculateDistance(float key[4], float image[4]); + +public: + /** + * Default constructor + */ + DistanceYCCMatteOperation(); + +}; +#endif From 58ab8d5c0a7e64b077e21ab2da19bca02f92ae66 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 19 Aug 2012 10:41:16 +0000 Subject: [PATCH 012/163] use BLI math length functions for distance compositor operations. --- .../compositor/operations/COM_DistanceRGBMatteOperation.cpp | 4 +--- .../compositor/operations/COM_DistanceYCCMatteOperation.cpp | 4 ++-- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/source/blender/compositor/operations/COM_DistanceRGBMatteOperation.cpp b/source/blender/compositor/operations/COM_DistanceRGBMatteOperation.cpp index df3809ba129..d3309e0c978 100644 --- a/source/blender/compositor/operations/COM_DistanceRGBMatteOperation.cpp +++ b/source/blender/compositor/operations/COM_DistanceRGBMatteOperation.cpp @@ -46,9 +46,7 @@ void DistanceRGBMatteOperation::deinitExecution() float DistanceRGBMatteOperation::calculateDistance(float key[4], float image[4]) { - return sqrt(pow((key[0] - image[0]), 2) + - pow((key[1] - image[1]), 2) + - pow((key[2] - image[2]), 2)); + return len_v3v3(key, image); } void DistanceRGBMatteOperation::executePixel(float output[4], float x, float y, PixelSampler sampler) diff --git a/source/blender/compositor/operations/COM_DistanceYCCMatteOperation.cpp b/source/blender/compositor/operations/COM_DistanceYCCMatteOperation.cpp index 32ed7486f5b..0a6f1fdfd31 100644 --- a/source/blender/compositor/operations/COM_DistanceYCCMatteOperation.cpp +++ b/source/blender/compositor/operations/COM_DistanceYCCMatteOperation.cpp @@ -29,7 +29,7 @@ DistanceYCCMatteOperation::DistanceYCCMatteOperation() : DistanceRGBMatteOperati float DistanceYCCMatteOperation::calculateDistance(float key[4], float image[4]) { - return sqrt(pow((key[1] - image[1]), 2) + - pow((key[2] - image[2]), 2)); + /* only measure the second 2 values */ + return len_v2v2(key + 1, image + 1); } From d36da8a8a1079d35aae445b76027a37c46f027be Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 19 Aug 2012 10:41:27 +0000 Subject: [PATCH 013/163] style cleanup --- source/blender/editors/interface/interface.c | 14 +++++----- .../editors/interface/interface_draw.c | 2 +- .../editors/interface/interface_handlers.c | 12 ++++++--- .../editors/interface/interface_icons.c | 2 +- .../editors/interface/interface_layout.c | 10 ++++--- .../blender/editors/interface/interface_ops.c | 2 +- .../editors/interface/interface_panel.c | 16 +++++------ .../editors/interface/interface_regions.c | 10 +++---- .../editors/interface/interface_templates.c | 5 ++-- .../editors/interface/interface_widgets.c | 27 ++++++++++--------- 10 files changed, 53 insertions(+), 47 deletions(-) diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c index e7eb1e3a698..62b26f5a8c1 100644 --- a/source/blender/editors/interface/interface.c +++ b/source/blender/editors/interface/interface.c @@ -238,7 +238,7 @@ static void ui_text_bounds_block(uiBlock *block, float offset) bt->rect.xmax = maxf(bt->rect.xmax, offset + block->minbounds); } - ui_check_but(bt); // clips text again + ui_check_but(bt); /* clips text again */ if (nextcol) x1addval += i + block->bounds; @@ -993,7 +993,7 @@ static void ui_but_to_pixelrect(rcti *rect, const ARegion *ar, uiBlock *block, u /* uses local copy of style, to scale things down, and allow widgets to change stuff */ void uiDrawBlock(const bContext *C, uiBlock *block) { - uiStyle style = *UI_GetStyle(); // XXX pass on as arg + uiStyle style = *UI_GetStyle(); /* XXX pass on as arg */ ARegion *ar; uiBut *but; rcti rect; @@ -1352,7 +1352,7 @@ int ui_is_but_unit(uiBut *but) if (unit_type == PROP_UNIT_NONE) return 0; -#if 1 // removed so angle buttons get correct snapping +#if 1 /* removed so angle buttons get correct snapping */ if (unit->system_rotation == USER_UNIT_ROT_RADIANS && unit_type == PROP_UNIT_ROTATION) return 0; #endif @@ -2095,7 +2095,7 @@ uiBlock *uiBeginBlock(const bContext *C, ARegion *region, const char *name, shor block = MEM_callocN(sizeof(uiBlock), "uiBlock"); block->active = 1; block->dt = dt; - block->evil_C = (void *)C; // XXX + block->evil_C = (void *)C; /* XXX */ if (scn) { block->color_profile = (scn->r.color_mgt_flag & R_COLOR_MANAGEMENT); @@ -2365,7 +2365,7 @@ static int buts_are_horiz(uiBut *but1, uiBut *but2) void uiBlockEndAlign(uiBlock *block) { - block->flag &= ~UI_BUT_ALIGN; // all 4 flags + block->flag &= ~UI_BUT_ALIGN; /* all 4 flags */ } int ui_but_can_align(uiBut *but) @@ -2588,8 +2588,8 @@ static uiBut *ui_def_but(uiBlock *block, int type, int retval, const char *str, but->lockstr = block->lockstr; but->dt = block->dt; - but->aspect = 1.0f; //XXX block->aspect; - but->block = block; // pointer back, used for frontbuffer status, and picker + but->aspect = 1.0f; /* XXX block->aspect; */ + but->block = block; /* pointer back, used for frontbuffer status, and picker */ if ((block->flag & UI_BUT_ALIGN) && ui_but_can_align(but)) but->alignnr = block->alignnr; diff --git a/source/blender/editors/interface/interface_draw.c b/source/blender/editors/interface/interface_draw.c index f7eff2cb22b..41a827bbda9 100644 --- a/source/blender/editors/interface/interface_draw.c +++ b/source/blender/editors/interface/interface_draw.c @@ -629,7 +629,7 @@ static void ui_draw_but_CHARTAB(uiBut *but) } } -#endif // WITH_INTERNATIONAL +#endif /* WITH_INTERNATIONAL */ #endif static void draw_scope_end(rctf *rect, GLint *scissor) diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c index 5226b2ae9e3..4010274f687 100644 --- a/source/blender/editors/interface/interface_handlers.c +++ b/source/blender/editors/interface/interface_handlers.c @@ -4707,7 +4707,6 @@ static int ui_but_menu(bContext *C, uiBut *but) static int ui_do_button(bContext *C, uiBlock *block, uiBut *but, wmEvent *event) { -// Scene *scene= CTX_data_scene(C); uiHandleButtonData *data; int retval; @@ -4874,7 +4873,7 @@ static int ui_do_button(bContext *C, uiBlock *block, uiBut *but, wmEvent *event) retval = ui_do_but_BUT(C, but, data, event); break; case COL: - if (but->a1 == UI_GRAD_V_ALT) // signal to prevent calling up color picker + if (but->a1 == UI_GRAD_V_ALT) /* signal to prevent calling up color picker */ retval = ui_do_but_EXIT(C, but, data, event); else retval = ui_do_but_BLOCK(C, but, data, event); @@ -5280,8 +5279,13 @@ static void button_activate_init(bContext *C, ARegion *ar, uiBut *but, uiButtonA data->wm = CTX_wm_manager(C); data->window = CTX_wm_window(C); data->region = ar; - if (ELEM(but->type, BUT_CURVE, SEARCH_MENU) ) ; // XXX curve is temp - else data->interactive = 1; + + if (ELEM(but->type, BUT_CURVE, SEARCH_MENU)) { + /* XXX curve is temp */ + } + else { + data->interactive = 1; + } data->state = BUTTON_STATE_INIT; diff --git a/source/blender/editors/interface/interface_icons.c b/source/blender/editors/interface/interface_icons.c index 2bfead708be..dd3c2e491a7 100644 --- a/source/blender/editors/interface/interface_icons.c +++ b/source/blender/editors/interface/interface_icons.c @@ -596,7 +596,7 @@ static void init_internal_icons(void) IMB_freeImBuf(bbuf); } -#endif // WITH_HEADLESS +#endif /* WITH_HEADLESS */ static void init_iconfile_list(struct ListBase *list) { diff --git a/source/blender/editors/interface/interface_layout.c b/source/blender/editors/interface/interface_layout.c index 32bad26f2c0..350aab728c4 100644 --- a/source/blender/editors/interface/interface_layout.c +++ b/source/blender/editors/interface/interface_layout.c @@ -2749,7 +2749,7 @@ static void ui_intro_button(DynStr *ds, uiButtonItem *bitem) uiBut *but = bitem->but; BLI_dynstr_appendf(ds, "'type':%d, ", but->type); /* see ~ UI_interface.h:200 */ BLI_dynstr_appendf(ds, "'draw_string':'''%s''', ", but->drawstr); - BLI_dynstr_appendf(ds, "'tip':'''%s''', ", but->tip ? but->tip : ""); // not exactly needed, rna has this + BLI_dynstr_appendf(ds, "'tip':'''%s''', ", but->tip ? but->tip : ""); /* not exactly needed, rna has this */ if (but->optype) { char *opstr = WM_operator_pystring(but->block->evil_C, but->optype, but->opptr, 0); @@ -2811,7 +2811,7 @@ static void ui_intro_uiLayout(DynStr *ds, uiLayout *layout) ui_intro_items(ds, &layout->items); } -static char *str = NULL; // XXX, constant re-freeing, far from ideal. +static char *str = NULL; /* XXX, constant re-freeing, far from ideal. */ const char *uiLayoutIntrospect(uiLayout *layout) { DynStr *ds = BLI_dynstr_new(); @@ -2848,8 +2848,10 @@ void uiLayoutOperatorButs(const bContext *C, uiLayout *layout, wmOperator *op, i /* poll() on this operator may still fail, at the moment there is no nice feedback when this happens * just fails silently */ if (!WM_operator_repeat_check(C, op)) { - uiBlockSetButLock(uiLayoutGetBlock(layout), TRUE, "Operator cannot redo"); - uiItemL(layout, IFACE_("* Redo Unsupported *"), ICON_NONE); // XXX, could give some nicer feedback or not show redo panel at all? + uiBlockSetButLock(uiLayoutGetBlock(layout), TRUE, "Operator can't' redo"); + + /* XXX, could give some nicer feedback or not show redo panel at all? */ + uiItemL(layout, IFACE_("* Redo Unsupported *"), ICON_NONE); } /* menu */ diff --git a/source/blender/editors/interface/interface_ops.c b/source/blender/editors/interface/interface_ops.c index 53ff198b44d..802000567da 100644 --- a/source/blender/editors/interface/interface_ops.c +++ b/source/blender/editors/interface/interface_ops.c @@ -1055,7 +1055,7 @@ void UI_buttons_operatortypes(void) WM_operatortype_append(UI_OT_copy_data_path_button); WM_operatortype_append(UI_OT_reset_default_button); WM_operatortype_append(UI_OT_copy_to_selected_button); - WM_operatortype_append(UI_OT_reports_to_textblock); // XXX: temp? + WM_operatortype_append(UI_OT_reports_to_textblock); /* XXX: temp? */ #ifdef WITH_PYTHON WM_operatortype_append(UI_OT_editsource); diff --git a/source/blender/editors/interface/interface_panel.c b/source/blender/editors/interface/interface_panel.c index 501a5cf91b0..3bbf5b17312 100644 --- a/source/blender/editors/interface/interface_panel.c +++ b/source/blender/editors/interface/interface_panel.c @@ -875,11 +875,11 @@ void uiEndPanels(const bContext *C, ARegion *ar, int *x, int *y) /* consistency; are panels not made, whilst they have tabs */ for (panot = ar->panels.first; panot; panot = panot->next) { - if ((panot->runtime_flag & PNL_ACTIVE) == 0) { // not made + if ((panot->runtime_flag & PNL_ACTIVE) == 0) { /* not made */ for (panew = ar->panels.first; panew; panew = panew->next) { if ((panew->runtime_flag & PNL_ACTIVE)) { - if (panew->paneltab == panot) { // panew is tab in notmade pa + if (panew->paneltab == panot) { /* panew is tab in notmade pa */ break; } } @@ -893,7 +893,7 @@ void uiEndPanels(const bContext *C, ARegion *ar, int *x, int *y) } panot->paneltab = panew; panew->paneltab = NULL; - ED_region_tag_redraw(ar); // the buttons panew were not made + ED_region_tag_redraw(ar); /* the buttons panew were not made */ } } } @@ -1045,10 +1045,10 @@ static void ui_handle_panel_header(const bContext *C, uiBlock *block, int mx, in } if (button) { - if (button == 2) { // close + if (button == 2) { /* close */ ED_region_tag_redraw(ar); } - else { // collapse + else { /* collapse */ if (block->panel->flag & PNL_CLOSED) { block->panel->flag &= ~PNL_CLOSED; /* snap back up so full panel aligns with screen edge */ @@ -1106,7 +1106,7 @@ int ui_handler_panel_region(bContext *C, wmEvent *event) if (!pa || pa->paneltab != NULL) continue; - if (pa->type && pa->type->flag & PNL_NO_HEADER) // XXX - accessed freed panels when scripts reload, need to fix. + if (pa->type && pa->type->flag & PNL_NO_HEADER) /* XXX - accessed freed panels when scripts reload, need to fix. */ continue; if (block->rect.xmin <= mx && block->rect.xmax >= mx) @@ -1177,7 +1177,7 @@ int ui_handler_panel_region(bContext *C, wmEvent *event) #endif } else if (event->type == PADPLUSKEY || event->type == PADMINUS) { -#if 0 // XXX make float panel exception? +#if 0 /* XXX make float panel exception? */ int zoom = 0; /* if panel is closed, only zoom if mouse is over the header */ @@ -1275,7 +1275,7 @@ static void panel_activate_state(const bContext *C, Panel *pa, uiHandlePanelStat * Aligorith, 2009Sep */ //test_add_new_tabs(ar); // also copies locations of tabs in dragged panel - check_panel_overlap(ar, NULL); // clears + check_panel_overlap(ar, NULL); /* clears */ } pa->flag &= ~PNL_SELECT; diff --git a/source/blender/editors/interface/interface_regions.c b/source/blender/editors/interface/interface_regions.c index dcab175c733..be118e1982e 100644 --- a/source/blender/editors/interface/interface_regions.c +++ b/source/blender/editors/interface/interface_regions.c @@ -1431,7 +1431,7 @@ static void ui_block_position(wmWindow *window, ARegion *butregion, uiBut *but, yof = butrct.ymax - block->rect.ymin; if (dir2 == UI_RIGHT) xof = butrct.xmax - block->rect.xmax; else xof = butrct.xmin - block->rect.xmin; - // changed direction? + /* changed direction? */ if ((dir1 & block->direction) == 0) { if (block->direction & UI_SHIFT_FLIPPED) xof += dir2 == UI_LEFT ? 25 : -25; @@ -1442,7 +1442,7 @@ static void ui_block_position(wmWindow *window, ARegion *butregion, uiBut *but, yof = butrct.ymin - block->rect.ymax; if (dir2 == UI_RIGHT) xof = butrct.xmax - block->rect.xmax; else xof = butrct.xmin - block->rect.xmin; - // changed direction? + /* changed direction? */ if ((dir1 & block->direction) == 0) { if (block->direction & UI_SHIFT_FLIPPED) xof += dir2 == UI_LEFT ? 25 : -25; @@ -1453,7 +1453,7 @@ static void ui_block_position(wmWindow *window, ARegion *butregion, uiBut *but, /* and now we handle the exception; no space below or to top */ if (top == 0 && down == 0) { if (dir1 == UI_LEFT || dir1 == UI_RIGHT) { - // align with bottom of screen + /* align with bottom of screen */ // yof= ysize; (not with menu scrolls) } } @@ -1461,12 +1461,12 @@ static void ui_block_position(wmWindow *window, ARegion *butregion, uiBut *but, /* or no space left or right */ if (left == 0 && right == 0) { if (dir1 == UI_TOP || dir1 == UI_DOWN) { - // align with left size of screen + /* align with left size of screen */ xof = -block->rect.xmin + 5; } } - // apply requested offset in the block + /* apply requested offset in the block */ xof += block->xofs / block->aspect; yof += block->yofs / block->aspect; #if 0 diff --git a/source/blender/editors/interface/interface_templates.c b/source/blender/editors/interface/interface_templates.c index 0c69a1888d0..7c4f181b9de 100644 --- a/source/blender/editors/interface/interface_templates.c +++ b/source/blender/editors/interface/interface_templates.c @@ -1517,7 +1517,7 @@ void uiTemplateWaveform(uiLayout *layout, PointerRNA *ptr, const char *propname) scopes->wavefrm_height = (scopes->wavefrm_height <= UI_UNIT_Y) ? UI_UNIT_Y : scopes->wavefrm_height; bt = uiDefBut(block, WAVEFORM, 0, "", rect.xmin, rect.ymin, rect.xmax - rect.xmin, scopes->wavefrm_height, scopes, 0, 0, 0, 0, ""); - (void)bt; // UNUSED + (void)bt; /* UNUSED */ MEM_freeN(cb); } @@ -2315,7 +2315,6 @@ static void list_item_row(bContext *C, uiLayout *layout, PointerRNA *ptr, Pointe void uiTemplateList(uiLayout *layout, bContext *C, PointerRNA *ptr, const char *propname, PointerRNA *activeptr, const char *activepropname, const char *prop_list, int rows, int maxrows, int listtype) { - //Scene *scene = CTX_data_scene(C); PropertyRNA *prop = NULL, *activeprop; PropertyType type, activetype; StructRNA *ptype; @@ -2626,7 +2625,7 @@ void uiTemplateRunningJobs(uiLayout *layout, bContext *C) uiLayout *ui_abs; ui_abs = uiLayoutAbsolute(layout, FALSE); - (void)ui_abs; // UNUSED + (void)ui_abs; /* UNUSED */ uiDefIconBut(block, BUT, handle_event, ICON_PANEL_CLOSE, 0, UI_UNIT_Y * 0.1, UI_UNIT_X * 0.8, UI_UNIT_Y * 0.8, NULL, 0.0f, 0.0f, 0, 0, TIP_("Stop this job")); diff --git a/source/blender/editors/interface/interface_widgets.c b/source/blender/editors/interface/interface_widgets.c index b439271b23d..aebdb349bd5 100644 --- a/source/blender/editors/interface/interface_widgets.c +++ b/source/blender/editors/interface/interface_widgets.c @@ -1095,7 +1095,7 @@ static void ui_text_label_rightclip(uiFontStyle *fstyle, uiBut *but, rcti *rect) static void widget_draw_text(uiFontStyle *fstyle, uiWidgetColors *wcol, uiBut *but, rcti *rect) { -// int transopts; + //int transopts; // UNUSED char *cpoin = NULL; /* for underline drawing */ @@ -1170,7 +1170,7 @@ static void widget_draw_text(uiFontStyle *fstyle, uiWidgetColors *wcol, uiBut *b #if 0 ui_rasterpos_safe(x, y, but->aspect); - if (but->type == IDPOIN) transopts = 0; // no translation, of course! + if (but->type == IDPOIN) transopts = 0; /* no translation, of course! */ else transopts = ui_translate_buttons(); #endif @@ -1654,13 +1654,13 @@ static void widget_state(uiWidgetType *wt, int state) static void widget_state_numslider(uiWidgetType *wt, int state) { uiWidgetStateColors *wcol_state = wt->wcol_state; - float blend = wcol_state->blend - 0.2f; // XXX special tweak to make sure that bar will still be visible + float blend = wcol_state->blend - 0.2f; /* XXX special tweak to make sure that bar will still be visible */ /* call this for option button */ widget_state(wt, state); /* now, set the inner-part so that it reflects state settings too */ - // TODO: maybe we should have separate settings for the blending colors used for this case? + /* TODO: maybe we should have separate settings for the blending colors used for this case? */ if (state & UI_SELECT) { if (state & UI_BUT_ANIMATED_KEY) @@ -2007,13 +2007,13 @@ void ui_draw_gradient(rcti *rect, const float hsv[3], const int type, const floa /* old below */ for (dx = 0.0f; dx < 1.0f; dx += color_step) { - // previous color + /* previous color */ copy_v3_v3(col0[0], col1[0]); copy_v3_v3(col0[1], col1[1]); copy_v3_v3(col0[2], col1[2]); copy_v3_v3(col0[3], col1[3]); - // new color + /* new color */ switch (type) { case UI_GRAD_SV: hsv_to_rgb(h, 0.0, dx, &col1[0][0], &col1[0][1], &col1[0][2]); @@ -2057,7 +2057,7 @@ void ui_draw_gradient(rcti *rect, const float hsv[3], const int type, const floa break; } - // rect + /* rect */ sx1 = rect->xmin + dx * (rect->xmax - rect->xmin); sx2 = rect->xmin + (dx + color_step) * (rect->xmax - rect->xmin); sy = rect->ymin; @@ -2221,7 +2221,6 @@ static void widget_numbut(uiWidgetColors *wcol, rcti *rect, int state, int round rect->xmax -= textofs; } -//static int ui_link_bezier_points(rcti *rect, float coord_array[][2], int resol) int ui_link_bezier_points(rcti *rect, float coord_array[][2], int resol) { float dist, vec[4][2]; @@ -2252,7 +2251,7 @@ void ui_draw_link_bezier(rcti *rect) if (ui_link_bezier_points(rect, coord_array, LINK_RESOL)) { /* we can reuse the dist variable here to increment the GL curve eval amount*/ - // const float dist = 1.0f/(float)LINK_RESOL; // UNUSED + // const float dist = 1.0f / (float)LINK_RESOL; // UNUSED glEnable(GL_BLEND); glEnable(GL_LINE_SMOOTH); @@ -2659,7 +2658,7 @@ static void widget_pulldownbut(uiWidgetColors *wcol, rcti *rect, int state, int { if (state & UI_ACTIVE) { uiWidgetBase wtb; - float rad = 0.5f * (rect->ymax - rect->ymin); // 4.0f + float rad = 0.5f * (rect->ymax - rect->ymin); /* 4.0f */ widget_init(&wtb); @@ -2787,7 +2786,7 @@ static void widget_but(uiWidgetColors *wcol, rcti *rect, int UNUSED(state), int static void widget_roundbut(uiWidgetColors *wcol, rcti *rect, int UNUSED(state), int roundboxalign) { uiWidgetBase wtb; - float rad = 5.0f; //0.5f*(rect->ymax - rect->ymin); + float rad = 5.0f; /* 0.5f * (rect->ymax - rect->ymin); */ widget_init(&wtb); @@ -3176,10 +3175,12 @@ void ui_draw_but(const bContext *C, ARegion *ar, uiStyle *style, uiBut *but, rct break; case HSVCUBE: - if (but->a1 == UI_GRAD_V_ALT) // vertical V slider, uses new widget draw now + if (but->a1 == UI_GRAD_V_ALT) { /* vertical V slider, uses new widget draw now */ ui_draw_but_HSV_v(but, rect); - else // other HSV pickers... + } + else { /* other HSV pickers... */ ui_draw_but_HSVCUBE(but, rect); + } break; case HSVCIRCLE: From adec7cdea2ea3404577be1957e222ec42604c469 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Sun, 19 Aug 2012 13:52:36 +0000 Subject: [PATCH 014/163] Patch #32326: NDOF support of rotation and panning the view at the same time Additional changes: - Option to the ndof menu letting you pick turntable/trackball independently of the mouse viewport navigation style - Option to change the rotation sensitivity separate from the panning Holding shift + moving the ndof does just as before locking it to panning Holding ctrl + moving will lock it to only rotation Patch by Fredrik Hansson, thanks! Reviewed by self and Mike Erwin. --- .../scripts/startup/bl_ui/space_userpref.py | 7 +- source/blender/editors/interface/resources.c | 4 + .../editors/space_view3d/view3d_edit.c | 223 ++++++++++++++---- .../editors/space_view3d/view3d_intern.h | 1 + .../blender/editors/space_view3d/view3d_ops.c | 4 +- source/blender/makesdna/DNA_userdef_types.h | 3 + source/blender/makesrna/intern/rna_userdef.c | 11 +- .../windowmanager/intern/wm_event_system.c | 7 +- 8 files changed, 210 insertions(+), 50 deletions(-) diff --git a/release/scripts/startup/bl_ui/space_userpref.py b/release/scripts/startup/bl_ui/space_userpref.py index e7dd9fb4751..b0b587056b1 100644 --- a/release/scripts/startup/bl_ui/space_userpref.py +++ b/release/scripts/startup/bl_ui/space_userpref.py @@ -858,6 +858,7 @@ class USERPREF_MT_ndof_settings(Menu): layout.separator() layout.prop(input_prefs, "ndof_sensitivity") + layout.prop(input_prefs, "ndof_orbit_sensitivity") if context.space_data.type == 'VIEW_3D': layout.separator() @@ -865,11 +866,10 @@ class USERPREF_MT_ndof_settings(Menu): layout.separator() layout.label(text="Orbit options") - if input_prefs.view_rotate_method == 'TRACKBALL': - layout.prop(input_prefs, "ndof_roll_invert_axis") + layout.prop(input_prefs, "ndof_turntable") + layout.prop(input_prefs, "ndof_roll_invert_axis") layout.prop(input_prefs, "ndof_tilt_invert_axis") layout.prop(input_prefs, "ndof_rotate_invert_axis") - layout.prop(input_prefs, "ndof_zoom_invert") layout.separator() layout.label(text="Pan options") @@ -878,6 +878,7 @@ class USERPREF_MT_ndof_settings(Menu): layout.prop(input_prefs, "ndof_panz_invert_axis") layout.label(text="Zoom options") + layout.prop(input_prefs, "ndof_zoom_invert") layout.prop(input_prefs, "ndof_zoom_updown") layout.separator() diff --git a/source/blender/editors/interface/resources.c b/source/blender/editors/interface/resources.c index 20e4360b791..ed6b2e00119 100644 --- a/source/blender/editors/interface/resources.c +++ b/source/blender/editors/interface/resources.c @@ -1967,6 +1967,10 @@ void init_userdef_do_versions(void) U.ndof_flag = NDOF_LOCK_HORIZON | NDOF_SHOULD_PAN | NDOF_SHOULD_ZOOM | NDOF_SHOULD_ROTATE; } + + if (U.ndof_orbit_sensitivity == 0.0f) { + U.ndof_orbit_sensitivity = 1.0f; + } if (U.tweak_threshold == 0) U.tweak_threshold = 10; diff --git a/source/blender/editors/space_view3d/view3d_edit.c b/source/blender/editors/space_view3d/view3d_edit.c index 310630a65ad..b262819474b 100644 --- a/source/blender/editors/space_view3d/view3d_edit.c +++ b/source/blender/editors/space_view3d/view3d_edit.c @@ -1036,20 +1036,6 @@ static int ndof_orbit_invoke(bContext *C, wmOperator *UNUSED(op), wmEvent *event ndof->tx, ndof->ty, ndof->tz, ndof->rx, ndof->ry, ndof->rz, ndof->dt); #endif - if (ndof->tz) { - /* Zoom! - * velocity should be proportional to the linear velocity attained by rotational motion of same strength - * [got that?] - * proportional to arclength = radius * angle - */ - float zoom_distance = zoom_sensitivity * rv3d->dist * dt * ndof->tz; - - if (U.ndof_flag & NDOF_ZOOM_INVERT) - zoom_distance = -zoom_distance; - - rv3d->dist += zoom_distance; - } - if (rv3d->viewlock == RV3D_LOCKED) { /* rotation not allowed -- explore panning options instead */ float pan_vec[3] = {ndof->tx, ndof->ty, 0.0f}; @@ -1067,34 +1053,7 @@ static int ndof_orbit_invoke(bContext *C, wmOperator *UNUSED(op), wmEvent *event rv3d->view = RV3D_VIEW_USER; - if (U.flag & USER_TRACKBALL) { - float rot[4]; - float axis[3]; - float angle = rot_sensitivity * ndof_to_axis_angle(ndof, axis); - - if (U.ndof_flag & NDOF_ROLL_INVERT_AXIS) - axis[2] = -axis[2]; - - if (U.ndof_flag & NDOF_TILT_INVERT_AXIS) - axis[0] = -axis[0]; - - if (U.ndof_flag & NDOF_ROTATE_INVERT_AXIS) - axis[1] = -axis[1]; - - /* transform rotation axis from view to world coordinates */ - mul_qt_v3(view_inv, axis); - - /* update the onscreen doo-dad */ - rv3d->rot_angle = angle; - copy_v3_v3(rv3d->rot_axis, axis); - - axis_angle_to_quat(rot, axis, angle); - - /* apply rotation */ - mul_qt_qtqt(rv3d->viewquat, rv3d->viewquat, rot); - - } - else { + if (U.ndof_flag & NDOF_TURNTABLE) { /* turntable view code by John Aughey, adapted for 3D mouse by [mce] */ float angle, rot[4]; @@ -1127,6 +1086,33 @@ static int ndof_orbit_invoke(bContext *C, wmOperator *UNUSED(op), wmEvent *event rot[3] = sin(angle); mul_qt_qtqt(rv3d->viewquat, rv3d->viewquat, rot); } + else { + float rot[4]; + float axis[3]; + float angle = rot_sensitivity * ndof_to_axis_angle(ndof, axis); + + if (U.ndof_flag & NDOF_ROLL_INVERT_AXIS) + axis[2] = -axis[2]; + + if (U.ndof_flag & NDOF_TILT_INVERT_AXIS) + axis[0] = -axis[0]; + + if (U.ndof_flag & NDOF_ROTATE_INVERT_AXIS) + axis[1] = -axis[1]; + + /* transform rotation axis from view to world coordinates */ + mul_qt_v3(view_inv, axis); + + /* update the onscreen doo-dad */ + rv3d->rot_angle = angle; + copy_v3_v3(rv3d->rot_axis, axis); + + axis_angle_to_quat(rot, axis, angle); + + /* apply rotation */ + mul_qt_qtqt(rv3d->viewquat, rv3d->viewquat, rot); + + } } } @@ -1247,6 +1233,159 @@ void VIEW3D_OT_ndof_pan(struct wmOperatorType *ot) ot->flag = 0; } + +/* +* this is basically just the pan only code + the rotate only code crammed into one function that does both +*/ +static int ndof_all_invoke(bContext *C, wmOperator *op, wmEvent *event) +{ + if (event->type != NDOF_MOTION) + return OPERATOR_CANCELLED; + else { + + ViewOpsData *vod; + RegionView3D *rv3d; + + View3D *v3d = CTX_wm_view3d(C); + wmNDOFMotionData *ndof = (wmNDOFMotionData *) event->customdata; + + ED_view3d_camera_lock_init(v3d, rv3d); + + viewops_data_create(C, op, event); + vod = op->customdata; + rv3d = vod->rv3d; + + + if (ndof->progress != P_FINISHING) { + + const float dt = ndof->dt; + float view_inv[4]; + + float speed = 10.f; /* blender units per second */ + /* ^^ this is ok for default cube scene, but should scale with.. something */ + + /* tune these until everything feels right */ + const float forward_sensitivity = 1.f; + const float vertical_sensitivity = 0.4f; + const float lateral_sensitivity = 0.6f; + + float pan_vec[3]; + const float rot_sensitivity = 1.f; + const float zoom_sensitivity = 1.f; + const float pan_sensitivity = 1.f; + float rot[4]; + float axis[3]; + float angle = rot_sensitivity * ndof_to_axis_angle(ndof, axis); + + if (U.ndof_flag & NDOF_PANX_INVERT_AXIS) + pan_vec[0] = -lateral_sensitivity * ndof->tvec[0]; + else + pan_vec[0] = lateral_sensitivity * ndof->tvec[0]; + + if (U.ndof_flag & NDOF_PANZ_INVERT_AXIS) + pan_vec[1] = -vertical_sensitivity * ndof->tvec[1]; + else + pan_vec[1] = vertical_sensitivity * ndof->tvec[1]; + + if (U.ndof_flag & NDOF_PANY_INVERT_AXIS) + pan_vec[2] = -forward_sensitivity * ndof->tvec[2]; + else + pan_vec[2] = forward_sensitivity * ndof->tvec[2]; + + mul_v3_fl(pan_vec, speed * dt); + + /* transform motion from view to world coordinates */ + invert_qt_qt(view_inv, rv3d->viewquat); + mul_qt_v3(view_inv, pan_vec); + + /* move center of view opposite of hand motion (this is camera mode, not object mode) */ + sub_v3_v3(rv3d->ofs, pan_vec); + + if (U.ndof_flag & NDOF_TURNTABLE) { + /* turntable view code by John Aughey, adapted for 3D mouse by [mce] */ + float angle, rot[4]; + float xvec[3] = {1, 0, 0}; + + /* Determine the direction of the x vector (for rotating up and down) */ + mul_qt_v3(view_inv, xvec); + + /* Perform the up/down rotation */ + angle = rot_sensitivity * dt * ndof->rx; + if (U.ndof_flag & NDOF_TILT_INVERT_AXIS) + angle = -angle; + rot[0] = cos(angle); + mul_v3_v3fl(rot + 1, xvec, sin(angle)); + mul_qt_qtqt(rv3d->viewquat, rv3d->viewquat, rot); + + /* Perform the orbital rotation */ + angle = rot_sensitivity * dt * ndof->ry; + if (U.ndof_flag & NDOF_ROTATE_INVERT_AXIS) + angle = -angle; + + /* update the onscreen doo-dad */ + rv3d->rot_angle = angle; + rv3d->rot_axis[0] = 0; + rv3d->rot_axis[1] = 0; + rv3d->rot_axis[2] = 1; + + rot[0] = cos(angle); + rot[1] = rot[2] = 0.0; + rot[3] = sin(angle); + mul_qt_qtqt(rv3d->viewquat, rv3d->viewquat, rot); + + } + else { + + float rot[4]; + float axis[3]; + float angle = rot_sensitivity * ndof_to_axis_angle(ndof, axis); + + if (U.ndof_flag & NDOF_ROLL_INVERT_AXIS) + axis[2] = -axis[2]; + + if (U.ndof_flag & NDOF_TILT_INVERT_AXIS) + axis[0] = -axis[0]; + + if (U.ndof_flag & NDOF_ROTATE_INVERT_AXIS) + axis[1] = -axis[1]; + + /* transform rotation axis from view to world coordinates */ + mul_qt_v3(view_inv, axis); + + /* update the onscreen doo-dad */ + rv3d->rot_angle = angle; + copy_v3_v3(rv3d->rot_axis, axis); + + axis_angle_to_quat(rot, axis, angle); + + /* apply rotation */ + mul_qt_qtqt(rv3d->viewquat, rv3d->viewquat, rot); + + } + } + ED_view3d_camera_lock_sync(v3d, rv3d); + + ED_region_tag_redraw(CTX_wm_region(C)); + viewops_data_free(C, op); + return OPERATOR_FINISHED; + } +} + +void VIEW3D_OT_ndof_all(struct wmOperatorType *ot) +{ + /* identifiers */ + ot->name = "NDOF move View"; + ot->description = "Position your viewpoint with the 3D mouse"; + ot->idname = "VIEW3D_OT_ndof_all"; + + /* api callbacks */ + ot->invoke = ndof_all_invoke; + ot->poll = ED_operator_view3d_active; + + /* flags */ + ot->flag = 0; +} + /* ************************ viewmove ******************************** */ diff --git a/source/blender/editors/space_view3d/view3d_intern.h b/source/blender/editors/space_view3d/view3d_intern.h index 8b51e6cf226..71e87e73747 100644 --- a/source/blender/editors/space_view3d/view3d_intern.h +++ b/source/blender/editors/space_view3d/view3d_intern.h @@ -79,6 +79,7 @@ void VIEW3D_OT_move(struct wmOperatorType *ot); void VIEW3D_OT_rotate(struct wmOperatorType *ot); void VIEW3D_OT_ndof_orbit(struct wmOperatorType *ot); void VIEW3D_OT_ndof_pan(struct wmOperatorType *ot); +void VIEW3D_OT_ndof_all(struct wmOperatorType *ot); void VIEW3D_OT_view_all(struct wmOperatorType *ot); void VIEW3D_OT_viewnumpad(struct wmOperatorType *ot); void VIEW3D_OT_view_selected(struct wmOperatorType *ot); diff --git a/source/blender/editors/space_view3d/view3d_ops.c b/source/blender/editors/space_view3d/view3d_ops.c index 7b3e7358978..14c02c2357e 100644 --- a/source/blender/editors/space_view3d/view3d_ops.c +++ b/source/blender/editors/space_view3d/view3d_ops.c @@ -64,6 +64,7 @@ void view3d_operatortypes(void) WM_operatortype_append(VIEW3D_OT_dolly); WM_operatortype_append(VIEW3D_OT_ndof_orbit); WM_operatortype_append(VIEW3D_OT_ndof_pan); + WM_operatortype_append(VIEW3D_OT_ndof_all); WM_operatortype_append(VIEW3D_OT_view_all); WM_operatortype_append(VIEW3D_OT_viewnumpad); WM_operatortype_append(VIEW3D_OT_view_orbit); @@ -221,8 +222,9 @@ void view3d_keymap(wmKeyConfig *keyconf) RNA_boolean_set(kmi->ptr, "align_active", TRUE); /* 3D mouse */ - WM_keymap_add_item(keymap, "VIEW3D_OT_ndof_orbit", NDOF_MOTION, 0, 0, 0); + WM_keymap_add_item(keymap, "VIEW3D_OT_ndof_orbit", NDOF_MOTION, 0, KM_CTRL, 0); WM_keymap_add_item(keymap, "VIEW3D_OT_ndof_pan", NDOF_MOTION, 0, KM_SHIFT, 0); + WM_keymap_add_item(keymap, "VIEW3D_OT_ndof_all", NDOF_MOTION, 0, 0, 0); WM_keymap_add_item(keymap, "VIEW3D_OT_view_selected", NDOF_BUTTON_FIT, KM_PRESS, 0, 0); RNA_enum_set(WM_keymap_add_item(keymap, "VIEW3D_OT_viewnumpad", NDOF_BUTTON_FRONT, KM_PRESS, 0, 0)->ptr, "type", RV3D_VIEW_FRONT); RNA_enum_set(WM_keymap_add_item(keymap, "VIEW3D_OT_viewnumpad", NDOF_BUTTON_BACK, KM_PRESS, 0, 0)->ptr, "type", RV3D_VIEW_BACK); diff --git a/source/blender/makesdna/DNA_userdef_types.h b/source/blender/makesdna/DNA_userdef_types.h index 8b62f58212b..3f9f4d3980e 100644 --- a/source/blender/makesdna/DNA_userdef_types.h +++ b/source/blender/makesdna/DNA_userdef_types.h @@ -414,6 +414,8 @@ typedef struct UserDef { short use_16bit_textures, use_gpu_mipmap; float ndof_sensitivity; /* overall sensitivity of 3D mouse */ + float ndof_orbit_sensitivity; + float pad4; int ndof_flag; /* flags for 3D mouse */ float glalphaclip; @@ -649,6 +651,7 @@ extern UserDef U; /* from blenkernel blender.c */ #define NDOF_PANX_INVERT_AXIS (1 << 12) #define NDOF_PANY_INVERT_AXIS (1 << 13) #define NDOF_PANZ_INVERT_AXIS (1 << 14) +#define NDOF_TURNTABLE (1 << 15) /* compute_device_type */ #define USER_COMPUTE_DEVICE_NONE 0 diff --git a/source/blender/makesrna/intern/rna_userdef.c b/source/blender/makesrna/intern/rna_userdef.c index e3cd236a8e3..7cebbe5a895 100644 --- a/source/blender/makesrna/intern/rna_userdef.c +++ b/source/blender/makesrna/intern/rna_userdef.c @@ -3358,7 +3358,11 @@ static void rna_def_userdef_input(BlenderRNA *brna) /* global options */ prop = RNA_def_property(srna, "ndof_sensitivity", PROP_FLOAT, PROP_NONE); RNA_def_property_range(prop, 0.25f, 4.0f); - RNA_def_property_ui_text(prop, "Sensitivity", "Overall sensitivity of the 3D Mouse"); + RNA_def_property_ui_text(prop, "Sensitivity", "Overall sensitivity of the 3D Mouse for panning"); + + prop = RNA_def_property(srna, "ndof_orbit_sensitivity", PROP_FLOAT, PROP_NONE); + RNA_def_property_range(prop, 0.25f, 4.0f); + RNA_def_property_ui_text(prop, "Orbit Sensitivity", "Overall sensitivity of the 3D Mouse for orbiting"); prop = RNA_def_property(srna, "ndof_zoom_updown", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "ndof_flag", NDOF_ZOOM_UPDOWN); @@ -3375,6 +3379,11 @@ static void rna_def_userdef_input(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Show Navigation Guide", "Display the center and axis during rotation"); /* TODO: update description when fly-mode visuals are in place ("projected position in fly mode")*/ + /* 3D view */ + prop = RNA_def_property(srna, "ndof_turntable", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "ndof_flag", NDOF_TURNTABLE); + RNA_def_property_ui_text(prop, "Turntable", "Turntable for ndof rotation"); + /* 3D view: roll */ prop = RNA_def_property(srna, "ndof_roll_invert_axis", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "ndof_flag", NDOF_ROLL_INVERT_AXIS); diff --git a/source/blender/windowmanager/intern/wm_event_system.c b/source/blender/windowmanager/intern/wm_event_system.c index 10a383df5c9..577a472b40d 100644 --- a/source/blender/windowmanager/intern/wm_event_system.c +++ b/source/blender/windowmanager/intern/wm_event_system.c @@ -2617,12 +2617,13 @@ static void attach_ndof_data(wmEvent *event, const GHOST_TEventNDOFMotionData *g wmNDOFMotionData *data = MEM_mallocN(sizeof(wmNDOFMotionData), "customdata NDOF"); const float s = U.ndof_sensitivity; + const float rs = U.ndof_orbit_sensitivity; data->tx = s * ghost->tx; - data->rx = s * ghost->rx; - data->ry = s * ghost->ry; - data->rz = s * ghost->rz; + data->rx = rs * ghost->rx; + data->ry = rs * ghost->ry; + data->rz = rs * ghost->rz; if (U.ndof_flag & NDOF_ZOOM_UPDOWN) { /* rotate so Y is where Z was */ From 994d75b6ae78fee99afd949292e48c4f32292995 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 19 Aug 2012 15:28:24 +0000 Subject: [PATCH 015/163] spelling cleanup: spelling corrections from user zeffii on IRC. --- doc/python_api/rst/info_best_practice.rst | 46 +++++++++++++---------- 1 file changed, 27 insertions(+), 19 deletions(-) diff --git a/doc/python_api/rst/info_best_practice.rst b/doc/python_api/rst/info_best_practice.rst index 37de8fa381d..1e12daba893 100644 --- a/doc/python_api/rst/info_best_practice.rst +++ b/doc/python_api/rst/info_best_practice.rst @@ -75,7 +75,7 @@ Example layouts: * layout.row() - Use row(), when you want more than 1 propertey in one line. + Use row(), when you want more than 1 property in one line. .. code-block:: python @@ -145,7 +145,7 @@ Even though you're not looping on the list data **python is**, so you need to be Modifying Lists ^^^^^^^^^^^^^^^ -In python we can add and remove from a list, This is slower when the list length is modified, especially at the start of the list, since all the data after the index of modification needs to be moved up or down 1 place. +In python we can add and remove from a list, this is slower when the list length is modified, especially at the start of the list, since all the data after the index of modification needs to be moved up or down 1 place. The most simple way to add onto the end of the list is to use ``my_list.append(list_item)`` or ``my_list.extend(some_list)`` and the fastest way to remove an item is ``my_list.pop()`` or ``del my_list[-1]``. @@ -154,13 +154,13 @@ To use an index you can use ``my_list.insert(index, list_item)`` or ``list.pop(i Sometimes its faster (but more memory hungry) to just rebuild the list. -Say you want to remove all triangle faces in a list. +Say you want to remove all triangular faces in a list. Rather than... .. code-block:: python - faces = mesh.faces[:] # make a list copy of the meshes faces + faces = mesh.tessfaces[:] # make a list copy of the meshes faces f_idx = len(faces) # Loop backwards while f_idx: # while the value is not 0 f_idx -= 1 @@ -173,13 +173,13 @@ It's faster to build a new list with list comprehension. .. code-block:: python - faces = [f for f in mesh.faces if len(f.vertices) != 3] + faces = [f for f in mesh.tessfaces if len(f.vertices) != 3] Adding List Items ^^^^^^^^^^^^^^^^^ -If you have a list that you want to add onto another list, rather then... +If you have a list that you want to add onto another list, rather than... .. code-block:: python @@ -205,6 +205,14 @@ This example shows a very sub-optimal way of making a reversed list. reverse_list.insert(0, list_item) +Python provides more convenient ways to reverse a list using the slice method, but you may want to time this before relying on it too much: + + +.. code-block:: python + + some_reversed_list = some_list[::-1] + + Removing List Items ^^^^^^^^^^^^^^^^^^^ @@ -224,7 +232,7 @@ Here is an example of how to remove items in 1 loop, removing the last items fir my_list.pop(list_index) -This example shows a fast way of removing items, for use in cases were where you can alter the list order without breaking the scripts functionality. This works by swapping 2 list items, so the item you remove is always last. +This example shows a fast way of removing items, for use in cases where you can alter the list order without breaking the scripts functionality. This works by swapping 2 list items, so the item you remove is always last. .. code-block:: python @@ -243,9 +251,9 @@ When removing many items in a large list this can provide a good speedup. Avoid Copying Lists ^^^^^^^^^^^^^^^^^^^ -When passing a list/dictionary to a function, it is faster to have the function modify the list rather then returning a new list so python doesn't have to duplicate the list in memory. +When passing a list/dictionary to a function, it is faster to have the function modify the list rather than returning a new list so python doesn't have to duplicate the list in memory. -Functions that modify a list in-place are more efficient then functions that create new lists. +Functions that modify a list in-place are more efficient than functions that create new lists. This is generally slower so only use for functions when it makes sense not to modify the list in place. @@ -273,22 +281,22 @@ Here are 3 ways of joining multiple strings into 1 string for writing This really applies to any area of your code that involves a lot of string joining. -Pythons string addition, *don't use if you can help it, especially when writing data in a loop.* +Python’s string addition, *don't use if you can help it, especially when writing data in a loop.* >>> file.write(str1 + " " + str2 + " " + str3 + "\n") -String formatting. Use this when you're writing string data from floats and int's +String formatting. Use this when you're writing string data from floats and ints >>> file.write("%s %s %s\n" % (str1, str2, str3)) -Pythons string joining function. To join a list of strings +Python’s string joining function. To join a list of strings >>> file.write(" ".join([str1, str2, str3, "\n"])) -join is fastest on many strings, string formatting is quite fast too (better for converting data types). String arithmetic is slowest. +join is fastest on many strings, `string formatting `_ is quite fast too (better for converting data types). String arithmetic is slowest. Parsing Strings (Import/Exporting) @@ -296,12 +304,12 @@ Parsing Strings (Import/Exporting) Since many file formats are ASCII, the way you parse/export strings can make a large difference in how fast your script runs. -When importing strings to make into blender there are a few ways to parse the string. +There are a few ways to parse strings when importing them into Blender. Parsing Numbers ^^^^^^^^^^^^^^^ -Use ``float(string)`` rather than ``eval(string)``, if you know the value will be an int then ``int(string)``, float() will work for an int too but its faster to read ints with int(). +Use ``float(string)`` rather than ``eval(string)``, if you know the value will be an int then ``int(string)``, float() will work for an int too but it's faster to read ints with int(). Checking String Start/End ^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -318,7 +326,7 @@ Using ``startswith()`` is slightly faster (approx 5%) and also avoids a possible my_string.endswith("foo_bar") can be used for line endings too. -if your unsure whether the text is upper or lower case use lower or upper string function. +If you are unsure whether the text is upper or lower case use ``lower()`` or ``upper()`` string function. >>> if line.lower().startswith("vert ") @@ -328,7 +336,7 @@ Use try/except Sparingly The **try** statement is useful to save time writing error checking code. -However **try** is significantly slower then an **if** since an exception has to be set each time, so avoid using **try** in areas of your code that execute in a loop and runs many times. +However **try** is significantly slower than an **if** since an exception has to be set each time, so avoid using **try** in areas of your code that execute in a loop and runs many times. There are cases where using **try** is faster than checking whether the condition will raise an error, so it is worth experimenting. @@ -336,7 +344,7 @@ There are cases where using **try** is faster than checking whether the conditio Value Comparison ---------------- -Python has two ways to compare values ``a == b`` and ``a is b``, The difference is that ``==`` may run the objects comparison function ``__cmp__()`` where as ``is`` compares identity, that both variables reference the same item in memory. +Python has two ways to compare values ``a == b`` and ``a is b``, the difference is that ``==`` may run the objects comparison function ``__cmp__()`` whereas ``is`` compares identity, that both variables reference the same item in memory. In cases where you know you are checking for the same value which is referenced from multiple places, ``is`` is faster. @@ -344,7 +352,7 @@ In cases where you know you are checking for the same value which is referenced Time Your Code -------------- -While developing a script its good to time it to be aware of any changes in performance, this can be done simply. +While developing a script it's good to time it to be aware of any changes in performance, this can be done simply. .. code-block:: python From 995a19a983b2c44ec9afec049395d7c1b4320137 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Sun, 19 Aug 2012 15:41:56 +0000 Subject: [PATCH 016/163] Sequencer: per-sequence modifier stack for color grading This implements basic color grading modifiers in sequencer, supporting color balance, RGB curves and HUE corrections. Implementation is close to object modifiers, some details are there: http://wiki.blender.org/index.php/User:Nazg-gul/SequencerModifiers Modifiers supports multi-threaded calculation, masks and instant parameter changes. Also added cache for pre-processed image buffers for current frame, so changing sequence properties does not require rendering of original sequence (like rendering scene, loading file from disk and so) --- release/scripts/startup/bl_ui/space_image.py | 2 +- .../scripts/startup/bl_ui/space_sequencer.py | 87 ++- source/blender/blenkernel/BKE_colortools.h | 4 + source/blender/blenkernel/BKE_sequencer.h | 50 ++ source/blender/blenkernel/CMakeLists.txt | 1 + source/blender/blenkernel/intern/colortools.c | 75 ++- source/blender/blenkernel/intern/seqcache.c | 120 ++++ .../blender/blenkernel/intern/seqmodifier.c | 522 ++++++++++++++++++ source/blender/blenkernel/intern/sequencer.c | 480 +++++++++------- source/blender/blenloader/intern/readfile.c | 37 ++ source/blender/blenloader/intern/writefile.c | 42 +- .../editors/space_sequencer/CMakeLists.txt | 1 + .../space_sequencer/sequencer_intern.h | 4 + .../space_sequencer/sequencer_modifier.c | 164 ++++++ .../editors/space_sequencer/sequencer_ops.c | 4 + source/blender/makesdna/DNA_sequence_types.h | 61 +- .../blender/makesrna/intern/rna_sequencer.c | 333 ++++++++++- source/blender/makesrna/intern/rna_ui_api.c | 1 + 18 files changed, 1735 insertions(+), 253 deletions(-) create mode 100644 source/blender/blenkernel/intern/seqmodifier.c create mode 100644 source/blender/editors/space_sequencer/sequencer_modifier.c diff --git a/release/scripts/startup/bl_ui/space_image.py b/release/scripts/startup/bl_ui/space_image.py index 5302ad9b471..0b4d4cd19e4 100644 --- a/release/scripts/startup/bl_ui/space_image.py +++ b/release/scripts/startup/bl_ui/space_image.py @@ -774,7 +774,7 @@ class IMAGE_PT_paint_curve(BrushButtonsPanel, Panel): toolsettings = context.tool_settings.image_paint brush = toolsettings.brush - layout.template_curve_mapping(brush, "curve") + layout.template_curve_mapping(brush, "curve", type='COLOR') row = layout.row(align=True) row.operator("brush.curve_preset", icon='SMOOTHCURVE', text="").shape = 'SMOOTH' diff --git a/release/scripts/startup/bl_ui/space_sequencer.py b/release/scripts/startup/bl_ui/space_sequencer.py index 50c8603a7c2..cd10bce8ef6 100644 --- a/release/scripts/startup/bl_ui/space_sequencer.py +++ b/release/scripts/startup/bl_ui/space_sequencer.py @@ -28,6 +28,29 @@ def act_strip(context): return None +def draw_color_balance(layout, color_balance): + col = layout.column() + col.label(text="Lift:") + col.template_color_wheel(color_balance, "lift", value_slider=True, cubic=True) + row = col.row() + row.prop(color_balance, "lift", text="") + row.prop(color_balance, "invert_lift", text="Inverse") + + col = layout.column() + col.label(text="Gamma:") + col.template_color_wheel(color_balance, "gamma", value_slider=True, lock_luminosity=True, cubic=True) + row = col.row() + row.prop(color_balance, "gamma", text="") + row.prop(color_balance, "invert_gamma", text="Inverse") + + col = layout.column() + col.label(text="Gain:") + col.template_color_wheel(color_balance, "gain", value_slider=True, lock_luminosity=True, cubic=True) + row = col.row() + row.prop(color_balance, "gain", text="") + row.prop(color_balance, "invert_gain", text="Inverse") + + class SEQUENCER_HT_header(Header): bl_space_type = 'SEQUENCE_EDITOR' @@ -442,7 +465,7 @@ class SEQUENCER_PT_effect(SequencerButtonsPanel, Panel): if strip.is_supports_mask: col = layout.column() - col.prop_search(strip, "input_mask", sequencer, "sequences") + col.prop_search(strip, "input_mask_strip", sequencer, "sequences", text="Mask") if strip.type == 'COLOR': layout.prop(strip, "color") @@ -772,26 +795,7 @@ class SEQUENCER_PT_filter(SequencerButtonsPanel, Panel): layout.prop(strip, "use_color_balance") if strip.use_color_balance and strip.color_balance: # TODO - need to add this somehow - col = layout.column() - col.label(text="Lift:") - col.template_color_wheel(strip.color_balance, "lift", value_slider=True, cubic=True) - row = col.row() - row.prop(strip.color_balance, "lift", text="") - row.prop(strip.color_balance, "invert_lift", text="Inverse") - - col = layout.column() - col.label(text="Gamma:") - col.template_color_wheel(strip.color_balance, "gamma", value_slider=True, lock_luminosity=True, cubic=True) - row = col.row() - row.prop(strip.color_balance, "gamma", text="") - row.prop(strip.color_balance, "invert_gamma", text="Inverse") - - col = layout.column() - col.label(text="Gain:") - col.template_color_wheel(strip.color_balance, "gain", value_slider=True, lock_luminosity=True, cubic=True) - row = col.row() - row.prop(strip.color_balance, "gain", text="") - row.prop(strip.color_balance, "invert_gain", text="Inverse") + draw_color_balance(layout, strip.color_balance) class SEQUENCER_PT_proxy(SequencerButtonsPanel, Panel): @@ -878,5 +882,46 @@ class SEQUENCER_PT_view(SequencerButtonsPanel_Output, Panel): col.prop(st, "show_separate_color") col.prop(st, "proxy_render_size") + +class SEQUENCER_PT_modifiers(SequencerButtonsPanel, Panel): + bl_label = "Modifiers" + + def draw(self, context): + layout = self.layout + + strip = act_strip(context) + sequencer = context.scene.sequence_editor + + layout.operator_menu_enum("sequencer.strip_modifier_add", "type") + + for mod in strip.modifiers: + box = layout.box() + + row = box.row() + row.prop(mod, "show_expanded", text="", emboss=False) + row.prop(mod, "name") + + row.prop(mod, "mute", text="") + props = row.operator("sequencer.strip_modifier_remove", text="", icon='X') + props.name = mod.name + + if mod.show_expanded: + row = box.row() + row.prop(mod, "input_mask_type", expand=True) + + if mod.input_mask_type == 'STRIP': + box.prop_search(mod, "input_mask_strip", sequencer, "sequences", text="Mask") + else: + box.prop(mod, "input_mask_id") + + if mod.type == 'COLOR_BALANCE': + box.prop(mod, "color_multiply") + draw_color_balance(box, mod.color_balance) + elif mod.type == 'CURVES': + box.template_curve_mapping(mod, "curve_mapping", type='COLOR') + elif mod.type == 'HUE_CORRECT': + box.template_curve_mapping(mod, "curve_mapping", type='HUE') + + if __name__ == "__main__": # only for live edit. bpy.utils.register_module(__name__) diff --git a/source/blender/blenkernel/BKE_colortools.h b/source/blender/blenkernel/BKE_colortools.h index f58af8f39a0..dcb40c960b1 100644 --- a/source/blender/blenkernel/BKE_colortools.h +++ b/source/blender/blenkernel/BKE_colortools.h @@ -47,8 +47,11 @@ struct rctf; # define DO_INLINE static inline #endif +void curvemapping_set_defaults(struct CurveMapping *cumap, int tot, float minx, float miny, float maxx, float maxy); struct CurveMapping *curvemapping_add(int tot, float minx, float miny, float maxx, float maxy); +void curvemapping_free_data(struct CurveMapping *cumap); void curvemapping_free(struct CurveMapping *cumap); +void curvemapping_copy_data(struct CurveMapping *target, struct CurveMapping *cumap); struct CurveMapping *curvemapping_copy(struct CurveMapping *cumap); void curvemapping_set_black_white(struct CurveMapping *cumap, const float black[3], const float white[3]); @@ -69,6 +72,7 @@ float curvemap_evaluateF(struct CurveMap *cuma, float value); float curvemapping_evaluateF(struct CurveMapping *cumap, int cur, float value); void curvemapping_evaluate3F(struct CurveMapping *cumap, float vecout[3], const float vecin[3]); void curvemapping_evaluateRGBF(struct CurveMapping *cumap, float vecout[3], const float vecin[3]); +void curvemapping_evaluate_premulRGB(struct CurveMapping *cumap, unsigned char vecout_byte[3], const unsigned char vecin_byte[3]); void curvemapping_evaluate_premulRGBF(struct CurveMapping *cumap, float vecout[3], const float vecin[3]); void curvemapping_do_ibuf(struct CurveMapping *cumap, struct ImBuf *ibuf); void curvemapping_premultiply(struct CurveMapping *cumap, int restore); diff --git a/source/blender/blenkernel/BKE_sequencer.h b/source/blender/blenkernel/BKE_sequencer.h index 823b1dd14da..d05e065ac15 100644 --- a/source/blender/blenkernel/BKE_sequencer.h +++ b/source/blender/blenkernel/BKE_sequencer.h @@ -31,11 +31,14 @@ */ struct bContext; +struct StripColorBalance; struct Editing; struct ImBuf; struct Main; +struct Mask; struct Scene; struct Sequence; +struct SequenceModifierData; struct Strip; struct StripElem; struct bSound; @@ -241,6 +244,10 @@ void BKE_sequencer_cache_put(SeqRenderData context, struct Sequence *seq, float void BKE_sequencer_cache_cleanup_sequence(struct Sequence *seq); +struct ImBuf *BKE_sequencer_preprocessed_cache_get(SeqRenderData context, struct Sequence *seq, float cfra, seq_stripelem_ibuf_t type); +void BKE_sequencer_preprocessed_cache_put(SeqRenderData context, struct Sequence *seq, float cfra, seq_stripelem_ibuf_t type, struct ImBuf *ibuf); +void BKE_sequencer_preprocessed_cache_cleanup_sequence(struct Sequence *seq); + /* ********************************************************************** * seqeffects.c * @@ -289,6 +296,7 @@ int BKE_sequence_swap(struct Sequence *seq_a, struct Sequence *seq_b, const char int BKE_sequence_check_depend(struct Sequence *seq, struct Sequence *cur); void BKE_sequence_invalidate_cache(struct Scene *scene, struct Sequence *seq); +void BKE_sequence_invalidate_cache_for_modifier(struct Scene *scene, struct Sequence *seq); void BKE_sequencer_update_sound_bounds_all(struct Scene *scene); void BKE_sequencer_update_sound_bounds(struct Scene *scene, struct Sequence *seq); @@ -347,4 +355,46 @@ extern SequencerDrawView sequencer_view3d_cb; extern ListBase seqbase_clipboard; extern int seqbase_clipboard_frame; +/* modifiers */ +typedef struct SequenceModifierTypeInfo { + /* default name for the modifier */ + char name[64]; /* MAX_NAME */ + + /* DNA structure name used on load/save filed */ + char struct_name[64]; /* MAX_NAME */ + + /* size of modifier data structure, used by allocation */ + int struct_size; + + /* data initialization */ + void (*init_data) (struct SequenceModifierData *smd); + + /* free data used by modifier, + * only modifier-specific data should be freed, modifier descriptor would + * be freed outside of this callback + */ + void (*free_data) (struct SequenceModifierData *smd); + + /* copy data from one modifier to another */ + void (*copy_data) (struct SequenceModifierData *smd, struct SequenceModifierData *target); + + /* apply modifier on a given image buffer */ + struct ImBuf* (*apply) (struct SequenceModifierData *smd, struct ImBuf *ibuf, struct ImBuf *mask); +} SequenceModifierTypeInfo; + +struct SequenceModifierTypeInfo *BKE_sequence_modifier_type_info_get(int type); + +void BKE_sequence_modifier_new(struct Sequence *seq, int type); +void BKE_sequence_modifier_free(struct SequenceModifierData *smd); +void BKE_sequence_modifier_unique_name(struct Sequence *seq, struct SequenceModifierData *smd); +struct SequenceModifierData *BKE_sequence_modifier_find_by_name(struct Sequence *seq, char *name); +struct ImBuf *BKE_sequence_modifier_apply_stack(SeqRenderData context, struct Sequence *seq, struct ImBuf *ibuf, int cfra); +void BKE_sequence_modifier_list_copy(struct Sequence *seqn, struct Sequence *seq); + +int BKE_sequence_supports_modifiers(struct Sequence *seq); + +/* internal filters */ +struct ImBuf *BKE_sequencer_render_mask_input(SeqRenderData context, int mask_input_type, struct Sequence *mask_sequence, struct Mask *mask_id, int cfra, int make_float); +void BKE_sequencer_color_balance_apply(struct StripColorBalance *cb, struct ImBuf *ibuf, float mul, short make_float, struct ImBuf *mask_input); + #endif /* __BKE_SEQUENCER_H__ */ diff --git a/source/blender/blenkernel/CMakeLists.txt b/source/blender/blenkernel/CMakeLists.txt index 38a39ad492d..0a0635126f5 100644 --- a/source/blender/blenkernel/CMakeLists.txt +++ b/source/blender/blenkernel/CMakeLists.txt @@ -128,6 +128,7 @@ set(SRC intern/script.c intern/seqcache.c intern/seqeffects.c + intern/seqmodifier.c intern/sequencer.c intern/shrinkwrap.c intern/sketch.c diff --git a/source/blender/blenkernel/intern/colortools.c b/source/blender/blenkernel/intern/colortools.c index 20fae973756..118169e8f7d 100644 --- a/source/blender/blenkernel/intern/colortools.c +++ b/source/blender/blenkernel/intern/colortools.c @@ -56,13 +56,11 @@ /* ***************** operations on full struct ************* */ -CurveMapping *curvemapping_add(int tot, float minx, float miny, float maxx, float maxy) +void curvemapping_set_defaults(CurveMapping *cumap, int tot, float minx, float miny, float maxx, float maxy) { - CurveMapping *cumap; int a; float clipminx, clipminy, clipmaxx, clipmaxy; - cumap = MEM_callocN(sizeof(CurveMapping), "new curvemap"); cumap->flag = CUMA_DO_CLIP; if (tot == 4) cumap->cur = 3; /* rhms, hack for 'col' curve? */ @@ -89,38 +87,59 @@ CurveMapping *curvemapping_add(int tot, float minx, float miny, float maxx, floa } cumap->changed_timestamp = 0; +} + +CurveMapping *curvemapping_add(int tot, float minx, float miny, float maxx, float maxy) +{ + CurveMapping *cumap; + + cumap = MEM_callocN(sizeof(CurveMapping), "new curvemap"); + + curvemapping_set_defaults(cumap, tot, minx, miny, maxx, maxy); return cumap; } -void curvemapping_free(CurveMapping *cumap) +void curvemapping_free_data(CurveMapping *cumap) { int a; - + + for (a = 0; a < CM_TOT; a++) { + if (cumap->cm[a].curve) MEM_freeN(cumap->cm[a].curve); + if (cumap->cm[a].table) MEM_freeN(cumap->cm[a].table); + if (cumap->cm[a].premultable) MEM_freeN(cumap->cm[a].premultable); + } +} + +void curvemapping_free(CurveMapping *cumap) +{ if (cumap) { - for (a = 0; a < CM_TOT; a++) { - if (cumap->cm[a].curve) MEM_freeN(cumap->cm[a].curve); - if (cumap->cm[a].table) MEM_freeN(cumap->cm[a].table); - if (cumap->cm[a].premultable) MEM_freeN(cumap->cm[a].premultable); - } + curvemapping_free_data(cumap); MEM_freeN(cumap); } } +void curvemapping_copy_data(CurveMapping *target, CurveMapping *cumap) +{ + int a; + + *target = *cumap; + + for (a = 0; a < CM_TOT; a++) { + if (cumap->cm[a].curve) + target->cm[a].curve = MEM_dupallocN(cumap->cm[a].curve); + if (cumap->cm[a].table) + target->cm[a].table = MEM_dupallocN(cumap->cm[a].table); + if (cumap->cm[a].premultable) + target->cm[a].premultable = MEM_dupallocN(cumap->cm[a].premultable); + } +} + CurveMapping *curvemapping_copy(CurveMapping *cumap) { - int a; - if (cumap) { CurveMapping *cumapn = MEM_dupallocN(cumap); - for (a = 0; a < CM_TOT; a++) { - if (cumap->cm[a].curve) - cumapn->cm[a].curve = MEM_dupallocN(cumap->cm[a].curve); - if (cumap->cm[a].table) - cumapn->cm[a].table = MEM_dupallocN(cumap->cm[a].table); - if (cumap->cm[a].premultable) - cumapn->cm[a].premultable = MEM_dupallocN(cumap->cm[a].premultable); - } + curvemapping_copy_data(cumapn, cumap); return cumapn; } return NULL; @@ -782,6 +801,22 @@ void curvemapping_evaluate_premulRGBF(CurveMapping *cumap, float vecout[3], cons vecout[2] = curvemap_evaluateF(cumap->cm + 2, fac); } +/* same as above, byte version */ +void curvemapping_evaluate_premulRGB(CurveMapping *cumap, unsigned char vecout_byte[3], const unsigned char vecin_byte[3]) +{ + float vecin[3], vecout[3]; + + vecin[0] = (float) vecin_byte[0] / 255.0f; + vecin[1] = (float) vecin_byte[1] / 255.0f; + vecin[2] = (float) vecin_byte[2] / 255.0f; + + curvemapping_evaluate_premulRGBF(cumap, vecout, vecin); + + vecout_byte[0] = FTOCHAR(vecout[0]); + vecout_byte[1] = FTOCHAR(vecout[1]); + vecout_byte[2] = FTOCHAR(vecout[2]); +} + /* only used for image editor curves */ void curvemapping_do_ibuf(CurveMapping *cumap, ImBuf *ibuf) diff --git a/source/blender/blenkernel/intern/seqcache.c b/source/blender/blenkernel/intern/seqcache.c index 387ec67eb1c..d79f23e8979 100644 --- a/source/blender/blenkernel/intern/seqcache.c +++ b/source/blender/blenkernel/intern/seqcache.c @@ -37,8 +37,11 @@ #include "BKE_sequencer.h" #include "IMB_moviecache.h" +#include "IMB_imbuf.h" #include "IMB_imbuf_types.h" +#include "BLI_listbase.h" + typedef struct SeqCacheKey { struct Sequence *seq; SeqRenderData context; @@ -46,7 +49,25 @@ typedef struct SeqCacheKey { seq_stripelem_ibuf_t type; } SeqCacheKey; +typedef struct SeqPreprocessCacheElem { + struct SeqPreprocessCacheElem *next, *prev; + + struct Sequence *seq; + SeqRenderData context; + seq_stripelem_ibuf_t type; + + ImBuf *ibuf; +} SeqPreprocessCacheElem; + +typedef struct SeqPreprocessCache { + int cfra; + ListBase elems; +} SeqPreprocessCache; + static struct MovieCache *moviecache = NULL; +static struct SeqPreprocessCache *preprocess_cache = NULL; + +static void preprocessed_cache_destruct(void); static int seq_cmp_render_data(const SeqRenderData *a, const SeqRenderData *b) { @@ -160,6 +181,8 @@ void BKE_sequencer_cache_destruct(void) { if (moviecache) IMB_moviecache_free(moviecache); + + preprocessed_cache_destruct(); } void BKE_sequencer_cache_cleanup(void) @@ -219,3 +242,100 @@ void BKE_sequencer_cache_put(SeqRenderData context, Sequence *seq, float cfra, s IMB_moviecache_put(moviecache, &key, i); } + +static void preprocessed_cache_clean(void) +{ + SeqPreprocessCacheElem *elem; + + if (!preprocess_cache) + return; + + for (elem = preprocess_cache->elems.first; elem; elem = elem->next) { + IMB_freeImBuf(elem->ibuf); + } + BLI_freelistN(&preprocess_cache->elems); + + preprocess_cache->elems.first = preprocess_cache->elems.last = NULL; +} + +static void preprocessed_cache_destruct(void) +{ + if (!preprocess_cache) + return; + + preprocessed_cache_clean(); + + MEM_freeN(preprocess_cache); + preprocess_cache = NULL; +} + +ImBuf *BKE_sequencer_preprocessed_cache_get(SeqRenderData context, Sequence *seq, float cfra, seq_stripelem_ibuf_t type) +{ + SeqPreprocessCacheElem *elem; + + if (!preprocess_cache) + return NULL; + + if (preprocess_cache->cfra != cfra) + return NULL; + + for (elem = preprocess_cache->elems.first; elem; elem = elem->next) { + if (elem->seq != seq) + continue; + + if (elem->type != type) + continue; + + if (seq_cmp_render_data(&elem->context, &context) != 0) + continue; + + IMB_refImBuf(elem->ibuf); + return elem->ibuf; + } + + return NULL; +} + +void BKE_sequencer_preprocessed_cache_put(SeqRenderData context, Sequence *seq, float cfra, seq_stripelem_ibuf_t type, ImBuf *ibuf) +{ + SeqPreprocessCacheElem *elem; + + if (!preprocess_cache) { + preprocess_cache = MEM_callocN(sizeof(SeqPreprocessCache), "sequencer preprocessed cache"); + } + else { + if (preprocess_cache->cfra != cfra) + preprocessed_cache_clean(); + } + + elem = MEM_callocN(sizeof(SeqPreprocessCacheElem), "sequencer preprocessed cache element"); + + elem->seq = seq; + elem->type = type; + elem->context = context; + elem->ibuf = ibuf; + + preprocess_cache->cfra = cfra; + + IMB_refImBuf(ibuf); + + BLI_addtail(&preprocess_cache->elems, elem); +} + +void BKE_sequencer_preprocessed_cache_cleanup_sequence(Sequence *seq) +{ + SeqPreprocessCacheElem *elem, *elem_next; + + if (!preprocess_cache) + return; + + for (elem = preprocess_cache->elems.first; elem; elem = elem_next) { + elem_next = elem->next; + + if (elem->seq == seq) { + IMB_freeImBuf(elem->ibuf); + + BLI_freelinkN(&preprocess_cache->elems, elem); + } + } +} diff --git a/source/blender/blenkernel/intern/seqmodifier.c b/source/blender/blenkernel/intern/seqmodifier.c new file mode 100644 index 00000000000..4157a3a1562 --- /dev/null +++ b/source/blender/blenkernel/intern/seqmodifier.c @@ -0,0 +1,522 @@ +/* + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * The Original Code is Copyright (C) 2012 Blender Foundation. + * All rights reserved. + * + * Contributor(s): Blender Foundation, + * Sergey Sharybin + * + * ***** END GPL LICENSE BLOCK ***** + */ + +/** \file blender/blenkernel/intern/seqmodifier.c + * \ingroup bke + */ + +#include +#include + +#include "MEM_guardedalloc.h" + +#include "BLI_listbase.h" +#include "BLI_path_util.h" +#include "BLI_string.h" +#include "BLI_utildefines.h" +#include "BLI_math.h" + +#include "DNA_sequence_types.h" + +#include "BKE_colortools.h" +#include "BKE_sequencer.h" +#include "BKE_utildefines.h" + +#include "IMB_imbuf.h" +#include "IMB_imbuf_types.h" + +static SequenceModifierTypeInfo *modifiersTypes[NUM_SEQUENCE_MODIFIER_TYPES]; +static int modifierTypesInit = FALSE; + +/*********************** Modifiers *************************/ + +typedef void (*modifier_apply_threaded_cb) (int width, int height, unsigned char *rect, float *rect_float, + unsigned char *mask_rect, float *mask_rect_float, void *data_v); + +typedef struct ModifierInitData { + ImBuf *ibuf; + ImBuf *mask; + void *user_data; + + modifier_apply_threaded_cb apply_callback; +} ModifierInitData; + +typedef struct ModifierThread { + int width, height; + + unsigned char *rect, *mask_rect; + float *rect_float, *mask_rect_float; + + void *user_data; + + modifier_apply_threaded_cb apply_callback; +} ModifierThread; + + +static ImBuf *modifier_mask_get(SequenceModifierData *smd, SeqRenderData context, int cfra, int make_float) +{ + return BKE_sequencer_render_mask_input(context, smd->mask_input_type, smd->mask_sequence, smd->mask_id, cfra, make_float); +} + +static void modifier_init_handle(void *handle_v, int start_line, int tot_line, void *init_data_v) +{ + ModifierThread *handle = (ModifierThread *) handle_v; + ModifierInitData *init_data = (ModifierInitData *) init_data_v; + ImBuf *ibuf = init_data->ibuf; + ImBuf *mask = init_data->mask; + + int offset = 4 * start_line * ibuf->x; + + memset(handle, 0, sizeof(ModifierThread)); + + handle->width = ibuf->x; + handle->height = tot_line; + handle->apply_callback = init_data->apply_callback; + handle->user_data = init_data->user_data; + + if (ibuf->rect) + handle->rect = (unsigned char *) ibuf->rect + offset; + + if (ibuf->rect_float) + handle->rect_float = ibuf->rect_float + offset; + + if (mask) { + if (mask->rect) + handle->mask_rect = (unsigned char *) mask->rect + offset; + + if (mask->rect_float) + handle->mask_rect_float = mask->rect_float + offset; + } + else { + handle->mask_rect = NULL; + handle->mask_rect_float = NULL; + } +} + +static void *modifier_do_thread(void *thread_data_v) +{ + ModifierThread *td = (ModifierThread *) thread_data_v; + + td->apply_callback(td->width, td->height, td->rect, td->rect_float, td->mask_rect, td->mask_rect_float, td->user_data); + + return NULL; +} + +static void modifier_apply_threaded(ImBuf *ibuf, ImBuf *mask, modifier_apply_threaded_cb apply_callback, void *user_data) +{ + ModifierInitData init_data; + + init_data.ibuf = ibuf; + init_data.mask = mask; + init_data.user_data = user_data; + + init_data.apply_callback = apply_callback; + + IMB_processor_apply_threaded(ibuf->y, sizeof(ModifierThread), &init_data, + modifier_init_handle, modifier_do_thread); +} + +/* **** Color Balance Modifier **** */ + +void colorBalance_init_data(SequenceModifierData *smd) +{ + ColorBalanceModifierData *cbmd = (ColorBalanceModifierData *) smd; + int c; + + cbmd->color_multiply = 1.0f; + + for (c = 0; c < 3; c++) { + cbmd->color_balance.lift[c] = 1.0f; + cbmd->color_balance.gamma[c] = 1.0f; + cbmd->color_balance.gain[c] = 1.0f; + } +} + +ImBuf *colorBalance_apply(SequenceModifierData *smd, ImBuf *ibuf, ImBuf *mask) +{ + ColorBalanceModifierData *cbmd = (ColorBalanceModifierData *) smd; + ImBuf *ibuf_new = IMB_dupImBuf(ibuf); + + BKE_sequencer_color_balance_apply(&cbmd->color_balance, ibuf_new, cbmd->color_multiply, FALSE, mask); + + return ibuf_new; +} + +static SequenceModifierTypeInfo seqModifier_ColorBalance = { + "Color Balance", /* name */ + "ColorBalanceModifierData", /* struct_name */ + sizeof(ColorBalanceModifierData), /* struct_size */ + colorBalance_init_data, /* init_data */ + NULL, /* free_data */ + NULL, /* copy_data */ + colorBalance_apply /* apply */ +}; + +/* **** Curves Modifier **** */ + +void curves_init_data(SequenceModifierData *smd) +{ + CurvesModifierData *cmd = (CurvesModifierData *) smd; + + curvemapping_set_defaults(&cmd->curve_mapping, 4, 0.0f, 0.0f, 1.0f, 1.0f); +} + +void curves_free_data(SequenceModifierData *smd) +{ + CurvesModifierData *cmd = (CurvesModifierData *) smd; + + curvemapping_free_data(&cmd->curve_mapping); +} + +void curves_copy_data(SequenceModifierData *target, SequenceModifierData *smd) +{ + CurvesModifierData *cmd = (CurvesModifierData *) smd; + CurvesModifierData *cmd_target = (CurvesModifierData *) target; + + curvemapping_copy_data(&cmd_target->curve_mapping, &cmd->curve_mapping); +} + +void curves_apply_threaded(int width, int height, unsigned char *rect, float *rect_float, + unsigned char *mask_rect, float *mask_rect_float, void *data_v) +{ + CurveMapping *curve_mapping = (CurveMapping *) data_v; + int x, y; + + for (y = 0; y < height; y++) { + for (x = 0; x < width; x++) { + int pixel_index = (y * width + x) * 4; + + if (rect_float) { + float *pixel = rect_float + pixel_index; + float result[3]; + + curvemapping_evaluate_premulRGBF(curve_mapping, result, pixel); + + if (mask_rect_float) { + float *m = mask_rect_float + pixel_index; + + pixel[0] = pixel[0] * (1.0f - m[0]) + result[0] * m[0]; + pixel[1] = pixel[1] * (1.0f - m[1]) + result[1] * m[1]; + pixel[2] = pixel[2] * (1.0f - m[2]) + result[2] * m[2]; + } + else { + pixel[0] = result[0]; + pixel[1] = result[1]; + pixel[2] = result[2]; + } + } + if (rect) { + unsigned char *pixel = rect + pixel_index; + unsigned char result[3]; + + curvemapping_evaluate_premulRGB(curve_mapping, result, pixel); + + if (mask_rect) { + float t[3]; + + rgb_uchar_to_float(t, mask_rect + pixel_index); + + pixel[0] = pixel[0] * (1.0f - t[0]) + result[0] * t[0]; + pixel[1] = pixel[1] * (1.0f - t[1]) + result[1] * t[1]; + pixel[2] = pixel[2] * (1.0f - t[2]) + result[2] * t[2]; + } + else { + pixel[0] = result[0]; + pixel[1] = result[1]; + pixel[2] = result[2]; + } + } + } + } +} + +ImBuf *curves_apply(struct SequenceModifierData *smd, ImBuf *ibuf, ImBuf *mask) +{ + CurvesModifierData *cmd = (CurvesModifierData *) smd; + ImBuf *ibuf_new = IMB_dupImBuf(ibuf); + + float black[3] = {0.0f, 0.0f, 0.0f}; + float white[3] = {1.0f, 1.0f, 1.0f}; + + curvemapping_initialize(&cmd->curve_mapping); + + curvemapping_premultiply(&cmd->curve_mapping, 0); + curvemapping_set_black_white(&cmd->curve_mapping, black, white); + + modifier_apply_threaded(ibuf_new, mask, curves_apply_threaded, &cmd->curve_mapping); + + curvemapping_premultiply(&cmd->curve_mapping, 1); + + return ibuf_new; +} + +static SequenceModifierTypeInfo seqModifier_Curves = { + "Curves", /* name */ + "CurvesModifierData", /* struct_name */ + sizeof(CurvesModifierData), /* struct_size */ + curves_init_data, /* init_data */ + curves_free_data, /* free_data */ + curves_copy_data, /* copy_data */ + curves_apply /* apply */ +}; + +/* **** Hue Correct Modifier **** */ + +void hue_correct_init_data(SequenceModifierData *smd) +{ + HueCorrectModifierData *hcmd = (HueCorrectModifierData *) smd; + int c; + + curvemapping_set_defaults(&hcmd->curve_mapping, 1, 0.0f, 0.0f, 1.0f, 1.0f); + hcmd->curve_mapping.preset = CURVE_PRESET_MID9; + + for (c = 0; c < 3; c++) { + CurveMap *cuma = &hcmd->curve_mapping.cm[c]; + + curvemap_reset(cuma, &hcmd->curve_mapping.clipr, hcmd->curve_mapping.preset, CURVEMAP_SLOPE_POSITIVE); + } + + /* default to showing Saturation */ + hcmd->curve_mapping.cur = 1; +} + +void hue_correct_free_data(SequenceModifierData *smd) +{ + HueCorrectModifierData *hcmd = (HueCorrectModifierData *) smd; + + curvemapping_free_data(&hcmd->curve_mapping); +} + +void hue_correct_copy_data(SequenceModifierData *target, SequenceModifierData *smd) +{ + HueCorrectModifierData *hcmd = (HueCorrectModifierData *) smd; + HueCorrectModifierData *hcmd_target = (HueCorrectModifierData *) target; + + curvemapping_copy_data(&hcmd_target->curve_mapping, &hcmd->curve_mapping); +} + +void hue_correct_apply_threaded(int width, int height, unsigned char *rect, float *rect_float, + unsigned char *mask_rect, float *mask_rect_float, void *data_v) +{ + CurveMapping *curve_mapping = (CurveMapping *) data_v; + int x, y; + + for (y = 0; y < height; y++) { + for (x = 0; x < width; x++) { + int pixel_index = (y * width + x) * 4; + float pixel[3], result[3], mask[3] = {1.0f, 1.0f, 1.0f}; + float hsv[3], f; + + if (rect_float) + copy_v3_v3(pixel, rect_float + pixel_index); + else + rgb_uchar_to_float(pixel, rect + pixel_index); + + rgb_to_hsv(pixel[0], pixel[1], pixel[2], hsv, hsv + 1, hsv + 2); + + /* adjust hue, scaling returned default 0.5 up to 1 */ + f = curvemapping_evaluateF(curve_mapping, 0, hsv[0]); + hsv[0] += f - 0.5f; + + /* adjust saturation, scaling returned default 0.5 up to 1 */ + f = curvemapping_evaluateF(curve_mapping, 1, hsv[0]); + hsv[1] *= (f * 2.0f); + + /* adjust value, scaling returned default 0.5 up to 1 */ + f = curvemapping_evaluateF(curve_mapping, 2, hsv[0]); + hsv[2] *= (f * 2.f); + + hsv[0] = hsv[0] - floorf(hsv[0]); /* mod 1.0 */ + CLAMP(hsv[1], 0.0f, 1.0f); + + /* convert back to rgb */ + hsv_to_rgb(hsv[0], hsv[1], hsv[2], result, result + 1, result + 2); + + if (mask_rect_float) + copy_v3_v3(mask, mask_rect_float + pixel_index); + else if (mask_rect) + rgb_uchar_to_float(mask, mask_rect + pixel_index); + + result[0] = pixel[0] * (1.0f - mask[0]) + result[0] * mask[0]; + result[1] = pixel[1] * (1.0f - mask[1]) + result[1] * mask[1]; + result[2] = pixel[2] * (1.0f - mask[2]) + result[2] * mask[2]; + + if (rect_float) + copy_v3_v3(rect_float + pixel_index, result); + else + rgb_float_to_uchar(rect + pixel_index, result); + } + } +} + +ImBuf *hue_correct_apply(struct SequenceModifierData *smd, ImBuf *ibuf, ImBuf *mask) +{ + HueCorrectModifierData *hcmd = (HueCorrectModifierData *) smd; + ImBuf *ibuf_new = IMB_dupImBuf(ibuf); + + curvemapping_initialize(&hcmd->curve_mapping); + + modifier_apply_threaded(ibuf_new, mask, hue_correct_apply_threaded, &hcmd->curve_mapping); + + return ibuf_new; +} + +static SequenceModifierTypeInfo seqModifier_HueCorrect = { + "Hue Correct", /* name */ + "HueCorrectModifierData", /* struct_name */ + sizeof(HueCorrectModifierData), /* struct_size */ + hue_correct_init_data, /* init_data */ + hue_correct_free_data, /* free_data */ + hue_correct_copy_data, /* copy_data */ + hue_correct_apply /* apply */ +}; + +/*********************** Modifier functions *************************/ + +static void sequence_modifier_type_info_init(void) +{ +#define INIT_TYPE(typeName) (modifiersTypes[seqModifierType_##typeName] = &seqModifier_##typeName) + + INIT_TYPE(ColorBalance); + INIT_TYPE(Curves); + INIT_TYPE(HueCorrect); + +#undef INIT_TYPE +} + +SequenceModifierTypeInfo *BKE_sequence_modifier_type_info_get(int type) +{ + if (!modifierTypesInit) { + sequence_modifier_type_info_init(); + modifierTypesInit = TRUE; + } + + return modifiersTypes[type]; +} + +void BKE_sequence_modifier_new(Sequence *seq, int type) +{ + SequenceModifierData *smd; + SequenceModifierTypeInfo *smti = BKE_sequence_modifier_type_info_get(type); + + smd = MEM_callocN(smti->struct_size, "sequence modifier"); + + smd->type = type; + smd->flag |= SEQUENCE_MODIFIER_EXPANDED; + + BLI_strncpy(smd->name, smti->name, sizeof(smd->name)); + + BLI_addtail(&seq->modifiers, smd); + + BKE_sequence_modifier_unique_name(seq, smd); + + if (smti->init_data) + smti->init_data(smd); +} + +void BKE_sequence_modifier_free(SequenceModifierData *smd) +{ + SequenceModifierTypeInfo *smti = BKE_sequence_modifier_type_info_get(smd->type); + + if (smti && smti->free_data) { + smti->free_data(smd); + } + + MEM_freeN(smd); +} + +void BKE_sequence_modifier_unique_name(Sequence *seq, SequenceModifierData *smd) +{ + SequenceModifierTypeInfo *smti = BKE_sequence_modifier_type_info_get(smd->type); + + BLI_uniquename(&seq->modifiers, smd, smti->name, '.', offsetof(SequenceModifierData, name), sizeof(smd->name)); +} + +SequenceModifierData *BKE_sequence_modifier_find_by_name(Sequence *seq, char *name) +{ + return BLI_findstring(&(seq->modifiers), name, offsetof(SequenceModifierData, name)); +} + +ImBuf *BKE_sequence_modifier_apply_stack(SeqRenderData context, Sequence *seq, ImBuf *ibuf, int cfra) +{ + SequenceModifierData *smd; + ImBuf *processed_ibuf = ibuf; + + for (smd = seq->modifiers.first; smd; smd = smd->next) { + SequenceModifierTypeInfo *smti = BKE_sequence_modifier_type_info_get(smd->type); + ImBuf *ibuf_new; + + /* could happen if modifier is being removed or not exists in current version of blender */ + if (!smti) + continue; + + /* modifier is muted, do nothing */ + if (smd->flag & SEQUENCE_MODIFIER_MUTE) + continue; + + if (smti->apply) { + ImBuf *mask = modifier_mask_get(smd, context, cfra, ibuf->rect_float != NULL); + + if (processed_ibuf == ibuf) + processed_ibuf = IMB_dupImBuf(ibuf); + + ibuf_new = smti->apply(smd, processed_ibuf, mask); + + if (ibuf_new != processed_ibuf) { + IMB_freeImBuf(processed_ibuf); + processed_ibuf = ibuf_new; + } + + if (mask) + IMB_freeImBuf(mask); + } + } + + return processed_ibuf; +} + +void BKE_sequence_modifier_list_copy(Sequence *seqn, Sequence *seq) +{ + SequenceModifierData *smd; + + for (smd = seq->modifiers.first; smd; smd = smd->next) { + SequenceModifierData *smdn; + SequenceModifierTypeInfo *smti = BKE_sequence_modifier_type_info_get(smd->type); + + smdn = MEM_dupallocN(smd); + + if (smti && smti->copy_data) + smti->copy_data(smdn, smd); + + smdn->next = smdn->prev = NULL; + BLI_addtail(&seqn->modifiers, smdn); + } +} + +int BKE_sequence_supports_modifiers(Sequence *seq) +{ + return !ELEM(seq->type, SEQ_TYPE_SOUND_RAM, SEQ_TYPE_SOUND_HD); +} diff --git a/source/blender/blenkernel/intern/sequencer.c b/source/blender/blenkernel/intern/sequencer.c index 9625fad69a6..b156d622202 100644 --- a/source/blender/blenkernel/intern/sequencer.c +++ b/source/blender/blenkernel/intern/sequencer.c @@ -83,6 +83,7 @@ static ImBuf *seq_render_strip_stack(SeqRenderData context, ListBase *seqbasep, float cfra, int chanshown); static ImBuf *seq_render_strip(SeqRenderData context, Sequence *seq, float cfra); static void seq_free_animdata(Scene *scene, Sequence *seq); +static ImBuf *seq_render_mask(SeqRenderData context, Mask *mask, float nr, short make_float); /* **** XXX ******** */ #define SELECT 1 @@ -203,7 +204,18 @@ void BKE_sequence_free(Scene *scene, Sequence *seq) seq_free_animdata(scene, seq); } + /* free modifiers */ + if (seq->modifiers.first) { + SequenceModifierData *smd, *smd_next; + + for (smd = seq->modifiers.first; smd; smd = smd_next) { + smd_next = smd->next; + BKE_sequence_modifier_free(smd); + } + } + BKE_sequencer_cache_cleanup_sequence(seq); + BKE_sequencer_preprocessed_cache_cleanup_sequence(seq); MEM_freeN(seq); } @@ -1432,7 +1444,7 @@ static void make_cb_table_float(float lift, float gain, float gamma, } } -static void color_balance_byte_byte(Sequence *seq, unsigned char *rect, unsigned char *mask_rect, int width, int height, float mul) +static void color_balance_byte_byte(StripColorBalance *cb_, unsigned char *rect, unsigned char *mask_rect, int width, int height, float mul) { unsigned char cb_tab[3][256]; int c; @@ -1440,7 +1452,7 @@ static void color_balance_byte_byte(Sequence *seq, unsigned char *rect, unsigned unsigned char *e = p + width * 4 * height; unsigned char *m = mask_rect; - StripColorBalance cb = calc_cb(seq->strip->color_balance); + StripColorBalance cb = calc_cb(cb_); for (c = 0; c < 3; c++) { make_cb_table_byte(cb.lift[c], cb.gain[c], cb.gamma[c], cb_tab[c], mul); @@ -1466,7 +1478,7 @@ static void color_balance_byte_byte(Sequence *seq, unsigned char *rect, unsigned } } -static void color_balance_byte_float(Sequence *seq, unsigned char *rect, float *rect_float, unsigned char *mask_rect, int width, int height, float mul) +static void color_balance_byte_float(StripColorBalance *cb_, unsigned char *rect, float *rect_float, unsigned char *mask_rect, int width, int height, float mul) { float cb_tab[4][256]; int c, i; @@ -1478,7 +1490,7 @@ static void color_balance_byte_float(Sequence *seq, unsigned char *rect, float * o = rect_float; - cb = calc_cb(seq->strip->color_balance); + cb = calc_cb(cb_); for (c = 0; c < 3; c++) { make_cb_table_float(cb.lift[c], cb.gain[c], cb.gamma[c], cb_tab[c], mul); @@ -1510,12 +1522,12 @@ static void color_balance_byte_float(Sequence *seq, unsigned char *rect, float * } } -static void color_balance_float_float(Sequence *seq, float *rect_float, float *mask_rect_float, int width, int height, float mul) +static void color_balance_float_float(StripColorBalance *cb_, float *rect_float, float *mask_rect_float, int width, int height, float mul) { float *p = rect_float; float *e = rect_float + width * 4 * height; float *m = mask_rect_float; - StripColorBalance cb = calc_cb(seq->strip->color_balance); + StripColorBalance cb = calc_cb(cb_); while (p < e) { int c; @@ -1535,20 +1547,23 @@ static void color_balance_float_float(Sequence *seq, float *rect_float, float *m } typedef struct ColorBalanceInitData { - Sequence *seq; + StripColorBalance *cb; ImBuf *ibuf; float mul; ImBuf *mask; + short make_float; } ColorBalanceInitData; typedef struct ColorBalanceThread { - Sequence *seq; + StripColorBalance *cb; float mul; int width, height; unsigned char *rect, *mask_rect; float *rect_float, *mask_rect_float; + + short make_float; } ColorBalanceThread; static void color_balance_init_handle(void *handle_v, int start_line, int tot_line, void *init_data_v) @@ -1562,10 +1577,11 @@ static void color_balance_init_handle(void *handle_v, int start_line, int tot_li memset(handle, 0, sizeof(ColorBalanceThread)); - handle->seq = init_data->seq; + handle->cb = init_data->cb; handle->mul = init_data->mul; handle->width = ibuf->x; handle->height = tot_line; + handle->make_float = init_data->make_float; if (ibuf->rect) handle->rect = (unsigned char *) ibuf->rect + offset; @@ -1589,7 +1605,7 @@ static void color_balance_init_handle(void *handle_v, int start_line, int tot_li static void *color_balance_do_thread(void *thread_data_v) { ColorBalanceThread *thread_data = (ColorBalanceThread *) thread_data_v; - Sequence *seq = thread_data->seq; + StripColorBalance *cb = thread_data->cb; int width = thread_data->width, height = thread_data->height; unsigned char *rect = thread_data->rect; unsigned char *mask_rect = thread_data->mask_rect; @@ -1598,48 +1614,56 @@ static void *color_balance_do_thread(void *thread_data_v) float mul = thread_data->mul; if (rect_float) { - color_balance_float_float(seq, rect_float, mask_rect_float, width, height, mul); + color_balance_float_float(cb, rect_float, mask_rect_float, width, height, mul); } - else if (seq->flag & SEQ_MAKE_FLOAT) { - color_balance_byte_float(seq, rect, rect_float, mask_rect, width, height, mul); + else if (thread_data->make_float) { + color_balance_byte_float(cb, rect, rect_float, mask_rect, width, height, mul); } else { - color_balance_byte_byte(seq, rect, mask_rect, width, height, mul); + color_balance_byte_byte(cb, rect, mask_rect, width, height, mul); } return NULL; } -static void color_balance(SeqRenderData context, Sequence *seq, ImBuf *ibuf, float mul, int cfra) +ImBuf *BKE_sequencer_render_mask_input(SeqRenderData context, int mask_input_type, Sequence *mask_sequence, Mask *mask_id, int cfra, int make_float) { - ColorBalanceInitData init_data; + ImBuf *mask_input = NULL; - if (!ibuf->rect_float && seq->flag & SEQ_MAKE_FLOAT) - imb_addrectfloatImBuf(ibuf); + if (mask_input_type == SEQUENCE_MASK_INPUT_STRIP) { + if (mask_sequence) { + mask_input = seq_render_strip(context, mask_sequence, cfra); - init_data.seq = seq; - init_data.ibuf = ibuf; - init_data.mul = mul; - init_data.mask = NULL; - - if (seq->mask_sequence) { - if (seq->mask_sequence != seq && !BKE_sequence_check_depend(seq, seq->mask_sequence)) { - ImBuf *mask = seq_render_strip(context, seq->mask_sequence, cfra); - - if (mask) { - if (ibuf->rect_float) { - if (!mask->rect_float) - IMB_float_from_rect(mask); - } - else { - if (!mask->rect) - IMB_rect_from_float(mask); - } - - init_data.mask = mask; + if (make_float) { + if (!mask_input->rect_float) + IMB_float_from_rect(mask_input); + } + else { + if (!mask_input->rect) + IMB_rect_from_float(mask_input); } } } + else if (mask_input_type == SEQUENCE_MASK_INPUT_ID) { + mask_input = seq_render_mask(context, mask_id, cfra, make_float); + } + + return mask_input; +} + +void BKE_sequencer_color_balance_apply(StripColorBalance *cb, ImBuf *ibuf, float mul, short make_float, ImBuf *mask_input) +{ + ColorBalanceInitData init_data; + + if (!ibuf->rect_float && make_float) + imb_addrectfloatImBuf(ibuf); + + init_data.cb = cb; + init_data.ibuf = ibuf; + init_data.mul = mul; + init_data.mask = NULL; + init_data.make_float = make_float; + init_data.mask = mask_input; IMB_processor_apply_threaded(ibuf->y, sizeof(ColorBalanceThread), &init_data, color_balance_init_handle, color_balance_do_thread); @@ -1650,9 +1674,26 @@ static void color_balance(SeqRenderData context, Sequence *seq, ImBuf *ibuf, flo */ if (ibuf->rect_float && ibuf->rect) imb_freerectImBuf(ibuf); +} - if (init_data.mask) - IMB_freeImBuf(init_data.mask); +static void sequence_color_balance(SeqRenderData context, Sequence *seq, ImBuf *ibuf, float mul, int cfra) +{ + StripColorBalance *cb = seq->strip->color_balance; + ImBuf *mask_input = NULL; + short make_float = seq->flag & SEQ_MAKE_FLOAT; + + if (seq->mask_sequence) { + if (seq->mask_sequence != seq && !BKE_sequence_check_depend(seq, seq->mask_sequence)) { + int make_float = ibuf->rect_float != NULL; + + mask_input = BKE_sequencer_render_mask_input(context, SEQUENCE_MASK_INPUT_STRIP, seq->mask_sequence, NULL, cfra, make_float); + } + } + + BKE_sequencer_color_balance_apply(cb, ibuf, mul, make_float, mask_input); + + if (mask_input) + IMB_freeImBuf(mask_input); } /* @@ -1696,6 +1737,10 @@ int BKE_sequencer_input_have_to_preprocess(SeqRenderData UNUSED(context), Sequen if (seq->sat != 1.0f) { return TRUE; } + + if (seq->modifiers.first) { + return TRUE; + } return FALSE; } @@ -1795,7 +1840,7 @@ static ImBuf *input_preprocess(SeqRenderData context, Sequence *seq, float cfra, } if (seq->flag & SEQ_USE_COLOR_BALANCE && seq->strip->color_balance) { - color_balance(context, seq, ibuf, mul, cfra); + sequence_color_balance(context, seq, ibuf, mul, cfra); mul = 1.0; } @@ -1818,7 +1863,6 @@ static ImBuf *input_preprocess(SeqRenderData context, Sequence *seq, float cfra, } } - if (ibuf->x != context.rectx || ibuf->y != context.recty) { if (context.scene->r.mode & R_OSA) { IMB_scaleImBuf(ibuf, (short)context.rectx, (short)context.recty); @@ -1827,6 +1871,16 @@ static ImBuf *input_preprocess(SeqRenderData context, Sequence *seq, float cfra, IMB_scalefastImBuf(ibuf, (short)context.rectx, (short)context.recty); } } + + if (seq->modifiers.first) { + ImBuf *ibuf_new = BKE_sequence_modifier_apply_stack(context, seq, ibuf, cfra); + + if (ibuf_new != ibuf) { + IMB_freeImBuf(ibuf); + ibuf = ibuf_new; + } + } + return ibuf; } @@ -2098,23 +2152,23 @@ static ImBuf *seq_render_movieclip_strip(SeqRenderData context, Sequence *seq, f } -static ImBuf *seq_render_mask_strip(SeqRenderData context, Sequence *seq, float nr) +static ImBuf *seq_render_mask(SeqRenderData context, Mask *mask, float nr, short make_float) { /* TODO - add option to rasterize to alpha imbuf? */ ImBuf *ibuf = NULL; float *maskbuf; int i; - if (!seq->mask) { + if (!mask) { return NULL; } else { Mask *mask_temp; MaskRasterHandle *mr_handle; - mask_temp = BKE_mask_copy_nolib(seq->mask); + mask_temp = BKE_mask_copy_nolib(mask); - BKE_mask_evaluate(mask_temp, seq->mask->sfra + nr, TRUE); + BKE_mask_evaluate(mask_temp, mask->sfra + nr, TRUE); maskbuf = MEM_mallocN(sizeof(float) * context.rectx * context.recty, __func__); @@ -2131,7 +2185,7 @@ static ImBuf *seq_render_mask_strip(SeqRenderData context, Sequence *seq, float } - if (seq->flag & SEQ_MAKE_FLOAT) { + if (make_float) { /* pixels */ float *fp_src; float *fp_dst; @@ -2173,6 +2227,13 @@ static ImBuf *seq_render_mask_strip(SeqRenderData context, Sequence *seq, float return ibuf; } +static ImBuf *seq_render_mask_strip(SeqRenderData context, Sequence *seq, float nr) +{ + short make_float = seq->flag & SEQ_MAKE_FLOAT; + + return seq_render_mask(context, seq->mask, nr, make_float); +} + static ImBuf *seq_render_scene_strip(SeqRenderData context, Sequence *seq, float nr) { ImBuf *ibuf = NULL; @@ -2328,10 +2389,162 @@ static ImBuf *seq_render_scene_strip(SeqRenderData context, Sequence *seq, float return ibuf; } +static ImBuf *do_render_strip_uncached(SeqRenderData context, Sequence *seq, float cfra) +{ + ImBuf *ibuf = NULL; + float nr = give_stripelem_index(seq, cfra); + int type = (seq->type & SEQ_TYPE_EFFECT && seq->type != SEQ_TYPE_SPEED) ? SEQ_TYPE_EFFECT : seq->type; + int use_preprocess = BKE_sequencer_input_have_to_preprocess(context, seq, cfra); + char name[FILE_MAX]; + + switch (type) { + case SEQ_TYPE_META: + { + ImBuf *meta_ibuf = NULL; + + if (seq->seqbase.first) + meta_ibuf = seq_render_strip_stack(context, &seq->seqbase, seq->start + nr, 0); + + if (meta_ibuf) { + ibuf = meta_ibuf; + if (ibuf && use_preprocess) { + ImBuf *i = IMB_dupImBuf(ibuf); + + IMB_freeImBuf(ibuf); + + ibuf = i; + } + } + + break; + } + + case SEQ_TYPE_SPEED: + { + ImBuf *child_ibuf = NULL; + + float f_cfra; + SpeedControlVars *s = (SpeedControlVars *)seq->effectdata; + + BKE_sequence_effect_speed_rebuild_map(context.scene, seq, 0); + + /* weeek! */ + f_cfra = seq->start + s->frameMap[(int)nr]; + + child_ibuf = seq_render_strip(context, seq->seq1, f_cfra); + + if (child_ibuf) { + ibuf = child_ibuf; + if (ibuf && use_preprocess) { + ImBuf *i = IMB_dupImBuf(ibuf); + + IMB_freeImBuf(ibuf); + + ibuf = i; + } + } + break; + } + + case SEQ_TYPE_EFFECT: + { + ibuf = seq_render_effect_strip_impl(context, seq, seq->start + nr); + break; + } + + case SEQ_TYPE_IMAGE: + { + StripElem *s_elem = BKE_sequencer_give_stripelem(seq, cfra); + + if (s_elem) { + BLI_join_dirfile(name, sizeof(name), seq->strip->dir, s_elem->name); + BLI_path_abs(name, G.main->name); + } + + if (s_elem && (ibuf = IMB_loadiffname(name, IB_rect))) { + /* we don't need both (speed reasons)! */ + if (ibuf->rect_float && ibuf->rect) + imb_freerectImBuf(ibuf); + + /* all sequencer color is done in SRGB space, linear gives odd crossfades */ + if (ibuf->profile == IB_PROFILE_LINEAR_RGB) + IMB_convert_profile(ibuf, IB_PROFILE_NONE); + + copy_to_ibuf_still(context, seq, nr, ibuf); + + s_elem->orig_width = ibuf->x; + s_elem->orig_height = ibuf->y; + } + break; + } + + case SEQ_TYPE_MOVIE: + { + seq_open_anim_file(seq); + + if (seq->anim) { + IMB_anim_set_preseek(seq->anim, seq->anim_preseek); + + ibuf = IMB_anim_absolute(seq->anim, nr + seq->anim_startofs, + seq->strip->proxy ? seq->strip->proxy->tc : IMB_TC_RECORD_RUN, + seq_rendersize_to_proxysize(context.preview_render_size)); + + /* we don't need both (speed reasons)! */ + if (ibuf && ibuf->rect_float && ibuf->rect) + imb_freerectImBuf(ibuf); + if (ibuf) { + seq->strip->stripdata->orig_width = ibuf->x; + seq->strip->stripdata->orig_height = ibuf->y; + } + } + copy_to_ibuf_still(context, seq, nr, ibuf); + break; + } + + case SEQ_TYPE_SCENE: + { + /* scene can be NULL after deletions */ + ibuf = seq_render_scene_strip(context, seq, nr); + + /* Scene strips update all animation, so we need to restore original state.*/ + BKE_animsys_evaluate_all_animation(context.bmain, context.scene, cfra); + + copy_to_ibuf_still(context, seq, nr, ibuf); + break; + } + + case SEQ_TYPE_MOVIECLIP: + { + ibuf = seq_render_movieclip_strip(context, seq, nr); + + if (ibuf && use_preprocess) { + ImBuf *i = IMB_dupImBuf(ibuf); + + IMB_freeImBuf(ibuf); + + ibuf = i; + } + + copy_to_ibuf_still(context, seq, nr, ibuf); + break; + } + + case SEQ_TYPE_MASK: + { + /* ibuf is alwats new */ + ibuf = seq_render_mask_strip(context, seq, nr); + + copy_to_ibuf_still(context, seq, nr, ibuf); + break; + } + } + + return ibuf; +} + static ImBuf *seq_render_strip(SeqRenderData context, Sequence *seq, float cfra) { ImBuf *ibuf = NULL; - char name[FILE_MAX]; int use_preprocess = BKE_sequencer_input_have_to_preprocess(context, seq, cfra); int is_proxy_image = FALSE; float nr = give_stripelem_index(seq, cfra); @@ -2348,147 +2561,20 @@ static ImBuf *seq_render_strip(SeqRenderData context, Sequence *seq, float cfra) if (ibuf == NULL) ibuf = copy_from_ibuf_still(context, seq, nr); - - /* MOVIECLIPs have their own proxy management */ - if (ibuf == NULL && seq->type != SEQ_TYPE_MOVIECLIP) { - ibuf = seq_proxy_fetch(context, seq, cfra); - is_proxy_image = (ibuf != NULL); - } - if (ibuf == NULL) switch (type) { - case SEQ_TYPE_META: - { - ImBuf *meta_ibuf = NULL; + if (ibuf == NULL) { + ibuf = BKE_sequencer_preprocessed_cache_get(context, seq, cfra, SEQ_STRIPELEM_IBUF); - if (seq->seqbase.first) - meta_ibuf = seq_render_strip_stack( - context, &seq->seqbase, - seq->start + nr, 0); - - if (meta_ibuf) { - ibuf = meta_ibuf; - if (ibuf && use_preprocess) { - ImBuf *i = IMB_dupImBuf(ibuf); - - IMB_freeImBuf(ibuf); - - ibuf = i; - } - } - - break; + if (ibuf == NULL) { + /* MOVIECLIPs have their own proxy management */ + if (ibuf == NULL && seq->type != SEQ_TYPE_MOVIECLIP) { + ibuf = seq_proxy_fetch(context, seq, cfra); + is_proxy_image = (ibuf != NULL); } - case SEQ_TYPE_SPEED: - { - ImBuf *child_ibuf = NULL; - float f_cfra; - SpeedControlVars *s = (SpeedControlVars *)seq->effectdata; + ibuf = do_render_strip_uncached(context, seq, cfra); - BKE_sequence_effect_speed_rebuild_map(context.scene, seq, 0); - - /* weeek! */ - f_cfra = seq->start + s->frameMap[(int)nr]; - - child_ibuf = seq_render_strip(context, seq->seq1, f_cfra); - - if (child_ibuf) { - ibuf = child_ibuf; - if (ibuf && use_preprocess) { - ImBuf *i = IMB_dupImBuf(ibuf); - - IMB_freeImBuf(ibuf); - - ibuf = i; - } - } - break; - } - case SEQ_TYPE_EFFECT: - { - ibuf = seq_render_effect_strip_impl(context, seq, seq->start + nr); - break; - } - case SEQ_TYPE_IMAGE: - { - StripElem *s_elem = BKE_sequencer_give_stripelem(seq, cfra); - - if (s_elem) { - BLI_join_dirfile(name, sizeof(name), seq->strip->dir, s_elem->name); - BLI_path_abs(name, G.main->name); - } - - if (s_elem && (ibuf = IMB_loadiffname(name, IB_rect))) { - /* we don't need both (speed reasons)! */ - if (ibuf->rect_float && ibuf->rect) - imb_freerectImBuf(ibuf); - - /* all sequencer color is done in SRGB space, linear gives odd crossfades */ - if (ibuf->profile == IB_PROFILE_LINEAR_RGB) - IMB_convert_profile(ibuf, IB_PROFILE_NONE); - - copy_to_ibuf_still(context, seq, nr, ibuf); - - s_elem->orig_width = ibuf->x; - s_elem->orig_height = ibuf->y; - } - break; - } - case SEQ_TYPE_MOVIE: - { - seq_open_anim_file(seq); - - if (seq->anim) { - IMB_anim_set_preseek(seq->anim, seq->anim_preseek); - - ibuf = IMB_anim_absolute(seq->anim, nr + seq->anim_startofs, - seq->strip->proxy ? seq->strip->proxy->tc : IMB_TC_RECORD_RUN, - seq_rendersize_to_proxysize(context.preview_render_size)); - - /* we don't need both (speed reasons)! */ - if (ibuf && ibuf->rect_float && ibuf->rect) - imb_freerectImBuf(ibuf); - if (ibuf) { - seq->strip->stripdata->orig_width = ibuf->x; - seq->strip->stripdata->orig_height = ibuf->y; - } - } - copy_to_ibuf_still(context, seq, nr, ibuf); - break; - } - case SEQ_TYPE_SCENE: - { - /* scene can be NULL after deletions */ - ibuf = seq_render_scene_strip(context, seq, nr); - - /* Scene strips update all animation, so we need to restore original state.*/ - BKE_animsys_evaluate_all_animation(context.bmain, context.scene, cfra); - - copy_to_ibuf_still(context, seq, nr, ibuf); - break; - } - case SEQ_TYPE_MOVIECLIP: - { - ibuf = seq_render_movieclip_strip(context, seq, nr); - - if (ibuf && use_preprocess) { - ImBuf *i = IMB_dupImBuf(ibuf); - - IMB_freeImBuf(ibuf); - - ibuf = i; - } - - copy_to_ibuf_still(context, seq, nr, ibuf); - break; - } - case SEQ_TYPE_MASK: - { - /* ibuf is alwats new */ - ibuf = seq_render_mask_strip(context, seq, nr); - - copy_to_ibuf_still(context, seq, nr, ibuf); - break; + BKE_sequencer_preprocessed_cache_put(context, seq, cfra, SEQ_STRIPELEM_IBUF, ibuf); } } @@ -2876,7 +2962,7 @@ int BKE_sequence_check_depend(Sequence *seq, Sequence *cur) return TRUE; } -void BKE_sequence_invalidate_cache(Scene *scene, Sequence *seq) +static void sequence_invalidate_cache(Scene *scene, Sequence *seq, int invalidate_preprocess) { Editing *ed = scene->ed; Sequence *cur; @@ -2884,18 +2970,33 @@ void BKE_sequence_invalidate_cache(Scene *scene, Sequence *seq) /* invalidate cache for current sequence */ BKE_sequencer_cache_cleanup_sequence(seq); + if (invalidate_preprocess) + BKE_sequencer_preprocessed_cache_cleanup_sequence(seq); + /* invalidate cache for all dependent sequences */ SEQ_BEGIN (ed, cur) { if (cur == seq) continue; - if (BKE_sequence_check_depend(seq, cur)) + if (BKE_sequence_check_depend(seq, cur)) { BKE_sequencer_cache_cleanup_sequence(cur); + BKE_sequencer_preprocessed_cache_cleanup_sequence(cur); + } } SEQ_END } +void BKE_sequence_invalidate_cache(Scene *scene, Sequence *seq) +{ + sequence_invalidate_cache(scene, seq, TRUE); +} + +void BKE_sequence_invalidate_cache_for_modifier(Scene *scene, Sequence *seq) +{ + sequence_invalidate_cache(scene, seq, FALSE); +} + void BKE_sequencer_free_imbuf(Scene *scene, ListBase *seqbase, int check_mem_usage, int keep_file_handles) { Sequence *seq; @@ -3941,6 +4042,12 @@ static Sequence *seq_dupli(Scene *scene, Scene *scene_to, Sequence *seq, int dup seqn->strip->color_balance = MEM_dupallocN(seq->strip->color_balance); } + if (seqn->modifiers.first) { + seqn->modifiers.first = seqn->modifiers.last = NULL; + + BKE_sequence_modifier_list_copy(seqn, seq); + } + if (seq->type == SEQ_TYPE_META) { seqn->strip->stripdata = NULL; @@ -4060,3 +4167,4 @@ int BKE_seqence_is_valid_check(Sequence *seq) return TRUE; } + diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index e7722e07442..eb22b9a2e2e 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -4785,6 +4785,16 @@ static void link_paint(FileData *fd, Scene *sce, Paint *p) } } +static void lib_link_sequence_modifiers(FileData *fd, Scene *scene, ListBase *lb) +{ + SequenceModifierData *smd; + + for (smd = lb->first; smd; smd = smd->next) { + if (smd->mask_id) + smd->mask_id = newlibadr_us(fd, scene->id.lib, smd->mask_id); + } +} + static void lib_link_scene(FileData *fd, Main *main) { Scene *sce; @@ -4869,6 +4879,8 @@ static void lib_link_scene(FileData *fd, Main *main) } } seq->anim = NULL; + + lib_link_sequence_modifiers(fd, sce, &seq->modifiers); } SEQ_END @@ -4925,6 +4937,29 @@ static void direct_link_paint(FileData *fd, Paint **paint) (*paint)->num_input_samples = 1; } +static void direct_link_sequence_modifiers(FileData *fd, ListBase *lb) +{ + SequenceModifierData *smd; + + link_list(fd, lb); + + for (smd = lb->first; smd; smd = smd->next) { + if (smd->mask_sequence) + smd->mask_sequence = newdataadr(fd, smd->mask_sequence); + + if (smd->type == seqModifierType_Curves) { + CurvesModifierData *cmd = (CurvesModifierData *) smd; + + direct_link_curvemapping(fd, &cmd->curve_mapping); + } + else if (smd->type == seqModifierType_HueCorrect) { + HueCorrectModifierData *hcmd = (HueCorrectModifierData *) smd; + + direct_link_curvemapping(fd, &hcmd->curve_mapping); + } + } +} + static void direct_link_scene(FileData *fd, Scene *sce) { Editing *ed; @@ -5037,6 +5072,8 @@ static void direct_link_scene(FileData *fd, Scene *sce) // seq->strip->color_balance->gui = 0; // XXX - peter, is this relevant in 2.5? } } + + direct_link_sequence_modifiers(fd, &seq->modifiers); } SEQ_END diff --git a/source/blender/blenloader/intern/writefile.c b/source/blender/blenloader/intern/writefile.c index 2a68af688ed..4ada0c54a93 100644 --- a/source/blender/blenloader/intern/writefile.c +++ b/source/blender/blenloader/intern/writefile.c @@ -646,15 +646,21 @@ static void write_animdata(WriteData *wd, AnimData *adt) write_nladata(wd, &adt->nla_tracks); } -static void write_curvemapping(WriteData *wd, CurveMapping *cumap) +static void write_curvemapping_curves(WriteData *wd, CurveMapping *cumap) { int a; - - writestruct(wd, DATA, "CurveMapping", 1, cumap); - for (a=0; acm[a].totpoint, cumap->cm[a].curve); } +static void write_curvemapping(WriteData *wd, CurveMapping *cumap) +{ + writestruct(wd, DATA, "CurveMapping", 1, cumap); + + write_curvemapping_curves(wd, cumap); +} + static void write_node_socket(WriteData *wd, bNodeSocket *sock) { bNodeSocketType *stype= ntreeGetSocketType(sock->type); @@ -2086,6 +2092,32 @@ static void write_lamps(WriteData *wd, ListBase *idbase) } } +static void write_sequence_modifiers(WriteData *wd, ListBase *modbase) +{ + SequenceModifierData *smd; + + for (smd = modbase->first; smd; smd = smd->next) { + SequenceModifierTypeInfo *smti = BKE_sequence_modifier_type_info_get(smd->type); + + if (smti) { + writestruct(wd, DATA, smti->struct_name, 1, smd); + + if (smd->type == seqModifierType_Curves) { + CurvesModifierData *cmd = (CurvesModifierData *) smd; + + write_curvemapping(wd, &cmd->curve_mapping); + } + else if (smd->type == seqModifierType_HueCorrect) { + HueCorrectModifierData *hcmd = (HueCorrectModifierData *) smd; + + write_curvemapping(wd, &hcmd->curve_mapping); + } + } + else { + writestruct(wd, DATA, "SequenceModifierData", 1, smd); + } + } +} static void write_scenes(WriteData *wd, ListBase *scebase) { @@ -2192,6 +2224,8 @@ static void write_scenes(WriteData *wd, ListBase *scebase) strip->done = TRUE; } + + write_sequence_modifiers(wd, &seq->modifiers); } SEQ_END diff --git a/source/blender/editors/space_sequencer/CMakeLists.txt b/source/blender/editors/space_sequencer/CMakeLists.txt index 7bee8c2bebf..dd5fbb92171 100644 --- a/source/blender/editors/space_sequencer/CMakeLists.txt +++ b/source/blender/editors/space_sequencer/CMakeLists.txt @@ -40,6 +40,7 @@ set(SRC sequencer_buttons.c sequencer_draw.c sequencer_edit.c + sequencer_modifier.c sequencer_ops.c sequencer_scopes.c sequencer_select.c diff --git a/source/blender/editors/space_sequencer/sequencer_intern.h b/source/blender/editors/space_sequencer/sequencer_intern.h index 16cf929a832..bad4fcf9135 100644 --- a/source/blender/editors/space_sequencer/sequencer_intern.h +++ b/source/blender/editors/space_sequencer/sequencer_intern.h @@ -177,5 +177,9 @@ struct ImBuf *make_histogram_view_from_ibuf(struct ImBuf * ibuf); void sequencer_buttons_register(struct ARegionType *art); void SEQUENCER_OT_properties(struct wmOperatorType *ot); +/* sequencer_modifiers.c */ +void SEQUENCER_OT_strip_modifier_add(struct wmOperatorType *ot); +void SEQUENCER_OT_strip_modifier_remove(struct wmOperatorType *ot); + #endif /* __SEQUENCER_INTERN_H__ */ diff --git a/source/blender/editors/space_sequencer/sequencer_modifier.c b/source/blender/editors/space_sequencer/sequencer_modifier.c new file mode 100644 index 00000000000..4ae4b995c11 --- /dev/null +++ b/source/blender/editors/space_sequencer/sequencer_modifier.c @@ -0,0 +1,164 @@ +/* + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * The Original Code is Copyright (C) 2012 Blender Foundation. + * All rights reserved. + * + * Contributor(s): Blender Foundation, + * Sergey Sharybin + * + * ***** END GPL LICENSE BLOCK ***** + */ + + +/** \file blender/editors/space_sequencer/sequencer_modifier.c + * \ingroup spseq + */ + +#include "MEM_guardedalloc.h" + +#include "BLI_blenlib.h" +#include "BLI_math.h" +#include "BLI_utildefines.h" + +#include "DNA_scene_types.h" +#include "DNA_mask_types.h" +#include "DNA_userdef_types.h" + +#include "BKE_context.h" +#include "BKE_global.h" +#include "BKE_library.h" +#include "BKE_main.h" +#include "BKE_sequencer.h" +#include "BKE_movieclip.h" +#include "BKE_sequencer.h" +#include "BKE_mask.h" +#include "BKE_report.h" + +#include "WM_api.h" +#include "WM_types.h" + +#include "RNA_define.h" +#include "RNA_enum_types.h" + +#include "UI_interface.h" +#include "UI_resources.h" + +/* own include */ +#include "sequencer_intern.h" + +/*********************** Add modifier operator *************************/ + +static int strip_modifier_active_poll(bContext *C) +{ + Scene *scene = CTX_data_scene(C); + Editing *ed = BKE_sequencer_editing_get(scene, FALSE); + + if (ed) { + Sequence *seq = BKE_sequencer_active_get(scene); + + if (seq) + return BKE_sequence_supports_modifiers(seq); + } + + return FALSE; +} + +static int strip_modifier_add_exec(bContext *C, wmOperator *op) +{ + Scene *scene = CTX_data_scene(C); + Sequence *seq = BKE_sequencer_active_get(scene); + int type = RNA_enum_get(op->ptr, "type"); + + BKE_sequence_modifier_new(seq, type); + + BKE_sequence_invalidate_cache(scene, seq); + WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene); + + return OPERATOR_FINISHED; +} + +void SEQUENCER_OT_strip_modifier_add(wmOperatorType *ot) +{ + PropertyRNA *prop; + + /* TODO: de-duplicate from RNA */ + static EnumPropertyItem sequence_modifier_type_items[] = { + {seqModifierType_ColorBalance, "COLOR_BALANCE", ICON_NONE, "Color Balance", ""}, + {seqModifierType_Curves, "CURVES", ICON_NONE, "Curves", ""}, + {seqModifierType_HueCorrect,"HUE_CORRECT", ICON_NONE, "Hue Correct", ""}, + {0, NULL, 0, NULL, NULL} + }; + + /* identifiers */ + ot->name = "Add Strip Modifier"; + ot->idname = "SEQUENCER_OT_strip_modifier_add"; + ot->description = "Add a modifier to strip"; + + /* api callbacks */ + ot->exec = strip_modifier_add_exec; + ot->poll = strip_modifier_active_poll; + + /* flags */ + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; + + /* properties */ + prop = RNA_def_enum(ot->srna, "type", sequence_modifier_type_items, seqModifierType_ColorBalance, "Type", ""); + ot->prop = prop; +} + +/*********************** Remove modifier operator *************************/ + +static int strip_modifier_remove_exec(bContext *C, wmOperator *op) +{ + Scene *scene = CTX_data_scene(C); + Sequence *seq = BKE_sequencer_active_get(scene); + char name[MAX_NAME]; + SequenceModifierData *smd; + + RNA_string_get(op->ptr, "name", name); + + smd = BKE_sequence_modifier_find_by_name(seq, name); + if (!smd) + return OPERATOR_CANCELLED; + + BLI_remlink(&seq->modifiers, smd); + BKE_sequence_modifier_free(smd); + + BKE_sequence_invalidate_cache(scene, seq); + WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene); + + return OPERATOR_FINISHED; +} + +void SEQUENCER_OT_strip_modifier_remove(wmOperatorType *ot) +{ + /* identifiers */ + ot->name = "Remove Strip Modifier"; + ot->idname = "SEQUENCER_OT_strip_modifier_remove"; + ot->description = "Add a modifier to strip"; + + /* api callbacks */ + ot->exec = strip_modifier_remove_exec; + ot->poll = strip_modifier_active_poll; + + /* flags */ + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; + + /* properties */ + RNA_def_string(ot->srna, "name", "Name", MAX_NAME, "Name", "Name of modifier to remove"); +} diff --git a/source/blender/editors/space_sequencer/sequencer_ops.c b/source/blender/editors/space_sequencer/sequencer_ops.c index 4a1c8f0c006..45ffc997172 100644 --- a/source/blender/editors/space_sequencer/sequencer_ops.c +++ b/source/blender/editors/space_sequencer/sequencer_ops.c @@ -114,6 +114,10 @@ void sequencer_operatortypes(void) WM_operatortype_append(SEQUENCER_OT_copy); WM_operatortype_append(SEQUENCER_OT_paste); + + /* sequencer_modifiers.c */ + WM_operatortype_append(SEQUENCER_OT_strip_modifier_add); + WM_operatortype_append(SEQUENCER_OT_strip_modifier_remove); } diff --git a/source/blender/makesdna/DNA_sequence_types.h b/source/blender/makesdna/DNA_sequence_types.h index 16e8b8904fa..d6c59456bd0 100644 --- a/source/blender/makesdna/DNA_sequence_types.h +++ b/source/blender/makesdna/DNA_sequence_types.h @@ -34,6 +34,7 @@ #define __DNA_SEQUENCE_TYPES_H__ #include "DNA_defs.h" +#include "DNA_color_types.h" #include "DNA_listBase.h" #include "DNA_vec_types.h" @@ -167,6 +168,9 @@ typedef struct Sequence { /* is sfra needed anymore? - it looks like its only used in one place */ int sfra, pad; /* starting frame according to the timeline of the scene. */ + + /* modifiers */ + ListBase modifiers; } Sequence; typedef struct MetaStack { @@ -229,6 +233,40 @@ typedef struct SpeedControlVars { int lastValidFrame; } SpeedControlVars; +/* ***************** Sequence modifiers ****************** */ + +typedef struct SequenceModifierData { + struct SequenceModifierData *next, *prev; + int type, flag; + char name[64]; /* MAX_NAME */ + + /* mask input, either sequence or maks ID */ + int mask_input_type, pad; + + struct Sequence *mask_sequence; + struct Mask *mask_id; +} SequenceModifierData; + +typedef struct ColorBalanceModifierData { + SequenceModifierData modifier; + + StripColorBalance color_balance; + float color_multiply; + int pad; +} ColorBalanceModifierData; + +typedef struct CurvesModifierData { + SequenceModifierData modifier; + + struct CurveMapping curve_mapping; +} CurvesModifierData; + +typedef struct HueCorrectModifierData { + SequenceModifierData modifier; + + struct CurveMapping curve_mapping; +} HueCorrectModifierData; + #define MAXSEQ 32 #define SELECT 1 @@ -352,5 +390,26 @@ enum { #define SEQ_HAS_PATH(_seq) (ELEM4((_seq)->type, SEQ_TYPE_MOVIE, SEQ_TYPE_IMAGE, SEQ_TYPE_SOUND_RAM, SEQ_TYPE_SOUND_HD)) -#endif +/* modifiers */ +/* SequenceModifierData->type */ +enum { + seqModifierType_ColorBalance = 1, + seqModifierType_Curves = 2, + seqModifierType_HueCorrect = 3, + + NUM_SEQUENCE_MODIFIER_TYPES +}; + +/* SequenceModifierData->flag */ +enum { + SEQUENCE_MODIFIER_MUTE = (1 << 0), + SEQUENCE_MODIFIER_EXPANDED = (1 << 1), +}; + +enum { + SEQUENCE_MASK_INPUT_STRIP = 0, + SEQUENCE_MASK_INPUT_ID = 1 +}; + +#endif diff --git a/source/blender/makesrna/intern/rna_sequencer.c b/source/blender/makesrna/intern/rna_sequencer.c index 6fc304e6bbb..fd8195005aa 100644 --- a/source/blender/makesrna/intern/rna_sequencer.c +++ b/source/blender/makesrna/intern/rna_sequencer.c @@ -332,8 +332,9 @@ static char *rna_SequenceTransform_path(PointerRNA *ptr) return BLI_strdup(""); } -static void rna_SequenceTransform_update(Main *UNUSED(bmain), Scene *scene, PointerRNA *ptr) +static void rna_SequenceTransform_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr) { + Scene *scene = (Scene *) ptr->id.data; Editing *ed = BKE_sequencer_editing_get(scene, FALSE); Sequence *seq = sequence_get_by_transform(ed, ptr->data); @@ -376,8 +377,9 @@ static char *rna_SequenceCrop_path(PointerRNA *ptr) return BLI_strdup(""); } -static void rna_SequenceCrop_update(Main *UNUSED(bmain), Scene *scene, PointerRNA *ptr) +static void rna_SequenceCrop_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr) { + Scene *scene = (Scene *) ptr->id.data; Editing *ed = BKE_sequencer_editing_get(scene, FALSE); Sequence *seq = sequence_get_by_crop(ed, ptr->data); @@ -613,8 +615,9 @@ static void rna_SequenceElement_filename_set(PointerRNA *ptr, const char *value) } #endif -static void rna_Sequence_update(Main *UNUSED(bmain), Scene *scene, PointerRNA *ptr) +static void rna_Sequence_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr) { + Scene *scene = (Scene *) ptr->id.data; Editing *ed = BKE_sequencer_editing_get(scene, FALSE); if (ed) { @@ -638,8 +641,9 @@ static int rna_Sequence_otherSequence_poll(PointerRNA *ptr, PointerRNA value) return TRUE; } -static void rna_Sequence_update_reopen_files(Main *UNUSED(bmain), Scene *scene, PointerRNA *ptr) +static void rna_Sequence_update_reopen_files(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr) { + Scene *scene = (Scene *) ptr->id.data; Editing *ed = BKE_sequencer_editing_get(scene, FALSE); BKE_sequencer_free_imbuf(scene, &ed->seqbase, FALSE, FALSE); @@ -648,16 +652,18 @@ static void rna_Sequence_update_reopen_files(Main *UNUSED(bmain), Scene *scene, BKE_sequencer_update_sound_bounds(scene, ptr->data); } -static void rna_Sequence_mute_update(Main *bmain, Scene *scene, PointerRNA *ptr) +static void rna_Sequence_mute_update(Main *bmain, Scene *UNUSED(scene), PointerRNA *ptr) { + Scene *scene = (Scene *) ptr->id.data; Editing *ed = BKE_sequencer_editing_get(scene, FALSE); BKE_sequencer_update_muting(ed); rna_Sequence_update(bmain, scene, ptr); } -static void rna_Sequence_filepath_update(Main *bmain, Scene *scene, PointerRNA *ptr) +static void rna_Sequence_filepath_update(Main *bmain, Scene *UNUSED(scene), PointerRNA *ptr) { + Scene *scene = (Scene *) ptr->id.data; Sequence *seq = (Sequence *)(ptr->data); BKE_sequence_reload_new_file(scene, seq, TRUE); BKE_sequence_calc(scene, seq); @@ -686,8 +692,9 @@ static Sequence *sequence_get_by_proxy(Editing *ed, StripProxy *proxy) return data.seq; } -static void rna_Sequence_tcindex_update(Main *bmain, Scene *scene, PointerRNA *ptr) +static void rna_Sequence_tcindex_update(Main *bmain, Scene *UNUSED(scene), PointerRNA *ptr) { + Scene *scene = (Scene *) ptr->id.data; Editing *ed = BKE_sequencer_editing_get(scene, FALSE); Sequence *seq = sequence_get_by_proxy(ed, ptr->data); @@ -695,8 +702,9 @@ static void rna_Sequence_tcindex_update(Main *bmain, Scene *scene, PointerRNA *p rna_Sequence_frame_change_update(scene, seq); } -static void rna_SequenceProxy_update(Main *UNUSED(bmain), Scene *scene, PointerRNA *ptr) +static void rna_SequenceProxy_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr) { + Scene *scene = (Scene *) ptr->id.data; Editing *ed = BKE_sequencer_editing_get(scene, FALSE); Sequence *seq = sequence_get_by_proxy(ed, ptr->data); @@ -724,6 +732,22 @@ static int colbalance_seq_cmp_cb(Sequence *seq, void *arg_pt) data->seq = seq; return -1; /* done so bail out */ } + + if (seq->modifiers.first) { + SequenceModifierData *smd = seq->modifiers.first; + + for (smd = seq->modifiers.first; smd; smd = smd->next) { + if (smd->type == seqModifierType_ColorBalance) { + ColorBalanceModifierData *cbmd = (ColorBalanceModifierData *) smd; + + if (&cbmd->color_balance == data->data) { + data->seq = seq; + return -1; /* done so bail out */ + } + } + } + } + return 1; } @@ -752,12 +776,16 @@ static char *rna_SequenceColorBalance_path(PointerRNA *ptr) return BLI_strdup(""); } -static void rna_SequenceColorBalance_update(Main *UNUSED(bmain), Scene *scene, PointerRNA *ptr) +static void rna_SequenceColorBalance_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr) { + Scene *scene = (Scene *) ptr->id.data; Editing *ed = BKE_sequencer_editing_get(scene, FALSE); Sequence *seq = sequence_get_by_colorbalance(ed, ptr->data); - BKE_sequence_invalidate_cache(scene, seq); + if (seq->strip->color_balance == ptr->data) + BKE_sequence_invalidate_cache(scene, seq); + else + BKE_sequence_invalidate_cache_for_modifier(scene, seq); } static void rna_SequenceEditor_overlay_lock_set(PointerRNA *ptr, int value) @@ -825,6 +853,113 @@ static float rna_WipeSequence_angle_get(PointerRNA *ptr) return DEG2RADF(((WipeVars *)seq->effectdata)->angle); } +static int modifier_seq_cmp_cb(Sequence *seq, void *arg_pt) +{ + SequenceSearchData *data = arg_pt; + + if (BLI_findindex(&seq->modifiers, data->data) != -1) { + data->seq = seq; + return -1; /* done so bail out */ + } + + return 1; +} + +static Sequence *sequence_get_by_modifier(Editing *ed, SequenceModifierData *smd) +{ + SequenceSearchData data; + + data.seq = NULL; + data.data = smd; + + /* irritating we need to search for our sequence! */ + BKE_sequencer_base_recursive_apply(&ed->seqbase, modifier_seq_cmp_cb, &data); + + return data.seq; +} + +static StructRNA *rna_SequenceModifier_refine(struct PointerRNA *ptr) +{ + SequenceModifierData *smd = (SequenceModifierData *) ptr->data; + + switch (smd->type) { + case seqModifierType_ColorBalance: + return &RNA_ColorBalanceModifier; + case seqModifierType_Curves: + return &RNA_CurvesModifier; + case seqModifierType_HueCorrect: + return &RNA_HueCorrectModifier; + default: + return &RNA_SequenceModifier; + } +} + +static char *rna_SequenceModifier_path(PointerRNA *ptr) +{ + Scene *scene = ptr->id.data; + Editing *ed = BKE_sequencer_editing_get(scene, FALSE); + SequenceModifierData *smd = ptr->data; + Sequence *seq = sequence_get_by_modifier(ed, smd); + + if (seq && seq->name + 2) + return BLI_sprintfN("sequence_editor.sequences_all[\"%s\"].modifiers[\"%s\"]", seq->name + 2, smd->name); + else + return BLI_strdup(""); +} + +static void rna_SequenceModifier_name_set(PointerRNA *ptr, const char *value) +{ + SequenceModifierData *smd = ptr->data; + Scene *scene = (Scene *) ptr->id.data; + Editing *ed = BKE_sequencer_editing_get(scene, FALSE); + Sequence *seq = sequence_get_by_modifier(ed, smd); + AnimData *adt; + char oldname[sizeof(smd->name)]; + + /* make a copy of the old name first */ + BLI_strncpy(oldname, smd->name, sizeof(smd->name)); + + /* copy the new name into the name slot */ + BLI_strncpy_utf8(smd->name, value, sizeof(smd->name)); + + /* make sure the name is truly unique */ + BKE_sequence_modifier_unique_name(seq, smd); + + /* fix all the animation data which may link to this */ + adt = BKE_animdata_from_id(&scene->id); + if (adt) { + char path[1024]; + + BLI_snprintf(path, sizeof(path), "sequence_editor.sequences_all[\"%s\"].modifiers", seq->name); + BKE_animdata_fix_paths_rename(&scene->id, adt, NULL, path, oldname, smd->name + 2, 0, 0, 1); + } +} + +static void rna_SequenceModifier_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr) +{ + /* strip from other scenes could be modified, so using active scene is not reliable */ + Scene *scene = (Scene *) ptr->id.data; + Editing *ed = BKE_sequencer_editing_get(scene, FALSE); + Sequence *seq = sequence_get_by_modifier(ed, ptr->data); + + BKE_sequence_invalidate_cache_for_modifier(scene, seq); +} + +static int rna_SequenceModifier_otherSequence_poll(PointerRNA *ptr, PointerRNA value) +{ + Scene *scene = (Scene *) ptr->id.data; + Editing *ed = BKE_sequencer_editing_get(scene, FALSE); + Sequence *seq = sequence_get_by_modifier(ed, ptr->data); + Sequence *cur = (Sequence *) value.data; + + if (seq == cur) + return FALSE; + + if (BKE_sequence_check_depend(seq, cur)) + return FALSE; + + return TRUE; +} #else @@ -991,13 +1126,13 @@ static void rna_def_strip_proxy(BlenderRNA *brna) } -static void rna_def_strip_color_balance(BlenderRNA *brna) +static void rna_def_color_balance(BlenderRNA *brna) { StructRNA *srna; PropertyRNA *prop; - srna = RNA_def_struct(brna, "SequenceColorBalance", NULL); - RNA_def_struct_ui_text(srna, "Sequence Color Balance", "Color balance parameters for a sequence strip"); + srna = RNA_def_struct(brna, "SequenceColorBalanceData", NULL); + RNA_def_struct_ui_text(srna, "Sequence Color Balance Data", "Color balance parameters for a sequence strip and it's modifiers"); RNA_def_struct_sdna(srna, "StripColorBalance"); prop = RNA_def_property(srna, "lift", PROP_FLOAT, PROP_COLOR); @@ -1005,19 +1140,19 @@ static void rna_def_strip_color_balance(BlenderRNA *brna) RNA_def_property_ui_range(prop, 0, 2, 0.1, 3); RNA_def_property_float_default(prop, 1.0f); RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_SequenceColorBalance_update"); - + prop = RNA_def_property(srna, "gamma", PROP_FLOAT, PROP_COLOR); RNA_def_property_ui_text(prop, "Gamma", "Color balance gamma (midtones)"); RNA_def_property_ui_range(prop, 0, 2, 0.1, 3); RNA_def_property_float_default(prop, 1.0f); RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_SequenceColorBalance_update"); - + prop = RNA_def_property(srna, "gain", PROP_FLOAT, PROP_COLOR); RNA_def_property_ui_text(prop, "Gain", "Color balance gain (highlights)"); RNA_def_property_ui_range(prop, 0, 2, 0.1, 3); RNA_def_property_float_default(prop, 1.0f); RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_SequenceColorBalance_update"); - + prop = RNA_def_property(srna, "invert_gain", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", SEQ_COLOR_BALANCE_INVERSE_GAIN); RNA_def_property_ui_text(prop, "Inverse Gain", ""); @@ -1033,15 +1168,13 @@ static void rna_def_strip_color_balance(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Inverse Lift", ""); RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_SequenceColorBalance_update"); - RNA_def_struct_path_func(srna, "rna_SequenceColorBalance_path"); - /* not yet used */ #if 0 prop = RNA_def_property(srna, "exposure", PROP_FLOAT, PROP_NONE); RNA_def_property_range(prop, 0.0f, 1.0f); RNA_def_property_ui_text(prop, "Exposure", ""); RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_Sequence_ColorBabalnce_update"); - + prop = RNA_def_property(srna, "saturation", PROP_FLOAT, PROP_NONE); RNA_def_property_range(prop, 0.0f, 1.0f); RNA_def_property_ui_text(prop, "Saturation", ""); @@ -1049,6 +1182,17 @@ static void rna_def_strip_color_balance(BlenderRNA *brna) #endif } +static void rna_def_strip_color_balance(BlenderRNA *brna) +{ + StructRNA *srna; + + srna = RNA_def_struct(brna, "SequenceColorBalance", "SequenceColorBalanceData"); + RNA_def_struct_ui_text(srna, "Sequence Color Balance", "Color balance parameters for a sequence strip"); + RNA_def_struct_sdna(srna, "StripColorBalance"); + + RNA_def_struct_path_func(srna, "rna_SequenceColorBalance_path"); +} + EnumPropertyItem blend_mode_items[] = { {SEQ_BLEND_REPLACE, "REPLACE", 0, "Replace", ""}, {SEQ_TYPE_CROSS, "CROSS", 0, "Cross", ""}, @@ -1062,6 +1206,18 @@ EnumPropertyItem blend_mode_items[] = { {0, NULL, 0, NULL, NULL} }; +static void rna_def_sequence_modifiers(BlenderRNA *brna, PropertyRNA *cprop) +{ + StructRNA *srna; + + RNA_def_property_srna(cprop, "SequenceModifiers"); + srna = RNA_def_struct(brna, "SequenceModifiers", NULL); + RNA_def_struct_sdna(srna, "Sequence"); + RNA_def_struct_ui_text(srna, "Strip Modifiers", "Collection of strip modifiers"); + + /* TODO: implement new/remove/clear methods for modifier stack */ +} + static void rna_def_sequence(BlenderRNA *brna) { StructRNA *srna; @@ -1253,6 +1409,12 @@ static void rna_def_sequence(BlenderRNA *brna) "to this frame"); RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_Sequence_update"); + /* modifiers */ + prop = RNA_def_property(srna, "modifiers", PROP_COLLECTION, PROP_NONE); + RNA_def_property_struct_type(prop, "SequenceModifier"); + RNA_def_property_ui_text(prop, "Modifiers", "Modifiers affecting this strip"); + rna_def_sequence_modifiers(brna, prop); + RNA_api_sequence_strip(srna); } @@ -1475,7 +1637,7 @@ static void rna_def_effect_inputs(StructRNA *srna, int count, int supports_mask) */ if (supports_mask) { - prop = RNA_def_property(srna, "input_mask", PROP_POINTER, PROP_NONE); + prop = RNA_def_property(srna, "input_mask_strip", PROP_POINTER, PROP_NONE); RNA_def_property_pointer_sdna(prop, NULL, "mask_sequence"); RNA_def_property_pointer_funcs(prop, NULL, NULL, NULL, "rna_Sequence_otherSequence_poll"); RNA_def_property_flag(prop, PROP_EDITABLE); @@ -1963,8 +2125,138 @@ static void rna_def_effects(BlenderRNA *brna) } } +static void rna_def_modifier(BlenderRNA *brna) +{ + StructRNA *srna; + PropertyRNA *prop; + + static EnumPropertyItem sequence_modifier_type_items[] = { + {seqModifierType_ColorBalance, "COLOR_BALANCE", ICON_NONE, "Color Balance", ""}, + {seqModifierType_Curves, "CURVES", ICON_NONE, "Curves", ""}, + {seqModifierType_HueCorrect,"HUE_CORRECT", ICON_NONE, "Hue Correct", ""}, + {0, NULL, 0, NULL, NULL} + }; + + static const EnumPropertyItem mask_input_type_items[] = { + {SEQUENCE_MASK_INPUT_STRIP, "STRIP", 0, "Strip", "Use sequencer strip as mask input"}, + {SEQUENCE_MASK_INPUT_ID, "ID", 0, "Mask", "Use mask ID as mask input"}, + {0, NULL, 0, NULL, NULL} + }; + + srna = RNA_def_struct(brna, "SequenceModifier", NULL); + RNA_def_struct_sdna(srna, "SequenceModifierData"); + RNA_def_struct_ui_text(srna, "SequenceModifier", "Modifier for sequence strip"); + RNA_def_struct_refine_func(srna, "rna_SequenceModifier_refine"); + RNA_def_struct_path_func(srna, "rna_SequenceModifier_path"); + + prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE); + RNA_def_property_string_funcs(prop, NULL, NULL, "rna_SequenceModifier_name_set"); + RNA_def_property_ui_text(prop, "Name", ""); + RNA_def_struct_name_property(srna, prop); + RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, NULL); + + prop = RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + RNA_def_property_enum_items(prop, sequence_modifier_type_items); + RNA_def_property_ui_text(prop, "Type", ""); + RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, NULL); + + prop = RNA_def_property(srna, "mute", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", SEQUENCE_MODIFIER_MUTE); + RNA_def_property_ui_text(prop, "Mute", "Mute this modifier"); + RNA_def_property_ui_icon(prop, ICON_RESTRICT_VIEW_OFF, 1); + RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_SequenceModifier_update"); + + prop = RNA_def_property(srna, "show_expanded", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", SEQUENCE_MODIFIER_EXPANDED); + RNA_def_property_ui_text(prop, "Expanded", "Mute expanded settings for the modifier"); + RNA_def_property_ui_icon(prop, ICON_TRIA_RIGHT, 1); + RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, NULL); + + prop = RNA_def_property(srna, "input_mask_type", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_sdna(prop, NULL, "mask_input_type"); + RNA_def_property_enum_items(prop, mask_input_type_items); + RNA_def_property_ui_text(prop, "Mask Input Type", "Type of input data used for mask"); + RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_SequenceModifier_update"); + + prop = RNA_def_property(srna, "input_mask_strip", PROP_POINTER, PROP_NONE); + RNA_def_property_pointer_sdna(prop, NULL, "mask_sequence"); + RNA_def_property_pointer_funcs(prop, NULL, NULL, NULL, "rna_SequenceModifier_otherSequence_poll"); + RNA_def_property_flag(prop, PROP_EDITABLE); + RNA_def_property_ui_text(prop, "Mask Strip", "Strip used as mask input for the modifier"); + RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_SequenceModifier_update"); + + prop = RNA_def_property(srna, "input_mask_id", PROP_POINTER, PROP_NONE); + RNA_def_property_pointer_sdna(prop, NULL, "mask_id"); + RNA_def_property_flag(prop, PROP_EDITABLE); + RNA_def_property_ui_text(prop, "Mask", "Mask ID used as mask input for the modifier"); + RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_SequenceModifier_update"); +} + +static void rna_def_colorbalance_modifier(BlenderRNA *brna) +{ + StructRNA *srna; + PropertyRNA *prop; + + srna = RNA_def_struct(brna, "ColorBalanceModifier", "SequenceModifier"); + RNA_def_struct_sdna(srna, "ColorBalanceModifierData"); + RNA_def_struct_ui_text(srna, "ColorBalanceModifier", "Color balance modifier for sequence strip"); + + prop = RNA_def_property(srna, "color_balance", PROP_POINTER, PROP_NONE); + RNA_def_property_struct_type(prop, "SequenceColorBalanceData"); + + prop = RNA_def_property(srna, "color_multiply", PROP_FLOAT, PROP_UNSIGNED); + RNA_def_property_float_sdna(prop, NULL, "color_multiply"); + RNA_def_property_range(prop, 0.0f, 20.0f); + RNA_def_property_float_default(prop, 1.0f); + RNA_def_property_ui_text(prop, "Multiply Colors", ""); + RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_SequenceModifier_update"); +} + +static void rna_def_curves_modifier(BlenderRNA *brna) +{ + StructRNA *srna; + PropertyRNA *prop; + + srna = RNA_def_struct(brna, "CurvesModifier", "SequenceModifier"); + RNA_def_struct_sdna(srna, "CurvesModifierData"); + RNA_def_struct_ui_text(srna, "CurvesModifier", "RGB curves modifier for sequence strip"); + + prop = RNA_def_property(srna, "curve_mapping", PROP_POINTER, PROP_NONE); + RNA_def_property_pointer_sdna(prop, NULL, "curve_mapping"); + RNA_def_property_struct_type(prop, "CurveMapping"); + RNA_def_property_ui_text(prop, "Curve Mapping", ""); + RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_SequenceModifier_update"); +} + +static void rna_def_hue_modifier(BlenderRNA *brna) +{ + StructRNA *srna; + PropertyRNA *prop; + + srna = RNA_def_struct(brna, "HueCorrectModifier", "SequenceModifier"); + RNA_def_struct_sdna(srna, "HueCorrectModifierData"); + RNA_def_struct_ui_text(srna, "HueCorrectModifier", "Hue correction modifier for sequence strip"); + + prop = RNA_def_property(srna, "curve_mapping", PROP_POINTER, PROP_NONE); + RNA_def_property_pointer_sdna(prop, NULL, "curve_mapping"); + RNA_def_property_struct_type(prop, "CurveMapping"); + RNA_def_property_ui_text(prop, "Curve Mapping", ""); + RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_SequenceModifier_update"); +} + +static void rna_def_modifiers(BlenderRNA *brna) +{ + rna_def_modifier(brna); + rna_def_colorbalance_modifier(brna); + rna_def_curves_modifier(brna); + rna_def_hue_modifier(brna); +} + void RNA_def_sequencer(BlenderRNA *brna) { + rna_def_color_balance(brna); + rna_def_strip_element(brna); rna_def_strip_proxy(brna); rna_def_strip_color_balance(brna); @@ -1983,6 +2275,7 @@ void RNA_def_sequencer(BlenderRNA *brna) rna_def_sound(brna); rna_def_effect(brna); rna_def_effects(brna); + rna_def_modifiers(brna); } #endif diff --git a/source/blender/makesrna/intern/rna_ui_api.c b/source/blender/makesrna/intern/rna_ui_api.c index 96ddcce6004..cf43bd74d72 100644 --- a/source/blender/makesrna/intern/rna_ui_api.c +++ b/source/blender/makesrna/intern/rna_ui_api.c @@ -125,6 +125,7 @@ void RNA_api_ui_layout(StructRNA *srna) {0, "NONE", 0, "None", ""}, {'v', "VECTOR", 0, "Vector", ""}, {'c', "COLOR", 0, "Color", ""}, + {'h', "HUE", 0, "Hue", ""}, {0, NULL, 0, NULL, NULL} }; From cf3d58512b524d98ce7d270889adaf9665ba4214 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 19 Aug 2012 15:56:49 +0000 Subject: [PATCH 017/163] - fix for error in ndof patch. - ColorBalanceModifierData wasn't aligned on 32bit systems. - BM_vert_find_first_loop() was missing NULL check. --- source/blender/bmesh/intern/bmesh_queries.c | 4 +++ .../editors/space_view3d/view3d_edit.c | 12 ++++---- .../editors/transform/transform_manipulator.c | 28 +++++++++---------- source/blender/makesdna/DNA_sequence_types.h | 1 - 4 files changed, 25 insertions(+), 20 deletions(-) diff --git a/source/blender/bmesh/intern/bmesh_queries.c b/source/blender/bmesh/intern/bmesh_queries.c index a439eff36f6..a9f146e4962 100644 --- a/source/blender/bmesh/intern/bmesh_queries.c +++ b/source/blender/bmesh/intern/bmesh_queries.c @@ -202,6 +202,10 @@ BMLoop *BM_vert_find_first_loop(BMVert *v) return NULL; e = bmesh_disk_faceedge_find_first(v->e, v); + + if (!e) + return NULL; + return bmesh_radial_faceloop_find_first(e->l, v); } diff --git a/source/blender/editors/space_view3d/view3d_edit.c b/source/blender/editors/space_view3d/view3d_edit.c index b262819474b..e5730e0f69b 100644 --- a/source/blender/editors/space_view3d/view3d_edit.c +++ b/source/blender/editors/space_view3d/view3d_edit.c @@ -1022,9 +1022,10 @@ static int ndof_orbit_invoke(bContext *C, wmOperator *UNUSED(op), wmEvent *event /* tune these until everything feels right */ const float rot_sensitivity = 1.f; +#if 0 const float zoom_sensitivity = 1.f; +#endif const float pan_sensitivity = 1.f; - const int has_rotation = rv3d->viewlock != RV3D_LOCKED && !is_zero_v3(ndof->rvec); float view_inv[4]; @@ -1249,12 +1250,11 @@ static int ndof_all_invoke(bContext *C, wmOperator *op, wmEvent *event) View3D *v3d = CTX_wm_view3d(C); wmNDOFMotionData *ndof = (wmNDOFMotionData *) event->customdata; - ED_view3d_camera_lock_init(v3d, rv3d); - viewops_data_create(C, op, event); vod = op->customdata; rv3d = vod->rv3d; - + + ED_view3d_camera_lock_init(v3d, rv3d); if (ndof->progress != P_FINISHING) { @@ -1271,11 +1271,13 @@ static int ndof_all_invoke(bContext *C, wmOperator *op, wmEvent *event) float pan_vec[3]; const float rot_sensitivity = 1.f; +#if 0 const float zoom_sensitivity = 1.f; const float pan_sensitivity = 1.f; float rot[4]; - float axis[3]; float angle = rot_sensitivity * ndof_to_axis_angle(ndof, axis); + float axis[3]; +#endif if (U.ndof_flag & NDOF_PANX_INVERT_AXIS) pan_vec[0] = -lateral_sensitivity * ndof->tvec[0]; diff --git a/source/blender/editors/transform/transform_manipulator.c b/source/blender/editors/transform/transform_manipulator.c index a89ba06c1af..74a2292d74c 100644 --- a/source/blender/editors/transform/transform_manipulator.c +++ b/source/blender/editors/transform/transform_manipulator.c @@ -84,22 +84,22 @@ /* return codes for select, and drawing flags */ -#define MAN_TRANS_X 1 -#define MAN_TRANS_Y 2 -#define MAN_TRANS_Z 4 -#define MAN_TRANS_C 7 +#define MAN_TRANS_X (1 << 0) +#define MAN_TRANS_Y (1 << 1) +#define MAN_TRANS_Z (1 << 2) +#define MAN_TRANS_C (MAN_TRANS_X | MAN_TRANS_Y | MAN_TRANS_Z) -#define MAN_ROT_X 8 -#define MAN_ROT_Y 16 -#define MAN_ROT_Z 32 -#define MAN_ROT_V 64 -#define MAN_ROT_T 128 -#define MAN_ROT_C 248 +#define MAN_ROT_X (1 << 3) +#define MAN_ROT_Y (1 << 4) +#define MAN_ROT_Z (1 << 5) +#define MAN_ROT_V (1 << 6) +#define MAN_ROT_T (1 << 7) +#define MAN_ROT_C (MAN_ROT_X | MAN_ROT_Y | MAN_ROT_Z | MAN_ROT_V | MAN_ROT_T) -#define MAN_SCALE_X 256 -#define MAN_SCALE_Y 512 -#define MAN_SCALE_Z 1024 -#define MAN_SCALE_C 1792 +#define MAN_SCALE_X (1 << 8) +#define MAN_SCALE_Y (1 << 9) +#define MAN_SCALE_Z (1 << 10) +#define MAN_SCALE_C (MAN_SCALE_X | MAN_SCALE_Y | MAN_SCALE_Z) /* color codes */ diff --git a/source/blender/makesdna/DNA_sequence_types.h b/source/blender/makesdna/DNA_sequence_types.h index d6c59456bd0..e7ab6f66408 100644 --- a/source/blender/makesdna/DNA_sequence_types.h +++ b/source/blender/makesdna/DNA_sequence_types.h @@ -252,7 +252,6 @@ typedef struct ColorBalanceModifierData { StripColorBalance color_balance; float color_multiply; - int pad; } ColorBalanceModifierData; typedef struct CurvesModifierData { From 526d0be9bfb727c87281e6edd92ffd4a27a57cbd Mon Sep 17 00:00:00 2001 From: Nicholas Bishop Date: Sun, 19 Aug 2012 17:13:45 +0000 Subject: [PATCH 018/163] Fix crash when adding skin modifier to empty mesh Fixes bug [#32362] SIGSEGV when adding skin modifier to empty mesh projects.blender.org/tracker/?func=detail&atid=498&aid=32362&group_id=9 --- source/blender/editors/object/object_modifier.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/source/blender/editors/object/object_modifier.c b/source/blender/editors/object/object_modifier.c index bbc7a6ace7d..2b1492aa732 100644 --- a/source/blender/editors/object/object_modifier.c +++ b/source/blender/editors/object/object_modifier.c @@ -1462,7 +1462,8 @@ static void modifier_skin_customdata_ensure(Object *ob) me->totvert); /* Mark an arbitrary vertex as root */ - vs->flag |= MVERT_SKIN_ROOT; + if (vs) + vs->flag |= MVERT_SKIN_ROOT; } } From 59c8c645c351af4473d869d543b0465225b9f85e Mon Sep 17 00:00:00 2001 From: Dalai Felinto Date: Sun, 19 Aug 2012 20:45:34 +0000 Subject: [PATCH 019/163] patch/bugfix [#32006] Fix for Collision Sensor - R6025 pure virtual function call crash when deleting objects in overlay scene by Jay Parker(battery) Fix for bug [#30477] Collision Sensor - R6025 pure virtual function call crash --- source/gameengine/Ketsji/KX_GameObject.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/source/gameengine/Ketsji/KX_GameObject.cpp b/source/gameengine/Ketsji/KX_GameObject.cpp index 04a806dfd92..3818cef7d6e 100644 --- a/source/gameengine/Ketsji/KX_GameObject.cpp +++ b/source/gameengine/Ketsji/KX_GameObject.cpp @@ -1688,7 +1688,8 @@ PyObject* KX_GameObject::PyReplaceMesh(PyObject* args) PyObject* KX_GameObject::PyEndObject() { - KX_Scene *scene = KX_GetActiveScene(); + SG_Node* node = this->GetSGNode(); + KX_Scene* scene = static_cast(node->GetSGClientInfo()); scene->DelayedRemoveObject(this); From 257c6de9ace4c66d6054d10712204b62aa8ace2f Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 19 Aug 2012 21:32:18 +0000 Subject: [PATCH 020/163] copy as script operator for the console, so you can copy input from a console for use in a textblock. --- release/scripts/modules/console_python.py | 34 +++++++++++++++++++ .../scripts/startup/bl_operators/console.py | 19 +++++++++++ .../scripts/startup/bl_ui/space_console.py | 1 + .../editors/space_console/space_console.c | 1 + source/blender/makesrna/intern/rna_space.c | 13 +++++++ 5 files changed, 68 insertions(+) diff --git a/release/scripts/modules/console_python.py b/release/scripts/modules/console_python.py index d32606eb0b0..6e8fee07c0f 100644 --- a/release/scripts/modules/console_python.py +++ b/release/scripts/modules/console_python.py @@ -290,6 +290,40 @@ def autocomplete(context): return {'FINISHED'} +def copy_as_script(context): + sc = context.space_data + lines = [ + "import bpy", + "import bpy.context as C", + "import bpy.data as D", + "from mathutils import *", + "from math import *", + "", + ] + + for line in sc.scrollback: + text = line.body + type = line.type + + if type == 'INFO': # ignore autocomp. + continue + if type == 'INPUT': + if text.startswith(PROMPT): + text = text[len(PROMPT):] + elif text.startswith(PROMPT_MULTI): + text = text[len(PROMPT_MULTI):] + elif type == 'OUTPUT': + text = "#~ " + text + elif type == 'ERROR': + text = "#! " + text + + lines.append(text) + + context.window_manager.clipboard = "\n".join(lines) + + return {'FINISHED'} + + def banner(context): sc = context.space_data version_string = sys.version.strip().replace('\n', ' ') diff --git a/release/scripts/startup/bl_operators/console.py b/release/scripts/startup/bl_operators/console.py index 82a54077bdc..fd95da02b28 100644 --- a/release/scripts/startup/bl_operators/console.py +++ b/release/scripts/startup/bl_operators/console.py @@ -67,6 +67,25 @@ class ConsoleAutocomplete(Operator): return {'FINISHED'} +class ConsoleCopyAsScript(Operator): + """Copy the console contents for use in a script""" + bl_idname = "console.copy_as_script" + bl_label = "Copy to Clipboard (as script)" + + def execute(self, context): + sc = context.space_data + + module = _lang_module_get(sc) + copy_as_script = getattr(module, "copy_as_script", None) + + if copy_as_script: + return copy_as_script(context) + else: + print("Error: copy_as_script - not found for %r" % + sc.language) + return {'FINISHED'} + + class ConsoleBanner(Operator): """Print a message when the terminal initializes""" bl_idname = "console.banner" diff --git a/release/scripts/startup/bl_ui/space_console.py b/release/scripts/startup/bl_ui/space_console.py index 7f9699f457b..7ded4954f80 100644 --- a/release/scripts/startup/bl_ui/space_console.py +++ b/release/scripts/startup/bl_ui/space_console.py @@ -51,6 +51,7 @@ class CONSOLE_MT_console(Menu): layout.separator() + layout.operator("console.copy_as_script") layout.operator("console.copy") layout.operator("console.paste") layout.menu("CONSOLE_MT_language") diff --git a/source/blender/editors/space_console/space_console.c b/source/blender/editors/space_console/space_console.c index 460b31d69bd..490a3b45990 100644 --- a/source/blender/editors/space_console/space_console.c +++ b/source/blender/editors/space_console/space_console.c @@ -326,6 +326,7 @@ static void console_keymap(struct wmKeyConfig *keyconf) WM_keymap_add_item(keymap, "CONSOLE_OT_autocomplete", SPACEKEY, KM_PRESS, KM_CTRL, 0); /* python operator - space_text.py */ #endif + WM_keymap_add_item(keymap, "CONSOLE_OT_copy_as_script", CKEY, KM_PRESS, KM_CTRL | KM_SHIFT, 0); WM_keymap_add_item(keymap, "CONSOLE_OT_copy", CKEY, KM_PRESS, KM_CTRL, 0); WM_keymap_add_item(keymap, "CONSOLE_OT_paste", VKEY, KM_PRESS, KM_CTRL, 0); #ifdef __APPLE__ diff --git a/source/blender/makesrna/intern/rna_space.c b/source/blender/makesrna/intern/rna_space.c index 456df187fff..ad14c60e532 100644 --- a/source/blender/makesrna/intern/rna_space.c +++ b/source/blender/makesrna/intern/rna_space.c @@ -2656,6 +2656,14 @@ static void rna_def_space_time(BlenderRNA *brna) static void rna_def_console_line(BlenderRNA *brna) { + static EnumPropertyItem console_line_type_items[] = { + {CONSOLE_LINE_OUTPUT, "OUTPUT", 0, "Output", ""}, + {CONSOLE_LINE_INPUT, "INPUT", 0, "Input", ""}, + {CONSOLE_LINE_INFO, "INFO", 0, "Info", ""}, + {CONSOLE_LINE_ERROR, "ERROR", 0, "Error", ""}, + {0, NULL, 0, NULL, NULL} + }; + StructRNA *srna; PropertyRNA *prop; @@ -2673,6 +2681,11 @@ static void rna_def_console_line(BlenderRNA *brna) RNA_def_property_int_sdna(prop, NULL, "cursor"); RNA_def_property_int_funcs(prop, NULL, NULL, "rna_ConsoleLine_cursor_index_range"); RNA_def_property_update(prop, NC_SPACE | ND_SPACE_CONSOLE, NULL); + + prop = RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_sdna(prop, NULL, "type"); + RNA_def_property_enum_items(prop, console_line_type_items); + RNA_def_property_ui_text(prop, "Type", "Console line type when used in scrollback"); } static void rna_def_space_console(BlenderRNA *brna) From 455c37c16b40746d796598a9d63c19491b7a2698 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 19 Aug 2012 22:19:19 +0000 Subject: [PATCH 021/163] option to build without the legacy compositor --- CMakeLists.txt | 2 ++ source/blender/nodes/CMakeLists.txt | 4 ++++ source/blender/nodes/SConscript | 3 +++ source/blender/nodes/composite/node_composite_tree.c | 12 +++++++++++- .../nodes/composite/nodes/node_composite_alphaOver.c | 6 ++---- .../composite/nodes/node_composite_bilateralblur.c | 3 ++- .../nodes/composite/nodes/node_composite_blur.c | 3 ++- .../composite/nodes/node_composite_brightness.c | 2 ++ .../composite/nodes/node_composite_channelMatte.c | 2 ++ .../composite/nodes/node_composite_chromaMatte.c | 2 ++ .../composite/nodes/node_composite_colorMatte.c | 2 ++ .../composite/nodes/node_composite_colorSpill.c | 2 ++ .../composite/nodes/node_composite_colorbalance.c | 2 ++ .../nodes/composite/nodes/node_composite_composite.c | 2 ++ .../nodes/composite/nodes/node_composite_crop.c | 2 ++ .../nodes/composite/nodes/node_composite_curves.c | 6 ++++++ .../nodes/composite/nodes/node_composite_defocus.c | 2 ++ .../nodes/composite/nodes/node_composite_diffMatte.c | 2 ++ .../nodes/composite/nodes/node_composite_dilate.c | 2 ++ .../composite/nodes/node_composite_directionalblur.c | 2 ++ .../nodes/composite/nodes/node_composite_displace.c | 2 ++ .../composite/nodes/node_composite_distanceMatte.c | 2 ++ .../composite/nodes/node_composite_doubleEdgeMask.c | 2 ++ .../nodes/composite/nodes/node_composite_filter.c | 2 ++ .../nodes/composite/nodes/node_composite_flip.c | 2 ++ .../nodes/composite/nodes/node_composite_gamma.c | 2 ++ .../nodes/composite/nodes/node_composite_glare.c | 2 ++ .../nodes/composite/nodes/node_composite_hueSatVal.c | 2 ++ .../composite/nodes/node_composite_huecorrect.c | 2 ++ .../nodes/composite/nodes/node_composite_idMask.c | 2 ++ .../nodes/composite/nodes/node_composite_image.c | 4 ++++ .../nodes/composite/nodes/node_composite_inpaint.c | 2 ++ .../nodes/composite/nodes/node_composite_invert.c | 2 ++ .../nodes/composite/nodes/node_composite_lensdist.c | 2 ++ .../nodes/composite/nodes/node_composite_levels.c | 2 ++ .../composite/nodes/node_composite_lummaMatte.c | 2 ++ .../nodes/composite/nodes/node_composite_mapUV.c | 2 ++ .../nodes/composite/nodes/node_composite_mapValue.c | 2 ++ .../nodes/composite/nodes/node_composite_math.c | 2 ++ .../nodes/composite/nodes/node_composite_mixrgb.c | 2 ++ .../nodes/composite/nodes/node_composite_movieclip.c | 2 ++ .../nodes/composite/nodes/node_composite_normal.c | 2 ++ .../nodes/composite/nodes/node_composite_normalize.c | 2 ++ .../nodes/composite/nodes/node_composite_premulkey.c | 2 ++ .../nodes/composite/nodes/node_composite_rgb.c | 2 ++ .../nodes/composite/nodes/node_composite_rotate.c | 2 ++ .../nodes/composite/nodes/node_composite_scale.c | 2 ++ .../composite/nodes/node_composite_sepcombHSVA.c | 4 ++++ .../composite/nodes/node_composite_sepcombRGBA.c | 4 ++++ .../composite/nodes/node_composite_sepcombYCCA.c | 4 ++++ .../composite/nodes/node_composite_sepcombYUVA.c | 4 ++++ .../nodes/composite/nodes/node_composite_setalpha.c | 2 ++ .../composite/nodes/node_composite_splitViewer.c | 2 ++ .../composite/nodes/node_composite_stabilize2d.c | 2 ++ .../nodes/composite/nodes/node_composite_texture.c | 2 ++ .../nodes/composite/nodes/node_composite_tonemap.c | 2 ++ .../nodes/composite/nodes/node_composite_trackpos.c | 2 ++ .../nodes/composite/nodes/node_composite_transform.c | 2 ++ .../nodes/composite/nodes/node_composite_translate.c | 2 ++ .../nodes/composite/nodes/node_composite_valToRgb.c | 4 ++++ .../nodes/composite/nodes/node_composite_value.c | 2 ++ .../nodes/composite/nodes/node_composite_vecBlur.c | 2 ++ .../nodes/composite/nodes/node_composite_viewer.c | 2 ++ .../nodes/composite/nodes/node_composite_zcombine.c | 2 ++ 64 files changed, 156 insertions(+), 7 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index fd473889909..338135f4987 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -132,6 +132,7 @@ option(WITH_BULLET "Enable Bullet (Physics Engine)" ON) option(WITH_GAMEENGINE "Enable Game Engine" ON) option(WITH_PLAYER "Build Player" OFF) option(WITH_COMPOSITOR "Enable the tile based nodal compositor" ON) +option(WITH_COMPOSITOR_LEGACY "Enable legacy compositor" ON) # GHOST Windowing Library Options option(WITH_GHOST_DEBUG "Enable debugging output for the GHOST library" OFF) @@ -1796,6 +1797,7 @@ if(FIRST_RUN) info_cfg_option(WITH_GAMEENGINE) info_cfg_option(WITH_PLAYER) info_cfg_option(WITH_BULLET) + info_cfg_option(WITH_IK_SOLVER) info_cfg_option(WITH_IK_ITASC) info_cfg_option(WITH_OPENCOLLADA) info_cfg_option(WITH_FFTW3) diff --git a/source/blender/nodes/CMakeLists.txt b/source/blender/nodes/CMakeLists.txt index d95751af82f..64987a52a21 100644 --- a/source/blender/nodes/CMakeLists.txt +++ b/source/blender/nodes/CMakeLists.txt @@ -251,4 +251,8 @@ if(WITH_COMPOSITOR) add_definitions(-DWITH_COMPOSITOR) endif() +if(WITH_COMPOSITOR_LEGACY) + add_definitions(-DWITH_COMPOSITOR_LEGACY) +endif() + blender_add_lib(bf_nodes "${SRC}" "${INC}" "${INC_SYS}") diff --git a/source/blender/nodes/SConscript b/source/blender/nodes/SConscript index bf70b5a6ed5..f42dfdd2e1e 100644 --- a/source/blender/nodes/SConscript +++ b/source/blender/nodes/SConscript @@ -40,6 +40,9 @@ if env['WITH_BF_COMPOSITOR']: incs += ' ../compositor ' defs.append("WITH_COMPOSITOR") +# TODO, make optional +defs.append("WITH_COMPOSITOR_LEGACY") + env.BlenderLib ( libname = 'bf_nodes', sources = sources, includes = Split(incs), defines = defs, libtype=['core','player'], priority = [190,105] ) env.BlenderLib ( libname = 'bf_cmpnodes', sources = cmpsources, includes = Split(incs), defines = defs, libtype=['core','player'], priority = [175,101] ) env.BlenderLib ( libname = 'bf_shdnodes', sources = shdsources, includes = Split(incs), defines = defs, libtype=['core','player'], priority = [175,101] ) diff --git a/source/blender/nodes/composite/node_composite_tree.c b/source/blender/nodes/composite/node_composite_tree.c index c6ad97c31da..17808179836 100644 --- a/source/blender/nodes/composite/node_composite_tree.c +++ b/source/blender/nodes/composite/node_composite_tree.c @@ -359,6 +359,7 @@ void ntreeCompositEndExecTree(bNodeTreeExec *exec, int use_tree_data) } #ifdef WITH_COMPOSITOR +#ifdef WITH_COMPOSITOR_LEGACY /* ***************************** threaded version for execute composite nodes ************* */ /* these are nodes without input, only giving values */ @@ -685,20 +686,29 @@ static void ntreeCompositExecTreeOld(bNodeTree *ntree, RenderData *rd, int do_pr /* XXX top-level tree uses the ntree->execdata pointer */ ntreeCompositEndExecTree(exec, 1); } -#endif +#endif /* WITH_COMPOSITOR_LEGACY */ +#endif /* WITH_COMPOSITOR */ void *COM_linker_hack = NULL; void ntreeCompositExecTree(bNodeTree *ntree, RenderData *rd, int rendering, int do_preview) { #ifdef WITH_COMPOSITOR +#ifdef WITH_COMPOSITOR_LEGACY if (G.debug_value == 200) + { ntreeCompositExecTreeOld(ntree, rd, do_preview); + } else +#endif + { COM_execute(rd, ntree, rendering); + } #else (void)ntree, (void)rd, (void)rendering, (void)do_preview; #endif + + (void)do_preview; } /* *********************************************** */ diff --git a/source/blender/nodes/composite/nodes/node_composite_alphaOver.c b/source/blender/nodes/composite/nodes/node_composite_alphaOver.c index 588574e324c..7e6def1714a 100644 --- a/source/blender/nodes/composite/nodes/node_composite_alphaOver.c +++ b/source/blender/nodes/composite/nodes/node_composite_alphaOver.c @@ -29,7 +29,6 @@ * \ingroup cmpnodes */ - #include "node_composite_util.h" /* **************** ALPHAOVER ******************** */ @@ -109,8 +108,6 @@ static void do_alphaover_mixed(bNode *node, float *out, float *src, float *over, } - - static void node_composit_exec_alphaover(void *UNUSED(data), bNode *node, bNodeStack **in, bNodeStack **out) { /* stack order in: col col */ @@ -153,7 +150,8 @@ void register_node_type_cmp_alphaover(bNodeTreeType *ttype) node_type_size(&ntype, 80, 40, 120); node_type_init(&ntype, node_alphaover_init); node_type_storage(&ntype, "NodeTwoFloats", node_free_standard_storage, node_copy_standard_storage); +#ifdef WITH_COMPOSITOR_LEGACY node_type_exec(&ntype, node_composit_exec_alphaover); - +#endif nodeRegisterType(ttype, &ntype); } diff --git a/source/blender/nodes/composite/nodes/node_composite_bilateralblur.c b/source/blender/nodes/composite/nodes/node_composite_bilateralblur.c index 0137093658c..cfaf40e2ab0 100644 --- a/source/blender/nodes/composite/nodes/node_composite_bilateralblur.c +++ b/source/blender/nodes/composite/nodes/node_composite_bilateralblur.c @@ -271,7 +271,8 @@ void register_node_type_cmp_bilateralblur(bNodeTreeType *ttype) node_type_size(&ntype, 150, 120, 200); node_type_init(&ntype, node_composit_init_bilateralblur); node_type_storage(&ntype, "NodeBilateralBlurData", node_free_standard_storage, node_copy_standard_storage); +#ifdef WITH_COMPOSITOR_LEGACY node_type_exec(&ntype, node_composit_exec_bilateralblur); - +#endif nodeRegisterType(ttype, &ntype); } diff --git a/source/blender/nodes/composite/nodes/node_composite_blur.c b/source/blender/nodes/composite/nodes/node_composite_blur.c index fb163222781..c95b2d23bda 100644 --- a/source/blender/nodes/composite/nodes/node_composite_blur.c +++ b/source/blender/nodes/composite/nodes/node_composite_blur.c @@ -734,7 +734,8 @@ void register_node_type_cmp_blur(bNodeTreeType *ttype) node_type_size(&ntype, 120, 80, 200); node_type_init(&ntype, node_composit_init_blur); node_type_storage(&ntype, "NodeBlurData", node_free_standard_storage, node_copy_standard_storage); +#ifdef WITH_COMPOSITOR_LEGACY node_type_exec(&ntype, node_composit_exec_blur); - +#endif nodeRegisterType(ttype, &ntype); } diff --git a/source/blender/nodes/composite/nodes/node_composite_brightness.c b/source/blender/nodes/composite/nodes/node_composite_brightness.c index 8761d35f18f..d30a2ba5e03 100644 --- a/source/blender/nodes/composite/nodes/node_composite_brightness.c +++ b/source/blender/nodes/composite/nodes/node_composite_brightness.c @@ -99,7 +99,9 @@ void register_node_type_cmp_brightcontrast(bNodeTreeType *ttype) node_type_base(ttype, &ntype, CMP_NODE_BRIGHTCONTRAST, "Bright/Contrast", NODE_CLASS_OP_COLOR, NODE_OPTIONS); node_type_socket_templates(&ntype, cmp_node_brightcontrast_in, cmp_node_brightcontrast_out); node_type_size(&ntype, 140, 100, 320); +#ifdef WITH_COMPOSITOR_LEGACY node_type_exec(&ntype, node_composit_exec_brightcontrast); +#endif nodeRegisterType(ttype, &ntype); } diff --git a/source/blender/nodes/composite/nodes/node_composite_channelMatte.c b/source/blender/nodes/composite/nodes/node_composite_channelMatte.c index 6163d8f01b1..12af1a7aa20 100644 --- a/source/blender/nodes/composite/nodes/node_composite_channelMatte.c +++ b/source/blender/nodes/composite/nodes/node_composite_channelMatte.c @@ -209,7 +209,9 @@ void register_node_type_cmp_channel_matte(bNodeTreeType *ttype) node_type_size(&ntype, 200, 80, 250); node_type_init(&ntype, node_composit_init_channel_matte); node_type_storage(&ntype, "NodeChroma", node_free_standard_storage, node_copy_standard_storage); +#ifdef WITH_COMPOSITOR_LEGACY node_type_exec(&ntype, node_composit_exec_channel_matte); +#endif nodeRegisterType(ttype, &ntype); } diff --git a/source/blender/nodes/composite/nodes/node_composite_chromaMatte.c b/source/blender/nodes/composite/nodes/node_composite_chromaMatte.c index 0c6ce79c51f..1204b05e415 100644 --- a/source/blender/nodes/composite/nodes/node_composite_chromaMatte.c +++ b/source/blender/nodes/composite/nodes/node_composite_chromaMatte.c @@ -192,7 +192,9 @@ void register_node_type_cmp_chroma_matte(bNodeTreeType *ttype) node_type_size(&ntype, 200, 80, 300); node_type_init(&ntype, node_composit_init_chroma_matte); node_type_storage(&ntype, "NodeChroma", node_free_standard_storage, node_copy_standard_storage); +#ifdef WITH_COMPOSITOR_LEGACY node_type_exec(&ntype, node_composit_exec_chroma_matte); +#endif nodeRegisterType(ttype, &ntype); } diff --git a/source/blender/nodes/composite/nodes/node_composite_colorMatte.c b/source/blender/nodes/composite/nodes/node_composite_colorMatte.c index 8aad5bdf179..d921c1efa51 100644 --- a/source/blender/nodes/composite/nodes/node_composite_colorMatte.c +++ b/source/blender/nodes/composite/nodes/node_composite_colorMatte.c @@ -132,7 +132,9 @@ void register_node_type_cmp_color_matte(bNodeTreeType *ttype) node_type_size(&ntype, 200, 80, 300); node_type_init(&ntype, node_composit_init_color_matte); node_type_storage(&ntype, "NodeChroma", node_free_standard_storage, node_copy_standard_storage); +#ifdef WITH_COMPOSITOR_LEGACY node_type_exec(&ntype, node_composit_exec_color_matte); +#endif nodeRegisterType(ttype, &ntype); } diff --git a/source/blender/nodes/composite/nodes/node_composite_colorSpill.c b/source/blender/nodes/composite/nodes/node_composite_colorSpill.c index 678091790ea..bfa8aac0183 100644 --- a/source/blender/nodes/composite/nodes/node_composite_colorSpill.c +++ b/source/blender/nodes/composite/nodes/node_composite_colorSpill.c @@ -335,7 +335,9 @@ void register_node_type_cmp_color_spill(bNodeTreeType *ttype) node_type_size(&ntype, 140, 80, 200); node_type_init(&ntype, node_composit_init_color_spill); node_type_storage(&ntype, "NodeColorspill", node_free_standard_storage, node_copy_standard_storage); +#ifdef WITH_COMPOSITOR_LEGACY node_type_exec(&ntype, node_composit_exec_color_spill); +#endif nodeRegisterType(ttype, &ntype); } diff --git a/source/blender/nodes/composite/nodes/node_composite_colorbalance.c b/source/blender/nodes/composite/nodes/node_composite_colorbalance.c index fa32db9b31d..ae5d8a24847 100644 --- a/source/blender/nodes/composite/nodes/node_composite_colorbalance.c +++ b/source/blender/nodes/composite/nodes/node_composite_colorbalance.c @@ -192,7 +192,9 @@ void register_node_type_cmp_colorbalance(bNodeTreeType *ttype) node_type_size(&ntype, 400, 200, 400); node_type_init(&ntype, node_composit_init_colorbalance); node_type_storage(&ntype, "NodeColorBalance", node_free_standard_storage, node_copy_standard_storage); +#ifdef WITH_COMPOSITOR_LEGACY node_type_exec(&ntype, node_composit_exec_colorbalance); +#endif nodeRegisterType(ttype, &ntype); } diff --git a/source/blender/nodes/composite/nodes/node_composite_composite.c b/source/blender/nodes/composite/nodes/node_composite_composite.c index 7b189ef40e5..71b392f14db 100644 --- a/source/blender/nodes/composite/nodes/node_composite_composite.c +++ b/source/blender/nodes/composite/nodes/node_composite_composite.c @@ -104,7 +104,9 @@ void register_node_type_cmp_composite(bNodeTreeType *ttype) node_type_base(ttype, &ntype, CMP_NODE_COMPOSITE, "Composite", NODE_CLASS_OUTPUT, NODE_PREVIEW); node_type_socket_templates(&ntype, cmp_node_composite_in, NULL); node_type_size(&ntype, 80, 60, 200); +#ifdef WITH_COMPOSITOR_LEGACY node_type_exec(&ntype, node_composit_exec_composite); +#endif /* Do not allow muting for this node. */ node_type_internal_connect(&ntype, NULL); diff --git a/source/blender/nodes/composite/nodes/node_composite_crop.c b/source/blender/nodes/composite/nodes/node_composite_crop.c index 8d676fd6d9f..f439b7ebc00 100644 --- a/source/blender/nodes/composite/nodes/node_composite_crop.c +++ b/source/blender/nodes/composite/nodes/node_composite_crop.c @@ -120,7 +120,9 @@ void register_node_type_cmp_crop(bNodeTreeType *ttype) node_type_size(&ntype, 140, 100, 320); node_type_init(&ntype, node_composit_init_crop); node_type_storage(&ntype, "NodeTwoXYs", node_free_standard_storage, node_copy_standard_storage); +#ifdef WITH_COMPOSITOR_LEGACY node_type_exec(&ntype, node_composit_exec_crop); +#endif nodeRegisterType(ttype, &ntype); } diff --git a/source/blender/nodes/composite/nodes/node_composite_curves.c b/source/blender/nodes/composite/nodes/node_composite_curves.c index b5a78015d76..cc9d7d1d1a4 100644 --- a/source/blender/nodes/composite/nodes/node_composite_curves.c +++ b/source/blender/nodes/composite/nodes/node_composite_curves.c @@ -71,7 +71,9 @@ void register_node_type_cmp_curve_time(bNodeTreeType *ttype) node_type_size(&ntype, 140, 100, 320); node_type_init(&ntype, node_composit_init_curves_time); node_type_storage(&ntype, "CurveMapping", node_free_curves, node_copy_curves); +#ifdef WITH_COMPOSITOR_LEGACY node_type_exec(&ntype, node_composit_exec_curves_time); +#endif nodeRegisterType(ttype, &ntype); } @@ -111,7 +113,9 @@ void register_node_type_cmp_curve_vec(bNodeTreeType *ttype) node_type_size(&ntype, 200, 140, 320); node_type_init(&ntype, node_composit_init_curve_vec); node_type_storage(&ntype, "CurveMapping", node_free_curves, node_copy_curves); +#ifdef WITH_COMPOSITOR_LEGACY node_type_exec(&ntype, node_composit_exec_curve_vec); +#endif nodeRegisterType(ttype, &ntype); } @@ -198,7 +202,9 @@ void register_node_type_cmp_curve_rgb(bNodeTreeType *ttype) node_type_size(&ntype, 200, 140, 320); node_type_init(&ntype, node_composit_init_curve_rgb); node_type_storage(&ntype, "CurveMapping", node_free_curves, node_copy_curves); +#ifdef WITH_COMPOSITOR_LEGACY node_type_exec(&ntype, node_composit_exec_curve_rgb); +#endif nodeRegisterType(ttype, &ntype); } diff --git a/source/blender/nodes/composite/nodes/node_composite_defocus.c b/source/blender/nodes/composite/nodes/node_composite_defocus.c index 280ff56be12..f23702a0606 100644 --- a/source/blender/nodes/composite/nodes/node_composite_defocus.c +++ b/source/blender/nodes/composite/nodes/node_composite_defocus.c @@ -891,7 +891,9 @@ void register_node_type_cmp_defocus(bNodeTreeType *ttype) node_type_size(&ntype, 150, 120, 200); node_type_init(&ntype, node_composit_init_defocus); node_type_storage(&ntype, "NodeDefocus", node_free_standard_storage, node_copy_standard_storage); +#ifdef WITH_COMPOSITOR_LEGACY node_type_exec(&ntype, node_composit_exec_defocus); +#endif nodeRegisterType(ttype, &ntype); } diff --git a/source/blender/nodes/composite/nodes/node_composite_diffMatte.c b/source/blender/nodes/composite/nodes/node_composite_diffMatte.c index 53061366b8b..b79911f27dc 100644 --- a/source/blender/nodes/composite/nodes/node_composite_diffMatte.c +++ b/source/blender/nodes/composite/nodes/node_composite_diffMatte.c @@ -143,7 +143,9 @@ void register_node_type_cmp_diff_matte(bNodeTreeType *ttype) node_type_size(&ntype, 200, 80, 250); node_type_init(&ntype, node_composit_init_diff_matte); node_type_storage(&ntype, "NodeChroma", node_free_standard_storage, node_copy_standard_storage); +#ifdef WITH_COMPOSITOR_LEGACY node_type_exec(&ntype, node_composit_exec_diff_matte); +#endif nodeRegisterType(ttype, &ntype); } diff --git a/source/blender/nodes/composite/nodes/node_composite_dilate.c b/source/blender/nodes/composite/nodes/node_composite_dilate.c index 5977d291388..6425606f9c4 100644 --- a/source/blender/nodes/composite/nodes/node_composite_dilate.c +++ b/source/blender/nodes/composite/nodes/node_composite_dilate.c @@ -161,7 +161,9 @@ void register_node_type_cmp_dilateerode(bNodeTreeType *ttype) node_type_socket_templates(&ntype, cmp_node_dilateerode_in, cmp_node_dilateerode_out); node_type_size(&ntype, 130, 100, 320); node_type_init(&ntype, node_composit_init_dilateerode); +#ifdef WITH_COMPOSITOR_LEGACY node_type_exec(&ntype, node_composit_exec_dilateerode); +#endif node_type_storage(&ntype, "NodeDilateErode", node_free_standard_storage, node_copy_standard_storage); diff --git a/source/blender/nodes/composite/nodes/node_composite_directionalblur.c b/source/blender/nodes/composite/nodes/node_composite_directionalblur.c index 73e28658309..3011e5772c5 100644 --- a/source/blender/nodes/composite/nodes/node_composite_directionalblur.c +++ b/source/blender/nodes/composite/nodes/node_composite_directionalblur.c @@ -139,7 +139,9 @@ void register_node_type_cmp_dblur(bNodeTreeType *ttype) node_type_size(&ntype, 150, 120, 200); node_type_init(&ntype, node_composit_init_dblur); node_type_storage(&ntype, "NodeDBlurData", node_free_standard_storage, node_copy_standard_storage); +#ifdef WITH_COMPOSITOR_LEGACY node_type_exec(&ntype, node_composit_exec_dblur); +#endif nodeRegisterType(ttype, &ntype); } diff --git a/source/blender/nodes/composite/nodes/node_composite_displace.c b/source/blender/nodes/composite/nodes/node_composite_displace.c index 49cba801d5a..abf440273a1 100644 --- a/source/blender/nodes/composite/nodes/node_composite_displace.c +++ b/source/blender/nodes/composite/nodes/node_composite_displace.c @@ -189,7 +189,9 @@ void register_node_type_cmp_displace(bNodeTreeType *ttype) node_type_base(ttype, &ntype, CMP_NODE_DISPLACE, "Displace", NODE_CLASS_DISTORT, NODE_OPTIONS); node_type_socket_templates(&ntype, cmp_node_displace_in, cmp_node_displace_out); node_type_size(&ntype, 140, 100, 320); +#ifdef WITH_COMPOSITOR_LEGACY node_type_exec(&ntype, node_composit_exec_displace); +#endif nodeRegisterType(ttype, &ntype); } diff --git a/source/blender/nodes/composite/nodes/node_composite_distanceMatte.c b/source/blender/nodes/composite/nodes/node_composite_distanceMatte.c index 86634487776..83b16a808a3 100644 --- a/source/blender/nodes/composite/nodes/node_composite_distanceMatte.c +++ b/source/blender/nodes/composite/nodes/node_composite_distanceMatte.c @@ -200,7 +200,9 @@ void register_node_type_cmp_distance_matte(bNodeTreeType *ttype) node_type_size(&ntype, 200, 80, 250); node_type_init(&ntype, node_composit_init_distance_matte); node_type_storage(&ntype, "NodeChroma", node_free_standard_storage, node_copy_standard_storage); +#ifdef WITH_COMPOSITOR_LEGACY node_type_exec(&ntype, node_composit_exec_distance_matte); +#endif nodeRegisterType(ttype, &ntype); } diff --git a/source/blender/nodes/composite/nodes/node_composite_doubleEdgeMask.c b/source/blender/nodes/composite/nodes/node_composite_doubleEdgeMask.c index c206b9a1a5d..0d9f946d4f7 100644 --- a/source/blender/nodes/composite/nodes/node_composite_doubleEdgeMask.c +++ b/source/blender/nodes/composite/nodes/node_composite_doubleEdgeMask.c @@ -1278,7 +1278,9 @@ void register_node_type_cmp_doubleedgemask(bNodeTreeType *ttype) node_type_base(ttype, &ntype, CMP_NODE_DOUBLEEDGEMASK, "Double Edge Mask", NODE_CLASS_MATTE, NODE_OPTIONS); node_type_socket_templates(&ntype, cmp_node_doubleedgemask_in, cmp_node_doubleedgemask_out); node_type_size(&ntype, 210, 210, 210); +#ifdef WITH_COMPOSITOR_LEGACY node_type_exec(&ntype, node_composit_exec_doubleedgemask); +#endif nodeRegisterType(ttype, &ntype); } diff --git a/source/blender/nodes/composite/nodes/node_composite_filter.c b/source/blender/nodes/composite/nodes/node_composite_filter.c index be5aab74e02..01fb4ee648c 100644 --- a/source/blender/nodes/composite/nodes/node_composite_filter.c +++ b/source/blender/nodes/composite/nodes/node_composite_filter.c @@ -228,7 +228,9 @@ void register_node_type_cmp_filter(bNodeTreeType *ttype) node_type_socket_templates(&ntype, cmp_node_filter_in, cmp_node_filter_out); node_type_size(&ntype, 80, 40, 120); node_type_label(&ntype, node_filter_label); +#ifdef WITH_COMPOSITOR_LEGACY node_type_exec(&ntype, node_composit_exec_filter); +#endif nodeRegisterType(ttype, &ntype); } diff --git a/source/blender/nodes/composite/nodes/node_composite_flip.c b/source/blender/nodes/composite/nodes/node_composite_flip.c index 44e93c08509..742e1f7852e 100644 --- a/source/blender/nodes/composite/nodes/node_composite_flip.c +++ b/source/blender/nodes/composite/nodes/node_composite_flip.c @@ -95,7 +95,9 @@ void register_node_type_cmp_flip(bNodeTreeType *ttype) node_type_base(ttype, &ntype, CMP_NODE_FLIP, "Flip", NODE_CLASS_DISTORT, NODE_OPTIONS); node_type_socket_templates(&ntype, cmp_node_flip_in, cmp_node_flip_out); node_type_size(&ntype, 140, 100, 320); +#ifdef WITH_COMPOSITOR_LEGACY node_type_exec(&ntype, node_composit_exec_flip); +#endif nodeRegisterType(ttype, &ntype); } diff --git a/source/blender/nodes/composite/nodes/node_composite_gamma.c b/source/blender/nodes/composite/nodes/node_composite_gamma.c index f681eb4f630..432001909f0 100644 --- a/source/blender/nodes/composite/nodes/node_composite_gamma.c +++ b/source/blender/nodes/composite/nodes/node_composite_gamma.c @@ -82,7 +82,9 @@ void register_node_type_cmp_gamma(bNodeTreeType *ttype) node_type_base(ttype, &ntype, CMP_NODE_GAMMA, "Gamma", NODE_CLASS_OP_COLOR, NODE_OPTIONS); node_type_socket_templates(&ntype, cmp_node_gamma_in, cmp_node_gamma_out); node_type_size(&ntype, 140, 100, 320); +#ifdef WITH_COMPOSITOR_LEGACY node_type_exec(&ntype, node_composit_exec_gamma); +#endif nodeRegisterType(ttype, &ntype); } diff --git a/source/blender/nodes/composite/nodes/node_composite_glare.c b/source/blender/nodes/composite/nodes/node_composite_glare.c index 17a23d4295e..9f266633923 100644 --- a/source/blender/nodes/composite/nodes/node_composite_glare.c +++ b/source/blender/nodes/composite/nodes/node_composite_glare.c @@ -499,7 +499,9 @@ void register_node_type_cmp_glare(bNodeTreeType *ttype) node_type_size(&ntype, 150, 120, 200); node_type_init(&ntype, node_composit_init_glare); node_type_storage(&ntype, "NodeGlare", node_free_standard_storage, node_copy_standard_storage); +#ifdef WITH_COMPOSITOR_LEGACY node_type_exec(&ntype, node_composit_exec_glare); +#endif nodeRegisterType(ttype, &ntype); } diff --git a/source/blender/nodes/composite/nodes/node_composite_hueSatVal.c b/source/blender/nodes/composite/nodes/node_composite_hueSatVal.c index 32bfc048cc7..91614340c75 100644 --- a/source/blender/nodes/composite/nodes/node_composite_hueSatVal.c +++ b/source/blender/nodes/composite/nodes/node_composite_hueSatVal.c @@ -111,7 +111,9 @@ void register_node_type_cmp_hue_sat(bNodeTreeType *ttype) node_type_size(&ntype, 150, 80, 250); node_type_init(&ntype, node_composit_init_hue_sat); node_type_storage(&ntype, "NodeHueSat", node_free_standard_storage, node_copy_standard_storage); +#ifdef WITH_COMPOSITOR_LEGACY node_type_exec(&ntype, node_composit_exec_hue_sat); +#endif nodeRegisterType(ttype, &ntype); } diff --git a/source/blender/nodes/composite/nodes/node_composite_huecorrect.c b/source/blender/nodes/composite/nodes/node_composite_huecorrect.c index d40abbe5f4d..e4c7567d102 100644 --- a/source/blender/nodes/composite/nodes/node_composite_huecorrect.c +++ b/source/blender/nodes/composite/nodes/node_composite_huecorrect.c @@ -160,7 +160,9 @@ void register_node_type_cmp_huecorrect(bNodeTreeType *ttype) node_type_size(&ntype, 320, 140, 400); node_type_init(&ntype, node_composit_init_huecorrect); node_type_storage(&ntype, "CurveMapping", node_free_curves, node_copy_curves); +#ifdef WITH_COMPOSITOR_LEGACY node_type_exec(&ntype, node_composit_exec_huecorrect); +#endif nodeRegisterType(ttype, &ntype); } diff --git a/source/blender/nodes/composite/nodes/node_composite_idMask.c b/source/blender/nodes/composite/nodes/node_composite_idMask.c index 09be1c54503..fdf5209a8e4 100644 --- a/source/blender/nodes/composite/nodes/node_composite_idMask.c +++ b/source/blender/nodes/composite/nodes/node_composite_idMask.c @@ -114,7 +114,9 @@ void register_node_type_cmp_idmask(bNodeTreeType *ttype) node_type_base(ttype, &ntype, CMP_NODE_ID_MASK, "ID Mask", NODE_CLASS_CONVERTOR, NODE_OPTIONS); node_type_socket_templates(&ntype, cmp_node_idmask_in, cmp_node_idmask_out); node_type_size(&ntype, 140, 100, 320); +#ifdef WITH_COMPOSITOR_LEGACY node_type_exec(&ntype, node_composit_exec_idmask); +#endif nodeRegisterType(ttype, &ntype); } diff --git a/source/blender/nodes/composite/nodes/node_composite_image.c b/source/blender/nodes/composite/nodes/node_composite_image.c index 3060496bb9e..824fb7bd64f 100644 --- a/source/blender/nodes/composite/nodes/node_composite_image.c +++ b/source/blender/nodes/composite/nodes/node_composite_image.c @@ -563,7 +563,9 @@ void register_node_type_cmp_image(bNodeTreeType *ttype) node_type_init(&ntype, node_composit_init_image); node_type_storage(&ntype, "ImageUser", node_composit_free_image, node_composit_copy_image); node_type_update(&ntype, cmp_node_image_update, NULL); +#ifdef WITH_COMPOSITOR_LEGACY node_type_exec(&ntype, node_composit_exec_image); +#endif nodeRegisterType(ttype, &ntype); } @@ -711,7 +713,9 @@ void register_node_type_cmp_rlayers(bNodeTreeType *ttype) node_type_base(ttype, &ntype, CMP_NODE_R_LAYERS, "Render Layers", NODE_CLASS_INPUT, NODE_PREVIEW|NODE_OPTIONS); node_type_socket_templates(&ntype, NULL, cmp_node_rlayers_out); node_type_size(&ntype, 150, 100, 300); +#ifdef WITH_COMPOSITOR_LEGACY node_type_exec(&ntype, node_composit_exec_rlayers); +#endif nodeRegisterType(ttype, &ntype); } diff --git a/source/blender/nodes/composite/nodes/node_composite_inpaint.c b/source/blender/nodes/composite/nodes/node_composite_inpaint.c index dc4177bd2a4..e99b500c56a 100644 --- a/source/blender/nodes/composite/nodes/node_composite_inpaint.c +++ b/source/blender/nodes/composite/nodes/node_composite_inpaint.c @@ -55,7 +55,9 @@ void register_node_type_cmp_inpaint(bNodeTreeType *ttype) node_type_base(ttype, &ntype, CMP_NODE_INPAINT, "Inpaint", NODE_CLASS_OP_FILTER, NODE_OPTIONS); node_type_socket_templates(&ntype, cmp_node_inpaint_in, cmp_node_inpaint_out); node_type_size(&ntype, 130, 100, 320); +#ifdef WITH_COMPOSITOR_LEGACY node_type_exec(&ntype, node_composit_exec_inpaint); +#endif nodeRegisterType(ttype, &ntype); } diff --git a/source/blender/nodes/composite/nodes/node_composite_invert.c b/source/blender/nodes/composite/nodes/node_composite_invert.c index 2a91647d6f5..5bd5c73b573 100644 --- a/source/blender/nodes/composite/nodes/node_composite_invert.c +++ b/source/blender/nodes/composite/nodes/node_composite_invert.c @@ -129,7 +129,9 @@ void register_node_type_cmp_invert(bNodeTreeType *ttype) node_type_socket_templates(&ntype, cmp_node_invert_in, cmp_node_invert_out); node_type_size(&ntype, 120, 120, 140); node_type_init(&ntype, node_composit_init_invert); +#ifdef WITH_COMPOSITOR_LEGACY node_type_exec(&ntype, node_composit_exec_invert); +#endif nodeRegisterType(ttype, &ntype); } diff --git a/source/blender/nodes/composite/nodes/node_composite_lensdist.c b/source/blender/nodes/composite/nodes/node_composite_lensdist.c index 7635a391441..3ca803ebbd7 100644 --- a/source/blender/nodes/composite/nodes/node_composite_lensdist.c +++ b/source/blender/nodes/composite/nodes/node_composite_lensdist.c @@ -200,7 +200,9 @@ void register_node_type_cmp_lensdist(bNodeTreeType *ttype) node_type_size(&ntype, 150, 120, 200); node_type_init(&ntype, node_composit_init_lensdist); node_type_storage(&ntype, "NodeLensDist", node_free_standard_storage, node_copy_standard_storage); +#ifdef WITH_COMPOSITOR_LEGACY node_type_exec(&ntype, node_composit_exec_lensdist); +#endif nodeRegisterType(ttype, &ntype); } diff --git a/source/blender/nodes/composite/nodes/node_composite_levels.c b/source/blender/nodes/composite/nodes/node_composite_levels.c index 1952756d397..43ad5aff497 100644 --- a/source/blender/nodes/composite/nodes/node_composite_levels.c +++ b/source/blender/nodes/composite/nodes/node_composite_levels.c @@ -323,7 +323,9 @@ void register_node_type_cmp_view_levels(bNodeTreeType *ttype) node_type_size(&ntype, 140, 100, 320); node_type_init(&ntype, node_composit_init_view_levels); node_type_storage(&ntype, "ImageUser", NULL, NULL); +#ifdef WITH_COMPOSITOR_LEGACY node_type_exec(&ntype, node_composit_exec_view_levels); +#endif nodeRegisterType(ttype, &ntype); } diff --git a/source/blender/nodes/composite/nodes/node_composite_lummaMatte.c b/source/blender/nodes/composite/nodes/node_composite_lummaMatte.c index 955d94942a4..e6e5131c687 100644 --- a/source/blender/nodes/composite/nodes/node_composite_lummaMatte.c +++ b/source/blender/nodes/composite/nodes/node_composite_lummaMatte.c @@ -113,7 +113,9 @@ void register_node_type_cmp_luma_matte(bNodeTreeType *ttype) node_type_size(&ntype, 200, 80, 250); node_type_init(&ntype, node_composit_init_luma_matte); node_type_storage(&ntype, "NodeChroma", node_free_standard_storage, node_copy_standard_storage); +#ifdef WITH_COMPOSITOR_LEGACY node_type_exec(&ntype, node_composit_exec_luma_matte); +#endif nodeRegisterType(ttype, &ntype); } diff --git a/source/blender/nodes/composite/nodes/node_composite_mapUV.c b/source/blender/nodes/composite/nodes/node_composite_mapUV.c index a41d010ee95..46c8c109bb7 100644 --- a/source/blender/nodes/composite/nodes/node_composite_mapUV.c +++ b/source/blender/nodes/composite/nodes/node_composite_mapUV.c @@ -169,7 +169,9 @@ void register_node_type_cmp_mapuv(bNodeTreeType *ttype) node_type_base(ttype, &ntype, CMP_NODE_MAP_UV, "Map UV", NODE_CLASS_DISTORT, NODE_OPTIONS); node_type_socket_templates(&ntype, cmp_node_mapuv_in, cmp_node_mapuv_out); node_type_size(&ntype, 140, 100, 320); +#ifdef WITH_COMPOSITOR_LEGACY node_type_exec(&ntype, node_composit_exec_mapuv); +#endif nodeRegisterType(ttype, &ntype); } diff --git a/source/blender/nodes/composite/nodes/node_composite_mapValue.c b/source/blender/nodes/composite/nodes/node_composite_mapValue.c index 1d296d540f9..da6c7f07f1a 100644 --- a/source/blender/nodes/composite/nodes/node_composite_mapValue.c +++ b/source/blender/nodes/composite/nodes/node_composite_mapValue.c @@ -91,7 +91,9 @@ void register_node_type_cmp_map_value(bNodeTreeType *ttype) node_type_size(&ntype, 100, 60, 150); node_type_init(&ntype, node_composit_init_map_value); node_type_storage(&ntype, "TexMapping", node_free_standard_storage, node_copy_standard_storage); +#ifdef WITH_COMPOSITOR_LEGACY node_type_exec(&ntype, node_composit_exec_map_value); +#endif nodeRegisterType(ttype, &ntype); } diff --git a/source/blender/nodes/composite/nodes/node_composite_math.c b/source/blender/nodes/composite/nodes/node_composite_math.c index 7cf337f2f88..d5d7982e674 100644 --- a/source/blender/nodes/composite/nodes/node_composite_math.c +++ b/source/blender/nodes/composite/nodes/node_composite_math.c @@ -203,7 +203,9 @@ void register_node_type_cmp_math(bNodeTreeType *ttype) node_type_socket_templates(&ntype, cmp_node_math_in, cmp_node_math_out); node_type_size(&ntype, 120, 110, 160); node_type_label(&ntype, node_math_label); +#ifdef WITH_COMPOSITOR_LEGACY node_type_exec(&ntype, node_composit_exec_math); +#endif nodeRegisterType(ttype, &ntype); } diff --git a/source/blender/nodes/composite/nodes/node_composite_mixrgb.c b/source/blender/nodes/composite/nodes/node_composite_mixrgb.c index 6f8891f2b81..e10ea9c48b5 100644 --- a/source/blender/nodes/composite/nodes/node_composite_mixrgb.c +++ b/source/blender/nodes/composite/nodes/node_composite_mixrgb.c @@ -90,7 +90,9 @@ void register_node_type_cmp_mix_rgb(bNodeTreeType *ttype) node_type_socket_templates(&ntype, cmp_node_mix_rgb_in, cmp_node_mix_rgb_out); node_type_size(&ntype, 110, 60, 120); node_type_label(&ntype, node_blend_label); +#ifdef WITH_COMPOSITOR_LEGACY node_type_exec(&ntype, node_composit_exec_mix_rgb); +#endif nodeRegisterType(ttype, &ntype); } diff --git a/source/blender/nodes/composite/nodes/node_composite_movieclip.c b/source/blender/nodes/composite/nodes/node_composite_movieclip.c index e8f09ae08d7..99b5b9f1972 100644 --- a/source/blender/nodes/composite/nodes/node_composite_movieclip.c +++ b/source/blender/nodes/composite/nodes/node_composite_movieclip.c @@ -155,7 +155,9 @@ void register_node_type_cmp_movieclip(bNodeTreeType *ttype) node_type_size(&ntype, 120, 80, 300); node_type_init(&ntype, init); node_type_storage(&ntype, "MovieClipUser", node_free_standard_storage, node_copy_standard_storage); +#ifdef WITH_COMPOSITOR_LEGACY node_type_exec(&ntype, node_composit_exec_movieclip); +#endif nodeRegisterType(ttype, &ntype); } diff --git a/source/blender/nodes/composite/nodes/node_composite_normal.c b/source/blender/nodes/composite/nodes/node_composite_normal.c index 99a1f9ea520..b27f197e9e7 100644 --- a/source/blender/nodes/composite/nodes/node_composite_normal.c +++ b/source/blender/nodes/composite/nodes/node_composite_normal.c @@ -99,7 +99,9 @@ void register_node_type_cmp_normal(bNodeTreeType *ttype) node_type_socket_templates(&ntype, cmp_node_normal_in, cmp_node_normal_out); node_type_init(&ntype, init); node_type_size(&ntype, 100, 60, 200); +#ifdef WITH_COMPOSITOR_LEGACY node_type_exec(&ntype, node_composit_exec_normal); +#endif nodeRegisterType(ttype, &ntype); } diff --git a/source/blender/nodes/composite/nodes/node_composite_normalize.c b/source/blender/nodes/composite/nodes/node_composite_normalize.c index 4697ab74a95..7a5b1b0e655 100644 --- a/source/blender/nodes/composite/nodes/node_composite_normalize.c +++ b/source/blender/nodes/composite/nodes/node_composite_normalize.c @@ -109,7 +109,9 @@ void register_node_type_cmp_normalize(bNodeTreeType *ttype) node_type_base(ttype, &ntype, CMP_NODE_NORMALIZE, "Normalize", NODE_CLASS_OP_VECTOR, NODE_OPTIONS); node_type_socket_templates(&ntype, cmp_node_normalize_in, cmp_node_normalize_out); node_type_size(&ntype, 100, 60, 150); +#ifdef WITH_COMPOSITOR_LEGACY node_type_exec(&ntype, node_composit_exec_normalize); +#endif nodeRegisterType(ttype, &ntype); } diff --git a/source/blender/nodes/composite/nodes/node_composite_premulkey.c b/source/blender/nodes/composite/nodes/node_composite_premulkey.c index 63b10b80462..75626ca25af 100644 --- a/source/blender/nodes/composite/nodes/node_composite_premulkey.c +++ b/source/blender/nodes/composite/nodes/node_composite_premulkey.c @@ -68,7 +68,9 @@ void register_node_type_cmp_premulkey(bNodeTreeType *ttype) node_type_base(ttype, &ntype, CMP_NODE_PREMULKEY, "Alpha Convert", NODE_CLASS_CONVERTOR, NODE_OPTIONS); node_type_socket_templates(&ntype, cmp_node_premulkey_in, cmp_node_premulkey_out); node_type_size(&ntype, 140, 100, 320); +#ifdef WITH_COMPOSITOR_LEGACY node_type_exec(&ntype, node_composit_exec_premulkey); +#endif nodeRegisterType(ttype, &ntype); } diff --git a/source/blender/nodes/composite/nodes/node_composite_rgb.c b/source/blender/nodes/composite/nodes/node_composite_rgb.c index beab47442d5..5f323f4ef2c 100644 --- a/source/blender/nodes/composite/nodes/node_composite_rgb.c +++ b/source/blender/nodes/composite/nodes/node_composite_rgb.c @@ -66,7 +66,9 @@ void register_node_type_cmp_rgb(bNodeTreeType *ttype) node_type_socket_templates(&ntype, NULL, cmp_node_rgb_out); node_type_init(&ntype, node_composit_init_rgb); node_type_size(&ntype, 140, 80, 140); +#ifdef WITH_COMPOSITOR_LEGACY node_type_exec(&ntype, node_composit_exec_rgb); +#endif nodeRegisterType(ttype, &ntype); } diff --git a/source/blender/nodes/composite/nodes/node_composite_rotate.c b/source/blender/nodes/composite/nodes/node_composite_rotate.c index 773be2fb41e..38b6e44f44e 100644 --- a/source/blender/nodes/composite/nodes/node_composite_rotate.c +++ b/source/blender/nodes/composite/nodes/node_composite_rotate.c @@ -134,7 +134,9 @@ void register_node_type_cmp_rotate(bNodeTreeType *ttype) node_type_socket_templates(&ntype, cmp_node_rotate_in, cmp_node_rotate_out); node_type_size(&ntype, 140, 100, 320); node_type_init(&ntype, node_composit_init_rotate); +#ifdef WITH_COMPOSITOR_LEGACY node_type_exec(&ntype, node_composit_exec_rotate); +#endif nodeRegisterType(ttype, &ntype); } diff --git a/source/blender/nodes/composite/nodes/node_composite_scale.c b/source/blender/nodes/composite/nodes/node_composite_scale.c index 1df67724762..75a4053d4ea 100644 --- a/source/blender/nodes/composite/nodes/node_composite_scale.c +++ b/source/blender/nodes/composite/nodes/node_composite_scale.c @@ -189,7 +189,9 @@ void register_node_type_cmp_scale(bNodeTreeType *ttype) node_type_base(ttype, &ntype, CMP_NODE_SCALE, "Scale", NODE_CLASS_DISTORT, NODE_OPTIONS); node_type_socket_templates(&ntype, cmp_node_scale_in, cmp_node_scale_out); node_type_size(&ntype, 140, 100, 320); +#ifdef WITH_COMPOSITOR_LEGACY node_type_exec(&ntype, node_composit_exec_scale); +#endif nodeRegisterType(ttype, &ntype); } diff --git a/source/blender/nodes/composite/nodes/node_composite_sepcombHSVA.c b/source/blender/nodes/composite/nodes/node_composite_sepcombHSVA.c index 2433cb37763..e19984b3358 100644 --- a/source/blender/nodes/composite/nodes/node_composite_sepcombHSVA.c +++ b/source/blender/nodes/composite/nodes/node_composite_sepcombHSVA.c @@ -106,7 +106,9 @@ void register_node_type_cmp_sephsva(bNodeTreeType *ttype) node_type_base(ttype, &ntype, CMP_NODE_SEPHSVA, "Separate HSVA", NODE_CLASS_CONVERTOR, 0); node_type_socket_templates(&ntype, cmp_node_sephsva_in, cmp_node_sephsva_out); node_type_size(&ntype, 80, 40, 140); +#ifdef WITH_COMPOSITOR_LEGACY node_type_exec(&ntype, node_composit_exec_sephsva); +#endif nodeRegisterType(ttype, &ntype); } @@ -175,7 +177,9 @@ void register_node_type_cmp_combhsva(bNodeTreeType *ttype) node_type_base(ttype, &ntype, CMP_NODE_COMBHSVA, "Combine HSVA", NODE_CLASS_CONVERTOR, NODE_OPTIONS); node_type_socket_templates(&ntype, cmp_node_combhsva_in, cmp_node_combhsva_out); node_type_size(&ntype, 80, 40, 140); +#ifdef WITH_COMPOSITOR_LEGACY node_type_exec(&ntype, node_composit_exec_combhsva); +#endif nodeRegisterType(ttype, &ntype); } diff --git a/source/blender/nodes/composite/nodes/node_composite_sepcombRGBA.c b/source/blender/nodes/composite/nodes/node_composite_sepcombRGBA.c index 988656ac454..57ad91d1700 100644 --- a/source/blender/nodes/composite/nodes/node_composite_sepcombRGBA.c +++ b/source/blender/nodes/composite/nodes/node_composite_sepcombRGBA.c @@ -84,7 +84,9 @@ void register_node_type_cmp_seprgba(bNodeTreeType *ttype) node_type_base(ttype, &ntype, CMP_NODE_SEPRGBA, "Separate RGBA", NODE_CLASS_CONVERTOR, 0); node_type_socket_templates(&ntype, cmp_node_seprgba_in, cmp_node_seprgba_out); node_type_size(&ntype, 80, 40, 140); +#ifdef WITH_COMPOSITOR_LEGACY node_type_exec(&ntype, node_composit_exec_seprgba); +#endif nodeRegisterType(ttype, &ntype); } @@ -152,7 +154,9 @@ void register_node_type_cmp_combrgba(bNodeTreeType *ttype) node_type_base(ttype, &ntype, CMP_NODE_COMBRGBA, "Combine RGBA", NODE_CLASS_CONVERTOR, NODE_OPTIONS); node_type_socket_templates(&ntype, cmp_node_combrgba_in, cmp_node_combrgba_out); node_type_size(&ntype, 80, 40, 140); +#ifdef WITH_COMPOSITOR_LEGACY node_type_exec(&ntype, node_composit_exec_combrgba); +#endif nodeRegisterType(ttype, &ntype); } diff --git a/source/blender/nodes/composite/nodes/node_composite_sepcombYCCA.c b/source/blender/nodes/composite/nodes/node_composite_sepcombYCCA.c index 486c0ed61ee..0ba59a547b7 100644 --- a/source/blender/nodes/composite/nodes/node_composite_sepcombYCCA.c +++ b/source/blender/nodes/composite/nodes/node_composite_sepcombYCCA.c @@ -153,7 +153,9 @@ void register_node_type_cmp_sepycca(bNodeTreeType *ttype) node_type_base(ttype, &ntype, CMP_NODE_SEPYCCA, "Separate YCbCrA", NODE_CLASS_CONVERTOR, NODE_OPTIONS); node_type_socket_templates(&ntype, cmp_node_sepycca_in, cmp_node_sepycca_out); node_type_size(&ntype, 80, 40, 140); +#ifdef WITH_COMPOSITOR_LEGACY node_type_exec(&ntype, node_composit_exec_sepycca); +#endif nodeRegisterType(ttype, &ntype); } @@ -298,7 +300,9 @@ void register_node_type_cmp_combycca(bNodeTreeType *ttype) node_type_base(ttype, &ntype, CMP_NODE_COMBYCCA, "Combine YCbCrA", NODE_CLASS_CONVERTOR, NODE_OPTIONS); node_type_socket_templates(&ntype, cmp_node_combycca_in, cmp_node_combycca_out); node_type_size(&ntype, 80, 40, 140); +#ifdef WITH_COMPOSITOR_LEGACY node_type_exec(&ntype, node_composit_exec_combycca); +#endif nodeRegisterType(ttype, &ntype); } diff --git a/source/blender/nodes/composite/nodes/node_composite_sepcombYUVA.c b/source/blender/nodes/composite/nodes/node_composite_sepcombYUVA.c index fdaae7307f0..d6946cc9b89 100644 --- a/source/blender/nodes/composite/nodes/node_composite_sepcombYUVA.c +++ b/source/blender/nodes/composite/nodes/node_composite_sepcombYUVA.c @@ -106,7 +106,9 @@ void register_node_type_cmp_sepyuva(bNodeTreeType *ttype) node_type_base(ttype, &ntype, CMP_NODE_SEPYUVA, "Separate YUVA", NODE_CLASS_CONVERTOR, 0); node_type_socket_templates(&ntype, cmp_node_sepyuva_in, cmp_node_sepyuva_out); node_type_size(&ntype, 80, 40, 140); +#ifdef WITH_COMPOSITOR_LEGACY node_type_exec(&ntype, node_composit_exec_sepyuva); +#endif nodeRegisterType(ttype, &ntype); } @@ -177,7 +179,9 @@ void register_node_type_cmp_combyuva(bNodeTreeType *ttype) node_type_base(ttype, &ntype, CMP_NODE_COMBYUVA, "Combine YUVA", NODE_CLASS_CONVERTOR, NODE_OPTIONS); node_type_socket_templates(&ntype, cmp_node_combyuva_in, cmp_node_combyuva_out); node_type_size(&ntype, 80, 40, 140); +#ifdef WITH_COMPOSITOR_LEGACY node_type_exec(&ntype, node_composit_exec_combyuva); +#endif nodeRegisterType(ttype, &ntype); } diff --git a/source/blender/nodes/composite/nodes/node_composite_setalpha.c b/source/blender/nodes/composite/nodes/node_composite_setalpha.c index c273807c54d..81955fbc59e 100644 --- a/source/blender/nodes/composite/nodes/node_composite_setalpha.c +++ b/source/blender/nodes/composite/nodes/node_composite_setalpha.c @@ -80,7 +80,9 @@ void register_node_type_cmp_setalpha(bNodeTreeType *ttype) node_type_base(ttype, &ntype, CMP_NODE_SETALPHA, "Set Alpha", NODE_CLASS_CONVERTOR, NODE_OPTIONS); node_type_socket_templates(&ntype, cmp_node_setalpha_in, cmp_node_setalpha_out); node_type_size(&ntype, 120, 40, 140); +#ifdef WITH_COMPOSITOR_LEGACY node_type_exec(&ntype, node_composit_exec_setalpha); +#endif nodeRegisterType(ttype, &ntype); } diff --git a/source/blender/nodes/composite/nodes/node_composite_splitViewer.c b/source/blender/nodes/composite/nodes/node_composite_splitViewer.c index abccbb83bd0..1b1cb420e7b 100644 --- a/source/blender/nodes/composite/nodes/node_composite_splitViewer.c +++ b/source/blender/nodes/composite/nodes/node_composite_splitViewer.c @@ -158,7 +158,9 @@ void register_node_type_cmp_splitviewer(bNodeTreeType *ttype) node_type_size(&ntype, 140, 100, 320); node_type_init(&ntype, node_composit_init_splitviewer); node_type_storage(&ntype, "ImageUser", node_free_standard_storage, node_copy_standard_storage); +#ifdef WITH_COMPOSITOR_LEGACY node_type_exec(&ntype, node_composit_exec_splitviewer); +#endif /* Do not allow muting for this node. */ node_type_internal_connect(&ntype, NULL); diff --git a/source/blender/nodes/composite/nodes/node_composite_stabilize2d.c b/source/blender/nodes/composite/nodes/node_composite_stabilize2d.c index fabdf8c0536..62163b4244b 100644 --- a/source/blender/nodes/composite/nodes/node_composite_stabilize2d.c +++ b/source/blender/nodes/composite/nodes/node_composite_stabilize2d.c @@ -74,7 +74,9 @@ void register_node_type_cmp_stabilize2d(bNodeTreeType *ttype) node_type_base(ttype, &ntype, CMP_NODE_STABILIZE2D, "Stabilize 2D", NODE_CLASS_DISTORT, NODE_OPTIONS); node_type_socket_templates(&ntype, cmp_node_stabilize2d_in, cmp_node_stabilize2d_out); node_type_size(&ntype, 140, 100, 320); +#ifdef WITH_COMPOSITOR_LEGACY node_type_exec(&ntype, node_composit_exec_stabilize2d); +#endif nodeRegisterType(ttype, &ntype); } diff --git a/source/blender/nodes/composite/nodes/node_composite_texture.c b/source/blender/nodes/composite/nodes/node_composite_texture.c index 95458ad755b..7e7e3239925 100644 --- a/source/blender/nodes/composite/nodes/node_composite_texture.c +++ b/source/blender/nodes/composite/nodes/node_composite_texture.c @@ -149,7 +149,9 @@ void register_node_type_cmp_texture(bNodeTreeType *ttype) node_type_base(ttype, &ntype, CMP_NODE_TEXTURE, "Texture", NODE_CLASS_INPUT, NODE_OPTIONS|NODE_PREVIEW); node_type_socket_templates(&ntype, cmp_node_texture_in, cmp_node_texture_out); node_type_size(&ntype, 120, 80, 240); +#ifdef WITH_COMPOSITOR_LEGACY node_type_exec(&ntype, node_composit_exec_texture); +#endif nodeRegisterType(ttype, &ntype); } diff --git a/source/blender/nodes/composite/nodes/node_composite_tonemap.c b/source/blender/nodes/composite/nodes/node_composite_tonemap.c index 50006e599e5..2beb20a9a47 100644 --- a/source/blender/nodes/composite/nodes/node_composite_tonemap.c +++ b/source/blender/nodes/composite/nodes/node_composite_tonemap.c @@ -171,7 +171,9 @@ void register_node_type_cmp_tonemap(bNodeTreeType *ttype) node_type_size(&ntype, 150, 120, 200); node_type_init(&ntype, node_composit_init_tonemap); node_type_storage(&ntype, "NodeTonemap", node_free_standard_storage, node_copy_standard_storage); +#ifdef WITH_COMPOSITOR_LEGACY node_type_exec(&ntype, node_composit_exec_tonemap); +#endif nodeRegisterType(ttype, &ntype); } diff --git a/source/blender/nodes/composite/nodes/node_composite_trackpos.c b/source/blender/nodes/composite/nodes/node_composite_trackpos.c index a40400c85f5..6b32ce4b186 100644 --- a/source/blender/nodes/composite/nodes/node_composite_trackpos.c +++ b/source/blender/nodes/composite/nodes/node_composite_trackpos.c @@ -59,7 +59,9 @@ void register_node_type_cmp_trackpos(bNodeTreeType *ttype) node_type_size(&ntype, 120, 80, 300); node_type_init(&ntype, init); node_type_storage(&ntype, "NodeTrackPosData", node_free_standard_storage, node_copy_standard_storage); +#ifdef WITH_COMPOSITOR_LEGACY node_type_exec(&ntype, node_composit_exec_trackpos); +#endif nodeRegisterType(ttype, &ntype); } diff --git a/source/blender/nodes/composite/nodes/node_composite_transform.c b/source/blender/nodes/composite/nodes/node_composite_transform.c index 8af55cde852..62713405610 100644 --- a/source/blender/nodes/composite/nodes/node_composite_transform.c +++ b/source/blender/nodes/composite/nodes/node_composite_transform.c @@ -134,7 +134,9 @@ void register_node_type_cmp_transform(bNodeTreeType *ttype) node_type_base(ttype, &ntype, CMP_NODE_TRANSFORM, "Transform", NODE_CLASS_DISTORT, NODE_OPTIONS); node_type_socket_templates(&ntype, cmp_node_transform_in, cmp_node_transform_out); node_type_size(&ntype, 140, 100, 320); +#ifdef WITH_COMPOSITOR_LEGACY node_type_exec(&ntype, node_composit_exec_transform); +#endif nodeRegisterType(ttype, &ntype); } diff --git a/source/blender/nodes/composite/nodes/node_composite_translate.c b/source/blender/nodes/composite/nodes/node_composite_translate.c index e147b100fce..062fdb43ef9 100644 --- a/source/blender/nodes/composite/nodes/node_composite_translate.c +++ b/source/blender/nodes/composite/nodes/node_composite_translate.c @@ -66,7 +66,9 @@ void register_node_type_cmp_translate(bNodeTreeType *ttype) node_type_base(ttype, &ntype, CMP_NODE_TRANSLATE, "Translate", NODE_CLASS_DISTORT, NODE_OPTIONS); node_type_socket_templates(&ntype, cmp_node_translate_in, cmp_node_translate_out); node_type_size(&ntype, 140, 100, 320); +#ifdef WITH_COMPOSITOR_LEGACY node_type_exec(&ntype, node_composit_exec_translate); +#endif nodeRegisterType(ttype, &ntype); } diff --git a/source/blender/nodes/composite/nodes/node_composite_valToRgb.c b/source/blender/nodes/composite/nodes/node_composite_valToRgb.c index 429ba262164..b700325c3a1 100644 --- a/source/blender/nodes/composite/nodes/node_composite_valToRgb.c +++ b/source/blender/nodes/composite/nodes/node_composite_valToRgb.c @@ -92,7 +92,9 @@ void register_node_type_cmp_valtorgb(bNodeTreeType *ttype) node_type_size(&ntype, 240, 200, 300); node_type_init(&ntype, node_composit_init_valtorgb); node_type_storage(&ntype, "ColorBand", node_free_standard_storage, node_copy_standard_storage); +#ifdef WITH_COMPOSITOR_LEGACY node_type_exec(&ntype, node_composit_exec_valtorgb); +#endif nodeRegisterType(ttype, &ntype); } @@ -144,7 +146,9 @@ void register_node_type_cmp_rgbtobw(bNodeTreeType *ttype) node_type_base(ttype, &ntype, CMP_NODE_RGBTOBW, "RGB to BW", NODE_CLASS_CONVERTOR, 0); node_type_socket_templates(&ntype, cmp_node_rgbtobw_in, cmp_node_rgbtobw_out); node_type_size(&ntype, 80, 40, 120); +#ifdef WITH_COMPOSITOR_LEGACY node_type_exec(&ntype, node_composit_exec_rgbtobw); +#endif nodeRegisterType(ttype, &ntype); } diff --git a/source/blender/nodes/composite/nodes/node_composite_value.c b/source/blender/nodes/composite/nodes/node_composite_value.c index 8d39b38c2fe..9558a0c55f2 100644 --- a/source/blender/nodes/composite/nodes/node_composite_value.c +++ b/source/blender/nodes/composite/nodes/node_composite_value.c @@ -65,7 +65,9 @@ void register_node_type_cmp_value(bNodeTreeType *ttype) node_type_socket_templates(&ntype, NULL, cmp_node_value_out); node_type_init(&ntype, node_composit_init_value); node_type_size(&ntype, 80, 40, 120); +#ifdef WITH_COMPOSITOR_LEGACY node_type_exec(&ntype, node_composit_exec_value); +#endif nodeRegisterType(ttype, &ntype); } diff --git a/source/blender/nodes/composite/nodes/node_composite_vecBlur.c b/source/blender/nodes/composite/nodes/node_composite_vecBlur.c index e1a20a65227..0ab88d1e464 100644 --- a/source/blender/nodes/composite/nodes/node_composite_vecBlur.c +++ b/source/blender/nodes/composite/nodes/node_composite_vecBlur.c @@ -103,7 +103,9 @@ void register_node_type_cmp_vecblur(bNodeTreeType *ttype) node_type_size(&ntype, 120, 80, 200); node_type_init(&ntype, node_composit_init_vecblur); node_type_storage(&ntype, "NodeBlurData", node_free_standard_storage, node_copy_standard_storage); +#ifdef WITH_COMPOSITOR_LEGACY node_type_exec(&ntype, node_composit_exec_vecblur); +#endif nodeRegisterType(ttype, &ntype); } diff --git a/source/blender/nodes/composite/nodes/node_composite_viewer.c b/source/blender/nodes/composite/nodes/node_composite_viewer.c index e97863a9463..cae8f248243 100644 --- a/source/blender/nodes/composite/nodes/node_composite_viewer.c +++ b/source/blender/nodes/composite/nodes/node_composite_viewer.c @@ -142,7 +142,9 @@ void register_node_type_cmp_viewer(bNodeTreeType *ttype) node_type_size(&ntype, 80, 60, 200); node_type_init(&ntype, node_composit_init_viewer); node_type_storage(&ntype, "ImageUser", node_free_standard_storage, node_copy_standard_storage); +#ifdef WITH_COMPOSITOR_LEGACY node_type_exec(&ntype, node_composit_exec_viewer); +#endif node_type_internal_connect(&ntype, NULL); nodeRegisterType(ttype, &ntype); diff --git a/source/blender/nodes/composite/nodes/node_composite_zcombine.c b/source/blender/nodes/composite/nodes/node_composite_zcombine.c index e431ff17be5..951a95e6de8 100644 --- a/source/blender/nodes/composite/nodes/node_composite_zcombine.c +++ b/source/blender/nodes/composite/nodes/node_composite_zcombine.c @@ -229,7 +229,9 @@ void register_node_type_cmp_zcombine(bNodeTreeType *ttype) node_type_base(ttype, &ntype, CMP_NODE_ZCOMBINE, "Z Combine", NODE_CLASS_OP_COLOR, NODE_OPTIONS); node_type_socket_templates(&ntype, cmp_node_zcombine_in, cmp_node_zcombine_out); node_type_size(&ntype, 80, 40, 120); +#ifdef WITH_COMPOSITOR_LEGACY node_type_exec(&ntype, node_composit_exec_zcombine); +#endif nodeRegisterType(ttype, &ntype); } From f9258696aacf97741957f01145e8385a8b7963d3 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 19 Aug 2012 23:36:29 +0000 Subject: [PATCH 022/163] disabling the compositor legacy build option now ifdef's exec() functions. --- .../nodes/node_composite_alphaOver.c | 4 ++++ .../nodes/node_composite_bilateralblur.c | 4 ++++ .../composite/nodes/node_composite_blur.c | 4 ++++ .../nodes/node_composite_brightness.c | 4 ++++ .../nodes/node_composite_channelMatte.c | 6 +++++- .../nodes/node_composite_chromaMatte.c | 3 +++ .../nodes/node_composite_colorMatte.c | 4 ++++ .../nodes/node_composite_colorSpill.c | 4 ++++ .../nodes/node_composite_colorbalance.c | 4 ++++ .../nodes/node_composite_composite.c | 7 ++++--- .../composite/nodes/node_composite_crop.c | 4 ++++ .../composite/nodes/node_composite_curves.c | 11 ++++++++++ .../composite/nodes/node_composite_defocus.c | 3 +++ .../nodes/node_composite_diffMatte.c | 4 ++++ .../composite/nodes/node_composite_dilate.c | 4 ++++ .../nodes/node_composite_directionalblur.c | 4 ++++ .../composite/nodes/node_composite_displace.c | 4 ++++ .../nodes/node_composite_distanceMatte.c | 4 ++++ .../nodes/node_composite_doubleEdgeMask.c | 4 ++++ .../composite/nodes/node_composite_filter.c | 3 +++ .../composite/nodes/node_composite_flip.c | 4 ++++ .../composite/nodes/node_composite_gamma.c | 4 ++++ .../composite/nodes/node_composite_glare.c | 3 +++ .../nodes/node_composite_hueSatVal.c | 4 ++++ .../nodes/node_composite_huecorrect.c | 4 ++++ .../composite/nodes/node_composite_idMask.c | 3 +++ .../composite/nodes/node_composite_image.c | 10 ++++++++-- .../composite/nodes/node_composite_inpaint.c | 5 +++++ .../composite/nodes/node_composite_invert.c | 4 ++++ .../composite/nodes/node_composite_lensdist.c | 3 +++ .../composite/nodes/node_composite_levels.c | 4 ++++ .../nodes/node_composite_lummaMatte.c | 4 ++++ .../composite/nodes/node_composite_mapUV.c | 4 ++++ .../composite/nodes/node_composite_mapValue.c | 3 +++ .../composite/nodes/node_composite_math.c | 4 ++++ .../composite/nodes/node_composite_mixrgb.c | 4 ++++ .../nodes/node_composite_movieclip.c | 4 ++++ .../composite/nodes/node_composite_normal.c | 6 ++++-- .../nodes/node_composite_normalize.c | 4 ++++ .../nodes/node_composite_premulkey.c | 4 ++++ .../composite/nodes/node_composite_rgb.c | 20 +++++++++++-------- .../composite/nodes/node_composite_rotate.c | 4 ++++ .../composite/nodes/node_composite_scale.c | 4 ++++ .../nodes/node_composite_sepcombHSVA.c | 8 ++++++++ .../nodes/node_composite_sepcombRGBA.c | 8 ++++++++ .../nodes/node_composite_sepcombYCCA.c | 8 ++++++++ .../nodes/node_composite_sepcombYUVA.c | 11 +++++++++- .../composite/nodes/node_composite_setalpha.c | 5 +++++ .../nodes/node_composite_splitViewer.c | 4 ++++ .../nodes/node_composite_stabilize2d.c | 4 ++++ .../composite/nodes/node_composite_texture.c | 4 ++++ .../composite/nodes/node_composite_tonemap.c | 3 +++ .../composite/nodes/node_composite_trackpos.c | 5 +++++ .../nodes/node_composite_transform.c | 4 ++++ .../nodes/node_composite_translate.c | 4 ++++ .../composite/nodes/node_composite_valToRgb.c | 8 ++++++++ .../composite/nodes/node_composite_value.c | 4 ++++ .../composite/nodes/node_composite_vecBlur.c | 4 +++- .../composite/nodes/node_composite_viewer.c | 3 +++ .../composite/nodes/node_composite_zcombine.c | 5 ++++- 60 files changed, 275 insertions(+), 19 deletions(-) diff --git a/source/blender/nodes/composite/nodes/node_composite_alphaOver.c b/source/blender/nodes/composite/nodes/node_composite_alphaOver.c index 7e6def1714a..92702ef2940 100644 --- a/source/blender/nodes/composite/nodes/node_composite_alphaOver.c +++ b/source/blender/nodes/composite/nodes/node_composite_alphaOver.c @@ -43,6 +43,8 @@ static bNodeSocketTemplate cmp_node_alphaover_out[]= { { -1, 0, "" } }; +#ifdef WITH_COMPOSITOR_LEGACY + static void do_alphaover_premul(bNode *UNUSED(node), float *out, float *src, float *over, float *fac) { @@ -136,6 +138,8 @@ static void node_composit_exec_alphaover(void *UNUSED(data), bNode *node, bNodeS } } +#endif /* WITH_COMPOSITOR_LEGACY */ + static void node_alphaover_init(bNodeTree *UNUSED(ntree), bNode* node, bNodeTemplate *UNUSED(ntemp)) { node->storage= MEM_callocN(sizeof(NodeTwoFloats), "NodeTwoFloats"); diff --git a/source/blender/nodes/composite/nodes/node_composite_bilateralblur.c b/source/blender/nodes/composite/nodes/node_composite_bilateralblur.c index cfaf40e2ab0..0562ff5a8a9 100644 --- a/source/blender/nodes/composite/nodes/node_composite_bilateralblur.c +++ b/source/blender/nodes/composite/nodes/node_composite_bilateralblur.c @@ -43,6 +43,8 @@ static bNodeSocketTemplate cmp_node_bilateralblur_out[] = { { -1, 0, "" } }; +#ifdef WITH_COMPOSITOR_LEGACY + #define INIT_C3 \ mean0 = 1; \ mean1[0] = src[0]; \ @@ -254,6 +256,8 @@ static void node_composit_exec_bilateralblur(void *UNUSED(data), bNode *node, bN free_compbuf(new); } +#endif /* WITH_COMPOSITOR_LEGACY */ + static void node_composit_init_bilateralblur(bNodeTree *UNUSED(ntree), bNode *node, bNodeTemplate *UNUSED(ntemp)) { NodeBilateralBlurData *nbbd = MEM_callocN(sizeof(NodeBilateralBlurData), "node bilateral blur data"); diff --git a/source/blender/nodes/composite/nodes/node_composite_blur.c b/source/blender/nodes/composite/nodes/node_composite_blur.c index c95b2d23bda..551164b8d26 100644 --- a/source/blender/nodes/composite/nodes/node_composite_blur.c +++ b/source/blender/nodes/composite/nodes/node_composite_blur.c @@ -44,6 +44,8 @@ static bNodeSocketTemplate cmp_node_blur_out[] = { { -1, 0, "" } }; +#ifdef WITH_COMPOSITOR_LEGACY + static float *make_gausstab(int filtertype, int rad) { float *gausstab, sum, val; @@ -720,6 +722,8 @@ static void node_composit_exec_blur(void *data, bNode *node, bNodeStack **in, bN generate_preview(data, node, out[0]->data); } +#endif /* WITH_COMPOSITOR_LEGACY */ + static void node_composit_init_blur(bNodeTree *UNUSED(ntree), bNode *node, bNodeTemplate *UNUSED(ntemp)) { node->storage = MEM_callocN(sizeof(NodeBlurData), "node blur data"); diff --git a/source/blender/nodes/composite/nodes/node_composite_brightness.c b/source/blender/nodes/composite/nodes/node_composite_brightness.c index d30a2ba5e03..f92fdd1ab9a 100644 --- a/source/blender/nodes/composite/nodes/node_composite_brightness.c +++ b/source/blender/nodes/composite/nodes/node_composite_brightness.c @@ -47,6 +47,8 @@ static bNodeSocketTemplate cmp_node_brightcontrast_out[]= { { -1, 0, "" } }; +#ifdef WITH_COMPOSITOR_LEGACY + static void do_brightnesscontrast(bNode *UNUSED(node), float *out, float *in, float *in_brightness, float *in_contrast) { float i; @@ -92,6 +94,8 @@ static void node_composit_exec_brightcontrast(void *UNUSED(data), bNode *node, b } } +#endif /* WITH_COMPOSITOR_LEGACY */ + void register_node_type_cmp_brightcontrast(bNodeTreeType *ttype) { static bNodeType ntype; diff --git a/source/blender/nodes/composite/nodes/node_composite_channelMatte.c b/source/blender/nodes/composite/nodes/node_composite_channelMatte.c index 12af1a7aa20..0bd99f79d3c 100644 --- a/source/blender/nodes/composite/nodes/node_composite_channelMatte.c +++ b/source/blender/nodes/composite/nodes/node_composite_channelMatte.c @@ -45,6 +45,8 @@ static bNodeSocketTemplate cmp_node_channel_matte_out[]={ {-1, 0, ""} }; +#ifdef WITH_COMPOSITOR_LEGACY + static void do_normalized_rgba_to_ycca2(bNode *UNUSED(node), float *out, float *in) { /*normalize to the range 0.0 to 1.0) */ @@ -179,12 +181,14 @@ static void node_composit_exec_channel_matte(void *data, bNode *node, bNodeStack out[0]->data=outbuf; if (out[1]->hasoutput) out[1]->data=valbuf_from_rgbabuf(outbuf, CHAN_A); - + if (cbuf!=in[0]->data) free_compbuf(cbuf); } +#endif /* WITH_COMPOSITOR_LEGACY */ + static void node_composit_init_channel_matte(bNodeTree *UNUSED(ntree), bNode* node, bNodeTemplate *UNUSED(ntemp)) { NodeChroma *c= MEM_callocN(sizeof(NodeChroma), "node chroma"); diff --git a/source/blender/nodes/composite/nodes/node_composite_chromaMatte.c b/source/blender/nodes/composite/nodes/node_composite_chromaMatte.c index 1204b05e415..57baa01d1d9 100644 --- a/source/blender/nodes/composite/nodes/node_composite_chromaMatte.c +++ b/source/blender/nodes/composite/nodes/node_composite_chromaMatte.c @@ -45,6 +45,8 @@ static bNodeSocketTemplate cmp_node_chroma_out[]={ {-1, 0, ""} }; +#ifdef WITH_COMPOSITOR_LEGACY + static void do_rgba_to_ycca_normalized(bNode *UNUSED(node), float *out, float *in) { rgb_to_ycc(in[0], in[1], in[2], &out[0], &out[1], &out[2], BLI_YCC_ITU_BT601); @@ -171,6 +173,7 @@ static void node_composit_exec_chroma_matte(void *data, bNode *node, bNodeStack free_compbuf(cbuf); } +#endif /* WITH_COMPOSITOR_LEGACY */ static void node_composit_init_chroma_matte(bNodeTree *UNUSED(ntree), bNode* node, bNodeTemplate *UNUSED(ntemp)) { diff --git a/source/blender/nodes/composite/nodes/node_composite_colorMatte.c b/source/blender/nodes/composite/nodes/node_composite_colorMatte.c index d921c1efa51..9bce09b516e 100644 --- a/source/blender/nodes/composite/nodes/node_composite_colorMatte.c +++ b/source/blender/nodes/composite/nodes/node_composite_colorMatte.c @@ -45,6 +45,8 @@ static bNodeSocketTemplate cmp_node_color_out[]={ {-1, 0, ""} }; +#ifdef WITH_COMPOSITOR_LEGACY + static void do_color_key(bNode *node, float *out, float *in) { float h_wrap; @@ -112,6 +114,8 @@ static void node_composit_exec_color_matte(void *data, bNode *node, bNodeStack * free_compbuf(cbuf); } +#endif /* WITH_COMPOSITOR_LEGACY */ + static void node_composit_init_color_matte(bNodeTree *UNUSED(ntree), bNode* node, bNodeTemplate *UNUSED(ntemp)) { NodeChroma *c= MEM_callocN(sizeof(NodeChroma), "node color"); diff --git a/source/blender/nodes/composite/nodes/node_composite_colorSpill.c b/source/blender/nodes/composite/nodes/node_composite_colorSpill.c index bfa8aac0183..b8ad5bdfc7e 100644 --- a/source/blender/nodes/composite/nodes/node_composite_colorSpill.c +++ b/source/blender/nodes/composite/nodes/node_composite_colorSpill.c @@ -47,6 +47,8 @@ static bNodeSocketTemplate cmp_node_color_spill_out[]={ {-1, 0, ""} }; +#ifdef WITH_COMPOSITOR_LEGACY + static void do_simple_spillmap_red(bNode *node, float* out, float *in) { NodeColorspill *ncs; @@ -315,6 +317,8 @@ static void node_composit_exec_color_spill(void *UNUSED(data), bNode *node, bNod free_compbuf(spillmap); } +#endif /* WITH_COMPOSITOR_LEGACY */ + static void node_composit_init_color_spill(bNodeTree *UNUSED(ntree), bNode* node, bNodeTemplate *UNUSED(ntemp)) { NodeColorspill *ncs= MEM_callocN(sizeof(NodeColorspill), "node colorspill"); diff --git a/source/blender/nodes/composite/nodes/node_composite_colorbalance.c b/source/blender/nodes/composite/nodes/node_composite_colorbalance.c index ae5d8a24847..a8c565eff44 100644 --- a/source/blender/nodes/composite/nodes/node_composite_colorbalance.c +++ b/source/blender/nodes/composite/nodes/node_composite_colorbalance.c @@ -46,6 +46,8 @@ static bNodeSocketTemplate cmp_node_colorbalance_out[]={ {-1, 0, ""} }; +#ifdef WITH_COMPOSITOR_LEGACY + /* this function implements ASC-CDL according to the spec at http://www.asctech.org/ Slope S = in * slope @@ -174,6 +176,8 @@ static void node_composit_exec_colorbalance(void *UNUSED(data), bNode *node, bNo } } +#endif /* WITH_COMPOSITOR_LEGACY */ + static void node_composit_init_colorbalance(bNodeTree *UNUSED(ntree), bNode* node, bNodeTemplate *UNUSED(ntemp)) { NodeColorBalance *n= node->storage= MEM_callocN(sizeof(NodeColorBalance), "node colorbalance"); diff --git a/source/blender/nodes/composite/nodes/node_composite_composite.c b/source/blender/nodes/composite/nodes/node_composite_composite.c index 71b392f14db..74f2e5c5b46 100644 --- a/source/blender/nodes/composite/nodes/node_composite_composite.c +++ b/source/blender/nodes/composite/nodes/node_composite_composite.c @@ -29,11 +29,8 @@ * \ingroup cmpnodes */ - #include "node_composite_util.h" - - /* **************** COMPOSITE ******************** */ static bNodeSocketTemplate cmp_node_composite_in[]= { { SOCK_RGBA, 1, N_("Image"), 0.0f, 0.0f, 0.0f, 1.0f}, @@ -42,6 +39,8 @@ static bNodeSocketTemplate cmp_node_composite_in[]= { { -1, 0, "" } }; +#ifdef WITH_COMPOSITOR_LEGACY + /* applies to render pipeline */ static void node_composit_exec_composite(void *data, bNode *node, bNodeStack **in, bNodeStack **UNUSED(out)) { @@ -97,6 +96,8 @@ static void node_composit_exec_composite(void *data, bNode *node, bNodeStack **i generate_preview(data, node, in[0]->data); } +#endif /* WITH_COMPOSITOR_LEGACY */ + void register_node_type_cmp_composite(bNodeTreeType *ttype) { static bNodeType ntype; diff --git a/source/blender/nodes/composite/nodes/node_composite_crop.c b/source/blender/nodes/composite/nodes/node_composite_crop.c index f439b7ebc00..ed4bd857361 100644 --- a/source/blender/nodes/composite/nodes/node_composite_crop.c +++ b/source/blender/nodes/composite/nodes/node_composite_crop.c @@ -43,6 +43,8 @@ static bNodeSocketTemplate cmp_node_crop_out[]= { { -1, 0, "" } }; +#ifdef WITH_COMPOSITOR_LEGACY + static void node_composit_exec_crop(void *UNUSED(data), bNode *node, bNodeStack **in, bNodeStack **out) { if (in[0]->data) { @@ -101,6 +103,8 @@ static void node_composit_exec_crop(void *UNUSED(data), bNode *node, bNodeStack } } +#endif /* WITH_COMPOSITOR_LEGACY */ + static void node_composit_init_crop(bNodeTree *UNUSED(ntree), bNode* node, bNodeTemplate *UNUSED(ntemp)) { NodeTwoXYs *nxy= MEM_callocN(sizeof(NodeTwoXYs), "node xy data"); diff --git a/source/blender/nodes/composite/nodes/node_composite_curves.c b/source/blender/nodes/composite/nodes/node_composite_curves.c index cc9d7d1d1a4..85830e8ca14 100644 --- a/source/blender/nodes/composite/nodes/node_composite_curves.c +++ b/source/blender/nodes/composite/nodes/node_composite_curves.c @@ -41,6 +41,8 @@ static bNodeSocketTemplate cmp_node_time_out[]= { { -1, 0, "" } }; +#ifdef WITH_COMPOSITOR_LEGACY + static void node_composit_exec_curves_time(void *data, bNode *node, bNodeStack **UNUSED(in), bNodeStack **out) { RenderData *rd= data; @@ -54,6 +56,7 @@ static void node_composit_exec_curves_time(void *data, bNode *node, bNodeStack * out[0]->vec[0]= CLAMPIS(fac, 0.0f, 1.0f); } +#endif /* WITH_COMPOSITOR_LEGACY */ static void node_composit_init_curves_time(bNodeTree *UNUSED(ntree), bNode* node, bNodeTemplate *UNUSED(ntemp)) { @@ -91,6 +94,8 @@ static bNodeSocketTemplate cmp_node_curve_vec_out[]= { { -1, 0, "" } }; +#ifdef WITH_COMPOSITOR_LEGACY + static void node_composit_exec_curve_vec(void *UNUSED(data), bNode *node, bNodeStack **in, bNodeStack **out) { /* stack order input: vec */ @@ -99,6 +104,8 @@ static void node_composit_exec_curve_vec(void *UNUSED(data), bNode *node, bNodeS curvemapping_evaluate_premulRGBF(node->storage, out[0]->vec, in[0]->vec); } +#endif /* WITH_COMPOSITOR_LEGACY */ + static void node_composit_init_curve_vec(bNodeTree *UNUSED(ntree), bNode* node, bNodeTemplate *UNUSED(ntemp)) { node->storage= curvemapping_add(3, -1.0f, -1.0f, 1.0f, 1.0f); @@ -135,6 +142,8 @@ static bNodeSocketTemplate cmp_node_curve_rgb_out[]= { { -1, 0, "" } }; +#ifdef WITH_COMPOSITOR_LEGACY + static void do_curves(bNode *node, float *out, float *in) { curvemapping_evaluate_premulRGBF(node->storage, out, in); @@ -188,6 +197,8 @@ static void node_composit_exec_curve_rgb(void *UNUSED(data), bNode *node, bNodeS } +#endif /* WITH_COMPOSITOR_LEGACY */ + static void node_composit_init_curve_rgb(bNodeTree *UNUSED(ntree), bNode* node, bNodeTemplate *UNUSED(ntemp)) { node->storage= curvemapping_add(4, 0.0f, 0.0f, 1.0f, 1.0f); diff --git a/source/blender/nodes/composite/nodes/node_composite_defocus.c b/source/blender/nodes/composite/nodes/node_composite_defocus.c index f23702a0606..e3d54213719 100644 --- a/source/blender/nodes/composite/nodes/node_composite_defocus.c +++ b/source/blender/nodes/composite/nodes/node_composite_defocus.c @@ -44,6 +44,7 @@ static bNodeSocketTemplate cmp_node_defocus_out[]= { { -1, 0, "" } }; +#ifdef WITH_COMPOSITOR_LEGACY // line coefs for point sampling & scancon. data. typedef struct BokehCoeffs { @@ -865,6 +866,8 @@ static void node_composit_exec_defocus(void *UNUSED(data), bNode *node, bNodeSta if (zbuf_use && (zbuf_use != zbuf)) free_compbuf(zbuf_use); } +#endif /* WITH_COMPOSITOR_LEGACY */ + static void node_composit_init_defocus(bNodeTree *UNUSED(ntree), bNode* node, bNodeTemplate *UNUSED(ntemp)) { /* qdn: defocus node */ diff --git a/source/blender/nodes/composite/nodes/node_composite_diffMatte.c b/source/blender/nodes/composite/nodes/node_composite_diffMatte.c index b79911f27dc..ff4d98dfea4 100644 --- a/source/blender/nodes/composite/nodes/node_composite_diffMatte.c +++ b/source/blender/nodes/composite/nodes/node_composite_diffMatte.c @@ -45,6 +45,8 @@ static bNodeSocketTemplate cmp_node_diff_matte_out[]={ {-1, 0, ""} }; +#ifdef WITH_COMPOSITOR_LEGACY + static void do_diff_matte(bNode *node, float *outColor, float *inColor1, float *inColor2) { NodeChroma *c= (NodeChroma *)node->storage; @@ -126,6 +128,8 @@ static void node_composit_exec_diff_matte(void *data, bNode *node, bNodeStack ** free_compbuf(imbuf2); } +#endif /* WITH_COMPOSITOR_LEGACY */ + static void node_composit_init_diff_matte(bNodeTree *UNUSED(ntree), bNode* node, bNodeTemplate *UNUSED(ntemp)) { NodeChroma *c= MEM_callocN(sizeof(NodeChroma), "node chroma"); diff --git a/source/blender/nodes/composite/nodes/node_composite_dilate.c b/source/blender/nodes/composite/nodes/node_composite_dilate.c index 6425606f9c4..d8dc44c7260 100644 --- a/source/blender/nodes/composite/nodes/node_composite_dilate.c +++ b/source/blender/nodes/composite/nodes/node_composite_dilate.c @@ -44,6 +44,8 @@ static bNodeSocketTemplate cmp_node_dilateerode_out[] = { { -1, 0, "" } }; +#ifdef WITH_COMPOSITOR_LEGACY + static void morpho_dilate(CompBuf *cbuf) { int x, y; @@ -146,6 +148,8 @@ static void node_composit_exec_dilateerode(void *UNUSED(data), bNode *node, bNod } } +#endif /* WITH_COMPOSITOR_LEGACY */ + static void node_composit_init_dilateerode(bNodeTree *UNUSED(ntree), bNode* node, bNodeTemplate *UNUSED(ntemp)) { NodeDilateErode *data = MEM_callocN(sizeof(NodeDilateErode), "NodeDilateErode"); diff --git a/source/blender/nodes/composite/nodes/node_composite_directionalblur.c b/source/blender/nodes/composite/nodes/node_composite_directionalblur.c index 3011e5772c5..2878d303632 100644 --- a/source/blender/nodes/composite/nodes/node_composite_directionalblur.c +++ b/source/blender/nodes/composite/nodes/node_composite_directionalblur.c @@ -42,6 +42,8 @@ static bNodeSocketTemplate cmp_node_dblur_out[] = { { -1, 0, "" } }; +#ifdef WITH_COMPOSITOR_LEGACY + static CompBuf *dblur(bNode *node, CompBuf *img, int iterations, int wrap, float center_x, float center_y, float dist, float angle, float spin, float zoom) { @@ -122,6 +124,8 @@ static void node_composit_exec_dblur(void *UNUSED(data), bNode *node, bNodeStack out[0]->data = dblur(node, new, ndbd->iter, ndbd->wrap, ndbd->center_x, ndbd->center_y, ndbd->distance, ndbd->angle, ndbd->spin, ndbd->zoom); } +#endif /* WITH_COMPOSITOR_LEGACY */ + static void node_composit_init_dblur(bNodeTree *UNUSED(ntree), bNode *node, bNodeTemplate *UNUSED(ntemp)) { NodeDBlurData *ndbd = MEM_callocN(sizeof(NodeDBlurData), "node dblur data"); diff --git a/source/blender/nodes/composite/nodes/node_composite_displace.c b/source/blender/nodes/composite/nodes/node_composite_displace.c index abf440273a1..51ccc2a4d39 100644 --- a/source/blender/nodes/composite/nodes/node_composite_displace.c +++ b/source/blender/nodes/composite/nodes/node_composite_displace.c @@ -47,6 +47,8 @@ static bNodeSocketTemplate cmp_node_displace_out[]= { { -1, 0, "" } }; +#ifdef WITH_COMPOSITOR_LEGACY + /* minimum distance (in pixels) a pixel has to be displaced * in order to take effect */ #define DISPLACE_EPSILON 0.01f @@ -182,6 +184,8 @@ static void node_composit_exec_displace(void *UNUSED(data), bNode *node, bNodeSt } } +#endif /* WITH_COMPOSITOR_LEGACY */ + void register_node_type_cmp_displace(bNodeTreeType *ttype) { static bNodeType ntype; diff --git a/source/blender/nodes/composite/nodes/node_composite_distanceMatte.c b/source/blender/nodes/composite/nodes/node_composite_distanceMatte.c index 83b16a808a3..7b3dbdb6a58 100644 --- a/source/blender/nodes/composite/nodes/node_composite_distanceMatte.c +++ b/source/blender/nodes/composite/nodes/node_composite_distanceMatte.c @@ -45,6 +45,8 @@ static bNodeSocketTemplate cmp_node_distance_matte_out[]={ {-1, 0, ""} }; +#ifdef WITH_COMPOSITOR_LEGACY + /* note, keyvals is passed on from caller as stack array */ /* might have been nicer as temp struct though... */ static void do_distance_matte(bNode *node, float *out, float *in) @@ -182,6 +184,8 @@ static void node_composit_exec_distance_matte(void *data, bNode *node, bNodeStac free_compbuf(inbuf); } +#endif /* WITH_COMPOSITOR_LEGACY */ + static void node_composit_init_distance_matte(bNodeTree *UNUSED(ntree), bNode* node, bNodeTemplate *UNUSED(ntemp)) { NodeChroma *c= MEM_callocN(sizeof(NodeChroma), "node chroma"); diff --git a/source/blender/nodes/composite/nodes/node_composite_doubleEdgeMask.c b/source/blender/nodes/composite/nodes/node_composite_doubleEdgeMask.c index 0d9f946d4f7..63a54efea74 100644 --- a/source/blender/nodes/composite/nodes/node_composite_doubleEdgeMask.c +++ b/source/blender/nodes/composite/nodes/node_composite_doubleEdgeMask.c @@ -42,6 +42,8 @@ static bNodeSocketTemplate cmp_node_doubleedgemask_out[]= { { -1, 0, "" } // output socket array terminator }; +#ifdef WITH_COMPOSITOR_LEGACY + static void do_adjacentKeepBorders(unsigned int t, unsigned int rw, unsigned int *limask, unsigned int *lomask, unsigned int *lres, float *res, unsigned int *rsize) { int x; @@ -1271,6 +1273,8 @@ static void node_composit_exec_doubleedgemask(void *UNUSED(data), bNode *node, b } } +#endif /* WITH_COMPOSITOR_LEGACY */ + void register_node_type_cmp_doubleedgemask(bNodeTreeType *ttype) { static bNodeType ntype; // allocate a node type data structure diff --git a/source/blender/nodes/composite/nodes/node_composite_filter.c b/source/blender/nodes/composite/nodes/node_composite_filter.c index 01fb4ee648c..0b12c03682b 100644 --- a/source/blender/nodes/composite/nodes/node_composite_filter.c +++ b/source/blender/nodes/composite/nodes/node_composite_filter.c @@ -43,6 +43,8 @@ static bNodeSocketTemplate cmp_node_filter_out[]= { { -1, 0, "" } }; +#ifdef WITH_COMPOSITOR_LEGACY + static void do_filter_edge(CompBuf *out, CompBuf *in, float *filter, float fac) { float *row1, *row2, *row3; @@ -219,6 +221,7 @@ static void node_composit_exec_filter(void *data, bNode *node, bNodeStack **in, } } +#endif /* WITH_COMPOSITOR_LEGACY */ void register_node_type_cmp_filter(bNodeTreeType *ttype) { diff --git a/source/blender/nodes/composite/nodes/node_composite_flip.c b/source/blender/nodes/composite/nodes/node_composite_flip.c index 742e1f7852e..147e7591af7 100644 --- a/source/blender/nodes/composite/nodes/node_composite_flip.c +++ b/source/blender/nodes/composite/nodes/node_composite_flip.c @@ -43,6 +43,8 @@ static bNodeSocketTemplate cmp_node_flip_out[]= { { -1, 0, "" } }; +#ifdef WITH_COMPOSITOR_LEGACY + static void node_composit_exec_flip(void *UNUSED(data), bNode *node, bNodeStack **in, bNodeStack **out) { if (in[0]->data) { @@ -88,6 +90,8 @@ static void node_composit_exec_flip(void *UNUSED(data), bNode *node, bNodeStack } } +#endif /* WITH_COMPOSITOR_LEGACY */ + void register_node_type_cmp_flip(bNodeTreeType *ttype) { static bNodeType ntype; diff --git a/source/blender/nodes/composite/nodes/node_composite_gamma.c b/source/blender/nodes/composite/nodes/node_composite_gamma.c index 432001909f0..87155478035 100644 --- a/source/blender/nodes/composite/nodes/node_composite_gamma.c +++ b/source/blender/nodes/composite/nodes/node_composite_gamma.c @@ -45,6 +45,8 @@ static bNodeSocketTemplate cmp_node_gamma_out[]= { { -1, 0, "" } }; +#ifdef WITH_COMPOSITOR_LEGACY + static void do_gamma(bNode *UNUSED(node), float *out, float *in, float *fac) { int i=0; @@ -75,6 +77,8 @@ static void node_composit_exec_gamma(void *UNUSED(data), bNode *node, bNodeStack } } +#endif /* WITH_COMPOSITOR_LEGACY */ + void register_node_type_cmp_gamma(bNodeTreeType *ttype) { static bNodeType ntype; diff --git a/source/blender/nodes/composite/nodes/node_composite_glare.c b/source/blender/nodes/composite/nodes/node_composite_glare.c index 9f266633923..6989bf59d79 100644 --- a/source/blender/nodes/composite/nodes/node_composite_glare.c +++ b/source/blender/nodes/composite/nodes/node_composite_glare.c @@ -41,6 +41,7 @@ static bNodeSocketTemplate cmp_node_glare_out[]= { { -1, 0, "" } }; +#ifdef WITH_COMPOSITOR_LEGACY // mix two images, src buffer does not have to be same size, static void mixImages(CompBuf *dst, CompBuf *src, float mix) @@ -474,6 +475,8 @@ static void node_composit_exec_glare(void *UNUSED(data), bNode *node, bNodeStack out[0]->data = new; } +#endif /* WITH_COMPOSITOR_LEGACY */ + static void node_composit_init_glare(bNodeTree *UNUSED(ntree), bNode* node, bNodeTemplate *UNUSED(ntemp)) { NodeGlare *ndg = MEM_callocN(sizeof(NodeGlare), "node glare data"); diff --git a/source/blender/nodes/composite/nodes/node_composite_hueSatVal.c b/source/blender/nodes/composite/nodes/node_composite_hueSatVal.c index 91614340c75..7a1ec9e324a 100644 --- a/source/blender/nodes/composite/nodes/node_composite_hueSatVal.c +++ b/source/blender/nodes/composite/nodes/node_composite_hueSatVal.c @@ -44,6 +44,8 @@ static bNodeSocketTemplate cmp_node_hue_sat_out[]= { { -1, 0, "" } }; +#ifdef WITH_COMPOSITOR_LEGACY + static void do_hue_sat_fac(bNode *node, float *out, float *in, float *fac) { NodeHueSat *nhs= node->storage; @@ -93,6 +95,8 @@ static void node_composit_exec_hue_sat(void *UNUSED(data), bNode *node, bNodeSta } } +#endif /* WITH_COMPOSITOR_LEGACY */ + static void node_composit_init_hue_sat(bNodeTree *UNUSED(ntree), bNode* node, bNodeTemplate *UNUSED(ntemp)) { NodeHueSat *nhs= MEM_callocN(sizeof(NodeHueSat), "node hue sat"); diff --git a/source/blender/nodes/composite/nodes/node_composite_huecorrect.c b/source/blender/nodes/composite/nodes/node_composite_huecorrect.c index e4c7567d102..1f343c648c3 100644 --- a/source/blender/nodes/composite/nodes/node_composite_huecorrect.c +++ b/source/blender/nodes/composite/nodes/node_composite_huecorrect.c @@ -43,6 +43,8 @@ static bNodeSocketTemplate cmp_node_huecorrect_out[]= { { -1, 0, "" } }; +#ifdef WITH_COMPOSITOR_LEGACY + static void do_huecorrect(bNode *node, float *out, float *in) { float hsv[3], f; @@ -135,6 +137,8 @@ static void node_composit_exec_huecorrect(void *UNUSED(data), bNode *node, bNode } +#endif /* WITH_COMPOSITOR_LEGACY */ + static void node_composit_init_huecorrect(bNodeTree *UNUSED(ntree), bNode* node, bNodeTemplate *UNUSED(ntemp)) { CurveMapping *cumapping = node->storage= curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f); diff --git a/source/blender/nodes/composite/nodes/node_composite_idMask.c b/source/blender/nodes/composite/nodes/node_composite_idMask.c index fdf5209a8e4..31a3a765ebe 100644 --- a/source/blender/nodes/composite/nodes/node_composite_idMask.c +++ b/source/blender/nodes/composite/nodes/node_composite_idMask.c @@ -44,6 +44,8 @@ static bNodeSocketTemplate cmp_node_idmask_out[]= { { -1, 0, "" } }; +#ifdef WITH_COMPOSITOR_LEGACY + /* stackbuf should be zeroed */ static void do_idmask(CompBuf *stackbuf, CompBuf *cbuf, float idnr) { @@ -106,6 +108,7 @@ static void node_composit_exec_idmask(void *data, bNode *node, bNodeStack **in, } } +#endif /* WITH_COMPOSITOR_LEGACY */ void register_node_type_cmp_idmask(bNodeTreeType *ttype) { diff --git a/source/blender/nodes/composite/nodes/node_composite_image.c b/source/blender/nodes/composite/nodes/node_composite_image.c index 824fb7bd64f..a3c65901121 100644 --- a/source/blender/nodes/composite/nodes/node_composite_image.c +++ b/source/blender/nodes/composite/nodes/node_composite_image.c @@ -322,6 +322,8 @@ float *node_composit_get_float_buffer(RenderData *rd, ImBuf *ibuf, int *alloc) return rect; } +#ifdef WITH_COMPOSITOR_LEGACY + /* note: this function is used for multilayer too, to ensure uniform * handling with BKE_image_get_ibuf() */ static CompBuf *node_composit_get_image(RenderData *rd, Image *ima, ImageUser *iuser) @@ -519,6 +521,8 @@ static void node_composit_exec_image(void *data, bNode *node, bNodeStack **UNUSE } } +#endif /* WITH_COMPOSITOR_LEGACY */ + static void node_composit_init_image(bNodeTree *ntree, bNode* node, bNodeTemplate *UNUSED(ntemp)) { ImageUser *iuser= MEM_callocN(sizeof(ImageUser), "node image user"); @@ -573,6 +577,8 @@ void register_node_type_cmp_image(bNodeTreeType *ttype) /* **************** RENDER RESULT ******************** */ +#ifdef WITH_COMPOSITOR_LEGACY + static CompBuf *compbuf_from_pass(RenderData *rd, RenderLayer *rl, int rectx, int recty, int passcode) { float *fp= RE_RenderLayerGetPass(rl, passcode); @@ -655,8 +661,6 @@ static void node_composit_rlayers_out(RenderData *rd, RenderLayer *rl, bNodeStac out[RRES_OUT_TRANSM_COLOR]->data= compbuf_from_pass(rd, rl, rectx, recty, SCE_PASS_TRANSM_COLOR); } - - static void node_composit_exec_rlayers(void *data, bNode *node, bNodeStack **UNUSED(in), bNodeStack **out) { Scene *sce= (Scene *)node->id; @@ -706,6 +710,8 @@ static void node_composit_exec_rlayers(void *data, bNode *node, bNodeStack **UNU RE_ReleaseResult(re); } +#endif /* WITH_COMPOSITOR_LEGACY */ + void register_node_type_cmp_rlayers(bNodeTreeType *ttype) { static bNodeType ntype; diff --git a/source/blender/nodes/composite/nodes/node_composite_inpaint.c b/source/blender/nodes/composite/nodes/node_composite_inpaint.c index e99b500c56a..25ecf428b4a 100644 --- a/source/blender/nodes/composite/nodes/node_composite_inpaint.c +++ b/source/blender/nodes/composite/nodes/node_composite_inpaint.c @@ -44,10 +44,15 @@ static bNodeSocketTemplate cmp_node_inpaint_out[] = { { -1, 0, "" } }; +#ifdef WITH_COMPOSITOR_LEGACY + static void node_composit_exec_inpaint(void *UNUSED(data), bNode *UNUSED(node), bNodeStack **UNUSED(in), bNodeStack **UNUSED(out)) { + /* pass */ } +#endif /* WITH_COMPOSITOR_LEGACY */ + void register_node_type_cmp_inpaint(bNodeTreeType *ttype) { static bNodeType ntype; diff --git a/source/blender/nodes/composite/nodes/node_composite_invert.c b/source/blender/nodes/composite/nodes/node_composite_invert.c index 5bd5c73b573..3518f90c027 100644 --- a/source/blender/nodes/composite/nodes/node_composite_invert.c +++ b/source/blender/nodes/composite/nodes/node_composite_invert.c @@ -43,6 +43,8 @@ static bNodeSocketTemplate cmp_node_invert_out[]= { { -1, 0, "" } }; +#ifdef WITH_COMPOSITOR_LEGACY + static void do_invert(bNode *node, float *out, float *in) { if (node->custom1 & CMP_CHAN_RGB) { @@ -115,6 +117,8 @@ static void node_composit_exec_invert(void *UNUSED(data), bNode *node, bNodeStac } } +#endif /* WITH_COMPOSITOR_LEGACY */ + static void node_composit_init_invert(bNodeTree *UNUSED(ntree), bNode* node, bNodeTemplate *UNUSED(ntemp)) { node->custom1 |= CMP_CHAN_RGB; diff --git a/source/blender/nodes/composite/nodes/node_composite_lensdist.c b/source/blender/nodes/composite/nodes/node_composite_lensdist.c index 3ca803ebbd7..22281a74016 100644 --- a/source/blender/nodes/composite/nodes/node_composite_lensdist.c +++ b/source/blender/nodes/composite/nodes/node_composite_lensdist.c @@ -43,6 +43,8 @@ static bNodeSocketTemplate cmp_node_lensdist_out[]= { { -1, 0, "" } }; +#ifdef WITH_COMPOSITOR_LEGACY + /* assumes *dst is type RGBA */ static void lensDistort(CompBuf *dst, CompBuf *src, float kr, float kg, float kb, int jit, int proj, int fit) { @@ -182,6 +184,7 @@ static void node_composit_exec_lensdist(void *UNUSED(data), bNode *node, bNodeSt out[0]->data = new; } +#endif /* WITH_COMPOSITOR_LEGACY */ static void node_composit_init_lensdist(bNodeTree *UNUSED(ntree), bNode* node, bNodeTemplate *UNUSED(ntemp)) { diff --git a/source/blender/nodes/composite/nodes/node_composite_levels.c b/source/blender/nodes/composite/nodes/node_composite_levels.c index 43ad5aff497..dfcfb4125f0 100644 --- a/source/blender/nodes/composite/nodes/node_composite_levels.c +++ b/source/blender/nodes/composite/nodes/node_composite_levels.c @@ -45,6 +45,8 @@ static bNodeSocketTemplate cmp_node_view_levels_out[]={ {-1, 0, ""} }; +#ifdef WITH_COMPOSITOR_LEGACY + static void fill_bins(bNode* node, CompBuf* in, int* bins) { float value[4]; @@ -309,6 +311,8 @@ static void node_composit_exec_view_levels(void *data, bNode *node, bNodeStack * free_compbuf(histogram); } +#endif /* WITH_COMPOSITOR_LEGACY */ + static void node_composit_init_view_levels(bNodeTree *UNUSED(ntree), bNode* node, bNodeTemplate *UNUSED(ntemp)) { node->custom1=1; /*All channels*/ diff --git a/source/blender/nodes/composite/nodes/node_composite_lummaMatte.c b/source/blender/nodes/composite/nodes/node_composite_lummaMatte.c index e6e5131c687..a4f6ffe746c 100644 --- a/source/blender/nodes/composite/nodes/node_composite_lummaMatte.c +++ b/source/blender/nodes/composite/nodes/node_composite_lummaMatte.c @@ -45,6 +45,8 @@ static bNodeSocketTemplate cmp_node_luma_matte_out[]={ {-1, 0, ""} }; +#ifdef WITH_COMPOSITOR_LEGACY + static void do_luma_matte(bNode *node, float *out, float *in) { NodeChroma *c=(NodeChroma *)node->storage; @@ -96,6 +98,8 @@ static void node_composit_exec_luma_matte(void *data, bNode *node, bNodeStack ** free_compbuf(cbuf); } +#endif /* WITH_COMPOSITOR_LEGACY */ + static void node_composit_init_luma_matte(bNodeTree *UNUSED(ntree), bNode* node, bNodeTemplate *UNUSED(ntemp)) { NodeChroma *c= MEM_callocN(sizeof(NodeChroma), "node chroma"); diff --git a/source/blender/nodes/composite/nodes/node_composite_mapUV.c b/source/blender/nodes/composite/nodes/node_composite_mapUV.c index 46c8c109bb7..04d2eaff4f4 100644 --- a/source/blender/nodes/composite/nodes/node_composite_mapUV.c +++ b/source/blender/nodes/composite/nodes/node_composite_mapUV.c @@ -44,6 +44,8 @@ static bNodeSocketTemplate cmp_node_mapuv_out[]= { { -1, 0, "" } }; +#ifdef WITH_COMPOSITOR_LEGACY + /* foreach UV, use these values to read in cbuf and write to stackbuf */ /* stackbuf should be zeroed */ static void do_mapuv(CompBuf *stackbuf, CompBuf *cbuf, CompBuf *uvbuf, float threshold) @@ -162,6 +164,8 @@ static void node_composit_exec_mapuv(void *UNUSED(data), bNode *node, bNodeStack } } +#endif /* WITH_COMPOSITOR_LEGACY */ + void register_node_type_cmp_mapuv(bNodeTreeType *ttype) { static bNodeType ntype; diff --git a/source/blender/nodes/composite/nodes/node_composite_mapValue.c b/source/blender/nodes/composite/nodes/node_composite_mapValue.c index da6c7f07f1a..49dc7323271 100644 --- a/source/blender/nodes/composite/nodes/node_composite_mapValue.c +++ b/source/blender/nodes/composite/nodes/node_composite_mapValue.c @@ -42,6 +42,8 @@ static bNodeSocketTemplate cmp_node_map_value_out[]= { { -1, 0, "" } }; +#ifdef WITH_COMPOSITOR_LEGACY + static void do_map_value(bNode *node, float *out, float *src) { TexMapping *texmap= node->storage; @@ -76,6 +78,7 @@ static void node_composit_exec_map_value(void *UNUSED(data), bNode *node, bNodeS } } +#endif /* WITH_COMPOSITOR_LEGACY */ static void node_composit_init_map_value(bNodeTree *UNUSED(ntree), bNode* node, bNodeTemplate *UNUSED(ntemp)) { diff --git a/source/blender/nodes/composite/nodes/node_composite_math.c b/source/blender/nodes/composite/nodes/node_composite_math.c index d5d7982e674..1bddfe0852a 100644 --- a/source/blender/nodes/composite/nodes/node_composite_math.c +++ b/source/blender/nodes/composite/nodes/node_composite_math.c @@ -44,6 +44,8 @@ static bNodeSocketTemplate cmp_node_math_out[]= { { -1, 0, "" } }; +#ifdef WITH_COMPOSITOR_LEGACY + static void do_math(bNode *node, float *out, float *in, float *in2) { switch (node->custom1) { @@ -195,6 +197,8 @@ static void node_composit_exec_math(void *UNUSED(data), bNode *node, bNodeStack out[0]->data= stackbuf; } +#endif /* WITH_COMPOSITOR_LEGACY */ + void register_node_type_cmp_math(bNodeTreeType *ttype) { static bNodeType ntype; diff --git a/source/blender/nodes/composite/nodes/node_composite_mixrgb.c b/source/blender/nodes/composite/nodes/node_composite_mixrgb.c index e10ea9c48b5..e2c9a5abcb1 100644 --- a/source/blender/nodes/composite/nodes/node_composite_mixrgb.c +++ b/source/blender/nodes/composite/nodes/node_composite_mixrgb.c @@ -43,6 +43,8 @@ static bNodeSocketTemplate cmp_node_mix_rgb_out[]= { { -1, 0, "" } }; +#ifdef WITH_COMPOSITOR_LEGACY + static void do_mix_rgb(bNode *node, float *out, float *in1, float *in2, float *fac) { float col[3]; @@ -81,6 +83,8 @@ static void node_composit_exec_mix_rgb(void *data, bNode *node, bNodeStack **in, } } +#endif /* WITH_COMPOSITOR_LEGACY */ + /* custom1 = mix type */ void register_node_type_cmp_mix_rgb(bNodeTreeType *ttype) { diff --git a/source/blender/nodes/composite/nodes/node_composite_movieclip.c b/source/blender/nodes/composite/nodes/node_composite_movieclip.c index 99b5b9f1972..370cff5e0d7 100644 --- a/source/blender/nodes/composite/nodes/node_composite_movieclip.c +++ b/source/blender/nodes/composite/nodes/node_composite_movieclip.c @@ -42,6 +42,8 @@ static bNodeSocketTemplate cmp_node_movieclip_out[] = { { -1, 0, "" } }; +#ifdef WITH_COMPOSITOR_LEGACY + static CompBuf *node_composit_get_movieclip(RenderData *rd, MovieClip *clip, MovieClipUser *user) { ImBuf *orig_ibuf, *ibuf; @@ -138,6 +140,8 @@ static void node_composit_exec_movieclip(void *data, bNode *node, bNodeStack **U } } +#endif /* WITH_COMPOSITOR_LEGACY */ + static void init(bNodeTree *UNUSED(ntree), bNode *node, bNodeTemplate *UNUSED(ntemp)) { MovieClipUser *user = MEM_callocN(sizeof(MovieClipUser), "node movie clip user"); diff --git a/source/blender/nodes/composite/nodes/node_composite_normal.c b/source/blender/nodes/composite/nodes/node_composite_normal.c index b27f197e9e7..6f1e86e2760 100644 --- a/source/blender/nodes/composite/nodes/node_composite_normal.c +++ b/source/blender/nodes/composite/nodes/node_composite_normal.c @@ -45,6 +45,8 @@ static bNodeSocketTemplate cmp_node_normal_out[]= { { -1, 0, "" } }; +#ifdef WITH_COMPOSITOR_LEGACY + static void do_normal(bNode *node, float *out, float *in) { bNodeSocket *sock= node->outputs.first; @@ -77,10 +79,10 @@ static void node_composit_exec_normal(void *UNUSED(data), bNode *node, bNodeStac out[1]->data= stackbuf; } - - } +#endif /* WITH_COMPOSITOR_LEGACY */ + static void init(bNodeTree *UNUSED(ntree), bNode *node, bNodeTemplate *UNUSED(ntemp)) { bNodeSocket *sock= node->outputs.first; diff --git a/source/blender/nodes/composite/nodes/node_composite_normalize.c b/source/blender/nodes/composite/nodes/node_composite_normalize.c index 7a5b1b0e655..1d2312d8280 100644 --- a/source/blender/nodes/composite/nodes/node_composite_normalize.c +++ b/source/blender/nodes/composite/nodes/node_composite_normalize.c @@ -43,6 +43,8 @@ static bNodeSocketTemplate cmp_node_normalize_out[]= { { -1, 0, "" } }; +#ifdef WITH_COMPOSITOR_LEGACY + static void do_normalize(bNode *UNUSED(node), float *out, float *src, float *min, float *mult) { float res; @@ -102,6 +104,8 @@ static void node_composit_exec_normalize(void *UNUSED(data), bNode *node, bNodeS } } +#endif /* WITH_COMPOSITOR_LEGACY */ + void register_node_type_cmp_normalize(bNodeTreeType *ttype) { static bNodeType ntype; diff --git a/source/blender/nodes/composite/nodes/node_composite_premulkey.c b/source/blender/nodes/composite/nodes/node_composite_premulkey.c index 75626ca25af..d791983b069 100644 --- a/source/blender/nodes/composite/nodes/node_composite_premulkey.c +++ b/source/blender/nodes/composite/nodes/node_composite_premulkey.c @@ -44,6 +44,8 @@ static bNodeSocketTemplate cmp_node_premulkey_out[]= { { -1, 0, "" } }; +#ifdef WITH_COMPOSITOR_LEGACY + static void node_composit_exec_premulkey(void *UNUSED(data), bNode *node, bNodeStack **in, bNodeStack **out) { if (out[0]->hasoutput==0) @@ -61,6 +63,8 @@ static void node_composit_exec_premulkey(void *UNUSED(data), bNode *node, bNodeS } } +#endif /* WITH_COMPOSITOR_LEGACY */ + void register_node_type_cmp_premulkey(bNodeTreeType *ttype) { static bNodeType ntype; diff --git a/source/blender/nodes/composite/nodes/node_composite_rgb.c b/source/blender/nodes/composite/nodes/node_composite_rgb.c index 5f323f4ef2c..65c1dcdb7bb 100644 --- a/source/blender/nodes/composite/nodes/node_composite_rgb.c +++ b/source/blender/nodes/composite/nodes/node_composite_rgb.c @@ -39,6 +39,18 @@ static bNodeSocketTemplate cmp_node_rgb_out[]= { { -1, 0, "" } }; +#ifdef WITH_COMPOSITOR_LEGACY + +static void node_composit_exec_rgb(void *UNUSED(data), bNode *node, bNodeStack **UNUSED(in), bNodeStack **out) +{ + bNodeSocket *sock= node->outputs.first; + float *col= ((bNodeSocketValueRGBA*)sock->default_value)->value; + + copy_v4_v4(out[0]->vec, col); +} + +#endif /* WITH_COMPOSITOR_LEGACY */ + static void node_composit_init_rgb(bNodeTree *UNUSED(ntree), bNode *node, bNodeTemplate *UNUSED(ntemp)) { bNodeSocket *sock= node->outputs.first; @@ -50,14 +62,6 @@ static void node_composit_init_rgb(bNodeTree *UNUSED(ntree), bNode *node, bNodeT col[3] = 1.0f; } -static void node_composit_exec_rgb(void *UNUSED(data), bNode *node, bNodeStack **UNUSED(in), bNodeStack **out) -{ - bNodeSocket *sock= node->outputs.first; - float *col= ((bNodeSocketValueRGBA*)sock->default_value)->value; - - copy_v4_v4(out[0]->vec, col); -} - void register_node_type_cmp_rgb(bNodeTreeType *ttype) { static bNodeType ntype; diff --git a/source/blender/nodes/composite/nodes/node_composite_rotate.c b/source/blender/nodes/composite/nodes/node_composite_rotate.c index 38b6e44f44e..87dc1e92438 100644 --- a/source/blender/nodes/composite/nodes/node_composite_rotate.c +++ b/source/blender/nodes/composite/nodes/node_composite_rotate.c @@ -44,6 +44,8 @@ static bNodeSocketTemplate cmp_node_rotate_out[]= { { -1, 0, "" } }; +#ifdef WITH_COMPOSITOR_LEGACY + /* only supports RGBA nodes now */ static void node_composit_exec_rotate(void *UNUSED(data), bNode *node, bNodeStack **in, bNodeStack **out) { @@ -121,6 +123,8 @@ static void node_composit_exec_rotate(void *UNUSED(data), bNode *node, bNodeStac } } +#endif /* WITH_COMPOSITOR_LEGACY */ + static void node_composit_init_rotate(bNodeTree *UNUSED(ntree), bNode* node, bNodeTemplate *UNUSED(ntemp)) { node->custom1= 1; /* Bilinear Filter*/ diff --git a/source/blender/nodes/composite/nodes/node_composite_scale.c b/source/blender/nodes/composite/nodes/node_composite_scale.c index 75a4053d4ea..2224d653c37 100644 --- a/source/blender/nodes/composite/nodes/node_composite_scale.c +++ b/source/blender/nodes/composite/nodes/node_composite_scale.c @@ -45,6 +45,8 @@ static bNodeSocketTemplate cmp_node_scale_out[] = { { -1, 0, "" } }; +#ifdef WITH_COMPOSITOR_LEGACY + /* only supports RGBA nodes now */ /* node->custom1 stores if input values are absolute or relative scale */ static void node_composit_exec_scale(void *data, bNode *node, bNodeStack **in, bNodeStack **out) @@ -182,6 +184,8 @@ static void node_composit_exec_scale(void *data, bNode *node, bNodeStack **in, b } } +#endif /* WITH_COMPOSITOR_LEGACY */ + void register_node_type_cmp_scale(bNodeTreeType *ttype) { static bNodeType ntype; diff --git a/source/blender/nodes/composite/nodes/node_composite_sepcombHSVA.c b/source/blender/nodes/composite/nodes/node_composite_sepcombHSVA.c index e19984b3358..ebc18cd19eb 100644 --- a/source/blender/nodes/composite/nodes/node_composite_sepcombHSVA.c +++ b/source/blender/nodes/composite/nodes/node_composite_sepcombHSVA.c @@ -46,6 +46,8 @@ static bNodeSocketTemplate cmp_node_sephsva_out[]= { { -1, 0, "" } }; +#ifdef WITH_COMPOSITOR_LEGACY + static void do_sephsva(bNode *UNUSED(node), float *out, float *in) { float h, s, v; @@ -99,6 +101,8 @@ static void node_composit_exec_sephsva(void *UNUSED(data), bNode *node, bNodeSta } } +#endif /* WITH_COMPOSITOR_LEGACY */ + void register_node_type_cmp_sephsva(bNodeTreeType *ttype) { static bNodeType ntype; @@ -127,6 +131,8 @@ static bNodeSocketTemplate cmp_node_combhsva_out[]= { { -1, 0, "" } }; +#ifdef WITH_COMPOSITOR_LEGACY + static void do_comb_hsva(bNode *UNUSED(node), float *out, float *in1, float *in2, float *in3, float *in4) { float r, g, b; @@ -170,6 +176,8 @@ static void node_composit_exec_combhsva(void *UNUSED(data), bNode *node, bNodeSt } } +#endif /* WITH_COMPOSITOR_LEGACY */ + void register_node_type_cmp_combhsva(bNodeTreeType *ttype) { static bNodeType ntype; diff --git a/source/blender/nodes/composite/nodes/node_composite_sepcombRGBA.c b/source/blender/nodes/composite/nodes/node_composite_sepcombRGBA.c index 57ad91d1700..0c989ed3fc6 100644 --- a/source/blender/nodes/composite/nodes/node_composite_sepcombRGBA.c +++ b/source/blender/nodes/composite/nodes/node_composite_sepcombRGBA.c @@ -45,6 +45,8 @@ static bNodeSocketTemplate cmp_node_seprgba_out[]= { { -1, 0, "" } }; +#ifdef WITH_COMPOSITOR_LEGACY + static void node_composit_exec_seprgba(void *UNUSED(data), bNode *UNUSED(node), bNodeStack **in, bNodeStack **out) { /* stack order out: bw channels */ @@ -77,6 +79,8 @@ static void node_composit_exec_seprgba(void *UNUSED(data), bNode *UNUSED(node), } } +#endif /* WITH_COMPOSITOR_LEGACY */ + void register_node_type_cmp_seprgba(bNodeTreeType *ttype) { static bNodeType ntype; @@ -106,6 +110,8 @@ static bNodeSocketTemplate cmp_node_combrgba_out[]= { { -1, 0, "" } }; +#ifdef WITH_COMPOSITOR_LEGACY + static void do_combrgba(bNode *UNUSED(node), float *out, float *in1, float *in2, float *in3, float *in4) { out[0] = in1[0]; @@ -147,6 +153,8 @@ static void node_composit_exec_combrgba(void *UNUSED(data), bNode *node, bNodeSt } } +#endif /* WITH_COMPOSITOR_LEGACY */ + void register_node_type_cmp_combrgba(bNodeTreeType *ttype) { static bNodeType ntype; diff --git a/source/blender/nodes/composite/nodes/node_composite_sepcombYCCA.c b/source/blender/nodes/composite/nodes/node_composite_sepcombYCCA.c index 0ba59a547b7..ccae7cfe57f 100644 --- a/source/blender/nodes/composite/nodes/node_composite_sepcombYCCA.c +++ b/source/blender/nodes/composite/nodes/node_composite_sepcombYCCA.c @@ -46,6 +46,8 @@ static bNodeSocketTemplate cmp_node_sepycca_out[]= { { -1, 0, "" } }; +#ifdef WITH_COMPOSITOR_LEGACY + static void do_sepycca_601(bNode *UNUSED(node), float *out, float *in) { float y, cb, cr; @@ -146,6 +148,8 @@ static void node_composit_exec_sepycca(void *UNUSED(data), bNode *node, bNodeSta } } +#endif /* WITH_COMPOSITOR_LEGACY */ + void register_node_type_cmp_sepycca(bNodeTreeType *ttype) { static bNodeType ntype; @@ -175,6 +179,8 @@ static bNodeSocketTemplate cmp_node_combycca_out[]= { { -1, 0, "" } }; +#ifdef WITH_COMPOSITOR_LEGACY + static void do_comb_ycca_601(bNode *UNUSED(node), float *out, float *in1, float *in2, float *in3, float *in4) { float r, g, b; @@ -293,6 +299,8 @@ static void node_composit_exec_combycca(void *UNUSED(data), bNode *node, bNodeSt } } +#endif /* WITH_COMPOSITOR_LEGACY */ + void register_node_type_cmp_combycca(bNodeTreeType *ttype) { static bNodeType ntype; diff --git a/source/blender/nodes/composite/nodes/node_composite_sepcombYUVA.c b/source/blender/nodes/composite/nodes/node_composite_sepcombYUVA.c index d6946cc9b89..9b8c805b0f0 100644 --- a/source/blender/nodes/composite/nodes/node_composite_sepcombYUVA.c +++ b/source/blender/nodes/composite/nodes/node_composite_sepcombYUVA.c @@ -46,6 +46,8 @@ static bNodeSocketTemplate cmp_node_sepyuva_out[]= { { -1, 0, "" } }; +#ifdef WITH_COMPOSITOR_LEGACY + static void do_sepyuva(bNode *UNUSED(node), float *out, float *in) { float y, u, v; @@ -99,6 +101,9 @@ static void node_composit_exec_sepyuva(void *UNUSED(data), bNode *node, bNodeSta } } +#endif /* WITH_COMPOSITOR_LEGACY */ + + void register_node_type_cmp_sepyuva(bNodeTreeType *ttype) { static bNodeType ntype; @@ -128,6 +133,8 @@ static bNodeSocketTemplate cmp_node_combyuva_out[]= { { -1, 0, "" } }; +#ifdef WITH_COMPOSITOR_LEGACY + static void do_comb_yuva(bNode *UNUSED(node), float *out, float *in1, float *in2, float *in3, float *in4) { float r, g, b; @@ -169,9 +176,11 @@ static void node_composit_exec_combyuva(void *UNUSED(data), bNode *node, bNodeSt do_comb_yuva, CB_VAL, CB_VAL, CB_VAL, CB_VAL); out[0]->data= stackbuf; - } + } } +#endif /* WITH_COMPOSITOR_LEGACY */ + void register_node_type_cmp_combyuva(bNodeTreeType *ttype) { static bNodeType ntype; diff --git a/source/blender/nodes/composite/nodes/node_composite_setalpha.c b/source/blender/nodes/composite/nodes/node_composite_setalpha.c index 81955fbc59e..503815b74a0 100644 --- a/source/blender/nodes/composite/nodes/node_composite_setalpha.c +++ b/source/blender/nodes/composite/nodes/node_composite_setalpha.c @@ -43,6 +43,8 @@ static bNodeSocketTemplate cmp_node_setalpha_out[]= { { -1, 0, "" } }; +#ifdef WITH_COMPOSITOR_LEGACY + static void node_composit_exec_setalpha(void *UNUSED(data), bNode *node, bNodeStack **in, bNodeStack **out) { /* stack order out: RGBA image */ @@ -73,6 +75,9 @@ static void node_composit_exec_setalpha(void *UNUSED(data), bNode *node, bNodeSt } } +#endif /* WITH_COMPOSITOR_LEGACY */ + + void register_node_type_cmp_setalpha(bNodeTreeType *ttype) { static bNodeType ntype; diff --git a/source/blender/nodes/composite/nodes/node_composite_splitViewer.c b/source/blender/nodes/composite/nodes/node_composite_splitViewer.c index 1b1cb420e7b..af115c25c14 100644 --- a/source/blender/nodes/composite/nodes/node_composite_splitViewer.c +++ b/source/blender/nodes/composite/nodes/node_composite_splitViewer.c @@ -39,6 +39,8 @@ static bNodeSocketTemplate cmp_node_splitviewer_in[]= { { -1, 0, "" } }; +#ifdef WITH_COMPOSITOR_LEGACY + static void do_copy_split_rgba(bNode *UNUSED(node), float *out, float *in1, float *in2, float *fac) { if (*fac==0.0f) { @@ -139,6 +141,8 @@ static void node_composit_exec_splitviewer(void *data, bNode *node, bNodeStack * } } +#endif /* WITH_COMPOSITOR_LEGACY */ + static void node_composit_init_splitviewer(bNodeTree *UNUSED(ntree), bNode* node, bNodeTemplate *UNUSED(ntemp)) { ImageUser *iuser= MEM_callocN(sizeof(ImageUser), "node image user"); diff --git a/source/blender/nodes/composite/nodes/node_composite_stabilize2d.c b/source/blender/nodes/composite/nodes/node_composite_stabilize2d.c index 62163b4244b..fdf0b38e844 100644 --- a/source/blender/nodes/composite/nodes/node_composite_stabilize2d.c +++ b/source/blender/nodes/composite/nodes/node_composite_stabilize2d.c @@ -45,6 +45,8 @@ static bNodeSocketTemplate cmp_node_stabilize2d_out[]= { { -1, 0, "" } }; +#ifdef WITH_COMPOSITOR_LEGACY + static void node_composit_exec_stabilize2d(void *data, bNode *node, bNodeStack **in, bNodeStack **out) { if (in[0]->data && node->id) { @@ -67,6 +69,8 @@ static void node_composit_exec_stabilize2d(void *data, bNode *node, bNodeStack * } } +#endif /* WITH_COMPOSITOR_LEGACY */ + void register_node_type_cmp_stabilize2d(bNodeTreeType *ttype) { static bNodeType ntype; diff --git a/source/blender/nodes/composite/nodes/node_composite_texture.c b/source/blender/nodes/composite/nodes/node_composite_texture.c index 7e7e3239925..3fedccd7d12 100644 --- a/source/blender/nodes/composite/nodes/node_composite_texture.c +++ b/source/blender/nodes/composite/nodes/node_composite_texture.c @@ -44,6 +44,8 @@ static bNodeSocketTemplate cmp_node_texture_out[]= { { -1, 0, "" } }; +#ifdef WITH_COMPOSITOR_LEGACY + /* called without rect allocated */ static void texture_procedural(CompBuf *cbuf, float *out, float xco, float yco) { @@ -142,6 +144,8 @@ static void node_composit_exec_texture(void *data, bNode *node, bNodeStack **in, } } +#endif /* WITH_COMPOSITOR_LEGACY */ + void register_node_type_cmp_texture(bNodeTreeType *ttype) { static bNodeType ntype; diff --git a/source/blender/nodes/composite/nodes/node_composite_tonemap.c b/source/blender/nodes/composite/nodes/node_composite_tonemap.c index 2beb20a9a47..d0ead67431c 100644 --- a/source/blender/nodes/composite/nodes/node_composite_tonemap.c +++ b/source/blender/nodes/composite/nodes/node_composite_tonemap.c @@ -41,6 +41,7 @@ static bNodeSocketTemplate cmp_node_tonemap_out[]= { { -1, 0, "" } }; +#ifdef WITH_COMPOSITOR_LEGACY static float avgLogLum(CompBuf *src, float* auto_key, float* Lav, float* Cav) { @@ -146,6 +147,8 @@ static void node_composit_exec_tonemap(void *UNUSED(data), bNode *node, bNodeSta free_compbuf(img); } +#endif /* WITH_COMPOSITOR_LEGACY */ + static void node_composit_init_tonemap(bNodeTree *UNUSED(ntree), bNode* node, bNodeTemplate *UNUSED(ntemp)) { NodeTonemap *ntm = MEM_callocN(sizeof(NodeTonemap), "node tonemap data"); diff --git a/source/blender/nodes/composite/nodes/node_composite_trackpos.c b/source/blender/nodes/composite/nodes/node_composite_trackpos.c index 6b32ce4b186..4364ca61ba1 100644 --- a/source/blender/nodes/composite/nodes/node_composite_trackpos.c +++ b/source/blender/nodes/composite/nodes/node_composite_trackpos.c @@ -39,10 +39,15 @@ static bNodeSocketTemplate cmp_node_trackpos_out[] = { { -1, 0, "" } }; +#ifdef WITH_COMPOSITOR_LEGACY + static void node_composit_exec_trackpos(void *UNUSED(data), bNode *UNUSED(node), bNodeStack **UNUSED(in), bNodeStack **UNUSED(out)) { + /* pass */ } +#endif /* WITH_COMPOSITOR_LEGACY */ + static void init(bNodeTree *UNUSED(ntree), bNode *node, bNodeTemplate *UNUSED(ntemp)) { NodeTrackPosData *data = MEM_callocN(sizeof(NodeTrackPosData), "node track position data"); diff --git a/source/blender/nodes/composite/nodes/node_composite_transform.c b/source/blender/nodes/composite/nodes/node_composite_transform.c index 62713405610..a8ef0286f2f 100644 --- a/source/blender/nodes/composite/nodes/node_composite_transform.c +++ b/source/blender/nodes/composite/nodes/node_composite_transform.c @@ -48,6 +48,8 @@ static bNodeSocketTemplate cmp_node_transform_out[] = { { -1, 0, "" } }; +#ifdef WITH_COMPOSITOR_LEGACY + CompBuf* node_composit_transform(CompBuf *cbuf, float x, float y, float angle, float scale, int filter_type) { CompBuf *stackbuf = alloc_compbuf(cbuf->x, cbuf->y, CB_RGBA, TRUE); @@ -127,6 +129,8 @@ static void node_composit_exec_transform(void *UNUSED(data), bNode *node, bNodeS } } +#endif /* WITH_COMPOSITOR_LEGACY */ + void register_node_type_cmp_transform(bNodeTreeType *ttype) { static bNodeType ntype; diff --git a/source/blender/nodes/composite/nodes/node_composite_translate.c b/source/blender/nodes/composite/nodes/node_composite_translate.c index 062fdb43ef9..649902ff908 100644 --- a/source/blender/nodes/composite/nodes/node_composite_translate.c +++ b/source/blender/nodes/composite/nodes/node_composite_translate.c @@ -46,6 +46,8 @@ static bNodeSocketTemplate cmp_node_translate_out[]= { { -1, 0, "" } }; +#ifdef WITH_COMPOSITOR_LEGACY + static void node_composit_exec_translate(void *UNUSED(data), bNode *UNUSED(node), bNodeStack **in, bNodeStack **out) { if (in[0]->data) { @@ -59,6 +61,8 @@ static void node_composit_exec_translate(void *UNUSED(data), bNode *UNUSED(node) } } +#endif /* WITH_COMPOSITOR_LEGACY */ + void register_node_type_cmp_translate(bNodeTreeType *ttype) { static bNodeType ntype; diff --git a/source/blender/nodes/composite/nodes/node_composite_valToRgb.c b/source/blender/nodes/composite/nodes/node_composite_valToRgb.c index b700325c3a1..b3b6218a265 100644 --- a/source/blender/nodes/composite/nodes/node_composite_valToRgb.c +++ b/source/blender/nodes/composite/nodes/node_composite_valToRgb.c @@ -44,6 +44,8 @@ static bNodeSocketTemplate cmp_node_valtorgb_out[]= { { -1, 0, "" } }; +#ifdef WITH_COMPOSITOR_LEGACY + static void do_colorband_composit(bNode *node, float *out, float *in) { do_colorband(node->storage, in[0], out); @@ -78,6 +80,8 @@ static void node_composit_exec_valtorgb(void *UNUSED(data), bNode *node, bNodeSt } } +#endif /* WITH_COMPOSITOR_LEGACY */ + static void node_composit_init_valtorgb(bNodeTree *UNUSED(ntree), bNode* node, bNodeTemplate *UNUSED(ntemp)) { node->storage= add_colorband(1); @@ -111,6 +115,8 @@ static bNodeSocketTemplate cmp_node_rgbtobw_out[]= { { -1, 0, "" } }; +#ifdef WITH_COMPOSITOR_LEGACY + static void do_rgbtobw(bNode *UNUSED(node), float *out, float *in) { out[0] = rgb_to_bw(in); @@ -139,6 +145,8 @@ static void node_composit_exec_rgbtobw(void *UNUSED(data), bNode *node, bNodeSta } } +#endif /* WITH_COMPOSITOR_LEGACY */ + void register_node_type_cmp_rgbtobw(bNodeTreeType *ttype) { static bNodeType ntype; diff --git a/source/blender/nodes/composite/nodes/node_composite_value.c b/source/blender/nodes/composite/nodes/node_composite_value.c index 9558a0c55f2..63ab4fcb58f 100644 --- a/source/blender/nodes/composite/nodes/node_composite_value.c +++ b/source/blender/nodes/composite/nodes/node_composite_value.c @@ -49,6 +49,8 @@ static void node_composit_init_value(bNodeTree *UNUSED(ntree), bNode *node, bNod dval->max = FLT_MAX; } +#ifdef WITH_COMPOSITOR_LEGACY + static void node_composit_exec_value(void *UNUSED(data), bNode *node, bNodeStack **UNUSED(in), bNodeStack **out) { bNodeSocket *sock= node->outputs.first; @@ -57,6 +59,8 @@ static void node_composit_exec_value(void *UNUSED(data), bNode *node, bNodeStack out[0]->vec[0]= val; } +#endif /* WITH_COMPOSITOR_LEGACY */ + void register_node_type_cmp_value(bNodeTreeType *ttype) { static bNodeType ntype; diff --git a/source/blender/nodes/composite/nodes/node_composite_vecBlur.c b/source/blender/nodes/composite/nodes/node_composite_vecBlur.c index 0ab88d1e464..62c2c02836a 100644 --- a/source/blender/nodes/composite/nodes/node_composite_vecBlur.c +++ b/source/blender/nodes/composite/nodes/node_composite_vecBlur.c @@ -45,7 +45,7 @@ static bNodeSocketTemplate cmp_node_vecblur_out[] = { { -1, 0, "" } }; - +#ifdef WITH_COMPOSITOR_LEGACY static void node_composit_exec_vecblur(void *UNUSED(data), bNode *node, bNodeStack **in, bNodeStack **out) { @@ -85,6 +85,8 @@ static void node_composit_exec_vecblur(void *UNUSED(data), bNode *node, bNodeSta free_compbuf(img); } +#endif /* WITH_COMPOSITOR_LEGACY */ + static void node_composit_init_vecblur(bNodeTree *UNUSED(ntree), bNode *node, bNodeTemplate *UNUSED(ntemp)) { NodeBlurData *nbd = MEM_callocN(sizeof(NodeBlurData), "node blur data"); diff --git a/source/blender/nodes/composite/nodes/node_composite_viewer.c b/source/blender/nodes/composite/nodes/node_composite_viewer.c index cae8f248243..0bdab75fc5f 100644 --- a/source/blender/nodes/composite/nodes/node_composite_viewer.c +++ b/source/blender/nodes/composite/nodes/node_composite_viewer.c @@ -41,6 +41,7 @@ static bNodeSocketTemplate cmp_node_viewer_in[] = { { -1, 0, "" } }; +#ifdef WITH_COMPOSITOR_LEGACY static void node_composit_exec_viewer(void *data, bNode *node, bNodeStack **in, bNodeStack **UNUSED(out)) { @@ -122,6 +123,8 @@ static void node_composit_exec_viewer(void *data, bNode *node, bNodeStack **in, } } +#endif /* WITH_COMPOSITOR_LEGACY */ + static void node_composit_init_viewer(bNodeTree *UNUSED(ntree), bNode *node, bNodeTemplate *UNUSED(ntemp)) { ImageUser *iuser = MEM_callocN(sizeof(ImageUser), "node image user"); diff --git a/source/blender/nodes/composite/nodes/node_composite_zcombine.c b/source/blender/nodes/composite/nodes/node_composite_zcombine.c index 951a95e6de8..3decbe8d230 100644 --- a/source/blender/nodes/composite/nodes/node_composite_zcombine.c +++ b/source/blender/nodes/composite/nodes/node_composite_zcombine.c @@ -48,6 +48,8 @@ static bNodeSocketTemplate cmp_node_zcombine_out[]= { { -1, 0, "" } }; +#ifdef WITH_COMPOSITOR_LEGACY + static void do_zcombine(bNode *node, float *out, float *src1, float *z1, float *src2, float *z2) { float alpha; @@ -219,9 +221,10 @@ static void node_composit_exec_zcombine(void *data, bNode *node, bNodeStack **in out[0]->data= stackbuf; } - } +#endif /* WITH_COMPOSITOR_LEGACY */ + void register_node_type_cmp_zcombine(bNodeTreeType *ttype) { static bNodeType ntype; From 817965613b5e9d4b357e156faae742b3d615264f Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 20 Aug 2012 00:11:13 +0000 Subject: [PATCH 023/163] added 'Unselected' option to remove doubles, merges selected vertices into unselected ones, but not each other. --- source/blender/editors/mesh/editmesh_tools.c | 35 +++++++++++++++----- 1 file changed, 26 insertions(+), 9 deletions(-) diff --git a/source/blender/editors/mesh/editmesh_tools.c b/source/blender/editors/mesh/editmesh_tools.c index 13c48c7f51d..4b8edb920a1 100644 --- a/source/blender/editors/mesh/editmesh_tools.c +++ b/source/blender/editors/mesh/editmesh_tools.c @@ -2042,22 +2042,38 @@ static int edbm_remove_doubles_exec(bContext *C, wmOperator *op) Object *obedit = CTX_data_edit_object(C); BMEditMesh *em = BMEdit_FromObject(obedit); BMOperator bmop; + const float mergedist = RNA_float_get(op->ptr, "mergedist"); + int use_unselected = RNA_boolean_get(op->ptr, "use_unselected"); + int totvert_orig = em->bm->totvert; int count; - EDBM_op_init(em, &bmop, op, "find_doubles verts=%hv dist=%f", BM_ELEM_SELECT, RNA_float_get(op->ptr, "mergedist")); - BMO_op_exec(em->bm, &bmop); + if (use_unselected) { + EDBM_op_init(em, &bmop, op, + "automerge verts=%hv dist=%f", + BM_ELEM_SELECT, mergedist); + BMO_op_exec(em->bm, &bmop); - count = BMO_slot_map_count(em->bm, &bmop, "targetmapout"); - - if (!EDBM_op_callf(em, op, "weld_verts targetmap=%s", &bmop, "targetmapout")) { - BMO_op_finish(em->bm, &bmop); - return OPERATOR_CANCELLED; + if (!EDBM_op_finish(em, &bmop, op, TRUE)) { + return OPERATOR_CANCELLED; + } } + else { + EDBM_op_init(em, &bmop, op, + "find_doubles verts=%hv dist=%f", + BM_ELEM_SELECT, mergedist); + BMO_op_exec(em->bm, &bmop); - if (!EDBM_op_finish(em, &bmop, op, TRUE)) { - return OPERATOR_CANCELLED; + if (!EDBM_op_callf(em, op, "weld_verts targetmap=%s", &bmop, "targetmapout")) { + BMO_op_finish(em->bm, &bmop); + return OPERATOR_CANCELLED; + } + + if (!EDBM_op_finish(em, &bmop, op, TRUE)) { + return OPERATOR_CANCELLED; + } } + count = totvert_orig - em->bm->totvert; BKE_reportf(op->reports, RPT_INFO, "Removed %d vert%s", count, (count == 1) ? "ex" : "ices"); EDBM_update_generic(C, em, TRUE); @@ -2082,6 +2098,7 @@ void MESH_OT_remove_doubles(wmOperatorType *ot) RNA_def_float(ot->srna, "mergedist", 0.0001f, 0.000001f, 50.0f, "Merge Distance", "Minimum distance between elements to merge", 0.00001, 10.0); + RNA_def_boolean(ot->srna, "use_unselected", 1, "Unselected", "Merge selected to other unselected vertices"); } /************************ Vertex Path Operator *************************/ From 65d5a818b52ade5f0d9ac00d1621100bc0f57707 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 20 Aug 2012 07:29:11 +0000 Subject: [PATCH 024/163] quiet unused function warnings in RNA for functions created by macros. --- source/blender/makesrna/intern/rna_mesh.c | 41 ++++++++++++++++++++++- 1 file changed, 40 insertions(+), 1 deletion(-) diff --git a/source/blender/makesrna/intern/rna_mesh.c b/source/blender/makesrna/intern/rna_mesh.c index 4f3e6081fcc..fe5f8e574a0 100644 --- a/source/blender/makesrna/intern/rna_mesh.c +++ b/source/blender/makesrna/intern/rna_mesh.c @@ -1393,6 +1393,46 @@ static PointerRNA rna_Mesh_tessface_uv_texture_new(struct Mesh *me, struct bCont return ptr; } +/* only to quiet warnings */ +static void UNUSED_FUNCTION(rna_mesh_unused)(void) +{ + /* unused functions made by macros */ + (void)rna_Mesh_skin_vertice_index_range; + (void)rna_Mesh_tessface_uv_texture_active_set; + (void)rna_Mesh_tessface_uv_texture_clone_get; + (void)rna_Mesh_tessface_uv_texture_clone_index_get; + (void)rna_Mesh_tessface_uv_texture_clone_index_set; + (void)rna_Mesh_tessface_uv_texture_clone_set; + (void)rna_Mesh_tessface_uv_texture_index_range; + (void)rna_Mesh_tessface_uv_texture_render_get; + (void)rna_Mesh_tessface_uv_texture_render_index_get; + (void)rna_Mesh_tessface_uv_texture_render_index_set; + (void)rna_Mesh_tessface_uv_texture_render_set; + (void)rna_Mesh_tessface_uv_texture_stencil_get; + (void)rna_Mesh_tessface_uv_texture_stencil_index_get; + (void)rna_Mesh_tessface_uv_texture_stencil_index_set; + (void)rna_Mesh_tessface_uv_texture_stencil_set; + (void)rna_Mesh_tessface_vertex_color_active_set; + (void)rna_Mesh_tessface_vertex_color_index_range; + (void)rna_Mesh_tessface_vertex_color_render_get; + (void)rna_Mesh_tessface_vertex_color_render_index_get; + (void)rna_Mesh_tessface_vertex_color_render_index_set; + (void)rna_Mesh_tessface_vertex_color_render_set; + (void)rna_Mesh_uv_layer_render_get; + (void)rna_Mesh_uv_layer_render_index_get; + (void)rna_Mesh_uv_layer_render_index_set; + (void)rna_Mesh_uv_layer_render_set; + (void)rna_Mesh_uv_texture_render_get; + (void)rna_Mesh_uv_texture_render_index_get; + (void)rna_Mesh_uv_texture_render_index_set; + (void)rna_Mesh_uv_texture_render_set; + (void)rna_Mesh_vertex_color_render_get; + (void)rna_Mesh_vertex_color_render_index_get; + (void)rna_Mesh_vertex_color_render_index_set; + (void)rna_Mesh_vertex_color_render_set; + /* end unused function block */ +} + #else static void rna_def_mvert_group(BlenderRNA *brna) @@ -3003,4 +3043,3 @@ void RNA_def_mesh(BlenderRNA *brna) } #endif - From 4a6395cc21bca5f5b24ea4c305f24482a0eb2144 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 20 Aug 2012 10:14:11 +0000 Subject: [PATCH 025/163] fix for own error in bpy.utils.blend_paths() arg parsing. --- source/blender/python/intern/bpy.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/source/blender/python/intern/bpy.c b/source/blender/python/intern/bpy.c index 4d5c02dad68..0f0250fb8d5 100644 --- a/source/blender/python/intern/bpy.c +++ b/source/blender/python/intern/bpy.c @@ -115,12 +115,12 @@ static PyObject *bpy_blend_paths(PyObject *UNUSED(self), PyObject *args, PyObjec PyObject *list; int absolute = FALSE; - int packed = FALSE; - int local = FALSE; + int packed = FALSE; + int local = FALSE; static const char *kwlist[] = {"absolute", "packed", "local", NULL}; - if (!PyArg_ParseTupleAndKeywords(args, kw, "|ii:blend_paths", - (char **)kwlist, &absolute, &packed)) + if (!PyArg_ParseTupleAndKeywords(args, kw, "|iii:blend_paths", + (char **)kwlist, &absolute, &packed, &local)) { return NULL; } From 0ae7286891c400ad4a1a0067964e2a93c7581b8e Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Mon, 20 Aug 2012 10:15:32 +0000 Subject: [PATCH 026/163] Sequencer: Python API for sequence modifiers --- source/blender/blenkernel/BKE_sequencer.h | 4 +- .../blender/blenkernel/intern/seqmodifier.c | 32 ++++++- source/blender/blenkernel/intern/sequencer.c | 9 +- .../space_sequencer/sequencer_modifier.c | 10 +- source/blender/makesrna/RNA_enum_types.h | 1 + source/blender/makesrna/intern/rna_object.c | 2 +- .../blender/makesrna/intern/rna_sequencer.c | 95 +++++++++++++++++-- 7 files changed, 124 insertions(+), 29 deletions(-) diff --git a/source/blender/blenkernel/BKE_sequencer.h b/source/blender/blenkernel/BKE_sequencer.h index d05e065ac15..7a5c45e4800 100644 --- a/source/blender/blenkernel/BKE_sequencer.h +++ b/source/blender/blenkernel/BKE_sequencer.h @@ -384,7 +384,9 @@ typedef struct SequenceModifierTypeInfo { struct SequenceModifierTypeInfo *BKE_sequence_modifier_type_info_get(int type); -void BKE_sequence_modifier_new(struct Sequence *seq, int type); +struct SequenceModifierData *BKE_sequence_modifier_new(struct Sequence *seq, const char *name, int type); +int BKE_sequence_modifier_remove(struct Sequence *seq, struct SequenceModifierData *smd); +void BKE_sequence_modifier_clear(struct Sequence *seq); void BKE_sequence_modifier_free(struct SequenceModifierData *smd); void BKE_sequence_modifier_unique_name(struct Sequence *seq, struct SequenceModifierData *smd); struct SequenceModifierData *BKE_sequence_modifier_find_by_name(struct Sequence *seq, char *name); diff --git a/source/blender/blenkernel/intern/seqmodifier.c b/source/blender/blenkernel/intern/seqmodifier.c index 4157a3a1562..26c2fe03688 100644 --- a/source/blender/blenkernel/intern/seqmodifier.c +++ b/source/blender/blenkernel/intern/seqmodifier.c @@ -417,7 +417,7 @@ SequenceModifierTypeInfo *BKE_sequence_modifier_type_info_get(int type) return modifiersTypes[type]; } -void BKE_sequence_modifier_new(Sequence *seq, int type) +SequenceModifierData *BKE_sequence_modifier_new(Sequence *seq, const char *name, int type) { SequenceModifierData *smd; SequenceModifierTypeInfo *smti = BKE_sequence_modifier_type_info_get(type); @@ -427,7 +427,10 @@ void BKE_sequence_modifier_new(Sequence *seq, int type) smd->type = type; smd->flag |= SEQUENCE_MODIFIER_EXPANDED; - BLI_strncpy(smd->name, smti->name, sizeof(smd->name)); + if (!name || !name[0]) + BLI_strncpy(smd->name, smti->name, sizeof(smd->name)); + else + BLI_strncpy(smd->name, name, sizeof(smd->name)); BLI_addtail(&seq->modifiers, smd); @@ -435,6 +438,31 @@ void BKE_sequence_modifier_new(Sequence *seq, int type) if (smti->init_data) smti->init_data(smd); + + return smd; +} + +int BKE_sequence_modifier_remove(Sequence *seq, SequenceModifierData *smd) +{ + if (BLI_findindex(&seq->modifiers, smd) == -1) + return FALSE; + + BLI_remlink(&seq->modifiers, smd); + BKE_sequence_modifier_free(smd); + + return TRUE; +} + +void BKE_sequence_modifier_clear(Sequence *seq) +{ + SequenceModifierData *smd, *smd_next; + + for (smd = seq->modifiers.first; smd; smd = smd_next) { + smd_next = smd->next; + BKE_sequence_modifier_free(smd); + } + + seq->modifiers.first = seq->modifiers.last = NULL; } void BKE_sequence_modifier_free(SequenceModifierData *smd) diff --git a/source/blender/blenkernel/intern/sequencer.c b/source/blender/blenkernel/intern/sequencer.c index b156d622202..d266fc25589 100644 --- a/source/blender/blenkernel/intern/sequencer.c +++ b/source/blender/blenkernel/intern/sequencer.c @@ -205,14 +205,7 @@ void BKE_sequence_free(Scene *scene, Sequence *seq) } /* free modifiers */ - if (seq->modifiers.first) { - SequenceModifierData *smd, *smd_next; - - for (smd = seq->modifiers.first; smd; smd = smd_next) { - smd_next = smd->next; - BKE_sequence_modifier_free(smd); - } - } + BKE_sequence_modifier_clear(seq); BKE_sequencer_cache_cleanup_sequence(seq); BKE_sequencer_preprocessed_cache_cleanup_sequence(seq); diff --git a/source/blender/editors/space_sequencer/sequencer_modifier.c b/source/blender/editors/space_sequencer/sequencer_modifier.c index 4ae4b995c11..b19d92d67a0 100644 --- a/source/blender/editors/space_sequencer/sequencer_modifier.c +++ b/source/blender/editors/space_sequencer/sequencer_modifier.c @@ -84,7 +84,7 @@ static int strip_modifier_add_exec(bContext *C, wmOperator *op) Sequence *seq = BKE_sequencer_active_get(scene); int type = RNA_enum_get(op->ptr, "type"); - BKE_sequence_modifier_new(seq, type); + BKE_sequence_modifier_new(seq, NULL, type); BKE_sequence_invalidate_cache(scene, seq); WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene); @@ -96,14 +96,6 @@ void SEQUENCER_OT_strip_modifier_add(wmOperatorType *ot) { PropertyRNA *prop; - /* TODO: de-duplicate from RNA */ - static EnumPropertyItem sequence_modifier_type_items[] = { - {seqModifierType_ColorBalance, "COLOR_BALANCE", ICON_NONE, "Color Balance", ""}, - {seqModifierType_Curves, "CURVES", ICON_NONE, "Curves", ""}, - {seqModifierType_HueCorrect,"HUE_CORRECT", ICON_NONE, "Hue Correct", ""}, - {0, NULL, 0, NULL, NULL} - }; - /* identifiers */ ot->name = "Add Strip Modifier"; ot->idname = "SEQUENCER_OT_strip_modifier_add"; diff --git a/source/blender/makesrna/RNA_enum_types.h b/source/blender/makesrna/RNA_enum_types.h index 2fbee1e9e1a..dd230b7b9f8 100644 --- a/source/blender/makesrna/RNA_enum_types.h +++ b/source/blender/makesrna/RNA_enum_types.h @@ -52,6 +52,7 @@ extern EnumPropertyItem region_type_items[]; extern EnumPropertyItem modifier_type_items[]; extern EnumPropertyItem constraint_type_items[]; extern EnumPropertyItem boidrule_type_items[]; +extern EnumPropertyItem sequence_modifier_type_items[]; extern EnumPropertyItem image_type_items[]; extern EnumPropertyItem image_color_mode_items[]; diff --git a/source/blender/makesrna/intern/rna_object.c b/source/blender/makesrna/intern/rna_object.c index e1f45e4de17..6dd75e94398 100644 --- a/source/blender/makesrna/intern/rna_object.c +++ b/source/blender/makesrna/intern/rna_object.c @@ -1768,7 +1768,7 @@ static void rna_def_object_modifiers(BlenderRNA *brna, PropertyRNA *cprop) func = RNA_def_function(srna, "new", "rna_Object_modifier_new"); RNA_def_function_flag(func, FUNC_USE_CONTEXT | FUNC_USE_REPORTS); RNA_def_function_ui_description(func, "Add a new modifier"); - parm = RNA_def_string(func, "name", "Name", 0, "", "New name for the bone"); + parm = RNA_def_string(func, "name", "Name", 0, "", "New name for the modifier"); RNA_def_property_flag(parm, PROP_REQUIRED); /* modifier to add */ parm = RNA_def_enum(func, "type", modifier_type_items, 1, "", "Modifier type to add"); diff --git a/source/blender/makesrna/intern/rna_sequencer.c b/source/blender/makesrna/intern/rna_sequencer.c index fd8195005aa..e14c1db8a76 100644 --- a/source/blender/makesrna/intern/rna_sequencer.c +++ b/source/blender/makesrna/intern/rna_sequencer.c @@ -30,6 +30,7 @@ #include "RNA_access.h" #include "RNA_define.h" +#include "RNA_enum_types.h" #include "rna_internal.h" @@ -58,8 +59,20 @@ typedef struct EffectInfo { int supports_mask; } EffectInfo; +EnumPropertyItem sequence_modifier_type_items[] = { + {seqModifierType_ColorBalance, "COLOR_BALANCE", ICON_NONE, "Color Balance", ""}, + {seqModifierType_Curves, "CURVES", ICON_NONE, "Curves", ""}, + {seqModifierType_HueCorrect,"HUE_CORRECT", ICON_NONE, "Hue Correct", ""}, + {0, NULL, 0, NULL, NULL} +}; + #ifdef RNA_RUNTIME +#include "BKE_report.h" + +#include "WM_api.h" +#include "WM_types.h" + typedef struct SequenceSearchData { Sequence *seq; void *data; @@ -961,6 +974,52 @@ static int rna_SequenceModifier_otherSequence_poll(PointerRNA *ptr, PointerRNA v return TRUE; } +static SequenceModifierData *rna_Sequence_modifier_new(Sequence *seq, bContext *C, ReportList *reports, const char *name, int type) +{ + if (!BKE_sequence_supports_modifiers(seq)) { + BKE_report(reports, RPT_ERROR, "Sequence type does not support modifiers"); + + return NULL; + } + else { + Scene *scene = CTX_data_scene(C); + SequenceModifierData *smd; + + smd = BKE_sequence_modifier_new(seq, name, type); + + BKE_sequence_invalidate_cache_for_modifier(scene, seq); + + WM_main_add_notifier(NC_SCENE | ND_SEQUENCER, NULL); + + return smd; + } +} + +static void rna_Sequence_modifier_remove(Sequence *seq, bContext *C, ReportList *reports, SequenceModifierData *smd) +{ + Scene *scene = CTX_data_scene(C); + + if (BKE_sequence_modifier_remove(seq, smd)) { + BKE_sequence_invalidate_cache_for_modifier(scene, seq); + + WM_main_add_notifier(NC_SCENE | ND_SEQUENCER, NULL); + } + else { + BKE_report(reports, RPT_ERROR, "Modifier was not found in the stack"); + } +} + +static void rna_Sequence_modifier_clear(Sequence *seq, bContext *C) +{ + Scene *scene = CTX_data_scene(C); + + BKE_sequence_modifier_clear(seq); + + BKE_sequence_invalidate_cache_for_modifier(scene, seq); + + WM_main_add_notifier(NC_SCENE | ND_SEQUENCER, NULL); +} + #else static void rna_def_strip_element(BlenderRNA *brna) @@ -1210,12 +1269,39 @@ static void rna_def_sequence_modifiers(BlenderRNA *brna, PropertyRNA *cprop) { StructRNA *srna; + FunctionRNA *func; + PropertyRNA *parm; + RNA_def_property_srna(cprop, "SequenceModifiers"); srna = RNA_def_struct(brna, "SequenceModifiers", NULL); RNA_def_struct_sdna(srna, "Sequence"); RNA_def_struct_ui_text(srna, "Strip Modifiers", "Collection of strip modifiers"); - /* TODO: implement new/remove/clear methods for modifier stack */ + /* add modifier */ + func = RNA_def_function(srna, "new", "rna_Sequence_modifier_new"); + RNA_def_function_flag(func, FUNC_USE_CONTEXT | FUNC_USE_REPORTS); + RNA_def_function_ui_description(func, "Add a new modifier"); + parm = RNA_def_string(func, "name", "Name", 0, "", "New name for the modifier"); + RNA_def_property_flag(parm, PROP_REQUIRED); + /* modifier to add */ + parm = RNA_def_enum(func, "type", sequence_modifier_type_items, seqModifierType_ColorBalance, "", "Modifier type to add"); + RNA_def_property_flag(parm, PROP_REQUIRED); + /* return type */ + parm = RNA_def_pointer(func, "modifier", "SequenceModifier", "", "Newly created modifier"); + RNA_def_function_return(func, parm); + + /* remove modifier */ + func = RNA_def_function(srna, "remove", "rna_Sequence_modifier_remove"); + RNA_def_function_flag(func, FUNC_USE_CONTEXT | FUNC_USE_REPORTS); + RNA_def_function_ui_description(func, "Remove an existing modifier from the sequence"); + /* modifier to remove */ + parm = RNA_def_pointer(func, "modifier", "SequenceModifier", "", "Modifier to remove"); + RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL); + + /* clear all modifiers */ + func = RNA_def_function(srna, "clear", "rna_Sequence_modifier_clear"); + RNA_def_function_flag(func, FUNC_USE_CONTEXT); + RNA_def_function_ui_description(func, "Remove all modifiers from the sequence"); } static void rna_def_sequence(BlenderRNA *brna) @@ -2130,13 +2216,6 @@ static void rna_def_modifier(BlenderRNA *brna) StructRNA *srna; PropertyRNA *prop; - static EnumPropertyItem sequence_modifier_type_items[] = { - {seqModifierType_ColorBalance, "COLOR_BALANCE", ICON_NONE, "Color Balance", ""}, - {seqModifierType_Curves, "CURVES", ICON_NONE, "Curves", ""}, - {seqModifierType_HueCorrect,"HUE_CORRECT", ICON_NONE, "Hue Correct", ""}, - {0, NULL, 0, NULL, NULL} - }; - static const EnumPropertyItem mask_input_type_items[] = { {SEQUENCE_MASK_INPUT_STRIP, "STRIP", 0, "Strip", "Use sequencer strip as mask input"}, {SEQUENCE_MASK_INPUT_ID, "ID", 0, "Mask", "Use mask ID as mask input"}, From ad647b2767ea8b5cdc24cb3fae1173eca8a0da9b Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Mon, 20 Aug 2012 10:56:19 +0000 Subject: [PATCH 027/163] Sequencer: skip adding ImBuf to cache when it failed to render --- source/blender/blenkernel/intern/sequencer.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/source/blender/blenkernel/intern/sequencer.c b/source/blender/blenkernel/intern/sequencer.c index d266fc25589..3699f802c91 100644 --- a/source/blender/blenkernel/intern/sequencer.c +++ b/source/blender/blenkernel/intern/sequencer.c @@ -2567,7 +2567,8 @@ static ImBuf *seq_render_strip(SeqRenderData context, Sequence *seq, float cfra) ibuf = do_render_strip_uncached(context, seq, cfra); - BKE_sequencer_preprocessed_cache_put(context, seq, cfra, SEQ_STRIPELEM_IBUF, ibuf); + if (ibuf) + BKE_sequencer_preprocessed_cache_put(context, seq, cfra, SEQ_STRIPELEM_IBUF, ibuf); } } From 0f6a6c7499f0c1fa509355c5967f30a42cfa771e Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 20 Aug 2012 13:51:25 +0000 Subject: [PATCH 028/163] fix for crash pasting nodes into a node tree when the ID pointer is lost. also fix for ID user count on paste which wasn't increasing. --- source/blender/blenkernel/BKE_node.h | 1 + source/blender/blenkernel/intern/node.c | 98 ++++++++++++++++++- source/blender/editors/space_node/node_edit.c | 25 ++++- 3 files changed, 119 insertions(+), 5 deletions(-) diff --git a/source/blender/blenkernel/BKE_node.h b/source/blender/blenkernel/BKE_node.h index 61845619452..c45afbe77a9 100644 --- a/source/blender/blenkernel/BKE_node.h +++ b/source/blender/blenkernel/BKE_node.h @@ -388,6 +388,7 @@ void nodeSocketSetType(struct bNodeSocket *sock, int type); /* Node Clipboard */ void BKE_node_clipboard_init(struct bNodeTree *ntree); void BKE_node_clipboard_clear(void); +int BKE_node_clipboard_validate(void); void BKE_node_clipboard_add_node(struct bNode *node); void BKE_node_clipboard_add_link(struct bNodeLink *link); const struct ListBase *BKE_node_clipboard_get_nodes(void); diff --git a/source/blender/blenkernel/intern/node.c b/source/blender/blenkernel/intern/node.c index 7cee9626c3f..dc2f3a1a2fa 100644 --- a/source/blender/blenkernel/intern/node.c +++ b/source/blender/blenkernel/intern/node.c @@ -1425,13 +1425,37 @@ void nodeSocketSetType(bNodeSocket *sock, int type) /* ************** Node Clipboard *********** */ +#define USE_NODE_CB_VALIDATE + +#ifdef USE_NODE_CB_VALIDATE +/** + * This data structure is to validate the node on creation, + * otherwise we may reference missing data. + * + * Currently its only used for ID's, but nodes may one day + * referene other pointers which need validation. + */ +typedef struct bNodeClipboardExtraInfo { + struct bNodeClipboardExtraInfo *next, *prev; + ID *id; + char id_name[MAX_ID_NAME]; + char library_name[FILE_MAX]; +} bNodeClipboardExtraInfo; +#endif /* USE_NODE_CB_VALIDATE */ + + typedef struct bNodeClipboard { ListBase nodes; + +#ifdef USE_NODE_CB_VALIDATE + ListBase nodes_extra_info; +#endif + ListBase links; int type; } bNodeClipboard; -bNodeClipboard node_clipboard; +bNodeClipboard node_clipboard = {{0}}; void BKE_node_clipboard_init(struct bNodeTree *ntree) { @@ -1454,11 +1478,83 @@ void BKE_node_clipboard_clear(void) nodeFreeNode(NULL, node); } node_clipboard.nodes.first = node_clipboard.nodes.last = NULL; + +#ifdef USE_NODE_CB_VALIDATE + BLI_freelistN(&node_clipboard.nodes_extra_info); +#endif +} + +/* return FALSE when one or more ID's are lost */ +int BKE_node_clipboard_validate(void) +{ + int ok = TRUE; + +#ifdef USE_NODE_CB_VALIDATE + bNodeClipboardExtraInfo *node_info; + bNode *node; + + + /* lists must be aligned */ + BLI_assert(BLI_countlist(&node_clipboard.nodes) == + BLI_countlist(&node_clipboard.nodes_extra_info)); + + for (node = node_clipboard.nodes.first, node_info = node_clipboard.nodes_extra_info.first; + node; + node = node->next, node_info = node_info->next) + { + /* validate the node against the stored node info */ + + /* re-assign each loop since we may clear, + * open a new file where the ID is valid, and paste again */ + node->id = node_info->id; + + /* currently only validate the ID */ + if (node->id) { + ListBase *lb = which_libbase(G.main, GS(node_info->id_name)); + BLI_assert(lb != NULL); + + if (BLI_findindex(lb, node_info->id) == -1) { + /* may assign NULL */ + node->id = BLI_findstring(lb, node_info->id_name + 2, offsetof(ID, name) + 2); + printf("%s %p\n", node_info->id_name, node->id); + if (node->id == NULL) { + ok = FALSE; + } + } + } + } +#endif /* USE_NODE_CB_VALIDATE */ + + return ok; } void BKE_node_clipboard_add_node(bNode *node) { +#ifdef USE_NODE_CB_VALIDATE + /* add extra info */ + bNodeClipboardExtraInfo *node_info = MEM_mallocN(sizeof(bNodeClipboardExtraInfo), STRINGIFY(bNodeClipboardExtraInfo)); + + node_info->id = node->id; + if (node->id) { + BLI_strncpy(node_info->id_name, node->id->name, sizeof(node_info->id_name)); + if (node->id->lib) { + BLI_strncpy(node_info->library_name, node->id->lib->filepath, sizeof(node_info->library_name)); + } + else { + node_info->library_name[0] = '\0'; + } + } + else { + node_info->id_name[0] = '\0'; + node_info->library_name[0] = '\0'; + } + BLI_addtail(&node_clipboard.nodes_extra_info, node_info); + /* end extra info */ +#endif /* USE_NODE_CB_VALIDATE */ + + /* add node */ BLI_addtail(&node_clipboard.nodes, node); + } void BKE_node_clipboard_add_link(bNodeLink *link) diff --git a/source/blender/editors/space_node/node_edit.c b/source/blender/editors/space_node/node_edit.c index e4fc19fbd08..6d01fc83647 100644 --- a/source/blender/editors/space_node/node_edit.c +++ b/source/blender/editors/space_node/node_edit.c @@ -2019,10 +2019,13 @@ static int node_clipboard_paste_exec(bContext *C, wmOperator *op) bNodeTree *ntree = snode->edittree; bNode *gnode = node_tree_get_editgroup(snode->nodetree); float gnode_x = 0.0f, gnode_y = 0.0f; + const ListBase *clipboard_nodes_lb; + const ListBase *clipboard_links_lb; bNode *node; bNodeLink *link; int num_nodes; float centerx, centery; + int is_clipboard_valid; if (BKE_node_clipboard_get_type() != ntree->type) { BKE_report(op->reports, RPT_ERROR, "Clipboard nodes are an incompatible type"); @@ -2038,10 +2041,17 @@ static int node_clipboard_paste_exec(bContext *C, wmOperator *op) if (gnode) nodeToView(gnode, 0.0f, 0.0f, &gnode_x, &gnode_y); + + /* validate pointers in the clipboard */ + is_clipboard_valid = BKE_node_clipboard_validate(); + + clipboard_nodes_lb = BKE_node_clipboard_get_nodes(); + clipboard_links_lb = BKE_node_clipboard_get_links(); + /* calculate "barycenter" for placing on mouse cursor */ num_nodes = 0; centerx = centery = 0.0f; - for (node = BKE_node_clipboard_get_nodes()->first; node; node = node->next) { + for (node = clipboard_nodes_lb->first; node; node = node->next) { ++num_nodes; centerx += 0.5f * (node->totr.xmin + node->totr.xmax); centery += 0.5f * (node->totr.ymin + node->totr.ymax); @@ -2050,15 +2060,18 @@ static int node_clipboard_paste_exec(bContext *C, wmOperator *op) centery /= num_nodes; /* copy nodes from clipboard */ - for (node = BKE_node_clipboard_get_nodes()->first; node; node = node->next) { + for (node = clipboard_nodes_lb->first; node; node = node->next) { bNode *new_node = nodeCopyNode(ntree, node); + /* needed since nodeCopyNode() doesn't increase ID's */ + id_us_plus(node->id); + /* pasted nodes are selected */ node_select(new_node); } /* reparent copied nodes */ - for (node = BKE_node_clipboard_get_nodes()->first; node; node = node->next) { + for (node = clipboard_nodes_lb->first; node; node = node->next) { bNode *new_node = node->new_node; if (new_node->parent) new_node->parent = new_node->parent->new_node; @@ -2071,7 +2084,7 @@ static int node_clipboard_paste_exec(bContext *C, wmOperator *op) } } - for (link = BKE_node_clipboard_get_links()->first; link; link = link->next) { + for (link = clipboard_links_lb->first; link; link = link->next) { nodeAddLink(ntree, link->fromnode->new_node, link->fromsock->new_sock, link->tonode->new_node, link->tosock->new_sock); } @@ -2081,6 +2094,10 @@ static int node_clipboard_paste_exec(bContext *C, wmOperator *op) snode_notify(C, snode); snode_dag_update(C, snode); + if (is_clipboard_valid == FALSE) { + BKE_report(op->reports, RPT_ERROR, "Some nodes ID references could not be found"); + } + return OPERATOR_FINISHED; } From 6c74d1147e56b36ad682d4bdeaed68d77166e776 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 20 Aug 2012 13:59:19 +0000 Subject: [PATCH 029/163] minor cleanup to node pasting. --- source/blender/blenkernel/intern/node.c | 2 +- source/blender/editors/space_node/node_edit.c | 55 ++++++++++--------- 2 files changed, 31 insertions(+), 26 deletions(-) diff --git a/source/blender/blenkernel/intern/node.c b/source/blender/blenkernel/intern/node.c index dc2f3a1a2fa..62e80645a35 100644 --- a/source/blender/blenkernel/intern/node.c +++ b/source/blender/blenkernel/intern/node.c @@ -1516,7 +1516,7 @@ int BKE_node_clipboard_validate(void) if (BLI_findindex(lb, node_info->id) == -1) { /* may assign NULL */ node->id = BLI_findstring(lb, node_info->id_name + 2, offsetof(ID, name) + 2); - printf("%s %p\n", node_info->id_name, node->id); + if (node->id == NULL) { ok = FALSE; } diff --git a/source/blender/editors/space_node/node_edit.c b/source/blender/editors/space_node/node_edit.c index 6d01fc83647..245c9cefd1f 100644 --- a/source/blender/editors/space_node/node_edit.c +++ b/source/blender/editors/space_node/node_edit.c @@ -2018,46 +2018,55 @@ static int node_clipboard_paste_exec(bContext *C, wmOperator *op) SpaceNode *snode = CTX_wm_space_node(C); bNodeTree *ntree = snode->edittree; bNode *gnode = node_tree_get_editgroup(snode->nodetree); - float gnode_x = 0.0f, gnode_y = 0.0f; + float gnode_center[2]; const ListBase *clipboard_nodes_lb; const ListBase *clipboard_links_lb; bNode *node; bNodeLink *link; int num_nodes; - float centerx, centery; + float center[2]; int is_clipboard_valid; + /* validate pointers in the clipboard */ + is_clipboard_valid = BKE_node_clipboard_validate(); + clipboard_nodes_lb = BKE_node_clipboard_get_nodes(); + clipboard_links_lb = BKE_node_clipboard_get_links(); + + if (clipboard_nodes_lb->first == NULL) { + BKE_report(op->reports, RPT_ERROR, "Clipboard is empty"); + return OPERATOR_CANCELLED; + } + if (BKE_node_clipboard_get_type() != ntree->type) { BKE_report(op->reports, RPT_ERROR, "Clipboard nodes are an incompatible type"); return OPERATOR_CANCELLED; } + /* only warn */ + if (is_clipboard_valid == FALSE) { + BKE_report(op->reports, RPT_WARNING, "Some nodes references could not be restored, will be left empty"); + } + ED_preview_kill_jobs(C); /* deselect old nodes */ node_deselect_all(snode); /* get group node offset */ - if (gnode) - nodeToView(gnode, 0.0f, 0.0f, &gnode_x, &gnode_y); - - - /* validate pointers in the clipboard */ - is_clipboard_valid = BKE_node_clipboard_validate(); - - clipboard_nodes_lb = BKE_node_clipboard_get_nodes(); - clipboard_links_lb = BKE_node_clipboard_get_links(); + if (gnode) { + nodeToView(gnode, 0.0f, 0.0f, &gnode_center[0], &gnode_center[1]); + } + else { + zero_v2(gnode_center); + } /* calculate "barycenter" for placing on mouse cursor */ - num_nodes = 0; - centerx = centery = 0.0f; - for (node = clipboard_nodes_lb->first; node; node = node->next) { - ++num_nodes; - centerx += 0.5f * (node->totr.xmin + node->totr.xmax); - centery += 0.5f * (node->totr.ymin + node->totr.ymax); + zero_v2(center); + for (node = clipboard_nodes_lb->first, num_nodes = 0; node; node = node->next, num_nodes++) { + center[0] += 0.5f * (node->totr.xmin + node->totr.xmax); + center[1] += 0.5f * (node->totr.ymin + node->totr.ymax); } - centerx /= num_nodes; - centery /= num_nodes; + mul_v2_fl(center, 1.0 / num_nodes); /* copy nodes from clipboard */ for (node = clipboard_nodes_lb->first; node; node = node->next) { @@ -2079,8 +2088,8 @@ static int node_clipboard_paste_exec(bContext *C, wmOperator *op) /* place nodes around the mouse cursor. child nodes locations are relative to parent */ if (!new_node->parent) { - new_node->locx += snode->cursor[0] - centerx - gnode_x; - new_node->locy += snode->cursor[1] - centery - gnode_y; + new_node->locx += snode->cursor[0] - center[0] - gnode_center[0]; + new_node->locy += snode->cursor[1] - center[1] - gnode_center[1]; } } @@ -2094,10 +2103,6 @@ static int node_clipboard_paste_exec(bContext *C, wmOperator *op) snode_notify(C, snode); snode_dag_update(C, snode); - if (is_clipboard_valid == FALSE) { - BKE_report(op->reports, RPT_ERROR, "Some nodes ID references could not be found"); - } - return OPERATOR_FINISHED; } From 831eaf2d7feb63ee6df55a2b00e1d76f793c0a5c Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Mon, 20 Aug 2012 15:14:23 +0000 Subject: [PATCH 030/163] Sequencer: fix regression introduced in own previous commit Invalidate preprocessed cache when when global sequencer cache is begin invalidated. This is needed so scene would be rendered with a proper settings, not taken from preprocess cache. --- source/blender/blenkernel/intern/seqcache.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/source/blender/blenkernel/intern/seqcache.c b/source/blender/blenkernel/intern/seqcache.c index d79f23e8979..57db188472c 100644 --- a/source/blender/blenkernel/intern/seqcache.c +++ b/source/blender/blenkernel/intern/seqcache.c @@ -68,6 +68,7 @@ static struct MovieCache *moviecache = NULL; static struct SeqPreprocessCache *preprocess_cache = NULL; static void preprocessed_cache_destruct(void); +static void preprocessed_cache_clean(void); static int seq_cmp_render_data(const SeqRenderData *a, const SeqRenderData *b) { @@ -191,6 +192,8 @@ void BKE_sequencer_cache_cleanup(void) IMB_moviecache_free(moviecache); moviecache = IMB_moviecache_create("seqcache", sizeof(SeqCacheKey), seqcache_hashhash, seqcache_hashcmp); } + + preprocessed_cache_clean(); } static int seqcache_key_check_seq(void *userkey, void *userdata) From 26f073b327ac31d683e1719ce8371b6e28bf01d6 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 20 Aug 2012 15:29:02 +0000 Subject: [PATCH 031/163] macros for rectangle center and size --- source/blender/blenfont/intern/blf_font.c | 6 +++--- source/blender/blenfont/intern/blf_glyph.c | 2 +- .../blenkernel/intern/mask_rasterize.c | 4 ++-- source/blender/blenlib/BLI_rect.h | 9 +++++++++ source/blender/blenlib/intern/rct.c | 8 ++++---- .../editors/animation/anim_channels_defines.c | 6 +++--- .../blender/editors/animation/anim_markers.c | 3 +-- source/blender/editors/gpencil/gpencil_edit.c | 4 ++-- .../blender/editors/gpencil/gpencil_paint.c | 4 ++-- source/blender/editors/interface/interface.c | 12 +++++------ .../editors/interface/interface_draw.c | 8 ++++---- .../editors/interface/interface_handlers.c | 4 ++-- .../editors/interface/interface_regions.c | 6 +++--- .../editors/interface/interface_widgets.c | 16 +++++++-------- source/blender/editors/interface/view2d.c | 8 ++++---- source/blender/editors/interface/view2d_ops.c | 12 +++++------ source/blender/editors/screen/area.c | 20 +++++++++---------- .../editors/space_logic/logic_buttons.c | 8 ++++---- source/blender/editors/space_node/drawnode.c | 6 +++--- source/blender/editors/space_node/node_edit.c | 4 ++-- .../editors/space_sequencer/sequencer_edit.c | 2 +- source/blender/editors/space_text/text_ops.c | 4 ++-- .../editors/space_view3d/view3d_edit.c | 8 ++++---- .../editors/space_view3d/view3d_select.c | 5 ++--- .../editors/transform/transform_conversions.c | 4 ++-- .../blender/render/intern/source/pipeline.c | 9 +++++---- .../render/intern/source/render_result.c | 9 +++++---- .../blender/windowmanager/intern/wm_gesture.c | 4 ++-- .../blender/windowmanager/intern/wm_window.c | 8 ++++---- 29 files changed, 106 insertions(+), 97 deletions(-) diff --git a/source/blender/blenfont/intern/blf_font.c b/source/blender/blenfont/intern/blf_font.c index dcefcc68d23..751c2f5043b 100644 --- a/source/blender/blenfont/intern/blf_font.c +++ b/source/blender/blenfont/intern/blf_font.c @@ -425,8 +425,8 @@ void blf_font_width_and_height(FontBLF *font, const char *str, float *width, flo } blf_font_boundbox(font, str, &box); - *width = ((box.xmax - box.xmin) * xa); - *height = ((box.ymax - box.ymin) * ya); + *width = (BLI_RCT_SIZE_X(&box) * xa); + *height = (BLI_RCT_SIZE_Y(&box) * ya); } float blf_font_width(FontBLF *font, const char *str) @@ -440,7 +440,7 @@ float blf_font_width(FontBLF *font, const char *str) xa = 1.0f; blf_font_boundbox(font, str, &box); - return (box.xmax - box.xmin) * xa; + return BLI_RCT_SIZE_X(&box) * xa; } float blf_font_height(FontBLF *font, const char *str) diff --git a/source/blender/blenfont/intern/blf_glyph.c b/source/blender/blenfont/intern/blf_glyph.c index 39945bf19b0..3e871fefff8 100644 --- a/source/blender/blenfont/intern/blf_glyph.c +++ b/source/blender/blenfont/intern/blf_glyph.c @@ -412,7 +412,7 @@ int blf_glyph_render(FontBLF *font, GlyphBLF *g, float x, float y) g->uv[1][1] = ((float)(g->yoff + g->height)) / ((float)gc->p2_height); /* update the x offset for the next glyph. */ - gc->x_offs += (int)(g->box.xmax - g->box.xmin + gc->pad); + gc->x_offs += (int)(BLI_RCT_SIZE_X(&g->box) + gc->pad); gc->rem_glyphs--; g->build_tex = 1; diff --git a/source/blender/blenkernel/intern/mask_rasterize.c b/source/blender/blenkernel/intern/mask_rasterize.c index 1fde1168999..6f7cf43be69 100644 --- a/source/blender/blenkernel/intern/mask_rasterize.c +++ b/source/blender/blenkernel/intern/mask_rasterize.c @@ -370,8 +370,8 @@ static void layer_bucket_init(MaskRasterLayer *layer, const float pixel_size) { MemArena *arena = BLI_memarena_new(1 << 16, __func__); - const float bucket_dim_x = layer->bounds.xmax - layer->bounds.xmin; - const float bucket_dim_y = layer->bounds.ymax - layer->bounds.ymin; + const float bucket_dim_x = BLI_RCT_SIZE_X(&layer->bounds); + const float bucket_dim_y = BLI_RCT_SIZE_Y(&layer->bounds); layer->buckets_x = (bucket_dim_x / pixel_size) / (float)BUCKET_PIXELS_PER_CELL; layer->buckets_y = (bucket_dim_y / pixel_size) / (float)BUCKET_PIXELS_PER_CELL; diff --git a/source/blender/blenlib/BLI_rect.h b/source/blender/blenlib/BLI_rect.h index d6579afcd0d..43639b141e1 100644 --- a/source/blender/blenlib/BLI_rect.h +++ b/source/blender/blenlib/BLI_rect.h @@ -75,6 +75,15 @@ void BLI_rctf_rcti_copy(struct rctf *dst, const struct rcti *src); void print_rctf(const char *str, const struct rctf *rect); void print_rcti(const char *str, const struct rcti *rect); +#define BLI_RCT_SIZE_X(rct) ((rct)->xmax - (rct)->xmin) +#define BLI_RCT_SIZE_Y(rct) ((rct)->ymax - (rct)->ymin) + +#define BLI_RCT_CENTER_X(rct) (((rct)->xmin + (rct)->xmax) / 2) +#define BLI_RCT_CENTER_Y(rct) (((rct)->ymin + (rct)->ymax) / 2) + +#define BLI_RCT_CENTER_X_FL(rct) ((float)((rct)->xmin + (rct)->xmax) / 2.0f) +#define BLI_RCT_CENTER_Y_FL(rct) ((float)((rct)->ymin + (rct)->ymax) / 2.0f) + #ifdef __cplusplus } #endif diff --git a/source/blender/blenlib/intern/rct.c b/source/blender/blenlib/intern/rct.c index 9c65c26c72b..61408610520 100644 --- a/source/blender/blenlib/intern/rct.c +++ b/source/blender/blenlib/intern/rct.c @@ -252,8 +252,8 @@ void BLI_rctf_translate(rctf *rect, float x, float y) /* change width & height around the central location */ void BLI_rcti_resize(rcti *rect, int x, int y) { - rect->xmin = rect->xmax = (rect->xmax + rect->xmin) / 2; - rect->ymin = rect->ymax = (rect->ymax + rect->ymin) / 2; + rect->xmin = rect->xmax = BLI_RCT_CENTER_X(rect); + rect->ymin = rect->ymax = BLI_RCT_CENTER_Y(rect); rect->xmin -= x / 2; rect->ymin -= y / 2; rect->xmax = rect->xmin + x; @@ -262,8 +262,8 @@ void BLI_rcti_resize(rcti *rect, int x, int y) void BLI_rctf_resize(rctf *rect, float x, float y) { - rect->xmin = rect->xmax = (rect->xmax + rect->xmin) * 0.5f; - rect->ymin = rect->ymax = (rect->ymax + rect->ymin) * 0.5f; + rect->xmin = rect->xmax = BLI_RCT_CENTER_X(rect); + rect->ymin = rect->ymax = BLI_RCT_CENTER_Y(rect); rect->xmin -= x * 0.5f; rect->ymin -= y * 0.5f; rect->xmax = rect->xmin + x; diff --git a/source/blender/editors/animation/anim_channels_defines.c b/source/blender/editors/animation/anim_channels_defines.c index 837230d9719..16168888573 100644 --- a/source/blender/editors/animation/anim_channels_defines.c +++ b/source/blender/editors/animation/anim_channels_defines.c @@ -3067,9 +3067,9 @@ void ANIM_channel_draw(bAnimContext *ac, bAnimListElem *ale, float yminc, float break; } } - + /* check if there's enough space for the toggles if the sliders are drawn too */ - if (!(draw_sliders) || ((v2d->mask.xmax - v2d->mask.xmin) > ACHANNEL_BUTTON_WIDTH / 2) ) { + if (!(draw_sliders) || (BLI_RCT_SIZE_X(&v2d->mask) > ACHANNEL_BUTTON_WIDTH / 2) ) { /* protect... */ if (acf->has_setting(ac, ale, ACHANNEL_SETTING_PROTECT)) offset += ICON_WIDTH; @@ -3461,7 +3461,7 @@ void ANIM_channel_draw_widgets(bContext *C, bAnimContext *ac, bAnimListElem *ale } /* check if there's enough space for the toggles if the sliders are drawn too */ - if (!(draw_sliders) || ((v2d->mask.xmax - v2d->mask.xmin) > ACHANNEL_BUTTON_WIDTH / 2) ) { + if (!(draw_sliders) || (BLI_RCT_SIZE_X(&v2d->mask) > ACHANNEL_BUTTON_WIDTH / 2) ) { /* protect... */ if (acf->has_setting(ac, ale, ACHANNEL_SETTING_PROTECT)) { offset += ICON_WIDTH; diff --git a/source/blender/editors/animation/anim_markers.c b/source/blender/editors/animation/anim_markers.c index a8daf852dda..c75024a469e 100644 --- a/source/blender/editors/animation/anim_markers.c +++ b/source/blender/editors/animation/anim_markers.c @@ -773,8 +773,7 @@ static int ed_marker_move_modal(bContext *C, wmOperator *op, wmEvent *evt) if (hasNumInput(&mm->num)) break; - dx = v2d->mask.xmax - v2d->mask.xmin; - dx = (v2d->cur.xmax - v2d->cur.xmin) / dx; + dx = BLI_RCT_SIZE_X(&v2d->cur) / BLI_RCT_SIZE_X(&v2d->mask); if (evt->x != mm->evtx) { /* XXX maybe init for first time */ int a, offs, totmark = 0; diff --git a/source/blender/editors/gpencil/gpencil_edit.c b/source/blender/editors/gpencil/gpencil_edit.c index 949f92c68e9..5d67b63af18 100644 --- a/source/blender/editors/gpencil/gpencil_edit.c +++ b/source/blender/editors/gpencil/gpencil_edit.c @@ -422,8 +422,8 @@ static void gp_strokepoint_convertcoords(bContext *C, bGPDstroke *gps, bGPDspoin } else { if (subrect) { - mvalf[0] = (((float)pt->x / 100.0f) * (subrect->xmax - subrect->xmin)) + subrect->xmin; - mvalf[1] = (((float)pt->y / 100.0f) * (subrect->ymax - subrect->ymin)) + subrect->ymin; + mvalf[0] = (((float)pt->x / 100.0f) * BLI_RCT_SIZE_X(subrect)) + subrect->xmin; + mvalf[1] = (((float)pt->y / 100.0f) * BLI_RCT_SIZE_Y(subrect)) + subrect->ymin; } else { mvalf[0] = (float)pt->x / 100.0f * ar->winx; diff --git a/source/blender/editors/gpencil/gpencil_paint.c b/source/blender/editors/gpencil/gpencil_paint.c index d98f4891dc5..1f317fa4f04 100644 --- a/source/blender/editors/gpencil/gpencil_paint.c +++ b/source/blender/editors/gpencil/gpencil_paint.c @@ -300,8 +300,8 @@ static void gp_stroke_convertcoords(tGPsdata *p, const int mval[2], float out[3] out[1] = (float)(mval[1]) / (float)(p->ar->winy) * 100; } else { /* camera view, use subrect */ - out[0] = ((mval[0] - p->subrect->xmin) / ((p->subrect->xmax - p->subrect->xmin))) * 100; - out[1] = ((mval[1] - p->subrect->ymin) / ((p->subrect->ymax - p->subrect->ymin))) * 100; + out[0] = ((mval[0] - p->subrect->xmin) / BLI_RCT_SIZE_X(p->subrect)) * 100; + out[1] = ((mval[1] - p->subrect->ymin) / BLI_RCT_SIZE_Y(p->subrect)) * 100; } } } diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c index 62b26f5a8c1..f728e999667 100644 --- a/source/blender/editors/interface/interface.c +++ b/source/blender/editors/interface/interface.c @@ -300,8 +300,8 @@ static void ui_centered_bounds_block(const bContext *C, uiBlock *block) ui_bounds_block(block); - width = block->rect.xmax - block->rect.xmin; - height = block->rect.ymax - block->rect.ymin; + width = BLI_RCT_SIZE_X(&block->rect); + height = BLI_RCT_SIZE_Y(&block->rect); startx = (xmax * 0.5f) - (width * 0.5f); starty = (ymax * 0.5f) - (height * 0.5f); @@ -488,10 +488,10 @@ static void ui_draw_linkline(uiLinkLine *line, int highlightActiveLines) if (line->from == NULL || line->to == NULL) return; - rect.xmin = (line->from->rect.xmin + line->from->rect.xmax) / 2.0f; - rect.ymin = (line->from->rect.ymin + line->from->rect.ymax) / 2.0f; - rect.xmax = (line->to->rect.xmin + line->to->rect.xmax) / 2.0f; - rect.ymax = (line->to->rect.ymin + line->to->rect.ymax) / 2.0f; + rect.xmin = BLI_RCT_CENTER_X(&line->from->rect); + rect.ymin = BLI_RCT_CENTER_Y(&line->from->rect); + rect.xmax = BLI_RCT_CENTER_X(&line->to->rect); + rect.ymax = BLI_RCT_CENTER_Y(&line->to->rect); if (line->flag & UI_SELECT) glColor3ub(100, 100, 100); diff --git a/source/blender/editors/interface/interface_draw.c b/source/blender/editors/interface/interface_draw.c index 41a827bbda9..109978780c2 100644 --- a/source/blender/editors/interface/interface_draw.c +++ b/source/blender/editors/interface/interface_draw.c @@ -439,8 +439,8 @@ void ui_draw_but_IMAGE(ARegion *UNUSED(ar), uiBut *but, uiWidgetColors *UNUSED(w //glColor4f(1.0, 0.f, 0.f, 1.f); //fdrawbox(rect->xmin, rect->ymin, rect->xmax, rect->ymax) - w = (rect->xmax - rect->xmin); - h = (rect->ymax - rect->ymin); + w = BLI_RCT_SIZE_X(rect); + h = BLI_RCT_SIZE_Y(rect); /* prevent drawing outside widget area */ glGetIntegerv(GL_SCISSOR_BOX, scissor); glScissor(ar->winrct.xmin + rect->xmin, ar->winrct.ymin + rect->ymin, w, h); @@ -732,8 +732,8 @@ void ui_draw_but_HISTOGRAM(ARegion *ar, uiBut *but, uiWidgetColors *UNUSED(wcol) rect.ymin = (float)recti->ymin + SCOPE_RESIZE_PAD + 2; rect.ymax = (float)recti->ymax - 1; - w = rect.xmax - rect.xmin; - h = (rect.ymax - rect.ymin) * hist->ymax; + w = BLI_RCT_SIZE_X(&rect); + h = BLI_RCT_SIZE_Y(&rect) * hist->ymax; glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c index 4010274f687..50b6de5ce46 100644 --- a/source/blender/editors/interface/interface_handlers.c +++ b/source/blender/editors/interface/interface_handlers.c @@ -693,7 +693,7 @@ static int ui_but_mouse_inside_icon(uiBut *but, ARegion *ar, wmEvent *event) rect.xmax = rect.xmin + (rect.ymax - rect.ymin); } else { - int delta = (rect.xmax - rect.xmin) - (rect.ymax - rect.ymin); + int delta = BLI_RCT_SIZE_X(&rect) - BLI_RCT_SIZE_Y(&rect); rect.xmin += delta / 2; rect.xmax -= delta / 2; } @@ -2763,7 +2763,7 @@ static int ui_do_but_SLI(bContext *C, uiBlock *block, uiBut *but, uiHandleButton } /* alt-click on sides to get "arrows" like in NUM buttons, and match wheel usage above */ else if (event->type == LEFTMOUSE && event->alt) { - int halfpos = (but->rect.xmin + but->rect.xmax) / 2; + int halfpos = BLI_RCT_CENTER_X(&but->rect); click = 2; if (mx < halfpos) mx = but->rect.xmin; diff --git a/source/blender/editors/interface/interface_regions.c b/source/blender/editors/interface/interface_regions.c index be118e1982e..c44a45c2150 100644 --- a/source/blender/editors/interface/interface_regions.c +++ b/source/blender/editors/interface/interface_regions.c @@ -1181,7 +1181,7 @@ ARegion *ui_searchbox_create(bContext *C, ARegion *butregion, uiBut *but) data->bbox.ymax = (ar->winrct.ymax - ar->winrct.ymin) - MENU_SHADOW_BOTTOM; /* check if button is lower half */ - if (but->rect.ymax < (but->block->rect.ymin + but->block->rect.ymax) / 2) { + if (but->rect.ymax < BLI_RCT_CENTER_Y(&but->block->rect)) { data->bbox.ymin += (but->rect.ymax - but->rect.ymin); } else { @@ -1495,8 +1495,8 @@ static void ui_block_position(wmWindow *window, ARegion *butregion, uiBut *but, /* safety calculus */ if (but) { - float midx = (butrct.xmin + butrct.xmax) / 2.0f; - float midy = (butrct.ymin + butrct.ymax) / 2.0f; + const float midx = BLI_RCT_CENTER_X(&butrct); + const float midy = BLI_RCT_CENTER_Y(&butrct); /* when you are outside parent button, safety there should be smaller */ diff --git a/source/blender/editors/interface/interface_widgets.c b/source/blender/editors/interface/interface_widgets.c index aebdb349bd5..3c944781d80 100644 --- a/source/blender/editors/interface/interface_widgets.c +++ b/source/blender/editors/interface/interface_widgets.c @@ -1843,8 +1843,8 @@ static void ui_hsv_cursor(float x, float y) void ui_hsvcircle_vals_from_pos(float *valrad, float *valdist, rcti *rect, float mx, float my) { /* duplication of code... well, simple is better now */ - float centx = (float)(rect->xmin + rect->xmax) / 2; - float centy = (float)(rect->ymin + rect->ymax) / 2; + float centx = BLI_RCT_CENTER_X_FL(rect); + float centy = BLI_RCT_CENTER_Y_FL(rect); float radius, dist; if (rect->xmax - rect->xmin > rect->ymax - rect->ymin) @@ -1876,8 +1876,8 @@ static void ui_draw_but_HSVCIRCLE(uiBut *but, uiWidgetColors *wcol, rcti *rect) color_profile = BLI_PR_NONE; radstep = 2.0f * (float)M_PI / (float)tot; - centx = (float)(rect->xmin + rect->xmax) / 2; - centy = (float)(rect->ymin + rect->ymax) / 2; + centx = BLI_RCT_CENTER_X_FL(rect); + centy = BLI_RCT_CENTER_Y_FL(rect); if (rect->xmax - rect->xmin > rect->ymax - rect->ymin) radius = (float)(rect->ymax - rect->ymin) / 2; @@ -2438,8 +2438,8 @@ static void widget_link(uiBut *but, uiWidgetColors *UNUSED(wcol), rcti *rect, in UI_ThemeColor(TH_TEXT_HI); - rectlink.xmin = (rect->xmin + rect->xmax) / 2; - rectlink.ymin = (rect->ymin + rect->ymax) / 2; + rectlink.xmin = BLI_RCT_CENTER_X(rect); + rectlink.ymin = BLI_RCT_CENTER_Y(rect); rectlink.xmax = but->linkto[0]; rectlink.ymax = but->linkto[1]; @@ -3269,12 +3269,12 @@ void ui_draw_menu_back(uiStyle *UNUSED(style), uiBlock *block, rcti *rect) if (block->flag & UI_BLOCK_CLIPTOP) { /* XXX no scaling for UI here yet */ glColor3ubv((unsigned char *)wt->wcol.text); - UI_DrawTriIcon((rect->xmax + rect->xmin) / 2, rect->ymax - 8, 't'); + UI_DrawTriIcon(BLI_RCT_CENTER_X(rect), rect->ymax - 8, 't'); } if (block->flag & UI_BLOCK_CLIPBOTTOM) { /* XXX no scaling for UI here yet */ glColor3ubv((unsigned char *)wt->wcol.text); - UI_DrawTriIcon((rect->xmax + rect->xmin) / 2, rect->ymin + 10, 'v'); + UI_DrawTriIcon(BLI_RCT_CENTER_X(rect), rect->ymin + 10, 'v'); } } } diff --git a/source/blender/editors/interface/view2d.c b/source/blender/editors/interface/view2d.c index 8ae08c08693..d498f57e8e3 100644 --- a/source/blender/editors/interface/view2d.c +++ b/source/blender/editors/interface/view2d.c @@ -508,7 +508,7 @@ void UI_view2d_curRect_validate_resize(View2D *v2d, int resize) cur->xmax += width - (cur->xmax - cur->xmin); } else { - temp = (cur->xmax + cur->xmin) * 0.5f; + temp = BLI_RCT_CENTER_X(cur); dh = width * 0.5f; cur->xmin = temp - dh; @@ -526,7 +526,7 @@ void UI_view2d_curRect_validate_resize(View2D *v2d, int resize) cur->ymax += height - (cur->ymax - cur->ymin); } else { - temp = (cur->ymax + cur->ymin) * 0.5f; + temp = BLI_RCT_CENTER_Y(cur); dh = height * 0.5f; cur->ymin = temp - dh; @@ -592,7 +592,7 @@ void UI_view2d_curRect_validate_resize(View2D *v2d, int resize) */ if ((cur->xmin < tot->xmin) && (cur->xmax > tot->xmax)) { /* outside boundaries on both sides, so take middle-point of tot, and place in balanced way */ - temp = (tot->xmax + tot->xmin) * 0.5f; + temp = BLI_RCT_CENTER_X(tot); diff = curheight * 0.5f; cur->xmin = temp - diff; @@ -642,7 +642,7 @@ void UI_view2d_curRect_validate_resize(View2D *v2d, int resize) */ if ((cur->ymin < tot->ymin) && (cur->ymax > tot->ymax)) { /* outside boundaries on both sides, so take middle-point of tot, and place in balanced way */ - temp = (tot->ymax + tot->ymin) * 0.5f; + temp = BLI_RCT_CENTER_Y(tot); diff = curheight * 0.5f; cur->ymin = temp - diff; diff --git a/source/blender/editors/interface/view2d_ops.c b/source/blender/editors/interface/view2d_ops.c index 33b72b34784..f12a9e06312 100644 --- a/source/blender/editors/interface/view2d_ops.c +++ b/source/blender/editors/interface/view2d_ops.c @@ -1139,7 +1139,7 @@ static int view_borderzoom_exec(bContext *C, wmOperator *op) if ((v2d->keepzoom & V2D_LOCKZOOM_X) == 0) { size = (cur_new.xmax - cur_new.xmin); zoom = size / (rect.xmax - rect.xmin); - center = (cur_new.xmax + cur_new.xmin) * 0.5f; + center = BLI_RCT_CENTER_X(&cur_new); cur_new.xmin = center - (size * zoom); cur_new.xmax = center + (size * zoom); @@ -1147,7 +1147,7 @@ static int view_borderzoom_exec(bContext *C, wmOperator *op) if ((v2d->keepzoom & V2D_LOCKZOOM_Y) == 0) { size = (cur_new.ymax - cur_new.ymin); zoom = size / (rect.ymax - rect.ymin); - center = (cur_new.ymax + cur_new.ymin) * 0.5f; + center = BLI_RCT_CENTER_Y(&cur_new); cur_new.ymin = center - (size * zoom); cur_new.ymax = center + (size * zoom); @@ -1201,10 +1201,10 @@ static float smooth_view_rect_to_fac(const rctf *rect_a, const rctf *rect_b) rect_a->ymax - rect_a->ymin}; float size_b[2] = {rect_b->xmax - rect_b->xmin, rect_b->ymax - rect_b->ymin}; - float cent_a[2] = {(rect_a->xmax + rect_a->xmin) * 0.5f, - (rect_a->ymax + rect_a->ymin) * 0.5f}; - float cent_b[2] = {(rect_b->xmax + rect_b->xmin) * 0.5f, - (rect_b->ymax + rect_b->ymin) * 0.5f}; + float cent_a[2] = {BLI_RCT_CENTER_X(rect_a), + BLI_RCT_CENTER_Y(rect_a)}; + float cent_b[2] = {BLI_RCT_CENTER_X(rect_b), + BLI_RCT_CENTER_Y(rect_b)}; float fac_max = 0.0f; float tfac; diff --git a/source/blender/editors/screen/area.c b/source/blender/editors/screen/area.c index 6f5f5c7dfa3..2c32295fe36 100644 --- a/source/blender/editors/screen/area.c +++ b/source/blender/editors/screen/area.c @@ -1010,7 +1010,7 @@ static void region_rect_recursive(ScrArea *sa, ARegion *ar, rcti *remainder, int if (alignment == RGN_ALIGN_HSPLIT) { if (rct_fits(remainder, 'h', prefsizex) > 4) { - ar->winrct.xmax = (remainder->xmin + remainder->xmax) / 2; + ar->winrct.xmax = BLI_RCT_CENTER_X(remainder); remainder->xmin = ar->winrct.xmax + 1; } else { @@ -1019,7 +1019,7 @@ static void region_rect_recursive(ScrArea *sa, ARegion *ar, rcti *remainder, int } else { if (rct_fits(remainder, 'v', prefsizey) > 4) { - ar->winrct.ymax = (remainder->ymin + remainder->ymax) / 2; + ar->winrct.ymax = BLI_RCT_CENTER_Y(remainder); remainder->ymin = ar->winrct.ymax + 1; } else { @@ -1051,20 +1051,20 @@ static void region_rect_recursive(ScrArea *sa, ARegion *ar, rcti *remainder, int } if (quad) { if (quad == 1) { /* left bottom */ - ar->winrct.xmax = (remainder->xmin + remainder->xmax) / 2; - ar->winrct.ymax = (remainder->ymin + remainder->ymax) / 2; + ar->winrct.xmax = BLI_RCT_CENTER_X(remainder); + ar->winrct.ymax = BLI_RCT_CENTER_Y(remainder); } else if (quad == 2) { /* left top */ - ar->winrct.xmax = (remainder->xmin + remainder->xmax) / 2; - ar->winrct.ymin = 1 + (remainder->ymin + remainder->ymax) / 2; + ar->winrct.xmax = BLI_RCT_CENTER_X(remainder); + ar->winrct.ymin = BLI_RCT_CENTER_Y(remainder) + 1; } else if (quad == 3) { /* right bottom */ - ar->winrct.xmin = 1 + (remainder->xmin + remainder->xmax) / 2; - ar->winrct.ymax = (remainder->ymin + remainder->ymax) / 2; + ar->winrct.xmin = BLI_RCT_CENTER_X(remainder) + 1; + ar->winrct.ymax = BLI_RCT_CENTER_Y(remainder); } else { /* right top */ - ar->winrct.xmin = 1 + (remainder->xmin + remainder->xmax) / 2; - ar->winrct.ymin = 1 + (remainder->ymin + remainder->ymax) / 2; + ar->winrct.xmin = BLI_RCT_CENTER_X(remainder) + 1; + ar->winrct.ymin = BLI_RCT_CENTER_Y(remainder) + 1; BLI_rcti_init(remainder, 0, 0, 0, 0); } diff --git a/source/blender/editors/space_logic/logic_buttons.c b/source/blender/editors/space_logic/logic_buttons.c index 999a8baf34b..abffb955405 100644 --- a/source/blender/editors/space_logic/logic_buttons.c +++ b/source/blender/editors/space_logic/logic_buttons.c @@ -84,10 +84,10 @@ static int cut_links_intersect(uiLinkLine *line, float mcoords[][2], int tot) int i, b; rcti rectlink; - rectlink.xmin = (int) (line->from->rect.xmin + line->from->rect.xmax) / 2; - rectlink.ymin = (int) (line->from->rect.ymin + line->from->rect.ymax) / 2; - rectlink.xmax = (int) (line->to->rect.xmin + line->to->rect.xmax) / 2; - rectlink.ymax = (int) (line->to->rect.ymin + line->to->rect.ymax) / 2; + rectlink.xmin = (int)BLI_RCT_CENTER_X(&line->from->rect); + rectlink.ymin = (int)BLI_RCT_CENTER_Y(&line->from->rect); + rectlink.xmax = (int)BLI_RCT_CENTER_X(&line->to->rect); + rectlink.ymax = (int)BLI_RCT_CENTER_Y(&line->to->rect); if (ui_link_bezier_points(&rectlink, coord_array, LINK_RESOL)) { for (i=0; iymax += NODE_DY; /* input sockets */ - dy = 0.5f * (rect->ymin + rect->ymax) + NODE_DY * (BLI_countlist(&gnode->inputs) - 1); + dy = BLI_RCT_CENTER_Y(rect) + (NODE_DY * (BLI_countlist(&gnode->inputs) - 1)); gsock = ngroup->inputs.first; sock = gnode->inputs.first; while (gsock || sock) { @@ -570,7 +570,7 @@ static void node_update_group(const bContext *C, bNodeTree *ntree, bNode *gnode) } /* output sockets */ - dy = 0.5f * (rect->ymin + rect->ymax) + NODE_DY * (BLI_countlist(&gnode->outputs) - 1); + dy = BLI_RCT_CENTER_Y(rect) + (NODE_DY * (BLI_countlist(&gnode->outputs) - 1)); gsock = ngroup->outputs.first; sock = gnode->outputs.first; while (gsock || sock) { @@ -979,7 +979,7 @@ static void node_draw_frame_label(bNode *node, const float aspect) ascender = BLF_ascender(fontid); /* 'x' doesn't need aspect correction */ - x = 0.5f * (rct->xmin + rct->xmax) - 0.5f * width; + x = BLI_RCT_CENTER_X(rct) - (0.5f * width); y = rct->ymax - (((NODE_DY / 4) / aspect) + (ascender * aspect)); BLF_position(fontid, x, y, 0); diff --git a/source/blender/editors/space_node/node_edit.c b/source/blender/editors/space_node/node_edit.c index 245c9cefd1f..4423b340d77 100644 --- a/source/blender/editors/space_node/node_edit.c +++ b/source/blender/editors/space_node/node_edit.c @@ -2063,8 +2063,8 @@ static int node_clipboard_paste_exec(bContext *C, wmOperator *op) /* calculate "barycenter" for placing on mouse cursor */ zero_v2(center); for (node = clipboard_nodes_lb->first, num_nodes = 0; node; node = node->next, num_nodes++) { - center[0] += 0.5f * (node->totr.xmin + node->totr.xmax); - center[1] += 0.5f * (node->totr.ymin + node->totr.ymax); + center[0] += BLI_RCT_CENTER_X(&node->totr); + center[1] += BLI_RCT_CENTER_Y(&node->totr); } mul_v2_fl(center, 1.0 / num_nodes); diff --git a/source/blender/editors/space_sequencer/sequencer_edit.c b/source/blender/editors/space_sequencer/sequencer_edit.c index 5bb3f710133..144de1f9d5e 100644 --- a/source/blender/editors/space_sequencer/sequencer_edit.c +++ b/source/blender/editors/space_sequencer/sequencer_edit.c @@ -2256,7 +2256,7 @@ static int sequencer_view_selected_exec(bContext *C, wmOperator *UNUSED(op)) /* only zoom out vertically */ if (orig_height > cur_new.ymax - cur_new.ymin) { - ymid = (cur_new.ymax + cur_new.ymin) / 2; + ymid = BLI_RCT_CENTER_Y(&cur_new); cur_new.ymin = ymid - (orig_height / 2); cur_new.ymax = ymid + (orig_height / 2); diff --git a/source/blender/editors/space_text/text_ops.c b/source/blender/editors/space_text/text_ops.c index df90ce24dda..5af44f93d06 100644 --- a/source/blender/editors/space_text/text_ops.c +++ b/source/blender/editors/space_text/text_ops.c @@ -2409,8 +2409,8 @@ static int text_scroll_bar_invoke(bContext *C, wmOperator *op, wmEvent *event) /* jump scroll, works in v2d but needs to be added here too :S */ if (event->type == MIDDLEMOUSE) { - tsc->old[0] = ar->winrct.xmin + (st->txtbar.xmax + st->txtbar.xmin) / 2; - tsc->old[1] = ar->winrct.ymin + (st->txtbar.ymax + st->txtbar.ymin) / 2; + tsc->old[0] = ar->winrct.xmin + BLI_RCT_CENTER_X(&st->txtbar); + tsc->old[1] = ar->winrct.ymin + BLI_RCT_CENTER_Y(&st->txtbar); tsc->delta[0] = 0; tsc->delta[1] = 0; diff --git a/source/blender/editors/space_view3d/view3d_edit.c b/source/blender/editors/space_view3d/view3d_edit.c index e5730e0f69b..4fe859adf45 100644 --- a/source/blender/editors/space_view3d/view3d_edit.c +++ b/source/blender/editors/space_view3d/view3d_edit.c @@ -382,9 +382,9 @@ static void calctrackballvec(rcti *rect, int mx, int my, float vec[3]) radius = TRACKBALLSIZE; /* normalize x and y */ - x = (rect->xmax + rect->xmin) / 2 - mx; + x = BLI_RCT_CENTER_X(rect) - mx; x /= (float)((rect->xmax - rect->xmin) / 4); - y = (rect->ymax + rect->ymin) / 2 - my; + y = BLI_RCT_CENTER_Y(rect) - my; y /= (float)((rect->ymax - rect->ymin) / 2); d = sqrt(x * x + y * y); @@ -1666,8 +1666,8 @@ static void viewzoom_apply(ViewOpsData *vod, int x, int y, const short viewzoom, int ctr[2], len1, len2; /* method which zooms based on how far you move the mouse */ - ctr[0] = (vod->ar->winrct.xmax + vod->ar->winrct.xmin) / 2; - ctr[1] = (vod->ar->winrct.ymax + vod->ar->winrct.ymin) / 2; + ctr[0] = BLI_RCT_CENTER_X(&vod->ar->winrct); + ctr[1] = BLI_RCT_CENTER_Y(&vod->ar->winrct); len1 = (int)sqrt((ctr[0] - x) * (ctr[0] - x) + (ctr[1] - y) * (ctr[1] - y)) + 5; len2 = (int)sqrt((ctr[0] - vod->origx) * (ctr[0] - vod->origx) + (ctr[1] - vod->origy) * (ctr[1] - vod->origy)) + 5; diff --git a/source/blender/editors/space_view3d/view3d_select.c b/source/blender/editors/space_view3d/view3d_select.c index 69fa42b0abb..8ef1b481143 100644 --- a/source/blender/editors/space_view3d/view3d_select.c +++ b/source/blender/editors/space_view3d/view3d_select.c @@ -765,9 +765,8 @@ static void do_lasso_select_node(int mcords[][2], short moves, short select) /* store selection in temp test flag */ for (node = snode->edittree->nodes.first; node; node = node->next) { - - node_centf[0] = (node->totr.xmin + node->totr.xmax) / 2; - node_centf[1] = (node->totr.ymin + node->totr.ymax) / 2; + node_centf[0] = BLI_RCT_CENTER_X(&node->totr); + node_centf[1] = BLI_RCT_CENTER_Y(&node->totr); ipoco_to_areaco_noclip(G.v2d, node_centf, node_cent); if (BLI_in_rcti_v(&rect, node_cent) && BLI_lasso_is_point_inside(mcords, moves, node_cent[0], node_cent[1])) { diff --git a/source/blender/editors/transform/transform_conversions.c b/source/blender/editors/transform/transform_conversions.c index c22a645eb53..120394aa7c1 100644 --- a/source/blender/editors/transform/transform_conversions.c +++ b/source/blender/editors/transform/transform_conversions.c @@ -5548,8 +5548,8 @@ static void createTransObject(bContext *C, TransInfo *t) static void NodeToTransData(TransData *td, TransData2D *td2d, bNode *node) { /* hold original location */ - float locxy[2] = {(node->totr.xmax + node->totr.xmin) / 2.0f, - (node->totr.ymax + node->totr.ymin) / 2.0f}; + float locxy[2] = {BLI_RCT_CENTER_X(&node->totr), + BLI_RCT_CENTER_Y(&node->totr)}; copy_v2_v2(td2d->loc, locxy); td2d->loc[2] = 0.0f; diff --git a/source/blender/render/intern/source/pipeline.c b/source/blender/render/intern/source/pipeline.c index 3d2b1608906..01b1f00ff98 100644 --- a/source/blender/render/intern/source/pipeline.c +++ b/source/blender/render/intern/source/pipeline.c @@ -59,6 +59,7 @@ #include "BKE_writeavi.h" /* <------ should be replaced once with generic movie module */ #include "BLI_math.h" +#include "BLI_rect.h" #include "BLI_listbase.h" #include "BLI_string.h" #include "BLI_path_util.h" @@ -739,8 +740,8 @@ static RenderPart *find_next_part(Render *re, int minx) /* find center of rendered parts, image center counts for 1 too */ for (pa = re->parts.first; pa; pa = pa->next) { if (pa->ready) { - centx += (pa->disprect.xmin + pa->disprect.xmax) / 2; - centy += (pa->disprect.ymin + pa->disprect.ymax) / 2; + centx += BLI_RCT_CENTER_X(&pa->disprect); + centy += BLI_RCT_CENTER_Y(&pa->disprect); tot++; } } @@ -750,8 +751,8 @@ static RenderPart *find_next_part(Render *re, int minx) /* closest of the non-rendering parts */ for (pa = re->parts.first; pa; pa = pa->next) { if (pa->ready == 0 && pa->nr == 0) { - long long int distx = centx - (pa->disprect.xmin + pa->disprect.xmax) / 2; - long long int disty = centy - (pa->disprect.ymin + pa->disprect.ymax) / 2; + long long int distx = centx - BLI_RCT_CENTER_X(&pa->disprect); + long long int disty = centy - BLI_RCT_CENTER_Y(&pa->disprect); distx = (long long int)sqrt(distx * distx + disty * disty); if (distx < mindist) { if (re->r.mode & R_PANORAMA) { diff --git a/source/blender/render/intern/source/render_result.c b/source/blender/render/intern/source/render_result.c index 5da661e7182..ce200b34d39 100644 --- a/source/blender/render/intern/source/render_result.c +++ b/source/blender/render/intern/source/render_result.c @@ -43,6 +43,7 @@ #include "BLI_fileops.h" #include "BLI_listbase.h" #include "BLI_path_util.h" +#include "BLI_rect.h" #include "BLI_string.h" #include "BLI_threads.h" #include "BLI_utildefines.h" @@ -420,8 +421,8 @@ RenderResult *render_result_new(Render *re, rcti *partrct, int crop, int savebuf SceneRenderLayer *srl; int rectx, recty, nr; - rectx = partrct->xmax - partrct->xmin; - recty = partrct->ymax - partrct->ymin; + rectx = BLI_RCT_SIZE_X(partrct); + recty = BLI_RCT_SIZE_Y(partrct); if (rectx <= 0 || recty <= 0) return NULL; @@ -558,8 +559,8 @@ RenderResult *render_result_new(Render *re, rcti *partrct, int crop, int savebuf } /* border render; calculate offset for use in compositor. compo is centralized coords */ - rr->xof = re->disprect.xmin + (re->disprect.xmax - re->disprect.xmin) / 2 - re->winx / 2; - rr->yof = re->disprect.ymin + (re->disprect.ymax - re->disprect.ymin) / 2 - re->winy / 2; + rr->xof = re->disprect.xmin + BLI_RCT_CENTER_X(&re->disprect) - (re->winx / 2); + rr->yof = re->disprect.ymin + BLI_RCT_CENTER_Y(&re->disprect) - (re->winy / 2); return rr; } diff --git a/source/blender/windowmanager/intern/wm_gesture.c b/source/blender/windowmanager/intern/wm_gesture.c index c9f1a2587df..2928ba024e5 100644 --- a/source/blender/windowmanager/intern/wm_gesture.c +++ b/source/blender/windowmanager/intern/wm_gesture.c @@ -130,8 +130,8 @@ int wm_gesture_evaluate(wmGesture *gesture) { if (gesture->type == WM_GESTURE_TWEAK) { rcti *rect = gesture->customdata; - int dx = rect->xmax - rect->xmin; - int dy = rect->ymax - rect->ymin; + int dx = BLI_RCT_SIZE_X(rect); + int dy = BLI_RCT_SIZE_Y(rect); if (ABS(dx) + ABS(dy) > U.tweak_threshold) { int theta = (int)floor(4.0f * atan2f((float)dy, (float)dx) / (float)M_PI + 0.5f); int val = EVT_GESTURE_W; diff --git a/source/blender/windowmanager/intern/wm_window.c b/source/blender/windowmanager/intern/wm_window.c index c2aa99352e9..fe3c2d0e901 100644 --- a/source/blender/windowmanager/intern/wm_window.c +++ b/source/blender/windowmanager/intern/wm_window.c @@ -464,8 +464,8 @@ wmWindow *WM_window_open(bContext *C, rcti *rect) win->posx = rect->xmin; win->posy = rect->ymin; - win->sizex = rect->xmax - rect->xmin; - win->sizey = rect->ymax - rect->ymin; + win->sizex = BLI_RCT_SIZE_X(rect); + win->sizey = BLI_RCT_SIZE_Y(rect); win->drawmethod = -1; win->drawdata = NULL; @@ -500,8 +500,8 @@ void WM_window_open_temp(bContext *C, rcti *position, int type) win->posy = position->ymin; } - win->sizex = position->xmax - position->xmin; - win->sizey = position->ymax - position->ymin; + win->sizex = BLI_RCT_SIZE_X(position); + win->sizey = BLI_RCT_SIZE_Y(position); if (win->ghostwin) { wm_window_set_size(win, win->sizex, win->sizey); From 5e78327b92f0acacd5e77485daa036b40c9ababa Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 20 Aug 2012 16:34:14 +0000 Subject: [PATCH 032/163] fix for mask feather intersection checks not working right for non-filled, feathered masks. now do intersection checks for both sides of the feather. --- source/blender/blenkernel/BKE_mask.h | 3 +- source/blender/blenkernel/intern/mask.c | 12 +++--- .../blenkernel/intern/mask_rasterize.c | 41 +++++++++++++++++-- 3 files changed, 46 insertions(+), 10 deletions(-) diff --git a/source/blender/blenkernel/BKE_mask.h b/source/blender/blenkernel/BKE_mask.h index 1836a88555b..a56f99c011c 100644 --- a/source/blender/blenkernel/BKE_mask.h +++ b/source/blender/blenkernel/BKE_mask.h @@ -74,9 +74,10 @@ float (*BKE_mask_spline_feather_differentiated_points(struct MaskSpline *spline, float (*BKE_mask_spline_differentiate_with_resolution_ex(struct MaskSpline *spline, int *tot_diff_point, const unsigned int resol))[2]; +void BKE_mask_spline_feather_collapse_inner_loops(struct MaskSpline *spline, float (*feather_points)[2], const int tot_feather_point); float (*BKE_mask_spline_differentiate_with_resolution(struct MaskSpline *spline, int width, int height, int *tot_diff_point))[2]; float (*BKE_mask_spline_feather_differentiated_points_with_resolution_ex(struct MaskSpline *spline, int *tot_feather_point, - const unsigned int resol))[2]; + const unsigned int resol, const int do_feather_isect))[2]; float (*BKE_mask_spline_feather_differentiated_points_with_resolution(struct MaskSpline *spline, int width, int height, int *tot_feather_point))[2]; float (*BKE_mask_spline_feather_points(struct MaskSpline *spline, int *tot_feather_point))[2]; diff --git a/source/blender/blenkernel/intern/mask.c b/source/blender/blenkernel/intern/mask.c index 3c46e7bcd47..d951f430dc2 100644 --- a/source/blender/blenkernel/intern/mask.c +++ b/source/blender/blenkernel/intern/mask.c @@ -559,7 +559,7 @@ static void feather_bucket_get_diagonal(FeatherEdgesBucket *buckets, int start_b *diagonal_bucket_b_r = &buckets[diagonal_bucket_b_index]; } -static void spline_feather_collapse_inner_loops(MaskSpline *spline, float (*feather_points)[2], int tot_feather_point) +void BKE_mask_spline_feather_collapse_inner_loops(MaskSpline *spline, float (*feather_points)[2], const int tot_feather_point) { #define BUCKET_INDEX(co) \ feather_bucket_index_from_coord(co, min, bucket_scale, buckets_per_side) @@ -721,7 +721,8 @@ static void spline_feather_collapse_inner_loops(MaskSpline *spline, float (*feat */ float (*BKE_mask_spline_feather_differentiated_points_with_resolution_ex(MaskSpline *spline, int *tot_feather_point, - const unsigned int resol + const unsigned int resol, + const int do_feather_isect ))[2] { MaskSplinePoint *points_array = BKE_mask_spline_point_array(spline); @@ -783,8 +784,9 @@ float (*BKE_mask_spline_feather_differentiated_points_with_resolution_ex(MaskSpl *tot_feather_point = tot; - if (spline->flag & MASK_SPLINE_NOINTERSECT) - spline_feather_collapse_inner_loops(spline, feather, tot); + if ((spline->flag & MASK_SPLINE_NOINTERSECT) && do_feather_isect) { + BKE_mask_spline_feather_collapse_inner_loops(spline, feather, tot); + } return feather; } @@ -794,7 +796,7 @@ float (*BKE_mask_spline_feather_differentiated_points_with_resolution(MaskSpline { unsigned int resol = BKE_mask_spline_feather_resolution(spline, width, height); - return BKE_mask_spline_feather_differentiated_points_with_resolution_ex(spline, tot_feather_point, resol); + return BKE_mask_spline_feather_differentiated_points_with_resolution_ex(spline, tot_feather_point, resol, TRUE); } float (*BKE_mask_spline_feather_differentiated_points(MaskSpline *spline, int *tot_feather_point))[2] diff --git a/source/blender/blenkernel/intern/mask_rasterize.c b/source/blender/blenkernel/intern/mask_rasterize.c index 6f7cf43be69..d39be3b8ed6 100644 --- a/source/blender/blenkernel/intern/mask_rasterize.c +++ b/source/blender/blenkernel/intern/mask_rasterize.c @@ -575,6 +575,7 @@ void BKE_maskrasterize_handle_init(MaskRasterHandle *mr_handle, struct Mask *mas int tot_diff_point; float (*diff_feather_points)[2]; + float (*diff_feather_points_flip)[2]; int tot_diff_feather_points; const unsigned int resol_a = BKE_mask_spline_resolution(spline, width, height) / 4; @@ -586,7 +587,7 @@ void BKE_maskrasterize_handle_init(MaskRasterHandle *mr_handle, struct Mask *mas if (do_feather) { diff_feather_points = BKE_mask_spline_feather_differentiated_points_with_resolution_ex( - spline, &tot_diff_feather_points, resol); + spline, &tot_diff_feather_points, resol, FALSE); BLI_assert(diff_feather_points); } else { @@ -649,6 +650,11 @@ void BKE_maskrasterize_handle_init(MaskRasterHandle *mr_handle, struct Mask *mas } if (is_fill) { + /* applt intersections depending on fill settings */ + if (spline->flag & MASK_SPLINE_NOINTERSECT) { + BKE_mask_spline_feather_collapse_inner_loops(spline, diff_feather_points, tot_diff_feather_points); + } + copy_v2_v2(co, diff_points[0]); sf_vert_prev = BLI_scanfill_vert_add(&sf_ctx, co); sf_vert_prev->tmp.u = sf_vert_tot; @@ -710,11 +716,27 @@ void BKE_maskrasterize_handle_init(MaskRasterHandle *mr_handle, struct Mask *mas /* unfilled spline */ if (diff_feather_points) { - float co_diff[3]; + float co_diff[2]; float co_feather[3]; co_feather[2] = 1.0f; + if (spline->flag & MASK_SPLINE_NOINTERSECT) { + diff_feather_points_flip = MEM_mallocN(sizeof(float) * 2 * tot_diff_feather_points, "diff_feather_points_flip"); + + for (j = 0; j < tot_diff_point; j++) { + sub_v2_v2v2(co_diff, diff_points[j], diff_feather_points[j]); + add_v2_v2v2(diff_feather_points_flip[j], diff_points[j], co_diff); + } + + BKE_mask_spline_feather_collapse_inner_loops(spline, diff_feather_points, tot_diff_feather_points); + BKE_mask_spline_feather_collapse_inner_loops(spline, diff_feather_points_flip, tot_diff_feather_points); + } + else { + diff_feather_points_flip = NULL; + } + + open_spline_ranges[open_spline_index].vertex_offset = sf_vert_tot; open_spline_ranges[open_spline_index].vertex_total = tot_diff_point; @@ -738,8 +760,14 @@ void BKE_maskrasterize_handle_init(MaskRasterHandle *mr_handle, struct Mask *mas /* feather vert B */ - sub_v2_v2v2(co_diff, co, co_feather); - add_v2_v2v2(co_feather, co, co_diff); + if (diff_feather_points_flip) { + copy_v2_v2(co_feather, diff_feather_points_flip[j]); + } + else { + sub_v2_v2v2(co_diff, co, co_feather); + add_v2_v2v2(co_feather, co, co_diff); + } + sf_vert = BLI_scanfill_vert_add(&sf_ctx, co_feather); sf_vert->tmp.u = sf_vert_tot; sf_vert->keyindex = SF_KEYINDEX_TEMP_ID; @@ -752,6 +780,11 @@ void BKE_maskrasterize_handle_init(MaskRasterHandle *mr_handle, struct Mask *mas tot_feather_quads -= 2; } + if (diff_feather_points_flip) { + MEM_freeN(diff_feather_points_flip); + diff_feather_points_flip = NULL; + } + /* cap ends */ /* dummy init value */ From ff876a473aa030a7308560c69c2b6fd4bb7e77a4 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 20 Aug 2012 16:56:11 +0000 Subject: [PATCH 033/163] HDR color picker now works in the clip space. --- source/blender/editors/include/ED_clip.h | 2 + .../blender/editors/interface/interface_ops.c | 14 +++++- .../blender/editors/space_clip/clip_editor.c | 48 +++++++++++++++++++ 3 files changed, 63 insertions(+), 1 deletion(-) diff --git a/source/blender/editors/include/ED_clip.h b/source/blender/editors/include/ED_clip.h index 3a1d63574a6..13c3b180230 100644 --- a/source/blender/editors/include/ED_clip.h +++ b/source/blender/editors/include/ED_clip.h @@ -62,6 +62,8 @@ int ED_space_clip_get_clip_frame_number(struct SpaceClip *sc); struct ImBuf *ED_space_clip_get_buffer(struct SpaceClip *sc); struct ImBuf *ED_space_clip_get_stable_buffer(struct SpaceClip *sc, float loc[2], float *scale, float *angle); +int ED_space_clip_color_sample(struct SpaceClip *sc, struct ARegion *ar, int mval[2], float r_col[3]); + void ED_clip_update_frame(const struct Main *mainp, int cfra); int ED_clip_view_selection(const struct bContext *C, struct ARegion *ar, int fit); diff --git a/source/blender/editors/interface/interface_ops.c b/source/blender/editors/interface/interface_ops.c index 802000567da..d3b81974479 100644 --- a/source/blender/editors/interface/interface_ops.c +++ b/source/blender/editors/interface/interface_ops.c @@ -27,7 +27,6 @@ * \ingroup edinterface */ - #include #include #include @@ -71,6 +70,7 @@ #include "ED_image.h" /* for HDR color sampling */ #include "ED_node.h" /* for HDR color sampling */ +#include "ED_clip.h" /* for HDR color sampling */ /* ********************************************************** */ @@ -165,6 +165,18 @@ static void eyedropper_color_sample_fl(bContext *C, Eyedropper *UNUSED(eye), int } } } + else if (sa->spacetype == SPACE_CLIP) { + ARegion *ar = BKE_area_find_region_type(sa, RGN_TYPE_WINDOW); + if (BLI_in_rcti(&ar->winrct, mx, my)) { + SpaceClip *sc = sa->spacedata.first; + int mval[2] = {mx - ar->winrct.xmin, + my - ar->winrct.ymin}; + + if (ED_space_clip_color_sample(sc, ar, mval, r_col)) { + return; + } + } + } } } diff --git a/source/blender/editors/space_clip/clip_editor.c b/source/blender/editors/space_clip/clip_editor.c index 5e4ef1aa24a..5b4849a425f 100644 --- a/source/blender/editors/space_clip/clip_editor.c +++ b/source/blender/editors/space_clip/clip_editor.c @@ -247,6 +247,54 @@ ImBuf *ED_space_clip_get_stable_buffer(SpaceClip *sc, float loc[2], float *scale return NULL; } +/* returns color in SRGB */ +/* matching ED_space_image_color_sample() */ +int ED_space_clip_color_sample(SpaceClip *sc, ARegion *ar, int mval[2], float r_col[3]) +{ + ImBuf *ibuf; + float fx, fy, co[2]; + int ret = FALSE; + + ibuf = ED_space_clip_get_buffer(sc); + if (!ibuf) { + return FALSE; + } + + /* map the mouse coords to the backdrop image space */ + ED_clip_mouse_pos(sc, ar, mval, co); + + fx = co[0]; + fy = co[1]; + + if (fx >= 0.0f && fy >= 0.0f && fx < 1.0f && fy < 1.0f) { + float *fp; + unsigned char *cp; + int x = (int)(fx * ibuf->x), y = (int)(fy * ibuf->y); + + CLAMP(x, 0, ibuf->x - 1); + CLAMP(y, 0, ibuf->y - 1); + + if (ibuf->rect_float) { + fp = (ibuf->rect_float + (ibuf->channels) * (y * ibuf->x + x)); + /* IB_PROFILE_NONE is default but infact its linear */ + if (ELEM(ibuf->profile, IB_PROFILE_LINEAR_RGB, IB_PROFILE_NONE)) { + linearrgb_to_srgb_v3_v3(r_col, fp); + } + else { + copy_v3_v3(r_col, fp); + } + ret = TRUE; + } + else if (ibuf->rect) { + cp = (unsigned char *)(ibuf->rect + y * ibuf->x + x); + rgb_uchar_to_float(r_col, cp); + ret = TRUE; + } + } + + return ret; +} + void ED_clip_update_frame(const Main *mainp, int cfra) { wmWindowManager *wm; From e410049a6a95aaffb605e8d6bbd4bb6a8df4fa4b Mon Sep 17 00:00:00 2001 From: Thomas Dinges Date: Mon, 20 Aug 2012 19:40:49 +0000 Subject: [PATCH 034/163] Cycles / Cmake: * Removed last instance of "BLENDER_PLUGIN" define, removed in r39465 in the cycles branch. --- intern/cycles/CMakeLists.txt | 1 - 1 file changed, 1 deletion(-) diff --git a/intern/cycles/CMakeLists.txt b/intern/cycles/CMakeLists.txt index 2127ad23bd3..697427081c3 100644 --- a/intern/cycles/CMakeLists.txt +++ b/intern/cycles/CMakeLists.txt @@ -63,7 +63,6 @@ include_directories( # Subdirectories if(WITH_CYCLES_BLENDER) - add_definitions(-DBLENDER_PLUGIN) add_subdirectory(blender) endif() From 94ce9505a9bf07e3d2532c82a0b8396f7c9727b3 Mon Sep 17 00:00:00 2001 From: Thomas Dinges Date: Mon, 20 Aug 2012 20:13:37 +0000 Subject: [PATCH 035/163] Legacy Compositor / Scons: * Added WITH_BF_COMPOSITOR_LEGACY, enabled per default. --- build_files/scons/tools/btools.py | 5 +++-- source/blender/nodes/SConscript | 4 ++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/build_files/scons/tools/btools.py b/build_files/scons/tools/btools.py index 8f5bb1ffc57..2fa503f3f26 100644 --- a/build_files/scons/tools/btools.py +++ b/build_files/scons/tools/btools.py @@ -108,7 +108,7 @@ def validate_arguments(args, bc): 'WITH_BF_STATICFFMPEG', 'BF_FFMPEG_LIB_STATIC', 'WITH_BF_OGG', 'BF_OGG', 'BF_OGG_LIB', 'WITH_BF_FRAMESERVER', - 'WITH_BF_COMPOSITOR', + 'WITH_BF_COMPOSITOR', 'WITH_BF_COMPOSITOR_LEGACY', 'WITH_BF_JPEG', 'BF_JPEG', 'BF_JPEG_INC', 'BF_JPEG_LIB', 'BF_JPEG_LIBPATH', 'WITH_BF_OPENJPEG', 'BF_OPENJPEG', 'BF_OPENJPEG_INC', 'BF_OPENJPEG_LIB', 'BF_OPENJPEG_LIBPATH', 'WITH_BF_REDCODE', 'BF_REDCODE', 'BF_REDCODE_INC', 'BF_REDCODE_LIB', 'BF_REDCODE_LIBPATH', @@ -583,7 +583,8 @@ def read_opts(env, cfg, args): ('BF_BOOST_LIBPATH', 'Boost library path', ''), ('BF_BOOST_LIB_STATIC', 'Boost static library', ''), - (BoolVariable('WITH_GHOST_XDND', 'Build with drag-n-drop support on Linux platforms using XDND protocol', True)) + (BoolVariable('WITH_GHOST_XDND', 'Build with drag-n-drop support on Linux platforms using XDND protocol', True)), + (BoolVariable('WITH_BF_COMPOSITOR_LEGACY', 'Enable the legacy compositor', True)) ) # end of opts.AddOptions() return localopts diff --git a/source/blender/nodes/SConscript b/source/blender/nodes/SConscript index f42dfdd2e1e..ec4f00a199a 100644 --- a/source/blender/nodes/SConscript +++ b/source/blender/nodes/SConscript @@ -40,8 +40,8 @@ if env['WITH_BF_COMPOSITOR']: incs += ' ../compositor ' defs.append("WITH_COMPOSITOR") -# TODO, make optional -defs.append("WITH_COMPOSITOR_LEGACY") +if env['WITH_BF_COMPOSITOR_LEGACY']: + defs.append("WITH_COMPOSITOR_LEGACY") env.BlenderLib ( libname = 'bf_nodes', sources = sources, includes = Split(incs), defines = defs, libtype=['core','player'], priority = [190,105] ) env.BlenderLib ( libname = 'bf_cmpnodes', sources = cmpsources, includes = Split(incs), defines = defs, libtype=['core','player'], priority = [175,101] ) From 77f47799ddff99da672aa58e5d989237403e7707 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 20 Aug 2012 23:06:17 +0000 Subject: [PATCH 036/163] code cleanup: use BLI_RCT_SIZE macro --- source/blender/blenlib/intern/rct.c | 4 +- .../operations/COM_DilateErodeOperation.cpp | 6 +- .../blender/editors/animation/anim_markers.c | 2 +- source/blender/editors/interface/interface.c | 22 ++-- .../editors/interface/interface_draw.c | 38 +++---- .../editors/interface/interface_handlers.c | 62 +++++------ .../editors/interface/interface_panel.c | 12 +-- .../editors/interface/interface_regions.c | 18 ++-- .../editors/interface/interface_style.c | 12 +-- .../editors/interface/interface_templates.c | 23 ++-- .../editors/interface/interface_widgets.c | 101 +++++++++--------- source/blender/editors/interface/view2d.c | 98 ++++++++--------- source/blender/editors/interface/view2d_ops.c | 52 ++++----- source/blender/editors/mask/mask_draw.c | 9 +- source/blender/editors/mesh/editface.c | 4 +- .../blender/editors/render/render_preview.c | 7 +- source/blender/editors/screen/area.c | 30 +++--- source/blender/editors/screen/screen_ops.c | 2 +- .../editors/space_action/action_draw.c | 2 +- .../editors/space_action/action_edit.c | 4 +- .../editors/space_action/action_select.c | 2 +- .../blender/editors/space_clip/clip_buttons.c | 3 +- .../editors/space_clip/clip_dopesheet_draw.c | 3 +- source/blender/editors/space_clip/clip_draw.c | 8 +- .../blender/editors/space_clip/clip_editor.c | 9 +- .../editors/space_clip/clip_graph_ops.c | 6 +- source/blender/editors/space_clip/clip_ops.c | 9 +- .../blender/editors/space_clip/space_clip.c | 4 +- .../editors/space_console/space_console.c | 2 +- source/blender/editors/space_file/filesel.c | 8 +- .../blender/editors/space_file/space_file.c | 2 +- .../blender/editors/space_graph/graph_draw.c | 4 +- .../editors/space_graph/graph_select.c | 2 +- .../editors/space_image/image_buttons.c | 2 +- .../blender/editors/space_image/image_draw.c | 3 +- .../blender/editors/space_image/image_edit.c | 5 +- .../blender/editors/space_image/image_ops.c | 8 +- .../blender/editors/space_image/space_image.c | 4 +- source/blender/editors/space_nla/nla_edit.c | 4 +- source/blender/editors/space_nla/nla_select.c | 2 +- source/blender/editors/space_node/drawnode.c | 4 +- source/blender/editors/space_node/node_draw.c | 2 +- source/blender/editors/space_node/node_view.c | 4 +- .../editors/space_outliner/outliner_edit.c | 4 +- .../editors/space_sequencer/sequencer_draw.c | 14 +-- .../editors/space_sequencer/sequencer_edit.c | 14 +-- source/blender/editors/space_time/time_ops.c | 2 +- .../editors/space_view3d/view3d_draw.c | 4 +- .../editors/space_view3d/view3d_edit.c | 8 +- .../editors/space_view3d/view3d_select.c | 4 +- source/blender/editors/transform/transform.c | 16 +-- .../windowmanager/intern/wm_subwindow.c | 4 +- .../BlenderRoutines/BL_KetsjiEmbedStart.cpp | 2 +- 53 files changed, 346 insertions(+), 334 deletions(-) diff --git a/source/blender/blenlib/intern/rct.c b/source/blender/blenlib/intern/rct.c index 61408610520..92cbcd485b6 100644 --- a/source/blender/blenlib/intern/rct.c +++ b/source/blender/blenlib/intern/rct.c @@ -382,11 +382,11 @@ void BLI_rctf_rcti_copy(rctf *dst, const rcti *src) void print_rctf(const char *str, const rctf *rect) { printf("%s: xmin %.3f, xmax %.3f, ymin %.3f, ymax %.3f (%.3fx%.3f)\n", str, - rect->xmin, rect->xmax, rect->ymin, rect->ymax, rect->xmax - rect->xmin, rect->ymax - rect->ymin); + rect->xmin, rect->xmax, rect->ymin, rect->ymax, BLI_RCT_SIZE_X(rect), BLI_RCT_SIZE_Y(rect)); } void print_rcti(const char *str, const rcti *rect) { printf("%s: xmin %d, xmax %d, ymin %d, ymax %d (%dx%d)\n", str, - rect->xmin, rect->xmax, rect->ymin, rect->ymax, rect->xmax - rect->xmin, rect->ymax - rect->ymin); + rect->xmin, rect->xmax, rect->ymin, rect->ymax, BLI_RCT_SIZE_X(rect), BLI_RCT_SIZE_Y(rect)); } diff --git a/source/blender/compositor/operations/COM_DilateErodeOperation.cpp b/source/blender/compositor/operations/COM_DilateErodeOperation.cpp index 2687fee28ce..c4b4452fbb0 100644 --- a/source/blender/compositor/operations/COM_DilateErodeOperation.cpp +++ b/source/blender/compositor/operations/COM_DilateErodeOperation.cpp @@ -79,7 +79,7 @@ void DilateErodeThresholdOperation::executePixel(float output[4], int x, int y, const int miny = max(y - this->m_scope, rect->ymin); const int maxx = min(x + this->m_scope, rect->xmax); const int maxy = min(y + this->m_scope, rect->ymax); - const int bufferWidth = rect->xmax - rect->xmin; + const int bufferWidth = BLI_RCT_SIZE_X(rect); int offset; this->m_inputProgram->read(inputValue, x, y, NULL); @@ -199,7 +199,7 @@ void DilateDistanceOperation::executePixel(float output[4], int x, int y, void * const int miny = max(y - this->m_scope, rect->ymin); const int maxx = min(x + this->m_scope, rect->xmax); const int maxy = min(y + this->m_scope, rect->ymax); - const int bufferWidth = rect->xmax - rect->xmin; + const int bufferWidth = BLI_RCT_SIZE_X(rect); int offset; float value = 0.0f; @@ -273,7 +273,7 @@ void ErodeDistanceOperation::executePixel(float output[4], int x, int y, void *d const int miny = max(y - this->m_scope, rect->ymin); const int maxx = min(x + this->m_scope, rect->xmax); const int maxy = min(y + this->m_scope, rect->ymax); - const int bufferWidth = rect->xmax - rect->xmin; + const int bufferWidth = BLI_RCT_SIZE_X(rect); int offset; float value = 1.0f; diff --git a/source/blender/editors/animation/anim_markers.c b/source/blender/editors/animation/anim_markers.c index c75024a469e..95adaa01b94 100644 --- a/source/blender/editors/animation/anim_markers.c +++ b/source/blender/editors/animation/anim_markers.c @@ -354,7 +354,7 @@ static void draw_marker(View2D *v2d, TimeMarker *marker, int cfra, int flag) xpos = marker->frame; /* no time correction for framelen! space is drawn with old values */ - ypixels = v2d->mask.ymax - v2d->mask.ymin; + ypixels = BLI_RCT_SIZE_Y(&v2d->mask); UI_view2d_getscale(v2d, &xscale, &yscale); glScalef(1.0f / xscale, 1.0f, 1.0f); diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c index f728e999667..10917f23cdd 100644 --- a/source/blender/editors/interface/interface.c +++ b/source/blender/editors/interface/interface.c @@ -99,8 +99,8 @@ void ui_block_to_window_fl(const ARegion *ar, uiBlock *block, float *x, float *y float gx, gy; int sx, sy, getsizex, getsizey; - getsizex = ar->winrct.xmax - ar->winrct.xmin + 1; - getsizey = ar->winrct.ymax - ar->winrct.ymin + 1; + getsizex = BLI_RCT_SIZE_X(&ar->winrct) + 1; + getsizey = BLI_RCT_SIZE_Y(&ar->winrct) + 1; sx = ar->winrct.xmin; sy = ar->winrct.ymin; @@ -145,8 +145,8 @@ void ui_window_to_block_fl(const ARegion *ar, uiBlock *block, float *x, float *y float a, b, c, d, e, f, px, py; int sx, sy, getsizex, getsizey; - getsizex = ar->winrct.xmax - ar->winrct.xmin + 1; - getsizey = ar->winrct.ymax - ar->winrct.ymin + 1; + getsizex = BLI_RCT_SIZE_X(&ar->winrct) + 1; + getsizey = BLI_RCT_SIZE_Y(&ar->winrct) + 1; sx = ar->winrct.xmin; sy = ar->winrct.ymin; @@ -272,7 +272,7 @@ void ui_bounds_block(uiBlock *block) block->rect.ymax += block->bounds; } - block->rect.xmax = block->rect.xmin + maxf(block->rect.xmax - block->rect.xmin, block->minbounds); + block->rect.xmax = block->rect.xmin + maxf(BLI_RCT_SIZE_X(&block->rect), block->minbounds); /* hardcoded exception... but that one is annoying with larger safety */ bt = block->buttons.first; @@ -325,8 +325,8 @@ static void ui_popup_bounds_block(const bContext *C, uiBlock *block, int bounds_ wm_window_get_size(window, &xmax, &ymax); - oldwidth = block->rect.xmax - block->rect.xmin; - oldheight = block->rect.ymax - block->rect.ymin; + oldwidth = BLI_RCT_SIZE_X(&block->rect); + oldheight = BLI_RCT_SIZE_Y(&block->rect); /* first we ensure wide enough text bounds */ if (bounds_calc == UI_BLOCK_BOUNDS_POPUP_MENU) { @@ -341,8 +341,8 @@ static void ui_popup_bounds_block(const bContext *C, uiBlock *block, int bounds_ ui_bounds_block(block); /* and we adjust the position to fit within window */ - width = block->rect.xmax - block->rect.xmin; - height = block->rect.ymax - block->rect.ymin; + width = BLI_RCT_SIZE_X(&block->rect); + height = BLI_RCT_SIZE_Y(&block->rect); /* avoid divide by zero below, caused by calling with no UI, but better not crash */ oldwidth = oldwidth > 0 ? oldwidth : MAX2(1, width); @@ -2204,7 +2204,7 @@ void ui_check_but(uiBut *but) /* safety is 4 to enable small number buttons (like 'users') */ - // okwidth= -4 + (but->rect.xmax - but->rect.xmin); // UNUSED + // okwidth= -4 + (BLI_RCT_SIZE_X(&but->rect)); // UNUSED /* name: */ switch (but->type) { @@ -2212,7 +2212,7 @@ void ui_check_but(uiBut *but) case MENU: case ICONTEXTROW: - if (but->rect.xmax - but->rect.xmin > 24) { + if (BLI_RCT_SIZE_X(&but->rect) > 24.0f) { UI_GET_BUT_VALUE_INIT(but, value); ui_set_name_menu(but, (int)value); } diff --git a/source/blender/editors/interface/interface_draw.c b/source/blender/editors/interface/interface_draw.c index 109978780c2..e66c0409192 100644 --- a/source/blender/editors/interface/interface_draw.c +++ b/source/blender/editors/interface/interface_draw.c @@ -493,8 +493,8 @@ static void ui_draw_but_CHARTAB(uiBut *but) charmax = G.charmax = 0xffff; /* Calculate the size of the button */ - width = abs(rect->xmax - rect->xmin); - height = abs(rect->ymax - rect->ymin); + width = absBLI_RCT_SIZE_X(rect); + height = absBLI_RCT_SIZE_Y(rect); butw = floor(width / 12); buth = floor(height / 6); @@ -642,8 +642,8 @@ static void draw_scope_end(rctf *rect, GLint *scissor) glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); /* scale widget */ - scaler_x1 = rect->xmin + (rect->xmax - rect->xmin) / 2 - SCOPE_RESIZE_PAD; - scaler_x2 = rect->xmin + (rect->xmax - rect->xmin) / 2 + SCOPE_RESIZE_PAD; + scaler_x1 = rect->xmin + BLI_RCT_SIZE_X(rect) / 2 - SCOPE_RESIZE_PAD; + scaler_x2 = rect->xmin + BLI_RCT_SIZE_X(rect) / 2 + SCOPE_RESIZE_PAD; glColor4f(0.f, 0.f, 0.f, 0.25f); fdrawline(scaler_x1, rect->ymin - 4, scaler_x2, rect->ymin - 4); @@ -805,9 +805,9 @@ void ui_draw_but_WAVEFORM(ARegion *ar, uiBut *but, uiWidgetColors *UNUSED(wcol), if (scopes->wavefrm_yfac < 0.5f) scopes->wavefrm_yfac = 0.98f; - w = rect.xmax - rect.xmin - 7; - h = (rect.ymax - rect.ymin) * scopes->wavefrm_yfac; - yofs = rect.ymin + (rect.ymax - rect.ymin - h) / 2.0f; + w = BLI_RCT_SIZE_X(&rect) - 7; + h = BLI_RCT_SIZE_Y(&rect) * scopes->wavefrm_yfac; + yofs = rect.ymin + (BLI_RCT_SIZE_Y(&rect) - h) / 2.0f; w3 = w / 3.0f; /* log scale for alpha */ @@ -1033,8 +1033,8 @@ void ui_draw_but_VECTORSCOPE(ARegion *ar, uiBut *but, uiWidgetColors *UNUSED(wco rect.ymin = (float)recti->ymin + SCOPE_RESIZE_PAD + 2; rect.ymax = (float)recti->ymax - 1; - w = rect.xmax - rect.xmin; - h = rect.ymax - rect.ymin; + w = BLI_RCT_SIZE_X(&rect); + h = BLI_RCT_SIZE_Y(&rect); centerx = rect.xmin + w / 2; centery = rect.ymin + h / 2; diam = (w < h) ? w : h; @@ -1262,12 +1262,12 @@ void ui_draw_but_NORMAL(uiBut *but, uiWidgetColors *wcol, rcti *rect) /* transform to button */ glPushMatrix(); - glTranslatef(rect->xmin + 0.5f * (rect->xmax - rect->xmin), rect->ymin + 0.5f * (rect->ymax - rect->ymin), 0.0f); + glTranslatef(rect->xmin + 0.5f * BLI_RCT_SIZE_X(rect), rect->ymin + 0.5f * BLI_RCT_SIZE_Y(rect), 0.0f); - if (rect->xmax - rect->xmin < rect->ymax - rect->ymin) - size = (rect->xmax - rect->xmin) / 200.f; + if (BLI_RCT_SIZE_X(rect) < BLI_RCT_SIZE_Y(rect)) + size = BLI_RCT_SIZE_X(rect) / 200.f; else - size = (rect->ymax - rect->ymin) / 200.f; + size = BLI_RCT_SIZE_Y(rect) / 200.f; glScalef(size, size, size); @@ -1368,8 +1368,8 @@ void ui_draw_but_CURVE(ARegion *ar, uiBut *but, uiWidgetColors *wcol, rcti *rect glScissor(scissor_new.xmin, scissor_new.ymin, scissor_new.xmax - scissor_new.xmin, scissor_new.ymax - scissor_new.ymin); /* calculate offset and zoom */ - zoomx = (rect->xmax - rect->xmin - 2.0f * but->aspect) / (cumap->curr.xmax - cumap->curr.xmin); - zoomy = (rect->ymax - rect->ymin - 2.0f * but->aspect) / (cumap->curr.ymax - cumap->curr.ymin); + zoomx = (BLI_RCT_SIZE_X(rect) - 2.0f * but->aspect) / BLI_RCT_SIZE_X(&cumap->curr); + zoomy = (BLI_RCT_SIZE_Y(rect) - 2.0f * but->aspect) / BLI_RCT_SIZE_Y(&cumap->curr); offsx = cumap->curr.xmin - but->aspect / zoomx; offsy = cumap->curr.ymin - but->aspect / zoomy; @@ -1545,8 +1545,8 @@ void ui_draw_but_TRACKPREVIEW(ARegion *ar, uiBut *but, uiWidgetColors *UNUSED(wc rect.ymin = (float)recti->ymin + SCOPE_RESIZE_PAD + 2; rect.ymax = (float)recti->ymax - 1; - width = rect.xmax - rect.xmin + 1; - height = rect.ymax - rect.ymin; + width = BLI_RCT_SIZE_X(&rect) + 1; + height = BLI_RCT_SIZE_Y(&rect); glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); @@ -1621,8 +1621,8 @@ void ui_draw_but_TRACKPREVIEW(ARegion *ar, uiBut *but, uiWidgetColors *UNUSED(wc glTranslatef(rect.xmin + track_pos[0], rect.ymin + track_pos[1], 0.f); glScissor(ar->winrct.xmin + rect.xmin, ar->winrct.ymin + rect.ymin, - rect.xmax - rect.xmin, - rect.ymax - rect.ymin); + BLI_RCT_SIZE_X(&rect), + BLI_RCT_SIZE_Y(&rect)); for (a = 0; a < 2; a++) { if (a == 1) { diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c index 50b6de5ce46..d78a677ea58 100644 --- a/source/blender/editors/interface/interface_handlers.c +++ b/source/blender/editors/interface/interface_handlers.c @@ -690,7 +690,7 @@ static int ui_but_mouse_inside_icon(uiBut *but, ARegion *ar, wmEvent *event) if (but->imb) ; /* use button size itself */ else if (but->flag & UI_ICON_LEFT) { - rect.xmax = rect.xmin + (rect.ymax - rect.ymin); + rect.xmax = rect.xmin + (BLI_RCT_SIZE_Y(&rect)); } else { int delta = BLI_RCT_SIZE_X(&rect) - BLI_RCT_SIZE_Y(&rect); @@ -714,7 +714,7 @@ static int ui_but_start_drag(bContext *C, uiBut *but, uiHandleButtonData *data, drag = WM_event_start_drag(C, but->icon, but->dragtype, but->dragpoin, ui_get_but_val(but)); if (but->imb) - WM_event_drag_image(drag, but->imb, but->imb_scale, but->rect.xmax - but->rect.xmin, but->rect.ymax - but->rect.ymin); + WM_event_drag_image(drag, but->imb, but->imb_scale, BLI_RCT_SIZE_X(&but->rect), BLI_RCT_SIZE_Y(&but->rect)); return 1; } @@ -1295,7 +1295,7 @@ static void ui_textedit_set_cursor_pos(uiBut *but, uiHandleButtonData *data, sho /* XXX solve generic */ if (but->type == NUM || but->type == NUMSLI) - startx += (int)(0.5f * (but->rect.ymax - but->rect.ymin)); + startx += (int)(0.5f * (BLI_RCT_SIZE_Y(&but->rect))); else if (ELEM(but->type, TEX, SEARCH_MENU)) { startx += 5; if (but->flag & UI_HAS_ICON) @@ -2610,7 +2610,7 @@ static int ui_do_but_NUM(bContext *C, uiBlock *block, uiBut *but, uiHandleButton softmax = but->softmax; if (!ui_is_but_float(but)) { - if (mx < (but->rect.xmin + (but->rect.xmax - but->rect.xmin) / 3 - 3)) { + if (mx < (but->rect.xmin + BLI_RCT_SIZE_X(&but->rect) / 3 - 3)) { button_activate_state(C, but, BUTTON_STATE_NUM_EDITING); temp = (int)data->value - 1; @@ -2621,7 +2621,7 @@ static int ui_do_but_NUM(bContext *C, uiBlock *block, uiBut *but, uiHandleButton button_activate_state(C, but, BUTTON_STATE_EXIT); } - else if (mx > (but->rect.xmin + (2 * (but->rect.xmax - but->rect.xmin) / 3) + 3)) { + else if (mx > (but->rect.xmin + (2 * BLI_RCT_SIZE_X(&but->rect) / 3) + 3)) { button_activate_state(C, but, BUTTON_STATE_NUM_EDITING); temp = (int)data->value + 1; @@ -2636,7 +2636,7 @@ static int ui_do_but_NUM(bContext *C, uiBlock *block, uiBut *but, uiHandleButton button_activate_state(C, but, BUTTON_STATE_TEXT_EDITING); } else { - if (mx < (but->rect.xmin + (but->rect.xmax - but->rect.xmin) / 3 - 3)) { + if (mx < (but->rect.xmin + BLI_RCT_SIZE_X(&but->rect) / 3 - 3)) { button_activate_state(C, but, BUTTON_STATE_NUM_EDITING); tempf = (float)data->value - 0.01f * but->a1; @@ -2645,7 +2645,7 @@ static int ui_do_but_NUM(bContext *C, uiBlock *block, uiBut *but, uiHandleButton button_activate_state(C, but, BUTTON_STATE_EXIT); } - else if (mx > but->rect.xmin + (2 * ((but->rect.xmax - but->rect.xmin) / 3) + 3)) { + else if (mx > but->rect.xmin + (2 * (BLI_RCT_SIZE_X(&but->rect) / 3) + 3)) { button_activate_state(C, but, BUTTON_STATE_NUM_EDITING); tempf = (float)data->value + 0.01f * but->a1; @@ -2673,14 +2673,14 @@ static int ui_numedit_but_SLI(uiBut *but, uiHandleButtonData *data, const short softmax = but->softmax; softrange = softmax - softmin; - if (but->type == NUMSLI) deler = ((but->rect.xmax - but->rect.xmin) - 5.0f * but->aspect); - else if (but->type == HSVSLI) deler = ((but->rect.xmax - but->rect.xmin) / 2.0f - 5.0f * but->aspect); + if (but->type == NUMSLI) deler = (BLI_RCT_SIZE_X(&but->rect) - 5.0f * but->aspect); + else if (but->type == HSVSLI) deler = (BLI_RCT_SIZE_X(&but->rect) / 2.0f - 5.0f * but->aspect); else if (but->type == SCROLL) { - int horizontal = (but->rect.xmax - but->rect.xmin > but->rect.ymax - but->rect.ymin); - float size = (horizontal) ? (but->rect.xmax - but->rect.xmin) : -(but->rect.ymax - but->rect.ymin); + int horizontal = (BLI_RCT_SIZE_X(&but->rect) > BLI_RCT_SIZE_Y(&but->rect)); + float size = (horizontal) ? BLI_RCT_SIZE_X(&but->rect) : -BLI_RCT_SIZE_Y(&but->rect); deler = size * (but->softmax - but->softmin) / (but->softmax - but->softmin + but->a1); } - else deler = (but->rect.xmax - but->rect.xmin - 5.0f * but->aspect); + else deler = (BLI_RCT_SIZE_X(&but->rect) - 5.0f * but->aspect); f = (float)(mx - data->dragstartx) / deler + data->dragfstart; @@ -2830,12 +2830,12 @@ static int ui_do_but_SLI(bContext *C, uiBlock *block, uiBut *but, uiHandleButton #if 0 if (but->type == SLI) { - f = (float)(mx - but->rect.xmin) / (but->rect.xmax - but->rect.xmin); /* same as below */ + f = (float)(mx - but->rect.xmin) / (BLI_RCT_SIZE_X(&but->rect)); /* same as below */ } else #endif { - f = (float)(mx - but->rect.xmin) / (but->rect.xmax - but->rect.xmin); + f = (float)(mx - but->rect.xmin) / (BLI_RCT_SIZE_X(&but->rect)); } f = softmin + f * softrange; @@ -2876,7 +2876,7 @@ static int ui_do_but_SCROLL(bContext *C, uiBlock *block, uiBut *but, uiHandleBut { int mx, my /*, click= 0 */; int retval = WM_UI_HANDLER_CONTINUE; - int horizontal = (but->rect.xmax - but->rect.xmin > but->rect.ymax - but->rect.ymin); + int horizontal = (BLI_RCT_SIZE_X(&but->rect) > BLI_RCT_SIZE_Y(&but->rect)); mx = event->x; my = event->y; @@ -3033,7 +3033,7 @@ static int ui_numedit_but_NORMAL(uiBut *but, uiHandleButtonData *data, int mx, i * else we'll get a harmless but annoying jump when first clicking */ fp = data->origvec; - rad = (but->rect.xmax - but->rect.xmin); + rad = BLI_RCT_SIZE_X(&but->rect); radsq = rad * rad; if (fp[2] > 0.0f) { @@ -3141,8 +3141,8 @@ static int ui_numedit_but_HSVCUBE(uiBut *but, uiHandleButtonData *data, int mx, /* relative position within box */ - x = ((float)mx_fl - but->rect.xmin) / (but->rect.xmax - but->rect.xmin); - y = ((float)my_fl - but->rect.ymin) / (but->rect.ymax - but->rect.ymin); + x = ((float)mx_fl - but->rect.xmin) / BLI_RCT_SIZE_X(&but->rect); + y = ((float)my_fl - but->rect.ymin) / BLI_RCT_SIZE_Y(&but->rect); CLAMP(x, 0.0f, 1.0f); CLAMP(y, 0.0f, 1.0f); @@ -3539,7 +3539,7 @@ static int ui_numedit_but_COLORBAND(uiBut *but, uiHandleButtonData *data, int mx if (data->draglastx == mx) return changed; - dx = ((float)(mx - data->draglastx)) / (but->rect.xmax - but->rect.xmin); + dx = ((float)(mx - data->draglastx)) / BLI_RCT_SIZE_X(&but->rect); data->dragcbd->pos += dx; CLAMP(data->dragcbd->pos, 0.0f, 1.0f); @@ -3568,7 +3568,7 @@ static int ui_do_but_COLORBAND(bContext *C, uiBlock *block, uiBut *but, uiHandle if (event->ctrl) { /* insert new key on mouse location */ - float pos = ((float)(mx - but->rect.xmin)) / (but->rect.xmax - but->rect.xmin); + float pos = ((float)(mx - but->rect.xmin)) / BLI_RCT_SIZE_X(&but->rect); colorband_element_add(coba, pos); button_activate_state(C, but, BUTTON_STATE_EXIT); } @@ -3580,7 +3580,7 @@ static int ui_do_but_COLORBAND(bContext *C, uiBlock *block, uiBut *but, uiHandle /* activate new key when mouse is close */ for (a = 0, cbd = coba->data; a < coba->tot; a++, cbd++) { - xco = but->rect.xmin + (cbd->pos * (but->rect.xmax - but->rect.xmin)); + xco = but->rect.xmin + (cbd->pos * BLI_RCT_SIZE_X(&but->rect)); xco = ABS(xco - mx); if (a == coba->cur) xco += 5; // selected one disadvantage if (xco < mindist) { @@ -3621,8 +3621,8 @@ static int ui_numedit_but_CURVE(uiBut *but, uiHandleButtonData *data, int snap, float fx, fy, zoomx, zoomy /*, offsx, offsy */ /* UNUSED */; int a, changed = 0; - zoomx = (but->rect.xmax - but->rect.xmin) / (cumap->curr.xmax - cumap->curr.xmin); - zoomy = (but->rect.ymax - but->rect.ymin) / (cumap->curr.ymax - cumap->curr.ymin); + zoomx = BLI_RCT_SIZE_X(&but->rect) / BLI_RCT_SIZE_X(&cumap->curr); + zoomy = BLI_RCT_SIZE_Y(&but->rect) / BLI_RCT_SIZE_Y(&cumap->curr); /* offsx= cumap->curr.xmin; */ /* offsy= cumap->curr.ymin; */ @@ -3717,8 +3717,8 @@ static int ui_do_but_CURVE(bContext *C, uiBlock *block, uiBut *but, uiHandleButt float dist, mindist = 200.0f; // 14 pixels radius int sel = -1; - zoomx = (but->rect.xmax - but->rect.xmin) / (cumap->curr.xmax - cumap->curr.xmin); - zoomy = (but->rect.ymax - but->rect.ymin) / (cumap->curr.ymax - cumap->curr.ymin); + zoomx = BLI_RCT_SIZE_X(&but->rect) / BLI_RCT_SIZE_X(&cumap->curr); + zoomy = BLI_RCT_SIZE_Y(&but->rect) / BLI_RCT_SIZE_Y(&cumap->curr); offsx = cumap->curr.xmin; offsy = cumap->curr.ymin; @@ -3862,7 +3862,7 @@ static int ui_numedit_but_HISTOGRAM(uiBut *but, uiHandleButtonData *data, int mx if (in_scope_resize_zone(but, data->dragstartx, data->dragstarty)) { /* resize histogram widget itself */ - hist->height = (but->rect.ymax - but->rect.ymin) + (data->dragstarty - my); + hist->height = BLI_RCT_SIZE_Y(&but->rect) + (data->dragstarty - my); } else { /* scale histogram values (dy / 10 for better control) */ @@ -3946,7 +3946,7 @@ static int ui_numedit_but_WAVEFORM(uiBut *but, uiHandleButtonData *data, int mx, if (in_scope_resize_zone(but, data->dragstartx, data->dragstarty)) { /* resize waveform widget itself */ - scopes->wavefrm_height = (but->rect.ymax - but->rect.ymin) + (data->dragstarty - my); + scopes->wavefrm_height = BLI_RCT_SIZE_Y(&but->rect) + (data->dragstarty - my); } else { /* scale waveform values */ @@ -4028,7 +4028,7 @@ static int ui_numedit_but_VECTORSCOPE(uiBut *but, uiHandleButtonData *data, int if (in_scope_resize_zone(but, data->dragstartx, data->dragstarty)) { /* resize vectorscope widget itself */ - scopes->vecscope_height = (but->rect.ymax - but->rect.ymin) + (data->dragstarty - my); + scopes->vecscope_height = BLI_RCT_SIZE_Y(&but->rect) + (data->dragstarty - my); } data->draglastx = mx; @@ -4098,8 +4098,8 @@ static int ui_do_but_CHARTAB(bContext *UNUSED(C), uiBlock *UNUSED(block), uiBut if (data->state == BUTTON_STATE_HIGHLIGHT) { if (ELEM3(event->type, LEFTMOUSE, PADENTER, RETKEY) && event->val == KM_PRESS) { /* Calculate the size of the button */ - width = abs(but->rect.xmax - but->rect.xmin); - height = abs(but->rect.ymax - but->rect.ymin); + width = abs(BLI_RCT_SIZE_X(&but->rect)); + height = abs(BLI_RCT_SIZE_Y(&but->rect)); butw = floor(width / 12); buth = floor(height / 6); @@ -4231,7 +4231,7 @@ static int ui_numedit_but_TRACKPREVIEW(bContext *C, uiBut *but, uiHandleButtonDa if (in_scope_resize_zone(but, data->dragstartx, data->dragstarty)) { /* resize preview widget itself */ - scopes->track_preview_height = (but->rect.ymax - but->rect.ymin) + (data->dragstarty - my); + scopes->track_preview_height = BLI_RCT_SIZE_Y(&but->rect) + (data->dragstarty - my); } else { if (!scopes->track_locked) { diff --git a/source/blender/editors/interface/interface_panel.c b/source/blender/editors/interface/interface_panel.c index 3bbf5b17312..512cda13df1 100644 --- a/source/blender/editors/interface/interface_panel.c +++ b/source/blender/editors/interface/interface_panel.c @@ -360,11 +360,11 @@ void UI_DrawTriIcon(float x, float y, char dir) static void ui_draw_tria_rect(rctf *rect, char dir) { if (dir == 'h') { - float half = 0.5f * (rect->ymax - rect->ymin); + float half = 0.5f * BLI_RCT_SIZE_Y(rect); ui_draw_anti_tria(rect->xmin, rect->ymin, rect->xmin, rect->ymax, rect->xmax, rect->ymin + half); } else { - float half = 0.5f * (rect->xmax - rect->xmin); + float half = 0.5f * BLI_RCT_SIZE_X(rect); ui_draw_anti_tria(rect->xmin, rect->ymax, rect->xmax, rect->ymax, rect->xmin + half, rect->ymin); } } @@ -483,8 +483,8 @@ static void rectf_scale(rctf *rect, float scale) { float centx = 0.5f * (rect->xmin + rect->xmax); float centy = 0.5f * (rect->ymin + rect->ymax); - float sizex = 0.5f * scale * (rect->xmax - rect->xmin); - float sizey = 0.5f * scale * (rect->ymax - rect->ymin); + float sizex = 0.5f * scale * BLI_RCT_SIZE_X(rect); + float sizey = 0.5f * scale * BLI_RCT_SIZE_Y(rect); rect->xmin = centx - sizex; rect->xmax = centx + sizex; @@ -985,8 +985,8 @@ static void ui_do_drag(const bContext *C, wmEvent *event, Panel *panel) dx = (event->x - data->startx) & ~(PNL_GRID - 1); dy = (event->y - data->starty) & ~(PNL_GRID - 1); - dx *= (float)(ar->v2d.cur.xmax - ar->v2d.cur.xmin) / (float)(ar->winrct.xmax - ar->winrct.xmin); - dy *= (float)(ar->v2d.cur.ymax - ar->v2d.cur.ymin) / (float)(ar->winrct.ymax - ar->winrct.ymin); + dx *= (float)BLI_RCT_SIZE_X(&ar->v2d.cur) / (float)BLI_RCT_SIZE_X(&ar->winrct); + dy *= (float)BLI_RCT_SIZE_Y(&ar->v2d.cur) / (float)BLI_RCT_SIZE_Y(&ar->winrct); if (data->state == PANEL_STATE_DRAG_SCALE) { panel->sizex = MAX2(data->startsizex + dx, UI_PANEL_MINX); diff --git a/source/blender/editors/interface/interface_regions.c b/source/blender/editors/interface/interface_regions.c index c44a45c2150..35488430b22 100644 --- a/source/blender/editors/interface/interface_regions.c +++ b/source/blender/editors/interface/interface_regions.c @@ -1095,13 +1095,13 @@ static void ui_searchbox_region_draw_cb(const bContext *UNUSED(C), ARegion *ar) if (data->items.more) { ui_searchbox_butrect(&rect, data, data->items.maxitem - 1); glEnable(GL_BLEND); - UI_icon_draw((rect.xmax - rect.xmin) / 2, rect.ymin - 9, ICON_TRIA_DOWN); + UI_icon_draw((BLI_RCT_SIZE_X(&rect)) / 2, rect.ymin - 9, ICON_TRIA_DOWN); glDisable(GL_BLEND); } if (data->items.offset) { ui_searchbox_butrect(&rect, data, 0); glEnable(GL_BLEND); - UI_icon_draw((rect.xmax - rect.xmin) / 2, rect.ymax - 7, ICON_TRIA_UP); + UI_icon_draw((BLI_RCT_SIZE_X(&rect)) / 2, rect.ymax - 7, ICON_TRIA_UP); glDisable(GL_BLEND); } } @@ -1176,16 +1176,16 @@ ARegion *ui_searchbox_create(bContext *C, ARegion *butregion, uiBut *but) /* widget rect, in region coords */ data->bbox.xmin = MENU_SHADOW_SIDE; - data->bbox.xmax = (ar->winrct.xmax - ar->winrct.xmin) - MENU_SHADOW_SIDE; + data->bbox.xmax = BLI_RCT_SIZE_X(&ar->winrct) - MENU_SHADOW_SIDE; data->bbox.ymin = MENU_SHADOW_BOTTOM; - data->bbox.ymax = (ar->winrct.ymax - ar->winrct.ymin) - MENU_SHADOW_BOTTOM; + data->bbox.ymax = BLI_RCT_SIZE_Y(&ar->winrct) - MENU_SHADOW_BOTTOM; /* check if button is lower half */ if (but->rect.ymax < BLI_RCT_CENTER_Y(&but->block->rect)) { - data->bbox.ymin += (but->rect.ymax - but->rect.ymin); + data->bbox.ymin += BLI_RCT_SIZE_Y(&but->rect); } else { - data->bbox.ymax -= (but->rect.ymax - but->rect.ymin); + data->bbox.ymax -= BLI_RCT_SIZE_Y(&but->rect); } } else { @@ -1356,15 +1356,15 @@ static void ui_block_position(wmWindow *window, ARegion *butregion, uiBut *but, } } - /* aspect = (float)(block->rect.xmax - block->rect.xmin + 4);*/ /*UNUSED*/ + /* aspect = (float)(BLI_RCT_SIZE_X(&block->rect) + 4);*/ /*UNUSED*/ ui_block_to_window_fl(butregion, but->block, &block->rect.xmin, &block->rect.ymin); ui_block_to_window_fl(butregion, but->block, &block->rect.xmax, &block->rect.ymax); //block->rect.xmin -= 2.0; block->rect.ymin -= 2.0; //block->rect.xmax += 2.0; block->rect.ymax += 2.0; - xsize = block->rect.xmax - block->rect.xmin + 4; /* 4 for shadow */ - ysize = block->rect.ymax - block->rect.ymin + 4; + xsize = BLI_RCT_SIZE_X(&block->rect) + 4; /* 4 for shadow */ + ysize = BLI_RCT_SIZE_Y(&block->rect) + 4; /* aspect /= (float)xsize;*/ /*UNUSED*/ { diff --git a/source/blender/editors/interface/interface_style.c b/source/blender/editors/interface/interface_style.c index 779341160c5..ee0613ea0d0 100644 --- a/source/blender/editors/interface/interface_style.c +++ b/source/blender/editors/interface/interface_style.c @@ -152,17 +152,17 @@ void uiStyleFontDrawExt(uiFontStyle *fs, rcti *rect, const char *str, uiStyleFontSet(fs); height = BLF_ascender(fs->uifont_id); - yofs = ceil(0.5f * (rect->ymax - rect->ymin - height)); + yofs = ceil(0.5f * (BLI_RCT_SIZE_Y(rect) - height)); if (fs->align == UI_STYLE_TEXT_CENTER) { - xofs = floor(0.5f * (rect->xmax - rect->xmin - BLF_width(fs->uifont_id, str))); + xofs = floor(0.5f * (BLI_RCT_SIZE_X(rect) - BLF_width(fs->uifont_id, str))); /* don't center text if it chops off the start of the text, 2 gives some margin */ if (xofs < 2) { xofs = 2; } } else if (fs->align == UI_STYLE_TEXT_RIGHT) { - xofs = rect->xmax - rect->xmin - BLF_width(fs->uifont_id, str) - 1; + xofs = BLI_RCT_SIZE_X(rect) - BLF_width(fs->uifont_id, str) - 1; } /* clip is very strict, so we give it some space */ @@ -209,7 +209,7 @@ void uiStyleFontDrawRotated(uiFontStyle *fs, rcti *rect, const char *str) height = BLF_ascender(fs->uifont_id); /* becomes x-offset when rotated */ - xofs = ceil(0.5f * (rect->ymax - rect->ymin - height)); + xofs = ceil(0.5f * (BLI_RCT_SIZE_Y(rect) - height)); /* ignore UI_STYLE, always aligned to top */ @@ -219,8 +219,8 @@ void uiStyleFontDrawRotated(uiFontStyle *fs, rcti *rect, const char *str) angle = 90.0f; /* translate rect to vertical */ - txtrect.xmin = rect->xmin - (rect->ymax - rect->ymin); - txtrect.ymin = rect->ymin - (rect->xmax - rect->xmin); + txtrect.xmin = rect->xmin - BLI_RCT_SIZE_Y(rect); + txtrect.ymin = rect->ymin - BLI_RCT_SIZE_X(rect); txtrect.xmax = rect->xmin; txtrect.ymax = rect->ymin; diff --git a/source/blender/editors/interface/interface_templates.c b/source/blender/editors/interface/interface_templates.c index 7c4f181b9de..24dccb2eecf 100644 --- a/source/blender/editors/interface/interface_templates.c +++ b/source/blender/editors/interface/interface_templates.c @@ -40,6 +40,7 @@ #include "BLI_utildefines.h" #include "BLI_string.h" #include "BLI_ghash.h" +#include "BLI_rect.h" #include "BLF_translation.h" @@ -1378,7 +1379,7 @@ static void colorband_buttons_large(uiLayout *layout, uiBlock *block, ColorBand static void colorband_buttons_small(uiLayout *layout, uiBlock *block, ColorBand *coba, rctf *butr, RNAUpdateCb *cb) { uiBut *bt; - float unit = (butr->xmax - butr->xmin) / 14.0f; + float unit = BLI_RCT_SIZE_X(butr) / 14.0f; float xs = butr->xmin; uiBlockBeginAlign(block); @@ -1404,7 +1405,7 @@ static void colorband_buttons_small(uiLayout *layout, uiBlock *block, ColorBand TIP_("Set interpolation between color stops")); uiButSetNFunc(bt, rna_update_cb, MEM_dupallocN(cb), NULL); - bt = uiDefBut(block, BUT_COLORBAND, 0, "", xs, butr->ymin, butr->xmax - butr->xmin, UI_UNIT_Y, coba, 0, 0, 0, 0, ""); + bt = uiDefBut(block, BUT_COLORBAND, 0, "", xs, butr->ymin, BLI_RCT_SIZE_X(butr), UI_UNIT_Y, coba, 0, 0, 0, 0, ""); uiButSetNFunc(bt, rna_update_cb, MEM_dupallocN(cb), NULL); uiBlockEndAlign(block); @@ -1479,7 +1480,7 @@ void uiTemplateHistogram(uiLayout *layout, PointerRNA *ptr, const char *propname hist->height = (hist->height <= UI_UNIT_Y) ? UI_UNIT_Y : hist->height; - bt = uiDefBut(block, HISTOGRAM, 0, "", rect.xmin, rect.ymin, rect.xmax - rect.xmin, hist->height, hist, 0, 0, 0, 0, ""); + bt = uiDefBut(block, HISTOGRAM, 0, "", rect.xmin, rect.ymin, BLI_RCT_SIZE_X(&rect), hist->height, hist, 0, 0, 0, 0, ""); uiButSetNFunc(bt, rna_update_cb, MEM_dupallocN(cb), NULL); MEM_freeN(cb); @@ -1516,7 +1517,7 @@ void uiTemplateWaveform(uiLayout *layout, PointerRNA *ptr, const char *propname) scopes->wavefrm_height = (scopes->wavefrm_height <= UI_UNIT_Y) ? UI_UNIT_Y : scopes->wavefrm_height; - bt = uiDefBut(block, WAVEFORM, 0, "", rect.xmin, rect.ymin, rect.xmax - rect.xmin, scopes->wavefrm_height, scopes, 0, 0, 0, 0, ""); + bt = uiDefBut(block, WAVEFORM, 0, "", rect.xmin, rect.ymin, BLI_RCT_SIZE_X(&rect), scopes->wavefrm_height, scopes, 0, 0, 0, 0, ""); (void)bt; /* UNUSED */ MEM_freeN(cb); @@ -1553,7 +1554,7 @@ void uiTemplateVectorscope(uiLayout *layout, PointerRNA *ptr, const char *propna scopes->vecscope_height = (scopes->vecscope_height <= UI_UNIT_Y) ? UI_UNIT_Y : scopes->vecscope_height; - bt = uiDefBut(block, VECTORSCOPE, 0, "", rect.xmin, rect.ymin, rect.xmax - rect.xmin, scopes->vecscope_height, scopes, 0, 0, 0, 0, ""); + bt = uiDefBut(block, VECTORSCOPE, 0, "", rect.xmin, rect.ymin, BLI_RCT_SIZE_X(&rect), scopes->vecscope_height, scopes, 0, 0, 0, 0, ""); uiButSetNFunc(bt, rna_update_cb, MEM_dupallocN(cb), NULL); MEM_freeN(cb); @@ -1568,11 +1569,11 @@ static void curvemap_buttons_zoom_in(bContext *C, void *cumap_v, void *UNUSED(ar float d; /* we allow 20 times zoom */ - if ( (cumap->curr.xmax - cumap->curr.xmin) > 0.04f * (cumap->clipr.xmax - cumap->clipr.xmin) ) { - d = 0.1154f * (cumap->curr.xmax - cumap->curr.xmin); + if (BLI_RCT_SIZE_X(&cumap->curr) > 0.04f * BLI_RCT_SIZE_X(&cumap->clipr)) { + d = 0.1154f * BLI_RCT_SIZE_X(&cumap->curr); cumap->curr.xmin += d; cumap->curr.xmax -= d; - d = 0.1154f * (cumap->curr.ymax - cumap->curr.ymin); + d = 0.1154f * BLI_RCT_SIZE_Y(&cumap->curr); cumap->curr.ymin += d; cumap->curr.ymax -= d; } @@ -1586,8 +1587,8 @@ static void curvemap_buttons_zoom_out(bContext *C, void *cumap_v, void *UNUSED(u float d, d1; /* we allow 20 times zoom, but don't view outside clip */ - if ( (cumap->curr.xmax - cumap->curr.xmin) < 20.0f * (cumap->clipr.xmax - cumap->clipr.xmin) ) { - d = d1 = 0.15f * (cumap->curr.xmax - cumap->curr.xmin); + if (BLI_RCT_SIZE_X(&cumap->curr) < 20.0f * BLI_RCT_SIZE_X(&cumap->clipr)) { + d = d1 = 0.15f * BLI_RCT_SIZE_X(&cumap->curr); if (cumap->flag & CUMA_DO_CLIP) if (cumap->curr.xmin - d < cumap->clipr.xmin) @@ -1600,7 +1601,7 @@ static void curvemap_buttons_zoom_out(bContext *C, void *cumap_v, void *UNUSED(u d1 = -cumap->curr.xmax + cumap->clipr.xmax; cumap->curr.xmax += d1; - d = d1 = 0.15f * (cumap->curr.ymax - cumap->curr.ymin); + d = d1 = 0.15f * BLI_RCT_SIZE_Y(&cumap->curr); if (cumap->flag & CUMA_DO_CLIP) if (cumap->curr.ymin - d < cumap->clipr.ymin) diff --git a/source/blender/editors/interface/interface_widgets.c b/source/blender/editors/interface/interface_widgets.c index 3c944781d80..bf5b3fbe8c7 100644 --- a/source/blender/editors/interface/interface_widgets.c +++ b/source/blender/editors/interface/interface_widgets.c @@ -260,8 +260,8 @@ static int round_box_shadow_edges(float (*vert)[2], rcti *rect, float rad, int r rad += step; - if (2.0f * rad > rect->ymax - rect->ymin) - rad = 0.5f * (rect->ymax - rect->ymin); + if (2.0f * rad > BLI_RCT_SIZE_Y(rect)) + rad = 0.5f * BLI_RCT_SIZE_Y(rect); minx = rect->xmin - step; miny = rect->ymin - step; @@ -346,8 +346,8 @@ static void round_box__edges(uiWidgetBase *wt, int roundboxalign, rcti *rect, fl const int vnum = ((roundboxalign & (UI_CNR_TOP_LEFT | UI_CNR_BOTTOM_LEFT)) == (UI_CNR_TOP_LEFT | UI_CNR_BOTTOM_LEFT) || (roundboxalign & (UI_CNR_TOP_RIGHT | UI_CNR_BOTTOM_RIGHT)) == (UI_CNR_TOP_RIGHT | UI_CNR_BOTTOM_RIGHT)) ? 1 : 2; - minsize = mini((rect->xmax - rect->xmin) * hnum, - (rect->ymax - rect->ymin) * vnum); + minsize = mini(BLI_RCT_SIZE_X(rect) * hnum, + BLI_RCT_SIZE_Y(rect) * vnum); if (2.0f * rad > minsize) rad = 0.5f * minsize; @@ -492,7 +492,7 @@ static void widget_num_tria(uiWidgetTrias *tria, rcti *rect, float triasize, cha float centx, centy, sizex, sizey, minsize; int a, i1 = 0, i2 = 1; - minsize = MIN2(rect->xmax - rect->xmin, rect->ymax - rect->ymin); + minsize = mini(BLI_RCT_SIZE_X(rect), BLI_RCT_SIZE_Y(rect)); /* center position and size */ centx = (float)rect->xmin + 0.5f * minsize; @@ -527,7 +527,7 @@ static void widget_scroll_circle(uiWidgetTrias *tria, rcti *rect, float triasize float centx, centy, sizex, sizey, minsize; int a, i1 = 0, i2 = 1; - minsize = MIN2(rect->xmax - rect->xmin, rect->ymax - rect->ymin); + minsize = mini(BLI_RCT_SIZE_X(rect), BLI_RCT_SIZE_Y(rect)); /* center position and size */ centx = (float)rect->xmin + 0.5f * minsize; @@ -571,14 +571,14 @@ static void widget_menu_trias(uiWidgetTrias *tria, rcti *rect) int a; /* center position and size */ - centx = rect->xmax - 0.5f * (rect->ymax - rect->ymin); - centy = rect->ymin + 0.5f * (rect->ymax - rect->ymin); - size = 0.4f * (rect->ymax - rect->ymin); + centx = rect->xmax - 0.5f * BLI_RCT_SIZE_Y(rect); + centy = rect->ymin + 0.5f * BLI_RCT_SIZE_Y(rect); + size = 0.4f * BLI_RCT_SIZE_Y(rect); /* XXX exception */ - asp = ((float)rect->xmax - rect->xmin) / ((float)rect->ymax - rect->ymin); + asp = ((float)BLI_RCT_SIZE_X(rect)) / ((float)BLI_RCT_SIZE_Y(rect)); if (asp > 1.2f && asp < 2.6f) - centx = rect->xmax - 0.3f * (rect->ymax - rect->ymin); + centx = rect->xmax - 0.3f * BLI_RCT_SIZE_Y(rect); for (a = 0; a < 6; a++) { tria->vec[a][0] = size * menu_tria_vert[a][0] + centx; @@ -595,9 +595,9 @@ static void widget_check_trias(uiWidgetTrias *tria, rcti *rect) int a; /* center position and size */ - centx = rect->xmin + 0.5f * (rect->ymax - rect->ymin); - centy = rect->ymin + 0.5f * (rect->ymax - rect->ymin); - size = 0.5f * (rect->ymax - rect->ymin); + centx = rect->xmin + 0.5f * BLI_RCT_SIZE_Y(rect); + centy = rect->ymin + 0.5f * BLI_RCT_SIZE_Y(rect); + size = 0.5f * BLI_RCT_SIZE_Y(rect); for (a = 0; a < 6; a++) { tria->vec[a][0] = size * check_tria_vert[a][0] + centx; @@ -841,8 +841,8 @@ static void widget_draw_preview(BIFIconID icon, float UNUSED(alpha), rcti *rect) if (icon == ICON_NONE) return; - w = rect->xmax - rect->xmin; - h = rect->ymax - rect->ymin; + w = BLI_RCT_SIZE_X(rect); + h = BLI_RCT_SIZE_Y(rect); size = MIN2(w, h); size -= PREVIEW_PAD * 2; /* padding */ @@ -970,7 +970,7 @@ static void ui_text_clip_give_next_off(uiBut *but) static void ui_text_leftclip(uiFontStyle *fstyle, uiBut *but, rcti *rect) { int border = (but->flag & UI_BUT_ALIGN_RIGHT) ? 8 : 10; - int okwidth = rect->xmax - rect->xmin - border; + int okwidth = BLI_RCT_SIZE_X(rect) - border; if (but->flag & UI_HAS_ICON) okwidth -= UI_DPI_ICON_SIZE; @@ -1033,7 +1033,7 @@ static void ui_text_leftclip(uiFontStyle *fstyle, uiBut *but, rcti *rect) static void ui_text_label_rightclip(uiFontStyle *fstyle, uiBut *but, rcti *rect) { int border = (but->flag & UI_BUT_ALIGN_RIGHT) ? 8 : 10; - int okwidth = rect->xmax - rect->xmin - border; + int okwidth = BLI_RCT_SIZE_X(rect) - border; char *cpoin = NULL; char *cpend = but->drawstr + strlen(but->drawstr); @@ -1265,7 +1265,7 @@ static void widget_draw_text_icon(uiFontStyle *fstyle, uiWidgetColors *wcol, uiB } else if (but->type == MENU && (but->flag & UI_BUT_NODE_LINK)) { int tmp = rect->xmin; - rect->xmin = rect->xmax - (rect->ymax - rect->ymin) - 1; + rect->xmin = rect->xmax - BLI_RCT_SIZE_Y(rect) - 1; widget_draw_icon(but, ICON_LAYER_USED, 1.0f, rect); rect->xmin = tmp; } @@ -1847,10 +1847,10 @@ void ui_hsvcircle_vals_from_pos(float *valrad, float *valdist, rcti *rect, float float centy = BLI_RCT_CENTER_Y_FL(rect); float radius, dist; - if (rect->xmax - rect->xmin > rect->ymax - rect->ymin) - radius = (float)(rect->ymax - rect->ymin) / 2; + if (BLI_RCT_SIZE_X(rect) > BLI_RCT_SIZE_Y(rect)) + radius = (float)BLI_RCT_SIZE_Y(rect) / 2; else - radius = (float)(rect->xmax - rect->xmin) / 2; + radius = (float)BLI_RCT_SIZE_X(rect) / 2; mx -= centx; my -= centy; @@ -1879,10 +1879,10 @@ static void ui_draw_but_HSVCIRCLE(uiBut *but, uiWidgetColors *wcol, rcti *rect) centx = BLI_RCT_CENTER_X_FL(rect); centy = BLI_RCT_CENTER_Y_FL(rect); - if (rect->xmax - rect->xmin > rect->ymax - rect->ymin) - radius = (float)(rect->ymax - rect->ymin) / 2; + if (BLI_RCT_SIZE_X(rect) > BLI_RCT_SIZE_Y(rect)) + radius = (float)BLI_RCT_SIZE_Y(rect) / 2; else - radius = (float)(rect->xmax - rect->xmin) / 2; + radius = (float)BLI_RCT_SIZE_X(rect) / 2; /* color */ ui_get_but_vectorf(but, rgb); @@ -2058,10 +2058,10 @@ void ui_draw_gradient(rcti *rect, const float hsv[3], const int type, const floa } /* rect */ - sx1 = rect->xmin + dx * (rect->xmax - rect->xmin); - sx2 = rect->xmin + (dx + color_step) * (rect->xmax - rect->xmin); + sx1 = rect->xmin + dx * BLI_RCT_SIZE_X(rect); + sx2 = rect->xmin + (dx + color_step) * BLI_RCT_SIZE_X(rect); sy = rect->ymin; - dy = (rect->ymax - rect->ymin) / 3.0; + dy = BLI_RCT_SIZE_Y(rect) / 3.0; glBegin(GL_QUADS); for (a = 0; a < 3; a++, sy += dy) { @@ -2116,8 +2116,8 @@ static void ui_draw_but_HSVCUBE(uiBut *but, rcti *rect) } /* cursor */ - x = rect->xmin + x * (rect->xmax - rect->xmin); - y = rect->ymin + y * (rect->ymax - rect->ymin); + x = rect->xmin + x * BLI_RCT_SIZE_X(rect); + y = rect->ymin + y * BLI_RCT_SIZE_Y(rect); CLAMP(x, rect->xmin + 3.0f, rect->xmax - 3.0f); CLAMP(y, rect->ymin + 3.0f, rect->ymax - 3.0f); @@ -2132,7 +2132,7 @@ static void ui_draw_but_HSVCUBE(uiBut *but, rcti *rect) static void ui_draw_but_HSV_v(uiBut *but, rcti *rect) { uiWidgetBase wtb; - float rad = 0.5f * (rect->xmax - rect->xmin); + float rad = 0.5f * BLI_RCT_SIZE_X(rect); float x, y; float rgb[3], hsv[3], v, range; int color_profile = but->block->color_profile; @@ -2166,8 +2166,8 @@ static void ui_draw_but_HSV_v(uiBut *but, rcti *rect) widgetbase_draw(&wtb, &wcol_tmp); /* cursor */ - x = rect->xmin + 0.5f * (rect->xmax - rect->xmin); - y = rect->ymin + v * (rect->ymax - rect->ymin); + x = rect->xmin + 0.5f * BLI_RCT_SIZE_X(rect); + y = rect->ymin + v * BLI_RCT_SIZE_Y(rect); CLAMP(y, rect->ymin + 3.0f, rect->ymax - 3.0f); ui_hsv_cursor(x, y); @@ -2178,7 +2178,7 @@ static void ui_draw_but_HSV_v(uiBut *but, rcti *rect) /* ************ separator, for menus etc ***************** */ static void ui_draw_separator(rcti *rect, uiWidgetColors *wcol) { - int y = rect->ymin + (rect->ymax - rect->ymin) / 2 - 1; + int y = rect->ymin + BLI_RCT_SIZE_Y(rect) / 2 - 1; unsigned char col[4]; col[0] = wcol->text[0]; @@ -2197,7 +2197,7 @@ static void ui_draw_separator(rcti *rect, uiWidgetColors *wcol) static void widget_numbut(uiWidgetColors *wcol, rcti *rect, int state, int roundboxalign) { uiWidgetBase wtb; - float rad = 0.5f * (rect->ymax - rect->ymin); + float rad = 0.5f * BLI_RCT_SIZE_Y(rect); float textofs = rad * 0.75f; if (state & UI_SELECT) @@ -2278,12 +2278,12 @@ void uiWidgetScrollDraw(uiWidgetColors *wcol, rcti *rect, rcti *slider, int stat widget_init(&wtb); /* determine horizontal/vertical */ - horizontal = (rect->xmax - rect->xmin > rect->ymax - rect->ymin); + horizontal = (BLI_RCT_SIZE_X(rect) > BLI_RCT_SIZE_Y(rect)); if (horizontal) - rad = 0.5f * (rect->ymax - rect->ymin); + rad = 0.5f * BLI_RCT_SIZE_Y(rect); else - rad = 0.5f * (rect->xmax - rect->xmin); + rad = 0.5f * BLI_RCT_SIZE_X(rect); wtb.shadedir = (horizontal) ? 1 : 0; @@ -2295,9 +2295,10 @@ void uiWidgetScrollDraw(uiWidgetColors *wcol, rcti *rect, rcti *slider, int stat widgetbase_draw(&wtb, wcol); /* slider */ - if (slider->xmax - slider->xmin < 2 || slider->ymax - slider->ymin < 2) ; + if ((BLI_RCT_SIZE_X(slider) < 2) || (BLI_RCT_SIZE_Y(slider) < 2)) { + /* pass */ + } else { - SWAP(short, wcol->shadetop, wcol->shadedown); copy_v4_v4_char(wcol->inner, wcol->item); @@ -2360,15 +2361,15 @@ static void widget_scroll(uiBut *but, uiWidgetColors *wcol, rcti *rect, int stat rect1 = *rect; /* determine horizontal/vertical */ - horizontal = (rect->xmax - rect->xmin > rect->ymax - rect->ymin); + horizontal = (BLI_RCT_SIZE_X(rect) > BLI_RCT_SIZE_Y(rect)); if (horizontal) { - fac = (rect->xmax - rect->xmin) / (size); + fac = BLI_RCT_SIZE_X(rect) / size; rect1.xmin = rect1.xmin + ceilf(fac * ((float)value - but->softmin)); rect1.xmax = rect1.xmin + ceilf(fac * (but->a1 - but->softmin)); /* ensure minimium size */ - min = rect->ymax - rect->ymin; + min = BLI_RCT_SIZE_Y(rect); if (rect1.xmax - rect1.xmin < min) { rect1.xmax = rect1.xmin + min; @@ -2380,12 +2381,12 @@ static void widget_scroll(uiBut *but, uiWidgetColors *wcol, rcti *rect, int stat } } else { - fac = (rect->ymax - rect->ymin) / (size); + fac = BLI_RCT_SIZE_Y(rect) / size; rect1.ymax = rect1.ymax - ceilf(fac * ((float)value - but->softmin)); rect1.ymin = rect1.ymax - ceilf(fac * (but->a1 - but->softmin)); /* ensure minimium size */ - min = rect->xmax - rect->xmin; + min = BLI_RCT_SIZE_X(rect); if (rect1.ymax - rect1.ymin < min) { rect1.ymax = rect1.ymin + min; @@ -2461,7 +2462,7 @@ static void widget_numslider(uiBut *but, uiWidgetColors *wcol, rcti *rect, int s /* backdrop first */ /* fully rounded */ - offs = 0.5f * (rect->ymax - rect->ymin); + offs = 0.5f * BLI_RCT_SIZE_Y(rect); toffs = offs * 0.75f; round_box_edges(&wtb, roundboxalign, rect, offs); @@ -2615,7 +2616,7 @@ static void widget_menubut(uiWidgetColors *wcol, rcti *rect, int UNUSED(state), widgetbase_draw(&wtb, wcol); /* text space */ - rect->xmax -= (rect->ymax - rect->ymin); + rect->xmax -= BLI_RCT_SIZE_Y(rect); } static void widget_menuiconbut(uiWidgetColors *wcol, rcti *rect, int UNUSED(state), int roundboxalign) @@ -2658,7 +2659,7 @@ static void widget_pulldownbut(uiWidgetColors *wcol, rcti *rect, int state, int { if (state & UI_ACTIVE) { uiWidgetBase wtb; - float rad = 0.5f * (rect->ymax - rect->ymin); /* 4.0f */ + float rad = 0.5f * BLI_RCT_SIZE_Y(rect); /* 4.0f */ widget_init(&wtb); @@ -2724,7 +2725,7 @@ static void widget_optionbut(uiWidgetColors *wcol, rcti *rect, int state, int UN widgetbase_draw(&wtb, wcol); /* text space */ - rect->xmin += (rect->ymax - rect->ymin) * 0.7 + delta; + rect->xmin += BLI_RCT_SIZE_Y(rect) * 0.7 + delta; } @@ -2786,7 +2787,7 @@ static void widget_but(uiWidgetColors *wcol, rcti *rect, int UNUSED(state), int static void widget_roundbut(uiWidgetColors *wcol, rcti *rect, int UNUSED(state), int roundboxalign) { uiWidgetBase wtb; - float rad = 5.0f; /* 0.5f * (rect->ymax - rect->ymin); */ + float rad = 5.0f; /* 0.5f * BLI_RCT_SIZE_Y(rect); */ widget_init(&wtb); diff --git a/source/blender/editors/interface/view2d.c b/source/blender/editors/interface/view2d.c index d498f57e8e3..86322b0c0ea 100644 --- a/source/blender/editors/interface/view2d.c +++ b/source/blender/editors/interface/view2d.c @@ -96,11 +96,11 @@ static void view2d_masks(View2D *v2d) /* check size if: */ if (v2d->scroll & V2D_SCROLL_HORIZONTAL) if (!(v2d->scroll & V2D_SCROLL_SCALE_HORIZONTAL)) - if (v2d->tot.xmax - v2d->tot.xmin <= v2d->cur.xmax - v2d->cur.xmin) + if (BLI_RCT_SIZE_X(&v2d->tot) <= BLI_RCT_SIZE_X(&v2d->cur)) v2d->scroll |= V2D_SCROLL_HORIZONTAL_HIDE; if (v2d->scroll & V2D_SCROLL_VERTICAL) if (!(v2d->scroll & V2D_SCROLL_SCALE_VERTICAL)) - if (v2d->tot.ymax - v2d->tot.ymin <= v2d->cur.ymax - v2d->cur.ymin) + if (BLI_RCT_SIZE_Y(&v2d->tot) <= BLI_RCT_SIZE_Y(&v2d->cur)) v2d->scroll |= V2D_SCROLL_VERTICAL_HIDE; #endif scroll = view2d_scroll_mapped(v2d->scroll); @@ -328,8 +328,8 @@ void UI_view2d_curRect_validate_resize(View2D *v2d, int resize) rctf *cur, *tot; /* use mask as size of region that View2D resides in, as it takes into account scrollbars already */ - winx = (float)(v2d->mask.xmax - v2d->mask.xmin + 1); - winy = (float)(v2d->mask.ymax - v2d->mask.ymin + 1); + winx = (float)(BLI_RCT_SIZE_X(&v2d->mask) + 1); + winy = (float)(BLI_RCT_SIZE_Y(&v2d->mask) + 1); /* get pointers to rcts for less typing */ cur = &v2d->cur; @@ -347,10 +347,10 @@ void UI_view2d_curRect_validate_resize(View2D *v2d, int resize) * - firstly, we calculate the sizes of the rects * - curwidth and curheight are saved as reference... modify width and height values here */ - totwidth = tot->xmax - tot->xmin; - totheight = tot->ymax - tot->ymin; - curwidth = width = cur->xmax - cur->xmin; - curheight = height = cur->ymax - cur->ymin; + totwidth = BLI_RCT_SIZE_X(tot); + totheight = BLI_RCT_SIZE_Y(tot); + curwidth = width = BLI_RCT_SIZE_X(cur); + curheight = height = BLI_RCT_SIZE_Y(cur); /* if zoom is locked, size on the appropriate axis is reset to mask size */ if (v2d->keepzoom & V2D_LOCKZOOM_X) @@ -499,13 +499,13 @@ void UI_view2d_curRect_validate_resize(View2D *v2d, int resize) /* resize from centerpoint, unless otherwise specified */ if (width != curwidth) { if (v2d->keepofs & V2D_LOCKOFS_X) { - cur->xmax += width - (cur->xmax - cur->xmin); + cur->xmax += width - BLI_RCT_SIZE_X(cur); } else if (v2d->keepofs & V2D_KEEPOFS_X) { if (v2d->align & V2D_ALIGN_NO_POS_X) - cur->xmin -= width - (cur->xmax - cur->xmin); + cur->xmin -= width - BLI_RCT_SIZE_X(cur); else - cur->xmax += width - (cur->xmax - cur->xmin); + cur->xmax += width - BLI_RCT_SIZE_X(cur); } else { temp = BLI_RCT_CENTER_X(cur); @@ -517,13 +517,13 @@ void UI_view2d_curRect_validate_resize(View2D *v2d, int resize) } if (height != curheight) { if (v2d->keepofs & V2D_LOCKOFS_Y) { - cur->ymax += height - (cur->ymax - cur->ymin); + cur->ymax += height - BLI_RCT_SIZE_Y(cur); } else if (v2d->keepofs & V2D_KEEPOFS_Y) { if (v2d->align & V2D_ALIGN_NO_POS_Y) - cur->ymin -= height - (cur->ymax - cur->ymin); + cur->ymin -= height - BLI_RCT_SIZE_Y(cur); else - cur->ymax += height - (cur->ymax - cur->ymin); + cur->ymax += height - BLI_RCT_SIZE_Y(cur); } else { temp = BLI_RCT_CENTER_Y(cur); @@ -540,8 +540,8 @@ void UI_view2d_curRect_validate_resize(View2D *v2d, int resize) float temp, diff; /* recalculate extents of cur */ - curwidth = cur->xmax - cur->xmin; - curheight = cur->ymax - cur->ymin; + curwidth = BLI_RCT_SIZE_X(cur); + curheight = BLI_RCT_SIZE_Y(cur); /* width */ if ( (curwidth > totwidth) && !(v2d->keepzoom & (V2D_KEEPZOOM | V2D_LOCKZOOM_X | V2D_LIMITZOOM)) ) { @@ -791,8 +791,8 @@ void UI_view2d_curRect_reset(View2D *v2d) float width, height; /* assume width and height of 'cur' rect by default, should be same size as mask */ - width = (float)(v2d->mask.xmax - v2d->mask.xmin + 1); - height = (float)(v2d->mask.ymax - v2d->mask.ymin + 1); + width = (float)(BLI_RCT_SIZE_X(&v2d->mask) + 1); + height = (float)(BLI_RCT_SIZE_Y(&v2d->mask) + 1); /* handle width - posx and negx flags are mutually exclusive, so watch out */ if ((v2d->align & V2D_ALIGN_NO_POS_X) && !(v2d->align & V2D_ALIGN_NO_NEG_X)) { @@ -958,8 +958,8 @@ static void view2d_map_cur_using_mask(View2D *v2d, rctf *curmasked) *curmasked = v2d->cur; if (view2d_scroll_mapped(v2d->scroll)) { - float dx = (v2d->cur.xmax - v2d->cur.xmin) / ((float)(v2d->mask.xmax - v2d->mask.xmin + 1)); - float dy = (v2d->cur.ymax - v2d->cur.ymin) / ((float)(v2d->mask.ymax - v2d->mask.ymin + 1)); + float dx = BLI_RCT_SIZE_X(&v2d->cur) / ((float)(BLI_RCT_SIZE_X(&v2d->mask) + 1)); + float dy = BLI_RCT_SIZE_Y(&v2d->cur) / ((float)(BLI_RCT_SIZE_Y(&v2d->mask) + 1)); if (v2d->mask.xmin != 0) curmasked->xmin -= dx * (float)v2d->mask.xmin; @@ -985,8 +985,8 @@ void UI_view2d_view_ortho(View2D *v2d) */ /* XXX brecht: instead of zero at least use a tiny offset, otherwise * pixel rounding is effectively random due to float inaccuracy */ - xofs = 0.001f * (v2d->cur.xmax - v2d->cur.xmin) / (v2d->mask.xmax - v2d->mask.xmin); - yofs = 0.001f * (v2d->cur.ymax - v2d->cur.ymin) / (v2d->mask.ymax - v2d->mask.ymin); + xofs = 0.001f * BLI_RCT_SIZE_X(&v2d->cur) / BLI_RCT_SIZE_X(&v2d->mask); + yofs = 0.001f * BLI_RCT_SIZE_Y(&v2d->cur) / BLI_RCT_SIZE_Y(&v2d->mask); /* apply mask-based adjustments to cur rect (due to scrollers), to eliminate scaling artifacts */ view2d_map_cur_using_mask(v2d, &curmasked); @@ -1044,8 +1044,8 @@ void UI_view2d_view_orthoSpecial(ARegion *ar, View2D *v2d, short xaxis) void UI_view2d_view_restore(const bContext *C) { ARegion *ar = CTX_wm_region(C); - int width = ar->winrct.xmax - ar->winrct.xmin + 1; - int height = ar->winrct.ymax - ar->winrct.ymin + 1; + int width = BLI_RCT_SIZE_X(&ar->winrct) + 1; + int height = BLI_RCT_SIZE_Y(&ar->winrct) + 1; wmOrtho2(0.0f, (float)width, 0.0f, (float)height); glLoadIdentity(); @@ -1140,8 +1140,8 @@ View2DGrid *UI_view2d_grid_calc(Scene *scene, View2D *v2d, short xunits, short x /* calculate x-axis grid scale (only if both args are valid) */ if (ELEM(V2D_ARG_DUMMY, xunits, xclamp) == 0) { - space = v2d->cur.xmax - v2d->cur.xmin; - pixels = (float)(v2d->mask.xmax - v2d->mask.xmin); + space = BLI_RCT_SIZE_X(&v2d->cur); + pixels = (float)BLI_RCT_SIZE_X(&v2d->mask); if (pixels != 0.0f) { grid->dx = (U.v2d_min_gridsize * space) / (seconddiv * pixels); @@ -1158,7 +1158,7 @@ View2DGrid *UI_view2d_grid_calc(Scene *scene, View2D *v2d, short xunits, short x /* calculate y-axis grid scale (only if both args are valid) */ if (ELEM(V2D_ARG_DUMMY, yunits, yclamp) == 0) { - space = v2d->cur.ymax - v2d->cur.ymin; + space = BLI_RCT_SIZE_Y(&v2d->cur); pixels = (float)winy; grid->dy = U.v2d_min_gridsize * space / pixels; @@ -1206,7 +1206,7 @@ void UI_view2d_grid_draw(View2D *v2d, View2DGrid *grid, int flag) vec2[1] = v2d->cur.ymax; /* minor gridlines */ - step = (v2d->mask.xmax - v2d->mask.xmin + 1) / U.v2d_min_gridsize; + step = (BLI_RCT_SIZE_X(&v2d->mask) + 1) / U.v2d_min_gridsize; UI_ThemeColor(TH_GRID); for (a = 0; a < step; a++) { @@ -1240,7 +1240,7 @@ void UI_view2d_grid_draw(View2D *v2d, View2DGrid *grid, int flag) vec1[0] = grid->startx; vec2[0] = v2d->cur.xmax; - step = (v2d->mask.ymax - v2d->mask.ymin + 1) / U.v2d_min_gridsize; + step = (BLI_RCT_SIZE_Y(&v2d->mask) + 1) / U.v2d_min_gridsize; UI_ThemeColor(TH_GRID); for (a = 0; a <= step; a++) { @@ -1457,7 +1457,7 @@ View2DScrollers *UI_view2d_scrollers_calc(const bContext *C, View2D *v2d, short /* horizontal scrollers */ if (scroll & V2D_SCROLL_HORIZONTAL) { /* scroller 'button' extents */ - totsize = v2d->tot.xmax - v2d->tot.xmin; + totsize = BLI_RCT_SIZE_X(&v2d->tot); scrollsize = (float)(hor.xmax - hor.xmin); if (totsize == 0.0f) totsize = 1.0f; /* avoid divide by zero */ @@ -1498,7 +1498,7 @@ View2DScrollers *UI_view2d_scrollers_calc(const bContext *C, View2D *v2d, short /* vertical scrollers */ if (scroll & V2D_SCROLL_VERTICAL) { /* scroller 'button' extents */ - totsize = v2d->tot.ymax - v2d->tot.ymin; + totsize = BLI_RCT_SIZE_Y(&v2d->tot); scrollsize = (float)(vert.ymax - vert.ymin); if (totsize == 0.0f) totsize = 1.0f; /* avoid divide by zero */ @@ -1649,10 +1649,10 @@ void UI_view2d_scrollers_draw(const bContext *C, View2D *v2d, View2DScrollers *v * - fac is x-coordinate to draw to * - dfac is gap between scale markings */ - fac = (grid->startx - v2d->cur.xmin) / (v2d->cur.xmax - v2d->cur.xmin); + fac = (grid->startx - v2d->cur.xmin) / BLI_RCT_SIZE_X(&v2d->cur); fac = (float)hor.xmin + fac * (hor.xmax - hor.xmin); - dfac = (grid->dx) / (v2d->cur.xmax - v2d->cur.xmin); + dfac = grid->dx / BLI_RCT_SIZE_X(&v2d->cur); dfac = dfac * (hor.xmax - hor.xmin); /* set starting value, and text color */ @@ -1763,10 +1763,10 @@ void UI_view2d_scrollers_draw(const bContext *C, View2D *v2d, View2DScrollers *v * - these involve a correction for horizontal scrollbar * NOTE: it's assumed that that scrollbar is there if this is involved! */ - fac = (grid->starty - v2d->cur.ymin) / (v2d->cur.ymax - v2d->cur.ymin); + fac = (grid->starty - v2d->cur.ymin) / BLI_RCT_SIZE_Y(&v2d->cur); fac = vert.ymin + fac * (vert.ymax - vert.ymin); - dfac = (grid->dy) / (v2d->cur.ymax - v2d->cur.ymin); + dfac = grid->dy / BLI_RCT_SIZE_Y(&v2d->cur); dfac = dfac * (vert.ymax - vert.ymin); /* set starting value, and text color */ @@ -1925,17 +1925,17 @@ void UI_view2d_region_to_view(View2D *v2d, int x, int y, float *r_viewx, float * float div, ofs; if (r_viewx) { - div = (float)(v2d->mask.xmax - v2d->mask.xmin); + div = (float)BLI_RCT_SIZE_X(&v2d->mask); ofs = (float)v2d->mask.xmin; - *r_viewx = v2d->cur.xmin + (v2d->cur.xmax - v2d->cur.xmin) * ((float)x - ofs) / div; + *r_viewx = v2d->cur.xmin + BLI_RCT_SIZE_X(&v2d->cur) * ((float)x - ofs) / div; } if (r_viewy) { - div = (float)(v2d->mask.ymax - v2d->mask.ymin); + div = (float)BLI_RCT_SIZE_Y(&v2d->mask); ofs = (float)v2d->mask.ymin; - *r_viewy = v2d->cur.ymin + (v2d->cur.ymax - v2d->cur.ymin) * ((float)y - ofs) / div; + *r_viewy = v2d->cur.ymin + BLI_RCT_SIZE_Y(&v2d->cur) * ((float)y - ofs) / div; } } @@ -1954,15 +1954,15 @@ void UI_view2d_view_to_region(View2D *v2d, float x, float y, int *regionx, int * *regiony = V2D_IS_CLIPPED; /* express given coordinates as proportional values */ - x = (x - v2d->cur.xmin) / (v2d->cur.xmax - v2d->cur.xmin); - y = (y - v2d->cur.ymin) / (v2d->cur.ymax - v2d->cur.ymin); + x = (x - v2d->cur.xmin) / BLI_RCT_SIZE_X(&v2d->cur); + y = (y - v2d->cur.ymin) / BLI_RCT_SIZE_Y(&v2d->cur); /* check if values are within bounds */ if ((x >= 0.0f) && (x <= 1.0f) && (y >= 0.0f) && (y <= 1.0f)) { if (regionx) - *regionx = (int)(v2d->mask.xmin + x * (v2d->mask.xmax - v2d->mask.xmin)); + *regionx = (int)(v2d->mask.xmin + x * BLI_RCT_SIZE_X(&v2d->mask)); if (regiony) - *regiony = (int)(v2d->mask.ymin + y * (v2d->mask.ymax - v2d->mask.ymin)); + *regiony = (int)(v2d->mask.ymin + y * BLI_RCT_SIZE_Y(&v2d->mask)); } } @@ -1975,12 +1975,12 @@ void UI_view2d_view_to_region(View2D *v2d, float x, float y, int *regionx, int * void UI_view2d_to_region_no_clip(View2D *v2d, float x, float y, int *regionx, int *regiony) { /* step 1: express given coordinates as proportional values */ - x = (x - v2d->cur.xmin) / (v2d->cur.xmax - v2d->cur.xmin); - y = (y - v2d->cur.ymin) / (v2d->cur.ymax - v2d->cur.ymin); + x = (x - v2d->cur.xmin) / BLI_RCT_SIZE_X(&v2d->cur); + y = (y - v2d->cur.ymin) / BLI_RCT_SIZE_Y(&v2d->cur); /* step 2: convert proportional distances to screen coordinates */ - x = v2d->mask.xmin + x * (v2d->mask.xmax - v2d->mask.xmin); - y = v2d->mask.ymin + y * (v2d->mask.ymax - v2d->mask.ymin); + x = v2d->mask.xmin + x * BLI_RCT_SIZE_X(&v2d->mask); + y = v2d->mask.ymin + y * BLI_RCT_SIZE_Y(&v2d->mask); /* although we don't clamp to lie within region bounds, we must avoid exceeding size of ints */ if (regionx) { @@ -2033,8 +2033,8 @@ View2D *UI_view2d_fromcontext_rwin(const bContext *C) */ void UI_view2d_getscale(View2D *v2d, float *x, float *y) { - if (x) *x = (v2d->mask.xmax - v2d->mask.xmin) / (v2d->cur.xmax - v2d->cur.xmin); - if (y) *y = (v2d->mask.ymax - v2d->mask.ymin) / (v2d->cur.ymax - v2d->cur.ymin); + if (x) *x = BLI_RCT_SIZE_X(&v2d->mask) / BLI_RCT_SIZE_X(&v2d->cur); + if (y) *y = BLI_RCT_SIZE_Y(&v2d->mask) / BLI_RCT_SIZE_Y(&v2d->cur); } /* Check if mouse is within scrollers diff --git a/source/blender/editors/interface/view2d_ops.c b/source/blender/editors/interface/view2d_ops.c index f12a9e06312..258025eefc9 100644 --- a/source/blender/editors/interface/view2d_ops.c +++ b/source/blender/editors/interface/view2d_ops.c @@ -119,10 +119,10 @@ static int view_pan_init(bContext *C, wmOperator *op) vpd->ar = ar; /* calculate translation factor - based on size of view */ - winx = (float)(ar->winrct.xmax - ar->winrct.xmin + 1); - winy = (float)(ar->winrct.ymax - ar->winrct.ymin + 1); - vpd->facx = (v2d->cur.xmax - v2d->cur.xmin) / winx; - vpd->facy = (v2d->cur.ymax - v2d->cur.ymin) / winy; + winx = (float)(BLI_RCT_SIZE_X(&ar->winrct) + 1); + winy = (float)(BLI_RCT_SIZE_Y(&ar->winrct) + 1); + vpd->facx = (BLI_RCT_SIZE_X(&v2d->cur)) / winx; + vpd->facy = (BLI_RCT_SIZE_Y(&v2d->cur)) / winy; return 1; } @@ -590,12 +590,12 @@ static void view_zoomstep_apply(bContext *C, wmOperator *op) facy = RNA_float_get(op->ptr, "zoomfacy"); if (facx >= 0.0f) { - dx = (v2d->cur.xmax - v2d->cur.xmin) * facx; - dy = (v2d->cur.ymax - v2d->cur.ymin) * facy; + dx = BLI_RCT_SIZE_X(&v2d->cur) * facx; + dy = BLI_RCT_SIZE_Y(&v2d->cur) * facy; } else { - dx = ((v2d->cur.xmax - v2d->cur.xmin) / (1.0f + 2.0f * facx)) * facx; - dy = ((v2d->cur.ymax - v2d->cur.ymin) / (1.0f + 2.0f * facy)) * facy; + dx = (BLI_RCT_SIZE_X(&v2d->cur) / (1.0f + 2.0f * facx)) * facx; + dy = (BLI_RCT_SIZE_Y(&v2d->cur) / (1.0f + 2.0f * facy)) * facy; } /* only resize view on an axis if change is allowed */ @@ -611,7 +611,7 @@ static void view_zoomstep_apply(bContext *C, wmOperator *op) } else { if (U.uiflag & USER_ZOOM_TO_MOUSEPOS) { - float mval_fac = (vzd->mx_2d - v2d->cur.xmin) / (v2d->cur.xmax - v2d->cur.xmin); + float mval_fac = (vzd->mx_2d - v2d->cur.xmin) / BLI_RCT_SIZE_X(&v2d->cur); float mval_faci = 1.0f - mval_fac; float ofs = (mval_fac * dx) - (mval_faci * dx); @@ -636,7 +636,7 @@ static void view_zoomstep_apply(bContext *C, wmOperator *op) } else { if (U.uiflag & USER_ZOOM_TO_MOUSEPOS) { - float mval_fac = (vzd->my_2d - v2d->cur.ymin) / (v2d->cur.ymax - v2d->cur.ymin); + float mval_fac = (vzd->my_2d - v2d->cur.ymin) / BLI_RCT_SIZE_Y(&v2d->cur); float mval_faci = 1.0f - mval_fac; float ofs = (mval_fac * dy) - (mval_faci * dy); @@ -821,7 +821,7 @@ static void view_zoomdrag_apply(bContext *C, wmOperator *op) } else { if (U.uiflag & USER_ZOOM_TO_MOUSEPOS) { - float mval_fac = (vzd->mx_2d - v2d->cur.xmin) / (v2d->cur.xmax - v2d->cur.xmin); + float mval_fac = (vzd->mx_2d - v2d->cur.xmin) / BLI_RCT_SIZE_X(&v2d->cur); float mval_faci = 1.0f - mval_fac; float ofs = (mval_fac * dx) - (mval_faci * dx); @@ -840,7 +840,7 @@ static void view_zoomdrag_apply(bContext *C, wmOperator *op) } else { if (U.uiflag & USER_ZOOM_TO_MOUSEPOS) { - float mval_fac = (vzd->my_2d - v2d->cur.ymin) / (v2d->cur.ymax - v2d->cur.ymin); + float mval_fac = (vzd->my_2d - v2d->cur.ymin) / BLI_RCT_SIZE_Y(&v2d->cur); float mval_faci = 1.0f - mval_fac; float ofs = (mval_fac * dy) - (mval_faci * dy); @@ -918,8 +918,8 @@ static int view_zoomdrag_invoke(bContext *C, wmOperator *op, wmEvent *event) * with magnify information that is stored in x axis */ fac = 0.01f * (event->x - event->prevx); - dx = fac * (v2d->cur.xmax - v2d->cur.xmin) / 10.0f; - dy = fac * (v2d->cur.ymax - v2d->cur.ymin) / 10.0f; + dx = fac * BLI_RCT_SIZE_X(&v2d->cur) / 10.0f; + dy = fac * BLI_RCT_SIZE_Y(&v2d->cur) / 10.0f; RNA_float_set(op->ptr, "deltax", dx); RNA_float_set(op->ptr, "deltay", dy); @@ -985,14 +985,14 @@ static int view_zoomdrag_modal(bContext *C, wmOperator *op, wmEvent *event) float dist; /* x-axis transform */ - dist = (v2d->mask.xmax - v2d->mask.xmin) / 2.0f; + dist = BLI_RCT_SIZE_X(&v2d->mask) / 2.0f; dx = 1.0f - (fabsf(vzd->lastx - dist) + 2.0f) / (fabsf(event->x - dist) + 2.0f); - dx *= 0.5f * (v2d->cur.xmax - v2d->cur.xmin); + dx *= 0.5f * BLI_RCT_SIZE_X(&v2d->cur); /* y-axis transform */ - dist = (v2d->mask.ymax - v2d->mask.ymin) / 2.0f; + dist = BLI_RCT_SIZE_Y(&v2d->mask) / 2.0f; dy = 1.0f - (fabsf(vzd->lasty - dist) + 2.0f) / (fabsf(event->y - dist) + 2.0f); - dy *= 0.5f * (v2d->cur.ymax - v2d->cur.ymin); + dy *= 0.5f * BLI_RCT_SIZE_Y(&v2d->cur); } else { /* 'continuous' or 'dolly' */ @@ -1000,11 +1000,11 @@ static int view_zoomdrag_modal(bContext *C, wmOperator *op, wmEvent *event) /* x-axis transform */ fac = 0.01f * (event->x - vzd->lastx); - dx = fac * (v2d->cur.xmax - v2d->cur.xmin); + dx = fac * BLI_RCT_SIZE_X(&v2d->cur); /* y-axis transform */ fac = 0.01f * (event->y - vzd->lasty); - dy = fac * (v2d->cur.ymax - v2d->cur.ymin); + dy = fac * BLI_RCT_SIZE_Y(&v2d->cur); #if 0 /* continuous zoom shouldn't move that fast... */ if (U.viewzoom == USER_ZOOM_CONT) { // XXX store this setting as RNA prop? @@ -1138,7 +1138,7 @@ static int view_borderzoom_exec(bContext *C, wmOperator *op) /* TODO: is this zoom factor calculation valid? It seems to produce same results everytime... */ if ((v2d->keepzoom & V2D_LOCKZOOM_X) == 0) { size = (cur_new.xmax - cur_new.xmin); - zoom = size / (rect.xmax - rect.xmin); + zoom = size / BLI_RCT_SIZE_X(&rect); center = BLI_RCT_CENTER_X(&cur_new); cur_new.xmin = center - (size * zoom); @@ -1146,7 +1146,7 @@ static int view_borderzoom_exec(bContext *C, wmOperator *op) } if ((v2d->keepzoom & V2D_LOCKZOOM_Y) == 0) { size = (cur_new.ymax - cur_new.ymin); - zoom = size / (rect.ymax - rect.ymin); + zoom = size / BLI_RCT_SIZE_Y(&rect); center = BLI_RCT_CENTER_Y(&cur_new); cur_new.ymin = center - (size * zoom); @@ -1478,7 +1478,7 @@ static void scroller_activate_init(bContext *C, wmOperator *op, wmEvent *event, if (in_scroller == 'h') { /* horizontal scroller - calculate adjustment factor first */ mask_size = (float)(v2d->hor.xmax - v2d->hor.xmin); - vsm->fac = (v2d->tot.xmax - v2d->tot.xmin) / mask_size; + vsm->fac = BLI_RCT_SIZE_X(&v2d->tot) / mask_size; /* get 'zone' (i.e. which part of scroller is activated) */ vsm->zone = mouse_in_scroller_handle(event->mval[0], v2d->hor.xmin, v2d->hor.xmax, scrollers->hor_min, scrollers->hor_max); @@ -1494,7 +1494,7 @@ static void scroller_activate_init(bContext *C, wmOperator *op, wmEvent *event, else { /* vertical scroller - calculate adjustment factor first */ mask_size = (float)(v2d->vert.ymax - v2d->vert.ymin); - vsm->fac = (v2d->tot.ymax - v2d->tot.ymin) / mask_size; + vsm->fac = BLI_RCT_SIZE_Y(&v2d->tot) / mask_size; /* get 'zone' (i.e. which part of scroller is activated) */ vsm->zone = mouse_in_scroller_handle(event->mval[1], v2d->vert.ymin, v2d->vert.ymax, scrollers->vert_min, scrollers->vert_max); @@ -1774,8 +1774,8 @@ static int reset_exec(bContext *C, wmOperator *UNUSED(op)) int winx, winy; /* zoom 1.0 */ - winx = (float)(v2d->mask.xmax - v2d->mask.xmin + 1); - winy = (float)(v2d->mask.ymax - v2d->mask.ymin + 1); + winx = (float)(BLI_RCT_SIZE_X(&v2d->mask) + 1); + winy = (float)(BLI_RCT_SIZE_Y(&v2d->mask) + 1); v2d->cur.xmax = v2d->cur.xmin + winx; v2d->cur.ymax = v2d->cur.ymin + winy; diff --git a/source/blender/editors/mask/mask_draw.c b/source/blender/editors/mask/mask_draw.c index 703ae70eb0f..9c2e70a836e 100644 --- a/source/blender/editors/mask/mask_draw.c +++ b/source/blender/editors/mask/mask_draw.c @@ -33,6 +33,7 @@ #include "BLI_utildefines.h" #include "BLI_math.h" +#include "BLI_rect.h" #include "BKE_context.h" #include "BKE_mask.h" @@ -512,12 +513,12 @@ void ED_mask_draw_region(Mask *mask, ARegion *ar, UI_view2d_to_region_no_clip(&ar->v2d, 0.0f, 0.0f, &x, &y); - /* w = v2d->tot.xmax - v2d->tot.xmin; */ - /* h = v2d->tot.ymax - v2d->tot.ymin;/*/ + /* w = BLI_RCT_SIZE_X(&v2d->tot); */ + /* h = BLI_RCT_SIZE_Y(&v2d->tot);/*/ - zoomx = (float)(ar->winrct.xmax - ar->winrct.xmin + 1) / (float)((ar->v2d.cur.xmax - ar->v2d.cur.xmin)); - zoomy = (float)(ar->winrct.ymax - ar->winrct.ymin + 1) / (float)((ar->v2d.cur.ymax - ar->v2d.cur.ymin)); + zoomx = (float)(BLI_RCT_SIZE_X(&ar->winrct) + 1) / (float)(BLI_RCT_SIZE_X(&ar->v2d.cur)); + zoomy = (float)(BLI_RCT_SIZE_Y(&ar->winrct) + 1) / (float)(BLI_RCT_SIZE_Y(&ar->v2d.cur)); if (do_scale_applied) { zoomx /= width; diff --git a/source/blender/editors/mesh/editface.c b/source/blender/editors/mesh/editface.c index 62600c7fe6b..3431bea18ea 100644 --- a/source/blender/editors/mesh/editface.c +++ b/source/blender/editors/mesh/editface.c @@ -570,8 +570,8 @@ int do_paintface_box_select(ViewContext *vc, rcti *rect, int select, int extend) unsigned int *rt; char *selar; int a, index; - int sx = rect->xmax - rect->xmin + 1; - int sy = rect->ymax - rect->ymin + 1; + int sx = BLI_RCT_SIZE_X(rect) + 1; + int sy = BLI_RCT_SIZE_Y(rect) + 1; me = BKE_mesh_from_object(ob); diff --git a/source/blender/editors/render/render_preview.c b/source/blender/editors/render/render_preview.c index 4f62974a3e1..84319061d52 100644 --- a/source/blender/editors/render/render_preview.c +++ b/source/blender/editors/render/render_preview.c @@ -474,7 +474,9 @@ static int ed_preview_draw_rect(ScrArea *sa, Scene *sce, ID *id, int split, int RenderResult rres; char name[32]; int do_gamma_correct = FALSE, do_predivide = FALSE; - int offx = 0, newx = rect->xmax - rect->xmin, newy = rect->ymax - rect->ymin; + int offx = 0; + int newx = BLI_RCT_SIZE_X(rect); + int newy = BLI_RCT_SIZE_Y(rect); if (id && GS(id->name) != ID_TE) { /* exception: don't color manage texture previews - show the raw values */ @@ -547,7 +549,8 @@ void ED_preview_draw(const bContext *C, void *idp, void *parentp, void *slotp, r SpaceButs *sbuts = sa->spacedata.first; rcti newrect; int ok; - int newx = rect->xmax - rect->xmin, newy = rect->ymax - rect->ymin; + int newx = BLI_RCT_SIZE_X(rect); + int newy = BLI_RCT_SIZE_Y(rect); newrect.xmin = rect->xmin; newrect.xmax = rect->xmin; diff --git a/source/blender/editors/screen/area.c b/source/blender/editors/screen/area.c index 2c32295fe36..10bc17ff59e 100644 --- a/source/blender/editors/screen/area.c +++ b/source/blender/editors/screen/area.c @@ -104,8 +104,8 @@ static void region_draw_emboss(ARegion *ar, rcti *scirct) void ED_region_pixelspace(ARegion *ar) { - int width = ar->winrct.xmax - ar->winrct.xmin + 1; - int height = ar->winrct.ymax - ar->winrct.ymin + 1; + int width = BLI_RCT_SIZE_X(&ar->winrct) + 1; + int height = BLI_RCT_SIZE_Y(&ar->winrct) + 1; wmOrtho2(-GLA_PIXEL_OFS, (float)width - GLA_PIXEL_OFS, -GLA_PIXEL_OFS, (float)height - GLA_PIXEL_OFS); glLoadIdentity(); @@ -901,10 +901,10 @@ static void region_azone_add(ScrArea *sa, ARegion *ar, int alignment) static int rct_fits(rcti *rect, char dir, int size) { if (dir == 'h') { - return rect->xmax - rect->xmin - size; + return BLI_RCT_SIZE_X(rect) - size; } - else { // 'v' - return rect->ymax - rect->ymin - size; + else { /* 'v' */ + return BLI_RCT_SIZE_Y(rect) - size; } } @@ -1073,8 +1073,8 @@ static void region_rect_recursive(ScrArea *sa, ARegion *ar, rcti *remainder, int } /* for speedup */ - ar->winx = ar->winrct.xmax - ar->winrct.xmin + 1; - ar->winy = ar->winrct.ymax - ar->winrct.ymin + 1; + ar->winx = BLI_RCT_SIZE_X(&ar->winrct) + 1; + ar->winy = BLI_RCT_SIZE_Y(&ar->winrct) + 1; /* set winrect for azones */ if (ar->flag & (RGN_FLAG_HIDDEN | RGN_FLAG_TOO_SMALL)) { @@ -1133,8 +1133,8 @@ static void area_calc_totrct(ScrArea *sa, int sizex, int sizey) else sa->totrct.ymax = sa->v2->vec.y; /* for speedup */ - sa->winx = sa->totrct.xmax - sa->totrct.xmin + 1; - sa->winy = sa->totrct.ymax - sa->totrct.ymin + 1; + sa->winx = BLI_RCT_SIZE_X(&sa->totrct) + 1; + sa->winy = BLI_RCT_SIZE_Y(&sa->totrct) + 1; } @@ -1268,8 +1268,8 @@ void ED_region_init(bContext *C, ARegion *ar) /* refresh can be called before window opened */ region_subwindow(CTX_wm_window(C), ar); - ar->winx = ar->winrct.xmax - ar->winrct.xmin + 1; - ar->winy = ar->winrct.ymax - ar->winrct.ymin + 1; + ar->winx = BLI_RCT_SIZE_X(&ar->winrct) + 1; + ar->winy = BLI_RCT_SIZE_Y(&ar->winrct) + 1; /* UI convention */ wmOrtho2(-0.01f, ar->winx - 0.01f, -0.01f, ar->winy - 0.01f); @@ -1574,7 +1574,7 @@ void ED_region_panels(const bContext *C, ARegion *ar, int vertical, const char * newcontext = UI_view2d_tab_set(v2d, contextnr); if (vertical) { - w = v2d->cur.xmax - v2d->cur.xmin; + w = BLI_RCT_SIZE_X(&v2d->cur); em = (ar->type->prefsizex) ? UI_UNIT_Y / 2 : UI_UNIT_Y; } else { @@ -1798,16 +1798,16 @@ void ED_region_info_draw(ARegion *ar, const char *text, int block, float alpha) /* background box */ rect = ar->winrct; rect.xmin = 0; - rect.ymin = ar->winrct.ymax - ar->winrct.ymin - header_height; + rect.ymin = BLI_RCT_SIZE_Y(&ar->winrct) - header_height; if (block) { - rect.xmax = ar->winrct.xmax - ar->winrct.xmin; + rect.xmax = BLI_RCT_SIZE_X(&ar->winrct); } else { rect.xmax = rect.xmin + BLF_width(fontid, text) + 24; } - rect.ymax = ar->winrct.ymax - ar->winrct.ymin; + rect.ymax = BLI_RCT_SIZE_Y(&ar->winrct); glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); diff --git a/source/blender/editors/screen/screen_ops.c b/source/blender/editors/screen/screen_ops.c index e92f7b7a3c2..97a63bb0df0 100644 --- a/source/blender/editors/screen/screen_ops.c +++ b/source/blender/editors/screen/screen_ops.c @@ -1612,7 +1612,7 @@ static int area_max_regionsize(ScrArea *sa, ARegion *scalear, AZEdge edge) int dist; if (edge == AE_RIGHT_TO_TOPLEFT || edge == AE_LEFT_TO_TOPRIGHT) { - dist = sa->totrct.xmax - sa->totrct.xmin; + dist = BLI_RCT_SIZE_X(&sa->totrct); } else { /* AE_BOTTOM_TO_TOPLEFT, AE_TOP_TO_BOTTOMRIGHT */ dist = sa->totrct.ymax - sa->totrct.ymin; diff --git a/source/blender/editors/space_action/action_draw.c b/source/blender/editors/space_action/action_draw.c index edec57d9e93..878fd20b27e 100644 --- a/source/blender/editors/space_action/action_draw.c +++ b/source/blender/editors/space_action/action_draw.c @@ -89,7 +89,7 @@ void draw_channel_names(bContext *C, bAnimContext *ac, ARegion *ar) * start of list offset, and the second is as a correction for the scrollers. */ height = ((items * ACHANNEL_STEP) + (ACHANNEL_HEIGHT * 2)); - if (height > (v2d->mask.ymax - v2d->mask.ymin)) { + if (height > BLI_RCT_SIZE_Y(&v2d->mask)) { /* don't use totrect set, as the width stays the same * (NOTE: this is ok here, the configuration is pretty straightforward) */ diff --git a/source/blender/editors/space_action/action_edit.c b/source/blender/editors/space_action/action_edit.c index dbde950188d..c95f1dba31d 100644 --- a/source/blender/editors/space_action/action_edit.c +++ b/source/blender/editors/space_action/action_edit.c @@ -365,13 +365,13 @@ static int actkeys_viewall(bContext *C, const short onlySel) /* set the horizontal range, with an extra offset so that the extreme keys will be in view */ get_keyframe_extents(&ac, &v2d->cur.xmin, &v2d->cur.xmax, onlySel); - extra = 0.1f * (v2d->cur.xmax - v2d->cur.xmin); + extra = 0.1f * BLI_RCT_SIZE_X(&v2d->cur); v2d->cur.xmin -= extra; v2d->cur.xmax += extra; /* set vertical range */ v2d->cur.ymax = 0.0f; - v2d->cur.ymin = (float)-(v2d->mask.ymax - v2d->mask.ymin); + v2d->cur.ymin = (float)-BLI_RCT_SIZE_Y(&v2d->mask); /* do View2D syncing */ UI_view2d_sync(CTX_wm_screen(C), CTX_wm_area(C), v2d, V2D_LOCK_COPY); diff --git a/source/blender/editors/space_action/action_select.c b/source/blender/editors/space_action/action_select.c index 6b61990d485..c9f765ac3db 100644 --- a/source/blender/editors/space_action/action_select.c +++ b/source/blender/editors/space_action/action_select.c @@ -309,7 +309,7 @@ static int actkeys_borderselect_exec(bContext *C, wmOperator *op) * - the frame-range select option is favored over the channel one (x over y), as frame-range one is often * used for tweaking timing when "blocking", while channels is not that useful... */ - if ((rect.xmax - rect.xmin) >= (rect.ymax - rect.ymin)) + if (BLI_RCT_SIZE_X(&rect) >= BLI_RCT_SIZE_Y(&rect)) mode = ACTKEYS_BORDERSEL_FRAMERANGE; else mode = ACTKEYS_BORDERSEL_CHANNELS; diff --git a/source/blender/editors/space_clip/clip_buttons.c b/source/blender/editors/space_clip/clip_buttons.c index e561b2a9e79..e66faa88b93 100644 --- a/source/blender/editors/space_clip/clip_buttons.c +++ b/source/blender/editors/space_clip/clip_buttons.c @@ -41,6 +41,7 @@ #include "BLI_math.h" #include "BLI_utildefines.h" #include "BLI_listbase.h" +#include "BLI_rect.h" #include "BKE_context.h" #include "BKE_depsgraph.h" @@ -168,7 +169,7 @@ void uiTemplateTrack(uiLayout *layout, PointerRNA *ptr, const char *propname) scopes->track_preview_height = (scopes->track_preview_height <= UI_UNIT_Y) ? UI_UNIT_Y : scopes->track_preview_height; - uiDefBut(block, TRACKPREVIEW, 0, "", rect.xmin, rect.ymin, rect.xmax - rect.xmin, + uiDefBut(block, TRACKPREVIEW, 0, "", rect.xmin, rect.ymin, BLI_RCT_SIZE_X(&rect), scopes->track_preview_height, scopes, 0, 0, 0, 0, ""); } diff --git a/source/blender/editors/space_clip/clip_dopesheet_draw.c b/source/blender/editors/space_clip/clip_dopesheet_draw.c index 83d895067cc..5d890155e25 100644 --- a/source/blender/editors/space_clip/clip_dopesheet_draw.c +++ b/source/blender/editors/space_clip/clip_dopesheet_draw.c @@ -44,6 +44,7 @@ #include "BLI_string.h" #include "BLI_listbase.h" #include "BLI_math.h" +#include "BLI_rect.h" #include "ED_screen.h" #include "ED_clip.h" @@ -273,7 +274,7 @@ void clip_draw_dopesheet_channels(const bContext *C, ARegion *ar) dopesheet = &tracking->dopesheet; height = (dopesheet->tot_channel * CHANNEL_STEP) + (CHANNEL_HEIGHT * 2); - if (height > (v2d->mask.ymax - v2d->mask.ymin)) { + if (height > BLI_RCT_SIZE_Y(&v2d->mask)) { /* don't use totrect set, as the width stays the same * (NOTE: this is ok here, the configuration is pretty straightforward) */ diff --git a/source/blender/editors/space_clip/clip_draw.c b/source/blender/editors/space_clip/clip_draw.c index c24cdab29e5..2353f8f8c12 100644 --- a/source/blender/editors/space_clip/clip_draw.c +++ b/source/blender/editors/space_clip/clip_draw.c @@ -958,12 +958,12 @@ static void draw_marker_texts(SpaceClip *sc, MovieTrackingTrack *track, MovieTra static void view2d_to_region_float(View2D *v2d, float x, float y, float *regionx, float *regiony) { /* express given coordinates as proportional values */ - x = -v2d->cur.xmin / (v2d->cur.xmax - v2d->cur.xmin); - y = -v2d->cur.ymin / (v2d->cur.ymax - v2d->cur.ymin); + x = -v2d->cur.xmin / BLI_RCT_SIZE_X(&v2d->cur); + y = -v2d->cur.ymin / BLI_RCT_SIZE_Y(&v2d->cur); /* convert proportional distances to screen coordinates */ - *regionx = v2d->mask.xmin + x * (v2d->mask.xmax - v2d->mask.xmin); - *regiony = v2d->mask.ymin + y * (v2d->mask.ymax - v2d->mask.ymin); + *regionx = v2d->mask.xmin + x * BLI_RCT_SIZE_X(&v2d->mask); + *regiony = v2d->mask.ymin + y * BLI_RCT_SIZE_Y(&v2d->mask); } static void draw_tracking_tracks(SpaceClip *sc, ARegion *ar, MovieClip *clip, diff --git a/source/blender/editors/space_clip/clip_editor.c b/source/blender/editors/space_clip/clip_editor.c index 5b4849a425f..7a54a39ee48 100644 --- a/source/blender/editors/space_clip/clip_editor.c +++ b/source/blender/editors/space_clip/clip_editor.c @@ -44,6 +44,7 @@ #include "BLI_utildefines.h" #include "BLI_math.h" +#include "BLI_rect.h" #include "GPU_extensions.h" @@ -148,8 +149,8 @@ void ED_space_clip_get_zoom(SpaceClip *sc, ARegion *ar, float *zoomx, float *zoo ED_space_clip_get_size(sc, &width, &height); - *zoomx = (float)(ar->winrct.xmax - ar->winrct.xmin + 1) / (float)((ar->v2d.cur.xmax - ar->v2d.cur.xmin) * width); - *zoomy = (float)(ar->winrct.ymax - ar->winrct.ymin + 1) / (float)((ar->v2d.cur.ymax - ar->v2d.cur.ymin) * height); + *zoomx = (float)(BLI_RCT_SIZE_X(&ar->winrct) + 1) / (float)(BLI_RCT_SIZE_X(&ar->v2d.cur) * width); + *zoomy = (float)(BLI_RCT_SIZE_Y(&ar->winrct) + 1) / (float)(BLI_RCT_SIZE_Y(&ar->v2d.cur) * height); } void ED_space_clip_get_aspect(SpaceClip *sc, float *aspx, float *aspy) @@ -393,8 +394,8 @@ int ED_clip_view_selection(const bContext *C, ARegion *ar, int fit) ED_space_clip_get_aspect(sc, &aspx, &aspy); - width = ar->winrct.xmax - ar->winrct.xmin + 1; - height = ar->winrct.ymax - ar->winrct.ymin + 1; + width = BLI_RCT_SIZE_X(&ar->winrct) + 1; + height = BLI_RCT_SIZE_Y(&ar->winrct) + 1; zoomx = (float)width / w / aspx; zoomy = (float)height / h / aspy; diff --git a/source/blender/editors/space_clip/clip_graph_ops.c b/source/blender/editors/space_clip/clip_graph_ops.c index a2cb812d51c..e94b28d22fa 100644 --- a/source/blender/editors/space_clip/clip_graph_ops.c +++ b/source/blender/editors/space_clip/clip_graph_ops.c @@ -580,11 +580,11 @@ static int view_all_exec(bContext *C, wmOperator *UNUSED(op)) } /* we need an extra "buffer" factor on either side so that the endpoints are visible */ - extra = 0.01f * (v2d->cur.xmax - v2d->cur.xmin); + extra = 0.01f * BLI_RCT_SIZE_X(&v2d->cur); v2d->cur.xmin -= extra; v2d->cur.xmax += extra; - extra = 0.01f * (v2d->cur.ymax - v2d->cur.ymin); + extra = 0.01f * BLI_RCT_SIZE_Y(&v2d->cur); v2d->cur.ymin -= extra; v2d->cur.ymax += extra; @@ -610,7 +610,7 @@ void CLIP_OT_graph_view_all(wmOperatorType *ot) void ED_clip_graph_center_current_frame(Scene *scene, ARegion *ar) { View2D *v2d = &ar->v2d; - float extra = (v2d->cur.xmax - v2d->cur.xmin) / 2.0f; + float extra = BLI_RCT_SIZE_X(&v2d->cur) / 2.0f; /* set extents of view to start/end frames */ v2d->cur.xmin = (float)CFRA - extra; diff --git a/source/blender/editors/space_clip/clip_ops.c b/source/blender/editors/space_clip/clip_ops.c index 36199b1908d..20b0ad509d3 100644 --- a/source/blender/editors/space_clip/clip_ops.c +++ b/source/blender/editors/space_clip/clip_ops.c @@ -39,6 +39,7 @@ #include "BLI_path_util.h" #include "BLI_utildefines.h" #include "BLI_math.h" +#include "BLI_rect.h" #include "BKE_context.h" #include "BKE_global.h" @@ -89,9 +90,9 @@ static void sclip_zoom_set(const bContext *C, float zoom, float location[2]) if ((width < 4) && (height < 4)) sc->zoom = oldzoom; - else if ((ar->winrct.xmax - ar->winrct.xmin) <= sc->zoom) + else if (BLI_RCT_SIZE_X(&ar->winrct) <= sc->zoom) sc->zoom = oldzoom; - else if ((ar->winrct.ymax - ar->winrct.ymin) <= sc->zoom) + else if (BLI_RCT_SIZE_Y(&ar->winrct) <= sc->zoom) sc->zoom = oldzoom; } @@ -725,8 +726,8 @@ static int view_all_exec(bContext *C, wmOperator *op) h = h * aspy; /* check if the image will fit in the image with zoom == 1 */ - width = ar->winrct.xmax - ar->winrct.xmin + 1; - height = ar->winrct.ymax - ar->winrct.ymin + 1; + width = BLI_RCT_SIZE_X(&ar->winrct) + 1; + height = BLI_RCT_SIZE_Y(&ar->winrct) + 1; if (fit_view) { const int margin = 5; /* margin from border */ diff --git a/source/blender/editors/space_clip/space_clip.c b/source/blender/editors/space_clip/space_clip.c index bf65429b9f4..bb06104d442 100644 --- a/source/blender/editors/space_clip/space_clip.c +++ b/source/blender/editors/space_clip/space_clip.c @@ -1036,8 +1036,8 @@ static void movieclip_main_area_set_view2d(const bContext *C, ARegion *ar) if (clip) h *= clip->aspy / clip->aspx / clip->tracking.camera.pixel_aspect; - winx = ar->winrct.xmax - ar->winrct.xmin + 1; - winy = ar->winrct.ymax - ar->winrct.ymin + 1; + winx = BLI_RCT_SIZE_X(&ar->winrct) + 1; + winy = BLI_RCT_SIZE_Y(&ar->winrct) + 1; ar->v2d.tot.xmin = 0; ar->v2d.tot.ymin = 0; diff --git a/source/blender/editors/space_console/space_console.c b/source/blender/editors/space_console/space_console.c index 490a3b45990..a4f7e30ed7b 100644 --- a/source/blender/editors/space_console/space_console.c +++ b/source/blender/editors/space_console/space_console.c @@ -142,7 +142,7 @@ static void console_main_area_init(wmWindowManager *wm, ARegion *ar) /* always keep the bottom part of the view aligned, less annoying */ if (prev_y_min != ar->v2d.cur.ymin) { - const float cur_y_range = ar->v2d.cur.ymax - ar->v2d.cur.ymin; + const float cur_y_range = BLI_RCT_SIZE_Y(&ar->v2d.cur); ar->v2d.cur.ymin = prev_y_min; ar->v2d.cur.ymax = prev_y_min + cur_y_range; } diff --git a/source/blender/editors/space_file/filesel.c b/source/blender/editors/space_file/filesel.c index 34f16c11537..09231efd367 100644 --- a/source/blender/editors/space_file/filesel.c +++ b/source/blender/editors/space_file/filesel.c @@ -270,12 +270,12 @@ int ED_fileselect_layout_numfiles(FileLayout *layout, ARegion *ar) int numfiles; if (layout->flag & FILE_LAYOUT_HOR) { - int width = (int)(ar->v2d.cur.xmax - ar->v2d.cur.xmin - 2 * layout->tile_border_x); + int width = (int)(BLI_RCT_SIZE_X(&ar->v2d.cur) - 2 * layout->tile_border_x); numfiles = (int)((float)width / (float)layout->tile_w + 0.5f); return numfiles * layout->rows; } else { - int height = (int)(ar->v2d.cur.ymax - ar->v2d.cur.ymin - 2 * layout->tile_border_y); + int height = (int)(BLI_RCT_SIZE_Y(&ar->v2d.cur) - 2 * layout->tile_border_y); numfiles = (int)((float)height / (float)layout->tile_h + 0.5f); return numfiles * layout->columns; } @@ -503,7 +503,7 @@ void ED_fileselect_init_layout(struct SpaceFile *sfile, ARegion *ar) layout->prv_border_y = 6; layout->tile_w = layout->prv_w + 2 * layout->prv_border_x; layout->tile_h = layout->prv_h + 2 * layout->prv_border_y + textheight; - layout->width = (int)(v2d->cur.xmax - v2d->cur.xmin - 2 * layout->tile_border_x); + layout->width = (int)(BLI_RCT_SIZE_X(&v2d->cur) - 2 * layout->tile_border_x); layout->columns = layout->width / (layout->tile_w + 2 * layout->tile_border_x); if (layout->columns > 0) layout->rows = numfiles / layout->columns + 1; // XXX dirty, modulo is zero @@ -522,7 +522,7 @@ void ED_fileselect_init_layout(struct SpaceFile *sfile, ARegion *ar) layout->prv_border_x = 0; layout->prv_border_y = 0; layout->tile_h = textheight * 3 / 2; - layout->height = (int)(v2d->cur.ymax - v2d->cur.ymin - 2 * layout->tile_border_y); + layout->height = (int)(BLI_RCT_SIZE_Y(&v2d->cur) - 2 * layout->tile_border_y); layout->rows = layout->height / (layout->tile_h + 2 * layout->tile_border_y); column_widths(sfile->files, layout); diff --git a/source/blender/editors/space_file/space_file.c b/source/blender/editors/space_file/space_file.c index 17669dfa8f9..8c5ecb48613 100644 --- a/source/blender/editors/space_file/space_file.c +++ b/source/blender/editors/space_file/space_file.c @@ -525,7 +525,7 @@ static void file_ui_area_draw(const bContext *C, ARegion *ar) glClear(GL_COLOR_BUFFER_BIT); /* scrolling here is just annoying, disable it */ - ar->v2d.cur.ymax = ar->v2d.cur.ymax - ar->v2d.cur.ymin; + ar->v2d.cur.ymax = BLI_RCT_SIZE_Y(&ar->v2d.cur); ar->v2d.cur.ymin = 0; /* set view2d view matrix for scrolling (without scrollers) */ diff --git a/source/blender/editors/space_graph/graph_draw.c b/source/blender/editors/space_graph/graph_draw.c index 870e9bb8168..ad97b7853c4 100644 --- a/source/blender/editors/space_graph/graph_draw.c +++ b/source/blender/editors/space_graph/graph_draw.c @@ -88,7 +88,7 @@ static void draw_fcurve_modifier_controls_envelope(FModifier *fcm, View2D *v2d) { FMod_Envelope *env = (FMod_Envelope *)fcm->data; FCM_EnvelopeData *fed; - const float fac = 0.05f * (v2d->cur.xmax - v2d->cur.xmin); + const float fac = 0.05f * BLI_RCT_SIZE_X(&v2d->cur); int i; /* draw two black lines showing the standard reference levels */ @@ -137,7 +137,7 @@ static void draw_fcurve_modifier_controls_envelope(FModifier *fcm, View2D *v2d) static void draw_fcurve_vertices_keyframes(FCurve *fcu, SpaceIpo *UNUSED(sipo), View2D *v2d, short edit, short sel) { BezTriple *bezt = fcu->bezt; - const float fac = 0.05f * (v2d->cur.xmax - v2d->cur.xmin); + const float fac = 0.05f * BLI_RCT_SIZE_X(&v2d->cur); int i; /* we use bgl points not standard gl points, to workaround vertex diff --git a/source/blender/editors/space_graph/graph_select.c b/source/blender/editors/space_graph/graph_select.c index 781099f6a68..32abad86828 100644 --- a/source/blender/editors/space_graph/graph_select.c +++ b/source/blender/editors/space_graph/graph_select.c @@ -325,7 +325,7 @@ static int graphkeys_borderselect_exec(bContext *C, wmOperator *op) * - the frame-range select option is favored over the channel one (x over y), as frame-range one is often * used for tweaking timing when "blocking", while channels is not that useful... */ - if ((rect.xmax - rect.xmin) >= (rect.ymax - rect.ymin)) + if ((BLI_RCT_SIZE_X(&rect)) >= (BLI_RCT_SIZE_Y(&rect))) mode = BEZT_OK_FRAMERANGE; else mode = BEZT_OK_VALUERANGE; diff --git a/source/blender/editors/space_image/image_buttons.c b/source/blender/editors/space_image/image_buttons.c index b8ca0deb770..56b340aac09 100644 --- a/source/blender/editors/space_image/image_buttons.c +++ b/source/blender/editors/space_image/image_buttons.c @@ -274,7 +274,7 @@ static void preview_cb(ScrArea *sa, struct uiBlock *block) /* while dragging we need to update the rects, otherwise it doesn't end with correct one */ - BLI_rctf_init(&dispf, 15.0f, (block->rect.xmax - block->rect.xmin) - 15.0f, 15.0f, (block->rect.ymax - block->rect.ymin) - 15.0f); + BLI_rctf_init(&dispf, 15.0f, BLI_RCT_SIZE_X(&block->rect) - 15.0f, 15.0f, (BLI_RCT_SIZE_Y(&block->rect)) - 15.0f); ui_graphics_to_window_rct(sa->win, &dispf, disprect); /* correction for gla draw */ diff --git a/source/blender/editors/space_image/image_draw.c b/source/blender/editors/space_image/image_draw.c index 52ed7fd1d0b..e293264c021 100644 --- a/source/blender/editors/space_image/image_draw.c +++ b/source/blender/editors/space_image/image_draw.c @@ -44,6 +44,7 @@ #include "PIL_time.h" #include "BLI_math.h" +#include "BLI_rect.h" #include "BLI_threads.h" #include "BLI_string.h" #include "BLI_utildefines.h" @@ -135,7 +136,7 @@ void ED_image_draw_info(ARegion *ar, int color_manage, int channels, int x, int /* noisy, high contrast make impossible to read if lower alpha is used. */ glColor4ub(0, 0, 0, 190); - glRecti(0.0, 0.0, ar->winrct.xmax - ar->winrct.xmin + 1, 20); + glRecti(0.0, 0.0, BLI_RCT_SIZE_X(&ar->winrct) + 1, 20); glDisable(GL_BLEND); BLF_size(blf_mono_font, 11, 72); diff --git a/source/blender/editors/space_image/image_edit.c b/source/blender/editors/space_image/image_edit.c index 036e70913b6..bb31ba42716 100644 --- a/source/blender/editors/space_image/image_edit.c +++ b/source/blender/editors/space_image/image_edit.c @@ -33,6 +33,7 @@ #include "DNA_scene_types.h" #include "BLI_math.h" +#include "BLI_rect.h" #include "BKE_context.h" #include "BKE_global.h" @@ -229,8 +230,8 @@ void ED_space_image_get_zoom(SpaceImage *sima, ARegion *ar, float *zoomx, float ED_space_image_get_size(sima, &width, &height); - *zoomx = (float)(ar->winrct.xmax - ar->winrct.xmin + 1) / (float)((ar->v2d.cur.xmax - ar->v2d.cur.xmin) * width); - *zoomy = (float)(ar->winrct.ymax - ar->winrct.ymin + 1) / (float)((ar->v2d.cur.ymax - ar->v2d.cur.ymin) * height); + *zoomx = (float)(BLI_RCT_SIZE_X(&ar->winrct) + 1) / (float)(BLI_RCT_SIZE_X(&ar->v2d.cur) * width); + *zoomy = (float)(BLI_RCT_SIZE_Y(&ar->winrct) + 1) / (float)(BLI_RCT_SIZE_Y(&ar->v2d.cur) * height); } void ED_space_image_get_uv_aspect(SpaceImage *sima, float *aspx, float *aspy) diff --git a/source/blender/editors/space_image/image_ops.c b/source/blender/editors/space_image/image_ops.c index b969d898882..3d6b316b743 100644 --- a/source/blender/editors/space_image/image_ops.c +++ b/source/blender/editors/space_image/image_ops.c @@ -98,9 +98,9 @@ static void sima_zoom_set(SpaceImage *sima, ARegion *ar, float zoom, float locat if ((width < 4) && (height < 4)) sima->zoom = oldzoom; - else if ((ar->winrct.xmax - ar->winrct.xmin) <= sima->zoom) + else if (BLI_RCT_SIZE_X(&ar->winrct) <= sima->zoom) sima->zoom = oldzoom; - else if ((ar->winrct.ymax - ar->winrct.ymin) <= sima->zoom) + else if (BLI_RCT_SIZE_Y(&ar->winrct) <= sima->zoom) sima->zoom = oldzoom; } @@ -581,8 +581,8 @@ static int image_view_all_exec(bContext *C, wmOperator *UNUSED(op)) h = height * aspy; /* check if the image will fit in the image with (zoom == 1) */ - width = ar->winrct.xmax - ar->winrct.xmin + 1; - height = ar->winrct.ymax - ar->winrct.ymin + 1; + width = BLI_RCT_SIZE_X(&ar->winrct) + 1; + height = BLI_RCT_SIZE_Y(&ar->winrct) + 1; if ((w >= width || h >= height) && (width > 0 && height > 0)) { /* find the zoom value that will fit the image in the image space */ diff --git a/source/blender/editors/space_image/space_image.c b/source/blender/editors/space_image/space_image.c index cc8940201e2..1f655884b73 100644 --- a/source/blender/editors/space_image/space_image.c +++ b/source/blender/editors/space_image/space_image.c @@ -556,8 +556,8 @@ static void image_main_area_set_view2d(SpaceImage *sima, ARegion *ar) if (ima) h *= ima->aspy / ima->aspx; - winx = ar->winrct.xmax - ar->winrct.xmin + 1; - winy = ar->winrct.ymax - ar->winrct.ymin + 1; + winx = BLI_RCT_SIZE_X(&ar->winrct) + 1; + winy = BLI_RCT_SIZE_Y(&ar->winrct) + 1; ar->v2d.tot.xmin = 0; ar->v2d.tot.ymin = 0; diff --git a/source/blender/editors/space_nla/nla_edit.c b/source/blender/editors/space_nla/nla_edit.c index a3e9ca1c4a2..775dd5445c3 100644 --- a/source/blender/editors/space_nla/nla_edit.c +++ b/source/blender/editors/space_nla/nla_edit.c @@ -304,13 +304,13 @@ static int nlaedit_viewall(bContext *C, const short onlySel) /* set the horizontal range, with an extra offset so that the extreme keys will be in view */ get_nlastrip_extents(&ac, &v2d->cur.xmin, &v2d->cur.xmax, onlySel); - extra = 0.1f * (v2d->cur.xmax - v2d->cur.xmin); + extra = 0.1f * BLI_RCT_SIZE_X(&v2d->cur); v2d->cur.xmin -= extra; v2d->cur.xmax += extra; /* set vertical range */ v2d->cur.ymax = 0.0f; - v2d->cur.ymin = (float)-(v2d->mask.ymax - v2d->mask.ymin); + v2d->cur.ymin = (float)-BLI_RCT_SIZE_Y(&v2d->mask); /* do View2D syncing */ UI_view2d_sync(CTX_wm_screen(C), CTX_wm_area(C), v2d, V2D_LOCK_COPY); diff --git a/source/blender/editors/space_nla/nla_select.c b/source/blender/editors/space_nla/nla_select.c index b6bef651af3..e7610210881 100644 --- a/source/blender/editors/space_nla/nla_select.c +++ b/source/blender/editors/space_nla/nla_select.c @@ -309,7 +309,7 @@ static int nlaedit_borderselect_exec(bContext *C, wmOperator *op) * - the frame-range select option is favored over the channel one (x over y), as frame-range one is often * used for tweaking timing when "blocking", while channels is not that useful... */ - if ((rect.xmax - rect.xmin) >= (rect.ymax - rect.ymin)) + if (BLI_RCT_SIZE_X(&rect) >= BLI_RCT_SIZE_Y(&rect)) mode = NLA_BORDERSEL_FRAMERANGE; else mode = NLA_BORDERSEL_CHANNELS; diff --git a/source/blender/editors/space_node/drawnode.c b/source/blender/editors/space_node/drawnode.c index 68286554093..2816b55651f 100644 --- a/source/blender/editors/space_node/drawnode.c +++ b/source/blender/editors/space_node/drawnode.c @@ -386,7 +386,7 @@ static void node_buts_normal(uiLayout *layout, bContext *UNUSED(C), PointerRNA * bt = uiDefButF(block, BUT_NORMAL, B_NODE_EXEC, "", (int)butr->xmin, (int)butr->xmin, - (short)(butr->xmax - butr->xmin), (short)(butr->xmax - butr->xmin), + (short)BLI_RCT_SIZE_X(butr), (short)BLI_RCT_SIZE_X(butr), nor, 0.0f, 1.0f, 0, 0, ""); uiButSetFunc(bt, node_normal_cb, ntree, node); } @@ -837,7 +837,7 @@ static void node_draw_group(const bContext *C, ARegion *ar, SpaceNode *snode, bN layout = uiBlockLayout(gnode->block, UI_LAYOUT_VERTICAL, UI_LAYOUT_PANEL, (int)(rect.xmin + NODE_MARGIN_X), (int)(rect.ymax + (group_header - (2.5f * dpi_fac))), - mini((int)(rect.xmax - rect.xmin - 18.0f), node_group_frame + 20), group_header, UI_GetStyle()); + mini((int)(BLI_RCT_SIZE_X(&rect) - 18.0f), node_group_frame + 20), group_header, UI_GetStyle()); RNA_pointer_create(&ntree->id, &RNA_Node, gnode, &ptr); uiTemplateIDBrowse(layout, (bContext *)C, &ptr, "node_tree", NULL, NULL, NULL); uiBlockLayoutResolve(gnode->block, NULL, NULL); diff --git a/source/blender/editors/space_node/node_draw.c b/source/blender/editors/space_node/node_draw.c index 1a4c302124f..f58448b39ac 100644 --- a/source/blender/editors/space_node/node_draw.c +++ b/source/blender/editors/space_node/node_draw.c @@ -1110,7 +1110,7 @@ void drawnodespace(const bContext *C, ARegion *ar, View2D *v2d) glEnable(GL_MAP1_VERTEX_3); /* aspect+font, set each time */ - snode->aspect = (v2d->cur.xmax - v2d->cur.xmin) / ((float)ar->winx); + snode->aspect = BLI_RCT_SIZE_X(&v2d->cur) / (float)ar->winx; snode->aspect_sqrt = sqrtf(snode->aspect); // XXX snode->curfont= uiSetCurFont_ext(snode->aspect); diff --git a/source/blender/editors/space_node/node_view.c b/source/blender/editors/space_node/node_view.c index 27b57885b2b..6f549bd252f 100644 --- a/source/blender/editors/space_node/node_view.c +++ b/source/blender/editors/space_node/node_view.c @@ -72,8 +72,8 @@ static int space_node_view_flag(bContext *C, SpaceNode *snode, ARegion *ar, cons int tot = 0; int has_frame = FALSE; - oldwidth = ar->v2d.cur.xmax - ar->v2d.cur.xmin; - oldheight = ar->v2d.cur.ymax - ar->v2d.cur.ymin; + oldwidth = BLI_RCT_SIZE_X(&ar->v2d.cur); + oldheight = BLI_RCT_SIZE_Y(&ar->v2d.cur); BLI_rctf_init_minmax(&cur_new); diff --git a/source/blender/editors/space_outliner/outliner_edit.c b/source/blender/editors/space_outliner/outliner_edit.c index 4fa8686bce3..b669e705a25 100644 --- a/source/blender/editors/space_outliner/outliner_edit.c +++ b/source/blender/editors/space_outliner/outliner_edit.c @@ -579,11 +579,11 @@ static int outliner_show_active_exec(bContext *C, wmOperator *UNUSED(op)) te = outliner_find_id(so, &so->tree, (ID *)OBACT); if (te) { /* make te->ys center of view */ - ytop = (int)(te->ys + (v2d->mask.ymax - v2d->mask.ymin) / 2); + ytop = (int)(te->ys + BLI_RCT_SIZE_Y(&v2d->mask) / 2); if (ytop > 0) ytop = 0; v2d->cur.ymax = (float)ytop; - v2d->cur.ymin = (float)(ytop - (v2d->mask.ymax - v2d->mask.ymin)); + v2d->cur.ymin = (float)(ytop - BLI_RCT_SIZE_Y(&v2d->mask)); /* make te->xs ==> te->xend center of view */ xdelta = (int)(te->xs - v2d->cur.xmin); diff --git a/source/blender/editors/space_sequencer/sequencer_draw.c b/source/blender/editors/space_sequencer/sequencer_draw.c index 7dd98c39e4c..25514b3168b 100644 --- a/source/blender/editors/space_sequencer/sequencer_draw.c +++ b/source/blender/editors/space_sequencer/sequencer_draw.c @@ -428,7 +428,7 @@ static void draw_seq_extensions(Scene *scene, ARegion *ar, Sequence *seq) y1 = seq->machine + SEQ_STRIP_OFSBOTTOM; y2 = seq->machine + SEQ_STRIP_OFSTOP; - pixely = (v2d->cur.ymax - v2d->cur.ymin) / (v2d->mask.ymax - v2d->mask.ymin); + pixely = BLI_RCT_SIZE_Y(&v2d->cur) / BLI_RCT_SIZE_Y(&v2d->mask); if (pixely <= 0) return; /* can happen when the view is split/resized */ @@ -721,7 +721,7 @@ static void draw_seq_strip(Scene *scene, ARegion *ar, Sequence *seq, int outline /* draw sound wave */ if (seq->type == SEQ_TYPE_SOUND_RAM) { - drawseqwave(scene, seq, x1, y1, x2, y2, (ar->v2d.cur.xmax - ar->v2d.cur.xmin) / ar->winx); + drawseqwave(scene, seq, x1, y1, x2, y2, BLI_RCT_SIZE_X(&ar->v2d.cur) / ar->winx); } /* draw lock */ @@ -929,10 +929,10 @@ void draw_image_seq(const bContext *C, Scene *scene, ARegion *ar, SpaceSeq *sseq if (draw_overlay) { if (sseq->overlay_type == SEQ_DRAW_OVERLAY_RECT) { rctf tot_clip; - tot_clip.xmin = v2d->tot.xmin + (ABS(v2d->tot.xmax - v2d->tot.xmin) * scene->ed->over_border.xmin); - tot_clip.ymin = v2d->tot.ymin + (ABS(v2d->tot.ymax - v2d->tot.ymin) * scene->ed->over_border.ymin); - tot_clip.xmax = v2d->tot.xmin + (ABS(v2d->tot.xmax - v2d->tot.xmin) * scene->ed->over_border.xmax); - tot_clip.ymax = v2d->tot.ymin + (ABS(v2d->tot.ymax - v2d->tot.ymin) * scene->ed->over_border.ymax); + tot_clip.xmin = v2d->tot.xmin + (ABS(BLI_RCT_SIZE_X(&v2d->tot)) * scene->ed->over_border.xmin); + tot_clip.ymin = v2d->tot.ymin + (ABS(BLI_RCT_SIZE_Y(&v2d->tot)) * scene->ed->over_border.ymin); + tot_clip.xmax = v2d->tot.xmin + (ABS(BLI_RCT_SIZE_X(&v2d->tot)) * scene->ed->over_border.xmax); + tot_clip.ymax = v2d->tot.ymin + (ABS(BLI_RCT_SIZE_Y(&v2d->tot)) * scene->ed->over_border.ymax); glTexCoord2f(scene->ed->over_border.xmin, scene->ed->over_border.ymin); glVertex2f(tot_clip.xmin, tot_clip.ymin); glTexCoord2f(scene->ed->over_border.xmin, scene->ed->over_border.ymax); glVertex2f(tot_clip.xmin, tot_clip.ymax); @@ -1114,7 +1114,7 @@ static void draw_seq_strips(const bContext *C, Editing *ed, ARegion *ar) View2D *v2d = &ar->v2d; Sequence *last_seq = BKE_sequencer_active_get(scene); int sel = 0, j; - float pixelx = (v2d->cur.xmax - v2d->cur.xmin) / (v2d->mask.xmax - v2d->mask.xmin); + float pixelx = BLI_RCT_SIZE_X(&v2d->cur) / BLI_RCT_SIZE_X(&v2d->mask); /* loop through twice, first unselected, then selected */ for (j = 0; j < 2; j++) { diff --git a/source/blender/editors/space_sequencer/sequencer_edit.c b/source/blender/editors/space_sequencer/sequencer_edit.c index 144de1f9d5e..2dc26a9d5b8 100644 --- a/source/blender/editors/space_sequencer/sequencer_edit.c +++ b/source/blender/editors/space_sequencer/sequencer_edit.c @@ -372,7 +372,7 @@ Sequence *find_nearest_seq(Scene *scene, View2D *v2d, int *hand, const int mval[ if (ed == NULL) return NULL; - pixelx = (v2d->cur.xmax - v2d->cur.xmin) / (v2d->mask.xmax - v2d->mask.xmin); + pixelx = BLI_RCT_SIZE_X(&v2d->cur) / BLI_RCT_SIZE_X(&v2d->mask); UI_view2d_region_to_view(v2d, mval[0], mval[1], &x, &y); @@ -2142,8 +2142,8 @@ static int sequencer_view_zoom_ratio_exec(bContext *C, wmOperator *op) float winx = (int)(rd->size * rd->xsch) / 100; float winy = (int)(rd->size * rd->ysch) / 100; - float facx = (v2d->mask.xmax - v2d->mask.xmin) / winx; - float facy = (v2d->mask.ymax - v2d->mask.ymin) / winy; + float facx = BLI_RCT_SIZE_X(&v2d->mask) / winx; + float facy = BLI_RCT_SIZE_Y(&v2d->mask) / winy; BLI_rctf_resize(&v2d->cur, (int)(winx * facx * ratio) + 1, (int)(winy * facy * ratio) + 1); @@ -2769,11 +2769,11 @@ static int view_ghost_border_exec(bContext *C, wmOperator *op) if (ed == NULL) return OPERATOR_CANCELLED; - rect.xmin /= (float)(ABS(v2d->tot.xmax - v2d->tot.xmin)); - rect.ymin /= (float)(ABS(v2d->tot.ymax - v2d->tot.ymin)); + rect.xmin /= (float)(ABS(BLI_RCT_SIZE_X(&v2d->tot))); + rect.ymin /= (float)(ABS(BLI_RCT_SIZE_Y(&v2d->tot))); - rect.xmax /= (float)(ABS(v2d->tot.xmax - v2d->tot.xmin)); - rect.ymax /= (float)(ABS(v2d->tot.ymax - v2d->tot.ymin)); + rect.xmax /= (float)(ABS(BLI_RCT_SIZE_X(&v2d->tot))); + rect.ymax /= (float)(ABS(BLI_RCT_SIZE_Y(&v2d->tot))); rect.xmin += 0.5f; rect.xmax += 0.5f; diff --git a/source/blender/editors/space_time/time_ops.c b/source/blender/editors/space_time/time_ops.c index 189c8bfc7d0..733fd27135b 100644 --- a/source/blender/editors/space_time/time_ops.c +++ b/source/blender/editors/space_time/time_ops.c @@ -151,7 +151,7 @@ static int time_view_all_exec(bContext *C, wmOperator *UNUSED(op)) v2d->cur.xmax = (float)PEFRA; /* we need an extra "buffer" factor on either side so that the endpoints are visible */ - extra = 0.01f * (v2d->cur.xmax - v2d->cur.xmin); + extra = 0.01f * BLI_RCT_SIZE_X(&v2d->cur); v2d->cur.xmin -= extra; v2d->cur.xmax += extra; diff --git a/source/blender/editors/space_view3d/view3d_draw.c b/source/blender/editors/space_view3d/view3d_draw.c index 199a1751f9d..93f8457e7a3 100644 --- a/source/blender/editors/space_view3d/view3d_draw.c +++ b/source/blender/editors/space_view3d/view3d_draw.c @@ -2038,8 +2038,8 @@ void view3d_update_depths_rect(ARegion *ar, ViewDepths *d, rcti *rect) x = rect->xmin; y = rect->ymin; - w = rect->xmax - rect->xmin; - h = rect->ymax - rect->ymin; + w = BLI_RCT_SIZE_X(rect); + h = BLI_RCT_SIZE_Y(rect); if (w <= 0 || h <= 0) { if (d->depths) diff --git a/source/blender/editors/space_view3d/view3d_edit.c b/source/blender/editors/space_view3d/view3d_edit.c index 4fe859adf45..6e0c598d0ce 100644 --- a/source/blender/editors/space_view3d/view3d_edit.c +++ b/source/blender/editors/space_view3d/view3d_edit.c @@ -383,9 +383,9 @@ static void calctrackballvec(rcti *rect, int mx, int my, float vec[3]) /* normalize x and y */ x = BLI_RCT_CENTER_X(rect) - mx; - x /= (float)((rect->xmax - rect->xmin) / 4); + x /= (float)(BLI_RCT_SIZE_X(rect) / 4); y = BLI_RCT_CENTER_Y(rect) - my; - y /= (float)((rect->ymax - rect->ymin) / 2); + y /= (float)(BLI_RCT_SIZE_Y(rect) / 2); d = sqrt(x * x + y * y); if (d < radius * (float)M_SQRT1_2) { /* Inside sphere */ @@ -2784,8 +2784,8 @@ static int view3d_zoom_border_exec(bContext *C, wmOperator *op) } /* work out the ratios, so that everything selected fits when we zoom */ - xscale = ((rect.xmax - rect.xmin) / vb[0]); - yscale = ((rect.ymax - rect.ymin) / vb[1]); + xscale = (BLI_RCT_SIZE_X(&rect) / vb[0]); + yscale = (BLI_RCT_SIZE_Y(&rect) / vb[1]); new_dist *= maxf(xscale, yscale); /* zoom in as required, or as far as we can go */ diff --git a/source/blender/editors/space_view3d/view3d_select.c b/source/blender/editors/space_view3d/view3d_select.c index 8ef1b481143..49d7c9ba28c 100644 --- a/source/blender/editors/space_view3d/view3d_select.c +++ b/source/blender/editors/space_view3d/view3d_select.c @@ -654,8 +654,8 @@ int do_paintvert_box_select(ViewContext *vc, rcti *rect, int select, int extend) unsigned int *rt; int a, index; char *selar; - int sx = rect->xmax - rect->xmin + 1; - int sy = rect->ymax - rect->ymin + 1; + int sx = BLI_RCT_SIZE_X(rect) + 1; + int sy = BLI_RCT_SIZE_Y(rect) + 1; me = vc->obact->data; diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c index f88d4becc74..6b6da99cf39 100644 --- a/source/blender/editors/transform/transform.c +++ b/source/blender/editors/transform/transform.c @@ -125,11 +125,11 @@ static void convertViewVec2D(View2D *v2d, float r_vec[3], int dx, int dy) { float divx, divy; - divx = v2d->mask.xmax - v2d->mask.xmin; - divy = v2d->mask.ymax - v2d->mask.ymin; + divx = BLI_RCT_SIZE_X(&v2d->mask); + divy = BLI_RCT_SIZE_Y(&v2d->mask); - r_vec[0] = (v2d->cur.xmax - v2d->cur.xmin) * dx / divx; - r_vec[1] = (v2d->cur.ymax - v2d->cur.ymin) * dy / divy; + r_vec[0] = BLI_RCT_SIZE_X(&v2d->cur) * dx / divx; + r_vec[1] = BLI_RCT_SIZE_Y(&v2d->cur) * dy / divy; r_vec[2] = 0.0f; } @@ -138,11 +138,11 @@ static void convertViewVec2D_mask(View2D *v2d, float r_vec[3], int dx, int dy) float divx, divy; float mulx, muly; - divx = v2d->mask.xmax - v2d->mask.xmin; - divy = v2d->mask.ymax - v2d->mask.ymin; + divx = BLI_RCT_SIZE_X(&v2d->mask); + divy = BLI_RCT_SIZE_Y(&v2d->mask); - mulx = (v2d->cur.xmax - v2d->cur.xmin); - muly = (v2d->cur.ymax - v2d->cur.ymin); + mulx = BLI_RCT_SIZE_X(&v2d->cur); + muly = BLI_RCT_SIZE_Y(&v2d->cur); /* difference with convertViewVec2D */ /* clamp w/h, mask only */ diff --git a/source/blender/windowmanager/intern/wm_subwindow.c b/source/blender/windowmanager/intern/wm_subwindow.c index c9fb2644cfa..0fa29bf3f14 100644 --- a/source/blender/windowmanager/intern/wm_subwindow.c +++ b/source/blender/windowmanager/intern/wm_subwindow.c @@ -116,8 +116,8 @@ void wm_subwindow_getsize(wmWindow *win, int swinid, int *x, int *y) wmSubWindow *swin = swin_from_swinid(win, swinid); if (swin) { - *x = swin->winrct.xmax - swin->winrct.xmin + 1; - *y = swin->winrct.ymax - swin->winrct.ymin + 1; + *x = BLI_RCT_SIZE_X(&swin->winrct) + 1; + *y = BLI_RCT_SIZE_Y(&swin->winrct) + 1; } } diff --git a/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp b/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp index cef068ccbaa..1b8f857c2cb 100644 --- a/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp +++ b/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp @@ -458,7 +458,7 @@ extern "C" void StartKetsjiShell(struct bContext *C, struct ARegion *ar, rcti *c // itself is unaware of the extra space, so we clear the whole region for it. glClearColor(scene->gm.framing.col[0], scene->gm.framing.col[1], scene->gm.framing.col[2], 1.0f); glViewport(ar->winrct.xmin, ar->winrct.ymin, - ar->winrct.xmax - ar->winrct.xmin, ar->winrct.ymax - ar->winrct.ymin); + BLI_RCT_SIZE_X(&ar->winrct), BLI_RCT_SIZE_Y(&ar->winrct)); glClear(GL_COLOR_BUFFER_BIT); } From 49d3766ceb17082fd64cdc0f01224237f1098564 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 21 Aug 2012 08:20:32 +0000 Subject: [PATCH 037/163] code cleanup: use math functions for curve compo code. --- .../COM_ColorBalanceASCCDLOperation.cpp | 6 +++--- .../operations/COM_ColorCurveOperation.cpp | 19 ++++++++----------- .../operations/COM_ColorCurveOperation.h | 4 ++-- 3 files changed, 13 insertions(+), 16 deletions(-) diff --git a/source/blender/compositor/operations/COM_ColorBalanceASCCDLOperation.cpp b/source/blender/compositor/operations/COM_ColorBalanceASCCDLOperation.cpp index dfbbef8c56e..aa4d0932c92 100644 --- a/source/blender/compositor/operations/COM_ColorBalanceASCCDLOperation.cpp +++ b/source/blender/compositor/operations/COM_ColorBalanceASCCDLOperation.cpp @@ -61,9 +61,9 @@ void ColorBalanceASCCDLOperation::executePixel(float output[4], float x, float y fac = min(1.0f, fac); const float mfac = 1.0f - fac; - output[0] = mfac * inputColor[0] + fac *colorbalance_cdl(inputColor[0], this->m_lift[0], this->m_gamma[0], this->m_gain[0]); - output[1] = mfac * inputColor[1] + fac *colorbalance_cdl(inputColor[1], this->m_lift[1], this->m_gamma[1], this->m_gain[1]); - output[2] = mfac * inputColor[2] + fac *colorbalance_cdl(inputColor[2], this->m_lift[2], this->m_gamma[2], this->m_gain[2]); + output[0] = mfac * inputColor[0] + fac * colorbalance_cdl(inputColor[0], this->m_lift[0], this->m_gamma[0], this->m_gain[0]); + output[1] = mfac * inputColor[1] + fac * colorbalance_cdl(inputColor[1], this->m_lift[1], this->m_gamma[1], this->m_gain[1]); + output[2] = mfac * inputColor[2] + fac * colorbalance_cdl(inputColor[2], this->m_lift[2], this->m_gamma[2], this->m_gain[2]); output[3] = inputColor[3]; } diff --git a/source/blender/compositor/operations/COM_ColorCurveOperation.cpp b/source/blender/compositor/operations/COM_ColorCurveOperation.cpp index 44784837301..ff2cf96d0ad 100644 --- a/source/blender/compositor/operations/COM_ColorCurveOperation.cpp +++ b/source/blender/compositor/operations/COM_ColorCurveOperation.cpp @@ -76,17 +76,16 @@ void ColorCurveOperation::executePixel(float output[4], float x, float y, PixelS this->m_inputFacProgram->read(fac, x, y, sampler); this->m_inputImageProgram->read(image, x, y, sampler); - if (*fac >= 1.0f) + if (*fac >= 1.0f) { curvemapping_evaluate_premulRGBF(workingCopy, output, image); + } else if (*fac <= 0.0f) { copy_v3_v3(output, image); } else { - float col[4], mfac = 1.0f - *fac; + float col[4]; curvemapping_evaluate_premulRGBF(workingCopy, col, image); - output[0] = mfac * image[0] + *fac * col[0]; - output[1] = mfac * image[1] + *fac * col[1]; - output[2] = mfac * image[2] + *fac * col[2]; + interp_v3_v3v3(output, image, col, *fac); } output[3] = image[3]; MEM_freeN(workingCopy); @@ -131,21 +130,19 @@ void ConstantLevelColorCurveOperation::executePixel(float output[4], float x, fl float fac[4]; float image[4]; - this->m_inputFacProgram->read(fac, x, y, sampler); this->m_inputImageProgram->read(image, x, y, sampler); - if (*fac >= 1.0f) + if (*fac >= 1.0f) { curvemapping_evaluate_premulRGBF(this->m_curveMapping, output, image); + } else if (*fac <= 0.0f) { copy_v3_v3(output, image); } else { - float col[4], mfac = 1.0f - *fac; + float col[4]; curvemapping_evaluate_premulRGBF(this->m_curveMapping, col, image); - output[0] = mfac * image[0] + *fac * col[0]; - output[1] = mfac * image[1] + *fac * col[1]; - output[2] = mfac * image[2] + *fac * col[2]; + interp_v3_v3v3(output, image, col, *fac); } output[3] = image[3]; } diff --git a/source/blender/compositor/operations/COM_ColorCurveOperation.h b/source/blender/compositor/operations/COM_ColorCurveOperation.h index 063873c6443..7dc1913b85a 100644 --- a/source/blender/compositor/operations/COM_ColorCurveOperation.h +++ b/source/blender/compositor/operations/COM_ColorCurveOperation.h @@ -82,8 +82,8 @@ public: */ void deinitExecution(); - void setBlackLevel(float black[3]) { this->m_black[0] = black[0]; this->m_black[1] = black[1]; this->m_black[2] = black[2]; } - void setWhiteLevel(float white[3]) { this->m_white[0] = white[0]; this->m_white[1] = white[1]; this->m_white[2] = white[2]; } + void setBlackLevel(float black[3]) { copy_v3_v3(this->m_black, black); } + void setWhiteLevel(float white[3]) { copy_v3_v3(this->m_white, white); } }; #endif From 988df245519352ab80d8ad488660a0a2f7a963d3 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 21 Aug 2012 08:30:45 +0000 Subject: [PATCH 038/163] compositor color curve was MEM_dupallocN'ing the curve for every pixel calculation (when there were black or white inputs on the curve node). avoid allocation by using local vars for black/white storage & curve calculation. --- source/blender/blenkernel/BKE_colortools.h | 3 + source/blender/blenkernel/intern/colortools.c | 57 +++++++++++++++---- .../operations/COM_ColorCurveOperation.cpp | 19 ++++--- 3 files changed, 60 insertions(+), 19 deletions(-) diff --git a/source/blender/blenkernel/BKE_colortools.h b/source/blender/blenkernel/BKE_colortools.h index dcb40c960b1..90358ba9609 100644 --- a/source/blender/blenkernel/BKE_colortools.h +++ b/source/blender/blenkernel/BKE_colortools.h @@ -53,6 +53,7 @@ void curvemapping_free_data(struct CurveMapping *cumap); void curvemapping_free(struct CurveMapping *cumap); void curvemapping_copy_data(struct CurveMapping *target, struct CurveMapping *cumap); struct CurveMapping *curvemapping_copy(struct CurveMapping *cumap); +void curvemapping_set_black_white_ex(const float black[3], const float white[3], float r_bwmul[3]); void curvemapping_set_black_white(struct CurveMapping *cumap, const float black[3], const float white[3]); #define CURVEMAP_SLOPE_NEGATIVE 0 @@ -73,6 +74,8 @@ float curvemapping_evaluateF(struct CurveMapping *cumap, int cur, void curvemapping_evaluate3F(struct CurveMapping *cumap, float vecout[3], const float vecin[3]); void curvemapping_evaluateRGBF(struct CurveMapping *cumap, float vecout[3], const float vecin[3]); void curvemapping_evaluate_premulRGB(struct CurveMapping *cumap, unsigned char vecout_byte[3], const unsigned char vecin_byte[3]); +void curvemapping_evaluate_premulRGBF_ex(struct CurveMapping *cumap, float vecout[3], const float vecin[3], + const float black[3], const float bwmul[3]); void curvemapping_evaluate_premulRGBF(struct CurveMapping *cumap, float vecout[3], const float vecin[3]); void curvemapping_do_ibuf(struct CurveMapping *cumap, struct ImBuf *ibuf); void curvemapping_premultiply(struct CurveMapping *cumap, int restore); diff --git a/source/blender/blenkernel/intern/colortools.c b/source/blender/blenkernel/intern/colortools.c index 118169e8f7d..606fd83b1a5 100644 --- a/source/blender/blenkernel/intern/colortools.c +++ b/source/blender/blenkernel/intern/colortools.c @@ -145,21 +145,31 @@ CurveMapping *curvemapping_copy(CurveMapping *cumap) return NULL; } -void curvemapping_set_black_white(CurveMapping *cumap, const float black[3], const float white[3]) +void curvemapping_set_black_white_ex(const float black[3], const float white[3], float r_bwmul[3]) { int a; - - if (white) - copy_v3_v3(cumap->white, white); - if (black) - copy_v3_v3(cumap->black, black); - + for (a = 0; a < 3; a++) { - if (cumap->white[a] == cumap->black[a]) - cumap->bwmul[a] = 0.0f; - else - cumap->bwmul[a] = 1.0f / (cumap->white[a] - cumap->black[a]); - } + const float delta = white[a] - black[a]; + if (delta != 0.0f) { + r_bwmul[a] = 1.0f / delta; + } + else { + r_bwmul[a] = 0.0f; + } + } +} + +void curvemapping_set_black_white(CurveMapping *cumap, const float black[3], const float white[3]) +{ + if (white) { + copy_v3_v3(cumap->white, white); + } + if (black) { + copy_v3_v3(cumap->black, black); + } + + curvemapping_set_black_white_ex(cumap->black, cumap->white, cumap->bwmul); } /* ***************** operations on single curve ************* */ @@ -785,6 +795,29 @@ void curvemapping_evaluateRGBF(CurveMapping *cumap, float vecout[3], const float vecout[2] = curvemapping_evaluateF(cumap, 2, curvemapping_evaluateF(cumap, 3, vecin[2])); } +/** same as #curvemapping_evaluate_premulRGBF + * but black/bwmul are passed as args for the compositor + * where they can change per pixel. + * + * Use in conjunction with #curvemapping_set_black_white_ex + * + * \param black Use instead of cumap->black + * \param bwmul Use instead of cumap->bwmul + */ +void curvemapping_evaluate_premulRGBF_ex(CurveMapping *cumap, float vecout[3], const float vecin[3], + const float black[3], const float bwmul[3]) +{ + float fac; + + fac = (vecin[0] - black[0]) * bwmul[0]; + vecout[0] = curvemap_evaluateF(cumap->cm, fac); + + fac = (vecin[1] - black[1]) * bwmul[1]; + vecout[1] = curvemap_evaluateF(cumap->cm + 1, fac); + + fac = (vecin[2] - black[2]) * bwmul[2]; + vecout[2] = curvemap_evaluateF(cumap->cm + 2, fac); +} /* RGB with black/white points and premult. tables are checked */ void curvemapping_evaluate_premulRGBF(CurveMapping *cumap, float vecout[3], const float vecin[3]) diff --git a/source/blender/compositor/operations/COM_ColorCurveOperation.cpp b/source/blender/compositor/operations/COM_ColorCurveOperation.cpp index ff2cf96d0ad..81205514040 100644 --- a/source/blender/compositor/operations/COM_ColorCurveOperation.cpp +++ b/source/blender/compositor/operations/COM_ColorCurveOperation.cpp @@ -61,34 +61,39 @@ void ColorCurveOperation::initExecution() void ColorCurveOperation::executePixel(float output[4], float x, float y, PixelSampler sampler) { CurveMapping *cumap = this->m_curveMapping; - CurveMapping *workingCopy = (CurveMapping *)MEM_dupallocN(cumap); - float black[4]; - float white[4]; float fac[4]; float image[4]; + /* local versions of cumap->black, cumap->white, cumap->bwmul */ + float black[4]; + float white[4]; + float bwmul[3]; + this->m_inputBlackProgram->read(black, x, y, sampler); this->m_inputWhiteProgram->read(white, x, y, sampler); - curvemapping_set_black_white(workingCopy, black, white); + /* get our own local bwmul value, + * since we can't be threadsafe and use cumap->bwmul & friends */ + curvemapping_set_black_white_ex(black, white, bwmul); this->m_inputFacProgram->read(fac, x, y, sampler); this->m_inputImageProgram->read(image, x, y, sampler); if (*fac >= 1.0f) { - curvemapping_evaluate_premulRGBF(workingCopy, output, image); + curvemapping_evaluate_premulRGBF_ex(cumap, output, image, + black, bwmul); } else if (*fac <= 0.0f) { copy_v3_v3(output, image); } else { float col[4]; - curvemapping_evaluate_premulRGBF(workingCopy, col, image); + curvemapping_evaluate_premulRGBF_ex(cumap, col, image, + black, bwmul); interp_v3_v3v3(output, image, col, *fac); } output[3] = image[3]; - MEM_freeN(workingCopy); } void ColorCurveOperation::deinitExecution() From 320473120958cf4c978eb12ca37e07dec8ed0e71 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 21 Aug 2012 08:47:36 +0000 Subject: [PATCH 039/163] code cleanup: don't use magic numbers for curve flag & use bool args for curvemapping_changed() --- source/blender/blenkernel/BKE_colortools.h | 2 +- source/blender/blenkernel/intern/brush.c | 2 +- source/blender/blenkernel/intern/colortools.c | 34 ++++++------------- source/blender/blenkernel/intern/texture.c | 2 +- .../blenloader/intern/versioning_250.c | 2 +- .../editors/interface/interface_draw.c | 4 +-- .../editors/interface/interface_handlers.c | 27 ++++++++------- .../editors/interface/interface_templates.c | 14 ++++---- source/blender/makesdna/DNA_color_types.h | 6 ++-- source/blender/makesrna/intern/rna_color.c | 2 +- 10 files changed, 42 insertions(+), 53 deletions(-) diff --git a/source/blender/blenkernel/BKE_colortools.h b/source/blender/blenkernel/BKE_colortools.h index 90358ba9609..249cb32a082 100644 --- a/source/blender/blenkernel/BKE_colortools.h +++ b/source/blender/blenkernel/BKE_colortools.h @@ -59,7 +59,7 @@ void curvemapping_set_black_white(struct CurveMapping *cumap, con #define CURVEMAP_SLOPE_NEGATIVE 0 #define CURVEMAP_SLOPE_POSITIVE 1 void curvemap_reset(struct CurveMap *cuma, struct rctf *clipr, int preset, int slope); -void curvemap_remove(struct CurveMap *cuma, int flag); +void curvemap_remove(struct CurveMap *cuma, const short flag); void curvemap_remove_point(struct CurveMap *cuma, struct CurveMapPoint *cmp); struct CurveMapPoint *curvemap_insert(struct CurveMap *cuma, float x, float y); void curvemap_sethandle(struct CurveMap *cuma, int type); diff --git a/source/blender/blenkernel/intern/brush.c b/source/blender/blenkernel/intern/brush.c index 468861242d0..fc4df9594f3 100644 --- a/source/blender/blenkernel/intern/brush.c +++ b/source/blender/blenkernel/intern/brush.c @@ -421,7 +421,7 @@ void BKE_brush_curve_preset(Brush *b, /*CurveMappingPreset*/ int preset) b->curve->preset = preset; curvemap_reset(cm, &b->curve->clipr, b->curve->preset, CURVEMAP_SLOPE_NEGATIVE); - curvemapping_changed(b->curve, 0); + curvemapping_changed(b->curve, FALSE); } int BKE_brush_texture_set_nr(Brush *brush, int nr) diff --git a/source/blender/blenkernel/intern/colortools.c b/source/blender/blenkernel/intern/colortools.c index 606fd83b1a5..4bc22d77ec9 100644 --- a/source/blender/blenkernel/intern/colortools.c +++ b/source/blender/blenkernel/intern/colortools.c @@ -202,7 +202,7 @@ void curvemap_remove_point(CurveMap *cuma, CurveMapPoint *point) } /* removes with flag set */ -void curvemap_remove(CurveMap *cuma, int flag) +void curvemap_remove(CurveMap *cuma, const short flag) { CurveMapPoint *cmp = MEM_mallocN((cuma->totpoint) * sizeof(CurveMapPoint), "curve points"); int a, b, removed = 0; @@ -711,12 +711,12 @@ void curvemapping_changed(CurveMapping *cumap, int rem_doubles) dy = cmp[a].y - cmp[a + 1].y; if (sqrtf(dx * dx + dy * dy) < thresh) { if (a == 0) { - cmp[a + 1].flag |= 2; + cmp[a + 1].flag |= CUMA_VECTOR; if (cmp[a + 1].flag & CUMA_SELECT) cmp[a].flag |= CUMA_SELECT; } else { - cmp[a].flag |= 2; + cmp[a].flag |= CUMA_VECTOR; if (cmp[a].flag & CUMA_SELECT) cmp[a + 1].flag |= CUMA_SELECT; } @@ -736,7 +736,7 @@ void curvemapping_changed_all(CurveMapping *cumap) for (a = 0; a < CM_TOT; a++) { if (cumap->cm[a].curve) { cumap->cur = a; - curvemapping_changed(cumap, 0); + curvemapping_changed(cumap, FALSE); } } @@ -807,31 +807,17 @@ void curvemapping_evaluateRGBF(CurveMapping *cumap, float vecout[3], const float void curvemapping_evaluate_premulRGBF_ex(CurveMapping *cumap, float vecout[3], const float vecin[3], const float black[3], const float bwmul[3]) { - float fac; - - fac = (vecin[0] - black[0]) * bwmul[0]; - vecout[0] = curvemap_evaluateF(cumap->cm, fac); - - fac = (vecin[1] - black[1]) * bwmul[1]; - vecout[1] = curvemap_evaluateF(cumap->cm + 1, fac); - - fac = (vecin[2] - black[2]) * bwmul[2]; - vecout[2] = curvemap_evaluateF(cumap->cm + 2, fac); + vecout[0] = curvemap_evaluateF(&cumap->cm[0], (vecin[0] - black[0]) * bwmul[0]); + vecout[1] = curvemap_evaluateF(&cumap->cm[1], (vecin[1] - black[1]) * bwmul[1]); + vecout[2] = curvemap_evaluateF(&cumap->cm[2], (vecin[2] - black[2]) * bwmul[2]); } /* RGB with black/white points and premult. tables are checked */ void curvemapping_evaluate_premulRGBF(CurveMapping *cumap, float vecout[3], const float vecin[3]) { - float fac; - - fac = (vecin[0] - cumap->black[0]) * cumap->bwmul[0]; - vecout[0] = curvemap_evaluateF(cumap->cm, fac); - - fac = (vecin[1] - cumap->black[1]) * cumap->bwmul[1]; - vecout[1] = curvemap_evaluateF(cumap->cm + 1, fac); - - fac = (vecin[2] - cumap->black[2]) * cumap->bwmul[2]; - vecout[2] = curvemap_evaluateF(cumap->cm + 2, fac); + vecout[0] = curvemap_evaluateF(&cumap->cm[0], (vecin[0] - cumap->black[0]) * cumap->bwmul[0]); + vecout[1] = curvemap_evaluateF(&cumap->cm[1], (vecin[1] - cumap->black[1]) * cumap->bwmul[1]); + vecout[2] = curvemap_evaluateF(&cumap->cm[2], (vecin[2] - cumap->black[2]) * cumap->bwmul[2]); } /* same as above, byte version */ diff --git a/source/blender/blenkernel/intern/texture.c b/source/blender/blenkernel/intern/texture.c index 5bad69c2e8d..2f54fe6cebd 100644 --- a/source/blender/blenkernel/intern/texture.c +++ b/source/blender/blenkernel/intern/texture.c @@ -1292,7 +1292,7 @@ PointDensity *BKE_add_pointdensity(void) pd->falloff_curve->preset = CURVE_PRESET_LINE; pd->falloff_curve->cm->flag &= ~CUMA_EXTEND_EXTRAPOLATE; curvemap_reset(pd->falloff_curve->cm, &pd->falloff_curve->clipr, pd->falloff_curve->preset, CURVEMAP_SLOPE_POSITIVE); - curvemapping_changed(pd->falloff_curve, 0); + curvemapping_changed(pd->falloff_curve, FALSE); return pd; } diff --git a/source/blender/blenloader/intern/versioning_250.c b/source/blender/blenloader/intern/versioning_250.c index d551caea425..ed5ffbf463e 100644 --- a/source/blender/blenloader/intern/versioning_250.c +++ b/source/blender/blenloader/intern/versioning_250.c @@ -2435,7 +2435,7 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main) tex->pd->falloff_curve->preset = CURVE_PRESET_LINE; tex->pd->falloff_curve->cm->flag &= ~CUMA_EXTEND_EXTRAPOLATE; curvemap_reset(tex->pd->falloff_curve->cm, &tex->pd->falloff_curve->clipr, tex->pd->falloff_curve->preset, CURVEMAP_SLOPE_POSITIVE); - curvemapping_changed(tex->pd->falloff_curve, 0); + curvemapping_changed(tex->pd->falloff_curve, FALSE); } } } diff --git a/source/blender/editors/interface/interface_draw.c b/source/blender/editors/interface/interface_draw.c index e66c0409192..c9a6ba0abe7 100644 --- a/source/blender/editors/interface/interface_draw.c +++ b/source/blender/editors/interface/interface_draw.c @@ -1481,7 +1481,7 @@ void ui_draw_but_CURVE(ARegion *ar, uiBut *but, uiWidgetColors *wcol, rcti *rect glBegin(GL_LINE_STRIP); if (cuma->table == NULL) - curvemapping_changed(cumap, 0); /* 0 = no remove doubles */ + curvemapping_changed(cumap, FALSE); cmp = cuma->table; /* first point */ @@ -1514,7 +1514,7 @@ void ui_draw_but_CURVE(ARegion *ar, uiBut *but, uiWidgetColors *wcol, rcti *rect glPointSize(3.0f); bglBegin(GL_POINTS); for (a = 0; a < cuma->totpoint; a++) { - if (cmp[a].flag & SELECT) + if (cmp[a].flag & CUMA_SELECT) UI_ThemeColor(TH_TEXT_HI); else UI_ThemeColor(TH_TEXT); diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c index d78a677ea58..ce0ec310ac3 100644 --- a/source/blender/editors/interface/interface_handlers.c +++ b/source/blender/editors/interface/interface_handlers.c @@ -3647,7 +3647,7 @@ static int ui_numedit_but_CURVE(uiBut *but, uiHandleButtonData *data, int snap, fy *= mval_factor; for (a = 0; a < cuma->totpoint; a++) { - if (cmp[a].flag & SELECT) { + if (cmp[a].flag & CUMA_SELECT) { float origx = cmp[a].x, origy = cmp[a].y; cmp[a].x += fx; cmp[a].y += fy; @@ -3660,7 +3660,7 @@ static int ui_numedit_but_CURVE(uiBut *but, uiHandleButtonData *data, int snap, } } - curvemapping_changed(cumap, 0); /* no remove doubles */ + curvemapping_changed(cumap, FALSE); if (moved_point) { data->draglastx = mx; @@ -3727,7 +3727,7 @@ static int ui_do_but_CURVE(bContext *C, uiBlock *block, uiBut *but, uiHandleButt fy = ((float)my - but->rect.ymin) / zoomy + offsy; curvemap_insert(cuma, fx, fy); - curvemapping_changed(cumap, 0); + curvemapping_changed(cumap, FALSE); changed = 1; } @@ -3756,12 +3756,12 @@ static int ui_do_but_CURVE(bContext *C, uiBlock *block, uiBut *but, uiHandleButt /* loop through the curve segment table and find what's near the mouse. * 0.05 is kinda arbitrary, but seems to be what works nicely. */ for (i = 0; i <= CM_TABLE; i++) { - if ( (fabsf(fx - cmp[i].x) < 0.05f) && - (fabsf(fy - cmp[i].y) < 0.05f)) + if ((fabsf(fx - cmp[i].x) < 0.05f) && + (fabsf(fy - cmp[i].y) < 0.05f)) { curvemap_insert(cuma, fx, fy); - curvemapping_changed(cumap, 0); + curvemapping_changed(cumap, FALSE); changed = 1; @@ -3783,11 +3783,11 @@ static int ui_do_but_CURVE(bContext *C, uiBlock *block, uiBut *but, uiHandleButt /* deselect all if this one is deselect. except if we hold shift */ if (event->shift == FALSE) { for (a = 0; a < cuma->totpoint; a++) - cmp[a].flag &= ~SELECT; - cmp[sel].flag |= SELECT; + cmp[a].flag &= ~CUMA_SELECT; + cmp[sel].flag |= CUMA_SELECT; } else - cmp[sel].flag ^= SELECT; + cmp[sel].flag ^= CUMA_SELECT; } else { /* move the view */ @@ -3822,12 +3822,13 @@ static int ui_do_but_CURVE(bContext *C, uiBlock *block, uiBut *but, uiHandleButt /* deselect all, select one */ if (event->shift == FALSE) { for (a = 0; a < cuma->totpoint; a++) - cmp[a].flag &= ~SELECT; - cmp[data->dragsel].flag |= SELECT; + cmp[a].flag &= ~CUMA_SELECT; + cmp[data->dragsel].flag |= CUMA_SELECT; } } - else - curvemapping_changed(cumap, 1); /* remove doubles */ + else { + curvemapping_changed(cumap, TRUE); /* remove doubles */ + } } button_activate_state(C, but, BUTTON_STATE_EXIT); diff --git a/source/blender/editors/interface/interface_templates.c b/source/blender/editors/interface/interface_templates.c index 24dccb2eecf..54202caa16c 100644 --- a/source/blender/editors/interface/interface_templates.c +++ b/source/blender/editors/interface/interface_templates.c @@ -1622,7 +1622,7 @@ static void curvemap_buttons_setclip(bContext *UNUSED(C), void *cumap_v, void *U { CurveMapping *cumap = cumap_v; - curvemapping_changed(cumap, 0); + curvemapping_changed(cumap, FALSE); } static void curvemap_buttons_delete(bContext *C, void *cb_v, void *cumap_v) @@ -1630,7 +1630,7 @@ static void curvemap_buttons_delete(bContext *C, void *cb_v, void *cumap_v) CurveMapping *cumap = cumap_v; curvemap_remove(cumap->cm + cumap->cur, SELECT); - curvemapping_changed(cumap, 0); + curvemapping_changed(cumap, FALSE); rna_update_cb(C, cb_v, NULL); } @@ -1672,26 +1672,26 @@ static void curvemap_tools_dofunc(bContext *C, void *cumap_v, int event) switch (event) { case 0: /* reset */ curvemap_reset(cuma, &cumap->clipr, cumap->preset, CURVEMAP_SLOPE_POSITIVE); - curvemapping_changed(cumap, 0); + curvemapping_changed(cumap, FALSE); break; case 1: cumap->curr = cumap->clipr; break; case 2: /* set vector */ curvemap_sethandle(cuma, 1); - curvemapping_changed(cumap, 0); + curvemapping_changed(cumap, FALSE); break; case 3: /* set auto */ curvemap_sethandle(cuma, 0); - curvemapping_changed(cumap, 0); + curvemapping_changed(cumap, FALSE); break; case 4: /* extend horiz */ cuma->flag &= ~CUMA_EXTEND_EXTRAPOLATE; - curvemapping_changed(cumap, 0); + curvemapping_changed(cumap, FALSE); break; case 5: /* extend extrapolate */ cuma->flag |= CUMA_EXTEND_EXTRAPOLATE; - curvemapping_changed(cumap, 0); + curvemapping_changed(cumap, FALSE); break; } ED_region_tag_redraw(CTX_wm_region(C)); diff --git a/source/blender/makesdna/DNA_color_types.h b/source/blender/makesdna/DNA_color_types.h index 1f8fdd20dda..4ead26c04f3 100644 --- a/source/blender/makesdna/DNA_color_types.h +++ b/source/blender/makesdna/DNA_color_types.h @@ -47,8 +47,10 @@ typedef struct CurveMapPoint { } CurveMapPoint; /* curvepoint->flag */ -#define CUMA_SELECT 1 -#define CUMA_VECTOR 2 +enum { + CUMA_SELECT = 1, + CUMA_VECTOR = 2 +}; typedef struct CurveMap { short totpoint, flag; diff --git a/source/blender/makesrna/intern/rna_color.c b/source/blender/makesrna/intern/rna_color.c index 15fdce09d83..5dafe77f9c1 100644 --- a/source/blender/makesrna/intern/rna_color.c +++ b/source/blender/makesrna/intern/rna_color.c @@ -79,7 +79,7 @@ static void rna_CurveMapping_clip_set(PointerRNA *ptr, int value) if (value) cumap->flag |= CUMA_DO_CLIP; else cumap->flag &= ~CUMA_DO_CLIP; - curvemapping_changed(cumap, 0); + curvemapping_changed(cumap, FALSE); } static void rna_CurveMapping_black_level_set(PointerRNA *ptr, const float *values) From 29dd72ea8496a4f0ece16e691c310c086b65bd25 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 21 Aug 2012 08:58:47 +0000 Subject: [PATCH 040/163] code cleanup: some legacy compo nodes were not ifdef'd --- source/blender/editors/interface/interface_templates.c | 2 +- .../nodes/composite/nodes/node_composite_alphaOver.c | 1 + .../nodes/composite/nodes/node_composite_bilateralblur.c | 1 + .../blender/nodes/composite/nodes/node_composite_blur.c | 1 + .../nodes/composite/nodes/node_composite_brightness.c | 2 +- .../nodes/composite/nodes/node_composite_colorSpill.c | 2 +- .../nodes/composite/nodes/node_composite_composite.c | 1 + .../nodes/composite/nodes/node_composite_keying.c | 9 +++++++-- .../nodes/composite/nodes/node_composite_keyingscreen.c | 9 +++++++-- .../blender/nodes/composite/nodes/node_composite_mask.c | 8 ++++++-- .../composite/nodes/node_composite_moviedistortion.c | 9 +++++++-- .../nodes/composite/nodes/node_composite_outputFile.c | 9 +++++++-- .../nodes/composite/nodes/node_composite_splitViewer.c | 1 + .../nodes/composite/nodes/node_composite_viewer.c | 1 + 14 files changed, 43 insertions(+), 13 deletions(-) diff --git a/source/blender/editors/interface/interface_templates.c b/source/blender/editors/interface/interface_templates.c index 54202caa16c..71c019ae29e 100644 --- a/source/blender/editors/interface/interface_templates.c +++ b/source/blender/editors/interface/interface_templates.c @@ -1757,7 +1757,7 @@ static void curvemap_buttons_reset(bContext *C, void *cb_v, void *cumap_v) cumap->white[0] = cumap->white[1] = cumap->white[2] = 1.0f; curvemapping_set_black_white(cumap, NULL, NULL); - curvemapping_changed(cumap, 0); + curvemapping_changed(cumap, FALSE); rna_update_cb(C, cb_v, NULL); } diff --git a/source/blender/nodes/composite/nodes/node_composite_alphaOver.c b/source/blender/nodes/composite/nodes/node_composite_alphaOver.c index 92702ef2940..6fbff76e2dd 100644 --- a/source/blender/nodes/composite/nodes/node_composite_alphaOver.c +++ b/source/blender/nodes/composite/nodes/node_composite_alphaOver.c @@ -157,5 +157,6 @@ void register_node_type_cmp_alphaover(bNodeTreeType *ttype) #ifdef WITH_COMPOSITOR_LEGACY node_type_exec(&ntype, node_composit_exec_alphaover); #endif + nodeRegisterType(ttype, &ntype); } diff --git a/source/blender/nodes/composite/nodes/node_composite_bilateralblur.c b/source/blender/nodes/composite/nodes/node_composite_bilateralblur.c index 0562ff5a8a9..e05ef1ea5a5 100644 --- a/source/blender/nodes/composite/nodes/node_composite_bilateralblur.c +++ b/source/blender/nodes/composite/nodes/node_composite_bilateralblur.c @@ -278,5 +278,6 @@ void register_node_type_cmp_bilateralblur(bNodeTreeType *ttype) #ifdef WITH_COMPOSITOR_LEGACY node_type_exec(&ntype, node_composit_exec_bilateralblur); #endif + nodeRegisterType(ttype, &ntype); } diff --git a/source/blender/nodes/composite/nodes/node_composite_blur.c b/source/blender/nodes/composite/nodes/node_composite_blur.c index 551164b8d26..b9b2406631b 100644 --- a/source/blender/nodes/composite/nodes/node_composite_blur.c +++ b/source/blender/nodes/composite/nodes/node_composite_blur.c @@ -741,5 +741,6 @@ void register_node_type_cmp_blur(bNodeTreeType *ttype) #ifdef WITH_COMPOSITOR_LEGACY node_type_exec(&ntype, node_composit_exec_blur); #endif + nodeRegisterType(ttype, &ntype); } diff --git a/source/blender/nodes/composite/nodes/node_composite_brightness.c b/source/blender/nodes/composite/nodes/node_composite_brightness.c index f92fdd1ab9a..2b8a394d6f2 100644 --- a/source/blender/nodes/composite/nodes/node_composite_brightness.c +++ b/source/blender/nodes/composite/nodes/node_composite_brightness.c @@ -106,6 +106,6 @@ void register_node_type_cmp_brightcontrast(bNodeTreeType *ttype) #ifdef WITH_COMPOSITOR_LEGACY node_type_exec(&ntype, node_composit_exec_brightcontrast); #endif - + nodeRegisterType(ttype, &ntype); } diff --git a/source/blender/nodes/composite/nodes/node_composite_colorSpill.c b/source/blender/nodes/composite/nodes/node_composite_colorSpill.c index b8ad5bdfc7e..9456ef8e9d9 100644 --- a/source/blender/nodes/composite/nodes/node_composite_colorSpill.c +++ b/source/blender/nodes/composite/nodes/node_composite_colorSpill.c @@ -342,6 +342,6 @@ void register_node_type_cmp_color_spill(bNodeTreeType *ttype) #ifdef WITH_COMPOSITOR_LEGACY node_type_exec(&ntype, node_composit_exec_color_spill); #endif - + nodeRegisterType(ttype, &ntype); } diff --git a/source/blender/nodes/composite/nodes/node_composite_composite.c b/source/blender/nodes/composite/nodes/node_composite_composite.c index 74f2e5c5b46..dadc863873d 100644 --- a/source/blender/nodes/composite/nodes/node_composite_composite.c +++ b/source/blender/nodes/composite/nodes/node_composite_composite.c @@ -108,6 +108,7 @@ void register_node_type_cmp_composite(bNodeTreeType *ttype) #ifdef WITH_COMPOSITOR_LEGACY node_type_exec(&ntype, node_composit_exec_composite); #endif + /* Do not allow muting for this node. */ node_type_internal_connect(&ntype, NULL); diff --git a/source/blender/nodes/composite/nodes/node_composite_keying.c b/source/blender/nodes/composite/nodes/node_composite_keying.c index f3074bc8ed3..b9721910fd1 100644 --- a/source/blender/nodes/composite/nodes/node_composite_keying.c +++ b/source/blender/nodes/composite/nodes/node_composite_keying.c @@ -60,9 +60,12 @@ static bNodeSocketTemplate cmp_node_keying_out[] = { { -1, 0, "" } }; -static void exec(void *UNUSED(data), bNode *UNUSED(node), bNodeStack **UNUSED(in), bNodeStack **UNUSED(out)) +#ifdef WITH_COMPOSITOR_LEGACY +static void node_composit_exec_keying(void *UNUSED(data), bNode *UNUSED(node), bNodeStack **UNUSED(in), bNodeStack **UNUSED(out)) { + /* pass */ } +#endif /* WITH_COMPOSITOR_LEGACY */ static void node_composit_init_keying(bNodeTree *UNUSED(ntree), bNode* node, bNodeTemplate *UNUSED(ntemp)) { @@ -91,7 +94,9 @@ void register_node_type_cmp_keying(bNodeTreeType *ttype) node_type_size(&ntype, 140, 100, 320); node_type_init(&ntype, node_composit_init_keying); node_type_storage(&ntype, "NodeKeyingData", node_free_standard_storage, node_copy_standard_storage); - node_type_exec(&ntype, exec); +#ifdef WITH_COMPOSITOR_LEGACY + node_type_exec(&ntype, node_composit_exec_keying); +#endif nodeRegisterType(ttype, &ntype); } diff --git a/source/blender/nodes/composite/nodes/node_composite_keyingscreen.c b/source/blender/nodes/composite/nodes/node_composite_keyingscreen.c index 73423e2bdd3..3fc4781fdc3 100644 --- a/source/blender/nodes/composite/nodes/node_composite_keyingscreen.c +++ b/source/blender/nodes/composite/nodes/node_composite_keyingscreen.c @@ -50,6 +50,7 @@ static bNodeSocketTemplate cmp_node_keyingscreen_out[] = { { -1, 0, "" } }; +#ifdef WITH_COMPOSITOR_LEGACY static void compute_gradient_screen(RenderData *rd, NodeKeyingScreenData *keyingscreen_data, MovieClip *clip, CompBuf *screenbuf) { @@ -157,7 +158,7 @@ static void compute_gradient_screen(RenderData *rd, NodeKeyingScreenData *keying BLI_freelistN(&edges); } -static void exec(void *data, bNode *node, bNodeStack **UNUSED(in), bNodeStack **out) +static void node_composit_exec_keyingscreen(void *data, bNode *node, bNodeStack **UNUSED(in), bNodeStack **out) { NodeKeyingScreenData *keyingscreen_data = node->storage; RenderData *rd = data; @@ -178,6 +179,8 @@ static void exec(void *data, bNode *node, bNodeStack **UNUSED(in), bNodeStack ** out[0]->data = screenbuf; } +#endif /* WITH_COMPOSITOR_LEGACY */ + static void node_composit_init_keyingscreen(bNodeTree *UNUSED(ntree), bNode* node, bNodeTemplate *UNUSED(ntemp)) { NodeKeyingScreenData *data; @@ -196,7 +199,9 @@ void register_node_type_cmp_keyingscreen(bNodeTreeType *ttype) node_type_size(&ntype, 140, 100, 320); node_type_init(&ntype, node_composit_init_keyingscreen); node_type_storage(&ntype, "NodeKeyingScreenData", node_free_standard_storage, node_copy_standard_storage); - node_type_exec(&ntype, exec); +#ifdef WITH_COMPOSITOR_LEGACY + node_type_exec(&ntype, node_composit_exec_keyingscreen); +#endif nodeRegisterType(ttype, &ntype); } diff --git a/source/blender/nodes/composite/nodes/node_composite_mask.c b/source/blender/nodes/composite/nodes/node_composite_mask.c index f4cbd1b7f6f..5c5bc2a9778 100644 --- a/source/blender/nodes/composite/nodes/node_composite_mask.c +++ b/source/blender/nodes/composite/nodes/node_composite_mask.c @@ -45,7 +45,8 @@ static bNodeSocketTemplate cmp_node_mask_out[] = { { -1, 0, "" } }; -static void exec(void *data, bNode *node, bNodeStack **UNUSED(in), bNodeStack **out) +#ifdef WITH_COMPOSITOR_LEGACY +static void node_composit_exec_mask(void *data, bNode *node, bNodeStack **UNUSED(in), bNodeStack **out) { if (node->id) { Mask *mask = (Mask *)node->id; @@ -84,6 +85,7 @@ static void exec(void *data, bNode *node, bNodeStack **UNUSED(in), bNodeStack ** out[0]->data = stackbuf; } } +#endif /* WITH_COMPOSITOR_LEGACY */ static void node_composit_init_mask(bNodeTree *UNUSED(ntree), bNode* node, bNodeTemplate *UNUSED(ntemp)) { @@ -103,7 +105,9 @@ void register_node_type_cmp_mask(bNodeTreeType *ttype) node_type_socket_templates(&ntype, NULL, cmp_node_mask_out); node_type_size(&ntype, 140, 100, 320); node_type_init(&ntype, node_composit_init_mask); - node_type_exec(&ntype, exec); +#ifdef WITH_COMPOSITOR_LEGACY + node_type_exec(&ntype, node_composit_exec_mask); +#endif node_type_storage(&ntype, "NodeMask", node_free_standard_storage, node_copy_standard_storage); diff --git a/source/blender/nodes/composite/nodes/node_composite_moviedistortion.c b/source/blender/nodes/composite/nodes/node_composite_moviedistortion.c index 65fe3b251d0..9f4cd467c94 100644 --- a/source/blender/nodes/composite/nodes/node_composite_moviedistortion.c +++ b/source/blender/nodes/composite/nodes/node_composite_moviedistortion.c @@ -47,7 +47,8 @@ static bNodeSocketTemplate cmp_node_moviedistortion_out[] = { { -1, 0, "" } }; -static void exec(void *data, bNode *node, bNodeStack **in, bNodeStack **out) +#ifdef WITH_COMPOSITOR_LEGACY +static void node_composit_exec_moviedistortion(void *data, bNode *node, bNodeStack **in, bNodeStack **out) { if (in[0]->data) { if (node->id) { @@ -104,6 +105,7 @@ static void exec(void *data, bNode *node, bNodeStack **in, bNodeStack **out) } } } +#endif /* WITH_COMPOSITOR_LEGACY */ static const char *label(bNode *node) { @@ -135,7 +137,10 @@ void register_node_type_cmp_moviedistortion(bNodeTreeType *ttype) node_type_socket_templates(&ntype, cmp_node_moviedistortion_in, cmp_node_moviedistortion_out); node_type_size(&ntype, 140, 100, 320); node_type_label(&ntype, label); - node_type_exec(&ntype, exec); +#ifdef WITH_COMPOSITOR_LEGACY + node_type_exec(&ntype, node_composit_exec_moviedistortion); +#endif + node_type_storage(&ntype, NULL, storage_free, storage_copy); nodeRegisterType(ttype, &ntype); diff --git a/source/blender/nodes/composite/nodes/node_composite_outputFile.c b/source/blender/nodes/composite/nodes/node_composite_outputFile.c index 8a0d7200079..aa92e713adf 100644 --- a/source/blender/nodes/composite/nodes/node_composite_outputFile.c +++ b/source/blender/nodes/composite/nodes/node_composite_outputFile.c @@ -227,6 +227,8 @@ static void update_output_file(bNodeTree *UNUSED(ntree), bNode *node) } } +#ifdef WITH_COMPOSITOR_LEGACY + /* write input data into individual files */ static void exec_output_file_singlelayer(RenderData *rd, bNode *node, bNodeStack **in) { @@ -386,7 +388,7 @@ static void exec_output_file_multilayer(RenderData *rd, bNode *node, bNodeStack IMB_exr_close(exrhandle); } -static void exec_output_file(void *data, bNode *node, bNodeStack **in, bNodeStack **UNUSED(out)) +static void node_composit_exec_outputfile(void *data, bNode *node, bNodeStack **in, bNodeStack **UNUSED(out)) { RenderData *rd= data; NodeImageMultiFile *nimf= node->storage; @@ -403,6 +405,7 @@ static void exec_output_file(void *data, bNode *node, bNodeStack **in, bNodeStac else exec_output_file_singlelayer(rd, node, in); } +#endif /* WITH_COMPOSITOR_LEGACY */ void register_node_type_cmp_output_file(bNodeTreeType *ttype) { @@ -414,7 +417,9 @@ void register_node_type_cmp_output_file(bNodeTreeType *ttype) node_type_init(&ntype, init_output_file); node_type_storage(&ntype, "NodeImageMultiFile", free_output_file, copy_output_file); node_type_update(&ntype, update_output_file, NULL); - node_type_exec(&ntype, exec_output_file); +#ifdef WITH_COMPOSITOR_LEGACY + node_type_exec(&ntype, node_composit_exec_outputfile); +#endif nodeRegisterType(ttype, &ntype); } diff --git a/source/blender/nodes/composite/nodes/node_composite_splitViewer.c b/source/blender/nodes/composite/nodes/node_composite_splitViewer.c index af115c25c14..420718f8dd9 100644 --- a/source/blender/nodes/composite/nodes/node_composite_splitViewer.c +++ b/source/blender/nodes/composite/nodes/node_composite_splitViewer.c @@ -165,6 +165,7 @@ void register_node_type_cmp_splitviewer(bNodeTreeType *ttype) #ifdef WITH_COMPOSITOR_LEGACY node_type_exec(&ntype, node_composit_exec_splitviewer); #endif + /* Do not allow muting for this node. */ node_type_internal_connect(&ntype, NULL); diff --git a/source/blender/nodes/composite/nodes/node_composite_viewer.c b/source/blender/nodes/composite/nodes/node_composite_viewer.c index 0bdab75fc5f..6321b1def4d 100644 --- a/source/blender/nodes/composite/nodes/node_composite_viewer.c +++ b/source/blender/nodes/composite/nodes/node_composite_viewer.c @@ -148,6 +148,7 @@ void register_node_type_cmp_viewer(bNodeTreeType *ttype) #ifdef WITH_COMPOSITOR_LEGACY node_type_exec(&ntype, node_composit_exec_viewer); #endif + node_type_internal_connect(&ntype, NULL); nodeRegisterType(ttype, &ntype); From 869382403a7e9744d650f9b8ea9b7f5d5e931e6e Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 21 Aug 2012 09:20:35 +0000 Subject: [PATCH 041/163] mask: skip self intersection on drawing when fill is disabled, since it was only drawing on one side of an unfilled spline. --- source/blender/blenfont/intern/blf_font.c | 8 ++++---- source/blender/blenkernel/BKE_mask.h | 3 ++- source/blender/blenkernel/intern/mask.c | 6 +++--- source/blender/editors/mask/mask_draw.c | 2 +- 4 files changed, 10 insertions(+), 9 deletions(-) diff --git a/source/blender/blenfont/intern/blf_font.c b/source/blender/blenfont/intern/blf_font.c index 751c2f5043b..509a092fabd 100644 --- a/source/blender/blenfont/intern/blf_font.c +++ b/source/blender/blenfont/intern/blf_font.c @@ -229,9 +229,9 @@ void blf_font_buffer(FontBLF *font, const char *str) FontBufInfoBLF *buf_info = &font->buf_info; float b_col_float[4]; const unsigned char b_col_char[4] = {buf_info->col[0] * 255, - buf_info->col[1] * 255, - buf_info->col[2] * 255, - buf_info->col[3] * 255}; + buf_info->col[1] * 255, + buf_info->col[2] * 255, + buf_info->col[3] * 255}; unsigned char *cbuf; int chx, chy; @@ -242,7 +242,7 @@ void blf_font_buffer(FontBLF *font, const char *str) blf_font_ensure_ascii_table(font); - /* another buffer spesific call for color conversion */ + /* another buffer specific call for color conversion */ if (buf_info->do_color_management) { srgb_to_linearrgb_v4(b_col_float, buf_info->col); } diff --git a/source/blender/blenkernel/BKE_mask.h b/source/blender/blenkernel/BKE_mask.h index a56f99c011c..b46aefe4e98 100644 --- a/source/blender/blenkernel/BKE_mask.h +++ b/source/blender/blenkernel/BKE_mask.h @@ -78,7 +78,8 @@ void BKE_mask_spline_feather_collapse_inner_loops(struct MaskSpline *spline, float (*BKE_mask_spline_differentiate_with_resolution(struct MaskSpline *spline, int width, int height, int *tot_diff_point))[2]; float (*BKE_mask_spline_feather_differentiated_points_with_resolution_ex(struct MaskSpline *spline, int *tot_feather_point, const unsigned int resol, const int do_feather_isect))[2]; -float (*BKE_mask_spline_feather_differentiated_points_with_resolution(struct MaskSpline *spline, int width, int height, int *tot_feather_point))[2]; +float (*BKE_mask_spline_feather_differentiated_points_with_resolution(struct MaskSpline *spline, int width, int height, + int *tot_feather_point, const int do_feather_isect))[2]; float (*BKE_mask_spline_feather_points(struct MaskSpline *spline, int *tot_feather_point))[2]; diff --git a/source/blender/blenkernel/intern/mask.c b/source/blender/blenkernel/intern/mask.c index d951f430dc2..1e1cbf8610e 100644 --- a/source/blender/blenkernel/intern/mask.c +++ b/source/blender/blenkernel/intern/mask.c @@ -792,16 +792,16 @@ float (*BKE_mask_spline_feather_differentiated_points_with_resolution_ex(MaskSpl } float (*BKE_mask_spline_feather_differentiated_points_with_resolution(MaskSpline *spline, int width, int height, - int *tot_feather_point))[2] + int *tot_feather_point, const int do_feather_isect))[2] { unsigned int resol = BKE_mask_spline_feather_resolution(spline, width, height); - return BKE_mask_spline_feather_differentiated_points_with_resolution_ex(spline, tot_feather_point, resol, TRUE); + return BKE_mask_spline_feather_differentiated_points_with_resolution_ex(spline, tot_feather_point, resol, do_feather_isect); } float (*BKE_mask_spline_feather_differentiated_points(MaskSpline *spline, int *tot_feather_point))[2] { - return BKE_mask_spline_feather_differentiated_points_with_resolution(spline, 0, 0, tot_feather_point); + return BKE_mask_spline_feather_differentiated_points_with_resolution(spline, 0, 0, tot_feather_point, TRUE); } float (*BKE_mask_spline_feather_points(MaskSpline *spline, int *tot_feather_point))[2] diff --git a/source/blender/editors/mask/mask_draw.c b/source/blender/editors/mask/mask_draw.c index 9c2e70a836e..c6b19e51de9 100644 --- a/source/blender/editors/mask/mask_draw.c +++ b/source/blender/editors/mask/mask_draw.c @@ -388,7 +388,7 @@ static void draw_spline_curve(MaskLayer *masklay, MaskSpline *spline, glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); } - feather_points = BKE_mask_spline_feather_differentiated_points_with_resolution(spline, width, height, &tot_feather_point); + feather_points = BKE_mask_spline_feather_differentiated_points_with_resolution(spline, width, height, &tot_feather_point, (is_fill != FALSE)); /* draw feather */ mask_spline_feather_color_get(masklay, spline, is_spline_sel, rgb_tmp); From 34ad9ec0046b9fe521a1a2bbbcea34409384005a Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 21 Aug 2012 09:45:30 +0000 Subject: [PATCH 042/163] code cleanup: includes and correction for macro --- source/blender/blenfont/intern/blf_dir.c | 5 ++++- source/blender/blenfont/intern/blf_font.c | 10 +++++---- source/blender/blenfont/intern/blf_glyph.c | 25 ++++++++++++---------- 3 files changed, 24 insertions(+), 16 deletions(-) diff --git a/source/blender/blenfont/intern/blf_dir.c b/source/blender/blenfont/intern/blf_dir.c index 4fde9fe6787..da916067302 100644 --- a/source/blender/blenfont/intern/blf_dir.c +++ b/source/blender/blenfont/intern/blf_dir.c @@ -43,7 +43,10 @@ #include "BKE_utildefines.h" -#include "BLI_blenlib.h" +#include "BLI_fileops.h" +#include "BLI_listbase.h" +#include "BLI_path_util.h" +#include "BLI_string.h" #include "BIF_gl.h" diff --git a/source/blender/blenfont/intern/blf_font.c b/source/blender/blenfont/intern/blf_font.c index 509a092fabd..d47fa5383d4 100644 --- a/source/blender/blenfont/intern/blf_font.c +++ b/source/blender/blenfont/intern/blf_font.c @@ -43,10 +43,12 @@ #include "DNA_vec_types.h" - -#include "BLI_blenlib.h" -#include "BLI_linklist.h" /* linknode */ +#include "BLI_listbase.h" #include "BLI_math.h" +#include "BLI_rect.h" +#include "BLI_string.h" +#include "BLI_string_utf8.h" +#include "BLI_linklist.h" /* linknode */ #include "BIF_gl.h" #include "BLF_api.h" @@ -152,7 +154,7 @@ static void blf_font_ensure_ascii_table(FontBLF *font) _kern_mode, \ &(_delta)) == 0) \ { \ - _pen_x += delta.x >> 6; \ + _pen_x += _delta.x >> 6; \ } \ } \ } (void)0 diff --git a/source/blender/blenfont/intern/blf_glyph.c b/source/blender/blenfont/intern/blf_glyph.c index 3e871fefff8..302edd8d533 100644 --- a/source/blender/blenfont/intern/blf_glyph.c +++ b/source/blender/blenfont/intern/blf_glyph.c @@ -46,7 +46,8 @@ #include "DNA_vec_types.h" #include "DNA_userdef_types.h" -#include "BLI_blenlib.h" +#include "BLI_listbase.h" +#include "BLI_rect.h" #include "BIF_gl.h" #include "BLF_api.h" @@ -314,13 +315,14 @@ static void blf_texture_draw(float uv[2][2], float dx, float y1, float dx1, floa static void blf_texture5_draw(const float shadow_col[4], float uv[2][2], float x1, float y1, float x2, float y2) { - float soft[25] = {1 / 60.0f, 1 / 60.0f, 2 / 60.0f, 1 / 60.0f, 1 / 60.0f, - 1 / 60.0f, 3 / 60.0f, 5 / 60.0f, 3 / 60.0f, 1 / 60.0f, - 2 / 60.0f, 5 / 60.0f, 8 / 60.0f, 5 / 60.0f, 2 / 60.0f, - 1 / 60.0f, 3 / 60.0f, 5 / 60.0f, 3 / 60.0f, 1 / 60.0f, - 1 / 60.0f, 1 / 60.0f, 2 / 60.0f, 1 / 60.0f, 1 / 60.0f}; + const float soft[25] = {1 / 60.0f, 1 / 60.0f, 2 / 60.0f, 1 / 60.0f, 1 / 60.0f, + 1 / 60.0f, 3 / 60.0f, 5 / 60.0f, 3 / 60.0f, 1 / 60.0f, + 2 / 60.0f, 5 / 60.0f, 8 / 60.0f, 5 / 60.0f, 2 / 60.0f, + 1 / 60.0f, 3 / 60.0f, 5 / 60.0f, 3 / 60.0f, 1 / 60.0f, + 1 / 60.0f, 1 / 60.0f, 2 / 60.0f, 1 / 60.0f, 1 / 60.0f}; - float color[4], *fp = soft; + const float *fp = soft; + float color[4]; int dx, dy; color[0] = shadow_col[0]; @@ -340,11 +342,12 @@ static void blf_texture5_draw(const float shadow_col[4], float uv[2][2], float x static void blf_texture3_draw(const float shadow_col[4], float uv[2][2], float x1, float y1, float x2, float y2) { - float soft[9] = {1 / 16.0f, 2 / 16.0f, 1 / 16.0f, - 2 / 16.0f, 4 / 16.0f, 2 / 16.0f, - 1 / 16.0f, 2 / 16.0f, 1 / 16.0f}; + const float soft[9] = {1 / 16.0f, 2 / 16.0f, 1 / 16.0f, + 2 / 16.0f, 4 / 16.0f, 2 / 16.0f, + 1 / 16.0f, 2 / 16.0f, 1 / 16.0f}; - float color[4], *fp = soft; + const float *fp = soft; + float color[4]; int dx, dy; color[0] = shadow_col[0]; From 671e3df070c7868d8a5a445ebab5f819718270c4 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Tue, 21 Aug 2012 10:24:30 +0000 Subject: [PATCH 043/163] Fix #32370: compiler error in wm_playanim.c due to conflicting Carbon ID type from Quicktime headers. However the Quicktime init/exit is no longer needed here, it happens in IMB_init/IMB_exit now, so removed that code. --- .../windowmanager/intern/wm_playanim.c | 49 ++----------------- 1 file changed, 5 insertions(+), 44 deletions(-) diff --git a/source/blender/windowmanager/intern/wm_playanim.c b/source/blender/windowmanager/intern/wm_playanim.c index 3c791cb6e5d..9fc3bf9cece 100644 --- a/source/blender/windowmanager/intern/wm_playanim.c +++ b/source/blender/windowmanager/intern/wm_playanim.c @@ -49,11 +49,12 @@ #include "PIL_time.h" -#include "BLI_listbase.h" -#include "BLI_string.h" -#include "BLI_path_util.h" #include "BLI_fileops.h" +#include "BLI_listbase.h" +#include "BLI_path_util.h" #include "BLI_rect.h" +#include "BLI_string.h" +#include "BLI_utildefines.h" #include "IMB_imbuf_types.h" #include "IMB_imbuf.h" @@ -65,22 +66,12 @@ #include "BIF_gl.h" #include "BIF_glutil.h" -#ifdef WITH_QUICKTIME -# ifdef _WIN32 -# include -# include -# elif defined(__APPLE__) -# include -# endif /* __APPLE__ */ -#endif /* WITH_QUICKTIME */ - #include "DNA_scene_types.h" -#include "BLI_utildefines.h" #include "ED_datafiles.h" /* for fonts */ -#include "wm_event_types.h" #include "GHOST_C-api.h" #include "BLF_api.h" +#include "wm_event_types.h" typedef struct PlayState { @@ -827,26 +818,6 @@ void playanim(int argc, const char **argv) } } -#ifdef WITH_QUICKTIME -#if defined(_WIN32) || defined(__APPLE__) && !defined(GHOST_COCOA) - /* Initialize QuickTime */ -#ifndef noErr -#define noErr 0 -#endif - -#ifdef _WIN32 - if (InitializeQTML(0) != noErr) - G.have_quicktime = FALSE; - else - G.have_quicktime = TRUE; -#endif /* _WIN32 */ - if (EnterMovies() != noErr) - G.have_quicktime = FALSE; - else -#endif /* _WIN32 || __APPLE__ && !defined(GHOST_COCOA)*/ - G.have_quicktime = TRUE; -#endif /* WITH_QUICKTIME */ - if (argc > 1) { BLI_strncpy(filepath, argv[1], sizeof(filepath)); } @@ -1098,16 +1069,6 @@ void playanim(int argc, const char **argv) ps.picture = ps.picture->next; } -#ifdef WITH_QUICKTIME -#if defined(_WIN32) || defined(__APPLE__) && !defined(GHOST_COCOA) - if (G.have_quicktime) { - ExitMovies(); -#ifdef _WIN32 - TerminateQTML(); -#endif /* _WIN32 */ - } -#endif /* _WIN32 || __APPLE__ && !defined(GHOST_COCOA) */ -#endif /* WITH_QUICKTIME */ /* cleanup */ #ifndef USE_IMB_CACHE From 9a776daca8fa0aa9bfa22c0c4dd9b6e649acdb84 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 21 Aug 2012 10:39:02 +0000 Subject: [PATCH 044/163] code cleanup: vfont's used confusing and over complicated method of storing memory for loaded fonts, not store as a temp var in the fonts. --- intern/guardedalloc/MEM_guardedalloc.h | 2 +- intern/guardedalloc/intern/mallocn.c | 4 +- source/blender/blenkernel/BKE_font.h | 4 - source/blender/blenkernel/BKE_packedFile.h | 1 + source/blender/blenkernel/intern/font.c | 104 +++--------------- source/blender/blenkernel/intern/packedFile.c | 12 +- source/blender/blenlib/BLI_vfontdata.h | 12 -- source/blender/blenlib/intern/freetypefont.c | 13 +-- source/blender/blenloader/intern/readfile.c | 1 + source/blender/makesdna/DNA_vfont_types.h | 4 + .../blender/windowmanager/intern/wm_files.c | 6 +- .../windowmanager/intern/wm_init_exit.c | 2 - 12 files changed, 42 insertions(+), 123 deletions(-) diff --git a/intern/guardedalloc/MEM_guardedalloc.h b/intern/guardedalloc/MEM_guardedalloc.h index 149483e719f..6973c19dea9 100644 --- a/intern/guardedalloc/MEM_guardedalloc.h +++ b/intern/guardedalloc/MEM_guardedalloc.h @@ -92,7 +92,7 @@ extern "C" { /** * Duplicates a block of memory, and returns a pointer to the * newly allocated block. */ - void *MEM_dupallocN(void *vmemh) + void *MEM_dupallocN(const void *vmemh) #if MEM_GNU_ATTRIBUTES __attribute__((warn_unused_result)) #endif diff --git a/intern/guardedalloc/intern/mallocn.c b/intern/guardedalloc/intern/mallocn.c index df6f4d59c7f..a65871f4410 100644 --- a/intern/guardedalloc/intern/mallocn.c +++ b/intern/guardedalloc/intern/mallocn.c @@ -248,12 +248,12 @@ size_t MEM_allocN_len(const void *vmemh) } } -void *MEM_dupallocN(void *vmemh) +void *MEM_dupallocN(const void *vmemh) { void *newp = NULL; if (vmemh) { - MemHead *memh = vmemh; + const MemHead *memh = vmemh; memh--; #ifndef DEBUG_MEMDUPLINAME diff --git a/source/blender/blenkernel/BKE_font.h b/source/blender/blenkernel/BKE_font.h index 938a13483d5..cd52dd75f26 100644 --- a/source/blender/blenkernel/BKE_font.h +++ b/source/blender/blenkernel/BKE_font.h @@ -76,13 +76,9 @@ void BKE_vfont_builtin_register(void *mem, int size); void BKE_vfont_free_data(struct VFont *vfont); void BKE_vfont_free(struct VFont *sc); -void BKE_vfont_free_global_ttf(void); struct VFont *BKE_vfont_builtin_get(void); struct VFont *BKE_vfont_load(struct Main *bmain, const char *name); -struct TmpFont *BKE_vfont_tmpfont_find(struct VFont *vfont); -void BKE_vfont_tmpfont_remove(struct VFont *vfont); - struct CharTrans *BKE_vfont_to_curve(struct Main *bmain, struct Scene *scene, struct Object *ob, int mode); int BKE_vfont_select_get(struct Object *ob, int *start, int *end); diff --git a/source/blender/blenkernel/BKE_packedFile.h b/source/blender/blenkernel/BKE_packedFile.h index 1891840f497..ecbd2e7536b 100644 --- a/source/blender/blenkernel/BKE_packedFile.h +++ b/source/blender/blenkernel/BKE_packedFile.h @@ -43,6 +43,7 @@ struct ReportList; struct VFont; /* pack */ +struct PackedFile *dupPackedFileMemory(const struct PackedFile *pf_src); struct PackedFile *newPackedFile(struct ReportList *reports, const char *filename, const char *relabase); struct PackedFile *newPackedFileMemory(void *mem, int memlen); diff --git a/source/blender/blenkernel/intern/font.c b/source/blender/blenkernel/intern/font.c index 49c3d77a527..8689d6648a9 100644 --- a/source/blender/blenkernel/intern/font.c +++ b/source/blender/blenkernel/intern/font.c @@ -60,10 +60,9 @@ #include "BKE_curve.h" #include "BKE_displist.h" -static ListBase ttfdata = {NULL, NULL}; +//static ListBase ttfdata = {NULL, NULL}; /* The vfont code */ - void BKE_vfont_free_data(struct VFont *vfont) { if (vfont->data) { @@ -83,7 +82,10 @@ void BKE_vfont_free_data(struct VFont *vfont) vfont->data = NULL; } - BKE_vfont_tmpfont_remove(vfont); + if (vfont->temp_pf) { + freePackedFile(vfont->temp_pf); /* NULL when the font file can't be found on disk */ + vfont->temp_pf = NULL; + } } void BKE_vfont_free(struct VFont *vf) @@ -91,7 +93,7 @@ void BKE_vfont_free(struct VFont *vf) if (vf == NULL) return; BKE_vfont_free_data(vf); - + if (vf->packedfile) { freePackedFile(vf->packedfile); vf->packedfile = NULL; @@ -128,63 +130,11 @@ static PackedFile *get_builtin_packedfile(void) } } -static void vfont_tmpfont_free(struct TmpFont *tf) -{ - if (tf->pf) { - freePackedFile(tf->pf); /* NULL when the font file can't be found on disk */ - } - MEM_freeN(tf); -} - -void BKE_vfont_free_global_ttf(void) -{ - struct TmpFont *tf, *tf_next; - - for (tf = ttfdata.first; tf; tf = tf_next) { - tf_next = tf->next; - vfont_tmpfont_free(tf); - } - ttfdata.first = ttfdata.last = NULL; -} - -struct TmpFont *BKE_vfont_tmpfont_find(VFont *vfont) -{ - struct TmpFont *tmpfnt = NULL; - - if (vfont == NULL) return NULL; - - /* Try finding the font from font list */ - for (tmpfnt = ttfdata.first; tmpfnt; tmpfnt = tmpfnt->next) { - if (tmpfnt->vfont == vfont) { - break; - } - } - - return tmpfnt; -} - -/* assumes a VFont's tmpfont can't be in the database more then once */ -void BKE_vfont_tmpfont_remove(VFont *vfont) -{ - struct TmpFont *tmpfnt; - - tmpfnt = BKE_vfont_tmpfont_find(vfont); - - if (tmpfnt) { - vfont_tmpfont_free(tmpfnt); - BLI_remlink(&ttfdata, tmpfnt); - } -} - static VFontData *vfont_get_data(Main *bmain, VFont *vfont) { - struct TmpFont *tmpfnt = NULL; - PackedFile *tpf; - - if (vfont == NULL) return NULL; - - /* Try finding the font from font list */ - tmpfnt = BKE_vfont_tmpfont_find(vfont); + if (vfont == NULL) { + return NULL; + } /* And then set the data */ if (!vfont->data) { @@ -198,30 +148,15 @@ static VFontData *vfont_get_data(Main *bmain, VFont *vfont) pf = vfont->packedfile; /* We need to copy a tmp font to memory unless it is already there */ - if (!tmpfnt) { - tpf = MEM_callocN(sizeof(*tpf), "PackedFile"); - tpf->data = MEM_mallocN(pf->size, "packFile"); - tpf->size = pf->size; - memcpy(tpf->data, pf->data, pf->size); - - /* Add temporary packed file to globals */ - tmpfnt = (struct TmpFont *) MEM_callocN(sizeof(struct TmpFont), "temp_font"); - tmpfnt->pf = tpf; - tmpfnt->vfont = vfont; - BLI_addtail(&ttfdata, tmpfnt); + if (vfont->temp_pf == NULL) { + vfont->temp_pf = dupPackedFileMemory(pf); } } else { pf = newPackedFile(NULL, vfont->name, ID_BLEND_PATH(bmain, &vfont->id)); - if (!tmpfnt) { - tpf = newPackedFile(NULL, vfont->name, ID_BLEND_PATH(bmain, &vfont->id)); - - /* Add temporary packed file to globals */ - tmpfnt = (struct TmpFont *) MEM_callocN(sizeof(struct TmpFont), "temp_font"); - tmpfnt->pf = tpf; - tmpfnt->vfont = vfont; - BLI_addtail(&ttfdata, tmpfnt); + if (vfont->temp_pf == NULL) { + vfont->temp_pf = newPackedFile(NULL, vfont->name, ID_BLEND_PATH(bmain, &vfont->id)); } } if (!pf) { @@ -252,9 +187,8 @@ VFont *BKE_vfont_load(Main *bmain, const char *name) char filename[FILE_MAXFILE]; VFont *vfont = NULL; PackedFile *pf; - PackedFile *tpf = NULL; + PackedFile *temp_pf = NULL; int is_builtin; - struct TmpFont *tmpfnt; if (strcmp(name, FO_BUILTIN_NAME) == 0) { BLI_strncpy(filename, name, sizeof(filename)); @@ -269,7 +203,7 @@ VFont *BKE_vfont_load(Main *bmain, const char *name) BLI_splitdirstring(dir, filename); pf = newPackedFile(NULL, name, bmain->name); - tpf = newPackedFile(NULL, name, bmain->name); + temp_pf = newPackedFile(NULL, name, bmain->name); is_builtin = FALSE; } @@ -295,10 +229,7 @@ VFont *BKE_vfont_load(Main *bmain, const char *name) /* Do not add FO_BUILTIN_NAME to temporary listbase */ if (strcmp(filename, FO_BUILTIN_NAME)) { - tmpfnt = (struct TmpFont *) MEM_callocN(sizeof(struct TmpFont), "temp_font"); - tmpfnt->pf = tpf; - tmpfnt->vfont = vfont; - BLI_addtail(&ttfdata, tmpfnt); + vfont->temp_pf = temp_pf; } } @@ -324,7 +255,7 @@ static VFont *which_vfont(Curve *cu, CharInfo *info) if (cu->vfontbi) return(cu->vfontbi); else return(cu->vfont); default: return(cu->vfont); - } + } } VFont *BKE_vfont_builtin_get(void) @@ -344,6 +275,7 @@ static VChar *find_vfont_char(VFontData *vfd, intptr_t character) { VChar *che = NULL; + /* TODO: use ghash */ for (che = vfd->characters.first; che; che = che->next) { if (che->index == character) break; diff --git a/source/blender/blenkernel/intern/packedFile.c b/source/blender/blenkernel/intern/packedFile.c index f115a41d419..ed2f4af0c51 100644 --- a/source/blender/blenkernel/intern/packedFile.c +++ b/source/blender/blenkernel/intern/packedFile.c @@ -158,7 +158,17 @@ void freePackedFile(PackedFile *pf) else printf("freePackedFile: Trying to free a NULL pointer\n"); } - + +PackedFile *dupPackedFileMemory(const PackedFile *pf_src) +{ + PackedFile *pf_dst; + + pf_dst = MEM_dupallocN(pf_src); + pf_dst->data = MEM_dupallocN(pf_src->data); + + return pf_dst; +} + PackedFile *newPackedFileMemory(void *mem, int memlen) { PackedFile *pf = MEM_callocN(sizeof(*pf), "PackedFile"); diff --git a/source/blender/blenlib/BLI_vfontdata.h b/source/blender/blenlib/BLI_vfontdata.h index a63ec8e9f61..ed7d10ab257 100644 --- a/source/blender/blenlib/BLI_vfontdata.h +++ b/source/blender/blenlib/BLI_vfontdata.h @@ -39,14 +39,8 @@ struct PackedFile; struct VFont; -#define MAX_VF_CHARS 256 - typedef struct VFontData { ListBase characters; - // ListBase nurbsbase[MAX_VF_CHARS]; - // float resol[MAX_VF_CHARS]; - // float width[MAX_VF_CHARS]; - // float *points[MAX_VF_CHARS]; char name[128]; } VFontData; @@ -59,12 +53,6 @@ typedef struct VChar { float *points; } VChar; -struct TmpFont { - struct TmpFont *next, *prev; - struct PackedFile *pf; - struct VFont *vfont; -}; - /** * Construct a new VFontData structure from * Freetype font data in a PackedFile. diff --git a/source/blender/blenlib/intern/freetypefont.c b/source/blender/blenlib/intern/freetypefont.c index 60999e76c47..597a645eb9c 100644 --- a/source/blender/blenlib/intern/freetypefont.c +++ b/source/blender/blenlib/intern/freetypefont.c @@ -293,19 +293,12 @@ static int objchr_to_ftvfontdata(VFont *vfont, FT_ULong charcode) { /* Freetype2 */ FT_Face face; - struct TmpFont *tf; - - /* Find the correct FreeType font */ - tf = BKE_vfont_tmpfont_find(vfont); - - /* What, no font found. Something strange here */ - if (!tf) return FALSE; /* Load the font to memory */ - if (tf->pf) { + if (vfont->temp_pf) { err = FT_New_Memory_Face(library, - tf->pf->data, - tf->pf->size, + vfont->temp_pf->data, + vfont->temp_pf->size, 0, &face); if (err) return FALSE; diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index eb22b9a2e2e..719081e378d 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -2913,6 +2913,7 @@ static void lib_link_vfont(FileData *UNUSED(fd), Main *main) static void direct_link_vfont(FileData *fd, VFont *vf) { vf->data = NULL; + vf->temp_pf = NULL; vf->packedfile = direct_link_packedfile(fd, vf->packedfile); } diff --git a/source/blender/makesdna/DNA_vfont_types.h b/source/blender/makesdna/DNA_vfont_types.h index 3cccfe6a19f..7aaeaf23db2 100644 --- a/source/blender/makesdna/DNA_vfont_types.h +++ b/source/blender/makesdna/DNA_vfont_types.h @@ -46,6 +46,10 @@ typedef struct VFont { struct VFontData *data; struct PackedFile *packedfile; + + /* runtime only, holds memory for freetype to read from + * TODO, replace this with blf_font_new() style loading */ + struct PackedFile *temp_pf; } VFont; /* *************** FONT ****************** */ diff --git a/source/blender/windowmanager/intern/wm_files.c b/source/blender/windowmanager/intern/wm_files.c index 660117de9f7..48b552acf26 100644 --- a/source/blender/windowmanager/intern/wm_files.c +++ b/source/blender/windowmanager/intern/wm_files.c @@ -380,8 +380,6 @@ void WM_file_read(bContext *C, const char *filepath, ReportList *reports) /* assume automated tasks with background, don't write recent file list */ const int do_history = (G.background == FALSE) && (CTX_wm_manager(C)->op_undo_depth == 0); - BKE_vfont_free_global_ttf(); - /* put aside screens to match with persistent windows later */ /* also exit screens and editors */ wm_window_match_init(C, &wmbase); @@ -490,9 +488,7 @@ int WM_homefile_read(bContext *C, ReportList *UNUSED(reports), short from_memory ListBase wmbase; char tstr[FILE_MAX]; int success = 0; - - BKE_vfont_free_global_ttf(); - + G.relbase_valid = 0; if (!from_memory) { char *cfgdir = BLI_get_folder(BLENDER_USER_CONFIG, NULL); diff --git a/source/blender/windowmanager/intern/wm_init_exit.c b/source/blender/windowmanager/intern/wm_init_exit.c index af24ea81fe6..8c2272e4707 100644 --- a/source/blender/windowmanager/intern/wm_init_exit.c +++ b/source/blender/windowmanager/intern/wm_init_exit.c @@ -399,8 +399,6 @@ void WM_exit_ext(bContext *C, const short do_python) // BIF_GlobalReebFree(); // BIF_freeRetarget(); BIF_freeTemplates(C); - - BKE_vfont_free_global_ttf(); /* bke_font.h */ free_openrecent(); From 08417318cd37b3f20c67b6062e604735a12b1179 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Tue, 21 Aug 2012 10:42:21 +0000 Subject: [PATCH 045/163] Sequencer: invalidate current frame cache on sequence transform --- source/blender/blenkernel/BKE_sequencer.h | 1 + source/blender/blenkernel/intern/seqcache.c | 9 ++++----- source/blender/editors/transform/transform_generics.c | 11 ++++++++++- 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/source/blender/blenkernel/BKE_sequencer.h b/source/blender/blenkernel/BKE_sequencer.h index 7a5c45e4800..7bd1d178296 100644 --- a/source/blender/blenkernel/BKE_sequencer.h +++ b/source/blender/blenkernel/BKE_sequencer.h @@ -246,6 +246,7 @@ void BKE_sequencer_cache_cleanup_sequence(struct Sequence *seq); struct ImBuf *BKE_sequencer_preprocessed_cache_get(SeqRenderData context, struct Sequence *seq, float cfra, seq_stripelem_ibuf_t type); void BKE_sequencer_preprocessed_cache_put(SeqRenderData context, struct Sequence *seq, float cfra, seq_stripelem_ibuf_t type, struct ImBuf *ibuf); +void BKE_sequencer_preprocessed_cache_cleanup(void); void BKE_sequencer_preprocessed_cache_cleanup_sequence(struct Sequence *seq); /* ********************************************************************** diff --git a/source/blender/blenkernel/intern/seqcache.c b/source/blender/blenkernel/intern/seqcache.c index 57db188472c..e3f0226c863 100644 --- a/source/blender/blenkernel/intern/seqcache.c +++ b/source/blender/blenkernel/intern/seqcache.c @@ -68,7 +68,6 @@ static struct MovieCache *moviecache = NULL; static struct SeqPreprocessCache *preprocess_cache = NULL; static void preprocessed_cache_destruct(void); -static void preprocessed_cache_clean(void); static int seq_cmp_render_data(const SeqRenderData *a, const SeqRenderData *b) { @@ -193,7 +192,7 @@ void BKE_sequencer_cache_cleanup(void) moviecache = IMB_moviecache_create("seqcache", sizeof(SeqCacheKey), seqcache_hashhash, seqcache_hashcmp); } - preprocessed_cache_clean(); + BKE_sequencer_preprocessed_cache_cleanup(); } static int seqcache_key_check_seq(void *userkey, void *userdata) @@ -246,7 +245,7 @@ void BKE_sequencer_cache_put(SeqRenderData context, Sequence *seq, float cfra, s IMB_moviecache_put(moviecache, &key, i); } -static void preprocessed_cache_clean(void) +void BKE_sequencer_preprocessed_cache_cleanup(void) { SeqPreprocessCacheElem *elem; @@ -266,7 +265,7 @@ static void preprocessed_cache_destruct(void) if (!preprocess_cache) return; - preprocessed_cache_clean(); + BKE_sequencer_preprocessed_cache_cleanup(); MEM_freeN(preprocess_cache); preprocess_cache = NULL; @@ -308,7 +307,7 @@ void BKE_sequencer_preprocessed_cache_put(SeqRenderData context, Sequence *seq, } else { if (preprocess_cache->cfra != cfra) - preprocessed_cache_clean(); + BKE_sequencer_preprocessed_cache_cleanup(); } elem = MEM_callocN(sizeof(SeqPreprocessCacheElem), "sequencer preprocessed cache element"); diff --git a/source/blender/editors/transform/transform_generics.c b/source/blender/editors/transform/transform_generics.c index 8e73fb8b8cb..bcebca52ce8 100644 --- a/source/blender/editors/transform/transform_generics.c +++ b/source/blender/editors/transform/transform_generics.c @@ -71,6 +71,7 @@ #include "BKE_mesh.h" #include "BKE_nla.h" #include "BKE_context.h" +#include "BKE_sequencer.h" #include "BKE_tessmesh.h" #include "BKE_tracking.h" #include "BKE_mask.h" @@ -890,6 +891,14 @@ static void recalcData_view3d(TransInfo *t) } } +/* helper for recalcData() - for sequencer transforms */ +static void recalcData_sequencer(TransInfo *t) +{ + BKE_sequencer_preprocessed_cache_cleanup(); + + flushTransSeq(t); +} + /* called for updating while transform acts, once per redraw */ void recalcData(TransInfo *t) { @@ -897,7 +906,7 @@ void recalcData(TransInfo *t) flushTransNodes(t); } else if (t->spacetype == SPACE_SEQ) { - flushTransSeq(t); + recalcData_sequencer(t); } else if (t->spacetype == SPACE_ACTION) { recalcData_actedit(t); From 6a2018fe13ad35537f8758f005b0cb3dc3bb0997 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 21 Aug 2012 10:44:10 +0000 Subject: [PATCH 046/163] code cleanup: minor changes to last commit. --- source/blender/blenkernel/BKE_packedFile.h | 2 +- source/blender/blenkernel/intern/font.c | 13 +++++-------- source/blender/blenkernel/intern/packedFile.c | 2 +- 3 files changed, 7 insertions(+), 10 deletions(-) diff --git a/source/blender/blenkernel/BKE_packedFile.h b/source/blender/blenkernel/BKE_packedFile.h index ecbd2e7536b..603cb1f22a6 100644 --- a/source/blender/blenkernel/BKE_packedFile.h +++ b/source/blender/blenkernel/BKE_packedFile.h @@ -43,7 +43,7 @@ struct ReportList; struct VFont; /* pack */ -struct PackedFile *dupPackedFileMemory(const struct PackedFile *pf_src); +struct PackedFile *dupPackedFile(const struct PackedFile *pf_src); struct PackedFile *newPackedFile(struct ReportList *reports, const char *filename, const char *relabase); struct PackedFile *newPackedFileMemory(void *mem, int memlen); diff --git a/source/blender/blenkernel/intern/font.c b/source/blender/blenkernel/intern/font.c index 8689d6648a9..0ffd68c9079 100644 --- a/source/blender/blenkernel/intern/font.c +++ b/source/blender/blenkernel/intern/font.c @@ -60,7 +60,6 @@ #include "BKE_curve.h" #include "BKE_displist.h" -//static ListBase ttfdata = {NULL, NULL}; /* The vfont code */ void BKE_vfont_free_data(struct VFont *vfont) @@ -149,7 +148,7 @@ static VFontData *vfont_get_data(Main *bmain, VFont *vfont) /* We need to copy a tmp font to memory unless it is already there */ if (vfont->temp_pf == NULL) { - vfont->temp_pf = dupPackedFileMemory(pf); + vfont->temp_pf = dupPackedFile(pf); } } else { @@ -237,8 +236,6 @@ VFont *BKE_vfont_load(Main *bmain, const char *name) if (!vfont || vfont->packedfile != pf) { freePackedFile(pf); } - - //XXX waitcursor(0); } return vfont; @@ -248,13 +245,13 @@ static VFont *which_vfont(Curve *cu, CharInfo *info) { switch (info->flag & (CU_CHINFO_BOLD | CU_CHINFO_ITALIC)) { case CU_CHINFO_BOLD: - if (cu->vfontb) return(cu->vfontb); else return(cu->vfont); + return cu->vfontb ? cu->vfontb : cu->vfont; case CU_CHINFO_ITALIC: - if (cu->vfonti) return(cu->vfonti); else return(cu->vfont); + return cu->vfonti ? cu->vfonti : cu->vfont; case (CU_CHINFO_BOLD | CU_CHINFO_ITALIC): - if (cu->vfontbi) return(cu->vfontbi); else return(cu->vfont); + return cu->vfontbi ? cu->vfontbi : cu->vfont; default: - return(cu->vfont); + return cu->vfont; } } diff --git a/source/blender/blenkernel/intern/packedFile.c b/source/blender/blenkernel/intern/packedFile.c index ed2f4af0c51..9787a5025f7 100644 --- a/source/blender/blenkernel/intern/packedFile.c +++ b/source/blender/blenkernel/intern/packedFile.c @@ -159,7 +159,7 @@ void freePackedFile(PackedFile *pf) printf("freePackedFile: Trying to free a NULL pointer\n"); } -PackedFile *dupPackedFileMemory(const PackedFile *pf_src) +PackedFile *dupPackedFile(const PackedFile *pf_src) { PackedFile *pf_dst; From ae9f5239a6c5dc120d13076bf90053f63b986c8b Mon Sep 17 00:00:00 2001 From: Jeroen Bakker Date: Tue, 21 Aug 2012 10:45:01 +0000 Subject: [PATCH 047/163] Fix for * [#32356] Problem with "Ghost" in the "Glare" Node in Compositor --- .../compositor/operations/COM_GlareGhostOperation.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/source/blender/compositor/operations/COM_GlareGhostOperation.cpp b/source/blender/compositor/operations/COM_GlareGhostOperation.cpp index 39fffd6ac64..ace04237b29 100644 --- a/source/blender/compositor/operations/COM_GlareGhostOperation.cpp +++ b/source/blender/compositor/operations/COM_GlareGhostOperation.cpp @@ -83,11 +83,11 @@ void GlareGhostOperation::generateGlare(float *data, MemoryBuffer *inputTile, No for (x = 0; x < gbuf->getWidth(); x++) { u = (float)(x + 0.5f) / (float)gbuf->getWidth(); s = (u - 0.5f) * sc + 0.5f, t = (v - 0.5f) * sc + 0.5f; - tbuf1->read(c, s * gbuf->getWidth(), t * gbuf->getHeight()); + tbuf1->readCubic(c, s * gbuf->getWidth(), t * gbuf->getHeight()); sm = smoothMask(s, t); mul_v3_fl(c, sm); s = (u - 0.5f) * isc + 0.5f, t = (v - 0.5f) * isc + 0.5f; - tbuf2->read(tc, s * gbuf->getWidth() - 0.5f, t * gbuf->getHeight() - 0.5f); + tbuf2->readCubic(tc, s * gbuf->getWidth() - 0.5f, t * gbuf->getHeight() - 0.5f); sm = smoothMask(s, t); madd_v3_v3fl(c, tc, sm); @@ -108,7 +108,7 @@ void GlareGhostOperation::generateGlare(float *data, MemoryBuffer *inputTile, No np = (n << 2) + p; s = (u - 0.5f) * scalef[np] + 0.5f; t = (v - 0.5f) * scalef[np] + 0.5f; - gbuf->read(c, s * gbuf->getWidth() - 0.5f, t * gbuf->getHeight() - 0.5f); + gbuf->readCubic(c, s * gbuf->getWidth() - 0.5f, t * gbuf->getHeight() - 0.5f); mul_v3_v3(c, cm[np]); sm = smoothMask(s, t) * 0.25f; madd_v3_v3fl(tc, c, sm); From f8db7ccb62cf2dbd26d4b6d9b89d6b3839a2b96a Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 21 Aug 2012 11:10:16 +0000 Subject: [PATCH 048/163] fix for bug with render slots - where the menus wouldnt only show layers from the last render which could be meaningless in different render slots. --- source/blender/blenkernel/intern/image.c | 4 +++- .../editors/space_image/image_buttons.c | 18 ++++++++++-------- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/source/blender/blenkernel/intern/image.c b/source/blender/blenkernel/intern/image.c index d84c20f7a94..2b2128439c7 100644 --- a/source/blender/blenkernel/intern/image.c +++ b/source/blender/blenkernel/intern/image.c @@ -2145,7 +2145,9 @@ RenderResult *BKE_image_acquire_renderresult(Scene *scene, Image *ima) void BKE_image_release_renderresult(Scene *scene, Image *ima) { - if (ima->rr) ; + if (ima->rr) { + /* pass */ + } else if (ima->type == IMA_TYPE_R_RESULT) { if (ima->render_slot == ima->last_render_slot) RE_ReleaseResult(RE_GetRender(scene->id.name)); diff --git a/source/blender/editors/space_image/image_buttons.c b/source/blender/editors/space_image/image_buttons.c index 56b340aac09..d0f4fe92257 100644 --- a/source/blender/editors/space_image/image_buttons.c +++ b/source/blender/editors/space_image/image_buttons.c @@ -681,10 +681,12 @@ void uiTemplateImage(uiLayout *layout, bContext *C, PointerRNA *ptr, const char } else if (ima->type == IMA_TYPE_R_RESULT) { /* browse layer/passes */ - Render *re = RE_GetRender(scene->id.name); - RenderResult *rr = RE_AcquireResultRead(re); + RenderResult *rr; + + /* use BKE_image_acquire_renderresult so we get the correct slot in the menu */ + rr = BKE_image_acquire_renderresult(scene, ima); uiblock_layer_pass_arrow_buttons(layout, rr, iuser, &ima->render_slot); - RE_ReleaseResult(re); + BKE_image_release_renderresult(scene, ima); } } else { @@ -867,16 +869,16 @@ void uiTemplateImageSettings(uiLayout *layout, PointerRNA *imfptr) void uiTemplateImageLayers(uiLayout *layout, bContext *C, Image *ima, ImageUser *iuser) { Scene *scene = CTX_data_scene(C); - Render *re; - RenderResult *rr; /* render layers and passes */ if (ima && iuser) { const float dpi_fac = UI_DPI_FAC; - re = RE_GetRender(scene->id.name); - rr = RE_AcquireResultRead(re); + RenderResult *rr; + + /* use BKE_image_acquire_renderresult so we get the correct slot in the menu */ + rr = BKE_image_acquire_renderresult(scene, ima); uiblock_layer_pass_buttons(layout, rr, iuser, 160 * dpi_fac, (ima->type == IMA_TYPE_R_RESULT) ? &ima->render_slot : NULL); - RE_ReleaseResult(re); + BKE_image_release_renderresult(scene, ima); } } From 4bcae5fb076cad3a9ca312a6ba881b5645be76e7 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 21 Aug 2012 11:53:09 +0000 Subject: [PATCH 049/163] code cleanup: more legacy compo functions ifdef'd --- source/blender/nodes/composite/node_composite_tree.c | 7 ++++++- source/blender/nodes/composite/node_composite_util.c | 4 +++- source/blender/nodes/composite/node_composite_util.h | 7 +++++-- .../blender/nodes/composite/nodes/node_composite_common.c | 6 +++++- 4 files changed, 19 insertions(+), 5 deletions(-) diff --git a/source/blender/nodes/composite/node_composite_tree.c b/source/blender/nodes/composite/node_composite_tree.c index 17808179836..351b9309d7a 100644 --- a/source/blender/nodes/composite/node_composite_tree.c +++ b/source/blender/nodes/composite/node_composite_tree.c @@ -95,7 +95,9 @@ static void free_node_cache(bNodeTree *UNUSED(ntree), bNode *node) for (sock= node->outputs.first; sock; sock= sock->next) { if (sock->cache) { +#ifdef WITH_COMPOSITOR_LEGACY free_compbuf(sock->cache); +#endif sock->cache= NULL; } } @@ -159,8 +161,9 @@ static void localize(bNodeTree *localtree, bNodeTree *ntree) for (sock= node->outputs.first; sock; sock= sock->next) { sock->new_sock->cache= sock->cache; +#ifdef WITH_COMPOSITOR_LEGACY compbuf_set_node(sock->new_sock->cache, node->new_node); - +#endif sock->cache= NULL; sock->new_sock->new_sock= sock; } @@ -236,7 +239,9 @@ static void local_merge(bNodeTree *localtree, bNodeTree *ntree) for (lsock= lnode->outputs.first; lsock; lsock= lsock->next) { if (ntreeOutputExists(lnode->new_node, lsock->new_sock)) { lsock->new_sock->cache= lsock->cache; +#ifdef WITH_COMPOSITOR_LEGACY compbuf_set_node(lsock->new_sock->cache, lnode->new_node); +#endif lsock->cache= NULL; lsock->new_sock= NULL; } diff --git a/source/blender/nodes/composite/node_composite_util.c b/source/blender/nodes/composite/node_composite_util.c index 1b9ff610e4c..b44454f38d9 100644 --- a/source/blender/nodes/composite/node_composite_util.c +++ b/source/blender/nodes/composite/node_composite_util.c @@ -29,9 +29,10 @@ * \ingroup nodes */ - #include "node_composite_util.h" +#ifdef WITH_COMPOSITOR_LEGACY + #include CompBuf *alloc_compbuf(int sizex, int sizey, int type, int alloc) @@ -1405,3 +1406,4 @@ void IIR_gauss(CompBuf* src, float sigma, int chan, int xy) #undef YVV } +#endif /* WITH_COMPOSITOR_LEGACY */ diff --git a/source/blender/nodes/composite/node_composite_util.h b/source/blender/nodes/composite/node_composite_util.h index 8f772b19d5e..f2719ee0779 100644 --- a/source/blender/nodes/composite/node_composite_util.h +++ b/source/blender/nodes/composite/node_composite_util.h @@ -86,6 +86,9 @@ /* only for forward declarations */ #include "NOD_composite.h" +#define CMP_SCALE_MAX 12000 + +#ifdef WITH_COMPOSITOR_LEGACY /* *************************** operations support *************************** */ @@ -198,9 +201,9 @@ void IIR_gauss(CompBuf* src, float sigma, int chan, int xy); /* transformations */ -#define CMP_SCALE_MAX 12000 - CompBuf* node_composit_transform(CompBuf *cbuf, float x, float y, float angle, float scale, int filter_type); float *node_composit_get_float_buffer(RenderData *rd, ImBuf *ibuf, int *alloc); #endif + +#endif /* WITH_COMPOSITOR_LEGACY */ diff --git a/source/blender/nodes/composite/nodes/node_composite_common.c b/source/blender/nodes/composite/nodes/node_composite_common.c index 3a3f94f05cc..90bed8e1e04 100644 --- a/source/blender/nodes/composite/nodes/node_composite_common.c +++ b/source/blender/nodes/composite/nodes/node_composite_common.c @@ -30,7 +30,6 @@ * \ingroup cmpnodes */ - #include "DNA_node_types.h" #include "BKE_node.h" @@ -184,7 +183,9 @@ static void group_free_internal(bNodeTreeExec *gexec) for (i=0, ns=gexec->stack; i < gexec->stacksize; ++i, ++ns) { if (!ns->external && !ns->is_copy) { if (ns->data) { +#ifdef WITH_COMPOSITOR_LEGACY free_compbuf(ns->data); +#endif ns->data = NULL; } } @@ -231,6 +232,7 @@ void register_node_type_cmp_group(bNodeTreeType *ttype) nodeRegisterType(ttype, &ntype); } +#ifdef WITH_COMPOSITOR_LEGACY /**** FOR LOOP ****/ @@ -377,3 +379,5 @@ void register_node_type_cmp_whileloop(bNodeTreeType *ttype) nodeRegisterType(ttype, &ntype); } #endif + +#endif /* WITH_COMPOSITOR_LEGACY */ From be4ac3a860723af7d176aeabb1dba112a1594bd3 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Tue, 21 Aug 2012 13:19:31 +0000 Subject: [PATCH 050/163] Fix #32355: select vertex path not working when vertices are selected with e.g. border select. There was a fix before bmesh where it would require exactly two vertices to be selected, but this was not ported over, and it also wasn't quite correct. This case should also work: click on two vertices, selected the path between them, and then click on a 3rd vertex and select path, to extend the path further from the 2nd to the 3rd vertex. Now both use cases should work. --- source/blender/editors/mesh/editmesh_tools.c | 38 ++++++++++++++++---- 1 file changed, 32 insertions(+), 6 deletions(-) diff --git a/source/blender/editors/mesh/editmesh_tools.c b/source/blender/editors/mesh/editmesh_tools.c index 4b8edb920a1..3de945fb06c 100644 --- a/source/blender/editors/mesh/editmesh_tools.c +++ b/source/blender/editors/mesh/editmesh_tools.c @@ -2122,23 +2122,49 @@ static int edbm_select_vertex_path_exec(bContext *C, wmOperator *op) Object *ob = CTX_data_edit_object(C); BMEditMesh *em = BMEdit_FromObject(ob); BMOperator bmop; + BMIter iter; + BMVert *eve = NULL, *svert = NULL, *evert = NULL; BMEditSelection *sv, *ev; /* get the type from RNA */ int type = RNA_enum_get(op->ptr, "type"); + /* first try to find vertices in edit selection */ sv = em->bm->selected.last; - if (sv != NULL) + if (sv != NULL) { ev = sv->prev; - else return OPERATOR_CANCELLED; - if (ev == NULL) - return OPERATOR_CANCELLED; - if ((sv->htype != BM_VERT) || (ev->htype != BM_VERT)) + if (ev && (sv->htype == BM_VERT) && (ev->htype == BM_VERT)) { + svert = (BMVert *)sv->ele; + evert = (BMVert *)ev->ele; + } + } + + /* if those are not found, because vertices where selected by e.g. + border or circle select, find two selected vertices */ + if (svert == NULL) { + BM_ITER_MESH (eve, &iter, em->bm, BM_VERTS_OF_MESH) { + if (!BM_elem_flag_test(eve, BM_ELEM_SELECT) || BM_elem_flag_test(eve, BM_ELEM_HIDDEN)) + continue; + + if (svert == NULL) svert = eve; + else if (evert == NULL) evert = eve; + else { + /* more than two vertices are selected, + show warning message and cancel operator */ + svert = evert = NULL; + break; + } + } + } + + if (svert == NULL || evert == NULL) { + BKE_report(op->reports, RPT_WARNING, "Path Selection requires that two vertices be selected"); return OPERATOR_CANCELLED; + } /* initialize the bmop using EDBM api, which does various ui error reporting and other stuff */ - EDBM_op_init(em, &bmop, op, "shortest_path startv=%e endv=%e type=%i", sv->ele, ev->ele, type); + EDBM_op_init(em, &bmop, op, "shortest_path startv=%e endv=%e type=%i", svert, evert, type); /* execute the operator */ BMO_op_exec(em->bm, &bmop); From 63e6fbfbd4b598f79522b98b11ee33dbfd8d041d Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Tue, 21 Aug 2012 13:19:34 +0000 Subject: [PATCH 051/163] Fix #32369: pixel glitch with compositor curves node, and some pixels having black point = white point. That's a degenerate case, clamped it now to 1e5, which is a bit arbitrary, but infinity would give NaN issues. --- source/blender/blenkernel/intern/colortools.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/source/blender/blenkernel/intern/colortools.c b/source/blender/blenkernel/intern/colortools.c index 4bc22d77ec9..24a84d79935 100644 --- a/source/blender/blenkernel/intern/colortools.c +++ b/source/blender/blenkernel/intern/colortools.c @@ -150,13 +150,8 @@ void curvemapping_set_black_white_ex(const float black[3], const float white[3], int a; for (a = 0; a < 3; a++) { - const float delta = white[a] - black[a]; - if (delta != 0.0f) { - r_bwmul[a] = 1.0f / delta; - } - else { - r_bwmul[a] = 0.0f; - } + const float delta = MAX2(white[a] - black[a], 1e-5f); + r_bwmul[a] = 1.0f / delta; } } From 809fce9d00ecf8eea2c3d2ea52c3de2ec2ede1ee Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Tue, 21 Aug 2012 14:38:03 +0000 Subject: [PATCH 052/163] Fix #32341: extrude with a mirror modifier could lead to orphan vertices, it was already removing unnecessary edges, just not vertices of those edges. --- source/blender/bmesh/operators/bmo_extrude.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/source/blender/bmesh/operators/bmo_extrude.c b/source/blender/bmesh/operators/bmo_extrude.c index 7b59a4a9101..9ea8e631435 100644 --- a/source/blender/bmesh/operators/bmo_extrude.c +++ b/source/blender/bmesh/operators/bmo_extrude.c @@ -380,10 +380,18 @@ void bmo_extrude_face_region_exec(BMesh *bm, BMOperator *op) /* this should always be wire, so this is mainly a speedup to avoid map lookup */ if (BM_edge_is_wire(e) && BMO_slot_map_contains(bm, op, "exclude", e)) { + BMVert *v1 = e->v1, *v2 = e->v2; + /* The original edge was excluded, * this would result in a standalone wire edge - see [#30399] */ BM_edge_kill(bm, e); + /* kill standalone vertices from this edge - see [#32341] */ + if (!v1->e) + BM_vert_kill(bm, v1); + if (!v2->e) + BM_vert_kill(bm, v1); + continue; } From 8bd7c3fba2749fdf2b16c4f32abf1a35692bc5bb Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 21 Aug 2012 14:43:51 +0000 Subject: [PATCH 053/163] change curve evaluation functions never to modify curve data (ensures thread safety), now initializations has to be done outside evaluation. --- source/blender/blenkernel/BKE_colortools.h | 28 ++++++++----- source/blender/blenkernel/intern/brush.c | 3 ++ source/blender/blenkernel/intern/colortools.c | 42 ++++++++----------- source/blender/blenkernel/intern/world.c | 3 +- .../blender/compositor/nodes/COM_TimeNode.cpp | 3 ++ source/blender/gpu/intern/gpu_material.c | 1 + source/blender/makesrna/intern/rna_color.c | 8 +++- source/blender/modifiers/intern/MOD_warp.c | 4 ++ .../modifiers/intern/MOD_weightvg_util.c | 4 ++ .../composite/nodes/node_composite_curves.c | 13 ++++-- .../nodes/node_composite_huecorrect.c | 6 ++- .../nodes/shader/nodes/node_shader_curves.c | 3 ++ .../nodes/texture/nodes/node_texture_curves.c | 1 + .../render/intern/source/convertblender.c | 5 +++ .../render/intern/source/pointdensity.c | 1 + .../render/intern/source/shadeoutput.c | 1 + 16 files changed, 84 insertions(+), 42 deletions(-) diff --git a/source/blender/blenkernel/BKE_colortools.h b/source/blender/blenkernel/BKE_colortools.h index 249cb32a082..9ce2de79dbf 100644 --- a/source/blender/blenkernel/BKE_colortools.h +++ b/source/blender/blenkernel/BKE_colortools.h @@ -67,25 +67,31 @@ void curvemap_sethandle(struct CurveMap *cuma, int type); void curvemapping_changed(struct CurveMapping *cumap, int rem_doubles); void curvemapping_changed_all(struct CurveMapping *cumap); +/* call before _all_ evaluation functions */ +void curvemapping_initialize(struct CurveMapping *cumap); + +/* keep these (const CurveMap) - to help with thread safety */ /* single curve, no table check */ -float curvemap_evaluateF(struct CurveMap *cuma, float value); +float curvemap_evaluateF(const struct CurveMap *cuma, float value); /* single curve, with table check */ -float curvemapping_evaluateF(struct CurveMapping *cumap, int cur, float value); -void curvemapping_evaluate3F(struct CurveMapping *cumap, float vecout[3], const float vecin[3]); -void curvemapping_evaluateRGBF(struct CurveMapping *cumap, float vecout[3], const float vecin[3]); -void curvemapping_evaluate_premulRGB(struct CurveMapping *cumap, unsigned char vecout_byte[3], const unsigned char vecin_byte[3]); -void curvemapping_evaluate_premulRGBF_ex(struct CurveMapping *cumap, float vecout[3], const float vecin[3], +float curvemapping_evaluateF(const struct CurveMapping *cumap, int cur, float value); +void curvemapping_evaluate3F(const struct CurveMapping *cumap, float vecout[3], const float vecin[3]); +void curvemapping_evaluateRGBF(const struct CurveMapping *cumap, float vecout[3], const float vecin[3]); +void curvemapping_evaluate_premulRGB(const struct CurveMapping *cumap, unsigned char vecout_byte[3], const unsigned char vecin_byte[3]); +void curvemapping_evaluate_premulRGBF_ex(const struct CurveMapping *cumap, float vecout[3], const float vecin[3], const float black[3], const float bwmul[3]); -void curvemapping_evaluate_premulRGBF(struct CurveMapping *cumap, float vecout[3], const float vecin[3]); +void curvemapping_evaluate_premulRGBF(const struct CurveMapping *cumap, float vecout[3], const float vecin[3]); +int curvemapping_RGBA_does_something(const struct CurveMapping *cumap); +void curvemapping_table_RGBA(const struct CurveMapping *cumap, float **array, int *size); + +/* non-const, these modify the curve */ void curvemapping_do_ibuf(struct CurveMapping *cumap, struct ImBuf *ibuf); void curvemapping_premultiply(struct CurveMapping *cumap, int restore); -int curvemapping_RGBA_does_something(struct CurveMapping *cumap); -void curvemapping_initialize(struct CurveMapping *cumap); -void curvemapping_table_RGBA(struct CurveMapping *cumap, float **array, int *size); + + void BKE_histogram_update_sample_line(struct Histogram *hist, struct ImBuf *ibuf, const short use_color_management); void scopes_update(struct Scopes *scopes, struct ImBuf *ibuf, int use_color_management); void scopes_free(struct Scopes *scopes); void scopes_new(struct Scopes *scopes); #endif - diff --git a/source/blender/blenkernel/intern/brush.c b/source/blender/blenkernel/intern/brush.c index fc4df9594f3..fde95e0767e 100644 --- a/source/blender/blenkernel/intern/brush.c +++ b/source/blender/blenkernel/intern/brush.c @@ -1253,7 +1253,9 @@ float BKE_brush_curve_strength_clamp(Brush *br, float p, const float len) if (p >= len) return 0; else p = p / len; + curvemapping_initialize(br->curve); p = curvemapping_evaluateF(br->curve, 0, p); + if (p < 0.0f) p = 0.0f; else if (p > 1.0f) p = 1.0f; return p; @@ -1267,6 +1269,7 @@ float BKE_brush_curve_strength(Brush *br, float p, const float len) else p = p / len; + curvemapping_initialize(br->curve); return curvemapping_evaluateF(br->curve, 0, p); } diff --git a/source/blender/blenkernel/intern/colortools.c b/source/blender/blenkernel/intern/colortools.c index 24a84d79935..79cd97ed25c 100644 --- a/source/blender/blenkernel/intern/colortools.c +++ b/source/blender/blenkernel/intern/colortools.c @@ -440,7 +440,7 @@ static void calchandle_curvemap(BezTriple *bezt, BezTriple *prev, BezTriple *nex /* in X, out Y. * X is presumed to be outside first or last */ -static float curvemap_calc_extend(CurveMap *cuma, float x, const float first[2], const float last[2]) +static float curvemap_calc_extend(const CurveMap *cuma, float x, const float first[2], const float last[2]) { if (x <= first[0]) { if ((cuma->flag & CUMA_EXTEND_EXTRAPOLATE) == 0) { @@ -739,7 +739,7 @@ void curvemapping_changed_all(CurveMapping *cumap) } /* table should be verified */ -float curvemap_evaluateF(CurveMap *cuma, float value) +float curvemap_evaluateF(const CurveMap *cuma, float value) { float fi; int i; @@ -761,33 +761,26 @@ float curvemap_evaluateF(CurveMap *cuma, float value) } /* works with curve 'cur' */ -float curvemapping_evaluateF(CurveMapping *cumap, int cur, float value) +float curvemapping_evaluateF(const CurveMapping *cumap, int cur, float value) { - CurveMap *cuma = cumap->cm + cur; - - /* allocate or bail out */ - if (cuma->table == NULL) { - curvemap_make_table(cuma, &cumap->clipr); - if (cuma->table == NULL) - return 1.0f - value; - } + const CurveMap *cuma = cumap->cm + cur; return curvemap_evaluateF(cuma, value); } /* vector case */ -void curvemapping_evaluate3F(CurveMapping *cumap, float vecout[3], const float vecin[3]) +void curvemapping_evaluate3F(const CurveMapping *cumap, float vecout[3], const float vecin[3]) { - vecout[0] = curvemapping_evaluateF(cumap, 0, vecin[0]); - vecout[1] = curvemapping_evaluateF(cumap, 1, vecin[1]); - vecout[2] = curvemapping_evaluateF(cumap, 2, vecin[2]); + vecout[0] = curvemap_evaluateF(&cumap->cm[0], vecin[0]); + vecout[1] = curvemap_evaluateF(&cumap->cm[1], vecin[1]); + vecout[2] = curvemap_evaluateF(&cumap->cm[2], vecin[2]); } /* RGB case, no black/white points, no premult */ -void curvemapping_evaluateRGBF(CurveMapping *cumap, float vecout[3], const float vecin[3]) +void curvemapping_evaluateRGBF(const CurveMapping *cumap, float vecout[3], const float vecin[3]) { - vecout[0] = curvemapping_evaluateF(cumap, 0, curvemapping_evaluateF(cumap, 3, vecin[0])); - vecout[1] = curvemapping_evaluateF(cumap, 1, curvemapping_evaluateF(cumap, 3, vecin[1])); - vecout[2] = curvemapping_evaluateF(cumap, 2, curvemapping_evaluateF(cumap, 3, vecin[2])); + vecout[0] = curvemap_evaluateF(&cumap->cm[0], curvemap_evaluateF(&cumap->cm[3], vecin[0])); + vecout[1] = curvemap_evaluateF(&cumap->cm[1], curvemap_evaluateF(&cumap->cm[3], vecin[1])); + vecout[2] = curvemap_evaluateF(&cumap->cm[2], curvemap_evaluateF(&cumap->cm[3], vecin[2])); } /** same as #curvemapping_evaluate_premulRGBF @@ -799,7 +792,7 @@ void curvemapping_evaluateRGBF(CurveMapping *cumap, float vecout[3], const float * \param black Use instead of cumap->black * \param bwmul Use instead of cumap->bwmul */ -void curvemapping_evaluate_premulRGBF_ex(CurveMapping *cumap, float vecout[3], const float vecin[3], +void curvemapping_evaluate_premulRGBF_ex(const CurveMapping *cumap, float vecout[3], const float vecin[3], const float black[3], const float bwmul[3]) { vecout[0] = curvemap_evaluateF(&cumap->cm[0], (vecin[0] - black[0]) * bwmul[0]); @@ -808,7 +801,7 @@ void curvemapping_evaluate_premulRGBF_ex(CurveMapping *cumap, float vecout[3], c } /* RGB with black/white points and premult. tables are checked */ -void curvemapping_evaluate_premulRGBF(CurveMapping *cumap, float vecout[3], const float vecin[3]) +void curvemapping_evaluate_premulRGBF(const CurveMapping *cumap, float vecout[3], const float vecin[3]) { vecout[0] = curvemap_evaluateF(&cumap->cm[0], (vecin[0] - cumap->black[0]) * cumap->bwmul[0]); vecout[1] = curvemap_evaluateF(&cumap->cm[1], (vecin[1] - cumap->black[1]) * cumap->bwmul[1]); @@ -816,7 +809,7 @@ void curvemapping_evaluate_premulRGBF(CurveMapping *cumap, float vecout[3], cons } /* same as above, byte version */ -void curvemapping_evaluate_premulRGB(CurveMapping *cumap, unsigned char vecout_byte[3], const unsigned char vecin_byte[3]) +void curvemapping_evaluate_premulRGB(const CurveMapping *cumap, unsigned char vecout_byte[3], const unsigned char vecin_byte[3]) { float vecin[3], vecout[3]; @@ -889,7 +882,7 @@ void curvemapping_do_ibuf(CurveMapping *cumap, ImBuf *ibuf) curvemapping_premultiply(cumap, 1); } -int curvemapping_RGBA_does_something(CurveMapping *cumap) +int curvemapping_RGBA_does_something(const CurveMapping *cumap) { int a; @@ -925,13 +918,12 @@ void curvemapping_initialize(CurveMapping *cumap) } } -void curvemapping_table_RGBA(CurveMapping *cumap, float **array, int *size) +void curvemapping_table_RGBA(const CurveMapping *cumap, float **array, int *size) { int a; *size = CM_TABLE + 1; *array = MEM_callocN(sizeof(float) * (*size) * 4, "CurveMapping"); - curvemapping_initialize(cumap); for (a = 0; a < *size; a++) { if (cumap->cm[0].table) diff --git a/source/blender/blenkernel/intern/world.c b/source/blender/blenkernel/intern/world.c index 303098ea0bd..dd71e43182e 100644 --- a/source/blender/blenkernel/intern/world.c +++ b/source/blender/blenkernel/intern/world.c @@ -128,8 +128,9 @@ World *BKE_world_copy(World *wrld) } } - if (wrld->nodetree) + if (wrld->nodetree) { wrldn->nodetree = ntreeCopyTree(wrld->nodetree); + } if (wrld->preview) wrldn->preview = BKE_previewimg_copy(wrld->preview); diff --git a/source/blender/compositor/nodes/COM_TimeNode.cpp b/source/blender/compositor/nodes/COM_TimeNode.cpp index 84ee4e77b06..82c8deafd9d 100644 --- a/source/blender/compositor/nodes/COM_TimeNode.cpp +++ b/source/blender/compositor/nodes/COM_TimeNode.cpp @@ -33,6 +33,8 @@ TimeNode::TimeNode(bNode *editorNode) : Node(editorNode) /* pass */ } +////curvemapping_initialize(&hcmd->curve_mapping); + void TimeNode::convertToOperations(ExecutionSystem *graph, CompositorContext *context) { SetValueOperation *operation = new SetValueOperation(); @@ -53,6 +55,7 @@ void TimeNode::convertToOperations(ExecutionSystem *graph, CompositorContext *co fac = (context->getFramenumber() - node->custom1) / (float)(node->custom2 - node->custom1); } + curvemapping_initialize((CurveMapping *)node->storage); fac = curvemapping_evaluateF((CurveMapping *)node->storage, 0, fac); operation->setValue(CLAMPIS(fac, 0.0f, 1.0f)); graph->addOperation(operation); diff --git a/source/blender/gpu/intern/gpu_material.c b/source/blender/gpu/intern/gpu_material.c index bd25a042ee4..efb24375729 100644 --- a/source/blender/gpu/intern/gpu_material.c +++ b/source/blender/gpu/intern/gpu_material.c @@ -427,6 +427,7 @@ static GPUNodeLink *lamp_get_visibility(GPUMaterial *mat, GPULamp *lamp, GPUNode float *array; int size; + curvemapping_initialize(lamp->curfalloff); curvemapping_table_RGBA(lamp->curfalloff, &array, &size); GPU_link(mat, "lamp_falloff_curve", GPU_dynamic_uniform(&lamp->dist, GPU_DYNAMIC_LAMP_DISTANCE, lamp->ob), GPU_texture(size, array), *dist, &visifac); } diff --git a/source/blender/makesrna/intern/rna_color.c b/source/blender/makesrna/intern/rna_color.c index 5dafe77f9c1..0bd42c2f5a0 100644 --- a/source/blender/makesrna/intern/rna_color.c +++ b/source/blender/makesrna/intern/rna_color.c @@ -337,6 +337,12 @@ static void rna_Scopes_update(Main *UNUSED(bmain), Scene *UNUSED(scene), Pointer s->ok = 0; } +/* this function only exists because #curvemap_evaluateF uses a 'const' qualifier */ +float rna_CurveMap_evaluateF(struct CurveMap *cuma, float value) +{ + return curvemap_evaluateF(cuma, value); +} + #else static void rna_def_curvemappoint(BlenderRNA *brna) @@ -419,7 +425,7 @@ static void rna_def_curvemap(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Points", ""); rna_def_curvemap_points_api(brna, prop); - func = RNA_def_function(srna, "evaluate", "curvemap_evaluateF"); + func = RNA_def_function(srna, "evaluate", "rna_CurveMap_evaluateF"); RNA_def_function_ui_description(func, "Evaluate curve at given location"); parm = RNA_def_float(func, "position", 0.0f, -FLT_MAX, FLT_MAX, "Position", "Position to evaluate curve at", -FLT_MAX, FLT_MAX); RNA_def_property_flag(parm, PROP_REQUIRED); diff --git a/source/blender/modifiers/intern/MOD_warp.c b/source/blender/modifiers/intern/MOD_warp.c index 9eb360f6819..95f6ef60665 100644 --- a/source/blender/modifiers/intern/MOD_warp.c +++ b/source/blender/modifiers/intern/MOD_warp.c @@ -195,6 +195,10 @@ static void warpModifier_do(WarpModifierData *wmd, Object *ob, if (wmd->curfalloff == NULL) /* should never happen, but bad lib linking could cause it */ wmd->curfalloff = curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f); + if (wmd->curfalloff) { + curvemapping_initialize(wmd->curfalloff); + } + invert_m4_m4(obinv, ob->obmat); mult_m4_m4m4(mat_from, obinv, wmd->object_from->obmat); diff --git a/source/blender/modifiers/intern/MOD_weightvg_util.c b/source/blender/modifiers/intern/MOD_weightvg_util.c index 81cdad0d5e5..7181b5bbb44 100644 --- a/source/blender/modifiers/intern/MOD_weightvg_util.c +++ b/source/blender/modifiers/intern/MOD_weightvg_util.c @@ -73,6 +73,10 @@ void weightvg_do_map(int num, float *new_w, short falloff_type, CurveMapping *cm return; } + if (cmap && falloff_type == MOD_WVG_MAPPING_CURVE) { + curvemapping_initialize(cmap); + } + /* Map each weight (vertex) to its new value, accordingly to the chosen mode. */ for (i = 0; i < num; ++i) { float fac = new_w[i]; diff --git a/source/blender/nodes/composite/nodes/node_composite_curves.c b/source/blender/nodes/composite/nodes/node_composite_curves.c index 85830e8ca14..ddc93e94061 100644 --- a/source/blender/nodes/composite/nodes/node_composite_curves.c +++ b/source/blender/nodes/composite/nodes/node_composite_curves.c @@ -52,7 +52,9 @@ static void node_composit_exec_curves_time(void *data, bNode *node, bNodeStack * if (node->custom1 < node->custom2) fac= (rd->cfra - node->custom1)/(float)(node->custom2-node->custom1); - fac= curvemapping_evaluateF(node->storage, 0, fac); + curvemapping_initialize(node->storage); + fac = curvemapping_evaluateF(node->storage, 0, fac); + out[0]->vec[0]= CLAMPIS(fac, 0.0f, 1.0f); } @@ -100,7 +102,8 @@ static void node_composit_exec_curve_vec(void *UNUSED(data), bNode *node, bNodeS { /* stack order input: vec */ /* stack order output: vec */ - + + curvemapping_initialize(node->storage); curvemapping_evaluate_premulRGBF(node->storage, out[0]->vec, in[0]->vec); } @@ -146,13 +149,15 @@ static bNodeSocketTemplate cmp_node_curve_rgb_out[]= { static void do_curves(bNode *node, float *out, float *in) { + curvemapping_initialize(node->storage); curvemapping_evaluate_premulRGBF(node->storage, out, in); out[3]= in[3]; } static void do_curves_fac(bNode *node, float *out, float *in, float *fac) { - + curvemapping_initialize(node->storage); + if (*fac >= 1.0f) curvemapping_evaluate_premulRGBF(node->storage, out, in); else if (*fac <= 0.0f) { @@ -176,6 +181,8 @@ static void node_composit_exec_curve_rgb(void *UNUSED(data), bNode *node, bNodeS if (out[0]->hasoutput==0) return; + curvemapping_initialize(node->storage); + /* input no image? then only color operation */ if (in[1]->data==NULL) { curvemapping_evaluateRGBF(node->storage, out[0]->vec, in[1]->vec); diff --git a/source/blender/nodes/composite/nodes/node_composite_huecorrect.c b/source/blender/nodes/composite/nodes/node_composite_huecorrect.c index 1f343c648c3..7e3f6a5fb3a 100644 --- a/source/blender/nodes/composite/nodes/node_composite_huecorrect.c +++ b/source/blender/nodes/composite/nodes/node_composite_huecorrect.c @@ -51,6 +51,8 @@ static void do_huecorrect(bNode *node, float *out, float *in) rgb_to_hsv(in[0], in[1], in[2], hsv, hsv+1, hsv+2); + curvemapping_initialize(node->storage); + /* adjust hue, scaling returned default 0.5 up to 1 */ f = curvemapping_evaluateF(node->storage, 0, hsv[0]); hsv[0] += f-0.5f; @@ -79,6 +81,8 @@ static void do_huecorrect_fac(bNode *node, float *out, float *in, float *fac) rgb_to_hsv(in[0], in[1], in[2], hsv, hsv+1, hsv+2); + curvemapping_initialize(node->storage); + /* adjust hue, scaling returned default 0.5 up to 1 */ f = curvemapping_evaluateF(node->storage, 0, hsv[0]); hsv[0] += f-0.5f; @@ -118,7 +122,7 @@ static void node_composit_exec_huecorrect(void *UNUSED(data), bNode *node, bNode out[0]->data = pass_on_compbuf(cbuf); return; } - + /* input no image? then only color operation */ if (in[1]->data==NULL) { do_huecorrect_fac(node, out[0]->vec, in[1]->vec, in[0]->vec); diff --git a/source/blender/nodes/shader/nodes/node_shader_curves.c b/source/blender/nodes/shader/nodes/node_shader_curves.c index be7f3c1c614..512182ebe12 100644 --- a/source/blender/nodes/shader/nodes/node_shader_curves.c +++ b/source/blender/nodes/shader/nodes/node_shader_curves.c @@ -65,6 +65,7 @@ static int gpu_shader_curve_vec(GPUMaterial *mat, bNode *node, GPUNodeStack *in, float *array; int size; + curvemapping_initialize(node->storage); curvemapping_table_RGBA(node->storage, &array, &size); return GPU_stack_link(mat, "curves_vec", in, out, GPU_texture(size, array)); } @@ -120,6 +121,8 @@ static int gpu_shader_curve_rgb(GPUMaterial *mat, bNode *node, GPUNodeStack *in, { float *array; int size; + + curvemapping_initialize(node->storage); curvemapping_table_RGBA(node->storage, &array, &size); return GPU_stack_link(mat, "curves_rgb", in, out, GPU_texture(size, array)); } diff --git a/source/blender/nodes/texture/nodes/node_texture_curves.c b/source/blender/nodes/texture/nodes/node_texture_curves.c index a56d69a6657..35e14c592a7 100644 --- a/source/blender/nodes/texture/nodes/node_texture_curves.c +++ b/source/blender/nodes/texture/nodes/node_texture_curves.c @@ -49,6 +49,7 @@ static void time_colorfn(float *out, TexParams *p, bNode *node, bNodeStack **UNU if (node->custom1 < node->custom2) fac = (p->cfra - node->custom1)/(float)(node->custom2-node->custom1); + curvemapping_initialize(node->storage); fac = curvemapping_evaluateF(node->storage, 0, fac); out[0] = CLAMPIS(fac, 0.0f, 1.0f); } diff --git a/source/blender/render/intern/source/convertblender.c b/source/blender/render/intern/source/convertblender.c index f34bd352e62..6bd95e824eb 100644 --- a/source/blender/render/intern/source/convertblender.c +++ b/source/blender/render/intern/source/convertblender.c @@ -3824,6 +3824,11 @@ static GroupObject *add_render_lamp(Render *re, Object *ob) lar->ld2= la->att2; lar->curfalloff = curvemapping_copy(la->curfalloff); + if (lar->curfalloff) { + /* so threads don't conflict on init */ + curvemapping_initialize(lar->curfalloff); + } + if (lar->type==LA_SPOT) { normalize_v3(lar->imat[0]); diff --git a/source/blender/render/intern/source/pointdensity.c b/source/blender/render/intern/source/pointdensity.c index 3c1a18316ca..49c2bf1d053 100644 --- a/source/blender/render/intern/source/pointdensity.c +++ b/source/blender/render/intern/source/pointdensity.c @@ -379,6 +379,7 @@ static void accum_density(void *userdata, int index, float squared_dist) } if (pdr->density_curve && dist != 0.0f) { + curvemapping_initialize(pdr->density_curve); density = curvemapping_evaluateF(pdr->density_curve, 0, density/dist)*dist; } diff --git a/source/blender/render/intern/source/shadeoutput.c b/source/blender/render/intern/source/shadeoutput.c index e209baa49a8..6883710d1be 100644 --- a/source/blender/render/intern/source/shadeoutput.c +++ b/source/blender/render/intern/source/shadeoutput.c @@ -1192,6 +1192,7 @@ float lamp_get_visibility(LampRen *lar, const float co[3], float lv[3], float *d visifac*= lar->distkw/(lar->distkw+lar->ld2*dist[0]*dist[0]); break; case LA_FALLOFF_CURVE: + /* curvemapping_initialize is called from #add_render_lamp */ visifac = curvemapping_evaluateF(lar->curfalloff, 0, dist[0]/lar->dist); break; } From 857a3cd1120c402e22928e7d43612a9fee72a80d Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Tue, 21 Aug 2012 14:49:07 +0000 Subject: [PATCH 054/163] Fix #32334: mesh separate by material with > 2 materials could include some incorrect extra edges. --- source/blender/editors/mesh/editmesh_tools.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source/blender/editors/mesh/editmesh_tools.c b/source/blender/editors/mesh/editmesh_tools.c index 3de945fb06c..3945c1bb57a 100644 --- a/source/blender/editors/mesh/editmesh_tools.c +++ b/source/blender/editors/mesh/editmesh_tools.c @@ -2958,12 +2958,12 @@ static int mesh_separate_material(Main *bmain, Scene *scene, Base *base_old, BMe BMIter iter; int result = FALSE; - BM_mesh_elem_hflag_disable_all(bm_old, BM_VERT | BM_EDGE | BM_FACE, BM_ELEM_TAG, FALSE); - while ((f_cmp = BM_iter_at_index(bm_old, BM_FACES_OF_MESH, NULL, 0))) { const short mat_nr = f_cmp->mat_nr; int tot = 0; + BM_mesh_elem_hflag_disable_all(bm_old, BM_VERT | BM_EDGE | BM_FACE, BM_ELEM_TAG, FALSE); + BM_ITER_MESH (f, &iter, bm_old, BM_FACES_OF_MESH) { if (f->mat_nr == mat_nr) { BMLoop *l_iter; From 3090ae35afe478435a77be6a9c1be913fe406242 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 21 Aug 2012 15:14:29 +0000 Subject: [PATCH 055/163] fix [#32374] Curve compositor UI drawing glitch copy the curve for the compositor. --- source/blender/blenkernel/intern/colortools.c | 2 +- source/blender/compositor/nodes/COM_TimeNode.cpp | 2 -- .../operations/COM_ColorCurveOperation.cpp | 4 ++-- .../operations/COM_CurveBaseOperation.cpp | 14 ++++++++++++++ .../operations/COM_CurveBaseOperation.h | 3 ++- .../COM_HueSaturationValueCorrectOperation.cpp | 1 + .../operations/COM_VectorCurveOperation.cpp | 1 + .../blender/editors/interface/interface_draw.c | 16 ++++++++++++---- 8 files changed, 33 insertions(+), 10 deletions(-) diff --git a/source/blender/blenkernel/intern/colortools.c b/source/blender/blenkernel/intern/colortools.c index 79cd97ed25c..85d28f68034 100644 --- a/source/blender/blenkernel/intern/colortools.c +++ b/source/blender/blenkernel/intern/colortools.c @@ -150,7 +150,7 @@ void curvemapping_set_black_white_ex(const float black[3], const float white[3], int a; for (a = 0; a < 3; a++) { - const float delta = MAX2(white[a] - black[a], 1e-5f); + const float delta = maxf(white[a] - black[a], 1e-5f); r_bwmul[a] = 1.0f / delta; } } diff --git a/source/blender/compositor/nodes/COM_TimeNode.cpp b/source/blender/compositor/nodes/COM_TimeNode.cpp index 82c8deafd9d..00ca797bd9b 100644 --- a/source/blender/compositor/nodes/COM_TimeNode.cpp +++ b/source/blender/compositor/nodes/COM_TimeNode.cpp @@ -33,8 +33,6 @@ TimeNode::TimeNode(bNode *editorNode) : Node(editorNode) /* pass */ } -////curvemapping_initialize(&hcmd->curve_mapping); - void TimeNode::convertToOperations(ExecutionSystem *graph, CompositorContext *context) { SetValueOperation *operation = new SetValueOperation(); diff --git a/source/blender/compositor/operations/COM_ColorCurveOperation.cpp b/source/blender/compositor/operations/COM_ColorCurveOperation.cpp index 81205514040..2f13a90c072 100644 --- a/source/blender/compositor/operations/COM_ColorCurveOperation.cpp +++ b/source/blender/compositor/operations/COM_ColorCurveOperation.cpp @@ -98,11 +98,11 @@ void ColorCurveOperation::executePixel(float output[4], float x, float y, PixelS void ColorCurveOperation::deinitExecution() { + CurveBaseOperation::deinitExecution(); this->m_inputFacProgram = NULL; this->m_inputImageProgram = NULL; this->m_inputBlackProgram = NULL; this->m_inputWhiteProgram = NULL; - curvemapping_premultiply(this->m_curveMapping, 1); } @@ -154,7 +154,7 @@ void ConstantLevelColorCurveOperation::executePixel(float output[4], float x, fl void ConstantLevelColorCurveOperation::deinitExecution() { + CurveBaseOperation::deinitExecution(); this->m_inputFacProgram = NULL; this->m_inputImageProgram = NULL; - curvemapping_premultiply(this->m_curveMapping, 1); } diff --git a/source/blender/compositor/operations/COM_CurveBaseOperation.cpp b/source/blender/compositor/operations/COM_CurveBaseOperation.cpp index 48d2bcd0ef9..36c49859880 100644 --- a/source/blender/compositor/operations/COM_CurveBaseOperation.cpp +++ b/source/blender/compositor/operations/COM_CurveBaseOperation.cpp @@ -38,3 +38,17 @@ void CurveBaseOperation::initExecution() { curvemapping_initialize(this->m_curveMapping); } +void CurveBaseOperation::deinitExecution() +{ + curvemapping_free(this->m_curveMapping); + this->m_curveMapping = NULL; +} + +void CurveBaseOperation::setCurveMapping(CurveMapping *mapping) +{ + /* duplicate the curve to avoid glitches while drawing, see bug [#32374] */ + if (this->m_curveMapping) { + curvemapping_free(this->m_curveMapping); + } + this->m_curveMapping = curvemapping_copy(mapping); +} diff --git a/source/blender/compositor/operations/COM_CurveBaseOperation.h b/source/blender/compositor/operations/COM_CurveBaseOperation.h index 1636c13a571..6bfce26f532 100644 --- a/source/blender/compositor/operations/COM_CurveBaseOperation.h +++ b/source/blender/compositor/operations/COM_CurveBaseOperation.h @@ -38,7 +38,8 @@ public: * Initialize the execution */ void initExecution(); + void deinitExecution(); - void setCurveMapping(CurveMapping *mapping) { this->m_curveMapping = mapping; } + void setCurveMapping(CurveMapping *mapping); }; #endif diff --git a/source/blender/compositor/operations/COM_HueSaturationValueCorrectOperation.cpp b/source/blender/compositor/operations/COM_HueSaturationValueCorrectOperation.cpp index 57d43f67c9b..8f58942fbe2 100644 --- a/source/blender/compositor/operations/COM_HueSaturationValueCorrectOperation.cpp +++ b/source/blender/compositor/operations/COM_HueSaturationValueCorrectOperation.cpp @@ -74,5 +74,6 @@ void HueSaturationValueCorrectOperation::executePixel(float output[4], float x, void HueSaturationValueCorrectOperation::deinitExecution() { + CurveBaseOperation::deinitExecution(); this->m_inputProgram = NULL; } diff --git a/source/blender/compositor/operations/COM_VectorCurveOperation.cpp b/source/blender/compositor/operations/COM_VectorCurveOperation.cpp index d0a077fed61..6450b0716a3 100644 --- a/source/blender/compositor/operations/COM_VectorCurveOperation.cpp +++ b/source/blender/compositor/operations/COM_VectorCurveOperation.cpp @@ -56,5 +56,6 @@ void VectorCurveOperation::executePixel(float output[4], float x, float y, Pixel void VectorCurveOperation::deinitExecution() { + CurveBaseOperation::deinitExecution(); this->m_inputProgram = NULL; } diff --git a/source/blender/editors/interface/interface_draw.c b/source/blender/editors/interface/interface_draw.c index c9a6ba0abe7..a8b50f5c76e 100644 --- a/source/blender/editors/interface/interface_draw.c +++ b/source/blender/editors/interface/interface_draw.c @@ -1355,8 +1355,14 @@ void ui_draw_but_CURVE(ARegion *ar, uiBut *but, uiWidgetColors *wcol, rcti *rect rcti scissor_new; int a; - cumap = (CurveMapping *)(but->editcumap ? but->editcumap : but->poin); - cuma = cumap->cm + cumap->cur; + if (but->editcumap) { + cumap = but->editcumap; + } + else { + cumap = (CurveMapping *)but->poin; + } + + cuma = &cumap->cm[cumap->cur]; /* need scissor test, curve can draw outside of boundary */ glGetIntegerv(GL_VIEWPORT, scissor); @@ -1485,8 +1491,9 @@ void ui_draw_but_CURVE(ARegion *ar, uiBut *but, uiWidgetColors *wcol, rcti *rect cmp = cuma->table; /* first point */ - if ((cuma->flag & CUMA_EXTEND_EXTRAPOLATE) == 0) + if ((cuma->flag & CUMA_EXTEND_EXTRAPOLATE) == 0) { glVertex2f(rect->xmin, rect->ymin + zoomy * (cmp[0].y - offsy)); + } else { fx = rect->xmin + zoomx * (cmp[0].x - offsx + cuma->ext_in[0]); fy = rect->ymin + zoomy * (cmp[0].y - offsy + cuma->ext_in[1]); @@ -1498,8 +1505,9 @@ void ui_draw_but_CURVE(ARegion *ar, uiBut *but, uiWidgetColors *wcol, rcti *rect glVertex2f(fx, fy); } /* last point */ - if ((cuma->flag & CUMA_EXTEND_EXTRAPOLATE) == 0) + if ((cuma->flag & CUMA_EXTEND_EXTRAPOLATE) == 0) { glVertex2f(rect->xmax, rect->ymin + zoomy * (cmp[CM_TABLE].y - offsy)); + } else { fx = rect->xmin + zoomx * (cmp[CM_TABLE].x - offsx - cuma->ext_out[0]); fy = rect->ymin + zoomy * (cmp[CM_TABLE].y - offsy - cuma->ext_out[1]); From 0fd2448c8b392363041b1ffc450c2fef23bc90ce Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 21 Aug 2012 15:45:17 +0000 Subject: [PATCH 056/163] alt+wheel scrolling over the render slots works again (this didnt support scrolling when new interfaces would replace the old ones). --- .../editors/interface/interface_handlers.c | 27 ++++++++++--------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c index ce0ec310ac3..957482bb379 100644 --- a/source/blender/editors/interface/interface_handlers.c +++ b/source/blender/editors/interface/interface_handlers.c @@ -2945,9 +2945,11 @@ static int ui_do_but_BLOCK(bContext *C, uiBut *but, uiHandleButtonData *data, wm return WM_UI_HANDLER_BREAK; } else if (ELEM3(but->type, MENU, ICONROW, ICONTEXTROW)) { - - if (event->type == WHEELDOWNMOUSE && event->alt) { - data->value = ui_step_name_menu(but, -1); + if (ELEM(event->type, WHEELDOWNMOUSE, WHEELUPMOUSE) && event->alt) { + const int direction = (event->type == WHEELDOWNMOUSE) ? -1 : 1; + + data->value = ui_step_name_menu(but, direction); + button_activate_state(C, but, BUTTON_STATE_EXIT); ui_apply_button(C, but->block, but, data, 1); @@ -2961,16 +2963,15 @@ static int ui_do_but_BLOCK(bContext *C, uiBut *but, uiHandleButtonData *data, wm data->postbut = but; data->posttype = BUTTON_ACTIVATE_OVER; - return WM_UI_HANDLER_BREAK; - } - else if (event->type == WHEELUPMOUSE && event->alt) { - data->value = ui_step_name_menu(but, 1); - button_activate_state(C, but, BUTTON_STATE_EXIT); - ui_apply_button(C, but->block, but, data, 1); - - /* why this is needed described above */ - data->postbut = but; - data->posttype = BUTTON_ACTIVATE_OVER; + /* without this, a new interface that draws as result of the menu change + * won't register that the mouse is over it, eg: + * Alt+MouseWheel over the render slots, without this, + * the slot menu fails to switch a second time. + * + * Theactive state of the button could be maintained some other way + * and remove this mousemove event. + */ + WM_event_add_mousemove(C); return WM_UI_HANDLER_BREAK; } From dd21def25d2ddfa6ca04a7d11481a84b76e2c0ab Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 21 Aug 2012 15:57:59 +0000 Subject: [PATCH 057/163] fixed [#32373] Copy Vertex Group operator copies any value as full 1.0 --- source/blender/editors/object/object_vgroup.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/source/blender/editors/object/object_vgroup.c b/source/blender/editors/object/object_vgroup.c index b7977c23010..c4616fc39c6 100644 --- a/source/blender/editors/object/object_vgroup.c +++ b/source/blender/editors/object/object_vgroup.c @@ -686,8 +686,9 @@ static void vgroup_duplicate(Object *ob) dw_org = defvert_find_index(dv, idg); if (dw_org) { /* defvert_verify_index re-allocs org so need to store the weight first */ + const float weight = dw_org->weight; dw_cpy = defvert_verify_index(dv, icdg); - dw_cpy->weight = dw_org->weight; + dw_cpy->weight = weight; } } From abd031bb4eb2d2e8a1820da5a3338aa79266f6ef Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 21 Aug 2012 19:35:06 +0000 Subject: [PATCH 058/163] code cleanup: use rect size macros for the interface --- .../editors/interface/interface_draw.c | 11 +++++--- .../editors/interface/interface_handlers.c | 4 +-- .../editors/interface/interface_layout.c | 7 +++-- .../editors/interface/interface_panel.c | 4 +-- .../editors/interface/interface_regions.c | 26 +++++++++---------- .../editors/interface/interface_widgets.c | 20 +++++++------- 6 files changed, 39 insertions(+), 33 deletions(-) diff --git a/source/blender/editors/interface/interface_draw.c b/source/blender/editors/interface/interface_draw.c index a8b50f5c76e..c3edd38f8d9 100644 --- a/source/blender/editors/interface/interface_draw.c +++ b/source/blender/editors/interface/interface_draw.c @@ -493,8 +493,8 @@ static void ui_draw_but_CHARTAB(uiBut *but) charmax = G.charmax = 0xffff; /* Calculate the size of the button */ - width = absBLI_RCT_SIZE_X(rect); - height = absBLI_RCT_SIZE_Y(rect); + width = abs(BLI_RCT_SIZE_X(rect)); + height = abs(BLI_RCT_SIZE_Y(rect)); butw = floor(width / 12); buth = floor(height / 6); @@ -1371,8 +1371,11 @@ void ui_draw_but_CURVE(ARegion *ar, uiBut *but, uiWidgetColors *wcol, rcti *rect scissor_new.xmax = ar->winrct.xmin + rect->xmax; scissor_new.ymax = ar->winrct.ymin + rect->ymax; BLI_rcti_isect(&scissor_new, &ar->winrct, &scissor_new); - glScissor(scissor_new.xmin, scissor_new.ymin, scissor_new.xmax - scissor_new.xmin, scissor_new.ymax - scissor_new.ymin); - + glScissor(scissor_new.xmin, + scissor_new.ymin, + BLI_RCT_SIZE_X(&scissor_new), + BLI_RCT_SIZE_Y(&scissor_new)); + /* calculate offset and zoom */ zoomx = (BLI_RCT_SIZE_X(rect) - 2.0f * but->aspect) / BLI_RCT_SIZE_X(&cumap->curr); zoomy = (BLI_RCT_SIZE_Y(rect) - 2.0f * but->aspect) / BLI_RCT_SIZE_Y(&cumap->curr); diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c index 957482bb379..f0d2cb183b5 100644 --- a/source/blender/editors/interface/interface_handlers.c +++ b/source/blender/editors/interface/interface_handlers.c @@ -4241,8 +4241,8 @@ static int ui_numedit_but_TRACKPREVIEW(bContext *C, uiBut *but, uiHandleButtonDa scopes->marker = BKE_tracking_marker_ensure(scopes->track, scopes->framenr); scopes->marker->flag &= ~(MARKER_DISABLED | MARKER_TRACKED); - scopes->marker->pos[0] += -dx * scopes->slide_scale[0] / (but->block->rect.xmax - but->block->rect.xmin); - scopes->marker->pos[1] += -dy * scopes->slide_scale[1] / (but->block->rect.ymax - but->block->rect.ymin); + scopes->marker->pos[0] += -dx * scopes->slide_scale[0] / BLI_RCT_SIZE_X(&but->block->rect); + scopes->marker->pos[1] += -dy * scopes->slide_scale[1] / BLI_RCT_SIZE_Y(&but->block->rect); WM_event_add_notifier(C, NC_MOVIECLIP | NA_EDITED, NULL); } diff --git a/source/blender/editors/interface/interface_layout.c b/source/blender/editors/interface/interface_layout.c index 350aab728c4..deef36de561 100644 --- a/source/blender/editors/interface/interface_layout.c +++ b/source/blender/editors/interface/interface_layout.c @@ -39,6 +39,7 @@ #include "BLI_listbase.h" #include "BLI_string.h" +#include "BLI_rect.h" #include "BLI_utildefines.h" #include "BLF_translation.h" @@ -238,8 +239,10 @@ static void ui_item_size(uiItem *item, int *r_w, int *r_h) if (item->type == ITEM_BUTTON) { uiButtonItem *bitem = (uiButtonItem *)item; - if (r_w) *r_w = bitem->but->rect.xmax - bitem->but->rect.xmin; - if (r_h) *r_h = bitem->but->rect.ymax - bitem->but->rect.ymin; + + + if (r_w) *r_w = BLI_RCT_SIZE_X(&bitem->but->rect); + if (r_h) *r_h = BLI_RCT_SIZE_Y(&bitem->but->rect); } else { uiLayout *litem = (uiLayout *)item; diff --git a/source/blender/editors/interface/interface_panel.c b/source/blender/editors/interface/interface_panel.c index 512cda13df1..d0e66f532cc 100644 --- a/source/blender/editors/interface/interface_panel.c +++ b/source/blender/editors/interface/interface_panel.c @@ -547,7 +547,7 @@ void ui_draw_aligned_panel(uiStyle *style, uiBlock *block, rcti *rect) /* itemrect smaller */ itemrect.xmax = headrect.xmax - 5.0f / block->aspect; - itemrect.xmin = itemrect.xmax - (headrect.ymax - headrect.ymin); + itemrect.xmin = itemrect.xmax - BLI_RCT_SIZE_Y(&headrect); itemrect.ymin = headrect.ymin; itemrect.ymax = headrect.ymax; @@ -596,7 +596,7 @@ void ui_draw_aligned_panel(uiStyle *style, uiBlock *block, rcti *rect) /* itemrect smaller */ itemrect.xmin = headrect.xmin + 5.0f / block->aspect; - itemrect.xmax = itemrect.xmin + (headrect.ymax - headrect.ymin); + itemrect.xmax = itemrect.xmin + BLI_RCT_SIZE_Y(&headrect); itemrect.ymin = headrect.ymin; itemrect.ymax = headrect.ymax; diff --git a/source/blender/editors/interface/interface_regions.c b/source/blender/editors/interface/interface_regions.c index 35488430b22..8dee1ff6a13 100644 --- a/source/blender/editors/interface/interface_regions.c +++ b/source/blender/editors/interface/interface_regions.c @@ -391,7 +391,7 @@ static void ui_tooltip_region_draw_cb(const bContext *UNUSED(C), ARegion *ar) /* draw text */ uiStyleFontSet(&data->fstyle); - bbox.ymax = bbox.ymax - 0.5f * ((bbox.ymax - bbox.ymin) - data->toth); + bbox.ymax = bbox.ymax - 0.5f * (BLI_RCT_SIZE_Y(&bbox) - data->toth); bbox.ymin = bbox.ymax - data->lineh; for (i = 0; i < data->totline; i++) { @@ -730,9 +730,9 @@ ARegion *ui_tooltip_create(bContext *C, ARegion *butregion, uiBut *but) /* widget rect, in region coords */ data->bbox.xmin = MENU_SHADOW_SIDE; - data->bbox.xmax = rect_i.xmax - rect_i.xmin + MENU_SHADOW_SIDE; + data->bbox.xmax = BLI_RCT_SIZE_X(&rect_i) + MENU_SHADOW_SIDE; data->bbox.ymin = MENU_SHADOW_BOTTOM; - data->bbox.ymax = rect_i.ymax - rect_i.ymin + MENU_SHADOW_BOTTOM; + data->bbox.ymax = BLI_RCT_SIZE_Y(&rect_i) + MENU_SHADOW_BOTTOM; /* region bigger for shadow */ ar->winrct.xmin = rect_i.xmin - MENU_SHADOW_SIDE; @@ -865,8 +865,8 @@ static void ui_searchbox_butrect(rcti *rect, uiSearchboxData *data, int itemnr) { /* thumbnail preview */ if (data->preview) { - int buth = (data->bbox.ymax - data->bbox.ymin - 2 * MENU_TOP) / data->prv_rows; - int butw = (data->bbox.xmax - data->bbox.xmin) / data->prv_cols; + int butw = BLI_RCT_SIZE_X(&data->bbox) / data->prv_cols; + int buth = (BLI_RCT_SIZE_Y(&data->bbox) - 2 * MENU_TOP) / data->prv_rows; int row, col; *rect = data->bbox; @@ -882,7 +882,7 @@ static void ui_searchbox_butrect(rcti *rect, uiSearchboxData *data, int itemnr) } /* list view */ else { - int buth = (data->bbox.ymax - data->bbox.ymin - 2 * MENU_TOP) / SEARCH_ITEMS; + int buth = (BLI_RCT_SIZE_Y(&data->bbox) - 2 * MENU_TOP) / SEARCH_ITEMS; *rect = data->bbox; rect->xmin = data->bbox.xmin + 3.0f; @@ -1200,7 +1200,7 @@ ARegion *ui_searchbox_create(bContext *C, ARegion *butregion, uiBut *but) BLI_rctf_translate(&rect_fl, ofsx, ofsy); /* minimal width */ - if (rect_fl.xmax - rect_fl.xmin < 150) { + if (BLI_RCT_SIZE_X(&rect_fl) < 150) { rect_fl.xmax = rect_fl.xmin + 150; /* XXX arbitrary */ } @@ -1233,15 +1233,15 @@ ARegion *ui_searchbox_create(bContext *C, ARegion *butregion, uiBut *but) UI_view2d_to_region_no_clip(&butregion->v2d, 0, but->rect.ymax + ofsy, NULL, &newy1); newy1 += butregion->winrct.ymin; - rect_i.ymax = rect_i.ymax - rect_i.ymin + newy1; + rect_i.ymax = BLI_RCT_SIZE_Y(&rect_i) + newy1; rect_i.ymin = newy1; } /* widget rect, in region coords */ data->bbox.xmin = MENU_SHADOW_SIDE; - data->bbox.xmax = rect_i.xmax - rect_i.xmin + MENU_SHADOW_SIDE; + data->bbox.xmax = BLI_RCT_SIZE_X(&rect_i) + MENU_SHADOW_SIDE; data->bbox.ymin = MENU_SHADOW_BOTTOM; - data->bbox.ymax = rect_i.ymax - rect_i.ymin + MENU_SHADOW_BOTTOM; + data->bbox.ymax = BLI_RCT_SIZE_Y(&rect_i) + MENU_SHADOW_BOTTOM; /* region bigger for shadow */ ar->winrct.xmin = rect_i.xmin - MENU_SHADOW_SIDE; @@ -2341,7 +2341,7 @@ static uiBlock *ui_block_func_POPUP(bContext *C, uiPopupBlockHandle *handle, voi if (pup->but) { /* minimum width to enforece */ - minwidth = pup->but->rect.xmax - pup->but->rect.xmin; + minwidth = BLI_RCT_SIZE_X(&pup->but->rect); if (pup->but->type == PULLDOWN || pup->but->menu_create_func) { direction = UI_DOWN; @@ -2383,7 +2383,7 @@ static uiBlock *ui_block_func_POPUP(bContext *C, uiPopupBlockHandle *handle, voi * button, so it doesn't overlap the text too much, also note * the offset is negative because we are inverse moving the * block to be under the mouse */ - offset[0] = -(bt->rect.xmin + 0.8f * (bt->rect.xmax - bt->rect.xmin)); + offset[0] = -(bt->rect.xmin + 0.8f * BLI_RCT_SIZE_X(&bt->rect)); offset[1] = -(bt->rect.ymin + 0.5f * UI_UNIT_Y); } else { @@ -2391,7 +2391,7 @@ static uiBlock *ui_block_func_POPUP(bContext *C, uiPopupBlockHandle *handle, voi * on the first item */ offset[0] = 0; for (bt = block->buttons.first; bt; bt = bt->next) - offset[0] = mini(offset[0], -(bt->rect.xmin + 0.8f * (bt->rect.xmax - bt->rect.xmin))); + offset[0] = mini(offset[0], -(bt->rect.xmin + 0.8f * BLI_RCT_SIZE_X(&bt->rect))); offset[1] = 1.5 * UI_UNIT_Y; } diff --git a/source/blender/editors/interface/interface_widgets.c b/source/blender/editors/interface/interface_widgets.c index bf5b3fbe8c7..ef8d8302fa7 100644 --- a/source/blender/editors/interface/interface_widgets.c +++ b/source/blender/editors/interface/interface_widgets.c @@ -1760,8 +1760,8 @@ static void widget_softshadow(rcti *rect, int roundboxalign, float radin, float float quad_strip[WIDGET_SIZE_MAX * 2][2]; /* prevent tooltips to not show round shadow */ - if (2.0f * radout > 0.2f * (rect1.ymax - rect1.ymin) ) - rect1.ymax -= 0.2f * (rect1.ymax - rect1.ymin); + if (2.0f * radout > 0.2f * BLI_RCT_SIZE_Y(&rect1)) + rect1.ymax -= 0.2f * BLI_RCT_SIZE_Y(&rect1); else rect1.ymax -= 2.0f * radout; @@ -2371,12 +2371,12 @@ static void widget_scroll(uiBut *but, uiWidgetColors *wcol, rcti *rect, int stat /* ensure minimium size */ min = BLI_RCT_SIZE_Y(rect); - if (rect1.xmax - rect1.xmin < min) { + if (BLI_RCT_SIZE_X(&rect1) < min) { rect1.xmax = rect1.xmin + min; if (rect1.xmax > rect->xmax) { rect1.xmax = rect->xmax; - rect1.xmin = MAX2(rect1.xmax - min, rect->xmin); + rect1.xmin = maxi(rect1.xmax - min, rect->xmin); } } } @@ -2388,7 +2388,7 @@ static void widget_scroll(uiBut *but, uiWidgetColors *wcol, rcti *rect, int stat /* ensure minimium size */ min = BLI_RCT_SIZE_X(rect); - if (rect1.ymax - rect1.ymin < min) { + if (BLI_RCT_SIZE_Y(&rect1) < min) { rect1.ymax = rect1.ymin + min; if (rect1.ymax > rect->ymax) { @@ -2416,10 +2416,10 @@ static void widget_progressbar(uiBut *but, uiWidgetColors *wcol, rcti *rect, int rect_prog.ymax = rect_prog.ymin + 4; rect_bar.ymax = rect_bar.ymin + 4; - w = value * (rect_prog.xmax - rect_prog.xmin); + w = value * BLI_RCT_SIZE_X(&rect_prog); /* ensure minimium size */ - min = rect_prog.ymax - rect_prog.ymin; + min = BLI_RCT_SIZE_Y(&rect_prog); w = MAX2(w, min); rect_bar.xmax = rect_bar.xmin + w; @@ -2483,7 +2483,7 @@ static void widget_numslider(uiBut *but, uiWidgetColors *wcol, rcti *rect, int s rect1 = *rect; value = ui_get_but_val(but); - fac = ((float)value - but->softmin) * (rect1.xmax - rect1.xmin - offs) / (but->softmax - but->softmin); + fac = ((float)value - but->softmin) * (BLI_RCT_SIZE_X(&rect1) - offs) / (but->softmax - but->softmin); /* left part of slider, always rounded */ rect1.xmax = rect1.xmin + ceil(offs + 1.0f); @@ -2705,10 +2705,10 @@ static void widget_optionbut(uiWidgetColors *wcol, rcti *rect, int state, int UN widget_init(&wtb); /* square */ - recttemp.xmax = recttemp.xmin + (recttemp.ymax - recttemp.ymin); + recttemp.xmax = recttemp.xmin + BLI_RCT_SIZE_Y(&recttemp); /* smaller */ - delta = 1 + (recttemp.ymax - recttemp.ymin) / 8; + delta = 1 + BLI_RCT_SIZE_Y(&recttemp) / 8; recttemp.xmin += delta; recttemp.ymin += delta; recttemp.xmax -= delta; From c92ab5c3ef2d8339650eb95cd2ebba8c6956b62d Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 21 Aug 2012 20:34:05 +0000 Subject: [PATCH 059/163] code cleanup: use rect size macros --- source/blender/blenfont/intern/blf_font.c | 2 +- source/blender/blenkernel/intern/colortools.c | 2 +- source/blender/blenlib/intern/rct.c | 4 ++-- .../blender/editors/gpencil/gpencil_paint.c | 12 +++++----- .../editors/interface/interface_draw.c | 4 ++-- source/blender/editors/interface/view2d.c | 24 ++++++++++--------- source/blender/editors/interface/view2d_ops.c | 18 +++++++------- source/blender/editors/screen/area.c | 6 ++--- source/blender/editors/screen/glutil.c | 21 ++++++++-------- source/blender/editors/screen/screen_ops.c | 2 +- source/blender/editors/screen/screendump.c | 14 ++++++----- .../editors/sculpt_paint/paint_cursor.c | 5 ++-- .../editors/space_buttons/buttons_header.c | 2 +- .../blender/editors/space_graph/graph_edit.c | 12 +++++----- .../editors/space_image/image_buttons.c | 4 ++-- .../blender/editors/space_image/image_edit.c | 4 ++-- source/blender/editors/space_node/node_draw.c | 14 +++++------ source/blender/editors/space_node/node_view.c | 7 ++---- .../editors/space_outliner/outliner_edit.c | 6 ++--- .../editors/space_sequencer/sequencer_edit.c | 4 ++-- source/blender/editors/space_text/text_draw.c | 3 ++- .../editors/space_view3d/view3d_draw.c | 24 +++++++++---------- .../editors/space_view3d/view3d_edit.c | 8 +++---- .../editors/transform/transform_snap.c | 4 ++-- .../nodes/composite/node_composite_util.c | 2 +- .../render/intern/source/convertblender.c | 10 ++++---- .../render/intern/source/imagetexture.c | 16 ++++++------- .../blender/render/intern/source/initrender.c | 4 ++-- .../blender/render/intern/source/pipeline.c | 12 +++++----- .../blender/render/intern/source/rendercore.c | 8 +++---- source/blender/render/intern/source/shadbuf.c | 12 +++++----- .../windowmanager/intern/wm_subwindow.c | 8 +++---- 32 files changed, 142 insertions(+), 136 deletions(-) diff --git a/source/blender/blenfont/intern/blf_font.c b/source/blender/blenfont/intern/blf_font.c index d47fa5383d4..ab43804db8e 100644 --- a/source/blender/blenfont/intern/blf_font.c +++ b/source/blender/blenfont/intern/blf_font.c @@ -456,7 +456,7 @@ float blf_font_height(FontBLF *font, const char *str) ya = 1.0f; blf_font_boundbox(font, str, &box); - return (box.ymax - box.ymin) * ya; + return BLI_RCT_SIZE_Y(&box) * ya; } float blf_font_fixed_width(FontBLF *font) diff --git a/source/blender/blenkernel/intern/colortools.c b/source/blender/blenkernel/intern/colortools.c index 85d28f68034..7c03c75bd99 100644 --- a/source/blender/blenkernel/intern/colortools.c +++ b/source/blender/blenkernel/intern/colortools.c @@ -668,7 +668,7 @@ void curvemapping_changed(CurveMapping *cumap, int rem_doubles) CurveMap *cuma = cumap->cm + cumap->cur; CurveMapPoint *cmp = cuma->curve; rctf *clipr = &cumap->clipr; - float thresh = 0.01f * (clipr->xmax - clipr->xmin); + float thresh = 0.01f * BLI_RCT_SIZE_X(clipr); float dx = 0.0f, dy = 0.0f; int a; diff --git a/source/blender/blenlib/intern/rct.c b/source/blender/blenlib/intern/rct.c index 92cbcd485b6..ac9ac39893b 100644 --- a/source/blender/blenlib/intern/rct.c +++ b/source/blender/blenlib/intern/rct.c @@ -366,9 +366,9 @@ int BLI_rcti_isect(const rcti *src1, const rcti *src2, rcti *dest) void BLI_rcti_rctf_copy(rcti *dst, const rctf *src) { dst->xmin = floorf(src->xmin + 0.5f); - dst->xmax = dst->xmin + floorf((src->xmax - src->xmin) + 0.5f); + dst->xmax = dst->xmin + floorf(BLI_RCT_SIZE_X(src) + 0.5f); dst->ymin = floorf(src->ymin + 0.5f); - dst->ymax = dst->ymin + floorf((src->ymax - src->ymin) + 0.5f); + dst->ymax = dst->ymin + floorf(BLI_RCT_SIZE_Y(src) + 0.5f); } void BLI_rctf_rcti_copy(rctf *dst, const rcti *src) diff --git a/source/blender/editors/gpencil/gpencil_paint.c b/source/blender/editors/gpencil/gpencil_paint.c index 1f317fa4f04..c5f2ad4254b 100644 --- a/source/blender/editors/gpencil/gpencil_paint.c +++ b/source/blender/editors/gpencil/gpencil_paint.c @@ -819,8 +819,8 @@ static void gp_stroke_eraser_dostroke(tGPsdata *p, int mval[], int mvalo[], shor y0 = (int)(gps->points->y / 100 * p->ar->winy); } else { /* camera view, use subrect */ - x0 = (int)((gps->points->x / 100) * (p->subrect->xmax - p->subrect->xmin)) + p->subrect->xmin; - y0 = (int)((gps->points->y / 100) * (p->subrect->ymax - p->subrect->ymin)) + p->subrect->ymin; + x0 = (int)((gps->points->x / 100) * BLI_RCT_SIZE_X(p->subrect)) + p->subrect->xmin; + y0 = (int)((gps->points->y / 100) * BLI_RCT_SIZE_Y(p->subrect)) + p->subrect->ymin; } } @@ -866,10 +866,10 @@ static void gp_stroke_eraser_dostroke(tGPsdata *p, int mval[], int mvalo[], shor y1 = (int)(pt2->y / 100 * p->ar->winy); } else { /* camera view, use subrect */ - x0 = (int)((pt1->x / 100) * (p->subrect->xmax - p->subrect->xmin)) + p->subrect->xmin; - y0 = (int)((pt1->y / 100) * (p->subrect->ymax - p->subrect->ymin)) + p->subrect->ymin; - x1 = (int)((pt2->x / 100) * (p->subrect->xmax - p->subrect->xmin)) + p->subrect->xmin; - y1 = (int)((pt2->y / 100) * (p->subrect->ymax - p->subrect->ymin)) + p->subrect->ymin; + x0 = (int)((pt1->x / 100) * BLI_RCT_SIZE_X(p->subrect)) + p->subrect->xmin; + y0 = (int)((pt1->y / 100) * BLI_RCT_SIZE_Y(p->subrect)) + p->subrect->ymin; + x1 = (int)((pt2->x / 100) * BLI_RCT_SIZE_X(p->subrect)) + p->subrect->xmin; + y1 = (int)((pt2->y / 100) * BLI_RCT_SIZE_Y(p->subrect)) + p->subrect->ymin; } } diff --git a/source/blender/editors/interface/interface_draw.c b/source/blender/editors/interface/interface_draw.c index c3edd38f8d9..77dbbc878a7 100644 --- a/source/blender/editors/interface/interface_draw.c +++ b/source/blender/editors/interface/interface_draw.c @@ -1733,8 +1733,8 @@ void ui_dropshadow(rctf *rct, float radius, float aspect, float alpha, int UNUSE glEnable(GL_BLEND); - if (radius > (rct->ymax - rct->ymin - 10.0f) / 2.0f) - rad = (rct->ymax - rct->ymin - 10.0f) / 2.0f; + if (radius > (BLI_RCT_SIZE_Y(rct) - 10.0f) / 2.0f) + rad = (BLI_RCT_SIZE_Y(rct) - 10.0f) / 2.0f; else rad = radius; diff --git a/source/blender/editors/interface/view2d.c b/source/blender/editors/interface/view2d.c index 86322b0c0ea..c3059b8d575 100644 --- a/source/blender/editors/interface/view2d.c +++ b/source/blender/editors/interface/view2d.c @@ -1458,7 +1458,7 @@ View2DScrollers *UI_view2d_scrollers_calc(const bContext *C, View2D *v2d, short if (scroll & V2D_SCROLL_HORIZONTAL) { /* scroller 'button' extents */ totsize = BLI_RCT_SIZE_X(&v2d->tot); - scrollsize = (float)(hor.xmax - hor.xmin); + scrollsize = (float)BLI_RCT_SIZE_X(&hor); if (totsize == 0.0f) totsize = 1.0f; /* avoid divide by zero */ fac1 = (v2d->cur.xmin - v2d->tot.xmin) / totsize; @@ -1498,8 +1498,8 @@ View2DScrollers *UI_view2d_scrollers_calc(const bContext *C, View2D *v2d, short /* vertical scrollers */ if (scroll & V2D_SCROLL_VERTICAL) { /* scroller 'button' extents */ - totsize = BLI_RCT_SIZE_Y(&v2d->tot); - scrollsize = (float)(vert.ymax - vert.ymin); + totsize = BLI_RCT_SIZE_Y(&v2d->tot); + scrollsize = (float)BLI_RCT_SIZE_Y(&vert); if (totsize == 0.0f) totsize = 1.0f; /* avoid divide by zero */ fac1 = (v2d->cur.ymin - v2d->tot.ymin) / totsize; @@ -1545,7 +1545,9 @@ View2DScrollers *UI_view2d_scrollers_calc(const bContext *C, View2D *v2d, short scrollers->yclamp = yclamp; scrollers->yunits = yunits; - scrollers->grid = UI_view2d_grid_calc(CTX_data_scene(C), v2d, xunits, xclamp, yunits, yclamp, (hor.xmax - hor.xmin), (vert.ymax - vert.ymin)); + scrollers->grid = UI_view2d_grid_calc(CTX_data_scene(C), v2d, + xunits, xclamp, yunits, yclamp, + BLI_RCT_SIZE_X(&hor), BLI_RCT_SIZE_Y(&vert)); } /* return scrollers */ @@ -1629,7 +1631,7 @@ void UI_view2d_scrollers_draw(const bContext *C, View2D *v2d, View2DScrollers *v */ if ((v2d->keepzoom & V2D_LOCKZOOM_X) == 0 && (v2d->scroll & V2D_SCROLL_SCALE_HORIZONTAL) && - (slider.xmax - slider.xmin > V2D_SCROLLER_HANDLE_SIZE)) + (BLI_RCT_SIZE_X(&slider) > V2D_SCROLLER_HANDLE_SIZE)) { state |= UI_SCROLL_ARROWS; } @@ -1650,10 +1652,10 @@ void UI_view2d_scrollers_draw(const bContext *C, View2D *v2d, View2DScrollers *v * - dfac is gap between scale markings */ fac = (grid->startx - v2d->cur.xmin) / BLI_RCT_SIZE_X(&v2d->cur); - fac = (float)hor.xmin + fac * (hor.xmax - hor.xmin); + fac = (float)hor.xmin + fac * BLI_RCT_SIZE_X(&hor); dfac = grid->dx / BLI_RCT_SIZE_X(&v2d->cur); - dfac = dfac * (hor.xmax - hor.xmin); + dfac = dfac * BLI_RCT_SIZE_X(&hor); /* set starting value, and text color */ UI_ThemeColor(TH_TEXT); @@ -1740,7 +1742,7 @@ void UI_view2d_scrollers_draw(const bContext *C, View2D *v2d, View2DScrollers *v */ if ((v2d->keepzoom & V2D_LOCKZOOM_Y) == 0 && (v2d->scroll & V2D_SCROLL_SCALE_VERTICAL) && - (slider.ymax - slider.ymin > V2D_SCROLLER_HANDLE_SIZE)) + (BLI_RCT_SIZE_Y(&slider) > V2D_SCROLLER_HANDLE_SIZE)) { state |= UI_SCROLL_ARROWS; } @@ -1764,10 +1766,10 @@ void UI_view2d_scrollers_draw(const bContext *C, View2D *v2d, View2DScrollers *v * NOTE: it's assumed that that scrollbar is there if this is involved! */ fac = (grid->starty - v2d->cur.ymin) / BLI_RCT_SIZE_Y(&v2d->cur); - fac = vert.ymin + fac * (vert.ymax - vert.ymin); + fac = vert.ymin + fac * BLI_RCT_SIZE_Y(&vert); dfac = grid->dy / BLI_RCT_SIZE_Y(&v2d->cur); - dfac = dfac * (vert.ymax - vert.ymin); + dfac = dfac * BLI_RCT_SIZE_Y(&vert); /* set starting value, and text color */ UI_ThemeColor(TH_TEXT); @@ -2140,7 +2142,7 @@ void UI_view2d_text_cache_draw(ARegion *ar) const char *str = (const char *)(v2s + 1); int xofs = 0, yofs; - yofs = ceil(0.5f * (v2s->rect.ymax - v2s->rect.ymin - default_height)); + yofs = ceil(0.5f * (BLI_RCT_SIZE_Y(&v2s->rect) - default_height)); if (yofs < 1) yofs = 1; if (col_pack_prev != v2s->col.pack) { diff --git a/source/blender/editors/interface/view2d_ops.c b/source/blender/editors/interface/view2d_ops.c index 258025eefc9..84c3abf2ae2 100644 --- a/source/blender/editors/interface/view2d_ops.c +++ b/source/blender/editors/interface/view2d_ops.c @@ -471,7 +471,7 @@ static int view_scrollup_exec(bContext *C, wmOperator *op) if (RNA_boolean_get(op->ptr, "page")) { ARegion *ar = CTX_wm_region(C); - RNA_int_set(op->ptr, "deltay", ar->v2d.mask.ymax - ar->v2d.mask.ymin); + RNA_int_set(op->ptr, "deltay", BLI_RCT_SIZE_Y(&ar->v2d.mask)); } /* apply movement, then we're done */ @@ -1137,7 +1137,7 @@ static int view_borderzoom_exec(bContext *C, wmOperator *op) /* TODO: is this zoom factor calculation valid? It seems to produce same results everytime... */ if ((v2d->keepzoom & V2D_LOCKZOOM_X) == 0) { - size = (cur_new.xmax - cur_new.xmin); + size = BLI_RCT_SIZE_X(&cur_new); zoom = size / BLI_RCT_SIZE_X(&rect); center = BLI_RCT_CENTER_X(&cur_new); @@ -1145,7 +1145,7 @@ static int view_borderzoom_exec(bContext *C, wmOperator *op) cur_new.xmax = center + (size * zoom); } if ((v2d->keepzoom & V2D_LOCKZOOM_Y) == 0) { - size = (cur_new.ymax - cur_new.ymin); + size = BLI_RCT_SIZE_Y(&cur_new); zoom = size / BLI_RCT_SIZE_Y(&rect); center = BLI_RCT_CENTER_Y(&cur_new); @@ -1197,10 +1197,10 @@ struct SmoothView2DStore { */ static float smooth_view_rect_to_fac(const rctf *rect_a, const rctf *rect_b) { - float size_a[2] = {rect_a->xmax - rect_a->xmin, - rect_a->ymax - rect_a->ymin}; - float size_b[2] = {rect_b->xmax - rect_b->xmin, - rect_b->ymax - rect_b->ymin}; + float size_a[2] = {BLI_RCT_SIZE_X(rect_a), + BLI_RCT_SIZE_Y(rect_a)}; + float size_b[2] = {BLI_RCT_SIZE_X(rect_b), + BLI_RCT_SIZE_Y(rect_b)}; float cent_a[2] = {BLI_RCT_CENTER_X(rect_a), BLI_RCT_CENTER_Y(rect_a)}; float cent_b[2] = {BLI_RCT_CENTER_X(rect_b), @@ -1477,7 +1477,7 @@ static void scroller_activate_init(bContext *C, wmOperator *op, wmEvent *event, if (in_scroller == 'h') { /* horizontal scroller - calculate adjustment factor first */ - mask_size = (float)(v2d->hor.xmax - v2d->hor.xmin); + mask_size = (float)BLI_RCT_SIZE_X(&v2d->hor); vsm->fac = BLI_RCT_SIZE_X(&v2d->tot) / mask_size; /* get 'zone' (i.e. which part of scroller is activated) */ @@ -1493,7 +1493,7 @@ static void scroller_activate_init(bContext *C, wmOperator *op, wmEvent *event, } else { /* vertical scroller - calculate adjustment factor first */ - mask_size = (float)(v2d->vert.ymax - v2d->vert.ymin); + mask_size = (float)BLI_RCT_SIZE_Y(&v2d->vert); vsm->fac = BLI_RCT_SIZE_Y(&v2d->tot) / mask_size; /* get 'zone' (i.e. which part of scroller is activated) */ diff --git a/source/blender/editors/screen/area.c b/source/blender/editors/screen/area.c index 10bc17ff59e..59310f9e675 100644 --- a/source/blender/editors/screen/area.c +++ b/source/blender/editors/screen/area.c @@ -1096,8 +1096,8 @@ static void region_rect_recursive(ScrArea *sa, ARegion *ar, rcti *remainder, int if (ar->alignment & RGN_SPLIT_PREV) { if (ar->prev) { remainder = remainder_prev; - ar->prev->winx = ar->prev->winrct.xmax - ar->prev->winrct.xmin + 1; - ar->prev->winy = ar->prev->winrct.ymax - ar->prev->winrct.ymin + 1; + ar->prev->winx = BLI_RCT_SIZE_X(&ar->prev->winrct) + 1; + ar->prev->winy = BLI_RCT_SIZE_Y(&ar->prev->winrct) + 1; } } @@ -1769,7 +1769,7 @@ void ED_region_header(const bContext *C, ARegion *ar) } /* always as last */ - UI_view2d_totRect_set(&ar->v2d, maxco + UI_UNIT_X + 80, ar->v2d.tot.ymax - ar->v2d.tot.ymin); + UI_view2d_totRect_set(&ar->v2d, maxco + UI_UNIT_X + 80, BLI_RCT_SIZE_Y(&ar->v2d.tot)); /* restore view matrix? */ UI_view2d_view_restore(C); diff --git a/source/blender/editors/screen/glutil.c b/source/blender/editors/screen/glutil.c index a534124d2c0..967c6e85590 100644 --- a/source/blender/editors/screen/glutil.c +++ b/source/blender/editors/screen/glutil.c @@ -35,6 +35,7 @@ #include "DNA_vec_types.h" +#include "BLI_rect.h" #include "BLI_utildefines.h" #include "BKE_colortools.h" @@ -668,8 +669,8 @@ void glaDrawPixelsSafe(float x, float y, int img_w, int img_h, int row_w, int fo void glaDefine2DArea(rcti *screen_rect) { - int sc_w = screen_rect->xmax - screen_rect->xmin + 1; - int sc_h = screen_rect->ymax - screen_rect->ymin + 1; + const int sc_w = BLI_RCT_SIZE_X(screen_rect) + 1; + const int sc_h = BLI_RCT_SIZE_Y(screen_rect) + 1; glViewport(screen_rect->xmin, screen_rect->ymin, sc_w, sc_h); glScissor(screen_rect->xmin, screen_rect->ymin, sc_w, sc_h); @@ -713,10 +714,10 @@ void gla2DSetMap(gla2DDrawInfo *di, rctf *rect) di->world_rect = *rect; - sc_w = (di->screen_rect.xmax - di->screen_rect.xmin); - sc_h = (di->screen_rect.ymax - di->screen_rect.ymin); - wo_w = (di->world_rect.xmax - di->world_rect.xmin); - wo_h = (di->world_rect.ymax - di->world_rect.ymin); + sc_w = BLI_RCT_SIZE_X(&di->screen_rect); + sc_h = BLI_RCT_SIZE_Y(&di->screen_rect); + wo_w = BLI_RCT_SIZE_X(&di->world_rect); + wo_h = BLI_RCT_SIZE_Y(&di->world_rect); di->wo_to_sc[0] = sc_w / wo_w; di->wo_to_sc[1] = sc_h / wo_h; @@ -744,10 +745,10 @@ gla2DDrawInfo *glaBegin2DDraw(rcti *screen_rect, rctf *world_rect) di->world_rect.ymax = di->screen_rect.ymax; } - sc_w = (di->screen_rect.xmax - di->screen_rect.xmin); - sc_h = (di->screen_rect.ymax - di->screen_rect.ymin); - wo_w = (di->world_rect.xmax - di->world_rect.xmin); - wo_h = (di->world_rect.ymax - di->world_rect.ymin); + sc_w = BLI_RCT_SIZE_X(&di->screen_rect); + sc_h = BLI_RCT_SIZE_Y(&di->screen_rect); + wo_w = BLI_RCT_SIZE_X(&di->world_rect); + wo_h = BLI_RCT_SIZE_Y(&di->world_rect); di->wo_to_sc[0] = sc_w / wo_w; di->wo_to_sc[1] = sc_h / wo_h; diff --git a/source/blender/editors/screen/screen_ops.c b/source/blender/editors/screen/screen_ops.c index 97a63bb0df0..6b42b2f9de8 100644 --- a/source/blender/editors/screen/screen_ops.c +++ b/source/blender/editors/screen/screen_ops.c @@ -1615,7 +1615,7 @@ static int area_max_regionsize(ScrArea *sa, ARegion *scalear, AZEdge edge) dist = BLI_RCT_SIZE_X(&sa->totrct); } else { /* AE_BOTTOM_TO_TOPLEFT, AE_TOP_TO_BOTTOMRIGHT */ - dist = sa->totrct.ymax - sa->totrct.ymin; + dist = BLI_RCT_SIZE_Y(&sa->totrct); } /* subtractwidth of regions on opposite side diff --git a/source/blender/editors/screen/screendump.c b/source/blender/editors/screen/screendump.c index 41e2f0b16a4..4e71c49465f 100644 --- a/source/blender/editors/screen/screendump.c +++ b/source/blender/editors/screen/screendump.c @@ -149,14 +149,16 @@ static void screenshot_crop(ImBuf *ibuf, rcti crop) { unsigned int *to = ibuf->rect; unsigned int *from = ibuf->rect + crop.ymin * ibuf->x + crop.xmin; - int y, cropw = crop.xmax - crop.xmin, croph = crop.ymax - crop.ymin; + int crop_x = BLI_RCT_SIZE_X(&crop); + int crop_y = BLI_RCT_SIZE_Y(&crop); + int y; - if (cropw > 0 && croph > 0) { - for (y = 0; y < croph; y++, to += cropw, from += ibuf->x) - memmove(to, from, sizeof(unsigned int) * cropw); + if (crop_x > 0 && crop_y > 0) { + for (y = 0; y < crop_y; y++, to += crop_x, from += ibuf->x) + memmove(to, from, sizeof(unsigned int) * crop_x); - ibuf->x = cropw; - ibuf->y = croph; + ibuf->x = crop_x; + ibuf->y = crop_y; } } diff --git a/source/blender/editors/sculpt_paint/paint_cursor.c b/source/blender/editors/sculpt_paint/paint_cursor.c index 7f51f54ee4b..8616d4e66eb 100644 --- a/source/blender/editors/sculpt_paint/paint_cursor.c +++ b/source/blender/editors/sculpt_paint/paint_cursor.c @@ -31,6 +31,7 @@ #include "MEM_guardedalloc.h" #include "BLI_math.h" +#include "BLI_rect.h" #include "BLI_utildefines.h" #include "DNA_brush_types.h" @@ -440,8 +441,8 @@ static void paint_draw_alpha_overlay(Sculpt *sd, Brush *brush, else { quad.xmin = 0; quad.ymin = 0; - quad.xmax = vc->ar->winrct.xmax - vc->ar->winrct.xmin; - quad.ymax = vc->ar->winrct.ymax - vc->ar->winrct.ymin; + quad.xmax = BLI_RCT_SIZE_X(&vc->ar->winrct); + quad.ymax = BLI_RCT_SIZE_Y(&vc->ar->winrct); } /* set quad color */ diff --git a/source/blender/editors/space_buttons/buttons_header.c b/source/blender/editors/space_buttons/buttons_header.c index 199875fdc7b..4bcd4a933ed 100644 --- a/source/blender/editors/space_buttons/buttons_header.c +++ b/source/blender/editors/space_buttons/buttons_header.c @@ -148,7 +148,7 @@ void buttons_header_buttons(const bContext *C, ARegion *ar) uiBlockEndAlign(block); /* always as last */ - UI_view2d_totRect_set(&ar->v2d, xco + (UI_UNIT_X / 2), ar->v2d.tot.ymax - ar->v2d.tot.ymin); + UI_view2d_totRect_set(&ar->v2d, xco + (UI_UNIT_X / 2), BLI_RCT_SIZE_Y(&ar->v2d.tot)); uiEndBlock(C, block); uiDrawBlock(C, block); diff --git a/source/blender/editors/space_graph/graph_edit.c b/source/blender/editors/space_graph/graph_edit.c index de6aa42d5a6..f01d64b46b8 100644 --- a/source/blender/editors/space_graph/graph_edit.c +++ b/source/blender/editors/space_graph/graph_edit.c @@ -224,16 +224,16 @@ static int graphkeys_viewall(bContext *C, const short do_sel_only, const short i return OPERATOR_CANCELLED; /* set the horizontal range, with an extra offset so that the extreme keys will be in view */ - get_graph_keyframe_extents(&ac, - &cur_new.xmin, &cur_new.xmax, - &cur_new.ymin, &cur_new.ymax, - do_sel_only, include_handles); + get_graph_keyframe_extents(&ac, + &cur_new.xmin, &cur_new.xmax, + &cur_new.ymin, &cur_new.ymax, + do_sel_only, include_handles); - extra = 0.1f * (cur_new.xmax - cur_new.xmin); + extra = 0.1f * BLI_RCT_SIZE_X(&cur_new); cur_new.xmin -= extra; cur_new.xmax += extra; - extra = 0.1f * (cur_new.ymax - cur_new.ymin); + extra = 0.1f * BLI_RCT_SIZE_Y(&cur_new); cur_new.ymin -= extra; cur_new.ymax += extra; diff --git a/source/blender/editors/space_image/image_buttons.c b/source/blender/editors/space_image/image_buttons.c index d0f4fe92257..40f0683a852 100644 --- a/source/blender/editors/space_image/image_buttons.c +++ b/source/blender/editors/space_image/image_buttons.c @@ -268,8 +268,8 @@ static void preview_cb(ScrArea *sa, struct uiBlock *block) int mval[2]; if (G.scene->r.mode & R_BORDER) { - winx *= (G.scene->r.border.xmax - G.scene->r.border.xmin); - winy *= (G.scene->r.border.ymax - G.scene->r.border.ymin); + winx *= BLI_RCT_SIZE_X(&G.scene->r.border); + winy *= BLI_RCT_SIZE_Y(&G.scene->r.border); } /* while dragging we need to update the rects, otherwise it doesn't end with correct one */ diff --git a/source/blender/editors/space_image/image_edit.c b/source/blender/editors/space_image/image_edit.c index bb31ba42716..ac9883b411d 100644 --- a/source/blender/editors/space_image/image_edit.c +++ b/source/blender/editors/space_image/image_edit.c @@ -182,8 +182,8 @@ void ED_space_image_get_size(SpaceImage *sima, int *width, int *height) *height = (scene->r.ysch * scene->r.size) / 100; if ((scene->r.mode & R_BORDER) && (scene->r.mode & R_CROP)) { - *width *= (scene->r.border.xmax - scene->r.border.xmin); - *height *= (scene->r.border.ymax - scene->r.border.ymin); + *width *= BLI_RCT_SIZE_X(&scene->r.border); + *height *= BLI_RCT_SIZE_Y(&scene->r.border); } } diff --git a/source/blender/editors/space_node/node_draw.c b/source/blender/editors/space_node/node_draw.c index f58448b39ac..a3d7785d550 100644 --- a/source/blender/editors/space_node/node_draw.c +++ b/source/blender/editors/space_node/node_draw.c @@ -343,7 +343,7 @@ static void node_update_basis(const bContext *C, bNodeTree *ntree, bNode *node) if (node->prvr.ymax < node->prvr.ymin) SWAP(float, node->prvr.ymax, node->prvr.ymin); } else { - float oldh = node->prvr.ymax - node->prvr.ymin; + float oldh = BLI_RCT_SIZE_Y(&node->prvr); if (oldh == 0.0f) oldh = 0.6f * node->width - NODE_DY; dy -= NODE_DYS / 2; @@ -584,9 +584,9 @@ void node_socket_circle_draw(bNodeTree *UNUSED(ntree), bNodeSocket *sock, float /* not a callback */ static void node_draw_preview(bNodePreview *preview, rctf *prv) { - float xscale = (prv->xmax - prv->xmin) / ((float)preview->xsize); - float yscale = (prv->ymax - prv->ymin) / ((float)preview->ysize); - float tile = (prv->xmax - prv->xmin) / 10.0f; + float xscale = BLI_RCT_SIZE_X(prv) / ((float)preview->xsize); + float yscale = BLI_RCT_SIZE_Y(prv) / ((float)preview->ysize); + float tile = BLI_RCT_SIZE_X(prv) / 10.0f; float x, y; /* draw checkerboard backdrop to show alpha */ @@ -852,8 +852,8 @@ static void node_draw_hidden(const bContext *C, ARegion *ar, SpaceNode *snode, b { bNodeSocket *sock; rctf *rct = &node->totr; - float dx, centy = 0.5f * (rct->ymax + rct->ymin); - float hiddenrad = 0.5f * (rct->ymax - rct->ymin); + float dx, centy = BLI_RCT_CENTER_Y(rct); + float hiddenrad = BLI_RCT_SIZE_Y(rct) / 2.0f; float socket_size = NODE_SOCKSIZE * U.dpi / 72; int color_id = node_get_colorid(node); char showname[128]; /* 128 is used below */ @@ -932,7 +932,7 @@ static void node_draw_hidden(const bContext *C, ARegion *ar, SpaceNode *snode, b uiDefBut(node->block, LABEL, 0, showname, (int)(rct->xmin + (NODE_MARGIN_X / snode->aspect_sqrt)), (int)(centy - 10), - (short)(rct->xmax - rct->xmin - 18.0f - 12.0f), (short)NODE_DY, + (short)(BLI_RCT_SIZE_X(rct) - 18.0f - 12.0f), (short)NODE_DY, NULL, 0, 0, 0, 0, ""); } diff --git a/source/blender/editors/space_node/node_view.c b/source/blender/editors/space_node/node_view.c index 6f549bd252f..e89e798a6fa 100644 --- a/source/blender/editors/space_node/node_view.c +++ b/source/blender/editors/space_node/node_view.c @@ -91,8 +91,8 @@ static int space_node_view_flag(bContext *C, SpaceNode *snode, ARegion *ar, cons } if (tot) { - width = cur_new.xmax - cur_new.xmin; - height = cur_new.ymax - cur_new.ymin; + width = BLI_RCT_SIZE_X(&cur_new); + height = BLI_RCT_SIZE_Y(&cur_new); /* for single non-frame nodes, don't zoom in, just pan view, * but do allow zooming out, this allows for big nodes to be zoomed out */ @@ -104,9 +104,6 @@ static int space_node_view_flag(bContext *C, SpaceNode *snode, ARegion *ar, cons BLI_rctf_resize(&cur_new, oldwidth, oldheight); } else { - width = cur_new.xmax - cur_new.xmin; - height = cur_new.ymax - cur_new.ymin; - if (width > height) { float newheight; newheight = oldheight * width / oldwidth; diff --git a/source/blender/editors/space_outliner/outliner_edit.c b/source/blender/editors/space_outliner/outliner_edit.c index b669e705a25..0874ddcb279 100644 --- a/source/blender/editors/space_outliner/outliner_edit.c +++ b/source/blender/editors/space_outliner/outliner_edit.c @@ -615,7 +615,7 @@ void OUTLINER_OT_show_active(wmOperatorType *ot) static int outliner_scroll_page_exec(bContext *C, wmOperator *op) { ARegion *ar = CTX_wm_region(C); - int dy = ar->v2d.mask.ymax - ar->v2d.mask.ymin; + int dy = BLI_RCT_SIZE_Y(&ar->v2d.mask); int up = 0; if (RNA_boolean_get(op->ptr, "up")) @@ -760,10 +760,10 @@ static void outliner_find_panel(Scene *UNUSED(scene), ARegion *ar, SpaceOops *so tselem->flag |= TSE_SELECTED; /* make te->ys center of view */ - ytop = (int)(te->ys + (ar->v2d.mask.ymax - ar->v2d.mask.ymin) / 2); + ytop = (int)(te->ys + BLI_RCT_SIZE_Y(&ar->v2d.mask) / 2); if (ytop > 0) ytop = 0; ar->v2d.cur.ymax = (float)ytop; - ar->v2d.cur.ymin = (float)(ytop - (ar->v2d.mask.ymax - ar->v2d.mask.ymin)); + ar->v2d.cur.ymin = (float)(ytop - BLI_RCT_SIZE_Y(&ar->v2d.mask)); /* make te->xs ==> te->xend center of view */ xdelta = (int)(te->xs - ar->v2d.cur.xmin); diff --git a/source/blender/editors/space_sequencer/sequencer_edit.c b/source/blender/editors/space_sequencer/sequencer_edit.c index 2dc26a9d5b8..010ed177b72 100644 --- a/source/blender/editors/space_sequencer/sequencer_edit.c +++ b/source/blender/editors/space_sequencer/sequencer_edit.c @@ -2246,7 +2246,7 @@ static int sequencer_view_selected_exec(bContext *C, wmOperator *UNUSED(op)) ymax += ymargin; ymin -= ymargin; - orig_height = cur_new.ymax - cur_new.ymin; + orig_height = BLI_RCT_SIZE_Y(&cur_new); cur_new.xmin = xmin; cur_new.xmax = xmax; @@ -2255,7 +2255,7 @@ static int sequencer_view_selected_exec(bContext *C, wmOperator *UNUSED(op)) cur_new.ymax = ymax; /* only zoom out vertically */ - if (orig_height > cur_new.ymax - cur_new.ymin) { + if (orig_height > BLI_RCT_SIZE_Y(&cur_new)) { ymid = BLI_RCT_CENTER_Y(&cur_new); cur_new.ymin = ymid - (orig_height / 2); diff --git a/source/blender/editors/space_text/text_draw.c b/source/blender/editors/space_text/text_draw.c index 6240d174575..97eb5b41db7 100644 --- a/source/blender/editors/space_text/text_draw.c +++ b/source/blender/editors/space_text/text_draw.c @@ -39,6 +39,7 @@ #include "BLF_api.h" #include "BLI_blenlib.h" +#include "BLI_math.h" #include "BLI_utildefines.h" #include "DNA_text_types.h" @@ -1231,7 +1232,7 @@ static void draw_textscroll(SpaceText *st, rcti *scroll, rcti *back) uiWidgetScrollDraw(&wcol, scroll, &st->txtbar, (st->flags & ST_SCROLL_SELECT) ? UI_SCROLL_PRESSED : 0); uiSetRoundBox(UI_CNR_ALL); - rad = 0.4f * MIN2(st->txtscroll.xmax - st->txtscroll.xmin, st->txtscroll.ymax - st->txtscroll.ymin); + rad = 0.4f * mini(BLI_RCT_SIZE_X(&st->txtscroll), BLI_RCT_SIZE_Y(&st->txtscroll)); UI_GetThemeColor3ubv(TH_HILITE, col); col[3] = 48; glColor4ubv(col); diff --git a/source/blender/editors/space_view3d/view3d_draw.c b/source/blender/editors/space_view3d/view3d_draw.c index 93f8457e7a3..24395865a5e 100644 --- a/source/blender/editors/space_view3d/view3d_draw.c +++ b/source/blender/editors/space_view3d/view3d_draw.c @@ -971,10 +971,10 @@ static void view3d_camera_border(Scene *scene, ARegion *ar, View3D *v3d, RegionV rect_camera = params.viewplane; /* get camera border within viewport */ - viewborder_r->xmin = ((rect_camera.xmin - rect_view.xmin) / (rect_view.xmax - rect_view.xmin)) * ar->winx; - viewborder_r->xmax = ((rect_camera.xmax - rect_view.xmin) / (rect_view.xmax - rect_view.xmin)) * ar->winx; - viewborder_r->ymin = ((rect_camera.ymin - rect_view.ymin) / (rect_view.ymax - rect_view.ymin)) * ar->winy; - viewborder_r->ymax = ((rect_camera.ymax - rect_view.ymin) / (rect_view.ymax - rect_view.ymin)) * ar->winy; + viewborder_r->xmin = ((rect_camera.xmin - rect_view.xmin) / BLI_RCT_SIZE_X(&rect_view)) * ar->winx; + viewborder_r->xmax = ((rect_camera.xmax - rect_view.xmin) / BLI_RCT_SIZE_X(&rect_view)) * ar->winx; + viewborder_r->ymin = ((rect_camera.ymin - rect_view.ymin) / BLI_RCT_SIZE_Y(&rect_view)) * ar->winy; + viewborder_r->ymax = ((rect_camera.ymax - rect_view.ymin) / BLI_RCT_SIZE_Y(&rect_view)) * ar->winy; } void ED_view3d_calc_camera_border_size(Scene *scene, ARegion *ar, View3D *v3d, RegionView3D *rv3d, float size_r[2]) @@ -982,8 +982,8 @@ void ED_view3d_calc_camera_border_size(Scene *scene, ARegion *ar, View3D *v3d, R rctf viewborder; view3d_camera_border(scene, ar, v3d, rv3d, &viewborder, TRUE, TRUE); - size_r[0] = viewborder.xmax - viewborder.xmin; - size_r[1] = viewborder.ymax - viewborder.ymin; + size_r[0] = BLI_RCT_SIZE_X(&viewborder); + size_r[1] = BLI_RCT_SIZE_Y(&viewborder); } void ED_view3d_calc_camera_border(Scene *scene, ARegion *ar, View3D *v3d, RegionView3D *rv3d, @@ -1339,7 +1339,7 @@ static void backdrawview3d(Scene *scene, ARegion *ar, View3D *v3d) glDisable(GL_MULTISAMPLE_ARB); region_scissor_winrct(ar, &winrct); - glScissor(winrct.xmin, winrct.ymin, winrct.xmax - winrct.xmin, winrct.ymax - winrct.ymin); + glScissor(winrct.xmin, winrct.ymin, BLI_RCT_SIZE_X(&winrct), BLI_RCT_SIZE_Y(&winrct)); glClearColor(0.0, 0.0, 0.0, 0.0); if (v3d->zbuf) { @@ -2846,10 +2846,10 @@ static int view3d_main_area_draw_engine(const bContext *C, ARegion *ar, int draw ED_view3d_calc_camera_border(scene, ar, v3d, rv3d, &viewborder, FALSE); - cliprct.xmin = viewborder.xmin + scene->r.border.xmin * (viewborder.xmax - viewborder.xmin); - cliprct.ymin = viewborder.ymin + scene->r.border.ymin * (viewborder.ymax - viewborder.ymin); - cliprct.xmax = viewborder.xmin + scene->r.border.xmax * (viewborder.xmax - viewborder.xmin); - cliprct.ymax = viewborder.ymin + scene->r.border.ymax * (viewborder.ymax - viewborder.ymin); + cliprct.xmin = viewborder.xmin + scene->r.border.xmin * BLI_RCT_SIZE_X(&viewborder); + cliprct.ymin = viewborder.ymin + scene->r.border.ymin * BLI_RCT_SIZE_Y(&viewborder); + cliprct.xmax = viewborder.xmin + scene->r.border.xmax * BLI_RCT_SIZE_X(&viewborder); + cliprct.ymax = viewborder.ymin + scene->r.border.ymax * BLI_RCT_SIZE_Y(&viewborder); cliprct.xmin += ar->winrct.xmin; cliprct.xmax += ar->winrct.xmin; @@ -2863,7 +2863,7 @@ static int view3d_main_area_draw_engine(const bContext *C, ARegion *ar, int draw if (cliprct.xmax > cliprct.xmin && cliprct.ymax > cliprct.ymin) { glGetIntegerv(GL_SCISSOR_BOX, scissor); - glScissor(cliprct.xmin, cliprct.ymin, cliprct.xmax - cliprct.xmin, cliprct.ymax - cliprct.ymin); + glScissor(cliprct.xmin, cliprct.ymin, BLI_RCT_SIZE_X(&cliprct), BLI_RCT_SIZE_Y(&cliprct)); } else return 0; diff --git a/source/blender/editors/space_view3d/view3d_edit.c b/source/blender/editors/space_view3d/view3d_edit.c index 6e0c598d0ce..db47f88c8f2 100644 --- a/source/blender/editors/space_view3d/view3d_edit.c +++ b/source/blender/editors/space_view3d/view3d_edit.c @@ -2617,10 +2617,10 @@ static int render_border_exec(bContext *C, wmOperator *op) /* calculate range */ ED_view3d_calc_camera_border(scene, ar, v3d, rv3d, &vb, FALSE); - scene->r.border.xmin = ((float)rect.xmin - vb.xmin) / (vb.xmax - vb.xmin); - scene->r.border.ymin = ((float)rect.ymin - vb.ymin) / (vb.ymax - vb.ymin); - scene->r.border.xmax = ((float)rect.xmax - vb.xmin) / (vb.xmax - vb.xmin); - scene->r.border.ymax = ((float)rect.ymax - vb.ymin) / (vb.ymax - vb.ymin); + scene->r.border.xmin = ((float)rect.xmin - vb.xmin) / BLI_RCT_SIZE_X(&vb); + scene->r.border.ymin = ((float)rect.ymin - vb.ymin) / BLI_RCT_SIZE_Y(&vb); + scene->r.border.xmax = ((float)rect.xmax - vb.xmin) / BLI_RCT_SIZE_X(&vb); + scene->r.border.ymax = ((float)rect.ymax - vb.ymin) / BLI_RCT_SIZE_Y(&vb); /* actually set border */ CLAMP(scene->r.border.xmin, 0.0f, 1.0f); diff --git a/source/blender/editors/transform/transform_snap.c b/source/blender/editors/transform/transform_snap.c index fcb857be4e0..89cb83e3661 100644 --- a/source/blender/editors/transform/transform_snap.c +++ b/source/blender/editors/transform/transform_snap.c @@ -961,8 +961,8 @@ static void TargetSnapOffset(TransInfo *t, TransData *td) if (t->spacetype == SPACE_NODE && td != NULL) { bNode *node = td->extra; char border = t->tsnap.snapNodeBorder; - float width = node->totr.xmax - node->totr.xmin; - float height = node->totr.ymax - node->totr.ymin; + float width = BLI_RCT_SIZE_X(&node->totr); + float height = BLI_RCT_SIZE_Y(&node->totr); if (border & NODE_LEFT) t->tsnap.snapTarget[0] -= 0.5f * width; diff --git a/source/blender/nodes/composite/node_composite_util.c b/source/blender/nodes/composite/node_composite_util.c index b44454f38d9..2277c5a2836 100644 --- a/source/blender/nodes/composite/node_composite_util.c +++ b/source/blender/nodes/composite/node_composite_util.c @@ -146,7 +146,7 @@ CompBuf *get_cropped_compbuf(rcti *drect, float *rectf, int rectx, int recty, in if (disprect.xmin>= disprect.xmax) return NULL; if (disprect.ymin>= disprect.ymax) return NULL; - cbuf= alloc_compbuf(disprect.xmax-disprect.xmin, disprect.ymax-disprect.ymin, type, 1); + cbuf= alloc_compbuf(BLI_RCT_SIZE_X(&disprect), BLI_RCT_SIZE_Y(&disprect), type, 1); outfp= cbuf->rect; rectf += type*(disprect.ymin*rectx + disprect.xmin); dx= type*cbuf->x; diff --git a/source/blender/render/intern/source/convertblender.c b/source/blender/render/intern/source/convertblender.c index 6bd95e824eb..ebacdee0c97 100644 --- a/source/blender/render/intern/source/convertblender.c +++ b/source/blender/render/intern/source/convertblender.c @@ -5247,13 +5247,15 @@ static void speedvector_project(Render *re, float zco[2], const float co[3], con /* precalculate amount of radians 1 pixel rotates */ if (pano) { /* size of 1 pixel mapped to viewplane coords */ - float psize= (re->viewplane.xmax-re->viewplane.xmin)/(float)re->winx; + float psize; + + psize = BLI_RCT_SIZE_X(&re->viewplane) / (float)re->winx; /* x angle of a pixel */ - pixelphix= atan(psize/re->clipsta); + pixelphix = atan(psize / re->clipsta); - psize= (re->viewplane.ymax-re->viewplane.ymin)/(float)re->winy; + psize = BLI_RCT_SIZE_Y(&re->viewplane) / (float)re->winy; /* y angle of a pixel */ - pixelphiy= atan(psize/re->clipsta); + pixelphiy = atan(psize / re->clipsta); } zmulx= re->winx/2; zmuly= re->winy/2; diff --git a/source/blender/render/intern/source/imagetexture.c b/source/blender/render/intern/source/imagetexture.c index 0a90a55b3bc..56bf5242f36 100644 --- a/source/blender/render/intern/source/imagetexture.c +++ b/source/blender/render/intern/source/imagetexture.c @@ -396,16 +396,16 @@ static float square_rctf(rctf *rf) { float x, y; - x= rf->xmax- rf->xmin; - y= rf->ymax- rf->ymin; - return (x*y); + x = BLI_RCT_SIZE_X(rf); + y = BLI_RCT_SIZE_Y(rf); + return x * y; } static float clipx_rctf(rctf *rf, float x1, float x2) { float size; - size= rf->xmax - rf->xmin; + size = BLI_RCT_SIZE_X(rf); if (rf->xminxmin = x1; @@ -418,7 +418,7 @@ static float clipx_rctf(rctf *rf, float x1, float x2) return 0.0; } else if (size!=0.0f) { - return (rf->xmax - rf->xmin)/size; + return BLI_RCT_SIZE_X(rf) / size; } return 1.0; } @@ -427,7 +427,7 @@ static float clipy_rctf(rctf *rf, float y1, float y2) { float size; - size= rf->ymax - rf->ymin; + size = BLI_RCT_SIZE_Y(rf); if (rf->yminymin = y1; @@ -440,8 +440,8 @@ static float clipy_rctf(rctf *rf, float y1, float y2) rf->ymin = rf->ymax; return 0.0; } - else if (size!=0.0f) { - return (rf->ymax - rf->ymin)/size; + else if (size != 0.0f) { + return BLI_RCT_SIZE_Y(rf) / size; } return 1.0; diff --git a/source/blender/render/intern/source/initrender.c b/source/blender/render/intern/source/initrender.c index cc8f6682781..7efdba77943 100644 --- a/source/blender/render/intern/source/initrender.c +++ b/source/blender/render/intern/source/initrender.c @@ -610,8 +610,8 @@ void initparts(Render *re) } else disprect.ymax = ymaxb; - rectx = disprect.xmax - disprect.xmin; - recty = disprect.ymax - disprect.ymin; + rectx = BLI_RCT_SIZE_X(&disprect); + recty = BLI_RCT_SIZE_Y(&disprect); /* so, now can we add this part? */ if (rectx > 0 && recty > 0) { diff --git a/source/blender/render/intern/source/pipeline.c b/source/blender/render/intern/source/pipeline.c index 01b1f00ff98..9a524831388 100644 --- a/source/blender/render/intern/source/pipeline.c +++ b/source/blender/render/intern/source/pipeline.c @@ -439,8 +439,8 @@ void RE_InitState(Render *re, Render *source, RenderData *rd, SceneRenderLayer * re->winy = winy; if (disprect) { re->disprect = *disprect; - re->rectx = disprect->xmax - disprect->xmin; - re->recty = disprect->ymax - disprect->ymin; + re->rectx = BLI_RCT_SIZE_X(disprect); + re->recty = BLI_RCT_SIZE_Y(disprect); } else { re->disprect.xmin = re->disprect.ymin = 0; @@ -672,15 +672,15 @@ static void *do_part_thread(void *pa_v) float panorama_pixel_rot(Render *re) { float psize, phi, xfac; - float borderfac = (float)(re->disprect.xmax - re->disprect.xmin) / (float)re->winx; + float borderfac = (float)BLI_RCT_SIZE_X(&re->disprect) / (float)re->winx; /* size of 1 pixel mapped to viewplane coords */ - psize = (re->viewplane.xmax - re->viewplane.xmin) / (float)(re->winx); + psize = BLI_RCT_SIZE_X(&re->viewplane) / (float)re->winx; /* angle of a pixel */ phi = atan(psize / re->clipsta); /* correction factor for viewplane shifting, first calculate how much the viewplane angle is */ - xfac = borderfac * ((re->viewplane.xmax - re->viewplane.xmin)) / (float)re->xparts; + xfac = borderfac * BLI_RCT_SIZE_X(&re->viewplane) / (float)re->xparts; xfac = atan(0.5f * xfac / re->clipsta); /* and how much the same viewplane angle is wrapped */ psize = 0.5f * phi * ((float)re->partx); @@ -713,7 +713,7 @@ static RenderPart *find_next_pano_slice(Render *re, int *minx, rctf *viewplane) float phi = panorama_pixel_rot(re); R.panodxp = (re->winx - (best->disprect.xmin + best->disprect.xmax) ) / 2; - R.panodxv = ((viewplane->xmax - viewplane->xmin) * R.panodxp) / (float)(re->winx); + R.panodxv = (BLI_RCT_SIZE_X(viewplane) * R.panodxp) / (float)(re->winx); /* shift viewplane */ R.viewplane.xmin = viewplane->xmin + R.panodxv; diff --git a/source/blender/render/intern/source/rendercore.c b/source/blender/render/intern/source/rendercore.c index a6b2c98f9d3..c009c7b7394 100644 --- a/source/blender/render/intern/source/rendercore.c +++ b/source/blender/render/intern/source/rendercore.c @@ -107,11 +107,11 @@ void calc_view_vector(float *view, float x, float y) } /* move x and y to real viewplane coords */ - x= (x/(float)R.winx); - view[0]= R.viewplane.xmin + x*(R.viewplane.xmax - R.viewplane.xmin); + x = (x / (float)R.winx); + view[0] = R.viewplane.xmin + x * BLI_RCT_SIZE_X(&R.viewplane); - y= (y/(float)R.winy); - view[1]= R.viewplane.ymin + y*(R.viewplane.ymax - R.viewplane.ymin); + y = (y / (float)R.winy); + view[1] = R.viewplane.ymin + y * BLI_RCT_SIZE_Y(&R.viewplane); // if (R.flag & R_SEC_FIELD) { // if (R.r.mode & R_ODDFIELD) view[1]= (y+R.ystart)*R.ycor; diff --git a/source/blender/render/intern/source/shadbuf.c b/source/blender/render/intern/source/shadbuf.c index 44e81215c37..dce4d681ec9 100644 --- a/source/blender/render/intern/source/shadbuf.c +++ b/source/blender/render/intern/source/shadbuf.c @@ -1506,10 +1506,10 @@ static void isb_bsp_split_init(ISBBranch *root, MemArena *mem, int level) root->divider[1]= 0.5f*(root->box.ymin+root->box.ymax); /* find best splitpoint */ - if (root->box.xmax-root->box.xmin > root->box.ymax-root->box.ymin) - i= root->index= 0; + if (BLI_RCT_SIZE_X(&root->box) > BLI_RCT_SIZE_Y(&root->box)) + i = root->index = 0; else - i= root->index= 1; + i = root->index = 1; left= root->left= BLI_memarena_alloc(mem, sizeof(ISBBranch)); right= root->right= BLI_memarena_alloc(mem, sizeof(ISBBranch)); @@ -1551,10 +1551,10 @@ static void isb_bsp_split(ISBBranch *root, MemArena *mem) root->divider[1]/= BSPMAX_SAMPLE; /* find best splitpoint */ - if (root->box.xmax-root->box.xmin > root->box.ymax-root->box.ymin) - i= root->index= 0; + if (BLI_RCT_SIZE_X(&root->box) > BLI_RCT_SIZE_Y(&root->box)) + i = root->index = 0; else - i= root->index= 1; + i = root->index = 1; /* new branches */ left= root->left= BLI_memarena_alloc(mem, sizeof(ISBBranch)); diff --git a/source/blender/windowmanager/intern/wm_subwindow.c b/source/blender/windowmanager/intern/wm_subwindow.c index 0fa29bf3f14..adf54af240b 100644 --- a/source/blender/windowmanager/intern/wm_subwindow.c +++ b/source/blender/windowmanager/intern/wm_subwindow.c @@ -256,13 +256,13 @@ void wmSubWindowScissorSet(wmWindow *win, int swinid, rcti *srct) win->curswin = _curswin; _curwindow = win; - width = _curswin->winrct.xmax - _curswin->winrct.xmin + 1; - height = _curswin->winrct.ymax - _curswin->winrct.ymin + 1; + width = BLI_RCT_SIZE_X(&_curswin->winrct) + 1; + height = BLI_RCT_SIZE_Y(&_curswin->winrct) + 1; glViewport(_curswin->winrct.xmin, _curswin->winrct.ymin, width, height); if (srct) { - width = srct->xmax - srct->xmin + 1; - height = srct->ymax - srct->ymin + 1; + width = BLI_RCT_SIZE_X(srct) + 1; + height = BLI_RCT_SIZE_Y(srct) + 1; glScissor(srct->xmin, srct->ymin, width, height); } else From 59c71eb00ad2b798af6b7ff7959225e975201e2b Mon Sep 17 00:00:00 2001 From: Antony Riakiotakis Date: Tue, 21 Aug 2012 21:01:07 +0000 Subject: [PATCH 060/163] For gcc based systems use g++ for linking. This is necessary so that exceptions are propagated between shared libraries. We already use g++ when linking with cmake. This solves crash when trying to render with missing files on MinGW-w64 cycles. The cause was an OpenEXR exception that went uncaught when trying to check the file's extension through OpenImageIO while building the shader tree. Thus my bug-hunting frustration can end with a happy chord. --- build_files/scons/tools/Blender.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/build_files/scons/tools/Blender.py b/build_files/scons/tools/Blender.py index 56d13649cd1..4ab020dc26a 100644 --- a/build_files/scons/tools/Blender.py +++ b/build_files/scons/tools/Blender.py @@ -845,6 +845,8 @@ class BlenderEnvironment(SConsEnvironment): print bc.HEADER+'Configuring program '+bc.ENDC+bc.OKGREEN+progname+bc.ENDC lenv = self.Clone() lenv.Append(LINKFLAGS = lenv['PLATFORM_LINKFLAGS']) + if lenv['OURPLATFORM'] in ('win32-mingw', 'win64-mingw', 'linuxcross', 'cygwin', 'linux'): + lenv.Replace(LINK = '$CXX') if lenv['OURPLATFORM'] in ('win32-vc', 'cygwin', 'win64-vc'): if lenv['BF_DEBUG']: lenv.Prepend(LINKFLAGS = ['/DEBUG','/PDB:'+progname+'.pdb','/NODEFAULTLIB:libcmt']) From 3793e178f46b571a9c026e139eac1bbe59b83c82 Mon Sep 17 00:00:00 2001 From: Antony Riakiotakis Date: Wed, 22 Aug 2012 00:06:09 +0000 Subject: [PATCH 061/163] Turn OpenMP off for MinGW64. I thought it behaved correctly in new compiler builds but unfortunately it looks like there is some issue still which mostly shows when openmp threads stop. This causes crashes after rendering with subsurf, multires, when calculating fluids and possibly when other functionality is used as well. This should make MinGW64 builds quite stable again :) --- CMakeLists.txt | 2 ++ build_files/scons/config/win64-mingw-config.py | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 338135f4987..6bb5d8af627 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1043,6 +1043,8 @@ elseif(WIN32) set(PLATFORM_LINKLIBS "${PLATFORM_LINKLIBS} -lpthread") add_definitions(-DFREE_WINDOWS64 -DMS_WIN64) + #Turn off OpenMP since it causes crashes on render for subsurfed/multiresolution meshes + set(WITH_OPENMP OFF) endif() add_definitions(-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE64_SOURCE) diff --git a/build_files/scons/config/win64-mingw-config.py b/build_files/scons/config/win64-mingw-config.py index 27286439297..ffd37065e35 100644 --- a/build_files/scons/config/win64-mingw-config.py +++ b/build_files/scons/config/win64-mingw-config.py @@ -170,7 +170,7 @@ WITH_BF_RAYOPTIMIZATION = True BF_RAYOPTIMIZATION_SSE_FLAGS = ['-mmmx', '-msse', '-msse2'] #May produce errors with unsupported MinGW-w64 builds -WITH_BF_OPENMP = True +WITH_BF_OPENMP = False ## CC = 'gcc' From ffcc63a7d0ef6e0651412588ec5e8867e7e0e023 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 22 Aug 2012 08:54:18 +0000 Subject: [PATCH 062/163] node tree functions for copy/free now support optional ID user count management, this is not used yet, so no functional changes. --- source/blender/blenkernel/BKE_node.h | 24 ++++--- source/blender/blenkernel/intern/lamp.c | 4 +- source/blender/blenkernel/intern/library.c | 4 +- source/blender/blenkernel/intern/material.c | 12 ++-- source/blender/blenkernel/intern/node.c | 65 +++++++++++++++++-- source/blender/blenkernel/intern/scene.c | 6 +- source/blender/blenkernel/intern/texture.c | 4 +- source/blender/blenkernel/intern/world.c | 4 +- .../blender/editors/space_node/node_group.c | 2 +- 9 files changed, 92 insertions(+), 33 deletions(-) diff --git a/source/blender/blenkernel/BKE_node.h b/source/blender/blenkernel/BKE_node.h index c45afbe77a9..2a0679e3977 100644 --- a/source/blender/blenkernel/BKE_node.h +++ b/source/blender/blenkernel/BKE_node.h @@ -301,21 +301,29 @@ struct bNodeType *ntreeGetNodeType(struct bNodeTree *ntree); struct bNodeSocketType *ntreeGetSocketType(int type); struct bNodeTree *ntreeAddTree(const char *name, int type, int nodetype); -void ntreeInitTypes(struct bNodeTree *ntree); +void ntreeInitTypes(struct bNodeTree *ntree); -void ntreeFreeTree(struct bNodeTree *ntree); +/* copy/free funcs, need to manage ID users */ +void ntreeFreeTree_ex(struct bNodeTree *ntree, const short do_id_user); +void ntreeFreeTree(struct bNodeTree *ntree); +struct bNodeTree *ntreeCopyTree_ex(struct bNodeTree *ntree, const short do_id_user); struct bNodeTree *ntreeCopyTree(struct bNodeTree *ntree); -void ntreeSwitchID(struct bNodeTree *ntree, struct ID *sce_from, struct ID *sce_to); -void ntreeMakeLocal(struct bNodeTree *ntree); -int ntreeHasType(struct bNodeTree *ntree, int type); +void ntreeSwitchID_ex(struct bNodeTree *ntree, struct ID *sce_from, struct ID *sce_to, const short do_id_user); +void ntreeSwitchID(struct bNodeTree *ntree, struct ID *sce_from, struct ID *sce_to); +/* node->id user count */ +void ntreeUserIncrefID(struct bNodeTree *ntree); +void ntreeUserDecrefID(struct bNodeTree *ntree); -void ntreeUpdateTree(struct bNodeTree *ntree); + +void ntreeMakeLocal(struct bNodeTree *ntree); +int ntreeHasType(struct bNodeTree *ntree, int type); +void ntreeUpdateTree(struct bNodeTree *ntree); /* XXX Currently each tree update call does call to ntreeVerifyNodes too. * Some day this should be replaced by a decent depsgraph automatism! */ -void ntreeVerifyNodes(struct Main *main, struct ID *id); +void ntreeVerifyNodes(struct Main *main, struct ID *id); -void ntreeGetDependencyList(struct bNodeTree *ntree, struct bNode ***deplist, int *totnodes); +void ntreeGetDependencyList(struct bNodeTree *ntree, struct bNode ***deplist, int *totnodes); /* XXX old trees handle output flags automatically based on special output node types and last active selection. * new tree types have a per-output socket flag to indicate the final output to use explicitly. diff --git a/source/blender/blenkernel/intern/lamp.c b/source/blender/blenkernel/intern/lamp.c index 4782d09a7c8..6a802236ec4 100644 --- a/source/blender/blenkernel/intern/lamp.c +++ b/source/blender/blenkernel/intern/lamp.c @@ -120,7 +120,7 @@ Lamp *BKE_lamp_copy(Lamp *la) lan->curfalloff = curvemapping_copy(la->curfalloff); if (la->nodetree) - lan->nodetree = ntreeCopyTree(la->nodetree); + lan->nodetree = ntreeCopyTree_ex(la->nodetree, FALSE); /* TODO: do_id_user arg needs checking */ if (la->preview) lan->preview = BKE_previewimg_copy(la->preview); @@ -223,7 +223,7 @@ void BKE_lamp_free(Lamp *la) /* is no lib link block, but lamp extension */ if (la->nodetree) { - ntreeFreeTree(la->nodetree); + ntreeFreeTree_ex(la->nodetree, FALSE); /* TODO: do_id_user arg needs checking */ MEM_freeN(la->nodetree); } diff --git a/source/blender/blenkernel/intern/library.c b/source/blender/blenkernel/intern/library.c index e073cfdf76d..f1d1d128c16 100644 --- a/source/blender/blenkernel/intern/library.c +++ b/source/blender/blenkernel/intern/library.c @@ -348,7 +348,7 @@ int id_copy(ID *id, ID **newid, int test) if (!test) *newid = (ID *)BKE_action_copy((bAction *)id); return 1; case ID_NT: - if (!test) *newid = (ID *)ntreeCopyTree((bNodeTree *)id); + if (!test) *newid = (ID *)ntreeCopyTree_ex((bNodeTree *)id, FALSE); /* TODO: do_id_user arg needs checking */ return 1; case ID_BR: if (!test) *newid = (ID *)BKE_brush_copy((Brush *)id); @@ -881,7 +881,7 @@ void BKE_libblock_free(ListBase *lb, void *idv) BKE_action_free((bAction *)id); break; case ID_NT: - ntreeFreeTree((bNodeTree *)id); + ntreeFreeTree_ex((bNodeTree *)id, FALSE); /* TODO: do_id_user arg needs checking */ break; case ID_BR: BKE_brush_free((Brush *)id); diff --git a/source/blender/blenkernel/intern/material.c b/source/blender/blenkernel/intern/material.c index e5f392e4bce..a1288b8af08 100644 --- a/source/blender/blenkernel/intern/material.c +++ b/source/blender/blenkernel/intern/material.c @@ -101,7 +101,7 @@ void BKE_material_free(Material *ma) /* is no lib link block, but material extension */ if (ma->nodetree) { - ntreeFreeTree(ma->nodetree); + ntreeFreeTree_ex(ma->nodetree, FALSE); /* TODO: do_id_user arg needs checking */ MEM_freeN(ma->nodetree); } @@ -235,7 +235,7 @@ Material *BKE_material_copy(Material *ma) if (ma->preview) man->preview = BKE_previewimg_copy(ma->preview); if (ma->nodetree) { - man->nodetree = ntreeCopyTree(ma->nodetree); /* 0 == full new tree */ + man->nodetree = ntreeCopyTree_ex(ma->nodetree, FALSE); /* TODO: do_id_user arg needs checking */ } man->gpumaterial.first = man->gpumaterial.last = NULL; @@ -1511,7 +1511,7 @@ void free_matcopybuf(void) matcopybuf.ramp_spec = NULL; if (matcopybuf.nodetree) { - ntreeFreeTree(matcopybuf.nodetree); + ntreeFreeTree_ex(matcopybuf.nodetree, FALSE); /* TODO: do_id_user arg needs checking */ MEM_freeN(matcopybuf.nodetree); matcopybuf.nodetree = NULL; } @@ -1537,7 +1537,7 @@ void copy_matcopybuf(Material *ma) matcopybuf.mtex[a] = MEM_dupallocN(mtex); } } - matcopybuf.nodetree = ntreeCopyTree(ma->nodetree); + matcopybuf.nodetree = ntreeCopyTree_ex(ma->nodetree, FALSE); /* TODO: do_id_user arg needs checking */ matcopybuf.preview = NULL; matcopybuf.gpumaterial.first = matcopybuf.gpumaterial.last = NULL; matcopied = 1; @@ -1561,7 +1561,7 @@ void paste_matcopybuf(Material *ma) } if (ma->nodetree) { - ntreeFreeTree(ma->nodetree); + ntreeFreeTree_ex(ma->nodetree, FALSE); /* TODO: do_id_user arg needs checking */ MEM_freeN(ma->nodetree); } @@ -1582,7 +1582,7 @@ void paste_matcopybuf(Material *ma) } } - ma->nodetree = ntreeCopyTree(matcopybuf.nodetree); + ma->nodetree = ntreeCopyTree_ex(matcopybuf.nodetree, FALSE); /* TODO: do_id_user arg needs checking */ } diff --git a/source/blender/blenkernel/intern/node.c b/source/blender/blenkernel/intern/node.c index 62e80645a35..56ae912756e 100644 --- a/source/blender/blenkernel/intern/node.c +++ b/source/blender/blenkernel/intern/node.c @@ -671,7 +671,7 @@ bNodeTree *ntreeAddTree(const char *name, int type, int nodetype) * copying for internal use (threads for eg), where you wont want it to modify the * scene data. */ -static bNodeTree *ntreeCopyTree_internal(bNodeTree *ntree, const short do_make_extern) +static bNodeTree *ntreeCopyTree_internal(bNodeTree *ntree, const short do_id_user, const short do_make_extern) { bNodeTree *newtree; bNode *node /*, *nnode */ /* UNUSED */, *last; @@ -702,6 +702,11 @@ static bNodeTree *ntreeCopyTree_internal(bNodeTree *ntree, const short do_make_e last = ntree->nodes.last; for (node = ntree->nodes.first; node; node = node->next) { + /* ntreeUserDecrefID inline */ + if (do_id_user) { + id_us_min(node->id); + } + if (do_make_extern) { id_lib_extern(node->id); } @@ -751,22 +756,56 @@ static bNodeTree *ntreeCopyTree_internal(bNodeTree *ntree, const short do_make_e return newtree; } +bNodeTree *ntreeCopyTree_ex(bNodeTree *ntree, const short do_id_user) +{ + return ntreeCopyTree_internal(ntree, do_id_user, TRUE); +} bNodeTree *ntreeCopyTree(bNodeTree *ntree) { - return ntreeCopyTree_internal(ntree, TRUE); + return ntreeCopyTree_ex(ntree, TRUE); } /* use when duplicating scenes */ -void ntreeSwitchID(bNodeTree *ntree, ID *id_from, ID *id_to) +void ntreeSwitchID_ex(bNodeTree *ntree, ID *id_from, ID *id_to, const short do_id_user) { bNode *node; + + if (id_from == id_to) { + /* should never happen but may as well skip if it does */ + return; + } + /* for scene duplication only */ for (node = ntree->nodes.first; node; node = node->next) { if (node->id == id_from) { + if (do_id_user) { + id_us_min(id_from); + id_us_plus(id_to); + } + node->id = id_to; } } } +void ntreeSwitchID(bNodeTree *ntree, ID *id_from, ID *id_to) +{ + ntreeSwitchID_ex(ntree, id_from, id_to, TRUE); +} + +void ntreeUserIncrefID(bNodeTree *ntree) +{ + bNode *node; + for (node = ntree->nodes.first; node; node = node->next) { + id_us_plus(node->id); + } +} +void ntreeUserDecrefID(bNodeTree *ntree) +{ + bNode *node; + for (node = ntree->nodes.first; node; node = node->next) { + id_us_min(node->id); + } +} /* *************** preview *********** */ /* if node->preview, then we assume the rect to exist */ @@ -913,6 +952,7 @@ static void node_unlink_attached(bNodeTree *ntree, bNode *parent) } } +/** \note caller needs to manage node->id user */ void nodeFreeNode(bNodeTree *ntree, bNode *node) { bNodeSocket *sock, *nextsock; @@ -956,7 +996,7 @@ void nodeFreeNode(bNodeTree *ntree, bNode *node) } /* do not free ntree itself here, BKE_libblock_free calls this function too */ -void ntreeFreeTree(bNodeTree *ntree) +void ntreeFreeTree_ex(bNodeTree *ntree, const short do_id_user) { bNode *node, *next; bNodeSocket *sock; @@ -990,6 +1030,12 @@ void ntreeFreeTree(bNodeTree *ntree) for (node = ntree->nodes.first; node; node = next) { next = node->next; + + /* ntreeUserIncrefID inline */ + if (do_id_user) { + id_us_min(node->id); + } + nodeFreeNode(ntree, node); } @@ -1000,6 +1046,11 @@ void ntreeFreeTree(bNodeTree *ntree) node_socket_free_default_value(sock->type, sock->default_value); BLI_freelistN(&ntree->outputs); } +/* same as ntreeFreeTree_ex but always manage users */ +void ntreeFreeTree(bNodeTree *ntree) +{ + ntreeFreeTree_ex(ntree, TRUE); +} void ntreeFreeCache(bNodeTree *ntree) { @@ -1137,7 +1188,7 @@ void ntreeMakeLocal(bNodeTree *ntree) } else if (cd.local && cd.lib) { /* this is the mixed case, we copy the tree and assign it to local users */ - bNodeTree *newtree = ntreeCopyTree(ntree); + bNodeTree *newtree = ntreeCopyTree_ex(ntree, FALSE); /* TODO: do_id_user arg needs checking */ newtree->id.us = 0; @@ -1188,7 +1239,7 @@ bNodeTree *ntreeLocalize(bNodeTree *ntree) } /* node copy func */ - ltree = ntreeCopyTree_internal(ntree, FALSE); + ltree = ntreeCopyTree_internal(ntree, FALSE, FALSE); if (adt) { AnimData *ladt = BKE_animdata_from_id(<ree->id); @@ -1248,7 +1299,7 @@ void ntreeLocalMerge(bNodeTree *localtree, bNodeTree *ntree) if (ntreetype->local_merge) ntreetype->local_merge(localtree, ntree); - ntreeFreeTree(localtree); + ntreeFreeTree_ex(localtree, FALSE); /* TODO: do_id_user arg needs checking */ MEM_freeN(localtree); } diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c index d476e90498c..4fd08c8f6f8 100644 --- a/source/blender/blenkernel/intern/scene.c +++ b/source/blender/blenkernel/intern/scene.c @@ -153,8 +153,8 @@ Scene *BKE_scene_copy(Scene *sce, int type) BKE_keyingsets_copy(&(scen->keyingsets), &(sce->keyingsets)); if (sce->nodetree) { - scen->nodetree = ntreeCopyTree(sce->nodetree); /* copies actions */ - ntreeSwitchID(scen->nodetree, &sce->id, &scen->id); + scen->nodetree = ntreeCopyTree_ex(sce->nodetree, FALSE); /* TODO: do_id_user arg needs checking */ /* copies actions */ + ntreeSwitchID_ex(scen->nodetree, &sce->id, &scen->id, FALSE); } obase = sce->base.first; @@ -321,7 +321,7 @@ void BKE_scene_free(Scene *sce) } if (sce->nodetree) { - ntreeFreeTree(sce->nodetree); + ntreeFreeTree_ex(sce->nodetree, FALSE); /* TODO: do_id_user arg needs checking */ MEM_freeN(sce->nodetree); } diff --git a/source/blender/blenkernel/intern/texture.c b/source/blender/blenkernel/intern/texture.c index 2f54fe6cebd..66b096b14f1 100644 --- a/source/blender/blenkernel/intern/texture.c +++ b/source/blender/blenkernel/intern/texture.c @@ -430,7 +430,7 @@ void BKE_texture_free(Tex *tex) tex->id.icon_id = 0; if (tex->nodetree) { - ntreeFreeTree(tex->nodetree); + ntreeFreeTree_ex(tex->nodetree, FALSE); /* TODO: do_id_user arg needs checking */ MEM_freeN(tex->nodetree); } } @@ -697,7 +697,7 @@ Tex *BKE_texture_copy(Tex *tex) if (tex->nodetree->execdata) { ntreeTexEndExecTree(tex->nodetree->execdata, 1); } - texn->nodetree = ntreeCopyTree(tex->nodetree); + texn->nodetree = ntreeCopyTree_ex(tex->nodetree, FALSE); /* TODO: do_id_user arg needs checking */ } return texn; diff --git a/source/blender/blenkernel/intern/world.c b/source/blender/blenkernel/intern/world.c index dd71e43182e..418d7da6b85 100644 --- a/source/blender/blenkernel/intern/world.c +++ b/source/blender/blenkernel/intern/world.c @@ -67,7 +67,7 @@ void BKE_world_free(World *wrld) /* is no lib link block, but world extension */ if (wrld->nodetree) { - ntreeFreeTree(wrld->nodetree); + ntreeFreeTree_ex(wrld->nodetree, FALSE); /* TODO: do_id_user arg needs checking */ MEM_freeN(wrld->nodetree); } @@ -129,7 +129,7 @@ World *BKE_world_copy(World *wrld) } if (wrld->nodetree) { - wrldn->nodetree = ntreeCopyTree(wrld->nodetree); + wrldn->nodetree = ntreeCopyTree_ex(wrld->nodetree, FALSE); /* TODO: do_id_user arg needs checking */ } if (wrld->preview) diff --git a/source/blender/editors/space_node/node_group.c b/source/blender/editors/space_node/node_group.c index efd2378bf31..4e3529738e6 100644 --- a/source/blender/editors/space_node/node_group.c +++ b/source/blender/editors/space_node/node_group.c @@ -424,7 +424,7 @@ static int node_group_ungroup(bNodeTree *ntree, bNode *gnode) * - all of wgroup's nodes are transferred across to their new home * - ngroup (i.e. the source NodeTree) is left unscathed */ - wgroup = ntreeCopyTree(ngroup); + wgroup = ntreeCopyTree_ex(ngroup, FALSE); /* TODO: do_id_user arg needs checking */ /* add the nodes into the ntree */ for (node = wgroup->nodes.first; node; node = nextn) { From a4fd9f827b5792538da664d1a5eaea2db9472b90 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 22 Aug 2012 09:10:16 +0000 Subject: [PATCH 063/163] fix for bug where scene copy and free didn't manage ID users. you could for eg, make a full copy of a scene, then manually remove its compo nodes - which would give invalid zero user count. --- source/blender/blenkernel/intern/node.c | 2 +- source/blender/blenkernel/intern/scene.c | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/source/blender/blenkernel/intern/node.c b/source/blender/blenkernel/intern/node.c index 56ae912756e..b67288f63fd 100644 --- a/source/blender/blenkernel/intern/node.c +++ b/source/blender/blenkernel/intern/node.c @@ -704,7 +704,7 @@ static bNodeTree *ntreeCopyTree_internal(bNodeTree *ntree, const short do_id_use /* ntreeUserDecrefID inline */ if (do_id_user) { - id_us_min(node->id); + id_us_plus(node->id); } if (do_make_extern) { diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c index 4fd08c8f6f8..145bd6a88e5 100644 --- a/source/blender/blenkernel/intern/scene.c +++ b/source/blender/blenkernel/intern/scene.c @@ -153,8 +153,9 @@ Scene *BKE_scene_copy(Scene *sce, int type) BKE_keyingsets_copy(&(scen->keyingsets), &(sce->keyingsets)); if (sce->nodetree) { - scen->nodetree = ntreeCopyTree_ex(sce->nodetree, FALSE); /* TODO: do_id_user arg needs checking */ /* copies actions */ - ntreeSwitchID_ex(scen->nodetree, &sce->id, &scen->id, FALSE); + /* ID's are managed on both copy and switch */ + scen->nodetree = ntreeCopyTree(sce->nodetree); + ntreeSwitchID(scen->nodetree, &sce->id, &scen->id); } obase = sce->base.first; @@ -321,7 +322,7 @@ void BKE_scene_free(Scene *sce) } if (sce->nodetree) { - ntreeFreeTree_ex(sce->nodetree, FALSE); /* TODO: do_id_user arg needs checking */ + ntreeFreeTree(sce->nodetree); MEM_freeN(sce->nodetree); } From 2b9fd376e1d0aa9491d8b842b7b45cc5beac5fbe Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 22 Aug 2012 09:35:46 +0000 Subject: [PATCH 064/163] all areas of blender now do node tree id user count management, except for some exceptions like making a node tree local and material clipboard. --- source/blender/blenkernel/intern/lamp.c | 4 ++-- source/blender/blenkernel/intern/library.c | 4 ++-- source/blender/blenkernel/intern/material.c | 18 +++++++++++------- source/blender/blenkernel/intern/node.c | 4 ++-- source/blender/blenkernel/intern/texture.c | 4 ++-- source/blender/blenkernel/intern/world.c | 4 ++-- source/blender/editors/space_node/node_group.c | 7 ++++--- 7 files changed, 25 insertions(+), 20 deletions(-) diff --git a/source/blender/blenkernel/intern/lamp.c b/source/blender/blenkernel/intern/lamp.c index 6a802236ec4..4782d09a7c8 100644 --- a/source/blender/blenkernel/intern/lamp.c +++ b/source/blender/blenkernel/intern/lamp.c @@ -120,7 +120,7 @@ Lamp *BKE_lamp_copy(Lamp *la) lan->curfalloff = curvemapping_copy(la->curfalloff); if (la->nodetree) - lan->nodetree = ntreeCopyTree_ex(la->nodetree, FALSE); /* TODO: do_id_user arg needs checking */ + lan->nodetree = ntreeCopyTree(la->nodetree); if (la->preview) lan->preview = BKE_previewimg_copy(la->preview); @@ -223,7 +223,7 @@ void BKE_lamp_free(Lamp *la) /* is no lib link block, but lamp extension */ if (la->nodetree) { - ntreeFreeTree_ex(la->nodetree, FALSE); /* TODO: do_id_user arg needs checking */ + ntreeFreeTree(la->nodetree); MEM_freeN(la->nodetree); } diff --git a/source/blender/blenkernel/intern/library.c b/source/blender/blenkernel/intern/library.c index f1d1d128c16..e073cfdf76d 100644 --- a/source/blender/blenkernel/intern/library.c +++ b/source/blender/blenkernel/intern/library.c @@ -348,7 +348,7 @@ int id_copy(ID *id, ID **newid, int test) if (!test) *newid = (ID *)BKE_action_copy((bAction *)id); return 1; case ID_NT: - if (!test) *newid = (ID *)ntreeCopyTree_ex((bNodeTree *)id, FALSE); /* TODO: do_id_user arg needs checking */ + if (!test) *newid = (ID *)ntreeCopyTree((bNodeTree *)id); return 1; case ID_BR: if (!test) *newid = (ID *)BKE_brush_copy((Brush *)id); @@ -881,7 +881,7 @@ void BKE_libblock_free(ListBase *lb, void *idv) BKE_action_free((bAction *)id); break; case ID_NT: - ntreeFreeTree_ex((bNodeTree *)id, FALSE); /* TODO: do_id_user arg needs checking */ + ntreeFreeTree((bNodeTree *)id); break; case ID_BR: BKE_brush_free((Brush *)id); diff --git a/source/blender/blenkernel/intern/material.c b/source/blender/blenkernel/intern/material.c index a1288b8af08..8a26a1b52c5 100644 --- a/source/blender/blenkernel/intern/material.c +++ b/source/blender/blenkernel/intern/material.c @@ -101,7 +101,7 @@ void BKE_material_free(Material *ma) /* is no lib link block, but material extension */ if (ma->nodetree) { - ntreeFreeTree_ex(ma->nodetree, FALSE); /* TODO: do_id_user arg needs checking */ + ntreeFreeTree(ma->nodetree); MEM_freeN(ma->nodetree); } @@ -235,7 +235,7 @@ Material *BKE_material_copy(Material *ma) if (ma->preview) man->preview = BKE_previewimg_copy(ma->preview); if (ma->nodetree) { - man->nodetree = ntreeCopyTree_ex(ma->nodetree, FALSE); /* TODO: do_id_user arg needs checking */ + man->nodetree = ntreeCopyTree(ma->nodetree); } man->gpumaterial.first = man->gpumaterial.last = NULL; @@ -1483,7 +1483,11 @@ void ramp_blend(int type, float r_col[3], const float fac, const float col[3]) } } -/* copy/paste buffer, if we had a propper py api that would be better */ +/** + * \brief copy/paste buffer, if we had a propper py api that would be better + * \note matcopybuf.nodetree does _NOT_ use ID's + * \todo matcopybuf.nodetree's node->id's are NOT validated, this will crash! + */ static Material matcopybuf; static short matcopied = 0; @@ -1511,7 +1515,7 @@ void free_matcopybuf(void) matcopybuf.ramp_spec = NULL; if (matcopybuf.nodetree) { - ntreeFreeTree_ex(matcopybuf.nodetree, FALSE); /* TODO: do_id_user arg needs checking */ + ntreeFreeTree_ex(matcopybuf.nodetree, FALSE); MEM_freeN(matcopybuf.nodetree); matcopybuf.nodetree = NULL; } @@ -1537,7 +1541,7 @@ void copy_matcopybuf(Material *ma) matcopybuf.mtex[a] = MEM_dupallocN(mtex); } } - matcopybuf.nodetree = ntreeCopyTree_ex(ma->nodetree, FALSE); /* TODO: do_id_user arg needs checking */ + matcopybuf.nodetree = ntreeCopyTree_ex(ma->nodetree, FALSE); matcopybuf.preview = NULL; matcopybuf.gpumaterial.first = matcopybuf.gpumaterial.last = NULL; matcopied = 1; @@ -1561,7 +1565,7 @@ void paste_matcopybuf(Material *ma) } if (ma->nodetree) { - ntreeFreeTree_ex(ma->nodetree, FALSE); /* TODO: do_id_user arg needs checking */ + ntreeFreeTree(ma->nodetree); MEM_freeN(ma->nodetree); } @@ -1582,7 +1586,7 @@ void paste_matcopybuf(Material *ma) } } - ma->nodetree = ntreeCopyTree_ex(matcopybuf.nodetree, FALSE); /* TODO: do_id_user arg needs checking */ + ma->nodetree = ntreeCopyTree_ex(matcopybuf.nodetree, FALSE); } diff --git a/source/blender/blenkernel/intern/node.c b/source/blender/blenkernel/intern/node.c index b67288f63fd..37562686a99 100644 --- a/source/blender/blenkernel/intern/node.c +++ b/source/blender/blenkernel/intern/node.c @@ -1188,7 +1188,7 @@ void ntreeMakeLocal(bNodeTree *ntree) } else if (cd.local && cd.lib) { /* this is the mixed case, we copy the tree and assign it to local users */ - bNodeTree *newtree = ntreeCopyTree_ex(ntree, FALSE); /* TODO: do_id_user arg needs checking */ + bNodeTree *newtree = ntreeCopyTree(ntree); newtree->id.us = 0; @@ -1299,7 +1299,7 @@ void ntreeLocalMerge(bNodeTree *localtree, bNodeTree *ntree) if (ntreetype->local_merge) ntreetype->local_merge(localtree, ntree); - ntreeFreeTree_ex(localtree, FALSE); /* TODO: do_id_user arg needs checking */ + ntreeFreeTree_ex(localtree, FALSE); MEM_freeN(localtree); } diff --git a/source/blender/blenkernel/intern/texture.c b/source/blender/blenkernel/intern/texture.c index 66b096b14f1..2f54fe6cebd 100644 --- a/source/blender/blenkernel/intern/texture.c +++ b/source/blender/blenkernel/intern/texture.c @@ -430,7 +430,7 @@ void BKE_texture_free(Tex *tex) tex->id.icon_id = 0; if (tex->nodetree) { - ntreeFreeTree_ex(tex->nodetree, FALSE); /* TODO: do_id_user arg needs checking */ + ntreeFreeTree(tex->nodetree); MEM_freeN(tex->nodetree); } } @@ -697,7 +697,7 @@ Tex *BKE_texture_copy(Tex *tex) if (tex->nodetree->execdata) { ntreeTexEndExecTree(tex->nodetree->execdata, 1); } - texn->nodetree = ntreeCopyTree_ex(tex->nodetree, FALSE); /* TODO: do_id_user arg needs checking */ + texn->nodetree = ntreeCopyTree(tex->nodetree); } return texn; diff --git a/source/blender/blenkernel/intern/world.c b/source/blender/blenkernel/intern/world.c index 418d7da6b85..dd71e43182e 100644 --- a/source/blender/blenkernel/intern/world.c +++ b/source/blender/blenkernel/intern/world.c @@ -67,7 +67,7 @@ void BKE_world_free(World *wrld) /* is no lib link block, but world extension */ if (wrld->nodetree) { - ntreeFreeTree_ex(wrld->nodetree, FALSE); /* TODO: do_id_user arg needs checking */ + ntreeFreeTree(wrld->nodetree); MEM_freeN(wrld->nodetree); } @@ -129,7 +129,7 @@ World *BKE_world_copy(World *wrld) } if (wrld->nodetree) { - wrldn->nodetree = ntreeCopyTree_ex(wrld->nodetree, FALSE); /* TODO: do_id_user arg needs checking */ + wrldn->nodetree = ntreeCopyTree(wrld->nodetree); } if (wrld->preview) diff --git a/source/blender/editors/space_node/node_group.c b/source/blender/editors/space_node/node_group.c index 4e3529738e6..77583ae1325 100644 --- a/source/blender/editors/space_node/node_group.c +++ b/source/blender/editors/space_node/node_group.c @@ -421,10 +421,11 @@ static int node_group_ungroup(bNodeTree *ntree, bNode *gnode) node->new_node = NULL; /* wgroup is a temporary copy of the NodeTree we're merging in - * - all of wgroup's nodes are transferred across to their new home - * - ngroup (i.e. the source NodeTree) is left unscathed + * - all of wgroup's nodes are transferred across to their new home + * - ngroup (i.e. the source NodeTree) is left unscathed + * - temp copy. don't change ID usercount */ - wgroup = ntreeCopyTree_ex(ngroup, FALSE); /* TODO: do_id_user arg needs checking */ + wgroup = ntreeCopyTree_ex(ngroup, FALSE); /* add the nodes into the ntree */ for (node = wgroup->nodes.first; node; node = nextn) { From 28b9576f4bbc2b9c5ae181350bf3a9e464eedf38 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 22 Aug 2012 10:03:37 +0000 Subject: [PATCH 065/163] error message when an addon was missing register/unregister functions whasnt very good (didnt point to file with the error) --- release/scripts/modules/addon_utils.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/release/scripts/modules/addon_utils.py b/release/scripts/modules/addon_utils.py index 02d9cd2d1c6..433d9024e0a 100644 --- a/release/scripts/modules/addon_utils.py +++ b/release/scripts/modules/addon_utils.py @@ -275,6 +275,7 @@ def enable(module_name, default_set=True, persistent=False): try: mod.register() except: + print("Exception in module register(): %r" % getattr(mod, "__file__", module_name)) handle_error() del sys.modules[module_name] return None @@ -316,6 +317,7 @@ def disable(module_name, default_set=True): try: mod.unregister() except: + print("Exception in module unregister(): %r" % getattr(mod, "__file__", module_name)) import traceback traceback.print_exc() else: From 7d673ef0d2fa934324d2fa9ac5c9efd3d8f61abf Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 22 Aug 2012 10:29:30 +0000 Subject: [PATCH 066/163] fix for blend_render_info.py not closing file & some edits to comments. --- release/scripts/modules/blend_render_info.py | 2 ++ .../scripts/templates/operator_mesh_add.py | 6 ++-- source/blender/makesdna/DNA_curve_types.h | 32 +++++++++++-------- source/blender/makesdna/DNA_sequence_types.h | 15 ++++++--- 4 files changed, 34 insertions(+), 21 deletions(-) diff --git a/release/scripts/modules/blend_render_info.py b/release/scripts/modules/blend_render_info.py index 8762ea0e287..d08b9e09dda 100755 --- a/release/scripts/modules/blend_render_info.py +++ b/release/scripts/modules/blend_render_info.py @@ -86,6 +86,8 @@ def read_blend_rend_chunk(path): scenes.append((start_frame, end_frame, scene_name)) + blendfile.close() + return scenes diff --git a/release/scripts/templates/operator_mesh_add.py b/release/scripts/templates/operator_mesh_add.py index f2bb231cb7a..fa248cb9005 100644 --- a/release/scripts/templates/operator_mesh_add.py +++ b/release/scripts/templates/operator_mesh_add.py @@ -78,9 +78,9 @@ class AddBox(bpy.types.Operator): def execute(self, context): verts_loc, faces = add_box(self.width, - self.height, - self.depth, - ) + self.height, + self.depth, + ) mesh = bpy.data.meshes.new("Box") diff --git a/source/blender/makesdna/DNA_curve_types.h b/source/blender/makesdna/DNA_curve_types.h index 56cf90d3d9d..284694f2b48 100644 --- a/source/blender/makesdna/DNA_curve_types.h +++ b/source/blender/makesdna/DNA_curve_types.h @@ -87,20 +87,22 @@ typedef struct BevPoint { short split_tag, dupe_tag; } BevPoint; -/* Keyframes on F-Curves (allows code reuse of Bezier eval code) and +/** + * Keyframes on F-Curves (allows code reuse of Bezier eval code) and * Points on Bezier Curves/Paths are generally BezTriples - */ -/* note: alfa location in struct is abused by Key system */ -/* vec in BezTriple looks like this: - * - vec[0][0]=x location of handle 1 - * - vec[0][1]=y location of handle 1 - * - vec[0][2]=z location of handle 1 (not used for FCurve Points(2d)) - * - vec[1][0]=x location of control point - * - vec[1][1]=y location of control point - * - vec[1][2]=z location of control point - * - vec[2][0]=x location of handle 2 - * - vec[2][1]=y location of handle 2 - * - vec[2][2]=z location of handle 2 (not used for FCurve Points(2d)) + * + * \note alfa location in struct is abused by Key system + * + * \note vec in BezTriple looks like this: + * - vec[0][0] = x location of handle 1 + * - vec[0][1] = y location of handle 1 + * - vec[0][2] = z location of handle 1 (not used for FCurve Points(2d)) + * - vec[1][0] = x location of control point + * - vec[1][1] = y location of control point + * - vec[1][2] = z location of control point + * - vec[2][0] = x location of handle 2 + * - vec[2][1] = y location of handle 2 + * - vec[2][2] = z location of handle 2 (not used for FCurve Points(2d)) */ typedef struct BezTriple { float vec[3][3]; @@ -119,6 +121,10 @@ typedef struct BPoint { float radius, pad; /* user-set radius per point for beveling etc */ } BPoint; +/** + * \note Nurb name is misleading, since it can be used for polygons too, + * also, it should be NURBS (Nurb isn't the singular of Nurbs). + */ typedef struct Nurb { struct Nurb *next, *prev; /* multiple nurbs per curve object are allowed */ short type; diff --git a/source/blender/makesdna/DNA_sequence_types.h b/source/blender/makesdna/DNA_sequence_types.h index e7ab6f66408..0835bb6b4c8 100644 --- a/source/blender/makesdna/DNA_sequence_types.h +++ b/source/blender/makesdna/DNA_sequence_types.h @@ -102,11 +102,16 @@ typedef struct Strip { StripColorBalance *color_balance; } Strip; -/* The sequence structure is the basic struct used by any strip. each of the strips uses a different sequence structure.*/ -/* WATCH IT: first part identical to ID (for use in ipo's) - * the commend above is historic, probably we can drop the ID compatibility, but take care making this change */ - -/* WATCH ITv2, this is really a 'Strip' in the UI!, name is highly confusing */ +/** + * The sequence structure is the basic struct used by any strip. + * each of the strips uses a different sequence structure. + * + * \warning The first part identical to ID (for use in ipo's) + * the commend above is historic, probably we can drop the ID compatibility, + * but take care making this change. + * + * \warning This is really a 'Strip' in the UI!, name is highly confusing. + */ typedef struct Sequence { struct Sequence *next, *prev; void *tmp; /* tmp var for copying, and tagging for linked selection */ From 92a1572102700fe2f03d4de75ac41c10db4621dd Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 22 Aug 2012 11:18:37 +0000 Subject: [PATCH 067/163] fix for rare crash in cycles BVH tree packing. --- intern/cycles/bvh/bvh.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/intern/cycles/bvh/bvh.cpp b/intern/cycles/bvh/bvh.cpp index 4d3588452eb..b58a34f9942 100644 --- a/intern/cycles/bvh/bvh.cpp +++ b/intern/cycles/bvh/bvh.cpp @@ -411,7 +411,7 @@ void BVH::pack_instances(size_t nodes_size) size_t nsize_bbox = (use_qbvh)? nsize-2: nsize-1; int4 *bvh_nodes = &bvh->pack.nodes[0]; size_t bvh_nodes_size = bvh->pack.nodes.size(); - int *bvh_is_leaf = &bvh->pack.is_leaf[0]; + int *bvh_is_leaf = (bvh->pack.is_leaf.size() != 0) ? &bvh->pack.is_leaf[0] : NULL; for(size_t i = 0, j = 0; i < bvh_nodes_size; i+=nsize, j++) { memcpy(pack_nodes + pack_nodes_offset, bvh_nodes + i, nsize_bbox*sizeof(int4)); @@ -419,7 +419,7 @@ void BVH::pack_instances(size_t nodes_size) /* modify offsets into arrays */ int4 data = bvh_nodes[i + nsize_bbox]; - if(bvh_is_leaf[j]) { + if(bvh_is_leaf && bvh_is_leaf[j]) { data.x += tri_offset; data.y += tri_offset; } From f67d0e63a44e5cda79dfd5981dace42a87bdebeb Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 22 Aug 2012 11:58:59 +0000 Subject: [PATCH 068/163] add new mask blend mode: 'Merge Subtract'. gives better results when using feather on overlapping masks when one subtracts from another. --- source/blender/blenkernel/intern/mask.c | 2 +- .../blender/blenkernel/intern/mask_rasterize.c | 5 ++++- source/blender/makesdna/DNA_mask_types.h | 17 +++++++++-------- source/blender/makesrna/intern/rna_mask.c | 3 ++- 4 files changed, 16 insertions(+), 11 deletions(-) diff --git a/source/blender/blenkernel/intern/mask.c b/source/blender/blenkernel/intern/mask.c index 1e1cbf8610e..a6ceba588d2 100644 --- a/source/blender/blenkernel/intern/mask.c +++ b/source/blender/blenkernel/intern/mask.c @@ -158,7 +158,7 @@ MaskLayer *BKE_mask_layer_new(Mask *mask, const char *name) mask->masklay_tot++; - masklay->blend = MASK_BLEND_MERGE; + masklay->blend = MASK_BLEND_MERGE_ADD; masklay->alpha = 1.0f; return masklay; diff --git a/source/blender/blenkernel/intern/mask_rasterize.c b/source/blender/blenkernel/intern/mask_rasterize.c index d39be3b8ed6..48e55601469 100644 --- a/source/blender/blenkernel/intern/mask_rasterize.c +++ b/source/blender/blenkernel/intern/mask_rasterize.c @@ -1282,9 +1282,12 @@ float BKE_maskrasterize_handle_sample(MaskRasterHandle *mr_handle, const float x } switch (layer->blend) { - case MASK_BLEND_MERGE: + case MASK_BLEND_MERGE_ADD: value += value_layer * (1.0f - value); break; + case MASK_BLEND_MERGE_SUBTRACT: + value -= value_layer * value; + break; case MASK_BLEND_ADD: value += value_layer; break; diff --git a/source/blender/makesdna/DNA_mask_types.h b/source/blender/makesdna/DNA_mask_types.h index b34a6c9b12f..6c7f7aa2471 100644 --- a/source/blender/makesdna/DNA_mask_types.h +++ b/source/blender/makesdna/DNA_mask_types.h @@ -168,14 +168,15 @@ enum { /* masklay->blend */ enum { - MASK_BLEND_ADD = 0, - MASK_BLEND_SUBTRACT = 1, - MASK_BLEND_LIGHTEN = 2, - MASK_BLEND_DARKEN = 3, - MASK_BLEND_MUL = 4, - MASK_BLEND_REPLACE = 5, - MASK_BLEND_DIFFERENCE = 6, - MASK_BLEND_MERGE = 7 + MASK_BLEND_ADD = 0, + MASK_BLEND_SUBTRACT = 1, + MASK_BLEND_LIGHTEN = 2, + MASK_BLEND_DARKEN = 3, + MASK_BLEND_MUL = 4, + MASK_BLEND_REPLACE = 5, + MASK_BLEND_DIFFERENCE = 6, + MASK_BLEND_MERGE_ADD = 7, + MASK_BLEND_MERGE_SUBTRACT = 8 }; /* masklay->blend_flag */ diff --git a/source/blender/makesrna/intern/rna_mask.c b/source/blender/makesrna/intern/rna_mask.c index f197bf8391d..a6571a2db4f 100644 --- a/source/blender/makesrna/intern/rna_mask.c +++ b/source/blender/makesrna/intern/rna_mask.c @@ -580,7 +580,8 @@ static void rna_def_maskSpline(BlenderRNA *brna) static void rna_def_mask_layer(BlenderRNA *brna) { static EnumPropertyItem masklay_blend_mode_items[] = { - {MASK_BLEND_MERGE, "MERGE", 0, "Merge", ""}, + {MASK_BLEND_MERGE_ADD, "MERGE_ADD", 0, "Merge Add", ""}, + {MASK_BLEND_MERGE_SUBTRACT, "MERGE_SUBTRACT", 0, "Merge Subtract", ""}, {MASK_BLEND_ADD, "ADD", 0, "Add", ""}, {MASK_BLEND_SUBTRACT, "SUBTRACT", 0, "Subtract", ""}, {MASK_BLEND_LIGHTEN, "LIGHTEN", 0, "Lighten", ""}, From 10b983002f953f88ca84bc418d339a8096e3cef4 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 22 Aug 2012 13:03:54 +0000 Subject: [PATCH 069/163] fix for glitch with mask refresh in the image view when lock was disabled - it would never update the image, (now check G.moving) --- source/blender/editors/space_image/space_image.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/source/blender/editors/space_image/space_image.c b/source/blender/editors/space_image/space_image.c index 1f655884b73..d2639edb276 100644 --- a/source/blender/editors/space_image/space_image.c +++ b/source/blender/editors/space_image/space_image.c @@ -42,6 +42,7 @@ #include "BKE_colortools.h" #include "BKE_context.h" #include "BKE_image.h" +#include "BKE_global.h" #include "BKE_scene.h" #include "BKE_screen.h" #include "BKE_tessmesh.h" @@ -373,7 +374,10 @@ static void image_refresh(const bContext *C, ScrArea *sa) /* check if we have to set the image from the editmesh */ if (ima && (ima->source == IMA_SRC_VIEWER && sima->mode == SI_MODE_MASK)) { - if (sima->lock) { + if (sima->lock == FALSE && G.moving) { + /* pass */ + } + else { if (scene->nodetree) { Mask *mask = ED_space_image_get_mask(sima); if (mask) { From 61dddcb800963390b348c977d307bec3620a443a Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Wed, 22 Aug 2012 13:10:37 +0000 Subject: [PATCH 070/163] Fix part of #32377: TIFF not saving on windows to paths with special characters, and DDS should not be in the list of file types because we can only load those currently. --- source/blender/imbuf/intern/dds/dds_api.cpp | 15 +++++++++++++-- source/blender/imbuf/intern/tiff.c | 10 +++++++++- source/blender/makesrna/intern/rna_scene.c | 2 +- 3 files changed, 23 insertions(+), 4 deletions(-) diff --git a/source/blender/imbuf/intern/dds/dds_api.cpp b/source/blender/imbuf/intern/dds/dds_api.cpp index fba326f7865..1aaeb4766e1 100644 --- a/source/blender/imbuf/intern/dds/dds_api.cpp +++ b/source/blender/imbuf/intern/dds/dds_api.cpp @@ -32,6 +32,10 @@ #include // printf #include +#ifdef WIN32 +#include "utfconv.h" +#endif + extern "C" { #include "imbuf.h" @@ -39,7 +43,6 @@ extern "C" { #include "IMB_imbuf.h" #include "IMB_allocimbuf.h" - int imb_save_dds(struct ImBuf * ibuf, const char *name, int flags) { return(0); /* todo: finish this function */ @@ -49,7 +52,15 @@ int imb_save_dds(struct ImBuf * ibuf, const char *name, int flags) if (ibuf->rect == 0) return (0); /* open file for writing */ - std::ofstream fildes(name); + std::ofstream fildes; + +#ifdef WIN32 + wchar_t *wname = alloc_utf16_from_8(name, 0); + fildes.open(wname); + free(wname); +#else + fildes.open(name); +#endif /* write header */ fildes << "DDS "; diff --git a/source/blender/imbuf/intern/tiff.c b/source/blender/imbuf/intern/tiff.c index 985c575daaa..ac5f5da8a67 100644 --- a/source/blender/imbuf/intern/tiff.c +++ b/source/blender/imbuf/intern/tiff.c @@ -59,7 +59,9 @@ #include "tiffio.h" - +#ifdef WIN32 +#include "utfconv.h" +#endif /*********************** * Local declarations. * @@ -712,7 +714,13 @@ int imb_savetiff(ImBuf *ibuf, const char *name, int flags) } else { /* create image as a file */ +#ifdef WIN32 + wchar_t *wname = alloc_utf16_from_8(name, 0); + image = TIFFOpenW(wname, "w"); + free(wname); +#else image = TIFFOpen(name, "w"); +#endif } if (image == NULL) { fprintf(stderr, diff --git a/source/blender/makesrna/intern/rna_scene.c b/source/blender/makesrna/intern/rna_scene.c index 09099ca5d93..a6f3c0095b5 100644 --- a/source/blender/makesrna/intern/rna_scene.c +++ b/source/blender/makesrna/intern/rna_scene.c @@ -209,7 +209,7 @@ EnumPropertyItem snap_node_element_items[] = { #define IMAGE_TYPE_ITEMS_IMAGE_ONLY \ R_IMF_ENUM_BMP \ - R_IMF_ENUM_DDS \ + /* DDS save not supported yet R_IMF_ENUM_DDS */ \ R_IMF_ENUM_IRIS \ R_IMF_ENUM_PNG \ R_IMF_ENUM_JPEG \ From 97ee630dcd18d98bb04dbcef9fdfe6bcc897ce4b Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Wed, 22 Aug 2012 13:10:43 +0000 Subject: [PATCH 071/163] Fix #32201: particle size compatibility broken for object/group duplication. After 2.63 there was a bugfix to take object scale into account for the duplicated objects, but this breaks compatibility on earlier files. Now there is an option to control if the scale should be used or not. Scale is used by default on newer files, and not used on older ones. --- release/scripts/startup/bl_ui/properties_particle.py | 2 ++ source/blender/blenkernel/intern/anim.c | 12 ++++++++++++ source/blender/blenloader/intern/readfile.c | 7 +++++++ source/blender/makesdna/DNA_particle_types.h | 4 +++- source/blender/makesrna/intern/rna_particle.c | 5 +++++ 5 files changed, 29 insertions(+), 1 deletion(-) diff --git a/release/scripts/startup/bl_ui/properties_particle.py b/release/scripts/startup/bl_ui/properties_particle.py index 2c9bcefd2f8..aa0ea1d2d9e 100644 --- a/release/scripts/startup/bl_ui/properties_particle.py +++ b/release/scripts/startup/bl_ui/properties_particle.py @@ -849,6 +849,7 @@ class PARTICLE_PT_render(ParticleButtonsPanel, Panel): sub = col.row() sub.prop(part, "use_global_dupli") sub.prop(part, "use_rotation_dupli") + sub.prop(part, "use_scale_dupli") elif part.render_type == 'GROUP': col.prop(part, "dupli_group") split = layout.split() @@ -865,6 +866,7 @@ class PARTICLE_PT_render(ParticleButtonsPanel, Panel): sub.active = (part.use_whole_group is False) sub.prop(part, "use_global_dupli") sub.prop(part, "use_rotation_dupli") + sub.prop(part, "use_scale_dupli") if part.use_group_count and not part.use_whole_group: row = layout.row() diff --git a/source/blender/blenkernel/intern/anim.c b/source/blender/blenkernel/intern/anim.c index 33cdede6fce..6e857bacb1b 100644 --- a/source/blender/blenkernel/intern/anim.c +++ b/source/blender/blenkernel/intern/anim.c @@ -1469,6 +1469,18 @@ static void new_particle_duplilist(ListBase *lb, ID *id, Scene *scene, Object *p quat_to_mat4(obmat, q); obmat[3][3] = 1.0f; + /* add scaling if requested */ + if ((part->draw & PART_DRAW_NO_SCALE_OB) == 0) + mult_m4_m4m4(obmat, obmat, size_mat); + } + else if (part->draw & PART_DRAW_NO_SCALE_OB) { + /* remove scaling */ + float size_mat[4][4], original_size[3]; + + mat4_to_size(original_size, obmat); + size_to_mat4(size_mat, original_size); + invert_m4(size_mat); + mult_m4_m4m4(obmat, obmat, size_mat); } diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index 719081e378d..1956cfaedf0 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -7925,10 +7925,17 @@ static void do_versions(FileData *fd, Library *lib, Main *main) } if (main->versionfile < 263 || (main->versionfile == 263 && main->subversionfile < 14)) { + ParticleSettings *part; bNodeTreeType *ntreetype = ntreeGetType(NTREE_COMPOSIT); if (ntreetype && ntreetype->foreach_nodetree) ntreetype->foreach_nodetree(main, NULL, do_version_ntree_keying_despill_balance); + + /* keep compatibility for dupliobject particle size */ + for (part=main->particle.first; part; part=part->id.next) + if (ELEM(part->ren_as, PART_DRAW_OB, PART_DRAW_GR)) + if ((part->draw & PART_DRAW_ROTATE_OB) == 0) + part->draw |= PART_DRAW_NO_SCALE_OB; } if (main->versionfile < 263 || (main->versionfile == 263 && main->subversionfile < 17)) { diff --git a/source/blender/makesdna/DNA_particle_types.h b/source/blender/makesdna/DNA_particle_types.h index 0853df87a35..5952aa8afb0 100644 --- a/source/blender/makesdna/DNA_particle_types.h +++ b/source/blender/makesdna/DNA_particle_types.h @@ -154,7 +154,8 @@ typedef struct ParticleSettings { short type, from, distr, texact; /* physics modes */ short phystype, rotmode, avemode, reactevent; - short draw, draw_as, draw_size, childtype; + int draw, pad1; + short draw_as, draw_size, childtype, pad2; short ren_as, subframes, draw_col; /* number of path segments, power of 2 except */ short draw_step, ren_step; @@ -398,6 +399,7 @@ typedef struct ParticleSystem { #define PART_DRAW_MAT_COL (1<<13) /* deprecated, but used in do_versions */ #define PART_DRAW_WHOLE_GR (1<<14) #define PART_DRAW_REN_STRAND (1<<15) +#define PART_DRAW_NO_SCALE_OB (1<<16) /* used with dupliobjects/groups */ /* part->draw_col */ #define PART_DRAW_COL_NONE 0 diff --git a/source/blender/makesrna/intern/rna_particle.c b/source/blender/makesrna/intern/rna_particle.c index 8cf3b718c30..fc3dfafe133 100644 --- a/source/blender/makesrna/intern/rna_particle.c +++ b/source/blender/makesrna/intern/rna_particle.c @@ -1846,6 +1846,11 @@ static void rna_def_particle_settings(BlenderRNA *brna) "particle rotation axis)"); RNA_def_property_update(prop, 0, "rna_Particle_redo"); + prop = RNA_def_property(srna, "use_scale_dupli", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_negative_sdna(prop, NULL, "draw", PART_DRAW_NO_SCALE_OB); + RNA_def_property_ui_text(prop, "Scale", "Use object's scale for duplication"); + RNA_def_property_update(prop, 0, "rna_Particle_redo"); + prop = RNA_def_property(srna, "use_render_adaptive", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "draw", PART_DRAW_REN_ADAPT); RNA_def_property_ui_text(prop, "Adaptive render", "Draw steps of the particle path"); From 267f625179d09bd482a425764da596056b4cdca5 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 22 Aug 2012 13:34:06 +0000 Subject: [PATCH 072/163] lasso select works in the node editor again, Ctrl+Alt+LMB, Ctrl+Alt+Shif+LMB to deselect --- .../blender/editors/space_clip/tracking_ops.c | 1 - .../blender/editors/space_node/node_intern.h | 1 + source/blender/editors/space_node/node_ops.c | 6 ++ .../blender/editors/space_node/node_select.c | 91 ++++++++++++++++++- 4 files changed, 97 insertions(+), 2 deletions(-) diff --git a/source/blender/editors/space_clip/tracking_ops.c b/source/blender/editors/space_clip/tracking_ops.c index cbf05026152..97f7d7bf132 100644 --- a/source/blender/editors/space_clip/tracking_ops.c +++ b/source/blender/editors/space_clip/tracking_ops.c @@ -42,7 +42,6 @@ #include "BLI_math.h" #include "BLI_listbase.h" #include "BLI_rect.h" -#include "BLI_lasso.h" #include "BLI_blenlib.h" #include "BKE_main.h" diff --git a/source/blender/editors/space_node/node_intern.h b/source/blender/editors/space_node/node_intern.h index 048e09efab5..2bb550d1a63 100644 --- a/source/blender/editors/space_node/node_intern.h +++ b/source/blender/editors/space_node/node_intern.h @@ -107,6 +107,7 @@ void NODE_OT_select_all(wmOperatorType *ot); void NODE_OT_select_linked_to(wmOperatorType *ot); void NODE_OT_select_linked_from(wmOperatorType *ot); void NODE_OT_select_border(struct wmOperatorType *ot); +void NODE_OT_select_lasso(struct wmOperatorType *ot); void NODE_OT_select_same_type(struct wmOperatorType *ot); void NODE_OT_select_same_type_next(wmOperatorType *ot); void NODE_OT_select_same_type_prev(wmOperatorType *ot); diff --git a/source/blender/editors/space_node/node_ops.c b/source/blender/editors/space_node/node_ops.c index 195dd60b72a..a5032fb6465 100644 --- a/source/blender/editors/space_node/node_ops.c +++ b/source/blender/editors/space_node/node_ops.c @@ -55,6 +55,7 @@ void node_operatortypes(void) WM_operatortype_append(NODE_OT_select_linked_to); WM_operatortype_append(NODE_OT_select_linked_from); WM_operatortype_append(NODE_OT_select_border); + WM_operatortype_append(NODE_OT_select_lasso); WM_operatortype_append(NODE_OT_select_same_type); WM_operatortype_append(NODE_OT_select_same_type_next); WM_operatortype_append(NODE_OT_select_same_type_prev); @@ -217,6 +218,11 @@ void node_keymap(struct wmKeyConfig *keyconf) kmi = WM_keymap_add_item(keymap, "NODE_OT_select_border", EVT_TWEAK_S, KM_ANY, 0, 0); RNA_boolean_set(kmi->ptr, "tweak", TRUE); + kmi = WM_keymap_add_item(keymap, "NODE_OT_select_lasso", EVT_TWEAK_A, KM_ANY, KM_CTRL | KM_ALT, 0); + RNA_boolean_set(kmi->ptr, "deselect", FALSE); + kmi = WM_keymap_add_item(keymap, "NODE_OT_select_lasso", EVT_TWEAK_A, KM_ANY, KM_CTRL | KM_SHIFT | KM_ALT, 0); + RNA_boolean_set(kmi->ptr, "deselect", TRUE); + /* each of these falls through if not handled... */ WM_keymap_add_item(keymap, "NODE_OT_link", LEFTMOUSE, KM_PRESS, 0, 0); kmi = WM_keymap_add_item(keymap, "NODE_OT_link", LEFTMOUSE, KM_PRESS, KM_CTRL, 0); diff --git a/source/blender/editors/space_node/node_select.c b/source/blender/editors/space_node/node_select.c index 2f4e7648a5f..f41f203aefe 100644 --- a/source/blender/editors/space_node/node_select.c +++ b/source/blender/editors/space_node/node_select.c @@ -35,6 +35,7 @@ #include "BKE_node.h" #include "BLI_rect.h" +#include "BLI_lasso.h" #include "BLI_utildefines.h" #include "ED_node.h" /* own include */ @@ -48,7 +49,9 @@ #include "WM_types.h" #include "UI_view2d.h" - + +#include "MEM_guardedalloc.h" + #include "node_intern.h" /* own include */ /* ****** helpers ****** */ @@ -534,6 +537,92 @@ void NODE_OT_select_border(wmOperatorType *ot) RNA_def_boolean(ot->srna, "tweak", 0, "Tweak", "Only activate when mouse is not over a node - useful for tweak gesture"); } +/* ****** Lasso Select ****** */ + +static int do_lasso_select_node(bContext *C, int mcords[][2], short moves, short select) +{ + SpaceNode *snode = CTX_wm_space_node(C); + bNode *node; + + ARegion *ar = CTX_wm_region(C); + + rcti rect; + int change = FALSE; + + /* get rectangle from operator */ + BLI_lasso_boundbox(&rect, mcords, moves); + + /* do actual selection */ + for (node = snode->edittree->nodes.first; node; node = node->next) { + int screen_co[2]; + const float cent[2] = {BLI_RCT_CENTER_X(&node->totr), + BLI_RCT_CENTER_Y(&node->totr)}; + + /* marker in screen coords */ + UI_view2d_view_to_region(&ar->v2d, + cent[0], cent[1], + &screen_co[0], &screen_co[1]); + + if (BLI_in_rcti(&rect, screen_co[0], screen_co[1]) && + BLI_lasso_is_point_inside(mcords, moves, screen_co[0], screen_co[1], INT_MAX)) + { + if (select) + node_select(node); + else + node_deselect(node); + + change = TRUE; + } + } + + if (change) { + WM_event_add_notifier(C, NC_NODE | NA_SELECTED, NULL); + } + + return change; +} + +static int node_lasso_select_exec(bContext *C, wmOperator *op) +{ + int mcords_tot; + int (*mcords)[2] = WM_gesture_lasso_path_to_array(C, op, &mcords_tot); + + if (mcords) { + short select; + + select = !RNA_boolean_get(op->ptr, "deselect"); + do_lasso_select_node(C, mcords, mcords_tot, select); + + MEM_freeN(mcords); + + return OPERATOR_FINISHED; + } + return OPERATOR_PASS_THROUGH; +} + +void NODE_OT_select_lasso(wmOperatorType *ot) +{ + /* identifiers */ + ot->name = "Lasso Select"; + ot->description = "Select nodes using lasso selection"; + ot->idname = "NODE_OT_select_lasso"; + + /* api callbacks */ + ot->invoke = WM_gesture_lasso_invoke; + ot->modal = WM_gesture_lasso_modal; + ot->exec = node_lasso_select_exec; + ot->poll = ED_operator_node_active; + ot->cancel = WM_gesture_lasso_cancel; + + /* flags */ + ot->flag = OPTYPE_UNDO; + + /* properties */ + RNA_def_collection_runtime(ot->srna, "path", &RNA_OperatorMousePath, "Path", ""); + RNA_def_boolean(ot->srna, "deselect", 0, "Deselect", "Deselect rather than select items"); + RNA_def_boolean(ot->srna, "extend", 1, "Extend", "Extend selection instead of deselecting everything first"); +} + /* ****** Select/Deselect All ****** */ static int node_select_all_exec(bContext *C, wmOperator *op) From 0fbd15df0ffc7e14cba808df41e50d35e534a5a1 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Wed, 22 Aug 2012 13:45:20 +0000 Subject: [PATCH 073/163] Sequencer: fix for incorrect proxies rendering after some recent refactor --- source/blender/blenkernel/intern/sequencer.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/source/blender/blenkernel/intern/sequencer.c b/source/blender/blenkernel/intern/sequencer.c index 3699f802c91..17764fa9775 100644 --- a/source/blender/blenkernel/intern/sequencer.c +++ b/source/blender/blenkernel/intern/sequencer.c @@ -2565,7 +2565,8 @@ static ImBuf *seq_render_strip(SeqRenderData context, Sequence *seq, float cfra) is_proxy_image = (ibuf != NULL); } - ibuf = do_render_strip_uncached(context, seq, cfra); + if (ibuf == NULL) + ibuf = do_render_strip_uncached(context, seq, cfra); if (ibuf) BKE_sequencer_preprocessed_cache_put(context, seq, cfra, SEQ_STRIPELEM_IBUF, ibuf); From d3f1222d3809d7a893de4cee541e24b3636563c5 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Wed, 22 Aug 2012 14:27:06 +0000 Subject: [PATCH 074/163] Fix #32262: mesh bridge between edge loops failed to find a good edge matching in some cases, in particular when the the edge loops were not planar. Now rather than finding the shortest distance between two vertices, one from each edge loop and using that as a starting point, it now finds the smallest sum of distances between all vertex pairs that would be connected. --- source/blender/bmesh/operators/bmo_connect.c | 49 +++++++++----------- 1 file changed, 23 insertions(+), 26 deletions(-) diff --git a/source/blender/bmesh/operators/bmo_connect.c b/source/blender/bmesh/operators/bmo_connect.c index 7418be3565c..a9599a48589 100644 --- a/source/blender/bmesh/operators/bmo_connect.c +++ b/source/blender/bmesh/operators/bmo_connect.c @@ -370,39 +370,36 @@ void bmo_bridge_loops_exec(BMesh *bm, BMOperator *op) } } - /* Find the shortest distance from a vert in vv1 to vv2[0]. Use that - * vertex in vv1 as a starting point in the first loop, while starting - * from vv2[0] in the second loop. This is a simplistic attempt to get - * a better edge-to-edge match between the two loops. */ + /* Find the smallest sum of distances from verts in vv1 to verts in vv2, + * finding a starting point in the first loop, to start with vv2[0] in the + * second loop. This is a simplistic attempt to get a better edge-to-edge + * match between two loops. */ if (cl1) { - int previ, nexti; float min = 1e32; - /* BMESH_TODO: Would be nice to do a more thorough analysis of all - * the vertices in both loops to find a more accurate match for the - * starting point and winding direction of the bridge generation. */ - - for (i = 0; i < BLI_array_count(vv1); i++) { - if (len_v3v3(vv1[i]->co, vv2[0]->co) < min) { - min = len_v3v3(vv1[i]->co, vv2[0]->co); + for (i = 0; i < lenv1; i++) { + float len; + + /* compute summed length between vertices in forward direction */ + len = 0.0f; + for (j = 0; j < lenv2; j++) + len += len_v3v3(vv1[clamp_index(i+j, lenv1)]->co, vv2[j]->co); + + if (len < min) { + min = len; starti = i; } - } - /* Reverse iteration order for the first loop if the distance of - * the (starti - 1) vert from vv1 is a better match for vv2[1] than - * the (starti + 1) vert. - * - * This is not always going to be right, but it will work better in - * the average case. - */ - previ = clamp_index(starti - 1, lenv1); - nexti = clamp_index(starti + 1, lenv1); + /* compute summed length between vertices in backward direction */ + len = 0.0f; + for (j = 0; j < lenv2; j++) + len += len_v3v3(vv1[clamp_index(i-j, lenv1)]->co, vv2[j]->co); - /* avoid sqrt for comparison */ - if (len_squared_v3v3(vv1[nexti]->co, vv2[1]->co) > len_squared_v3v3(vv1[previ]->co, vv2[1]->co)) { - /* reverse direction for reading vv1 (1 is forward, -1 is backward) */ - dir1 = -1; + if (len < min) { + min = len; + starti = i; + dir1 = -1; + } } } From 7f9467098e349b69d8f14114aaf22f0df0d1daa9 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Wed, 22 Aug 2012 14:27:09 +0000 Subject: [PATCH 075/163] Fix #32309: missing shortcuts in sculpt mode Hide/Mask menu. Keymap poll was too strict, only has to check if we are in sculpt mode, not if the mouse is in the main region too. --- source/blender/editors/sculpt_paint/paint_ops.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/blender/editors/sculpt_paint/paint_ops.c b/source/blender/editors/sculpt_paint/paint_ops.c index 560174e73ae..104f727c603 100644 --- a/source/blender/editors/sculpt_paint/paint_ops.c +++ b/source/blender/editors/sculpt_paint/paint_ops.c @@ -624,7 +624,7 @@ void ED_keymap_paint(wmKeyConfig *keyconf) /* Sculpt mode */ keymap = WM_keymap_find(keyconf, "Sculpt", 0, 0); - keymap->poll = sculpt_poll; + keymap->poll = sculpt_mode_poll; RNA_enum_set(WM_keymap_add_item(keymap, "SCULPT_OT_brush_stroke", LEFTMOUSE, KM_PRESS, 0, 0)->ptr, "mode", BRUSH_STROKE_NORMAL); RNA_enum_set(WM_keymap_add_item(keymap, "SCULPT_OT_brush_stroke", LEFTMOUSE, KM_PRESS, KM_CTRL, 0)->ptr, "mode", BRUSH_STROKE_INVERT); From 3ec93e8c35030b97a5faf654ca5ccc003f1e724b Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 22 Aug 2012 15:04:11 +0000 Subject: [PATCH 076/163] doc type correction --- doc/python_api/rst/info_gotcha.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/python_api/rst/info_gotcha.rst b/doc/python_api/rst/info_gotcha.rst index eb312799b41..1d561216b52 100644 --- a/doc/python_api/rst/info_gotcha.rst +++ b/doc/python_api/rst/info_gotcha.rst @@ -137,11 +137,11 @@ For the time being this limitation just has to be worked around but we're aware NGons and Tessellation Faces ============================ -Since 2.63 NGons are supported, this adds some complexity since in some cases you need to access triangles still (some exporters for example). +Since 2.63 NGons are supported, this adds some complexity since in some cases you need to access triangles/quads still (some exporters for example). There are now 3 ways to access faces: -* :class:`bpy.types.MeshPolygon` - this is the data stricture which now stores faces in object mode (access as ``mesh.polygons`` rather then ``mesh.faces``). +* :class:`bpy.types.MeshPolygon` - this is the data structure which now stores faces in object mode (access as ``mesh.polygons`` rather then ``mesh.faces``). * :class:`bpy.types.MeshTessFace` - the result of triangulating (tessellated) polygons, the main method of face access in 2.62 or older (access as ``mesh.tessfaces``). * :class:`bmesh.types.BMFace` - the polygons as used in editmode. From 84e80b690472957035454071aa71c0382cccecc1 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Wed, 22 Aug 2012 15:10:07 +0000 Subject: [PATCH 077/163] Fix #32301: mesh select more/less not taking hidden vertices/faces into account. --- source/blender/bmesh/operators/bmo_utils.c | 34 ++++++++++++++-------- 1 file changed, 22 insertions(+), 12 deletions(-) diff --git a/source/blender/bmesh/operators/bmo_utils.c b/source/blender/bmesh/operators/bmo_utils.c index 1d73435032d..88ed1250264 100644 --- a/source/blender/bmesh/operators/bmo_utils.c +++ b/source/blender/bmesh/operators/bmo_utils.c @@ -182,14 +182,17 @@ static void bmo_region_extend_extend(BMesh *bm, BMOperator *op, int usefaces) if (!usefaces) { BMO_ITER (v, &siter, bm, op, "geom", BM_VERT) { BM_ITER_ELEM (e, &eiter, v, BM_EDGES_OF_VERT) { - if (!BMO_elem_flag_test(bm, e, SEL_ORIG)) - break; + if (!BM_elem_flag_test(e, BM_ELEM_HIDDEN)) + if (!BMO_elem_flag_test(bm, e, SEL_ORIG)) + break; } if (e) { BM_ITER_ELEM (e, &eiter, v, BM_EDGES_OF_VERT) { - BMO_elem_flag_enable(bm, e, SEL_FLAG); - BMO_elem_flag_enable(bm, BM_edge_other_vert(e, v), SEL_FLAG); + if (!BM_elem_flag_test(e, BM_ELEM_HIDDEN)) { + BMO_elem_flag_enable(bm, e, SEL_FLAG); + BMO_elem_flag_enable(bm, BM_edge_other_vert(e, v), SEL_FLAG); + } } } } @@ -202,8 +205,10 @@ static void bmo_region_extend_extend(BMesh *bm, BMOperator *op, int usefaces) BMO_ITER (f, &siter, bm, op, "geom", BM_FACE) { BM_ITER_ELEM (l, &liter, f, BM_LOOPS_OF_FACE) { BM_ITER_ELEM (f2, &fiter, l->e, BM_FACES_OF_EDGE) { - if (!BMO_elem_flag_test(bm, f2, SEL_ORIG)) { - BMO_elem_flag_enable(bm, f2, SEL_FLAG); + if (!BM_elem_flag_test(f2, BM_ELEM_HIDDEN)) { + if (!BMO_elem_flag_test(bm, f2, SEL_ORIG)) { + BMO_elem_flag_enable(bm, f2, SEL_FLAG); + } } } } @@ -221,15 +226,18 @@ static void bmo_region_extend_constrict(BMesh *bm, BMOperator *op, int usefaces) if (!usefaces) { BMO_ITER (v, &siter, bm, op, "geom", BM_VERT) { BM_ITER_ELEM (e, &eiter, v, BM_EDGES_OF_VERT) { - if (!BMO_elem_flag_test(bm, e, SEL_ORIG)) - break; + if (!BM_elem_flag_test(e, BM_ELEM_HIDDEN)) + if (!BMO_elem_flag_test(bm, e, SEL_ORIG)) + break; } if (e) { BMO_elem_flag_enable(bm, v, SEL_FLAG); BM_ITER_ELEM (e, &eiter, v, BM_EDGES_OF_VERT) { - BMO_elem_flag_enable(bm, e, SEL_FLAG); + if (!BM_elem_flag_test(e, BM_ELEM_HIDDEN)) { + BMO_elem_flag_enable(bm, e, SEL_FLAG); + } } } @@ -243,9 +251,11 @@ static void bmo_region_extend_constrict(BMesh *bm, BMOperator *op, int usefaces) BMO_ITER (f, &siter, bm, op, "geom", BM_FACE) { BM_ITER_ELEM (l, &liter, f, BM_LOOPS_OF_FACE) { BM_ITER_ELEM (f2, &fiter, l->e, BM_FACES_OF_EDGE) { - if (!BMO_elem_flag_test(bm, f2, SEL_ORIG)) { - BMO_elem_flag_enable(bm, f, SEL_FLAG); - break; + if (!BM_elem_flag_test(f2, BM_ELEM_HIDDEN)) { + if (!BMO_elem_flag_test(bm, f2, SEL_ORIG)) { + BMO_elem_flag_enable(bm, f, SEL_FLAG); + break; + } } } } From 6143acf8784bdb89c9b93c04c93c1ef0ca6e97e3 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 22 Aug 2012 15:38:03 +0000 Subject: [PATCH 078/163] hook menu was using last remembered use_bone setting --- release/scripts/startup/bl_ui/space_view3d.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/release/scripts/startup/bl_ui/space_view3d.py b/release/scripts/startup/bl_ui/space_view3d.py index d81f53d4fa6..5db103466a9 100644 --- a/release/scripts/startup/bl_ui/space_view3d.py +++ b/release/scripts/startup/bl_ui/space_view3d.py @@ -1182,7 +1182,7 @@ class VIEW3D_MT_hook(Menu): layout = self.layout layout.operator_context = 'EXEC_AREA' layout.operator("object.hook_add_newob") - layout.operator("object.hook_add_selob") + layout.operator("object.hook_add_selob").use_bone = False layout.operator("object.hook_add_selob", text="Hook to Selected Object Bone").use_bone = True if [mod.type == 'HOOK' for mod in context.active_object.modifiers]: From 1939baa47d6d6cd6cedb7440bc7b8e988fe6c702 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 22 Aug 2012 16:44:32 +0000 Subject: [PATCH 079/163] style cleanup --- source/blender/editors/interface/interface.c | 2 + .../blender/editors/space_logic/space_logic.c | 48 +++++++++---------- source/blender/editors/space_node/drawnode.c | 8 ++-- source/blender/editors/space_node/node_add.c | 4 +- source/blender/editors/space_node/node_draw.c | 4 +- source/blender/editors/space_node/node_edit.c | 4 +- .../editors/space_node/node_relationships.c | 7 +-- source/blender/editors/transform/transform.c | 2 + source/blender/editors/uvedit/uvedit_ops.c | 4 +- .../imbuf/intern/openexr/openexr_api.cpp | 5 +- source/blender/makesrna/intern/rna_nodetree.c | 6 +-- .../blender/makesrna/intern/rna_sequencer.c | 2 +- source/blender/python/bmesh/bmesh_py_types.c | 2 + source/blender/python/intern/bpy_operator.c | 2 + 14 files changed, 55 insertions(+), 45 deletions(-) diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c index 10917f23cdd..37a110ba33b 100644 --- a/source/blender/editors/interface/interface.c +++ b/source/blender/editors/interface/interface.c @@ -3814,7 +3814,9 @@ void uiButGetStrInfo(bContext *C, uiBut *but, int nbr, ...) if (WM_key_event_operator_string(C, but->optype->idname, but->opcontext, prop, TRUE, buf, sizeof(buf))) + { tmp = BLI_strdup(buf); + } } } diff --git a/source/blender/editors/space_logic/space_logic.c b/source/blender/editors/space_logic/space_logic.c index 1caf1075ae6..1a50f72153a 100644 --- a/source/blender/editors/space_logic/space_logic.c +++ b/source/blender/editors/space_logic/space_logic.c @@ -302,48 +302,48 @@ static void logic_header_area_draw(const bContext *C, ARegion *ar) /* only called once, from space/spacetypes.c */ void ED_spacetype_logic(void) { - SpaceType *st= MEM_callocN(sizeof(SpaceType), "spacetype logic"); + SpaceType *st = MEM_callocN(sizeof(SpaceType), "spacetype logic"); ARegionType *art; - st->spaceid= SPACE_LOGIC; + st->spaceid = SPACE_LOGIC; strncpy(st->name, "Logic", BKE_ST_MAXNAME); - st->new= logic_new; - st->free= logic_free; - st->init= logic_init; - st->duplicate= logic_duplicate; - st->operatortypes= logic_operatortypes; - st->keymap= logic_keymap; - st->refresh= logic_refresh; - st->context= logic_context; + st->new = logic_new; + st->free = logic_free; + st->init = logic_init; + st->duplicate = logic_duplicate; + st->operatortypes = logic_operatortypes; + st->keymap = logic_keymap; + st->refresh = logic_refresh; + st->context = logic_context; /* regions: main window */ - art= MEM_callocN(sizeof(ARegionType), "spacetype logic region"); + art = MEM_callocN(sizeof(ARegionType), "spacetype logic region"); art->regionid = RGN_TYPE_WINDOW; - art->keymapflag= ED_KEYMAP_UI|ED_KEYMAP_FRAMES|ED_KEYMAP_VIEW2D; - art->init= logic_main_area_init; - art->draw= logic_main_area_draw; - art->listener= logic_listener; + art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_FRAMES | ED_KEYMAP_VIEW2D; + art->init = logic_main_area_init; + art->draw = logic_main_area_draw; + art->listener = logic_listener; BLI_addhead(&st->regiontypes, art); /* regions: listview/buttons */ - art= MEM_callocN(sizeof(ARegionType), "spacetype logic region"); + art = MEM_callocN(sizeof(ARegionType), "spacetype logic region"); art->regionid = RGN_TYPE_UI; art->prefsizex= 220; // XXX - art->keymapflag= ED_KEYMAP_UI|ED_KEYMAP_FRAMES; - art->listener= logic_listener; - art->init= logic_buttons_area_init; - art->draw= logic_buttons_area_draw; + art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_FRAMES; + art->listener = logic_listener; + art->init = logic_buttons_area_init; + art->draw = logic_buttons_area_draw; BLI_addhead(&st->regiontypes, art); /* regions: header */ art= MEM_callocN(sizeof(ARegionType), "spacetype logic region"); art->regionid = RGN_TYPE_HEADER; - art->prefsizey= HEADERY; - art->keymapflag= ED_KEYMAP_UI|ED_KEYMAP_VIEW2D|ED_KEYMAP_FRAMES|ED_KEYMAP_HEADER; - art->init= logic_header_area_init; - art->draw= logic_header_area_draw; + art->prefsizey = HEADERY; + art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_VIEW2D | ED_KEYMAP_FRAMES | ED_KEYMAP_HEADER; + art->init = logic_header_area_init; + art->draw = logic_header_area_draw; BLI_addhead(&st->regiontypes, art); diff --git a/source/blender/editors/space_node/drawnode.c b/source/blender/editors/space_node/drawnode.c index 2816b55651f..c1a410317b7 100644 --- a/source/blender/editors/space_node/drawnode.c +++ b/source/blender/editors/space_node/drawnode.c @@ -857,13 +857,13 @@ static void node_draw_group(const bContext *C, ARegion *ar, SpaceNode *snode, bN while (gsock && (!sock || sock->groupsock != gsock)) { draw_group_socket(C, snode, ntree, gnode, NULL, gsock, index, SOCK_IN); gsock = gsock->next; - ++index; + index++; } while (sock && gsock && sock->groupsock == gsock) { draw_group_socket(C, snode, ntree, gnode, sock, gsock, index, SOCK_IN); sock = sock->next; gsock = gsock->next; - ++index; + index++; } } gsock = ngroup->outputs.first; @@ -877,13 +877,13 @@ static void node_draw_group(const bContext *C, ARegion *ar, SpaceNode *snode, bN while (gsock && (!sock || sock->groupsock != gsock)) { draw_group_socket(C, snode, ntree, gnode, NULL, gsock, index, SOCK_OUT); gsock = gsock->next; - ++index; + index++; } while (sock && gsock && sock->groupsock == gsock) { draw_group_socket(C, snode, ntree, gnode, sock, gsock, index, SOCK_OUT); sock = sock->next; gsock = gsock->next; - ++index; + index++; } } diff --git a/source/blender/editors/space_node/node_add.c b/source/blender/editors/space_node/node_add.c index 7d007d024ab..99d49fa1e8f 100644 --- a/source/blender/editors/space_node/node_add.c +++ b/source/blender/editors/space_node/node_add.c @@ -25,7 +25,7 @@ * ***** END GPL LICENSE BLOCK ***** */ -/** \file blender/editors/space_node/node_relationships.c +/** \file blender/editors/space_node/node_add.c * \ingroup spnode */ @@ -360,7 +360,7 @@ static int new_node_tree_exec(bContext *C, wmOperator *op) /* RNA_property_pointer_set increases the user count, * fixed here as the editor is the initial user. */ - --ntree->id.us; + ntree->id.us++; RNA_property_update(C, &ptr, prop); } else if (snode) { diff --git a/source/blender/editors/space_node/node_draw.c b/source/blender/editors/space_node/node_draw.c index a3d7785d550..0f559b0cbfc 100644 --- a/source/blender/editors/space_node/node_draw.c +++ b/source/blender/editors/space_node/node_draw.c @@ -226,12 +226,12 @@ void ED_node_sort(bNodeTree *ntree) while (a < k && b < k && node_b) { if (compare_nodes(node_a, node_b) == 0) { node_a = node_a->next; - ++a; + a++; } else { tmp = node_b; node_b = node_b->next; - ++b; + b++; BLI_remlink(&ntree->nodes, tmp); BLI_insertlinkbefore(&ntree->nodes, node_a, tmp); } diff --git a/source/blender/editors/space_node/node_edit.c b/source/blender/editors/space_node/node_edit.c index 4423b340d77..382c02c8765 100644 --- a/source/blender/editors/space_node/node_edit.c +++ b/source/blender/editors/space_node/node_edit.c @@ -1838,7 +1838,7 @@ static int node_output_file_move_active_socket_exec(bContext *C, wmOperator *op) return OPERATOR_CANCELLED; BLI_remlink(&node->inputs, sock); BLI_insertlinkbefore(&node->inputs, before, sock); - --nimf->active_input; + nimf->active_input--; } else { bNodeSocket *after = sock->next; @@ -1846,7 +1846,7 @@ static int node_output_file_move_active_socket_exec(bContext *C, wmOperator *op) return OPERATOR_CANCELLED; BLI_remlink(&node->inputs, sock); BLI_insertlinkafter(&node->inputs, after, sock); - ++nimf->active_input; + nimf->active_input++; } snode_notify(C, snode); diff --git a/source/blender/editors/space_node/node_relationships.c b/source/blender/editors/space_node/node_relationships.c index 6295a568113..f5a65065895 100644 --- a/source/blender/editors/space_node/node_relationships.c +++ b/source/blender/editors/space_node/node_relationships.c @@ -224,8 +224,9 @@ static void snode_autoconnect(SpaceNode *snode, int allow_multiple, int replace) if (!sock_fr) continue; - if (snode_autoconnect_input(snode, node_fr, sock_fr, node_to, sock_to, replace)) - ++numlinks; + if (snode_autoconnect_input(snode, node_fr, sock_fr, node_to, sock_to, replace)) { + numlinks++; + } } } @@ -246,7 +247,7 @@ static void snode_autoconnect(SpaceNode *snode, int allow_multiple, int replace) continue; if (snode_autoconnect_input(snode, node_fr, sock_fr, node_to, sock_to, replace)) { - ++numlinks; + numlinks++; break; } } diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c index 6b6da99cf39..284c670fa08 100644 --- a/source/blender/editors/transform/transform.c +++ b/source/blender/editors/transform/transform.c @@ -4978,7 +4978,9 @@ static int createSlideVerts(TransInfo *t) /* This test is only relevant if object is not wire-drawn! See [#32068]. */ if (v3d && t->obedit->dt > OB_WIRE && v3d->drawtype > OB_WIRE && !BMBVH_EdgeVisible(btree, e2, ar, v3d, t->obedit)) + { continue; + } j = GET_INT_FROM_POINTER(BLI_smallhash_lookup(&table, (uintptr_t)v)); diff --git a/source/blender/editors/uvedit/uvedit_ops.c b/source/blender/editors/uvedit/uvedit_ops.c index 54c5cbfce93..d3336d105c4 100644 --- a/source/blender/editors/uvedit/uvedit_ops.c +++ b/source/blender/editors/uvedit/uvedit_ops.c @@ -205,8 +205,8 @@ void ED_uvedit_assign_image(Main *bmain, Scene *scene, Object *obedit, Image *im ED_image_get_uv_aspect(previma, prev_aspect, prev_aspect + 1); ED_image_get_uv_aspect(ima, aspect, aspect + 1); - fprev_aspect = prev_aspect[0]/prev_aspect[1]; - faspect = aspect[0]/aspect[1]; + fprev_aspect = prev_aspect[0] / prev_aspect[1]; + faspect = aspect[0] / aspect[1]; #endif /* ensure we have a uv map */ diff --git a/source/blender/imbuf/intern/openexr/openexr_api.cpp b/source/blender/imbuf/intern/openexr/openexr_api.cpp index b66a7449781..91876249bf6 100644 --- a/source/blender/imbuf/intern/openexr/openexr_api.cpp +++ b/source/blender/imbuf/intern/openexr/openexr_api.cpp @@ -728,8 +728,9 @@ static int imb_exr_split_token(const char *str, const char *end, const char **to { int maxlen = end - str; int len = 0; - while (len < maxlen && *(end - len - 1) != '.') - ++len; + while (len < maxlen && *(end - len - 1) != '.') { + len++; + } *token = end - len; return len; diff --git a/source/blender/makesrna/intern/rna_nodetree.c b/source/blender/makesrna/intern/rna_nodetree.c index 27201ea6389..6a732cc2649 100644 --- a/source/blender/makesrna/intern/rna_nodetree.c +++ b/source/blender/makesrna/intern/rna_nodetree.c @@ -3711,7 +3711,7 @@ static void def_cmp_keying(StructRNA *srna) RNA_def_property_float_sdna(prop, NULL, "clip_white"); RNA_def_property_range(prop, 0.0f, 1.0f); RNA_def_property_ui_text(prop, "Clip White", "Value of non-scaled matte pixel which considers as fully foreground pixel"); - RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update"); + RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update"); prop = RNA_def_property(srna, "blur_pre", PROP_INT, PROP_NONE); RNA_def_property_int_sdna(prop, NULL, "blur_pre"); @@ -3790,12 +3790,12 @@ static void def_cmp_trackpos(StructRNA *srna) prop = RNA_def_property(srna, "tracking_object", PROP_STRING, PROP_NONE); RNA_def_property_string_sdna(prop, NULL, "tracking_object"); RNA_def_property_ui_text(prop, "Tracking Object", ""); - RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update"); + RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update"); prop = RNA_def_property(srna, "track_name", PROP_STRING, PROP_NONE); RNA_def_property_string_sdna(prop, NULL, "track_name"); RNA_def_property_ui_text(prop, "Track", ""); - RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update"); + RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update"); } /* -- Texture Nodes --------------------------------------------------------- */ diff --git a/source/blender/makesrna/intern/rna_sequencer.c b/source/blender/makesrna/intern/rna_sequencer.c index e14c1db8a76..3e841f81450 100644 --- a/source/blender/makesrna/intern/rna_sequencer.c +++ b/source/blender/makesrna/intern/rna_sequencer.c @@ -62,7 +62,7 @@ typedef struct EffectInfo { EnumPropertyItem sequence_modifier_type_items[] = { {seqModifierType_ColorBalance, "COLOR_BALANCE", ICON_NONE, "Color Balance", ""}, {seqModifierType_Curves, "CURVES", ICON_NONE, "Curves", ""}, - {seqModifierType_HueCorrect,"HUE_CORRECT", ICON_NONE, "Hue Correct", ""}, + {seqModifierType_HueCorrect, "HUE_CORRECT", ICON_NONE, "Hue Correct", ""}, {0, NULL, 0, NULL, NULL} }; diff --git a/source/blender/python/bmesh/bmesh_py_types.c b/source/blender/python/bmesh/bmesh_py_types.c index 9270aec8d95..24e7cd575ed 100644 --- a/source/blender/python/bmesh/bmesh_py_types.c +++ b/source/blender/python/bmesh/bmesh_py_types.c @@ -2159,7 +2159,9 @@ static PyObject *bpy_bmelemseq_sort(BPy_BMElemSeq *self, PyObject *args, PyObjec "|Oi:BMElemSeq.sort", (char **)kwlist, &keyfunc, &reverse)) + { return NULL; + } } if (keyfunc != NULL && !PyCallable_Check(keyfunc)) { diff --git a/source/blender/python/intern/bpy_operator.c b/source/blender/python/intern/bpy_operator.c index 90ea589fde4..55ef217e781 100644 --- a/source/blender/python/intern/bpy_operator.c +++ b/source/blender/python/intern/bpy_operator.c @@ -160,7 +160,9 @@ static PyObject *pyop_call(PyObject *UNUSED(self), PyObject *args) if (!PyArg_ParseTuple(args, "sO|O!si:_bpy.ops.call", &opname, &context_dict, &PyDict_Type, &kw, &context_str, &is_undo)) + { return NULL; + } ot = WM_operatortype_find(opname, TRUE); From b0dd030ba61fe81914d14e520f710684a2406900 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Wed, 22 Aug 2012 17:22:04 +0000 Subject: [PATCH 080/163] Fixed regression introduced in 50107 Shader preview job localizes material without referencing it as a user, so don't need to unreference itself as a user from this material. Added BKE_material_free_ex function which could skip user dereferencing. This also removed old hack with mtex users. --- source/blender/blenkernel/BKE_material.h | 1 + source/blender/blenkernel/intern/material.c | 10 ++++++++-- source/blender/editors/render/render_preview.c | 9 +-------- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/source/blender/blenkernel/BKE_material.h b/source/blender/blenkernel/BKE_material.h index 030af85ba84..dd1b1a7752b 100644 --- a/source/blender/blenkernel/BKE_material.h +++ b/source/blender/blenkernel/BKE_material.h @@ -48,6 +48,7 @@ struct Scene; void init_def_material(void); void BKE_material_free(struct Material *sc); +void BKE_material_free_ex(struct Material *ma, int do_id_user); void test_object_materials(struct ID *id); void resize_object_material(struct Object *ob, const short totcol); void init_material(struct Material *ma); diff --git a/source/blender/blenkernel/intern/material.c b/source/blender/blenkernel/intern/material.c index 8a26a1b52c5..fd167c69e62 100644 --- a/source/blender/blenkernel/intern/material.c +++ b/source/blender/blenkernel/intern/material.c @@ -79,13 +79,19 @@ void init_def_material(void) /* not material itself */ void BKE_material_free(Material *ma) +{ + BKE_material_free_ex(ma, TRUE); +} + +/* not material itself */ +void BKE_material_free_ex(Material *ma, int do_id_user) { MTex *mtex; int a; for (a = 0; a < MAX_MTEX; a++) { mtex = ma->mtex[a]; - if (mtex && mtex->tex) mtex->tex->id.us--; + if (do_id_user && mtex && mtex->tex) mtex->tex->id.us--; if (mtex) MEM_freeN(mtex); } @@ -101,7 +107,7 @@ void BKE_material_free(Material *ma) /* is no lib link block, but material extension */ if (ma->nodetree) { - ntreeFreeTree(ma->nodetree); + ntreeFreeTree_ex(ma->nodetree, do_id_user); MEM_freeN(ma->nodetree); } diff --git a/source/blender/editors/render/render_preview.c b/source/blender/editors/render/render_preview.c index 84319061d52..add2cbd566b 100644 --- a/source/blender/editors/render/render_preview.c +++ b/source/blender/editors/render/render_preview.c @@ -749,7 +749,6 @@ static void shader_preview_free(void *customdata) if (sp->matcopy) { struct IDProperty *properties; - int a; /* node previews */ shader_preview_updatejob(sp); @@ -757,13 +756,7 @@ static void shader_preview_free(void *customdata) /* get rid of copied material */ BLI_remlink(&pr_main->mat, sp->matcopy); - /* BKE_material_free decrements texture, prevent this. hack alert! */ - for (a = 0; a < MAX_MTEX; a++) { - MTex *mtex = sp->matcopy->mtex[a]; - if (mtex && mtex->tex) mtex->tex = NULL; - } - - BKE_material_free(sp->matcopy); + BKE_material_free_ex(sp->matcopy, FALSE); properties = IDP_GetProperties((ID *)sp->matcopy, FALSE); if (properties) { From 7683f87f273884ffc918377608526565c0eb693b Mon Sep 17 00:00:00 2001 From: Antony Riakiotakis Date: Wed, 22 Aug 2012 19:01:09 +0000 Subject: [PATCH 081/163] Fix compilation on MinGW after recent utf 16 fixes (possibly win32 too). gcc ostream does not support wchar_t, I hope it works as expected with unicode filenames. --- source/blender/imbuf/intern/dds/CMakeLists.txt | 1 + source/blender/imbuf/intern/dds/SConscript | 3 ++- source/blender/imbuf/intern/dds/dds_api.cpp | 4 ++-- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/source/blender/imbuf/intern/dds/CMakeLists.txt b/source/blender/imbuf/intern/dds/CMakeLists.txt index ae5f1ca9d09..e514b7ab6f9 100644 --- a/source/blender/imbuf/intern/dds/CMakeLists.txt +++ b/source/blender/imbuf/intern/dds/CMakeLists.txt @@ -31,6 +31,7 @@ set(INC ../../../blenlib ../../../makesdna ../../../../../intern/guardedalloc + ../../../../../intern/utfconv ) set(INC_SYS diff --git a/source/blender/imbuf/intern/dds/SConscript b/source/blender/imbuf/intern/dds/SConscript index 918ae7b530b..4245f5001b9 100644 --- a/source/blender/imbuf/intern/dds/SConscript +++ b/source/blender/imbuf/intern/dds/SConscript @@ -11,7 +11,8 @@ incs = ['.', '../../../blenkernel', '../../../blenlib', 'intern/include', - '#/intern/guardedalloc'] + '#/intern/guardedalloc', + '#/intern/utfconv'] defs = ['WITH_DDS'] diff --git a/source/blender/imbuf/intern/dds/dds_api.cpp b/source/blender/imbuf/intern/dds/dds_api.cpp index 1aaeb4766e1..71313d4438f 100644 --- a/source/blender/imbuf/intern/dds/dds_api.cpp +++ b/source/blender/imbuf/intern/dds/dds_api.cpp @@ -32,7 +32,7 @@ #include // printf #include -#ifdef WIN32 +#if defined (WIN32) && !defined(FREE_WINDOWS) #include "utfconv.h" #endif @@ -54,7 +54,7 @@ int imb_save_dds(struct ImBuf * ibuf, const char *name, int flags) /* open file for writing */ std::ofstream fildes; -#ifdef WIN32 +#if defined (WIN32) && !defined(FREE_WINDOWS) wchar_t *wname = alloc_utf16_from_8(name, 0); fildes.open(wname); free(wname); From c0c575751d27198fc5bda18f0d51fafca4c3a967 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 23 Aug 2012 04:55:59 +0000 Subject: [PATCH 082/163] bmesh tool: support for merged-bridge (like bridge, collapsing), with a factor to blend between loops. --- source/blender/bmesh/intern/bmesh_opdefines.c | 2 + source/blender/bmesh/operators/bmo_connect.c | 140 ++++++++++++------ source/blender/editors/mesh/editmesh_tools.c | 9 +- 3 files changed, 102 insertions(+), 49 deletions(-) diff --git a/source/blender/bmesh/intern/bmesh_opdefines.c b/source/blender/bmesh/intern/bmesh_opdefines.c index eacee8e12ad..986c84b0639 100644 --- a/source/blender/bmesh/intern/bmesh_opdefines.c +++ b/source/blender/bmesh/intern/bmesh_opdefines.c @@ -422,6 +422,8 @@ static BMOpDefine bmo_bridge_loops_def = { "bridge_loops", {{BMO_OP_SLOT_ELEMENT_BUF, "edges"}, /* input edge */ {BMO_OP_SLOT_ELEMENT_BUF, "faceout"}, /* new face */ + {BMO_OP_SLOT_BOOL, "use_merge"}, + {BMO_OP_SLOT_FLT, "merge_factor"}, {0, /* null-terminating sentinel */}}, bmo_bridge_loops_exec, 0, diff --git a/source/blender/bmesh/operators/bmo_connect.c b/source/blender/bmesh/operators/bmo_connect.c index a9599a48589..055e61596ee 100644 --- a/source/blender/bmesh/operators/bmo_connect.c +++ b/source/blender/bmesh/operators/bmo_connect.c @@ -223,6 +223,10 @@ void bmo_bridge_loops_exec(BMesh *bm, BMOperator *op) BMEdge *e, *nexte; int c = 0, cl1 = 0, cl2 = 0; + /* merge-bridge support */ + const int use_merge = BMO_slot_bool_get(op, "use_merge"); + const float merge_factor = BMO_slot_float_get(op, "merge_factor"); + BMO_slot_buffer_flag_enable(bm, op, "edges", BM_EDGE, EDGE_MARK); BMO_ITER (e, &siter, bm, op, "edges", BM_EDGE) { @@ -423,59 +427,99 @@ void bmo_bridge_loops_exec(BMesh *bm, BMOperator *op) } } - /* Generate the bridge quads */ - for (i = 0; i < BLI_array_count(ee1) && i < BLI_array_count(ee2); i++) { - BMFace *f; + /* merge loops of bridge faces */ + if (use_merge) { + /* at the moment these will be the same */ + const int vert_len = mini(BLI_array_count(vv1), BLI_array_count(vv2)); + const int edge_len = mini(BLI_array_count(ee1), BLI_array_count(ee2)); - BMLoop *l_1 = NULL; - BMLoop *l_2 = NULL; - BMLoop *l_1_next = NULL; - BMLoop *l_2_next = NULL; - BMLoop *l_iter; - BMFace *f_example; - - int i1, i1next, i2, i2next; - - i1 = clamp_index(i * dir1 + starti, lenv1); - i1next = clamp_index((i + 1) * dir1 + starti, lenv1); - i2 = i; - i2next = clamp_index(i + 1, lenv2); - - if (vv1[i1] == vv1[i1next]) { - continue; + if (merge_factor <= 0.0f) { + /* 2 --> 1 */ + for (i = 0; i < vert_len; i++) { + BM_vert_splice(bm, vv2[i], vv1[i]); + } + for (i = 0; i < edge_len; i++) { + BM_edge_splice(bm, ee2[i], ee1[i]); + } } - - if (wdir < 0) { - SWAP(int, i1, i1next); - SWAP(int, i2, i2next); - } - - /* get loop data - before making the face */ - bm_vert_loop_pair(bm, vv1[i1], vv2[i2], &l_1, &l_2); - bm_vert_loop_pair(bm, vv1[i1next], vv2[i2next], &l_1_next, &l_2_next); - /* copy if loop data if its is missing on one ring */ - if (l_1 && l_1_next == NULL) l_1_next = l_1; - if (l_1_next && l_1 == NULL) l_1 = l_1_next; - if (l_2 && l_2_next == NULL) l_2_next = l_2; - if (l_2_next && l_2 == NULL) l_2 = l_2_next; - f_example = l_1 ? l_1->f : (l_2 ? l_2->f : NULL); - - f = BM_face_create_quad_tri(bm, - vv1[i1], - vv2[i2], - vv2[i2next], - vv1[i1next], - f_example, TRUE); - if (!f || f->len != 4) { - fprintf(stderr, "%s: in bridge! (bmesh internal error)\n", __func__); + else if (merge_factor >= 1.0f) { + /* 1 --> 2 */ + for (i = 0; i < vert_len; i++) { + BM_vert_splice(bm, vv1[i], vv2[i]); + } + for (i = 0; i < edge_len; i++) { + BM_edge_splice(bm, ee1[i], ee2[i]); + } } else { - l_iter = BM_FACE_FIRST_LOOP(f); + /* mid factor, be tricky */ + /* 1 --> 2 */ + for (i = 0; i < vert_len; i++) { + BM_data_interp_from_verts(bm, vv1[i], vv2[i], vv2[i], merge_factor); + interp_v3_v3v3(vv2[i]->co, vv1[i]->co, vv2[i]->co, merge_factor); + BM_vert_splice(bm, vv1[i], vv2[i]); + } + for (i = 0; i < edge_len; i++) { + //BM_data_interp_from_edge(bm, vv1[i], vv2[i], vv2[i], merge_factor); + BM_edge_splice(bm, ee1[i], ee2[i]); + } + } + } + else { + /* Generate the bridge quads */ + for (i = 0; i < BLI_array_count(ee1) && i < BLI_array_count(ee2); i++) { + BMFace *f; - if (l_1) BM_elem_attrs_copy(bm, bm, l_1, l_iter); l_iter = l_iter->next; - if (l_2) BM_elem_attrs_copy(bm, bm, l_2, l_iter); l_iter = l_iter->next; - if (l_2_next) BM_elem_attrs_copy(bm, bm, l_2_next, l_iter); l_iter = l_iter->next; - if (l_1_next) BM_elem_attrs_copy(bm, bm, l_1_next, l_iter); + BMLoop *l_1 = NULL; + BMLoop *l_2 = NULL; + BMLoop *l_1_next = NULL; + BMLoop *l_2_next = NULL; + BMLoop *l_iter; + BMFace *f_example; + + int i1, i1next, i2, i2next; + + i1 = clamp_index(i * dir1 + starti, lenv1); + i1next = clamp_index((i + 1) * dir1 + starti, lenv1); + i2 = i; + i2next = clamp_index(i + 1, lenv2); + + if (vv1[i1] == vv1[i1next]) { + continue; + } + + if (wdir < 0) { + SWAP(int, i1, i1next); + SWAP(int, i2, i2next); + } + + /* get loop data - before making the face */ + bm_vert_loop_pair(bm, vv1[i1], vv2[i2], &l_1, &l_2); + bm_vert_loop_pair(bm, vv1[i1next], vv2[i2next], &l_1_next, &l_2_next); + /* copy if loop data if its is missing on one ring */ + if (l_1 && l_1_next == NULL) l_1_next = l_1; + if (l_1_next && l_1 == NULL) l_1 = l_1_next; + if (l_2 && l_2_next == NULL) l_2_next = l_2; + if (l_2_next && l_2 == NULL) l_2 = l_2_next; + f_example = l_1 ? l_1->f : (l_2 ? l_2->f : NULL); + + f = BM_face_create_quad_tri(bm, + vv1[i1], + vv2[i2], + vv2[i2next], + vv1[i1next], + f_example, TRUE); + if (!f || f->len != 4) { + fprintf(stderr, "%s: in bridge! (bmesh internal error)\n", __func__); + } + else { + l_iter = BM_FACE_FIRST_LOOP(f); + + if (l_1) BM_elem_attrs_copy(bm, bm, l_1, l_iter); l_iter = l_iter->next; + if (l_2) BM_elem_attrs_copy(bm, bm, l_2, l_iter); l_iter = l_iter->next; + if (l_2_next) BM_elem_attrs_copy(bm, bm, l_2_next, l_iter); l_iter = l_iter->next; + if (l_1_next) BM_elem_attrs_copy(bm, bm, l_1_next, l_iter); + } } } } diff --git a/source/blender/editors/mesh/editmesh_tools.c b/source/blender/editors/mesh/editmesh_tools.c index 3945c1bb57a..6bd2ac75226 100644 --- a/source/blender/editors/mesh/editmesh_tools.c +++ b/source/blender/editors/mesh/editmesh_tools.c @@ -4804,8 +4804,12 @@ static int edbm_bridge_edge_loops_exec(bContext *C, wmOperator *op) Object *obedit = CTX_data_edit_object(C); BMEditMesh *em = BMEdit_FromObject(obedit); - if (!EDBM_op_callf(em, op, "bridge_loops edges=%he", BM_ELEM_SELECT)) + if (!EDBM_op_callf(em, op, + "bridge_loops edges=%he use_merge=%b merge_factor=%f", + BM_ELEM_SELECT, RNA_boolean_get(op->ptr, "use_merge"), RNA_float_get(op->ptr, "merge_factor"))) + { return OPERATOR_CANCELLED; + } EDBM_update_generic(C, em, TRUE); @@ -4827,6 +4831,9 @@ void MESH_OT_bridge_edge_loops(wmOperatorType *ot) ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; RNA_def_boolean(ot->srna, "inside", 0, "Inside", ""); + + RNA_def_boolean(ot->srna, "use_merge", FALSE, "Merge", "Merge rather than creating faces"); + RNA_def_float(ot->srna, "merge_factor", 0.5f, 0.0f, 1.0f, "Merge Factor", "", 0.0f, 1.0f); } typedef struct { From 6e90903bafa54ae25b887bd6bddeef787c3c5a29 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 23 Aug 2012 05:19:40 +0000 Subject: [PATCH 083/163] - add BM_data_interp_from_edges() function (matches BM_data_interp_from_verts). - bridge-merged now merges edge customdata and flags for verts and edges. --- source/blender/bmesh/intern/bmesh_interp.c | 52 ++++++++++++++------ source/blender/bmesh/intern/bmesh_interp.h | 1 + source/blender/bmesh/operators/bmo_connect.c | 4 +- 3 files changed, 40 insertions(+), 17 deletions(-) diff --git a/source/blender/bmesh/intern/bmesh_interp.c b/source/blender/bmesh/intern/bmesh_interp.c index 9453932b684..16488501651 100644 --- a/source/blender/bmesh/intern/bmesh_interp.c +++ b/source/blender/bmesh/intern/bmesh_interp.c @@ -45,46 +45,66 @@ #include "bmesh.h" #include "intern/bmesh_private.h" -/** - * \brief Data, Interp From Verts - * - * Interpolates per-vertex data from two sources to a target. - */ -void BM_data_interp_from_verts(BMesh *bm, BMVert *v1, BMVert *v2, BMVert *v, const float fac) +/* edge and vertex share, currently theres no need to have different logic */ +static void bm_data_interp_from_elem(BMesh *bm, BMElem *ele1, BMElem *ele2, BMElem *ele_dst, const float fac) { - if (v1->head.data && v2->head.data) { + if (ele1->head.data && ele2->head.data) { /* first see if we can avoid interpolation */ if (fac <= 0.0f) { - if (v1 == v) { + if (ele1 == ele_dst) { /* do nothing */ } else { - CustomData_bmesh_free_block(&bm->vdata, &v->head.data); - CustomData_bmesh_copy_data(&bm->vdata, &bm->vdata, v1->head.data, &v->head.data); + CustomData_bmesh_free_block(&bm->vdata, &ele_dst->head.data); + CustomData_bmesh_copy_data(&bm->vdata, &bm->vdata, ele1->head.data, &ele_dst->head.data); } } else if (fac >= 1.0f) { - if (v2 == v) { + if (ele2 == ele_dst) { /* do nothing */ } else { - CustomData_bmesh_free_block(&bm->vdata, &v->head.data); - CustomData_bmesh_copy_data(&bm->vdata, &bm->vdata, v2->head.data, &v->head.data); + CustomData_bmesh_free_block(&bm->vdata, &ele_dst->head.data); + CustomData_bmesh_copy_data(&bm->vdata, &bm->vdata, ele2->head.data, &ele_dst->head.data); } } else { void *src[2]; float w[2]; - src[0] = v1->head.data; - src[1] = v2->head.data; + src[0] = ele1->head.data; + src[1] = ele2->head.data; w[0] = 1.0f - fac; w[1] = fac; - CustomData_bmesh_interp(&bm->vdata, src, w, NULL, 2, v->head.data); + CustomData_bmesh_interp(&bm->vdata, src, w, NULL, 2, ele_dst->head.data); } } } +/** + * \brief Data, Interp From Verts + * + * Interpolates per-vertex data from two sources to a target. + * + * \note This is an exact match to #BM_data_interp_from_edges + */ +void BM_data_interp_from_verts(BMesh *bm, BMVert *v1, BMVert *v2, BMVert *v, const float fac) +{ + bm_data_interp_from_elem(bm, (BMElem *)v1, (BMElem *)v2, (BMElem *)v, fac); +} + +/** + * \brief Data, Interp From Edges + * + * Interpolates per-edge data from two sources to a target. + * + * \note This is an exact match to #BM_data_interp_from_verts + */ +void BM_data_interp_from_edges(BMesh *bm, BMEdge *e1, BMEdge *e2, BMEdge *e, const float fac) +{ + bm_data_interp_from_elem(bm, (BMElem *)e1, (BMElem *)e2, (BMElem *)e, fac); +} + /** * \brief Data Vert Average * diff --git a/source/blender/bmesh/intern/bmesh_interp.h b/source/blender/bmesh/intern/bmesh_interp.h index 3380a3e6b1b..8be963f5798 100644 --- a/source/blender/bmesh/intern/bmesh_interp.h +++ b/source/blender/bmesh/intern/bmesh_interp.h @@ -31,6 +31,7 @@ void BM_loop_interp_multires(BMesh *bm, BMLoop *target, BMFace *source); void BM_vert_interp_from_face(BMesh *bm, BMVert *v, BMFace *source); void BM_data_interp_from_verts(BMesh *bm, BMVert *v1, BMVert *v2, BMVert *v, const float fac); +void BM_data_interp_from_edges(BMesh *bm, BMEdge *e1, BMEdge *e2, BMEdge *e, const float fac); void BM_data_interp_face_vert_edge(BMesh *bm, BMVert *v1, BMVert *v2, BMVert *v, BMEdge *e1, const float fac); void BM_data_layer_add(BMesh *em, CustomData *data, int type); void BM_data_layer_add_named(BMesh *bm, CustomData *data, int type, const char *name); diff --git a/source/blender/bmesh/operators/bmo_connect.c b/source/blender/bmesh/operators/bmo_connect.c index 055e61596ee..c9a0d74de38 100644 --- a/source/blender/bmesh/operators/bmo_connect.c +++ b/source/blender/bmesh/operators/bmo_connect.c @@ -457,10 +457,12 @@ void bmo_bridge_loops_exec(BMesh *bm, BMOperator *op) for (i = 0; i < vert_len; i++) { BM_data_interp_from_verts(bm, vv1[i], vv2[i], vv2[i], merge_factor); interp_v3_v3v3(vv2[i]->co, vv1[i]->co, vv2[i]->co, merge_factor); + BM_elem_flag_merge(vv1[i], vv2[i]); BM_vert_splice(bm, vv1[i], vv2[i]); } for (i = 0; i < edge_len; i++) { - //BM_data_interp_from_edge(bm, vv1[i], vv2[i], vv2[i], merge_factor); + BM_data_interp_from_edges(bm, ee1[i], ee2[i], ee2[i], merge_factor); + BM_elem_flag_merge(ee1[i], ee2[i]); BM_edge_splice(bm, ee1[i], ee2[i]); } } From 45a0287f45e48d2a6224ec73f6d58890344b1ca3 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 23 Aug 2012 06:27:12 +0000 Subject: [PATCH 084/163] change I made gave a little nicer bleeding direction for inpaint but introduced dithering artifact. --- source/blender/compositor/operations/COM_InpaintOperation.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source/blender/compositor/operations/COM_InpaintOperation.cpp b/source/blender/compositor/operations/COM_InpaintOperation.cpp index bfc0ecd1c00..70d4d987c81 100644 --- a/source/blender/compositor/operations/COM_InpaintOperation.cpp +++ b/source/blender/compositor/operations/COM_InpaintOperation.cpp @@ -182,8 +182,8 @@ void InpaintSimpleOperation::pix_step(int x, int y) for (int dx = -1; dx <= 1; dx++) { for (int dy = -1; dy <= 1; dy++) { - if (dx != 0 && dy != 0) { - + /* changing to both != 0 gives dithering artifacts */ + if (dx != 0 || dy != 0) { int x_ofs = x + dx; int y_ofs = y + dy; From 1ab5a4f0edb1e39de4d6adc1f874e2bfcdead243 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 23 Aug 2012 06:48:01 +0000 Subject: [PATCH 085/163] despeckle composite node --- source/blender/blenkernel/BKE_node.h | 3 +- source/blender/blenkernel/intern/node.c | 1 + source/blender/compositor/CMakeLists.txt | 4 + .../compositor/intern/COM_Converter.cpp | 4 + .../compositor/nodes/COM_DespeckleNode.cpp | 50 +++++++ .../compositor/nodes/COM_DespeckleNode.h | 36 +++++ .../operations/COM_DespeckleOperation.cpp | 139 ++++++++++++++++++ .../operations/COM_DespeckleOperation.h | 49 ++++++ source/blender/editors/space_node/drawnode.c | 12 ++ source/blender/makesrna/intern/rna_nodetree.c | 17 +++ .../makesrna/intern/rna_nodetree_types.h | 1 + source/blender/nodes/CMakeLists.txt | 1 + source/blender/nodes/NOD_composite.h | 1 + .../nodes/node_composite_despeckle.c | 66 +++++++++ 14 files changed, 383 insertions(+), 1 deletion(-) create mode 100644 source/blender/compositor/nodes/COM_DespeckleNode.cpp create mode 100644 source/blender/compositor/nodes/COM_DespeckleNode.h create mode 100644 source/blender/compositor/operations/COM_DespeckleOperation.cpp create mode 100644 source/blender/compositor/operations/COM_DespeckleOperation.h create mode 100644 source/blender/nodes/composite/nodes/node_composite_despeckle.c diff --git a/source/blender/blenkernel/BKE_node.h b/source/blender/blenkernel/BKE_node.h index 2a0679e3977..4748267278e 100644 --- a/source/blender/blenkernel/BKE_node.h +++ b/source/blender/blenkernel/BKE_node.h @@ -680,7 +680,8 @@ void ntreeGPUMaterialNodes(struct bNodeTree *ntree, struct GPUMateria #define CMP_NODE_KEYINGSCREEN 269 #define CMP_NODE_KEYING 270 #define CMP_NODE_TRACKPOS 271 -#define CMP_NODE_INPAINT 272 +#define CMP_NODE_INPAINT 272 +#define CMP_NODE_DESPECKLE 273 #define CMP_NODE_GLARE 301 #define CMP_NODE_TONEMAP 302 diff --git a/source/blender/blenkernel/intern/node.c b/source/blender/blenkernel/intern/node.c index 37562686a99..22b0cccf175 100644 --- a/source/blender/blenkernel/intern/node.c +++ b/source/blender/blenkernel/intern/node.c @@ -2139,6 +2139,7 @@ static void registerCompositNodes(bNodeTreeType *ttype) register_node_type_cmp_vecblur(ttype); register_node_type_cmp_dilateerode(ttype); register_node_type_cmp_inpaint(ttype); + register_node_type_cmp_despeckle(ttype); register_node_type_cmp_defocus(ttype); register_node_type_cmp_valtorgb(ttype); diff --git a/source/blender/compositor/CMakeLists.txt b/source/blender/compositor/CMakeLists.txt index c110d4f077e..9932ed17378 100644 --- a/source/blender/compositor/CMakeLists.txt +++ b/source/blender/compositor/CMakeLists.txt @@ -284,6 +284,8 @@ set(SRC nodes/COM_FilterNode.cpp nodes/COM_FilterNode.h + nodes/COM_DespeckleNode.cpp + nodes/COM_DespeckleNode.h nodes/COM_DilateErodeNode.cpp nodes/COM_DilateErodeNode.h nodes/COM_InpaintNode.cpp @@ -592,6 +594,8 @@ set(SRC operations/COM_ConvolutionFilterOperation.cpp operations/COM_ConvolutionEdgeFilterOperation.h operations/COM_ConvolutionEdgeFilterOperation.cpp + operations/COM_DespeckleOperation.cpp + operations/COM_DespeckleOperation.h operations/COM_DilateErodeOperation.cpp operations/COM_DilateErodeOperation.h operations/COM_InpaintOperation.cpp diff --git a/source/blender/compositor/intern/COM_Converter.cpp b/source/blender/compositor/intern/COM_Converter.cpp index 37b53c44ef7..d4fad80ed07 100644 --- a/source/blender/compositor/intern/COM_Converter.cpp +++ b/source/blender/compositor/intern/COM_Converter.cpp @@ -56,6 +56,7 @@ #include "COM_Converter.h" #include "COM_CropNode.h" #include "COM_DefocusNode.h" +#include "COM_DespeckleNode.h" #include "COM_DifferenceMatteNode.h" #include "COM_DilateErodeNode.h" #include "COM_DirectionalBlurNode.h" @@ -307,6 +308,9 @@ Node *Converter::convert(bNode *b_node, bool fast) case CMP_NODE_INPAINT: node = new InpaintNode(b_node); break; + case CMP_NODE_DESPECKLE: + node = new DespeckleNode(b_node); + break; case CMP_NODE_LENSDIST: node = new LensDistortionNode(b_node); break; diff --git a/source/blender/compositor/nodes/COM_DespeckleNode.cpp b/source/blender/compositor/nodes/COM_DespeckleNode.cpp new file mode 100644 index 00000000000..603ddcd1389 --- /dev/null +++ b/source/blender/compositor/nodes/COM_DespeckleNode.cpp @@ -0,0 +1,50 @@ +/* + * Copyright 2011, Blender Foundation. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Contributor: Campbell Barton + */ + +#include "COM_DespeckleNode.h" +#include "DNA_scene_types.h" +#include "COM_ExecutionSystem.h" +#include "COM_DespeckleOperation.h" +#include "BLI_math.h" + +DespeckleNode::DespeckleNode(bNode *editorNode) : Node(editorNode) +{ + /* pass */ +} + +void DespeckleNode::convertToOperations(ExecutionSystem *graph, CompositorContext *context) +{ + bNode *editorNode = this->getbNode(); + InputSocket *inputSocket = this->getInputSocket(0); + InputSocket *inputImageSocket = this->getInputSocket(1); + OutputSocket *outputSocket = this->getOutputSocket(0); + DespeckleOperation *operation = new DespeckleOperation(); + + operation->setbNode(editorNode); + operation->setThreshold(editorNode->custom3); + operation->setThresholdNeighbour(editorNode->custom4); + + inputImageSocket->relinkConnections(operation->getInputSocket(0), 1, graph); + inputSocket->relinkConnections(operation->getInputSocket(1), 0, graph); + outputSocket->relinkConnections(operation->getOutputSocket()); + addPreviewOperation(graph, operation->getOutputSocket(0)); + + graph->addOperation(operation); +} diff --git a/source/blender/compositor/nodes/COM_DespeckleNode.h b/source/blender/compositor/nodes/COM_DespeckleNode.h new file mode 100644 index 00000000000..2b8ab9d0226 --- /dev/null +++ b/source/blender/compositor/nodes/COM_DespeckleNode.h @@ -0,0 +1,36 @@ +/* + * Copyright 2011, Blender Foundation. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Contributor: Campbell Barton + */ + +#ifndef _COM_DespeckleNode_h_ +#define _COM_DespeckleNode_h_ + +#include "COM_Node.h" + +/** + * @brief DespeckleNode + * @ingroup Node + */ +class DespeckleNode : public Node { +public: + DespeckleNode(bNode *editorNode); + void convertToOperations(ExecutionSystem *graph, CompositorContext *context); +}; + +#endif diff --git a/source/blender/compositor/operations/COM_DespeckleOperation.cpp b/source/blender/compositor/operations/COM_DespeckleOperation.cpp new file mode 100644 index 00000000000..6e2f9ab4351 --- /dev/null +++ b/source/blender/compositor/operations/COM_DespeckleOperation.cpp @@ -0,0 +1,139 @@ +/* + * Copyright 2011, Blender Foundation. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Contributor: Campbell Barton + */ + +#include "MEM_guardedalloc.h" + +#include "COM_DespeckleOperation.h" + +#include "BLI_utildefines.h" + +DespeckleOperation::DespeckleOperation() : NodeOperation() +{ + this->addInputSocket(COM_DT_COLOR); + this->addInputSocket(COM_DT_VALUE); + this->addOutputSocket(COM_DT_COLOR); + this->setResolutionInputSocketIndex(0); + this->m_inputOperation = NULL; + this->setComplex(true); +} +void DespeckleOperation::initExecution() +{ + this->m_inputOperation = this->getInputSocketReader(0); + this->m_inputValueOperation = this->getInputSocketReader(1); +} + +void DespeckleOperation::deinitExecution() +{ + this->m_inputOperation = NULL; + this->m_inputValueOperation = NULL; +} + +BLI_INLINE int color_diff(const float a[3], const float b[3], const float threshold) +{ + return ((fabsf(a[0] - b[0]) > threshold) || + (fabsf(a[1] - b[1]) > threshold) || + (fabsf(a[2] - b[2]) > threshold)); +} + +void DespeckleOperation::executePixel(float output[4], int x, int y, void *data) +{ + float w = 0.0f; + float color_org[4]; + float color_mid[4]; + float color_mid_ok[4]; + float in1[4]; + int x1 = x - 1; + int x2 = x; + int x3 = x + 1; + int y1 = y - 1; + int y2 = y; + int y3 = y + 1; + CLAMP(x1, 0, getWidth() - 1); + CLAMP(x2, 0, getWidth() - 1); + CLAMP(x3, 0, getWidth() - 1); + CLAMP(y1, 0, getHeight() - 1); + CLAMP(y2, 0, getHeight() - 1); + CLAMP(y3, 0, getHeight() - 1); + float value[4]; + this->m_inputValueOperation->read(value, x2, y2, NULL); + //const float mval = 1.0f - value[0]; + + + this->m_inputOperation->read(color_org, x2, y2, NULL); + +#define TOT_DIV_ONE 1.0 +#define TOT_DIV_CNR M_SQRT1_2 + +#define WTOT (TOT_DIV_ONE * 4 + TOT_DIV_CNR * 4) + +#define COLOR_ADD(fac) \ +{ \ + madd_v4_v4fl(color_mid, in1, fac); \ + if (color_diff(in1, color_org, this->m_threshold)) { \ + w += fac; \ + madd_v4_v4fl(color_mid_ok, in1, fac); \ + } \ +} + + zero_v4(color_mid); + zero_v4(color_mid_ok); + + this->m_inputOperation->read(in1, x1, y1, NULL); COLOR_ADD(TOT_DIV_CNR) + this->m_inputOperation->read(in1, x2, y1, NULL); COLOR_ADD(TOT_DIV_ONE) + this->m_inputOperation->read(in1, x3, y1, NULL); COLOR_ADD(TOT_DIV_CNR) + this->m_inputOperation->read(in1, x1, y2, NULL); COLOR_ADD(TOT_DIV_ONE) + +#if 0 + this->m_inputOperation->read(in2, x2, y2, NULL); + madd_v4_v4fl(color_mid, in2, this->m_filter[4]); +#endif + + this->m_inputOperation->read(in1, x3, y2, NULL); COLOR_ADD(TOT_DIV_ONE) + this->m_inputOperation->read(in1, x1, y3, NULL); COLOR_ADD(TOT_DIV_CNR) + this->m_inputOperation->read(in1, x2, y3, NULL); COLOR_ADD(TOT_DIV_ONE) + this->m_inputOperation->read(in1, x3, y3, NULL); COLOR_ADD(TOT_DIV_CNR) + + mul_v4_fl(color_mid, 1.0f / (4.0f + (4.0f * M_SQRT1_2))); + //mul_v4_fl(color_mid, 1.0f / w); + + if ((w != 0.0f) && + ((w / WTOT) > (this->m_threshold_neighbour)) && + color_diff(color_mid, color_org, this->m_threshold)) + { + mul_v4_fl(color_mid_ok, 1.0f / w); + interp_v4_v4v4(output, color_org, color_mid_ok, value[0]); + } + else { + copy_v4_v4(output, color_org); + } +} + +bool DespeckleOperation::determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output) +{ + rcti newInput; + int addx = 1; //(this->m_filterWidth - 1) / 2 + 1; + int addy = 1; //(this->m_filterHeight - 1) / 2 + 1; + newInput.xmax = input->xmax + addx; + newInput.xmin = input->xmin - addx; + newInput.ymax = input->ymax + addy; + newInput.ymin = input->ymin - addy; + + return NodeOperation::determineDependingAreaOfInterest(&newInput, readOperation, output); +} diff --git a/source/blender/compositor/operations/COM_DespeckleOperation.h b/source/blender/compositor/operations/COM_DespeckleOperation.h new file mode 100644 index 00000000000..5b79d7cb7e0 --- /dev/null +++ b/source/blender/compositor/operations/COM_DespeckleOperation.h @@ -0,0 +1,49 @@ +/* + * Copyright 2011, Blender Foundation. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Contributor: Campbell Barton + */ + +#ifndef _COM_DespeckleOperation_h +#define _COM_DespeckleOperation_h +#include "COM_NodeOperation.h" + +class DespeckleOperation : public NodeOperation { +private: + float m_threshold; + float m_threshold_neighbour; + + int m_filterWidth; + int m_filterHeight; + +protected: + SocketReader *m_inputOperation; + SocketReader *m_inputValueOperation; + +public: + DespeckleOperation(); + bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output); + void executePixel(float output[4], int x, int y, void *data); + + void setThreshold(float threshold) { this->m_threshold = threshold; } + void setThresholdNeighbour(float threshold) { this->m_threshold_neighbour = threshold; } + + void initExecution(); + void deinitExecution(); +}; + +#endif diff --git a/source/blender/editors/space_node/drawnode.c b/source/blender/editors/space_node/drawnode.c index c1a410317b7..125d5e3be77 100644 --- a/source/blender/editors/space_node/drawnode.c +++ b/source/blender/editors/space_node/drawnode.c @@ -1812,6 +1812,15 @@ static void node_composit_buts_inpaint(uiLayout *layout, bContext *UNUSED(C), Po uiItemR(layout, ptr, "distance", 0, NULL, ICON_NONE); } +static void node_composit_buts_despeckle(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr) +{ + uiLayout *col; + + col = uiLayoutColumn(layout, FALSE); + uiItemR(col, ptr, "threshold", 0, NULL, ICON_NONE); + uiItemR(col, ptr, "threshold_neighbour", 0, NULL, ICON_NONE); +} + static void node_composit_buts_diff_matte(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr) { uiLayout *col; @@ -2674,6 +2683,9 @@ static void node_composit_set_butfunc(bNodeType *ntype) case CMP_NODE_INPAINT: ntype->uifunc = node_composit_buts_inpaint; break; + case CMP_NODE_DESPECKLE: + ntype->uifunc = node_composit_buts_despeckle; + break; case CMP_NODE_OUTPUT_FILE: ntype->uifunc = node_composit_buts_file_output; ntype->uifuncbut = node_composit_buts_file_output_details; diff --git a/source/blender/makesrna/intern/rna_nodetree.c b/source/blender/makesrna/intern/rna_nodetree.c index 6a732cc2649..a608a84bd89 100644 --- a/source/blender/makesrna/intern/rna_nodetree.c +++ b/source/blender/makesrna/intern/rna_nodetree.c @@ -2148,6 +2148,23 @@ static void def_cmp_inpaint(StructRNA *srna) RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update"); } +static void def_cmp_despeckle(StructRNA *srna) +{ + PropertyRNA *prop; + + prop = RNA_def_property(srna, "threshold", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "custom3"); + RNA_def_property_range(prop, 0.0, 1.0f); + RNA_def_property_ui_text(prop, "Threshold", "Threshold for detecting pixels to despeckle"); + RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update"); + + prop = RNA_def_property(srna, "threshold_neighbour", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "custom4"); + RNA_def_property_range(prop, 0.0, 1.0f); + RNA_def_property_ui_text(prop, "Neighbour", "Threshold for the number of neighbour pixels that must match"); + RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update"); +} + static void def_cmp_scale(StructRNA *srna) { PropertyRNA *prop; diff --git a/source/blender/makesrna/intern/rna_nodetree_types.h b/source/blender/makesrna/intern/rna_nodetree_types.h index c70dd01cd57..15ad1c557a5 100644 --- a/source/blender/makesrna/intern/rna_nodetree_types.h +++ b/source/blender/makesrna/intern/rna_nodetree_types.h @@ -122,6 +122,7 @@ DefNode( CompositorNode, CMP_NODE_ZCOMBINE, def_cmp_zcombine, "ZCOMB DefNode( CompositorNode, CMP_NODE_COMBRGBA, 0, "COMBRGBA", CombRGBA, "Combine RGBA", "" ) DefNode( CompositorNode, CMP_NODE_DILATEERODE, def_cmp_dilate_erode, "DILATEERODE", DilateErode, "Dilate/Erode", "" ) DefNode( CompositorNode, CMP_NODE_INPAINT, def_cmp_inpaint, "INPAINT", Inpaint, "Inpaint", "" ) +DefNode( CompositorNode, CMP_NODE_DESPECKLE, def_cmp_despeckle, "DESPECKLE", Despeckle, "Despeckle", "" ) DefNode( CompositorNode, CMP_NODE_ROTATE, def_cmp_rotate, "ROTATE", Rotate, "Rotate", "" ) DefNode( CompositorNode, CMP_NODE_SCALE, def_cmp_scale, "SCALE", Scale, "Scale", "" ) DefNode( CompositorNode, CMP_NODE_SEPYCCA, def_cmp_ycc, "SEPYCCA", SepYCCA, "Separate YCCA", "" ) diff --git a/source/blender/nodes/CMakeLists.txt b/source/blender/nodes/CMakeLists.txt index 64987a52a21..e1adb419a8a 100644 --- a/source/blender/nodes/CMakeLists.txt +++ b/source/blender/nodes/CMakeLists.txt @@ -59,6 +59,7 @@ set(SRC composite/nodes/node_composite_composite.c composite/nodes/node_composite_crop.c composite/nodes/node_composite_curves.c + composite/nodes/node_composite_despeckle.c composite/nodes/node_composite_doubleEdgeMask.c composite/nodes/node_composite_defocus.c composite/nodes/node_composite_diffMatte.c diff --git a/source/blender/nodes/NOD_composite.h b/source/blender/nodes/NOD_composite.h index 92e547288c9..bcef230e1d0 100644 --- a/source/blender/nodes/NOD_composite.h +++ b/source/blender/nodes/NOD_composite.h @@ -81,6 +81,7 @@ void register_node_type_cmp_bilateralblur(struct bNodeTreeType *ttype); void register_node_type_cmp_vecblur(struct bNodeTreeType *ttype); void register_node_type_cmp_dilateerode(struct bNodeTreeType *ttype); void register_node_type_cmp_inpaint(struct bNodeTreeType *ttype); +void register_node_type_cmp_despeckle(struct bNodeTreeType *ttype); void register_node_type_cmp_defocus(struct bNodeTreeType *ttype); void register_node_type_cmp_valtorgb(struct bNodeTreeType *ttype); diff --git a/source/blender/nodes/composite/nodes/node_composite_despeckle.c b/source/blender/nodes/composite/nodes/node_composite_despeckle.c new file mode 100644 index 00000000000..c1861ca9d86 --- /dev/null +++ b/source/blender/nodes/composite/nodes/node_composite_despeckle.c @@ -0,0 +1,66 @@ +/* + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * The Original Code is Copyright (C) 2006 Blender Foundation. + * All rights reserved. + * + * The Original Code is: all of this file. + * + * Contributor(s): none yet. + * + * ***** END GPL LICENSE BLOCK ***** + */ + +/** \file blender/nodes/composite/nodes/node_composite_despeckle.c + * \ingroup cmpnodes + */ + +#include "node_composite_util.h" + +/* **************** FILTER ******************** */ +static bNodeSocketTemplate cmp_node_despeckle_in[]= { + { SOCK_FLOAT, 1, N_("Fac"), 1.0f, 1.0f, 1.0f, 1.0f, 0.0f, 1.0f, PROP_FACTOR}, + { SOCK_RGBA, 1, N_("Image"), 1.0f, 1.0f, 1.0f, 1.0f}, + { -1, 0, "" } +}; +static bNodeSocketTemplate cmp_node_despeckle_out[]= { + { SOCK_RGBA, 0, N_("Image")}, + { -1, 0, "" } +}; + +#ifdef WITH_COMPOSITOR_LEGACY + +static void node_composit_exec_despeckle(void *UNUSED(data), bNode *UNUSED(node), bNodeStack **UNUSED(in), bNodeStack **UNUSED(out)) +{ + /* pass */ +} + +#endif /* WITH_COMPOSITOR_LEGACY */ + +void register_node_type_cmp_despeckle(bNodeTreeType *ttype) +{ + static bNodeType ntype; + + node_type_base(ttype, &ntype, CMP_NODE_DESPECKLE, "Despeckle", NODE_CLASS_OP_FILTER, NODE_PREVIEW|NODE_OPTIONS); + node_type_socket_templates(&ntype, cmp_node_despeckle_in, cmp_node_despeckle_out); + node_type_size(&ntype, 80, 40, 120); +#ifdef WITH_COMPOSITOR_LEGACY + node_type_exec(&ntype, node_composit_exec_despeckle); +#endif + + nodeRegisterType(ttype, &ntype); +} From 4e772065d7e17e53e31d04816eef7c4468835c82 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 23 Aug 2012 07:02:11 +0000 Subject: [PATCH 086/163] set defaults for de-speckle --- .../compositor/operations/COM_DespeckleOperation.cpp | 4 ++-- .../nodes/composite/nodes/node_composite_despeckle.c | 7 +++++++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/source/blender/compositor/operations/COM_DespeckleOperation.cpp b/source/blender/compositor/operations/COM_DespeckleOperation.cpp index 6e2f9ab4351..8a18e4e2330 100644 --- a/source/blender/compositor/operations/COM_DespeckleOperation.cpp +++ b/source/blender/compositor/operations/COM_DespeckleOperation.cpp @@ -128,8 +128,8 @@ void DespeckleOperation::executePixel(float output[4], int x, int y, void *data) bool DespeckleOperation::determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output) { rcti newInput; - int addx = 1; //(this->m_filterWidth - 1) / 2 + 1; - int addy = 1; //(this->m_filterHeight - 1) / 2 + 1; + int addx = 2; //(this->m_filterWidth - 1) / 2 + 1; + int addy = 2; //(this->m_filterHeight - 1) / 2 + 1; newInput.xmax = input->xmax + addx; newInput.xmin = input->xmin - addx; newInput.ymax = input->ymax + addy; diff --git a/source/blender/nodes/composite/nodes/node_composite_despeckle.c b/source/blender/nodes/composite/nodes/node_composite_despeckle.c index c1861ca9d86..86c5a0b467c 100644 --- a/source/blender/nodes/composite/nodes/node_composite_despeckle.c +++ b/source/blender/nodes/composite/nodes/node_composite_despeckle.c @@ -51,6 +51,12 @@ static void node_composit_exec_despeckle(void *UNUSED(data), bNode *UNUSED(node) #endif /* WITH_COMPOSITOR_LEGACY */ +static void node_composit_init_despeckle(bNodeTree *UNUSED(ntree), bNode* node, bNodeTemplate *UNUSED(ntemp)) +{ + node->custom3 = 0.5f; + node->custom4 = 0.5f; +} + void register_node_type_cmp_despeckle(bNodeTreeType *ttype) { static bNodeType ntype; @@ -58,6 +64,7 @@ void register_node_type_cmp_despeckle(bNodeTreeType *ttype) node_type_base(ttype, &ntype, CMP_NODE_DESPECKLE, "Despeckle", NODE_CLASS_OP_FILTER, NODE_PREVIEW|NODE_OPTIONS); node_type_socket_templates(&ntype, cmp_node_despeckle_in, cmp_node_despeckle_out); node_type_size(&ntype, 80, 40, 120); + node_type_init(&ntype, node_composit_init_despeckle); #ifdef WITH_COMPOSITOR_LEGACY node_type_exec(&ntype, node_composit_exec_despeckle); #endif From 9ecc6fdcc719d4e79be92d1ded5d7ac0d20c9416 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 23 Aug 2012 07:10:48 +0000 Subject: [PATCH 087/163] style cleanup --- source/blender/blenkernel/BKE_node.h | 2 +- source/blender/blenkernel/BKE_sequencer.h | 2 +- source/blender/imbuf/IMB_moviecache.h | 2 +- source/blender/imbuf/IMB_thumbs.h | 6 +- .../nodes/composite/node_composite_tree.c | 112 +++++++++--------- .../nodes/node_composite_alphaOver.c | 2 +- .../nodes/node_composite_bokehimage.c | 2 +- .../composite/nodes/node_composite_boxmask.c | 2 +- .../nodes/node_composite_channelMatte.c | 2 +- .../nodes/node_composite_chromaMatte.c | 2 +- .../nodes/node_composite_colorMatte.c | 2 +- .../nodes/node_composite_colorSpill.c | 2 +- .../nodes/node_composite_colorbalance.c | 2 +- .../nodes/node_composite_colorcorrection.c | 2 +- .../composite/nodes/node_composite_common.c | 28 ++--- .../composite/nodes/node_composite_crop.c | 2 +- .../composite/nodes/node_composite_curves.c | 6 +- .../composite/nodes/node_composite_defocus.c | 2 +- .../nodes/node_composite_despeckle.c | 2 +- .../nodes/node_composite_diffMatte.c | 2 +- .../composite/nodes/node_composite_dilate.c | 2 +- .../nodes/node_composite_distanceMatte.c | 2 +- .../nodes/node_composite_ellipsemask.c | 2 +- .../composite/nodes/node_composite_glare.c | 2 +- .../nodes/node_composite_hueSatVal.c | 2 +- .../nodes/node_composite_huecorrect.c | 2 +- .../composite/nodes/node_composite_image.c | 2 +- .../composite/nodes/node_composite_invert.c | 2 +- .../composite/nodes/node_composite_keying.c | 2 +- .../nodes/node_composite_keyingscreen.c | 2 +- .../composite/nodes/node_composite_lensdist.c | 2 +- .../composite/nodes/node_composite_levels.c | 8 +- .../nodes/node_composite_lummaMatte.c | 2 +- .../composite/nodes/node_composite_mapValue.c | 2 +- .../composite/nodes/node_composite_mask.c | 2 +- .../nodes/node_composite_outputFile.c | 2 +- .../composite/nodes/node_composite_rotate.c | 2 +- .../nodes/node_composite_splitViewer.c | 2 +- .../composite/nodes/node_composite_tonemap.c | 2 +- .../composite/nodes/node_composite_valToRgb.c | 2 +- source/blender/nodes/intern/node_common.c | 2 +- .../shader/nodes/node_shader_attribute.c | 2 +- .../nodes/shader/nodes/node_shader_curves.c | 4 +- .../nodes/shader/nodes/node_shader_geom.c | 2 +- .../nodes/shader/nodes/node_shader_mapping.c | 2 +- .../nodes/shader/nodes/node_shader_material.c | 2 +- .../shader/nodes/node_shader_tex_checker.c | 2 +- .../nodes/node_shader_tex_environment.c | 2 +- .../shader/nodes/node_shader_tex_gradient.c | 2 +- .../shader/nodes/node_shader_tex_image.c | 2 +- .../shader/nodes/node_shader_tex_magic.c | 2 +- .../shader/nodes/node_shader_tex_musgrave.c | 2 +- .../shader/nodes/node_shader_tex_noise.c | 2 +- .../nodes/shader/nodes/node_shader_tex_sky.c | 2 +- .../shader/nodes/node_shader_tex_voronoi.c | 2 +- .../nodes/shader/nodes/node_shader_tex_wave.c | 2 +- .../nodes/shader/nodes/node_shader_valToRgb.c | 2 +- .../nodes/texture/nodes/node_texture_bricks.c | 2 +- .../nodes/texture/nodes/node_texture_curves.c | 4 +- .../nodes/texture/nodes/node_texture_image.c | 2 +- .../nodes/texture/nodes/node_texture_output.c | 2 +- .../nodes/texture/nodes/node_texture_proc.c | 2 +- .../texture/nodes/node_texture_valToRgb.c | 2 +- .../render/intern/source/imagetexture.c | 8 +- .../render/intern/source/render_texture.c | 4 +- source/gameengine/Ketsji/BL_Texture.cpp | 2 +- source/gameengine/VideoTexture/ImageBuff.cpp | 2 +- source/gameengine/VideoTexture/ImageBuff.h | 2 +- 68 files changed, 149 insertions(+), 149 deletions(-) diff --git a/source/blender/blenkernel/BKE_node.h b/source/blender/blenkernel/BKE_node.h index 4748267278e..c8b69898daa 100644 --- a/source/blender/blenkernel/BKE_node.h +++ b/source/blender/blenkernel/BKE_node.h @@ -146,7 +146,7 @@ typedef struct bNodeType { /// Additional parameters in the side panel. void (*uifuncbut)(struct uiLayout *, struct bContext *C, struct PointerRNA *ptr); /// Additional drawing on backdrop. - void (*uibackdropfunc)(struct SpaceNode* snode, struct ImBuf* backdrop, struct bNode* node, int x, int y); + void (*uibackdropfunc)(struct SpaceNode *snode, struct ImBuf *backdrop, struct bNode *node, int x, int y); /// Draw a node socket. Default draws the input value button. NodeSocketButtonFunction drawinputfunc; diff --git a/source/blender/blenkernel/BKE_sequencer.h b/source/blender/blenkernel/BKE_sequencer.h index 7bd1d178296..2a90bb2c679 100644 --- a/source/blender/blenkernel/BKE_sequencer.h +++ b/source/blender/blenkernel/BKE_sequencer.h @@ -380,7 +380,7 @@ typedef struct SequenceModifierTypeInfo { void (*copy_data) (struct SequenceModifierData *smd, struct SequenceModifierData *target); /* apply modifier on a given image buffer */ - struct ImBuf* (*apply) (struct SequenceModifierData *smd, struct ImBuf *ibuf, struct ImBuf *mask); + struct ImBuf *(*apply) (struct SequenceModifierData *smd, struct ImBuf *ibuf, struct ImBuf *mask); } SequenceModifierTypeInfo; struct SequenceModifierTypeInfo *BKE_sequence_modifier_type_info_get(int type); diff --git a/source/blender/imbuf/IMB_moviecache.h b/source/blender/imbuf/IMB_moviecache.h index 00d3368ae5f..4588c2bcee5 100644 --- a/source/blender/imbuf/IMB_moviecache.h +++ b/source/blender/imbuf/IMB_moviecache.h @@ -58,7 +58,7 @@ void IMB_moviecache_set_priority_callback(struct MovieCache *cache, MovieCacheGe MovieCachePriorityDeleterFP prioritydeleterfp); void IMB_moviecache_put(struct MovieCache *cache, void *userkey, struct ImBuf *ibuf); -struct ImBuf* IMB_moviecache_get(struct MovieCache *cache, void *userkey); +struct ImBuf *IMB_moviecache_get(struct MovieCache *cache, void *userkey); void IMB_moviecache_free(struct MovieCache *cache); void IMB_moviecache_cleanup(struct MovieCache *cache, int (cleanup_check_cb) (void *userkey, void *userdata), void *userdata); diff --git a/source/blender/imbuf/IMB_thumbs.h b/source/blender/imbuf/IMB_thumbs.h index 76c09ec1486..e206541b135 100644 --- a/source/blender/imbuf/IMB_thumbs.h +++ b/source/blender/imbuf/IMB_thumbs.h @@ -63,16 +63,16 @@ typedef enum ThumbSource { // IB_metadata /* create thumbnail for file and returns new imbuf for thumbnail */ -ImBuf* IMB_thumb_create(const char* path, ThumbSize size, ThumbSource source, ImBuf *ibuf); +ImBuf *IMB_thumb_create(const char* path, ThumbSize size, ThumbSource source, ImBuf *ibuf); /* read thumbnail for file and returns new imbuf for thumbnail */ -ImBuf* IMB_thumb_read(const char* path, ThumbSize size); +ImBuf *IMB_thumb_read(const char* path, ThumbSize size); /* delete all thumbs for the file */ void IMB_thumb_delete(const char* path, ThumbSize size); /* return the state of the thumb, needed to determine how to manage the thumb */ -ImBuf* IMB_thumb_manage(const char* path, ThumbSize size, ThumbSource source); +ImBuf *IMB_thumb_manage(const char* path, ThumbSize size, ThumbSource source); /* create the necessary dirs to store the thumbnails */ void IMB_thumb_makedirs(void); diff --git a/source/blender/nodes/composite/node_composite_tree.c b/source/blender/nodes/composite/node_composite_tree.c index 351b9309d7a..37444b6da92 100644 --- a/source/blender/nodes/composite/node_composite_tree.c +++ b/source/blender/nodes/composite/node_composite_tree.c @@ -795,13 +795,13 @@ static void force_hidden_passes(bNode *node, int passflag) void ntreeCompositForceHidden(bNodeTree *ntree, Scene *curscene) { bNode *node; - - if (ntree==NULL) return; - - for (node= ntree->nodes.first; node; node= node->next) { - if ( node->type==CMP_NODE_R_LAYERS) { - Scene *sce= node->id?(Scene *)node->id:curscene; - SceneRenderLayer *srl= BLI_findlink(&sce->r.layers, node->custom1); + + if (ntree == NULL) return; + + for (node = ntree->nodes.first; node; node = node->next) { + if (node->type == CMP_NODE_R_LAYERS) { + Scene *sce = node->id ? (Scene *)node->id : curscene; + SceneRenderLayer *srl = BLI_findlink(&sce->r.layers, node->custom1); if (srl) force_hidden_passes(node, srl->passflag); } @@ -809,7 +809,7 @@ void ntreeCompositForceHidden(bNodeTree *ntree, Scene *curscene) * Updates should only happen when actually necessary. */ #if 0 - else if ( node->type==CMP_NODE_IMAGE) { + else if (node->type == CMP_NODE_IMAGE) { nodeUpdate(ntree, node); } #endif @@ -822,15 +822,15 @@ void ntreeCompositForceHidden(bNodeTree *ntree, Scene *curscene) void ntreeCompositTagRender(Scene *curscene) { Scene *sce; - - for (sce= G.main->scene.first; sce; sce= sce->id.next) { + + for (sce = G.main->scene.first; sce; sce = sce->id.next) { if (sce->nodetree) { bNode *node; - - for (node= sce->nodetree->nodes.first; node; node= node->next) { - if (node->id==(ID *)curscene || node->type==CMP_NODE_COMPOSITE) + + for (node = sce->nodetree->nodes.first; node; node = node->next) { + if (node->id == (ID *)curscene || node->type == CMP_NODE_COMPOSITE) nodeUpdate(sce->nodetree, node); - else if (node->type==CMP_NODE_TEXTURE) /* uses scene sizex/sizey */ + else if (node->type == CMP_NODE_TEXTURE) /* uses scene sizex/sizey */ nodeUpdate(sce->nodetree, node); } } @@ -844,37 +844,37 @@ static int node_animation_properties(bNodeTree *ntree, bNode *node) Link *link; PointerRNA ptr; PropertyRNA *prop; - + /* check to see if any of the node's properties have fcurves */ RNA_pointer_create((ID *)ntree, &RNA_Node, node, &ptr); lb = RNA_struct_type_properties(ptr.type); - - for (link=lb->first; link; link=link->next) { - int driven, len=1, index; + + for (link = lb->first; link; link = link->next) { + int driven, len = 1, index; prop = (PropertyRNA *)link; - + if (RNA_property_array_check(prop)) len = RNA_property_array_length(&ptr, prop); - - for (index=0; indexinputs.first; sock; sock=sock->next) { - int driven, len=1, index; - + for (sock = node->inputs.first; sock; sock = sock->next) { + int driven, len = 1, index; + RNA_pointer_create((ID *)ntree, &RNA_NodeSocket, sock, &ptr); prop = RNA_struct_find_property(&ptr, "default_value"); if (prop) { if (RNA_property_array_check(prop)) len = RNA_property_array_length(&ptr, prop); - - for (index=0; indexnodes.first; node; node= node->next) { - + int tagged = 0; + + if (ntree == NULL) return 0; + + for (node = ntree->nodes.first; node; node = node->next) { + tagged = node_animation_properties(ntree, node); - + /* otherwise always tag these node types */ - if (node->type==CMP_NODE_IMAGE) { - Image *ima= (Image *)node->id; + if (node->type == CMP_NODE_IMAGE) { + Image *ima = (Image *)node->id; if (ima && ELEM(ima->source, IMA_SRC_MOVIE, IMA_SRC_SEQUENCE)) { nodeUpdate(ntree, node); - tagged= 1; + tagged = 1; } } - else if (node->type==CMP_NODE_TIME) { + else if (node->type == CMP_NODE_TIME) { nodeUpdate(ntree, node); - tagged= 1; + tagged = 1; } /* here was tag render layer, but this is called after a render, so re-composites fail */ - else if (node->type==NODE_GROUP) { - if ( ntreeCompositTagAnimated((bNodeTree *)node->id) ) { + else if (node->type == NODE_GROUP) { + if (ntreeCompositTagAnimated((bNodeTree *)node->id) ) { nodeUpdate(ntree, node); } } else if (ELEM(node->type, CMP_NODE_MOVIECLIP, CMP_NODE_TRANSFORM)) { nodeUpdate(ntree, node); - tagged= 1; + tagged = 1; } - else if (node->type==CMP_NODE_MASK) { + else if (node->type == CMP_NODE_MASK) { nodeUpdate(ntree, node); - tagged= 1; + tagged = 1; } } - + return tagged; } @@ -934,11 +934,11 @@ int ntreeCompositTagAnimated(bNodeTree *ntree) void ntreeCompositTagGenerators(bNodeTree *ntree) { bNode *node; - - if (ntree==NULL) return; - - for (node= ntree->nodes.first; node; node= node->next) { - if ( ELEM(node->type, CMP_NODE_R_LAYERS, CMP_NODE_IMAGE)) + + if (ntree == NULL) return; + + for (node = ntree->nodes.first; node; node = node->next) { + if (ELEM(node->type, CMP_NODE_R_LAYERS, CMP_NODE_IMAGE)) nodeUpdate(ntree, node); } } @@ -947,12 +947,12 @@ void ntreeCompositTagGenerators(bNodeTree *ntree) void ntreeCompositClearTags(bNodeTree *ntree) { bNode *node; - - if (ntree==NULL) return; - - for (node= ntree->nodes.first; node; node= node->next) { - node->need_exec= 0; - if (node->type==NODE_GROUP) + + if (ntree == NULL) return; + + for (node = ntree->nodes.first; node; node = node->next) { + node->need_exec = 0; + if (node->type == NODE_GROUP) ntreeCompositClearTags((bNodeTree *)node->id); } } diff --git a/source/blender/nodes/composite/nodes/node_composite_alphaOver.c b/source/blender/nodes/composite/nodes/node_composite_alphaOver.c index 6fbff76e2dd..86eb0aa2c83 100644 --- a/source/blender/nodes/composite/nodes/node_composite_alphaOver.c +++ b/source/blender/nodes/composite/nodes/node_composite_alphaOver.c @@ -140,7 +140,7 @@ static void node_composit_exec_alphaover(void *UNUSED(data), bNode *node, bNodeS #endif /* WITH_COMPOSITOR_LEGACY */ -static void node_alphaover_init(bNodeTree *UNUSED(ntree), bNode* node, bNodeTemplate *UNUSED(ntemp)) +static void node_alphaover_init(bNodeTree *UNUSED(ntree), bNode *node, bNodeTemplate *UNUSED(ntemp)) { node->storage= MEM_callocN(sizeof(NodeTwoFloats), "NodeTwoFloats"); } diff --git a/source/blender/nodes/composite/nodes/node_composite_bokehimage.c b/source/blender/nodes/composite/nodes/node_composite_bokehimage.c index 24378c4d5b7..c5697679f90 100644 --- a/source/blender/nodes/composite/nodes/node_composite_bokehimage.c +++ b/source/blender/nodes/composite/nodes/node_composite_bokehimage.c @@ -41,7 +41,7 @@ static bNodeSocketTemplate cmp_node_bokehimage_out[]= { { SOCK_RGBA, 0, N_("Image"), 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f}, { -1, 0, "" } }; -static void node_composit_init_bokehimage(bNodeTree *UNUSED(ntree), bNode* node, bNodeTemplate *UNUSED(ntemp)) +static void node_composit_init_bokehimage(bNodeTree *UNUSED(ntree), bNode *node, bNodeTemplate *UNUSED(ntemp)) { NodeBokehImage * data = MEM_callocN(sizeof(NodeBokehImage), "NodeBokehImage"); data->angle = 0.0f; diff --git a/source/blender/nodes/composite/nodes/node_composite_boxmask.c b/source/blender/nodes/composite/nodes/node_composite_boxmask.c index 81c13980f22..1ba522c0e5f 100644 --- a/source/blender/nodes/composite/nodes/node_composite_boxmask.c +++ b/source/blender/nodes/composite/nodes/node_composite_boxmask.c @@ -46,7 +46,7 @@ static bNodeSocketTemplate cmp_node_boxmask_out[]= { { -1, 0, "" } }; -static void node_composit_init_boxmask(bNodeTree *UNUSED(ntree), bNode* node, bNodeTemplate *UNUSED(ntemp)) +static void node_composit_init_boxmask(bNodeTree *UNUSED(ntree), bNode *node, bNodeTemplate *UNUSED(ntemp)) { NodeBoxMask *data = MEM_callocN(sizeof(NodeBoxMask), "NodeBoxMask"); data->x = 0.5; diff --git a/source/blender/nodes/composite/nodes/node_composite_channelMatte.c b/source/blender/nodes/composite/nodes/node_composite_channelMatte.c index 0bd99f79d3c..cda6fa85d74 100644 --- a/source/blender/nodes/composite/nodes/node_composite_channelMatte.c +++ b/source/blender/nodes/composite/nodes/node_composite_channelMatte.c @@ -189,7 +189,7 @@ static void node_composit_exec_channel_matte(void *data, bNode *node, bNodeStack #endif /* WITH_COMPOSITOR_LEGACY */ -static void node_composit_init_channel_matte(bNodeTree *UNUSED(ntree), bNode* node, bNodeTemplate *UNUSED(ntemp)) +static void node_composit_init_channel_matte(bNodeTree *UNUSED(ntree), bNode *node, bNodeTemplate *UNUSED(ntemp)) { NodeChroma *c= MEM_callocN(sizeof(NodeChroma), "node chroma"); node->storage=c; diff --git a/source/blender/nodes/composite/nodes/node_composite_chromaMatte.c b/source/blender/nodes/composite/nodes/node_composite_chromaMatte.c index 57baa01d1d9..55ee1b090bb 100644 --- a/source/blender/nodes/composite/nodes/node_composite_chromaMatte.c +++ b/source/blender/nodes/composite/nodes/node_composite_chromaMatte.c @@ -175,7 +175,7 @@ static void node_composit_exec_chroma_matte(void *data, bNode *node, bNodeStack #endif /* WITH_COMPOSITOR_LEGACY */ -static void node_composit_init_chroma_matte(bNodeTree *UNUSED(ntree), bNode* node, bNodeTemplate *UNUSED(ntemp)) +static void node_composit_init_chroma_matte(bNodeTree *UNUSED(ntree), bNode *node, bNodeTemplate *UNUSED(ntemp)) { NodeChroma *c= MEM_callocN(sizeof(NodeChroma), "node chroma"); node->storage= c; diff --git a/source/blender/nodes/composite/nodes/node_composite_colorMatte.c b/source/blender/nodes/composite/nodes/node_composite_colorMatte.c index 9bce09b516e..37fb29811ba 100644 --- a/source/blender/nodes/composite/nodes/node_composite_colorMatte.c +++ b/source/blender/nodes/composite/nodes/node_composite_colorMatte.c @@ -116,7 +116,7 @@ static void node_composit_exec_color_matte(void *data, bNode *node, bNodeStack * #endif /* WITH_COMPOSITOR_LEGACY */ -static void node_composit_init_color_matte(bNodeTree *UNUSED(ntree), bNode* node, bNodeTemplate *UNUSED(ntemp)) +static void node_composit_init_color_matte(bNodeTree *UNUSED(ntree), bNode *node, bNodeTemplate *UNUSED(ntemp)) { NodeChroma *c= MEM_callocN(sizeof(NodeChroma), "node color"); node->storage= c; diff --git a/source/blender/nodes/composite/nodes/node_composite_colorSpill.c b/source/blender/nodes/composite/nodes/node_composite_colorSpill.c index 9456ef8e9d9..c4120ab22c6 100644 --- a/source/blender/nodes/composite/nodes/node_composite_colorSpill.c +++ b/source/blender/nodes/composite/nodes/node_composite_colorSpill.c @@ -319,7 +319,7 @@ static void node_composit_exec_color_spill(void *UNUSED(data), bNode *node, bNod #endif /* WITH_COMPOSITOR_LEGACY */ -static void node_composit_init_color_spill(bNodeTree *UNUSED(ntree), bNode* node, bNodeTemplate *UNUSED(ntemp)) +static void node_composit_init_color_spill(bNodeTree *UNUSED(ntree), bNode *node, bNodeTemplate *UNUSED(ntemp)) { NodeColorspill *ncs= MEM_callocN(sizeof(NodeColorspill), "node colorspill"); node->storage=ncs; diff --git a/source/blender/nodes/composite/nodes/node_composite_colorbalance.c b/source/blender/nodes/composite/nodes/node_composite_colorbalance.c index a8c565eff44..0868c9467e5 100644 --- a/source/blender/nodes/composite/nodes/node_composite_colorbalance.c +++ b/source/blender/nodes/composite/nodes/node_composite_colorbalance.c @@ -178,7 +178,7 @@ static void node_composit_exec_colorbalance(void *UNUSED(data), bNode *node, bNo #endif /* WITH_COMPOSITOR_LEGACY */ -static void node_composit_init_colorbalance(bNodeTree *UNUSED(ntree), bNode* node, bNodeTemplate *UNUSED(ntemp)) +static void node_composit_init_colorbalance(bNodeTree *UNUSED(ntree), bNode *node, bNodeTemplate *UNUSED(ntemp)) { NodeColorBalance *n= node->storage= MEM_callocN(sizeof(NodeColorBalance), "node colorbalance"); diff --git a/source/blender/nodes/composite/nodes/node_composite_colorcorrection.c b/source/blender/nodes/composite/nodes/node_composite_colorcorrection.c index 6b02202151c..ce43b2f0f2b 100644 --- a/source/blender/nodes/composite/nodes/node_composite_colorcorrection.c +++ b/source/blender/nodes/composite/nodes/node_composite_colorcorrection.c @@ -47,7 +47,7 @@ static bNodeSocketTemplate cmp_node_colorcorrection_out[]={ { -1,0,""} }; -static void node_composit_init_colorcorrection(bNodeTree *UNUSED(ntree), bNode* node, bNodeTemplate *UNUSED(ntemp)) +static void node_composit_init_colorcorrection(bNodeTree *UNUSED(ntree), bNode *node, bNodeTemplate *UNUSED(ntemp)) { NodeColorCorrection *n= node->storage= MEM_callocN(sizeof(NodeColorCorrection), "node colorcorrection"); n->startmidtones = 0.2f; diff --git a/source/blender/nodes/composite/nodes/node_composite_common.c b/source/blender/nodes/composite/nodes/node_composite_common.c index 90bed8e1e04..2596248d696 100644 --- a/source/blender/nodes/composite/nodes/node_composite_common.c +++ b/source/blender/nodes/composite/nodes/node_composite_common.c @@ -88,7 +88,7 @@ static void copy_stack(bNodeStack *to, bNodeStack *from) copy_v4_v4(to->vec, from->vec); to->data = from->data; to->datatype = from->datatype; - + /* tag as copy to prevent freeing */ to->is_copy = 1; } @@ -101,7 +101,7 @@ static void move_stack(bNodeStack *to, bNodeStack *from) to->data = from->data; to->datatype = from->datatype; to->is_copy = from->is_copy; - + zero_v4(from->vec); from->data = NULL; from->datatype = 0; @@ -113,19 +113,19 @@ static void move_stack(bNodeStack *to, bNodeStack *from) static void *group_initexec(bNode *node) { - bNodeTree *ngroup= (bNodeTree *)node->id; + bNodeTree *ngroup = (bNodeTree *)node->id; bNodeTreeExec *exec; bNodeSocket *sock; bNodeStack *ns; - + if (!ngroup) return NULL; - + /* initialize the internal node tree execution */ exec = ntreeCompositBeginExecTree(ngroup, 0); - + /* tag group outputs as external to prevent freeing */ - for (sock=ngroup->outputs.first; sock; sock=sock->next) { + for (sock = ngroup->outputs.first; sock; sock = sock->next) { if (!(sock->flag & SOCK_INTERNAL)) { ns = node_get_socket_stack(exec->stack, sock); ns->external = 1; @@ -137,8 +137,8 @@ static void *group_initexec(bNode *node) static void group_freeexec(bNode *UNUSED(node), void *nodedata) { - bNodeTreeExec *gexec= (bNodeTreeExec *)nodedata; - + bNodeTreeExec *gexec = (bNodeTreeExec *)nodedata; + if (gexec) ntreeCompositEndExecTree(gexec, 0); } @@ -166,7 +166,7 @@ static void group_move_outputs(bNode *node, bNodeStack **out, bNodeStack *gstack bNodeSocket *sock; bNodeStack *ns; int a; - for (sock=node->outputs.first, a=0; sock; sock=sock->next, ++a) { + for (sock = node->outputs.first, a = 0; sock; sock = sock->next, ++a) { if (sock->groupsock) { ns = node_get_socket_stack(gstack, sock->groupsock); move_stack(out[a], ns); @@ -179,8 +179,8 @@ static void group_free_internal(bNodeTreeExec *gexec) { bNodeStack *ns; int i; - - for (i=0, ns=gexec->stack; i < gexec->stacksize; ++i, ++ns) { + + for (i = 0, ns = gexec->stack; i < gexec->stacksize; ++i, ++ns) { if (!ns->external && !ns->is_copy) { if (ns->data) { #ifdef WITH_COMPOSITOR_LEGACY @@ -218,7 +218,7 @@ void register_node_type_cmp_group(bNodeTreeType *ttype) { static bNodeType ntype; - node_type_base(ttype, &ntype, NODE_GROUP, "Group", NODE_CLASS_GROUP, NODE_OPTIONS|NODE_CONST_OUTPUT); + node_type_base(ttype, &ntype, NODE_GROUP, "Group", NODE_CLASS_GROUP, NODE_OPTIONS | NODE_CONST_OUTPUT); node_type_socket_templates(&ntype, NULL, NULL); node_type_size(&ntype, 120, 60, 200); node_type_label(&ntype, node_group_label); @@ -228,7 +228,7 @@ void register_node_type_cmp_group(bNodeTreeType *ttype) node_type_update(&ntype, NULL, node_group_verify); node_type_group_edit(&ntype, node_group_edit_get, node_group_edit_set, node_group_edit_clear); node_type_exec_new(&ntype, group_initexec, group_freeexec, group_execute); - + nodeRegisterType(ttype, &ntype); } diff --git a/source/blender/nodes/composite/nodes/node_composite_crop.c b/source/blender/nodes/composite/nodes/node_composite_crop.c index ed4bd857361..9b1483d95cf 100644 --- a/source/blender/nodes/composite/nodes/node_composite_crop.c +++ b/source/blender/nodes/composite/nodes/node_composite_crop.c @@ -105,7 +105,7 @@ static void node_composit_exec_crop(void *UNUSED(data), bNode *node, bNodeStack #endif /* WITH_COMPOSITOR_LEGACY */ -static void node_composit_init_crop(bNodeTree *UNUSED(ntree), bNode* node, bNodeTemplate *UNUSED(ntemp)) +static void node_composit_init_crop(bNodeTree *UNUSED(ntree), bNode *node, bNodeTemplate *UNUSED(ntemp)) { NodeTwoXYs *nxy= MEM_callocN(sizeof(NodeTwoXYs), "node xy data"); node->storage= nxy; diff --git a/source/blender/nodes/composite/nodes/node_composite_curves.c b/source/blender/nodes/composite/nodes/node_composite_curves.c index ddc93e94061..1948709ec84 100644 --- a/source/blender/nodes/composite/nodes/node_composite_curves.c +++ b/source/blender/nodes/composite/nodes/node_composite_curves.c @@ -60,7 +60,7 @@ static void node_composit_exec_curves_time(void *data, bNode *node, bNodeStack * #endif /* WITH_COMPOSITOR_LEGACY */ -static void node_composit_init_curves_time(bNodeTree *UNUSED(ntree), bNode* node, bNodeTemplate *UNUSED(ntemp)) +static void node_composit_init_curves_time(bNodeTree *UNUSED(ntree), bNode *node, bNodeTemplate *UNUSED(ntemp)) { node->custom1= 1; node->custom2= 250; @@ -109,7 +109,7 @@ static void node_composit_exec_curve_vec(void *UNUSED(data), bNode *node, bNodeS #endif /* WITH_COMPOSITOR_LEGACY */ -static void node_composit_init_curve_vec(bNodeTree *UNUSED(ntree), bNode* node, bNodeTemplate *UNUSED(ntemp)) +static void node_composit_init_curve_vec(bNodeTree *UNUSED(ntree), bNode *node, bNodeTemplate *UNUSED(ntemp)) { node->storage= curvemapping_add(3, -1.0f, -1.0f, 1.0f, 1.0f); } @@ -206,7 +206,7 @@ static void node_composit_exec_curve_rgb(void *UNUSED(data), bNode *node, bNodeS #endif /* WITH_COMPOSITOR_LEGACY */ -static void node_composit_init_curve_rgb(bNodeTree *UNUSED(ntree), bNode* node, bNodeTemplate *UNUSED(ntemp)) +static void node_composit_init_curve_rgb(bNodeTree *UNUSED(ntree), bNode *node, bNodeTemplate *UNUSED(ntemp)) { node->storage= curvemapping_add(4, 0.0f, 0.0f, 1.0f, 1.0f); } diff --git a/source/blender/nodes/composite/nodes/node_composite_defocus.c b/source/blender/nodes/composite/nodes/node_composite_defocus.c index e3d54213719..1a9852264bf 100644 --- a/source/blender/nodes/composite/nodes/node_composite_defocus.c +++ b/source/blender/nodes/composite/nodes/node_composite_defocus.c @@ -868,7 +868,7 @@ static void node_composit_exec_defocus(void *UNUSED(data), bNode *node, bNodeSta #endif /* WITH_COMPOSITOR_LEGACY */ -static void node_composit_init_defocus(bNodeTree *UNUSED(ntree), bNode* node, bNodeTemplate *UNUSED(ntemp)) +static void node_composit_init_defocus(bNodeTree *UNUSED(ntree), bNode *node, bNodeTemplate *UNUSED(ntemp)) { /* qdn: defocus node */ NodeDefocus *nbd = MEM_callocN(sizeof(NodeDefocus), "node defocus data"); diff --git a/source/blender/nodes/composite/nodes/node_composite_despeckle.c b/source/blender/nodes/composite/nodes/node_composite_despeckle.c index 86c5a0b467c..21b703dc9a8 100644 --- a/source/blender/nodes/composite/nodes/node_composite_despeckle.c +++ b/source/blender/nodes/composite/nodes/node_composite_despeckle.c @@ -51,7 +51,7 @@ static void node_composit_exec_despeckle(void *UNUSED(data), bNode *UNUSED(node) #endif /* WITH_COMPOSITOR_LEGACY */ -static void node_composit_init_despeckle(bNodeTree *UNUSED(ntree), bNode* node, bNodeTemplate *UNUSED(ntemp)) +static void node_composit_init_despeckle(bNodeTree *UNUSED(ntree), bNode *node, bNodeTemplate *UNUSED(ntemp)) { node->custom3 = 0.5f; node->custom4 = 0.5f; diff --git a/source/blender/nodes/composite/nodes/node_composite_diffMatte.c b/source/blender/nodes/composite/nodes/node_composite_diffMatte.c index ff4d98dfea4..ed43baef420 100644 --- a/source/blender/nodes/composite/nodes/node_composite_diffMatte.c +++ b/source/blender/nodes/composite/nodes/node_composite_diffMatte.c @@ -130,7 +130,7 @@ static void node_composit_exec_diff_matte(void *data, bNode *node, bNodeStack ** #endif /* WITH_COMPOSITOR_LEGACY */ -static void node_composit_init_diff_matte(bNodeTree *UNUSED(ntree), bNode* node, bNodeTemplate *UNUSED(ntemp)) +static void node_composit_init_diff_matte(bNodeTree *UNUSED(ntree), bNode *node, bNodeTemplate *UNUSED(ntemp)) { NodeChroma *c= MEM_callocN(sizeof(NodeChroma), "node chroma"); node->storage= c; diff --git a/source/blender/nodes/composite/nodes/node_composite_dilate.c b/source/blender/nodes/composite/nodes/node_composite_dilate.c index d8dc44c7260..f53c64b990a 100644 --- a/source/blender/nodes/composite/nodes/node_composite_dilate.c +++ b/source/blender/nodes/composite/nodes/node_composite_dilate.c @@ -150,7 +150,7 @@ static void node_composit_exec_dilateerode(void *UNUSED(data), bNode *node, bNod #endif /* WITH_COMPOSITOR_LEGACY */ -static void node_composit_init_dilateerode(bNodeTree *UNUSED(ntree), bNode* node, bNodeTemplate *UNUSED(ntemp)) +static void node_composit_init_dilateerode(bNodeTree *UNUSED(ntree), bNode *node, bNodeTemplate *UNUSED(ntemp)) { NodeDilateErode *data = MEM_callocN(sizeof(NodeDilateErode), "NodeDilateErode"); data->falloff = PROP_SMOOTH; diff --git a/source/blender/nodes/composite/nodes/node_composite_distanceMatte.c b/source/blender/nodes/composite/nodes/node_composite_distanceMatte.c index 7b3dbdb6a58..7a101ff43b5 100644 --- a/source/blender/nodes/composite/nodes/node_composite_distanceMatte.c +++ b/source/blender/nodes/composite/nodes/node_composite_distanceMatte.c @@ -186,7 +186,7 @@ static void node_composit_exec_distance_matte(void *data, bNode *node, bNodeStac #endif /* WITH_COMPOSITOR_LEGACY */ -static void node_composit_init_distance_matte(bNodeTree *UNUSED(ntree), bNode* node, bNodeTemplate *UNUSED(ntemp)) +static void node_composit_init_distance_matte(bNodeTree *UNUSED(ntree), bNode *node, bNodeTemplate *UNUSED(ntemp)) { NodeChroma *c= MEM_callocN(sizeof(NodeChroma), "node chroma"); node->storage= c; diff --git a/source/blender/nodes/composite/nodes/node_composite_ellipsemask.c b/source/blender/nodes/composite/nodes/node_composite_ellipsemask.c index 18a86680245..a97322a17c0 100644 --- a/source/blender/nodes/composite/nodes/node_composite_ellipsemask.c +++ b/source/blender/nodes/composite/nodes/node_composite_ellipsemask.c @@ -46,7 +46,7 @@ static bNodeSocketTemplate cmp_node_ellipsemask_out[]= { { -1, 0, "" } }; -static void node_composit_init_ellipsemask(bNodeTree *UNUSED(ntree), bNode* node, bNodeTemplate *UNUSED(ntemp)) +static void node_composit_init_ellipsemask(bNodeTree *UNUSED(ntree), bNode *node, bNodeTemplate *UNUSED(ntemp)) { NodeEllipseMask *data = MEM_callocN(sizeof(NodeEllipseMask), "NodeEllipseMask"); data->x = 0.5; diff --git a/source/blender/nodes/composite/nodes/node_composite_glare.c b/source/blender/nodes/composite/nodes/node_composite_glare.c index 6989bf59d79..7d6c0cb1a29 100644 --- a/source/blender/nodes/composite/nodes/node_composite_glare.c +++ b/source/blender/nodes/composite/nodes/node_composite_glare.c @@ -477,7 +477,7 @@ static void node_composit_exec_glare(void *UNUSED(data), bNode *node, bNodeStack #endif /* WITH_COMPOSITOR_LEGACY */ -static void node_composit_init_glare(bNodeTree *UNUSED(ntree), bNode* node, bNodeTemplate *UNUSED(ntemp)) +static void node_composit_init_glare(bNodeTree *UNUSED(ntree), bNode *node, bNodeTemplate *UNUSED(ntemp)) { NodeGlare *ndg = MEM_callocN(sizeof(NodeGlare), "node glare data"); ndg->quality = 1; diff --git a/source/blender/nodes/composite/nodes/node_composite_hueSatVal.c b/source/blender/nodes/composite/nodes/node_composite_hueSatVal.c index 7a1ec9e324a..c8784ceedb7 100644 --- a/source/blender/nodes/composite/nodes/node_composite_hueSatVal.c +++ b/source/blender/nodes/composite/nodes/node_composite_hueSatVal.c @@ -97,7 +97,7 @@ static void node_composit_exec_hue_sat(void *UNUSED(data), bNode *node, bNodeSta #endif /* WITH_COMPOSITOR_LEGACY */ -static void node_composit_init_hue_sat(bNodeTree *UNUSED(ntree), bNode* node, bNodeTemplate *UNUSED(ntemp)) +static void node_composit_init_hue_sat(bNodeTree *UNUSED(ntree), bNode *node, bNodeTemplate *UNUSED(ntemp)) { NodeHueSat *nhs= MEM_callocN(sizeof(NodeHueSat), "node hue sat"); node->storage= nhs; diff --git a/source/blender/nodes/composite/nodes/node_composite_huecorrect.c b/source/blender/nodes/composite/nodes/node_composite_huecorrect.c index 7e3f6a5fb3a..42077cd5c06 100644 --- a/source/blender/nodes/composite/nodes/node_composite_huecorrect.c +++ b/source/blender/nodes/composite/nodes/node_composite_huecorrect.c @@ -143,7 +143,7 @@ static void node_composit_exec_huecorrect(void *UNUSED(data), bNode *node, bNode #endif /* WITH_COMPOSITOR_LEGACY */ -static void node_composit_init_huecorrect(bNodeTree *UNUSED(ntree), bNode* node, bNodeTemplate *UNUSED(ntemp)) +static void node_composit_init_huecorrect(bNodeTree *UNUSED(ntree), bNode *node, bNodeTemplate *UNUSED(ntemp)) { CurveMapping *cumapping = node->storage= curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f); int c; diff --git a/source/blender/nodes/composite/nodes/node_composite_image.c b/source/blender/nodes/composite/nodes/node_composite_image.c index a3c65901121..96a92055ca9 100644 --- a/source/blender/nodes/composite/nodes/node_composite_image.c +++ b/source/blender/nodes/composite/nodes/node_composite_image.c @@ -523,7 +523,7 @@ static void node_composit_exec_image(void *data, bNode *node, bNodeStack **UNUSE #endif /* WITH_COMPOSITOR_LEGACY */ -static void node_composit_init_image(bNodeTree *ntree, bNode* node, bNodeTemplate *UNUSED(ntemp)) +static void node_composit_init_image(bNodeTree *ntree, bNode *node, bNodeTemplate *UNUSED(ntemp)) { ImageUser *iuser= MEM_callocN(sizeof(ImageUser), "node image user"); node->storage= iuser; diff --git a/source/blender/nodes/composite/nodes/node_composite_invert.c b/source/blender/nodes/composite/nodes/node_composite_invert.c index 3518f90c027..b0e656b173b 100644 --- a/source/blender/nodes/composite/nodes/node_composite_invert.c +++ b/source/blender/nodes/composite/nodes/node_composite_invert.c @@ -119,7 +119,7 @@ static void node_composit_exec_invert(void *UNUSED(data), bNode *node, bNodeStac #endif /* WITH_COMPOSITOR_LEGACY */ -static void node_composit_init_invert(bNodeTree *UNUSED(ntree), bNode* node, bNodeTemplate *UNUSED(ntemp)) +static void node_composit_init_invert(bNodeTree *UNUSED(ntree), bNode *node, bNodeTemplate *UNUSED(ntemp)) { node->custom1 |= CMP_CHAN_RGB; } diff --git a/source/blender/nodes/composite/nodes/node_composite_keying.c b/source/blender/nodes/composite/nodes/node_composite_keying.c index b9721910fd1..6553df350ff 100644 --- a/source/blender/nodes/composite/nodes/node_composite_keying.c +++ b/source/blender/nodes/composite/nodes/node_composite_keying.c @@ -67,7 +67,7 @@ static void node_composit_exec_keying(void *UNUSED(data), bNode *UNUSED(node), b } #endif /* WITH_COMPOSITOR_LEGACY */ -static void node_composit_init_keying(bNodeTree *UNUSED(ntree), bNode* node, bNodeTemplate *UNUSED(ntemp)) +static void node_composit_init_keying(bNodeTree *UNUSED(ntree), bNode *node, bNodeTemplate *UNUSED(ntemp)) { NodeKeyingData *data; diff --git a/source/blender/nodes/composite/nodes/node_composite_keyingscreen.c b/source/blender/nodes/composite/nodes/node_composite_keyingscreen.c index 3fc4781fdc3..e16b7e5d885 100644 --- a/source/blender/nodes/composite/nodes/node_composite_keyingscreen.c +++ b/source/blender/nodes/composite/nodes/node_composite_keyingscreen.c @@ -181,7 +181,7 @@ static void node_composit_exec_keyingscreen(void *data, bNode *node, bNodeStack #endif /* WITH_COMPOSITOR_LEGACY */ -static void node_composit_init_keyingscreen(bNodeTree *UNUSED(ntree), bNode* node, bNodeTemplate *UNUSED(ntemp)) +static void node_composit_init_keyingscreen(bNodeTree *UNUSED(ntree), bNode *node, bNodeTemplate *UNUSED(ntemp)) { NodeKeyingScreenData *data; diff --git a/source/blender/nodes/composite/nodes/node_composite_lensdist.c b/source/blender/nodes/composite/nodes/node_composite_lensdist.c index 22281a74016..a4983cce8b8 100644 --- a/source/blender/nodes/composite/nodes/node_composite_lensdist.c +++ b/source/blender/nodes/composite/nodes/node_composite_lensdist.c @@ -186,7 +186,7 @@ static void node_composit_exec_lensdist(void *UNUSED(data), bNode *node, bNodeSt #endif /* WITH_COMPOSITOR_LEGACY */ -static void node_composit_init_lensdist(bNodeTree *UNUSED(ntree), bNode* node, bNodeTemplate *UNUSED(ntemp)) +static void node_composit_init_lensdist(bNodeTree *UNUSED(ntree), bNode *node, bNodeTemplate *UNUSED(ntemp)) { NodeLensDist *nld = MEM_callocN(sizeof(NodeLensDist), "node lensdist data"); nld->jit = nld->proj = nld->fit = 0; diff --git a/source/blender/nodes/composite/nodes/node_composite_levels.c b/source/blender/nodes/composite/nodes/node_composite_levels.c index dfcfb4125f0..601516c5bb0 100644 --- a/source/blender/nodes/composite/nodes/node_composite_levels.c +++ b/source/blender/nodes/composite/nodes/node_composite_levels.c @@ -47,7 +47,7 @@ static bNodeSocketTemplate cmp_node_view_levels_out[]={ #ifdef WITH_COMPOSITOR_LEGACY -static void fill_bins(bNode* node, CompBuf* in, int* bins) +static void fill_bins(bNode *node, CompBuf* in, int* bins) { float value[4]; int ivalue=0; @@ -104,7 +104,7 @@ static void fill_bins(bNode* node, CompBuf* in, int* bins) } } -static float brightness_mean(bNode* node, CompBuf* in) +static float brightness_mean(bNode *node, CompBuf* in) { float sum=0.0; int numPixels=0.0; @@ -155,7 +155,7 @@ static float brightness_mean(bNode* node, CompBuf* in) return sum/numPixels; } -static float brightness_standard_deviation(bNode* node, CompBuf* in, float mean) +static float brightness_standard_deviation(bNode *node, CompBuf* in, float mean) { float sum=0.0; int numPixels=0.0; @@ -313,7 +313,7 @@ static void node_composit_exec_view_levels(void *data, bNode *node, bNodeStack * #endif /* WITH_COMPOSITOR_LEGACY */ -static void node_composit_init_view_levels(bNodeTree *UNUSED(ntree), bNode* node, bNodeTemplate *UNUSED(ntemp)) +static void node_composit_init_view_levels(bNodeTree *UNUSED(ntree), bNode *node, bNodeTemplate *UNUSED(ntemp)) { node->custom1=1; /*All channels*/ } diff --git a/source/blender/nodes/composite/nodes/node_composite_lummaMatte.c b/source/blender/nodes/composite/nodes/node_composite_lummaMatte.c index a4f6ffe746c..61cd4493f39 100644 --- a/source/blender/nodes/composite/nodes/node_composite_lummaMatte.c +++ b/source/blender/nodes/composite/nodes/node_composite_lummaMatte.c @@ -100,7 +100,7 @@ static void node_composit_exec_luma_matte(void *data, bNode *node, bNodeStack ** #endif /* WITH_COMPOSITOR_LEGACY */ -static void node_composit_init_luma_matte(bNodeTree *UNUSED(ntree), bNode* node, bNodeTemplate *UNUSED(ntemp)) +static void node_composit_init_luma_matte(bNodeTree *UNUSED(ntree), bNode *node, bNodeTemplate *UNUSED(ntemp)) { NodeChroma *c= MEM_callocN(sizeof(NodeChroma), "node chroma"); node->storage=c; diff --git a/source/blender/nodes/composite/nodes/node_composite_mapValue.c b/source/blender/nodes/composite/nodes/node_composite_mapValue.c index 49dc7323271..be69c11b35f 100644 --- a/source/blender/nodes/composite/nodes/node_composite_mapValue.c +++ b/source/blender/nodes/composite/nodes/node_composite_mapValue.c @@ -80,7 +80,7 @@ static void node_composit_exec_map_value(void *UNUSED(data), bNode *node, bNodeS #endif /* WITH_COMPOSITOR_LEGACY */ -static void node_composit_init_map_value(bNodeTree *UNUSED(ntree), bNode* node, bNodeTemplate *UNUSED(ntemp)) +static void node_composit_init_map_value(bNodeTree *UNUSED(ntree), bNode *node, bNodeTemplate *UNUSED(ntemp)) { node->storage= add_tex_mapping(); } diff --git a/source/blender/nodes/composite/nodes/node_composite_mask.c b/source/blender/nodes/composite/nodes/node_composite_mask.c index 5c5bc2a9778..3463c1a8413 100644 --- a/source/blender/nodes/composite/nodes/node_composite_mask.c +++ b/source/blender/nodes/composite/nodes/node_composite_mask.c @@ -87,7 +87,7 @@ static void node_composit_exec_mask(void *data, bNode *node, bNodeStack **UNUSED } #endif /* WITH_COMPOSITOR_LEGACY */ -static void node_composit_init_mask(bNodeTree *UNUSED(ntree), bNode* node, bNodeTemplate *UNUSED(ntemp)) +static void node_composit_init_mask(bNodeTree *UNUSED(ntree), bNode *node, bNodeTemplate *UNUSED(ntemp)) { NodeMask *data = MEM_callocN(sizeof(NodeMask), STRINGIFY(NodeMask)); data->size_x = data->size_y = 256; diff --git a/source/blender/nodes/composite/nodes/node_composite_outputFile.c b/source/blender/nodes/composite/nodes/node_composite_outputFile.c index aa92e713adf..399cb1d1557 100644 --- a/source/blender/nodes/composite/nodes/node_composite_outputFile.c +++ b/source/blender/nodes/composite/nodes/node_composite_outputFile.c @@ -166,7 +166,7 @@ void ntreeCompositOutputFileSetLayer(bNode *node, bNodeSocket *sock, const char ntreeCompositOutputFileUniqueLayer(&node->inputs, sock, name, '_'); } -static void init_output_file(bNodeTree *ntree, bNode* node, bNodeTemplate *ntemp) +static void init_output_file(bNodeTree *ntree, bNode *node, bNodeTemplate *ntemp) { NodeImageMultiFile *nimf= MEM_callocN(sizeof(NodeImageMultiFile), "node image multi file"); ImageFormatData *format = NULL; diff --git a/source/blender/nodes/composite/nodes/node_composite_rotate.c b/source/blender/nodes/composite/nodes/node_composite_rotate.c index 87dc1e92438..8968fd5fb3a 100644 --- a/source/blender/nodes/composite/nodes/node_composite_rotate.c +++ b/source/blender/nodes/composite/nodes/node_composite_rotate.c @@ -125,7 +125,7 @@ static void node_composit_exec_rotate(void *UNUSED(data), bNode *node, bNodeStac #endif /* WITH_COMPOSITOR_LEGACY */ -static void node_composit_init_rotate(bNodeTree *UNUSED(ntree), bNode* node, bNodeTemplate *UNUSED(ntemp)) +static void node_composit_init_rotate(bNodeTree *UNUSED(ntree), bNode *node, bNodeTemplate *UNUSED(ntemp)) { node->custom1= 1; /* Bilinear Filter*/ } diff --git a/source/blender/nodes/composite/nodes/node_composite_splitViewer.c b/source/blender/nodes/composite/nodes/node_composite_splitViewer.c index 420718f8dd9..f6811f526f7 100644 --- a/source/blender/nodes/composite/nodes/node_composite_splitViewer.c +++ b/source/blender/nodes/composite/nodes/node_composite_splitViewer.c @@ -143,7 +143,7 @@ static void node_composit_exec_splitviewer(void *data, bNode *node, bNodeStack * #endif /* WITH_COMPOSITOR_LEGACY */ -static void node_composit_init_splitviewer(bNodeTree *UNUSED(ntree), bNode* node, bNodeTemplate *UNUSED(ntemp)) +static void node_composit_init_splitviewer(bNodeTree *UNUSED(ntree), bNode *node, bNodeTemplate *UNUSED(ntemp)) { ImageUser *iuser= MEM_callocN(sizeof(ImageUser), "node image user"); node->storage= iuser; diff --git a/source/blender/nodes/composite/nodes/node_composite_tonemap.c b/source/blender/nodes/composite/nodes/node_composite_tonemap.c index d0ead67431c..5e4efe2f3b1 100644 --- a/source/blender/nodes/composite/nodes/node_composite_tonemap.c +++ b/source/blender/nodes/composite/nodes/node_composite_tonemap.c @@ -149,7 +149,7 @@ static void node_composit_exec_tonemap(void *UNUSED(data), bNode *node, bNodeSta #endif /* WITH_COMPOSITOR_LEGACY */ -static void node_composit_init_tonemap(bNodeTree *UNUSED(ntree), bNode* node, bNodeTemplate *UNUSED(ntemp)) +static void node_composit_init_tonemap(bNodeTree *UNUSED(ntree), bNode *node, bNodeTemplate *UNUSED(ntemp)) { NodeTonemap *ntm = MEM_callocN(sizeof(NodeTonemap), "node tonemap data"); ntm->type = 1; diff --git a/source/blender/nodes/composite/nodes/node_composite_valToRgb.c b/source/blender/nodes/composite/nodes/node_composite_valToRgb.c index b3b6218a265..87a776c7bea 100644 --- a/source/blender/nodes/composite/nodes/node_composite_valToRgb.c +++ b/source/blender/nodes/composite/nodes/node_composite_valToRgb.c @@ -82,7 +82,7 @@ static void node_composit_exec_valtorgb(void *UNUSED(data), bNode *node, bNodeSt #endif /* WITH_COMPOSITOR_LEGACY */ -static void node_composit_init_valtorgb(bNodeTree *UNUSED(ntree), bNode* node, bNodeTemplate *UNUSED(ntemp)) +static void node_composit_init_valtorgb(bNodeTree *UNUSED(ntree), bNode *node, bNodeTemplate *UNUSED(ntemp)) { node->storage= add_colorband(1); } diff --git a/source/blender/nodes/intern/node_common.c b/source/blender/nodes/intern/node_common.c index 8e550ef3d4b..ffa636fa952 100644 --- a/source/blender/nodes/intern/node_common.c +++ b/source/blender/nodes/intern/node_common.c @@ -571,7 +571,7 @@ static ListBase node_reroute_internal_connect(bNodeTree *ntree, bNode *node) return ret; } -static void node_reroute_init(bNodeTree *ntree, bNode* node, bNodeTemplate *UNUSED(ntemp)) +static void node_reroute_init(bNodeTree *ntree, bNode *node, bNodeTemplate *UNUSED(ntemp)) { /* Note: Cannot use socket templates for this, since it would reset the socket type * on each file read via the template verification procedure. diff --git a/source/blender/nodes/shader/nodes/node_shader_attribute.c b/source/blender/nodes/shader/nodes/node_shader_attribute.c index 2821c3e3fe6..9c65323337e 100644 --- a/source/blender/nodes/shader/nodes/node_shader_attribute.c +++ b/source/blender/nodes/shader/nodes/node_shader_attribute.c @@ -36,7 +36,7 @@ static bNodeSocketTemplate sh_node_attribute_out[]= { { -1, 0, "" } }; -static void node_shader_init_attribute(bNodeTree *UNUSED(ntree), bNode* node, bNodeTemplate *UNUSED(ntemp)) +static void node_shader_init_attribute(bNodeTree *UNUSED(ntree), bNode *node, bNodeTemplate *UNUSED(ntemp)) { NodeShaderAttribute *attr = MEM_callocN(sizeof(NodeShaderAttribute), "NodeShaderAttribute"); node->storage = attr; diff --git a/source/blender/nodes/shader/nodes/node_shader_curves.c b/source/blender/nodes/shader/nodes/node_shader_curves.c index 512182ebe12..0c08f1bc215 100644 --- a/source/blender/nodes/shader/nodes/node_shader_curves.c +++ b/source/blender/nodes/shader/nodes/node_shader_curves.c @@ -55,7 +55,7 @@ static void node_shader_exec_curve_vec(void *UNUSED(data), bNode *node, bNodeSta curvemapping_evaluate3F(node->storage, out[0]->vec, vec); } -static void node_shader_init_curve_vec(bNodeTree *UNUSED(ntree), bNode* node, bNodeTemplate *UNUSED(ntemp)) +static void node_shader_init_curve_vec(bNodeTree *UNUSED(ntree), bNode *node, bNodeTemplate *UNUSED(ntemp)) { node->storage= curvemapping_add(3, -1.0f, -1.0f, 1.0f, 1.0f); } @@ -112,7 +112,7 @@ static void node_shader_exec_curve_rgb(void *UNUSED(data), bNode *node, bNodeSta } } -static void node_shader_init_curve_rgb(bNodeTree *UNUSED(ntree), bNode* node, bNodeTemplate *UNUSED(ntemp)) +static void node_shader_init_curve_rgb(bNodeTree *UNUSED(ntree), bNode *node, bNodeTemplate *UNUSED(ntemp)) { node->storage= curvemapping_add(4, 0.0f, 0.0f, 1.0f, 1.0f); } diff --git a/source/blender/nodes/shader/nodes/node_shader_geom.c b/source/blender/nodes/shader/nodes/node_shader_geom.c index aa108271ec3..f23158ab5d4 100644 --- a/source/blender/nodes/shader/nodes/node_shader_geom.c +++ b/source/blender/nodes/shader/nodes/node_shader_geom.c @@ -120,7 +120,7 @@ static void node_shader_exec_geom(void *data, bNode *node, bNodeStack **UNUSED(i } } -static void node_shader_init_geometry(bNodeTree *UNUSED(ntree), bNode* node, bNodeTemplate *UNUSED(ntemp)) +static void node_shader_init_geometry(bNodeTree *UNUSED(ntree), bNode *node, bNodeTemplate *UNUSED(ntemp)) { node->storage= MEM_callocN(sizeof(NodeGeometry), "NodeGeometry"); } diff --git a/source/blender/nodes/shader/nodes/node_shader_mapping.c b/source/blender/nodes/shader/nodes/node_shader_mapping.c index c260cc421b3..4508f66543e 100644 --- a/source/blender/nodes/shader/nodes/node_shader_mapping.c +++ b/source/blender/nodes/shader/nodes/node_shader_mapping.c @@ -67,7 +67,7 @@ static void node_shader_exec_mapping(void *UNUSED(data), bNode *node, bNodeStack } -static void node_shader_init_mapping(bNodeTree *UNUSED(ntree), bNode* node, bNodeTemplate *UNUSED(ntemp)) +static void node_shader_init_mapping(bNodeTree *UNUSED(ntree), bNode *node, bNodeTemplate *UNUSED(ntemp)) { node->storage= add_tex_mapping(); } diff --git a/source/blender/nodes/shader/nodes/node_shader_material.c b/source/blender/nodes/shader/nodes/node_shader_material.c index 758660f7d0c..57865e072e7 100644 --- a/source/blender/nodes/shader/nodes/node_shader_material.c +++ b/source/blender/nodes/shader/nodes/node_shader_material.c @@ -200,7 +200,7 @@ static void node_shader_exec_material(void *data, bNode *node, bNodeStack **in, } -static void node_shader_init_material(bNodeTree *UNUSED(ntree), bNode* node, bNodeTemplate *UNUSED(ntemp)) +static void node_shader_init_material(bNodeTree *UNUSED(ntree), bNode *node, bNodeTemplate *UNUSED(ntemp)) { node->custom1= SH_NODE_MAT_DIFF|SH_NODE_MAT_SPEC; } diff --git a/source/blender/nodes/shader/nodes/node_shader_tex_checker.c b/source/blender/nodes/shader/nodes/node_shader_tex_checker.c index dda451004a3..0c1e7dcb995 100644 --- a/source/blender/nodes/shader/nodes/node_shader_tex_checker.c +++ b/source/blender/nodes/shader/nodes/node_shader_tex_checker.c @@ -43,7 +43,7 @@ static bNodeSocketTemplate sh_node_tex_checker_out[]= { { -1, 0, "" } }; -static void node_shader_init_tex_checker(bNodeTree *UNUSED(ntree), bNode* node, bNodeTemplate *UNUSED(ntemp)) +static void node_shader_init_tex_checker(bNodeTree *UNUSED(ntree), bNode *node, bNodeTemplate *UNUSED(ntemp)) { NodeTexChecker *tex = MEM_callocN(sizeof(NodeTexChecker), "NodeTexChecker"); default_tex_mapping(&tex->base.tex_mapping); diff --git a/source/blender/nodes/shader/nodes/node_shader_tex_environment.c b/source/blender/nodes/shader/nodes/node_shader_tex_environment.c index e3300c89a01..572f06e007b 100644 --- a/source/blender/nodes/shader/nodes/node_shader_tex_environment.c +++ b/source/blender/nodes/shader/nodes/node_shader_tex_environment.c @@ -39,7 +39,7 @@ static bNodeSocketTemplate sh_node_tex_environment_out[]= { { -1, 0, "" } }; -static void node_shader_init_tex_environment(bNodeTree *UNUSED(ntree), bNode* node, bNodeTemplate *UNUSED(ntemp)) +static void node_shader_init_tex_environment(bNodeTree *UNUSED(ntree), bNode *node, bNodeTemplate *UNUSED(ntemp)) { NodeTexEnvironment *tex = MEM_callocN(sizeof(NodeTexEnvironment), "NodeTexEnvironment"); default_tex_mapping(&tex->base.tex_mapping); diff --git a/source/blender/nodes/shader/nodes/node_shader_tex_gradient.c b/source/blender/nodes/shader/nodes/node_shader_tex_gradient.c index 20a524ad00c..a7f869155fa 100644 --- a/source/blender/nodes/shader/nodes/node_shader_tex_gradient.c +++ b/source/blender/nodes/shader/nodes/node_shader_tex_gradient.c @@ -40,7 +40,7 @@ static bNodeSocketTemplate sh_node_tex_gradient_out[]= { { -1, 0, "" } }; -static void node_shader_init_tex_gradient(bNodeTree *UNUSED(ntree), bNode* node, bNodeTemplate *UNUSED(ntemp)) +static void node_shader_init_tex_gradient(bNodeTree *UNUSED(ntree), bNode *node, bNodeTemplate *UNUSED(ntemp)) { NodeTexGradient *tex = MEM_callocN(sizeof(NodeTexGradient), "NodeTexGradient"); default_tex_mapping(&tex->base.tex_mapping); diff --git a/source/blender/nodes/shader/nodes/node_shader_tex_image.c b/source/blender/nodes/shader/nodes/node_shader_tex_image.c index d4d43c1430c..176c50bcabb 100644 --- a/source/blender/nodes/shader/nodes/node_shader_tex_image.c +++ b/source/blender/nodes/shader/nodes/node_shader_tex_image.c @@ -40,7 +40,7 @@ static bNodeSocketTemplate sh_node_tex_image_out[]= { { -1, 0, "" } }; -static void node_shader_init_tex_image(bNodeTree *UNUSED(ntree), bNode* node, bNodeTemplate *UNUSED(ntemp)) +static void node_shader_init_tex_image(bNodeTree *UNUSED(ntree), bNode *node, bNodeTemplate *UNUSED(ntemp)) { NodeTexImage *tex = MEM_callocN(sizeof(NodeTexImage), "NodeTexImage"); default_tex_mapping(&tex->base.tex_mapping); diff --git a/source/blender/nodes/shader/nodes/node_shader_tex_magic.c b/source/blender/nodes/shader/nodes/node_shader_tex_magic.c index 8d7607a9c72..b9f1b5c1d21 100644 --- a/source/blender/nodes/shader/nodes/node_shader_tex_magic.c +++ b/source/blender/nodes/shader/nodes/node_shader_tex_magic.c @@ -42,7 +42,7 @@ static bNodeSocketTemplate sh_node_tex_magic_out[]= { { -1, 0, "" } }; -static void node_shader_init_tex_magic(bNodeTree *UNUSED(ntree), bNode* node, bNodeTemplate *UNUSED(ntemp)) +static void node_shader_init_tex_magic(bNodeTree *UNUSED(ntree), bNode *node, bNodeTemplate *UNUSED(ntemp)) { NodeTexMagic *tex = MEM_callocN(sizeof(NodeTexMagic), "NodeTexMagic"); default_tex_mapping(&tex->base.tex_mapping); diff --git a/source/blender/nodes/shader/nodes/node_shader_tex_musgrave.c b/source/blender/nodes/shader/nodes/node_shader_tex_musgrave.c index e71695df680..60b4f65f0b4 100644 --- a/source/blender/nodes/shader/nodes/node_shader_tex_musgrave.c +++ b/source/blender/nodes/shader/nodes/node_shader_tex_musgrave.c @@ -46,7 +46,7 @@ static bNodeSocketTemplate sh_node_tex_musgrave_out[]= { { -1, 0, "" } }; -static void node_shader_init_tex_musgrave(bNodeTree *UNUSED(ntree), bNode* node, bNodeTemplate *UNUSED(ntemp)) +static void node_shader_init_tex_musgrave(bNodeTree *UNUSED(ntree), bNode *node, bNodeTemplate *UNUSED(ntemp)) { NodeTexMusgrave *tex = MEM_callocN(sizeof(NodeTexMusgrave), "NodeTexMusgrave"); default_tex_mapping(&tex->base.tex_mapping); diff --git a/source/blender/nodes/shader/nodes/node_shader_tex_noise.c b/source/blender/nodes/shader/nodes/node_shader_tex_noise.c index 95b81c5e1fb..bd049300048 100644 --- a/source/blender/nodes/shader/nodes/node_shader_tex_noise.c +++ b/source/blender/nodes/shader/nodes/node_shader_tex_noise.c @@ -43,7 +43,7 @@ static bNodeSocketTemplate sh_node_tex_noise_out[]= { { -1, 0, "" } }; -static void node_shader_init_tex_noise(bNodeTree *UNUSED(ntree), bNode* node, bNodeTemplate *UNUSED(ntemp)) +static void node_shader_init_tex_noise(bNodeTree *UNUSED(ntree), bNode *node, bNodeTemplate *UNUSED(ntemp)) { NodeTexNoise *tex = MEM_callocN(sizeof(NodeTexNoise), "NodeTexNoise"); default_tex_mapping(&tex->base.tex_mapping); diff --git a/source/blender/nodes/shader/nodes/node_shader_tex_sky.c b/source/blender/nodes/shader/nodes/node_shader_tex_sky.c index 48020c10aa0..977d689ace6 100644 --- a/source/blender/nodes/shader/nodes/node_shader_tex_sky.c +++ b/source/blender/nodes/shader/nodes/node_shader_tex_sky.c @@ -39,7 +39,7 @@ static bNodeSocketTemplate sh_node_tex_sky_out[]= { { -1, 0, "" } }; -static void node_shader_init_tex_sky(bNodeTree *UNUSED(ntree), bNode* node, bNodeTemplate *UNUSED(ntemp)) +static void node_shader_init_tex_sky(bNodeTree *UNUSED(ntree), bNode *node, bNodeTemplate *UNUSED(ntemp)) { NodeTexSky *tex = MEM_callocN(sizeof(NodeTexSky), "NodeTexSky"); default_tex_mapping(&tex->base.tex_mapping); diff --git a/source/blender/nodes/shader/nodes/node_shader_tex_voronoi.c b/source/blender/nodes/shader/nodes/node_shader_tex_voronoi.c index e654666db26..22baa3853ac 100644 --- a/source/blender/nodes/shader/nodes/node_shader_tex_voronoi.c +++ b/source/blender/nodes/shader/nodes/node_shader_tex_voronoi.c @@ -41,7 +41,7 @@ static bNodeSocketTemplate sh_node_tex_voronoi_out[]= { { -1, 0, "" } }; -static void node_shader_init_tex_voronoi(bNodeTree *UNUSED(ntree), bNode* node, bNodeTemplate *UNUSED(ntemp)) +static void node_shader_init_tex_voronoi(bNodeTree *UNUSED(ntree), bNode *node, bNodeTemplate *UNUSED(ntemp)) { NodeTexVoronoi *tex = MEM_callocN(sizeof(NodeTexVoronoi), "NodeTexVoronoi"); default_tex_mapping(&tex->base.tex_mapping); diff --git a/source/blender/nodes/shader/nodes/node_shader_tex_wave.c b/source/blender/nodes/shader/nodes/node_shader_tex_wave.c index 8a6994e7b73..8a099521ee9 100644 --- a/source/blender/nodes/shader/nodes/node_shader_tex_wave.c +++ b/source/blender/nodes/shader/nodes/node_shader_tex_wave.c @@ -44,7 +44,7 @@ static bNodeSocketTemplate sh_node_tex_wave_out[]= { { -1, 0, "" } }; -static void node_shader_init_tex_wave(bNodeTree *UNUSED(ntree), bNode* node, bNodeTemplate *UNUSED(ntemp)) +static void node_shader_init_tex_wave(bNodeTree *UNUSED(ntree), bNode *node, bNodeTemplate *UNUSED(ntemp)) { NodeTexWave *tex = MEM_callocN(sizeof(NodeTexWave), "NodeTexWave"); default_tex_mapping(&tex->base.tex_mapping); diff --git a/source/blender/nodes/shader/nodes/node_shader_valToRgb.c b/source/blender/nodes/shader/nodes/node_shader_valToRgb.c index fb3316c2036..d3094200f83 100644 --- a/source/blender/nodes/shader/nodes/node_shader_valToRgb.c +++ b/source/blender/nodes/shader/nodes/node_shader_valToRgb.c @@ -57,7 +57,7 @@ static void node_shader_exec_valtorgb(void *UNUSED(data), bNode *node, bNodeStac } } -static void node_shader_init_valtorgb(bNodeTree *UNUSED(ntree), bNode* node, bNodeTemplate *UNUSED(ntemp)) +static void node_shader_init_valtorgb(bNodeTree *UNUSED(ntree), bNode *node, bNodeTemplate *UNUSED(ntemp)) { node->storage= add_colorband(1); } diff --git a/source/blender/nodes/texture/nodes/node_texture_bricks.c b/source/blender/nodes/texture/nodes/node_texture_bricks.c index 7435034845f..f6259962529 100644 --- a/source/blender/nodes/texture/nodes/node_texture_bricks.c +++ b/source/blender/nodes/texture/nodes/node_texture_bricks.c @@ -50,7 +50,7 @@ static bNodeSocketTemplate outputs[]= { { -1, 0, "" } }; -static void init(bNodeTree *UNUSED(ntree), bNode* node, bNodeTemplate *UNUSED(ntemp)) +static void init(bNodeTree *UNUSED(ntree), bNode *node, bNodeTemplate *UNUSED(ntemp)) { node->custom3 = 0.5; /* offset */ node->custom4 = 1.0; /* squash */ diff --git a/source/blender/nodes/texture/nodes/node_texture_curves.c b/source/blender/nodes/texture/nodes/node_texture_curves.c index 35e14c592a7..543b39ec75e 100644 --- a/source/blender/nodes/texture/nodes/node_texture_curves.c +++ b/source/blender/nodes/texture/nodes/node_texture_curves.c @@ -60,7 +60,7 @@ static void time_exec(void *data, bNode *node, bNodeStack **in, bNodeStack **out } -static void time_init(bNodeTree *UNUSED(ntree), bNode* node, bNodeTemplate *UNUSED(ntemp)) +static void time_init(bNodeTree *UNUSED(ntree), bNode *node, bNodeTemplate *UNUSED(ntemp)) { node->custom1= 1; node->custom2= 250; @@ -106,7 +106,7 @@ static void rgb_exec(void *data, bNode *node, bNodeStack **in, bNodeStack **out) tex_output(node, in, out[0], &rgb_colorfn, data); } -static void rgb_init(bNodeTree *UNUSED(ntree), bNode* node, bNodeTemplate *UNUSED(ntemp)) +static void rgb_init(bNodeTree *UNUSED(ntree), bNode *node, bNodeTemplate *UNUSED(ntemp)) { node->storage= curvemapping_add(4, 0.0f, 0.0f, 1.0f, 1.0f); } diff --git a/source/blender/nodes/texture/nodes/node_texture_image.c b/source/blender/nodes/texture/nodes/node_texture_image.c index d49a1edd70c..7ce91c37295 100644 --- a/source/blender/nodes/texture/nodes/node_texture_image.c +++ b/source/blender/nodes/texture/nodes/node_texture_image.c @@ -86,7 +86,7 @@ static void exec(void *data, bNode *node, bNodeStack **in, bNodeStack **out) tex_output(node, in, out[0], &colorfn, data); } -static void init(bNodeTree *UNUSED(ntree), bNode* node, bNodeTemplate *UNUSED(ntemp)) +static void init(bNodeTree *UNUSED(ntree), bNode *node, bNodeTemplate *UNUSED(ntemp)) { ImageUser *iuser= MEM_callocN(sizeof(ImageUser), "node image user"); node->storage= iuser; diff --git a/source/blender/nodes/texture/nodes/node_texture_output.c b/source/blender/nodes/texture/nodes/node_texture_output.c index 9383d5675cb..ce22bc00a55 100644 --- a/source/blender/nodes/texture/nodes/node_texture_output.c +++ b/source/blender/nodes/texture/nodes/node_texture_output.c @@ -141,7 +141,7 @@ static void assign_index(struct bNode *node) node->custom1 = index; } -static void init(bNodeTree *UNUSED(ntree), bNode* node, bNodeTemplate *UNUSED(ntemp)) +static void init(bNodeTree *UNUSED(ntree), bNode *node, bNodeTemplate *UNUSED(ntemp)) { TexNodeOutput *tno = MEM_callocN(sizeof(TexNodeOutput), "TEX_output"); node->storage= tno; diff --git a/source/blender/nodes/texture/nodes/node_texture_proc.c b/source/blender/nodes/texture/nodes/node_texture_proc.c index 3b33383c73b..102f6e1c428 100644 --- a/source/blender/nodes/texture/nodes/node_texture_proc.c +++ b/source/blender/nodes/texture/nodes/node_texture_proc.c @@ -281,7 +281,7 @@ ProcDef(stucci) /* --- */ -static void init(bNodeTree *UNUSED(ntree), bNode* node, bNodeTemplate *UNUSED(ntemp)) +static void init(bNodeTree *UNUSED(ntree), bNode *node, bNodeTemplate *UNUSED(ntemp)) { Tex *tex = MEM_callocN(sizeof(Tex), "Tex"); node->storage= tex; diff --git a/source/blender/nodes/texture/nodes/node_texture_valToRgb.c b/source/blender/nodes/texture/nodes/node_texture_valToRgb.c index 10db0debd5b..515613509f6 100644 --- a/source/blender/nodes/texture/nodes/node_texture_valToRgb.c +++ b/source/blender/nodes/texture/nodes/node_texture_valToRgb.c @@ -57,7 +57,7 @@ static void valtorgb_exec(void *data, bNode *node, bNodeStack **in, bNodeStack * tex_output(node, in, out[0], &valtorgb_colorfn, data); } -static void valtorgb_init(bNodeTree *UNUSED(ntree), bNode* node, bNodeTemplate *UNUSED(ntemp)) +static void valtorgb_init(bNodeTree *UNUSED(ntree), bNode *node, bNodeTemplate *UNUSED(ntemp)) { node->storage = add_colorband(1); } diff --git a/source/blender/render/intern/source/imagetexture.c b/source/blender/render/intern/source/imagetexture.c index 56bf5242f36..e4fb87e8e4f 100644 --- a/source/blender/render/intern/source/imagetexture.c +++ b/source/blender/render/intern/source/imagetexture.c @@ -717,7 +717,7 @@ static int ibuf_get_color_clip_bilerp(float col[4], ImBuf *ibuf, float u, float return ibuf_get_color_clip(col, ibuf, (int)u, (int)v, extflag); } -static void area_sample(TexResult* texr, ImBuf* ibuf, float fx, float fy, afdata_t* AFD) +static void area_sample(TexResult *texr, ImBuf *ibuf, float fx, float fy, afdata_t *AFD) { int xs, ys, clip = 0; float tc[4], xsd, ysd, cw = 0.f; @@ -839,7 +839,7 @@ static void imp2radangle(float A, float B, float C, float F, float* a, float* b, } } -static void ewa_eval(TexResult* texr, ImBuf* ibuf, float fx, float fy, afdata_t* AFD) +static void ewa_eval(TexResult *texr, ImBuf *ibuf, float fx, float fy, afdata_t *AFD) { /* scaling dxt/dyt by full resolution can cause overflow because of huge A/B/C and esp. F values, * scaling by aspect ratio alone does the opposite, so try something in between instead... */ @@ -926,7 +926,7 @@ static void ewa_eval(TexResult* texr, ImBuf* ibuf, float fx, float fy, afdata_t* texr->ta = texr->talpha ? texr->ta*d : 1.f; /* TXF alpha (clip ? cw*d : 1.f); */ } -static void feline_eval(TexResult* texr, ImBuf* ibuf, float fx, float fy, afdata_t* AFD) +static void feline_eval(TexResult *texr, ImBuf *ibuf, float fx, float fy, afdata_t *AFD) { const int maxn = AFD->iProbes - 1; const float ll = ((AFD->majrad == AFD->minrad) ? 2.f*AFD->majrad : 2.f*(AFD->majrad - AFD->minrad)) / (maxn ? (float)maxn : 1.f); @@ -1219,7 +1219,7 @@ static int imagewraposa_aniso(Tex *tex, Image *ima, ImBuf *ibuf, const float tex ImBuf *previbuf, *curibuf; float levf; int maxlev; - ImBuf* mipmaps[IB_MIPMAP_LEVELS + 1]; + ImBuf *mipmaps[IB_MIPMAP_LEVELS + 1]; /* modify ellipse minor axis if too eccentric, use for area sampling as well * scaling dxt/dyt as done in pbrt is not the same diff --git a/source/blender/render/intern/source/render_texture.c b/source/blender/render/intern/source/render_texture.c index 3d0816e048d..14c178c10f9 100644 --- a/source/blender/render/intern/source/render_texture.c +++ b/source/blender/render/intern/source/render_texture.c @@ -1703,7 +1703,7 @@ static int compatible_bump_compute(CompatibleBump *compat_bump, ShadeInput *shi, if (!shi->osatex && (tex->type == TEX_IMAGE) && tex->ima) { /* in case we have no proper derivatives, fall back to * computing du/dv it based on image size */ - ImBuf* ibuf = BKE_image_get_ibuf(tex->ima, &tex->iuser); + ImBuf *ibuf = BKE_image_get_ibuf(tex->ima, &tex->iuser); if (ibuf) { du = 1.f/(float)ibuf->x; dv = 1.f/(float)ibuf->y; @@ -1878,7 +1878,7 @@ static int ntap_bump_compute(NTapBump *ntap_bump, ShadeInput *shi, MTex *mtex, T /* resolve image dimensions */ if (found_deriv_map || (mtex->texflag&MTEX_BUMP_TEXTURESPACE)!=0) { - ImBuf* ibuf = BKE_image_get_ibuf(tex->ima, &tex->iuser); + ImBuf *ibuf = BKE_image_get_ibuf(tex->ima, &tex->iuser); if (ibuf) { dimx = ibuf->x; dimy = ibuf->y; diff --git a/source/gameengine/Ketsji/BL_Texture.cpp b/source/gameengine/Ketsji/BL_Texture.cpp index 49963cee3b3..b8cc4ebeff9 100644 --- a/source/gameengine/Ketsji/BL_Texture.cpp +++ b/source/gameengine/Ketsji/BL_Texture.cpp @@ -193,7 +193,7 @@ void BL_Texture::InitGLTex(unsigned int *pix,int x,int y,bool mipmap) glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); } -void BL_Texture::InitGLCompressedTex(ImBuf* ibuf, bool mipmap) +void BL_Texture::InitGLCompressedTex(ImBuf *ibuf, bool mipmap) { #ifndef WITH_DDS // Fall back to uncompressed if DDS isn't enabled diff --git a/source/gameengine/VideoTexture/ImageBuff.cpp b/source/gameengine/VideoTexture/ImageBuff.cpp index 9854da0ea86..17513d20a39 100644 --- a/source/gameengine/VideoTexture/ImageBuff.cpp +++ b/source/gameengine/VideoTexture/ImageBuff.cpp @@ -144,7 +144,7 @@ void ImageBuff::clear (short width, short height, unsigned char color) // img must point to a array of RGBA data of size width*height void ImageBuff::plot (unsigned char * img, short width, short height, short x, short y, short mode) { - struct ImBuf* tmpbuf; + struct ImBuf *tmpbuf; if (m_size[0] == 0 || m_size[1] == 0 || width <= 0 || height <= 0) return; diff --git a/source/gameengine/VideoTexture/ImageBuff.h b/source/gameengine/VideoTexture/ImageBuff.h index b3e7386c899..b2bdbc17dc9 100644 --- a/source/gameengine/VideoTexture/ImageBuff.h +++ b/source/gameengine/VideoTexture/ImageBuff.h @@ -38,7 +38,7 @@ struct ImBuf; class ImageBuff : public ImageBase { private: - struct ImBuf* m_imbuf; // temporary structure for buffer manipulation + struct ImBuf *m_imbuf; // temporary structure for buffer manipulation public: /// constructor ImageBuff (void) : ImageBase(true), m_imbuf(NULL) {} From 25b7370e862b2ca950a1d9074b1dd561c18b7363 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 23 Aug 2012 07:39:51 +0000 Subject: [PATCH 088/163] de-duplicate sequencer jump operator, use next/prev option instead. --- source/blender/editors/screen/screen_ops.c | 4 +- .../editors/space_sequencer/sequencer_edit.c | 46 ++++--------------- .../space_sequencer/sequencer_intern.h | 3 +- .../editors/space_sequencer/sequencer_ops.c | 9 ++-- 4 files changed, 17 insertions(+), 45 deletions(-) diff --git a/source/blender/editors/screen/screen_ops.c b/source/blender/editors/screen/screen_ops.c index 6b42b2f9de8..ed519dc626c 100644 --- a/source/blender/editors/screen/screen_ops.c +++ b/source/blender/editors/screen/screen_ops.c @@ -2030,8 +2030,8 @@ static void SCREEN_OT_keyframe_jump(wmOperatorType *ot) ot->poll = ED_operator_screenactive_norender; ot->flag = OPTYPE_UNDO; - /* rna */ - RNA_def_boolean(ot->srna, "next", 1, "Next Keyframe", ""); + /* properties */ + RNA_def_boolean(ot->srna, "next", TRUE, "Next Keyframe", ""); } /* ************** switch screen operator ***************************** */ diff --git a/source/blender/editors/space_sequencer/sequencer_edit.c b/source/blender/editors/space_sequencer/sequencer_edit.c index 010ed177b72..5f210922383 100644 --- a/source/blender/editors/space_sequencer/sequencer_edit.c +++ b/source/blender/editors/space_sequencer/sequencer_edit.c @@ -2345,42 +2345,13 @@ static int next_prev_edit_internal(Scene *scene, int side) return change; } -/* move frame to next edit point operator */ -static int sequencer_next_edit_exec(bContext *C, wmOperator *UNUSED(op)) +/* jump frame to edit point operator */ +static int sequencer_strip_jump_exec(bContext *C, wmOperator *op) { Scene *scene = CTX_data_scene(C); - - if (!next_prev_edit_internal(scene, SEQ_SIDE_RIGHT)) - return OPERATOR_CANCELLED; + short next = RNA_boolean_get(op->ptr, "next"); - WM_event_add_notifier(C, NC_SCENE | ND_FRAME, scene); - - return OPERATOR_FINISHED; -} - -void SEQUENCER_OT_next_edit(wmOperatorType *ot) -{ - /* identifiers */ - ot->name = "Next Edit"; - ot->idname = "SEQUENCER_OT_next_edit"; - ot->description = "Move frame to next edit point"; - - /* api callbacks */ - ot->exec = sequencer_next_edit_exec; - ot->poll = sequencer_edit_poll; - - /* flags */ - ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - - /* properties */ -} - -/* move frame to previous edit point operator */ -static int sequencer_previous_edit_exec(bContext *C, wmOperator *UNUSED(op)) -{ - Scene *scene = CTX_data_scene(C); - - if (!next_prev_edit_internal(scene, SEQ_SIDE_LEFT)) + if (!next_prev_edit_internal(scene, next ? SEQ_SIDE_RIGHT : SEQ_SIDE_LEFT)) return OPERATOR_CANCELLED; WM_event_add_notifier(C, NC_SCENE | ND_FRAME, scene); @@ -2388,21 +2359,22 @@ static int sequencer_previous_edit_exec(bContext *C, wmOperator *UNUSED(op)) return OPERATOR_FINISHED; } -void SEQUENCER_OT_previous_edit(wmOperatorType *ot) +void SEQUENCER_OT_strip_jump(wmOperatorType *ot) { /* identifiers */ - ot->name = "Previous Edit"; - ot->idname = "SEQUENCER_OT_previous_edit"; + ot->name = "Jump to Strip"; + ot->idname = "SEQUENCER_OT_strip_jump"; ot->description = "Move frame to previous edit point"; /* api callbacks */ - ot->exec = sequencer_previous_edit_exec; + ot->exec = sequencer_strip_jump_exec; ot->poll = sequencer_edit_poll; /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* properties */ + RNA_def_boolean(ot->srna, "next", TRUE, "Next Strip", ""); } static void swap_sequence(Scene *scene, Sequence *seqa, Sequence *seqb) diff --git a/source/blender/editors/space_sequencer/sequencer_intern.h b/source/blender/editors/space_sequencer/sequencer_intern.h index bad4fcf9135..b87c5c454c7 100644 --- a/source/blender/editors/space_sequencer/sequencer_intern.h +++ b/source/blender/editors/space_sequencer/sequencer_intern.h @@ -95,8 +95,7 @@ void SEQUENCER_OT_meta_toggle(struct wmOperatorType *ot); void SEQUENCER_OT_meta_make(struct wmOperatorType *ot); void SEQUENCER_OT_meta_separate(struct wmOperatorType *ot); void SEQUENCER_OT_snap(struct wmOperatorType *ot); -void SEQUENCER_OT_previous_edit(struct wmOperatorType *ot); -void SEQUENCER_OT_next_edit(struct wmOperatorType *ot); +void SEQUENCER_OT_strip_jump(struct wmOperatorType *ot); void SEQUENCER_OT_swap(struct wmOperatorType *ot); void SEQUENCER_OT_swap_data(struct wmOperatorType *ot); void SEQUENCER_OT_rendersize(struct wmOperatorType *ot); diff --git a/source/blender/editors/space_sequencer/sequencer_ops.c b/source/blender/editors/space_sequencer/sequencer_ops.c index 45ffc997172..68bb4bda7bc 100644 --- a/source/blender/editors/space_sequencer/sequencer_ops.c +++ b/source/blender/editors/space_sequencer/sequencer_ops.c @@ -72,8 +72,7 @@ void sequencer_operatortypes(void) WM_operatortype_append(SEQUENCER_OT_meta_make); WM_operatortype_append(SEQUENCER_OT_meta_separate); WM_operatortype_append(SEQUENCER_OT_snap); - WM_operatortype_append(SEQUENCER_OT_next_edit); - WM_operatortype_append(SEQUENCER_OT_previous_edit); + WM_operatortype_append(SEQUENCER_OT_strip_jump); WM_operatortype_append(SEQUENCER_OT_swap); WM_operatortype_append(SEQUENCER_OT_swap_data); WM_operatortype_append(SEQUENCER_OT_rendersize); @@ -189,8 +188,10 @@ void sequencer_keymap(wmKeyConfig *keyconf) WM_keymap_add_item(keymap, "SEQUENCER_OT_view_all", HOMEKEY, KM_PRESS, 0, 0); WM_keymap_add_item(keymap, "SEQUENCER_OT_view_selected", PADPERIOD, KM_PRESS, 0, 0); - WM_keymap_add_item(keymap, "SEQUENCER_OT_next_edit", PAGEUPKEY, KM_PRESS, 0, 0); - WM_keymap_add_item(keymap, "SEQUENCER_OT_previous_edit", PAGEDOWNKEY, KM_PRESS, 0, 0); + kmi = WM_keymap_add_item(keymap, "SEQUENCER_OT_strip_jump", PAGEUPKEY, KM_PRESS, 0, 0); + RNA_boolean_set(kmi->ptr, "next", TRUE); + kmi = WM_keymap_add_item(keymap, "SEQUENCER_OT_strip_jump", PAGEDOWNKEY, KM_PRESS, 0, 0); + RNA_boolean_set(kmi->ptr, "next", FALSE); RNA_enum_set(WM_keymap_add_item(keymap, "SEQUENCER_OT_swap", LEFTARROWKEY, KM_PRESS, KM_ALT, 0)->ptr, "side", SEQ_SIDE_LEFT); RNA_enum_set(WM_keymap_add_item(keymap, "SEQUENCER_OT_swap", RIGHTARROWKEY, KM_PRESS, KM_ALT, 0)->ptr, "side", SEQ_SIDE_RIGHT); From 40db82e31482361a9cda585e3eb396e81859cf31 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 23 Aug 2012 08:10:45 +0000 Subject: [PATCH 089/163] alt page up/down now jump between strip center frames (since often the middle frame is a better sample to check). --- .../editors/space_sequencer/sequencer_edit.c | 67 ++++++++++++++----- .../editors/space_sequencer/sequencer_ops.c | 10 +++ 2 files changed, 62 insertions(+), 15 deletions(-) diff --git a/source/blender/editors/space_sequencer/sequencer_edit.c b/source/blender/editors/space_sequencer/sequencer_edit.c index 5f210922383..de95b9119e2 100644 --- a/source/blender/editors/space_sequencer/sequencer_edit.c +++ b/source/blender/editors/space_sequencer/sequencer_edit.c @@ -2288,7 +2288,9 @@ void SEQUENCER_OT_view_selected(wmOperatorType *ot) } -static int find_next_prev_edit(Scene *scene, int cfra, int side) +static int find_next_prev_edit(Scene *scene, int cfra, + const short side, + const short do_skip_mute, const short do_center) { Editing *ed = BKE_sequencer_editing_get(scene, FALSE); Sequence *seq, *best_seq = NULL, *frame_seq = NULL; @@ -2299,19 +2301,32 @@ static int find_next_prev_edit(Scene *scene, int cfra, int side) if (ed == NULL) return cfra; for (seq = ed->seqbasep->first; seq; seq = seq->next) { + int seq_frame; + + if (do_skip_mute && (seq->flag & SEQ_MUTE)) { + continue; + } + + if (do_center) { + seq_frame = (seq->startdisp + seq->enddisp) / 2; + } + else { + seq_frame = seq->startdisp; + } + dist = MAXFRAME * 2; switch (side) { case SEQ_SIDE_LEFT: - if (seq->startdisp < cfra) { - dist = cfra - seq->startdisp; + if (seq_frame < cfra) { + dist = cfra - seq_frame; } break; case SEQ_SIDE_RIGHT: - if (seq->startdisp > cfra) { - dist = seq->startdisp - cfra; + if (seq_frame > cfra) { + dist = seq_frame - cfra; } - else if (seq->startdisp == cfra) { + else if (seq_frame == cfra) { frame_seq = seq; } break; @@ -2326,20 +2341,38 @@ static int find_next_prev_edit(Scene *scene, int cfra, int side) /* if no sequence to the right is found and the * frame is on the start of the last sequence, * move to the end of the last sequence */ - if (frame_seq) cfra = frame_seq->enddisp; + if (frame_seq) { + if (do_center) { + cfra = (frame_seq->startdisp + frame_seq->enddisp) / 2; + } + else { + cfra = frame_seq->enddisp; + } + } - return best_seq ? best_seq->startdisp : cfra; + if (best_seq) { + if (do_center) { + cfra = (best_seq->startdisp + best_seq->enddisp) / 2; + } + else { + cfra = best_seq->startdisp; + } + } + + return cfra; } -static int next_prev_edit_internal(Scene *scene, int side) +static int strip_jump_internal(Scene *scene, + const short side, + const short do_skip_mute, const short do_center) { - int change = 0; + int change = FALSE; int cfra = CFRA; - int nfra = find_next_prev_edit(scene, cfra, side); + int nfra = find_next_prev_edit(scene, cfra, side, do_skip_mute, do_center); if (nfra != cfra) { CFRA = nfra; - change = 1; + change = TRUE; } return change; @@ -2350,9 +2383,12 @@ static int sequencer_strip_jump_exec(bContext *C, wmOperator *op) { Scene *scene = CTX_data_scene(C); short next = RNA_boolean_get(op->ptr, "next"); + short center = RNA_boolean_get(op->ptr, "center"); - if (!next_prev_edit_internal(scene, next ? SEQ_SIDE_RIGHT : SEQ_SIDE_LEFT)) + /* currently do_skip_mute is always TRUE */ + if (!strip_jump_internal(scene, next ? SEQ_SIDE_RIGHT : SEQ_SIDE_LEFT, TRUE, center)) { return OPERATOR_CANCELLED; + } WM_event_add_notifier(C, NC_SCENE | ND_FRAME, scene); @@ -2365,16 +2401,17 @@ void SEQUENCER_OT_strip_jump(wmOperatorType *ot) ot->name = "Jump to Strip"; ot->idname = "SEQUENCER_OT_strip_jump"; ot->description = "Move frame to previous edit point"; - + /* api callbacks */ ot->exec = sequencer_strip_jump_exec; ot->poll = sequencer_edit_poll; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* properties */ RNA_def_boolean(ot->srna, "next", TRUE, "Next Strip", ""); + RNA_def_boolean(ot->srna, "center", TRUE, "Use strip center", ""); } static void swap_sequence(Scene *scene, Sequence *seqa, Sequence *seqb) diff --git a/source/blender/editors/space_sequencer/sequencer_ops.c b/source/blender/editors/space_sequencer/sequencer_ops.c index 68bb4bda7bc..e434e6b94e7 100644 --- a/source/blender/editors/space_sequencer/sequencer_ops.c +++ b/source/blender/editors/space_sequencer/sequencer_ops.c @@ -190,8 +190,18 @@ void sequencer_keymap(wmKeyConfig *keyconf) kmi = WM_keymap_add_item(keymap, "SEQUENCER_OT_strip_jump", PAGEUPKEY, KM_PRESS, 0, 0); RNA_boolean_set(kmi->ptr, "next", TRUE); + RNA_boolean_set(kmi->ptr, "center", FALSE); kmi = WM_keymap_add_item(keymap, "SEQUENCER_OT_strip_jump", PAGEDOWNKEY, KM_PRESS, 0, 0); RNA_boolean_set(kmi->ptr, "next", FALSE); + RNA_boolean_set(kmi->ptr, "center", FALSE); + + /* alt for center */ + kmi = WM_keymap_add_item(keymap, "SEQUENCER_OT_strip_jump", PAGEUPKEY, KM_PRESS, KM_ALT, 0); + RNA_boolean_set(kmi->ptr, "next", TRUE); + RNA_boolean_set(kmi->ptr, "center", TRUE); + kmi = WM_keymap_add_item(keymap, "SEQUENCER_OT_strip_jump", PAGEDOWNKEY, KM_PRESS, KM_ALT, 0); + RNA_boolean_set(kmi->ptr, "next", FALSE); + RNA_boolean_set(kmi->ptr, "center", TRUE); RNA_enum_set(WM_keymap_add_item(keymap, "SEQUENCER_OT_swap", LEFTARROWKEY, KM_PRESS, KM_ALT, 0)->ptr, "side", SEQ_SIDE_LEFT); RNA_enum_set(WM_keymap_add_item(keymap, "SEQUENCER_OT_swap", RIGHTARROWKEY, KM_PRESS, KM_ALT, 0)->ptr, "side", SEQ_SIDE_RIGHT); From 9bae78ed5d2261c9d61c854d405286741fcb39b2 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Thu, 23 Aug 2012 09:04:30 +0000 Subject: [PATCH 090/163] Sequencer: move up/down operators for modifiers --- .../scripts/startup/bl_ui/space_sequencer.py | 13 +++- .../space_sequencer/sequencer_intern.h | 1 + .../space_sequencer/sequencer_modifier.c | 66 +++++++++++++++++++ .../editors/space_sequencer/sequencer_ops.c | 1 + 4 files changed, 79 insertions(+), 2 deletions(-) diff --git a/release/scripts/startup/bl_ui/space_sequencer.py b/release/scripts/startup/bl_ui/space_sequencer.py index cd10bce8ef6..25054a6baa6 100644 --- a/release/scripts/startup/bl_ui/space_sequencer.py +++ b/release/scripts/startup/bl_ui/space_sequencer.py @@ -899,10 +899,19 @@ class SEQUENCER_PT_modifiers(SequencerButtonsPanel, Panel): row = box.row() row.prop(mod, "show_expanded", text="", emboss=False) - row.prop(mod, "name") + row.prop(mod, "name", text="") row.prop(mod, "mute", text="") - props = row.operator("sequencer.strip_modifier_remove", text="", icon='X') + + sub = row.row(align=True) + props = sub.operator("sequencer.strip_modifier_move", text="", icon='TRIA_UP') + props.name = mod.name + props.direction = 'UP' + props = sub.operator("sequencer.strip_modifier_move", text="", icon='TRIA_DOWN') + props.name = mod.name + props.direction = 'DOWN' + + props = row.operator("sequencer.strip_modifier_remove", text="", icon='X', emboss=False) props.name = mod.name if mod.show_expanded: diff --git a/source/blender/editors/space_sequencer/sequencer_intern.h b/source/blender/editors/space_sequencer/sequencer_intern.h index b87c5c454c7..4ee9c6710bc 100644 --- a/source/blender/editors/space_sequencer/sequencer_intern.h +++ b/source/blender/editors/space_sequencer/sequencer_intern.h @@ -179,6 +179,7 @@ void SEQUENCER_OT_properties(struct wmOperatorType *ot); /* sequencer_modifiers.c */ void SEQUENCER_OT_strip_modifier_add(struct wmOperatorType *ot); void SEQUENCER_OT_strip_modifier_remove(struct wmOperatorType *ot); +void SEQUENCER_OT_strip_modifier_move(struct wmOperatorType *ot); #endif /* __SEQUENCER_INTERN_H__ */ diff --git a/source/blender/editors/space_sequencer/sequencer_modifier.c b/source/blender/editors/space_sequencer/sequencer_modifier.c index b19d92d67a0..a4a485b34c6 100644 --- a/source/blender/editors/space_sequencer/sequencer_modifier.c +++ b/source/blender/editors/space_sequencer/sequencer_modifier.c @@ -154,3 +154,69 @@ void SEQUENCER_OT_strip_modifier_remove(wmOperatorType *ot) /* properties */ RNA_def_string(ot->srna, "name", "Name", MAX_NAME, "Name", "Name of modifier to remove"); } + +/*********************** Move operator *************************/ + +enum { + SEQ_MODIFIER_MOVE_UP = 0, + SEQ_MODIFIER_MOVE_DOWN +}; + +static int strip_modifier_move_exec(bContext *C, wmOperator *op) +{ + Scene *scene = CTX_data_scene(C); + Sequence *seq = BKE_sequencer_active_get(scene); + char name[MAX_NAME]; + int direction; + SequenceModifierData *smd; + + RNA_string_get(op->ptr, "name", name); + direction = RNA_enum_get(op->ptr, "direction"); + + smd = BKE_sequence_modifier_find_by_name(seq, name); + if (!smd) + return OPERATOR_CANCELLED; + + if (direction == SEQ_MODIFIER_MOVE_UP) { + if (smd->prev) { + BLI_remlink(&seq->modifiers, smd); + BLI_insertlink(&seq->modifiers, smd->prev->prev, smd); + } + } + else if (direction == SEQ_MODIFIER_MOVE_DOWN) { + if (smd->next) { + BLI_remlink(&seq->modifiers, smd); + BLI_insertlink(&seq->modifiers, smd->next, smd); + } + } + + BKE_sequence_invalidate_cache(scene, seq); + WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene); + + return OPERATOR_FINISHED; +} + +void SEQUENCER_OT_strip_modifier_move(wmOperatorType *ot) +{ + static EnumPropertyItem direction_items[] = { + {SEQ_MODIFIER_MOVE_UP, "UP", 0, "Up", "Move modifier up in the stack"}, + {SEQ_MODIFIER_MOVE_DOWN, "DOWN", 0, "Down", "Move modifier down in the stack"}, + {0, NULL, 0, NULL, NULL} + }; + + /* identifiers */ + ot->name = "Move Strip Modifier"; + ot->idname = "SEQUENCER_OT_strip_modifier_move"; + ot->description = "Move modifier up and down in the stack"; + + /* api callbacks */ + ot->exec = strip_modifier_move_exec; + ot->poll = strip_modifier_active_poll; + + /* flags */ + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; + + /* properties */ + RNA_def_string(ot->srna, "name", "Name", MAX_NAME, "Name", "Name of modifier to remove"); + RNA_def_enum(ot->srna, "direction", direction_items, SEQ_MODIFIER_MOVE_UP, "Type", ""); +} diff --git a/source/blender/editors/space_sequencer/sequencer_ops.c b/source/blender/editors/space_sequencer/sequencer_ops.c index e434e6b94e7..960ae502126 100644 --- a/source/blender/editors/space_sequencer/sequencer_ops.c +++ b/source/blender/editors/space_sequencer/sequencer_ops.c @@ -117,6 +117,7 @@ void sequencer_operatortypes(void) /* sequencer_modifiers.c */ WM_operatortype_append(SEQUENCER_OT_strip_modifier_add); WM_operatortype_append(SEQUENCER_OT_strip_modifier_remove); + WM_operatortype_append(SEQUENCER_OT_strip_modifier_move); } From e91e1814d0cd6de342f64a6307f1359a7757cf62 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 23 Aug 2012 09:20:15 +0000 Subject: [PATCH 091/163] fix own error in BM_data_interp_from_edges() from recent commit. --- source/blender/bmesh/intern/bmesh_interp.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/source/blender/bmesh/intern/bmesh_interp.c b/source/blender/bmesh/intern/bmesh_interp.c index 16488501651..9033436d1b2 100644 --- a/source/blender/bmesh/intern/bmesh_interp.c +++ b/source/blender/bmesh/intern/bmesh_interp.c @@ -46,7 +46,7 @@ #include "intern/bmesh_private.h" /* edge and vertex share, currently theres no need to have different logic */ -static void bm_data_interp_from_elem(BMesh *bm, BMElem *ele1, BMElem *ele2, BMElem *ele_dst, const float fac) +static void bm_data_interp_from_elem(CustomData *data_layer, BMElem *ele1, BMElem *ele2, BMElem *ele_dst, const float fac) { if (ele1->head.data && ele2->head.data) { /* first see if we can avoid interpolation */ @@ -55,8 +55,8 @@ static void bm_data_interp_from_elem(BMesh *bm, BMElem *ele1, BMElem *ele2, BMEl /* do nothing */ } else { - CustomData_bmesh_free_block(&bm->vdata, &ele_dst->head.data); - CustomData_bmesh_copy_data(&bm->vdata, &bm->vdata, ele1->head.data, &ele_dst->head.data); + CustomData_bmesh_free_block(data_layer, &ele_dst->head.data); + CustomData_bmesh_copy_data(data_layer, data_layer, ele1->head.data, &ele_dst->head.data); } } else if (fac >= 1.0f) { @@ -64,8 +64,8 @@ static void bm_data_interp_from_elem(BMesh *bm, BMElem *ele1, BMElem *ele2, BMEl /* do nothing */ } else { - CustomData_bmesh_free_block(&bm->vdata, &ele_dst->head.data); - CustomData_bmesh_copy_data(&bm->vdata, &bm->vdata, ele2->head.data, &ele_dst->head.data); + CustomData_bmesh_free_block(data_layer, &ele_dst->head.data); + CustomData_bmesh_copy_data(data_layer, data_layer, ele2->head.data, &ele_dst->head.data); } } else { @@ -76,7 +76,7 @@ static void bm_data_interp_from_elem(BMesh *bm, BMElem *ele1, BMElem *ele2, BMEl src[1] = ele2->head.data; w[0] = 1.0f - fac; w[1] = fac; - CustomData_bmesh_interp(&bm->vdata, src, w, NULL, 2, ele_dst->head.data); + CustomData_bmesh_interp(data_layer, src, w, NULL, 2, ele_dst->head.data); } } } @@ -90,7 +90,7 @@ static void bm_data_interp_from_elem(BMesh *bm, BMElem *ele1, BMElem *ele2, BMEl */ void BM_data_interp_from_verts(BMesh *bm, BMVert *v1, BMVert *v2, BMVert *v, const float fac) { - bm_data_interp_from_elem(bm, (BMElem *)v1, (BMElem *)v2, (BMElem *)v, fac); + bm_data_interp_from_elem(&bm->vdata, (BMElem *)v1, (BMElem *)v2, (BMElem *)v, fac); } /** @@ -102,7 +102,7 @@ void BM_data_interp_from_verts(BMesh *bm, BMVert *v1, BMVert *v2, BMVert *v, con */ void BM_data_interp_from_edges(BMesh *bm, BMEdge *e1, BMEdge *e2, BMEdge *e, const float fac) { - bm_data_interp_from_elem(bm, (BMElem *)e1, (BMElem *)e2, (BMElem *)e, fac); + bm_data_interp_from_elem(&bm->edata, (BMElem *)e1, (BMElem *)e2, (BMElem *)e, fac); } /** From fd2c3d1e3014221667422f4f85665baaaf23bdf3 Mon Sep 17 00:00:00 2001 From: Mitchell Stokes Date: Thu, 23 Aug 2012 09:24:59 +0000 Subject: [PATCH 092/163] BGE: When creating a controller by linking a sensor and actuator, the created controller will always be an and controller instead of the last controller type added. --- source/blender/editors/interface/interface_handlers.c | 1 + 1 file changed, 1 insertion(+) diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c index f0d2cb183b5..39567a5b00b 100644 --- a/source/blender/editors/interface/interface_handlers.c +++ b/source/blender/editors/interface/interface_handlers.c @@ -838,6 +838,7 @@ static void ui_add_smart_controller(bContext *C, uiBut *from, uiBut *to) /* (3) add a new controller */ if (WM_operator_name_call(C, "LOGIC_OT_controller_add", WM_OP_EXEC_DEFAULT, NULL) & OPERATOR_FINISHED) { cont = (bController *)ob->controllers.last; + cont->type = CONT_LOGIC_AND; /* Quick fix to make sure we always have an AND controller. It might be nicer to make sure the operator gives us the right one though... */ /* (4) link the sensor->controller->actuator */ tmp_but = MEM_callocN(sizeof(uiBut), "uiBut"); From bbd8863956b1dbaa31fe0cae64080a4224cb883d Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 23 Aug 2012 09:54:15 +0000 Subject: [PATCH 093/163] code cleanup: use const weights for customdata interpolation functions --- source/blender/blenkernel/intern/customdata.c | 54 +++++++++---------- .../editors/space_sequencer/sequencer_edit.c | 4 +- 2 files changed, 29 insertions(+), 29 deletions(-) diff --git a/source/blender/blenkernel/intern/customdata.c b/source/blender/blenkernel/intern/customdata.c index b04bd5bc47f..d4e23c365e8 100644 --- a/source/blender/blenkernel/intern/customdata.c +++ b/source/blender/blenkernel/intern/customdata.c @@ -99,7 +99,7 @@ typedef struct LayerTypeInfo { * (there should be (sub element count)^2 weights per element) * count gives the number of elements in sources */ - void (*interp)(void **sources, float *weights, float *sub_weights, + void (*interp)(void **sources, const float *weights, const float *sub_weights, int count, void *dest); /* a function to swap the data in corners of the element */ @@ -203,8 +203,8 @@ static void linklist_free_simple(void *link) MEM_freeN(link); } -static void layerInterp_mdeformvert(void **sources, float *weights, - float *UNUSED(sub_weights), int count, void *dest) +static void layerInterp_mdeformvert(void **sources, const float *weights, + const float *UNUSED(sub_weights), int count, void *dest) { MDeformVert *dvert = dest; LinkNode *dest_dw = NULL; /* a list of lists of MDeformWeight pointers */ @@ -261,8 +261,8 @@ static void layerInterp_mdeformvert(void **sources, float *weights, } -static void layerInterp_msticky(void **sources, float *weights, - float *UNUSED(sub_weights), int count, void *dest) +static void layerInterp_msticky(void **sources, const float *weights, + const float *UNUSED(sub_weights), int count, void *dest) { float co[2], w; MSticky *mst; @@ -291,13 +291,13 @@ static void layerCopy_tface(const void *source, void *dest, int count) dest_tf[i] = source_tf[i]; } -static void layerInterp_tface(void **sources, float *weights, - float *sub_weights, int count, void *dest) +static void layerInterp_tface(void **sources, const float *weights, + const float *sub_weights, int count, void *dest) { MTFace *tf = dest; int i, j, k; float uv[4][2] = {{0.0f}}; - float *sub_weight; + const float *sub_weight; if (count <= 0) return; @@ -392,13 +392,13 @@ static void layerCopy_origspace_face(const void *source, void *dest, int count) dest_tf[i] = source_tf[i]; } -static void layerInterp_origspace_face(void **sources, float *weights, - float *sub_weights, int count, void *dest) +static void layerInterp_origspace_face(void **sources, const float *weights, + const float *sub_weights, int count, void *dest) { OrigSpaceFace *osf = dest; int i, j, k; float uv[4][2] = {{0.0f}}; - float *sub_weight; + const float *sub_weight; if (count <= 0) return; @@ -680,12 +680,12 @@ static void layerDefault_mloopcol(void *data, int count) } -static void layerInterp_mloopcol(void **sources, float *weights, - float *sub_weights, int count, void *dest) +static void layerInterp_mloopcol(void **sources, const float *weights, + const float *sub_weights, int count, void *dest) { MLoopCol *mc = dest; int i; - float *sub_weight; + const float *sub_weight; struct { float a; float r; @@ -768,8 +768,8 @@ static void layerAdd_mloopuv(void *data1, void *data2) add_v2_v2(l1->uv, l2->uv); } -static void layerInterp_mloopuv(void **sources, float *weights, - float *sub_weights, int count, void *dest) +static void layerInterp_mloopuv(void **sources, const float *weights, + const float *sub_weights, int count, void *dest) { MLoopUV *mluv = dest; float *uv = mluv->uv; @@ -838,8 +838,8 @@ static void layerAdd_mloop_origspace(void *data1, void *data2) add_v2_v2(l1->uv, l2->uv); } -static void layerInterp_mloop_origspace(void **sources, float *weights, - float *sub_weights, int count, void *dest) +static void layerInterp_mloop_origspace(void **sources, const float *weights, + const float *sub_weights, int count, void *dest) { OrigSpaceLoop *mluv = dest; float *uv = mluv->uv; @@ -866,8 +866,8 @@ static void layerInterp_mloop_origspace(void **sources, float *weights, } /* --- end copy */ -static void layerInterp_mcol(void **sources, float *weights, - float *sub_weights, int count, void *dest) +static void layerInterp_mcol(void **sources, const float *weights, + const float *sub_weights, int count, void *dest) { MCol *mc = dest; int i, j, k; @@ -878,7 +878,7 @@ static void layerInterp_mcol(void **sources, float *weights, float b; } col[4] = {{0.0f}}; - float *sub_weight; + const float *sub_weight; if (count <= 0) return; @@ -946,8 +946,8 @@ static void layerDefault_mcol(void *data, int count) } } -static void layerInterp_bweight(void **sources, float *weights, - float *UNUSED(sub_weights), int count, void *dest) +static void layerInterp_bweight(void **sources, const float *weights, + const float *UNUSED(sub_weights), int count, void *dest) { float *f = dest; float **in = (float **)sources; @@ -969,8 +969,8 @@ static void layerInterp_bweight(void **sources, float *weights, } } -static void layerInterp_shapekey(void **sources, float *weights, - float *UNUSED(sub_weights), int count, void *dest) +static void layerInterp_shapekey(void **sources, const float *weights, + const float *UNUSED(sub_weights), int count, void *dest) { float *co = dest; float **in = (float **)sources; @@ -1003,8 +1003,8 @@ static void layerDefault_mvert_skin(void *data, int count) } } -static void layerInterp_mvert_skin(void **sources, float *weights, - float *UNUSED(sub_weights), +static void layerInterp_mvert_skin(void **sources, const float *weights, + const float *UNUSED(sub_weights), int count, void *dest) { float radius[3], w; diff --git a/source/blender/editors/space_sequencer/sequencer_edit.c b/source/blender/editors/space_sequencer/sequencer_edit.c index de95b9119e2..81699d36f5f 100644 --- a/source/blender/editors/space_sequencer/sequencer_edit.c +++ b/source/blender/editors/space_sequencer/sequencer_edit.c @@ -2363,8 +2363,8 @@ static int find_next_prev_edit(Scene *scene, int cfra, } static int strip_jump_internal(Scene *scene, - const short side, - const short do_skip_mute, const short do_center) + const short side, + const short do_skip_mute, const short do_center) { int change = FALSE; int cfra = CFRA; From fa6a8b8090236db6bd295239abc3f10815ba1c30 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Thu, 23 Aug 2012 10:56:14 +0000 Subject: [PATCH 094/163] Fix #32389: scons was compiling without iksolver and only itasc since a few days, which gave performance issues. --- source/blender/ikplugin/SConscript | 1 + 1 file changed, 1 insertion(+) diff --git a/source/blender/ikplugin/SConscript b/source/blender/ikplugin/SConscript index 38c53894df8..97b1cf18e0d 100644 --- a/source/blender/ikplugin/SConscript +++ b/source/blender/ikplugin/SConscript @@ -7,5 +7,6 @@ incs = '#/intern/guardedalloc #/intern/iksolver/extern ../makesdna ../blenlib' incs += ' ../blenkernel ../include ../ikplugin #/intern/itasc #/extern/Eigen3' defs.append('WITH_IK_ITASC') +defs.append('WITH_IK_SOLVER') env.BlenderLib ( 'bf_ikplugin', sources, Split(incs), defs, libtype=['core','player'], priority=[180, 190] ) From efa97ea40f777d8f626b5c101e5ee56331e936d1 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Thu, 23 Aug 2012 10:56:16 +0000 Subject: [PATCH 095/163] Fix #32391: new remove doubles "unselected" option was enabled by default, don't think this was intentional. --- source/blender/editors/mesh/editmesh_tools.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/blender/editors/mesh/editmesh_tools.c b/source/blender/editors/mesh/editmesh_tools.c index 6bd2ac75226..07b53b1cf7f 100644 --- a/source/blender/editors/mesh/editmesh_tools.c +++ b/source/blender/editors/mesh/editmesh_tools.c @@ -2098,7 +2098,7 @@ void MESH_OT_remove_doubles(wmOperatorType *ot) RNA_def_float(ot->srna, "mergedist", 0.0001f, 0.000001f, 50.0f, "Merge Distance", "Minimum distance between elements to merge", 0.00001, 10.0); - RNA_def_boolean(ot->srna, "use_unselected", 1, "Unselected", "Merge selected to other unselected vertices"); + RNA_def_boolean(ot->srna, "use_unselected", 0, "Unselected", "Merge selected to other unselected vertices"); } /************************ Vertex Path Operator *************************/ From 32a05baad9793e6843066a5c4156a1522366da9a Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Thu, 23 Aug 2012 11:18:31 +0000 Subject: [PATCH 096/163] Fix #32388: bpy.ops.wm.path_open() not working with path with spaces on Windows. --- release/scripts/startup/bl_operators/wm.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/release/scripts/startup/bl_operators/wm.py b/release/scripts/startup/bl_operators/wm.py index a81733fe59c..b34c427c4a1 100644 --- a/release/scripts/startup/bl_operators/wm.py +++ b/release/scripts/startup/bl_operators/wm.py @@ -790,7 +790,7 @@ class WM_OT_path_open(Operator): return {'CANCELLED'} if sys.platform[:3] == "win": - subprocess.Popen(["start", filepath], shell=True) + os.startfile(filepath) elif sys.platform == "darwin": subprocess.Popen(["open", filepath]) else: From 6a13ae2b5238a6eec82e8f5999ddb6b3f4c19ad2 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Thu, 23 Aug 2012 13:32:54 +0000 Subject: [PATCH 097/163] Sequencer: fix for color balance keyframing and modifier renaming --- .../blender/makesrna/intern/rna_sequencer.c | 36 +++++++++++++------ 1 file changed, 26 insertions(+), 10 deletions(-) diff --git a/source/blender/makesrna/intern/rna_sequencer.c b/source/blender/makesrna/intern/rna_sequencer.c index 3e841f81450..ab59d043daf 100644 --- a/source/blender/makesrna/intern/rna_sequencer.c +++ b/source/blender/makesrna/intern/rna_sequencer.c @@ -76,6 +76,7 @@ EnumPropertyItem sequence_modifier_type_items[] = { typedef struct SequenceSearchData { Sequence *seq; void *data; + SequenceModifierData *smd; } SequenceSearchData; /* build a temp reference to the parent */ @@ -743,6 +744,7 @@ static int colbalance_seq_cmp_cb(Sequence *seq, void *arg_pt) if (seq->strip && seq->strip->color_balance == data->data) { data->seq = seq; + data->smd = NULL; return -1; /* done so bail out */ } @@ -755,6 +757,7 @@ static int colbalance_seq_cmp_cb(Sequence *seq, void *arg_pt) if (&cbmd->color_balance == data->data) { data->seq = seq; + data->smd = smd; return -1; /* done so bail out */ } } @@ -764,27 +767,39 @@ static int colbalance_seq_cmp_cb(Sequence *seq, void *arg_pt) return 1; } -static Sequence *sequence_get_by_colorbalance(Editing *ed, StripColorBalance *cb) +static Sequence *sequence_get_by_colorbalance(Editing *ed, StripColorBalance *cb, SequenceModifierData **smd_r) { SequenceSearchData data; data.seq = NULL; + data.smd = NULL; data.data = cb; /* irritating we need to search for our sequence! */ BKE_sequencer_base_recursive_apply(&ed->seqbase, colbalance_seq_cmp_cb, &data); + *smd_r = data.smd; + return data.seq; } static char *rna_SequenceColorBalance_path(PointerRNA *ptr) { Scene *scene = ptr->id.data; + SequenceModifierData *smd; Editing *ed = BKE_sequencer_editing_get(scene, FALSE); - Sequence *seq = sequence_get_by_colorbalance(ed, ptr->data); + Sequence *seq = sequence_get_by_colorbalance(ed, ptr->data, &smd); - if (seq && seq->name + 2) - return BLI_sprintfN("sequence_editor.sequences_all[\"%s\"].color_balance", seq->name + 2); + if (seq && seq->name + 2) { + if (!smd) { + /* path to old filter color balance */ + return BLI_sprintfN("sequence_editor.sequences_all[\"%s\"].color_balance", seq->name + 2); + } + else { + /* path to modifier */ + return BLI_sprintfN("sequence_editor.sequences_all[\"%s\"].modifiers[\"%s\"].color_balance", seq->name + 2, smd->name); + } + } else return BLI_strdup(""); } @@ -793,9 +808,10 @@ static void rna_SequenceColorBalance_update(Main *UNUSED(bmain), Scene *UNUSED(s { Scene *scene = (Scene *) ptr->id.data; Editing *ed = BKE_sequencer_editing_get(scene, FALSE); - Sequence *seq = sequence_get_by_colorbalance(ed, ptr->data); + SequenceModifierData *smd; + Sequence *seq = sequence_get_by_colorbalance(ed, ptr->data, &smd); - if (seq->strip->color_balance == ptr->data) + if (smd == NULL) BKE_sequence_invalidate_cache(scene, seq); else BKE_sequence_invalidate_cache_for_modifier(scene, seq); @@ -943,8 +959,8 @@ static void rna_SequenceModifier_name_set(PointerRNA *ptr, const char *value) if (adt) { char path[1024]; - BLI_snprintf(path, sizeof(path), "sequence_editor.sequences_all[\"%s\"].modifiers", seq->name); - BKE_animdata_fix_paths_rename(&scene->id, adt, NULL, path, oldname, smd->name + 2, 0, 0, 1); + BLI_snprintf(path, sizeof(path), "sequence_editor.sequences_all[\"%s\"].modifiers", seq->name + 2); + BKE_animdata_fix_paths_rename(&scene->id, adt, NULL, path, oldname, smd->name, 0, 0, 1); } } @@ -1239,6 +1255,8 @@ static void rna_def_color_balance(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Saturation", ""); RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_Sequence_ColorBabalnce_update"); #endif + + RNA_def_struct_path_func(srna, "rna_SequenceColorBalance_path"); } static void rna_def_strip_color_balance(BlenderRNA *brna) @@ -1248,8 +1266,6 @@ static void rna_def_strip_color_balance(BlenderRNA *brna) srna = RNA_def_struct(brna, "SequenceColorBalance", "SequenceColorBalanceData"); RNA_def_struct_ui_text(srna, "Sequence Color Balance", "Color balance parameters for a sequence strip"); RNA_def_struct_sdna(srna, "StripColorBalance"); - - RNA_def_struct_path_func(srna, "rna_SequenceColorBalance_path"); } EnumPropertyItem blend_mode_items[] = { From 0dd42fd5138f19e22c347ac0a0817d8ba605a5c4 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Thu, 23 Aug 2012 13:54:30 +0000 Subject: [PATCH 098/163] Fix #32387: some mesh modifications breaking other shape keys. The vertex shapekey index is now no longer copied, and propagation of offsets in the basis to other shapekeys is disabled if new vertices were added. The reason being that the propagation will only be done for the old vertices leaving the new ones behind, and so doing e.g. subdivide + translate on the basis would create a mess on other shape keys. --- source/blender/bmesh/intern/bmesh_core.c | 7 +++++++ source/blender/bmesh/intern/bmesh_mesh_conv.c | 9 +++++++++ 2 files changed, 16 insertions(+) diff --git a/source/blender/bmesh/intern/bmesh_core.c b/source/blender/bmesh/intern/bmesh_core.c index 8c8cc216e96..94d94cbec3e 100644 --- a/source/blender/bmesh/intern/bmesh_core.c +++ b/source/blender/bmesh/intern/bmesh_core.c @@ -80,7 +80,14 @@ BMVert *BM_vert_create(BMesh *bm, const float co[3], const BMVert *example) CustomData_bmesh_set_default(&bm->vdata, &v->head.data); if (example) { + int *keyi; + BM_elem_attrs_copy(bm, bm, example, v); + + /* exception: don't copy the original shapekey index */ + keyi = CustomData_bmesh_get(&bm->vdata, v->head.data, CD_SHAPE_KEYINDEX); + if(keyi) + *keyi = ORIGINDEX_NONE; } BM_CHECK_ELEMENT(v); diff --git a/source/blender/bmesh/intern/bmesh_mesh_conv.c b/source/blender/bmesh/intern/bmesh_mesh_conv.c index 123eb6829a3..51c8b5d3bd8 100644 --- a/source/blender/bmesh/intern/bmesh_mesh_conv.c +++ b/source/blender/bmesh/intern/bmesh_mesh_conv.c @@ -793,6 +793,15 @@ void BM_mesh_bm_to_me(BMesh *bm, Mesh *me, int dotess) if (keyi && *keyi != ORIGINDEX_NONE) { sub_v3_v3v3(ofs[i], mvert->co, fp[*keyi]); } + else { + /* if there are new vertices in the mesh, we can't propagate the offset + * because it will only work for the existing vertices and not the new + * ones, creating a mess when doing e.g. subdivide + translate */ + MEM_freeN(ofs); + ofs = NULL; + break; + } + mvert++; } } From f4ab3b9d8b613931956439a27044d4bae35ad3cd Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 23 Aug 2012 14:49:20 +0000 Subject: [PATCH 099/163] sequencer zooms horizontal only from mouse wheel and plus buttons. --- source/blender/editors/interface/view2d_ops.c | 26 ++++++++++++++++--- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/source/blender/editors/interface/view2d_ops.c b/source/blender/editors/interface/view2d_ops.c index 84c3abf2ae2..cc2ca5c5475 100644 --- a/source/blender/editors/interface/view2d_ops.c +++ b/source/blender/editors/interface/view2d_ops.c @@ -672,13 +672,22 @@ static void view_zoomstep_exit(wmOperator *op) /* this operator only needs this single callback, where it calls the view_zoom_*() methods */ static int view_zoomin_exec(bContext *C, wmOperator *op) { + ScrArea *sa = CTX_wm_area(C); + short do_zoom_x = TRUE; + short do_zoom_y = TRUE; + /* check that there's an active region, as View2D data resides there */ if (!view_zoom_poll(C)) return OPERATOR_PASS_THROUGH; + /* default not to zoom the sequencer vertically */ + if (sa && sa->spacetype == SPACE_SEQ) { + do_zoom_y = FALSE; + } + /* set RNA-Props - zooming in by uniform factor */ - RNA_float_set(op->ptr, "zoomfacx", 0.0375f); - RNA_float_set(op->ptr, "zoomfacy", 0.0375f); + RNA_float_set(op->ptr, "zoomfacx", do_zoom_x ? 0.0375f : 0.0f); + RNA_float_set(op->ptr, "zoomfacy", do_zoom_y ? 0.0375f : 0.0f); /* apply movement, then we're done */ view_zoomstep_apply(C, op); @@ -729,13 +738,22 @@ static void VIEW2D_OT_zoom_in(wmOperatorType *ot) /* this operator only needs this single callback, where it callsthe view_zoom_*() methods */ static int view_zoomout_exec(bContext *C, wmOperator *op) { + ScrArea *sa = CTX_wm_area(C); + short do_zoom_x = TRUE; + short do_zoom_y = TRUE; + /* check that there's an active region, as View2D data resides there */ if (!view_zoom_poll(C)) return OPERATOR_PASS_THROUGH; + /* default not to zoom the sequencer vertically */ + if (sa && sa->spacetype == SPACE_SEQ) { + do_zoom_y = FALSE; + } + /* set RNA-Props - zooming in by uniform factor */ - RNA_float_set(op->ptr, "zoomfacx", -0.0375f); - RNA_float_set(op->ptr, "zoomfacy", -0.0375f); + RNA_float_set(op->ptr, "zoomfacx", do_zoom_x ? -0.0375f : 0.0f); + RNA_float_set(op->ptr, "zoomfacy", do_zoom_y ? -0.0375f : 0.0f); /* apply movement, then we're done */ view_zoomstep_apply(C, op); From c9d5f32270b70f8951f738e63da11b54685f8899 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Thu, 23 Aug 2012 16:14:52 +0000 Subject: [PATCH 100/163] Sequencer: display color sample information when mouse is holded down Behaves in exactly the same way as image editor's color sampling. Would be nice to display color managed color too, but that's for tomato branch. --- .../editors/space_sequencer/CMakeLists.txt | 1 + .../editors/space_sequencer/sequencer_draw.c | 45 +++- .../space_sequencer/sequencer_intern.h | 6 + .../editors/space_sequencer/sequencer_ops.c | 6 + .../editors/space_sequencer/sequencer_view.c | 221 ++++++++++++++++++ 5 files changed, 270 insertions(+), 9 deletions(-) create mode 100644 source/blender/editors/space_sequencer/sequencer_view.c diff --git a/source/blender/editors/space_sequencer/CMakeLists.txt b/source/blender/editors/space_sequencer/CMakeLists.txt index dd5fbb92171..c1f7fc942e4 100644 --- a/source/blender/editors/space_sequencer/CMakeLists.txt +++ b/source/blender/editors/space_sequencer/CMakeLists.txt @@ -44,6 +44,7 @@ set(SRC sequencer_ops.c sequencer_scopes.c sequencer_select.c + sequencer_view.c space_sequencer.c sequencer_intern.h diff --git a/source/blender/editors/space_sequencer/sequencer_draw.c b/source/blender/editors/space_sequencer/sequencer_draw.c index 25514b3168b..d6a2b0a001e 100644 --- a/source/blender/editors/space_sequencer/sequencer_draw.c +++ b/source/blender/editors/space_sequencer/sequencer_draw.c @@ -811,6 +811,41 @@ static void UNUSED_FUNCTION(set_special_seq_update) (int val) else special_seq_update = NULL; } +ImBuf *sequencer_ibuf_get(struct Main *bmain, Scene *scene, SpaceSeq *sseq, int cfra, int frame_ofs) +{ + SeqRenderData context; + ImBuf *ibuf; + int rectx, recty; + float render_size = 0.0; + float proxy_size = 100.0; + + render_size = sseq->render_size; + if (render_size == 0) { + render_size = scene->r.size; + } + else { + proxy_size = render_size; + } + + if (render_size < 0) { + return NULL; + } + + rectx = (render_size * (float)scene->r.xsch) / 100.0f + 0.5f; + recty = (render_size * (float)scene->r.ysch) / 100.0f + 0.5f; + + context = BKE_sequencer_new_render_data(bmain, scene, rectx, recty, proxy_size); + + if (special_seq_update) + ibuf = BKE_sequencer_give_ibuf_direct(context, cfra + frame_ofs, special_seq_update); + else if (!U.prefetchframes) // XXX || (G.f & G_PLAYANIM) == 0) { + ibuf = BKE_sequencer_give_ibuf(context, cfra + frame_ofs, sseq->chanshown); + else + ibuf = BKE_sequencer_give_ibuf_threaded(context, cfra + frame_ofs, sseq->chanshown); + + return ibuf; +} + void draw_image_seq(const bContext *C, Scene *scene, ARegion *ar, SpaceSeq *sseq, int cfra, int frame_ofs, int draw_overlay) { struct Main *bmain = CTX_data_main(C); @@ -824,7 +859,6 @@ void draw_image_seq(const bContext *C, Scene *scene, ARegion *ar, SpaceSeq *sseq float col[3]; GLuint texid; GLuint last_texid; - SeqRenderData context; render_size = sseq->render_size; if (render_size == 0) { @@ -865,14 +899,7 @@ void draw_image_seq(const bContext *C, Scene *scene, ARegion *ar, SpaceSeq *sseq if (G.is_rendering) return; - context = BKE_sequencer_new_render_data(bmain, scene, rectx, recty, proxy_size); - - if (special_seq_update) - ibuf = BKE_sequencer_give_ibuf_direct(context, cfra + frame_ofs, special_seq_update); - else if (!U.prefetchframes) // XXX || (G.f & G_PLAYANIM) == 0) { - ibuf = BKE_sequencer_give_ibuf(context, cfra + frame_ofs, sseq->chanshown); - else - ibuf = BKE_sequencer_give_ibuf_threaded(context, cfra + frame_ofs, sseq->chanshown); + ibuf = sequencer_ibuf_get(bmain, scene, sseq, cfra, frame_ofs); if (ibuf == NULL) return; diff --git a/source/blender/editors/space_sequencer/sequencer_intern.h b/source/blender/editors/space_sequencer/sequencer_intern.h index 4ee9c6710bc..81ee9927cb6 100644 --- a/source/blender/editors/space_sequencer/sequencer_intern.h +++ b/source/blender/editors/space_sequencer/sequencer_intern.h @@ -44,6 +44,7 @@ struct ScrArea; struct ARegion; struct ARegionType; struct Scene; +struct Main; /* space_sequencer.c */ struct ARegion *sequencer_has_buttons_region(struct ScrArea *sa); @@ -55,6 +56,8 @@ void draw_image_seq(const struct bContext* C, struct Scene *scene, struct ARegi void seq_reset_imageofs(struct SpaceSeq *sseq); +struct ImBuf *sequencer_ibuf_get(struct Main *bmain, struct Scene *scene, struct SpaceSeq *sseq, int cfra, int frame_ofs); + /* sequencer_edit.c */ struct View2D; void seq_rectf(struct Sequence *seq, struct rctf *rectf); @@ -181,5 +184,8 @@ void SEQUENCER_OT_strip_modifier_add(struct wmOperatorType *ot); void SEQUENCER_OT_strip_modifier_remove(struct wmOperatorType *ot); void SEQUENCER_OT_strip_modifier_move(struct wmOperatorType *ot); +/* sequencer_view.c */ +void SEQUENCER_OT_sample(struct wmOperatorType *ot); + #endif /* __SEQUENCER_INTERN_H__ */ diff --git a/source/blender/editors/space_sequencer/sequencer_ops.c b/source/blender/editors/space_sequencer/sequencer_ops.c index 960ae502126..aa6bacf8836 100644 --- a/source/blender/editors/space_sequencer/sequencer_ops.c +++ b/source/blender/editors/space_sequencer/sequencer_ops.c @@ -118,6 +118,9 @@ void sequencer_operatortypes(void) WM_operatortype_append(SEQUENCER_OT_strip_modifier_add); WM_operatortype_append(SEQUENCER_OT_strip_modifier_remove); WM_operatortype_append(SEQUENCER_OT_strip_modifier_move); + + /* sequencer_view.h */ + WM_operatortype_append(SEQUENCER_OT_sample); } @@ -335,6 +338,9 @@ void sequencer_keymap(wmKeyConfig *keyconf) RNA_float_set(WM_keymap_add_item(keymap, "SEQUENCER_OT_view_zoom_ratio", PAD4, KM_PRESS, 0, 0)->ptr, "ratio", 0.25f); RNA_float_set(WM_keymap_add_item(keymap, "SEQUENCER_OT_view_zoom_ratio", PAD8, KM_PRESS, 0, 0)->ptr, "ratio", 0.125f); #endif + + /* sample */ + WM_keymap_add_item(keymap, "SEQUENCER_OT_sample", ACTIONMOUSE, KM_PRESS, 0, 0); } void ED_operatormacros_sequencer(void) diff --git a/source/blender/editors/space_sequencer/sequencer_view.c b/source/blender/editors/space_sequencer/sequencer_view.c new file mode 100644 index 00000000000..fa39003bd55 --- /dev/null +++ b/source/blender/editors/space_sequencer/sequencer_view.c @@ -0,0 +1,221 @@ +/* + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * The Original Code is Copyright (C) 2012 Blender Foundation. + * All rights reserved. + * + * Contributor(s): Blender Foundation, + * Sergey Sharybin + * + * ***** END GPL LICENSE BLOCK ***** + */ + + +/** \file blender/editors/space_sequencer/sequencer_modifier.c + * \ingroup spseq + */ + +#include "MEM_guardedalloc.h" + +#include "BLI_utildefines.h" + +#include "DNA_scene_types.h" + +#include "BKE_context.h" +#include "BKE_main.h" +#include "BKE_sequencer.h" +#include "BKE_screen.h" + +#include "WM_api.h" +#include "WM_types.h" + +#include "ED_image.h" +#include "ED_screen.h" +#include "ED_space_api.h" + +#include "IMB_imbuf.h" +#include "IMB_imbuf_types.h" + +#include "UI_view2d.h" + +/* own include */ +#include "sequencer_intern.h" + +/******************** sample backdrop operator ********************/ + +typedef struct ImageSampleInfo { + ARegionType *art; + void *draw_handle; + int x, y; + int channels; + + unsigned char col[4]; + float colf[4]; + + unsigned char *colp; + float *colfp; + + int draw; +} ImageSampleInfo; + +static void sample_draw(const bContext *C, ARegion *ar, void *arg_info) +{ + Scene *scene = CTX_data_scene(C); + ImageSampleInfo *info = arg_info; + + if (info->draw) { + ED_image_draw_info(ar, (scene->r.color_mgt_flag & R_COLOR_MANAGEMENT), info->channels, + info->x, info->y, info->col, info->colf, NULL, NULL); + } +} + +static void sample_apply(bContext *C, wmOperator *op, wmEvent *event) +{ + Main *bmain = CTX_data_main(C); + Scene *scene = CTX_data_scene(C); + SpaceSeq *sseq = (SpaceSeq *) CTX_wm_space_data(C); + ARegion *ar = CTX_wm_region(C); + ImBuf *ibuf = sequencer_ibuf_get(bmain, scene, sseq, CFRA, 0); + ImageSampleInfo *info = op->customdata; + float fx, fy; + + if (ibuf == NULL) { + IMB_freeImBuf(ibuf); + info->draw = 0; + return; + } + + UI_view2d_region_to_view(&ar->v2d, event->mval[0], event->mval[1], &fx, &fy); + + fx += (float) ibuf->x / 2.0f; + fy += (float) ibuf->y / 2.0f; + + if (fx >= 0.0f && fy >= 0.0f && fx < ibuf->x && fy < ibuf->y) { + float *fp; + unsigned char *cp; + int x = (int) fx, y = (int) fy; + + info->x = x; + info->y = y; + info->draw = 1; + info->channels = ibuf->channels; + + info->colp = NULL; + info->colfp = NULL; + + if (ibuf->rect) { + cp = (unsigned char *)(ibuf->rect + y * ibuf->x + x); + + info->col[0] = cp[0]; + info->col[1] = cp[1]; + info->col[2] = cp[2]; + info->col[3] = cp[3]; + info->colp = info->col; + + info->colf[0] = (float)cp[0] / 255.0f; + info->colf[1] = (float)cp[1] / 255.0f; + info->colf[2] = (float)cp[2] / 255.0f; + info->colf[3] = (float)cp[3] / 255.0f; + info->colfp = info->colf; + } + if (ibuf->rect_float) { + fp = (ibuf->rect_float + (ibuf->channels) * (y * ibuf->x + x)); + + info->colf[0] = fp[0]; + info->colf[1] = fp[1]; + info->colf[2] = fp[2]; + info->colf[3] = fp[3]; + info->colfp = info->colf; + } + } + else { + info->draw = 0; + } + + IMB_freeImBuf(ibuf); + ED_area_tag_redraw(CTX_wm_area(C)); +} + +static void sample_exit(bContext *C, wmOperator *op) +{ + ImageSampleInfo *info = op->customdata; + + ED_region_draw_cb_exit(info->art, info->draw_handle); + ED_area_tag_redraw(CTX_wm_area(C)); + MEM_freeN(info); +} + +static int sample_invoke(bContext *C, wmOperator *op, wmEvent *event) +{ + ARegion *ar = CTX_wm_region(C); + ImageSampleInfo *info; + + info = MEM_callocN(sizeof(ImageSampleInfo), "ImageSampleInfo"); + info->art = ar->type; + info->draw_handle = ED_region_draw_cb_activate(ar->type, sample_draw, info, REGION_DRAW_POST_PIXEL); + op->customdata = info; + + sample_apply(C, op, event); + + WM_event_add_modal_handler(C, op); + + return OPERATOR_RUNNING_MODAL; +} + +static int sample_modal(bContext *C, wmOperator *op, wmEvent *event) +{ + switch (event->type) { + case LEFTMOUSE: + case RIGHTMOUSE: /* XXX hardcoded */ + sample_exit(C, op); + return OPERATOR_CANCELLED; + case MOUSEMOVE: + sample_apply(C, op, event); + break; + } + + return OPERATOR_RUNNING_MODAL; +} + +static int sample_cancel(bContext *C, wmOperator *op) +{ + sample_exit(C, op); + + return OPERATOR_CANCELLED; +} + +int sample_poll(bContext *C) +{ + return BKE_sequencer_editing_get(CTX_data_scene(C), FALSE) != NULL; +} + +void SEQUENCER_OT_sample(wmOperatorType *ot) +{ + /* identifiers */ + ot->name = "Sample Color"; + ot->idname = "SEQUENCER_OT_sample"; + ot->description = "Use mouse to sample color in current frame"; + + /* api callbacks */ + ot->invoke = sample_invoke; + ot->modal = sample_modal; + ot->cancel = sample_cancel; + ot->poll = sample_poll; + + /* flags */ + ot->flag = OPTYPE_BLOCKING; +} From 65dbeabdc6a89506df40222c52a1fc1db8c19e39 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 23 Aug 2012 16:17:47 +0000 Subject: [PATCH 101/163] style cleanup: indentation, also quiet double promotion warnings for despeckle node. --- source/blender/blenkernel/intern/node.c | 44 +++++++++---------- .../blender/blenkernel/intern/subsurf_ccg.c | 18 ++++---- .../operations/COM_DespeckleOperation.cpp | 6 +-- .../blender/editors/space_view3d/drawobject.c | 6 +-- source/blender/imbuf/intern/indexer.c | 6 +-- source/blender/imbuf/intern/scaling.c | 2 +- source/blender/modifiers/intern/MOD_boolean.c | 6 +-- source/blender/modifiers/intern/MOD_cast.c | 12 ++--- .../blender/modifiers/intern/MOD_displace.c | 4 +- .../blender/modifiers/intern/MOD_fluidsim.c | 4 +- source/blender/modifiers/intern/MOD_lattice.c | 6 +-- .../blender/modifiers/intern/MOD_meshdeform.c | 10 ++--- .../modifiers/intern/MOD_particlesystem.c | 4 +- 13 files changed, 64 insertions(+), 64 deletions(-) diff --git a/source/blender/blenkernel/intern/node.c b/source/blender/blenkernel/intern/node.c index 22b0cccf175..bf5fc6449f8 100644 --- a/source/blender/blenkernel/intern/node.c +++ b/source/blender/blenkernel/intern/node.c @@ -1487,10 +1487,10 @@ void nodeSocketSetType(bNodeSocket *sock, int type) * referene other pointers which need validation. */ typedef struct bNodeClipboardExtraInfo { - struct bNodeClipboardExtraInfo *next, *prev; + struct bNodeClipboardExtraInfo *next, *prev; ID *id; - char id_name[MAX_ID_NAME]; - char library_name[FILE_MAX]; + char id_name[MAX_ID_NAME]; + char library_name[FILE_MAX]; } bNodeClipboardExtraInfo; #endif /* USE_NODE_CB_VALIDATE */ @@ -1499,7 +1499,7 @@ typedef struct bNodeClipboard { ListBase nodes; #ifdef USE_NODE_CB_VALIDATE - ListBase nodes_extra_info; + ListBase nodes_extra_info; #endif ListBase links; @@ -1531,7 +1531,7 @@ void BKE_node_clipboard_clear(void) node_clipboard.nodes.first = node_clipboard.nodes.last = NULL; #ifdef USE_NODE_CB_VALIDATE - BLI_freelistN(&node_clipboard.nodes_extra_info); + BLI_freelistN(&node_clipboard.nodes_extra_info); #endif } @@ -1582,28 +1582,28 @@ int BKE_node_clipboard_validate(void) void BKE_node_clipboard_add_node(bNode *node) { #ifdef USE_NODE_CB_VALIDATE - /* add extra info */ - bNodeClipboardExtraInfo *node_info = MEM_mallocN(sizeof(bNodeClipboardExtraInfo), STRINGIFY(bNodeClipboardExtraInfo)); + /* add extra info */ + bNodeClipboardExtraInfo *node_info = MEM_mallocN(sizeof(bNodeClipboardExtraInfo), STRINGIFY(bNodeClipboardExtraInfo)); node_info->id = node->id; - if (node->id) { - BLI_strncpy(node_info->id_name, node->id->name, sizeof(node_info->id_name)); - if (node->id->lib) { - BLI_strncpy(node_info->library_name, node->id->lib->filepath, sizeof(node_info->library_name)); - } - else { - node_info->library_name[0] = '\0'; - } - } - else { - node_info->id_name[0] = '\0'; - node_info->library_name[0] = '\0'; - } - BLI_addtail(&node_clipboard.nodes_extra_info, node_info); + if (node->id) { + BLI_strncpy(node_info->id_name, node->id->name, sizeof(node_info->id_name)); + if (node->id->lib) { + BLI_strncpy(node_info->library_name, node->id->lib->filepath, sizeof(node_info->library_name)); + } + else { + node_info->library_name[0] = '\0'; + } + } + else { + node_info->id_name[0] = '\0'; + node_info->library_name[0] = '\0'; + } + BLI_addtail(&node_clipboard.nodes_extra_info, node_info); /* end extra info */ #endif /* USE_NODE_CB_VALIDATE */ - /* add node */ + /* add node */ BLI_addtail(&node_clipboard.nodes, node); } diff --git a/source/blender/blenkernel/intern/subsurf_ccg.c b/source/blender/blenkernel/intern/subsurf_ccg.c index b2762d23ef3..555ed5890c8 100644 --- a/source/blender/blenkernel/intern/subsurf_ccg.c +++ b/source/blender/blenkernel/intern/subsurf_ccg.c @@ -1468,9 +1468,9 @@ static void ccgdm_getVertCos(DerivedMesh *dm, float (*cos)[3]) } static void ccgDM_foreachMappedVert( - DerivedMesh *dm, - void (*func)(void *userData, int index, const float co[3], const float no_f[3], const short no_s[3]), - void *userData) + DerivedMesh *dm, + void (*func)(void *userData, int index, const float co[3], const float no_f[3], const short no_s[3]), + void *userData) { CCGDerivedMesh *ccgdm = (CCGDerivedMesh *) dm; CCGVertIterator *vi; @@ -1490,9 +1490,9 @@ static void ccgDM_foreachMappedVert( } static void ccgDM_foreachMappedEdge( - DerivedMesh *dm, - void (*func)(void *userData, int index, const float v0co[3], const float v1co[3]), - void *userData) + DerivedMesh *dm, + void (*func)(void *userData, int index, const float v0co[3], const float v1co[3]), + void *userData) { CCGDerivedMesh *ccgdm = (CCGDerivedMesh *) dm; CCGSubSurf *ss = ccgdm->ss; @@ -2492,9 +2492,9 @@ static void ccgDM_drawMappedEdgesInterp(DerivedMesh *dm, } static void ccgDM_foreachMappedFaceCenter( - DerivedMesh *dm, - void (*func)(void *userData, int index, const float co[3], const float no[3]), - void *userData) + DerivedMesh *dm, + void (*func)(void *userData, int index, const float co[3], const float no[3]), + void *userData) { CCGDerivedMesh *ccgdm = (CCGDerivedMesh *) dm; CCGSubSurf *ss = ccgdm->ss; diff --git a/source/blender/compositor/operations/COM_DespeckleOperation.cpp b/source/blender/compositor/operations/COM_DespeckleOperation.cpp index 8a18e4e2330..599f54720f2 100644 --- a/source/blender/compositor/operations/COM_DespeckleOperation.cpp +++ b/source/blender/compositor/operations/COM_DespeckleOperation.cpp @@ -78,8 +78,8 @@ void DespeckleOperation::executePixel(float output[4], int x, int y, void *data) this->m_inputOperation->read(color_org, x2, y2, NULL); -#define TOT_DIV_ONE 1.0 -#define TOT_DIV_CNR M_SQRT1_2 +#define TOT_DIV_ONE 1.0f +#define TOT_DIV_CNR (float)M_SQRT1_2 #define WTOT (TOT_DIV_ONE * 4 + TOT_DIV_CNR * 4) @@ -110,7 +110,7 @@ void DespeckleOperation::executePixel(float output[4], int x, int y, void *data) this->m_inputOperation->read(in1, x2, y3, NULL); COLOR_ADD(TOT_DIV_ONE) this->m_inputOperation->read(in1, x3, y3, NULL); COLOR_ADD(TOT_DIV_CNR) - mul_v4_fl(color_mid, 1.0f / (4.0f + (4.0f * M_SQRT1_2))); + mul_v4_fl(color_mid, 1.0f / (4.0f + (4.0f * (float)M_SQRT1_2))); //mul_v4_fl(color_mid, 1.0f / w); if ((w != 0.0f) && diff --git a/source/blender/editors/space_view3d/drawobject.c b/source/blender/editors/space_view3d/drawobject.c index a1a7bda4800..8e9776e0e17 100644 --- a/source/blender/editors/space_view3d/drawobject.c +++ b/source/blender/editors/space_view3d/drawobject.c @@ -2256,9 +2256,9 @@ void mesh_foreachScreenFace( } void nurbs_foreachScreenVert( - ViewContext *vc, - void (*func)(void *userData, Nurb *nu, BPoint *bp, BezTriple *bezt, int beztindex, int x, int y), - void *userData) + ViewContext *vc, + void (*func)(void *userData, Nurb *nu, BPoint *bp, BezTriple *bezt, int beztindex, int x, int y), + void *userData) { Curve *cu = vc->obedit->data; short s[2] = {IS_CLIPPED, 0}; diff --git a/source/blender/imbuf/intern/indexer.c b/source/blender/imbuf/intern/indexer.c index d5ca7da7d93..4108f0d89d7 100644 --- a/source/blender/imbuf/intern/indexer.c +++ b/source/blender/imbuf/intern/indexer.c @@ -221,7 +221,7 @@ struct anim_index *IMB_indexer_open(const char *name) } unsigned long long IMB_indexer_get_seek_pos( - struct anim_index *idx, int frame_index) + struct anim_index *idx, int frame_index) { if (frame_index < 0) { frame_index = 0; @@ -233,7 +233,7 @@ unsigned long long IMB_indexer_get_seek_pos( } unsigned long long IMB_indexer_get_seek_pos_dts( - struct anim_index *idx, int frame_index) + struct anim_index *idx, int frame_index) { if (frame_index < 0) { frame_index = 0; @@ -581,7 +581,7 @@ static struct proxy_output_ctx *alloc_proxy_output_ffmpeg( } static int add_to_proxy_output_ffmpeg( - struct proxy_output_ctx *ctx, AVFrame *frame) + struct proxy_output_ctx *ctx, AVFrame *frame) { int outsize = 0; diff --git a/source/blender/imbuf/intern/scaling.c b/source/blender/imbuf/intern/scaling.c index e90269a0986..389c3c42b6d 100644 --- a/source/blender/imbuf/intern/scaling.c +++ b/source/blender/imbuf/intern/scaling.c @@ -294,7 +294,7 @@ struct ImBuf *IMB_double_y(struct ImBuf *ibuf1) /* result in ibuf2, scaling should be done correctly */ void imb_onehalf_no_alloc(struct ImBuf *ibuf2, struct ImBuf *ibuf1) { - int x, y; + int x, y; const short do_rect = (ibuf1->rect != NULL); const short do_float = (ibuf1->rect_float != NULL) && (ibuf2->rect_float != NULL); diff --git a/source/blender/modifiers/intern/MOD_boolean.c b/source/blender/modifiers/intern/MOD_boolean.c index fb9788fb278..5c78a8efe23 100644 --- a/source/blender/modifiers/intern/MOD_boolean.c +++ b/source/blender/modifiers/intern/MOD_boolean.c @@ -67,9 +67,9 @@ static int isDisabled(ModifierData *md, int UNUSED(useRenderParams)) } static void foreachObjectLink( - ModifierData *md, Object *ob, - void (*walk)(void *userData, Object *ob, Object **obpoin), - void *userData) + ModifierData *md, Object *ob, + void (*walk)(void *userData, Object *ob, Object **obpoin), + void *userData) { BooleanModifierData *bmd = (BooleanModifierData *) md; diff --git a/source/blender/modifiers/intern/MOD_cast.c b/source/blender/modifiers/intern/MOD_cast.c index c80b4dfa4de..2530a230e0a 100644 --- a/source/blender/modifiers/intern/MOD_cast.c +++ b/source/blender/modifiers/intern/MOD_cast.c @@ -127,8 +127,8 @@ static void updateDepgraph(ModifierData *md, DagForest *forest, } static void sphere_do( - CastModifierData *cmd, Object *ob, DerivedMesh *dm, - float (*vertexCos)[3], int numVerts) + CastModifierData *cmd, Object *ob, DerivedMesh *dm, + float (*vertexCos)[3], int numVerts) { MDeformVert *dvert = NULL; @@ -299,8 +299,8 @@ static void sphere_do( } static void cuboid_do( - CastModifierData *cmd, Object *ob, DerivedMesh *dm, - float (*vertexCos)[3], int numVerts) + CastModifierData *cmd, Object *ob, DerivedMesh *dm, + float (*vertexCos)[3], int numVerts) { MDeformVert *dvert = NULL; Object *ctrl_ob = NULL; @@ -600,8 +600,8 @@ static void deformVerts(ModifierData *md, Object *ob, } static void deformVertsEM( - ModifierData *md, Object *ob, struct BMEditMesh *editData, - DerivedMesh *derivedData, float (*vertexCos)[3], int numVerts) + ModifierData *md, Object *ob, struct BMEditMesh *editData, + DerivedMesh *derivedData, float (*vertexCos)[3], int numVerts) { DerivedMesh *dm = get_dm(ob, editData, derivedData, NULL, 0); CastModifierData *cmd = (CastModifierData *)md; diff --git a/source/blender/modifiers/intern/MOD_displace.c b/source/blender/modifiers/intern/MOD_displace.c index 1d84dbc78f9..4a6d5ceb10f 100644 --- a/source/blender/modifiers/intern/MOD_displace.c +++ b/source/blender/modifiers/intern/MOD_displace.c @@ -166,8 +166,8 @@ static void updateDepgraph(ModifierData *md, DagForest *forest, /* dm must be a CDDerivedMesh */ static void displaceModifier_do( - DisplaceModifierData *dmd, Object *ob, - DerivedMesh *dm, float (*vertexCos)[3], int numVerts) + DisplaceModifierData *dmd, Object *ob, + DerivedMesh *dm, float (*vertexCos)[3], int numVerts) { int i; MVert *mvert; diff --git a/source/blender/modifiers/intern/MOD_fluidsim.c b/source/blender/modifiers/intern/MOD_fluidsim.c index 694f4f174e8..c9121010d5d 100644 --- a/source/blender/modifiers/intern/MOD_fluidsim.c +++ b/source/blender/modifiers/intern/MOD_fluidsim.c @@ -98,8 +98,8 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, } static void updateDepgraph( - ModifierData *md, DagForest *forest, Scene *scene, - Object *ob, DagNode *obNode) + ModifierData *md, DagForest *forest, Scene *scene, + Object *ob, DagNode *obNode) { FluidsimModifierData *fluidmd = (FluidsimModifierData *) md; Base *base; diff --git a/source/blender/modifiers/intern/MOD_lattice.c b/source/blender/modifiers/intern/MOD_lattice.c index 2c05b164d86..d64ccf750b2 100644 --- a/source/blender/modifiers/intern/MOD_lattice.c +++ b/source/blender/modifiers/intern/MOD_lattice.c @@ -82,9 +82,9 @@ static int isDisabled(ModifierData *md, int UNUSED(userRenderParams)) } static void foreachObjectLink( - ModifierData *md, Object *ob, - void (*walk)(void *userData, Object *ob, Object **obpoin), - void *userData) + ModifierData *md, Object *ob, + void (*walk)(void *userData, Object *ob, Object **obpoin), + void *userData) { LatticeModifierData *lmd = (LatticeModifierData *) md; diff --git a/source/blender/modifiers/intern/MOD_meshdeform.c b/source/blender/modifiers/intern/MOD_meshdeform.c index aafb21b3c34..f0bdf1bb737 100644 --- a/source/blender/modifiers/intern/MOD_meshdeform.c +++ b/source/blender/modifiers/intern/MOD_meshdeform.c @@ -104,9 +104,9 @@ static int isDisabled(ModifierData *md, int UNUSED(useRenderParams)) } static void foreachObjectLink( - ModifierData *md, Object *ob, - void (*walk)(void *userData, Object *ob, Object **obpoin), - void *userData) + ModifierData *md, Object *ob, + void (*walk)(void *userData, Object *ob, Object **obpoin), + void *userData) { MeshDeformModifierData *mmd = (MeshDeformModifierData *) md; @@ -182,8 +182,8 @@ static float meshdeform_dynamic_bind(MeshDeformModifierData *mmd, float (*dco)[3 } static void meshdeformModifier_do( - ModifierData *md, Object *ob, DerivedMesh *dm, - float (*vertexCos)[3], int numVerts) + ModifierData *md, Object *ob, DerivedMesh *dm, + float (*vertexCos)[3], int numVerts) { MeshDeformModifierData *mmd = (MeshDeformModifierData *) md; struct Mesh *me = (mmd->object) ? mmd->object->data : NULL; diff --git a/source/blender/modifiers/intern/MOD_particlesystem.c b/source/blender/modifiers/intern/MOD_particlesystem.c index ecdc5b53460..890e45f7e80 100644 --- a/source/blender/modifiers/intern/MOD_particlesystem.c +++ b/source/blender/modifiers/intern/MOD_particlesystem.c @@ -199,8 +199,8 @@ static void deformVerts(ModifierData *md, Object *ob, * updates is coded */ #if 0 static void deformVertsEM( - ModifierData *md, Object *ob, EditMesh *editData, - DerivedMesh *derivedData, float (*vertexCos)[3], int numVerts) + ModifierData *md, Object *ob, EditMesh *editData, + DerivedMesh *derivedData, float (*vertexCos)[3], int numVerts) { DerivedMesh *dm = derivedData; From f6a6fa419ea667b05180b2608db3edc15f171dd0 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 23 Aug 2012 17:16:11 +0000 Subject: [PATCH 102/163] fix [#32395] BMesh data interpolation feedback loop --- source/blender/blenkernel/intern/customdata.c | 51 ++++++++++++++++++- 1 file changed, 49 insertions(+), 2 deletions(-) diff --git a/source/blender/blenkernel/intern/customdata.c b/source/blender/blenkernel/intern/customdata.c index d4e23c365e8..c55f1b551e2 100644 --- a/source/blender/blenkernel/intern/customdata.c +++ b/source/blender/blenkernel/intern/customdata.c @@ -1962,6 +1962,23 @@ void CustomData_free_elem(CustomData *data, int index, int count) #define SOURCE_BUF_SIZE 100 +/* This define makes it so when we are interpolating customdata, + * the source is checked if it matches the destination. + * + * There are 2 ways to get around this, + * - Each interp function could accumulate the final result in a local, stack variable, + * then apply the result at the end. + * + * - Or we can make a temp copy of the destinations custom data before applying it. + * This isn't so efficient but avoids having to consider feedback loop on each interp function. + * Since this is more of a corner case its also not worth worrying about speed too much. + * + * (opted for the second option for now), keeping as an ifdef since we may wan't to change how works. + * + * see bug [#32395] - Campbell. + */ +#define USE_INTERP_OVERLAP_FIX + void CustomData_interp(const CustomData *source, CustomData *dest, int *src_indices, float *weights, float *sub_weights, int count, int dest_index) @@ -1999,8 +2016,12 @@ void CustomData_interp(const CustomData *source, CustomData *dest, if (dest->layers[dest_i].type == source->layers[src_i].type) { void *src_data = source->layers[src_i].data; - for (j = 0; j < count; ++j) + for (j = 0; j < count; ++j) { + /* if this happens we need to do a temp copy, see: USE_INTERP_OVERLAP_FIX */ + BLI_assert(dest_index != src_indices[j]); + sources[j] = (char *)src_data + typeInfo->size * src_indices[j]; + } dest_offset = dest_index * typeInfo->size; @@ -2578,6 +2599,11 @@ void CustomData_bmesh_interp(CustomData *data, void **src_blocks, float *weights void *source_buf[SOURCE_BUF_SIZE]; void **sources = source_buf; +#ifdef USE_INTERP_OVERLAP_FIX + /* incase there is overlap with the source */ + void *dest_block_copy = NULL; +#endif + /* slow fallback in case we're interpolating a ridiculous number of * elements */ @@ -2590,14 +2616,35 @@ void CustomData_bmesh_interp(CustomData *data, void **src_blocks, float *weights CustomDataLayer *layer = &data->layers[i]; const LayerTypeInfo *typeInfo = layerType_getInfo(layer->type); if (typeInfo->interp) { - for (j = 0; j < count; ++j) + for (j = 0; j < count; ++j) { +#ifdef USE_INTERP_OVERLAP_FIX + void *src_block; + if (UNLIKELY(src_blocks[j] == dest_block)) { + if (dest_block_copy == NULL) { + CustomData_bmesh_copy_data(data, data, dest_block, &dest_block_copy); + } + src_block = dest_block_copy; + } + else { + src_block = src_blocks[j]; + } + sources[j] = (char *)src_block + layer->offset; +#else sources[j] = (char *)src_blocks[j] + layer->offset; +#endif + } typeInfo->interp(sources, weights, sub_weights, count, (char *)dest_block + layer->offset); } } +#ifdef USE_INTERP_OVERLAP_FIX + if (dest_block_copy) { + CustomData_bmesh_free_block(data, &dest_block_copy); + } +#endif + if (count > SOURCE_BUF_SIZE) MEM_freeN(sources); } From dfbc793d885ae603089e5764cdd25fb2c983a03b Mon Sep 17 00:00:00 2001 From: Dalai Felinto Date: Thu, 23 Aug 2012 17:37:04 +0000 Subject: [PATCH 103/163] bugfix for [32368] Added controllers don't count over 10 Blender original code (NaN likely) was relying on strcmp to sort the list of controllers. As it happens, in strcmp 10 < 2, thus the list was never in the right order. The curious thing is that in 2.49 it worked, but I think it did because the make_unique_prop_names function was called twice. Strange ;) The solution is to use blender BLI_natstrcmp to do natural sorting --- source/blender/editors/space_logic/logic_window.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/blender/editors/space_logic/logic_window.c b/source/blender/editors/space_logic/logic_window.c index 915e5c20e99..a8bd0a443fa 100644 --- a/source/blender/editors/space_logic/logic_window.c +++ b/source/blender/editors/space_logic/logic_window.c @@ -109,7 +109,7 @@ static int vergname(const void *v1, const void *v2) x1= (char **)v1; x2= (char **)v2; - return strcmp(*x1, *x2); + return BLI_natstrcmp(*x1, *x2); } void make_unique_prop_names(bContext *C, char *str) From 56b28635e74c37e33b44baaa770ecf7d58a32895 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 23 Aug 2012 18:25:45 +0000 Subject: [PATCH 104/163] code cleanup: rename BLI_in_rctf() --> BLI_rctf_isect_pt(), to conform with our naming convention. --- source/blender/blenfont/intern/blf_glyph.c | 8 +++---- .../blenkernel/intern/mask_rasterize.c | 6 ++--- source/blender/blenlib/BLI_rect.h | 14 ++++++------ source/blender/blenlib/intern/rct.c | 10 ++++----- .../editors/animation/keyframes_edit.c | 2 +- .../blender/editors/gpencil/gpencil_paint.c | 4 ++-- source/blender/editors/include/UI_view2d.h | 4 ++-- .../editors/interface/interface_handlers.c | 18 +++++++-------- .../blender/editors/interface/interface_ops.c | 8 +++---- .../editors/interface/interface_panel.c | 2 +- .../editors/interface/interface_regions.c | 6 ++--- source/blender/editors/mask/mask_select.c | 4 ++-- source/blender/editors/screen/area.c | 2 +- source/blender/editors/screen/screen_edit.c | 2 +- source/blender/editors/screen/screen_ops.c | 6 ++--- .../editors/sculpt_paint/paint_image.c | 18 +++++++-------- .../editors/space_clip/clip_graph_ops.c | 2 +- .../editors/space_clip/tracking_select.c | 4 ++-- source/blender/editors/space_file/file_ops.c | 4 ++-- source/blender/editors/space_node/drawnode.c | 2 +- source/blender/editors/space_node/node_draw.c | 6 ++--- source/blender/editors/space_node/node_edit.c | 12 +++++----- .../editors/space_node/node_relationships.c | 2 +- .../blender/editors/space_node/node_select.c | 2 +- .../editors/space_view3d/view3d_select.c | 16 +++++++------- source/blender/editors/uvedit/uvedit_ops.c | 10 ++++----- source/blender/render/intern/source/shadbuf.c | 2 +- .../windowmanager/intern/wm_event_system.c | 22 +++++++++---------- 28 files changed, 99 insertions(+), 99 deletions(-) diff --git a/source/blender/blenfont/intern/blf_glyph.c b/source/blender/blenfont/intern/blf_glyph.c index 302edd8d533..63225651e5b 100644 --- a/source/blender/blenfont/intern/blf_glyph.c +++ b/source/blender/blenfont/intern/blf_glyph.c @@ -437,13 +437,13 @@ int blf_glyph_render(FontBLF *font, GlyphBLF *g, float x, float y) y2 = y + g->pos_y - g->height; if (font->flags & BLF_CLIPPING) { - if (!BLI_in_rctf(&font->clip_rec, dx + font->pos[0], y1 + font->pos[1])) + if (!BLI_rctf_isect_pt(&font->clip_rec, dx + font->pos[0], y1 + font->pos[1])) return 0; - if (!BLI_in_rctf(&font->clip_rec, dx + font->pos[0], y2 + font->pos[1])) + if (!BLI_rctf_isect_pt(&font->clip_rec, dx + font->pos[0], y2 + font->pos[1])) return 0; - if (!BLI_in_rctf(&font->clip_rec, dx1 + font->pos[0], y2 + font->pos[1])) + if (!BLI_rctf_isect_pt(&font->clip_rec, dx1 + font->pos[0], y2 + font->pos[1])) return 0; - if (!BLI_in_rctf(&font->clip_rec, dx1 + font->pos[0], y1 + font->pos[1])) + if (!BLI_rctf_isect_pt(&font->clip_rec, dx1 + font->pos[0], y1 + font->pos[1])) return 0; } diff --git a/source/blender/blenkernel/intern/mask_rasterize.c b/source/blender/blenkernel/intern/mask_rasterize.c index 48e55601469..eb96d6726b9 100644 --- a/source/blender/blenkernel/intern/mask_rasterize.c +++ b/source/blender/blenkernel/intern/mask_rasterize.c @@ -1196,7 +1196,7 @@ static float maskrasterize_layer_isect(unsigned int *face, float (*cos)[3], cons BLI_INLINE unsigned int layer_bucket_index_from_xy(MaskRasterLayer *layer, const float xy[2]) { - BLI_assert(BLI_in_rctf_v(&layer->bounds, xy)); + BLI_assert(BLI_rctf_isect_pt_v(&layer->bounds, xy)); return ( (unsigned int)((xy[0] - layer->bounds.xmin) * layer->buckets_xy_scalar[0])) + (((unsigned int)((xy[1] - layer->bounds.ymin) * layer->buckets_xy_scalar[1])) * layer->buckets_x); @@ -1233,7 +1233,7 @@ static float layer_bucket_depth_from_xy(MaskRasterLayer *layer, const float xy[2 float BKE_maskrasterize_handle_sample(MaskRasterHandle *mr_handle, const float xy[2]) { /* can't do this because some layers may invert */ - /* if (BLI_in_rctf_v(&mr_handle->bounds, xy)) */ + /* if (BLI_rctf_isect_pt_v(&mr_handle->bounds, xy)) */ const unsigned int layers_tot = mr_handle->layers_tot; unsigned int i; @@ -1246,7 +1246,7 @@ float BKE_maskrasterize_handle_sample(MaskRasterHandle *mr_handle, const float x float value_layer; /* also used as signal for unused layer (when render is disabled) */ - if (layer->alpha != 0.0f && BLI_in_rctf_v(&layer->bounds, xy)) { + if (layer->alpha != 0.0f && BLI_rctf_isect_pt_v(&layer->bounds, xy)) { value_layer = 1.0f - layer_bucket_depth_from_xy(layer, xy); switch (layer->falloff) { diff --git a/source/blender/blenlib/BLI_rect.h b/source/blender/blenlib/BLI_rect.h index 43639b141e1..eb9915d6c9b 100644 --- a/source/blender/blenlib/BLI_rect.h +++ b/source/blender/blenlib/BLI_rect.h @@ -57,16 +57,16 @@ void BLI_rctf_interp(struct rctf *rect, const struct rctf *rect_a, const struct //void BLI_rcti_interp(struct rctf *rect, struct rctf *rect_a, struct rctf *rect_b, float fac); int BLI_rctf_compare(const struct rctf *rect_a, const struct rctf *rect_b, const float limit); int BLI_rcti_compare(const struct rcti *rect_a, const struct rcti *rect_b); -int BLI_in_rcti(const struct rcti *rect, const int x, const int y); -int BLI_in_rcti_v(const struct rcti *rect, const int xy[2]); -int BLI_in_rctf(const struct rctf *rect, const float x, const float y); -int BLI_in_rctf_v(const struct rctf *rect, const float xy[2]); +int BLI_rctf_isect(const struct rctf *src1, const struct rctf *src2, struct rctf *dest); +int BLI_rcti_isect(const struct rcti *src1, const struct rcti *src2, struct rcti *dest); +int BLI_rcti_isect_pt(const struct rcti *rect, const int x, const int y); +int BLI_rcti_isect_pt_v(const struct rcti *rect, const int xy[2]); +int BLI_rctf_isect_pt(const struct rctf *rect, const float x, const float y); +int BLI_rctf_isect_pt_v(const struct rctf *rect, const float xy[2]); int BLI_rcti_isect_segment(const struct rcti *rect, const int s1[2], const int s2[2]); #if 0 /* NOT NEEDED YET */ int BLI_rctf_isect_segment(struct rcti *rect, int s1[2], int s2[2]); #endif -int BLI_rctf_isect(const struct rctf *src1, const struct rctf *src2, struct rctf *dest); -int BLI_rcti_isect(const struct rcti *src1, const struct rcti *src2, struct rcti *dest); void BLI_rctf_union(struct rctf *rctf1, const struct rctf *rctf2); void BLI_rcti_union(struct rcti *rcti1, const struct rcti *rcti2); void BLI_rcti_rctf_copy(struct rcti *dst, const struct rctf *src); @@ -88,4 +88,4 @@ void print_rcti(const char *str, const struct rcti *rect); } #endif -#endif +#endif /* __BLI_RECT_H__ */ diff --git a/source/blender/blenlib/intern/rct.c b/source/blender/blenlib/intern/rct.c index ac9ac39893b..225ede8a8ef 100644 --- a/source/blender/blenlib/intern/rct.c +++ b/source/blender/blenlib/intern/rct.c @@ -58,7 +58,7 @@ int BLI_rctf_is_empty(const rctf *rect) return ((rect->xmax <= rect->xmin) || (rect->ymax <= rect->ymin)); } -int BLI_in_rcti(const rcti *rect, const int x, const int y) +int BLI_rcti_isect_pt(const rcti *rect, const int x, const int y) { if (x < rect->xmin) return 0; if (x > rect->xmax) return 0; @@ -74,7 +74,7 @@ int BLI_in_rcti(const rcti *rect, const int x, const int y) * * \return True if \a rect is empty. */ -int BLI_in_rcti_v(const rcti *rect, const int xy[2]) +int BLI_rcti_isect_pt_v(const rcti *rect, const int xy[2]) { if (xy[0] < rect->xmin) return 0; if (xy[0] > rect->xmax) return 0; @@ -83,7 +83,7 @@ int BLI_in_rcti_v(const rcti *rect, const int xy[2]) return 1; } -int BLI_in_rctf(const rctf *rect, const float x, const float y) +int BLI_rctf_isect_pt(const rctf *rect, const float x, const float y) { if (x < rect->xmin) return 0; if (x > rect->xmax) return 0; @@ -92,7 +92,7 @@ int BLI_in_rctf(const rctf *rect, const float x, const float y) return 1; } -int BLI_in_rctf_v(const rctf *rect, const float xy[2]) +int BLI_rctf_isect_pt_v(const rctf *rect, const float xy[2]) { if (xy[0] < rect->xmin) return 0; if (xy[0] > rect->xmax) return 0; @@ -124,7 +124,7 @@ int BLI_rcti_isect_segment(const rcti *rect, const int s1[2], const int s2[2]) if (s1[1] > rect->ymax && s2[1] > rect->ymax) return 0; /* if either points intersect then we definetly intersect */ - if (BLI_in_rcti_v(rect, s1) || BLI_in_rcti_v(rect, s2)) { + if (BLI_rcti_isect_pt_v(rect, s1) || BLI_rcti_isect_pt_v(rect, s2)) { return 1; } else { diff --git a/source/blender/editors/animation/keyframes_edit.c b/source/blender/editors/animation/keyframes_edit.c index 78ac729f16e..b277d0eccb5 100644 --- a/source/blender/editors/animation/keyframes_edit.c +++ b/source/blender/editors/animation/keyframes_edit.c @@ -505,7 +505,7 @@ static short ok_bezier_region(KeyframeEditData *ked, BezTriple *bezt) if (ked->data) { short ok = 0; - #define KEY_CHECK_OK(_index) BLI_in_rctf_v(ked->data, bezt->vec[_index]) + #define KEY_CHECK_OK(_index) BLI_rctf_isect_pt_v(ked->data, bezt->vec[_index]) KEYFRAME_OK_CHECKS(KEY_CHECK_OK); #undef KEY_CHECK_OK diff --git a/source/blender/editors/gpencil/gpencil_paint.c b/source/blender/editors/gpencil/gpencil_paint.c index c5f2ad4254b..6f2952a1967 100644 --- a/source/blender/editors/gpencil/gpencil_paint.c +++ b/source/blender/editors/gpencil/gpencil_paint.c @@ -825,7 +825,7 @@ static void gp_stroke_eraser_dostroke(tGPsdata *p, int mval[], int mvalo[], shor } /* do boundbox check first */ - if (BLI_in_rcti(rect, x0, y0)) { + if (BLI_rcti_isect_pt(rect, x0, y0)) { /* only check if point is inside */ if ( ((x0 - mval[0]) * (x0 - mval[0]) + (y0 - mval[1]) * (y0 - mval[1])) <= rad * rad) { /* free stroke */ @@ -874,7 +874,7 @@ static void gp_stroke_eraser_dostroke(tGPsdata *p, int mval[], int mvalo[], shor } /* check that point segment of the boundbox of the eraser stroke */ - if (BLI_in_rcti(rect, x0, y0) || BLI_in_rcti(rect, x1, y1)) { + if (BLI_rcti_isect_pt(rect, x0, y0) || BLI_rcti_isect_pt(rect, x1, y1)) { /* check if point segment of stroke had anything to do with * eraser region (either within stroke painted, or on its lines) * - this assumes that linewidth is irrelevant diff --git a/source/blender/editors/include/UI_view2d.h b/source/blender/editors/include/UI_view2d.h index 9ab024a8b76..3a8f05a76f0 100644 --- a/source/blender/editors/include/UI_view2d.h +++ b/source/blender/editors/include/UI_view2d.h @@ -120,8 +120,8 @@ enum { /* Macros: */ /* test if mouse in a scrollbar (assume that scroller availability has been tested) */ -#define IN_2D_VERT_SCROLL(v2d, co) (BLI_in_rcti_v(&v2d->vert, co)) -#define IN_2D_HORIZ_SCROLL(v2d, co) (BLI_in_rcti_v(&v2d->hor, co)) +#define IN_2D_VERT_SCROLL(v2d, co) (BLI_rcti_isect_pt_v(&v2d->vert, co)) +#define IN_2D_HORIZ_SCROLL(v2d, co) (BLI_rcti_isect_pt_v(&v2d->hor, co)) /* ------------------------------------------ */ /* Type definitions: */ diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c index 39567a5b00b..33a5a0729ee 100644 --- a/source/blender/editors/interface/interface_handlers.c +++ b/source/blender/editors/interface/interface_handlers.c @@ -698,7 +698,7 @@ static int ui_but_mouse_inside_icon(uiBut *but, ARegion *ar, wmEvent *event) rect.xmax -= delta / 2; } - return BLI_in_rcti(&rect, x, y); + return BLI_rcti_isect_pt(&rect, x, y); } static int ui_but_start_drag(bContext *C, uiBut *but, uiHandleButtonData *data, wmEvent *event) @@ -4918,7 +4918,7 @@ static int ui_do_button(bContext *C, uiBlock *block, uiBut *but, wmEvent *event) static int ui_but_contains_pt(uiBut *but, int mx, int my) { - return BLI_in_rctf(&but->rect, mx, my); + return BLI_rctf_isect_pt(&but->rect, mx, my); } static uiBut *ui_but_find_activated(ARegion *ar) @@ -4994,7 +4994,7 @@ static int ui_mouse_inside_region(ARegion *ar, int x, int y) uiBlock *block; /* check if the mouse is in the region */ - if (!BLI_in_rcti(&ar->winrct, x, y)) { + if (!BLI_rcti_isect_pt(&ar->winrct, x, y)) { for (block = ar->uiblocks.first; block; block = block->next) block->auto_open = FALSE; @@ -5033,7 +5033,7 @@ static int ui_mouse_inside_region(ARegion *ar, int x, int y) } /* check if in the rect */ - if (!BLI_in_rcti(&mask_rct, mx, my)) + if (!BLI_rcti_isect_pt(&mask_rct, mx, my)) return 0; } @@ -5086,7 +5086,7 @@ static uiBut *ui_but_find_mouse_over(ARegion *ar, int x, int y) /* CLIP_EVENTS prevents the event from reaching other blocks */ if (block->flag & UI_BLOCK_CLIP_EVENTS) { /* check if mouse is inside block */ - if (BLI_in_rctf(&block->rect, mx, my)) { + if (BLI_rctf_isect_pt(&block->rect, mx, my)) { break; } } @@ -6100,7 +6100,7 @@ static int ui_handle_menu_event(bContext *C, wmEvent *event, uiPopupBlockHandle ui_window_to_block(ar, block, &mx, &my); /* check if mouse is inside block */ - inside = BLI_in_rctf(&block->rect, mx, my); + inside = BLI_rctf_isect_pt(&block->rect, mx, my); /* if there's an active modal button, don't check events or outside, except for search menu */ but = ui_but_find_activated(ar); @@ -6349,7 +6349,7 @@ static int ui_handle_menu_event(bContext *C, wmEvent *event, uiPopupBlockHandle uiSafetyRct *saferct = block->saferct.first; if (ELEM3(event->type, LEFTMOUSE, MIDDLEMOUSE, RIGHTMOUSE) && event->val == KM_PRESS) { - if (saferct && !BLI_in_rctf(&saferct->parent, event->x, event->y)) { + if (saferct && !BLI_rctf_isect_pt(&saferct->parent, event->x, event->y)) { if (block->flag & (UI_BLOCK_OUT_1)) menu->menuretval = UI_RETURN_OK; else @@ -6382,9 +6382,9 @@ static int ui_handle_menu_event(bContext *C, wmEvent *event, uiPopupBlockHandle * events we check all preceding block rects too to make * arrow keys navigation work */ if (event->type != MOUSEMOVE || saferct == block->saferct.first) { - if (BLI_in_rctf(&saferct->parent, (float)event->x, (float)event->y)) + if (BLI_rctf_isect_pt(&saferct->parent, (float)event->x, (float)event->y)) break; - if (BLI_in_rctf(&saferct->safety, (float)event->x, (float)event->y)) + if (BLI_rctf_isect_pt(&saferct->safety, (float)event->x, (float)event->y)) break; } } diff --git a/source/blender/editors/interface/interface_ops.c b/source/blender/editors/interface/interface_ops.c index d3b81974479..67c0d04a79f 100644 --- a/source/blender/editors/interface/interface_ops.c +++ b/source/blender/editors/interface/interface_ops.c @@ -140,10 +140,10 @@ static void eyedropper_color_sample_fl(bContext *C, Eyedropper *UNUSED(eye), int wmWindow *win = CTX_wm_window(C); ScrArea *sa; for (sa = win->screen->areabase.first; sa; sa = sa->next) { - if (BLI_in_rcti(&sa->totrct, mx, my)) { + if (BLI_rcti_isect_pt(&sa->totrct, mx, my)) { if (sa->spacetype == SPACE_IMAGE) { ARegion *ar = BKE_area_find_region_type(sa, RGN_TYPE_WINDOW); - if (BLI_in_rcti(&ar->winrct, mx, my)) { + if (BLI_rcti_isect_pt(&ar->winrct, mx, my)) { SpaceImage *sima = sa->spacedata.first; int mval[2] = {mx - ar->winrct.xmin, my - ar->winrct.ymin}; @@ -155,7 +155,7 @@ static void eyedropper_color_sample_fl(bContext *C, Eyedropper *UNUSED(eye), int } else if (sa->spacetype == SPACE_NODE) { ARegion *ar = BKE_area_find_region_type(sa, RGN_TYPE_WINDOW); - if (BLI_in_rcti(&ar->winrct, mx, my)) { + if (BLI_rcti_isect_pt(&ar->winrct, mx, my)) { SpaceNode *snode = sa->spacedata.first; int mval[2] = {mx - ar->winrct.xmin, my - ar->winrct.ymin}; @@ -167,7 +167,7 @@ static void eyedropper_color_sample_fl(bContext *C, Eyedropper *UNUSED(eye), int } else if (sa->spacetype == SPACE_CLIP) { ARegion *ar = BKE_area_find_region_type(sa, RGN_TYPE_WINDOW); - if (BLI_in_rcti(&ar->winrct, mx, my)) { + if (BLI_rcti_isect_pt(&ar->winrct, mx, my)) { SpaceClip *sc = sa->spacedata.first; int mval[2] = {mx - ar->winrct.xmin, my - ar->winrct.ymin}; diff --git a/source/blender/editors/interface/interface_panel.c b/source/blender/editors/interface/interface_panel.c index d0e66f532cc..fa3e04d1351 100644 --- a/source/blender/editors/interface/interface_panel.c +++ b/source/blender/editors/interface/interface_panel.c @@ -979,7 +979,7 @@ static void ui_do_drag(const bContext *C, wmEvent *event, Panel *panel) short align = panel_aligned(sa, ar), dx = 0, dy = 0; /* first clip for window, no dragging outside */ - if (!BLI_in_rcti_v(&ar->winrct, &event->x)) + if (!BLI_rcti_isect_pt_v(&ar->winrct, &event->x)) return; dx = (event->x - data->startx) & ~(PNL_GRID - 1); diff --git a/source/blender/editors/interface/interface_regions.c b/source/blender/editors/interface/interface_regions.c index 8dee1ff6a13..96c1b00d46d 100644 --- a/source/blender/editors/interface/interface_regions.c +++ b/source/blender/editors/interface/interface_regions.c @@ -899,7 +899,7 @@ int ui_searchbox_inside(ARegion *ar, int x, int y) { uiSearchboxData *data = ar->regiondata; - return(BLI_in_rcti(&data->bbox, x - ar->winrct.xmin, y - ar->winrct.ymin)); + return(BLI_rcti_isect_pt(&data->bbox, x - ar->winrct.xmin, y - ar->winrct.ymin)); } /* string validated to be of correct length (but->hardmax) */ @@ -935,13 +935,13 @@ void ui_searchbox_event(bContext *C, ARegion *ar, uiBut *but, wmEvent *event) ui_searchbox_select(C, ar, but, 1); break; case MOUSEMOVE: - if (BLI_in_rcti(&ar->winrct, event->x, event->y)) { + if (BLI_rcti_isect_pt(&ar->winrct, event->x, event->y)) { rcti rect; int a; for (a = 0; a < data->items.totitem; a++) { ui_searchbox_butrect(&rect, data, a); - if (BLI_in_rcti(&rect, event->x - ar->winrct.xmin, event->y - ar->winrct.ymin)) { + if (BLI_rcti_isect_pt(&rect, event->x - ar->winrct.xmin, event->y - ar->winrct.ymin)) { if (data->active != a + 1) { data->active = a + 1; ui_searchbox_select(C, ar, but, 0); diff --git a/source/blender/editors/mask/mask_select.c b/source/blender/editors/mask/mask_select.c index 285306ce12f..ace427f65ab 100644 --- a/source/blender/editors/mask/mask_select.c +++ b/source/blender/editors/mask/mask_select.c @@ -440,7 +440,7 @@ static int border_select_exec(bContext *C, wmOperator *op) /* TODO: handles? */ /* TODO: uw? */ - if (BLI_in_rctf_v(&rectf, point_deform->bezt.vec[1])) { + if (BLI_rctf_isect_pt_v(&rectf, point_deform->bezt.vec[1])) { BKE_mask_point_select_set(point, mode == GESTURE_MODAL_SELECT); BKE_mask_point_select_set_handle(point, mode == GESTURE_MODAL_SELECT); } @@ -525,7 +525,7 @@ static int do_lasso_select_mask(bContext *C, int mcords[][2], short moves, short point_deform->bezt.vec[1][0], point_deform->bezt.vec[1][1], &screen_co[0], &screen_co[1]); - if (BLI_in_rcti(&rect, screen_co[0], screen_co[1]) && + if (BLI_rcti_isect_pt(&rect, screen_co[0], screen_co[1]) && BLI_lasso_is_point_inside(mcords, moves, screen_co[0], screen_co[1], INT_MAX)) { BKE_mask_point_select_set(point, select); diff --git a/source/blender/editors/screen/area.c b/source/blender/editors/screen/area.c index 59310f9e675..0bfe5d04e5e 100644 --- a/source/blender/editors/screen/area.c +++ b/source/blender/editors/screen/area.c @@ -161,7 +161,7 @@ void ED_area_overdraw_flush(ScrArea *sa, ARegion *ar) ys = (az->y1 + az->y2) / 2; /* test if inside */ - if (BLI_in_rcti(&ar->winrct, xs, ys)) { + if (BLI_rcti_isect_pt(&ar->winrct, xs, ys)) { az->do_draw = TRUE; } } diff --git a/source/blender/editors/screen/screen_edit.c b/source/blender/editors/screen/screen_edit.c index d1458fec94b..adffb97c16f 100644 --- a/source/blender/editors/screen/screen_edit.c +++ b/source/blender/editors/screen/screen_edit.c @@ -1267,7 +1267,7 @@ void ED_screen_set_subwinactive(bContext *C, wmEvent *event) } if (sa) { for (ar = sa->regionbase.first; ar; ar = ar->next) { - if (BLI_in_rcti_v(&ar->winrct, &event->x)) + if (BLI_rcti_isect_pt_v(&ar->winrct, &event->x)) scr->subwinactive = ar->swinid; } } diff --git a/source/blender/editors/screen/screen_ops.c b/source/blender/editors/screen/screen_ops.c index ed519dc626c..823037a7903 100644 --- a/source/blender/editors/screen/screen_ops.c +++ b/source/blender/editors/screen/screen_ops.c @@ -521,7 +521,7 @@ static ScrArea *screen_areahascursor(bScreen *scr, int x, int y) ScrArea *sa = NULL; sa = scr->areabase.first; while (sa) { - if (BLI_in_rcti(&sa->totrct, x, y)) break; + if (BLI_rcti_isect_pt(&sa->totrct, x, y)) break; sa = sa->next; } @@ -540,7 +540,7 @@ static int actionzone_area_poll(bContext *C) int y = win->eventstate->y; for (az = sa->actionzones.first; az; az = az->next) - if (BLI_in_rcti(&az->rect, x, y)) + if (BLI_rcti_isect_pt(&az->rect, x, y)) return 1; } return 0; @@ -551,7 +551,7 @@ AZone *is_in_area_actionzone(ScrArea *sa, const int xy[2]) AZone *az = NULL; for (az = sa->actionzones.first; az; az = az->next) { - if (BLI_in_rcti_v(&az->rect, xy)) { + if (BLI_rcti_isect_pt_v(&az->rect, xy)) { if (az->type == AZONE_AREA) { /* no triangle intersect but a hotspot circle based on corner */ int radius = (xy[0] - az->x1) * (xy[0] - az->x1) + (xy[1] - az->y1) * (xy[1] - az->y1); diff --git a/source/blender/editors/sculpt_paint/paint_image.c b/source/blender/editors/sculpt_paint/paint_image.c index 223d90d404d..d916ee299b6 100644 --- a/source/blender/editors/sculpt_paint/paint_image.c +++ b/source/blender/editors/sculpt_paint/paint_image.c @@ -1615,7 +1615,7 @@ static int line_clip_rect2f( if (fabsf(l1[0] - l2[0]) < PROJ_GEOM_TOLERANCE) { /* this is a single point (or close to)*/ - if (BLI_in_rctf_v(rect, l1)) { + if (BLI_rctf_isect_pt_v(rect, l1)) { copy_v2_v2(l1_clip, l1); copy_v2_v2(l2_clip, l2); return 1; @@ -1643,7 +1643,7 @@ static int line_clip_rect2f( } if (fabsf(l1[1] - l2[1]) < PROJ_GEOM_TOLERANCE) { /* this is a single point (or close to)*/ - if (BLI_in_rctf_v(rect, l1)) { + if (BLI_rctf_isect_pt_v(rect, l1)) { copy_v2_v2(l1_clip, l1); copy_v2_v2(l2_clip, l2); return 1; @@ -1667,12 +1667,12 @@ static int line_clip_rect2f( /* Done with vertical lines */ /* are either of the points inside the rectangle ? */ - if (BLI_in_rctf_v(rect, l1)) { + if (BLI_rctf_isect_pt_v(rect, l1)) { copy_v2_v2(l1_clip, l1); ok1 = 1; } - if (BLI_in_rctf_v(rect, l2)) { + if (BLI_rctf_isect_pt_v(rect, l2)) { copy_v2_v2(l2_clip, l2); ok2 = 1; } @@ -1820,7 +1820,7 @@ static int project_bucket_isect_circle(const float cent[2], const float radius_s * this is even less work then an intersection test */ #if 0 - if (BLI_in_rctf_v(bucket_bounds, cent)) + if (BLI_rctf_isect_pt_v(bucket_bounds, cent)) return 1; #endif @@ -1987,9 +1987,9 @@ static void project_bucket_clip_face( float bucket_bounds_ss[4][2]; /* get the UV space bounding box */ - inside_bucket_flag |= BLI_in_rctf_v(bucket_bounds, v1coSS); - inside_bucket_flag |= BLI_in_rctf_v(bucket_bounds, v2coSS) << 1; - inside_bucket_flag |= BLI_in_rctf_v(bucket_bounds, v3coSS) << 2; + inside_bucket_flag |= BLI_rctf_isect_pt_v(bucket_bounds, v1coSS); + inside_bucket_flag |= BLI_rctf_isect_pt_v(bucket_bounds, v2coSS) << 1; + inside_bucket_flag |= BLI_rctf_isect_pt_v(bucket_bounds, v3coSS) << 2; if (inside_bucket_flag == ISECT_ALL3) { /* all screenspace points are inside the bucket bounding box, this means we don't need to clip and can simply return the UVs */ @@ -2816,7 +2816,7 @@ static int project_bucket_face_isect(ProjPaintState *ps, int bucket_x, int bucke fidx = mf->v4 ? 3 : 2; do { v = ps->screenCoords[(*(&mf->v1 + fidx))]; - if (BLI_in_rctf_v(&bucket_bounds, v)) { + if (BLI_rctf_isect_pt_v(&bucket_bounds, v)) { return 1; } } while (fidx--); diff --git a/source/blender/editors/space_clip/clip_graph_ops.c b/source/blender/editors/space_clip/clip_graph_ops.c index e94b28d22fa..71dcd326887 100644 --- a/source/blender/editors/space_clip/clip_graph_ops.c +++ b/source/blender/editors/space_clip/clip_graph_ops.c @@ -321,7 +321,7 @@ static void border_select_cb(void *userdata, MovieTrackingTrack *UNUSED(track), { BorderSelectuserData *data = (BorderSelectuserData *) userdata; - if (BLI_in_rctf(&data->rect, scene_framenr, val)) { + if (BLI_rctf_isect_pt(&data->rect, scene_framenr, val)) { int flag = 0; if (coord == 0) diff --git a/source/blender/editors/space_clip/tracking_select.c b/source/blender/editors/space_clip/tracking_select.c index 5a79e832ebe..507e492497d 100644 --- a/source/blender/editors/space_clip/tracking_select.c +++ b/source/blender/editors/space_clip/tracking_select.c @@ -363,7 +363,7 @@ static int border_select_exec(bContext *C, wmOperator *op) MovieTrackingMarker *marker = BKE_tracking_marker_get(track, framenr); if (MARKER_VISIBLE(sc, track, marker)) { - if (BLI_in_rctf_v(&rectf, marker->pos)) { + if (BLI_rctf_isect_pt_v(&rectf, marker->pos)) { if (mode == GESTURE_MODAL_SELECT) BKE_tracking_track_flag_set(track, TRACK_AREA_ALL, SELECT); else @@ -441,7 +441,7 @@ static int do_lasso_select_marker(bContext *C, int mcords[][2], short moves, sho /* marker in screen coords */ ED_clip_point_stable_pos__reverse(sc, ar, marker->pos, screen_co); - if (BLI_in_rcti(&rect, screen_co[0], screen_co[1]) && + if (BLI_rcti_isect_pt(&rect, screen_co[0], screen_co[1]) && BLI_lasso_is_point_inside(mcords, moves, screen_co[0], screen_co[1], V2D_IS_CLIPPED)) { if (select) diff --git a/source/blender/editors/space_file/file_ops.c b/source/blender/editors/space_file/file_ops.c index 01962853556..ff7a71af8c2 100644 --- a/source/blender/editors/space_file/file_ops.c +++ b/source/blender/editors/space_file/file_ops.c @@ -327,7 +327,7 @@ static int file_select_invoke(bContext *C, wmOperator *op, wmEvent *event) rect.xmin = rect.xmax = event->mval[0]; rect.ymin = rect.ymax = event->mval[1]; - if (!BLI_in_rcti(&ar->v2d.mask, rect.xmin, rect.ymin)) + if (!BLI_rcti_isect_pt(&ar->v2d.mask, rect.xmin, rect.ymin)) return OPERATOR_CANCELLED; /* single select, deselect all selected first */ @@ -525,7 +525,7 @@ int file_highlight_set(SpaceFile *sfile, ARegion *ar, int mx, int my) mx -= ar->winrct.xmin; my -= ar->winrct.ymin; - if (BLI_in_rcti(&ar->v2d.mask, mx, my)) { + if (BLI_rcti_isect_pt(&ar->v2d.mask, mx, my)) { float fx, fy; int active_file; diff --git a/source/blender/editors/space_node/drawnode.c b/source/blender/editors/space_node/drawnode.c index 125d5e3be77..8a1f0e5b611 100644 --- a/source/blender/editors/space_node/drawnode.c +++ b/source/blender/editors/space_node/drawnode.c @@ -454,7 +454,7 @@ static int node_resize_area_default(bNode *node, int x, int y) rctf totr = node->totr; /* right part of node */ totr.xmin = node->totr.xmax - 20.0f; - if (BLI_in_rctf(&totr, x, y)) + if (BLI_rctf_isect_pt(&totr, x, y)) return NODE_RESIZE_RIGHT; else return 0; diff --git a/source/blender/editors/space_node/node_draw.c b/source/blender/editors/space_node/node_draw.c index 0f559b0cbfc..f1a91df6f53 100644 --- a/source/blender/editors/space_node/node_draw.c +++ b/source/blender/editors/space_node/node_draw.c @@ -476,12 +476,12 @@ void node_update_default(const bContext *C, bNodeTree *ntree, bNode *node) int node_select_area_default(bNode *node, int x, int y) { - return BLI_in_rctf(&node->totr, x, y); + return BLI_rctf_isect_pt(&node->totr, x, y); } int node_tweak_area_default(bNode *node, int x, int y) { - return BLI_in_rctf(&node->totr, x, y); + return BLI_rctf_isect_pt(&node->totr, x, y); } int node_get_colorid(bNode *node) @@ -989,7 +989,7 @@ void node_set_cursor(wmWindow *win, SpaceNode *snode) else { /* check nodes front to back */ for (node = ntree->nodes.last; node; node = node->prev) { - if (BLI_in_rctf(&node->totr, snode->cursor[0], snode->cursor[1])) + if (BLI_rctf_isect_pt(&node->totr, snode->cursor[0], snode->cursor[1])) break; /* first hit on node stops */ } if (node) { diff --git a/source/blender/editors/space_node/node_edit.c b/source/blender/editors/space_node/node_edit.c index 382c02c8765..fbae8b17ebf 100644 --- a/source/blender/editors/space_node/node_edit.c +++ b/source/blender/editors/space_node/node_edit.c @@ -1037,11 +1037,11 @@ static int UNUSED_FUNCTION(node_mouse_groupheader) (SpaceNode * snode) // XXX areamouseco_to_ipoco(G.v2d, mval, &mx, &my); /* click in header or outside? */ - if (BLI_in_rctf(&gnode->totr, mx, my) == 0) { + if (BLI_rctf_isect_pt(&gnode->totr, mx, my) == 0) { rctf rect = gnode->totr; rect.ymax += NODE_DY; - if (BLI_in_rctf(&rect, mx, my) == 0) + if (BLI_rctf_isect_pt(&rect, mx, my) == 0) snode_make_group_editable(snode, NULL); /* toggles, so exits editmode */ // else // XXX transform_nodes(snode->nodetree, 'g', "Move group"); @@ -1085,7 +1085,7 @@ int node_find_indicated_socket(SpaceNode *snode, bNode **nodep, bNodeSocket **so if (in_out & SOCK_IN) { for (sock = node->inputs.first; sock; sock = sock->next) { if (!nodeSocketIsHidden(sock)) { - if (BLI_in_rctf(&rect, sock->locx, sock->locy)) { + if (BLI_rctf_isect_pt(&rect, sock->locx, sock->locy)) { if (node == visible_node(snode, &rect)) { *nodep = node; *sockp = sock; @@ -1098,7 +1098,7 @@ int node_find_indicated_socket(SpaceNode *snode, bNode **nodep, bNodeSocket **so if (in_out & SOCK_OUT) { for (sock = node->outputs.first; sock; sock = sock->next) { if (!nodeSocketIsHidden(sock)) { - if (BLI_in_rctf(&rect, sock->locx, sock->locy)) { + if (BLI_rctf_isect_pt(&rect, sock->locx, sock->locy)) { if (node == visible_node(snode, &rect)) { *nodep = node; *sockp = sock; @@ -1116,7 +1116,7 @@ int node_find_indicated_socket(SpaceNode *snode, bNode **nodep, bNodeSocket **so if (in_out & SOCK_IN) { for (sock = snode->edittree->outputs.first; sock; sock = sock->next) { if (!nodeSocketIsHidden(sock)) { - if (BLI_in_rctf(&rect, sock->locx, sock->locy)) { + if (BLI_rctf_isect_pt(&rect, sock->locx, sock->locy)) { *nodep = NULL; /* NULL node pointer indicates group socket */ *sockp = sock; return 1; @@ -1127,7 +1127,7 @@ int node_find_indicated_socket(SpaceNode *snode, bNode **nodep, bNodeSocket **so if (in_out & SOCK_OUT) { for (sock = snode->edittree->inputs.first; sock; sock = sock->next) { if (!nodeSocketIsHidden(sock)) { - if (BLI_in_rctf(&rect, sock->locx, sock->locy)) { + if (BLI_rctf_isect_pt(&rect, sock->locx, sock->locy)) { *nodep = NULL; /* NULL node pointer indicates group socket */ *sockp = sock; return 1; diff --git a/source/blender/editors/space_node/node_relationships.c b/source/blender/editors/space_node/node_relationships.c index f5a65065895..12c221b9273 100644 --- a/source/blender/editors/space_node/node_relationships.c +++ b/source/blender/editors/space_node/node_relationships.c @@ -1140,7 +1140,7 @@ static int node_attach_exec(bContext *C, wmOperator *UNUSED(op)) /* skip selected, those are the nodes we want to attach */ if ((frame->type != NODE_FRAME) || (frame->flag & NODE_SELECT)) continue; - if (BLI_in_rctf(&frame->totr, snode->cursor[0], snode->cursor[1])) + if (BLI_rctf_isect_pt(&frame->totr, snode->cursor[0], snode->cursor[1])) break; } if (frame) { diff --git a/source/blender/editors/space_node/node_select.c b/source/blender/editors/space_node/node_select.c index f41f203aefe..a56d76a3ef7 100644 --- a/source/blender/editors/space_node/node_select.c +++ b/source/blender/editors/space_node/node_select.c @@ -563,7 +563,7 @@ static int do_lasso_select_node(bContext *C, int mcords[][2], short moves, short cent[0], cent[1], &screen_co[0], &screen_co[1]); - if (BLI_in_rcti(&rect, screen_co[0], screen_co[1]) && + if (BLI_rcti_isect_pt(&rect, screen_co[0], screen_co[1]) && BLI_lasso_is_point_inside(mcords, moves, screen_co[0], screen_co[1], INT_MAX)) { if (select) diff --git a/source/blender/editors/space_view3d/view3d_select.c b/source/blender/editors/space_view3d/view3d_select.c index 49d7c9ba28c..6f3cc744537 100644 --- a/source/blender/editors/space_view3d/view3d_select.c +++ b/source/blender/editors/space_view3d/view3d_select.c @@ -291,7 +291,7 @@ static int view3d_selectable_data(bContext *C) /* helper also for borderselect */ static int edge_fully_inside_rect(rcti *rect, short x1, short y1, short x2, short y2) { - return BLI_in_rcti(rect, x1, y1) && BLI_in_rcti(rect, x2, y2); + return BLI_rcti_isect_pt(rect, x1, y1) && BLI_rcti_isect_pt(rect, x2, y2); } static int edge_inside_rect(rcti *rect, short x1, short y1, short x2, short y2) @@ -394,7 +394,7 @@ static void do_lasso_select_mesh__doSelectVert(void *userData, BMVert *eve, int { LassoSelectUserData *data = userData; - if (BLI_in_rcti(data->rect, x, y) && + if (BLI_rcti_isect_pt(data->rect, x, y) && BLI_lasso_is_point_inside(data->mcords, data->moves, x, y, IS_CLIPPED)) { BM_vert_select_set(data->vc->em->bm, eve, data->select); @@ -425,7 +425,7 @@ static void do_lasso_select_mesh__doSelectFace(void *userData, BMFace *efa, int { LassoSelectUserData *data = userData; - if (BLI_in_rcti(data->rect, x, y) && + if (BLI_rcti_isect_pt(data->rect, x, y) && BLI_lasso_is_point_inside(data->mcords, data->moves, x, y, IS_CLIPPED)) { BM_face_select_set(data->vc->em->bm, efa, data->select); @@ -769,7 +769,7 @@ static void do_lasso_select_node(int mcords[][2], short moves, short select) node_centf[1] = BLI_RCT_CENTER_Y(&node->totr); ipoco_to_areaco_noclip(G.v2d, node_centf, node_cent); - if (BLI_in_rcti_v(&rect, node_cent) && BLI_lasso_is_point_inside(mcords, moves, node_cent[0], node_cent[1])) { + if (BLI_rcti_isect_pt_v(&rect, node_cent) && BLI_lasso_is_point_inside(mcords, moves, node_cent[0], node_cent[1])) { if (select) { node->flag |= SELECT; } @@ -1552,7 +1552,7 @@ static void do_nurbs_box_select__doSelect(void *userData, Nurb *UNUSED(nu), BPoi Object *obedit = data->vc->obedit; Curve *cu = (Curve *)obedit->data; - if (BLI_in_rcti(data->rect, x, y)) { + if (BLI_rcti_isect_pt(data->rect, x, y)) { if (bp) { bp->f1 = data->select ? (bp->f1 | SELECT) : (bp->f1 & ~SELECT); if (bp == cu->lastsel && !(bp->f1 & 1)) cu->lastsel = NULL; @@ -1599,7 +1599,7 @@ static void do_lattice_box_select__doSelect(void *userData, BPoint *bp, int x, i { BoxSelectUserData *data = userData; - if (BLI_in_rcti(data->rect, x, y)) { + if (BLI_rcti_isect_pt(data->rect, x, y)) { bp->f1 = data->select ? (bp->f1 | SELECT) : (bp->f1 & ~SELECT); } } @@ -1624,7 +1624,7 @@ static void do_mesh_box_select__doSelectVert(void *userData, BMVert *eve, int x, { BoxSelectUserData *data = userData; - if (BLI_in_rcti(data->rect, x, y)) { + if (BLI_rcti_isect_pt(data->rect, x, y)) { BM_vert_select_set(data->vc->em->bm, eve, data->select); } } @@ -1650,7 +1650,7 @@ static void do_mesh_box_select__doSelectFace(void *userData, BMFace *efa, int x, { BoxSelectUserData *data = userData; - if (BLI_in_rcti(data->rect, x, y)) { + if (BLI_rcti_isect_pt(data->rect, x, y)) { BM_face_select_set(data->vc->em->bm, efa, data->select); } } diff --git a/source/blender/editors/uvedit/uvedit_ops.c b/source/blender/editors/uvedit/uvedit_ops.c index d3336d105c4..6f3e6bee850 100644 --- a/source/blender/editors/uvedit/uvedit_ops.c +++ b/source/blender/editors/uvedit/uvedit_ops.c @@ -2567,7 +2567,7 @@ static int border_select_exec(bContext *C, wmOperator *op) tf = CustomData_bmesh_get(&em->bm->pdata, efa->head.data, CD_MTEXPOLY); if (uvedit_face_visible_test(scene, ima, efa, tf)) { uv_poly_center(em, efa, cent); - if (BLI_in_rctf_v(&rectf, cent)) { + if (BLI_rctf_isect_pt_v(&rectf, cent)) { BM_elem_flag_enable(efa, BM_ELEM_TAG); change = 1; } @@ -2592,13 +2592,13 @@ static int border_select_exec(bContext *C, wmOperator *op) if (!pinned || (ts->uv_flag & UV_SYNC_SELECTION) ) { /* UV_SYNC_SELECTION - can't do pinned selection */ - if (BLI_in_rctf_v(&rectf, luv->uv)) { + if (BLI_rctf_isect_pt_v(&rectf, luv->uv)) { if (select) uvedit_uv_select_enable(em, scene, l, FALSE); else uvedit_uv_select_disable(em, scene, l); } } else if (pinned) { - if ((luv->flag & MLOOPUV_PINNED) && BLI_in_rctf_v(&rectf, luv->uv)) { + if ((luv->flag & MLOOPUV_PINNED) && BLI_rctf_isect_pt_v(&rectf, luv->uv)) { if (select) uvedit_uv_select_enable(em, scene, l, FALSE); else uvedit_uv_select_disable(em, scene, l); } @@ -2771,7 +2771,7 @@ static int do_lasso_select_mesh_uv(bContext *C, int mcords[][2], short moves, sh float cent[2]; uv_poly_center(em, efa, cent); UI_view2d_view_to_region(&ar->v2d, cent[0], cent[1], &screen_uv[0], &screen_uv[1]); - if (BLI_in_rcti_v(&rect, screen_uv) && + if (BLI_rcti_isect_pt_v(&rect, screen_uv) && BLI_lasso_is_point_inside(mcords, moves, screen_uv[0], screen_uv[1], V2D_IS_CLIPPED)) { uvedit_face_select_enable(scene, em, efa, FALSE); @@ -2788,7 +2788,7 @@ static int do_lasso_select_mesh_uv(bContext *C, int mcords[][2], short moves, sh if ((select) != (uvedit_uv_select_test(em, scene, l))) { MLoopUV *luv = CustomData_bmesh_get(&em->bm->ldata, l->head.data, CD_MLOOPUV); UI_view2d_view_to_region(&ar->v2d, luv->uv[0], luv->uv[1], &screen_uv[0], &screen_uv[1]); - if (BLI_in_rcti_v(&rect, screen_uv) && + if (BLI_rcti_isect_pt_v(&rect, screen_uv) && BLI_lasso_is_point_inside(mcords, moves, screen_uv[0], screen_uv[1], V2D_IS_CLIPPED)) { if (select) { diff --git a/source/blender/render/intern/source/shadbuf.c b/source/blender/render/intern/source/shadbuf.c index dce4d681ec9..2d7a64bad04 100644 --- a/source/blender/render/intern/source/shadbuf.c +++ b/source/blender/render/intern/source/shadbuf.c @@ -1824,7 +1824,7 @@ static void isb_bsp_face_inside(ISBBranch *bspn, BSPFace *face) if ((samp->facenr!=face->facenr || samp->obi!=face->obi) && samp->shadfac) { if (face->box.zmin < samp->zco[2]) { - if (BLI_in_rctf_v((rctf *)&face->box, samp->zco)) { + if (BLI_rctf_isect_pt_v((rctf *)&face->box, samp->zco)) { int inshadow= 0; if (face->type) { diff --git a/source/blender/windowmanager/intern/wm_event_system.c b/source/blender/windowmanager/intern/wm_event_system.c index 577a472b40d..60c61dbe88c 100644 --- a/source/blender/windowmanager/intern/wm_event_system.c +++ b/source/blender/windowmanager/intern/wm_event_system.c @@ -922,7 +922,7 @@ static int wm_operator_invoke(bContext *C, wmOperatorType *ot, wmEvent *event, ScrArea *sa = CTX_wm_area(C); if (ar && ar->regiontype == RGN_TYPE_WINDOW && event && - BLI_in_rcti_v(&ar->winrct, &event->x)) + BLI_rcti_isect_pt_v(&ar->winrct, &event->x)) { winrect = &ar->winrct; } @@ -1642,17 +1642,17 @@ static int handler_boundbox_test(wmEventHandler *handler, wmEvent *event) rcti rect = *handler->bblocal; BLI_rcti_translate(&rect, handler->bbwin->xmin, handler->bbwin->ymin); - if (BLI_in_rcti_v(&rect, &event->x)) + if (BLI_rcti_isect_pt_v(&rect, &event->x)) return 1; - else if (event->type == MOUSEMOVE && BLI_in_rcti_v(&rect, &event->prevx)) + else if (event->type == MOUSEMOVE && BLI_rcti_isect_pt_v(&rect, &event->prevx)) return 1; else return 0; } else { - if (BLI_in_rcti_v(handler->bbwin, &event->x)) + if (BLI_rcti_isect_pt_v(handler->bbwin, &event->x)) return 1; - else if (event->type == MOUSEMOVE && BLI_in_rcti_v(handler->bbwin, &event->prevx)) + else if (event->type == MOUSEMOVE && BLI_rcti_isect_pt_v(handler->bbwin, &event->prevx)) return 1; else return 0; @@ -1888,10 +1888,10 @@ static int wm_event_inside_i(wmEvent *event, rcti *rect) { if (wm_event_always_pass(event)) return 1; - if (BLI_in_rcti_v(rect, &event->x)) + if (BLI_rcti_isect_pt_v(rect, &event->x)) return 1; if (event->type == MOUSEMOVE) { - if (BLI_in_rcti_v(rect, &event->prevx)) { + if (BLI_rcti_isect_pt_v(rect, &event->prevx)) { return 1; } return 0; @@ -1906,7 +1906,7 @@ static ScrArea *area_event_inside(bContext *C, const int xy[2]) if (screen) for (sa = screen->areabase.first; sa; sa = sa->next) - if (BLI_in_rcti_v(&sa->totrct, xy)) + if (BLI_rcti_isect_pt_v(&sa->totrct, xy)) return sa; return NULL; } @@ -1919,7 +1919,7 @@ static ARegion *region_event_inside(bContext *C, const int xy[2]) if (screen && area) for (ar = area->regionbase.first; ar; ar = ar->next) - if (BLI_in_rcti_v(&ar->winrct, xy)) + if (BLI_rcti_isect_pt_v(&ar->winrct, xy)) return ar; return NULL; } @@ -1950,7 +1950,7 @@ static void wm_paintcursor_test(bContext *C, wmEvent *event) wm_paintcursor_tag(C, wm->paintcursors.first, ar); /* if previous position was not in current region, we have to set a temp new context */ - if (ar == NULL || !BLI_in_rcti_v(&ar->winrct, &event->prevx)) { + if (ar == NULL || !BLI_rcti_isect_pt_v(&ar->winrct, &event->prevx)) { ScrArea *sa = CTX_wm_area(C); CTX_wm_area_set(C, area_event_inside(C, &event->prevx)); @@ -2125,7 +2125,7 @@ void wm_event_do_handlers(bContext *C) if (CTX_wm_window(C) == NULL) return; - doit |= (BLI_in_rcti_v(&ar->winrct, &event->x)); + doit |= (BLI_rcti_isect_pt_v(&ar->winrct, &event->x)); if (action & WM_HANDLER_BREAK) break; From b47a7c770130cff7b9e1a96e74ebd37f6cf6c47e Mon Sep 17 00:00:00 2001 From: Nicholas Rishel Date: Fri, 24 Aug 2012 05:12:05 +0000 Subject: [PATCH 105/163] Code cleanup: comment referenced an outdated file path + spelling error --- source/blender/blenkernel/BKE_context.h | 4 ++-- source/blender/blenkernel/BKE_screen.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/source/blender/blenkernel/BKE_context.h b/source/blender/blenkernel/BKE_context.h index f5e073eb27a..22b8f474cca 100644 --- a/source/blender/blenkernel/BKE_context.h +++ b/source/blender/blenkernel/BKE_context.h @@ -88,7 +88,7 @@ typedef struct bContextStore { int used; } bContextStore; -/* for the conrtext's rna mode enum +/* for the context's rna mode enum * keep aligned with data_mode_strings in context.c */ enum { CTX_MODE_EDIT_MESH = 0, @@ -174,7 +174,7 @@ void CTX_wm_operator_poll_msg_set(struct bContext *C, const char *msg); * * - listbases consist of CollectionPointerLink items and must be * freed with BLI_freelistN! - * - the dir listbase consits of LinkData items */ + * - the dir listbase consists of LinkData items */ /* data type, needed so we can tell between a NULL pointer and an empty list */ enum { diff --git a/source/blender/blenkernel/BKE_screen.h b/source/blender/blenkernel/BKE_screen.h index e99fc413ca1..8aa08beec57 100644 --- a/source/blender/blenkernel/BKE_screen.h +++ b/source/blender/blenkernel/BKE_screen.h @@ -55,7 +55,7 @@ struct wmWindowManager; #include "RNA_types.h" /* spacetype has everything stored to get an editor working, it gets initialized via - * ED_spacetypes_init() in editors/area/spacetypes.c */ + * ED_spacetypes_init() in editors/space_api/spacetypes.c */ /* an editor in Blender is a combined ScrArea + SpaceType + SpaceData */ #define BKE_ST_MAXNAME 64 From cfd21c7852dd29d8e58fd77ce4221598442efe7c Mon Sep 17 00:00:00 2001 From: Nicholas Rishel Date: Fri, 24 Aug 2012 05:14:16 +0000 Subject: [PATCH 106/163] Gave the spacetype time region header malloc a more descriptive text, consistent with other header mallocs. --- source/blender/editors/space_outliner/space_outliner.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/blender/editors/space_outliner/space_outliner.c b/source/blender/editors/space_outliner/space_outliner.c index 489a4efe891..6cfc3f97b31 100644 --- a/source/blender/editors/space_outliner/space_outliner.c +++ b/source/blender/editors/space_outliner/space_outliner.c @@ -483,7 +483,7 @@ void ED_spacetype_outliner(void) BLI_addhead(&st->regiontypes, art); /* regions: header */ - art = MEM_callocN(sizeof(ARegionType), "spacetype time region"); + art = MEM_callocN(sizeof(ARegionType), "spacetype time header region"); art->regionid = RGN_TYPE_HEADER; art->prefsizey = HEADERY; art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_VIEW2D | ED_KEYMAP_FRAMES | ED_KEYMAP_HEADER; From 93d89ec7683af9daf989fa643be3edceb1615ba1 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 24 Aug 2012 08:17:53 +0000 Subject: [PATCH 107/163] correct assert for customdata overlap, also quiet `uninitialized` warning in transform. --- source/blender/blenkernel/intern/customdata.c | 2 +- source/blender/editors/transform/transform.c | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/source/blender/blenkernel/intern/customdata.c b/source/blender/blenkernel/intern/customdata.c index c55f1b551e2..36c571a53ce 100644 --- a/source/blender/blenkernel/intern/customdata.c +++ b/source/blender/blenkernel/intern/customdata.c @@ -2018,7 +2018,7 @@ void CustomData_interp(const CustomData *source, CustomData *dest, for (j = 0; j < count; ++j) { /* if this happens we need to do a temp copy, see: USE_INTERP_OVERLAP_FIX */ - BLI_assert(dest_index != src_indices[j]); + BLI_assert(((source == dest) && (dest_index == src_indices[j])) == FALSE); sources[j] = (char *)src_data + typeInfo->size * src_indices[j]; } diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c index 284c670fa08..8259ca64bad 100644 --- a/source/blender/editors/transform/transform.c +++ b/source/blender/editors/transform/transform.c @@ -208,6 +208,11 @@ void convertViewVec(TransInfo *t, float r_vec[3], int dx, int dy) /* TODO - NOT WORKING, this isnt so bad since its only display aspect */ ED_space_clip_get_aspect(t->sa->spacedata.first, &aspx, &aspy); } + else { + /* should never happen, quiet warnings */ + BLI_assert(0); + aspx = aspy = 1.0f; + } r_vec[0] *= aspx; r_vec[1] *= aspy; From 501efb0e7cb671cfa2e0dd37308ab6759f32cb49 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Fri, 24 Aug 2012 09:07:04 +0000 Subject: [PATCH 108/163] Sequencer: bright/contrast modifier Behaves in exactly the same way as bright/contrast compositor node. Some code could be de-duplicated, like contrast formula and mask influence, but wouldn't call it stopper for commit since it's already needed for grading Mango. --- .../scripts/startup/bl_ui/space_sequencer.py | 4 + .../blender/blenkernel/intern/seqmodifier.c | 101 ++++++++++++++++++ source/blender/makesdna/DNA_sequence_types.h | 8 ++ .../blender/makesrna/intern/rna_sequencer.c | 25 +++++ 4 files changed, 138 insertions(+) diff --git a/release/scripts/startup/bl_ui/space_sequencer.py b/release/scripts/startup/bl_ui/space_sequencer.py index 25054a6baa6..ebc73752aef 100644 --- a/release/scripts/startup/bl_ui/space_sequencer.py +++ b/release/scripts/startup/bl_ui/space_sequencer.py @@ -930,6 +930,10 @@ class SEQUENCER_PT_modifiers(SequencerButtonsPanel, Panel): box.template_curve_mapping(mod, "curve_mapping", type='COLOR') elif mod.type == 'HUE_CORRECT': box.template_curve_mapping(mod, "curve_mapping", type='HUE') + elif mod.type == 'BRIGHT_CONTRAST': + col = box.column() + col.prop(mod, "bright") + col.prop(mod, "contrast") if __name__ == "__main__": # only for live edit. diff --git a/source/blender/blenkernel/intern/seqmodifier.c b/source/blender/blenkernel/intern/seqmodifier.c index 26c2fe03688..70f27db0f74 100644 --- a/source/blender/blenkernel/intern/seqmodifier.c +++ b/source/blender/blenkernel/intern/seqmodifier.c @@ -394,6 +394,106 @@ static SequenceModifierTypeInfo seqModifier_HueCorrect = { hue_correct_apply /* apply */ }; +/* **** Bright/Contrast Modifier **** */ + +typedef struct BrightContrastThreadData { + float bright; + float contrast; +} BrightContrastThreadData; + +void brightcontrast_apply_threaded(int width, int height, unsigned char *rect, float *rect_float, + unsigned char *mask_rect, float *mask_rect_float, void *data_v) +{ + BrightContrastThreadData *data = (BrightContrastThreadData *) data_v; + int x, y; + + float i; + int c; + float a, b, v; + float brightness = data->bright / 100.0f; + float contrast = data->contrast; + float delta = contrast / 200.0f; + + a = 1.0f - delta * 2.0f; + /* + * The algorithm is by Werner D. Streidt + * (http://visca.com/ffactory/archives/5-99/msg00021.html) + * Extracted of OpenCV demhist.c + */ + if (contrast > 0) { + a = 1.0f / a; + b = a * (brightness - delta); + } + else { + delta *= -1; + b = a * (brightness + delta); + } + + for (y = 0; y < height; y++) { + for (x = 0; x < width; x++) { + int pixel_index = (y * width + x) * 4; + + if (rect) { + unsigned char *pixel = rect + pixel_index; + + for (c = 0; c < 3; c++) { + i = pixel[c]; + v = a * i + b; + + if (mask_rect) { + unsigned char *m = mask_rect + pixel_index; + float t = (float) m[c] / 255.0f; + + pixel[c] = pixel[c] * (1.0f - t) + v * t; + } + else + pixel[c] = v; + } + } + else if (rect_float) { + float *pixel = rect_float + pixel_index; + + for (c = 0; c < 3; c++) { + i = pixel[c]; + v = a * i + b; + + if (mask_rect_float) { + float *m = mask_rect_float + pixel_index; + + pixel[c] = pixel[c] * (1.0f - m[c]) + v * m[c]; + } + else + pixel[c] = v; + } + } + } + } +} + +ImBuf *brightcontrast_apply(struct SequenceModifierData *smd, ImBuf *ibuf, ImBuf *mask) +{ + BrightContrastModifierData *bcmd = (BrightContrastModifierData *) smd; + BrightContrastThreadData data; + ImBuf *ibuf_new = IMB_dupImBuf(ibuf); + + data.bright = bcmd->bright; + data.contrast = bcmd->contrast; + + modifier_apply_threaded(ibuf_new, mask, brightcontrast_apply_threaded, &data); + + return ibuf_new; +} + +static SequenceModifierTypeInfo seqModifier_BrightContrast = { + "Bright/Contrast", /* name */ + "BrightContrastModifierData", /* struct_name */ + sizeof(BrightContrastModifierData), /* struct_size */ + NULL, /* init_data */ + NULL, /* free_data */ + NULL, /* copy_data */ + brightcontrast_apply /* apply */ +}; + /*********************** Modifier functions *************************/ static void sequence_modifier_type_info_init(void) @@ -403,6 +503,7 @@ static void sequence_modifier_type_info_init(void) INIT_TYPE(ColorBalance); INIT_TYPE(Curves); INIT_TYPE(HueCorrect); + INIT_TYPE(BrightContrast); #undef INIT_TYPE } diff --git a/source/blender/makesdna/DNA_sequence_types.h b/source/blender/makesdna/DNA_sequence_types.h index 0835bb6b4c8..c83bddbfc64 100644 --- a/source/blender/makesdna/DNA_sequence_types.h +++ b/source/blender/makesdna/DNA_sequence_types.h @@ -271,6 +271,13 @@ typedef struct HueCorrectModifierData { struct CurveMapping curve_mapping; } HueCorrectModifierData; +typedef struct BrightContrastModifierData { + SequenceModifierData modifier; + + float bright; + float contrast; +} BrightContrastModifierData; + #define MAXSEQ 32 #define SELECT 1 @@ -401,6 +408,7 @@ enum { seqModifierType_ColorBalance = 1, seqModifierType_Curves = 2, seqModifierType_HueCorrect = 3, + seqModifierType_BrightContrast = 4, NUM_SEQUENCE_MODIFIER_TYPES }; diff --git a/source/blender/makesrna/intern/rna_sequencer.c b/source/blender/makesrna/intern/rna_sequencer.c index ab59d043daf..932c578899d 100644 --- a/source/blender/makesrna/intern/rna_sequencer.c +++ b/source/blender/makesrna/intern/rna_sequencer.c @@ -63,6 +63,7 @@ EnumPropertyItem sequence_modifier_type_items[] = { {seqModifierType_ColorBalance, "COLOR_BALANCE", ICON_NONE, "Color Balance", ""}, {seqModifierType_Curves, "CURVES", ICON_NONE, "Curves", ""}, {seqModifierType_HueCorrect, "HUE_CORRECT", ICON_NONE, "Hue Correct", ""}, + {seqModifierType_BrightContrast, "BRIGHT_CONTRAST", ICON_NONE, "Bright/Contrast", ""}, {0, NULL, 0, NULL, NULL} }; @@ -918,6 +919,8 @@ static StructRNA *rna_SequenceModifier_refine(struct PointerRNA *ptr) return &RNA_CurvesModifier; case seqModifierType_HueCorrect: return &RNA_HueCorrectModifier; + case seqModifierType_BrightContrast: + return &RNA_BrightContrastModifier; default: return &RNA_SequenceModifier; } @@ -2340,12 +2343,34 @@ static void rna_def_hue_modifier(BlenderRNA *brna) RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_SequenceModifier_update"); } +static void rna_def_brightcontrast_modifier(BlenderRNA *brna) +{ + StructRNA *srna; + PropertyRNA *prop; + + srna = RNA_def_struct(brna, "BrightContrastModifier", "SequenceModifier"); + RNA_def_struct_sdna(srna, "BrightContrastModifierData"); + RNA_def_struct_ui_text(srna, "BrightContrastModifier", "Bright/contrast modifier data for sequence strip"); + + prop = RNA_def_property(srna, "bright", PROP_FLOAT, PROP_UNSIGNED); + RNA_def_property_float_sdna(prop, NULL, "bright"); + RNA_def_property_ui_text(prop, "Bright", ""); + RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_SequenceModifier_update"); + + prop = RNA_def_property(srna, "contrast", PROP_FLOAT, PROP_UNSIGNED); + RNA_def_property_float_sdna(prop, NULL, "contrast"); + RNA_def_property_ui_text(prop, "Contrast", ""); + RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_SequenceModifier_update"); +} + static void rna_def_modifiers(BlenderRNA *brna) { rna_def_modifier(brna); + rna_def_colorbalance_modifier(brna); rna_def_curves_modifier(brna); rna_def_hue_modifier(brna); + rna_def_brightcontrast_modifier(brna); } void RNA_def_sequencer(BlenderRNA *brna) From 7a66f139b4283dd4cf3ad0936d825cb905bfc676 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Fri, 24 Aug 2012 09:44:46 +0000 Subject: [PATCH 109/163] Sequencer: allow negative bright/contrast --- source/blender/makesrna/intern/rna_sequencer.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/source/blender/makesrna/intern/rna_sequencer.c b/source/blender/makesrna/intern/rna_sequencer.c index 932c578899d..a3884b62ec1 100644 --- a/source/blender/makesrna/intern/rna_sequencer.c +++ b/source/blender/makesrna/intern/rna_sequencer.c @@ -2354,11 +2354,13 @@ static void rna_def_brightcontrast_modifier(BlenderRNA *brna) prop = RNA_def_property(srna, "bright", PROP_FLOAT, PROP_UNSIGNED); RNA_def_property_float_sdna(prop, NULL, "bright"); + RNA_def_property_range(prop, -FLT_MAX, FLT_MAX); RNA_def_property_ui_text(prop, "Bright", ""); RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_SequenceModifier_update"); prop = RNA_def_property(srna, "contrast", PROP_FLOAT, PROP_UNSIGNED); RNA_def_property_float_sdna(prop, NULL, "contrast"); + RNA_def_property_range(prop, -FLT_MAX, FLT_MAX); RNA_def_property_ui_text(prop, "Contrast", ""); RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_SequenceModifier_update"); } From 61a39c7b1756cebb4a13949b5a880aa9d0d4ee3e Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Fri, 24 Aug 2012 12:10:35 +0000 Subject: [PATCH 110/163] Fix second part #32377: saving/loading exr files to file paths with non-ascii characters should now work on Windows. --- .../imbuf/intern/openexr/CMakeLists.txt | 1 + .../blender/imbuf/intern/openexr/SConscript | 4 +- .../imbuf/intern/openexr/openexr_api.cpp | 135 +++++++++++++++--- 3 files changed, 122 insertions(+), 18 deletions(-) diff --git a/source/blender/imbuf/intern/openexr/CMakeLists.txt b/source/blender/imbuf/intern/openexr/CMakeLists.txt index 4ee2ff4cc47..a5afc1abdc6 100644 --- a/source/blender/imbuf/intern/openexr/CMakeLists.txt +++ b/source/blender/imbuf/intern/openexr/CMakeLists.txt @@ -31,6 +31,7 @@ set(INC ../../../blenlib ../../../makesdna ../../../../../intern/guardedalloc + ../../../../../intern/utfconv ) set(INC_SYS diff --git a/source/blender/imbuf/intern/openexr/SConscript b/source/blender/imbuf/intern/openexr/SConscript index e590077db2b..a6c5ad984e2 100644 --- a/source/blender/imbuf/intern/openexr/SConscript +++ b/source/blender/imbuf/intern/openexr/SConscript @@ -10,7 +10,9 @@ incs = ['.', '../../../blenlib', 'intern/include', '#/intern/guardedalloc', - '../../../makesdna'] + '../../../makesdna', + '#/intern/utfconv'] + incs += Split(env['BF_OPENEXR_INC']) defs = ['WITH_OPENEXR'] diff --git a/source/blender/imbuf/intern/openexr/openexr_api.cpp b/source/blender/imbuf/intern/openexr/openexr_api.cpp index 91876249bf6..1b99a3040a8 100644 --- a/source/blender/imbuf/intern/openexr/openexr_api.cpp +++ b/source/blender/imbuf/intern/openexr/openexr_api.cpp @@ -32,12 +32,17 @@ #include #include #include +#include #include #include #include +#if defined (WIN32) && !defined(FREE_WINDOWS) +#include "utfconv.h" +#endif + extern "C" { @@ -76,6 +81,7 @@ _CRTIMP void __cdecl _invalid_parameter_noinfo(void) #include #include #include +#include #include #else #include @@ -90,6 +96,7 @@ _CRTIMP void __cdecl _invalid_parameter_noinfo(void) #include #include #include +#include #endif using namespace Imf; @@ -192,6 +199,28 @@ static void openexr_header_metadata(Header *header, struct ImBuf *ibuf) header->insert(info->key, StringAttribute(info->value)); } +static void openexr_ofstream_open(std::ofstream& ofs, const char *name) +{ +#if defined (WIN32) && !defined(FREE_WINDOWS) + wchar_t *wname = alloc_utf16_from_8(name, 0); + ofs.open(wname, std::ios_base::binary); + free(wname); +#else + ofs.open(name, std::ios_base::binary); +#endif +} + +static void openexr_ifstream_open(std::ifstream& ifs, const char *name) +{ +#if defined (WIN32) && !defined(FREE_WINDOWS) + wchar_t *wname = alloc_utf16_from_8(name, 0); + ifs.open(wname, std::ios_base::binary); + free(wname); +#else + ifs.open(name, std::ios_base::binary); +#endif +} + static int imb_save_openexr_half(struct ImBuf *ibuf, const char *name, int flags) { const int channels = ibuf->channels; @@ -216,7 +245,13 @@ static int imb_save_openexr_half(struct ImBuf *ibuf, const char *name, int flags header.channels().insert("Z", Channel(Imf::FLOAT)); FrameBuffer frameBuffer; - OutputFile *file = new OutputFile(name, header); + + /* manually create ofstream, so we can handle utf-8 filepaths on windows */ + std::ofstream std_ostream; + openexr_ofstream_open(std_ostream, name); + StdOFStream exr_ostream(std_ostream, name); + + OutputFile file(exr_ostream, header); /* we store first everything in half array */ RGBAZ *pixels = new RGBAZ[height * width]; @@ -281,9 +316,9 @@ static int imb_save_openexr_half(struct ImBuf *ibuf, const char *name, int flags // printf("OpenEXR-save: Writing OpenEXR file of height %d.\n", height); - file->setFrameBuffer(frameBuffer); - file->writePixels(height); - delete file; + file.setFrameBuffer(frameBuffer); + file.writePixels(height); + delete[] pixels; } catch (const std::exception &exc) @@ -321,7 +356,14 @@ static int imb_save_openexr_float(struct ImBuf *ibuf, const char *name, int flag header.channels().insert("Z", Channel(Imf::FLOAT)); FrameBuffer frameBuffer; - OutputFile *file = new OutputFile(name, header); + + /* manually create ofstream, so we can handle utf-8 filepaths on windows */ + std::ofstream std_ostream; + openexr_ofstream_open(std_ostream, name); + StdOFStream exr_ostream(std_ostream, name); + + OutputFile file(exr_ostream, header); + int xstride = sizeof(float) * channels; int ystride = -xstride * width; float *rect[4] = {NULL, NULL, NULL, NULL}; @@ -340,9 +382,8 @@ static int imb_save_openexr_float(struct ImBuf *ibuf, const char *name, int flag if (is_zbuf) frameBuffer.insert("Z", Slice(Imf::FLOAT, (char *) (ibuf->zbuf_float + (height - 1) * width), sizeof(float), sizeof(float) * -width)); - file->setFrameBuffer(frameBuffer); - file->writePixels(height); - delete file; + file.setFrameBuffer(frameBuffer); + file.writePixels(height); } catch (const std::exception &exc) { @@ -391,9 +432,15 @@ static ListBase exrhandles = {NULL, NULL}; typedef struct ExrHandle { struct ExrHandle *next, *prev; + std::ifstream *std_istream; + StdIFStream *exr_istream; InputFile *ifile; + + std::ofstream *std_ostream; + StdOFStream *exr_ostream; TiledOutputFile *tofile; OutputFile *ofile; + int tilex, tiley; int width, height; int mipmap; @@ -486,12 +533,24 @@ int IMB_exr_begin_write(void *handle, const char *filename, int width, int heigh header.insert("BlenderMultiChannel", StringAttribute("Blender V2.55.1 and newer")); /* avoid crash/abort when we don't have permission to write here */ + /* manually create ofstream, so we can handle utf-8 filepaths on windows */ try { - data->ofile = new OutputFile(filename, header); + data->std_ostream = new std::ofstream(); + openexr_ofstream_open(*(data->std_ostream), filename); + + data->exr_ostream = new StdOFStream(*(data->std_ostream), filename); + data->ofile = new OutputFile(*(data->exr_ostream), header); } catch (const std::exception &exc) { std::cerr << "IMB_exr_begin_write: ERROR: " << exc.what() << std::endl; + + delete data->ofile; + delete data->exr_ostream; + delete data->std_ostream; + data->ofile = NULL; + data->exr_ostream = NULL; + data->std_ostream = NULL; } return (data->ofile != NULL); @@ -518,7 +577,24 @@ void IMB_exrtile_begin_write(void *handle, const char *filename, int mipmap, int header.insert("BlenderMultiChannel", StringAttribute("Blender V2.43")); - data->tofile = new TiledOutputFile(filename, header); + /* avoid crash/abort when we don't have permission to write here */ + /* manually create ofstream, so we can handle utf-8 filepaths on windows */ + try { + data->std_ostream = new std::ofstream(); + openexr_ofstream_open(*(data->std_ostream), filename); + + data->exr_ostream = new StdOFStream(*(data->std_ostream), filename); + data->tofile = new TiledOutputFile(*(data->exr_ostream), header); + } + catch (const std::exception &exc) { + delete data->tofile; + delete data->exr_ostream; + delete data->std_ostream; + + data->tofile = NULL; + data->exr_ostream = NULL; + data->std_ostream = NULL; + } } /* read from file */ @@ -527,7 +603,25 @@ int IMB_exr_begin_read(void *handle, const char *filename, int *width, int *heig ExrHandle *data = (ExrHandle *)handle; if (BLI_exists(filename) && BLI_file_size(filename) > 32) { /* 32 is arbitrary, but zero length files crashes exr */ - data->ifile = new InputFile(filename); + /* avoid crash/abort when we don't have permission to write here */ + /* manually create ofstream, so we can handle utf-8 filepaths on windows */ + try { + data->std_istream = new std::ifstream(); + openexr_ifstream_open(*(data->std_istream), filename); + + data->exr_istream = new StdIFStream(*(data->std_istream), filename); + data->ifile = new InputFile(*(data->exr_istream)); + } + catch (const std::exception &exc) { + delete data->ifile; + delete data->exr_istream; + delete data->std_istream; + + data->ifile = NULL; + data->exr_istream = NULL; + data->std_istream = NULL; + } + if (data->ifile) { Box2i dw = data->ifile->header().dataWindow(); data->width = *width = dw.max.x - dw.min.x + 1; @@ -696,16 +790,23 @@ void IMB_exr_close(void *handle) ExrLayer *lay; ExrPass *pass; - if (data->ifile) - delete data->ifile; - else if (data->ofile) - delete data->ofile; - else if (data->tofile) - delete data->tofile; + delete data->ifile; + delete data->exr_istream; + delete data->std_istream; + + delete data->ofile; + delete data->tofile; + delete data->exr_ostream; + delete data->std_ostream; data->ifile = NULL; + data->exr_istream = NULL; + data->std_istream = NULL; + data->ofile = NULL; data->tofile = NULL; + data->exr_ostream = NULL; + data->std_ostream = NULL; BLI_freelistN(&data->channels); From cb21d3f670a2ef9c689e465960f2de44dfccacdd Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Fri, 24 Aug 2012 12:10:38 +0000 Subject: [PATCH 111/163] Code cleanup: remove some unused code. --- source/blender/windowmanager/intern/wm_playanim.c | 6 ------ source/blender/windowmanager/intern/wm_window.c | 6 ------ 2 files changed, 12 deletions(-) diff --git a/source/blender/windowmanager/intern/wm_playanim.c b/source/blender/windowmanager/intern/wm_playanim.c index 9fc3bf9cece..0074d6236db 100644 --- a/source/blender/windowmanager/intern/wm_playanim.c +++ b/source/blender/windowmanager/intern/wm_playanim.c @@ -699,12 +699,6 @@ void playanim_window_open(const char *title, int posx, int posy, int sizex, int inital_state = start_maximized ? GHOST_kWindowStateFullScreen : GHOST_kWindowStateNormal; else inital_state = start_maximized ? GHOST_kWindowStateMaximized : GHOST_kWindowStateNormal; -#if defined(__APPLE__) && !defined(GHOST_COCOA) - { - extern int macPrefState; /* creator.c */ - initial_state += macPrefState; - } -#endif g_WS.ghost_window = GHOST_CreateWindow(g_WS.ghost_system, title, diff --git a/source/blender/windowmanager/intern/wm_window.c b/source/blender/windowmanager/intern/wm_window.c index fe3c2d0e901..b83b93454e6 100644 --- a/source/blender/windowmanager/intern/wm_window.c +++ b/source/blender/windowmanager/intern/wm_window.c @@ -340,12 +340,6 @@ static void wm_window_add_ghostwindow(const char *title, wmWindow *win) wm_get_screensize(&scr_w, &scr_h); posy = (scr_h - win->posy - win->sizey); -#if defined(__APPLE__) && !defined(GHOST_COCOA) - { - extern int macPrefState; /* creator.c */ - initial_state += macPrefState; - } -#endif /* Disable AA for now, as GL_SELECT (used for border, lasso, ... select) * doesn't work well when AA is initialized, even if not used. */ ghostwin = GHOST_CreateWindow(g_system, title, From a7831c74e6bb4fdee43ba65513ed06e631e05bfd Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 24 Aug 2012 12:48:56 +0000 Subject: [PATCH 112/163] fix for bug in variable size blur compositor node - using incorrect Y blur operations and uninitialized memory was causing random blur results. --- source/blender/compositor/nodes/COM_BlurNode.cpp | 6 +++++- .../blender/compositor/operations/COM_BlurBaseOperation.cpp | 5 +++++ .../operations/COM_GaussianAlphaXBlurOperation.cpp | 1 + .../operations/COM_GaussianAlphaYBlurOperation.cpp | 1 + 4 files changed, 12 insertions(+), 1 deletion(-) diff --git a/source/blender/compositor/nodes/COM_BlurNode.cpp b/source/blender/compositor/nodes/COM_BlurNode.cpp index 93ef002c8d7..e39ef2b3f23 100644 --- a/source/blender/compositor/nodes/COM_BlurNode.cpp +++ b/source/blender/compositor/nodes/COM_BlurNode.cpp @@ -74,14 +74,18 @@ void BlurNode::convertToOperations(ExecutionSystem *graph, CompositorContext *co operationx->setbNode(editorNode); operationx->setQuality(quality); operationx->setSize(1.0f); + operationx->setFalloff(PROP_SMOOTH); + operationx->setSubtract(false); addLink(graph, clamp->getOutputSocket(), operationx->getInputSocket(0)); graph->addOperation(operationx); - GaussianYBlurOperation *operationy = new GaussianYBlurOperation(); + GaussianAlphaYBlurOperation *operationy = new GaussianAlphaYBlurOperation(); operationy->setData(data); operationy->setbNode(editorNode); operationy->setQuality(quality); operationy->setSize(1.0f); + operationy->setFalloff(PROP_SMOOTH); + operationy->setSubtract(false); addLink(graph, operationx->getOutputSocket(), operationy->getInputSocket(0)); graph->addOperation(operationy); diff --git a/source/blender/compositor/operations/COM_BlurBaseOperation.cpp b/source/blender/compositor/operations/COM_BlurBaseOperation.cpp index c527807f839..39a0014ac41 100644 --- a/source/blender/compositor/operations/COM_BlurBaseOperation.cpp +++ b/source/blender/compositor/operations/COM_BlurBaseOperation.cpp @@ -121,6 +121,11 @@ float *BlurBaseOperation::make_dist_fac_inverse(int rad, int falloff) val = val * val; break; case PROP_LIN: +#ifndef NDEBUG + /* uninitialized! */ + case -1: + BLI_assert(0); +#endif default: /* nothing */ break; diff --git a/source/blender/compositor/operations/COM_GaussianAlphaXBlurOperation.cpp b/source/blender/compositor/operations/COM_GaussianAlphaXBlurOperation.cpp index 82f38556e82..8c5e5faf12a 100644 --- a/source/blender/compositor/operations/COM_GaussianAlphaXBlurOperation.cpp +++ b/source/blender/compositor/operations/COM_GaussianAlphaXBlurOperation.cpp @@ -33,6 +33,7 @@ GaussianAlphaXBlurOperation::GaussianAlphaXBlurOperation() : BlurBaseOperation(C { this->m_gausstab = NULL; this->m_rad = 0; + this->m_falloff = -1; /* intentionally invalid, so we can detect uninitialized values */ } void *GaussianAlphaXBlurOperation::initializeTileData(rcti *rect) diff --git a/source/blender/compositor/operations/COM_GaussianAlphaYBlurOperation.cpp b/source/blender/compositor/operations/COM_GaussianAlphaYBlurOperation.cpp index bfd9564817e..197715595ed 100644 --- a/source/blender/compositor/operations/COM_GaussianAlphaYBlurOperation.cpp +++ b/source/blender/compositor/operations/COM_GaussianAlphaYBlurOperation.cpp @@ -33,6 +33,7 @@ GaussianAlphaYBlurOperation::GaussianAlphaYBlurOperation() : BlurBaseOperation(C { this->m_gausstab = NULL; this->m_rad = 0; + this->m_falloff = -1; /* intentionally invalid, so we can detect uninitialized values */ } void *GaussianAlphaYBlurOperation::initializeTileData(rcti *rect) From aba2754a1968fdbdcf69556c3cc1cedba6d76fda Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 24 Aug 2012 13:22:05 +0000 Subject: [PATCH 113/163] stop socket hiding from causing compositor recalculation. --- source/blender/makesrna/intern/rna_nodetree.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/blender/makesrna/intern/rna_nodetree.c b/source/blender/makesrna/intern/rna_nodetree.c index a608a84bd89..2013fd7318e 100644 --- a/source/blender/makesrna/intern/rna_nodetree.c +++ b/source/blender/makesrna/intern/rna_nodetree.c @@ -4141,7 +4141,7 @@ static void rna_def_node_socket(BlenderRNA *brna) RNA_def_property_boolean_sdna(prop, NULL, "flag", SOCK_HIDDEN); RNA_def_property_boolean_funcs(prop, NULL, "rna_NodeSocket_hide_set"); RNA_def_property_ui_text(prop, "Hide", "Hide the socket"); - RNA_def_property_update(prop, NC_NODE | NA_EDITED, NULL); + RNA_def_property_update(prop, NC_NODE | ND_DISPLAY, NULL); prop = RNA_def_property(srna, "is_linked", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", SOCK_IN_USE); From b30da4d58f4f5b24f902d8f2fa7d04e4406536ac Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Fri, 24 Aug 2012 13:29:48 +0000 Subject: [PATCH 114/163] Fix #32198: UV unwrap of half a UV sphere would not give a perfect sphere as a result. This wasn't really guaranteed anyway, because of numerical precision and possible asymmetry in the triangulation, but we can do a bit better. Now we bias the choice of how to split a quad into two triangles slightly towards one of two possibilities, so that in case they are equal, floating point errors do not decide the direction and symmetry is preserved. --- source/blender/editors/uvedit/uvedit_parametrizer.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/source/blender/editors/uvedit/uvedit_parametrizer.c b/source/blender/editors/uvedit/uvedit_parametrizer.c index 2161d4989db..72c38be5398 100644 --- a/source/blender/editors/uvedit/uvedit_parametrizer.c +++ b/source/blender/editors/uvedit/uvedit_parametrizer.c @@ -1135,7 +1135,11 @@ static PFace *p_face_add_fill(PChart *chart, PVert *v1, PVert *v2, PVert *v3) static PBool p_quad_split_direction(PHandle *handle, float **co, PHashKey *vkeys) { - float fac = len_v3v3(co[0], co[2]) - len_v3v3(co[1], co[3]); + /* slight bias to prefer one edge over the other in case they are equal, so + * that in symmetric models we choose the same split direction instead of + * depending on floating point errors to decide */ + float bias = 1.0f + 1e-6f; + float fac = len_v3v3(co[0], co[2])*bias - len_v3v3(co[1], co[3]); PBool dir = (fac <= 0.0f); /* the face exists check is there because of a special case: when From 90a0cf41d01c9f1a1510922b5c7d85119d40a5d5 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 24 Aug 2012 14:00:39 +0000 Subject: [PATCH 115/163] use the zoom level to set the size for new mask point handle sizes (artist request - handles were annoyingly bug when zoomed in) --- source/blender/editors/mask/mask_add.c | 33 +++++++++++++++++++++----- 1 file changed, 27 insertions(+), 6 deletions(-) diff --git a/source/blender/editors/mask/mask_add.c b/source/blender/editors/mask/mask_add.c index e9b31b8df1a..d2a5e80fc24 100644 --- a/source/blender/editors/mask/mask_add.c +++ b/source/blender/editors/mask/mask_add.c @@ -182,7 +182,8 @@ static int find_nearest_diff_point(const bContext *C, Mask *mask, const float no static void setup_vertex_point(const bContext *C, Mask *mask, MaskSpline *spline, MaskSplinePoint *new_point, const float point_co[2], const float tangent[2], const float u, - MaskSplinePoint *reference_point, const short reference_adjacent) + MaskSplinePoint *reference_point, const short reference_adjacent, + const float view_zoom) { ScrArea *sa = CTX_wm_area(C); @@ -225,8 +226,8 @@ static void setup_vertex_point(const bContext *C, Mask *mask, MaskSpline *spline /* initial offset for handles */ if (spline->tot_point == 1) { /* first point of splien is aligned horizontally */ - bezt->vec[0][0] -= len / width; - bezt->vec[2][0] += len / width; + bezt->vec[0][0] -= len / maxi(width, height) * view_zoom; + bezt->vec[2][0] += len / maxi(width, height) * view_zoom; } else if (tangent) { float vec[2]; @@ -391,7 +392,7 @@ static int add_vertex_subdivide(const bContext *C, Mask *mask, const float co[2] new_point = &spline->points[point_index + 1]; - setup_vertex_point(C, mask, spline, new_point, co, tangent, u, NULL, TRUE); + setup_vertex_point(C, mask, spline, new_point, co, tangent, u, NULL, TRUE, 1.0f); /* TODO - we could pass the spline! */ BKE_mask_layer_shape_changed_add(masklay, BKE_mask_layer_shape_spline_to_index(masklay, spline) + point_index + 1, TRUE, TRUE); @@ -490,7 +491,7 @@ static int add_vertex_extrude(const bContext *C, Mask *mask, MaskLayer *masklay, masklay->act_point = new_point; - setup_vertex_point(C, mask, spline, new_point, co, NULL, 0.5f, ref_point, FALSE); + setup_vertex_point(C, mask, spline, new_point, co, NULL, 0.5f, ref_point, FALSE, 1.0f); if (masklay->splines_shapes.first) { point_index = (((int)(new_point - spline->points) + 0) % spline->tot_point); @@ -512,6 +513,7 @@ static int add_vertex_new(const bContext *C, Mask *mask, MaskLayer *masklay, con MaskSpline *spline; MaskSplinePoint *point; MaskSplinePoint *new_point = NULL, *ref_point = NULL; + float view_zoom; if (!masklay) { /* if there's no masklay currently operationg on, create new one */ @@ -536,7 +538,26 @@ static int add_vertex_new(const bContext *C, Mask *mask, MaskLayer *masklay, con masklay->act_point = new_point; - setup_vertex_point(C, mask, spline, new_point, co, NULL, 0.5f, ref_point, FALSE); + { + ScrArea *sa = CTX_wm_area(C); + ARegion *ar = CTX_wm_region(C); + + /* calc view zoom in a simplistic way */ + float co_a[2]; + float co_b[2]; + int mval_a[2] = {0, 0}; + int mval_b[2] = {1, 1}; + + ED_mask_mouse_pos(sa, ar, mval_a, co_a); + ED_mask_mouse_pos(sa, ar, mval_b, co_b); + + view_zoom = ((co_b[0] - co_a[0]) + (co_b[1] - co_a[1])) / 2.0f; + + /* scale up - arbitrarty but works well in the view */ + view_zoom *= 200.0f; + } + + setup_vertex_point(C, mask, spline, new_point, co, NULL, 0.5f, ref_point, FALSE, view_zoom); { int point_index = (((int)(new_point - spline->points) + 0) % spline->tot_point); From 1a2d0d84dab40176ca8a390a2986f3f3fed01d78 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Fri, 24 Aug 2012 14:04:21 +0000 Subject: [PATCH 116/163] Fix for build error on some platforms, seems ImfStdIO.h is not included with the other headers everywhere. --- .../imbuf/intern/openexr/openexr_api.cpp | 220 ++++++++++++------ 1 file changed, 143 insertions(+), 77 deletions(-) diff --git a/source/blender/imbuf/intern/openexr/openexr_api.cpp b/source/blender/imbuf/intern/openexr/openexr_api.cpp index 1b99a3040a8..34afdda0177 100644 --- a/source/blender/imbuf/intern/openexr/openexr_api.cpp +++ b/source/blender/imbuf/intern/openexr/openexr_api.cpp @@ -35,7 +35,7 @@ #include #include #include - +#include #include @@ -71,6 +71,7 @@ _CRTIMP void __cdecl _invalid_parameter_noinfo(void) #if defined(_WIN32) && !defined(FREE_WINDOWS) #include +#include #include #include #include @@ -81,10 +82,10 @@ _CRTIMP void __cdecl _invalid_parameter_noinfo(void) #include #include #include -#include #include #else #include +#include #include #include #include @@ -96,12 +97,13 @@ _CRTIMP void __cdecl _invalid_parameter_noinfo(void) #include #include #include -#include #endif using namespace Imf; using namespace Imath; +/* Memory Input Stream */ + class Mem_IStream : public Imf::IStream { public: @@ -149,6 +151,122 @@ void Mem_IStream::clear() { } +/* File Input Stream */ + +class IFileStream : public IStream +{ +public: + IFileStream(const char *filename) + : IStream(filename) + { + /* utf-8 file path support on windows */ +#if defined (WIN32) && !defined(FREE_WINDOWS) + wchar_t *wfilename = alloc_utf16_from_8(filename, 0); + ifs.open(wfilename, std::ios_base::binary); + free(wfilename); +#else + ifs.open(filename, std::ios_base::binary); +#endif + + if (!ifs) + Iex::throwErrnoExc(); + } + + virtual bool read(char c[], int n) + { + if (!ifs) + throw Iex::InputExc("Unexpected end of file."); + + errno = 0; + ifs.read(c, n); + return check_error(); + } + + virtual Int64 tellg() + { + return std::streamoff(ifs.tellg()); + } + + virtual void seekg(Int64 pos) + { + ifs.seekg(pos); + check_error(); + } + + virtual void clear() + { + ifs.clear(); + } + +private: + bool check_error() + { + if (!ifs) { + if (errno) + Iex::throwErrnoExc(); + + return false; + } + + return true; + } + + std::ifstream ifs; +}; + +/* File Output Stream */ + +class OFileStream : public OStream +{ +public: + OFileStream(const char *filename) + : OStream(filename) + { + /* utf-8 file path support on windows */ +#if defined (WIN32) && !defined(FREE_WINDOWS) + wchar_t *wfilename = alloc_utf16_from_8(filename, 0); + ofs.open(wfilename, std::ios_base::binary); + free(wfilename); +#else + ofs.open(filename, std::ios_base::binary); +#endif + + if (!ofs) + Iex::throwErrnoExc(); + } + + virtual void write(const char c[], int n) + { + errno = 0; + ofs.write(c, n); + check_error(); + } + + virtual Int64 tellp() + { + return std::streamoff(ofs.tellp()); + } + + virtual void seekp(Int64 pos) + { + ofs.seekp(pos); + check_error(); + } + +private: + void check_error() + { + if (!ofs) { + if (errno) + Iex::throwErrnoExc(); + + throw Iex::ErrnoExc("File output failed."); + } + } + + std::ofstream ofs; +}; + struct _RGBAZ { half r; half g; @@ -199,28 +317,6 @@ static void openexr_header_metadata(Header *header, struct ImBuf *ibuf) header->insert(info->key, StringAttribute(info->value)); } -static void openexr_ofstream_open(std::ofstream& ofs, const char *name) -{ -#if defined (WIN32) && !defined(FREE_WINDOWS) - wchar_t *wname = alloc_utf16_from_8(name, 0); - ofs.open(wname, std::ios_base::binary); - free(wname); -#else - ofs.open(name, std::ios_base::binary); -#endif -} - -static void openexr_ifstream_open(std::ifstream& ifs, const char *name) -{ -#if defined (WIN32) && !defined(FREE_WINDOWS) - wchar_t *wname = alloc_utf16_from_8(name, 0); - ifs.open(wname, std::ios_base::binary); - free(wname); -#else - ifs.open(name, std::ios_base::binary); -#endif -} - static int imb_save_openexr_half(struct ImBuf *ibuf, const char *name, int flags) { const int channels = ibuf->channels; @@ -247,11 +343,8 @@ static int imb_save_openexr_half(struct ImBuf *ibuf, const char *name, int flags FrameBuffer frameBuffer; /* manually create ofstream, so we can handle utf-8 filepaths on windows */ - std::ofstream std_ostream; - openexr_ofstream_open(std_ostream, name); - StdOFStream exr_ostream(std_ostream, name); - - OutputFile file(exr_ostream, header); + OFileStream file_stream(name); + OutputFile file(file_stream, header); /* we store first everything in half array */ RGBAZ *pixels = new RGBAZ[height * width]; @@ -358,11 +451,8 @@ static int imb_save_openexr_float(struct ImBuf *ibuf, const char *name, int flag FrameBuffer frameBuffer; /* manually create ofstream, so we can handle utf-8 filepaths on windows */ - std::ofstream std_ostream; - openexr_ofstream_open(std_ostream, name); - StdOFStream exr_ostream(std_ostream, name); - - OutputFile file(exr_ostream, header); + OFileStream file_stream(name); + OutputFile file(file_stream, header); int xstride = sizeof(float) * channels; int ystride = -xstride * width; @@ -432,12 +522,10 @@ static ListBase exrhandles = {NULL, NULL}; typedef struct ExrHandle { struct ExrHandle *next, *prev; - std::ifstream *std_istream; - StdIFStream *exr_istream; + IFileStream *ifile_stream; InputFile *ifile; - std::ofstream *std_ostream; - StdOFStream *exr_ostream; + OFileStream *ofile_stream; TiledOutputFile *tofile; OutputFile *ofile; @@ -535,22 +623,17 @@ int IMB_exr_begin_write(void *handle, const char *filename, int width, int heigh /* avoid crash/abort when we don't have permission to write here */ /* manually create ofstream, so we can handle utf-8 filepaths on windows */ try { - data->std_ostream = new std::ofstream(); - openexr_ofstream_open(*(data->std_ostream), filename); - - data->exr_ostream = new StdOFStream(*(data->std_ostream), filename); - data->ofile = new OutputFile(*(data->exr_ostream), header); + data->ofile_stream = new OFileStream(filename); + data->ofile = new OutputFile(*(data->ofile_stream), header); } catch (const std::exception &exc) { std::cerr << "IMB_exr_begin_write: ERROR: " << exc.what() << std::endl; delete data->ofile; - delete data->exr_ostream; - delete data->std_ostream; + delete data->ofile_stream; data->ofile = NULL; - data->exr_ostream = NULL; - data->std_ostream = NULL; + data->ofile_stream = NULL; } return (data->ofile != NULL); @@ -580,20 +663,15 @@ void IMB_exrtile_begin_write(void *handle, const char *filename, int mipmap, int /* avoid crash/abort when we don't have permission to write here */ /* manually create ofstream, so we can handle utf-8 filepaths on windows */ try { - data->std_ostream = new std::ofstream(); - openexr_ofstream_open(*(data->std_ostream), filename); - - data->exr_ostream = new StdOFStream(*(data->std_ostream), filename); - data->tofile = new TiledOutputFile(*(data->exr_ostream), header); + data->ofile_stream = new OFileStream(filename); + data->tofile = new TiledOutputFile(*(data->ofile_stream), header); } catch (const std::exception &exc) { delete data->tofile; - delete data->exr_ostream; - delete data->std_ostream; + delete data->ofile_stream; data->tofile = NULL; - data->exr_ostream = NULL; - data->std_ostream = NULL; + data->ofile_stream = NULL; } } @@ -604,22 +682,16 @@ int IMB_exr_begin_read(void *handle, const char *filename, int *width, int *heig if (BLI_exists(filename) && BLI_file_size(filename) > 32) { /* 32 is arbitrary, but zero length files crashes exr */ /* avoid crash/abort when we don't have permission to write here */ - /* manually create ofstream, so we can handle utf-8 filepaths on windows */ try { - data->std_istream = new std::ifstream(); - openexr_ifstream_open(*(data->std_istream), filename); - - data->exr_istream = new StdIFStream(*(data->std_istream), filename); - data->ifile = new InputFile(*(data->exr_istream)); + data->ifile_stream = new IFileStream(filename); + data->ifile = new InputFile(*(data->ifile_stream)); } catch (const std::exception &exc) { delete data->ifile; - delete data->exr_istream; - delete data->std_istream; + delete data->ifile_stream; data->ifile = NULL; - data->exr_istream = NULL; - data->std_istream = NULL; + data->ifile_stream = NULL; } if (data->ifile) { @@ -791,22 +863,16 @@ void IMB_exr_close(void *handle) ExrPass *pass; delete data->ifile; - delete data->exr_istream; - delete data->std_istream; - + delete data->ifile_stream; delete data->ofile; delete data->tofile; - delete data->exr_ostream; - delete data->std_ostream; + delete data->ofile_stream; data->ifile = NULL; - data->exr_istream = NULL; - data->std_istream = NULL; - + data->ifile_stream = NULL; data->ofile = NULL; data->tofile = NULL; - data->exr_ostream = NULL; - data->std_ostream = NULL; + data->ofile_stream = NULL; BLI_freelistN(&data->channels); From b5e90d6b1c8dd65adaaae62f3facc8f532e06f40 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 24 Aug 2012 14:54:14 +0000 Subject: [PATCH 117/163] fix [#32357] Subdivide fails on newly created edge problem since bmesh merge, new edges were not selected. --- source/blender/bmesh/intern/bmesh_opdefines.c | 2 ++ source/blender/bmesh/operators/bmo_create.c | 2 ++ source/blender/editors/mesh/editmesh_tools.c | 1 + 3 files changed, 5 insertions(+) diff --git a/source/blender/bmesh/intern/bmesh_opdefines.c b/source/blender/bmesh/intern/bmesh_opdefines.c index 986c84b0639..48d8583ee7c 100644 --- a/source/blender/bmesh/intern/bmesh_opdefines.c +++ b/source/blender/bmesh/intern/bmesh_opdefines.c @@ -408,6 +408,8 @@ static BMOpDefine bmo_contextual_create_def = { "contextual_create", {{BMO_OP_SLOT_ELEMENT_BUF, "geom"}, //input geometry. {BMO_OP_SLOT_ELEMENT_BUF, "faceout"}, /* newly-made face(s) */ + /* note, this is for stand-alone edges only, not edges which are apart of newly created faces */ + {BMO_OP_SLOT_ELEMENT_BUF, "edgeout"}, /* newly-made edge(s) */ {BMO_OP_SLOT_INT, "mat_nr"}, /* material to use */ {BMO_OP_SLOT_BOOL, "use_smooth"}, /* material to use */ {0, /* null-terminating sentinel */}}, diff --git a/source/blender/bmesh/operators/bmo_create.c b/source/blender/bmesh/operators/bmo_create.c index db09c5f3d27..4723b631c5f 100644 --- a/source/blender/bmesh/operators/bmo_create.c +++ b/source/blender/bmesh/operators/bmo_create.c @@ -1415,6 +1415,7 @@ void bmo_contextual_create_exec(BMesh *bm, BMOperator *op) /* create edge */ e = BM_edge_create(bm, verts[0], verts[1], NULL, TRUE); BMO_elem_flag_enable(bm, e, ELE_OUT); + BMO_slot_buffer_from_enabled_flag(bm, op, "edgeout", BM_EDGE, ELE_OUT); } else if (0) { /* nice feature but perhaps it should be a different tool? */ @@ -1460,6 +1461,7 @@ void bmo_contextual_create_exec(BMesh *bm, BMOperator *op) } } } + BMO_slot_buffer_from_enabled_flag(bm, op, "edgeout", BM_EDGE, ELE_OUT); /* done creating edges */ } else if (amount > 2) { diff --git a/source/blender/editors/mesh/editmesh_tools.c b/source/blender/editors/mesh/editmesh_tools.c index 07b53b1cf7f..843a36cda35 100644 --- a/source/blender/editors/mesh/editmesh_tools.c +++ b/source/blender/editors/mesh/editmesh_tools.c @@ -1056,6 +1056,7 @@ static int edbm_add_edge_face_exec(bContext *C, wmOperator *op) BMO_op_exec(em->bm, &bmop); BMO_slot_buffer_hflag_enable(em->bm, &bmop, "faceout", BM_FACE, BM_ELEM_SELECT, TRUE); + BMO_slot_buffer_hflag_enable(em->bm, &bmop, "edgeout", BM_EDGE, BM_ELEM_SELECT, TRUE); if (!EDBM_op_finish(em, &bmop, op, TRUE)) { return OPERATOR_CANCELLED; From 2536362f7955be7e86c9ed660a7b240060b1984d Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Fri, 24 Aug 2012 16:09:48 +0000 Subject: [PATCH 118/163] Sequencer: reshuffle overlapping strips on cancel trasnform It was possible to create overlapped strips by duplicating and cancelling transform, now it sohuld be handled properly. --- source/blender/editors/transform/transform_conversions.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/source/blender/editors/transform/transform_conversions.c b/source/blender/editors/transform/transform_conversions.c index 120394aa7c1..8eba8ebea41 100644 --- a/source/blender/editors/transform/transform_conversions.c +++ b/source/blender/editors/transform/transform_conversions.c @@ -4209,7 +4209,7 @@ static void freeSeqData(TransInfo *t) for (a = 0; a < t->total; a++, td++) { if ((seq != seq_prev) && (seq->depth == 0) && (seq->flag & SEQ_OVERLAP)) { seq = ((TransDataSeq *)td->extra)->seq; - shuffle_seq(seqbasep, seq); + BKE_sequence_base_shuffle(seqbasep, seq, t->scene); } seq_prev = seq; @@ -4244,7 +4244,7 @@ static void freeSeqData(TransInfo *t) has_effect = TRUE; } else { - /* Tag seq with a non zero value, used by shuffle_seq_time to identify the ones to shuffle */ + /* Tag seq with a non zero value, used by BKE_sequence_base_shuffle_time to identify the ones to shuffle */ seq->tmp = (void *)1; } } @@ -4289,7 +4289,7 @@ static void freeSeqData(TransInfo *t) BKE_sequence_base_shuffle_time(seqbasep, t->scene); } #else - shuffle_seq_time(seqbasep, t->scene); + BKE_sequence_base_shuffle_time(seqbasep, t->scene); #endif if (has_effect) { @@ -4340,6 +4340,9 @@ static void freeSeqData(TransInfo *t) for (a = 0; a < t->total; a++, td++) { seq = ((TransDataSeq *)td->extra)->seq; if ((seq != seq_prev) && (seq->depth == 0)) { + if (seq->flag & SEQ_OVERLAP) + BKE_sequence_base_shuffle(seqbasep, seq, t->scene); + BKE_sequence_calc_disp(t->scene, seq); } seq_prev = seq; From d3a566457b8272a1a34be59569856305c9777c65 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 24 Aug 2012 16:55:25 +0000 Subject: [PATCH 119/163] fix for merged bridge crashing on closed loops (own bug in recent commit) --- source/blender/bmesh/operators/bmo_connect.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/source/blender/bmesh/operators/bmo_connect.c b/source/blender/bmesh/operators/bmo_connect.c index c9a0d74de38..5b317aebbf0 100644 --- a/source/blender/bmesh/operators/bmo_connect.c +++ b/source/blender/bmesh/operators/bmo_connect.c @@ -429,8 +429,7 @@ void bmo_bridge_loops_exec(BMesh *bm, BMOperator *op) /* merge loops of bridge faces */ if (use_merge) { - /* at the moment these will be the same */ - const int vert_len = mini(BLI_array_count(vv1), BLI_array_count(vv2)); + const int vert_len = mini(BLI_array_count(vv1), BLI_array_count(vv2)) - ((cl1 || cl2) ? 1 : 0); const int edge_len = mini(BLI_array_count(ee1), BLI_array_count(ee2)); if (merge_factor <= 0.0f) { From c3bc1da93cc009f699dab95c066767170e9e595c Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 24 Aug 2012 17:01:35 +0000 Subject: [PATCH 120/163] alternate fix for bug [#32395], now customdata is interpolated into a temp variable and applied at the end of each layer interpolation function. So this now works for CDDM customdata interpolation and avoids duplicating the customdata when the source and destination overlap. --- source/blender/blenkernel/intern/customdata.c | 116 ++++++++---------- 1 file changed, 50 insertions(+), 66 deletions(-) diff --git a/source/blender/blenkernel/intern/customdata.c b/source/blender/blenkernel/intern/customdata.c index 36c571a53ce..a00bea38e51 100644 --- a/source/blender/blenkernel/intern/customdata.c +++ b/source/blender/blenkernel/intern/customdata.c @@ -72,25 +72,29 @@ typedef struct LayerTypeInfo { const char *structname; /* name of the struct used, for file writing */ int structnum; /* number of structs per element, for file writing */ - /* default layer name. + /** + * default layer name. * note! when NULL this is a way to ensure there is only ever one item * see: CustomData_layertype_is_singleton() */ const char *defaultname; - /* a function to copy count elements of this layer's data + /** + * a function to copy count elements of this layer's data * (deep copy if appropriate) * if NULL, memcpy is used */ void (*copy)(const void *source, void *dest, int count); - /* a function to free any dynamically allocated components of this + /** + * a function to free any dynamically allocated components of this * layer's data (note the data pointer itself should not be freed) * size should be the size of one element of this layer's data (e.g. * LayerTypeInfo.size) */ void (*free)(void *data, int count, int size); - /* a function to interpolate between count source elements of this + /** + * a function to interpolate between count source elements of this * layer's data and store the result in dest * if weights == NULL or sub_weights == NULL, they should default to 1 * @@ -98,18 +102,24 @@ typedef struct LayerTypeInfo { * sub_weights gives the sub-element weights for each element in sources * (there should be (sub element count)^2 weights per element) * count gives the number of elements in sources + * + * \note in some cases \a dest pointer is in \a sources + * so all functions have to take this into account and delay + * applying changes while reading from sources. + * See bug [#32395] - Campbell. */ void (*interp)(void **sources, const float *weights, const float *sub_weights, int count, void *dest); - /* a function to swap the data in corners of the element */ + /** a function to swap the data in corners of the element */ void (*swap)(void *data, const int *corner_indices); - /* a function to set a layer's data to default values. if NULL, the + /** + * a function to set a layer's data to default values. if NULL, the * default is assumed to be all zeros */ void (*set_default)(void *data, int count); - /* functions necessary for geometry collapse*/ + /** functions necessary for geometry collapse */ int (*equal)(void *data1, void *data2); void (*multiply)(void *data, float fac); void (*initminmax)(void *min, void *max); @@ -117,13 +127,13 @@ typedef struct LayerTypeInfo { void (*dominmax)(void *data1, void *min, void *max); void (*copyvalue)(void *source, void *dest); - /* a function to read data from a cdf file */ + /** a function to read data from a cdf file */ int (*read)(CDataFile *cdf, void *data, int count); - /* a function to write data to a cdf file */ + /** a function to write data to a cdf file */ int (*write)(CDataFile *cdf, void *data, int count); - /* a function to determine file size */ + /** a function to determine file size */ size_t (*filesize)(CDataFile *cdf, void *data, int count); } LayerTypeInfo; @@ -243,6 +253,8 @@ static void layerInterp_mdeformvert(void **sources, const float *weights, } } + /* delay writing to the destination incase dest is in sources */ + /* now we know how many unique deform weights there are, so realloc */ if (dvert->dw) MEM_freeN(dvert->dw); @@ -276,6 +288,7 @@ static void layerInterp_msticky(void **sources, const float *weights, madd_v2_v2fl(co, mst->co, w); } + /* delay writing to the destination incase dest is in sources */ mst = (MSticky *)dest; copy_v2_v2(mst->co, co); } @@ -318,6 +331,7 @@ static void layerInterp_tface(void **sources, const float *weights, } } + /* delay writing to the destination incase dest is in sources */ *tf = *(MTFace *)(*sources); memcpy(tf->uv, uv, sizeof(tf->uv)); } @@ -419,6 +433,8 @@ static void layerInterp_origspace_face(void **sources, const float *weights, } } + /* delay writing to the destination incase dest is in sources */ + #if 0 /* no need, this ONLY contains UV's */ *osf = *(OrigSpaceFace *)(*sources); #endif @@ -719,7 +735,8 @@ static void layerInterp_mloopcol(void **sources, const float *weights, CLAMP(col.r, 0.0f, 255.0f); CLAMP(col.g, 0.0f, 255.0f); CLAMP(col.b, 0.0f, 255.0f); - + + /* delay writing to the destination incase dest is in sources */ mc->r = (int)col.r; mc->g = (int)col.g; mc->b = (int)col.b; @@ -771,8 +788,7 @@ static void layerAdd_mloopuv(void *data1, void *data2) static void layerInterp_mloopuv(void **sources, const float *weights, const float *sub_weights, int count, void *dest) { - MLoopUV *mluv = dest; - float *uv = mluv->uv; + float uv[2]; int i; zero_v2(uv); @@ -793,6 +809,9 @@ static void layerInterp_mloopuv(void **sources, const float *weights, madd_v2_v2fl(uv, src->uv, weight); } } + + /* delay writing to the destination incase dest is in sources */ + copy_v2_v2(((MLoopUV *)dest)->uv, uv); } /* origspace is almost exact copy of mloopuv's, keep in sync */ @@ -841,8 +860,7 @@ static void layerAdd_mloop_origspace(void *data1, void *data2) static void layerInterp_mloop_origspace(void **sources, const float *weights, const float *sub_weights, int count, void *dest) { - OrigSpaceLoop *mluv = dest; - float *uv = mluv->uv; + float uv[2]; int i; zero_v2(uv); @@ -858,11 +876,14 @@ static void layerInterp_mloop_origspace(void **sources, const float *weights, } else { for (i = 0; i < count; i++) { - float weight = weights ? weights[i] : 1; + float weight = weights ? weights[i] : 1.0f; OrigSpaceLoop *src = sources[i]; madd_v2_v2fl(uv, src->uv, weight); } } + + /* delay writing to the destination incase dest is in sources */ + copy_v2_v2(((OrigSpaceLoop *)dest)->uv, uv); } /* --- end copy */ @@ -907,6 +928,7 @@ static void layerInterp_mcol(void **sources, const float *weights, } } + /* delay writing to the destination incase dest is in sources */ for (j = 0; j < 4; ++j) { /* Subdivide smooth or fractal can cause problems without clamping @@ -949,30 +971,33 @@ static void layerDefault_mcol(void *data, int count) static void layerInterp_bweight(void **sources, const float *weights, const float *UNUSED(sub_weights), int count, void *dest) { - float *f = dest; + float f; float **in = (float **)sources; int i; if (count <= 0) return; - *f = 0.0f; + f = 0.0f; if (weights) { for (i = 0; i < count; ++i) { - *f += *in[i] * weights[i]; + f += *in[i] * weights[i]; } } else { for (i = 0; i < count; ++i) { - *f += *in[i]; + f += *in[i]; } } + + /* delay writing to the destination incase dest is in sources */ + *((float *)dest) = f; } static void layerInterp_shapekey(void **sources, const float *weights, const float *UNUSED(sub_weights), int count, void *dest) { - float *co = dest; + float co[3]; float **in = (float **)sources; int i; @@ -990,6 +1015,9 @@ static void layerInterp_shapekey(void **sources, const float *weights, add_v3_v3(co, in[i]); } } + + /* delay writing to the destination incase dest is in sources */ + copy_v3_v3((float *)dest, co); } static void layerDefault_mvert_skin(void *data, int count) @@ -1019,6 +1047,7 @@ static void layerInterp_mvert_skin(void **sources, const float *weights, madd_v3_v3fl(radius, vs->radius, w); } + /* delay writing to the destination incase dest is in sources */ vs = dest; copy_v3_v3(vs->radius, radius); vs->flag &= ~MVERT_SKIN_ROOT; @@ -1962,23 +1991,6 @@ void CustomData_free_elem(CustomData *data, int index, int count) #define SOURCE_BUF_SIZE 100 -/* This define makes it so when we are interpolating customdata, - * the source is checked if it matches the destination. - * - * There are 2 ways to get around this, - * - Each interp function could accumulate the final result in a local, stack variable, - * then apply the result at the end. - * - * - Or we can make a temp copy of the destinations custom data before applying it. - * This isn't so efficient but avoids having to consider feedback loop on each interp function. - * Since this is more of a corner case its also not worth worrying about speed too much. - * - * (opted for the second option for now), keeping as an ifdef since we may wan't to change how works. - * - * see bug [#32395] - Campbell. - */ -#define USE_INTERP_OVERLAP_FIX - void CustomData_interp(const CustomData *source, CustomData *dest, int *src_indices, float *weights, float *sub_weights, int count, int dest_index) @@ -2017,9 +2029,6 @@ void CustomData_interp(const CustomData *source, CustomData *dest, void *src_data = source->layers[src_i].data; for (j = 0; j < count; ++j) { - /* if this happens we need to do a temp copy, see: USE_INTERP_OVERLAP_FIX */ - BLI_assert(((source == dest) && (dest_index == src_indices[j])) == FALSE); - sources[j] = (char *)src_data + typeInfo->size * src_indices[j]; } @@ -2599,11 +2608,6 @@ void CustomData_bmesh_interp(CustomData *data, void **src_blocks, float *weights void *source_buf[SOURCE_BUF_SIZE]; void **sources = source_buf; -#ifdef USE_INTERP_OVERLAP_FIX - /* incase there is overlap with the source */ - void *dest_block_copy = NULL; -#endif - /* slow fallback in case we're interpolating a ridiculous number of * elements */ @@ -2617,21 +2621,7 @@ void CustomData_bmesh_interp(CustomData *data, void **src_blocks, float *weights const LayerTypeInfo *typeInfo = layerType_getInfo(layer->type); if (typeInfo->interp) { for (j = 0; j < count; ++j) { -#ifdef USE_INTERP_OVERLAP_FIX - void *src_block; - if (UNLIKELY(src_blocks[j] == dest_block)) { - if (dest_block_copy == NULL) { - CustomData_bmesh_copy_data(data, data, dest_block, &dest_block_copy); - } - src_block = dest_block_copy; - } - else { - src_block = src_blocks[j]; - } - sources[j] = (char *)src_block + layer->offset; -#else sources[j] = (char *)src_blocks[j] + layer->offset; -#endif } typeInfo->interp(sources, weights, sub_weights, count, @@ -2639,12 +2629,6 @@ void CustomData_bmesh_interp(CustomData *data, void **src_blocks, float *weights } } -#ifdef USE_INTERP_OVERLAP_FIX - if (dest_block_copy) { - CustomData_bmesh_free_block(data, &dest_block_copy); - } -#endif - if (count > SOURCE_BUF_SIZE) MEM_freeN(sources); } From 3da7e0f3bf04d2814b13a395527f450916eebe1f Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 24 Aug 2012 17:58:49 +0000 Subject: [PATCH 121/163] mesh bridge tool now leaves bridge faces selected. --- source/blender/bmesh/operators/bmo_connect.c | 5 ++++ source/blender/editors/mesh/editmesh_tools.c | 31 ++++++++++++++------ 2 files changed, 27 insertions(+), 9 deletions(-) diff --git a/source/blender/bmesh/operators/bmo_connect.c b/source/blender/bmesh/operators/bmo_connect.c index 5b317aebbf0..6943dcb3e5d 100644 --- a/source/blender/bmesh/operators/bmo_connect.c +++ b/source/blender/bmesh/operators/bmo_connect.c @@ -39,6 +39,7 @@ #define FACE_NEW 2 #define EDGE_MARK 4 #define EDGE_DONE 8 +#define FACE_OUT 16 void bmo_connect_verts_exec(BMesh *bm, BMOperator *op) { @@ -514,6 +515,8 @@ void bmo_bridge_loops_exec(BMesh *bm, BMOperator *op) fprintf(stderr, "%s: in bridge! (bmesh internal error)\n", __func__); } else { + BMO_elem_flag_enable(bm, f, FACE_OUT); + l_iter = BM_FACE_FIRST_LOOP(f); if (l_1) BM_elem_attrs_copy(bm, bm, l_1, l_iter); l_iter = l_iter->next; @@ -525,6 +528,8 @@ void bmo_bridge_loops_exec(BMesh *bm, BMOperator *op) } } + BMO_slot_buffer_from_enabled_flag(bm, op, "faceout", BM_FACE, FACE_OUT); + cleanup: BLI_array_free(ee1); BLI_array_free(ee2); diff --git a/source/blender/editors/mesh/editmesh_tools.c b/source/blender/editors/mesh/editmesh_tools.c index 843a36cda35..92cc3366b3e 100644 --- a/source/blender/editors/mesh/editmesh_tools.c +++ b/source/blender/editors/mesh/editmesh_tools.c @@ -4802,19 +4802,32 @@ void MESH_OT_bevel(wmOperatorType *ot) static int edbm_bridge_edge_loops_exec(bContext *C, wmOperator *op) { + BMOperator bmop; Object *obedit = CTX_data_edit_object(C); BMEditMesh *em = BMEdit_FromObject(obedit); + const int use_merge = RNA_boolean_get(op->ptr, "use_merge"); + const float merge_factor = RNA_float_get(op->ptr, "merge_factor"); - if (!EDBM_op_callf(em, op, - "bridge_loops edges=%he use_merge=%b merge_factor=%f", - BM_ELEM_SELECT, RNA_boolean_get(op->ptr, "use_merge"), RNA_float_get(op->ptr, "merge_factor"))) - { - return OPERATOR_CANCELLED; - } - - EDBM_update_generic(C, em, TRUE); + EDBM_op_init(em, &bmop, op, + "bridge_loops edges=%he use_merge=%b merge_factor=%f", + BM_ELEM_SELECT, use_merge, merge_factor); - return OPERATOR_FINISHED; + BMO_op_exec(em->bm, &bmop); + + /* when merge is used the edges are joined and remain selected */ + if (use_merge == FALSE) { + EDBM_flag_disable_all(em, BM_ELEM_SELECT); + BMO_slot_buffer_hflag_enable(em->bm, &bmop, "faceout", BM_FACE, BM_ELEM_SELECT, TRUE); + } + + if (!EDBM_op_finish(em, &bmop, op, TRUE)) { + return OPERATOR_CANCELLED; + + } + else { + EDBM_update_generic(C, em, TRUE); + return OPERATOR_FINISHED; + } } void MESH_OT_bridge_edge_loops(wmOperatorType *ot) From ed0489bb6ed0f711aed90f4e903eb862bae4ff1a Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 24 Aug 2012 23:22:34 +0000 Subject: [PATCH 122/163] style cleanup: also spelling --- .../Recast/Source/RecastFilter.cpp | 4 +- .../blender/blenkernel/intern/DerivedMesh.c | 4 +- source/blender/blenkernel/intern/anim.c | 6 +- source/blender/blenkernel/intern/armature.c | 2 +- source/blender/blenkernel/intern/curve.c | 2 +- .../blender/blenkernel/intern/dynamicpaint.c | 2 +- source/blender/blenkernel/intern/fcurve.c | 2 +- source/blender/blenkernel/intern/material.c | 7 +- source/blender/blenkernel/intern/nla.c | 2 +- source/blender/blenkernel/intern/node.c | 2 +- source/blender/bmesh/intern/bmesh_opdefines.c | 64 +++++++++---------- .../blender/editors/animation/fmodifier_ui.c | 2 +- .../blender/editors/gpencil/gpencil_paint.c | 2 +- .../editors/interface/interface_handlers.c | 2 +- .../blender/editors/render/render_internal.c | 2 +- .../editors/uvedit/uvedit_parametrizer.c | 6 +- .../gameengine/SceneGraph/SG_ParentRelation.h | 2 +- 17 files changed, 56 insertions(+), 57 deletions(-) diff --git a/extern/recastnavigation/Recast/Source/RecastFilter.cpp b/extern/recastnavigation/Recast/Source/RecastFilter.cpp index bf985c362c9..9df71ea3fbf 100644 --- a/extern/recastnavigation/Recast/Source/RecastFilter.cpp +++ b/extern/recastnavigation/Recast/Source/RecastFilter.cpp @@ -128,7 +128,7 @@ void rcFilterLedgeSpans(rcContext* ctx, const int walkableHeight, const int walk rcSpan* ns = solid.spans[dx + dy*w]; int nbot = -walkableClimb; int ntop = ns ? (int)ns->smin : MAX_HEIGHT; - // Skip neightbour if the gap between the spans is too small. + // Skip neighbor if the gap between the spans is too small. if (rcMin(top,ntop) - rcMax(bot,nbot) > walkableHeight) minh = rcMin(minh, nbot - bot); @@ -137,7 +137,7 @@ void rcFilterLedgeSpans(rcContext* ctx, const int walkableHeight, const int walk { nbot = (int)ns->smax; ntop = ns->next ? (int)ns->next->smin : MAX_HEIGHT; - // Skip neightbour if the gap between the spans is too small. + // Skip neighbor if the gap between the spans is too small. if (rcMin(top,ntop) - rcMax(bot,nbot) > walkableHeight) { minh = rcMin(minh, nbot - bot); diff --git a/source/blender/blenkernel/intern/DerivedMesh.c b/source/blender/blenkernel/intern/DerivedMesh.c index a8a3d0cdbcb..a29484638c0 100644 --- a/source/blender/blenkernel/intern/DerivedMesh.c +++ b/source/blender/blenkernel/intern/DerivedMesh.c @@ -541,7 +541,7 @@ void DM_to_mesh(DerivedMesh *dm, Mesh *me, Object *ob) CustomData_free(&me->pdata, me->totpoly); /* ok, this should now use new CD shapekey data, - * which shouuld be fed through the modifier + * which should be fed through the modifier * stack*/ if (tmp.totvert != me->totvert && !did_shapekeys && me->key) { printf("%s: YEEK! this should be recoded! Shape key loss!: ID '%s'\n", __func__, tmp.id.name); @@ -1793,7 +1793,7 @@ static void mesh_calc_modifiers(Scene *scene, Object *ob, float (*inputVertexCos { finaldm->recalcTessellation(finaldm); } - /* Even if tessellation is not needed, some modifiers migh have modified CD layers + /* Even if tessellation is not needed, some modifiers might have modified CD layers * (like mloopcol or mloopuv), hence we have to update those. */ else if (finaldm->dirty & DM_DIRTY_TESS_CDLAYERS) { /* A tessellation already exists, it should always have a CD_POLYINDEX. */ diff --git a/source/blender/blenkernel/intern/anim.c b/source/blender/blenkernel/intern/anim.c index 6e857bacb1b..9b4f0a31e28 100644 --- a/source/blender/blenkernel/intern/anim.c +++ b/source/blender/blenkernel/intern/anim.c @@ -282,7 +282,7 @@ void animviz_get_object_motionpaths(Object *ob, ListBase *targets) /* ........ */ -/* Note on evaluation optimisations: +/* Note on evaluation optimizations: * Optimisations currently used here play tricks with the depsgraph in order to try and * evaluate as few objects as strictly necessary to get nicer performance under standard * production conditions. For those people who really need the accurate version, @@ -323,7 +323,7 @@ static void motionpaths_calc_optimise_depsgraph(Scene *scene, ListBase *targets) /* update scene for current frame */ static void motionpaths_calc_update_scene(Scene *scene) { -#if 1 // 'production' optimisations always on +#if 1 // 'production' optimizations always on Base *base, *last = NULL; /* only stuff that moves or needs display still */ @@ -431,7 +431,7 @@ void animviz_calc_motionpaths(Scene *scene, ListBase *targets) if (efra <= sfra) return; /* optimize the depsgraph for faster updates */ - /* TODO: whether this is used should depend on some setting for the level of optimisations used */ + /* TODO: whether this is used should depend on some setting for the level of optimizations used */ motionpaths_calc_optimise_depsgraph(scene, targets); /* calculate path over requested range */ diff --git a/source/blender/blenkernel/intern/armature.c b/source/blender/blenkernel/intern/armature.c index 79ee0e96450..04585791135 100644 --- a/source/blender/blenkernel/intern/armature.c +++ b/source/blender/blenkernel/intern/armature.c @@ -1463,7 +1463,7 @@ void vec_roll_to_mat3(const float vec[3], const float roll, float mat[][3]) * * was 0.0000000000001, caused bug [#31333], smaller values give unstable * roll when toggling editmode again... - * No good value here, trying 0.000000001 as best compromize. :/ + * No good value here, trying 0.000000001 as best compromise. :/ */ if (dot_v3v3(axis, axis) > 1.0e-9f) { /* if nor is *not* a multiple of target ... */ diff --git a/source/blender/blenkernel/intern/curve.c b/source/blender/blenkernel/intern/curve.c index e2bb1aaa2c7..d2b8ec2cc02 100644 --- a/source/blender/blenkernel/intern/curve.c +++ b/source/blender/blenkernel/intern/curve.c @@ -1165,7 +1165,7 @@ void BKE_curve_forward_diff_bezier(float q0, float q1, float q2, float q3, float static void forward_diff_bezier_cotangent(const float p0[3], const float p1[3], const float p2[3], const float p3[3], float p[3], int it, int stride) { - /* note that these are not purpendicular to the curve + /* note that these are not perpendicular to the curve * they need to be rotated for this, * * This could also be optimized like BKE_curve_forward_diff_bezier */ diff --git a/source/blender/blenkernel/intern/dynamicpaint.c b/source/blender/blenkernel/intern/dynamicpaint.c index 8db93f8b44a..06807dfcbad 100644 --- a/source/blender/blenkernel/intern/dynamicpaint.c +++ b/source/blender/blenkernel/intern/dynamicpaint.c @@ -3996,7 +3996,7 @@ void surface_determineForceTargetPoints(PaintSurfaceData *sData, int index, floa float force_intersect; float temp; - /* project force vector on the plane determined by these two neightbour points + /* project force vector on the plane determined by these two neighbor points * and calculate relative force angle from it*/ cross_v3_v3v3(tangent, bNeighs[closest_id[0]].dir, bNeighs[closest_id[1]].dir); normalize_v3(tangent); diff --git a/source/blender/blenkernel/intern/fcurve.c b/source/blender/blenkernel/intern/fcurve.c index 67e7743c8a4..53c12d32bc1 100644 --- a/source/blender/blenkernel/intern/fcurve.c +++ b/source/blender/blenkernel/intern/fcurve.c @@ -365,7 +365,7 @@ int binarysearch_bezt_index(BezTriple array[], float frame, int arraylen, short /* initialize replace-flag first */ *replace = 0; - /* sneaky optimisations (don't go through searching process if...): + /* sneaky optimizations (don't go through searching process if...): * - keyframe to be added is to be added out of current bounds * - keyframe to be added would replace one of the existing ones on bounds */ diff --git a/source/blender/blenkernel/intern/material.c b/source/blender/blenkernel/intern/material.c index fd167c69e62..7523c59a879 100644 --- a/source/blender/blenkernel/intern/material.c +++ b/source/blender/blenkernel/intern/material.c @@ -813,7 +813,7 @@ void assign_material(Object *ob, Material *ma, short act, int assign_type) *totcolp = act; } - // Determine the object/mesh linking + /* Determine the object/mesh linking */ if (assign_type == BKE_MAT_ASSIGN_USERPREF && ob->totcol && ob->actcol) { /* copy from previous material */ bit = ob->matbits[ob->actcol - 1]; @@ -1633,7 +1633,7 @@ static void decode_tfaceflag(Material *ma, int flag, int convertall) /* flag is shifted in 1 to make 0 != no flag yet (see encode_tfaceflag) */ flag -= 1; - alphablend = flag >> 15; //encoded in the encode_tfaceflag function + alphablend = flag >> 15; /* encoded in the encode_tfaceflag function */ (*game).flag = 0; /* General Material Options */ @@ -2033,8 +2033,7 @@ int do_version_tface(Main *main, int fileload) nowarning = 0; } else - convert_tfacematerial(main, ma); - continue; + convert_tfacematerial(main, ma); continue; } /* no conflicts in this material - 90% of cases diff --git a/source/blender/blenkernel/intern/nla.c b/source/blender/blenkernel/intern/nla.c index d62b03b5060..9590160c8f3 100644 --- a/source/blender/blenkernel/intern/nla.c +++ b/source/blender/blenkernel/intern/nla.c @@ -764,7 +764,7 @@ void BKE_nlastrips_clear_metas(ListBase *strips, short onlySel, short onlyTemp) } /* Add the given NLA-Strip to the given Meta-Strip, assuming that the - * strip isn't attached to anyy list of strips + * strip isn't attached to any list of strips */ short BKE_nlameta_add_strip(NlaStrip *mstrip, NlaStrip *strip) { diff --git a/source/blender/blenkernel/intern/node.c b/source/blender/blenkernel/intern/node.c index bf5fc6449f8..c283db94103 100644 --- a/source/blender/blenkernel/intern/node.c +++ b/source/blender/blenkernel/intern/node.c @@ -1484,7 +1484,7 @@ void nodeSocketSetType(bNodeSocket *sock, int type) * otherwise we may reference missing data. * * Currently its only used for ID's, but nodes may one day - * referene other pointers which need validation. + * reference other pointers which need validation. */ typedef struct bNodeClipboardExtraInfo { struct bNodeClipboardExtraInfo *next, *prev; diff --git a/source/blender/bmesh/intern/bmesh_opdefines.c b/source/blender/bmesh/intern/bmesh_opdefines.c index 48d8583ee7c..362157ad71b 100644 --- a/source/blender/bmesh/intern/bmesh_opdefines.c +++ b/source/blender/bmesh/intern/bmesh_opdefines.c @@ -366,8 +366,8 @@ static BMOpDefine bmo_weld_verts_def = { */ static BMOpDefine bmo_create_vert_def = { "create_vert", - {{BMO_OP_SLOT_VEC, "co"}, //the coordinate of the new vert - {BMO_OP_SLOT_ELEMENT_BUF, "newvertout"}, //the new vert + {{BMO_OP_SLOT_VEC, "co"}, /* the coordinate of the new vert */ + {BMO_OP_SLOT_ELEMENT_BUF, "newvertout"}, /* the new vert */ {0, /* null-terminating sentinel */}}, bmo_create_vert_exec, 0, @@ -381,8 +381,8 @@ static BMOpDefine bmo_create_vert_def = { */ static BMOpDefine bmo_join_triangles_def = { "join_triangles", - {{BMO_OP_SLOT_ELEMENT_BUF, "faces"}, //input geometry. - {BMO_OP_SLOT_ELEMENT_BUF, "faceout"}, //joined faces + {{BMO_OP_SLOT_ELEMENT_BUF, "faces"}, /* input geometry. */ + {BMO_OP_SLOT_ELEMENT_BUF, "faceout"}, /* joined faces */ {BMO_OP_SLOT_BOOL, "cmp_sharp"}, {BMO_OP_SLOT_BOOL, "cmp_uvs"}, {BMO_OP_SLOT_BOOL, "cmp_vcols"}, @@ -406,7 +406,7 @@ static BMOpDefine bmo_join_triangles_def = { */ static BMOpDefine bmo_contextual_create_def = { "contextual_create", - {{BMO_OP_SLOT_ELEMENT_BUF, "geom"}, //input geometry. + {{BMO_OP_SLOT_ELEMENT_BUF, "geom"}, /* input geometry. */ {BMO_OP_SLOT_ELEMENT_BUF, "faceout"}, /* newly-made face(s) */ /* note, this is for stand-alone edges only, not edges which are apart of newly created faces */ {BMO_OP_SLOT_ELEMENT_BUF, "edgeout"}, /* newly-made edge(s) */ @@ -459,8 +459,8 @@ static BMOpDefine bmo_edgenet_fill_def = { */ static BMOpDefine bmo_edgenet_prepare_def = { "edgenet_prepare", - {{BMO_OP_SLOT_ELEMENT_BUF, "edges"}, //input edges - {BMO_OP_SLOT_ELEMENT_BUF, "edgeout"}, //new edges + {{BMO_OP_SLOT_ELEMENT_BUF, "edges"}, /* input edges */ + {BMO_OP_SLOT_ELEMENT_BUF, "edgeout"}, /* new edges */ {0, /* null-terminating sentinel */}}, bmo_edgenet_prepare, 0, @@ -474,9 +474,9 @@ static BMOpDefine bmo_edgenet_prepare_def = { */ static BMOpDefine bmo_rotate_def = { "rotate", - {{BMO_OP_SLOT_VEC, "cent"}, //center of rotation - {BMO_OP_SLOT_MAT, "mat"}, //matrix defining rotation - {BMO_OP_SLOT_ELEMENT_BUF, "verts"}, //input vertices + {{BMO_OP_SLOT_VEC, "cent"}, /* center of rotation */ + {BMO_OP_SLOT_MAT, "mat"}, /* matrix defining rotation */ + {BMO_OP_SLOT_ELEMENT_BUF, "verts"}, /* input vertices */ {0, /* null-terminating sentinel */}}, bmo_rotate_exec, 0, @@ -490,8 +490,8 @@ static BMOpDefine bmo_rotate_def = { */ static BMOpDefine bmo_translate_def = { "translate", - {{BMO_OP_SLOT_VEC, "vec"}, //translation offset - {BMO_OP_SLOT_ELEMENT_BUF, "verts"}, //input vertices + {{BMO_OP_SLOT_VEC, "vec"}, /* translation offset */ + {BMO_OP_SLOT_ELEMENT_BUF, "verts"}, /* input vertices */ {0, /* null-terminating sentinel */}}, bmo_translate_exec, 0, @@ -504,8 +504,8 @@ static BMOpDefine bmo_translate_def = { */ static BMOpDefine bmo_scale_def = { "scale", - {{BMO_OP_SLOT_VEC, "vec"}, //scale factor - {BMO_OP_SLOT_ELEMENT_BUF, "verts"}, //input vertices + {{BMO_OP_SLOT_VEC, "vec"}, /* scale factor */ + {BMO_OP_SLOT_ELEMENT_BUF, "verts"}, /* input vertices */ {0, /* null-terminating sentinel */}}, bmo_scale_exec, 0, @@ -520,8 +520,8 @@ static BMOpDefine bmo_scale_def = { */ static BMOpDefine bmo_transform_def = { "transform", - {{BMO_OP_SLOT_MAT, "mat"}, //transform matrix - {BMO_OP_SLOT_ELEMENT_BUF, "verts"}, //input vertices + {{BMO_OP_SLOT_MAT, "mat"}, /* transform matrix */ + {BMO_OP_SLOT_ELEMENT_BUF, "verts"}, /* input vertices */ {0, /* null-terminating sentinel */}}, bmo_transform_exec, 0, @@ -550,9 +550,9 @@ static BMOpDefine bmo_object_load_bmesh_def = { */ static BMOpDefine bmo_bmesh_to_mesh_def = { "bmesh_to_mesh", - {{BMO_OP_SLOT_PTR, "mesh"}, //pointer to a mesh structure to fill in - {BMO_OP_SLOT_PTR, "object"}, //pointer to an object structure - {BMO_OP_SLOT_BOOL, "notessellation"}, //don't calculate mfaces + {{BMO_OP_SLOT_PTR, "mesh"}, /* pointer to a mesh structure to fill in */ + {BMO_OP_SLOT_PTR, "object"}, /* pointer to an object structure */ + {BMO_OP_SLOT_BOOL, "notessellation"}, /* don't calculate mfaces */ {0, /* null-terminating sentinel */}}, bmo_bmesh_to_mesh_exec, 0, @@ -566,9 +566,9 @@ static BMOpDefine bmo_bmesh_to_mesh_def = { */ static BMOpDefine bmo_mesh_to_bmesh_def = { "mesh_to_bmesh", - {{BMO_OP_SLOT_PTR, "mesh"}, //pointer to a Mesh structure - {BMO_OP_SLOT_PTR, "object"}, //pointer to an Object structure - {BMO_OP_SLOT_BOOL, "set_shapekey"}, //load active shapekey coordinates into verts + {{BMO_OP_SLOT_PTR, "mesh"}, /* pointer to a Mesh structure */ + {BMO_OP_SLOT_PTR, "object"}, /* pointer to an Object structure */ + {BMO_OP_SLOT_BOOL, "set_shapekey"}, /* load active shapekey coordinates into verts */ {0, /* null-terminating sentinel */}}, bmo_mesh_to_bmesh_exec, 0 @@ -581,9 +581,9 @@ static BMOpDefine bmo_mesh_to_bmesh_def = { */ static BMOpDefine bmo_extrude_discrete_faces_def = { "extrude_discrete_faces", - {{BMO_OP_SLOT_ELEMENT_BUF, "faces"}, //input faces - {BMO_OP_SLOT_ELEMENT_BUF, "faceout"}, //output faces - {BMO_OP_SLOT_ELEMENT_BUF, "skirtout"}, //output skirt geometry, faces and edges + {{BMO_OP_SLOT_ELEMENT_BUF, "faces"}, /* input faces */ + {BMO_OP_SLOT_ELEMENT_BUF, "faceout"}, /* output faces */ + {BMO_OP_SLOT_ELEMENT_BUF, "skirtout"}, /* output skirt geometry, faces and edges */ {0} /* null-terminating sentinel */}, bmo_extrude_discrete_faces_exec, 0 @@ -597,8 +597,8 @@ static BMOpDefine bmo_extrude_discrete_faces_def = { */ static BMOpDefine bmo_extrude_edge_only_def = { "extrude_edge_only", - {{BMO_OP_SLOT_ELEMENT_BUF, "edges"}, //input vertices - {BMO_OP_SLOT_ELEMENT_BUF, "geomout"}, //output geometry + {{BMO_OP_SLOT_ELEMENT_BUF, "edges"}, /* input vertices */ + {BMO_OP_SLOT_ELEMENT_BUF, "geomout"}, /* output geometry */ {0} /* null-terminating sentinel */}, bmo_extrude_edge_only_exec, 0 @@ -611,9 +611,9 @@ static BMOpDefine bmo_extrude_edge_only_def = { */ static BMOpDefine bmo_extrude_vert_indiv_def = { "extrude_vert_indiv", - {{BMO_OP_SLOT_ELEMENT_BUF, "verts"}, //input vertices - {BMO_OP_SLOT_ELEMENT_BUF, "edgeout"}, //output wire edges - {BMO_OP_SLOT_ELEMENT_BUF, "vertout"}, //output vertices + {{BMO_OP_SLOT_ELEMENT_BUF, "verts"}, /* input vertices */ + {BMO_OP_SLOT_ELEMENT_BUF, "edgeout"}, /* output wire edges */ + {BMO_OP_SLOT_ELEMENT_BUF, "vertout"}, /* output vertices */ {0} /* null-terminating sentinel */}, bmo_extrude_vert_indiv_exec, 0 @@ -651,7 +651,7 @@ static BMOpDefine bmo_dissolve_edges_def = { "dissolve_edges", {{BMO_OP_SLOT_ELEMENT_BUF, "edges"}, {BMO_OP_SLOT_ELEMENT_BUF, "regionout"}, - {BMO_OP_SLOT_BOOL, "use_verts"}, // dissolve verts left between only 2 edges. + {BMO_OP_SLOT_BOOL, "use_verts"}, /* dissolve verts left between only 2 edges. */ {0} /* null-terminating sentinel */}, bmo_dissolve_edges_exec, BMO_OP_FLAG_UNTAN_MULTIRES @@ -670,7 +670,7 @@ static BMOpDefine bmo_dissolve_faces_def = { "dissolve_faces", {{BMO_OP_SLOT_ELEMENT_BUF, "faces"}, {BMO_OP_SLOT_ELEMENT_BUF, "regionout"}, - {BMO_OP_SLOT_BOOL, "use_verts"}, // dissolve verts left between only 2 edges. + {BMO_OP_SLOT_BOOL, "use_verts"}, /* dissolve verts left between only 2 edges. */ {0} /* null-terminating sentinel */}, bmo_dissolve_faces_exec, BMO_OP_FLAG_UNTAN_MULTIRES diff --git a/source/blender/editors/animation/fmodifier_ui.c b/source/blender/editors/animation/fmodifier_ui.c index 83cb0db4978..e254fb7a3c4 100644 --- a/source/blender/editors/animation/fmodifier_ui.c +++ b/source/blender/editors/animation/fmodifier_ui.c @@ -336,7 +336,7 @@ static int binarysearch_fcm_envelopedata_index(FCM_EnvelopeData array[], float f /* initialize exists-flag first */ *exists = 0; - /* sneaky optimisations (don't go through searching process if...): + /* sneaky optimizations (don't go through searching process if...): * - keyframe to be added is to be added out of current bounds * - keyframe to be added would replace one of the existing ones on bounds */ diff --git a/source/blender/editors/gpencil/gpencil_paint.c b/source/blender/editors/gpencil/gpencil_paint.c index 6f2952a1967..e4bfbea75b0 100644 --- a/source/blender/editors/gpencil/gpencil_paint.c +++ b/source/blender/editors/gpencil/gpencil_paint.c @@ -1480,7 +1480,7 @@ static void gpencil_draw_apply_event(wmOperator *op, wmEvent *event) float mousef[2]; int tablet = 0; - /* convert from window-space to area-space mouse coordintes + /* convert from window-space to area-space mouse coordinates * NOTE: float to ints conversions, +1 factor is probably used to ensure a bit more accurate rounding... */ p->mval[0] = event->mval[0] + 1; diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c index 33a5a0729ee..9227ad158fd 100644 --- a/source/blender/editors/interface/interface_handlers.c +++ b/source/blender/editors/interface/interface_handlers.c @@ -2969,7 +2969,7 @@ static int ui_do_but_BLOCK(bContext *C, uiBut *but, uiHandleButtonData *data, wm * Alt+MouseWheel over the render slots, without this, * the slot menu fails to switch a second time. * - * Theactive state of the button could be maintained some other way + * The active state of the button could be maintained some other way * and remove this mousemove event. */ WM_event_add_mousemove(C); diff --git a/source/blender/editors/render/render_internal.c b/source/blender/editors/render/render_internal.c index 1cc241f17db..b236b555850 100644 --- a/source/blender/editors/render/render_internal.c +++ b/source/blender/editors/render/render_internal.c @@ -588,7 +588,7 @@ static int screen_render_invoke(bContext *C, wmOperator *op, wmEvent *event) /* store actual owner of job, so modal operator could check for it, * the reason of this is that active scene could change when rendering - * several layers from composistor [#31800] + * several layers from compositor [#31800] */ op->customdata = scene; diff --git a/source/blender/editors/uvedit/uvedit_parametrizer.c b/source/blender/editors/uvedit/uvedit_parametrizer.c index 72c38be5398..f017394356e 100644 --- a/source/blender/editors/uvedit/uvedit_parametrizer.c +++ b/source/blender/editors/uvedit/uvedit_parametrizer.c @@ -45,7 +45,7 @@ #include #include -#include "BLO_sys_types.h" // for intptr_t support +#include "BLO_sys_types.h" /* for intptr_t support */ /* Utils */ @@ -1040,7 +1040,7 @@ static PFace *p_face_add(PHandle *handle) /* allocate */ f = (PFace *)BLI_memarena_alloc(handle->arena, sizeof *f); - f->flag = 0; // init ! + f->flag = 0; /* init ! */ e1 = (PEdge *)BLI_memarena_alloc(handle->arena, sizeof *e1); e2 = (PEdge *)BLI_memarena_alloc(handle->arena, sizeof *e2); @@ -1139,7 +1139,7 @@ static PBool p_quad_split_direction(PHandle *handle, float **co, PHashKey *vkeys * that in symmetric models we choose the same split direction instead of * depending on floating point errors to decide */ float bias = 1.0f + 1e-6f; - float fac = len_v3v3(co[0], co[2])*bias - len_v3v3(co[1], co[3]); + float fac = len_v3v3(co[0], co[2]) * bias - len_v3v3(co[1], co[3]); PBool dir = (fac <= 0.0f); /* the face exists check is there because of a special case: when diff --git a/source/gameengine/SceneGraph/SG_ParentRelation.h b/source/gameengine/SceneGraph/SG_ParentRelation.h index 925c0ed2766..4478ed11bc1 100644 --- a/source/gameengine/SceneGraph/SG_ParentRelation.h +++ b/source/gameengine/SceneGraph/SG_ParentRelation.h @@ -82,7 +82,7 @@ public : * You must provide a way of duplicating an * instance of an SG_ParentRelation. This should * return a pointer to a new duplicate allocated - * on the heap. Responsibilty for deleting the + * on the heap. Responsibility for deleting the * duplicate resides with the caller of this method. */ From 043783c20b4f330c9d068d9000bfdc630977ff5d Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 25 Aug 2012 11:54:58 +0000 Subject: [PATCH 123/163] use set's when checking against multiple types. --- release/scripts/modules/rna_xml.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/release/scripts/modules/rna_xml.py b/release/scripts/modules/rna_xml.py index 5354fd1c776..a259a4ec396 100644 --- a/release/scripts/modules/rna_xml.py +++ b/release/scripts/modules/rna_xml.py @@ -99,11 +99,11 @@ def rna2xml(fw=print_ln, subvalue = getattr(value, prop) subvalue_type = type(subvalue) - if subvalue_type in (int, bool, float): + if subvalue_type in {int, bool, float}: node_attrs.append("%s=\"%s\"" % (prop, number_to_str(subvalue, subvalue_type))) elif subvalue_type is str: node_attrs.append("%s=%s" % (prop, quoteattr(subvalue))) - elif subvalue_type == set: + elif subvalue_type is set: node_attrs.append("%s=%s" % (prop, quoteattr("{" + ",".join(list(subvalue)) + "}"))) elif subvalue is None: node_attrs.append("%s=\"NONE\"" % prop) @@ -137,7 +137,7 @@ def rna2xml(fw=print_ln, # default def str_recursive(s): subsubvalue_type = type(s) - if subsubvalue_type in (int, float, bool): + if subsubvalue_type in {int, float, bool}: return number_to_str(s, subsubvalue_type) else: return " ".join([str_recursive(si) for si in s]) From 049811dabd87de6a6cb044cfe0730bb99c5583e1 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 25 Aug 2012 12:32:22 +0000 Subject: [PATCH 124/163] don't use a while loop when in compatible_eul(). this is a low level rotation function called in many places so better to avoid iterations. checked this function against the previous method using random rotation inputs and compared results, while this isnt exactly the same the results are very close and acceptable in both cases, also checked baking actions that the resulting FCurves are good and give matching rotations. --- source/blender/blenlib/intern/math_rotation.c | 94 ++++++------------- 1 file changed, 28 insertions(+), 66 deletions(-) diff --git a/source/blender/blenlib/intern/math_rotation.c b/source/blender/blenlib/intern/math_rotation.c index 1698733dda7..d44e26aad08 100644 --- a/source/blender/blenlib/intern/math_rotation.c +++ b/source/blender/blenlib/intern/math_rotation.c @@ -1040,84 +1040,46 @@ void rotate_eul(float *beul, const char axis, const float ang) } -/* exported to transform.c */ - /* order independent! */ void compatible_eul(float eul[3], const float oldrot[3]) { - float dx, dy, dz; + /* we could use M_PI as pi_thresh: which is correct but 5.1 gives better results. + * Checked with baking actions to fcurves - campbell */ + const float pi_thresh = (5.1f); + const float pi_x2 = (2.0f * (float)M_PI); + + float deul[3]; + unsigned int i; /* correct differences of about 360 degrees first */ - dx = eul[0] - oldrot[0]; - dy = eul[1] - oldrot[1]; - dz = eul[2] - oldrot[2]; - - while (fabsf(dx) > 5.1f) { - if (dx > 0.0f) eul[0] -= 2.0f * (float)M_PI; - else eul[0] += 2.0f * (float)M_PI; - dx = eul[0] - oldrot[0]; - } - while (fabsf(dy) > 5.1f) { - if (dy > 0.0f) eul[1] -= 2.0f * (float)M_PI; - else eul[1] += 2.0f * (float)M_PI; - dy = eul[1] - oldrot[1]; - } - while (fabsf(dz) > 5.1f) { - if (dz > 0.0f) eul[2] -= 2.0f * (float)M_PI; - else eul[2] += 2.0f * (float)M_PI; - dz = eul[2] - oldrot[2]; + for (i = 0; i < 3; i++) { + deul[i] = eul[i] - oldrot[i]; + if (deul[i] > pi_thresh) { + eul[i] -= floorf(( deul[i] / pi_x2) + 0.5) * pi_x2; + deul[i] = eul[i] - oldrot[i]; + } + else if (deul[i] < -pi_thresh) { + eul[i] += floorf((-deul[i] / pi_x2) + 0.5) * pi_x2; + deul[i] = eul[i] - oldrot[i]; + } } /* is 1 of the axis rotations larger than 180 degrees and the other small? NO ELSE IF!! */ - if (fabsf(dx) > 3.2f && fabsf(dy) < 1.6f && fabsf(dz) < 1.6f) { - if (dx > 0.0f) eul[0] -= 2.0f * (float)M_PI; - else eul[0] += 2.0f * (float)M_PI; + if (fabsf(deul[0]) > 3.2f && fabsf(deul[1]) < 1.6f && fabsf(deul[2]) < 1.6f) { + if (deul[0] > 0.0f) eul[0] -= pi_x2; + else eul[0] += pi_x2; } - if (fabsf(dy) > 3.2f && fabsf(dz) < 1.6f && fabsf(dx) < 1.6f) { - if (dy > 0.0f) eul[1] -= 2.0f * (float)M_PI; - else eul[1] += 2.0f * (float)M_PI; + if (fabsf(deul[1]) > 3.2f && fabsf(deul[2]) < 1.6f && fabsf(deul[0]) < 1.6f) { + if (deul[1] > 0.0f) eul[1] -= pi_x2; + else eul[1] += pi_x2; } - if (fabsf(dz) > 3.2f && fabsf(dx) < 1.6f && fabsf(dy) < 1.6f) { - if (dz > 0.0f) eul[2] -= 2.0f * (float)M_PI; - else eul[2] += 2.0f * (float)M_PI; + if (fabsf(deul[2]) > 3.2f && fabsf(deul[0]) < 1.6f && fabsf(deul[1]) < 1.6f) { + if (deul[2] > 0.0f) eul[2] -= pi_x2; + else eul[2] += pi_x2; } - /* the method below was there from ancient days... but why! probably because the code sucks :) - */ -#if 0 - /* calc again */ - dx = eul[0] - oldrot[0]; - dy = eul[1] - oldrot[1]; - dz = eul[2] - oldrot[2]; - - /* special case, tested for x-z */ - - if ((fabsf(dx) > 3.1f && fabsf(dz) > 1.5f) || (fabsf(dx) > 1.5f && fabsf(dz) > 3.1f)) { - if (dx > 0.0f) eul[0] -= M_PI; - else eul[0] += M_PI; - if (eul[1] > 0.0) eul[1] = M_PI - eul[1]; - else eul[1] = -M_PI - eul[1]; - if (dz > 0.0f) eul[2] -= M_PI; - else eul[2] += M_PI; - - } - else if ((fabsf(dx) > 3.1f && fabsf(dy) > 1.5f) || (fabsf(dx) > 1.5f && fabsf(dy) > 3.1f)) { - if (dx > 0.0f) eul[0] -= M_PI; - else eul[0] += M_PI; - if (dy > 0.0f) eul[1] -= M_PI; - else eul[1] += M_PI; - if (eul[2] > 0.0f) eul[2] = M_PI - eul[2]; - else eul[2] = -M_PI - eul[2]; - } - else if ((fabsf(dy) > 3.1f && fabsf(dz) > 1.5f) || (fabsf(dy) > 1.5f && fabsf(dz) > 3.f1)) { - if (eul[0] > 0.0f) eul[0] = M_PI - eul[0]; - else eul[0] = -M_PI - eul[0]; - if (dy > 0.0f) eul[1] -= M_PI; - else eul[1] += M_PI; - if (dz > 0.0f) eul[2] -= M_PI; - else eul[2] += M_PI; - } -#endif +#undef PI_THRESH +#undef PI_2F } /* uses 2 methods to retrieve eulers, and picks the closest */ From 179ac9ebc0c47ca0f0f068a6258ec16ed787db4b Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 25 Aug 2012 12:37:15 +0000 Subject: [PATCH 125/163] baking actions with euler rotations now uses compatible eulers for pose and object bakes. --- .../scripts/modules/bpy_extras/anim_utils.py | 29 ++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/release/scripts/modules/bpy_extras/anim_utils.py b/release/scripts/modules/bpy_extras/anim_utils.py index c4ec805a72d..0ef310dd16a 100644 --- a/release/scripts/modules/bpy_extras/anim_utils.py +++ b/release/scripts/modules/bpy_extras/anim_utils.py @@ -68,7 +68,7 @@ def bake_action(frame_start, # Helper Functions def pose_frame_info(obj): - from mathutils import Matrix + from mathutils import Matrix, Euler info = {} @@ -181,6 +181,9 @@ def bake_action(frame_start, while pbone.constraints: pbone.constraints.remove(pbone.constraints[0]) + # create compatible eulers + euler_prev = None + for f in frame_range: f_step = (f - frame_start) // frame_step matrix = pose_info[f_step][name]["matrix_key"] @@ -198,8 +201,19 @@ def bake_action(frame_start, elif rotation_mode == 'AXIS_ANGLE': pbone.keyframe_insert("rotation_axis_angle", -1, f, name) else: # euler, XYZ, ZXY etc + + if euler_prev is not None: + euler = pbone.rotation_euler.copy() + euler.make_compatible(euler_prev) + pbone.rotation_euler = euler + euler_prev = euler + del euler + pbone.keyframe_insert("rotation_euler", -1, f, name) + if euler_prev is None: + euler_prev = pbone.rotation_euler.copy() + pbone.keyframe_insert("scale", -1, f, name) # object. TODO. multiple objects @@ -208,6 +222,9 @@ def bake_action(frame_start, while obj.constraints: obj.constraints.remove(obj.constraints[0]) + # create compatible eulers + euler_prev = None + for f in frame_range: matrix = obj_info[(f - frame_start) // frame_step]["matrix_key"] obj.matrix_local = matrix @@ -221,8 +238,18 @@ def bake_action(frame_start, elif rotation_mode == 'AXIS_ANGLE': obj.keyframe_insert("rotation_axis_angle", -1, f) else: # euler, XYZ, ZXY etc + if euler_prev is not None: + euler = obj.rotation_euler.copy() + euler.make_compatible(euler_prev) + obj.rotation_euler = euler + euler_prev = euler + del euler + obj.keyframe_insert("rotation_euler", -1, f) + if euler_prev is None: + euler_prev = obj.rotation_euler.copy() + obj.keyframe_insert("scale", -1, f) scene.frame_set(frame_back) From 71d1b09708f742ee084c498ae031a1c7da6d6328 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 25 Aug 2012 12:55:14 +0000 Subject: [PATCH 126/163] minor code cleanup --- release/scripts/modules/bpy_extras/anim_utils.py | 6 +++--- source/blender/blenkernel/intern/object.c | 2 +- source/blender/blenlib/BLI_math_rotation.h | 6 +++--- source/blender/blenlib/intern/math_rotation.c | 8 ++++---- source/blender/python/intern/bpy_rna.c | 4 ++-- source/blender/python/mathutils/mathutils_Euler.c | 4 ++-- source/blender/python/mathutils/mathutils_Euler.h | 4 ++-- source/blender/python/mathutils/mathutils_Matrix.c | 2 +- 8 files changed, 18 insertions(+), 18 deletions(-) diff --git a/release/scripts/modules/bpy_extras/anim_utils.py b/release/scripts/modules/bpy_extras/anim_utils.py index 0ef310dd16a..b8d08628de4 100644 --- a/release/scripts/modules/bpy_extras/anim_utils.py +++ b/release/scripts/modules/bpy_extras/anim_utils.py @@ -68,7 +68,7 @@ def bake_action(frame_start, # Helper Functions def pose_frame_info(obj): - from mathutils import Matrix, Euler + from mathutils import Matrix info = {} @@ -201,14 +201,14 @@ def bake_action(frame_start, elif rotation_mode == 'AXIS_ANGLE': pbone.keyframe_insert("rotation_axis_angle", -1, f, name) else: # euler, XYZ, ZXY etc - + if euler_prev is not None: euler = pbone.rotation_euler.copy() euler.make_compatible(euler_prev) pbone.rotation_euler = euler euler_prev = euler del euler - + pbone.keyframe_insert("rotation_euler", -1, f, name) if euler_prev is None: diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c index 914e19bd1dc..dfa3582cee8 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -1514,7 +1514,7 @@ void BKE_object_mat3_to_rot(Object *ob, float mat[][3], short use_compat) /* end drot correction */ if (use_compat) mat3_to_compatible_eulO(ob->rot, ob->rot, ob->rotmode, tmat); - else mat3_to_eulO(ob->rot, ob->rotmode, tmat); + else mat3_to_eulO(ob->rot, ob->rotmode, tmat); } } } diff --git a/source/blender/blenlib/BLI_math_rotation.h b/source/blender/blenlib/BLI_math_rotation.h index a40d4ca8463..64a6a6ec7d5 100644 --- a/source/blender/blenlib/BLI_math_rotation.h +++ b/source/blender/blenlib/BLI_math_rotation.h @@ -151,10 +151,10 @@ void mat3_to_eulO(float eul[3], const short order, float mat[3][3]); void mat4_to_eulO(float eul[3], const short order, float mat[4][4]); void axis_angle_to_eulO(float eul[3], const short order, const float axis[3], const float angle); -void mat3_to_compatible_eulO(float eul[3], float old[3], short order, float mat[3][3]); -void mat4_to_compatible_eulO(float eul[3], float old[3], short order, float mat[4][4]); +void mat3_to_compatible_eulO(float eul[3], float old[3], const short order, float mat[3][3]); +void mat4_to_compatible_eulO(float eul[3], float old[3], const short order, float mat[4][4]); -void rotate_eulO(float eul[3], short order, char axis, float angle); +void rotate_eulO(float eul[3], const short order, char axis, float angle); /******************************* Dual Quaternions ****************************/ diff --git a/source/blender/blenlib/intern/math_rotation.c b/source/blender/blenlib/intern/math_rotation.c index d44e26aad08..64fbfbf8a7d 100644 --- a/source/blender/blenlib/intern/math_rotation.c +++ b/source/blender/blenlib/intern/math_rotation.c @@ -1231,7 +1231,7 @@ void eulO_to_mat3(float M[3][3], const float e[3], const short order) } /* returns two euler calculation methods, so we can pick the best */ -static void mat3_to_eulo2(float M[3][3], float *e1, float *e2, short order) +static void mat3_to_eulo2(float M[3][3], float *e1, float *e2, const short order) { RotOrderInfo *R = GET_ROTATIONORDER_INFO(order); short i = R->axis[0], j = R->axis[1], k = R->axis[2]; @@ -1311,7 +1311,7 @@ void mat4_to_eulO(float e[3], const short order, float M[4][4]) } /* uses 2 methods to retrieve eulers, and picks the closest */ -void mat3_to_compatible_eulO(float eul[3], float oldrot[3], short order, float mat[3][3]) +void mat3_to_compatible_eulO(float eul[3], float oldrot[3], const short order, float mat[3][3]) { float eul1[3], eul2[3]; float d1, d2; @@ -1331,7 +1331,7 @@ void mat3_to_compatible_eulO(float eul[3], float oldrot[3], short order, float m copy_v3_v3(eul, eul1); } -void mat4_to_compatible_eulO(float eul[3], float oldrot[3], short order, float M[4][4]) +void mat4_to_compatible_eulO(float eul[3], float oldrot[3], const short order, float M[4][4]) { float m[3][3]; @@ -1343,7 +1343,7 @@ void mat4_to_compatible_eulO(float eul[3], float oldrot[3], short order, float M /* rotate the given euler by the given angle on the specified axis */ // NOTE: is this safe to do with different axis orders? -void rotate_eulO(float beul[3], short order, char axis, float ang) +void rotate_eulO(float beul[3], const short order, char axis, float ang) { float eul[3], mat1[3][3], mat2[3][3], totmat[3][3]; diff --git a/source/blender/python/intern/bpy_rna.c b/source/blender/python/intern/bpy_rna.c index bd660ae0001..4ae8e821298 100644 --- a/source/blender/python/intern/bpy_rna.c +++ b/source/blender/python/intern/bpy_rna.c @@ -369,7 +369,7 @@ static int deferred_register_prop(StructRNA *srna, PyObject *key, PyObject *item static PyObject *pyrna_prop_array_subscript_slice(BPy_PropertyArrayRNA *self, PointerRNA *ptr, PropertyRNA *prop, Py_ssize_t start, Py_ssize_t stop, Py_ssize_t length); -static short pyrna_rotation_euler_order_get(PointerRNA *ptr, PropertyRNA **prop_eul_order, short order_fallback); +static short pyrna_rotation_euler_order_get(PointerRNA *ptr, PropertyRNA **prop_eul_order, const short order_fallback); /* bpyrna vector/euler/quat callbacks */ static unsigned char mathutils_rna_array_cb_index = -1; /* index for our callbacks */ @@ -571,7 +571,7 @@ static Mathutils_Callback mathutils_rna_matrix_cb = { NULL }; -static short pyrna_rotation_euler_order_get(PointerRNA *ptr, PropertyRNA **prop_eul_order, short order_fallback) +static short pyrna_rotation_euler_order_get(PointerRNA *ptr, PropertyRNA **prop_eul_order, const short order_fallback) { /* attempt to get order */ if (*prop_eul_order == NULL) diff --git a/source/blender/python/mathutils/mathutils_Euler.c b/source/blender/python/mathutils/mathutils_Euler.c index 583831b1655..468ef3788c1 100644 --- a/source/blender/python/mathutils/mathutils_Euler.c +++ b/source/blender/python/mathutils/mathutils_Euler.c @@ -701,7 +701,7 @@ PyTypeObject euler_Type = { * (i.e. it was allocated elsewhere by MEM_mallocN()) * pass Py_NEW - if vector is not a WRAPPER and managed by PYTHON * (i.e. it must be created here with PyMEM_malloc())*/ -PyObject *Euler_CreatePyObject(float *eul, short order, int type, PyTypeObject *base_type) +PyObject *Euler_CreatePyObject(float *eul, const short order, int type, PyTypeObject *base_type) { EulerObject *self; @@ -738,7 +738,7 @@ PyObject *Euler_CreatePyObject(float *eul, short order, int type, PyTypeObject * return (PyObject *)self; } -PyObject *Euler_CreatePyObject_cb(PyObject *cb_user, short order, +PyObject *Euler_CreatePyObject_cb(PyObject *cb_user, const short order, unsigned char cb_type, unsigned char cb_subtype) { EulerObject *self = (EulerObject *)Euler_CreatePyObject(NULL, order, Py_NEW, NULL); diff --git a/source/blender/python/mathutils/mathutils_Euler.h b/source/blender/python/mathutils/mathutils_Euler.h index bcbc6c60ca7..e04d45e4630 100644 --- a/source/blender/python/mathutils/mathutils_Euler.h +++ b/source/blender/python/mathutils/mathutils_Euler.h @@ -48,8 +48,8 @@ typedef struct { * blender (stored in blend_data). This is an either/or struct not both */ //prototypes -PyObject *Euler_CreatePyObject(float *eul, short order, int type, PyTypeObject *base_type); -PyObject *Euler_CreatePyObject_cb(PyObject *cb_user, short order, +PyObject *Euler_CreatePyObject(float *eul, const short order, int type, PyTypeObject *base_type); +PyObject *Euler_CreatePyObject_cb(PyObject *cb_user, const short order, unsigned char cb_type, unsigned char cb_subtype); short euler_order_from_string(const char *str, const char *error_prefix); diff --git a/source/blender/python/mathutils/mathutils_Matrix.c b/source/blender/python/mathutils/mathutils_Matrix.c index d98c6e9d2fd..be519ded88e 100644 --- a/source/blender/python/mathutils/mathutils_Matrix.c +++ b/source/blender/python/mathutils/mathutils_Matrix.c @@ -995,7 +995,7 @@ static PyObject *Matrix_to_euler(MatrixObject *self, PyObject *args) if (eul_compat) { if (order == 1) mat3_to_compatible_eul(eul, eul_compatf, mat); - else mat3_to_compatible_eulO(eul, eul_compatf, order, mat); + else mat3_to_compatible_eulO(eul, eul_compatf, order, mat); } else { if (order == 1) mat3_to_eul(eul, mat); From a7ec09aef91d41a8a1fa5ca531cae5bbbbcde161 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 25 Aug 2012 14:07:51 +0000 Subject: [PATCH 127/163] ability to register your own online manual callbacks - useful for 3rd party addon developers, who may want to link to their own URL's. --- release/scripts/modules/bpy/utils.py | 39 +++++++++++++++++++++- release/scripts/startup/bl_operators/wm.py | 30 ++++++++--------- 2 files changed, 52 insertions(+), 17 deletions(-) diff --git a/release/scripts/modules/bpy/utils.py b/release/scripts/modules/bpy/utils.py index 09deb33c174..ef2c151dad2 100644 --- a/release/scripts/modules/bpy/utils.py +++ b/release/scripts/modules/bpy/utils.py @@ -33,6 +33,7 @@ __all__ = ( "refresh_script_paths", "register_class", "register_module", + "register_manual_map", "resource_path", "script_path_user", "script_path_pref", @@ -56,7 +57,6 @@ import addon_utils as _addon_utils _script_module_dirs = "startup", "modules" - def _test_import(module_name, loaded_modules): use_time = _bpy.app.debug_python @@ -595,3 +595,40 @@ def unregister_module(module, verbose=False): traceback.print_exc() if verbose: print("done.\n") + + +# ----------------------------------------------------------------------------- +# Manual lookups, each function has to return a basepath and a sequence +# of... + +# we start with the built-in default mapping +def _blender_default_map(): + import sys + import rna_wiki_reference as ref_mod + ret = (ref_mod.url_manual_prefix, ref_mod.url_manual_mapping) + # avoid storing in memory + del sys.modules["rna_wiki_reference"] + return ret + +# hooks for doc lookups +_manual_map = [_blender_default_map] + +def register_manual_map(manual_hook): + _manual_map.append(manual_hook) + +def unregister_manual_map(manual_hook): + _manual_map.remove(manual_hook) + +def manual_map(): + # reverse so default is called last + for cb in reversed(_manual_map): + try: + prefix, url_manual_mapping = cb() + except: + print("Error calling %r" % cb) + import traceback + traceback.print_exc() + continue + + yield prefix, url_manual_mapping + diff --git a/release/scripts/startup/bl_operators/wm.py b/release/scripts/startup/bl_operators/wm.py index b34c427c4a1..ed4d5dd55f5 100644 --- a/release/scripts/startup/bl_operators/wm.py +++ b/release/scripts/startup/bl_operators/wm.py @@ -862,26 +862,24 @@ class WM_OT_doc_view_manual(Operator): if rna_id is None: return {'PASS_THROUGH'} - import rna_wiki_reference - rna_ref = self._find_reference(rna_id, rna_wiki_reference.url_manual_mapping) + url = None - if rna_ref is None: - self.report({'WARNING'}, "No reference available '%s', " - "Update info in %r" % - (self.doc_id, rna_wiki_reference.__file__)) + for prefix, url_manual_mapping in bpy.utils.manual_map(): + rna_ref = self._find_reference(rna_id, url_manual_mapping) + if rna_ref is not None: + url = prefix + rna_ref + break - import sys - del sys.modules["rna_wiki_reference"] - - if rna_ref is None: + if url is None: + self.report({'WARNING'}, "No reference available %r, " + "Update info in 'rna_wiki_reference.py' " + " or callback to bpy.utils.manual_map()" % + self.doc_id) return {'CANCELLED'} else: - url = rna_wiki_reference.url_manual_prefix + rna_ref - - import webbrowser - webbrowser.open(url) - - return {'FINISHED'} + import webbrowser + webbrowser.open(url) + return {'FINISHED'} class WM_OT_doc_view(Operator): From 6b1582c012a93aa8497b4d8a087500bcb5fbaecc Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 25 Aug 2012 14:18:54 +0000 Subject: [PATCH 128/163] better handle sizes by default for mask mode, now ignore image width/height --- release/scripts/modules/bpy/utils.py | 2 ++ source/blender/editors/mask/mask_add.c | 43 +++++++++----------------- 2 files changed, 16 insertions(+), 29 deletions(-) diff --git a/release/scripts/modules/bpy/utils.py b/release/scripts/modules/bpy/utils.py index ef2c151dad2..e24b61a757d 100644 --- a/release/scripts/modules/bpy/utils.py +++ b/release/scripts/modules/bpy/utils.py @@ -34,6 +34,8 @@ __all__ = ( "register_class", "register_module", "register_manual_map", + "unregister_manual_map", + "manual_map", "resource_path", "script_path_user", "script_path_pref", diff --git a/source/blender/editors/mask/mask_add.c b/source/blender/editors/mask/mask_add.c index d2a5e80fc24..b37f758596b 100644 --- a/source/blender/editors/mask/mask_add.c +++ b/source/blender/editors/mask/mask_add.c @@ -180,25 +180,20 @@ static int find_nearest_diff_point(const bContext *C, Mask *mask, const float no /******************** add vertex *********************/ -static void setup_vertex_point(const bContext *C, Mask *mask, MaskSpline *spline, MaskSplinePoint *new_point, +static void setup_vertex_point(Mask *mask, MaskSpline *spline, MaskSplinePoint *new_point, const float point_co[2], const float tangent[2], const float u, MaskSplinePoint *reference_point, const short reference_adjacent, const float view_zoom) { - ScrArea *sa = CTX_wm_area(C); - MaskSplinePoint *prev_point = NULL; MaskSplinePoint *next_point = NULL; BezTriple *bezt; - int width, height; float co[3]; - const float len = 20.0; /* default length of handle in pixel space */ + const float len = 10.0; /* default length of handle in pixel space */ copy_v2_v2(co, point_co); co[2] = 0.0f; - ED_mask_get_size(sa, &width, &height); - /* point coordinate */ bezt = &new_point->bezt; @@ -226,21 +221,15 @@ static void setup_vertex_point(const bContext *C, Mask *mask, MaskSpline *spline /* initial offset for handles */ if (spline->tot_point == 1) { /* first point of splien is aligned horizontally */ - bezt->vec[0][0] -= len / maxi(width, height) * view_zoom; - bezt->vec[2][0] += len / maxi(width, height) * view_zoom; + bezt->vec[0][0] -= len * view_zoom; + bezt->vec[2][0] += len * view_zoom; } else if (tangent) { float vec[2]; copy_v2_v2(vec, tangent); - vec[0] *= width; - vec[1] *= height; - - mul_v2_fl(vec, len / len_v2(vec)); - - vec[0] /= width; - vec[1] /= height; + mul_v2_fl(vec, len); sub_v2_v2(bezt->vec[0], vec); add_v2_v2(bezt->vec[2], vec); @@ -392,7 +381,7 @@ static int add_vertex_subdivide(const bContext *C, Mask *mask, const float co[2] new_point = &spline->points[point_index + 1]; - setup_vertex_point(C, mask, spline, new_point, co, tangent, u, NULL, TRUE, 1.0f); + setup_vertex_point(mask, spline, new_point, co, tangent, u, NULL, TRUE, 1.0f); /* TODO - we could pass the spline! */ BKE_mask_layer_shape_changed_add(masklay, BKE_mask_layer_shape_spline_to_index(masklay, spline) + point_index + 1, TRUE, TRUE); @@ -491,7 +480,7 @@ static int add_vertex_extrude(const bContext *C, Mask *mask, MaskLayer *masklay, masklay->act_point = new_point; - setup_vertex_point(C, mask, spline, new_point, co, NULL, 0.5f, ref_point, FALSE, 1.0f); + setup_vertex_point(mask, spline, new_point, co, NULL, 0.5f, ref_point, FALSE, 1.0f); if (masklay->splines_shapes.first) { point_index = (((int)(new_point - spline->points) + 0) % spline->tot_point); @@ -542,22 +531,18 @@ static int add_vertex_new(const bContext *C, Mask *mask, MaskLayer *masklay, con ScrArea *sa = CTX_wm_area(C); ARegion *ar = CTX_wm_region(C); + float zoom_x, zoom_y; /* calc view zoom in a simplistic way */ - float co_a[2]; - float co_b[2]; - int mval_a[2] = {0, 0}; - int mval_b[2] = {1, 1}; + ED_mask_zoom(sa, ar, &zoom_x, &zoom_y); - ED_mask_mouse_pos(sa, ar, mval_a, co_a); - ED_mask_mouse_pos(sa, ar, mval_b, co_b); + view_zoom = zoom_x + zoom_y / 2.0f; + view_zoom = 1.0f / view_zoom; - view_zoom = ((co_b[0] - co_a[0]) + (co_b[1] - co_a[1])) / 2.0f; - - /* scale up - arbitrarty but works well in the view */ - view_zoom *= 200.0f; + /* arbitrary but gives good results */ + view_zoom /= 500.0f; } - setup_vertex_point(C, mask, spline, new_point, co, NULL, 0.5f, ref_point, FALSE, view_zoom); + setup_vertex_point(mask, spline, new_point, co, NULL, 0.5f, ref_point, FALSE, view_zoom); { int point_index = (((int)(new_point - spline->points) + 0) % spline->tot_point); From d5fdec6619becffac9c903aba335dd6f47b2c103 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 25 Aug 2012 15:00:41 +0000 Subject: [PATCH 129/163] add manual lookup to addon tempalte --- release/scripts/templates/addon_add_object.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/release/scripts/templates/addon_add_object.py b/release/scripts/templates/addon_add_object.py index a2d7315af4b..d7fc23f9242 100644 --- a/release/scripts/templates/addon_add_object.py +++ b/release/scripts/templates/addon_add_object.py @@ -68,13 +68,23 @@ def add_object_button(self, context): icon='PLUGIN') +# This allows you to right click on a button and link to the manual +def add_object_manual_map(): + url_manual_prefix = "http://wiki.blender.org/index.php/Doc:2.6/Manual/" + url_manual_mapping = ( + ("bpy.ops.mesh.add_object", "Modeling/Objects"), + ) + return url_manual_prefix, url_manual_mapping + + def register(): bpy.utils.register_class(OBJECT_OT_add_object) + bpy.utils.register_manual_map(add_object_manual_map) bpy.types.INFO_MT_mesh_add.append(add_object_button) - def unregister(): bpy.utils.unregister_class(OBJECT_OT_add_object) + bpy.utils.unregister_manual_map(add_object_manual_map) bpy.types.INFO_MT_mesh_add.remove(add_object_button) From 32e4e0f8737d3441e621b7da4640a6041fa69c01 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 25 Aug 2012 17:42:15 +0000 Subject: [PATCH 130/163] add conjugate_qt_qt(), also some code cleanup and use const for 'rotOrders' var in math_rotation.c --- source/blender/blenlib/BLI_math_rotation.h | 1 + source/blender/blenlib/intern/math_rotation.c | 48 ++++++++++--------- source/blender/bmesh/intern/bmesh_mods.c | 2 +- .../editors/space_view3d/view3d_edit.c | 3 +- 4 files changed, 28 insertions(+), 26 deletions(-) diff --git a/source/blender/blenlib/BLI_math_rotation.h b/source/blender/blenlib/BLI_math_rotation.h index 64a6a6ec7d5..8a439c7cf7a 100644 --- a/source/blender/blenlib/BLI_math_rotation.h +++ b/source/blender/blenlib/BLI_math_rotation.h @@ -60,6 +60,7 @@ void sub_qt_qtqt(float q[4], const float a[4], const float b[4]); void invert_qt(float q[4]); void invert_qt_qt(float q1[4], const float q2[4]); void conjugate_qt(float q[4]); +void conjugate_qt_qt(float q1[4], const float q2[4]); float dot_qtqt(const float a[4], const float b[4]); float normalize_qt(float q[4]); float normalize_qt_qt(float q1[4], const float q2[4]); diff --git a/source/blender/blenlib/intern/math_rotation.c b/source/blender/blenlib/intern/math_rotation.c index 64fbfbf8a7d..91aad259918 100644 --- a/source/blender/blenlib/intern/math_rotation.c +++ b/source/blender/blenlib/intern/math_rotation.c @@ -34,7 +34,7 @@ /******************************** Quaternions ********************************/ -/* used to test is a quat is not normalized */ +/* used to test is a quat is not normalized (only used for debug prints) */ #define QUAT_EPSILON 0.0001 /* convenience, avoids setting Y axis everywhere */ @@ -113,6 +113,14 @@ void mul_qt_v3(const float q[4], float v[3]) v[1] = t2; } +void conjugate_qt_qt(float q1[4], const float q2[4]) +{ + q1[0] = q2[0]; + q1[1] = -q2[1]; + q1[2] = -q2[2]; + q1[3] = -q2[3]; +} + void conjugate_qt(float q[4]) { q[1] = -q[1]; @@ -370,7 +378,7 @@ float normalize_qt(float q[4]) { float len; - len = (float)sqrt(dot_qtqt(q, q)); + len = sqrtf(dot_qtqt(q, q)); if (len != 0.0f) { mul_qt_fl(q, 1.0f / len); } @@ -404,15 +412,10 @@ void rotation_between_vecs_to_quat(float q[4], const float v1[3], const float v2 void rotation_between_quats_to_quat(float q[4], const float q1[4], const float q2[4]) { float tquat[4]; - double dot = 0.0f; - int x; - copy_qt_qt(tquat, q1); - conjugate_qt(tquat); - dot = 1.0f / dot_qtqt(tquat, tquat); + conjugate_qt_qt(tquat, q1); - for (x = 0; x < 4; x++) - tquat[x] *= dot; + mul_qt_fl(tquat, 1.0f / dot_qtqt(tquat, tquat)); mul_qt_qtqt(q, tquat, q2); } @@ -1128,7 +1131,7 @@ typedef struct RotOrderInfo { /* Array of info for Rotation Order calculations * WARNING: must be kept in same order as eEulerRotationOrders */ -static RotOrderInfo rotOrders[] = { +static const RotOrderInfo rotOrders[] = { /* i, j, k, n */ {{0, 1, 2}, 0}, /* XYZ */ {{0, 2, 1}, 1}, /* XZY */ @@ -1147,7 +1150,7 @@ static RotOrderInfo rotOrders[] = { /* Construct quaternion from Euler angles (in radians). */ void eulO_to_quat(float q[4], const float e[3], const short order) { - RotOrderInfo *R = GET_ROTATIONORDER_INFO(order); + const RotOrderInfo *R = GET_ROTATIONORDER_INFO(order); short i = R->axis[0], j = R->axis[1], k = R->axis[2]; double ti, tj, th, ci, cj, ch, si, sj, sh, cc, cs, sc, ss; double a[3]; @@ -1192,7 +1195,7 @@ void quat_to_eulO(float e[3], short const order, const float q[4]) /* Construct 3x3 matrix from Euler angles (in radians). */ void eulO_to_mat3(float M[3][3], const float e[3], const short order) { - RotOrderInfo *R = GET_ROTATIONORDER_INFO(order); + const RotOrderInfo *R = GET_ROTATIONORDER_INFO(order); short i = R->axis[0], j = R->axis[1], k = R->axis[2]; double ti, tj, th, ci, cj, ch, si, sj, sh, cc, cs, sc, ss; @@ -1233,7 +1236,7 @@ void eulO_to_mat3(float M[3][3], const float e[3], const short order) /* returns two euler calculation methods, so we can pick the best */ static void mat3_to_eulo2(float M[3][3], float *e1, float *e2, const short order) { - RotOrderInfo *R = GET_ROTATIONORDER_INFO(order); + const RotOrderInfo *R = GET_ROTATIONORDER_INFO(order); short i = R->axis[0], j = R->axis[1], k = R->axis[2]; float m[3][3]; double cy; @@ -1368,7 +1371,7 @@ void rotate_eulO(float beul[3], const short order, char axis, float ang) /* the matrix is written to as 3 axis vectors */ void eulO_to_gimbal_axis(float gmat[][3], const float eul[3], const short order) { - RotOrderInfo *R = GET_ROTATIONORDER_INFO(order); + const RotOrderInfo *R = GET_ROTATIONORDER_INFO(order); float mat[3][3]; float teul[3]; @@ -1436,10 +1439,9 @@ void mat4_to_dquat(DualQuat *dq, float basemat[][4], float mat[][4]) mult_m4_m4m4(baseRS, mat, basemat); mat4_to_size(scale, baseRS); - copy_v3_v3(dscale, scale); - dscale[0] -= 1.0f; - dscale[1] -= 1.0f; - dscale[2] -= 1.0f; + dscale[0] = scale[0] - 1.0f; + dscale[1] = scale[1] - 1.0f; + dscale[2] = scale[2] - 1.0f; if ((determinant_m4(mat) < 0.0f) || len_v3(dscale) > 1e-4f) { /* extract R and S */ @@ -1475,10 +1477,10 @@ void mat4_to_dquat(DualQuat *dq, float basemat[][4], float mat[][4]) /* dual part */ t = R[3]; q = dq->quat; - dq->trans[0] = -0.5f * (t[0] * q[1] + t[1] * q[2] + t[2] * q[3]); - dq->trans[1] = 0.5f * (t[0] * q[0] + t[1] * q[3] - t[2] * q[2]); - dq->trans[2] = 0.5f * (-t[0] * q[3] + t[1] * q[0] + t[2] * q[1]); - dq->trans[3] = 0.5f * (t[0] * q[2] - t[1] * q[1] + t[2] * q[0]); + dq->trans[0] = -0.5f * ( t[0] * q[1] + t[1] * q[2] + t[2] * q[3]); + dq->trans[1] = 0.5f * ( t[0] * q[0] + t[1] * q[3] - t[2] * q[2]); + dq->trans[2] = 0.5f * (-t[0] * q[3] + t[1] * q[0] + t[2] * q[1]); + dq->trans[3] = 0.5f * ( t[0] * q[2] - t[1] * q[1] + t[2] * q[0]); } void dquat_to_mat4(float mat[][4], DualQuat *dq) @@ -1489,7 +1491,7 @@ void dquat_to_mat4(float mat[][4], DualQuat *dq) copy_qt_qt(q0, dq->quat); /* normalize */ - len = (float)sqrt(dot_qtqt(q0, q0)); + len = sqrtf(dot_qtqt(q0, q0)); if (len != 0.0f) mul_qt_fl(q0, 1.0f / len); diff --git a/source/blender/bmesh/intern/bmesh_mods.c b/source/blender/bmesh/intern/bmesh_mods.c index fc270c61113..73e2d83520c 100644 --- a/source/blender/bmesh/intern/bmesh_mods.c +++ b/source/blender/bmesh/intern/bmesh_mods.c @@ -174,7 +174,7 @@ int BM_disk_dissolve(BMesh *bm, BMVert *v) f = BM_faces_join_pair(bm, e->l->f, e->l->radial_next->f, e, TRUE); /* return if couldn't join faces in manifold * conditions */ - //!disabled for testing why bad things happen + /* !disabled for testing why bad things happen */ if (!f) { return FALSE; } diff --git a/source/blender/editors/space_view3d/view3d_edit.c b/source/blender/editors/space_view3d/view3d_edit.c index db47f88c8f2..e74bda87a43 100644 --- a/source/blender/editors/space_view3d/view3d_edit.c +++ b/source/blender/editors/space_view3d/view3d_edit.c @@ -662,8 +662,7 @@ static void viewrotate_apply(ViewOpsData *vod, int x, int y) if (vod->use_dyn_ofs) { /* compute the post multiplication quat, to rotate the offset correctly */ - copy_qt_qt(q1, vod->oldquat); - conjugate_qt(q1); + conjugate_qt_qt(q1, vod->oldquat); mul_qt_qtqt(q1, q1, vod->viewquat); conjugate_qt(q1); /* conj == inv for unit quat */ From 7caff79a1a029312a7788239007c915ae0daa66a Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 25 Aug 2012 17:58:49 +0000 Subject: [PATCH 131/163] code cleanup: vec_to_quat --- source/blender/blenlib/intern/math_rotation.c | 90 ++++++++++--------- 1 file changed, 46 insertions(+), 44 deletions(-) diff --git a/source/blender/blenlib/intern/math_rotation.c b/source/blender/blenlib/intern/math_rotation.c index 91aad259918..f0ed23aabc9 100644 --- a/source/blender/blenlib/intern/math_rotation.c +++ b/source/blender/blenlib/intern/math_rotation.c @@ -422,65 +422,65 @@ void rotation_between_quats_to_quat(float q[4], const float q1[4], const float q void vec_to_quat(float q[4], const float vec[3], short axis, const short upflag) { - float q2[4], nor[3], *fp, mat[3][3], angle, si, co, x2, y2, z2, len1; + float nor[3], tvec[3]; + float angle, si, co, len; assert(axis >= 0 && axis <= 5); assert(upflag >= 0 && upflag <= 2); - /* first rotate to axis */ + /* first set the quat to unit */ + unit_qt(q); + + len = len_v3(vec); + + if (UNLIKELY(len == 0.0f)) { + return; + } + + /* rotate to axis */ if (axis > 2) { - x2 = vec[0]; - y2 = vec[1]; - z2 = vec[2]; + copy_v3_v3(tvec, vec); axis -= 3; } else { - x2 = -vec[0]; - y2 = -vec[1]; - z2 = -vec[2]; + negate_v3_v3(tvec, vec); } - q[0] = 1.0; - q[1] = q[2] = q[3] = 0.0; - - len1 = (float)sqrt(x2 * x2 + y2 * y2 + z2 * z2); - if (len1 == 0.0f) return; - /* nasty! I need a good routine for this... * problem is a rotation of an Y axis to the negative Y-axis for example. */ if (axis == 0) { /* x-axis */ - nor[0] = 0.0; - nor[1] = -z2; - nor[2] = y2; + nor[0] = 0.0; + nor[1] = -tvec[2]; + nor[2] = tvec[1]; - if (fabsf(y2) + fabsf(z2) < 0.0001f) - nor[1] = 1.0; + if (fabsf(tvec[1]) + fabsf(tvec[2]) < 0.0001f) + nor[1] = 1.0f; - co = x2; + co = tvec[0]; } else if (axis == 1) { /* y-axis */ - nor[0] = z2; - nor[1] = 0.0; - nor[2] = -x2; + nor[0] = tvec[2]; + nor[1] = 0.0; + nor[2] = -tvec[0]; - if (fabsf(x2) + fabsf(z2) < 0.0001f) - nor[2] = 1.0; + if (fabsf(tvec[0]) + fabsf(tvec[2]) < 0.0001f) + nor[2] = 1.0f; - co = y2; + co = tvec[1]; } else { /* z-axis */ - nor[0] = -y2; - nor[1] = x2; - nor[2] = 0.0; + nor[0] = -tvec[1]; + nor[1] = tvec[0]; + nor[2] = 0.0; - if (fabsf(x2) + fabsf(y2) < 0.0001f) - nor[0] = 1.0; + if (fabsf(tvec[0]) + fabsf(tvec[1]) < 0.0001f) + nor[0] = 1.0f; - co = z2; + co = tvec[2]; } - co /= len1; + co /= len; normalize_v3(nor); @@ -492,28 +492,30 @@ void vec_to_quat(float q[4], const float vec[3], short axis, const short upflag) q[3] = nor[2] * si; if (axis != upflag) { + float mat[3][3]; + float q2[4]; + const float *fp = mat[2]; quat_to_mat3(mat, q); - fp = mat[2]; if (axis == 0) { - if (upflag == 1) angle = (float)(0.5 * atan2(fp[2], fp[1])); - else angle = (float)(-0.5 * atan2(fp[1], fp[2])); + if (upflag == 1) angle = 0.5f * atan2f(fp[2], fp[1]); + else angle = -0.5f * atan2f(fp[1], fp[2]); } else if (axis == 1) { - if (upflag == 0) angle = (float)(-0.5 * atan2(fp[2], fp[0])); - else angle = (float)(0.5 * atan2(fp[0], fp[2])); + if (upflag == 0) angle = -0.5f * atan2f(fp[2], fp[0]); + else angle = 0.5f * atan2f(fp[0], fp[2]); } else { - if (upflag == 0) angle = (float)(0.5 * atan2(-fp[1], -fp[0])); - else angle = (float)(-0.5 * atan2(-fp[0], -fp[1])); + if (upflag == 0) angle = 0.5f * atan2f(-fp[1], -fp[0]); + else angle = -0.5f * atan2f(-fp[0], -fp[1]); } co = cosf(angle); - si = sinf(angle) / len1; + si = sinf(angle) / len; q2[0] = co; - q2[1] = x2 * si; - q2[2] = y2 * si; - q2[3] = z2 * si; + q2[1] = tvec[0] * si; + q2[2] = tvec[1] * si; + q2[3] = tvec[2] * si; mul_qt_qtqt(q, q2, q); } From 699b23ecdbaa98c78c9a0685253c3a0ee354f194 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 25 Aug 2012 19:43:15 +0000 Subject: [PATCH 132/163] fix for type mismatch with SWAP() macro. --- source/blender/blenkernel/intern/curve.c | 4 ++-- source/blender/blenkernel/intern/mesh.c | 12 +++++----- source/blender/blenkernel/intern/sequencer.c | 4 ++-- source/blender/editors/curve/editcurve.c | 2 +- .../editors/sculpt_paint/paint_image.c | 24 +++++++++++-------- 5 files changed, 25 insertions(+), 21 deletions(-) diff --git a/source/blender/blenkernel/intern/curve.c b/source/blender/blenkernel/intern/curve.c index d2b8ec2cc02..664172f2851 100644 --- a/source/blender/blenkernel/intern/curve.c +++ b/source/blender/blenkernel/intern/curve.c @@ -3094,11 +3094,11 @@ void BKE_nurb_direction_switch(Nurb *nu) swapdata(bezt2->vec[0], bezt2->vec[2], 12); SWAP(char, bezt1->h1, bezt1->h2); - SWAP(short, bezt1->f1, bezt1->f3); + SWAP(char, bezt1->f1, bezt1->f3); if (bezt1 != bezt2) { SWAP(char, bezt2->h1, bezt2->h2); - SWAP(short, bezt2->f1, bezt2->f3); + SWAP(char, bezt2->f1, bezt2->f3); bezt1->alfa = -bezt1->alfa; bezt2->alfa = -bezt2->alfa; } diff --git a/source/blender/blenkernel/intern/mesh.c b/source/blender/blenkernel/intern/mesh.c index f5ae3c7da2b..8c3ec7e2e40 100644 --- a/source/blender/blenkernel/intern/mesh.c +++ b/source/blender/blenkernel/intern/mesh.c @@ -2702,13 +2702,13 @@ int BKE_mesh_recalc_tessellation(CustomData *fdata, #endif { /* sort loop indices to ensure winding is correct */ - if (mf->v1 > mf->v2) SWAP(int, mf->v1, mf->v2); - if (mf->v2 > mf->v3) SWAP(int, mf->v2, mf->v3); - if (mf->v1 > mf->v2) SWAP(int, mf->v1, mf->v2); + if (mf->v1 > mf->v2) SWAP(unsigned int, mf->v1, mf->v2); + if (mf->v2 > mf->v3) SWAP(unsigned int, mf->v2, mf->v3); + if (mf->v1 > mf->v2) SWAP(unsigned int, mf->v1, mf->v2); - if (mf->v1 > mf->v2) SWAP(int, mf->v1, mf->v2); - if (mf->v2 > mf->v3) SWAP(int, mf->v2, mf->v3); - if (mf->v1 > mf->v2) SWAP(int, mf->v1, mf->v2); + if (mf->v1 > mf->v2) SWAP(unsigned int, mf->v1, mf->v2); + if (mf->v2 > mf->v3) SWAP(unsigned int, mf->v2, mf->v3); + if (mf->v1 > mf->v2) SWAP(unsigned int, mf->v1, mf->v2); } /* end abusing the edcode */ diff --git a/source/blender/blenkernel/intern/sequencer.c b/source/blender/blenkernel/intern/sequencer.c index 17764fa9775..3bcef50a3b4 100644 --- a/source/blender/blenkernel/intern/sequencer.c +++ b/source/blender/blenkernel/intern/sequencer.c @@ -3627,8 +3627,8 @@ int BKE_sequence_swap(Sequence *seq_a, Sequence *seq_b, const char **error_str) SWAP(float, seq_a->blend_opacity, seq_b->blend_opacity); - SWAP(void *, seq_a->prev, seq_b->prev); - SWAP(void *, seq_a->next, seq_b->next); + SWAP(Sequence *, seq_a->prev, seq_b->prev); + SWAP(Sequence *, seq_a->next, seq_b->next); SWAP(int, seq_a->start, seq_b->start); SWAP(int, seq_a->startofs, seq_b->startofs); SWAP(int, seq_a->endofs, seq_b->endofs); diff --git a/source/blender/editors/curve/editcurve.c b/source/blender/editors/curve/editcurve.c index bc154de9691..e2d15897233 100644 --- a/source/blender/editors/curve/editcurve.c +++ b/source/blender/editors/curve/editcurve.c @@ -1938,7 +1938,7 @@ static void adduplicateflagNurb(Object *obedit, short flag) } else { - if (newu == 1) SWAP(short, newu, newv); + if (newu == 1) SWAP(int, newu, newv); newnu = (Nurb *)MEM_mallocN(sizeof(Nurb), "adduplicateN5"); memcpy(newnu, nu, sizeof(Nurb)); diff --git a/source/blender/editors/sculpt_paint/paint_image.c b/source/blender/editors/sculpt_paint/paint_image.c index d916ee299b6..953215b83aa 100644 --- a/source/blender/editors/sculpt_paint/paint_image.c +++ b/source/blender/editors/sculpt_paint/paint_image.c @@ -388,7 +388,11 @@ typedef struct UndoImageTile { char idname[MAX_ID_NAME]; /* name instead of pointer*/ char ibufname[IB_FILENAME_SIZE]; - void *rect; + union { + float *fp; + unsigned int *uint; + void *pt; + } rect; int x, y; short source, use_float; @@ -406,10 +410,10 @@ static void undo_copy_tile(UndoImageTile *tile, ImBuf *tmpibuf, ImBuf *ibuf, int tile->y * IMAPAINT_TILE_SIZE, IMAPAINT_TILE_SIZE, IMAPAINT_TILE_SIZE); if (ibuf->rect_float) { - SWAP(void *, tmpibuf->rect_float, tile->rect); + SWAP(float *, tmpibuf->rect_float, tile->rect.fp); } else { - SWAP(void *, tmpibuf->rect, tile->rect); + SWAP(unsigned int *, tmpibuf->rect, tile->rect.uint); } if (restore) @@ -428,7 +432,7 @@ static void *image_undo_push_tile(Image *ima, ImBuf *ibuf, ImBuf **tmpibuf, int if (tile->x == x_tile && tile->y == y_tile && ima->gen_type == tile->gen_type && ima->source == tile->source) if (tile->use_float == use_float) if (strcmp(tile->idname, ima->id.name) == 0 && strcmp(tile->ibufname, ibuf->name) == 0) - return tile->rect; + return tile->rect.pt; if (*tmpibuf == NULL) *tmpibuf = IMB_allocImBuf(IMAPAINT_TILE_SIZE, IMAPAINT_TILE_SIZE, 32, IB_rectfloat | IB_rect); @@ -440,7 +444,7 @@ static void *image_undo_push_tile(Image *ima, ImBuf *ibuf, ImBuf **tmpibuf, int allocsize = IMAPAINT_TILE_SIZE * IMAPAINT_TILE_SIZE * 4; allocsize *= (ibuf->rect_float) ? sizeof(float) : sizeof(char); - tile->rect = MEM_mapallocN(allocsize, "UndeImageTile.rect"); + tile->rect.pt = MEM_mapallocN(allocsize, "UndeImageTile.rect"); BLI_strncpy(tile->ibufname, ibuf->name, sizeof(tile->ibufname)); @@ -453,7 +457,7 @@ static void *image_undo_push_tile(Image *ima, ImBuf *ibuf, ImBuf **tmpibuf, int BLI_addtail(lb, tile); - return tile->rect; + return tile->rect.pt; } static void image_undo_restore(bContext *C, ListBase *lb) @@ -517,7 +521,7 @@ static void image_undo_free(ListBase *lb) UndoImageTile *tile; for (tile = lb->first; tile; tile = tile->next) - MEM_freeN(tile->rect); + MEM_freeN(tile->rect.pt); } /* get active image for face depending on old/new shading system */ @@ -4545,15 +4549,15 @@ static int imapaint_canvas_set(ImagePaintState *s, Image *ima) /* temporarily add float rect for cloning */ if (s->canvas->rect_float && !s->clonecanvas->rect_float) { - int profile = IB_PROFILE_NONE; + short profile = IB_PROFILE_NONE; /* Don't want to color manage, but don't disturb existing profiles */ - SWAP(int, s->clonecanvas->profile, profile); + SWAP(short, s->clonecanvas->profile, profile); IMB_float_from_rect(s->clonecanvas); s->clonefreefloat = 1; - SWAP(int, s->clonecanvas->profile, profile); + SWAP(short, s->clonecanvas->profile, profile); } else if (!s->canvas->rect_float && !s->clonecanvas->rect) IMB_rect_from_float(s->clonecanvas); From a3c4b0f47d1a74fe228f3329de01f774a5e6b65f Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 25 Aug 2012 20:16:08 +0000 Subject: [PATCH 133/163] make SWAP macros typesafe using CHECK_TYPE macro. Its unlikely you want to do short -> int, int -> float etc, conversion during swapping (if its needed we could have a non type checking macro). Double that the optimized assembler outbut using SWAP() remains unchanged from before. This exposed quite a few places where redundant type conversion was going on. Also remove curve.c's swapdata() and replace its use with swap_v3_v3() --- source/blender/blenkernel/intern/curve.c | 38 ++++++--------------- source/blender/blenlib/BLI_math_base.h | 24 ++++++++++++- source/blender/blenlib/BLI_utildefines.h | 24 ++++++++++++- source/blender/makesrna/intern/rna_object.c | 2 +- 4 files changed, 57 insertions(+), 31 deletions(-) diff --git a/source/blender/blenkernel/intern/curve.c b/source/blender/blenkernel/intern/curve.c index 664172f2851..a2f88781cbb 100644 --- a/source/blender/blenkernel/intern/curve.c +++ b/source/blender/blenkernel/intern/curve.c @@ -3047,29 +3047,6 @@ void BKE_nurbList_handles_set(ListBase *editnurb, short code) } } -static void swapdata(void *adr1, void *adr2, int len) -{ - - if (len <= 0) return; - - if (len < 65) { - char adr[64]; - - memcpy(adr, adr1, len); - memcpy(adr1, adr2, len); - memcpy(adr2, adr, len); - } - else { - char *adr; - - adr = (char *)MEM_mallocN(len, "curve swap"); - memcpy(adr, adr1, len); - memcpy(adr1, adr2, len); - memcpy(adr2, adr, len); - MEM_freeN(adr); - } -} - void BKE_nurb_direction_switch(Nurb *nu) { BezTriple *bezt1, *bezt2; @@ -3077,7 +3054,9 @@ void BKE_nurb_direction_switch(Nurb *nu) float *fp1, *fp2, *tempf; int a, b; - if (nu->pntsu == 1 && nu->pntsv == 1) return; + if (nu->pntsu == 1 && nu->pntsv == 1) { + return; + } if (nu->type == CU_BEZIER) { a = nu->pntsu; @@ -3086,12 +3065,15 @@ void BKE_nurb_direction_switch(Nurb *nu) if (a & 1) a += 1; /* if odd, also swap middle content */ a /= 2; while (a > 0) { - if (bezt1 != bezt2) + if (bezt1 != bezt2) { SWAP(BezTriple, *bezt1, *bezt2); + } - swapdata(bezt1->vec[0], bezt1->vec[2], 12); - if (bezt1 != bezt2) - swapdata(bezt2->vec[0], bezt2->vec[2], 12); + swap_v3_v3(bezt1->vec[0], bezt1->vec[2]); + + if (bezt1 != bezt2) { + swap_v3_v3(bezt2->vec[0], bezt2->vec[2]); + } SWAP(char, bezt1->h1, bezt1->h2); SWAP(char, bezt1->f1, bezt1->f3); diff --git a/source/blender/blenlib/BLI_math_base.h b/source/blender/blenlib/BLI_math_base.h index b0e0d3cbf19..4a89776a52e 100644 --- a/source/blender/blenlib/BLI_math_base.h +++ b/source/blender/blenlib/BLI_math_base.h @@ -137,8 +137,30 @@ # endif #endif +/* Causes warning: + * incompatible types when assigning to type 'Foo' from type 'Bar' + * ... the compiler optimizes away the temp var */ +#ifndef CHECK_TYPE +#ifdef __GNUC__ +#define CHECK_TYPE(var, type) { \ + __typeof(var) *__tmp; \ + __tmp = (type *)NULL; \ + (void)__tmp; \ +} (void)0 +#else +#define CHECK_TYPE(var, type) +#endif +#endif + #ifndef SWAP -# define SWAP(type, a, b) { type sw_ap; sw_ap = (a); (a) = (b); (b) = sw_ap; } (void)0 +# define SWAP(type, a, b) { \ + type sw_ap; \ + CHECK_TYPE(a, type); \ + CHECK_TYPE(b, type); \ + sw_ap = (a); \ + (a) = (b); \ + (b) = sw_ap; \ +} (void)0 #endif #ifndef CLAMP diff --git a/source/blender/blenlib/BLI_utildefines.h b/source/blender/blenlib/BLI_utildefines.h index 78d54defafd..8a459b9b07c 100644 --- a/source/blender/blenlib/BLI_utildefines.h +++ b/source/blender/blenlib/BLI_utildefines.h @@ -113,8 +113,30 @@ /* some math and copy defines */ +/* Causes warning: + * incompatible types when assigning to type 'Foo' from type 'Bar' + * ... the compiler optimizes away the temp var */ +#ifndef CHECK_TYPE +#ifdef __GNUC__ +#define CHECK_TYPE(var, type) { \ + __typeof(var) *__tmp; \ + __tmp = (type *)NULL; \ + (void)__tmp; \ +} (void)0 +#else +#define CHECK_TYPE(var, type) +#endif +#endif + #ifndef SWAP -# define SWAP(type, a, b) { type sw_ap; sw_ap = (a); (a) = (b); (b) = sw_ap; } (void)0 +# define SWAP(type, a, b) { \ + type sw_ap; \ + CHECK_TYPE(a, type); \ + CHECK_TYPE(b, type); \ + sw_ap = (a); \ + (a) = (b); \ + (b) = sw_ap; \ +} (void)0 #endif #define ABS(a) ( (a) < 0 ? (-(a)) : (a) ) diff --git a/source/blender/makesrna/intern/rna_object.c b/source/blender/makesrna/intern/rna_object.c index 6dd75e94398..e69d313b23b 100644 --- a/source/blender/makesrna/intern/rna_object.c +++ b/source/blender/makesrna/intern/rna_object.c @@ -313,7 +313,7 @@ static void rna_Object_layer_update(Main *bmain, Scene *scene, PointerRNA *ptr) if (!base) return; - SWAP(int, base->lay, ob->lay); + SWAP(unsigned int, base->lay, ob->lay); rna_Object_layer_update__internal(bmain, scene, base, ob); ob->lay = base->lay; From 2ec75c310413434bd6b6c3d8bebe2668c285c2f0 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 25 Aug 2012 20:49:51 +0000 Subject: [PATCH 134/163] code cleanup: comments and some minor edits to interface code. --- source/blender/editors/interface/interface.c | 51 +++++++++++-------- .../editors/interface/interface_handlers.c | 5 +- .../editors/interface/interface_intern.h | 32 ++++++------ .../editors/interface/interface_layout.c | 2 +- 4 files changed, 49 insertions(+), 41 deletions(-) diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c index 37a110ba33b..afbabaaa8d7 100644 --- a/source/blender/editors/interface/interface.c +++ b/source/blender/editors/interface/interface.c @@ -510,18 +510,18 @@ static void ui_draw_links(uiBlock *block) /* Draw the inactive lines (lines with neither button being hovered over). * As we go, remember if we see any active or selected lines. */ - int foundselectline = 0; - int foundactiveline = 0; + int foundselectline = FALSE; + int foundactiveline = FALSE; for (but = block->buttons.first; but; but = but->next) { if (but->type == LINK && but->link) { for (line = but->link->lines.first; line; line = line->next) { if (!(line->from->flag & UI_ACTIVE) && !(line->to->flag & UI_ACTIVE)) ui_draw_linkline(line, 0); else - foundactiveline = 1; + foundactiveline = TRUE; if ((line->from->flag & UI_SELECT) || (line->to->flag & UI_SELECT)) - foundselectline = 1; + foundselectline = TRUE; } } } @@ -680,28 +680,27 @@ int uiButActiveOnly(const bContext *C, uiBlock *block, uiBut *but) { uiBlock *oldblock; uiBut *oldbut; - int activate = 0, found = 0, isactive = 0; + int activate = FALSE, found = FALSE, isactive = FALSE; oldblock = block->oldblock; if (!oldblock) - activate = 1; + activate = TRUE; else { for (oldbut = oldblock->buttons.first; oldbut; oldbut = oldbut->next) { if (ui_but_equals_old(oldbut, but)) { - found = 1; + found = TRUE; if (oldbut->active) - isactive = 1; + isactive = TRUE; break; } } } - if (activate || found == 0) { + if ((activate == TRUE) || (found == FALSE)) { ui_button_activate_do((bContext *)C, CTX_wm_region(C), but); } - else if (found && isactive == 0) { - + else if ((found == TRUE) && (isactive == FALSE)) { BLI_remlink(&block->buttons, but); ui_free_but(C, but); return 0; @@ -911,7 +910,7 @@ void uiEndBlock(const bContext *C, uiBlock *block) if (ot == NULL || WM_operator_poll_context((bContext *)C, ot, but->opcontext) == 0) { but->flag |= UI_BUT_DISABLED; - but->lock = 1; + but->lock = TRUE; } if (but->context) @@ -1067,9 +1066,12 @@ void uiDrawBlock(const bContext *C, uiBlock *block) static void ui_is_but_sel(uiBut *but, double *value) { - short is_push = 0, is_true = 1; + short is_push = 0; /* (0 == UNSELECT), (1 == SELECT), (2 == DO-NOHING) */ + short is_true = TRUE; - if (ELEM3(but->type, TOGN, ICONTOGN, OPTIONN)) is_true = 0; + if (ELEM3(but->type, TOGN, ICONTOGN, OPTIONN)) { + is_true = FALSE; + } if (but->bit) { int lvalue; @@ -1198,14 +1200,14 @@ void uiComposeLinks(uiBlock *block) void uiBlockSetButLock(uiBlock *block, int val, const char *lockstr) { if (val) { - block->lock = val ? 1 : 0; + block->lock = val ? TRUE : FALSE; block->lockstr = lockstr; } } void uiBlockClearButLock(uiBlock *block) { - block->lock = 0; + block->lock = FALSE; block->lockstr = NULL; } @@ -1515,10 +1517,15 @@ void ui_set_but_val(uiBut *but, double value) if (but->pointype == CHA) value = (char)floor(value + 0.5); else if (but->pointype == SHO) { - /* gcc 3.2.1 seems to have problems + /* gcc 3.2.1 seems to have problems * casting a double like 32772.0 to - * a short so we cast to an int, then - * to a short */ + * a short so we cast to an int, then + * to a short. + * + * Update: even in gcc.4.6 using intermediate int cast gives -32764, + * where as a direct cast from double to short gives -32768, + * if this difference isn't important we could remove this hack, + * since we dont support gcc3 anymore - Campbell */ int gcckludge; gcckludge = (int) floor(value + 0.5); value = (short)gcckludge; @@ -2625,7 +2632,7 @@ static uiBut *ui_def_but(uiBlock *block, int type, int retval, const char *str, but->flag |= (block->flag & UI_BUT_ALIGN); - if (but->lock) { + if (but->lock == TRUE) { if (but->lockstr) { but->flag |= UI_BUT_DISABLED; } @@ -2855,7 +2862,7 @@ static uiBut *ui_def_but_operator_ptr(uiBlock *block, int type, wmOperatorType * if (!ot) { but->flag |= UI_BUT_DISABLED; - but->lock = 1; + but->lock = TRUE; but->lockstr = ""; } @@ -2894,7 +2901,7 @@ static uiBut *ui_def_but_operator_text(uiBlock *block, int type, const char *opn if (!ot) { but->flag |= UI_BUT_DISABLED; - but->lock = 1; + but->lock = TRUE; but->lockstr = ""; } diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c index 9227ad158fd..ca52daa8cd2 100644 --- a/source/blender/editors/interface/interface_handlers.c +++ b/source/blender/editors/interface/interface_handlers.c @@ -1140,8 +1140,9 @@ static void ui_but_copy_paste(bContext *C, uiBut *but, uiHandleButtonData *data, static ColorBand but_copypaste_coba = {0}; char buf[UI_MAX_DRAW_STR + 1] = {0}; - if (mode == 'v' && but->lock) + if (mode == 'v' && but->lock == TRUE) { return; + } if (mode == 'v') { /* extract first line from clipboard in case of multi-line copies */ @@ -4793,7 +4794,7 @@ static int ui_do_button(bContext *C, uiBlock *block, uiBut *but, wmEvent *event) /* verify if we can edit this button */ if (ELEM(event->type, LEFTMOUSE, RETKEY)) { /* this should become disabled button .. */ - if (but->lock) { + if (but->lock == TRUE) { if (but->lockstr) { BKE_report(NULL, RPT_WARNING, but->lockstr); button_activate_state(C, but, BUTTON_STATE_EXIT); diff --git a/source/blender/editors/interface/interface_intern.h b/source/blender/editors/interface/interface_intern.h index 13d05ca617c..567109e26d0 100644 --- a/source/blender/editors/interface/interface_intern.h +++ b/source/blender/editors/interface/interface_intern.h @@ -303,27 +303,27 @@ struct uiBlock { const char *lockstr; char lock; - char active; // to keep blocks while drawing and free them afterwards - char tooltipdisabled; // to avoid tooltip after click - char endblock; // uiEndBlock done? - - float xofs, yofs; // offset to parent button - int dobounds, mx, my; // for doing delayed - int bounds, minbounds; // for doing delayed + char active; /* to keep blocks while drawing and free them afterwards */ + char tooltipdisabled; /* to avoid tooltip after click */ + char endblock; /* uiEndBlock done? */ - rctf safety; // pulldowns, to detect outside, can differ per case how it is created - ListBase saferct; // uiSafetyRct list + float xofs, yofs; /* offset to parent button */ + int dobounds, mx, my; /* for doing delayed */ + int bounds, minbounds; /* for doing delayed */ - uiPopupBlockHandle *handle; // handle + rctf safety; /* pulldowns, to detect outside, can differ per case how it is created */ + ListBase saferct; /* uiSafetyRct list */ - struct wmOperator *ui_operator; // use so presets can find the operator, - // across menus and from nested popups which fail for operator context. + uiPopupBlockHandle *handle; /* handle */ - void *evil_C; // XXX hack for dynamic operator enums + struct wmOperator *ui_operator; /* use so presets can find the operator, */ + /* across menus and from nested popups which fail for operator context. */ - struct UnitSettings *unit; // unit system, used a lot for numeric buttons so include here rather then fetching through the scene every time. - float _hsv[3]; // XXX, only access via ui_block_hsv_get() - char color_profile; // color profile for correcting linear colors for display + void *evil_C; /* XXX hack for dynamic operator enums */ + + struct UnitSettings *unit; /* unit system, used a lot for numeric buttons so include here rather then fetching through the scene every time. */ + float _hsv[3]; /* XXX, only access via ui_block_hsv_get() */ + char color_profile; /* color profile for correcting linear colors for display */ }; typedef struct uiSafetyRct { diff --git a/source/blender/editors/interface/interface_layout.c b/source/blender/editors/interface/interface_layout.c index deef36de561..b68e14898d0 100644 --- a/source/blender/editors/interface/interface_layout.c +++ b/source/blender/editors/interface/interface_layout.c @@ -630,7 +630,7 @@ static void ui_item_disabled(uiLayout *layout, const char *name) but = uiDefBut(block, LABEL, 0, name, 0, 0, w, UI_UNIT_Y, NULL, 0.0, 0.0, 0, 0, ""); but->flag |= UI_BUT_DISABLED; - but->lock = 1; + but->lock = TRUE; but->lockstr = ""; } From a5e77e37537e4067c89c84e1a3a66f9f61845de3 Mon Sep 17 00:00:00 2001 From: Joshua Leung Date: Sun, 26 Aug 2012 07:27:51 +0000 Subject: [PATCH 135/163] Compiling fix for Windows+Mingw: "Ambiguous" use of IStream --- source/blender/imbuf/intern/openexr/openexr_api.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/blender/imbuf/intern/openexr/openexr_api.cpp b/source/blender/imbuf/intern/openexr/openexr_api.cpp index 34afdda0177..26aab29b8dd 100644 --- a/source/blender/imbuf/intern/openexr/openexr_api.cpp +++ b/source/blender/imbuf/intern/openexr/openexr_api.cpp @@ -153,7 +153,7 @@ void Mem_IStream::clear() /* File Input Stream */ -class IFileStream : public IStream +class IFileStream : public Imf::IStream { public: IFileStream(const char *filename) From aa17fc367bbd8a5a5834c07f3b225547dae11ee5 Mon Sep 17 00:00:00 2001 From: Joshua Leung Date: Sun, 26 Aug 2012 08:03:31 +0000 Subject: [PATCH 136/163] Bugfix [#32410] Create New Group (CTRL+G) tried to activate even when nothing is selected Some group operators were missing poll() callbacks --- source/blender/editors/object/object_group.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/source/blender/editors/object/object_group.c b/source/blender/editors/object/object_group.c index 53bfddee740..cca37cf3a44 100644 --- a/source/blender/editors/object/object_group.c +++ b/source/blender/editors/object/object_group.c @@ -370,6 +370,7 @@ void OBJECT_OT_group_add(wmOperatorType *ot) /* api callbacks */ ot->exec = group_add_exec; + ot->poll = ED_operator_objectmode; /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; @@ -403,6 +404,7 @@ void OBJECT_OT_group_link(wmOperatorType *ot) /* api callbacks */ ot->exec = group_link_exec; ot->invoke = WM_enum_search_invoke; + ot->poll = ED_operator_objectmode; /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; @@ -438,6 +440,7 @@ void OBJECT_OT_group_remove(wmOperatorType *ot) /* api callbacks */ ot->exec = group_remove_exec; + ot->poll = ED_operator_objectmode; /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; From 1b487e994850c0acb647aaa9a36464d613f89f51 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Sun, 26 Aug 2012 11:01:14 +0000 Subject: [PATCH 137/163] Some FFmpeg changes - Make FFmpeg initialization called from creator, not from functions which requires FFmpeg. Makes it easier to follow when initialization should happen. - Enable DNxHD codec. It was commented a while ago due to some strange behavior on some platforms. Re-tested it on Linux and Windows and it seemd to be working quite nice. Would let it be tested further, if it wouldn't be stable enough, easy to comment it again. - Make non-error messages from writeffmpeg.c printed only if ffmpeg debug argument was passed to blender. Reduces console pollution with messages which are not useful for general troubleshooting. Error messages would still be printed to the console. - Show FFmpeg error message when video stream failed to allocate. makes it easier to understand what exactly is wrong from Blender interface, no need to restart blender with FFmpeg debug flag and check for console messages. Used custom log callback for this which stores last error message in static variable. This is not thread safe, but with current design FFmpeg routines could not be called form several threads anyway, so think it's fine solution/ --- .../blender/blenkernel/intern/writeffmpeg.c | 72 ++++++++++--------- source/blender/blenlib/BLI_string.h | 7 ++ source/blender/blenlib/intern/string.c | 19 +++-- source/blender/imbuf/IMB_imbuf.h | 4 ++ source/blender/imbuf/intern/anim_movie.c | 4 -- source/blender/imbuf/intern/util.c | 51 +++++++++---- source/blender/makesrna/intern/rna_scene.c | 2 +- source/creator/creator.c | 1 + .../gameengine/VideoTexture/VideoFFmpeg.cpp | 6 -- 9 files changed, 100 insertions(+), 66 deletions(-) diff --git a/source/blender/blenkernel/intern/writeffmpeg.c b/source/blender/blenkernel/intern/writeffmpeg.c index f22fd74baf4..2e07b4143b0 100644 --- a/source/blender/blenkernel/intern/writeffmpeg.c +++ b/source/blender/blenkernel/intern/writeffmpeg.c @@ -69,8 +69,6 @@ #include "ffmpeg_compat.h" -extern void do_init_ffmpeg(void); - static int ffmpeg_type = 0; static int ffmpeg_codec = CODEC_ID_MPEG4; static int ffmpeg_audio_codec = CODEC_ID_NONE; @@ -101,6 +99,8 @@ static AUD_Device *audio_mixdown_device = 0; #define FFMPEG_AUTOSPLIT_SIZE 2000000000 +#define PRINT if (G.debug & G_DEBUG_FFMPEG) printf + /* Delete a picture buffer */ static void delete_picture(AVFrame *f) @@ -139,7 +139,7 @@ static int write_audio_frame(void) if (c->coded_frame && c->coded_frame->pts != AV_NOPTS_VALUE) { pkt.pts = av_rescale_q(c->coded_frame->pts, c->time_base, audio_stream->time_base); - fprintf(stderr, "Audio Frame PTS: %d\n", (int)pkt.pts); + PRINT("Audio Frame PTS: %d\n", (int) pkt.pts); } pkt.stream_index = audio_stream->index; @@ -265,10 +265,10 @@ static int write_video_frame(RenderData *rd, int cfra, AVFrame *frame, ReportLis packet.pts = av_rescale_q(c->coded_frame->pts, c->time_base, video_stream->time_base); - fprintf(stderr, "Video Frame PTS: %d\n", (int)packet.pts); + PRINT("Video Frame PTS: %d\n", (int)packet.pts); } else { - fprintf(stderr, "Video Frame PTS: not set\n"); + PRINT("Video Frame PTS: not set\n"); } if (c->coded_frame->key_frame) packet.flags |= AV_PKT_FLAG_KEY; @@ -364,7 +364,7 @@ static void set_ffmpeg_property_option(AVCodecContext *c, IDProperty *prop) char *param; const AVOption *rv = NULL; - fprintf(stderr, "FFMPEG expert option: %s: ", prop->name); + PRINT("FFMPEG expert option: %s: ", prop->name); BLI_strncpy(name, prop->name, sizeof(name)); @@ -376,15 +376,15 @@ static void set_ffmpeg_property_option(AVCodecContext *c, IDProperty *prop) switch (prop->type) { case IDP_STRING: - fprintf(stderr, "%s.\n", IDP_String(prop)); + PRINT("%s.\n", IDP_String(prop)); av_set_string3(c, prop->name, IDP_String(prop), 1, &rv); break; case IDP_FLOAT: - fprintf(stderr, "%g.\n", IDP_Float(prop)); + PRINT("%g.\n", IDP_Float(prop)); rv = av_set_double(c, prop->name, IDP_Float(prop)); break; case IDP_INT: - fprintf(stderr, "%d.\n", IDP_Int(prop)); + PRINT("%d.\n", IDP_Int(prop)); if (param) { if (IDP_Int(prop)) { @@ -401,7 +401,7 @@ static void set_ffmpeg_property_option(AVCodecContext *c, IDProperty *prop) } if (!rv) { - fprintf(stderr, "ffmpeg-option not supported: %s! Skipping.\n", + PRINT("ffmpeg-option not supported: %s! Skipping.\n", prop->name); } } @@ -446,11 +446,14 @@ static void set_ffmpeg_properties(RenderData *rd, AVCodecContext *c, const char /* prepare a video stream for the output file */ static AVStream *alloc_video_stream(RenderData *rd, int codec_id, AVFormatContext *of, - int rectx, int recty) + int rectx, int recty, char *error, int error_size) { AVStream *st; AVCodecContext *c; AVCodec *codec; + + error[0] = '\0'; + st = av_new_stream(of, 0); if (!st) return NULL; @@ -547,13 +550,13 @@ static AVStream *alloc_video_stream(RenderData *rd, int codec_id, AVFormatContex // || !strcmp(of->oformat->name, "3gp") ) { - fprintf(stderr, "Using global header\n"); + PRINT("Using global header\n"); c->flags |= CODEC_FLAG_GLOBAL_HEADER; } /* Determine whether we are encoding interlaced material or not */ if (rd->mode & R_FIELDS) { - fprintf(stderr, "Encoding interlaced video\n"); + PRINT("Encoding interlaced video\n"); c->flags |= CODEC_FLAG_INTERLACED_DCT; c->flags |= CODEC_FLAG_INTERLACED_ME; } @@ -566,8 +569,7 @@ static AVStream *alloc_video_stream(RenderData *rd, int codec_id, AVFormatContex set_ffmpeg_properties(rd, c, "video"); if (avcodec_open(c, codec) < 0) { - // - //XXX error("Couldn't initialize codec"); + BLI_strncpy(error, IMB_ffmpeg_last_error(), error_size); return NULL; } @@ -672,7 +674,7 @@ static int start_ffmpeg_impl(struct RenderData *rd, int rectx, int recty, Report AVFormatContext *of; AVOutputFormat *fmt; AVDictionary *opts = NULL; - char name[256]; + char name[256], error[1024]; const char **exts; ffmpeg_type = rd->ffcodecdata.type; @@ -684,11 +686,9 @@ static int start_ffmpeg_impl(struct RenderData *rd, int rectx, int recty, Report ffmpeg_autosplit = rd->ffcodecdata.flags & FFMPEG_AUTOSPLIT_OUTPUT; - do_init_ffmpeg(); - /* Determine the correct filename */ BKE_ffmpeg_filepath_get(name, rd); - fprintf(stderr, "Starting output to %s(ffmpeg)...\n" + PRINT("Starting output to %s(ffmpeg)...\n" " Using type=%d, codec=%d, audio_codec=%d,\n" " video_bitrate=%d, audio_bitrate=%d,\n" " gop_size=%d, autosplit=%d\n" @@ -793,10 +793,14 @@ static int start_ffmpeg_impl(struct RenderData *rd, int rectx, int recty, Report } if (fmt->video_codec != CODEC_ID_NONE) { - video_stream = alloc_video_stream(rd, fmt->video_codec, of, rectx, recty); - printf("alloc video stream %p\n", video_stream); + video_stream = alloc_video_stream(rd, fmt->video_codec, of, rectx, recty, error, sizeof(error)); + PRINT("alloc video stream %p\n", video_stream); if (!video_stream) { - BKE_report(reports, RPT_ERROR, "Error initializing video stream."); + if (error[0]) + BKE_report(reports, RPT_ERROR, error); + else + BKE_report(reports, RPT_ERROR, "Error initializing video stream."); + av_dict_free(&opts); return 0; } @@ -870,10 +874,10 @@ void flush_ffmpeg(void) packet.pts = av_rescale_q(c->coded_frame->pts, c->time_base, video_stream->time_base); - fprintf(stderr, "Video Frame PTS: %d\n", (int)packet.pts); + PRINT("Video Frame PTS: %d\n", (int)packet.pts); } else { - fprintf(stderr, "Video Frame PTS: not set\n"); + PRINT("Video Frame PTS: not set\n"); } if (c->coded_frame->key_frame) { packet.flags |= AV_PKT_FLAG_KEY; @@ -983,9 +987,9 @@ int BKE_ffmpeg_append(RenderData *rd, int start_frame, int frame, int *pixels, i AVFrame *avframe; int success = 1; - fprintf(stderr, "Writing frame %i, " - "render width=%d, render height=%d\n", frame, - rectx, recty); + PRINT("Writing frame %i, " + "render width=%d, render height=%d\n", frame, + rectx, recty); // why is this done before writing the video frame and again at end_ffmpeg? // write_audio_frames(frame / (((double)rd->frs_sec) / rd->frs_sec_base)); @@ -1013,7 +1017,7 @@ void BKE_ffmpeg_end(void) { unsigned int i; - fprintf(stderr, "Closing ffmpeg...\n"); + PRINT("Closing ffmpeg...\n"); #if 0 if (audio_stream) { /* SEE UPPER */ @@ -1029,7 +1033,7 @@ void BKE_ffmpeg_end(void) #endif if (video_stream && video_stream->codec) { - fprintf(stderr, "Flushing delayed frames...\n"); + PRINT("Flushing delayed frames...\n"); flush_ffmpeg(); } @@ -1041,7 +1045,7 @@ void BKE_ffmpeg_end(void) if (video_stream && video_stream->codec) { avcodec_close(video_stream->codec); - printf("zero video stream %p\n", video_stream); + PRINT("zero video stream %p\n", video_stream); video_stream = 0; } @@ -1142,8 +1146,8 @@ IDProperty *BKE_ffmpeg_property_add(RenderData *rd, const char *type, int opt_in BLI_strncpy(name, o->name, sizeof(name)); } - fprintf(stderr, "ffmpeg_property_add: %s %d %d %s\n", - type, parent_index, opt_index, name); + PRINT("ffmpeg_property_add: %s %d %d %s\n", + type, parent_index, opt_index, name); prop = IDP_GetPropertyFromGroup(group, name); if (prop) { @@ -1316,12 +1320,10 @@ static void ffmpeg_set_expert_options(RenderData *rd) if (rd->ffcodecdata.flags & FFMPEG_LOSSLESS_OUTPUT) BKE_ffmpeg_property_add_string(rd, "video", "cqp:0"); } -#if 0 /* disabled for after release */ else if (codec_id == CODEC_ID_DNXHD) { if (rd->ffcodecdata.flags & FFMPEG_LOSSLESS_OUTPUT) - ffmpeg_property_add_string(rd, "video", "mbd:rd"); + BKE_ffmpeg_property_add_string(rd, "video", "mbd:rd"); } -#endif } void BKE_ffmpeg_preset_set(RenderData *rd, int preset) diff --git a/source/blender/blenlib/BLI_string.h b/source/blender/blenlib/BLI_string.h index a74629e589c..b3d0df04eb1 100644 --- a/source/blender/blenlib/BLI_string.h +++ b/source/blender/blenlib/BLI_string.h @@ -32,6 +32,8 @@ * \ingroup bli */ +#include + #ifdef __cplusplus extern "C" { #endif @@ -139,6 +141,11 @@ __attribute__((nonnull)) #endif ; +/* + * Replacement for vsnprintf + */ +size_t BLI_vsnprintf(char *buffer, size_t count, const char *format, va_list arg); + /* * Print formatted string into a newly mallocN'd string * and return it. diff --git a/source/blender/blenlib/intern/string.c b/source/blender/blenlib/intern/string.c index 7a750a74a33..8501db7c8b8 100644 --- a/source/blender/blenlib/intern/string.c +++ b/source/blender/blenlib/intern/string.c @@ -78,22 +78,31 @@ char *BLI_strncpy(char *dst, const char *src, const size_t maxncpy) return dst; } -size_t BLI_snprintf(char *buffer, size_t count, const char *format, ...) +size_t BLI_vsnprintf(char *buffer, size_t count, const char *format, va_list arg) { size_t n; - va_list arg; - va_start(arg, format); n = vsnprintf(buffer, count, format, arg); - + if (n != -1 && n < count) { buffer[n] = '\0'; } else { buffer[count - 1] = '\0'; } - + + return n; +} + +size_t BLI_snprintf(char *buffer, size_t count, const char *format, ...) +{ + size_t n; + va_list arg; + + va_start(arg, format); + n = BLI_vsnprintf(buffer, count, format, arg); va_end(arg); + return n; } diff --git a/source/blender/imbuf/IMB_imbuf.h b/source/blender/imbuf/IMB_imbuf.h index 738e61dbe6e..a04affd4891 100644 --- a/source/blender/imbuf/IMB_imbuf.h +++ b/source/blender/imbuf/IMB_imbuf.h @@ -506,5 +506,9 @@ void IMB_processor_apply_threaded(int buffer_lines, int handle_size, void *init_ void *customdata), void *(do_thread) (void *)); +/* ffmpeg */ +void IMB_ffmpeg_init(void); +const char *IMB_ffmpeg_last_error(void); + #endif diff --git a/source/blender/imbuf/intern/anim_movie.c b/source/blender/imbuf/intern/anim_movie.c index f07a18cb89c..9092d59c351 100644 --- a/source/blender/imbuf/intern/anim_movie.c +++ b/source/blender/imbuf/intern/anim_movie.c @@ -439,8 +439,6 @@ static ImBuf *avi_fetchibuf(struct anim *anim, int position) #ifdef WITH_FFMPEG -extern void do_init_ffmpeg(void); - static int startffmpeg(struct anim *anim) { int i, videoStream; @@ -463,8 +461,6 @@ static int startffmpeg(struct anim *anim) streamcount = anim->streamindex; - do_init_ffmpeg(); - if (avformat_open_input(&pFormatCtx, anim->name, NULL, NULL) != 0) { return -1; } diff --git a/source/blender/imbuf/intern/util.c b/source/blender/imbuf/intern/util.c index 2b0597d64a5..9ec22f0798e 100644 --- a/source/blender/imbuf/intern/util.c +++ b/source/blender/imbuf/intern/util.c @@ -43,6 +43,8 @@ #include "BLI_path_util.h" #include "BLI_fileops.h" +#include "BLI_utildefines.h" +#include "BLI_string.h" #include "DNA_userdef_types.h" #include "BKE_global.h" @@ -220,6 +222,8 @@ static int isqtime(const char *name) #ifdef WITH_FFMPEG +static char ffmpeg_last_error[1024]; + void silence_log_ffmpeg(int quiet) { if (quiet) { @@ -230,21 +234,40 @@ void silence_log_ffmpeg(int quiet) } } -extern void do_init_ffmpeg(void); -void do_init_ffmpeg(void) +void ffmpeg_log_callback(void *ptr, int level, const char *format, va_list arg) { - static int ffmpeg_init = 0; - if (!ffmpeg_init) { - ffmpeg_init = 1; - av_register_all(); - avdevice_register_all(); - if ((G.debug & G_DEBUG_FFMPEG) == 0) { - silence_log_ffmpeg(1); - } - else { - silence_log_ffmpeg(0); - } + if (ELEM(level, AV_LOG_FATAL, AV_LOG_ERROR)) { + size_t n = BLI_vsnprintf(ffmpeg_last_error, sizeof(ffmpeg_last_error), format, arg); + + /* strip trailing \n */ + ffmpeg_last_error[n - 1] = '\0'; } + + /* call default logger to print all message to console */ + av_log_default_callback(ptr, level, format, arg); +} + +void IMB_ffmpeg_init(void) +{ + av_register_all(); + avdevice_register_all(); + + if ((G.debug & G_DEBUG_FFMPEG) == 0) { + silence_log_ffmpeg(1); + } + else { + silence_log_ffmpeg(0); + } + + ffmpeg_last_error[0] = '\0'; + + /* set own callback which could store last error to report to UI */ + av_log_set_callback(ffmpeg_log_callback); +} + +const char *IMB_ffmpeg_last_error(void) +{ + return ffmpeg_last_error; } static int isffmpeg(const char *filename) @@ -255,8 +278,6 @@ static int isffmpeg(const char *filename) AVCodec *pCodec; AVCodecContext *pCodecCtx; - do_init_ffmpeg(); - if (BLI_testextensie(filename, ".swf") || BLI_testextensie(filename, ".jpg") || BLI_testextensie(filename, ".png") || diff --git a/source/blender/makesrna/intern/rna_scene.c b/source/blender/makesrna/intern/rna_scene.c index a6f3c0095b5..597c2294ade 100644 --- a/source/blender/makesrna/intern/rna_scene.c +++ b/source/blender/makesrna/intern/rna_scene.c @@ -2995,7 +2995,7 @@ static void rna_def_scene_ffmpeg_settings(BlenderRNA *brna) {CODEC_ID_FLV1, "FLASH", 0, "Flash Video", ""}, {CODEC_ID_FFV1, "FFV1", 0, "FFmpeg video codec #1", ""}, {CODEC_ID_QTRLE, "QTRLE", 0, "QTRLE", ""}, - /* {CODEC_ID_DNXHD, "DNXHD", 0, "DNxHD", ""}, */ /* disabled for after release */ + {CODEC_ID_DNXHD, "DNXHD", 0, "DNxHD", ""}, {0, NULL, 0, NULL, NULL} }; diff --git a/source/creator/creator.c b/source/creator/creator.c index 3e884d1aa38..58e1066e5ff 100644 --- a/source/creator/creator.c +++ b/source/creator/creator.c @@ -1273,6 +1273,7 @@ int main(int argc, const char **argv) initglobals(); /* blender.c */ IMB_init(); + IMB_ffmpeg_init(); BLI_callback_global_init(); diff --git a/source/gameengine/VideoTexture/VideoFFmpeg.cpp b/source/gameengine/VideoTexture/VideoFFmpeg.cpp index 4586a50e6a9..1ba944aa955 100644 --- a/source/gameengine/VideoTexture/VideoFFmpeg.cpp +++ b/source/gameengine/VideoTexture/VideoFFmpeg.cpp @@ -52,8 +52,6 @@ const long timeScale = 1000; #define CATCH_EXCP catch (Exception & exp) \ { exp.report(); m_status = SourceError; } -extern "C" void do_init_ffmpeg(); - // class RenderVideo // constructor @@ -521,8 +519,6 @@ void VideoFFmpeg::releaseFrame(AVFrame* frame) // open video file void VideoFFmpeg::openFile (char * filename) { - do_init_ffmpeg(); - if (openStream(filename, NULL, NULL) != 0) return; @@ -586,8 +582,6 @@ void VideoFFmpeg::openCam (char * file, short camIdx) char filename[28], rateStr[20]; char *p; - do_init_ffmpeg(); - #ifdef WIN32 // video capture on windows only through Video For Windows driver inputFormat = av_find_input_format("vfwcap"); From 3bfe4520ae027a5d431b7f7714a02adb416492c2 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Sun, 26 Aug 2012 11:01:18 +0000 Subject: [PATCH 138/163] Style cleanup: whitespace --- .../blender/blenkernel/intern/writeffmpeg.c | 71 ++++++------------- 1 file changed, 22 insertions(+), 49 deletions(-) diff --git a/source/blender/blenkernel/intern/writeffmpeg.c b/source/blender/blenkernel/intern/writeffmpeg.c index 2e07b4143b0..3526058e12b 100644 --- a/source/blender/blenkernel/intern/writeffmpeg.c +++ b/source/blender/blenkernel/intern/writeffmpeg.c @@ -125,9 +125,7 @@ static int write_audio_frame(void) AUD_readDevice(audio_mixdown_device, audio_input_buffer, audio_input_samples); audio_time += (double) audio_input_samples / (double) c->sample_rate; - pkt.size = avcodec_encode_audio(c, audio_output_buffer, - audio_outbuf_size, - (short *)audio_input_buffer); + pkt.size = avcodec_encode_audio(c, audio_output_buffer, audio_outbuf_size, (short *) audio_input_buffer); if (pkt.size < 0) { // XXX error("Error writing audio packet"); @@ -137,8 +135,7 @@ static int write_audio_frame(void) pkt.data = audio_output_buffer; if (c->coded_frame && c->coded_frame->pts != AV_NOPTS_VALUE) { - pkt.pts = av_rescale_q(c->coded_frame->pts, - c->time_base, audio_stream->time_base); + pkt.pts = av_rescale_q(c->coded_frame->pts, c->time_base, audio_stream->time_base); PRINT("Audio Frame PTS: %d\n", (int) pkt.pts); } @@ -189,8 +186,7 @@ static const char **get_file_extensions(int format) return rv; } case FFMPEG_MPEG2: { - static const char *rv[] = { ".dvd", ".vob", ".mpg", ".mpeg", - NULL }; + static const char *rv[] = { ".dvd", ".vob", ".mpg", ".mpeg", NULL }; return rv; } case FFMPEG_MPEG4: { @@ -254,17 +250,14 @@ static int write_video_frame(RenderData *rd, int cfra, AVFrame *frame, ReportLis frame->top_field_first = ((rd->mode & R_ODDFIELD) != 0); } - outsize = avcodec_encode_video(c, video_buffer, video_buffersize, - frame); + outsize = avcodec_encode_video(c, video_buffer, video_buffersize, frame); if (outsize > 0) { AVPacket packet; av_init_packet(&packet); if (c->coded_frame->pts != AV_NOPTS_VALUE) { - packet.pts = av_rescale_q(c->coded_frame->pts, - c->time_base, - video_stream->time_base); + packet.pts = av_rescale_q(c->coded_frame->pts, c->time_base, video_stream->time_base); PRINT("Video Frame PTS: %d\n", (int)packet.pts); } else { @@ -401,8 +394,7 @@ static void set_ffmpeg_property_option(AVCodecContext *c, IDProperty *prop) } if (!rv) { - PRINT("ffmpeg-option not supported: %s! Skipping.\n", - prop->name); + PRINT("ffmpeg-option not supported: %s! Skipping.\n", prop->name); } } @@ -463,7 +455,6 @@ static AVStream *alloc_video_stream(RenderData *rd, int codec_id, AVFormatContex c->codec_id = codec_id; c->codec_type = AVMEDIA_TYPE_VIDEO; - /* Get some values from the current render settings */ c->width = rectx; @@ -495,7 +486,8 @@ static AVStream *alloc_video_stream(RenderData *rd, int codec_id, AVFormatContex c->me_method = ME_EPZS; codec = avcodec_find_encoder(c->codec_id); - if (!codec) return NULL; + if (!codec) + return NULL; /* Be sure to use the correct pixel format(e.g. RGB, YUV) */ @@ -563,8 +555,7 @@ static AVStream *alloc_video_stream(RenderData *rd, int codec_id, AVFormatContex /* xasp & yasp got float lately... */ - st->sample_aspect_ratio = c->sample_aspect_ratio = av_d2q( - ((double) rd->xasp / (double) rd->yasp), 255); + st->sample_aspect_ratio = c->sample_aspect_ratio = av_d2q(((double) rd->xasp / (double) rd->yasp), 255); set_ffmpeg_properties(rd, c, "video"); @@ -586,16 +577,11 @@ static AVStream *alloc_video_stream(RenderData *rd, int codec_id, AVFormatContex else video_buffersize = avpicture_get_size(c->pix_fmt, c->width, c->height); - video_buffer = (uint8_t *)MEM_mallocN(video_buffersize * sizeof(uint8_t), - "FFMPEG video buffer"); + video_buffer = (uint8_t *)MEM_mallocN(video_buffersize * sizeof(uint8_t), "FFMPEG video buffer"); current_frame = alloc_picture(c->pix_fmt, c->width, c->height); - img_convert_ctx = sws_getContext(c->width, c->height, - PIX_FMT_BGR32, - c->width, c->height, - c->pix_fmt, - SWS_BICUBIC, + img_convert_ctx = sws_getContext(c->width, c->height, PIX_FMT_BGR32, c->width, c->height, c->pix_fmt, SWS_BICUBIC, NULL, NULL, NULL); return st; } @@ -647,11 +633,9 @@ static AVStream *alloc_audio_stream(RenderData *rd, int codec_id, AVFormatContex audio_outbuf_size = c->frame_size * c->channels * sizeof(int16_t) * 4; } - audio_output_buffer = (uint8_t *)av_malloc( - audio_outbuf_size); + audio_output_buffer = (uint8_t *) av_malloc(audio_outbuf_size); - audio_input_buffer = (uint8_t *)av_malloc( - audio_input_samples * c->channels * sizeof(int16_t)); + audio_input_buffer = (uint8_t *) av_malloc(audio_input_samples * c->channels * sizeof(int16_t)); audio_time = 0.0f; @@ -683,8 +667,7 @@ static int start_ffmpeg_impl(struct RenderData *rd, int rectx, int recty, Report ffmpeg_video_bitrate = rd->ffcodecdata.video_bitrate; ffmpeg_audio_bitrate = rd->ffcodecdata.audio_bitrate; ffmpeg_gop_size = rd->ffcodecdata.gop_size; - ffmpeg_autosplit = rd->ffcodecdata.flags - & FFMPEG_AUTOSPLIT_OUTPUT; + ffmpeg_autosplit = rd->ffcodecdata.flags & FFMPEG_AUTOSPLIT_OUTPUT; /* Determine the correct filename */ BKE_ffmpeg_filepath_get(name, rd); @@ -871,10 +854,8 @@ void flush_ffmpeg(void) break; } if (c->coded_frame->pts != AV_NOPTS_VALUE) { - packet.pts = av_rescale_q(c->coded_frame->pts, - c->time_base, - video_stream->time_base); - PRINT("Video Frame PTS: %d\n", (int)packet.pts); + packet.pts = av_rescale_q(c->coded_frame->pts, c->time_base, video_stream->time_base); + PRINT("Video Frame PTS: %d\n", (int) packet.pts); } else { PRINT("Video Frame PTS: not set\n"); @@ -920,8 +901,7 @@ void BKE_ffmpeg_filepath_get(char *string, RenderData *rd) } while (*fe) { - if (BLI_strcasecmp(string + strlen(string) - strlen(*fe), - *fe) == 0) + if (BLI_strcasecmp(string + strlen(string) - strlen(*fe), *fe) == 0) { break; } @@ -987,9 +967,7 @@ int BKE_ffmpeg_append(RenderData *rd, int start_frame, int frame, int *pixels, i AVFrame *avframe; int success = 1; - PRINT("Writing frame %i, " - "render width=%d, render height=%d\n", frame, - rectx, recty); + PRINT("Writing frame %i, render width=%d, render height=%d\n", frame, rectx, recty); // why is this done before writing the video frame and again at end_ffmpeg? // write_audio_frames(frame / (((double)rd->frs_sec) / rd->frs_sec_base)); @@ -1146,8 +1124,7 @@ IDProperty *BKE_ffmpeg_property_add(RenderData *rd, const char *type, int opt_in BLI_strncpy(name, o->name, sizeof(name)); } - PRINT("ffmpeg_property_add: %s %d %d %s\n", - type, parent_index, opt_index, name); + PRINT("ffmpeg_property_add: %s %d %d %s\n", type, parent_index, opt_index, name); prop = IDP_GetPropertyFromGroup(group, name); if (prop) { @@ -1185,8 +1162,7 @@ IDProperty *BKE_ffmpeg_property_add(RenderData *rd, const char *type, int opt_in /* not all versions of ffmpeg include that, so here we go ... */ -static const AVOption *my_av_find_opt(void *v, const char *name, - const char *unit, int mask, int flags) +static const AVOption *my_av_find_opt(void *v, const char *name, const char *unit, int mask, int flags) { AVClass *c = *(AVClass **)v; const AVOption *o = c->option; @@ -1239,14 +1215,11 @@ int BKE_ffmpeg_property_add_string(RenderData *rd, const char *type, const char if (param && o->type != FF_OPT_TYPE_CONST && o->unit) { p = my_av_find_opt(&c, param, o->unit, 0, 0); if (p) { - prop = BKE_ffmpeg_property_add(rd, - (char *) type, p - c.av_class->option, - o - c.av_class->option); + prop = BKE_ffmpeg_property_add(rd, (char *) type, p - c.av_class->option, o - c.av_class->option); } } else { - prop = BKE_ffmpeg_property_add(rd, - (char *) type, o - c.av_class->option, 0); + prop = BKE_ffmpeg_property_add(rd, (char *) type, o - c.av_class->option, 0); } From ee96cde864ff8451713e9e9674890bbd69fc42a4 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 26 Aug 2012 11:35:43 +0000 Subject: [PATCH 139/163] style cleanup: whitespace --- source/blender/blenkernel/intern/sound.c | 38 +- source/blender/blenlib/BLI_pbvh.h | 4 +- source/blender/blenlib/intern/pbvh.c | 4 +- source/blender/blenloader/intern/readfile.c | 2 +- .../blenloader/intern/versioning_250.c | 6 +- .../blenloader/intern/versioning_legacy.c | 4 +- source/blender/blenloader/intern/writefile.c | 2 +- source/blender/bmesh/intern/bmesh_error.h | 4 +- source/blender/bmesh/intern/bmesh_mods.h | 4 +- .../blender/bmesh/intern/bmesh_operator_api.h | 2 +- source/blender/collada/AnimationExporter.h | 4 +- source/blender/collada/AnimationImporter.cpp | 2 +- source/blender/collada/TransformReader.h | 2 +- source/blender/collada/collada_internal.h | 2 +- source/blender/editors/io/io_collada.c | 8 +- .../blender/editors/physics/physics_fluid.c | 2 +- .../editors/space_clip/clip_dopesheet_ops.c | 4 +- source/blender/editors/space_clip/clip_ops.c | 6 +- .../blender/editors/space_file/space_file.c | 2 +- .../editors/space_logic/logic_window.c | 34 +- .../space_sequencer/sequencer_intern.h | 2 +- .../blender/editors/space_view3d/view3d_fly.c | 2 +- source/blender/imbuf/IMB_thumbs.h | 8 +- source/blender/imbuf/intern/imbuf_cocoa.m | 27 +- source/blender/makesrna/intern/rna_tracking.c | 2 +- .../blender/modifiers/intern/MOD_displace.c | 2 +- source/blender/python/bmesh/bmesh_py_api.c | 6 +- source/blender/python/bmesh/bmesh_py_ops.c | 2 +- source/blender/python/bmesh/bmesh_py_types.c | 410 +++++++++--------- .../python/bmesh/bmesh_py_types_customdata.c | 108 ++--- .../python/bmesh/bmesh_py_types_meshdata.c | 58 +-- .../python/bmesh/bmesh_py_types_select.c | 40 +- source/blender/python/bmesh/bmesh_py_utils.c | 44 +- source/blender/quicktime/apple/qtkit_export.m | 4 +- source/blender/quicktime/apple/qtkit_import.m | 8 +- .../blender/render/intern/include/rayobject.h | 19 +- source/blender/windowmanager/WM_api.h | 4 +- .../bad_level_call_stubs/stubs.c | 4 +- .../Converter/KX_ConvertSensors.cpp | 24 +- source/gameengine/Expressions/BoolValue.cpp | 2 +- .../gameengine/GamePlayer/ghost/GPG_ghost.cpp | 2 +- source/gameengine/Ketsji/KX_Camera.cpp | 4 +- 42 files changed, 458 insertions(+), 460 deletions(-) diff --git a/source/blender/blenkernel/intern/sound.c b/source/blender/blenkernel/intern/sound.c index 14360297ec0..2462de07a18 100644 --- a/source/blender/blenkernel/intern/sound.c +++ b/source/blender/blenkernel/intern/sound.c @@ -774,37 +774,37 @@ void sound_force_device(int UNUSED(device)) {} void sound_init_once(void) {} void sound_init(struct Main *UNUSED(bmain)) {} void sound_exit(void) {} -void sound_cache(struct bSound* UNUSED(sound)) { } -void sound_delete_cache(struct bSound* UNUSED(sound)) {} -void sound_load(struct Main *UNUSED(bmain), struct bSound* UNUSED(sound)) {} +void sound_cache(struct bSound *UNUSED(sound)) { } +void sound_delete_cache(struct bSound *UNUSED(sound)) {} +void sound_load(struct Main *UNUSED(bmain), struct bSound *UNUSED(sound)) {} void sound_create_scene(struct Scene *UNUSED(scene)) {} void sound_destroy_scene(struct Scene *UNUSED(scene)) {} void sound_mute_scene(struct Scene *UNUSED(scene), int UNUSED(muted)) {} -void* sound_scene_add_scene_sound(struct Scene *UNUSED(scene), struct Sequence* UNUSED(sequence), int UNUSED(startframe), int UNUSED(endframe), int UNUSED(frameskip)) { return NULL; } -void* sound_scene_add_scene_sound_defaults(struct Scene *UNUSED(scene), struct Sequence* UNUSED(sequence)) { return NULL; } -void* sound_add_scene_sound(struct Scene *UNUSED(scene), struct Sequence* UNUSED(sequence), int UNUSED(startframe), int UNUSED(endframe), int UNUSED(frameskip)) { return NULL; } -void* sound_add_scene_sound_defaults(struct Scene *UNUSED(scene), struct Sequence* UNUSED(sequence)) { return NULL; } -void sound_remove_scene_sound(struct Scene *UNUSED(scene), void* UNUSED(handle)) {} -void sound_mute_scene_sound(void* UNUSED(handle), char UNUSED(mute)) {} -void sound_move_scene_sound(struct Scene *UNUSED(scene), void* UNUSED(handle), int UNUSED(startframe), int UNUSED(endframe), int UNUSED(frameskip)) {} +void *sound_scene_add_scene_sound(struct Scene *UNUSED(scene), struct Sequence *UNUSED(sequence), int UNUSED(startframe), int UNUSED(endframe), int UNUSED(frameskip)) { return NULL; } +void *sound_scene_add_scene_sound_defaults(struct Scene *UNUSED(scene), struct Sequence *UNUSED(sequence)) { return NULL; } +void *sound_add_scene_sound(struct Scene *UNUSED(scene), struct Sequence *UNUSED(sequence), int UNUSED(startframe), int UNUSED(endframe), int UNUSED(frameskip)) { return NULL; } +void *sound_add_scene_sound_defaults(struct Scene *UNUSED(scene), struct Sequence *UNUSED(sequence)) { return NULL; } +void sound_remove_scene_sound(struct Scene *UNUSED(scene), void *UNUSED(handle)) {} +void sound_mute_scene_sound(void *UNUSED(handle), char UNUSED(mute)) {} +void sound_move_scene_sound(struct Scene *UNUSED(scene), void *UNUSED(handle), int UNUSED(startframe), int UNUSED(endframe), int UNUSED(frameskip)) {} void sound_move_scene_sound_defaults(struct Scene *UNUSED(scene), struct Sequence *UNUSED(sequence)) {} void sound_play_scene(struct Scene *UNUSED(scene)) {} void sound_stop_scene(struct Scene *UNUSED(scene)) {} void sound_seek_scene(struct Main *UNUSED(bmain), struct Scene *UNUSED(scene)) {} float sound_sync_scene(struct Scene *UNUSED(scene)) { return NAN_FLT; } int sound_scene_playing(struct Scene *UNUSED(scene)) { return -1; } -int sound_read_sound_buffer(struct bSound* UNUSED(sound), float* UNUSED(buffer), int UNUSED(length), float UNUSED(start), float UNUSED(end)) { return 0; } -void sound_read_waveform(struct bSound* sound) { (void)sound; } +int sound_read_sound_buffer(struct bSound *UNUSED(sound), float *UNUSED(buffer), int UNUSED(length), float UNUSED(start), float UNUSED(end)) { return 0; } +void sound_read_waveform(struct bSound *sound) { (void)sound; } void sound_init_main(struct Main *bmain) { (void)bmain; } void sound_set_cfra(int cfra) { (void)cfra; } -void sound_update_sequencer(struct Main* main, struct bSound* sound) { (void)main; (void)sound; } -void sound_update_scene(struct Scene* scene) { (void)scene; } -void sound_update_scene_sound(void* handle, struct bSound* sound) { (void)handle; (void)sound; } +void sound_update_sequencer(struct Main *main, struct bSound *sound) { (void)main; (void)sound; } +void sound_update_scene(struct Scene *scene) { (void)scene; } +void sound_update_scene_sound(void *handle, struct bSound *sound) { (void)handle; (void)sound; } void sound_update_scene_listener(struct Scene *scene) { (void)scene; } void sound_update_fps(struct Scene *scene) { (void)scene; } -void sound_set_scene_sound_volume(void* handle, float volume, char animated) { (void)handle; (void)volume; (void)animated; } -void sound_set_scene_sound_pan(void* handle, float pan, char animated) { (void)handle; (void)pan; (void)animated; } +void sound_set_scene_sound_volume(void *handle, float volume, char animated) { (void)handle; (void)volume; (void)animated; } +void sound_set_scene_sound_pan(void *handle, float pan, char animated) { (void)handle; (void)pan; (void)animated; } void sound_set_scene_volume(struct Scene *scene, float volume) { (void)scene; (void)volume; } -void sound_set_scene_sound_pitch(void* handle, float pitch, char animated) { (void)handle; (void)pitch; (void)animated; } -float sound_get_length(struct bSound* sound) { (void)sound; return 0; } +void sound_set_scene_sound_pitch(void *handle, float pitch, char animated) { (void)handle; (void)pitch; (void)animated; } +float sound_get_length(struct bSound *sound) { (void)sound; return 0; } #endif // WITH_AUDASPACE diff --git a/source/blender/blenlib/BLI_pbvh.h b/source/blender/blenlib/BLI_pbvh.h index 6c0d547fe6f..20d04f7881e 100644 --- a/source/blender/blenlib/BLI_pbvh.h +++ b/source/blender/blenlib/BLI_pbvh.h @@ -260,8 +260,8 @@ void BLI_pbvh_node_free_proxies(PBVHNode *node); PBVHProxyNode *BLI_pbvh_node_add_proxy(PBVH *bvh, PBVHNode *node); void BLI_pbvh_gather_proxies(PBVH *pbvh, PBVHNode ***nodes, int *totnode); -//void BLI_pbvh_node_BB_reset(PBVHNode* node); -//void BLI_pbvh_node_BB_expand(PBVHNode* node, float co[3]); +//void BLI_pbvh_node_BB_reset(PBVHNode *node); +//void BLI_pbvh_node_BB_expand(PBVHNode *node, float co[3]); #endif /* __BLI_PBVH_H__ */ diff --git a/source/blender/blenlib/intern/pbvh.c b/source/blender/blenlib/intern/pbvh.c index b4b546d9167..22597c9f8e6 100644 --- a/source/blender/blenlib/intern/pbvh.c +++ b/source/blender/blenlib/intern/pbvh.c @@ -260,12 +260,12 @@ static void update_node_vb(PBVH *bvh, PBVHNode *node) node->vb = vb; } -//void BLI_pbvh_node_BB_reset(PBVHNode* node) +//void BLI_pbvh_node_BB_reset(PBVHNode *node) //{ // BB_reset(&node->vb); //} // -//void BLI_pbvh_node_BB_expand(PBVHNode* node, float co[3]) +//void BLI_pbvh_node_BB_expand(PBVHNode *node, float co[3]) //{ // BB_expand(&node->vb, co); //} diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index 1956cfaedf0..e6b97f1b2ff 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -2617,7 +2617,7 @@ static void lib_link_armature(FileData *fd, Main *main) } } -static void direct_link_bones(FileData *fd, Bone* bone) +static void direct_link_bones(FileData *fd, Bone *bone) { Bone *child; diff --git a/source/blender/blenloader/intern/versioning_250.c b/source/blender/blenloader/intern/versioning_250.c index ed5ffbf463e..1bad1bd80df 100644 --- a/source/blender/blenloader/intern/versioning_250.c +++ b/source/blender/blenloader/intern/versioning_250.c @@ -129,7 +129,7 @@ static void area_add_header_region(ScrArea *sa, ListBase *lb) ar->v2d.flag = (V2D_PIXELOFS_X|V2D_PIXELOFS_Y); } -static void sequencer_init_preview_region(ARegion* ar) +static void sequencer_init_preview_region(ARegion *ar) { // XXX a bit ugly still, copied from space_sequencer /* NOTE: if you change values here, also change them in space_sequencer.c, sequencer_new */ @@ -1787,7 +1787,7 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main) SpaceLink *sl; for (sl = sa->spacedata.first; sl; sl = sl->next) { if (sl->spacetype == SPACE_VIEW3D) { - View3D* v3d = (View3D *)sl; + View3D *v3d = (View3D *)sl; v3d->flag2 &= ~V3D_RENDER_OVERRIDE; } } @@ -2206,7 +2206,7 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main) bActuator *act; for (act = ob->actuators.first; act; act = act->next) { if (act->type == ACT_STEERING) { - bSteeringActuator* stact = act->data; + bSteeringActuator *stact = act->data; if (stact->facingaxis == 0) { stact->facingaxis = 1; } diff --git a/source/blender/blenloader/intern/versioning_legacy.c b/source/blender/blenloader/intern/versioning_legacy.c index c31906cbd80..8ace277b42d 100644 --- a/source/blender/blenloader/intern/versioning_legacy.c +++ b/source/blender/blenloader/intern/versioning_legacy.c @@ -1141,7 +1141,7 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main) } if (main->versionfile <= 212) { - bSound* sound; + bSound *sound; bProperty *prop; Object *ob; Mesh *me; @@ -1307,7 +1307,7 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main) } if (main->versionfile <= 224) { - bSound* sound; + bSound *sound; Scene *sce; Mesh *me; bScreen *sc; diff --git a/source/blender/blenloader/intern/writefile.c b/source/blender/blenloader/intern/writefile.c index 4ada0c54a93..252e81537c4 100644 --- a/source/blender/blenloader/intern/writefile.c +++ b/source/blender/blenloader/intern/writefile.c @@ -2525,7 +2525,7 @@ static void write_libraries(WriteData *wd, Main *main) } } -static void write_bone(WriteData *wd, Bone* bone) +static void write_bone(WriteData *wd, Bone *bone) { Bone* cbone; diff --git a/source/blender/bmesh/intern/bmesh_error.h b/source/blender/bmesh/intern/bmesh_error.h index c3cedcb0e13..2ef146c7b38 100644 --- a/source/blender/bmesh/intern/bmesh_error.h +++ b/source/blender/bmesh/intern/bmesh_error.h @@ -84,8 +84,8 @@ void BMO_error_clear(BMesh *bm); (void)((!(a)) ? ( \ ( \ fprintf(stderr, \ - "BMESH_ASSERT failed: %s, %s(), %d at \'%s\'\n", \ - __FILE__, __func__, __LINE__, STRINGIFY(a)), \ + "BMESH_ASSERT failed: %s, %s(), %d at \'%s\'\n", \ + __FILE__, __func__, __LINE__, STRINGIFY(a)), \ _BMESH_DUMMY_ABORT(), \ NULL)) : NULL) diff --git a/source/blender/bmesh/intern/bmesh_mods.h b/source/blender/bmesh/intern/bmesh_mods.h index 802c6cca05d..790f0cb6267 100644 --- a/source/blender/bmesh/intern/bmesh_mods.h +++ b/source/blender/bmesh/intern/bmesh_mods.h @@ -47,9 +47,9 @@ BMFace *BM_face_split_n(BMesh *bm, BMFace *f, float cos[][3], int n, BMLoop **r_l, BMEdge *example); -BMEdge* BM_vert_collapse_faces(BMesh *bm, BMEdge *ke, BMVert *kv, float fac, +BMEdge *BM_vert_collapse_faces(BMesh *bm, BMEdge *ke, BMVert *kv, float fac, const short join_faces, const short kill_degenerate_faces); -BMEdge* BM_vert_collapse_edge(BMesh *bm, BMEdge *ke, BMVert *kv, +BMEdge *BM_vert_collapse_edge(BMesh *bm, BMEdge *ke, BMVert *kv, const short kill_degenerate_faces); diff --git a/source/blender/bmesh/intern/bmesh_operator_api.h b/source/blender/bmesh/intern/bmesh_operator_api.h index 91a48c782f0..0674103162c 100644 --- a/source/blender/bmesh/intern/bmesh_operator_api.h +++ b/source/blender/bmesh/intern/bmesh_operator_api.h @@ -289,7 +289,7 @@ void BMO_slot_vec_get(BMOperator *op, const char *slot_name, float r_vec[3]); /* only supports square mats */ /* size must be 3 or 4; this api is meant only for transformation matrices. * note that internally the matrix is stored in 4x4 form, and it's safe to - * call whichever BMO_Get_Mat* function you want. */ + * call whichever BMO_Get_MatXXX function you want. */ void BMO_slot_mat_set(BMOperator *op, const char *slot_name, const float *mat, int size); void BMO_slot_mat4_get(BMOperator *op, const char *slot_name, float r_mat[4][4]); void BMO_slot_mat3_set(BMOperator *op, const char *slot_name, float r_mat[3][3]); diff --git a/source/blender/collada/AnimationExporter.h b/source/blender/collada/AnimationExporter.h index 0a7832e9d64..7fd39765cc9 100644 --- a/source/blender/collada/AnimationExporter.h +++ b/source/blender/collada/AnimationExporter.h @@ -96,7 +96,7 @@ public: protected: const ExportSettings *export_settings; - void dae_animation(Object* ob, FCurve *fcu, char* transformName, bool is_param, Material *ma = NULL); + void dae_animation(Object *ob, FCurve *fcu, char *transformName, bool is_param, Material *ma = NULL); void write_bone_animation_matrix(Object *ob_arm, Bone *bone); @@ -161,7 +161,7 @@ protected: bool hasAnimations(Scene *sce); - char* extract_transform_name(char *rna_path); + char *extract_transform_name(char *rna_path); std::string getObjectBoneName(Object *ob, const FCurve * fcu); }; diff --git a/source/blender/collada/AnimationImporter.cpp b/source/blender/collada/AnimationImporter.cpp index a237222774d..d241926c20c 100644 --- a/source/blender/collada/AnimationImporter.cpp +++ b/source/blender/collada/AnimationImporter.cpp @@ -561,7 +561,7 @@ void AnimationImporter:: Assign_transform_animations(COLLADAFW::Transformation * case COLLADAFW::Transformation::MATRIX: /*{ - COLLADAFW::Matrix* mat = (COLLADAFW::Matrix*)transform; + COLLADAFW::Matrix *mat = (COLLADAFW::Matrix*)transform; COLLADABU::Math::Matrix4 mat4 = mat->getMatrix(); switch (binding->animationClass) { case COLLADAFW::AnimationList::TRANSFORM: diff --git a/source/blender/collada/TransformReader.h b/source/blender/collada/TransformReader.h index a08f4438d73..47e59a1bf52 100644 --- a/source/blender/collada/TransformReader.h +++ b/source/blender/collada/TransformReader.h @@ -56,7 +56,7 @@ public: COLLADAFW::Transformation *tm; // which transform is animated by an AnimationList->id }; - TransformReader(UnitConverter* conv); + TransformReader(UnitConverter *conv); void get_node_mat(float mat[][4], COLLADAFW::Node *node, std::map *animation_map, Object *ob); diff --git a/source/blender/collada/collada_internal.h b/source/blender/collada/collada_internal.h index b64c75e7960..c1f75f996ce 100644 --- a/source/blender/collada/collada_internal.h +++ b/source/blender/collada/collada_internal.h @@ -59,7 +59,7 @@ public: // Initialize with Z_UP, since Blender uses right-handed, z-up UnitConverter(); - void read_asset(const COLLADAFW::FileInfo* asset); + void read_asset(const COLLADAFW::FileInfo *asset); void convertVector3(COLLADABU::Math::Vector3 &vec, float *v); diff --git a/source/blender/editors/io/io_collada.c b/source/blender/editors/io/io_collada.c index ebfc0522f17..d0ce3f0cace 100644 --- a/source/blender/editors/io/io_collada.c +++ b/source/blender/editors/io/io_collada.c @@ -269,15 +269,15 @@ void WM_OT_collada_export(wmOperatorType *ot) RNA_def_boolean(ot->srna, "active_uv_only", 0, "Only Active UV layer", - "Export textures assigned to the object UV maps"); + "Export textures assigned to the object UV maps"); RNA_def_boolean(ot->srna, "include_uv_textures", 0, "Include UV Textures", - "Export textures assigned to the object UV maps"); + "Export textures assigned to the object UV maps"); RNA_def_boolean(ot->srna, "include_material_textures", 0, "Include Material Textures", - "Export textures assigned to the object Materials"); + "Export textures assigned to the object Materials"); - RNA_def_boolean(ot->srna, "use_texture_copies", 1, "Copy", + RNA_def_boolean(ot->srna, "use_texture_copies", 1, "Copy", "Copy textures to same folder where the .dae file is exported"); diff --git a/source/blender/editors/physics/physics_fluid.c b/source/blender/editors/physics/physics_fluid.c index 2f91652968f..f95b07bd71e 100644 --- a/source/blender/editors/physics/physics_fluid.c +++ b/source/blender/editors/physics/physics_fluid.c @@ -1113,7 +1113,7 @@ void fluidsimSettingsFree(FluidsimSettings *UNUSED(fss)) { } -FluidsimSettings* fluidsimSettingsCopy(FluidsimSettings *UNUSED(fss)) +FluidsimSettings *fluidsimSettingsCopy(FluidsimSettings *UNUSED(fss)) { return NULL; } diff --git a/source/blender/editors/space_clip/clip_dopesheet_ops.c b/source/blender/editors/space_clip/clip_dopesheet_ops.c index 6d1610f3f91..09f6271b6ef 100644 --- a/source/blender/editors/space_clip/clip_dopesheet_ops.c +++ b/source/blender/editors/space_clip/clip_dopesheet_ops.c @@ -157,7 +157,7 @@ void CLIP_OT_dopesheet_select_channel(wmOperatorType *ot) /* properties */ RNA_def_float_vector(ot->srna, "location", 2, NULL, -FLT_MAX, FLT_MAX, - "Location", "Mouse location to select channel", -100.0f, 100.0f); + "Location", "Mouse location to select channel", -100.0f, 100.0f); RNA_def_boolean(ot->srna, "extend", 0, - "Extend", "Extend selection rather than clearing the existing selection"); + "Extend", "Extend selection rather than clearing the existing selection"); } diff --git a/source/blender/editors/space_clip/clip_ops.c b/source/blender/editors/space_clip/clip_ops.c index 20b0ad509d3..aa2cadbd2d3 100644 --- a/source/blender/editors/space_clip/clip_ops.c +++ b/source/blender/editors/space_clip/clip_ops.c @@ -456,7 +456,7 @@ void CLIP_OT_view_pan(wmOperatorType *ot) /* properties */ RNA_def_float_vector(ot->srna, "offset", 2, NULL, -FLT_MAX, FLT_MAX, - "Offset", "Offset in floating point units, 1.0 is the width and height of the image", -FLT_MAX, FLT_MAX); + "Offset", "Offset in floating point units, 1.0 is the width and height of the image", -FLT_MAX, FLT_MAX); } /********************** view zoom operator *********************/ @@ -580,7 +580,7 @@ void CLIP_OT_view_zoom(wmOperatorType *ot) /* properties */ RNA_def_float(ot->srna, "factor", 0.0f, 0.0f, FLT_MAX, - "Factor", "Zoom factor, values higher than 1.0 zoom in, lower values zoom out", -FLT_MAX, FLT_MAX); + "Factor", "Zoom factor, values higher than 1.0 zoom in, lower values zoom out", -FLT_MAX, FLT_MAX); } /********************** view zoom in/out operator *********************/ @@ -701,7 +701,7 @@ void CLIP_OT_view_zoom_ratio(wmOperatorType *ot) /* properties */ RNA_def_float(ot->srna, "ratio", 0.0f, 0.0f, FLT_MAX, - "Ratio", "Zoom ratio, 1.0 is 1:1, higher is zoomed in, lower is zoomed out", -FLT_MAX, FLT_MAX); + "Ratio", "Zoom ratio, 1.0 is 1:1, higher is zoomed in, lower is zoomed out", -FLT_MAX, FLT_MAX); } /********************** view all operator *********************/ diff --git a/source/blender/editors/space_file/space_file.c b/source/blender/editors/space_file/space_file.c index 8c5ecb48613..fcf6f28b406 100644 --- a/source/blender/editors/space_file/space_file.c +++ b/source/blender/editors/space_file/space_file.c @@ -252,7 +252,7 @@ static void file_refresh(const bContext *C, ScrArea *UNUSED(sa)) static void file_listener(ScrArea *sa, wmNotifier *wmn) { - /* SpaceFile* sfile = (SpaceFile*)sa->spacedata.first; */ + /* SpaceFile *sfile = (SpaceFile*)sa->spacedata.first; */ /* context changes */ switch (wmn->category) { diff --git a/source/blender/editors/space_logic/logic_window.c b/source/blender/editors/space_logic/logic_window.c index a8bd0a443fa..08e0934e8ae 100644 --- a/source/blender/editors/space_logic/logic_window.c +++ b/source/blender/editors/space_logic/logic_window.c @@ -724,25 +724,25 @@ static const char *actuator_name(int type) static const char *actuator_pup(Object *owner) { switch (owner->type) { - case OB_ARMATURE: - return "Actuators %t|Action %x15|Armature %x23|Motion %x0|Constraint %x9|Ipo %x1" - "|Camera %x3|Sound %x5|Property %x6|Edit Object %x10" - "|Scene %x11|Random %x13|Message %x14|Game %x17" - "|Visibility %x18|2D Filter %x19|Parent %x20|State %x22"; - break; + case OB_ARMATURE: + return ("Actuators %t|Action %x15|Armature %x23|Motion %x0|Constraint %x9|Ipo %x1" + "|Camera %x3|Sound %x5|Property %x6|Edit Object %x10" + "|Scene %x11|Random %x13|Message %x14|Game %x17" + "|Visibility %x18|2D Filter %x19|Parent %x20|State %x22"); + break; - case OB_MESH: - return "Actuators %t|Shape Action %x21|Motion %x0|Constraint %x9|Ipo %x1" - "|Camera %x3|Sound %x5|Property %x6|Edit Object %x10" - "|Scene %x11|Random %x13|Message %x14|Game %x17" - "|Visibility %x18|2D Filter %x19|Parent %x20|State %x22"; - break; + case OB_MESH: + return ("Actuators %t|Shape Action %x21|Motion %x0|Constraint %x9|Ipo %x1" + "|Camera %x3|Sound %x5|Property %x6|Edit Object %x10" + "|Scene %x11|Random %x13|Message %x14|Game %x17" + "|Visibility %x18|2D Filter %x19|Parent %x20|State %x22"); + break; - default: - return "Actuators %t|Motion %x0|Constraint %x9|Ipo %x1" - "|Camera %x3|Sound %x5|Property %x6|Edit Object %x10" - "|Scene %x11|Random %x13|Message %x14|Game %x17" - "|Visibility %x18|2D Filter %x19|Parent %x20|State %x22"; + default: + return ("Actuators %t|Motion %x0|Constraint %x9|Ipo %x1" + "|Camera %x3|Sound %x5|Property %x6|Edit Object %x10" + "|Scene %x11|Random %x13|Message %x14|Game %x17" + "|Visibility %x18|2D Filter %x19|Parent %x20|State %x22"); } } diff --git a/source/blender/editors/space_sequencer/sequencer_intern.h b/source/blender/editors/space_sequencer/sequencer_intern.h index 81ee9927cb6..f5c3a4c4d89 100644 --- a/source/blender/editors/space_sequencer/sequencer_intern.h +++ b/source/blender/editors/space_sequencer/sequencer_intern.h @@ -52,7 +52,7 @@ struct ARegion *sequencer_has_buttons_region(struct ScrArea *sa); /* sequencer_draw.c */ void draw_timeline_seq(const struct bContext *C, struct ARegion *ar); -void draw_image_seq(const struct bContext* C, struct Scene *scene, struct ARegion *ar, struct SpaceSeq *sseq, int cfra, int offset, int draw_overlay); +void draw_image_seq(const struct bContext *C, struct Scene *scene, struct ARegion *ar, struct SpaceSeq *sseq, int cfra, int offset, int draw_overlay); void seq_reset_imageofs(struct SpaceSeq *sseq); diff --git a/source/blender/editors/space_view3d/view3d_fly.c b/source/blender/editors/space_view3d/view3d_fly.c index 561e97a8393..855771b17a2 100644 --- a/source/blender/editors/space_view3d/view3d_fly.c +++ b/source/blender/editors/space_view3d/view3d_fly.c @@ -489,7 +489,7 @@ static void flyEvent(FlyInfo *fly, wmEvent *event) else if (event->type == NDOF_MOTION) { /* do these automagically get delivered? yes. */ // puts("ndof motion detected in fly mode!"); - // static const char* tag_name = "3D mouse position"; + // static const char *tag_name = "3D mouse position"; wmNDOFMotionData *incoming_ndof = (wmNDOFMotionData *)event->customdata; switch (incoming_ndof->progress) { diff --git a/source/blender/imbuf/IMB_thumbs.h b/source/blender/imbuf/IMB_thumbs.h index e206541b135..a6f38516a14 100644 --- a/source/blender/imbuf/IMB_thumbs.h +++ b/source/blender/imbuf/IMB_thumbs.h @@ -63,16 +63,16 @@ typedef enum ThumbSource { // IB_metadata /* create thumbnail for file and returns new imbuf for thumbnail */ -ImBuf *IMB_thumb_create(const char* path, ThumbSize size, ThumbSource source, ImBuf *ibuf); +ImBuf *IMB_thumb_create(const char *path, ThumbSize size, ThumbSource source, ImBuf *ibuf); /* read thumbnail for file and returns new imbuf for thumbnail */ -ImBuf *IMB_thumb_read(const char* path, ThumbSize size); +ImBuf *IMB_thumb_read(const char *path, ThumbSize size); /* delete all thumbs for the file */ -void IMB_thumb_delete(const char* path, ThumbSize size); +void IMB_thumb_delete(const char *path, ThumbSize size); /* return the state of the thumb, needed to determine how to manage the thumb */ -ImBuf *IMB_thumb_manage(const char* path, ThumbSize size, ThumbSource source); +ImBuf *IMB_thumb_manage(const char *path, ThumbSize size, ThumbSource source); /* create the necessary dirs to store the thumbnails */ void IMB_thumb_makedirs(void); diff --git a/source/blender/imbuf/intern/imbuf_cocoa.m b/source/blender/imbuf/intern/imbuf_cocoa.m index ebfee7a1a30..10381e9d1c3 100644 --- a/source/blender/imbuf/intern/imbuf_cocoa.m +++ b/source/blender/imbuf/intern/imbuf_cocoa.m @@ -92,9 +92,8 @@ struct ImBuf *imb_cocoaLoadImage(unsigned char *mem, int size, int flags) /* allocate the image buffer */ ibuf = IMB_allocImBuf(bitmapSize.width, bitmapSize.height, 32/*RGBA*/, 0); if (!ibuf) { - fprintf(stderr, - "imb_cocoaLoadImage: could not allocate memory for the " \ - "image.\n"); + fprintf(stderr, + "imb_cocoaLoadImage: could not allocate memory for the image.\n"); [bitmapImage release]; [pool drain]; return NULL; @@ -243,8 +242,8 @@ short imb_cocoaSaveImage(struct ImBuf *ibuf, char *name, int flags) break; default: fprintf(stderr, - "imb_cocoaSaveImage: unsupported number of bytes per " - "pixel: %d\n", samplesperpixel); + "imb_cocoaSaveImage: unsupported number of bytes per " + "pixel: %d\n", samplesperpixel); return (0); } @@ -257,16 +256,16 @@ short imb_cocoaSaveImage(struct ImBuf *ibuf, char *name, int flags) /* Create bitmap image rep in blender format */ blBitmapFormatImage = [[NSBitmapImageRep alloc] initWithBitmapDataPlanes:NULL - pixelsWide:ibuf->x - pixelsHigh:ibuf->y - bitsPerSample:bitspersample samplesPerPixel:samplesperpixel hasAlpha:hasAlpha isPlanar:NO - colorSpaceName:colorSpace - bitmapFormat:NSAlphaNonpremultipliedBitmapFormat - bytesPerRow:(ibuf->x*bitspersample*samplesperpixel/8) - bitsPerPixel:(bitspersample*samplesperpixel)]; + pixelsWide:ibuf->x + pixelsHigh:ibuf->y + bitsPerSample:bitspersample samplesPerPixel:samplesperpixel hasAlpha:hasAlpha isPlanar:NO + colorSpaceName:colorSpace + bitmapFormat:NSAlphaNonpremultipliedBitmapFormat + bytesPerRow:(ibuf->x*bitspersample*samplesperpixel/8) + bitsPerPixel:(bitspersample*samplesperpixel)]; if (!blBitmapFormatImage) { - [pool drain]; - return FALSE; + [pool drain]; + return FALSE; } /* setup pointers */ diff --git a/source/blender/makesrna/intern/rna_tracking.c b/source/blender/makesrna/intern/rna_tracking.c index 0898ba5608f..172a79970b5 100644 --- a/source/blender/makesrna/intern/rna_tracking.c +++ b/source/blender/makesrna/intern/rna_tracking.c @@ -910,7 +910,7 @@ static void rna_def_trackingMarkers(BlenderRNA *brna, PropertyRNA *cprop) "Frame number to find marker for", MINFRAME, MAXFRAME); RNA_def_property_flag(parm, PROP_REQUIRED); parm = RNA_def_boolean(func, "exact", TRUE, "Exact", - "Get marker at exact frame number rather than get estimated marker"); + "Get marker at exact frame number rather than get estimated marker"); parm = RNA_def_pointer(func, "marker", "MovieTrackingMarker", "", "Marker for specified frame"); RNA_def_function_return(func, parm); diff --git a/source/blender/modifiers/intern/MOD_displace.c b/source/blender/modifiers/intern/MOD_displace.c index 4a6d5ceb10f..988d15e8df4 100644 --- a/source/blender/modifiers/intern/MOD_displace.c +++ b/source/blender/modifiers/intern/MOD_displace.c @@ -185,7 +185,7 @@ static void displaceModifier_do( if (dmd->texture) { tex_co = MEM_callocN(sizeof(*tex_co) * numVerts, - "displaceModifier_do tex_co"); + "displaceModifier_do tex_co"); get_texture_coords((MappingInfoModifierData *)dmd, ob, dm, vertexCos, tex_co, numVerts); modifier_init_texture(dmd->modifier.scene, dmd->texture); diff --git a/source/blender/python/bmesh/bmesh_py_api.c b/source/blender/python/bmesh/bmesh_py_api.c index f3e5b300ced..e02efc79da0 100644 --- a/source/blender/python/bmesh/bmesh_py_api.c +++ b/source/blender/python/bmesh/bmesh_py_api.c @@ -97,9 +97,9 @@ static PyObject *bpy_bm_from_edit_mesh(PyObject *UNUSED(self), PyObject *value) } static struct PyMethodDef BPy_BM_methods[] = { - {"new", (PyCFunction)bpy_bm_new, METH_NOARGS, bpy_bm_new_doc}, - {"from_edit_mesh", (PyCFunction)bpy_bm_from_edit_mesh, METH_O, bpy_bm_from_edit_mesh_doc}, - {NULL, NULL, 0, NULL} + {"new", (PyCFunction)bpy_bm_new, METH_NOARGS, bpy_bm_new_doc}, + {"from_edit_mesh", (PyCFunction)bpy_bm_from_edit_mesh, METH_O, bpy_bm_from_edit_mesh_doc}, + {NULL, NULL, 0, NULL} }; PyDoc_STRVAR(BPy_BM_doc, diff --git a/source/blender/python/bmesh/bmesh_py_ops.c b/source/blender/python/bmesh/bmesh_py_ops.c index 8e7c4810b08..c16b1fb901f 100644 --- a/source/blender/python/bmesh/bmesh_py_ops.c +++ b/source/blender/python/bmesh/bmesh_py_ops.c @@ -420,7 +420,7 @@ static PyObject *bpy_bmesh_fmod_getattro(PyObject *UNUSED(self), PyObject *pynam } PyErr_Format(PyExc_AttributeError, - "BMeshOpsModule: operator \"%.200s\" doesn't exist", + "BMeshOpsModule: operator \"%.200s\" doesn't exist", name); return NULL; } diff --git a/source/blender/python/bmesh/bmesh_py_types.c b/source/blender/python/bmesh/bmesh_py_types.c index 24e7cd575ed..d7d9baf35ed 100644 --- a/source/blender/python/bmesh/bmesh_py_types.c +++ b/source/blender/python/bmesh/bmesh_py_types.c @@ -55,34 +55,34 @@ /* scene does not use BM_* flags. */ PyC_FlagSet bpy_bm_scene_vert_edge_face_flags[] = { - {1, "VERT"}, - {2, "EDGE"}, - {4, "FACE"}, - {0, NULL} + {1, "VERT"}, + {2, "EDGE"}, + {4, "FACE"}, + {0, NULL} }; PyC_FlagSet bpy_bm_htype_vert_edge_face_flags[] = { - {BM_VERT, "VERT"}, - {BM_EDGE, "EDGE"}, - {BM_FACE, "FACE"}, - {0, NULL} + {BM_VERT, "VERT"}, + {BM_EDGE, "EDGE"}, + {BM_FACE, "FACE"}, + {0, NULL} }; PyC_FlagSet bpy_bm_htype_all_flags[] = { - {BM_VERT, "VERT"}, - {BM_LOOP, "EDGE"}, - {BM_FACE, "FACE"}, - {BM_LOOP, "LOOP"}, - {0, NULL} + {BM_VERT, "VERT"}, + {BM_LOOP, "EDGE"}, + {BM_FACE, "FACE"}, + {BM_LOOP, "LOOP"}, + {0, NULL} }; PyC_FlagSet bpy_bm_hflag_all_flags[] = { - {BM_ELEM_SELECT, "SELECT"}, - {BM_ELEM_HIDDEN, "HIDE"}, - {BM_ELEM_SEAM, "SEAM"}, - {BM_ELEM_SMOOTH, "SMOOTH"}, - {BM_ELEM_TAG, "TAG"}, - {0, NULL} + {BM_ELEM_SELECT, "SELECT"}, + {BM_ELEM_HIDDEN, "HIDE"}, + {BM_ELEM_SEAM, "SEAM"}, + {BM_ELEM_SMOOTH, "SMOOTH"}, + {BM_ELEM_TAG, "TAG"}, + {0, NULL} }; /* py-type definitions @@ -556,131 +556,131 @@ static PyObject *bpy_bmelemseq_layers_get(BPy_BMElemSeq *self, void *htype) } static PyGetSetDef bpy_bmesh_getseters[] = { - {(char *)"verts", (getter)bpy_bmvertseq_get, (setter)NULL, (char *)bpy_bmvertseq_doc, NULL}, - {(char *)"edges", (getter)bpy_bmedgeseq_get, (setter)NULL, (char *)bpy_bmedgeseq_doc, NULL}, - {(char *)"faces", (getter)bpy_bmfaceseq_get, (setter)NULL, (char *)bpy_bmfaceseq_doc, NULL}, - {(char *)"loops", (getter)bpy_bmloopseq_get, (setter)NULL, (char *)bpy_bmloopseq_doc, NULL}, - {(char *)"select_mode", (getter)bpy_bmesh_select_mode_get, (setter)bpy_bmesh_select_mode_set, (char *)bpy_bmesh_select_mode_doc, NULL}, + {(char *)"verts", (getter)bpy_bmvertseq_get, (setter)NULL, (char *)bpy_bmvertseq_doc, NULL}, + {(char *)"edges", (getter)bpy_bmedgeseq_get, (setter)NULL, (char *)bpy_bmedgeseq_doc, NULL}, + {(char *)"faces", (getter)bpy_bmfaceseq_get, (setter)NULL, (char *)bpy_bmfaceseq_doc, NULL}, + {(char *)"loops", (getter)bpy_bmloopseq_get, (setter)NULL, (char *)bpy_bmloopseq_doc, NULL}, + {(char *)"select_mode", (getter)bpy_bmesh_select_mode_get, (setter)bpy_bmesh_select_mode_set, (char *)bpy_bmesh_select_mode_doc, NULL}, - {(char *)"select_history", (getter)bpy_bmesh_select_history_get, (setter)bpy_bmesh_select_history_set, (char *)bpy_bmesh_select_history_doc, NULL}, + {(char *)"select_history", (getter)bpy_bmesh_select_history_get, (setter)bpy_bmesh_select_history_set, (char *)bpy_bmesh_select_history_doc, NULL}, - /* readonly checks */ - {(char *)"is_wrapped", (getter)bpy_bmesh_is_wrapped_get, (setter)NULL, (char *)bpy_bmesh_is_wrapped_doc, NULL}, /* as with mathutils */ - {(char *)"is_valid", (getter)bpy_bm_is_valid_get, (setter)NULL, (char *)bpy_bm_is_valid_doc, NULL}, + /* readonly checks */ + {(char *)"is_wrapped", (getter)bpy_bmesh_is_wrapped_get, (setter)NULL, (char *)bpy_bmesh_is_wrapped_doc, NULL}, /* as with mathutils */ + {(char *)"is_valid", (getter)bpy_bm_is_valid_get, (setter)NULL, (char *)bpy_bm_is_valid_doc, NULL}, - {NULL, NULL, NULL, NULL, NULL} /* Sentinel */ + {NULL, NULL, NULL, NULL, NULL} /* Sentinel */ }; static PyGetSetDef bpy_bmvert_getseters[] = { - /* generic */ - {(char *)"select", (getter)bpy_bm_elem_hflag_get, (setter)bpy_bm_elem_hflag_set, (char *)bpy_bm_elem_select_doc, (void *)BM_ELEM_SELECT}, - {(char *)"hide", (getter)bpy_bm_elem_hflag_get, (setter)bpy_bm_elem_hflag_set, (char *)bpy_bm_elem_hide_doc, (void *)BM_ELEM_HIDDEN}, - {(char *)"tag", (getter)bpy_bm_elem_hflag_get, (setter)bpy_bm_elem_hflag_set, (char *)bpy_bm_elem_tag_doc, (void *)BM_ELEM_TAG}, - {(char *)"index", (getter)bpy_bm_elem_index_get, (setter)bpy_bm_elem_index_set, (char *)bpy_bm_elem_index_doc, NULL}, + /* generic */ + {(char *)"select", (getter)bpy_bm_elem_hflag_get, (setter)bpy_bm_elem_hflag_set, (char *)bpy_bm_elem_select_doc, (void *)BM_ELEM_SELECT}, + {(char *)"hide", (getter)bpy_bm_elem_hflag_get, (setter)bpy_bm_elem_hflag_set, (char *)bpy_bm_elem_hide_doc, (void *)BM_ELEM_HIDDEN}, + {(char *)"tag", (getter)bpy_bm_elem_hflag_get, (setter)bpy_bm_elem_hflag_set, (char *)bpy_bm_elem_tag_doc, (void *)BM_ELEM_TAG}, + {(char *)"index", (getter)bpy_bm_elem_index_get, (setter)bpy_bm_elem_index_set, (char *)bpy_bm_elem_index_doc, NULL}, - {(char *)"co", (getter)bpy_bmvert_co_get, (setter)bpy_bmvert_co_set, (char *)bpy_bmvert_co_doc, NULL}, - {(char *)"normal", (getter)bpy_bmvert_normal_get, (setter)bpy_bmvert_normal_set, (char *)bpy_bmvert_normal_doc, NULL}, + {(char *)"co", (getter)bpy_bmvert_co_get, (setter)bpy_bmvert_co_set, (char *)bpy_bmvert_co_doc, NULL}, + {(char *)"normal", (getter)bpy_bmvert_normal_get, (setter)bpy_bmvert_normal_set, (char *)bpy_bmvert_normal_doc, NULL}, - /* connectivity data */ - {(char *)"link_edges", (getter)bpy_bmelemseq_elem_get, (setter)NULL, (char *)bpy_bmvert_link_edges_doc, (void *)BM_EDGES_OF_VERT}, - {(char *)"link_faces", (getter)bpy_bmelemseq_elem_get, (setter)NULL, (char *)bpy_bmvert_link_faces_doc, (void *)BM_FACES_OF_VERT}, - {(char *)"link_loops", (getter)bpy_bmelemseq_elem_get, (setter)NULL, (char *)bpy_bmvert_link_loops_doc, (void *)BM_LOOPS_OF_VERT}, + /* connectivity data */ + {(char *)"link_edges", (getter)bpy_bmelemseq_elem_get, (setter)NULL, (char *)bpy_bmvert_link_edges_doc, (void *)BM_EDGES_OF_VERT}, + {(char *)"link_faces", (getter)bpy_bmelemseq_elem_get, (setter)NULL, (char *)bpy_bmvert_link_faces_doc, (void *)BM_FACES_OF_VERT}, + {(char *)"link_loops", (getter)bpy_bmelemseq_elem_get, (setter)NULL, (char *)bpy_bmvert_link_loops_doc, (void *)BM_LOOPS_OF_VERT}, - /* readonly checks */ - {(char *)"is_manifold", (getter)bpy_bmvert_is_manifold_get, (setter)NULL, (char *)bpy_bmvert_is_manifold_doc, NULL}, - {(char *)"is_wire", (getter)bpy_bmvert_is_wire_get, (setter)NULL, (char *)bpy_bmvert_is_wire_doc, NULL}, - {(char *)"is_valid", (getter)bpy_bm_is_valid_get, (setter)NULL, (char *)bpy_bm_is_valid_doc, NULL}, + /* readonly checks */ + {(char *)"is_manifold", (getter)bpy_bmvert_is_manifold_get, (setter)NULL, (char *)bpy_bmvert_is_manifold_doc, NULL}, + {(char *)"is_wire", (getter)bpy_bmvert_is_wire_get, (setter)NULL, (char *)bpy_bmvert_is_wire_doc, NULL}, + {(char *)"is_valid", (getter)bpy_bm_is_valid_get, (setter)NULL, (char *)bpy_bm_is_valid_doc, NULL}, - {NULL, NULL, NULL, NULL, NULL} /* Sentinel */ + {NULL, NULL, NULL, NULL, NULL} /* Sentinel */ }; static PyGetSetDef bpy_bmedge_getseters[] = { - /* generic */ - {(char *)"select", (getter)bpy_bm_elem_hflag_get, (setter)bpy_bm_elem_hflag_set, (char *)bpy_bm_elem_select_doc, (void *)BM_ELEM_SELECT}, - {(char *)"hide", (getter)bpy_bm_elem_hflag_get, (setter)bpy_bm_elem_hflag_set, (char *)bpy_bm_elem_hide_doc, (void *)BM_ELEM_HIDDEN}, - {(char *)"tag", (getter)bpy_bm_elem_hflag_get, (setter)bpy_bm_elem_hflag_set, (char *)bpy_bm_elem_tag_doc, (void *)BM_ELEM_TAG}, - {(char *)"index", (getter)bpy_bm_elem_index_get, (setter)bpy_bm_elem_index_set, (char *)bpy_bm_elem_index_doc, NULL}, + /* generic */ + {(char *)"select", (getter)bpy_bm_elem_hflag_get, (setter)bpy_bm_elem_hflag_set, (char *)bpy_bm_elem_select_doc, (void *)BM_ELEM_SELECT}, + {(char *)"hide", (getter)bpy_bm_elem_hflag_get, (setter)bpy_bm_elem_hflag_set, (char *)bpy_bm_elem_hide_doc, (void *)BM_ELEM_HIDDEN}, + {(char *)"tag", (getter)bpy_bm_elem_hflag_get, (setter)bpy_bm_elem_hflag_set, (char *)bpy_bm_elem_tag_doc, (void *)BM_ELEM_TAG}, + {(char *)"index", (getter)bpy_bm_elem_index_get, (setter)bpy_bm_elem_index_set, (char *)bpy_bm_elem_index_doc, NULL}, - {(char *)"smooth", (getter)bpy_bm_elem_hflag_get, (setter)bpy_bm_elem_hflag_set, (char *)bpy_bm_elem_smooth_doc, (void *)BM_ELEM_SMOOTH}, - {(char *)"seam", (getter)bpy_bm_elem_hflag_get, (setter)bpy_bm_elem_hflag_set, (char *)bpy_bm_elem_seam_doc, (void *)BM_ELEM_SEAM}, + {(char *)"smooth", (getter)bpy_bm_elem_hflag_get, (setter)bpy_bm_elem_hflag_set, (char *)bpy_bm_elem_smooth_doc, (void *)BM_ELEM_SMOOTH}, + {(char *)"seam", (getter)bpy_bm_elem_hflag_get, (setter)bpy_bm_elem_hflag_set, (char *)bpy_bm_elem_seam_doc, (void *)BM_ELEM_SEAM}, - /* connectivity data */ - {(char *)"verts", (getter)bpy_bmelemseq_elem_get, (setter)NULL, (char *)bpy_bmedge_verts_doc, (void *)BM_VERTS_OF_EDGE}, + /* connectivity data */ + {(char *)"verts", (getter)bpy_bmelemseq_elem_get, (setter)NULL, (char *)bpy_bmedge_verts_doc, (void *)BM_VERTS_OF_EDGE}, - {(char *)"link_faces", (getter)bpy_bmelemseq_elem_get, (setter)NULL, (char *)bpy_bmedge_link_faces_doc, (void *)BM_FACES_OF_EDGE}, - {(char *)"link_loops", (getter)bpy_bmelemseq_elem_get, (setter)NULL, (char *)bpy_bmedge_link_loops_doc, (void *)BM_LOOPS_OF_EDGE}, + {(char *)"link_faces", (getter)bpy_bmelemseq_elem_get, (setter)NULL, (char *)bpy_bmedge_link_faces_doc, (void *)BM_FACES_OF_EDGE}, + {(char *)"link_loops", (getter)bpy_bmelemseq_elem_get, (setter)NULL, (char *)bpy_bmedge_link_loops_doc, (void *)BM_LOOPS_OF_EDGE}, - /* readonly checks */ - {(char *)"is_manifold", (getter)bpy_bmedge_is_manifold_get, (setter)NULL, (char *)bpy_bmedge_is_manifold_doc, NULL}, - {(char *)"is_wire", (getter)bpy_bmedge_is_wire_get, (setter)NULL, (char *)bpy_bmedge_is_wire_doc, NULL}, - {(char *)"is_boundary", (getter)bpy_bmedge_is_boundary_get, (setter)NULL, (char *)bpy_bmedge_is_boundary_doc, NULL}, - {(char *)"is_valid", (getter)bpy_bm_is_valid_get, (setter)NULL, (char *)bpy_bm_is_valid_doc, NULL}, + /* readonly checks */ + {(char *)"is_manifold", (getter)bpy_bmedge_is_manifold_get, (setter)NULL, (char *)bpy_bmedge_is_manifold_doc, NULL}, + {(char *)"is_wire", (getter)bpy_bmedge_is_wire_get, (setter)NULL, (char *)bpy_bmedge_is_wire_doc, NULL}, + {(char *)"is_boundary", (getter)bpy_bmedge_is_boundary_get, (setter)NULL, (char *)bpy_bmedge_is_boundary_doc, NULL}, + {(char *)"is_valid", (getter)bpy_bm_is_valid_get, (setter)NULL, (char *)bpy_bm_is_valid_doc, NULL}, - {NULL, NULL, NULL, NULL, NULL} /* Sentinel */ + {NULL, NULL, NULL, NULL, NULL} /* Sentinel */ }; static PyGetSetDef bpy_bmface_getseters[] = { - /* generic */ - {(char *)"select", (getter)bpy_bm_elem_hflag_get, (setter)bpy_bm_elem_hflag_set, (char *)bpy_bm_elem_select_doc, (void *)BM_ELEM_SELECT}, - {(char *)"hide", (getter)bpy_bm_elem_hflag_get, (setter)bpy_bm_elem_hflag_set, (char *)bpy_bm_elem_hide_doc, (void *)BM_ELEM_HIDDEN}, - {(char *)"tag", (getter)bpy_bm_elem_hflag_get, (setter)bpy_bm_elem_hflag_set, (char *)bpy_bm_elem_tag_doc, (void *)BM_ELEM_TAG}, - {(char *)"index", (getter)bpy_bm_elem_index_get, (setter)bpy_bm_elem_index_set, (char *)bpy_bm_elem_index_doc, NULL}, + /* generic */ + {(char *)"select", (getter)bpy_bm_elem_hflag_get, (setter)bpy_bm_elem_hflag_set, (char *)bpy_bm_elem_select_doc, (void *)BM_ELEM_SELECT}, + {(char *)"hide", (getter)bpy_bm_elem_hflag_get, (setter)bpy_bm_elem_hflag_set, (char *)bpy_bm_elem_hide_doc, (void *)BM_ELEM_HIDDEN}, + {(char *)"tag", (getter)bpy_bm_elem_hflag_get, (setter)bpy_bm_elem_hflag_set, (char *)bpy_bm_elem_tag_doc, (void *)BM_ELEM_TAG}, + {(char *)"index", (getter)bpy_bm_elem_index_get, (setter)bpy_bm_elem_index_set, (char *)bpy_bm_elem_index_doc, NULL}, - {(char *)"smooth", (getter)bpy_bm_elem_hflag_get, (setter)bpy_bm_elem_hflag_set, (char *)bpy_bm_elem_smooth_doc, (void *)BM_ELEM_SMOOTH}, + {(char *)"smooth", (getter)bpy_bm_elem_hflag_get, (setter)bpy_bm_elem_hflag_set, (char *)bpy_bm_elem_smooth_doc, (void *)BM_ELEM_SMOOTH}, - {(char *)"normal", (getter)bpy_bmface_normal_get, (setter)bpy_bmface_normal_set, (char *)bpy_bmface_normal_doc, NULL}, + {(char *)"normal", (getter)bpy_bmface_normal_get, (setter)bpy_bmface_normal_set, (char *)bpy_bmface_normal_doc, NULL}, - {(char *)"material_index", (getter)bpy_bmface_material_index_get, (setter)bpy_bmface_material_index_set, (char *)bpy_bmface_material_index_doc, NULL}, + {(char *)"material_index", (getter)bpy_bmface_material_index_get, (setter)bpy_bmface_material_index_set, (char *)bpy_bmface_material_index_doc, NULL}, - /* connectivity data */ - {(char *)"verts", (getter)bpy_bmelemseq_elem_get, (setter)NULL, (char *)bpy_bmface_verts_doc, (void *)BM_VERTS_OF_FACE}, - {(char *)"edges", (getter)bpy_bmelemseq_elem_get, (setter)NULL, (char *)bpy_bmface_edges_doc, (void *)BM_EDGES_OF_FACE}, - {(char *)"loops", (getter)bpy_bmelemseq_elem_get, (setter)NULL, (char *)bpy_bmface_loops_doc, (void *)BM_LOOPS_OF_FACE}, + /* connectivity data */ + {(char *)"verts", (getter)bpy_bmelemseq_elem_get, (setter)NULL, (char *)bpy_bmface_verts_doc, (void *)BM_VERTS_OF_FACE}, + {(char *)"edges", (getter)bpy_bmelemseq_elem_get, (setter)NULL, (char *)bpy_bmface_edges_doc, (void *)BM_EDGES_OF_FACE}, + {(char *)"loops", (getter)bpy_bmelemseq_elem_get, (setter)NULL, (char *)bpy_bmface_loops_doc, (void *)BM_LOOPS_OF_FACE}, - /* readonly checks */ - {(char *)"is_valid", (getter)bpy_bm_is_valid_get, (setter)NULL, (char *)bpy_bm_is_valid_doc, NULL}, + /* readonly checks */ + {(char *)"is_valid", (getter)bpy_bm_is_valid_get, (setter)NULL, (char *)bpy_bm_is_valid_doc, NULL}, - {NULL, NULL, NULL, NULL, NULL} /* Sentinel */ + {NULL, NULL, NULL, NULL, NULL} /* Sentinel */ }; static PyGetSetDef bpy_bmloop_getseters[] = { - /* generic */ - // flags are available but not used for loops. - // {(char *)"select", (getter)bpy_bm_elem_hflag_get, (setter)bpy_bm_elem_hflag_set, (char *)bpy_bm_elem_select_doc, (void *)BM_ELEM_SELECT}, - // {(char *)"hide", (getter)bpy_bm_elem_hflag_get, (setter)bpy_bm_elem_hflag_set, (char *)bpy_bm_elem_hide_doc, (void *)BM_ELEM_HIDDEN}, - {(char *)"tag", (getter)bpy_bm_elem_hflag_get, (setter)bpy_bm_elem_hflag_set, (char *)bpy_bm_elem_tag_doc, (void *)BM_ELEM_TAG}, - {(char *)"index", (getter)bpy_bm_elem_index_get, (setter)bpy_bm_elem_index_set, (char *)bpy_bm_elem_index_doc, NULL}, + /* generic */ + // flags are available but not used for loops. + // {(char *)"select", (getter)bpy_bm_elem_hflag_get, (setter)bpy_bm_elem_hflag_set, (char *)bpy_bm_elem_select_doc, (void *)BM_ELEM_SELECT}, + // {(char *)"hide", (getter)bpy_bm_elem_hflag_get, (setter)bpy_bm_elem_hflag_set, (char *)bpy_bm_elem_hide_doc, (void *)BM_ELEM_HIDDEN}, + {(char *)"tag", (getter)bpy_bm_elem_hflag_get, (setter)bpy_bm_elem_hflag_set, (char *)bpy_bm_elem_tag_doc, (void *)BM_ELEM_TAG}, + {(char *)"index", (getter)bpy_bm_elem_index_get, (setter)bpy_bm_elem_index_set, (char *)bpy_bm_elem_index_doc, NULL}, - {(char *)"vert", (getter)bpy_bmloop_vert_get, (setter)NULL, (char *)bpy_bmloop_vert_doc, NULL}, - {(char *)"edge", (getter)bpy_bmloop_edge_get, (setter)NULL, (char *)bpy_bmloop_edge_doc, NULL}, - {(char *)"face", (getter)bpy_bmloop_face_get, (setter)NULL, (char *)bpy_bmloop_face_doc, NULL}, + {(char *)"vert", (getter)bpy_bmloop_vert_get, (setter)NULL, (char *)bpy_bmloop_vert_doc, NULL}, + {(char *)"edge", (getter)bpy_bmloop_edge_get, (setter)NULL, (char *)bpy_bmloop_edge_doc, NULL}, + {(char *)"face", (getter)bpy_bmloop_face_get, (setter)NULL, (char *)bpy_bmloop_face_doc, NULL}, - /* connectivity data */ - {(char *)"link_loops", (getter)bpy_bmelemseq_elem_get, (setter)NULL, (char *)bpy_bmloops_link_loops_doc, (void *)BM_LOOPS_OF_LOOP}, - {(char *)"link_loop_next", (getter)bpy_bmloop_link_loop_next_get, (setter)NULL, (char *)bpy_bmloop_link_loop_next_doc, NULL}, - {(char *)"link_loop_prev", (getter)bpy_bmloop_link_loop_prev_get, (setter)NULL, (char *)bpy_bmloop_link_loop_prev_doc, NULL}, + /* connectivity data */ + {(char *)"link_loops", (getter)bpy_bmelemseq_elem_get, (setter)NULL, (char *)bpy_bmloops_link_loops_doc, (void *)BM_LOOPS_OF_LOOP}, + {(char *)"link_loop_next", (getter)bpy_bmloop_link_loop_next_get, (setter)NULL, (char *)bpy_bmloop_link_loop_next_doc, NULL}, + {(char *)"link_loop_prev", (getter)bpy_bmloop_link_loop_prev_get, (setter)NULL, (char *)bpy_bmloop_link_loop_prev_doc, NULL}, - /* readonly checks */ - {(char *)"is_valid", (getter)bpy_bm_is_valid_get, (setter)NULL, (char *)bpy_bm_is_valid_doc, NULL}, + /* readonly checks */ + {(char *)"is_valid", (getter)bpy_bm_is_valid_get, (setter)NULL, (char *)bpy_bm_is_valid_doc, NULL}, - {NULL, NULL, NULL, NULL, NULL} /* Sentinel */ + {NULL, NULL, NULL, NULL, NULL} /* Sentinel */ }; static PyGetSetDef bpy_bmvertseq_getseters[] = { - {(char *)"layers", (getter)bpy_bmelemseq_layers_get, (setter)NULL, (char *)bpy_bmelemseq_layers_doc, (void *)BM_VERT}, - {NULL, NULL, NULL, NULL, NULL} /* Sentinel */ + {(char *)"layers", (getter)bpy_bmelemseq_layers_get, (setter)NULL, (char *)bpy_bmelemseq_layers_doc, (void *)BM_VERT}, + {NULL, NULL, NULL, NULL, NULL} /* Sentinel */ }; static PyGetSetDef bpy_bmedgeseq_getseters[] = { - {(char *)"layers", (getter)bpy_bmelemseq_layers_get, (setter)NULL, (char *)bpy_bmelemseq_layers_doc, (void *)BM_EDGE}, - {NULL, NULL, NULL, NULL, NULL} /* Sentinel */ + {(char *)"layers", (getter)bpy_bmelemseq_layers_get, (setter)NULL, (char *)bpy_bmelemseq_layers_doc, (void *)BM_EDGE}, + {NULL, NULL, NULL, NULL, NULL} /* Sentinel */ }; static PyGetSetDef bpy_bmfaceseq_getseters[] = { - {(char *)"layers", (getter)bpy_bmelemseq_layers_get, (setter)NULL, (char *)bpy_bmelemseq_layers_doc, (void *)BM_FACE}, - {NULL, NULL, NULL, NULL, NULL} /* Sentinel */ + {(char *)"layers", (getter)bpy_bmelemseq_layers_get, (setter)NULL, (char *)bpy_bmelemseq_layers_doc, (void *)BM_FACE}, + {NULL, NULL, NULL, NULL, NULL} /* Sentinel */ }; static PyGetSetDef bpy_bmloopseq_getseters[] = { - {(char *)"layers", (getter)bpy_bmelemseq_layers_get, (setter)NULL, (char *)bpy_bmelemseq_layers_doc, (void *)BM_LOOP}, - {NULL, NULL, NULL, NULL, NULL} /* Sentinel */ + {(char *)"layers", (getter)bpy_bmelemseq_layers_get, (setter)NULL, (char *)bpy_bmelemseq_layers_doc, (void *)BM_LOOP}, + {NULL, NULL, NULL, NULL, NULL} /* Sentinel */ }; @@ -2166,7 +2166,7 @@ static PyObject *bpy_bmelemseq_sort(BPy_BMElemSeq *self, PyObject *args, PyObjec if (keyfunc != NULL && !PyCallable_Check(keyfunc)) { PyErr_SetString(PyExc_TypeError, - "the 'key' argument is not a callable object"); + "the 'key' argument is not a callable object"); return NULL; } @@ -2280,129 +2280,129 @@ static PyObject *bpy_bmelemseq_sort(BPy_BMElemSeq *self, PyObject *args, PyObjec } static struct PyMethodDef bpy_bmesh_methods[] = { - /* utility */ - {"copy", (PyCFunction)bpy_bmesh_copy, METH_NOARGS, bpy_bmesh_copy_doc}, - {"clear", (PyCFunction)bpy_bmesh_clear, METH_NOARGS, bpy_bmesh_clear_doc}, - {"free", (PyCFunction)bpy_bmesh_free, METH_NOARGS, bpy_bmesh_free_doc}, + /* utility */ + {"copy", (PyCFunction)bpy_bmesh_copy, METH_NOARGS, bpy_bmesh_copy_doc}, + {"clear", (PyCFunction)bpy_bmesh_clear, METH_NOARGS, bpy_bmesh_clear_doc}, + {"free", (PyCFunction)bpy_bmesh_free, METH_NOARGS, bpy_bmesh_free_doc}, - /* conversion */ - {"from_object", (PyCFunction)bpy_bmesh_from_object, METH_VARARGS | METH_KEYWORDS, bpy_bmesh_from_object_doc}, - {"from_mesh", (PyCFunction)bpy_bmesh_from_mesh, METH_VARARGS | METH_KEYWORDS, bpy_bmesh_from_mesh_doc}, - {"to_mesh", (PyCFunction)bpy_bmesh_to_mesh, METH_VARARGS, bpy_bmesh_to_mesh_doc}, + /* conversion */ + {"from_object", (PyCFunction)bpy_bmesh_from_object, METH_VARARGS | METH_KEYWORDS, bpy_bmesh_from_object_doc}, + {"from_mesh", (PyCFunction)bpy_bmesh_from_mesh, METH_VARARGS | METH_KEYWORDS, bpy_bmesh_from_mesh_doc}, + {"to_mesh", (PyCFunction)bpy_bmesh_to_mesh, METH_VARARGS, bpy_bmesh_to_mesh_doc}, - /* meshdata */ - {"select_flush_mode", (PyCFunction)bpy_bmesh_select_flush_mode, METH_NOARGS, bpy_bmesh_select_flush_mode_doc}, - {"select_flush", (PyCFunction)bpy_bmesh_select_flush, METH_O, bpy_bmesh_select_flush_doc}, - {"normal_update", (PyCFunction)bpy_bmesh_normal_update, METH_VARARGS, bpy_bmesh_normal_update_doc}, - {"transform", (PyCFunction)bpy_bmesh_transform, METH_VARARGS | METH_KEYWORDS, bpy_bmesh_transform_doc}, - {NULL, NULL, 0, NULL} + /* meshdata */ + {"select_flush_mode", (PyCFunction)bpy_bmesh_select_flush_mode, METH_NOARGS, bpy_bmesh_select_flush_mode_doc}, + {"select_flush", (PyCFunction)bpy_bmesh_select_flush, METH_O, bpy_bmesh_select_flush_doc}, + {"normal_update", (PyCFunction)bpy_bmesh_normal_update, METH_VARARGS, bpy_bmesh_normal_update_doc}, + {"transform", (PyCFunction)bpy_bmesh_transform, METH_VARARGS | METH_KEYWORDS, bpy_bmesh_transform_doc}, + {NULL, NULL, 0, NULL} }; static struct PyMethodDef bpy_bmvert_methods[] = { - {"select_set", (PyCFunction)bpy_bm_elem_select_set, METH_O, bpy_bm_elem_select_set_doc}, - {"hide_set", (PyCFunction)bpy_bm_elem_hide_set, METH_O, bpy_bm_elem_hide_set_doc}, - {"copy_from", (PyCFunction)bpy_bm_elem_copy_from, METH_O, bpy_bm_elem_copy_from_doc}, - {"copy_from_face_interp", (PyCFunction)bpy_bmvert_copy_from_face_interp, METH_VARARGS, bpy_bmvert_copy_from_face_interp_doc}, - {"copy_from_vert_interp", (PyCFunction)bpy_bmvert_copy_from_vert_interp, METH_VARARGS, bpy_bmvert_copy_from_vert_interp_doc}, + {"select_set", (PyCFunction)bpy_bm_elem_select_set, METH_O, bpy_bm_elem_select_set_doc}, + {"hide_set", (PyCFunction)bpy_bm_elem_hide_set, METH_O, bpy_bm_elem_hide_set_doc}, + {"copy_from", (PyCFunction)bpy_bm_elem_copy_from, METH_O, bpy_bm_elem_copy_from_doc}, + {"copy_from_face_interp", (PyCFunction)bpy_bmvert_copy_from_face_interp, METH_VARARGS, bpy_bmvert_copy_from_face_interp_doc}, + {"copy_from_vert_interp", (PyCFunction)bpy_bmvert_copy_from_vert_interp, METH_VARARGS, bpy_bmvert_copy_from_vert_interp_doc}, - {"calc_vert_angle", (PyCFunction)bpy_bmvert_calc_edge_angle, METH_NOARGS, bpy_bmvert_calc_edge_angle_doc}, - {"calc_shell_factor", (PyCFunction)bpy_bmvert_calc_shell_factor, METH_NOARGS, bpy_bmvert_calc_shell_factor_doc}, + {"calc_vert_angle", (PyCFunction)bpy_bmvert_calc_edge_angle, METH_NOARGS, bpy_bmvert_calc_edge_angle_doc}, + {"calc_shell_factor", (PyCFunction)bpy_bmvert_calc_shell_factor, METH_NOARGS, bpy_bmvert_calc_shell_factor_doc}, - {"normal_update", (PyCFunction)bpy_bmvert_normal_update, METH_NOARGS, bpy_bmvert_normal_update_doc}, + {"normal_update", (PyCFunction)bpy_bmvert_normal_update, METH_NOARGS, bpy_bmvert_normal_update_doc}, - {NULL, NULL, 0, NULL} + {NULL, NULL, 0, NULL} }; static struct PyMethodDef bpy_bmedge_methods[] = { - {"select_set", (PyCFunction)bpy_bm_elem_select_set, METH_O, bpy_bm_elem_select_set_doc}, - {"hide_set", (PyCFunction)bpy_bm_elem_hide_set, METH_O, bpy_bm_elem_hide_set_doc}, - {"copy_from", (PyCFunction)bpy_bm_elem_copy_from, METH_O, bpy_bm_elem_copy_from_doc}, + {"select_set", (PyCFunction)bpy_bm_elem_select_set, METH_O, bpy_bm_elem_select_set_doc}, + {"hide_set", (PyCFunction)bpy_bm_elem_hide_set, METH_O, bpy_bm_elem_hide_set_doc}, + {"copy_from", (PyCFunction)bpy_bm_elem_copy_from, METH_O, bpy_bm_elem_copy_from_doc}, - {"other_vert", (PyCFunction)bpy_bmedge_other_vert, METH_O, bpy_bmedge_other_vert_doc}, + {"other_vert", (PyCFunction)bpy_bmedge_other_vert, METH_O, bpy_bmedge_other_vert_doc}, - {"calc_length", (PyCFunction)bpy_bmedge_calc_length, METH_NOARGS, bpy_bmedge_calc_length_doc}, - {"calc_face_angle", (PyCFunction)bpy_bmedge_calc_face_angle, METH_NOARGS, bpy_bmedge_calc_face_angle_doc}, - {"calc_tangent", (PyCFunction)bpy_bmedge_calc_tangent, METH_VARARGS, bpy_bmedge_calc_tangent_doc}, + {"calc_length", (PyCFunction)bpy_bmedge_calc_length, METH_NOARGS, bpy_bmedge_calc_length_doc}, + {"calc_face_angle", (PyCFunction)bpy_bmedge_calc_face_angle, METH_NOARGS, bpy_bmedge_calc_face_angle_doc}, + {"calc_tangent", (PyCFunction)bpy_bmedge_calc_tangent, METH_VARARGS, bpy_bmedge_calc_tangent_doc}, - {"normal_update", (PyCFunction)bpy_bmedge_normal_update, METH_NOARGS, bpy_bmedge_normal_update_doc}, + {"normal_update", (PyCFunction)bpy_bmedge_normal_update, METH_NOARGS, bpy_bmedge_normal_update_doc}, - {NULL, NULL, 0, NULL} + {NULL, NULL, 0, NULL} }; static struct PyMethodDef bpy_bmface_methods[] = { - {"select_set", (PyCFunction)bpy_bm_elem_select_set, METH_O, bpy_bm_elem_select_set_doc}, - {"hide_set", (PyCFunction)bpy_bm_elem_hide_set, METH_O, bpy_bm_elem_hide_set_doc}, + {"select_set", (PyCFunction)bpy_bm_elem_select_set, METH_O, bpy_bm_elem_select_set_doc}, + {"hide_set", (PyCFunction)bpy_bm_elem_hide_set, METH_O, bpy_bm_elem_hide_set_doc}, - {"copy_from", (PyCFunction)bpy_bm_elem_copy_from, METH_O, bpy_bm_elem_copy_from_doc}, - {"copy_from_face_interp", (PyCFunction)bpy_bmface_copy_from_face_interp, METH_O, bpy_bmface_copy_from_face_interp_doc}, + {"copy_from", (PyCFunction)bpy_bm_elem_copy_from, METH_O, bpy_bm_elem_copy_from_doc}, + {"copy_from_face_interp", (PyCFunction)bpy_bmface_copy_from_face_interp, METH_O, bpy_bmface_copy_from_face_interp_doc}, - {"copy", (PyCFunction)bpy_bmface_copy, METH_VARARGS | METH_KEYWORDS, bpy_bmface_copy_doc}, + {"copy", (PyCFunction)bpy_bmface_copy, METH_VARARGS | METH_KEYWORDS, bpy_bmface_copy_doc}, - {"calc_area", (PyCFunction)bpy_bmface_calc_area, METH_NOARGS, bpy_bmface_calc_area_doc}, - {"calc_perimeter", (PyCFunction)bpy_bmface_calc_perimeter, METH_NOARGS, bpy_bmface_calc_perimeter_doc}, - {"calc_center_median", (PyCFunction)bpy_bmface_calc_center_mean, METH_NOARGS, bpy_bmface_calc_center_mean_doc}, - {"calc_center_bounds", (PyCFunction)bpy_bmface_calc_center_bounds, METH_NOARGS, bpy_bmface_calc_center_bounds_doc}, + {"calc_area", (PyCFunction)bpy_bmface_calc_area, METH_NOARGS, bpy_bmface_calc_area_doc}, + {"calc_perimeter", (PyCFunction)bpy_bmface_calc_perimeter, METH_NOARGS, bpy_bmface_calc_perimeter_doc}, + {"calc_center_median", (PyCFunction)bpy_bmface_calc_center_mean, METH_NOARGS, bpy_bmface_calc_center_mean_doc}, + {"calc_center_bounds", (PyCFunction)bpy_bmface_calc_center_bounds, METH_NOARGS, bpy_bmface_calc_center_bounds_doc}, - {"normal_update", (PyCFunction)bpy_bmface_normal_update, METH_NOARGS, bpy_bmface_normal_update_doc}, + {"normal_update", (PyCFunction)bpy_bmface_normal_update, METH_NOARGS, bpy_bmface_normal_update_doc}, - {NULL, NULL, 0, NULL} + {NULL, NULL, 0, NULL} }; static struct PyMethodDef bpy_bmloop_methods[] = { - {"copy_from", (PyCFunction)bpy_bm_elem_copy_from, METH_O, bpy_bm_elem_copy_from_doc}, - {"copy_from_face_interp", (PyCFunction)bpy_bmloop_copy_from_face_interp, METH_O, bpy_bmloop_copy_from_face_interp_doc}, + {"copy_from", (PyCFunction)bpy_bm_elem_copy_from, METH_O, bpy_bm_elem_copy_from_doc}, + {"copy_from_face_interp", (PyCFunction)bpy_bmloop_copy_from_face_interp, METH_O, bpy_bmloop_copy_from_face_interp_doc}, - {"calc_angle", (PyCFunction)bpy_bmloop_calc_angle, METH_NOARGS, bpy_bmloop_calc_angle_doc}, - {"calc_normal", (PyCFunction)bpy_bmloop_calc_normal, METH_NOARGS, bpy_bmloop_calc_normal_doc}, - {"calc_tangent", (PyCFunction)bpy_bmloop_calc_tangent, METH_NOARGS, bpy_bmloop_calc_tangent_doc}, - {NULL, NULL, 0, NULL} + {"calc_angle", (PyCFunction)bpy_bmloop_calc_angle, METH_NOARGS, bpy_bmloop_calc_angle_doc}, + {"calc_normal", (PyCFunction)bpy_bmloop_calc_normal, METH_NOARGS, bpy_bmloop_calc_normal_doc}, + {"calc_tangent", (PyCFunction)bpy_bmloop_calc_tangent, METH_NOARGS, bpy_bmloop_calc_tangent_doc}, + {NULL, NULL, 0, NULL} }; static struct PyMethodDef bpy_bmelemseq_methods[] = { - /* odd function, initializes index values */ - {"index_update", (PyCFunction)bpy_bmelemseq_index_update, METH_NOARGS, bpy_bmelemseq_index_update_doc}, - {NULL, NULL, 0, NULL} + /* odd function, initializes index values */ + {"index_update", (PyCFunction)bpy_bmelemseq_index_update, METH_NOARGS, bpy_bmelemseq_index_update_doc}, + {NULL, NULL, 0, NULL} }; static struct PyMethodDef bpy_bmvertseq_methods[] = { - {"new", (PyCFunction)bpy_bmvertseq_new, METH_VARARGS, bpy_bmvertseq_new_doc}, - {"remove", (PyCFunction)bpy_bmvertseq_remove, METH_O, bpy_bmvertseq_remove_doc}, + {"new", (PyCFunction)bpy_bmvertseq_new, METH_VARARGS, bpy_bmvertseq_new_doc}, + {"remove", (PyCFunction)bpy_bmvertseq_remove, METH_O, bpy_bmvertseq_remove_doc}, - /* odd function, initializes index values */ - {"index_update", (PyCFunction)bpy_bmelemseq_index_update, METH_NOARGS, bpy_bmelemseq_index_update_doc}, - {"sort", (PyCFunction)bpy_bmelemseq_sort, METH_VARARGS | METH_KEYWORDS, bpy_bmelemseq_sort_doc}, - {NULL, NULL, 0, NULL} + /* odd function, initializes index values */ + {"index_update", (PyCFunction)bpy_bmelemseq_index_update, METH_NOARGS, bpy_bmelemseq_index_update_doc}, + {"sort", (PyCFunction)bpy_bmelemseq_sort, METH_VARARGS | METH_KEYWORDS, bpy_bmelemseq_sort_doc}, + {NULL, NULL, 0, NULL} }; static struct PyMethodDef bpy_bmedgeseq_methods[] = { - {"new", (PyCFunction)bpy_bmedgeseq_new, METH_VARARGS, bpy_bmedgeseq_new_doc}, - {"remove", (PyCFunction)bpy_bmedgeseq_remove, METH_O, bpy_bmedgeseq_remove_doc}, - /* 'bpy_bmelemseq_get' for different purpose */ - {"get", (PyCFunction)bpy_bmedgeseq_get__method, METH_VARARGS, bpy_bmedgeseq_get__method_doc}, + {"new", (PyCFunction)bpy_bmedgeseq_new, METH_VARARGS, bpy_bmedgeseq_new_doc}, + {"remove", (PyCFunction)bpy_bmedgeseq_remove, METH_O, bpy_bmedgeseq_remove_doc}, + /* 'bpy_bmelemseq_get' for different purpose */ + {"get", (PyCFunction)bpy_bmedgeseq_get__method, METH_VARARGS, bpy_bmedgeseq_get__method_doc}, - /* odd function, initializes index values */ - {"index_update", (PyCFunction)bpy_bmelemseq_index_update, METH_NOARGS, bpy_bmelemseq_index_update_doc}, - {"sort", (PyCFunction)bpy_bmelemseq_sort, METH_VARARGS | METH_KEYWORDS, bpy_bmelemseq_sort_doc}, - {NULL, NULL, 0, NULL} + /* odd function, initializes index values */ + {"index_update", (PyCFunction)bpy_bmelemseq_index_update, METH_NOARGS, bpy_bmelemseq_index_update_doc}, + {"sort", (PyCFunction)bpy_bmelemseq_sort, METH_VARARGS | METH_KEYWORDS, bpy_bmelemseq_sort_doc}, + {NULL, NULL, 0, NULL} }; static struct PyMethodDef bpy_bmfaceseq_methods[] = { - {"new", (PyCFunction)bpy_bmfaceseq_new, METH_VARARGS, bpy_bmfaceseq_new_doc}, - {"remove", (PyCFunction)bpy_bmfaceseq_remove, METH_O, bpy_bmfaceseq_remove_doc}, - /* 'bpy_bmelemseq_get' for different purpose */ - {"get", (PyCFunction)bpy_bmfaceseq_get__method, METH_VARARGS, bpy_bmfaceseq_get__method_doc}, + {"new", (PyCFunction)bpy_bmfaceseq_new, METH_VARARGS, bpy_bmfaceseq_new_doc}, + {"remove", (PyCFunction)bpy_bmfaceseq_remove, METH_O, bpy_bmfaceseq_remove_doc}, + /* 'bpy_bmelemseq_get' for different purpose */ + {"get", (PyCFunction)bpy_bmfaceseq_get__method, METH_VARARGS, bpy_bmfaceseq_get__method_doc}, - /* odd function, initializes index values */ - {"index_update", (PyCFunction)bpy_bmelemseq_index_update, METH_NOARGS, bpy_bmelemseq_index_update_doc}, - {"sort", (PyCFunction)bpy_bmelemseq_sort, METH_VARARGS | METH_KEYWORDS, bpy_bmelemseq_sort_doc}, - {NULL, NULL, 0, NULL} + /* odd function, initializes index values */ + {"index_update", (PyCFunction)bpy_bmelemseq_index_update, METH_NOARGS, bpy_bmelemseq_index_update_doc}, + {"sort", (PyCFunction)bpy_bmelemseq_sort, METH_VARARGS | METH_KEYWORDS, bpy_bmelemseq_sort_doc}, + {NULL, NULL, 0, NULL} }; static struct PyMethodDef bpy_bmloopseq_methods[] = { - /* odd function, initializes index values */ - /* no: index_update() function since we cant iterate over loops */ - /* no: sort() function since we cant iterate over loops */ - {NULL, NULL, 0, NULL} + /* odd function, initializes index values */ + /* no: index_update() function since we cant iterate over loops */ + /* no: sort() function since we cant iterate over loops */ + {NULL, NULL, 0, NULL} }; /* Sequences @@ -2637,29 +2637,29 @@ static int bpy_bmelem_ass_subscript(BPy_BMElem *self, BPy_BMLayerItem *key, PyOb } static PySequenceMethods bpy_bmelemseq_as_sequence = { - (lenfunc)bpy_bmelemseq_length, /* sq_length */ - NULL, /* sq_concat */ - NULL, /* sq_repeat */ - (ssizeargfunc)bpy_bmelemseq_subscript_int, /* sq_item */ /* Only set this so PySequence_Check() returns True */ - NULL, /* sq_slice */ - (ssizeobjargproc)NULL, /* sq_ass_item */ - NULL, /* *was* sq_ass_slice */ - (objobjproc)bpy_bmelemseq_contains, /* sq_contains */ - (binaryfunc) NULL, /* sq_inplace_concat */ - (ssizeargfunc) NULL, /* sq_inplace_repeat */ + (lenfunc)bpy_bmelemseq_length, /* sq_length */ + NULL, /* sq_concat */ + NULL, /* sq_repeat */ + (ssizeargfunc)bpy_bmelemseq_subscript_int, /* sq_item */ /* Only set this so PySequence_Check() returns True */ + NULL, /* sq_slice */ + (ssizeobjargproc)NULL, /* sq_ass_item */ + NULL, /* *was* sq_ass_slice */ + (objobjproc)bpy_bmelemseq_contains, /* sq_contains */ + (binaryfunc) NULL, /* sq_inplace_concat */ + (ssizeargfunc) NULL, /* sq_inplace_repeat */ }; static PyMappingMethods bpy_bmelemseq_as_mapping = { - (lenfunc)bpy_bmelemseq_length, /* mp_length */ - (binaryfunc)bpy_bmelemseq_subscript, /* mp_subscript */ - (objobjargproc)NULL, /* mp_ass_subscript */ + (lenfunc)bpy_bmelemseq_length, /* mp_length */ + (binaryfunc)bpy_bmelemseq_subscript, /* mp_subscript */ + (objobjargproc)NULL, /* mp_ass_subscript */ }; /* for customdata access */ static PyMappingMethods bpy_bm_elem_as_mapping = { - (lenfunc)NULL, /* mp_length */ /* keep this empty, messes up 'if elem: ...' test */ - (binaryfunc)bpy_bmelem_subscript, /* mp_subscript */ - (objobjargproc)bpy_bmelem_ass_subscript, /* mp_ass_subscript */ + (lenfunc)NULL, /* mp_length */ /* keep this empty, messes up 'if elem: ...' test */ + (binaryfunc)bpy_bmelem_subscript, /* mp_subscript */ + (objobjargproc)bpy_bmelem_ass_subscript, /* mp_ass_subscript */ }; /* Iterator @@ -3055,15 +3055,15 @@ void BPy_BM_init_types(void) * ********************* */ static struct PyModuleDef BPy_BM_types_module_def = { - PyModuleDef_HEAD_INIT, - "bmesh.types", /* m_name */ - NULL, /* m_doc */ - 0, /* m_size */ - NULL, /* m_methods */ - NULL, /* m_reload */ - NULL, /* m_traverse */ - NULL, /* m_clear */ - NULL, /* m_free */ + PyModuleDef_HEAD_INIT, + "bmesh.types", /* m_name */ + NULL, /* m_doc */ + 0, /* m_size */ + NULL, /* m_methods */ + NULL, /* m_reload */ + NULL, /* m_traverse */ + NULL, /* m_clear */ + NULL, /* m_free */ }; PyObject *BPyInit_bmesh_types(void) diff --git a/source/blender/python/bmesh/bmesh_py_types_customdata.c b/source/blender/python/bmesh/bmesh_py_types_customdata.c index d484ad5c87e..e45a39a0643 100644 --- a/source/blender/python/bmesh/bmesh_py_types_customdata.c +++ b/source/blender/python/bmesh/bmesh_py_types_customdata.c @@ -175,64 +175,64 @@ static PyObject *bpy_bmlayeritem_name_get(BPy_BMLayerItem *self, void *UNUSED(fl } static PyGetSetDef bpy_bmlayeraccess_vert_getseters[] = { - {(char *)"deform", (getter)bpy_bmlayeraccess_collection_get, (setter)NULL, (char *)bpy_bmlayeraccess_collection__deform_doc, (void *)CD_MDEFORMVERT}, + {(char *)"deform", (getter)bpy_bmlayeraccess_collection_get, (setter)NULL, (char *)bpy_bmlayeraccess_collection__deform_doc, (void *)CD_MDEFORMVERT}, - {(char *)"float", (getter)bpy_bmlayeraccess_collection_get, (setter)NULL, (char *)bpy_bmlayeraccess_collection__float_doc, (void *)CD_PROP_FLT}, - {(char *)"int", (getter)bpy_bmlayeraccess_collection_get, (setter)NULL, (char *)bpy_bmlayeraccess_collection__int_doc, (void *)CD_PROP_INT}, - {(char *)"string", (getter)bpy_bmlayeraccess_collection_get, (setter)NULL, (char *)bpy_bmlayeraccess_collection__string_doc, (void *)CD_PROP_STR}, + {(char *)"float", (getter)bpy_bmlayeraccess_collection_get, (setter)NULL, (char *)bpy_bmlayeraccess_collection__float_doc, (void *)CD_PROP_FLT}, + {(char *)"int", (getter)bpy_bmlayeraccess_collection_get, (setter)NULL, (char *)bpy_bmlayeraccess_collection__int_doc, (void *)CD_PROP_INT}, + {(char *)"string", (getter)bpy_bmlayeraccess_collection_get, (setter)NULL, (char *)bpy_bmlayeraccess_collection__string_doc, (void *)CD_PROP_STR}, - {(char *)"shape", (getter)bpy_bmlayeraccess_collection_get, (setter)NULL, (char *)bpy_bmlayeraccess_collection__shape_doc, (void *)CD_SHAPEKEY}, - {(char *)"bevel_weight", (getter)bpy_bmlayeraccess_collection_get, (setter)NULL, (char *)bpy_bmlayeraccess_collection__bevel_weight_doc, (void *)CD_BWEIGHT}, + {(char *)"shape", (getter)bpy_bmlayeraccess_collection_get, (setter)NULL, (char *)bpy_bmlayeraccess_collection__shape_doc, (void *)CD_SHAPEKEY}, + {(char *)"bevel_weight", (getter)bpy_bmlayeraccess_collection_get, (setter)NULL, (char *)bpy_bmlayeraccess_collection__bevel_weight_doc, (void *)CD_BWEIGHT}, - {NULL, NULL, NULL, NULL, NULL} /* Sentinel */ + {NULL, NULL, NULL, NULL, NULL} /* Sentinel */ }; static PyGetSetDef bpy_bmlayeraccess_edge_getseters[] = { - {(char *)"float", (getter)bpy_bmlayeraccess_collection_get, (setter)NULL, (char *)bpy_bmlayeraccess_collection__float_doc, (void *)CD_PROP_FLT}, - {(char *)"int", (getter)bpy_bmlayeraccess_collection_get, (setter)NULL, (char *)bpy_bmlayeraccess_collection__int_doc, (void *)CD_PROP_INT}, - {(char *)"string", (getter)bpy_bmlayeraccess_collection_get, (setter)NULL, (char *)bpy_bmlayeraccess_collection__string_doc, (void *)CD_PROP_STR}, + {(char *)"float", (getter)bpy_bmlayeraccess_collection_get, (setter)NULL, (char *)bpy_bmlayeraccess_collection__float_doc, (void *)CD_PROP_FLT}, + {(char *)"int", (getter)bpy_bmlayeraccess_collection_get, (setter)NULL, (char *)bpy_bmlayeraccess_collection__int_doc, (void *)CD_PROP_INT}, + {(char *)"string", (getter)bpy_bmlayeraccess_collection_get, (setter)NULL, (char *)bpy_bmlayeraccess_collection__string_doc, (void *)CD_PROP_STR}, - {(char *)"bevel_weight", (getter)bpy_bmlayeraccess_collection_get, (setter)NULL, (char *)bpy_bmlayeraccess_collection__bevel_weight_doc, (void *)CD_BWEIGHT}, - {(char *)"crease", (getter)bpy_bmlayeraccess_collection_get, (setter)NULL, (char *)bpy_bmlayeraccess_collection__crease_doc, (void *)CD_CREASE}, + {(char *)"bevel_weight", (getter)bpy_bmlayeraccess_collection_get, (setter)NULL, (char *)bpy_bmlayeraccess_collection__bevel_weight_doc, (void *)CD_BWEIGHT}, + {(char *)"crease", (getter)bpy_bmlayeraccess_collection_get, (setter)NULL, (char *)bpy_bmlayeraccess_collection__crease_doc, (void *)CD_CREASE}, - {NULL, NULL, NULL, NULL, NULL} /* Sentinel */ + {NULL, NULL, NULL, NULL, NULL} /* Sentinel */ }; static PyGetSetDef bpy_bmlayeraccess_face_getseters[] = { - {(char *)"float", (getter)bpy_bmlayeraccess_collection_get, (setter)NULL, (char *)bpy_bmlayeraccess_collection__float_doc, (void *)CD_PROP_FLT}, - {(char *)"int", (getter)bpy_bmlayeraccess_collection_get, (setter)NULL, (char *)bpy_bmlayeraccess_collection__int_doc, (void *)CD_PROP_INT}, - {(char *)"string", (getter)bpy_bmlayeraccess_collection_get, (setter)NULL, (char *)bpy_bmlayeraccess_collection__string_doc, (void *)CD_PROP_STR}, + {(char *)"float", (getter)bpy_bmlayeraccess_collection_get, (setter)NULL, (char *)bpy_bmlayeraccess_collection__float_doc, (void *)CD_PROP_FLT}, + {(char *)"int", (getter)bpy_bmlayeraccess_collection_get, (setter)NULL, (char *)bpy_bmlayeraccess_collection__int_doc, (void *)CD_PROP_INT}, + {(char *)"string", (getter)bpy_bmlayeraccess_collection_get, (setter)NULL, (char *)bpy_bmlayeraccess_collection__string_doc, (void *)CD_PROP_STR}, - {(char *)"tex", (getter)bpy_bmlayeraccess_collection_get, (setter)NULL, (char *)bpy_bmlayeraccess_collection__tex_doc, (void *)CD_MTEXPOLY}, + {(char *)"tex", (getter)bpy_bmlayeraccess_collection_get, (setter)NULL, (char *)bpy_bmlayeraccess_collection__tex_doc, (void *)CD_MTEXPOLY}, - {NULL, NULL, NULL, NULL, NULL} /* Sentinel */ + {NULL, NULL, NULL, NULL, NULL} /* Sentinel */ }; static PyGetSetDef bpy_bmlayeraccess_loop_getseters[] = { - {(char *)"float", (getter)bpy_bmlayeraccess_collection_get, (setter)NULL, (char *)bpy_bmlayeraccess_collection__float_doc, (void *)CD_PROP_FLT}, - {(char *)"int", (getter)bpy_bmlayeraccess_collection_get, (setter)NULL, (char *)bpy_bmlayeraccess_collection__int_doc, (void *)CD_PROP_INT}, - {(char *)"string", (getter)bpy_bmlayeraccess_collection_get, (setter)NULL, (char *)bpy_bmlayeraccess_collection__string_doc, (void *)CD_PROP_STR}, + {(char *)"float", (getter)bpy_bmlayeraccess_collection_get, (setter)NULL, (char *)bpy_bmlayeraccess_collection__float_doc, (void *)CD_PROP_FLT}, + {(char *)"int", (getter)bpy_bmlayeraccess_collection_get, (setter)NULL, (char *)bpy_bmlayeraccess_collection__int_doc, (void *)CD_PROP_INT}, + {(char *)"string", (getter)bpy_bmlayeraccess_collection_get, (setter)NULL, (char *)bpy_bmlayeraccess_collection__string_doc, (void *)CD_PROP_STR}, - {(char *)"uv", (getter)bpy_bmlayeraccess_collection_get, (setter)NULL, (char *)bpy_bmlayeraccess_collection__uv_doc, (void *)CD_MLOOPUV}, - {(char *)"color", (getter)bpy_bmlayeraccess_collection_get, (setter)NULL, (char *)bpy_bmlayeraccess_collection__color_doc, (void *)CD_MLOOPCOL}, + {(char *)"uv", (getter)bpy_bmlayeraccess_collection_get, (setter)NULL, (char *)bpy_bmlayeraccess_collection__uv_doc, (void *)CD_MLOOPUV}, + {(char *)"color", (getter)bpy_bmlayeraccess_collection_get, (setter)NULL, (char *)bpy_bmlayeraccess_collection__color_doc, (void *)CD_MLOOPCOL}, - {NULL, NULL, NULL, NULL, NULL} /* Sentinel */ + {NULL, NULL, NULL, NULL, NULL} /* Sentinel */ }; static PyGetSetDef bpy_bmlayercollection_getseters[] = { - /* BMESH_TODO, make writeable */ - {(char *)"active", (getter)bpy_bmlayercollection_active_get, (setter)NULL, (char *)bpy_bmlayercollection_active_doc, NULL}, - {(char *)"is_singleton", (getter)bpy_bmlayercollection_is_singleton_get, (setter)NULL, (char *)bpy_bmlayercollection_is_singleton_doc, NULL}, + /* BMESH_TODO, make writeable */ + {(char *)"active", (getter)bpy_bmlayercollection_active_get, (setter)NULL, (char *)bpy_bmlayercollection_active_doc, NULL}, + {(char *)"is_singleton", (getter)bpy_bmlayercollection_is_singleton_get, (setter)NULL, (char *)bpy_bmlayercollection_is_singleton_doc, NULL}, - {NULL, NULL, NULL, NULL, NULL} /* Sentinel */ + {NULL, NULL, NULL, NULL, NULL} /* Sentinel */ }; static PyGetSetDef bpy_bmlayeritem_getseters[] = { - /* BMESH_TODO, make writeable */ - {(char *)"name", (getter)bpy_bmlayeritem_name_get, (setter)NULL, (char *)bpy_bmlayercollection_name_doc, NULL}, + /* BMESH_TODO, make writeable */ + {(char *)"name", (getter)bpy_bmlayeritem_name_get, (setter)NULL, (char *)bpy_bmlayercollection_name_doc, NULL}, - {NULL, NULL, NULL, NULL, NULL} /* Sentinel */ + {NULL, NULL, NULL, NULL, NULL} /* Sentinel */ }; @@ -556,20 +556,20 @@ static PyObject *bpy_bmlayercollection_get(BPy_BMLayerCollection *self, PyObject } static struct PyMethodDef bpy_bmlayeritem_methods[] = { - {"copy_from", (PyCFunction)bpy_bmlayeritem_copy_from, METH_O, bpy_bmlayeritem_copy_from_doc}, - {NULL, NULL, 0, NULL} + {"copy_from", (PyCFunction)bpy_bmlayeritem_copy_from, METH_O, bpy_bmlayeritem_copy_from_doc}, + {NULL, NULL, 0, NULL} }; static struct PyMethodDef bpy_bmelemseq_methods[] = { - {"verify", (PyCFunction)bpy_bmlayercollection_verify, METH_NOARGS, bpy_bmlayercollection_verify_doc}, - {"new", (PyCFunction)bpy_bmlayercollection_new, METH_VARARGS, bpy_bmlayercollection_new_doc}, - {"remove", (PyCFunction)bpy_bmlayercollection_remove, METH_O, bpy_bmlayercollection_remove_doc}, + {"verify", (PyCFunction)bpy_bmlayercollection_verify, METH_NOARGS, bpy_bmlayercollection_verify_doc}, + {"new", (PyCFunction)bpy_bmlayercollection_new, METH_VARARGS, bpy_bmlayercollection_new_doc}, + {"remove", (PyCFunction)bpy_bmlayercollection_remove, METH_O, bpy_bmlayercollection_remove_doc}, - {"keys", (PyCFunction)bpy_bmlayercollection_keys, METH_NOARGS, bpy_bmlayercollection_keys_doc}, - {"values", (PyCFunction)bpy_bmlayercollection_values, METH_NOARGS, bpy_bmlayercollection_values_doc}, - {"items", (PyCFunction)bpy_bmlayercollection_items, METH_NOARGS, bpy_bmlayercollection_items_doc}, - {"get", (PyCFunction)bpy_bmlayercollection_get, METH_VARARGS, bpy_bmlayercollection_get_doc}, - {NULL, NULL, 0, NULL} + {"keys", (PyCFunction)bpy_bmlayercollection_keys, METH_NOARGS, bpy_bmlayercollection_keys_doc}, + {"values", (PyCFunction)bpy_bmlayercollection_values, METH_NOARGS, bpy_bmlayercollection_values_doc}, + {"items", (PyCFunction)bpy_bmlayercollection_items, METH_NOARGS, bpy_bmlayercollection_items_doc}, + {"get", (PyCFunction)bpy_bmlayercollection_get, METH_VARARGS, bpy_bmlayercollection_get_doc}, + {NULL, NULL, 0, NULL} }; /* Sequences @@ -724,22 +724,22 @@ static int bpy_bmlayercollection_contains(BPy_BMLayerCollection *self, PyObject } static PySequenceMethods bpy_bmlayercollection_as_sequence = { - (lenfunc)bpy_bmlayercollection_length, /* sq_length */ - NULL, /* sq_concat */ - NULL, /* sq_repeat */ - (ssizeargfunc)bpy_bmlayercollection_subscript_int, /* sq_item */ /* Only set this so PySequence_Check() returns True */ - NULL, /* sq_slice */ - (ssizeobjargproc)NULL, /* sq_ass_item */ - NULL, /* *was* sq_ass_slice */ - (objobjproc)bpy_bmlayercollection_contains, /* sq_contains */ - (binaryfunc) NULL, /* sq_inplace_concat */ - (ssizeargfunc) NULL, /* sq_inplace_repeat */ + (lenfunc)bpy_bmlayercollection_length, /* sq_length */ + NULL, /* sq_concat */ + NULL, /* sq_repeat */ + (ssizeargfunc)bpy_bmlayercollection_subscript_int, /* sq_item */ /* Only set this so PySequence_Check() returns True */ + NULL, /* sq_slice */ + (ssizeobjargproc)NULL, /* sq_ass_item */ + NULL, /* *was* sq_ass_slice */ + (objobjproc)bpy_bmlayercollection_contains, /* sq_contains */ + (binaryfunc) NULL, /* sq_inplace_concat */ + (ssizeargfunc) NULL, /* sq_inplace_repeat */ }; static PyMappingMethods bpy_bmlayercollection_as_mapping = { - (lenfunc)bpy_bmlayercollection_length, /* mp_length */ - (binaryfunc)bpy_bmlayercollection_subscript, /* mp_subscript */ - (objobjargproc)NULL, /* mp_ass_subscript */ + (lenfunc)bpy_bmlayercollection_length, /* mp_length */ + (binaryfunc)bpy_bmlayercollection_subscript, /* mp_subscript */ + (objobjargproc)NULL, /* mp_ass_subscript */ }; /* Iterator diff --git a/source/blender/python/bmesh/bmesh_py_types_meshdata.c b/source/blender/python/bmesh/bmesh_py_types_meshdata.c index 1b21f62a115..b5fee2a3e8e 100644 --- a/source/blender/python/bmesh/bmesh_py_types_meshdata.c +++ b/source/blender/python/bmesh/bmesh_py_types_meshdata.c @@ -91,10 +91,10 @@ static int bpy_bmtexpoly_image_set(BPy_BMTexPoly *self, PyObject *value, void *U } static PyGetSetDef bpy_bmtexpoly_getseters[] = { - /* attributes match rna_def_mtpoly */ - {(char *)"image", (getter)bpy_bmtexpoly_image_get, (setter)bpy_bmtexpoly_image_set, (char *)bpy_bmtexpoly_image_doc, NULL}, + /* attributes match rna_def_mtpoly */ + {(char *)"image", (getter)bpy_bmtexpoly_image_get, (setter)bpy_bmtexpoly_image_set, (char *)bpy_bmtexpoly_image_doc, NULL}, - {NULL, NULL, NULL, NULL, NULL} /* Sentinel */ + {NULL, NULL, NULL, NULL, NULL} /* Sentinel */ }; PyTypeObject BPy_BMTexPoly_Type = {{{0}}}; /* bm.loops.layers.uv.active */ @@ -201,13 +201,13 @@ static int bpy_bmloopuv_flag_set(BPy_BMLoopUV *self, PyObject *value, void *flag } static PyGetSetDef bpy_bmloopuv_getseters[] = { - /* attributes match rna_def_mloopuv */ - {(char *)"uv", (getter)bpy_bmloopuv_uv_get, (setter)bpy_bmloopuv_uv_set, (char *)bpy_bmloopuv_uv_doc, NULL}, - {(char *)"pin_uv", (getter)bpy_bmloopuv_flag_get, (setter)bpy_bmloopuv_flag_set, (char *)bpy_bmloopuv_flag__pin_uv_doc, (void *)MLOOPUV_PINNED}, - {(char *)"select", (getter)bpy_bmloopuv_flag_get, (setter)bpy_bmloopuv_flag_set, (char *)bpy_bmloopuv_flag__select_doc, (void *)MLOOPUV_VERTSEL}, - {(char *)"select_edge", (getter)bpy_bmloopuv_flag_get, (setter)bpy_bmloopuv_flag_set, (char *)bpy_bmloopuv_flag__select_edge_doc, (void *)MLOOPUV_EDGESEL}, + /* attributes match rna_def_mloopuv */ + {(char *)"uv", (getter)bpy_bmloopuv_uv_get, (setter)bpy_bmloopuv_uv_set, (char *)bpy_bmloopuv_uv_doc, NULL}, + {(char *)"pin_uv", (getter)bpy_bmloopuv_flag_get, (setter)bpy_bmloopuv_flag_set, (char *)bpy_bmloopuv_flag__pin_uv_doc, (void *)MLOOPUV_PINNED}, + {(char *)"select", (getter)bpy_bmloopuv_flag_get, (setter)bpy_bmloopuv_flag_set, (char *)bpy_bmloopuv_flag__select_doc, (void *)MLOOPUV_VERTSEL}, + {(char *)"select_edge", (getter)bpy_bmloopuv_flag_get, (setter)bpy_bmloopuv_flag_set, (char *)bpy_bmloopuv_flag__select_edge_doc, (void *)MLOOPUV_EDGESEL}, - {NULL, NULL, NULL, NULL, NULL} /* Sentinel */ + {NULL, NULL, NULL, NULL, NULL} /* Sentinel */ }; PyTypeObject BPy_BMLoopUV_Type = {{{0}}}; /* bm.loops.layers.uv.active */ @@ -485,21 +485,21 @@ static int bpy_bmdeformvert_contains(BPy_BMDeformVert *self, PyObject *value) /* only defined for __contains__ */ static PySequenceMethods bpy_bmdeformvert_as_sequence = { - (lenfunc)bpy_bmdeformvert_len, /* sq_length */ - NULL, /* sq_concat */ - NULL, /* sq_repeat */ + (lenfunc)bpy_bmdeformvert_len, /* sq_length */ + NULL, /* sq_concat */ + NULL, /* sq_repeat */ - /* note: if this is set PySequence_Check() returns True, - * but in this case we dont want to be treated as a seq */ - NULL, /* sq_item */ + /* note: if this is set PySequence_Check() returns True, + * but in this case we dont want to be treated as a seq */ + NULL, /* sq_item */ - NULL, /* sq_slice */ - NULL, /* sq_ass_item */ - NULL, /* *was* sq_ass_slice */ - (objobjproc)bpy_bmdeformvert_contains, /* sq_contains */ - (binaryfunc) NULL, /* sq_inplace_concat */ - (ssizeargfunc) NULL, /* sq_inplace_repeat */ -}; + NULL, /* sq_slice */ + NULL, /* sq_ass_item */ + NULL, /* *was* sq_ass_slice */ + (objobjproc)bpy_bmdeformvert_contains, /* sq_contains */ + (binaryfunc) NULL, /* sq_inplace_concat */ + (ssizeargfunc) NULL, /* sq_inplace_repeat */ + }; static PyMappingMethods bpy_bmdeformvert_as_mapping = { (lenfunc)bpy_bmdeformvert_len, @@ -631,13 +631,13 @@ static PyObject *bpy_bmdeformvert_clear(BPy_BMDeformVert *self) } static struct PyMethodDef bpy_bmdeformvert_methods[] = { - {"keys", (PyCFunction)bpy_bmdeformvert_keys, METH_NOARGS, bpy_bmdeformvert_keys_doc}, - {"values", (PyCFunction)bpy_bmdeformvert_values, METH_NOARGS, bpy_bmdeformvert_values_doc}, - {"items", (PyCFunction)bpy_bmdeformvert_items, METH_NOARGS, bpy_bmdeformvert_items_doc}, - {"get", (PyCFunction)bpy_bmdeformvert_get, METH_VARARGS, bpy_bmdeformvert_get_doc}, - /* BMESH_TODO pop, popitem, update */ - {"clear", (PyCFunction)bpy_bmdeformvert_clear, METH_NOARGS, bpy_bmdeformvert_clear_doc}, - {NULL, NULL, 0, NULL} + {"keys", (PyCFunction)bpy_bmdeformvert_keys, METH_NOARGS, bpy_bmdeformvert_keys_doc}, + {"values", (PyCFunction)bpy_bmdeformvert_values, METH_NOARGS, bpy_bmdeformvert_values_doc}, + {"items", (PyCFunction)bpy_bmdeformvert_items, METH_NOARGS, bpy_bmdeformvert_items_doc}, + {"get", (PyCFunction)bpy_bmdeformvert_get, METH_VARARGS, bpy_bmdeformvert_get_doc}, + /* BMESH_TODO pop, popitem, update */ + {"clear", (PyCFunction)bpy_bmdeformvert_clear, METH_NOARGS, bpy_bmdeformvert_clear_doc}, + {NULL, NULL, 0, NULL} }; PyTypeObject BPy_BMDeformVert_Type = {{{0}}}; /* bm.loops.layers.uv.active */ diff --git a/source/blender/python/bmesh/bmesh_py_types_select.c b/source/blender/python/bmesh/bmesh_py_types_select.c index 40d39539894..c3adc8366bd 100644 --- a/source/blender/python/bmesh/bmesh_py_types_select.c +++ b/source/blender/python/bmesh/bmesh_py_types_select.c @@ -68,8 +68,8 @@ static PyObject *bpy_bmeditselseq_active_get(BPy_BMEditSelSeq *self, void *UNUSE } static PyGetSetDef bpy_bmeditselseq_getseters[] = { - {(char *)"active", (getter)bpy_bmeditselseq_active_get, (setter)NULL, (char *)bpy_bmeditselseq_active_doc, NULL}, - {NULL, NULL, NULL, NULL, NULL} /* Sentinel */ + {(char *)"active", (getter)bpy_bmeditselseq_active_get, (setter)NULL, (char *)bpy_bmeditselseq_active_doc, NULL}, + {NULL, NULL, NULL, NULL, NULL} /* Sentinel */ }; PyDoc_STRVAR(bpy_bmeditselseq_validate_doc, @@ -159,12 +159,12 @@ static PyObject *bpy_bmeditselseq_remove(BPy_BMEditSelSeq *self, BPy_BMElem *val } static struct PyMethodDef bpy_bmeditselseq_methods[] = { - {"validate", (PyCFunction)bpy_bmeditselseq_validate, METH_NOARGS, bpy_bmeditselseq_validate_doc}, - {"clear", (PyCFunction)bpy_bmeditselseq_clear, METH_NOARGS, bpy_bmeditselseq_clear_doc}, + {"validate", (PyCFunction)bpy_bmeditselseq_validate, METH_NOARGS, bpy_bmeditselseq_validate_doc}, + {"clear", (PyCFunction)bpy_bmeditselseq_clear, METH_NOARGS, bpy_bmeditselseq_clear_doc}, - {"add", (PyCFunction)bpy_bmeditselseq_add, METH_O, bpy_bmeditselseq_add_doc}, - {"remove", (PyCFunction)bpy_bmeditselseq_remove, METH_O, bpy_bmeditselseq_remove_doc}, - {NULL, NULL, 0, NULL} + {"add", (PyCFunction)bpy_bmeditselseq_add, METH_O, bpy_bmeditselseq_add_doc}, + {"remove", (PyCFunction)bpy_bmeditselseq_remove, METH_O, bpy_bmeditselseq_remove_doc}, + {NULL, NULL, 0, NULL} }; @@ -313,22 +313,22 @@ static int bpy_bmeditselseq_contains(BPy_BMEditSelSeq *self, PyObject *value) } static PySequenceMethods bpy_bmeditselseq_as_sequence = { - (lenfunc)bpy_bmeditselseq_length, /* sq_length */ - NULL, /* sq_concat */ - NULL, /* sq_repeat */ - (ssizeargfunc)bpy_bmeditselseq_subscript_int,/* sq_item */ /* Only set this so PySequence_Check() returns True */ - NULL, /* sq_slice */ - (ssizeobjargproc)NULL, /* sq_ass_item */ - NULL, /* *was* sq_ass_slice */ - (objobjproc)bpy_bmeditselseq_contains, /* sq_contains */ - (binaryfunc) NULL, /* sq_inplace_concat */ - (ssizeargfunc) NULL, /* sq_inplace_repeat */ + (lenfunc)bpy_bmeditselseq_length, /* sq_length */ + NULL, /* sq_concat */ + NULL, /* sq_repeat */ + (ssizeargfunc)bpy_bmeditselseq_subscript_int,/* sq_item */ /* Only set this so PySequence_Check() returns True */ + NULL, /* sq_slice */ + (ssizeobjargproc)NULL, /* sq_ass_item */ + NULL, /* *was* sq_ass_slice */ + (objobjproc)bpy_bmeditselseq_contains, /* sq_contains */ + (binaryfunc) NULL, /* sq_inplace_concat */ + (ssizeargfunc) NULL, /* sq_inplace_repeat */ }; static PyMappingMethods bpy_bmeditselseq_as_mapping = { - (lenfunc)bpy_bmeditselseq_length, /* mp_length */ - (binaryfunc)bpy_bmeditselseq_subscript, /* mp_subscript */ - (objobjargproc)NULL, /* mp_ass_subscript */ + (lenfunc)bpy_bmeditselseq_length, /* mp_length */ + (binaryfunc)bpy_bmeditselseq_subscript, /* mp_subscript */ + (objobjargproc)NULL, /* mp_ass_subscript */ }; diff --git a/source/blender/python/bmesh/bmesh_py_utils.c b/source/blender/python/bmesh/bmesh_py_utils.c index 4417bc2ce8d..b70df53aff0 100644 --- a/source/blender/python/bmesh/bmesh_py_utils.c +++ b/source/blender/python/bmesh/bmesh_py_utils.c @@ -39,9 +39,7 @@ #include "../mathutils/mathutils.h" #include "bmesh.h" - #include "bmesh_py_types.h" - #include "bmesh_py_utils.h" /* own include */ @@ -653,18 +651,18 @@ static PyObject *bpy_bm_utils_loop_separate(PyObject *UNUSED(self), BPy_BMLoop * static struct PyMethodDef BPy_BM_utils_methods[] = { - {"vert_collapse_edge", (PyCFunction)bpy_bm_utils_vert_collapse_edge, METH_VARARGS, bpy_bm_utils_vert_collapse_edge_doc}, - {"vert_collapse_faces", (PyCFunction)bpy_bm_utils_vert_collapse_faces, METH_VARARGS, bpy_bm_utils_vert_collapse_faces_doc}, - {"vert_dissolve", (PyCFunction)bpy_bm_utils_vert_dissolve, METH_VARARGS, bpy_bm_utils_vert_dissolve_doc}, /* could use METH_O */ - {"vert_separate", (PyCFunction)bpy_bm_utils_vert_separate, METH_VARARGS, bpy_bm_utils_vert_separate_doc}, - {"edge_split", (PyCFunction)bpy_bm_utils_edge_split, METH_VARARGS, bpy_bm_utils_edge_split_doc}, - {"edge_rotate", (PyCFunction)bpy_bm_utils_edge_rotate, METH_VARARGS, bpy_bm_utils_edge_rotate_doc}, - {"face_split", (PyCFunction)bpy_bm_utils_face_split, METH_VARARGS | METH_KEYWORDS, bpy_bm_utils_face_split_doc}, - {"face_join", (PyCFunction)bpy_bm_utils_face_join, METH_VARARGS, bpy_bm_utils_face_join_doc}, - {"face_vert_separate", (PyCFunction)bpy_bm_utils_face_vert_separate, METH_VARARGS, bpy_bm_utils_face_vert_separate_doc}, - {"face_flip", (PyCFunction)bpy_bm_utils_face_flip, METH_O, bpy_bm_utils_face_flip_doc}, - {"loop_separate", (PyCFunction)bpy_bm_utils_loop_separate, METH_O, bpy_bm_utils_loop_separate_doc}, - {NULL, NULL, 0, NULL} + {"vert_collapse_edge", (PyCFunction)bpy_bm_utils_vert_collapse_edge, METH_VARARGS, bpy_bm_utils_vert_collapse_edge_doc}, + {"vert_collapse_faces", (PyCFunction)bpy_bm_utils_vert_collapse_faces, METH_VARARGS, bpy_bm_utils_vert_collapse_faces_doc}, + {"vert_dissolve", (PyCFunction)bpy_bm_utils_vert_dissolve, METH_VARARGS, bpy_bm_utils_vert_dissolve_doc}, /* could use METH_O */ + {"vert_separate", (PyCFunction)bpy_bm_utils_vert_separate, METH_VARARGS, bpy_bm_utils_vert_separate_doc}, + {"edge_split", (PyCFunction)bpy_bm_utils_edge_split, METH_VARARGS, bpy_bm_utils_edge_split_doc}, + {"edge_rotate", (PyCFunction)bpy_bm_utils_edge_rotate, METH_VARARGS, bpy_bm_utils_edge_rotate_doc}, + {"face_split", (PyCFunction)bpy_bm_utils_face_split, METH_VARARGS | METH_KEYWORDS, bpy_bm_utils_face_split_doc}, + {"face_join", (PyCFunction)bpy_bm_utils_face_join, METH_VARARGS, bpy_bm_utils_face_join_doc}, + {"face_vert_separate", (PyCFunction)bpy_bm_utils_face_vert_separate, METH_VARARGS, bpy_bm_utils_face_vert_separate_doc}, + {"face_flip", (PyCFunction)bpy_bm_utils_face_flip, METH_O, bpy_bm_utils_face_flip_doc}, + {"loop_separate", (PyCFunction)bpy_bm_utils_loop_separate, METH_O, bpy_bm_utils_loop_separate_doc}, + {NULL, NULL, 0, NULL} }; @@ -672,15 +670,15 @@ PyDoc_STRVAR(BPy_BM_utils_doc, "This module provides access to blenders bmesh data structures." ); static struct PyModuleDef BPy_BM_utils_module_def = { - PyModuleDef_HEAD_INIT, - "bmesh.utils", /* m_name */ - BPy_BM_utils_doc, /* m_doc */ - 0, /* m_size */ - BPy_BM_utils_methods, /* m_methods */ - NULL, /* m_reload */ - NULL, /* m_traverse */ - NULL, /* m_clear */ - NULL, /* m_free */ + PyModuleDef_HEAD_INIT, + "bmesh.utils", /* m_name */ + BPy_BM_utils_doc, /* m_doc */ + 0, /* m_size */ + BPy_BM_utils_methods, /* m_methods */ + NULL, /* m_reload */ + NULL, /* m_traverse */ + NULL, /* m_clear */ + NULL, /* m_free */ }; diff --git a/source/blender/quicktime/apple/qtkit_export.m b/source/blender/quicktime/apple/qtkit_export.m index f8b09ae8b1b..47df4c7363f 100644 --- a/source/blender/quicktime/apple/qtkit_export.m +++ b/source/blender/quicktime/apple/qtkit_export.m @@ -88,8 +88,8 @@ typedef struct QuicktimeExport { AudioStreamBasicDescription audioInputFormat, audioOutputFormat; AudioStreamPacketDescription *audioOutputPktDesc; SInt64 audioFilePos; - char* audioInputBuffer; - char* audioOutputBuffer; + char *audioInputBuffer; + char *audioOutputBuffer; UInt32 audioCodecMaxOutputPacketSize; UInt64 audioTotalExportedFrames, audioTotalSavedFrames; UInt64 audioLastFrame; diff --git a/source/blender/quicktime/apple/qtkit_import.m b/source/blender/quicktime/apple/qtkit_import.m index 073fb31ff96..e30b8331fc0 100644 --- a/source/blender/quicktime/apple/qtkit_import.m +++ b/source/blender/quicktime/apple/qtkit_import.m @@ -153,8 +153,9 @@ static ImBuf * nsImageToiBuf(NSImage *sourceImage, int width, int height) ibuf = IMB_allocImBuf (width, height, 32, IB_rect); if (!ibuf) { - if(QTIME_DEBUG) printf("quicktime_import: could not allocate memory for the " \ - "image.\n"); + if (QTIME_DEBUG) { + printf("quicktime_import: could not allocate memory for the image.\n"); + } return NULL; } @@ -455,8 +456,7 @@ ImBuf *imb_quicktime_decode(unsigned char *mem, int size, int flags) ibuf = IMB_allocImBuf(bitmapSize.width, bitmapSize.height, 32/*RGBA*/, 0); if (!ibuf) { fprintf(stderr, - "imb_cocoaLoadImage: could not allocate memory for the " \ - "image.\n"); + "imb_cocoaLoadImage: could not allocate memory for the image.\n"); [bitmapImage release]; [pool drain]; return NULL; diff --git a/source/blender/render/intern/include/rayobject.h b/source/blender/render/intern/include/rayobject.h index ce20ce4ea46..7752baadff4 100644 --- a/source/blender/render/intern/include/rayobject.h +++ b/source/blender/render/intern/include/rayobject.h @@ -55,14 +55,14 @@ int RE_rayobject_raycast(RayObject *r, struct Isect *i); /* Acceleration Structures */ -RayObject* RE_rayobject_octree_create(int ocres, int size); -RayObject* RE_rayobject_instance_create(RayObject *target, float transform[][4], void *ob, void *target_ob); -RayObject* RE_rayobject_empty_create(void); +RayObject *RE_rayobject_octree_create(int ocres, int size); +RayObject *RE_rayobject_instance_create(RayObject *target, float transform[][4], void *ob, void *target_ob); +RayObject *RE_rayobject_empty_create(void); -RayObject* RE_rayobject_blibvh_create(int size); /* BLI_kdopbvh.c */ -RayObject* RE_rayobject_vbvh_create(int size); /* raytrace/rayobject_vbvh.c */ -RayObject* RE_rayobject_svbvh_create(int size); /* raytrace/rayobject_svbvh.c */ -RayObject* RE_rayobject_qbvh_create(int size); /* raytrace/rayobject_qbvh.c */ +RayObject *RE_rayobject_blibvh_create(int size); /* BLI_kdopbvh.c */ +RayObject *RE_rayobject_vbvh_create(int size); /* raytrace/rayobject_vbvh.c */ +RayObject *RE_rayobject_svbvh_create(int size); /* raytrace/rayobject_svbvh.c */ +RayObject *RE_rayobject_qbvh_create(int size); /* raytrace/rayobject_qbvh.c */ /* Building */ @@ -85,7 +85,7 @@ typedef struct RayFace { #define RE_rayface_isQuad(a) ((a)->quad) -RayObject* RE_rayface_from_vlak(RayFace *face, struct ObjectInstanceRen *obi, struct VlakRen *vlr); +RayObject *RE_rayface_from_vlak(RayFace *face, struct ObjectInstanceRen *obi, struct VlakRen *vlr); /* RayObject representing faces directly from a given VlakRen structure. Thus * allowing to save memory, but making code triangle intersection dependent on @@ -96,7 +96,7 @@ typedef struct VlakPrimitive { struct VlakRen *face; } VlakPrimitive; -RayObject* RE_vlakprimitive_from_vlak(VlakPrimitive *face, struct ObjectInstanceRen *obi, struct VlakRen *vlr); +RayObject *RE_vlakprimitive_from_vlak(VlakPrimitive *face, struct ObjectInstanceRen *obi, struct VlakRen *vlr); /* Bounding Box */ @@ -118,4 +118,3 @@ void RE_rayobject_hint_bb(RayObject *r, struct RayHint *hint, float *min, float #endif #endif - diff --git a/source/blender/windowmanager/WM_api.h b/source/blender/windowmanager/WM_api.h index 588be336afa..ff7c8cd2ea7 100644 --- a/source/blender/windowmanager/WM_api.h +++ b/source/blender/windowmanager/WM_api.h @@ -245,8 +245,8 @@ void WM_operator_py_idname(char *to, const char *from); /* *************** menu types ******************** */ void WM_menutype_init(void); struct MenuType *WM_menutype_find(const char *idname, int quiet); -int WM_menutype_add(struct MenuType* mt); -void WM_menutype_freelink(struct MenuType* mt); +int WM_menutype_add(struct MenuType *mt); +void WM_menutype_freelink(struct MenuType *mt); void WM_menutype_free(void); /* default operator callbacks for border/circle/lasso */ diff --git a/source/blenderplayer/bad_level_call_stubs/stubs.c b/source/blenderplayer/bad_level_call_stubs/stubs.c index 9ae2cb0c353..b600c08f4dc 100644 --- a/source/blenderplayer/bad_level_call_stubs/stubs.c +++ b/source/blenderplayer/bad_level_call_stubs/stubs.c @@ -183,7 +183,7 @@ int RE_WriteEnvmapResult(struct ReportList *reports, struct Scene *scene, struct /* rna */ float *give_cursor(struct Scene *scene, struct View3D *v3d) {return (float *) NULL;} void WM_menutype_free(void) {} -void WM_menutype_freelink(struct MenuType* mt) {} +void WM_menutype_freelink(struct MenuType *mt) {} int WM_menutype_add(struct MenuType *mt) {return 0;} int WM_operator_props_dialog_popup(struct bContext *C, struct wmOperator *op, int width, int height) {return 0;} int WM_operator_confirm(struct bContext *C, struct wmOperator *op, struct wmEvent *event) {return 0;} @@ -418,7 +418,7 @@ void uiTemplateColorWheel(struct uiLayout *layout, struct PointerRNA *ptr, char void uiTemplateHistogram(struct uiLayout *layout, struct PointerRNA *ptr, char *propname, int expand) {} void uiTemplateReportsBanner(struct uiLayout *layout, struct bContext *C, struct wmOperator *op) {} void uiTemplateWaveform(struct uiLayout *layout, struct PointerRNA *ptr, char *propname, int expand) {} -void uiTemplateVectorscope(struct uiLayout *_self, struct PointerRNA *data, char* property, int expand) {} +void uiTemplateVectorscope(struct uiLayout *_self, struct PointerRNA *data, char *property, int expand) {} void uiTemplateNodeLink(struct uiLayout *layout, struct bNodeTree *ntree, struct bNode *node, struct bNodeSocket *input) {} void uiTemplateNodeView(struct uiLayout *layout, struct bContext *C, struct bNodeTree *ntree, struct bNode *node, struct bNodeSocket *input) {} void uiTemplateTextureUser(struct uiLayout *layout, struct bContext *C) {} diff --git a/source/gameengine/Converter/KX_ConvertSensors.cpp b/source/gameengine/Converter/KX_ConvertSensors.cpp index 93eeaaf05fb..9f155a6ebc3 100644 --- a/source/gameengine/Converter/KX_ConvertSensors.cpp +++ b/source/gameengine/Converter/KX_ConvertSensors.cpp @@ -657,19 +657,19 @@ void BL_ConvertSensors(struct Object* blenderobject, if (gamecont) { logicmgr->RegisterToSensor(gamecont,gamesensor); - } else { - printf( - "Warning, sensor \"%s\" could not find its controller " - "(link %d of %d) from object \"%s\"\n" - "\tthere has been an error converting the blender controller for the game engine," - "logic may be incorrect\n", sens->name, i+1, sens->totlinks, blenderobject->id.name+2); } - } else { - printf( - "Warning, sensor \"%s\" has lost a link to a controller " - "(link %d of %d) from object \"%s\"\n" - "\tpossible causes are partially appended objects or an error reading the file," - "logic may be incorrect\n", sens->name, i+1, sens->totlinks, blenderobject->id.name+2); + else { + printf("Warning, sensor \"%s\" could not find its controller " + "(link %d of %d) from object \"%s\"\n" + "\tthere has been an error converting the blender controller for the game engine," + "logic may be incorrect\n", sens->name, i+1, sens->totlinks, blenderobject->id.name+2); + } + } + else { + printf("Warning, sensor \"%s\" has lost a link to a controller " + "(link %d of %d) from object \"%s\"\n" + "\tpossible causes are partially appended objects or an error reading the file," + "logic may be incorrect\n", sens->name, i+1, sens->totlinks, blenderobject->id.name+2); } } // special case: Keyboard sensor with no link diff --git a/source/gameengine/Expressions/BoolValue.cpp b/source/gameengine/Expressions/BoolValue.cpp index b3c4dc144df..40997a25be1 100644 --- a/source/gameengine/Expressions/BoolValue.cpp +++ b/source/gameengine/Expressions/BoolValue.cpp @@ -139,7 +139,7 @@ this object default: { ret = new CErrorValue(val->GetText() + op2str(op) + - "[operator not allowed on booleans]"); + "[operator not allowed on booleans]"); break; } } diff --git a/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp b/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp index 63f2988e259..41f641b4368 100644 --- a/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp +++ b/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp @@ -194,7 +194,7 @@ void usage(const char* program, bool isBlenderPlayer) } printf("usage: %s [-w [w h l t]] [-f [fw fh fb ff]] %s[-g gamengineoptions] " - "[-s stereomode] [-m aasamples] %s\n", program, consoleoption, example_filename); + "[-s stereomode] [-m aasamples] %s\n", program, consoleoption, example_filename); printf(" -h: Prints this command summary\n\n"); printf(" -w: display in a window\n"); printf(" --Optional parameters--\n"); diff --git a/source/gameengine/Ketsji/KX_Camera.cpp b/source/gameengine/Ketsji/KX_Camera.cpp index a9602d16430..ac17adaf052 100644 --- a/source/gameengine/Ketsji/KX_Camera.cpp +++ b/source/gameengine/Ketsji/KX_Camera.cpp @@ -1048,7 +1048,9 @@ KX_PYMETHODDEF_DOC_VARARGS(KX_Camera, getScreenRay, { Py_DECREF(argValue); PyErr_SetString(PyExc_TypeError, - "Error in getScreenRay. Invalid 2D coordinate. Expected a normalized 2D screen coordinate, a distance and an optional property argument"); + "Error in getScreenRay. Invalid 2D coordinate. " + "Expected a normalized 2D screen coordinate, " + "a distance and an optional property argument"); return NULL; } Py_DECREF(argValue); From 25a925ceabb9987c0204df32200b664dcc1aaf44 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 26 Aug 2012 12:21:25 +0000 Subject: [PATCH 140/163] fix for build error without ffmpeg --- source/creator/creator.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/source/creator/creator.c b/source/creator/creator.c index 58e1066e5ff..80981c08c5e 100644 --- a/source/creator/creator.c +++ b/source/creator/creator.c @@ -1273,7 +1273,10 @@ int main(int argc, const char **argv) initglobals(); /* blender.c */ IMB_init(); + +#ifdef WITH_FFMPEG IMB_ffmpeg_init(); +#endif BLI_callback_global_init(); From d35957ba9493dfdcc83440a968d6ceb3fcfdc645 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 26 Aug 2012 13:41:40 +0000 Subject: [PATCH 141/163] code cleanup: split out mask spline evaluation into its own file. --- source/blender/blenkernel/BKE_mask.h | 46 +- source/blender/blenkernel/CMakeLists.txt | 1 + source/blender/blenkernel/intern/mask.c | 602 +--------------- .../blender/blenkernel/intern/mask_evaluate.c | 647 ++++++++++++++++++ 4 files changed, 681 insertions(+), 615 deletions(-) create mode 100644 source/blender/blenkernel/intern/mask_evaluate.c diff --git a/source/blender/blenkernel/BKE_mask.h b/source/blender/blenkernel/BKE_mask.h index b46aefe4e98..a1c36d53368 100644 --- a/source/blender/blenkernel/BKE_mask.h +++ b/source/blender/blenkernel/BKE_mask.h @@ -19,7 +19,8 @@ * All rights reserved. * * Contributor(s): Blender Foundation, - * Sergey Sharybin + * Sergey Sharybin, + * Campbell Barton * * ***** END GPL LICENSE BLOCK ***** */ @@ -63,29 +64,12 @@ void BKE_mask_layer_copy_list(struct ListBase *masklayers_new, struct ListBase * /* splines */ struct MaskSpline *BKE_mask_spline_add(struct MaskLayer *masklay); - -unsigned int BKE_mask_spline_resolution(struct MaskSpline *spline, int width, int height); -unsigned int BKE_mask_spline_feather_resolution(struct MaskSpline *spline, int width, int height); - -int BKE_mask_spline_differentiate_calc_total(const struct MaskSpline *spline, const unsigned int resol); - -float (*BKE_mask_spline_differentiate(struct MaskSpline *spline, int *tot_diff_point))[2]; -float (*BKE_mask_spline_feather_differentiated_points(struct MaskSpline *spline, int *tot_feather_point))[2]; - -float (*BKE_mask_spline_differentiate_with_resolution_ex(struct MaskSpline *spline, int *tot_diff_point, - const unsigned int resol))[2]; -void BKE_mask_spline_feather_collapse_inner_loops(struct MaskSpline *spline, float (*feather_points)[2], const int tot_feather_point); -float (*BKE_mask_spline_differentiate_with_resolution(struct MaskSpline *spline, int width, int height, int *tot_diff_point))[2]; -float (*BKE_mask_spline_feather_differentiated_points_with_resolution_ex(struct MaskSpline *spline, int *tot_feather_point, - const unsigned int resol, const int do_feather_isect))[2]; -float (*BKE_mask_spline_feather_differentiated_points_with_resolution(struct MaskSpline *spline, int width, int height, - int *tot_feather_point, const int do_feather_isect))[2]; - -float (*BKE_mask_spline_feather_points(struct MaskSpline *spline, int *tot_feather_point))[2]; - void BKE_mask_point_direction_switch(struct MaskSplinePoint *point); void BKE_mask_spline_direction_switch(struct MaskLayer *masklay, struct MaskSpline *spline); +struct BezTriple *BKE_mask_spline_point_next_bezt(struct MaskSpline *spline, struct MaskSplinePoint *points_array, + struct MaskSplinePoint *point); + typedef enum { MASK_PROJ_NEG = -1, MASK_PROJ_ANY = 0, @@ -205,6 +189,26 @@ int BKE_mask_get_duration(struct Mask *mask); #define MASK_RESOL_MAX 128 +/* mask_evaluate.c */ +unsigned int BKE_mask_spline_resolution(struct MaskSpline *spline, int width, int height); +unsigned int BKE_mask_spline_feather_resolution(struct MaskSpline *spline, int width, int height); +int BKE_mask_spline_differentiate_calc_total(const struct MaskSpline *spline, const unsigned int resol); + +float (*BKE_mask_spline_differentiate(struct MaskSpline *spline, int *tot_diff_point))[2]; +float (*BKE_mask_spline_feather_differentiated_points(struct MaskSpline *spline, int *tot_feather_point))[2]; + +float (*BKE_mask_spline_differentiate_with_resolution_ex(struct MaskSpline *spline, int *tot_diff_point, + const unsigned int resol))[2]; +void BKE_mask_spline_feather_collapse_inner_loops(struct MaskSpline *spline, float (*feather_points)[2], const int tot_feather_point); +float (*BKE_mask_spline_differentiate_with_resolution(struct MaskSpline *spline, int width, int height, int *tot_diff_point))[2]; +float (*BKE_mask_spline_feather_differentiated_points_with_resolution_ex(struct MaskSpline *spline, int *tot_feather_point, + const unsigned int resol, const int do_feather_isect))[2]; +float (*BKE_mask_spline_feather_differentiated_points_with_resolution(struct MaskSpline *spline, int width, int height, + int *tot_feather_point, const int do_feather_isect))[2]; + +float (*BKE_mask_spline_feather_points(struct MaskSpline *spline, int *tot_feather_point))[2]; + + /* mask_rasterize.c */ struct MaskRasterHandle; typedef struct MaskRasterHandle MaskRasterHandle; diff --git a/source/blender/blenkernel/CMakeLists.txt b/source/blender/blenkernel/CMakeLists.txt index 0a0635126f5..afa3998fb49 100644 --- a/source/blender/blenkernel/CMakeLists.txt +++ b/source/blender/blenkernel/CMakeLists.txt @@ -101,6 +101,7 @@ set(SRC intern/lamp.c intern/lattice.c intern/library.c + intern/mask_evaluate.c intern/mask_rasterize.c intern/mask.c intern/material.c diff --git a/source/blender/blenkernel/intern/mask.c b/source/blender/blenkernel/intern/mask.c index a6ceba588d2..d7f6b6f6b25 100644 --- a/source/blender/blenkernel/intern/mask.c +++ b/source/blender/blenkernel/intern/mask.c @@ -19,7 +19,8 @@ * All rights reserved. * * Contributor(s): Blender Foundation, - * Sergey Sharybin + * Sergey Sharybin, + * Campbell Barton * * ***** END GPL LICENSE BLOCK ***** */ @@ -41,12 +42,8 @@ #include "DNA_mask_types.h" #include "DNA_node_types.h" -#include "DNA_scene_types.h" -#include "DNA_object_types.h" #include "DNA_screen_types.h" #include "DNA_space_types.h" -#include "DNA_movieclip_types.h" -#include "DNA_tracking_types.h" #include "DNA_sequence_types.h" #include "BKE_curve.h" @@ -58,7 +55,6 @@ #include "BKE_sequencer.h" #include "BKE_tracking.h" #include "BKE_movieclip.h" -#include "BKE_utildefines.h" static MaskSplinePoint *mask_spline_point_next(MaskSpline *spline, MaskSplinePoint *points_array, MaskSplinePoint *point) { @@ -90,7 +86,7 @@ static MaskSplinePoint *mask_spline_point_prev(MaskSpline *spline, MaskSplinePoi } } -static BezTriple *mask_spline_point_next_bezt(MaskSpline *spline, MaskSplinePoint *points_array, MaskSplinePoint *point) +BezTriple *BKE_mask_spline_point_next_bezt(MaskSpline *spline, MaskSplinePoint *points_array, MaskSplinePoint *point) { if (point == &points_array[spline->tot_point - 1]) { if (spline->flag & MASK_SPLINE_CYCLIC) { @@ -269,588 +265,6 @@ MaskSpline *BKE_mask_spline_add(MaskLayer *masklay) return spline; } -unsigned int BKE_mask_spline_resolution(MaskSpline *spline, int width, int height) -{ - float max_segment = 0.01f; - unsigned int i, resol = 1; - - if (width != 0 && height != 0) { - if (width >= height) - max_segment = 1.0f / (float) width; - else - max_segment = 1.0f / (float) height; - } - - for (i = 0; i < spline->tot_point; i++) { - MaskSplinePoint *point = &spline->points[i]; - BezTriple *bezt, *bezt_next; - float a, b, c, len; - unsigned int cur_resol; - - bezt = &point->bezt; - bezt_next = mask_spline_point_next_bezt(spline, spline->points, point); - - if (bezt_next == NULL) { - break; - } - - a = len_v3v3(bezt->vec[1], bezt->vec[2]); - b = len_v3v3(bezt->vec[2], bezt_next->vec[0]); - c = len_v3v3(bezt_next->vec[0], bezt_next->vec[1]); - - len = a + b + c; - cur_resol = len / max_segment; - - resol = MAX2(resol, cur_resol); - - if (resol >= MASK_RESOL_MAX) { - break; - } - } - - return CLAMPIS(resol, 1, MASK_RESOL_MAX); -} - -unsigned int BKE_mask_spline_feather_resolution(MaskSpline *spline, int width, int height) -{ - const float max_segment = 0.005; - unsigned int resol = BKE_mask_spline_resolution(spline, width, height); - float max_jump = 0.0f; - int i; - - /* avoid checking the featrher if we already hit the maximum value */ - if (resol >= MASK_RESOL_MAX) { - return MASK_RESOL_MAX; - } - - for (i = 0; i < spline->tot_point; i++) { - MaskSplinePoint *point = &spline->points[i]; - float prev_u, prev_w; - int j; - - prev_u = 0.0f; - prev_w = point->bezt.weight; - - for (j = 0; j < point->tot_uw; j++) { - const float w_diff = (point->uw[j].w - prev_w); - const float u_diff = (point->uw[j].u - prev_u); - - /* avoid divide by zero and very high values, - * though these get clamped eventually */ - if (u_diff > FLT_EPSILON) { - float jump = fabsf(w_diff / u_diff); - - max_jump = MAX2(max_jump, jump); - } - - prev_u = point->uw[j].u; - prev_w = point->uw[j].w; - } - } - - resol += max_jump / max_segment; - - return CLAMPIS(resol, 1, MASK_RESOL_MAX); -} - -int BKE_mask_spline_differentiate_calc_total(const MaskSpline *spline, const unsigned int resol) -{ - if (spline->flag & MASK_SPLINE_CYCLIC) { - return spline->tot_point * resol; - } - else { - return ((spline->tot_point - 1) * resol) + 1; - } -} - -float (*BKE_mask_spline_differentiate_with_resolution_ex(MaskSpline *spline, - int *tot_diff_point, - const unsigned int resol - ))[2] -{ - MaskSplinePoint *points_array = BKE_mask_spline_point_array(spline); - - MaskSplinePoint *point, *prev; - float (*diff_points)[2], (*fp)[2]; - const int tot = BKE_mask_spline_differentiate_calc_total(spline, resol); - int a; - - if (spline->tot_point <= 1) { - /* nothing to differentiate */ - *tot_diff_point = 0; - return NULL; - } - - /* len+1 because of 'forward_diff_bezier' function */ - *tot_diff_point = tot; - diff_points = fp = MEM_mallocN((tot + 1) * sizeof(*diff_points), "mask spline vets"); - - a = spline->tot_point - 1; - if (spline->flag & MASK_SPLINE_CYCLIC) - a++; - - prev = points_array; - point = prev + 1; - - while (a--) { - BezTriple *prevbezt; - BezTriple *bezt; - int j; - - if (a == 0 && (spline->flag & MASK_SPLINE_CYCLIC)) - point = points_array; - - prevbezt = &prev->bezt; - bezt = &point->bezt; - - for (j = 0; j < 2; j++) { - BKE_curve_forward_diff_bezier(prevbezt->vec[1][j], prevbezt->vec[2][j], - bezt->vec[0][j], bezt->vec[1][j], - &(*fp)[j], resol, 2 * sizeof(float)); - } - - fp += resol; - - if (a == 0 && (spline->flag & MASK_SPLINE_CYCLIC) == 0) { - copy_v2_v2(*fp, bezt->vec[1]); - } - - prev = point; - point++; - } - - return diff_points; -} - -float (*BKE_mask_spline_differentiate_with_resolution(MaskSpline *spline, int width, int height, - int *tot_diff_point - ))[2] -{ - int unsigned resol = BKE_mask_spline_resolution(spline, width, height); - - return BKE_mask_spline_differentiate_with_resolution_ex(spline, tot_diff_point, resol); -} - -float (*BKE_mask_spline_differentiate(MaskSpline *spline, int *tot_diff_point))[2] -{ - return BKE_mask_spline_differentiate_with_resolution(spline, 0, 0, tot_diff_point); -} - -/* ** feather points self-intersection collapse routine ** */ - -typedef struct FeatherEdgesBucket { - int tot_segment; - int (*segments)[2]; - int alloc_segment; -} FeatherEdgesBucket; - -static void feather_bucket_add_edge(FeatherEdgesBucket *bucket, int start, int end) -{ - const int alloc_delta = 256; - - if (bucket->tot_segment >= bucket->alloc_segment) { - if (!bucket->segments) { - bucket->segments = MEM_callocN(alloc_delta * sizeof(*bucket->segments), "feather bucket segments"); - } - else { - bucket->segments = MEM_reallocN(bucket->segments, - (alloc_delta + bucket->tot_segment) * sizeof(*bucket->segments)); - } - - bucket->alloc_segment += alloc_delta; - } - - bucket->segments[bucket->tot_segment][0] = start; - bucket->segments[bucket->tot_segment][1] = end; - - bucket->tot_segment++; -} - -static void feather_bucket_check_intersect(float (*feather_points)[2], int tot_feather_point, FeatherEdgesBucket *bucket, - int cur_a, int cur_b) -{ - int i; - - float *v1 = (float *) feather_points[cur_a]; - float *v2 = (float *) feather_points[cur_b]; - - for (i = 0; i < bucket->tot_segment; i++) { - int check_a = bucket->segments[i][0]; - int check_b = bucket->segments[i][1]; - - float *v3 = (float *) feather_points[check_a]; - float *v4 = (float *) feather_points[check_b]; - - if (check_a >= cur_a - 1 || cur_b == check_a) - continue; - - if (isect_seg_seg_v2(v1, v2, v3, v4)) { - int k; - float p[2]; - float min_a[2], max_a[2]; - float min_b[2], max_b[2]; - - isect_seg_seg_v2_point(v1, v2, v3, v4, p); - - INIT_MINMAX2(min_a, max_a); - INIT_MINMAX2(min_b, max_b); - - /* collapse loop with smaller AABB */ - for (k = 0; k < tot_feather_point; k++) { - if (k >= check_b && k <= cur_a) { - DO_MINMAX2(feather_points[k], min_a, max_a); - } - else { - DO_MINMAX2(feather_points[k], min_b, max_b); - } - } - - if (max_a[0] - min_a[0] < max_b[0] - min_b[0] || - max_a[1] - min_a[1] < max_b[1] - min_b[1]) - { - for (k = check_b; k <= cur_a; k++) { - copy_v2_v2(feather_points[k], p); - } - } - else { - for (k = 0; k <= check_a; k++) { - copy_v2_v2(feather_points[k], p); - } - - if (cur_b != 0) { - for (k = cur_b; k < tot_feather_point; k++) { - copy_v2_v2(feather_points[k], p); - } - } - } - } - } -} - -static int feather_bucket_index_from_coord(float co[2], const float min[2], const float bucket_scale[2], - const int buckets_per_side) -{ - int x = (int) ((co[0] - min[0]) * bucket_scale[0]); - int y = (int) ((co[1] - min[1]) * bucket_scale[1]); - - if (x == buckets_per_side) - x--; - - if (y == buckets_per_side) - y--; - - return y * buckets_per_side + x; -} - -static void feather_bucket_get_diagonal(FeatherEdgesBucket *buckets, int start_bucket_index, int end_bucket_index, - int buckets_per_side, FeatherEdgesBucket **diagonal_bucket_a_r, - FeatherEdgesBucket **diagonal_bucket_b_r) -{ - int start_bucket_x = start_bucket_index % buckets_per_side; - int start_bucket_y = start_bucket_index / buckets_per_side; - - int end_bucket_x = end_bucket_index % buckets_per_side; - int end_bucket_y = end_bucket_index / buckets_per_side; - - int diagonal_bucket_a_index = start_bucket_y * buckets_per_side + end_bucket_x; - int diagonal_bucket_b_index = end_bucket_y * buckets_per_side + start_bucket_x; - - *diagonal_bucket_a_r = &buckets[diagonal_bucket_a_index]; - *diagonal_bucket_b_r = &buckets[diagonal_bucket_b_index]; -} - -void BKE_mask_spline_feather_collapse_inner_loops(MaskSpline *spline, float (*feather_points)[2], const int tot_feather_point) -{ -#define BUCKET_INDEX(co) \ - feather_bucket_index_from_coord(co, min, bucket_scale, buckets_per_side) - - int buckets_per_side, tot_bucket; - float bucket_size, bucket_scale[2]; - - FeatherEdgesBucket *buckets; - - int i; - float min[2], max[2]; - float max_delta_x = -1.0f, max_delta_y = -1.0f, max_delta; - - if (tot_feather_point < 4) { - /* self-intersection works only for quads at least, - * in other cases polygon can't be self-intersecting anyway - */ - - return; - } - - /* find min/max corners of mask to build buckets in that space */ - INIT_MINMAX2(min, max); - - for (i = 0; i < tot_feather_point; i++) { - int next = i + 1; - float delta; - - DO_MINMAX2(feather_points[i], min, max); - - if (next == tot_feather_point) { - if (spline->flag & MASK_SPLINE_CYCLIC) - next = 0; - else - break; - } - - delta = fabsf(feather_points[i][0] - feather_points[next][0]); - if (delta > max_delta_x) - max_delta_x = delta; - - delta = fabsf(feather_points[i][1] - feather_points[next][1]); - if (delta > max_delta_y) - max_delta_y = delta; - } - - /* prevent divisionsby zero by ensuring bounding box is not collapsed */ - if (max[0] - min[0] < FLT_EPSILON) { - max[0] += 0.01f; - min[0] -= 0.01f; - } - - if (max[1] - min[1] < FLT_EPSILON) { - max[1] += 0.01f; - min[1] -= 0.01f; - } - - /* use dynamically calculated buckets per side, so we likely wouldn't - * run into a situation when segment doesn't fit two buckets which is - * pain collecting candidates for intersection - */ - - max_delta_x /= max[0] - min[0]; - max_delta_y /= max[1] - min[1]; - - max_delta = MAX2(max_delta_x, max_delta_y); - - buckets_per_side = MIN2(512, 0.9f / max_delta); - - if (buckets_per_side == 0) { - /* happens when some segment fills the whole bounding box across some of dimension */ - - buckets_per_side = 1; - } - - tot_bucket = buckets_per_side * buckets_per_side; - bucket_size = 1.0f / buckets_per_side; - - /* pre-compute multipliers, to save mathematical operations in loops */ - bucket_scale[0] = 1.0f / ((max[0] - min[0]) * bucket_size); - bucket_scale[1] = 1.0f / ((max[1] - min[1]) * bucket_size); - - /* fill in buckets' edges */ - buckets = MEM_callocN(sizeof(FeatherEdgesBucket) * tot_bucket, "feather buckets"); - - for (i = 0; i < tot_feather_point; i++) { - int start = i, end = i + 1; - int start_bucket_index, end_bucket_index; - - if (end == tot_feather_point) { - if (spline->flag & MASK_SPLINE_CYCLIC) - end = 0; - else - break; - } - - start_bucket_index = BUCKET_INDEX(feather_points[start]); - end_bucket_index = BUCKET_INDEX(feather_points[end]); - - feather_bucket_add_edge(&buckets[start_bucket_index], start, end); - - if (start_bucket_index != end_bucket_index) { - FeatherEdgesBucket *end_bucket = &buckets[end_bucket_index]; - FeatherEdgesBucket *diagonal_bucket_a, *diagonal_bucket_b; - - feather_bucket_get_diagonal(buckets, start_bucket_index, end_bucket_index, buckets_per_side, - &diagonal_bucket_a, &diagonal_bucket_b); - - feather_bucket_add_edge(end_bucket, start, end); - feather_bucket_add_edge(diagonal_bucket_a, start, end); - feather_bucket_add_edge(diagonal_bucket_a, start, end); - } - } - - /* check all edges for intersection with edges from their buckets */ - for (i = 0; i < tot_feather_point; i++) { - int cur_a = i, cur_b = i + 1; - int start_bucket_index, end_bucket_index; - - FeatherEdgesBucket *start_bucket; - - if (cur_b == tot_feather_point) - cur_b = 0; - - start_bucket_index = BUCKET_INDEX(feather_points[cur_a]); - end_bucket_index = BUCKET_INDEX(feather_points[cur_b]); - - start_bucket = &buckets[start_bucket_index]; - - feather_bucket_check_intersect(feather_points, tot_feather_point, start_bucket, cur_a, cur_b); - - if (start_bucket_index != end_bucket_index) { - FeatherEdgesBucket *end_bucket = &buckets[end_bucket_index]; - FeatherEdgesBucket *diagonal_bucket_a, *diagonal_bucket_b; - - feather_bucket_get_diagonal(buckets, start_bucket_index, end_bucket_index, buckets_per_side, - &diagonal_bucket_a, &diagonal_bucket_b); - - feather_bucket_check_intersect(feather_points, tot_feather_point, end_bucket, cur_a, cur_b); - feather_bucket_check_intersect(feather_points, tot_feather_point, diagonal_bucket_a, cur_a, cur_b); - feather_bucket_check_intersect(feather_points, tot_feather_point, diagonal_bucket_b, cur_a, cur_b); - } - } - - /* free buckets */ - for (i = 0; i < tot_bucket; i++) { - if (buckets[i].segments) - MEM_freeN(buckets[i].segments); - } - - MEM_freeN(buckets); - -#undef BUCKET_INDEX -} - -/** - * values align with #BKE_mask_spline_differentiate_with_resolution_ex - * when \a resol arguments match. - */ -float (*BKE_mask_spline_feather_differentiated_points_with_resolution_ex(MaskSpline *spline, - int *tot_feather_point, - const unsigned int resol, - const int do_feather_isect - ))[2] -{ - MaskSplinePoint *points_array = BKE_mask_spline_point_array(spline); - MaskSplinePoint *point, *prev; - float (*feather)[2], (*fp)[2]; - - const int tot = BKE_mask_spline_differentiate_calc_total(spline, resol); - int a; - - /* tot+1 because of 'forward_diff_bezier' function */ - feather = fp = MEM_mallocN((tot + 1) * sizeof(*feather), "mask spline feather diff points"); - - a = spline->tot_point - 1; - if (spline->flag & MASK_SPLINE_CYCLIC) - a++; - - prev = points_array; - point = prev + 1; - - while (a--) { - /* BezTriple *prevbezt; */ /* UNUSED */ - /* BezTriple *bezt; */ /* UNUSED */ - int j; - - if (a == 0 && (spline->flag & MASK_SPLINE_CYCLIC)) - point = points_array; - - - /* prevbezt = &prev->bezt; */ - /* bezt = &point->bezt; */ - - for (j = 0; j < resol; j++, fp++) { - float u = (float) j / resol, weight; - float co[2], n[2]; - - /* TODO - these calls all calculate similar things - * could be unified for some speed */ - BKE_mask_point_segment_co(spline, prev, u, co); - BKE_mask_point_normal(spline, prev, u, n); - weight = BKE_mask_point_weight(spline, prev, u); - - madd_v2_v2v2fl(*fp, co, n, weight); - } - - if (a == 0 && (spline->flag & MASK_SPLINE_CYCLIC) == 0) { - float u = 1.0f, weight; - float co[2], n[2]; - - BKE_mask_point_segment_co(spline, prev, u, co); - BKE_mask_point_normal(spline, prev, u, n); - weight = BKE_mask_point_weight(spline, prev, u); - - madd_v2_v2v2fl(*fp, co, n, weight); - } - - prev = point; - point++; - } - - *tot_feather_point = tot; - - if ((spline->flag & MASK_SPLINE_NOINTERSECT) && do_feather_isect) { - BKE_mask_spline_feather_collapse_inner_loops(spline, feather, tot); - } - - return feather; -} - -float (*BKE_mask_spline_feather_differentiated_points_with_resolution(MaskSpline *spline, int width, int height, - int *tot_feather_point, const int do_feather_isect))[2] -{ - unsigned int resol = BKE_mask_spline_feather_resolution(spline, width, height); - - return BKE_mask_spline_feather_differentiated_points_with_resolution_ex(spline, tot_feather_point, resol, do_feather_isect); -} - -float (*BKE_mask_spline_feather_differentiated_points(MaskSpline *spline, int *tot_feather_point))[2] -{ - return BKE_mask_spline_feather_differentiated_points_with_resolution(spline, 0, 0, tot_feather_point, TRUE); -} - -float (*BKE_mask_spline_feather_points(MaskSpline *spline, int *tot_feather_point))[2] -{ - MaskSplinePoint *points_array = BKE_mask_spline_point_array(spline); - - int i, tot = 0; - float (*feather)[2], (*fp)[2]; - - /* count */ - for (i = 0; i < spline->tot_point; i++) { - MaskSplinePoint *point = &points_array[i]; - - tot += point->tot_uw + 1; - } - - /* create data */ - feather = fp = MEM_mallocN(tot * sizeof(*feather), "mask spline feather points"); - - for (i = 0; i < spline->tot_point; i++) { - MaskSplinePoint *point = &points_array[i]; - BezTriple *bezt = &point->bezt; - float weight, n[2]; - int j; - - BKE_mask_point_normal(spline, point, 0.0f, n); - weight = BKE_mask_point_weight(spline, point, 0.0f); - - madd_v2_v2v2fl(*fp, bezt->vec[1], n, weight); - fp++; - - for (j = 0; j < point->tot_uw; j++) { - float u = point->uw[j].u; - float co[2]; - - BKE_mask_point_segment_co(spline, point, u, co); - BKE_mask_point_normal(spline, point, u, n); - weight = BKE_mask_point_weight(spline, point, u); - - madd_v2_v2v2fl(*fp, co, n, weight); - fp++; - } - } - - *tot_feather_point = tot; - - return feather; -} - void BKE_mask_point_direction_switch(MaskSplinePoint *point) { const int tot_uw = point->tot_uw; @@ -1111,7 +525,7 @@ float *BKE_mask_point_segment_diff_with_resolution(MaskSpline *spline, MaskSplin int j, resol = BKE_mask_spline_resolution(spline, width, height); bezt = &point->bezt; - bezt_next = mask_spline_point_next_bezt(spline, points_array, point); + bezt_next = BKE_mask_spline_point_next_bezt(spline, points_array, point); if (!bezt_next) return NULL; @@ -1143,7 +557,7 @@ void BKE_mask_point_segment_co(MaskSpline *spline, MaskSplinePoint *point, float BezTriple *bezt = &point->bezt, *bezt_next; float q0[2], q1[2], q2[2], r0[2], r1[2]; - bezt_next = mask_spline_point_next_bezt(spline, points_array, point); + bezt_next = BKE_mask_spline_point_next_bezt(spline, points_array, point); if (!bezt_next) { copy_v2_v2(co, bezt->vec[1]); @@ -1167,7 +581,7 @@ void BKE_mask_point_normal(MaskSpline *spline, MaskSplinePoint *point, float u, BezTriple *bezt = &point->bezt, *bezt_next; float q0[2], q1[2], q2[2], r0[2], r1[2], vec[2]; - bezt_next = mask_spline_point_next_bezt(spline, points_array, point); + bezt_next = BKE_mask_spline_point_next_bezt(spline, points_array, point); if (!bezt_next) { BKE_mask_point_handle(point, vec); @@ -1202,7 +616,7 @@ float BKE_mask_point_weight_scalar(MaskSpline *spline, MaskSplinePoint *point, c MaskSplinePoint *points_array = BKE_mask_spline_point_array_from_point(spline, point); BezTriple *bezt = &point->bezt, *bezt_next; - bezt_next = mask_spline_point_next_bezt(spline, points_array, point); + bezt_next = BKE_mask_spline_point_next_bezt(spline, points_array, point); if (!bezt_next) { return bezt->weight; @@ -1223,7 +637,7 @@ float BKE_mask_point_weight(MaskSpline *spline, MaskSplinePoint *point, const fl MaskSplinePoint *points_array = BKE_mask_spline_point_array_from_point(spline, point); BezTriple *bezt = &point->bezt, *bezt_next; - bezt_next = mask_spline_point_next_bezt(spline, points_array, point); + bezt_next = BKE_mask_spline_point_next_bezt(spline, points_array, point); if (!bezt_next) { return bezt->weight; diff --git a/source/blender/blenkernel/intern/mask_evaluate.c b/source/blender/blenkernel/intern/mask_evaluate.c new file mode 100644 index 00000000000..4480fbf53b5 --- /dev/null +++ b/source/blender/blenkernel/intern/mask_evaluate.c @@ -0,0 +1,647 @@ +/* + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * The Original Code is Copyright (C) 2012 Blender Foundation. + * All rights reserved. + * + * Contributor(s): Blender Foundation, + * Sergey Sharybin, + * Campbell Barton + * + * ***** END GPL LICENSE BLOCK ***** + */ + +/** \file blender/blenkernel/intern/mask_evaluate.c + * \ingroup bke + * + * Functions for evaluating the mask beziers into points for the outline and feather. + */ + +#include +#include + +#include "MEM_guardedalloc.h" + +#include "BLI_utildefines.h" +#include "BLI_path_util.h" +#include "BLI_string.h" +#include "BLI_listbase.h" +#include "BLI_math.h" + +#include "DNA_mask_types.h" +#include "DNA_node_types.h" +#include "DNA_scene_types.h" +#include "DNA_object_types.h" +#include "DNA_screen_types.h" +#include "DNA_space_types.h" +#include "DNA_movieclip_types.h" +#include "DNA_tracking_types.h" +#include "DNA_sequence_types.h" + +#include "BKE_curve.h" +#include "BKE_global.h" +#include "BKE_library.h" +#include "BKE_main.h" +#include "BKE_mask.h" +#include "BKE_node.h" +#include "BKE_sequencer.h" +#include "BKE_tracking.h" +#include "BKE_movieclip.h" +#include "BKE_utildefines.h" + + +unsigned int BKE_mask_spline_resolution(MaskSpline *spline, int width, int height) +{ + float max_segment = 0.01f; + unsigned int i, resol = 1; + + if (width != 0 && height != 0) { + if (width >= height) + max_segment = 1.0f / (float) width; + else + max_segment = 1.0f / (float) height; + } + + for (i = 0; i < spline->tot_point; i++) { + MaskSplinePoint *point = &spline->points[i]; + BezTriple *bezt, *bezt_next; + float a, b, c, len; + unsigned int cur_resol; + + bezt = &point->bezt; + bezt_next = BKE_mask_spline_point_next_bezt(spline, spline->points, point); + + if (bezt_next == NULL) { + break; + } + + a = len_v3v3(bezt->vec[1], bezt->vec[2]); + b = len_v3v3(bezt->vec[2], bezt_next->vec[0]); + c = len_v3v3(bezt_next->vec[0], bezt_next->vec[1]); + + len = a + b + c; + cur_resol = len / max_segment; + + resol = MAX2(resol, cur_resol); + + if (resol >= MASK_RESOL_MAX) { + break; + } + } + + return CLAMPIS(resol, 1, MASK_RESOL_MAX); +} + +unsigned int BKE_mask_spline_feather_resolution(MaskSpline *spline, int width, int height) +{ + const float max_segment = 0.005; + unsigned int resol = BKE_mask_spline_resolution(spline, width, height); + float max_jump = 0.0f; + int i; + + /* avoid checking the featrher if we already hit the maximum value */ + if (resol >= MASK_RESOL_MAX) { + return MASK_RESOL_MAX; + } + + for (i = 0; i < spline->tot_point; i++) { + MaskSplinePoint *point = &spline->points[i]; + float prev_u, prev_w; + int j; + + prev_u = 0.0f; + prev_w = point->bezt.weight; + + for (j = 0; j < point->tot_uw; j++) { + const float w_diff = (point->uw[j].w - prev_w); + const float u_diff = (point->uw[j].u - prev_u); + + /* avoid divide by zero and very high values, + * though these get clamped eventually */ + if (u_diff > FLT_EPSILON) { + float jump = fabsf(w_diff / u_diff); + + max_jump = MAX2(max_jump, jump); + } + + prev_u = point->uw[j].u; + prev_w = point->uw[j].w; + } + } + + resol += max_jump / max_segment; + + return CLAMPIS(resol, 1, MASK_RESOL_MAX); +} + +int BKE_mask_spline_differentiate_calc_total(const MaskSpline *spline, const unsigned int resol) +{ + if (spline->flag & MASK_SPLINE_CYCLIC) { + return spline->tot_point * resol; + } + else { + return ((spline->tot_point - 1) * resol) + 1; + } +} + +float (*BKE_mask_spline_differentiate_with_resolution_ex(MaskSpline *spline, + int *tot_diff_point, + const unsigned int resol + ))[2] +{ + MaskSplinePoint *points_array = BKE_mask_spline_point_array(spline); + + MaskSplinePoint *point, *prev; + float (*diff_points)[2], (*fp)[2]; + const int tot = BKE_mask_spline_differentiate_calc_total(spline, resol); + int a; + + if (spline->tot_point <= 1) { + /* nothing to differentiate */ + *tot_diff_point = 0; + return NULL; + } + + /* len+1 because of 'forward_diff_bezier' function */ + *tot_diff_point = tot; + diff_points = fp = MEM_mallocN((tot + 1) * sizeof(*diff_points), "mask spline vets"); + + a = spline->tot_point - 1; + if (spline->flag & MASK_SPLINE_CYCLIC) + a++; + + prev = points_array; + point = prev + 1; + + while (a--) { + BezTriple *prevbezt; + BezTriple *bezt; + int j; + + if (a == 0 && (spline->flag & MASK_SPLINE_CYCLIC)) + point = points_array; + + prevbezt = &prev->bezt; + bezt = &point->bezt; + + for (j = 0; j < 2; j++) { + BKE_curve_forward_diff_bezier(prevbezt->vec[1][j], prevbezt->vec[2][j], + bezt->vec[0][j], bezt->vec[1][j], + &(*fp)[j], resol, 2 * sizeof(float)); + } + + fp += resol; + + if (a == 0 && (spline->flag & MASK_SPLINE_CYCLIC) == 0) { + copy_v2_v2(*fp, bezt->vec[1]); + } + + prev = point; + point++; + } + + return diff_points; +} + +float (*BKE_mask_spline_differentiate_with_resolution(MaskSpline *spline, int width, int height, + int *tot_diff_point + ))[2] +{ + int unsigned resol = BKE_mask_spline_resolution(spline, width, height); + + return BKE_mask_spline_differentiate_with_resolution_ex(spline, tot_diff_point, resol); +} + +float (*BKE_mask_spline_differentiate(MaskSpline *spline, int *tot_diff_point))[2] +{ + return BKE_mask_spline_differentiate_with_resolution(spline, 0, 0, tot_diff_point); +} + +/* ** feather points self-intersection collapse routine ** */ + +typedef struct FeatherEdgesBucket { + int tot_segment; + int (*segments)[2]; + int alloc_segment; +} FeatherEdgesBucket; + +static void feather_bucket_add_edge(FeatherEdgesBucket *bucket, int start, int end) +{ + const int alloc_delta = 256; + + if (bucket->tot_segment >= bucket->alloc_segment) { + if (!bucket->segments) { + bucket->segments = MEM_callocN(alloc_delta * sizeof(*bucket->segments), "feather bucket segments"); + } + else { + bucket->segments = MEM_reallocN(bucket->segments, + (alloc_delta + bucket->tot_segment) * sizeof(*bucket->segments)); + } + + bucket->alloc_segment += alloc_delta; + } + + bucket->segments[bucket->tot_segment][0] = start; + bucket->segments[bucket->tot_segment][1] = end; + + bucket->tot_segment++; +} + +static void feather_bucket_check_intersect(float (*feather_points)[2], int tot_feather_point, FeatherEdgesBucket *bucket, + int cur_a, int cur_b) +{ + int i; + + float *v1 = (float *) feather_points[cur_a]; + float *v2 = (float *) feather_points[cur_b]; + + for (i = 0; i < bucket->tot_segment; i++) { + int check_a = bucket->segments[i][0]; + int check_b = bucket->segments[i][1]; + + float *v3 = (float *) feather_points[check_a]; + float *v4 = (float *) feather_points[check_b]; + + if (check_a >= cur_a - 1 || cur_b == check_a) + continue; + + if (isect_seg_seg_v2(v1, v2, v3, v4)) { + int k; + float p[2]; + float min_a[2], max_a[2]; + float min_b[2], max_b[2]; + + isect_seg_seg_v2_point(v1, v2, v3, v4, p); + + INIT_MINMAX2(min_a, max_a); + INIT_MINMAX2(min_b, max_b); + + /* collapse loop with smaller AABB */ + for (k = 0; k < tot_feather_point; k++) { + if (k >= check_b && k <= cur_a) { + DO_MINMAX2(feather_points[k], min_a, max_a); + } + else { + DO_MINMAX2(feather_points[k], min_b, max_b); + } + } + + if (max_a[0] - min_a[0] < max_b[0] - min_b[0] || + max_a[1] - min_a[1] < max_b[1] - min_b[1]) + { + for (k = check_b; k <= cur_a; k++) { + copy_v2_v2(feather_points[k], p); + } + } + else { + for (k = 0; k <= check_a; k++) { + copy_v2_v2(feather_points[k], p); + } + + if (cur_b != 0) { + for (k = cur_b; k < tot_feather_point; k++) { + copy_v2_v2(feather_points[k], p); + } + } + } + } + } +} + +static int feather_bucket_index_from_coord(float co[2], const float min[2], const float bucket_scale[2], + const int buckets_per_side) +{ + int x = (int) ((co[0] - min[0]) * bucket_scale[0]); + int y = (int) ((co[1] - min[1]) * bucket_scale[1]); + + if (x == buckets_per_side) + x--; + + if (y == buckets_per_side) + y--; + + return y * buckets_per_side + x; +} + +static void feather_bucket_get_diagonal(FeatherEdgesBucket *buckets, int start_bucket_index, int end_bucket_index, + int buckets_per_side, FeatherEdgesBucket **diagonal_bucket_a_r, + FeatherEdgesBucket **diagonal_bucket_b_r) +{ + int start_bucket_x = start_bucket_index % buckets_per_side; + int start_bucket_y = start_bucket_index / buckets_per_side; + + int end_bucket_x = end_bucket_index % buckets_per_side; + int end_bucket_y = end_bucket_index / buckets_per_side; + + int diagonal_bucket_a_index = start_bucket_y * buckets_per_side + end_bucket_x; + int diagonal_bucket_b_index = end_bucket_y * buckets_per_side + start_bucket_x; + + *diagonal_bucket_a_r = &buckets[diagonal_bucket_a_index]; + *diagonal_bucket_b_r = &buckets[diagonal_bucket_b_index]; +} + +void BKE_mask_spline_feather_collapse_inner_loops(MaskSpline *spline, float (*feather_points)[2], const int tot_feather_point) +{ +#define BUCKET_INDEX(co) \ + feather_bucket_index_from_coord(co, min, bucket_scale, buckets_per_side) + + int buckets_per_side, tot_bucket; + float bucket_size, bucket_scale[2]; + + FeatherEdgesBucket *buckets; + + int i; + float min[2], max[2]; + float max_delta_x = -1.0f, max_delta_y = -1.0f, max_delta; + + if (tot_feather_point < 4) { + /* self-intersection works only for quads at least, + * in other cases polygon can't be self-intersecting anyway + */ + + return; + } + + /* find min/max corners of mask to build buckets in that space */ + INIT_MINMAX2(min, max); + + for (i = 0; i < tot_feather_point; i++) { + int next = i + 1; + float delta; + + DO_MINMAX2(feather_points[i], min, max); + + if (next == tot_feather_point) { + if (spline->flag & MASK_SPLINE_CYCLIC) + next = 0; + else + break; + } + + delta = fabsf(feather_points[i][0] - feather_points[next][0]); + if (delta > max_delta_x) + max_delta_x = delta; + + delta = fabsf(feather_points[i][1] - feather_points[next][1]); + if (delta > max_delta_y) + max_delta_y = delta; + } + + /* prevent divisionsby zero by ensuring bounding box is not collapsed */ + if (max[0] - min[0] < FLT_EPSILON) { + max[0] += 0.01f; + min[0] -= 0.01f; + } + + if (max[1] - min[1] < FLT_EPSILON) { + max[1] += 0.01f; + min[1] -= 0.01f; + } + + /* use dynamically calculated buckets per side, so we likely wouldn't + * run into a situation when segment doesn't fit two buckets which is + * pain collecting candidates for intersection + */ + + max_delta_x /= max[0] - min[0]; + max_delta_y /= max[1] - min[1]; + + max_delta = MAX2(max_delta_x, max_delta_y); + + buckets_per_side = MIN2(512, 0.9f / max_delta); + + if (buckets_per_side == 0) { + /* happens when some segment fills the whole bounding box across some of dimension */ + + buckets_per_side = 1; + } + + tot_bucket = buckets_per_side * buckets_per_side; + bucket_size = 1.0f / buckets_per_side; + + /* pre-compute multipliers, to save mathematical operations in loops */ + bucket_scale[0] = 1.0f / ((max[0] - min[0]) * bucket_size); + bucket_scale[1] = 1.0f / ((max[1] - min[1]) * bucket_size); + + /* fill in buckets' edges */ + buckets = MEM_callocN(sizeof(FeatherEdgesBucket) * tot_bucket, "feather buckets"); + + for (i = 0; i < tot_feather_point; i++) { + int start = i, end = i + 1; + int start_bucket_index, end_bucket_index; + + if (end == tot_feather_point) { + if (spline->flag & MASK_SPLINE_CYCLIC) + end = 0; + else + break; + } + + start_bucket_index = BUCKET_INDEX(feather_points[start]); + end_bucket_index = BUCKET_INDEX(feather_points[end]); + + feather_bucket_add_edge(&buckets[start_bucket_index], start, end); + + if (start_bucket_index != end_bucket_index) { + FeatherEdgesBucket *end_bucket = &buckets[end_bucket_index]; + FeatherEdgesBucket *diagonal_bucket_a, *diagonal_bucket_b; + + feather_bucket_get_diagonal(buckets, start_bucket_index, end_bucket_index, buckets_per_side, + &diagonal_bucket_a, &diagonal_bucket_b); + + feather_bucket_add_edge(end_bucket, start, end); + feather_bucket_add_edge(diagonal_bucket_a, start, end); + feather_bucket_add_edge(diagonal_bucket_a, start, end); + } + } + + /* check all edges for intersection with edges from their buckets */ + for (i = 0; i < tot_feather_point; i++) { + int cur_a = i, cur_b = i + 1; + int start_bucket_index, end_bucket_index; + + FeatherEdgesBucket *start_bucket; + + if (cur_b == tot_feather_point) + cur_b = 0; + + start_bucket_index = BUCKET_INDEX(feather_points[cur_a]); + end_bucket_index = BUCKET_INDEX(feather_points[cur_b]); + + start_bucket = &buckets[start_bucket_index]; + + feather_bucket_check_intersect(feather_points, tot_feather_point, start_bucket, cur_a, cur_b); + + if (start_bucket_index != end_bucket_index) { + FeatherEdgesBucket *end_bucket = &buckets[end_bucket_index]; + FeatherEdgesBucket *diagonal_bucket_a, *diagonal_bucket_b; + + feather_bucket_get_diagonal(buckets, start_bucket_index, end_bucket_index, buckets_per_side, + &diagonal_bucket_a, &diagonal_bucket_b); + + feather_bucket_check_intersect(feather_points, tot_feather_point, end_bucket, cur_a, cur_b); + feather_bucket_check_intersect(feather_points, tot_feather_point, diagonal_bucket_a, cur_a, cur_b); + feather_bucket_check_intersect(feather_points, tot_feather_point, diagonal_bucket_b, cur_a, cur_b); + } + } + + /* free buckets */ + for (i = 0; i < tot_bucket; i++) { + if (buckets[i].segments) + MEM_freeN(buckets[i].segments); + } + + MEM_freeN(buckets); + +#undef BUCKET_INDEX +} + +/** + * values align with #BKE_mask_spline_differentiate_with_resolution_ex + * when \a resol arguments match. + */ +float (*BKE_mask_spline_feather_differentiated_points_with_resolution_ex(MaskSpline *spline, + int *tot_feather_point, + const unsigned int resol, + const int do_feather_isect + ))[2] +{ + MaskSplinePoint *points_array = BKE_mask_spline_point_array(spline); + MaskSplinePoint *point, *prev; + float (*feather)[2], (*fp)[2]; + + const int tot = BKE_mask_spline_differentiate_calc_total(spline, resol); + int a; + + /* tot+1 because of 'forward_diff_bezier' function */ + feather = fp = MEM_mallocN((tot + 1) * sizeof(*feather), "mask spline feather diff points"); + + a = spline->tot_point - 1; + if (spline->flag & MASK_SPLINE_CYCLIC) + a++; + + prev = points_array; + point = prev + 1; + + while (a--) { + /* BezTriple *prevbezt; */ /* UNUSED */ + /* BezTriple *bezt; */ /* UNUSED */ + int j; + + if (a == 0 && (spline->flag & MASK_SPLINE_CYCLIC)) + point = points_array; + + + /* prevbezt = &prev->bezt; */ + /* bezt = &point->bezt; */ + + for (j = 0; j < resol; j++, fp++) { + float u = (float) j / resol, weight; + float co[2], n[2]; + + /* TODO - these calls all calculate similar things + * could be unified for some speed */ + BKE_mask_point_segment_co(spline, prev, u, co); + BKE_mask_point_normal(spline, prev, u, n); + weight = BKE_mask_point_weight(spline, prev, u); + + madd_v2_v2v2fl(*fp, co, n, weight); + } + + if (a == 0 && (spline->flag & MASK_SPLINE_CYCLIC) == 0) { + float u = 1.0f, weight; + float co[2], n[2]; + + BKE_mask_point_segment_co(spline, prev, u, co); + BKE_mask_point_normal(spline, prev, u, n); + weight = BKE_mask_point_weight(spline, prev, u); + + madd_v2_v2v2fl(*fp, co, n, weight); + } + + prev = point; + point++; + } + + *tot_feather_point = tot; + + if ((spline->flag & MASK_SPLINE_NOINTERSECT) && do_feather_isect) { + BKE_mask_spline_feather_collapse_inner_loops(spline, feather, tot); + } + + return feather; +} + +float (*BKE_mask_spline_feather_differentiated_points_with_resolution(MaskSpline *spline, int width, int height, + int *tot_feather_point, const int do_feather_isect))[2] +{ + unsigned int resol = BKE_mask_spline_feather_resolution(spline, width, height); + + return BKE_mask_spline_feather_differentiated_points_with_resolution_ex(spline, tot_feather_point, resol, do_feather_isect); +} + +float (*BKE_mask_spline_feather_differentiated_points(MaskSpline *spline, int *tot_feather_point))[2] +{ + return BKE_mask_spline_feather_differentiated_points_with_resolution(spline, 0, 0, tot_feather_point, TRUE); +} + +float (*BKE_mask_spline_feather_points(MaskSpline *spline, int *tot_feather_point))[2] +{ + MaskSplinePoint *points_array = BKE_mask_spline_point_array(spline); + + int i, tot = 0; + float (*feather)[2], (*fp)[2]; + + /* count */ + for (i = 0; i < spline->tot_point; i++) { + MaskSplinePoint *point = &points_array[i]; + + tot += point->tot_uw + 1; + } + + /* create data */ + feather = fp = MEM_mallocN(tot * sizeof(*feather), "mask spline feather points"); + + for (i = 0; i < spline->tot_point; i++) { + MaskSplinePoint *point = &points_array[i]; + BezTriple *bezt = &point->bezt; + float weight, n[2]; + int j; + + BKE_mask_point_normal(spline, point, 0.0f, n); + weight = BKE_mask_point_weight(spline, point, 0.0f); + + madd_v2_v2v2fl(*fp, bezt->vec[1], n, weight); + fp++; + + for (j = 0; j < point->tot_uw; j++) { + float u = point->uw[j].u; + float co[2]; + + BKE_mask_point_segment_co(spline, point, u, co); + BKE_mask_point_normal(spline, point, u, n); + weight = BKE_mask_point_weight(spline, point, u); + + madd_v2_v2v2fl(*fp, co, n, weight); + fp++; + } + } + + *tot_feather_point = tot; + + return feather; +} From 7b84a75a2232c2fd810b584539110046b6a4f518 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Sun, 26 Aug 2012 16:41:03 +0000 Subject: [PATCH 142/163] Fix zooming in/out preview in sequencer It was a regression since disabling Y-axis zooming in sequencer. Now check region type and allow all kind of zooming for preview region. --- source/blender/editors/interface/view2d_ops.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/source/blender/editors/interface/view2d_ops.c b/source/blender/editors/interface/view2d_ops.c index cc2ca5c5475..5b19bb2d3c9 100644 --- a/source/blender/editors/interface/view2d_ops.c +++ b/source/blender/editors/interface/view2d_ops.c @@ -682,7 +682,10 @@ static int view_zoomin_exec(bContext *C, wmOperator *op) /* default not to zoom the sequencer vertically */ if (sa && sa->spacetype == SPACE_SEQ) { - do_zoom_y = FALSE; + ARegion *ar = CTX_wm_region(C); + + if (ar && ar->regiontype != RGN_TYPE_PREVIEW) + do_zoom_y = FALSE; } /* set RNA-Props - zooming in by uniform factor */ @@ -727,7 +730,7 @@ static void VIEW2D_OT_zoom_in(wmOperatorType *ot) /* api callbacks */ ot->invoke = view_zoomin_invoke; -// ot->exec = view_zoomin_exec; // XXX, needs view_zoomdrag_init called first. + ot->exec = view_zoomin_exec; // XXX, needs view_zoomdrag_init called first. ot->poll = view_zoom_poll; /* rna - must keep these in sync with the other operators */ @@ -748,7 +751,10 @@ static int view_zoomout_exec(bContext *C, wmOperator *op) /* default not to zoom the sequencer vertically */ if (sa && sa->spacetype == SPACE_SEQ) { - do_zoom_y = FALSE; + ARegion *ar = CTX_wm_region(C); + + if (ar && ar->regiontype != RGN_TYPE_PREVIEW) + do_zoom_y = FALSE; } /* set RNA-Props - zooming in by uniform factor */ From 52310bd4a799e90dda3e589b7e863c217df0fd4e Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 26 Aug 2012 18:09:01 +0000 Subject: [PATCH 143/163] code cleanup: remove dead assignments, gave mask vars clearer names & moved some mask evaluation funcs into mask_evaluate.c --- source/blender/blenkernel/BKE_mask.h | 28 ++-- source/blender/blenkernel/intern/mask.c | 67 --------- .../blender/blenkernel/intern/mask_evaluate.c | 139 +++++++++++++----- .../editors/transform/transform_conversions.c | 4 +- 4 files changed, 118 insertions(+), 120 deletions(-) diff --git a/source/blender/blenkernel/BKE_mask.h b/source/blender/blenkernel/BKE_mask.h index a1c36d53368..9cf5a7f31a5 100644 --- a/source/blender/blenkernel/BKE_mask.h +++ b/source/blender/blenkernel/BKE_mask.h @@ -84,19 +84,6 @@ void BKE_mask_point_handle(struct MaskSplinePoint *point, float handle[2]); void BKE_mask_point_set_handle(struct MaskSplinePoint *point, float loc[2], int keep_direction, float orig_handle[2], float orig_vec[3][3]); -float *BKE_mask_point_segment_diff(struct MaskSpline *spline, struct MaskSplinePoint *point, - unsigned int *tot_diff_point); -float *BKE_mask_point_segment_feather_diff(struct MaskSpline *spline, struct MaskSplinePoint *point, - unsigned int *tot_feather_point); - -float *BKE_mask_point_segment_diff_with_resolution(struct MaskSpline *spline, struct MaskSplinePoint *point, - int width, int height, - unsigned int *tot_diff_point); - -float *BKE_mask_point_segment_feather_diff_with_resolution(struct MaskSpline *spline, struct MaskSplinePoint *point, - int width, int height, - unsigned int *tot_feather_point); - void BKE_mask_point_segment_co(struct MaskSpline *spline, struct MaskSplinePoint *point, float u, float co[2]); void BKE_mask_point_normal(struct MaskSpline *spline, struct MaskSplinePoint *point, float u, float n[2]); @@ -189,6 +176,7 @@ int BKE_mask_get_duration(struct Mask *mask); #define MASK_RESOL_MAX 128 + /* mask_evaluate.c */ unsigned int BKE_mask_spline_resolution(struct MaskSpline *spline, int width, int height); unsigned int BKE_mask_spline_feather_resolution(struct MaskSpline *spline, int width, int height); @@ -205,9 +193,21 @@ float (*BKE_mask_spline_feather_differentiated_points_with_resolution_ex(struct const unsigned int resol, const int do_feather_isect))[2]; float (*BKE_mask_spline_feather_differentiated_points_with_resolution(struct MaskSpline *spline, int width, int height, int *tot_feather_point, const int do_feather_isect))[2]; - +/* *** mask point functions which involve evaluation *** */ float (*BKE_mask_spline_feather_points(struct MaskSpline *spline, int *tot_feather_point))[2]; +float *BKE_mask_point_segment_diff(struct MaskSpline *spline, struct MaskSplinePoint *point, + unsigned int *tot_diff_point); +float *BKE_mask_point_segment_feather_diff(struct MaskSpline *spline, struct MaskSplinePoint *point, + unsigned int *tot_feather_point); + +float *BKE_mask_point_segment_diff_with_resolution(struct MaskSpline *spline, struct MaskSplinePoint *point, + int width, int height, + unsigned int *tot_diff_point); + +float *BKE_mask_point_segment_feather_diff_with_resolution(struct MaskSpline *spline, struct MaskSplinePoint *point, + int width, int height, + unsigned int *tot_feather_point); /* mask_rasterize.c */ struct MaskRasterHandle; diff --git a/source/blender/blenkernel/intern/mask.c b/source/blender/blenkernel/intern/mask.c index d7f6b6f6b25..5182c52605a 100644 --- a/source/blender/blenkernel/intern/mask.c +++ b/source/blender/blenkernel/intern/mask.c @@ -483,73 +483,6 @@ void BKE_mask_point_set_handle(MaskSplinePoint *point, float loc[2], int keep_di } } -float *BKE_mask_point_segment_feather_diff_with_resolution(MaskSpline *spline, MaskSplinePoint *point, - int width, int height, - unsigned int *tot_feather_point) -{ - float *feather, *fp; - unsigned int resol = BKE_mask_spline_feather_resolution(spline, width, height); - unsigned int i; - - feather = fp = MEM_callocN(2 * resol * sizeof(float), "mask point spline feather diff points"); - - for (i = 0; i < resol; i++, fp += 2) { - float u = (float)(i % resol) / resol, weight; - float co[2], n[2]; - - BKE_mask_point_segment_co(spline, point, u, co); - BKE_mask_point_normal(spline, point, u, n); - weight = BKE_mask_point_weight(spline, point, u); - - fp[0] = co[0] + n[0] * weight; - fp[1] = co[1] + n[1] * weight; - } - - *tot_feather_point = resol; - - return feather; -} - -float *BKE_mask_point_segment_feather_diff(MaskSpline *spline, MaskSplinePoint *point, unsigned int *tot_feather_point) -{ - return BKE_mask_point_segment_feather_diff_with_resolution(spline, point, 0, 0, tot_feather_point); -} - -float *BKE_mask_point_segment_diff_with_resolution(MaskSpline *spline, MaskSplinePoint *point, - int width, int height, unsigned int *tot_diff_point) -{ - MaskSplinePoint *points_array = BKE_mask_spline_point_array_from_point(spline, point); - - BezTriple *bezt, *bezt_next; - float *diff_points, *fp; - int j, resol = BKE_mask_spline_resolution(spline, width, height); - - bezt = &point->bezt; - bezt_next = BKE_mask_spline_point_next_bezt(spline, points_array, point); - - if (!bezt_next) - return NULL; - - /* resol+1 because of 'forward_diff_bezier' function */ - *tot_diff_point = resol + 1; - diff_points = fp = MEM_callocN((resol + 1) * 2 * sizeof(float), "mask segment vets"); - - for (j = 0; j < 2; j++) { - BKE_curve_forward_diff_bezier(bezt->vec[1][j], bezt->vec[2][j], - bezt_next->vec[0][j], bezt_next->vec[1][j], - fp + j, resol, 2 * sizeof(float)); - } - - copy_v2_v2(fp + 2 * resol, bezt_next->vec[1]); - - return diff_points; -} - -float *BKE_mask_point_segment_diff(MaskSpline *spline, MaskSplinePoint *point, unsigned int *tot_diff_point) -{ - return BKE_mask_point_segment_diff_with_resolution(spline, point, 0, 0, tot_diff_point); -} - void BKE_mask_point_segment_co(MaskSpline *spline, MaskSplinePoint *point, float u, float co[2]) { MaskSplinePoint *points_array = BKE_mask_spline_point_array_from_point(spline, point); diff --git a/source/blender/blenkernel/intern/mask_evaluate.c b/source/blender/blenkernel/intern/mask_evaluate.c index 4480fbf53b5..9d9f1665a7b 100644 --- a/source/blender/blenkernel/intern/mask_evaluate.c +++ b/source/blender/blenkernel/intern/mask_evaluate.c @@ -70,27 +70,24 @@ unsigned int BKE_mask_spline_resolution(MaskSpline *spline, int width, int heigh unsigned int i, resol = 1; if (width != 0 && height != 0) { - if (width >= height) - max_segment = 1.0f / (float) width; - else - max_segment = 1.0f / (float) height; + max_segment = 1.0f / (float)maxi(width, height); } for (i = 0; i < spline->tot_point; i++) { MaskSplinePoint *point = &spline->points[i]; - BezTriple *bezt, *bezt_next; + BezTriple *bezt_curr, *bezt_next; float a, b, c, len; unsigned int cur_resol; - bezt = &point->bezt; + bezt_curr = &point->bezt; bezt_next = BKE_mask_spline_point_next_bezt(spline, spline->points, point); if (bezt_next == NULL) { break; } - a = len_v3v3(bezt->vec[1], bezt->vec[2]); - b = len_v3v3(bezt->vec[2], bezt_next->vec[0]); + a = len_v3v3(bezt_curr->vec[1], bezt_curr->vec[2]); + b = len_v3v3(bezt_curr->vec[2], bezt_next->vec[0]); c = len_v3v3(bezt_next->vec[0], bezt_next->vec[1]); len = a + b + c; @@ -165,7 +162,7 @@ float (*BKE_mask_spline_differentiate_with_resolution_ex(MaskSpline *spline, { MaskSplinePoint *points_array = BKE_mask_spline_point_array(spline); - MaskSplinePoint *point, *prev; + MaskSplinePoint *point_curr, *point_prev; float (*diff_points)[2], (*fp)[2]; const int tot = BKE_mask_spline_differentiate_calc_total(spline, resol); int a; @@ -184,34 +181,34 @@ float (*BKE_mask_spline_differentiate_with_resolution_ex(MaskSpline *spline, if (spline->flag & MASK_SPLINE_CYCLIC) a++; - prev = points_array; - point = prev + 1; + point_prev = points_array; + point_curr = point_prev + 1; while (a--) { - BezTriple *prevbezt; - BezTriple *bezt; + BezTriple *bezt_prev; + BezTriple *bezt_curr; int j; if (a == 0 && (spline->flag & MASK_SPLINE_CYCLIC)) - point = points_array; + point_curr = points_array; - prevbezt = &prev->bezt; - bezt = &point->bezt; + bezt_prev = &point_prev->bezt; + bezt_curr = &point_curr->bezt; for (j = 0; j < 2; j++) { - BKE_curve_forward_diff_bezier(prevbezt->vec[1][j], prevbezt->vec[2][j], - bezt->vec[0][j], bezt->vec[1][j], + BKE_curve_forward_diff_bezier(bezt_prev->vec[1][j], bezt_prev->vec[2][j], + bezt_curr->vec[0][j], bezt_curr->vec[1][j], &(*fp)[j], resol, 2 * sizeof(float)); } fp += resol; if (a == 0 && (spline->flag & MASK_SPLINE_CYCLIC) == 0) { - copy_v2_v2(*fp, bezt->vec[1]); + copy_v2_v2(*fp, bezt_curr->vec[1]); } - prev = point; - point++; + point_prev = point_curr; + point_curr++; } return diff_points; @@ -521,7 +518,7 @@ float (*BKE_mask_spline_feather_differentiated_points_with_resolution_ex(MaskSpl ))[2] { MaskSplinePoint *points_array = BKE_mask_spline_point_array(spline); - MaskSplinePoint *point, *prev; + MaskSplinePoint *point_curr, *point_prev; float (*feather)[2], (*fp)[2]; const int tot = BKE_mask_spline_differentiate_calc_total(spline, resol); @@ -534,20 +531,20 @@ float (*BKE_mask_spline_feather_differentiated_points_with_resolution_ex(MaskSpl if (spline->flag & MASK_SPLINE_CYCLIC) a++; - prev = points_array; - point = prev + 1; + point_prev = points_array; + point_curr = point_prev + 1; while (a--) { - /* BezTriple *prevbezt; */ /* UNUSED */ - /* BezTriple *bezt; */ /* UNUSED */ + /* BezTriple *bezt_prev; */ /* UNUSED */ + /* BezTriple *bezt_curr; */ /* UNUSED */ int j; if (a == 0 && (spline->flag & MASK_SPLINE_CYCLIC)) - point = points_array; + point_curr = points_array; - /* prevbezt = &prev->bezt; */ - /* bezt = &point->bezt; */ + /* bezt_prev = &point_prev->bezt; */ + /* bezt_curr = &point_curr->bezt; */ for (j = 0; j < resol; j++, fp++) { float u = (float) j / resol, weight; @@ -555,9 +552,9 @@ float (*BKE_mask_spline_feather_differentiated_points_with_resolution_ex(MaskSpl /* TODO - these calls all calculate similar things * could be unified for some speed */ - BKE_mask_point_segment_co(spline, prev, u, co); - BKE_mask_point_normal(spline, prev, u, n); - weight = BKE_mask_point_weight(spline, prev, u); + BKE_mask_point_segment_co(spline, point_prev, u, co); + BKE_mask_point_normal(spline, point_prev, u, n); + weight = BKE_mask_point_weight(spline, point_prev, u); madd_v2_v2v2fl(*fp, co, n, weight); } @@ -566,15 +563,15 @@ float (*BKE_mask_spline_feather_differentiated_points_with_resolution_ex(MaskSpl float u = 1.0f, weight; float co[2], n[2]; - BKE_mask_point_segment_co(spline, prev, u, co); - BKE_mask_point_normal(spline, prev, u, n); - weight = BKE_mask_point_weight(spline, prev, u); + BKE_mask_point_segment_co(spline, point_prev, u, co); + BKE_mask_point_normal(spline, point_prev, u, n); + weight = BKE_mask_point_weight(spline, point_prev, u); madd_v2_v2v2fl(*fp, co, n, weight); } - prev = point; - point++; + point_prev = point_curr; + point_curr++; } *tot_feather_point = tot; @@ -645,3 +642,71 @@ float (*BKE_mask_spline_feather_points(MaskSpline *spline, int *tot_feather_poin return feather; } + +/* *** mask point functions which involve evaluation *** */ +float *BKE_mask_point_segment_feather_diff_with_resolution(MaskSpline *spline, MaskSplinePoint *point, + int width, int height, + unsigned int *tot_feather_point) +{ + float *feather, *fp; + unsigned int resol = BKE_mask_spline_feather_resolution(spline, width, height); + unsigned int i; + + feather = fp = MEM_callocN(2 * resol * sizeof(float), "mask point spline feather diff points"); + + for (i = 0; i < resol; i++, fp += 2) { + float u = (float)(i % resol) / resol, weight; + float co[2], n[2]; + + BKE_mask_point_segment_co(spline, point, u, co); + BKE_mask_point_normal(spline, point, u, n); + weight = BKE_mask_point_weight(spline, point, u); + + fp[0] = co[0] + n[0] * weight; + fp[1] = co[1] + n[1] * weight; + } + + *tot_feather_point = resol; + + return feather; +} + +float *BKE_mask_point_segment_feather_diff(MaskSpline *spline, MaskSplinePoint *point, unsigned int *tot_feather_point) +{ + return BKE_mask_point_segment_feather_diff_with_resolution(spline, point, 0, 0, tot_feather_point); +} + +float *BKE_mask_point_segment_diff_with_resolution(MaskSpline *spline, MaskSplinePoint *point, + int width, int height, unsigned int *tot_diff_point) +{ + MaskSplinePoint *points_array = BKE_mask_spline_point_array_from_point(spline, point); + + BezTriple *bezt, *bezt_next; + float *diff_points, *fp; + int j, resol = BKE_mask_spline_resolution(spline, width, height); + + bezt = &point->bezt; + bezt_next = BKE_mask_spline_point_next_bezt(spline, points_array, point); + + if (!bezt_next) + return NULL; + + /* resol+1 because of 'forward_diff_bezier' function */ + *tot_diff_point = resol + 1; + diff_points = fp = MEM_callocN((resol + 1) * 2 * sizeof(float), "mask segment vets"); + + for (j = 0; j < 2; j++) { + BKE_curve_forward_diff_bezier(bezt->vec[1][j], bezt->vec[2][j], + bezt_next->vec[0][j], bezt_next->vec[1][j], + fp + j, resol, 2 * sizeof(float)); + } + + copy_v2_v2(fp + 2 * resol, bezt_next->vec[1]); + + return diff_points; +} + +float *BKE_mask_point_segment_diff(MaskSpline *spline, MaskSplinePoint *point, unsigned int *tot_diff_point) +{ + return BKE_mask_point_segment_diff_with_resolution(spline, point, 0, 0, tot_diff_point); +} diff --git a/source/blender/editors/transform/transform_conversions.c b/source/blender/editors/transform/transform_conversions.c index 8eba8ebea41..7f77341447d 100644 --- a/source/blender/editors/transform/transform_conversions.c +++ b/source/blender/editors/transform/transform_conversions.c @@ -6239,7 +6239,7 @@ static void createTransMaskingData(bContext *C, TransInfo *t) /* count */ for (masklay = mask->masklayers.first; masklay; masklay = masklay->next) { - MaskSpline *spline = masklay->splines.first; + MaskSpline *spline; if (masklay->restrictflag & (MASK_RESTRICT_VIEW | MASK_RESTRICT_SELECT)) { continue; @@ -6282,7 +6282,7 @@ static void createTransMaskingData(bContext *C, TransInfo *t) /* create data */ for (masklay = mask->masklayers.first; masklay; masklay = masklay->next) { - MaskSpline *spline = masklay->splines.first; + MaskSpline *spline; if (masklay->restrictflag & (MASK_RESTRICT_VIEW | MASK_RESTRICT_SELECT)) { continue; From d33eb704f6e603d54ac3d0556ebcabf487356209 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 26 Aug 2012 18:21:34 +0000 Subject: [PATCH 144/163] code cleanup: quiet warning for dead assignment. --- source/blender/editors/space_view3d/view3d_edit.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/source/blender/editors/space_view3d/view3d_edit.c b/source/blender/editors/space_view3d/view3d_edit.c index e74bda87a43..5169d823bd8 100644 --- a/source/blender/editors/space_view3d/view3d_edit.c +++ b/source/blender/editors/space_view3d/view3d_edit.c @@ -1641,6 +1641,7 @@ static void viewzoom_apply(ViewOpsData *vod, int x, int y, const short viewzoom, CLAMP(vod->rv3d->camzoom, RV3D_CAMZOOM_MIN, RV3D_CAMZOOM_MAX); } + if (viewzoom == USER_ZOOM_CONT) { double time = PIL_check_seconds_timer(); float time_step = (float)(time - vod->timer_lastdraw); @@ -1689,8 +1690,10 @@ static void viewzoom_apply(ViewOpsData *vod, int x, int y, const short viewzoom, } if (use_cam_zoom) { + /* zfac is ignored in this case, see below */ +#if 0 zfac = vod->camzoom0 * (2.0f * ((len2 / len1) - 1.0f) + 1.0f) / vod->rv3d->camzoom; - zfac = 0; +#endif } else { zfac = vod->dist0 * (2.0f * ((len2 / len1) - 1.0f) + 1.0f) / vod->rv3d->dist; From fa5b0e1d0fc0b89ab3127becd59697ec6cfa5ecb Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Sun, 26 Aug 2012 19:36:56 +0000 Subject: [PATCH 145/163] Sequencer: typo fix --- source/blender/blenkernel/intern/seqeffects.c | 36 +++++++++---------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/source/blender/blenkernel/intern/seqeffects.c b/source/blender/blenkernel/intern/seqeffects.c index 87906337ca2..d137393e698 100644 --- a/source/blender/blenkernel/intern/seqeffects.c +++ b/source/blender/blenkernel/intern/seqeffects.c @@ -56,7 +56,7 @@ #include "RNA_access.h" -static void slize_get_byte_buffers(const SeqRenderData *context, const ImBuf *ibuf1, const ImBuf *ibuf2, +static void slice_get_byte_buffers(const SeqRenderData *context, const ImBuf *ibuf1, const ImBuf *ibuf2, const ImBuf *ibuf3, const ImBuf *out, int start_line, unsigned char **rect1, unsigned char **rect2, unsigned char **rect3, unsigned char **rect_out) { @@ -72,7 +72,7 @@ static void slize_get_byte_buffers(const SeqRenderData *context, const ImBuf *ib *rect3 = (unsigned char*) ibuf3->rect + offset; } -static void slize_get_float_buffers(const SeqRenderData *context, const ImBuf *ibuf1, const ImBuf *ibuf2, +static void slice_get_float_buffers(const SeqRenderData *context, const ImBuf *ibuf1, const ImBuf *ibuf2, const ImBuf *ibuf3, const ImBuf *out, int start_line, float **rect1, float **rect2, float **rect3, float **rect_out) { @@ -286,14 +286,14 @@ static void do_alphaover_effect(SeqRenderData context, Sequence *UNUSED(seq), fl if (out->rect_float) { float *rect1 = NULL, *rect2 = NULL, *rect_out = NULL; - slize_get_float_buffers(&context, ibuf1, ibuf2, NULL, out, start_line, &rect1, &rect2, NULL, &rect_out); + slice_get_float_buffers(&context, ibuf1, ibuf2, NULL, out, start_line, &rect1, &rect2, NULL, &rect_out); do_alphaover_effect_float(facf0, facf1, context.rectx, total_lines, rect1, rect2, rect_out); } else { unsigned char *rect1 = NULL, *rect2 = NULL, *rect_out = NULL; - slize_get_byte_buffers(&context, ibuf1, ibuf2, NULL, out, start_line, &rect1, &rect2, NULL, &rect_out); + slice_get_byte_buffers(&context, ibuf1, ibuf2, NULL, out, start_line, &rect1, &rect2, NULL, &rect_out); do_alphaover_effect_byte(facf0, facf1, context.rectx, total_lines, (char *) rect1, (char *) rect2, (char *) rect_out); } @@ -448,14 +448,14 @@ static void do_alphaunder_effect(SeqRenderData context, Sequence *UNUSED(seq), f if (out->rect_float) { float *rect1 = NULL, *rect2 = NULL, *rect_out = NULL; - slize_get_float_buffers(&context, ibuf1, ibuf2, NULL, out, start_line, &rect1, &rect2, NULL, &rect_out); + slice_get_float_buffers(&context, ibuf1, ibuf2, NULL, out, start_line, &rect1, &rect2, NULL, &rect_out); do_alphaunder_effect_float(facf0, facf1, context.rectx, total_lines, rect1, rect2, rect_out); } else { unsigned char *rect1 = NULL, *rect2 = NULL, *rect_out = NULL; - slize_get_byte_buffers(&context, ibuf1, ibuf2, NULL, out, start_line, &rect1, &rect2, NULL, &rect_out); + slice_get_byte_buffers(&context, ibuf1, ibuf2, NULL, out, start_line, &rect1, &rect2, NULL, &rect_out); do_alphaunder_effect_byte(facf0, facf1, context.rectx, total_lines, (char *) rect1, (char *) rect2, (char *) rect_out); } @@ -558,14 +558,14 @@ static void do_cross_effect(SeqRenderData context, Sequence *UNUSED(seq), float if (out->rect_float) { float *rect1 = NULL, *rect2 = NULL, *rect_out = NULL; - slize_get_float_buffers(&context, ibuf1, ibuf2, NULL, out, start_line, &rect1, &rect2, NULL, &rect_out); + slice_get_float_buffers(&context, ibuf1, ibuf2, NULL, out, start_line, &rect1, &rect2, NULL, &rect_out); do_cross_effect_float(facf0, facf1, context.rectx, total_lines, rect1, rect2, rect_out); } else { unsigned char *rect1 = NULL, *rect2 = NULL, *rect_out = NULL; - slize_get_byte_buffers(&context, ibuf1, ibuf2, NULL, out, start_line, &rect1, &rect2, NULL, &rect_out); + slice_get_byte_buffers(&context, ibuf1, ibuf2, NULL, out, start_line, &rect1, &rect2, NULL, &rect_out); do_cross_effect_byte(facf0, facf1, context.rectx, total_lines, (char *) rect1, (char *) rect2, (char *) rect_out); } @@ -807,14 +807,14 @@ static void do_gammacross_effect(SeqRenderData context, Sequence *UNUSED(seq), f if (out->rect_float) { float *rect1 = NULL, *rect2 = NULL, *rect_out = NULL; - slize_get_float_buffers(&context, ibuf1, ibuf2, NULL, out, start_line, &rect1, &rect2, NULL, &rect_out); + slice_get_float_buffers(&context, ibuf1, ibuf2, NULL, out, start_line, &rect1, &rect2, NULL, &rect_out); do_gammacross_effect_float(facf0, facf1, context.rectx, total_lines, rect1, rect2, rect_out); } else { unsigned char *rect1 = NULL, *rect2 = NULL, *rect_out = NULL; - slize_get_byte_buffers(&context, ibuf1, ibuf2, NULL, out, start_line, &rect1, &rect2, NULL, &rect_out); + slice_get_byte_buffers(&context, ibuf1, ibuf2, NULL, out, start_line, &rect1, &rect2, NULL, &rect_out); do_gammacross_effect_byte(facf0, facf1, context.rectx, total_lines, rect1, rect2, rect_out); } @@ -913,14 +913,14 @@ static void do_add_effect(SeqRenderData context, Sequence *UNUSED(seq), float UN if (out->rect_float) { float *rect1 = NULL, *rect2 = NULL, *rect_out = NULL; - slize_get_float_buffers(&context, ibuf1, ibuf2, NULL, out, start_line, &rect1, &rect2, NULL, &rect_out); + slice_get_float_buffers(&context, ibuf1, ibuf2, NULL, out, start_line, &rect1, &rect2, NULL, &rect_out); do_add_effect_float(facf0, facf1, context.rectx, total_lines, rect1, rect2, rect_out); } else { unsigned char *rect1 = NULL, *rect2 = NULL, *rect_out = NULL; - slize_get_byte_buffers(&context, ibuf1, ibuf2, NULL, out, start_line, &rect1, &rect2, NULL, &rect_out); + slice_get_byte_buffers(&context, ibuf1, ibuf2, NULL, out, start_line, &rect1, &rect2, NULL, &rect_out); do_add_effect_byte(facf0, facf1, context.rectx, total_lines, rect1, rect2, rect_out); } @@ -1017,14 +1017,14 @@ static void do_sub_effect(SeqRenderData context, Sequence *UNUSED(seq), float UN if (out->rect_float) { float *rect1 = NULL, *rect2 = NULL, *rect_out = NULL; - slize_get_float_buffers(&context, ibuf1, ibuf2, NULL, out, start_line, &rect1, &rect2, NULL, &rect_out); + slice_get_float_buffers(&context, ibuf1, ibuf2, NULL, out, start_line, &rect1, &rect2, NULL, &rect_out); do_sub_effect_float(facf0, facf1, context.rectx, total_lines, rect1, rect2, rect_out); } else { unsigned char *rect1 = NULL, *rect2 = NULL, *rect_out = NULL; - slize_get_byte_buffers(&context, ibuf1, ibuf2, NULL, out, start_line, &rect1, &rect2, NULL, &rect_out); + slice_get_byte_buffers(&context, ibuf1, ibuf2, NULL, out, start_line, &rect1, &rect2, NULL, &rect_out); do_sub_effect_byte(facf0, facf1, context.rectx, total_lines, (char *) rect1, (char *) rect2, (char *) rect_out); } @@ -1214,14 +1214,14 @@ static void do_mul_effect(SeqRenderData context, Sequence *UNUSED(seq), float UN if (out->rect_float) { float *rect1 = NULL, *rect2 = NULL, *rect_out = NULL; - slize_get_float_buffers(&context, ibuf1, ibuf2, NULL, out, start_line, &rect1, &rect2, NULL, &rect_out); + slice_get_float_buffers(&context, ibuf1, ibuf2, NULL, out, start_line, &rect1, &rect2, NULL, &rect_out); do_mul_effect_float(facf0, facf1, context.rectx, total_lines, rect1, rect2, rect_out); } else { unsigned char *rect1 = NULL, *rect2 = NULL, *rect_out = NULL; - slize_get_byte_buffers(&context, ibuf1, ibuf2, NULL, out, start_line, &rect1, &rect2, NULL, &rect_out); + slice_get_byte_buffers(&context, ibuf1, ibuf2, NULL, out, start_line, &rect1, &rect2, NULL, &rect_out); do_mul_effect_byte(facf0, facf1, context.rectx, total_lines, rect1, rect2, rect_out); } @@ -2748,7 +2748,7 @@ static void do_overdrop_effect(SeqRenderData context, Sequence *UNUSED(seq), flo if (out->rect_float) { float *rect1 = NULL, *rect2 = NULL, *rect_out = NULL; - slize_get_float_buffers(&context, ibuf1, ibuf2, NULL, out, start_line, &rect1, &rect2, NULL, &rect_out); + slice_get_float_buffers(&context, ibuf1, ibuf2, NULL, out, start_line, &rect1, &rect2, NULL, &rect_out); do_drop_effect_float(facf0, facf1, x, y, rect1, rect2, rect_out); do_alphaover_effect_float(facf0, facf1, x, y, rect1, rect2, rect_out); @@ -2756,7 +2756,7 @@ static void do_overdrop_effect(SeqRenderData context, Sequence *UNUSED(seq), flo else { unsigned char *rect1 = NULL, *rect2 = NULL, *rect_out = NULL; - slize_get_byte_buffers(&context, ibuf1, ibuf2, NULL, out, start_line, &rect1, &rect2, NULL, &rect_out); + slice_get_byte_buffers(&context, ibuf1, ibuf2, NULL, out, start_line, &rect1, &rect2, NULL, &rect_out); do_drop_effect_byte(facf0, facf1, x, y, (char *) rect1, (char *) rect2, (char *) rect_out); do_alphaover_effect_byte(facf0, facf1, x, y, (char *) rect1, (char *) rect2, (char *) rect_out); From c68890cb870477091db35ce2092121dc24548c1e Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 26 Aug 2012 20:22:42 +0000 Subject: [PATCH 146/163] ensure there are always the same number of feather points and non feather points when drawing. --- source/blender/editors/mask/mask_draw.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/source/blender/editors/mask/mask_draw.c b/source/blender/editors/mask/mask_draw.c index c6b19e51de9..00bbfcf3188 100644 --- a/source/blender/editors/mask/mask_draw.c +++ b/source/blender/editors/mask/mask_draw.c @@ -365,6 +365,9 @@ static void draw_spline_curve(MaskLayer *masklay, MaskSpline *spline, const short is_active, int width, int height) { + const unsigned int resol = maxi(BKE_mask_spline_feather_resolution(spline, width, height), + BKE_mask_spline_resolution(spline, width, height)); + unsigned char rgb_tmp[4]; const short is_spline_sel = (spline->flag & SELECT) && (masklay->restrictflag & MASK_RESTRICT_SELECT) == 0; @@ -377,7 +380,7 @@ static void draw_spline_curve(MaskLayer *masklay, MaskSpline *spline, int tot_feather_point; float (*feather_points)[2]; - diff_points = BKE_mask_spline_differentiate_with_resolution(spline, width, height, &tot_diff_point); + diff_points = BKE_mask_spline_differentiate_with_resolution_ex(spline, &tot_diff_point, resol); if (!diff_points) return; @@ -388,7 +391,7 @@ static void draw_spline_curve(MaskLayer *masklay, MaskSpline *spline, glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); } - feather_points = BKE_mask_spline_feather_differentiated_points_with_resolution(spline, width, height, &tot_feather_point, (is_fill != FALSE)); + feather_points = BKE_mask_spline_feather_differentiated_points_with_resolution_ex(spline, &tot_feather_point, resol, (is_fill != FALSE)); /* draw feather */ mask_spline_feather_color_get(masklay, spline, is_spline_sel, rgb_tmp); From b78b1924f3999bdc365984431f8f3ecf16ef4d1a Mon Sep 17 00:00:00 2001 From: Mitchell Stokes Date: Sun, 26 Aug 2012 23:17:50 +0000 Subject: [PATCH 147/163] BGE: Make sure lib loaded cameras are added to the active scene's camera list. --- source/gameengine/Ketsji/KX_Scene.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/source/gameengine/Ketsji/KX_Scene.cpp b/source/gameengine/Ketsji/KX_Scene.cpp index 5d4b9ae40c2..f9fa0ae65f1 100644 --- a/source/gameengine/Ketsji/KX_Scene.cpp +++ b/source/gameengine/Ketsji/KX_Scene.cpp @@ -1825,6 +1825,9 @@ static void MergeScene_GameObject(KX_GameObject* gameobj, KX_Scene *to, KX_Scene if (gameobj->GetGameObjectType() == SCA_IObject::OBJ_LIGHT) ((KX_LightObject*)gameobj)->UpdateScene(to); + if (gameobj->GetGameObjectType() == SCA_IObject::OBJ_CAMERA) + to->AddCamera((KX_Camera*)gameobj); + /* Add the object to the scene's logic manager */ to->GetLogicManager()->RegisterGameObjectName(gameobj->GetName(), gameobj); to->GetLogicManager()->RegisterGameObj(gameobj->GetBlenderObject(), gameobj); From ae6907a065da928043da35221ca879f1d58ecf0b Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 27 Aug 2012 06:55:33 +0000 Subject: [PATCH 148/163] fix [#32417] Grease Pencil color change + DopeSheet 'Summary' = crash summery wasn't checking fcurve types. --- .../editors/animation/keyframes_draw.c | 20 +++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/source/blender/editors/animation/keyframes_draw.c b/source/blender/editors/animation/keyframes_draw.c index d024e2b0393..98ab6dc99a6 100644 --- a/source/blender/editors/animation/keyframes_draw.c +++ b/source/blender/editors/animation/keyframes_draw.c @@ -857,13 +857,21 @@ void summary_to_keylist(bAnimContext *ac, DLRBT_Tree *keys, DLRBT_Tree *blocks) /* loop through each F-Curve, grabbing the keyframes */ for (ale = anim_data.first; ale; ale = ale->next) { - fcurve_to_keylist(ale->adt, ale->data, keys, blocks); - if (ale->datatype == ALE_MASKLAY) { - mask_to_keylist(ac->ads, ale->data, keys); - } - else if (ale->datatype == ALE_GPFRAME) { - gpl_to_keylist(ac->ads, ale->data, keys); + switch (ale->datatype) { + case ALE_FCURVE: + fcurve_to_keylist(ale->adt, ale->data, keys, blocks); + break; + case ALE_MASKLAY: + mask_to_keylist(ac->ads, ale->data, keys); + break; + case ALE_GPFRAME: + gpl_to_keylist(ac->ads, ale->data, keys); + break; + default: + printf("%s: datatype %d unhandled\n", __func__, ale->datatype); + break; + } } From 5d60dabef468a79c7d253f53dc19b89a0f36fe80 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 27 Aug 2012 08:23:51 +0000 Subject: [PATCH 149/163] remove incorrect comment, add in useful one. --- source/blender/editors/animation/keyframes_draw.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/source/blender/editors/animation/keyframes_draw.c b/source/blender/editors/animation/keyframes_draw.c index 98ab6dc99a6..46537674e59 100644 --- a/source/blender/editors/animation/keyframes_draw.c +++ b/source/blender/editors/animation/keyframes_draw.c @@ -852,12 +852,17 @@ void summary_to_keylist(bAnimContext *ac, DLRBT_Tree *keys, DLRBT_Tree *blocks) int filter; /* get F-Curves to take keyframes from */ - filter = ANIMFILTER_DATA_VISIBLE; // curves only + filter = ANIMFILTER_DATA_VISIBLE; ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); /* loop through each F-Curve, grabbing the keyframes */ for (ale = anim_data.first; ale; ale = ale->next) { + /* Why not use all #eAnim_KeyType here? + * All of the other key types are actually "summaries" themselves, and will just end up duplicating stuff + * that comes up through standard filtering of just F-Curves. + * Given the way that these work, there isn't really any benefit at all from including them. - Aligorith */ + switch (ale->datatype) { case ALE_FCURVE: fcurve_to_keylist(ale->adt, ale->data, keys, blocks); @@ -869,9 +874,8 @@ void summary_to_keylist(bAnimContext *ac, DLRBT_Tree *keys, DLRBT_Tree *blocks) gpl_to_keylist(ac->ads, ale->data, keys); break; default: - printf("%s: datatype %d unhandled\n", __func__, ale->datatype); + // printf("%s: datatype %d unhandled\n", __func__, ale->datatype); break; - } } From b563039b8fb6b26804a13180efee83f892b6c939 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Mon, 27 Aug 2012 09:01:34 +0000 Subject: [PATCH 150/163] Sequencer: fix crash of histogram view for float images Overexposured pixels lead to wrong memory access in histogram making function --- .../blender/editors/space_sequencer/sequencer_scopes.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/source/blender/editors/space_sequencer/sequencer_scopes.c b/source/blender/editors/space_sequencer/sequencer_scopes.c index 5debeaf79ae..6f460500bc4 100644 --- a/source/blender/editors/space_sequencer/sequencer_scopes.c +++ b/source/blender/editors/space_sequencer/sequencer_scopes.c @@ -470,7 +470,7 @@ static ImBuf *make_histogram_view_from_ibuf_byte(ImBuf *ibuf) unsigned int bins[3][256]; - memset(bins, 0, 3 * 256 * sizeof(unsigned int)); + memset(bins, 0, sizeof(bins)); for (y = 0; y < ibuf->y; y++) { for (x = 0; x < ibuf->x; x++) { @@ -507,10 +507,10 @@ static ImBuf *make_histogram_view_from_ibuf_byte(ImBuf *ibuf) static int get_bin_float(float f) { if (f < -0.25f) { - f = -0.25f; + return 0; } - else if (f > 1.25f) { - f = 1.25f; + else if (f >= 1.25f) { + return 511; } return (int) (((f + 0.25f) / 1.5f) * 512); @@ -524,7 +524,7 @@ static ImBuf *make_histogram_view_from_ibuf_float(ImBuf *ibuf) unsigned int bins[3][512]; - memset(bins, 0, 3 * 256 * sizeof(unsigned int)); + memset(bins, 0, sizeof(bins)); for (y = 0; y < ibuf->y; y++) { for (x = 0; x < ibuf->x; x++) { From 1216dcffaaeb9691715fa33e2a160690b3885990 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Mon, 27 Aug 2012 09:01:35 +0000 Subject: [PATCH 151/163] Style cleanup: spaces in sequencer scopes --- .../space_sequencer/sequencer_scopes.c | 52 ++++++------------- 1 file changed, 17 insertions(+), 35 deletions(-) diff --git a/source/blender/editors/space_sequencer/sequencer_scopes.c b/source/blender/editors/space_sequencer/sequencer_scopes.c index 6f460500bc4..1655b3ec7bc 100644 --- a/source/blender/editors/space_sequencer/sequencer_scopes.c +++ b/source/blender/editors/space_sequencer/sequencer_scopes.c @@ -60,16 +60,14 @@ static void scope_put_pixel(unsigned char *table, unsigned char *pos) pos[3] = 255; } -static void scope_put_pixel_single(unsigned char *table, unsigned char *pos, - int col) +static void scope_put_pixel_single(unsigned char *table, unsigned char *pos, int col) { char newval = table[pos[col]]; pos[col] = newval; pos[3] = 255; } -static void wform_put_line(int w, - unsigned char *last_pos, unsigned char *new_pos) +static void wform_put_line(int w, unsigned char *last_pos, unsigned char *new_pos) { if (last_pos > new_pos) { unsigned char *temp = new_pos; @@ -86,8 +84,7 @@ static void wform_put_line(int w, } } -static void wform_put_line_single( - int w, unsigned char *last_pos, unsigned char *new_pos, int col) +static void wform_put_line_single(int w, unsigned char *last_pos, unsigned char *new_pos, int col) { if (last_pos > new_pos) { unsigned char *temp = new_pos; @@ -161,8 +158,7 @@ static ImBuf *make_waveform_view_from_ibuf_byte(ImBuf *ibuf) wform_put_grid(tgt, w, h); for (x = 0; x < 256; x++) { - wtable[x] = (unsigned char) (pow(((float) x + 1) / 256, - waveform_gamma) * 255); + wtable[x] = (unsigned char) (pow(((float) x + 1) / 256, waveform_gamma) * 255); } for (y = 0; y < ibuf->y; y++) { @@ -204,8 +200,7 @@ static ImBuf *make_waveform_view_from_ibuf_float(ImBuf *ibuf) wform_put_grid(tgt, w, h); for (x = 0; x < 256; x++) { - wtable[x] = (unsigned char) (pow(((float) x + 1) / 256, - waveform_gamma) * 255); + wtable[x] = (unsigned char) (pow(((float) x + 1) / 256, waveform_gamma) * 255); } for (y = 0; y < ibuf->y; y++) { @@ -249,8 +244,7 @@ ImBuf *make_waveform_view_from_ibuf(ImBuf *ibuf) static ImBuf *make_sep_waveform_view_from_ibuf_byte(ImBuf *ibuf) { - ImBuf *rval = IMB_allocImBuf( - ibuf->x + 3, 515, 32, IB_rect); + ImBuf *rval = IMB_allocImBuf(ibuf->x + 3, 515, 32, IB_rect); int x, y; unsigned char *src = (unsigned char *) ibuf->rect; unsigned char *tgt = (unsigned char *) rval->rect; @@ -263,8 +257,7 @@ static ImBuf *make_sep_waveform_view_from_ibuf_byte(ImBuf *ibuf) wform_put_grid(tgt, w, h); for (x = 0; x < 256; x++) { - wtable[x] = (unsigned char) (pow(((float) x + 1) / 256, - waveform_gamma) * 255); + wtable[x] = (unsigned char) (pow(((float) x + 1) / 256, waveform_gamma) * 255); } for (y = 0; y < ibuf->y; y++) { @@ -275,16 +268,14 @@ static ImBuf *make_sep_waveform_view_from_ibuf_byte(ImBuf *ibuf) unsigned char *rgb = src + 4 * (ibuf->x * y + x); for (c = 0; c < 3; c++) { unsigned char *p = tgt; - p += 4 * (w * ((rgb[c] * (h - 3)) / 255 + 1) + - c * sw + x / 3 + 1); + p += 4 * (w * ((rgb[c] * (h - 3)) / 255 + 1) + c * sw + x / 3 + 1); scope_put_pixel_single(wtable, p, c); p += 4 * w; scope_put_pixel_single(wtable, p, c); if (last_p[c] != NULL) { - wform_put_line_single( - w, last_p[c], p, c); + wform_put_line_single(w, last_p[c], p, c); } last_p[c] = p; } @@ -311,8 +302,7 @@ static ImBuf *make_sep_waveform_view_from_ibuf_float(ImBuf *ibuf) wform_put_grid(tgt, w, h); for (x = 0; x < 256; x++) { - wtable[x] = (unsigned char) (pow(((float) x + 1) / 256, - waveform_gamma) * 255); + wtable[x] = (unsigned char) (pow(((float) x + 1) / 256, waveform_gamma) * 255); } for (y = 0; y < ibuf->y; y++) { @@ -327,16 +317,14 @@ static ImBuf *make_sep_waveform_view_from_ibuf_float(ImBuf *ibuf) CLAMP(v, 0.0f, 1.0f); - p += 4 * (w * ((int) (v * (h - 3)) + 1) + - c * sw + x / 3 + 1); + p += 4 * (w * ((int) (v * (h - 3)) + 1) + c * sw + x / 3 + 1); scope_put_pixel_single(wtable, p, c); p += 4 * w; scope_put_pixel_single(wtable, p, c); if (last_p[c] != NULL) { - wform_put_line_single( - w, last_p[c], p, c); + wform_put_line_single(w, last_p[c], p, c); } last_p[c] = p; } @@ -492,10 +480,8 @@ static ImBuf *make_histogram_view_from_ibuf_byte(ImBuf *ibuf) for (c = 0; c < 3; c++) { for (x = 0; x < 256; x++) { - draw_histogram_bar(rval, x * 2 + 1, - ((float) bins[c][x]) / n, c); - draw_histogram_bar(rval, x * 2 + 2, - ((float) bins[c][x]) / n, c); + draw_histogram_bar(rval, x * 2 + 1, ((float) bins[c][x]) / n, c); + draw_histogram_bar(rval, x * 2 + 2, ((float) bins[c][x]) / n, c); } } @@ -567,9 +553,7 @@ ImBuf *make_histogram_view_from_ibuf(ImBuf *ibuf) } } -static void vectorscope_put_cross(unsigned char r, unsigned char g, - unsigned char b, - char *tgt, int w, int h, int size) +static void vectorscope_put_cross(unsigned char r, unsigned char g, unsigned char b, char *tgt, int w, int h, int size) { float rgb[3], yuv[3]; char *p; @@ -609,8 +593,7 @@ static ImBuf *make_vectorscope_view_from_ibuf_byte(ImBuf *ibuf) unsigned char wtable[256]; for (x = 0; x < 256; x++) { - wtable[x] = (unsigned char) (pow(((float) x + 1) / 256, - scope_gamma) * 255); + wtable[x] = (unsigned char) (pow(((float) x + 1) / 256, scope_gamma) * 255); } for (x = 0; x <= 255; x++) { @@ -656,8 +639,7 @@ static ImBuf *make_vectorscope_view_from_ibuf_float(ImBuf *ibuf) unsigned char wtable[256]; for (x = 0; x < 256; x++) { - wtable[x] = (unsigned char) (pow(((float) x + 1) / 256, - scope_gamma) * 255); + wtable[x] = (unsigned char) (pow(((float) x + 1) / 256, scope_gamma) * 255); } for (x = 0; x <= 255; x++) { From d6a92c9c31423168d3facb747cc215e7b33b6e7b Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Mon, 27 Aug 2012 09:01:36 +0000 Subject: [PATCH 152/163] Sequencer: proper cache invalidation when deleting sequences Solves issue with effects not being recalculated when deleting their input. --- source/blender/blenkernel/intern/sequencer.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/source/blender/blenkernel/intern/sequencer.c b/source/blender/blenkernel/intern/sequencer.c index 3bcef50a3b4..8aab622148b 100644 --- a/source/blender/blenkernel/intern/sequencer.c +++ b/source/blender/blenkernel/intern/sequencer.c @@ -207,8 +207,10 @@ void BKE_sequence_free(Scene *scene, Sequence *seq) /* free modifiers */ BKE_sequence_modifier_clear(seq); - BKE_sequencer_cache_cleanup_sequence(seq); - BKE_sequencer_preprocessed_cache_cleanup_sequence(seq); + /* free cached data used by this strip, + * also invalidate cache for all dependent sequences + */ + BKE_sequence_invalidate_cache(scene, seq); MEM_freeN(seq); } @@ -2936,6 +2938,9 @@ static void free_anim_seq(Sequence *seq) /* check whether sequence cur depends on seq */ int BKE_sequence_check_depend(Sequence *seq, Sequence *cur) { + if (cur->seq1 == seq || cur->seq2 == seq || cur->seq3 == seq) + return TRUE; + /* sequences are not intersecting in time, assume no dependency exists between them */ if (cur->enddisp < seq->startdisp || cur->startdisp > seq->enddisp) return FALSE; From 4035bf16e75acde1ef77d8a176edc95dbad70f35 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Mon, 27 Aug 2012 09:15:48 +0000 Subject: [PATCH 153/163] Fix #31853: Marker deletion invokes strip deletion --- .../editors/space_sequencer/sequencer_edit.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/source/blender/editors/space_sequencer/sequencer_edit.c b/source/blender/editors/space_sequencer/sequencer_edit.c index 81699d36f5f..5a40c2ce4e7 100644 --- a/source/blender/editors/space_sequencer/sequencer_edit.c +++ b/source/blender/editors/space_sequencer/sequencer_edit.c @@ -1668,6 +1668,20 @@ static int sequencer_delete_exec(bContext *C, wmOperator *UNUSED(op)) return OPERATOR_FINISHED; } +static int sequencer_delete_invoke(bContext *C, wmOperator *op, wmEvent *event) +{ + ARegion *ar = CTX_wm_region(C); + + if (ar->regiontype == RGN_TYPE_WINDOW) { + /* bounding box of 30 pixels is used for markers shortcuts, + * prevent conflict with markers shortcurts here + */ + if (event->mval[1] <= 30) + return OPERATOR_PASS_THROUGH; + } + + return WM_operator_confirm(C, op, event); +} void SEQUENCER_OT_delete(wmOperatorType *ot) { @@ -1678,7 +1692,7 @@ void SEQUENCER_OT_delete(wmOperatorType *ot) ot->description = "Erase selected strips from the sequencer"; /* api callbacks */ - ot->invoke = WM_operator_confirm; + ot->invoke = sequencer_delete_invoke; ot->exec = sequencer_delete_exec; ot->poll = sequencer_edit_poll; From 13254cde8c7ca38af2dcec35efdb9f8f9b3bca46 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 27 Aug 2012 09:44:56 +0000 Subject: [PATCH 154/163] Alternate mask spline feather offset calculation method: now there are 2 [Even | Smooth] - Even preserves thickness but can give unsightly loops - Smooth gives nicer shape but can give unsightly feather/spline mismatch for 'S' shapes created by beziers. This is an example where smooth works much nicer. http://www.graphicall.org/ftp/ideasman42/mask_compare.png --- .../startup/bl_ui/properties_mask_common.py | 1 + source/blender/blenkernel/intern/mask.c | 19 +- .../blender/blenkernel/intern/mask_evaluate.c | 170 +++++++++++++++++- source/blender/blenlib/BLI_math_vector.h | 3 + source/blender/blenlib/intern/math_vector.c | 23 +++ source/blender/makesdna/DNA_mask_types.h | 20 ++- source/blender/makesrna/intern/rna_mask.c | 13 ++ 7 files changed, 220 insertions(+), 29 deletions(-) diff --git a/release/scripts/startup/bl_ui/properties_mask_common.py b/release/scripts/startup/bl_ui/properties_mask_common.py index 67980c388b5..208b0a63075 100644 --- a/release/scripts/startup/bl_ui/properties_mask_common.py +++ b/release/scripts/startup/bl_ui/properties_mask_common.py @@ -121,6 +121,7 @@ class MASK_PT_spline(): spline = mask.layers.active.splines.active col = layout.column() + col.prop(spline, "offset_mode") col.prop(spline, "weight_interpolation") row = col.row() diff --git a/source/blender/blenkernel/intern/mask.c b/source/blender/blenkernel/intern/mask.c index 5182c52605a..f73fb3879b8 100644 --- a/source/blender/blenkernel/intern/mask.c +++ b/source/blender/blenkernel/intern/mask.c @@ -1194,17 +1194,6 @@ void BKE_mask_calc_handle_point(MaskSpline *spline, MaskSplinePoint *point) mask_calc_point_handle(point, point_prev, point_next); } -static void enforce_dist_v2_v2fl(float v1[2], const float v2[2], const float dist) -{ - if (!equals_v2v2(v2, v1)) { - float nor[2]; - - sub_v2_v2v2(nor, v1, v2); - normalize_v2(nor); - madd_v2_v2v2fl(v1, v2, nor, dist); - } -} - void BKE_mask_calc_handle_adjacent_interp(MaskSpline *spline, MaskSplinePoint *point, const float u) { /* TODO! - make this interpolate between siblings - not always midpoint! */ @@ -1246,8 +1235,8 @@ void BKE_mask_calc_handle_adjacent_interp(MaskSpline *spline, MaskSplinePoint *p length_average /= (float)length_tot; weight_average /= (float)length_tot; - enforce_dist_v2_v2fl(point->bezt.vec[0], point->bezt.vec[1], length_average); - enforce_dist_v2_v2fl(point->bezt.vec[2], point->bezt.vec[1], length_average); + dist_ensure_v2_v2fl(point->bezt.vec[0], point->bezt.vec[1], length_average); + dist_ensure_v2_v2fl(point->bezt.vec[2], point->bezt.vec[1], length_average); point->bezt.weight = weight_average; } } @@ -1279,8 +1268,8 @@ void BKE_mask_calc_handle_point_auto(MaskSpline *spline, MaskSplinePoint *point, /* preserve length by applying it back */ if (do_recalc_length == FALSE) { - enforce_dist_v2_v2fl(point->bezt.vec[0], point->bezt.vec[1], length_average); - enforce_dist_v2_v2fl(point->bezt.vec[2], point->bezt.vec[1], length_average); + dist_ensure_v2_v2fl(point->bezt.vec[0], point->bezt.vec[1], length_average); + dist_ensure_v2_v2fl(point->bezt.vec[2], point->bezt.vec[1], length_average); } } diff --git a/source/blender/blenkernel/intern/mask_evaluate.c b/source/blender/blenkernel/intern/mask_evaluate.c index 9d9f1665a7b..065dc38c81e 100644 --- a/source/blender/blenkernel/intern/mask_evaluate.c +++ b/source/blender/blenkernel/intern/mask_evaluate.c @@ -507,15 +507,12 @@ void BKE_mask_spline_feather_collapse_inner_loops(MaskSpline *spline, float (*fe #undef BUCKET_INDEX } -/** - * values align with #BKE_mask_spline_differentiate_with_resolution_ex - * when \a resol arguments match. - */ -float (*BKE_mask_spline_feather_differentiated_points_with_resolution_ex(MaskSpline *spline, - int *tot_feather_point, - const unsigned int resol, - const int do_feather_isect - ))[2] +/** only called from #BKE_mask_spline_feather_differentiated_points_with_resolution_ex() ! */ +static float (*mask_spline_feather_differentiated_points_with_resolution_ex__even(MaskSpline *spline, + int *tot_feather_point, + const unsigned int resol, + const int do_feather_isect + ))[2] { MaskSplinePoint *points_array = BKE_mask_spline_point_array(spline); MaskSplinePoint *point_curr, *point_prev; @@ -583,6 +580,161 @@ float (*BKE_mask_spline_feather_differentiated_points_with_resolution_ex(MaskSpl return feather; } +/** only called from #BKE_mask_spline_feather_differentiated_points_with_resolution_ex() ! */ +static float (*mask_spline_feather_differentiated_points_with_resolution_ex__double(MaskSpline *spline, + int *tot_feather_point, + const unsigned int resol, + const int do_feather_isect + ))[2] +{ + MaskSplinePoint *points_array = BKE_mask_spline_point_array(spline); + + MaskSplinePoint *point_curr, *point_prev; + float (*feather)[2], (*fp)[2]; + const int tot = BKE_mask_spline_differentiate_calc_total(spline, resol); + int a; + + if (spline->tot_point <= 1) { + /* nothing to differentiate */ + *tot_feather_point = 0; + return NULL; + } + + /* len+1 because of 'forward_diff_bezier' function */ + *tot_feather_point = tot; + feather = fp = MEM_mallocN((tot + 1) * sizeof(*feather), "mask spline vets"); + + a = spline->tot_point - 1; + if (spline->flag & MASK_SPLINE_CYCLIC) + a++; + + point_prev = points_array; + point_curr = point_prev + 1; + + while (a--) { + BezTriple local_prevbezt; + BezTriple local_bezt; + float point_prev_n[2], point_curr_n[2], tvec[2]; + float weight_prev, weight_curr; + float len_base, len_feather, len_scalar; + + BezTriple *bezt_prev; + BezTriple *bezt_curr; + int j; + + if (a == 0 && (spline->flag & MASK_SPLINE_CYCLIC)) + point_curr = points_array; + + bezt_prev = &point_prev->bezt; + bezt_curr = &point_curr->bezt; + + /* modified copy for feather */ + local_prevbezt = *bezt_prev; + local_bezt = *bezt_curr; + + bezt_prev = &local_prevbezt; + bezt_curr = &local_bezt; + + /* calc the normals */ + sub_v2_v2v2(tvec, bezt_prev->vec[1], bezt_prev->vec[0]); + normalize_v2(tvec); + point_prev_n[0] = -tvec[1]; + point_prev_n[1] = tvec[0]; + + sub_v2_v2v2(tvec, bezt_curr->vec[1], bezt_curr->vec[0]); + normalize_v2(tvec); + point_curr_n[0] = -tvec[1]; + point_curr_n[1] = tvec[0]; + + weight_prev = bezt_prev->weight; + weight_curr = bezt_curr->weight; + + mul_v2_fl(point_prev_n, weight_prev); + mul_v2_fl(point_curr_n, weight_curr); + + /* before we transform verts */ + len_base = len_v2v2(bezt_prev->vec[1], bezt_curr->vec[1]); + + // add_v2_v2(bezt_prev->vec[0], point_prev_n); // not needed + add_v2_v2(bezt_prev->vec[1], point_prev_n); + add_v2_v2(bezt_prev->vec[2], point_prev_n); + + add_v2_v2(bezt_curr->vec[0], point_curr_n); + add_v2_v2(bezt_curr->vec[1], point_curr_n); + // add_v2_v2(bezt_curr->vec[2], point_curr_n); // not needed + + len_feather = len_v2v2(bezt_prev->vec[1], bezt_curr->vec[1]); + + /* scale by chane in length */ + len_scalar = len_feather / len_base; + dist_ensure_v2_v2fl(bezt_prev->vec[2], bezt_prev->vec[1], len_scalar * len_v2v2(bezt_prev->vec[2], bezt_prev->vec[1])); + dist_ensure_v2_v2fl(bezt_curr->vec[0], bezt_curr->vec[1], len_scalar * len_v2v2(bezt_curr->vec[0], bezt_curr->vec[1])); + + + for (j = 0; j < 2; j++) { + BKE_curve_forward_diff_bezier(bezt_prev->vec[1][j], bezt_prev->vec[2][j], + bezt_curr->vec[0][j], bezt_curr->vec[1][j], + &(*fp)[j], resol, 2 * sizeof(float)); + } + + + /* scale by the uw's */ + if (point_prev->tot_uw) { + for (j = 0; j < resol; j++, fp++) { + float u = (float) j / resol; + float weight_uw, weight_scalar; + float co[2]; + + /* TODO - these calls all calculate similar things + * could be unified for some speed */ + BKE_mask_point_segment_co(spline, point_prev, u, co); + + weight_uw = BKE_mask_point_weight(spline, point_prev, u); + weight_scalar = BKE_mask_point_weight_scalar(spline, point_prev, u); + + dist_ensure_v2_v2fl(*fp, co, len_v2v2(*fp, co) * (weight_uw / weight_scalar)); + } + } + else { + fp += resol; + } + + if (a == 0 && (spline->flag & MASK_SPLINE_CYCLIC) == 0) { + copy_v2_v2(*fp, bezt_curr->vec[1]); + } + + point_prev = point_curr; + point_curr++; + } + + if ((spline->flag & MASK_SPLINE_NOINTERSECT) && do_feather_isect) { + BKE_mask_spline_feather_collapse_inner_loops(spline, feather, tot); + } + + return feather; +} + +/** + * values align with #BKE_mask_spline_differentiate_with_resolution_ex + * when \a resol arguments match. + */ +float (*BKE_mask_spline_feather_differentiated_points_with_resolution_ex(MaskSpline *spline, + int *tot_feather_point, + const unsigned int resol, + const int do_feather_isect + ))[2] +{ + switch (spline->offset_mode) { + case MASK_SPLINE_OFFSET_EVEN: + return mask_spline_feather_differentiated_points_with_resolution_ex__even(spline, tot_feather_point, resol, do_feather_isect); + break; + case MASK_SPLINE_OFFSET_SMOOTH: + default: + return mask_spline_feather_differentiated_points_with_resolution_ex__double(spline, tot_feather_point, resol, do_feather_isect); + break; + } +} + float (*BKE_mask_spline_feather_differentiated_points_with_resolution(MaskSpline *spline, int width, int height, int *tot_feather_point, const int do_feather_isect))[2] { diff --git a/source/blender/blenlib/BLI_math_vector.h b/source/blender/blenlib/BLI_math_vector.h index 8499a7f219c..eef8c9daaef 100644 --- a/source/blender/blenlib/BLI_math_vector.h +++ b/source/blender/blenlib/BLI_math_vector.h @@ -220,6 +220,9 @@ MINLINE void normal_float_to_short_v3(short r[3], const float n[3]); void minmax_v3v3_v3(float min[3], float max[3], const float vec[3]); +void dist_ensure_v3_v3fl(float v1[3], const float v2[3], const float dist); +void dist_ensure_v2_v2fl(float v1[2], const float v2[2], const float dist); + /***************************** Array Functions *******************************/ /* attempted to follow fixed length vertex functions. names could be improved*/ double dot_vn_vn(const float *array_src_a, const float *array_src_b, const int size); diff --git a/source/blender/blenlib/intern/math_vector.c b/source/blender/blenlib/intern/math_vector.c index 5cda1c0b81f..4196bab0474 100644 --- a/source/blender/blenlib/intern/math_vector.c +++ b/source/blender/blenlib/intern/math_vector.c @@ -451,6 +451,29 @@ void minmax_v3v3_v3(float min[3], float max[3], const float vec[3]) if (max[2] < vec[2]) max[2] = vec[2]; } +/** ensure \a v1 is \a dist from \a v2 */ +void dist_ensure_v3_v3fl(float v1[3], const float v2[3], const float dist) +{ + if (!equals_v3v3(v2, v1)) { + float nor[3]; + + sub_v3_v3v3(nor, v1, v2); + normalize_v3(nor); + madd_v3_v3v3fl(v1, v2, nor, dist); + } +} + +void dist_ensure_v2_v2fl(float v1[2], const float v2[2], const float dist) +{ + if (!equals_v2v2(v2, v1)) { + float nor[2]; + + sub_v2_v2v2(nor, v1, v2); + normalize_v2(nor); + madd_v2_v2v2fl(v1, v2, nor, dist); + } +} + /***************************** Array Functions *******************************/ double dot_vn_vn(const float *array_src_a, const float *array_src_b, const int size) diff --git a/source/blender/makesdna/DNA_mask_types.h b/source/blender/makesdna/DNA_mask_types.h index 6c7f7aa2471..bf388d8c018 100644 --- a/source/blender/makesdna/DNA_mask_types.h +++ b/source/blender/makesdna/DNA_mask_types.h @@ -82,13 +82,14 @@ typedef struct MaskSplinePoint { typedef struct MaskSpline { struct MaskSpline *next, *prev; - int flag; /* defferent spline flag (closed, ...) */ + short flag; /* defferent spline flag (closed, ...) */ + char offset_mode; /* feather offset method */ + char weight_interp; /* weight interpolation */ + int tot_point; /* total number of points */ MaskSplinePoint *points; /* points which defines spline itself */ MaskParent parent; /* parenting information of the whole spline */ - int weight_interp, pad; /* weight interpolation */ - MaskSplinePoint *points_deform; /* deformed copy of 'points' BezTriple data - not saved */ } MaskSpline; @@ -146,8 +147,17 @@ enum { }; /* MaskSpline->weight_interp */ -#define MASK_SPLINE_INTERP_LINEAR 1 -#define MASK_SPLINE_INTERP_EASE 2 +enum { + MASK_SPLINE_INTERP_LINEAR = 1, + MASK_SPLINE_INTERP_EASE = 2 +}; + +/* MaskSpline->offset_mode */ +enum { + MASK_SPLINE_OFFSET_EVEN = 0, + MASK_SPLINE_OFFSET_SMOOTH = 1 +}; + /* ob->restrictflag */ #define MASK_RESTRICT_VIEW 1 diff --git a/source/blender/makesrna/intern/rna_mask.c b/source/blender/makesrna/intern/rna_mask.c index a6571a2db4f..719baed8edb 100644 --- a/source/blender/makesrna/intern/rna_mask.c +++ b/source/blender/makesrna/intern/rna_mask.c @@ -540,6 +540,12 @@ static void rna_def_maskSpline(BlenderRNA *brna) {0, NULL, 0, NULL, NULL} }; + static EnumPropertyItem spline_offset_mode_items[] = { + {MASK_SPLINE_OFFSET_EVEN, "EVEN", 0, "Even", "Calculate even feather offset"}, + {MASK_SPLINE_OFFSET_SMOOTH, "SMOOTH", 0, "Smooth", "Calculate feather offset as a second curve"}, + {0, NULL, 0, NULL, NULL} + }; + StructRNA *srna; PropertyRNA *prop; @@ -548,6 +554,13 @@ static void rna_def_maskSpline(BlenderRNA *brna) srna = RNA_def_struct(brna, "MaskSpline", NULL); RNA_def_struct_ui_text(srna, "Mask spline", "Single spline used for defining mask shape"); + /* offset mode */ + prop = RNA_def_property(srna, "offset_mode", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_sdna(prop, NULL, "offset_mode"); + RNA_def_property_enum_items(prop, spline_offset_mode_items); + RNA_def_property_ui_text(prop, "Feather Offset", "The method used for calculating the feather offset"); + RNA_def_property_update(prop, 0, "rna_Mask_update_data"); + /* weight interpolation */ prop = RNA_def_property(srna, "weight_interpolation", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "weight_interp"); From 590251f55a113848043c8eb43563379f614f65f3 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Mon, 27 Aug 2012 11:59:26 +0000 Subject: [PATCH 155/163] File format fixes - Add check for header field in BMP decoder. This is needed to distinguish whether file is indeed BMP image or not. Without this check Blender could easily crash when it'll try to load non-BMP image. Tested with files from own HDD, but all of them has got BM header field, more testing would be welcome. - Made Jpeg2000 aware of J2K codec. Originally was needed to verify .j2c files here in the studio, but having support of this codec would be nice in general. Currently supports only reading in this codec, writing would still using jp2 codec. --- source/blender/imbuf/intern/bmp.c | 13 ++++++++++++- source/blender/imbuf/intern/jp2.c | 20 +++++++++++++++----- source/blender/imbuf/intern/util.c | 1 + 3 files changed, 28 insertions(+), 6 deletions(-) diff --git a/source/blender/imbuf/intern/bmp.c b/source/blender/imbuf/intern/bmp.c index eb12b219da9..60dd4f65594 100644 --- a/source/blender/imbuf/intern/bmp.c +++ b/source/blender/imbuf/intern/bmp.c @@ -69,16 +69,25 @@ typedef struct BMPHEADER { static int checkbmp(unsigned char *mem) { +#define CHECK_HEADER_FIELD(mem, field) ((mem[0] == field[0]) && (mem[1] == field[0])) + int ret_val = 0; BMPINFOHEADER bmi; unsigned int u; if (mem) { - if ((mem[0] == 'B') && (mem[1] == 'M')) { + if (CHECK_HEADER_FIELD(mem, "BM") || + CHECK_HEADER_FIELD(mem, "BA") || + CHECK_HEADER_FIELD(mem, "CI") || + CHECK_HEADER_FIELD(mem, "CP") || + CHECK_HEADER_FIELD(mem, "IC") || + CHECK_HEADER_FIELD(mem, "PT")) + { /* skip fileheader */ mem += BMP_FILEHEADER_SIZE; } else { + return 0; } /* for systems where an int needs to be 4 bytes aligned */ @@ -97,6 +106,8 @@ static int checkbmp(unsigned char *mem) } return(ret_val); + +#undef CHECK_HEADER_FIELD } int imb_is_a_bmp(unsigned char *buf) diff --git a/source/blender/imbuf/intern/jp2.c b/source/blender/imbuf/intern/jp2.c index 8be7a9ea28b..1fe9a5ab522 100644 --- a/source/blender/imbuf/intern/jp2.c +++ b/source/blender/imbuf/intern/jp2.c @@ -41,6 +41,7 @@ #define JP2_FILEHEADER_SIZE 14 static char JP2_HEAD[] = {0x0, 0x0, 0x0, 0x0C, 0x6A, 0x50, 0x20, 0x20, 0x0D, 0x0A, 0x87, 0x0A}; +static char J2K_HEAD[] = {0xFF, 0x4F, 0xFF, 0x51, 0x00}; /* We only need this because of how the presets are set */ /* this typedef is copied from 'openjpeg-1.5.0/applications/codec/image_to_j2k.c' */ @@ -59,15 +60,19 @@ typedef struct img_folder { static int check_jp2(unsigned char *mem) /* J2K_CFMT */ { - return memcmp(JP2_HEAD, mem, 12) ? 0 : 1; + return memcmp(JP2_HEAD, mem, sizeof(JP2_HEAD)) ? 0 : 1; +} + +static int check_j2k(unsigned char *mem) /* J2K_CFMT */ +{ + return memcmp(J2K_HEAD, mem, sizeof(J2K_HEAD)) ? 0 : 1; } int imb_is_a_jp2(unsigned char *buf) -{ +{ return check_jp2(buf); } - /** * sample error callback expecting a FILE* client object */ @@ -116,6 +121,7 @@ struct ImBuf *imb_jp2_decode(unsigned char *mem, size_t size, int flags) unsigned int i, i_next, w, h, planes; unsigned int y; int *r, *g, *b, *a; /* matching 'opj_image_comp.data' type */ + int is_jp2, is_j2k; opj_dparameters_t parameters; /* decompression parameters */ @@ -125,7 +131,11 @@ struct ImBuf *imb_jp2_decode(unsigned char *mem, size_t size, int flags) opj_dinfo_t *dinfo = NULL; /* handle to a decompressor */ opj_cio_t *cio = NULL; - if (check_jp2(mem) == 0) return(NULL); + is_jp2 = check_jp2(mem); + is_j2k = check_j2k(mem); + + if (!is_jp2 && !is_j2k) + return(NULL); /* configure the event callbacks (not required) */ memset(&event_mgr, 0, sizeof(opj_event_mgr_t)); @@ -141,7 +151,7 @@ struct ImBuf *imb_jp2_decode(unsigned char *mem, size_t size, int flags) /* JPEG 2000 compressed image data */ /* get a decoder handle */ - dinfo = opj_create_decompress(CODEC_JP2); + dinfo = opj_create_decompress(is_jp2 ? CODEC_JP2 : CODEC_J2K); /* catch events using our callbacks and give a local context */ opj_set_event_mgr((opj_common_ptr)dinfo, &event_mgr, stderr); diff --git a/source/blender/imbuf/intern/util.c b/source/blender/imbuf/intern/util.c index 9ec22f0798e..a765ac5c3b4 100644 --- a/source/blender/imbuf/intern/util.c +++ b/source/blender/imbuf/intern/util.c @@ -83,6 +83,7 @@ const char *imb_ext_image[] = { #endif #ifdef WITH_OPENJPEG ".jp2", + ".j2c", #endif #ifdef WITH_HDR ".hdr", From 77f0be7fec206749bd3aadbe626c9db6944d8f3f Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 27 Aug 2012 13:40:19 +0000 Subject: [PATCH 156/163] support unary positive operators for vectors (same as numpy), so you can do 'vector_a = +vector_b', this makes a copy. --- source/blender/python/mathutils/mathutils_Color.c | 4 ++-- source/blender/python/mathutils/mathutils_Quaternion.c | 2 +- source/blender/python/mathutils/mathutils_Vector.c | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/source/blender/python/mathutils/mathutils_Color.c b/source/blender/python/mathutils/mathutils_Color.c index 8a87938d825..05fc84eaa87 100644 --- a/source/blender/python/mathutils/mathutils_Color.c +++ b/source/blender/python/mathutils/mathutils_Color.c @@ -644,8 +644,8 @@ static PyNumberMethods Color_NumMethods = { NULL, /*nb_remainder*/ NULL, /*nb_divmod*/ NULL, /*nb_power*/ - (unaryfunc) Color_neg, /*nb_negative*/ - (unaryfunc) NULL, /*tp_positive*/ + (unaryfunc) Color_neg, /*nb_negative*/ + (unaryfunc) Color_copy, /*tp_positive*/ (unaryfunc) NULL, /*tp_absolute*/ (inquiry) NULL, /*tp_bool*/ (unaryfunc) NULL, /*nb_invert*/ diff --git a/source/blender/python/mathutils/mathutils_Quaternion.c b/source/blender/python/mathutils/mathutils_Quaternion.c index 40c0215ffd1..b595dab494d 100644 --- a/source/blender/python/mathutils/mathutils_Quaternion.c +++ b/source/blender/python/mathutils/mathutils_Quaternion.c @@ -903,7 +903,7 @@ static PyNumberMethods Quaternion_NumMethods = { NULL, /*nb_divmod*/ NULL, /*nb_power*/ (unaryfunc) Quaternion_neg, /*nb_negative*/ - (unaryfunc) 0, /*tp_positive*/ + (unaryfunc) Quaternion_copy,/*tp_positive*/ (unaryfunc) 0, /*tp_absolute*/ (inquiry) 0, /*tp_bool*/ (unaryfunc) 0, /*nb_invert*/ diff --git a/source/blender/python/mathutils/mathutils_Vector.c b/source/blender/python/mathutils/mathutils_Vector.c index c7911cb1572..74a4cd838d0 100644 --- a/source/blender/python/mathutils/mathutils_Vector.c +++ b/source/blender/python/mathutils/mathutils_Vector.c @@ -2046,7 +2046,7 @@ static PyNumberMethods Vector_NumMethods = { NULL, /*nb_divmod*/ NULL, /*nb_power*/ (unaryfunc) Vector_neg, /*nb_negative*/ - (unaryfunc) NULL, /*tp_positive*/ + (unaryfunc) Vector_copy,/*tp_positive*/ (unaryfunc) NULL, /*tp_absolute*/ (inquiry) NULL, /*tp_bool*/ (unaryfunc) NULL, /*nb_invert*/ From 316b72647a2e0a7e5d2c5a3f799f023cd127b42e Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Mon, 27 Aug 2012 20:58:43 +0000 Subject: [PATCH 157/163] Picky spell-checking... --- source/blender/makesrna/intern/rna_nodetree.c | 2 +- source/blender/makesrna/intern/rna_pose.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/source/blender/makesrna/intern/rna_nodetree.c b/source/blender/makesrna/intern/rna_nodetree.c index 2013fd7318e..497cb9291ec 100644 --- a/source/blender/makesrna/intern/rna_nodetree.c +++ b/source/blender/makesrna/intern/rna_nodetree.c @@ -2161,7 +2161,7 @@ static void def_cmp_despeckle(StructRNA *srna) prop = RNA_def_property(srna, "threshold_neighbour", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "custom4"); RNA_def_property_range(prop, 0.0, 1.0f); - RNA_def_property_ui_text(prop, "Neighbour", "Threshold for the number of neighbour pixels that must match"); + RNA_def_property_ui_text(prop, "Neighbor", "Threshold for the number of neighbor pixels that must match"); RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update"); } diff --git a/source/blender/makesrna/intern/rna_pose.c b/source/blender/makesrna/intern/rna_pose.c index 35c85f0f40e..739f302fcbe 100644 --- a/source/blender/makesrna/intern/rna_pose.c +++ b/source/blender/makesrna/intern/rna_pose.c @@ -1109,7 +1109,7 @@ static void rna_def_pose_itasc(BlenderRNA *brna) {0, "ANIMATION", 0, "Animation", "Stateless solver computing pose starting from current action and non-IK constraints"}, {ITASC_SIMULATION, "SIMULATION", 0, "Simulation", - "Statefull solver running in real-time context and ignoring actions " + "State-full solver running in real-time context and ignoring actions " "and non-IK constraints"}, {0, NULL, 0, NULL, NULL} }; From 40e3af441bff25d887aee85d040a8c869bef6692 Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Mon, 27 Aug 2012 21:01:21 +0000 Subject: [PATCH 158/163] =?UTF-8?q?Adding=20despeckle=20as=20=E2=80=9Cblen?= =?UTF-8?q?der=E2=80=9D=20word...?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- release/scripts/modules/bl_i18n_utils/spell_check_utils.py | 1 + 1 file changed, 1 insertion(+) diff --git a/release/scripts/modules/bl_i18n_utils/spell_check_utils.py b/release/scripts/modules/bl_i18n_utils/spell_check_utils.py index ef4926c4a98..46b369146b7 100644 --- a/release/scripts/modules/bl_i18n_utils/spell_check_utils.py +++ b/release/scripts/modules/bl_i18n_utils/spell_check_utils.py @@ -329,6 +329,7 @@ dict_uimsgs = { "bweight", "colorband", "datablock", "datablocks", + "despeckle", "dopesheet", "dupliface", "duplifaces", "dupliframe", "dupliframes", From a798371df157ecd30e4bfd6035c7a4c6a8b1f277 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 28 Aug 2012 01:50:13 +0000 Subject: [PATCH 159/163] code cleanup: use switch for metaball type checks and minor style cleanup --- source/blender/blenkernel/intern/mball.c | 150 +++++++++++------------ 1 file changed, 74 insertions(+), 76 deletions(-) diff --git a/source/blender/blenkernel/intern/mball.c b/source/blender/blenkernel/intern/mball.c index 039fb2c22f3..a92497ffb9d 100644 --- a/source/blender/blenkernel/intern/mball.c +++ b/source/blender/blenkernel/intern/mball.c @@ -633,66 +633,65 @@ static float densfunc(MetaElem *ball, float x, float y, float z) mul_m4_v3((float (*)[4])ball->imat, dvec); - if (ball->type == MB_BALL) { - } - else if (ball->type == MB_TUBEX) { - if (dvec[0] > ball->len) dvec[0] -= ball->len; - else if (dvec[0] < -ball->len) dvec[0] += ball->len; - else dvec[0] = 0.0; - } - else if (ball->type == MB_TUBEY) { - if (dvec[1] > ball->len) dvec[1] -= ball->len; - else if (dvec[1] < -ball->len) dvec[1] += ball->len; - else dvec[1] = 0.0; - } - else if (ball->type == MB_TUBEZ) { - if (dvec[2] > ball->len) dvec[2] -= ball->len; - else if (dvec[2] < -ball->len) dvec[2] += ball->len; - else dvec[2] = 0.0; - } - else if (ball->type == MB_TUBE) { - if (dvec[0] > ball->expx) dvec[0] -= ball->expx; - else if (dvec[0] < -ball->expx) dvec[0] += ball->expx; - else dvec[0] = 0.0; - } - else if (ball->type == MB_PLANE) { - if (dvec[0] > ball->expx) dvec[0] -= ball->expx; - else if (dvec[0] < -ball->expx) dvec[0] += ball->expx; - else dvec[0] = 0.0; - if (dvec[1] > ball->expy) dvec[1] -= ball->expy; - else if (dvec[1] < -ball->expy) dvec[1] += ball->expy; - else dvec[1] = 0.0; - } - else if (ball->type == MB_ELIPSOID) { - dvec[0] *= 1 / ball->expx; - dvec[1] *= 1 / ball->expy; - dvec[2] *= 1 / ball->expz; - } - else if (ball->type == MB_CUBE) { - if (dvec[0] > ball->expx) dvec[0] -= ball->expx; - else if (dvec[0] < -ball->expx) dvec[0] += ball->expx; - else dvec[0] = 0.0; - if (dvec[1] > ball->expy) dvec[1] -= ball->expy; - else if (dvec[1] < -ball->expy) dvec[1] += ball->expy; - else dvec[1] = 0.0; - if (dvec[2] > ball->expz) dvec[2] -= ball->expz; - else if (dvec[2] < -ball->expz) dvec[2] += ball->expz; - else dvec[2] = 0.0; + switch (ball->type) { + case MB_BALL: + /* do nothing */ + break; + case MB_TUBEX: + if (dvec[0] > ball->len) dvec[0] -= ball->len; + else if (dvec[0] < -ball->len) dvec[0] += ball->len; + else dvec[0] = 0.0; + break; + case MB_TUBEY: + if (dvec[1] > ball->len) dvec[1] -= ball->len; + else if (dvec[1] < -ball->len) dvec[1] += ball->len; + else dvec[1] = 0.0; + break; + case MB_TUBEZ: + if (dvec[2] > ball->len) dvec[2] -= ball->len; + else if (dvec[2] < -ball->len) dvec[2] += ball->len; + else dvec[2] = 0.0; + break; + case MB_TUBE: + if (dvec[0] > ball->expx) dvec[0] -= ball->expx; + else if (dvec[0] < -ball->expx) dvec[0] += ball->expx; + else dvec[0] = 0.0; + break; + case MB_PLANE: + if (dvec[0] > ball->expx) dvec[0] -= ball->expx; + else if (dvec[0] < -ball->expx) dvec[0] += ball->expx; + else dvec[0] = 0.0; + if (dvec[1] > ball->expy) dvec[1] -= ball->expy; + else if (dvec[1] < -ball->expy) dvec[1] += ball->expy; + else dvec[1] = 0.0; + break; + case MB_ELIPSOID: + dvec[0] /= ball->expx; + dvec[1] /= ball->expy; + dvec[2] /= ball->expz; + break; + case MB_CUBE: + if (dvec[0] > ball->expx) dvec[0] -= ball->expx; + else if (dvec[0] < -ball->expx) dvec[0] += ball->expx; + else dvec[0] = 0.0; + + if (dvec[1] > ball->expy) dvec[1] -= ball->expy; + else if (dvec[1] < -ball->expy) dvec[1] += ball->expy; + else dvec[1] = 0.0; + + if (dvec[2] > ball->expz) dvec[2] -= ball->expz; + else if (dvec[2] < -ball->expz) dvec[2] += ball->expz; + else dvec[2] = 0.0; + break; } - dist2 = len_v3(dvec); + dist2 = 1.0f - (len_v3(dvec) / ball->rad2); - if (ball->flag & MB_NEGATIVE) { - dist2 = 1.0f - (dist2 / ball->rad2); - if (dist2 < 0.0f) return 0.5f; - - return 0.5f - ball->s * dist2 * dist2 * dist2; + if ((ball->flag & MB_NEGATIVE) == 0) { + return (dist2 < 0.0f) ? -0.5f : (ball->s * dist2 * dist2 * dist2) - 0.5f; } else { - dist2 = 1.0f - (dist2 / ball->rad2); - if (dist2 < 0.0f) return -0.5f; - - return ball->s * dist2 * dist2 * dist2 - 0.5f; + return (dist2 < 0.0f) ? 0.5f : 0.5f - (ball->s * dist2 * dist2 * dist2); } } @@ -775,15 +774,12 @@ static float metaball(float x, float y, float z) if (totelem > 1) { node = find_metaball_octal_node(metaball_tree->first, x, y, z, metaball_tree->depth); if (node) { - ml_p = node->elems.first; - - while (ml_p) { + for (ml_p = node->elems.first; ml_p; ml_p = ml_p->next) { dens += densfunc(ml_p->ml, x, y, z); - ml_p = ml_p->next; } dens += -0.5f * (metaball_tree->pos - node->pos); - dens += 0.5f * (metaball_tree->neg - node->neg); + dens += 0.5f * (metaball_tree->neg - node->neg); } else { for (a = 0; a < totelem; a++) { @@ -1591,10 +1587,12 @@ static void find_first_points(PROCESS *mbproc, MetaBall *mb, int a) /* add CUBE (with indexes c_i, c_j, c_k) to the stack, * this cube includes found point of Implicit Surface */ - if (ml->flag & MB_NEGATIVE) - add_cube(mbproc, c_i, c_j, c_k, 2); - else + if ((ml->flag & MB_NEGATIVE) == 0) { add_cube(mbproc, c_i, c_j, c_k, 1); + } + else { + add_cube(mbproc, c_i, c_j, c_k, 2); + } } len = len_v3v3(workp, in); workp_v = tmp_v; @@ -1882,11 +1880,11 @@ static void fill_metaball_octal_node(octal_node *node, MetaElem *ml, short i) BLI_addtail(&(node->nodes[i]->elems), ml_p); node->count++; - if (ml->flag & MB_NEGATIVE) { - node->nodes[i]->neg++; + if ((ml->flag & MB_NEGATIVE) == 0) { + node->nodes[i]->pos++; } else { - node->nodes[i]->pos++; + node->nodes[i]->neg++; } } @@ -2212,14 +2210,14 @@ static void init_metaball_octal_tree(int depth) ml_p->ml = mainb[a]; BLI_addtail(&node->elems, ml_p); - if (mainb[a]->flag & MB_NEGATIVE) { - /* number of negative MetaElem in scene */ - metaball_tree->neg++; - } - else { + if ((mainb[a]->flag & MB_NEGATIVE) == 0) { /* number of positive MetaElem in scene */ metaball_tree->pos++; } + else { + /* number of negative MetaElem in scene */ + metaball_tree->neg++; + } } /* size of first node */ @@ -2262,11 +2260,11 @@ void BKE_mball_polygonize(Scene *scene, Object *ob, ListBase *dispbase) } /* if scene includes more then one MetaElem, then octal tree optimization is used */ - if ((totelem > 1) && (totelem <= 64)) init_metaball_octal_tree(1); - if ((totelem > 64) && (totelem <= 128)) init_metaball_octal_tree(2); - if ((totelem > 128) && (totelem <= 512)) init_metaball_octal_tree(3); - if ((totelem > 512) && (totelem <= 1024)) init_metaball_octal_tree(4); - if (totelem > 1024) init_metaball_octal_tree(5); + if ((totelem > 1) && (totelem <= 64)) init_metaball_octal_tree(1); + if ((totelem > 64) && (totelem <= 128)) init_metaball_octal_tree(2); + if ((totelem > 128) && (totelem <= 512)) init_metaball_octal_tree(3); + if ((totelem > 512) && (totelem <= 1024)) init_metaball_octal_tree(4); + if (totelem > 1024) init_metaball_octal_tree(5); /* don't polygonize metaballs with too high resolution (base mball to small) * note: Eps was 0.0001f but this was giving problems for blood animation for durian, using 0.00001f */ From c43583a23ae0e552779148236f973d20275f9bd0 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 28 Aug 2012 10:02:10 +0000 Subject: [PATCH 160/163] fix for own crash caused by curve refactor, now curve tables are initialized once when the tree is initialized. thanks to Antony Riakiotakis for providing a fix, though this works a little different. --- source/blender/blenkernel/intern/colortools.c | 15 ++++++++++++--- .../nodes/shader/nodes/node_shader_curves.c | 9 ++++++++- source/blender/python/generic/py_capi_utils.c | 4 +++- 3 files changed, 23 insertions(+), 5 deletions(-) diff --git a/source/blender/blenkernel/intern/colortools.c b/source/blender/blenkernel/intern/colortools.c index 7c03c75bd99..d65c81b4f9b 100644 --- a/source/blender/blenkernel/intern/colortools.c +++ b/source/blender/blenkernel/intern/colortools.c @@ -105,9 +105,18 @@ void curvemapping_free_data(CurveMapping *cumap) int a; for (a = 0; a < CM_TOT; a++) { - if (cumap->cm[a].curve) MEM_freeN(cumap->cm[a].curve); - if (cumap->cm[a].table) MEM_freeN(cumap->cm[a].table); - if (cumap->cm[a].premultable) MEM_freeN(cumap->cm[a].premultable); + if (cumap->cm[a].curve) { + MEM_freeN(cumap->cm[a].curve); + cumap->cm[a].curve = NULL; + } + if (cumap->cm[a].table) { + MEM_freeN(cumap->cm[a].table); + cumap->cm[a].table = NULL; + } + if (cumap->cm[a].premultable) { + MEM_freeN(cumap->cm[a].premultable); + cumap->cm[a].premultable = NULL; + } } } diff --git a/source/blender/nodes/shader/nodes/node_shader_curves.c b/source/blender/nodes/shader/nodes/node_shader_curves.c index 0c08f1bc215..8831b07d8a0 100644 --- a/source/blender/nodes/shader/nodes/node_shader_curves.c +++ b/source/blender/nodes/shader/nodes/node_shader_curves.c @@ -45,6 +45,12 @@ static bNodeSocketTemplate sh_node_curve_vec_out[]= { { -1, 0, "" } }; +static void *node_shader_initexec_curve(bNode *node) +{ + curvemapping_initialize(node->storage); + return NULL; /* unused return */ +} + static void node_shader_exec_curve_vec(void *UNUSED(data), bNode *node, bNodeStack **in, bNodeStack **out) { float vec[3]; @@ -65,7 +71,6 @@ static int gpu_shader_curve_vec(GPUMaterial *mat, bNode *node, GPUNodeStack *in, float *array; int size; - curvemapping_initialize(node->storage); curvemapping_table_RGBA(node->storage, &array, &size); return GPU_stack_link(mat, "curves_vec", in, out, GPU_texture(size, array)); } @@ -81,6 +86,7 @@ void register_node_type_sh_curve_vec(bNodeTreeType *ttype) node_type_init(&ntype, node_shader_init_curve_vec); node_type_storage(&ntype, "CurveMapping", node_free_curves, node_copy_curves); node_type_exec(&ntype, node_shader_exec_curve_vec); + node_type_exec_new(&ntype, node_shader_initexec_curve, NULL, NULL); /* only for its initexec func */ node_type_gpu(&ntype, gpu_shader_curve_vec); nodeRegisterType(ttype, &ntype); @@ -138,6 +144,7 @@ void register_node_type_sh_curve_rgb(bNodeTreeType *ttype) node_type_init(&ntype, node_shader_init_curve_rgb); node_type_storage(&ntype, "CurveMapping", node_free_curves, node_copy_curves); node_type_exec(&ntype, node_shader_exec_curve_rgb); + node_type_exec_new(&ntype, node_shader_initexec_curve, NULL, NULL); /* only for its initexec func */ node_type_gpu(&ntype, gpu_shader_curve_rgb); nodeRegisterType(ttype, &ntype); diff --git a/source/blender/python/generic/py_capi_utils.c b/source/blender/python/generic/py_capi_utils.c index 657844ebfff..520773c1ddf 100644 --- a/source/blender/python/generic/py_capi_utils.c +++ b/source/blender/python/generic/py_capi_utils.c @@ -523,7 +523,9 @@ void PyC_SetHomePath(const char *py_path_bundle) } } -/* Would be nice if python had this built in */ +/* Would be nice if python had this built in + * See: http://wiki.blender.org/index.php/Dev:Doc/Tools/Debugging/PyFromC + */ void PyC_RunQuicky(const char *filepath, int n, ...) { FILE *fp = fopen(filepath, "r"); From 8fd747114388dbbb10733415eaa707f9801abf1a Mon Sep 17 00:00:00 2001 From: Jeroen Bakker Date: Tue, 28 Aug 2012 10:41:37 +0000 Subject: [PATCH 161/163] cleanup pixel sampler code (pixel interpolations in compositor) --- .../compositor/intern/COM_SocketReader.h | 6 ++-- .../compositor/nodes/COM_RotateNode.cpp | 14 +------- .../compositor/nodes/COM_Stabilize2dNode.cpp | 9 +++-- .../compositor/nodes/COM_TransformNode.cpp | 12 +------ source/blender/makesrna/intern/rna_nodetree.c | 35 ++++++------------- 5 files changed, 23 insertions(+), 53 deletions(-) diff --git a/source/blender/compositor/intern/COM_SocketReader.h b/source/blender/compositor/intern/COM_SocketReader.h index 01e1403b021..88b018ef8ba 100644 --- a/source/blender/compositor/intern/COM_SocketReader.h +++ b/source/blender/compositor/intern/COM_SocketReader.h @@ -30,9 +30,9 @@ #endif typedef enum PixelSampler { - COM_PS_NEAREST, - COM_PS_BILINEAR, - COM_PS_BICUBIC + COM_PS_NEAREST = 0, + COM_PS_BILINEAR = 1, + COM_PS_BICUBIC = 2 } PixelSampler; class MemoryBuffer; diff --git a/source/blender/compositor/nodes/COM_RotateNode.cpp b/source/blender/compositor/nodes/COM_RotateNode.cpp index bb058d18b80..d7712323a27 100644 --- a/source/blender/compositor/nodes/COM_RotateNode.cpp +++ b/source/blender/compositor/nodes/COM_RotateNode.cpp @@ -39,19 +39,7 @@ void RotateNode::convertToOperations(ExecutionSystem *system, CompositorContext RotateOperation *operation = new RotateOperation(); SetSamplerOperation *sampler = new SetSamplerOperation(); - switch (this->getbNode()->custom1) { - case 0: - sampler->setSampler(COM_PS_NEAREST); - break; - case 1: - sampler->setSampler(COM_PS_BILINEAR); - break; - case 2: - sampler->setSampler(COM_PS_BICUBIC); - break; - - } - + sampler->setSampler((PixelSampler)this->getbNode()->custom1); addLink(system, sampler->getOutputSocket(), operation->getInputSocket(0)); inputSocket->relinkConnections(sampler->getInputSocket(0), 0, system); diff --git a/source/blender/compositor/nodes/COM_Stabilize2dNode.cpp b/source/blender/compositor/nodes/COM_Stabilize2dNode.cpp index 85b8695263f..b28ee3eade1 100644 --- a/source/blender/compositor/nodes/COM_Stabilize2dNode.cpp +++ b/source/blender/compositor/nodes/COM_Stabilize2dNode.cpp @@ -26,6 +26,7 @@ #include "COM_RotateOperation.h" #include "COM_ScaleOperation.h" #include "COM_MovieClipAttributeOperation.h" +#include "COM_SetSamplerOperation.h" extern "C" { #include "DNA_movieclip_types.h" @@ -49,6 +50,7 @@ void Stabilize2dNode::convertToOperations(ExecutionSystem *graph, CompositorCont MovieClipAttributeOperation *angleAttribute = new MovieClipAttributeOperation(); MovieClipAttributeOperation *xAttribute = new MovieClipAttributeOperation(); MovieClipAttributeOperation *yAttribute = new MovieClipAttributeOperation(); + SetSamplerOperation *psoperation = new SetSamplerOperation(); scaleAttribute->setAttribute(MCA_SCALE); scaleAttribute->setFramenumber(context->getFramenumber()); @@ -77,8 +79,10 @@ void Stabilize2dNode::convertToOperations(ExecutionSystem *graph, CompositorCont addLink(graph, rotateOperation->getOutputSocket(), translateOperation->getInputSocket(0)); addLink(graph, xAttribute->getOutputSocket(), translateOperation->getInputSocket(1)); addLink(graph, yAttribute->getOutputSocket(), translateOperation->getInputSocket(2)); - - this->getOutputSocket()->relinkConnections(translateOperation->getOutputSocket()); + + psoperation->setSampler((PixelSampler)this->getbNode()->custom1); + addLink(graph, translateOperation->getOutputSocket(), psoperation->getInputSocket(0)); + this->getOutputSocket()->relinkConnections(psoperation->getOutputSocket()); graph->addOperation(scaleAttribute); graph->addOperation(angleAttribute); @@ -87,4 +91,5 @@ void Stabilize2dNode::convertToOperations(ExecutionSystem *graph, CompositorCont graph->addOperation(scaleOperation); graph->addOperation(translateOperation); graph->addOperation(rotateOperation); + graph->addOperation(psoperation); } diff --git a/source/blender/compositor/nodes/COM_TransformNode.cpp b/source/blender/compositor/nodes/COM_TransformNode.cpp index ff6e276d1ac..154761665cf 100644 --- a/source/blender/compositor/nodes/COM_TransformNode.cpp +++ b/source/blender/compositor/nodes/COM_TransformNode.cpp @@ -46,17 +46,7 @@ void TransformNode::convertToOperations(ExecutionSystem *graph, CompositorContex TranslateOperation *translateOperation = new TranslateOperation(); SetSamplerOperation *sampler = new SetSamplerOperation(); - switch (this->getbNode()->custom1) { - case 0: - sampler->setSampler(COM_PS_NEAREST); - break; - case 1: - sampler->setSampler(COM_PS_BILINEAR); - break; - case 2: - sampler->setSampler(COM_PS_BICUBIC); - break; - } + sampler->setSampler((PixelSampler)this->getbNode()->custom1); imageInput->relinkConnections(sampler->getInputSocket(0), 0, graph); addLink(graph, sampler->getOutputSocket(), scaleOperation->getInputSocket(0)); diff --git a/source/blender/makesrna/intern/rna_nodetree.c b/source/blender/makesrna/intern/rna_nodetree.c index 497cb9291ec..2f763a6ed0e 100644 --- a/source/blender/makesrna/intern/rna_nodetree.c +++ b/source/blender/makesrna/intern/rna_nodetree.c @@ -133,6 +133,14 @@ EnumPropertyItem node_filter_items[] = { {0, NULL, 0, NULL, NULL} }; +EnumPropertyItem node_sampler_type_items[] = { + {0, "NEAREST", 0, "Nearest", ""}, + {1, "BILINEAR", 0, "Bilinear", ""}, + {2, "BICUBIC", 0, "Bicubic", ""}, + {0, NULL, 0, NULL, NULL} +}; + + EnumPropertyItem prop_noise_basis_items[] = { {SHD_NOISE_PERLIN, "PERLIN", 0, "Perlin", ""}, {SHD_NOISE_VORONOI_F1, "VORONOI_F1", 0, "Voronoi F1", ""}, @@ -2213,16 +2221,9 @@ static void def_cmp_rotate(StructRNA *srna) { PropertyRNA *prop; - static EnumPropertyItem rotate_items[] = { - {0, "NEAREST", 0, "Nearest", ""}, - {1, "BILINEAR", 0, "Bilinear", ""}, - {2, "BICUBIC", 0, "Bicubic", ""}, - {0, NULL, 0, NULL, NULL} - }; - prop = RNA_def_property(srna, "filter_type", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "custom1"); - RNA_def_property_enum_items(prop, rotate_items); + RNA_def_property_enum_items(prop, node_sampler_type_items); RNA_def_property_ui_text(prop, "Filter", "Method to use to filter rotation"); RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update"); } @@ -3150,13 +3151,6 @@ static void def_cmp_stabilize2d(StructRNA *srna) { PropertyRNA *prop; - static EnumPropertyItem filter_type_items[] = { - {0, "NEAREST", 0, "Nearest", ""}, - {1, "BILINEAR", 0, "Bilinear", ""}, - {2, "BICUBIC", 0, "Bicubic", ""}, - {0, NULL, 0, NULL, NULL} - }; - prop = RNA_def_property(srna, "clip", PROP_POINTER, PROP_NONE); RNA_def_property_pointer_sdna(prop, NULL, "id"); RNA_def_property_struct_type(prop, "MovieClip"); @@ -3166,7 +3160,7 @@ static void def_cmp_stabilize2d(StructRNA *srna) prop = RNA_def_property(srna, "filter_type", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "custom1"); - RNA_def_property_enum_items(prop, filter_type_items); + RNA_def_property_enum_items(prop, node_sampler_type_items); RNA_def_property_ui_text(prop, "Filter", "Method to use to filter stabilization"); RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update"); } @@ -3264,16 +3258,9 @@ static void dev_cmd_transform(StructRNA *srna) { PropertyRNA *prop; - static EnumPropertyItem filter_type_items[] = { - {0, "NEAREST", 0, "Nearest", ""}, - {1, "BILINEAR", 0, "Bilinear", ""}, - {2, "BICUBIC", 0, "Bicubic", ""}, - {0, NULL, 0, NULL, NULL} - }; - prop = RNA_def_property(srna, "filter_type", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "custom1"); - RNA_def_property_enum_items(prop, filter_type_items); + RNA_def_property_enum_items(prop, node_sampler_type_items); RNA_def_property_ui_text(prop, "Filter", "Method to use to filter transform"); RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update"); } From 7aeaeaf37805d7d906787e5ad5d0d76817dd0bc5 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 28 Aug 2012 11:27:46 +0000 Subject: [PATCH 162/163] fix bug in mathutils.geometry.intersect_point_line() where 4D vectors were treated as 2D. also change behavior to return a 2d vector when all args are 2D. --- .../blender/python/mathutils/mathutils_geometry.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/source/blender/python/mathutils/mathutils_geometry.c b/source/blender/python/mathutils/mathutils_geometry.c index 524515ac460..19f9aa2dc88 100644 --- a/source/blender/python/mathutils/mathutils_geometry.c +++ b/source/blender/python/mathutils/mathutils_geometry.c @@ -728,6 +728,7 @@ static PyObject *M_Geometry_intersect_point_line(PyObject *UNUSED(self), PyObjec float pt_in[3], pt_out[3], l1[3], l2[3]; float lambda; PyObject *ret; + int size = 2; if (!PyArg_ParseTuple(args, "O!O!O!:intersect_point_line", &vector_Type, &pt, @@ -745,20 +746,20 @@ static PyObject *M_Geometry_intersect_point_line(PyObject *UNUSED(self), PyObjec } /* accept 2d verts */ - if (pt->size == 3) { copy_v3_v3(pt_in, pt->vec); } - else { pt_in[2] = 0.0f; copy_v2_v2(pt_in, pt->vec); } + if (pt->size >= 3) { copy_v3_v3(pt_in, pt->vec); size = 3; } + else { copy_v2_v2(pt_in, pt->vec); pt_in[2] = 0.0f; } - if (line_1->size == 3) { copy_v3_v3(l1, line_1->vec); } - else { l1[2] = 0.0f; copy_v2_v2(l1, line_1->vec); } + if (line_1->size >= 3) { copy_v3_v3(l1, line_1->vec); size = 3; } + else { copy_v2_v2(l1, line_1->vec); l1[2] = 0.0f; } - if (line_2->size == 3) { copy_v3_v3(l2, line_2->vec); } - else { l2[2] = 0.0f; copy_v2_v2(l2, line_2->vec); } + if (line_2->size >= 3) { copy_v3_v3(l2, line_2->vec); size = 3; } + else { copy_v2_v2(l2, line_2->vec); l2[2] = 0.0f; } /* do the calculation */ lambda = closest_to_line_v3(pt_out, pt_in, l1, l2); ret = PyTuple_New(2); - PyTuple_SET_ITEM(ret, 0, Vector_CreatePyObject(pt_out, 3, Py_NEW, NULL)); + PyTuple_SET_ITEM(ret, 0, Vector_CreatePyObject(pt_out, size, Py_NEW, NULL)); PyTuple_SET_ITEM(ret, 1, PyFloat_FromDouble(lambda)); return ret; } From 8321acaf439b33cca0b054565be176047d289134 Mon Sep 17 00:00:00 2001 From: Jens Verwiebe Date: Tue, 28 Aug 2012 13:43:20 +0000 Subject: [PATCH 163/163] missing linebreak when multithreaded gl meesage is printed to log --- intern/ghost/intern/GHOST_WindowCocoa.mm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/intern/ghost/intern/GHOST_WindowCocoa.mm b/intern/ghost/intern/GHOST_WindowCocoa.mm index 31f91802e38..294766cba24 100644 --- a/intern/ghost/intern/GHOST_WindowCocoa.mm +++ b/intern/ghost/intern/GHOST_WindowCocoa.mm @@ -1150,7 +1150,7 @@ GHOST_TSuccess GHOST_WindowCocoa::installDrawingContext(GHOST_TDrawingContextTyp /******* Multithreaded opengl code : uncomment for enabling cglCtx = (CGLContextObj)[tmpOpenGLContext CGLContextObj]; if (CGLEnable(cglCtx, kCGLCEMPEngine) == kCGLNoError) - printf("\nSwitched openGL to multithreaded mode"); + printf("\nSwitched openGL to multithreaded mode\n"); */ if (!s_firstOpenGLcontext) s_firstOpenGLcontext = tmpOpenGLContext;